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

Unified Diff: extensions/browser/updater/update_service.cc

Issue 1362043005: Add extensions code to use common updater in components/update_client/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merged latest origin/master Created 5 years, 2 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
Index: extensions/browser/updater/update_service.cc
diff --git a/extensions/browser/updater/update_service.cc b/extensions/browser/updater/update_service.cc
index 0cb055cf6f5e8b48df83923299170aa46fa6f9ec..ad40abd57acd77d04d520073e3671bb39b5de931 100644
--- a/extensions/browser/updater/update_service.cc
+++ b/extensions/browser/updater/update_service.cc
@@ -4,79 +4,61 @@
#include "extensions/browser/updater/update_service.h"
-#include <set>
-
-#include "base/message_loop/message_loop.h"
-#include "components/update_client/update_query_params.h"
+#include "base/bind.h"
+#include "base/files/file_util.h"
+#include "components/update_client/update_client.h"
#include "content/public/browser/browser_context.h"
-#include "extensions/browser/updater/extension_downloader.h"
+#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extensions_browser_client.h"
+#include "extensions/browser/updater/update_data_provider.h"
#include "extensions/browser/updater/update_service_factory.h"
-#include "extensions/common/extension_urls.h"
-using update_client::UpdateQueryParams;
+namespace {
-namespace extensions {
+void UpdateCheckCompleteCallback(int error) {}
-// static
-UpdateService* UpdateService::Get(content::BrowserContext* context) {
- return UpdateServiceFactory::GetForBrowserContext(context);
+void InstallUpdateCallback(content::BrowserContext* context,
+ const std::string& extension_id,
+ const base::FilePath& temp_dir) {
+ extensions::ExtensionSystem::Get(context)
+ ->InstallUpdate(extension_id, temp_dir);
}
-void UpdateService::DownloadAndInstall(
- const std::string& id,
- const base::Callback<void(bool)>& callback) {
- DCHECK(download_callback_.is_null());
- download_callback_ = callback;
- downloader_->AddPendingExtension(id, extension_urls::GetWebstoreUpdateUrl(),
- 0);
- downloader_->StartAllPending(nullptr);
-}
+} // namespace
-UpdateService::UpdateService(content::BrowserContext* context)
- : browser_context_(context),
- downloader_(new ExtensionDownloader(this, context->GetRequestContext())) {
- downloader_->set_manifest_query_params(
- UpdateQueryParams::Get(UpdateQueryParams::CRX));
-}
+namespace extensions {
-UpdateService::~UpdateService() {
+// static
+UpdateService* UpdateService::Get(content::BrowserContext* context) {
+ return UpdateServiceFactory::GetForBrowserContext(context);
}
-void UpdateService::OnExtensionDownloadFailed(
- const std::string& id,
- Error error,
- const PingResult& ping,
- const std::set<int>& request_ids) {
- auto callback = download_callback_;
- download_callback_.Reset();
- callback.Run(false);
+void UpdateService::Shutdown() {
+ if (update_data_provider_) {
+ update_data_provider_->Shutdown();
+ update_data_provider_ = nullptr;
+ }
+ update_client_ = nullptr;
+ context_ = nullptr;
}
-void UpdateService::OnExtensionDownloadFinished(
- const CRXFileInfo& file,
- bool file_ownership_passed,
- const GURL& download_url,
- const std::string& version,
- const PingResult& ping,
- const std::set<int>& request_id,
- const InstallCallback& install_callback) {
- // TODO(rockot): Actually unpack and install the CRX.
- auto callback = download_callback_;
- download_callback_.Reset();
- callback.Run(true);
- if (!install_callback.is_null())
- install_callback.Run(true);
+void UpdateService::StartUpdateCheck(std::vector<std::string> extension_ids) {
+ if (!update_client_)
+ return;
+ update_client_->Update(extension_ids, base::Bind(&UpdateDataProvider::GetData,
+ update_data_provider_),
+ base::Bind(&UpdateCheckCompleteCallback));
}
-bool UpdateService::IsExtensionPending(const std::string& id) {
- // TODO(rockot): Implement this. For now all IDs are "pending".
- return true;
+UpdateService::UpdateService(
+ content::BrowserContext* context,
+ scoped_refptr<update_client::UpdateClient> update_client)
+ : context_(context), update_client_(update_client) {
+ CHECK(update_client_);
+ update_data_provider_ =
+ new UpdateDataProvider(context_, base::Bind(&InstallUpdateCallback));
}
-bool UpdateService::GetExtensionExistingVersion(const std::string& id,
- std::string* version) {
- // TODO(rockot): Implement this.
- return false;
-}
+UpdateService::~UpdateService() {}
} // namespace extensions
« no previous file with comments | « extensions/browser/updater/update_service.h ('k') | extensions/browser/updater/update_service_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698