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 16 matching lines...) Expand all Loading... |
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 callback_(base::Bind(&ViewHttpCacheJob::OnStartCompleted, | 31 callback_(base::Bind(&ViewHttpCacheJob::OnStartCompleted, |
32 base::Unretained(this))), | 32 base::Unretained(this))), |
33 weak_factory_(this) { | 33 weak_factory_(this) { |
34 } | 34 } |
35 | 35 |
36 // net::URLRequestJob implementation. | 36 // net::URLRequestJob implementation. |
37 virtual void Start() override; | 37 void Start() override; |
38 virtual void Kill() override; | 38 void Kill() override; |
39 virtual bool GetMimeType(std::string* mime_type) const override{ | 39 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 bool GetCharset(std::string* charset) override { |
43 return core_->GetCharset(charset); | 43 return core_->GetCharset(charset); |
44 } | 44 } |
45 virtual bool ReadRawData(net::IOBuffer* buf, | 45 bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override { |
46 int buf_size, int *bytes_read) override{ | |
47 return core_->ReadRawData(buf, buf_size, bytes_read); | 46 return core_->ReadRawData(buf, buf_size, bytes_read); |
48 } | 47 } |
49 | 48 |
50 private: | 49 private: |
51 class Core : public base::RefCounted<Core> { | 50 class Core : public base::RefCounted<Core> { |
52 public: | 51 public: |
53 Core() | 52 Core() |
54 : data_offset_(0), | 53 : data_offset_(0), |
55 callback_(base::Bind(&Core::OnIOComplete, this)) { | 54 callback_(base::Bind(&Core::OnIOComplete, this)) { |
56 } | 55 } |
(...skipping 19 matching lines...) Expand all Loading... |
76 | 75 |
77 std::string data_; | 76 std::string data_; |
78 int data_offset_; | 77 int data_offset_; |
79 net::ViewCacheHelper cache_helper_; | 78 net::ViewCacheHelper cache_helper_; |
80 net::CompletionCallback callback_; | 79 net::CompletionCallback callback_; |
81 base::Closure user_callback_; | 80 base::Closure user_callback_; |
82 | 81 |
83 DISALLOW_COPY_AND_ASSIGN(Core); | 82 DISALLOW_COPY_AND_ASSIGN(Core); |
84 }; | 83 }; |
85 | 84 |
86 virtual ~ViewHttpCacheJob() {} | 85 ~ViewHttpCacheJob() override {} |
87 | 86 |
88 void StartAsync(); | 87 void StartAsync(); |
89 void OnStartCompleted(); | 88 void OnStartCompleted(); |
90 | 89 |
91 scoped_refptr<Core> core_; | 90 scoped_refptr<Core> core_; |
92 base::Closure callback_; | 91 base::Closure callback_; |
93 | 92 |
94 base::WeakPtrFactory<ViewHttpCacheJob> weak_factory_; | 93 base::WeakPtrFactory<ViewHttpCacheJob> weak_factory_; |
95 | 94 |
96 DISALLOW_COPY_AND_ASSIGN(ViewHttpCacheJob); | 95 DISALLOW_COPY_AND_ASSIGN(ViewHttpCacheJob); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 url.host() == kChromeUINetworkViewCacheHost; | 194 url.host() == kChromeUINetworkViewCacheHost; |
196 } | 195 } |
197 | 196 |
198 // Static. | 197 // Static. |
199 net::URLRequestJob* ViewHttpCacheJobFactory::CreateJobForRequest( | 198 net::URLRequestJob* ViewHttpCacheJobFactory::CreateJobForRequest( |
200 net::URLRequest* request, net::NetworkDelegate* network_delegate) { | 199 net::URLRequest* request, net::NetworkDelegate* network_delegate) { |
201 return new ViewHttpCacheJob(request, network_delegate); | 200 return new ViewHttpCacheJob(request, network_delegate); |
202 } | 201 } |
203 | 202 |
204 } // namespace content | 203 } // namespace content |
OLD | NEW |