Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1020)

Unified Diff: chrome/browser/component_updater/cros_component_installer.h

Issue 2911483002: Check env-version upon component load (Closed)
Patch Set: address comments from waffles Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/component_updater/cros_component_installer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/component_updater/cros_component_installer.h
diff --git a/chrome/browser/component_updater/cros_component_installer.h b/chrome/browser/component_updater/cros_component_installer.h
index 7673d744f2d468add48964847aa5d17111e3694d..e938369e8ed5235317950734404a993a5659dafc 100644
--- a/chrome/browser/component_updater/cros_component_installer.h
+++ b/chrome/browser/component_updater/cros_component_installer.h
@@ -13,6 +13,24 @@
#include "components/update_client/update_client.h"
#include "crypto/sha2.h"
+#if defined(OS_CHROMEOS)
+#include "chromeos/dbus/dbus_method_call_status.h"
+#endif // defined(OS_CHROMEOS)
+
+// Developer API usage:
+// ...
+// void LoadCallback(const std::string& mount_point){
+// if (mount_point.empty()) {
+// // component is not loaded.
+// return;
+// }
+// ...
+// }
+// ...
+// component_updater::CrOSComponent::LoadComponent(
+// name,
+// base::Bind(&LoadCallback));
+//
namespace component_updater {
#if defined(OS_CHROMEOS)
@@ -34,6 +52,11 @@ class CrOSComponentInstallerTraits : public ComponentInstallerTraits {
~CrOSComponentInstallerTraits() override {}
private:
+ FRIEND_TEST_ALL_PREFIXES(CrOSComponentInstallerTest, IsCompatibleOrNot);
+ FRIEND_TEST_ALL_PREFIXES(CrOSComponentInstallerTest,
+ ComponentReadyCorrectManifest);
+ FRIEND_TEST_ALL_PREFIXES(CrOSComponentInstallerTest,
+ ComponentReadyWrongManifest);
// The following methods override ComponentInstallerTraits.
bool SupportsGroupPolicyEnabledComponentUpdates() const override;
bool RequiresNetworkEncryption() const override;
@@ -50,6 +73,9 @@ class CrOSComponentInstallerTraits : public ComponentInstallerTraits {
std::string GetName() const override;
update_client::InstallerAttributes GetInstallerAttributes() const override;
std::vector<std::string> GetMimeTypes() const override;
+
+ virtual bool IsCompatible(const std::string& env_version_str,
+ const std::string& min_env_version_str);
std::string name;
std::string env_version;
uint8_t kSha2Hash_[crypto::kSHA256Length] = {};
@@ -60,62 +86,22 @@ class CrOSComponentInstallerTraits : public ComponentInstallerTraits {
// This class contains functions used to register and install a component.
class CrOSComponent {
public:
- // Register and start installing a CrOS component.
- // |install_callback| is triggered after install finishes and returns error
- // code.
- //
- // example:
- // ...
- // void load_callback(const std::string& result){
- // if (result.empty) {
- // // component is not mounted.
- // return;
- // }
- // // [component mount point: result]
- // }
- // void install_callback(update_client::Error error){
- // // switch(error){
- // // case update_client::Error::NONE:
- // // // component is installed
- // // break;
- // // case update_client::Error::INVALID_ARGUMENT:
- // // // your install failed due to your wrong parameters.
- // // break;
- // // default:
- // // // your install failed due to system failure.
- // // break;
- // // }
- // // Even when error code other than NONE returned (your install failed),
- // // component might has already being installed previously.
- // // Plus, if you want to know current version of component.
- // component_updater:CrOSComponent::LoadCrOSComponent(name, load_callback);
- // }
- // ...
- // component_updater::CrOSComponent::InstallCrOSComponent(
- // name,
- // base::Bind(&install_callback));
- //
- static bool InstallCrOSComponent(
+ static void LoadComponent(
const std::string& name,
- const update_client::Callback& install_callback);
-
- static void LoadCrOSComponent(
- const std::string& name,
- const base::Callback<void(const std::string&)>& mount_callback);
+ const base::Callback<void(const std::string&)>& load_callback);
private:
+ FRIEND_TEST_ALL_PREFIXES(CrOSComponentInstallerTest,
+ RegisterComponentSuccess);
+ FRIEND_TEST_ALL_PREFIXES(CrOSComponentInstallerTest, RegisterComponentFail);
CrOSComponent() {}
- // Register a component.
- static void RegisterCrOSComponentInternal(ComponentUpdateService* cus,
- const ComponentConfig& config,
- const base::Closure& callback);
- // A helper function to pass into RegisterCrOSComonentInternal as a callback.
- // It calls OnDemandUpdate to install the component right after being
- // registered.
- static void InstallChromeOSComponent(
+ static void RegisterResult(ComponentUpdateService* cus,
+ const std::string& id,
+ const update_client::Callback& install_callback);
+ static void InstallComponent(
ComponentUpdateService* cus,
- const std::string& id,
- const update_client::Callback& install_callback);
+ const std::string& name,
+ const base::Callback<void(const std::string&)>& load_callback);
};
#endif // defined(OS_CHROMEOS)
« no previous file with comments | « no previous file | chrome/browser/component_updater/cros_component_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698