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

Side by Side Diff: chrome/browser/component_updater/component_updater_service.cc

Issue 10392192: Remove content::URLFetcherDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More cleanup Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/component_updater/component_updater_service.h" 5 #include "chrome/browser/component_updater/component_updater_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/component_updater/component_unpacker.h" 23 #include "chrome/browser/component_updater/component_unpacker.h"
24 #include "chrome/common/chrome_notification_types.h" 24 #include "chrome/common/chrome_notification_types.h"
25 #include "chrome/common/chrome_utility_messages.h" 25 #include "chrome/common/chrome_utility_messages.h"
26 #include "chrome/common/chrome_version_info.h" 26 #include "chrome/common/chrome_version_info.h"
27 #include "chrome/common/extensions/extension.h" 27 #include "chrome/common/extensions/extension.h"
28 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
29 #include "content/public/browser/utility_process_host.h" 29 #include "content/public/browser/utility_process_host.h"
30 #include "content/public/browser/utility_process_host_client.h" 30 #include "content/public/browser/utility_process_host_client.h"
31 #include "content/public/common/url_fetcher.h" 31 #include "content/public/common/url_fetcher.h"
32 #include "content/public/common/url_fetcher_delegate.h"
33 #include "googleurl/src/gurl.h" 32 #include "googleurl/src/gurl.h"
34 #include "net/base/escape.h" 33 #include "net/base/escape.h"
35 #include "net/base/load_flags.h" 34 #include "net/base/load_flags.h"
35 #include "net/url_request/url_fetcher_delegate.h"
36 36
37 using content::BrowserThread; 37 using content::BrowserThread;
38 using content::UtilityProcessHost; 38 using content::UtilityProcessHost;
39 using content::UtilityProcessHostClient; 39 using content::UtilityProcessHostClient;
40 using extensions::Extension; 40 using extensions::Extension;
41 41
42 // The component updater is designed to live until process shutdown, so 42 // The component updater is designed to live until process shutdown, so
43 // base::Bind() calls are not refcounted. 43 // base::Bind() calls are not refcounted.
44 44
45 namespace { 45 namespace {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 Version proposed_ver(proposed); 106 Version proposed_ver(proposed);
107 if (!proposed_ver.IsValid()) 107 if (!proposed_ver.IsValid())
108 return false; 108 return false;
109 return (current.CompareTo(proposed_ver) < 0); 109 return (current.CompareTo(proposed_ver) < 0);
110 } 110 }
111 111
112 // Helper template class that allows our main class to have separate 112 // Helper template class that allows our main class to have separate
113 // OnURLFetchComplete() callbacks for different types of url requests 113 // OnURLFetchComplete() callbacks for different types of url requests
114 // they are differentiated by the |Ctx| type. 114 // they are differentiated by the |Ctx| type.
115 template <typename Del, typename Ctx> 115 template <typename Del, typename Ctx>
116 class DelegateWithContext : public content::URLFetcherDelegate { 116 class DelegateWithContext : public net::URLFetcherDelegate {
117 public: 117 public:
118 DelegateWithContext(Del* delegate, Ctx* context) 118 DelegateWithContext(Del* delegate, Ctx* context)
119 : delegate_(delegate), context_(context) {} 119 : delegate_(delegate), context_(context) {}
120 120
121 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE { 121 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE {
122 delegate_->OnURLFetchComplete(source, context_); 122 delegate_->OnURLFetchComplete(source, context_);
123 delete this; 123 delete this;
124 } 124 }
125 125
126 private: 126 private:
127 ~DelegateWithContext() {} 127 ~DelegateWithContext() {}
128 128
129 Del* delegate_; 129 Del* delegate_;
130 Ctx* context_; 130 Ctx* context_;
131 }; 131 };
132 // This function creates the right DelegateWithContext using template inference. 132 // This function creates the right DelegateWithContext using template inference.
133 template <typename Del, typename Ctx> 133 template <typename Del, typename Ctx>
134 content::URLFetcherDelegate* MakeContextDelegate(Del* delegate, Ctx* context) { 134 net::URLFetcherDelegate* MakeContextDelegate(Del* delegate, Ctx* context) {
135 return new DelegateWithContext<Del, Ctx>(delegate, context); 135 return new DelegateWithContext<Del, Ctx>(delegate, context);
136 } 136 }
137 137
138 // Helper to start a url request using |fetcher| with the common flags. 138 // Helper to start a url request using |fetcher| with the common flags.
139 void StartFetch(content::URLFetcher* fetcher, 139 void StartFetch(content::URLFetcher* fetcher,
140 net::URLRequestContextGetter* context_getter, 140 net::URLRequestContextGetter* context_getter,
141 bool save_to_file) { 141 bool save_to_file) {
142 fetcher->SetRequestContext(context_getter); 142 fetcher->SetRequestContext(context_getter);
143 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 143 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
144 net::LOAD_DO_NOT_SAVE_COOKIES | 144 net::LOAD_DO_NOT_SAVE_COOKIES |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 ScheduleNextRun(false); 769 ScheduleNextRun(false);
770 } 770 }
771 771
772 // The component update factory. Using the component updater as a singleton 772 // The component update factory. Using the component updater as a singleton
773 // is the job of the browser process. 773 // is the job of the browser process.
774 ComponentUpdateService* ComponentUpdateServiceFactory( 774 ComponentUpdateService* ComponentUpdateServiceFactory(
775 ComponentUpdateService::Configurator* config) { 775 ComponentUpdateService::Configurator* config) {
776 DCHECK(config); 776 DCHECK(config);
777 return new CrxUpdateService(config); 777 return new CrxUpdateService(config);
778 } 778 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/mock_url_fetchers.cc ('k') | chrome/browser/extensions/app_notify_channel_setup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698