Commit eee45130 authored by rdsmith@chromium.org's avatar rdsmith@chromium.org

Move of SdchDictionaryFetcher to net.

BUG=385744
R=jar@chromium.org

Review URL: https://codereview.chromium.org/341553005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278587 0039d316-1c4b-4281-b951-d872f2087c98
parent 7f2b78ed
......@@ -36,7 +36,6 @@
#include "chrome/browser/net/dns_probe_service.h"
#include "chrome/browser/net/pref_proxy_config_tracker.h"
#include "chrome/browser/net/proxy_service_factory.h"
#include "chrome/browser/net/sdch_dictionary_fetcher.h"
#include "chrome/common/chrome_content_client.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
......
......@@ -19,7 +19,6 @@
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/net/chrome_network_delegate.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/net/sdch_dictionary_fetcher.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
......@@ -29,6 +28,7 @@
#include "content/public/browser/resource_context.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "net/base/sdch_dictionary_fetcher.h"
#include "net/base/sdch_manager.h"
#include "net/ftp/ftp_network_layer.h"
#include "net/http/http_cache.h"
......@@ -256,7 +256,7 @@ void OffTheRecordProfileIOData::InitializeInternal(
// Setup the SDCHManager for this profile.
sdch_manager_.reset(new net::SdchManager);
sdch_manager_->set_sdch_fetcher(
new SdchDictionaryFetcher(
new net::SdchDictionaryFetcher(
sdch_manager_.get(),
// SdchDictionaryFetcher takes a reference to the Getter, and
// hence implicitly takes ownership.
......
......@@ -26,7 +26,6 @@
#include "chrome/browser/net/cookie_store_util.h"
#include "chrome/browser/net/http_server_properties_manager.h"
#include "chrome/browser/net/predictor.h"
#include "chrome/browser/net/sdch_dictionary_fetcher.h"
#include "chrome/browser/net/sqlite_server_bound_cert_store.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_constants.h"
......@@ -43,6 +42,7 @@
#include "extensions/browser/extension_protocols.h"
#include "extensions/common/constants.h"
#include "net/base/cache_type.h"
#include "net/base/sdch_dictionary_fetcher.h"
#include "net/base/sdch_manager.h"
#include "net/ftp/ftp_network_layer.h"
#include "net/http/http_cache.h"
......@@ -534,7 +534,7 @@ void ProfileImplIOData::InitializeInternal(
// Setup the SDCHManager for this profile.
sdch_manager_.reset(new net::SdchManager);
sdch_manager_->set_sdch_fetcher(
new SdchDictionaryFetcher(
new net::SdchDictionaryFetcher(
sdch_manager_.get(),
// SdchDictionaryFetcher takes a reference to the Getter, and
// hence implicitly takes ownership.
......
......@@ -1282,8 +1282,6 @@
'browser/net/proxy_service_factory.h',
'browser/net/referrer.cc',
'browser/net/referrer.h',
'browser/net/sdch_dictionary_fetcher.cc',
'browser/net/sdch_dictionary_fetcher.h',
'browser/net/service_providers_win.cc',
'browser/net/service_providers_win.h',
'browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.cc',
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2014 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 "net/base/sdch_dictionary_fetcher.h"
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/message_loop/message_loop.h"
#include "chrome/browser/profiles/profile.h"
#include "net/base/load_flags.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_status.h"
namespace net {
SdchDictionaryFetcher::SdchDictionaryFetcher(
net::SdchManager* manager,
net::URLRequestContextGetter* context)
SdchManager* manager,
URLRequestContextGetter* context)
: manager_(manager),
weak_factory_(this),
task_is_pending_(false),
......@@ -35,13 +36,13 @@ void SdchDictionaryFetcher::Schedule(const GURL& dictionary_url) {
// and get a different dictionary, but there is no reason to have it in the
// queue twice at one time.
if (!fetch_queue_.empty() && fetch_queue_.back() == dictionary_url) {
net::SdchManager::SdchErrorRecovery(
net::SdchManager::DICTIONARY_ALREADY_SCHEDULED_TO_DOWNLOAD);
SdchManager::SdchErrorRecovery(
SdchManager::DICTIONARY_ALREADY_SCHEDULED_TO_DOWNLOAD);
return;
}
if (attempted_load_.find(dictionary_url) != attempted_load_.end()) {
net::SdchManager::SdchErrorRecovery(
net::SdchManager::DICTIONARY_ALREADY_TRIED_TO_DOWNLOAD);
SdchManager::SdchErrorRecovery(
SdchManager::DICTIONARY_ALREADY_TRIED_TO_DOWNLOAD);
return;
}
attempted_load_.insert(dictionary_url);
......@@ -79,20 +80,20 @@ void SdchDictionaryFetcher::StartFetching() {
return;
DCHECK(context_.get());
current_fetch_.reset(net::URLFetcher::Create(
fetch_queue_.front(), net::URLFetcher::GET, this));
current_fetch_.reset(URLFetcher::Create(
fetch_queue_.front(), URLFetcher::GET, this));
fetch_queue_.pop();
current_fetch_->SetRequestContext(context_.get());
current_fetch_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
net::LOAD_DO_NOT_SAVE_COOKIES);
current_fetch_->SetLoadFlags(LOAD_DO_NOT_SEND_COOKIES |
LOAD_DO_NOT_SAVE_COOKIES);
current_fetch_->Start();
}
void SdchDictionaryFetcher::OnURLFetchComplete(
const net::URLFetcher* source) {
const URLFetcher* source) {
DCHECK(CalledOnValidThread());
if ((200 == source->GetResponseCode()) &&
(source->GetStatus().status() == net::URLRequestStatus::SUCCESS)) {
(source->GetStatus().status() == URLRequestStatus::SUCCESS)) {
std::string data;
source->GetResponseAsString(&data);
manager_->AddSdchDictionary(data, source->GetURL());
......@@ -100,3 +101,5 @@ void SdchDictionaryFetcher::OnURLFetchComplete(
current_fetch_.reset(NULL);
ScheduleDelayedRun();
}
} // namespace net
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2014 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.
......@@ -6,8 +6,8 @@
// 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_
#ifndef NET_BASE_SDCH_DICTIONARY_FETCHER_H_
#define NET_BASE_SDCH_DICTIONARY_FETCHER_H_
#include <queue>
#include <set>
......@@ -20,20 +20,20 @@
#include "net/url_request/url_fetcher_delegate.h"
namespace net {
class URLFetcher;
class URLRequestContextGetter;
} // namespace net
class SdchDictionaryFetcher
: public net::URLFetcherDelegate,
public net::SdchFetcher,
class NET_EXPORT SdchDictionaryFetcher
: public URLFetcherDelegate,
public SdchFetcher,
public base::NonThreadSafe {
public:
// Consumer must guarantee that the SdchManager pointer outlives
// this object. The current implementation guarantees this by
// the SdchManager owning this object.
SdchDictionaryFetcher(net::SdchManager* manager,
net::URLRequestContextGetter* context);
SdchDictionaryFetcher(SdchManager* manager,
URLRequestContextGetter* context);
virtual ~SdchDictionaryFetcher();
// Implementation of SdchFetcher class.
......@@ -54,17 +54,17 @@ class SdchDictionaryFetcher
// in the |fetch_queue_|.
void StartFetching();
// Implementation of net::URLFetcherDelegate. Called after transmission
// Implementation of URLFetcherDelegate. Called after transmission
// completes (either successfully or with failure).
virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE;
net::SdchManager* const manager_;
SdchManager* const manager_;
// 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<net::URLFetcher> current_fetch_;
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
......@@ -89,9 +89,11 @@ class SdchDictionaryFetcher
// Store the system_url_request_context_getter to use it when we start
// fetching.
scoped_refptr<net::URLRequestContextGetter> context_;
scoped_refptr<URLRequestContextGetter> context_;
DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher);
};
#endif // CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_
} // namespace net
#endif // NET_BASE_SDCH_DICTIONARY_FETCHER_H_
......@@ -40,7 +40,7 @@ namespace net {
// A browser may register a fetcher that is used by the dictionary managers to
// get data from a specified URL. This allows us to use very high level browser
// functionality in this base (when the functionaity can be provided).
class SdchFetcher {
class NET_EXPORT SdchFetcher {
public:
SdchFetcher() {}
virtual ~SdchFetcher() {}
......
......@@ -253,6 +253,8 @@
'base/priority_queue.h',
'base/request_priority.cc',
'base/request_priority.h',
'base/sdch_dictionary_fetcher.cc',
'base/sdch_dictionary_fetcher.h',
'base/sdch_manager.cc',
'base/sdch_manager.h',
'base/static_cookie_policy.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment