diff options
author | jar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-23 01:18:16 +0000 |
---|---|---|
committer | jar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-23 01:18:16 +0000 |
commit | 6088942a9ddd522ed237b805641138f853fc3a7f (patch) | |
tree | 38f2078177a0e30fecf4edeaacdda5704a067607 /chrome/browser/net/sdch_dictionary_fetcher.cc | |
parent | 9516babc4a834ec72508b35fb86741f9254f5419 (diff) | |
download | chromium_src-6088942a9ddd522ed237b805641138f853fc3a7f.zip chromium_src-6088942a9ddd522ed237b805641138f853fc3a7f.tar.gz chromium_src-6088942a9ddd522ed237b805641138f853fc3a7f.tar.bz2 |
Re-land SDCH filter support experiment
Fix up solution files for webkit and net
Add one line keyword change to help linux build
r=hunanr,openvcdiff,nsylvain
Review URL: http://codereview.chromium.org/4026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2469 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/sdch_dictionary_fetcher.cc')
-rw-r--r-- | chrome/browser/net/sdch_dictionary_fetcher.cc | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/chrome/browser/net/sdch_dictionary_fetcher.cc b/chrome/browser/net/sdch_dictionary_fetcher.cc new file mode 100644 index 0000000..1b5c21c --- /dev/null +++ b/chrome/browser/net/sdch_dictionary_fetcher.cc @@ -0,0 +1,45 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/net/sdch_dictionary_fetcher.h" +#include "chrome/browser/profile.h" + +void SdchDictionaryFetcher::Schedule(const GURL& dictionary_url) { + fetch_queue_.push(dictionary_url); + ScheduleDelayedRun(); +} + +// TODO(jar): If QOS low priority is supported, switch to using that instead of +// just waiting to do the fetch. +void SdchDictionaryFetcher::ScheduleDelayedRun() { + if (fetch_queue_.empty() || current_fetch_.get() || task_is_pending_) + return; + MessageLoop::current()->PostDelayedTask(FROM_HERE, + method_factory_.NewRunnableMethod(&SdchDictionaryFetcher::StartFetching), + kMsDelayFromRequestTillDownload); + task_is_pending_ = true; +} + +void SdchDictionaryFetcher::StartFetching() { + DCHECK(task_is_pending_); + task_is_pending_ = false; + + current_fetch_.reset(new URLFetcher(fetch_queue_.front(), URLFetcher::GET, + this)); + fetch_queue_.pop(); + current_fetch_->set_request_context(Profile::GetDefaultRequestContext()); + current_fetch_->Start(); +} + +void SdchDictionaryFetcher::OnURLFetchComplete(const URLFetcher* source, + const GURL& url, + const URLRequestStatus& status, + int response_code, + const ResponseCookies& cookies, + const std::string& data) { + if (200 == response_code) + SdchManager::Global()->AddSdchDictionary(data, url); + current_fetch_.reset(NULL); + ScheduleDelayedRun(); +} |