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

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

Issue 6347033: net: Add namespace net to Sdch* classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: namespace on unittest Created 9 years, 10 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) 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/sdch_dictionary_fetcher.h" 5 #include "chrome/browser/net/sdch_dictionary_fetcher.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "net/url_request/url_request_status.h" 9 #include "net/url_request/url_request_status.h"
10 10
11 SdchDictionaryFetcher::SdchDictionaryFetcher() 11 SdchDictionaryFetcher::SdchDictionaryFetcher()
12 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), 12 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
13 task_is_pending_(false) { 13 task_is_pending_(false) {
14 } 14 }
15 15
16 SdchDictionaryFetcher::~SdchDictionaryFetcher() { 16 SdchDictionaryFetcher::~SdchDictionaryFetcher() {
17 } 17 }
18 18
19 // static
20 void SdchDictionaryFetcher::Shutdown() {
21 net::SdchManager::Shutdown();
22 }
23
19 void SdchDictionaryFetcher::Schedule(const GURL& dictionary_url) { 24 void SdchDictionaryFetcher::Schedule(const GURL& dictionary_url) {
20 // Avoid pushing duplicate copy onto queue. We may fetch this url again later 25 // Avoid pushing duplicate copy onto queue. We may fetch this url again later
21 // and get a different dictionary, but there is no reason to have it in the 26 // and get a different dictionary, but there is no reason to have it in the
22 // queue twice at one time. 27 // queue twice at one time.
23 if (!fetch_queue_.empty() && fetch_queue_.back() == dictionary_url) { 28 if (!fetch_queue_.empty() && fetch_queue_.back() == dictionary_url) {
24 SdchManager::SdchErrorRecovery( 29 net::SdchManager::SdchErrorRecovery(
25 SdchManager::DICTIONARY_ALREADY_SCHEDULED_TO_DOWNLOAD); 30 net::SdchManager::DICTIONARY_ALREADY_SCHEDULED_TO_DOWNLOAD);
26 return; 31 return;
27 } 32 }
28 if (attempted_load_.find(dictionary_url) != attempted_load_.end()) { 33 if (attempted_load_.find(dictionary_url) != attempted_load_.end()) {
29 SdchManager::SdchErrorRecovery( 34 net::SdchManager::SdchErrorRecovery(
30 SdchManager::DICTIONARY_ALREADY_TRIED_TO_DOWNLOAD); 35 net::SdchManager::DICTIONARY_ALREADY_TRIED_TO_DOWNLOAD);
31 return; 36 return;
32 } 37 }
33 attempted_load_.insert(dictionary_url); 38 attempted_load_.insert(dictionary_url);
34 fetch_queue_.push(dictionary_url); 39 fetch_queue_.push(dictionary_url);
35 ScheduleDelayedRun(); 40 ScheduleDelayedRun();
36 } 41 }
37 42
38 void SdchDictionaryFetcher::ScheduleDelayedRun() { 43 void SdchDictionaryFetcher::ScheduleDelayedRun() {
39 if (fetch_queue_.empty() || current_fetch_.get() || task_is_pending_) 44 if (fetch_queue_.empty() || current_fetch_.get() || task_is_pending_)
40 return; 45 return;
(...skipping 25 matching lines...) Expand all
66 71
67 void SdchDictionaryFetcher::OnURLFetchComplete( 72 void SdchDictionaryFetcher::OnURLFetchComplete(
68 const URLFetcher* source, 73 const URLFetcher* source,
69 const GURL& url, 74 const GURL& url,
70 const net::URLRequestStatus& status, 75 const net::URLRequestStatus& status,
71 int response_code, 76 int response_code,
72 const ResponseCookies& cookies, 77 const ResponseCookies& cookies,
73 const std::string& data) { 78 const std::string& data) {
74 if ((200 == response_code) && 79 if ((200 == response_code) &&
75 (status.status() == net::URLRequestStatus::SUCCESS)) 80 (status.status() == net::URLRequestStatus::SUCCESS))
76 SdchManager::Global()->AddSdchDictionary(data, url); 81 net::SdchManager::Global()->AddSdchDictionary(data, url);
77 current_fetch_.reset(NULL); 82 current_fetch_.reset(NULL);
78 ScheduleDelayedRun(); 83 ScheduleDelayedRun();
79 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698