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/location.h" | |
12 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
13 #include "base/single_thread_task_runner.h" | 12 #include "base/message_loop/message_loop.h" |
14 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
15 #include "base/thread_task_runner_handle.h" | |
16 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
17 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
18 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
19 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
20 #include "net/url_request/url_request_simple_job.h" | 18 #include "net/url_request/url_request_simple_job.h" |
21 #include "net/url_request/view_cache_helper.h" | 19 #include "net/url_request/view_cache_helper.h" |
22 | 20 |
23 namespace content { | 21 namespace content { |
24 namespace { | 22 namespace { |
25 | 23 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 89 |
92 scoped_refptr<Core> core_; | 90 scoped_refptr<Core> core_; |
93 base::Closure callback_; | 91 base::Closure callback_; |
94 | 92 |
95 base::WeakPtrFactory<ViewHttpCacheJob> weak_factory_; | 93 base::WeakPtrFactory<ViewHttpCacheJob> weak_factory_; |
96 | 94 |
97 DISALLOW_COPY_AND_ASSIGN(ViewHttpCacheJob); | 95 DISALLOW_COPY_AND_ASSIGN(ViewHttpCacheJob); |
98 }; | 96 }; |
99 | 97 |
100 void ViewHttpCacheJob::Start() { | 98 void ViewHttpCacheJob::Start() { |
101 base::ThreadTaskRunnerHandle::Get()->PostTask( | 99 base::MessageLoop::current()->PostTask( |
102 FROM_HERE, | 100 FROM_HERE, |
103 base::Bind(&ViewHttpCacheJob::StartAsync, weak_factory_.GetWeakPtr())); | 101 base::Bind(&ViewHttpCacheJob::StartAsync, weak_factory_.GetWeakPtr())); |
104 } | 102 } |
105 | 103 |
106 void ViewHttpCacheJob::Kill() { | 104 void ViewHttpCacheJob::Kill() { |
107 weak_factory_.InvalidateWeakPtrs(); | 105 weak_factory_.InvalidateWeakPtrs(); |
108 if (core_.get()) { | 106 if (core_.get()) { |
109 core_->Orphan(); | 107 core_->Orphan(); |
110 core_ = NULL; | 108 core_ = NULL; |
111 } | 109 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 url.host() == kChromeUINetworkViewCacheHost; | 194 url.host() == kChromeUINetworkViewCacheHost; |
197 } | 195 } |
198 | 196 |
199 // Static. | 197 // Static. |
200 net::URLRequestJob* ViewHttpCacheJobFactory::CreateJobForRequest( | 198 net::URLRequestJob* ViewHttpCacheJobFactory::CreateJobForRequest( |
201 net::URLRequest* request, net::NetworkDelegate* network_delegate) { | 199 net::URLRequest* request, net::NetworkDelegate* network_delegate) { |
202 return new ViewHttpCacheJob(request, network_delegate); | 200 return new ViewHttpCacheJob(request, network_delegate); |
203 } | 201 } |
204 | 202 |
205 } // namespace content | 203 } // namespace content |
OLD | NEW |