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

Side by Side Diff: chrome/browser/net/chrome_url_request_context.cc

Issue 8589012: base::Bind fixes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/net/chrome_url_request_context.h" 5 #include "chrome/browser/net/chrome_url_request_context.h"
6 6
7 #include "base/bind.h"
7 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
8 #include "base/message_loop.h" 9 #include "base/message_loop.h"
9 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
10 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
11 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/io_thread.h" 13 #include "chrome/browser/io_thread.h"
13 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/profiles/profile_io_data.h" 16 #include "chrome/browser/profiles/profile_io_data.h"
16 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 155
155 // If we aren't running on the IO thread, we cannot call 156 // If we aren't running on the IO thread, we cannot call
156 // GetURLRequestContext(). Instead we will post a task to the IO loop 157 // GetURLRequestContext(). Instead we will post a task to the IO loop
157 // and wait for it to complete. 158 // and wait for it to complete.
158 159
159 base::WaitableEvent completion(false, false); 160 base::WaitableEvent completion(false, false);
160 net::CookieStore* result = NULL; 161 net::CookieStore* result = NULL;
161 162
162 BrowserThread::PostTask( 163 BrowserThread::PostTask(
163 BrowserThread::IO, FROM_HERE, 164 BrowserThread::IO, FROM_HERE,
164 NewRunnableMethod(this, 165 base::Bind(&ChromeURLRequestContextGetter::GetCookieStoreAsyncHelper,
165 &ChromeURLRequestContextGetter::GetCookieStoreAsyncHelper, 166 this,
166 &completion, 167 &completion,
167 &result)); 168 &result));
wtc 2011/11/17 08:16:21 Nit: align all the function arguments of base::Bin
168 169
169 completion.Wait(); 170 completion.Wait();
170 DCHECK(result); 171 DCHECK(result);
171 return result; 172 return result;
172 } 173 }
173 174
174 scoped_refptr<base::MessageLoopProxy> 175 scoped_refptr<base::MessageLoopProxy>
175 ChromeURLRequestContextGetter::GetIOMessageLoopProxy() const { 176 ChromeURLRequestContextGetter::GetIOMessageLoopProxy() const {
176 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 177 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
177 } 178 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 269
269 if (chrome::NOTIFICATION_PREF_CHANGED == type) { 270 if (chrome::NOTIFICATION_PREF_CHANGED == type) {
270 std::string* pref_name_in = content::Details<std::string>(details).ptr(); 271 std::string* pref_name_in = content::Details<std::string>(details).ptr();
271 PrefService* prefs = content::Source<PrefService>(source).ptr(); 272 PrefService* prefs = content::Source<PrefService>(source).ptr();
272 DCHECK(pref_name_in && prefs); 273 DCHECK(pref_name_in && prefs);
273 if (*pref_name_in == prefs::kAcceptLanguages) { 274 if (*pref_name_in == prefs::kAcceptLanguages) {
274 std::string accept_language = 275 std::string accept_language =
275 prefs->GetString(prefs::kAcceptLanguages); 276 prefs->GetString(prefs::kAcceptLanguages);
276 BrowserThread::PostTask( 277 BrowserThread::PostTask(
277 BrowserThread::IO, FROM_HERE, 278 BrowserThread::IO, FROM_HERE,
278 NewRunnableMethod( 279 base::Bind(
280 &ChromeURLRequestContextGetter::OnAcceptLanguageChange,
279 this, 281 this,
280 &ChromeURLRequestContextGetter::OnAcceptLanguageChange,
281 accept_language)); 282 accept_language));
282 } else if (*pref_name_in == prefs::kDefaultCharset) { 283 } else if (*pref_name_in == prefs::kDefaultCharset) {
283 std::string default_charset = 284 std::string default_charset =
284 prefs->GetString(prefs::kDefaultCharset); 285 prefs->GetString(prefs::kDefaultCharset);
285 BrowserThread::PostTask( 286 BrowserThread::PostTask(
286 BrowserThread::IO, FROM_HERE, 287 BrowserThread::IO, FROM_HERE,
287 NewRunnableMethod( 288 base::Bind(
289 &ChromeURLRequestContextGetter::OnDefaultCharsetChange,
288 this, 290 this,
289 &ChromeURLRequestContextGetter::OnDefaultCharsetChange,
290 default_charset)); 291 default_charset));
291 } else if (*pref_name_in == prefs::kClearSiteDataOnExit) { 292 } else if (*pref_name_in == prefs::kClearSiteDataOnExit) {
292 bool clear_site_data = 293 bool clear_site_data =
293 prefs->GetBoolean(prefs::kClearSiteDataOnExit); 294 prefs->GetBoolean(prefs::kClearSiteDataOnExit);
294 BrowserThread::PostTask( 295 BrowserThread::PostTask(
295 BrowserThread::IO, FROM_HERE, 296 BrowserThread::IO, FROM_HERE,
296 NewRunnableMethod( 297 base::Bind(
298 &ChromeURLRequestContextGetter::OnClearSiteDataOnExitChange,
297 this, 299 this,
298 &ChromeURLRequestContextGetter::OnClearSiteDataOnExitChange,
299 clear_site_data)); 300 clear_site_data));
300 } 301 }
301 } else { 302 } else {
302 NOTREACHED(); 303 NOTREACHED();
303 } 304 }
304 } 305 }
305 306
306 void ChromeURLRequestContextGetter::RegisterPrefsObserver(Profile* profile) { 307 void ChromeURLRequestContextGetter::RegisterPrefsObserver(Profile* profile) {
307 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
308 309
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language)); 388 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language));
388 } 389 }
389 390
390 void ChromeURLRequestContext::OnDefaultCharsetChange( 391 void ChromeURLRequestContext::OnDefaultCharsetChange(
391 const std::string& default_charset) { 392 const std::string& default_charset) {
392 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 393 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
393 set_referrer_charset(default_charset); 394 set_referrer_charset(default_charset);
394 set_accept_charset( 395 set_accept_charset(
395 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset)); 396 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset));
396 } 397 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/connection_tester.cc » ('j') | chrome/browser/net/network_stats.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698