summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-11 02:08:34 +0000
committerrlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-11 02:08:34 +0000
commitd24fc3a01519bb8894321a53935f127face2af28 (patch)
treefc7ea4ec3050b3cb57f4bdc1353acff3d3005dcf
parente9af2580653877913a9b7973949a01c04123030f (diff)
downloadchromium_src-d24fc3a01519bb8894321a53935f127face2af28.zip
chromium_src-d24fc3a01519bb8894321a53935f127face2af28.tar.gz
chromium_src-d24fc3a01519bb8894321a53935f127face2af28.tar.bz2
Swiching SDCHDictionaryFetcher from using the deprecated GetDefaultRequestContext to using the system request context.
BUG=97760 TEST=none Review URL: http://codereview.chromium.org/9317019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121615 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/io_thread.cc6
-rw-r--r--chrome/browser/net/sdch_dictionary_fetcher.cc20
-rw-r--r--chrome/browser/net/sdch_dictionary_fetcher.h12
3 files changed, 21 insertions, 17 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index 6ad01f6..b82dc1b 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -449,7 +449,6 @@ void IOThread::Init() {
ConstructProxyScriptFetcherContext(globals_, net_log_);
sdch_manager_ = new net::SdchManager();
- sdch_manager_->set_sdch_fetcher(new SdchDictionaryFetcher);
// InitSystemRequestContext turns right around and posts a task back
// to the IO thread, so we can't let it run until we know the IO
@@ -620,4 +619,7 @@ void IOThread::InitSystemRequestContextOnIOThread() {
new net::FtpNetworkLayer(globals_->host_resolver.get()));
globals_->system_request_context =
ConstructSystemRequestContext(globals_, net_log_);
+
+ sdch_manager_->set_sdch_fetcher(
+ new SdchDictionaryFetcher(system_url_request_context_getter_.get()));
}
diff --git a/chrome/browser/net/sdch_dictionary_fetcher.cc b/chrome/browser/net/sdch_dictionary_fetcher.cc
index 9a0d374..405f5f2 100644
--- a/chrome/browser/net/sdch_dictionary_fetcher.cc
+++ b/chrome/browser/net/sdch_dictionary_fetcher.cc
@@ -9,11 +9,14 @@
#include "base/message_loop.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/common/url_fetcher.h"
+#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_status.h"
-SdchDictionaryFetcher::SdchDictionaryFetcher()
+SdchDictionaryFetcher::SdchDictionaryFetcher(
+ net::URLRequestContextGetter* context)
: ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
- task_is_pending_(false) {
+ task_is_pending_(false),
+ context_(context) {
DCHECK(CalledOnValidThread());
}
@@ -61,20 +64,11 @@ void SdchDictionaryFetcher::StartFetching() {
DCHECK(task_is_pending_);
task_is_pending_ = false;
- net::URLRequestContextGetter* context =
- Profile::Deprecated::GetDefaultRequestContext();
- if (!context) {
- // Shutdown in progress.
- // Simulate handling of all dictionary requests by clearing queue.
- while (!fetch_queue_.empty())
- fetch_queue_.pop();
- return;
- }
-
+ DCHECK(context_.get());
current_fetch_.reset(content::URLFetcher::Create(
fetch_queue_.front(), content::URLFetcher::GET, this));
fetch_queue_.pop();
- current_fetch_->SetRequestContext(context);
+ current_fetch_->SetRequestContext(context_.get());
current_fetch_->Start();
}
diff --git a/chrome/browser/net/sdch_dictionary_fetcher.h b/chrome/browser/net/sdch_dictionary_fetcher.h
index b96368f..4476557 100644
--- a/chrome/browser/net/sdch_dictionary_fetcher.h
+++ b/chrome/browser/net/sdch_dictionary_fetcher.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -20,12 +20,16 @@
#include "content/public/common/url_fetcher_delegate.h"
#include "net/base/sdch_manager.h"
+namespace net {
+class URLRequestContextGetter;
+} // namespace net
+
class SdchDictionaryFetcher
: public content::URLFetcherDelegate,
public net::SdchFetcher,
public base::NonThreadSafe {
public:
- SdchDictionaryFetcher();
+ explicit SdchDictionaryFetcher(net::URLRequestContextGetter* context);
virtual ~SdchDictionaryFetcher();
// Stop fetching dictionaries, and abandon any current URLFetcheer operations
@@ -82,6 +86,10 @@ class SdchDictionaryFetcher
// TODO(jar): Try to augment the SDCH proposal to include this restiction.
std::set<GURL> attempted_load_;
+ // Store the system_url_request_context_getter to use it when we start
+ // fetching.
+ scoped_refptr<net::URLRequestContextGetter> context_;
+
DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher);
};