summaryrefslogtreecommitdiff
path: root/chrome/browser/component_updater
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-06-03 10:58:34 +0100
committerTorne (Richard Coles) <torne@google.com>2014-06-03 10:58:34 +0100
commitcedac228d2dd51db4b79ea1e72c7f249408ee061 (patch)
treeaa4ff43d7fe316e95d12721ce5e17653a768a0dd /chrome/browser/component_updater
parent6a869ecff032b5bed299d661b078b0555034598b (diff)
downloadchromium_org-cedac228d2dd51db4b79ea1e72c7f249408ee061.tar.gz
Merge from Chromium at DEPS revision 273901
This commit was generated by merge_to_master.py. Change-Id: I45745444894df927ffc1045ab8de88b9e52636a3
Diffstat (limited to 'chrome/browser/component_updater')
-rw-r--r--chrome/browser/component_updater/cld_component_installer.cc38
-rw-r--r--chrome/browser/component_updater/cld_component_installer.h57
-rw-r--r--chrome/browser/component_updater/component_updater_service.cc116
-rw-r--r--chrome/browser/component_updater/component_updater_service.h45
-rw-r--r--chrome/browser/component_updater/component_updater_utils.cc18
-rw-r--r--chrome/browser/component_updater/component_updater_utils.h1
-rw-r--r--chrome/browser/component_updater/ppapi_utils.cc1
-rw-r--r--chrome/browser/component_updater/recovery_component_installer.cc19
-rw-r--r--chrome/browser/component_updater/test/cld_component_installer_unittest.cc111
-rw-r--r--chrome/browser/component_updater/test/component_updater_service_unittest.cc5
-rw-r--r--chrome/browser/component_updater/test/update_checker_unittest.cc3
11 files changed, 298 insertions, 116 deletions
diff --git a/chrome/browser/component_updater/cld_component_installer.cc b/chrome/browser/component_updater/cld_component_installer.cc
index 190925a8b2..3ec1f595e6 100644
--- a/chrome/browser/component_updater/cld_component_installer.cc
+++ b/chrome/browser/component_updater/cld_component_installer.cc
@@ -14,7 +14,6 @@
#include "base/logging.h"
#include "base/path_service.h"
#include "base/platform_file.h"
-#include "chrome/browser/component_updater/default_component_installer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
@@ -48,31 +47,6 @@ const uint8 kPublicKeySHA256[32] = {
const char kCldManifestName[] = "CLD2 Data";
-class CldComponentInstallerTraits : public ComponentInstallerTraits {
- public:
- CldComponentInstallerTraits();
- virtual ~CldComponentInstallerTraits() {}
-
- private:
- // The following methods override ComponentInstallerTraits.
- virtual bool CanAutoUpdate() const OVERRIDE;
- virtual bool OnCustomInstall(const base::DictionaryValue& manifest,
- const base::FilePath& install_dir) OVERRIDE;
- virtual bool VerifyInstallation(
- const base::FilePath& install_dir) const OVERRIDE;
- virtual void ComponentReady(
- const base::Version& version,
- const base::FilePath& path,
- scoped_ptr<base::DictionaryValue> manifest) OVERRIDE;
- virtual base::FilePath GetBaseDirectory() const OVERRIDE;
- virtual void GetHash(std::vector<uint8>* hash) const OVERRIDE;
- virtual std::string GetName() const OVERRIDE;
-
- base::FilePath GetInstalledPath(const base::FilePath& base) const;
- void SetLatestCldDataFile(const base::FilePath& path);
- DISALLOW_COPY_AND_ASSIGN(CldComponentInstallerTraits);
-};
-
CldComponentInstallerTraits::CldComponentInstallerTraits() {
}
@@ -87,7 +61,7 @@ bool CldComponentInstallerTraits::OnCustomInstall(
}
base::FilePath CldComponentInstallerTraits::GetInstalledPath(
- const base::FilePath& base) const {
+ const base::FilePath& base) {
// Currently, all platforms have the file at the same location because there
// is no binary difference in the generated file on any supported platform.
// NB: This may change when 64-bit is officially supported.
@@ -141,7 +115,6 @@ void RegisterCldComponent(ComponentUpdateService* cus) {
installer->Register(cus);
}
-// This method is completely threadsafe.
void CldComponentInstallerTraits::SetLatestCldDataFile(
const base::FilePath& path) {
VLOG(1) << "Setting CLD data file location: " << path.value();
@@ -149,13 +122,10 @@ void CldComponentInstallerTraits::SetLatestCldDataFile(
cld_file.Get() = path;
}
-bool GetLatestCldDataFile(base::FilePath* path) {
+base::FilePath GetLatestCldDataFile() {
base::AutoLock lock(cld_file_lock.Get());
- const base::FilePath cached = cld_file.Get();
- if (cached.empty())
- return false;
- *path = cached;
- return true;
+ // cld_file is an empty path by default, meaning "file not available yet".
+ return cld_file.Get();
}
} // namespace component_updater
diff --git a/chrome/browser/component_updater/cld_component_installer.h b/chrome/browser/component_updater/cld_component_installer.h
index 20a4b3c672..9e92c71128 100644
--- a/chrome/browser/component_updater/cld_component_installer.h
+++ b/chrome/browser/component_updater/cld_component_installer.h
@@ -5,19 +5,66 @@
#ifndef CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_
#define CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_
+#include <string>
+#include <vector>
+
#include "base/files/file_path.h"
+#include "base/gtest_prod_util.h"
+#include "chrome/browser/component_updater/default_component_installer.h"
+
+namespace test {
+class ScopedCLDDynamicDataHarness;
+} // namespace test
namespace component_updater {
class ComponentUpdateService;
+// Visible for testing. No need to instantiate this class directly.
+class CldComponentInstallerTraits : public ComponentInstallerTraits {
+ public:
+ CldComponentInstallerTraits();
+ virtual ~CldComponentInstallerTraits() {}
+
+ private:
+ friend class CldComponentInstallerTest; // For access within SetUp()
+ friend class test::ScopedCLDDynamicDataHarness; // For browser tests only
+ FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, ComponentReady);
+ FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetBaseDirectory);
+ FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetHash);
+ FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetInstalledPath);
+ FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetName);
+ FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, OnCustomInstall);
+ FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, SetLatestCldDataFile);
+ FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, VerifyInstallation);
+
+ // The following methods override ComponentInstallerTraits.
+ virtual bool CanAutoUpdate() const OVERRIDE;
+ virtual bool OnCustomInstall(const base::DictionaryValue& manifest,
+ const base::FilePath& install_dir) OVERRIDE;
+ virtual bool VerifyInstallation(
+ const base::FilePath& install_dir) const OVERRIDE;
+ virtual void ComponentReady(
+ const base::Version& version,
+ const base::FilePath& path,
+ scoped_ptr<base::DictionaryValue> manifest) OVERRIDE;
+ virtual base::FilePath GetBaseDirectory() const OVERRIDE;
+ virtual void GetHash(std::vector<uint8>* hash) const OVERRIDE;
+ virtual std::string GetName() const OVERRIDE;
+
+ static base::FilePath GetInstalledPath(const base::FilePath& base);
+ static void SetLatestCldDataFile(const base::FilePath& path);
+ DISALLOW_COPY_AND_ASSIGN(CldComponentInstallerTraits);
+};
+
+// Call once during startup to make the component update service aware of
+// the CLD component.
void RegisterCldComponent(ComponentUpdateService* cus);
-// Places the path to the latest CLD data file into the specified path object.
-// Returns true if and only if the file has been observed to exist at least
-// once and was valid when it was observed; if the function returns false, the
-// path parameter is not modified. This function is threadsafe.
-bool GetLatestCldDataFile(base::FilePath* path);
+// Returns the path to the latest CLD data file into the specified path object,
+// or an empty path if the CLD data file has not been observed yet.
+// This function is threadsafe.
+base::FilePath GetLatestCldDataFile();
} // namespace component_updater
diff --git a/chrome/browser/component_updater/component_updater_service.cc b/chrome/browser/component_updater/component_updater_service.cc
index 60740e678b..2bf5ab6861 100644
--- a/chrome/browser/component_updater/component_updater_service.cc
+++ b/chrome/browser/component_updater/component_updater_service.cc
@@ -149,7 +149,7 @@ void UnblockandReapAllThrottles(CUResourceThrottle::WeakPtrVector* throttles) {
// only from the UI thread. The unpack and installation is done in a blocking
// pool thread. The network requests are done in the IO thread or in the file
// thread.
-class CrxUpdateService : public ComponentUpdateService {
+class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater {
public:
explicit CrxUpdateService(ComponentUpdateService::Configurator* config);
virtual ~CrxUpdateService();
@@ -160,12 +160,15 @@ class CrxUpdateService : public ComponentUpdateService {
virtual Status Start() OVERRIDE;
virtual Status Stop() OVERRIDE;
virtual Status RegisterComponent(const CrxComponent& component) OVERRIDE;
- virtual Status OnDemandUpdate(const std::string& component_id) OVERRIDE;
virtual void GetComponents(
std::vector<CrxComponentInfo>* components) OVERRIDE;
+ virtual OnDemandUpdater& GetOnDemandUpdater() OVERRIDE;
+
+ // Overrides for OnDemandUpdater.
virtual content::ResourceThrottle* GetOnDemandResourceThrottle(
net::URLRequest* request,
const std::string& crx_id) OVERRIDE;
+ virtual Status OnDemandUpdate(const std::string& component_id) OVERRIDE;
// Context for a crx download url request.
struct CRXContext {
@@ -496,60 +499,6 @@ ComponentUpdateService::Status CrxUpdateService::RegisterComponent(
return kOk;
}
-// Start the process of checking for an update, for a particular component
-// that was previously registered.
-// |component_id| is a value returned from GetCrxComponentID().
-ComponentUpdateService::Status CrxUpdateService::OnDemandUpdate(
- const std::string& component_id) {
- return OnDemandUpdateInternal(FindUpdateItemById(component_id));
-}
-
-ComponentUpdateService::Status CrxUpdateService::OnDemandUpdateInternal(
- CrxUpdateItem* uit) {
- if (!uit)
- return kError;
-
- // Check if the request is too soon.
- base::TimeDelta delta = base::Time::Now() - uit->last_check;
- if (delta < base::TimeDelta::FromSeconds(config_->OnDemandDelay()))
- return kError;
-
- switch (uit->status) {
- // If the item is already in the process of being updated, there is
- // no point in this call, so return kInProgress.
- case CrxUpdateItem::kChecking:
- case CrxUpdateItem::kCanUpdate:
- case CrxUpdateItem::kDownloadingDiff:
- case CrxUpdateItem::kDownloading:
- case CrxUpdateItem::kUpdatingDiff:
- case CrxUpdateItem::kUpdating:
- return kInProgress;
- // Otherwise the item was already checked a while back (or it is new),
- // set its status to kNew to give it a slightly higher priority.
- case CrxUpdateItem::kNew:
- case CrxUpdateItem::kUpdated:
- case CrxUpdateItem::kUpToDate:
- case CrxUpdateItem::kNoUpdate:
- ChangeItemState(uit, CrxUpdateItem::kNew);
- uit->on_demand = true;
- break;
- case CrxUpdateItem::kLastStatus:
- NOTREACHED() << uit->status;
- }
-
- // In case the current delay is long, set the timer to a shorter value
- // to get the ball rolling.
- if (timer_.IsRunning()) {
- timer_.Stop();
- timer_.Start(FROM_HERE,
- base::TimeDelta::FromSeconds(config_->StepDelay()),
- this,
- &CrxUpdateService::ProcessPendingItems);
- }
-
- return kOk;
-}
-
void CrxUpdateService::GetComponents(
std::vector<CrxComponentInfo>* components) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -565,6 +514,10 @@ void CrxUpdateService::GetComponents(
}
}
+OnDemandUpdater& CrxUpdateService::GetOnDemandUpdater() {
+ return *this;
+}
+
// This is the main loop of the component updater. It updates one component
// at a time if updates are available. Otherwise, it does an update check or
// takes a long sleep until the loop runs again.
@@ -1010,6 +963,57 @@ void CrxUpdateService::OnNewResourceThrottle(
UnblockResourceThrottle(rt);
}
+ComponentUpdateService::Status CrxUpdateService::OnDemandUpdate(
+ const std::string& component_id) {
+ return OnDemandUpdateInternal(FindUpdateItemById(component_id));
+}
+
+ComponentUpdateService::Status CrxUpdateService::OnDemandUpdateInternal(
+ CrxUpdateItem* uit) {
+ if (!uit)
+ return kError;
+
+ // Check if the request is too soon.
+ base::TimeDelta delta = base::Time::Now() - uit->last_check;
+ if (delta < base::TimeDelta::FromSeconds(config_->OnDemandDelay()))
+ return kError;
+
+ switch (uit->status) {
+ // If the item is already in the process of being updated, there is
+ // no point in this call, so return kInProgress.
+ case CrxUpdateItem::kChecking:
+ case CrxUpdateItem::kCanUpdate:
+ case CrxUpdateItem::kDownloadingDiff:
+ case CrxUpdateItem::kDownloading:
+ case CrxUpdateItem::kUpdatingDiff:
+ case CrxUpdateItem::kUpdating:
+ return kInProgress;
+ // Otherwise the item was already checked a while back (or it is new),
+ // set its status to kNew to give it a slightly higher priority.
+ case CrxUpdateItem::kNew:
+ case CrxUpdateItem::kUpdated:
+ case CrxUpdateItem::kUpToDate:
+ case CrxUpdateItem::kNoUpdate:
+ ChangeItemState(uit, CrxUpdateItem::kNew);
+ uit->on_demand = true;
+ break;
+ case CrxUpdateItem::kLastStatus:
+ NOTREACHED() << uit->status;
+ }
+
+ // In case the current delay is long, set the timer to a shorter value
+ // to get the ball rolling.
+ if (timer_.IsRunning()) {
+ timer_.Stop();
+ timer_.Start(FROM_HERE,
+ base::TimeDelta::FromSeconds(config_->StepDelay()),
+ this,
+ &CrxUpdateService::ProcessPendingItems);
+ }
+
+ return kOk;
+}
+
///////////////////////////////////////////////////////////////////////////////
CUResourceThrottle::CUResourceThrottle(const net::URLRequest* request)
diff --git a/chrome/browser/component_updater/component_updater_service.h b/chrome/browser/component_updater/component_updater_service.h
index 99164c3b16..9ea18dc7c9 100644
--- a/chrome/browser/component_updater/component_updater_service.h
+++ b/chrome/browser/component_updater/component_updater_service.h
@@ -29,7 +29,7 @@ class ResourceThrottle;
namespace component_updater {
-class OnDemandTester;
+class OnDemandUpdater;
// Component specific installers must derive from this class and implement
// OnUpdateError() and Install(). A valid instance of this class must be
@@ -208,30 +208,43 @@ class ComponentUpdateService {
// Returns a list of registered components.
virtual void GetComponents(std::vector<CrxComponentInfo>* components) = 0;
+ // Returns an interface for on-demand updates. On-demand updates are
+ // proactively triggered outside the normal component update service schedule.
+ virtual OnDemandUpdater& GetOnDemandUpdater() = 0;
+
+ virtual ~ComponentUpdateService() {}
+
+ private:
+ friend class ::ComponentsUI;
+};
+
+typedef ComponentUpdateService::Observer ServiceObserver;
+
+class OnDemandUpdater {
+ public:
+ virtual ~OnDemandUpdater() {}
+
// Returns a network resource throttle. It means that a component will be
- // downloaded and installed before the resource is unthrottled. This is the
- // only function callable from the IO thread.
+ // downloaded and installed before the resource is unthrottled. This function
+ // can be called from the IO thread.
virtual content::ResourceThrottle* GetOnDemandResourceThrottle(
net::URLRequest* request,
const std::string& crx_id) = 0;
- virtual ~ComponentUpdateService() {}
-
- friend class ::ComponentsUI;
+ private:
friend class OnDemandTester;
+ friend class ::ComponentsUI;
- private:
- // Ask the component updater to do an update check for a previously
- // registered component, immediately. If an update or check is already
- // in progress, returns |kInProgress|.
- // There is no guarantee that the item will actually be updated,
- // since an update may not be available. Listeners for the component will
- // know the outcome of the check.
- virtual Status OnDemandUpdate(const std::string& component_id) = 0;
+ // Triggers an update check for a component. |component_id| is a value
+ // returned by GetCrxComponentID(). If an update for this component is already
+ // in progress, the function returns |kInProgress|. If an update is available,
+ // the update will be applied. The caller can subscribe to component update
+ // service notifications to get an indication about the outcome of the
+ // on-demand update.
+ virtual ComponentUpdateService::Status OnDemandUpdate(
+ const std::string& component_id) = 0;
};
-typedef ComponentUpdateService::Observer ServiceObserver;
-
// Creates the component updater. You must pass a valid |config| allocated on
// the heap which the component updater will own.
ComponentUpdateService* ComponentUpdateServiceFactory(
diff --git a/chrome/browser/component_updater/component_updater_utils.cc b/chrome/browser/component_updater/component_updater_utils.cc
index d6cb1e0ee2..ec6d497ac3 100644
--- a/chrome/browser/component_updater/component_updater_utils.cc
+++ b/chrome/browser/component_updater/component_updater_utils.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/component_updater/component_updater_utils.h"
+#include <cmath>
+
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/guid.h"
@@ -25,6 +27,17 @@
namespace component_updater {
+namespace {
+
+// Returns the amount of physical memory in GB, rounded to the nearest GB.
+int GetPhysicalMemoryGB() {
+ const double kOneGB = 1024 * 1024 * 1024;
+ const int64 phys_mem = base::SysInfo::AmountOfPhysicalMemory();
+ return static_cast<int>(std::floor(0.5 + phys_mem / kOneGB));
+}
+
+} // namespace
+
std::string BuildProtocolRequest(const std::string& request_body,
const std::string& additional_attributes) {
const std::string prod_id(chrome::OmahaQueryParams::GetProdIdString(
@@ -63,6 +76,11 @@ std::string BuildProtocolRequest(const std::string& request_body,
#endif
base::StringAppendF(&request, ">");
+ // HW platform information.
+ base::StringAppendF(&request,
+ "<hw physmemory=\"%d\"/>",
+ GetPhysicalMemoryGB()); // "physmem" in GB.
+
// OS version and platform information.
base::StringAppendF(
&request,
diff --git a/chrome/browser/component_updater/component_updater_utils.h b/chrome/browser/component_updater/component_updater_utils.h
index 17acb5937e..7c238d28ed 100644
--- a/chrome/browser/component_updater/component_updater_utils.h
+++ b/chrome/browser/component_updater/component_updater_utils.h
@@ -34,6 +34,7 @@ struct CrxUpdateItem;
// requestid="{7383396D-B4DD-46E1-9104-AAC6B918E792}"
// updaterchannel="canary" arch="x86" nacl_arch="x86-64"
// ADDITIONAL ATTRIBUTES>
+// <hw physmemory="16"/>
// <os platform="win" version="6.1" arch="x86"/>
// ... REQUEST BODY ...
// </request>
diff --git a/chrome/browser/component_updater/ppapi_utils.cc b/chrome/browser/component_updater/ppapi_utils.cc
index cdd8363bb7..f8f7dc44b8 100644
--- a/chrome/browser/component_updater/ppapi_utils.cc
+++ b/chrome/browser/component_updater/ppapi_utils.cc
@@ -87,6 +87,7 @@
#include "ppapi/c/private/ppb_flash_message_loop.h"
#include "ppapi/c/private/ppb_flash_print.h"
#include "ppapi/c/private/ppb_host_resolver_private.h"
+#include "ppapi/c/private/ppb_input_event_private.h"
#include "ppapi/c/private/ppb_isolated_file_system_private.h"
#include "ppapi/c/private/ppb_output_protection_private.h"
#include "ppapi/c/private/ppb_pdf.h"
diff --git a/chrome/browser/component_updater/recovery_component_installer.cc b/chrome/browser/component_updater/recovery_component_installer.cc
index 642f94cec6..4baa3666db 100644
--- a/chrome/browser/component_updater/recovery_component_installer.cc
+++ b/chrome/browser/component_updater/recovery_component_installer.cc
@@ -20,6 +20,7 @@
#include "base/strings/string_util.h"
#include "base/values.h"
#include "chrome/browser/component_updater/component_updater_service.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
@@ -114,11 +115,23 @@ bool RecoveryComponentInstaller::Install(const base::DictionaryValue& manifest,
return false;
if (current_version_.CompareTo(version) >= 0)
return false;
- base::FilePath main_file = unpack_path.Append(kRecoveryFileName);
+
+ // Passed the basic tests. Copy the installation to a permanent directory.
+ base::FilePath path;
+ if (!PathService::Get(chrome::DIR_RECOVERY_BASE, &path))
+ return false;
+ path = path.AppendASCII(version.GetString());
+ if (base::PathExists(path) && !base::DeleteFile(path, true))
+ return false;
+ if (!base::Move(unpack_path, path)) {
+ DVLOG(1) << "Recovery component move failed.";
+ return false;
+ }
+
+ base::FilePath main_file = path.Append(kRecoveryFileName);
if (!base::PathExists(main_file))
return false;
- // Passed the basic tests. The installation continues with the
- // recovery component itself running from the temp directory.
+ // Run the recovery component.
CommandLine cmdline(main_file);
std::string arguments;
if (manifest.GetStringASCII("x-recovery-args", &arguments))
diff --git a/chrome/browser/component_updater/test/cld_component_installer_unittest.cc b/chrome/browser/component_updater/test/cld_component_installer_unittest.cc
new file mode 100644
index 0000000000..6fc4f14b73
--- /dev/null
+++ b/chrome/browser/component_updater/test/cld_component_installer_unittest.cc
@@ -0,0 +1,111 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <vector>
+
+#include "base/file_util.h"
+#include "base/files/file_path.h"
+#include "base/files/scoped_temp_dir.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/run_loop.h"
+#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/values.h"
+#include "base/version.h"
+#include "chrome/browser/component_updater/cld_component_installer.h"
+#include "chrome/common/chrome_constants.h"
+#include "chrome/common/chrome_paths.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/platform_test.h"
+
+namespace component_updater {
+
+class CldComponentInstallerTest : public PlatformTest {
+ public:
+ virtual void SetUp() OVERRIDE {
+ PlatformTest::SetUp();
+
+ // ScopedTempDir automatically does a recursive delete on the entire
+ // directory in its destructor, so no cleanup is required in TearDown.
+ // Note that all files created by this test case are created within the
+ // directory that is created here, so even though they are not explicitly
+ // created *as temp files*, they will still get cleaned up automagically.
+ ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
+
+ // The "latest CLD data file" is a static piece of information, and thus
+ // for correctness we empty it before each test.
+ traits.SetLatestCldDataFile(base::FilePath());
+ }
+
+ base::ScopedTempDir temp_dir_;
+ component_updater::CldComponentInstallerTraits traits;
+};
+
+TEST_F(CldComponentInstallerTest, SetLatestCldDataFile) {
+ ASSERT_TRUE(component_updater::GetLatestCldDataFile().empty());
+ const base::FilePath expected(FILE_PATH_LITERAL("test/foo.test"));
+ traits.SetLatestCldDataFile(expected);
+
+ base::FilePath result = component_updater::GetLatestCldDataFile();
+ ASSERT_EQ(expected, result);
+}
+
+TEST_F(CldComponentInstallerTest, VerifyInstallation) {
+ // All files are created within a ScopedTempDir, which deletes all
+ // children when its destructor is called (at the end of each test).
+ ASSERT_FALSE(traits.VerifyInstallation(temp_dir_.path()));
+ const base::FilePath data_file_dir =
+ temp_dir_.path().Append(FILE_PATH_LITERAL("_platform_specific")).Append(
+ FILE_PATH_LITERAL("all"));
+ ASSERT_TRUE(base::CreateDirectory(data_file_dir));
+ const base::FilePath data_file =
+ data_file_dir.Append(chrome::kCLDDataFilename);
+ const std::string test_data("fake cld2 data file content here :)");
+ ASSERT_EQ(static_cast<int32>(test_data.length()),
+ base::WriteFile(data_file, test_data.c_str(), test_data.length()));
+ ASSERT_TRUE(traits.VerifyInstallation(temp_dir_.path()));
+}
+
+TEST_F(CldComponentInstallerTest, OnCustomInstall) {
+ const base::DictionaryValue manifest;
+ const base::FilePath install_dir;
+ // Sanity: shouldn't crash.
+ ASSERT_TRUE(traits.OnCustomInstall(manifest, install_dir));
+}
+
+TEST_F(CldComponentInstallerTest, GetInstalledPath) {
+ const base::FilePath base_dir;
+ const base::FilePath result =
+ CldComponentInstallerTraits::GetInstalledPath(base_dir);
+ ASSERT_TRUE(EndsWith(result.value(), chrome::kCLDDataFilename, true));
+}
+
+TEST_F(CldComponentInstallerTest, GetBaseDirectory) {
+ const base::FilePath result = traits.GetBaseDirectory();
+ ASSERT_FALSE(result.empty());
+}
+
+TEST_F(CldComponentInstallerTest, GetHash) {
+ std::vector<uint8> hash;
+ traits.GetHash(&hash);
+ ASSERT_EQ(static_cast<size_t>(32), hash.size());
+}
+
+TEST_F(CldComponentInstallerTest, GetName) {
+ ASSERT_FALSE(traits.GetName().empty());
+}
+
+TEST_F(CldComponentInstallerTest, ComponentReady) {
+ scoped_ptr<base::DictionaryValue> manifest;
+ const base::FilePath install_dir(FILE_PATH_LITERAL("/foo"));
+ const base::Version version("1.2.3.4");
+ traits.ComponentReady(version, install_dir, manifest.Pass());
+ base::FilePath result = component_updater::GetLatestCldDataFile();
+ ASSERT_TRUE(StartsWith(result.AsUTF16Unsafe(),
+ install_dir.AsUTF16Unsafe(),
+ true));
+ ASSERT_TRUE(EndsWith(result.value(), chrome::kCLDDataFilename, true));
+}
+
+} // namespace component_updater
diff --git a/chrome/browser/component_updater/test/component_updater_service_unittest.cc b/chrome/browser/component_updater/test/component_updater_service_unittest.cc
index b58905bb52..520903551d 100644
--- a/chrome/browser/component_updater/test/component_updater_service_unittest.cc
+++ b/chrome/browser/component_updater/test/component_updater_service_unittest.cc
@@ -247,7 +247,7 @@ void ComponentUpdaterTest::RunThreadsUntilIdle() {
ComponentUpdateService::Status OnDemandTester::OnDemand(
ComponentUpdateService* cus,
const std::string& component_id) {
- return cus->OnDemandUpdate(component_id);
+ return cus->GetOnDemandUpdater().OnDemandUpdate(component_id);
}
// Verify that our test fixture work and the component updater can
@@ -1296,7 +1296,8 @@ content::ResourceThrottle* RequestTestResourceThrottle(
&context);
content::ResourceThrottle* rt =
- cus->GetOnDemandResourceThrottle(&url_request, crx_id);
+ cus->GetOnDemandUpdater().GetOnDemandResourceThrottle(&url_request,
+ crx_id);
rt->set_controller_for_testing(controller);
controller->SetThrottle(rt);
return rt;
diff --git a/chrome/browser/component_updater/test/update_checker_unittest.cc b/chrome/browser/component_updater/test/update_checker_unittest.cc
index 223be81e70..0b60900341 100644
--- a/chrome/browser/component_updater/test/update_checker_unittest.cc
+++ b/chrome/browser/component_updater/test/update_checker_unittest.cc
@@ -192,6 +192,9 @@ TEST_F(UpdateCheckerTest, UpdateCheckSuccess) {
"app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">"
"<updatecheck /><packages><package fp=\"fp1\"/></packages></app>"));
+ EXPECT_NE(string::npos,
+ post_interceptor_->GetRequests()[0].find("<hw physmemory="));
+
// Sanity check the arguments of the callback after parsing.
EXPECT_EQ(0, error_);
EXPECT_TRUE(error_message_.empty());