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

Side by Side Diff: chrome/browser/extensions/extension_updater.cc

Issue 5730004: Rename ExtensionsService to ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extension_updater.h" 5 #include "chrome/browser/extensions/extension_updater.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "base/sha2.h" 14 #include "base/sha2.h"
15 #include "base/stl_util-inl.h" 15 #include "base/stl_util-inl.h"
16 #include "base/string_number_conversions.h" 16 #include "base/string_number_conversions.h"
17 #include "base/string_split.h" 17 #include "base/string_split.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/time.h" 19 #include "base/time.h"
20 #include "base/thread.h" 20 #include "base/thread.h"
21 #include "base/version.h" 21 #include "base/version.h"
22 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/extensions/extension_error_reporter.h" 23 #include "chrome/browser/extensions/extension_error_reporter.h"
24 #include "chrome/browser/extensions/extensions_service.h" 24 #include "chrome/browser/extensions/extension_service.h"
25 #include "chrome/browser/prefs/pref_service.h" 25 #include "chrome/browser/prefs/pref_service.h"
26 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/utility_process_host.h" 27 #include "chrome/browser/utility_process_host.h"
28 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/chrome_version_info.h" 29 #include "chrome/common/chrome_version_info.h"
30 #include "chrome/common/extensions/extension.h" 30 #include "chrome/common/extensions/extension.h"
31 #include "chrome/common/extensions/extension_constants.h" 31 #include "chrome/common/extensions/extension_constants.h"
32 #include "chrome/common/pref_names.h" 32 #include "chrome/common/pref_names.h"
33 #include "googleurl/src/gurl.h" 33 #include "googleurl/src/gurl.h"
34 #include "net/base/escape.h" 34 #include "net/base/escape.h"
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 void ExtensionUpdater::OnCRXFetchComplete(const GURL& url, 630 void ExtensionUpdater::OnCRXFetchComplete(const GURL& url,
631 const URLRequestStatus& status, 631 const URLRequestStatus& status,
632 int response_code, 632 int response_code,
633 const std::string& data) { 633 const std::string& data) {
634 if (status.status() == URLRequestStatus::SUCCESS && 634 if (status.status() == URLRequestStatus::SUCCESS &&
635 response_code == 200) { 635 response_code == 200) {
636 if (current_extension_fetch_.id == kBlacklistAppID) { 636 if (current_extension_fetch_.id == kBlacklistAppID) {
637 ProcessBlacklist(data); 637 ProcessBlacklist(data);
638 } else { 638 } else {
639 // Successfully fetched - now write crx to a file so we can have the 639 // Successfully fetched - now write crx to a file so we can have the
640 // ExtensionsService install it. 640 // ExtensionService install it.
641 BrowserThread::PostTask( 641 BrowserThread::PostTask(
642 BrowserThread::FILE, FROM_HERE, 642 BrowserThread::FILE, FROM_HERE,
643 NewRunnableMethod( 643 NewRunnableMethod(
644 file_handler_.get(), &ExtensionUpdaterFileHandler::WriteTempFile, 644 file_handler_.get(), &ExtensionUpdaterFileHandler::WriteTempFile,
645 current_extension_fetch_.id, data, url, 645 current_extension_fetch_.id, data, url,
646 make_scoped_refptr(this))); 646 make_scoped_refptr(this)));
647 } 647 }
648 } else { 648 } else {
649 // TODO(asargent) do things like exponential backoff, handling 649 // TODO(asargent) do things like exponential backoff, handling
650 // 503 Service Unavailable / Retry-After headers, etc. here. 650 // 503 Service Unavailable / Retry-After headers, etc. here.
(...skipping 11 matching lines...) Expand all
662 FetchUpdatedExtension(next.id, next.url, next.package_hash, next.version); 662 FetchUpdatedExtension(next.id, next.url, next.package_hash, next.version);
663 } 663 }
664 } 664 }
665 665
666 void ExtensionUpdater::OnCRXFileWritten(const std::string& id, 666 void ExtensionUpdater::OnCRXFileWritten(const std::string& id,
667 const FilePath& path, 667 const FilePath& path,
668 const GURL& download_url) { 668 const GURL& download_url) {
669 // This can be called after we've been stopped. 669 // This can be called after we've been stopped.
670 if (!alive_) 670 if (!alive_)
671 return; 671 return;
672 // The ExtensionsService is now responsible for cleaning up the temp file 672 // The ExtensionService is now responsible for cleaning up the temp file
673 // at |path|. 673 // at |path|.
674 service_->UpdateExtension(id, path, download_url); 674 service_->UpdateExtension(id, path, download_url);
675 } 675 }
676 676
677 677
678 void ExtensionUpdater::ScheduleNextCheck(const TimeDelta& target_delay) { 678 void ExtensionUpdater::ScheduleNextCheck(const TimeDelta& target_delay) {
679 DCHECK(alive_); 679 DCHECK(alive_);
680 DCHECK(!timer_.IsRunning()); 680 DCHECK(!timer_.IsRunning());
681 DCHECK(target_delay >= TimeDelta::FromSeconds(1)); 681 DCHECK(target_delay >= TimeDelta::FromSeconds(1));
682 682
(...skipping 11 matching lines...) Expand all
694 694
695 timer_.Start(actual_delay, this, &ExtensionUpdater::TimerFired); 695 timer_.Start(actual_delay, this, &ExtensionUpdater::TimerFired);
696 } 696 }
697 697
698 void ExtensionUpdater::TimerFired() { 698 void ExtensionUpdater::TimerFired() {
699 DCHECK(alive_); 699 DCHECK(alive_);
700 CheckNow(); 700 CheckNow();
701 701
702 // If the user has overridden the update frequency, don't bother reporting 702 // If the user has overridden the update frequency, don't bother reporting
703 // this. 703 // this.
704 if (frequency_seconds_ == ExtensionsService::kDefaultUpdateFrequencySeconds) { 704 if (frequency_seconds_ == ExtensionService::kDefaultUpdateFrequencySeconds) {
705 Time last = Time::FromInternalValue(prefs_->GetInt64( 705 Time last = Time::FromInternalValue(prefs_->GetInt64(
706 kLastExtensionsUpdateCheck)); 706 kLastExtensionsUpdateCheck));
707 if (last.ToInternalValue() != 0) { 707 if (last.ToInternalValue() != 0) {
708 // Use counts rather than time so we can use minutes rather than millis. 708 // Use counts rather than time so we can use minutes rather than millis.
709 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.UpdateCheckGap", 709 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.UpdateCheckGap",
710 (Time::Now() - last).InMinutes(), 710 (Time::Now() - last).InMinutes(),
711 base::TimeDelta::FromSeconds(kStartupWaitSeconds).InMinutes(), 711 base::TimeDelta::FromSeconds(kStartupWaitSeconds).InMinutes(),
712 base::TimeDelta::FromDays(40).InMinutes(), 712 base::TimeDelta::FromDays(40).InMinutes(),
713 50); // 50 buckets seems to be the default. 713 50); // 50 buckets seems to be the default.
714 } 714 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this)); 905 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this));
906 extension_fetcher_->set_request_context( 906 extension_fetcher_->set_request_context(
907 Profile::GetDefaultRequestContext()); 907 Profile::GetDefaultRequestContext());
908 extension_fetcher_->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES | 908 extension_fetcher_->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES |
909 net::LOAD_DO_NOT_SAVE_COOKIES | 909 net::LOAD_DO_NOT_SAVE_COOKIES |
910 net::LOAD_DISABLE_CACHE); 910 net::LOAD_DISABLE_CACHE);
911 extension_fetcher_->Start(); 911 extension_fetcher_->Start();
912 current_extension_fetch_ = ExtensionFetch(id, url, hash, version); 912 current_extension_fetch_ = ExtensionFetch(id, url, hash, version);
913 } 913 }
914 } 914 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_updater.h ('k') | chrome/browser/extensions/extension_updater_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698