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" |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace content { | 21 namespace content { |
22 namespace { | 22 namespace { |
23 | 23 |
24 // A job subclass that dumps an HTTP cache entry. | 24 // A job subclass that dumps an HTTP cache entry. |
25 class ViewHttpCacheJob : public net::URLRequestJob { | 25 class ViewHttpCacheJob : public net::URLRequestJob { |
26 public: | 26 public: |
27 ViewHttpCacheJob(net::URLRequest* request, | 27 ViewHttpCacheJob(net::URLRequest* request, |
28 net::NetworkDelegate* network_delegate) | 28 net::NetworkDelegate* network_delegate) |
29 : net::URLRequestJob(request, network_delegate), | 29 : net::URLRequestJob(request, network_delegate), |
30 core_(new Core), | 30 core_(new Core), |
31 weak_factory_(this), | |
32 callback_(base::Bind(&ViewHttpCacheJob::OnStartCompleted, | 31 callback_(base::Bind(&ViewHttpCacheJob::OnStartCompleted, |
33 base::Unretained(this))) { | 32 base::Unretained(this))), |
| 33 weak_factory_(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; |
39 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE{ | 39 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE{ |
40 return core_->GetMimeType(mime_type); | 40 return core_->GetMimeType(mime_type); |
41 } | 41 } |
42 virtual bool GetCharset(std::string* charset) OVERRIDE{ | 42 virtual bool GetCharset(std::string* charset) OVERRIDE{ |
43 return core_->GetCharset(charset); | 43 return core_->GetCharset(charset); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 DISALLOW_COPY_AND_ASSIGN(Core); | 83 DISALLOW_COPY_AND_ASSIGN(Core); |
84 }; | 84 }; |
85 | 85 |
86 virtual ~ViewHttpCacheJob() {} | 86 virtual ~ViewHttpCacheJob() {} |
87 | 87 |
88 void StartAsync(); | 88 void StartAsync(); |
89 void OnStartCompleted(); | 89 void OnStartCompleted(); |
90 | 90 |
91 scoped_refptr<Core> core_; | 91 scoped_refptr<Core> core_; |
| 92 base::Closure callback_; |
| 93 |
92 base::WeakPtrFactory<ViewHttpCacheJob> weak_factory_; | 94 base::WeakPtrFactory<ViewHttpCacheJob> weak_factory_; |
93 base::Closure callback_; | |
94 | 95 |
95 DISALLOW_COPY_AND_ASSIGN(ViewHttpCacheJob); | 96 DISALLOW_COPY_AND_ASSIGN(ViewHttpCacheJob); |
96 }; | 97 }; |
97 | 98 |
98 void ViewHttpCacheJob::Start() { | 99 void ViewHttpCacheJob::Start() { |
99 base::MessageLoop::current()->PostTask( | 100 base::MessageLoop::current()->PostTask( |
100 FROM_HERE, | 101 FROM_HERE, |
101 base::Bind(&ViewHttpCacheJob::StartAsync, weak_factory_.GetWeakPtr())); | 102 base::Bind(&ViewHttpCacheJob::StartAsync, weak_factory_.GetWeakPtr())); |
102 } | 103 } |
103 | 104 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 url.host() == kChromeUINetworkViewCacheHost; | 195 url.host() == kChromeUINetworkViewCacheHost; |
195 } | 196 } |
196 | 197 |
197 // Static. | 198 // Static. |
198 net::URLRequestJob* ViewHttpCacheJobFactory::CreateJobForRequest( | 199 net::URLRequestJob* ViewHttpCacheJobFactory::CreateJobForRequest( |
199 net::URLRequest* request, net::NetworkDelegate* network_delegate) { | 200 net::URLRequest* request, net::NetworkDelegate* network_delegate) { |
200 return new ViewHttpCacheJob(request, network_delegate); | 201 return new ViewHttpCacheJob(request, network_delegate); |
201 } | 202 } |
202 | 203 |
203 } // namespace content | 204 } // namespace content |
OLD | NEW |