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

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

Issue 20254: Fetch SDCH dictionary as soon as current URL fetch completes... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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) 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 #include "chrome/browser/profile.h" 6 #include "chrome/browser/profile.h"
7 7
8 void SdchDictionaryFetcher::Schedule(const GURL& dictionary_url) { 8 void SdchDictionaryFetcher::Schedule(const GURL& dictionary_url) {
9 // Avoid pushing duplicate copy onto queue. We may fetch this url again later 9 // Avoid pushing duplicate copy onto queue. We may fetch this url again later
10 // and get a different dictionary, but there is no reason to have it in the 10 // and get a different dictionary, but there is no reason to have it in the
11 // queue twice at one time. 11 // queue twice at one time.
12 if (!fetch_queue_.empty() && fetch_queue_.back() == dictionary_url) { 12 if (!fetch_queue_.empty() && fetch_queue_.back() == dictionary_url) {
13 SdchManager::SdchErrorRecovery( 13 SdchManager::SdchErrorRecovery(
14 SdchManager::DICTIONARY_ALREADY_SCHEDULED_TO_DOWNLOAD); 14 SdchManager::DICTIONARY_ALREADY_SCHEDULED_TO_DOWNLOAD);
15 return; 15 return;
16 } 16 }
17 fetch_queue_.push(dictionary_url); 17 fetch_queue_.push(dictionary_url);
18 ScheduleDelayedRun(); 18 ScheduleDelayedRun();
19 } 19 }
20 20
21 // TODO(jar): If QOS low priority is supported, switch to using that instead of
22 // just waiting to do the fetch.
23 void SdchDictionaryFetcher::ScheduleDelayedRun() { 21 void SdchDictionaryFetcher::ScheduleDelayedRun() {
24 if (fetch_queue_.empty() || current_fetch_.get() || task_is_pending_) 22 if (fetch_queue_.empty() || current_fetch_.get() || task_is_pending_)
25 return; 23 return;
26 MessageLoop::current()->PostDelayedTask(FROM_HERE, 24 MessageLoop::current()->PostDelayedTask(FROM_HERE,
27 method_factory_.NewRunnableMethod(&SdchDictionaryFetcher::StartFetching), 25 method_factory_.NewRunnableMethod(&SdchDictionaryFetcher::StartFetching),
28 kMsDelayFromRequestTillDownload); 26 kMsDelayFromRequestTillDownload);
29 task_is_pending_ = true; 27 task_is_pending_ = true;
30 } 28 }
31 29
32 void SdchDictionaryFetcher::StartFetching() { 30 void SdchDictionaryFetcher::StartFetching() {
(...skipping 11 matching lines...) Expand all
44 const GURL& url, 42 const GURL& url,
45 const URLRequestStatus& status, 43 const URLRequestStatus& status,
46 int response_code, 44 int response_code,
47 const ResponseCookies& cookies, 45 const ResponseCookies& cookies,
48 const std::string& data) { 46 const std::string& data) {
49 if ((200 == response_code) && (status.status() == URLRequestStatus::SUCCESS)) 47 if ((200 == response_code) && (status.status() == URLRequestStatus::SUCCESS))
50 SdchManager::Global()->AddSdchDictionary(data, url); 48 SdchManager::Global()->AddSdchDictionary(data, url);
51 current_fetch_.reset(NULL); 49 current_fetch_.reset(NULL);
52 ScheduleDelayedRun(); 50 ScheduleDelayedRun();
53 } 51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698