empty_component_loader_policy.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2022 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 ANDROID_WEBVIEW_BROWSER_COMPONENT_UPDATER_LOADER_POLICIES_EMPTY_COMPONENT_LOADER_POLICY_H_
  5. #define ANDROID_WEBVIEW_BROWSER_COMPONENT_UPDATER_LOADER_POLICIES_EMPTY_COMPONENT_LOADER_POLICY_H_
  6. #include <stdint.h>
  7. #include <string>
  8. #include <vector>
  9. #include "base/containers/flat_map.h"
  10. #include "base/files/scoped_file.h"
  11. #include "components/component_updater/android/component_loader_policy.h"
  12. namespace base {
  13. class DictionaryValue;
  14. class Version;
  15. } // namespace base
  16. namespace android_webview {
  17. // A fake empty component to run experiment to measure component updater
  18. // performance impact.
  19. // TODO(crbug.com/1288006): remove this when the experiment is over.
  20. class EmptyComponentLoaderPolicy
  21. : public component_updater::ComponentLoaderPolicy {
  22. public:
  23. EmptyComponentLoaderPolicy() = default;
  24. ~EmptyComponentLoaderPolicy() override = default;
  25. EmptyComponentLoaderPolicy(const EmptyComponentLoaderPolicy&) = delete;
  26. EmptyComponentLoaderPolicy& operator=(const EmptyComponentLoaderPolicy&) =
  27. delete;
  28. // The following methods override ComponentLoaderPolicy.
  29. void ComponentLoaded(
  30. const base::Version& version,
  31. base::flat_map<std::string, base::ScopedFD>& fd_map,
  32. std::unique_ptr<base::DictionaryValue> manifest) override;
  33. void ComponentLoadFailed(
  34. component_updater::ComponentLoadResult error) override;
  35. void GetHash(std::vector<uint8_t>* hash) const override;
  36. std::string GetMetricsSuffix() const override;
  37. };
  38. void LoadEmptyComponent(
  39. component_updater::ComponentLoaderPolicyVector& policies);
  40. } // namespace android_webview
  41. #endif // ANDROID_WEBVIEW_BROWSER_COMPONENT_UPDATER_LOADER_POLICIES_EMPTY_COMPONENT_LOADER_POLICY_H_