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

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

Issue 258008: Move initialization of ChromeURLRequestContexts to the IO thread. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync again, just in case Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/net/resolve_proxy_msg_helper.cc ('k') | chrome/browser/net/url_fetcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/sdch_dictionary_fetcher.h" 5 #include "chrome/browser/net/sdch_dictionary_fetcher.h"
6 6
7 #include "chrome/browser/profile.h" 7 #include "chrome/browser/profile.h"
8 #include "net/url_request/url_request_status.h" 8 #include "net/url_request/url_request_status.h"
9 9
10 void SdchDictionaryFetcher::Schedule(const GURL& dictionary_url) { 10 void SdchDictionaryFetcher::Schedule(const GURL& dictionary_url) {
(...skipping 21 matching lines...) Expand all
32 MessageLoop::current()->PostDelayedTask(FROM_HERE, 32 MessageLoop::current()->PostDelayedTask(FROM_HERE,
33 method_factory_.NewRunnableMethod(&SdchDictionaryFetcher::StartFetching), 33 method_factory_.NewRunnableMethod(&SdchDictionaryFetcher::StartFetching),
34 kMsDelayFromRequestTillDownload); 34 kMsDelayFromRequestTillDownload);
35 task_is_pending_ = true; 35 task_is_pending_ = true;
36 } 36 }
37 37
38 void SdchDictionaryFetcher::StartFetching() { 38 void SdchDictionaryFetcher::StartFetching() {
39 DCHECK(task_is_pending_); 39 DCHECK(task_is_pending_);
40 task_is_pending_ = false; 40 task_is_pending_ = false;
41 41
42 URLRequestContext* context = Profile::GetDefaultRequestContext(); 42 URLRequestContextGetter* context = Profile::GetDefaultRequestContext();
43 if (!context) { 43 if (!context) {
44 // Shutdown in progress. 44 // Shutdown in progress.
45 // Simulate handling of all dictionary requests by clearing queue. 45 // Simulate handling of all dictionary requests by clearing queue.
46 while (!fetch_queue_.empty()) 46 while (!fetch_queue_.empty())
47 fetch_queue_.pop(); 47 fetch_queue_.pop();
48 return; 48 return;
49 } 49 }
50 50
51 current_fetch_.reset(new URLFetcher(fetch_queue_.front(), URLFetcher::GET, 51 current_fetch_.reset(new URLFetcher(fetch_queue_.front(), URLFetcher::GET,
52 this)); 52 this));
53 fetch_queue_.pop(); 53 fetch_queue_.pop();
54 current_fetch_->set_request_context(context); 54 current_fetch_->set_request_context(context);
55 current_fetch_->Start(); 55 current_fetch_->Start();
56 } 56 }
57 57
58 void SdchDictionaryFetcher::OnURLFetchComplete(const URLFetcher* source, 58 void SdchDictionaryFetcher::OnURLFetchComplete(const URLFetcher* source,
59 const GURL& url, 59 const GURL& url,
60 const URLRequestStatus& status, 60 const URLRequestStatus& status,
61 int response_code, 61 int response_code,
62 const ResponseCookies& cookies, 62 const ResponseCookies& cookies,
63 const std::string& data) { 63 const std::string& data) {
64 if ((200 == response_code) && (status.status() == URLRequestStatus::SUCCESS)) 64 if ((200 == response_code) && (status.status() == URLRequestStatus::SUCCESS))
65 SdchManager::Global()->AddSdchDictionary(data, url); 65 SdchManager::Global()->AddSdchDictionary(data, url);
66 current_fetch_.reset(NULL); 66 current_fetch_.reset(NULL);
67 ScheduleDelayedRun(); 67 ScheduleDelayedRun();
68 } 68 }
OLDNEW
« no previous file with comments | « chrome/browser/net/resolve_proxy_msg_helper.cc ('k') | chrome/browser/net/url_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698