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.h | |
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.h')
-rw-r--r-- | chrome/browser/net/sdch_dictionary_fetcher.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/chrome/browser/net/sdch_dictionary_fetcher.h b/chrome/browser/net/sdch_dictionary_fetcher.h new file mode 100644 index 0000000..34d3f28 --- /dev/null +++ b/chrome/browser/net/sdch_dictionary_fetcher.h @@ -0,0 +1,66 @@ +// 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. + +// Support modularity by calling to load a new SDCH filter dictionary. +// Note that this sort of calling can't be done in the /net directory, as it has +// no concept of the HTTP cache (which is only visible at the browser level). + +#ifndef CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_ +#define CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_ + +#include <queue> +#include <string> + +#include "base/task.h" +#include "chrome/browser/url_fetcher.h" +#include "net/base/sdch_manager.h" + +class SdchDictionaryFetcher : public URLFetcher::Delegate, + public SdchFetcher { + public: + #pragma warning(suppress: 4355) // OK to pass "this" here. + SdchDictionaryFetcher() : method_factory_(this), task_is_pending_(false) {} + virtual ~SdchDictionaryFetcher() {} + + // Implementation of SdchFetcher class. + // This method gets the requested dictionary, and then calls back into the + // SdchManager class with the dictionary's text. + virtual void Schedule(const GURL& dictionary_url); + + private: + // Delay between Schedule and actual download. + static const int kMsDelayFromRequestTillDownload = 15000; + + // Ensure the download after the above delay. + void ScheduleDelayedRun(); + + // Make sure we're processing (or waiting for) the the arrival of the next URL + // in the |fetch_queue_|. + void StartFetching(); + + // Implementation of URLFetcher::Delegate. Called after transmission + // completes (either successfully or with failure). + virtual void OnURLFetchComplete(const URLFetcher* source, + const GURL& url, + const URLRequestStatus& status, + int response_code, + const ResponseCookies& cookies, + const std::string& data); + + // A queue of URLs that are being used to download dictionaries. + std::queue<GURL> fetch_queue_; + // The currently outstanding URL fetch of a dicitonary. + // If this is null, then there is no outstanding request. + scoped_ptr<URLFetcher> current_fetch_; + + // Always spread out the dictionary fetches, so that they don't steal + // bandwidth from the actual page load. Create delayed tasks to spread out + // the download. + ScopedRunnableMethodFactory<SdchDictionaryFetcher> method_factory_; + bool task_is_pending_; + + DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); +}; + +#endif // CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_ |