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..09617da8f4a1a2ae87a7538463b6b4ba40a6edb5 100644 |
--- a/chrome/browser/component_updater/cros_component_installer.h |
+++ b/chrome/browser/component_updater/cros_component_installer.h |
@@ -13,6 +13,30 @@ |
#include "components/update_client/update_client.h" |
#include "crypto/sha2.h" |
+// Register and start installing a CrOS component. |
+// |
+// Developer API usage: |
+// ... |
+// 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){ |
+// // error code: 1) update_client::Error::NONE, success 2) otherwise, |
+// // fail. |
+// // 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); |
waffles
2017/05/30 22:12:17
Sorry, I'm still confused about this API. We have
xiaochu
2017/05/31 15:40:11
Done.
This makes sense. Thanks!
|
+// } |
+// ... |
+// component_updater::CrOSComponent::InstallCrOSComponent( |
+// name, |
+// base::Bind(&install_callback)); |
+// |
namespace component_updater { |
#if defined(OS_CHROMEOS) |
@@ -34,6 +58,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 +79,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,52 +92,17 @@ 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 InstallCrOSComponent( |
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); |
- |
private: |
- CrOSComponent() {} |
- // Register a component. |
+ // Install a component (called by InstallCrOSComponent). |
+ static void InstallCrOSComponent( |
+ ComponentUpdateService* cus, |
+ const std::string& name, |
+ const update_client::Callback& install_callback); |
+ // Register a component (called by InstallCrOSComponent). |
static void RegisterCrOSComponentInternal(ComponentUpdateService* cus, |
const ComponentConfig& config, |
const base::Closure& callback); |
@@ -116,6 +113,17 @@ class CrOSComponent { |
ComponentUpdateService* cus, |
const std::string& id, |
const update_client::Callback& install_callback); |
+ |
+ public: |
waffles
2017/05/30 22:12:17
Group all public members together. Same for privat
xiaochu
2017/05/31 15:40:11
Done.
|
+ static void LoadCrOSComponent( |
+ const std::string& name, |
+ const base::Callback<void(const std::string&)>& load_callback); |
+ |
+ private: |
+ FRIEND_TEST_ALL_PREFIXES(CrOSComponentInstallerTest, |
+ RegisterComponentSuccess); |
+ FRIEND_TEST_ALL_PREFIXES(CrOSComponentInstallerTest, RegisterComponentFail); |
+ CrOSComponent() {} |
}; |
#endif // defined(OS_CHROMEOS) |