web_bundler.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef SERVICES_DATA_DECODER_WEB_BUNDLER_H_
  5. #define SERVICES_DATA_DECODER_WEB_BUNDLER_H_
  6. #include <vector>
  7. #include "base/files/file.h"
  8. #include "mojo/public/cpp/base/big_buffer.h"
  9. #include "mojo/public/cpp/bindings/pending_remote.h"
  10. #include "mojo/public/cpp/bindings/remote.h"
  11. #include "services/data_decoder/public/mojom/resource_snapshot_for_web_bundle.mojom.h"
  12. #include "services/data_decoder/public/mojom/web_bundler.mojom.h"
  13. #include "third_party/abseil-cpp/absl/types/optional.h"
  14. namespace data_decoder {
  15. class WebBundler : public mojom::WebBundler {
  16. public:
  17. WebBundler();
  18. ~WebBundler() override;
  19. WebBundler(const WebBundler&) = delete;
  20. WebBundler& operator=(const WebBundler&) = delete;
  21. private:
  22. // mojom::WebBundler implementation.
  23. void Generate(
  24. std::vector<mojo::PendingRemote<mojom::ResourceSnapshotForWebBundle>>
  25. snapshots,
  26. base::File file,
  27. GenerateCallback callback) override;
  28. void OnConnectionError();
  29. void GetNextResourceCount();
  30. void OnGetResourceCount(uint64_t count);
  31. void GetNextResourceInfo();
  32. void OnGetResourceInfo(mojom::SerializedResourceInfoPtr info);
  33. void OnGetResourceBody(absl::optional<mojo_base::BigBuffer> body);
  34. void WriteWebBundleIndex();
  35. std::vector<mojo::Remote<mojom::ResourceSnapshotForWebBundle>> snapshots_;
  36. base::File file_;
  37. GenerateCallback callback_;
  38. std::vector<std::vector<mojom::SerializedResourceInfoPtr>> resources_;
  39. std::vector<std::vector<absl::optional<mojo_base::BigBuffer>>> bodies_;
  40. uint64_t pending_resource_count_;
  41. };
  42. } // namespace data_decoder
  43. #endif // SERVICES_DATA_DECODER_WEB_BUNDLER_H_