OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/net/view_http_cache_job_factory.h" | 5 #include "content/browser/net/view_http_cache_job_factory.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
17 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
18 #include "net/url_request/url_request_context.h" | |
19 #include "net/url_request/url_request_simple_job.h" | 18 #include "net/url_request/url_request_simple_job.h" |
20 #include "net/url_request/view_cache_helper.h" | 19 #include "net/url_request/view_cache_helper.h" |
21 | 20 |
22 namespace { | 21 namespace { |
23 | 22 |
24 // A job subclass that dumps an HTTP cache entry. | 23 // A job subclass that dumps an HTTP cache entry. |
25 class ViewHttpCacheJob : public net::URLRequestJob { | 24 class ViewHttpCacheJob : public net::URLRequestJob { |
26 public: | 25 public: |
27 explicit ViewHttpCacheJob(net::URLRequest* request) | 26 ViewHttpCacheJob(net::URLRequest* request, |
28 : net::URLRequestJob(request, request->context()->network_delegate()), | 27 net::NetworkDelegate* network_delegate) |
| 28 : net::URLRequestJob(request, network_delegate), |
29 core_(new Core), | 29 core_(new Core), |
30 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 30 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
31 ALLOW_THIS_IN_INITIALIZER_LIST( | 31 ALLOW_THIS_IN_INITIALIZER_LIST( |
32 callback_(base::Bind(&ViewHttpCacheJob::OnStartCompleted, | 32 callback_(base::Bind(&ViewHttpCacheJob::OnStartCompleted, |
33 base::Unretained(this)))) { | 33 base::Unretained(this)))) { |
34 } | 34 } |
35 | 35 |
36 // net::URLRequestJob implementation. | 36 // net::URLRequestJob implementation. |
37 virtual void Start() OVERRIDE; | 37 virtual void Start() OVERRIDE; |
38 virtual void Kill() OVERRIDE; | 38 virtual void Kill() OVERRIDE; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } // namespace. | 190 } // namespace. |
191 | 191 |
192 // Static. | 192 // Static. |
193 bool ViewHttpCacheJobFactory::IsSupportedURL(const GURL& url) { | 193 bool ViewHttpCacheJobFactory::IsSupportedURL(const GURL& url) { |
194 return url.SchemeIs(chrome::kChromeUIScheme) && | 194 return url.SchemeIs(chrome::kChromeUIScheme) && |
195 url.host() == chrome::kChromeUINetworkViewCacheHost; | 195 url.host() == chrome::kChromeUINetworkViewCacheHost; |
196 } | 196 } |
197 | 197 |
198 // Static. | 198 // Static. |
199 net::URLRequestJob* ViewHttpCacheJobFactory::CreateJobForRequest( | 199 net::URLRequestJob* ViewHttpCacheJobFactory::CreateJobForRequest( |
200 net::URLRequest* request) { | 200 net::URLRequest* request, net::NetworkDelegate* network_delegate) { |
201 return new ViewHttpCacheJob(request); | 201 return new ViewHttpCacheJob(request, network_delegate); |
202 } | 202 } |
OLD | NEW |