OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/dom_ui/chrome_url_data_manager.h" | 5 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 // calls back once the data is available. | 36 // calls back once the data is available. |
37 class URLRequestChromeJob : public URLRequestJob { | 37 class URLRequestChromeJob : public URLRequestJob { |
38 public: | 38 public: |
39 explicit URLRequestChromeJob(URLRequest* request); | 39 explicit URLRequestChromeJob(URLRequest* request); |
40 virtual ~URLRequestChromeJob(); | 40 virtual ~URLRequestChromeJob(); |
41 | 41 |
42 // URLRequestJob implementation. | 42 // URLRequestJob implementation. |
43 virtual void Start(); | 43 virtual void Start(); |
44 virtual void Kill(); | 44 virtual void Kill(); |
45 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); | 45 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); |
46 virtual bool GetMimeType(std::string* mime_type); | 46 virtual bool GetMimeType(std::string* mime_type) const; |
47 | 47 |
48 // Called by ChromeURLDataManager to notify us that the data blob is ready | 48 // Called by ChromeURLDataManager to notify us that the data blob is ready |
49 // for us. | 49 // for us. |
50 void DataAvailable(RefCountedBytes* bytes); | 50 void DataAvailable(RefCountedBytes* bytes); |
51 | 51 |
52 void SetMimeType(const std::string& mime_type) { | 52 void SetMimeType(const std::string& mime_type) { |
53 mime_type_ = mime_type; | 53 mime_type_ = mime_type; |
54 } | 54 } |
55 | 55 |
56 private: | 56 private: |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 // Start reading asynchronously so that all error reporting and data | 271 // Start reading asynchronously so that all error reporting and data |
272 // callbacks happen as they would for network requests. | 272 // callbacks happen as they would for network requests. |
273 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | 273 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( |
274 this, &URLRequestChromeJob::StartAsync)); | 274 this, &URLRequestChromeJob::StartAsync)); |
275 } | 275 } |
276 | 276 |
277 void URLRequestChromeJob::Kill() { | 277 void URLRequestChromeJob::Kill() { |
278 chrome_url_data_manager.RemoveRequest(this); | 278 chrome_url_data_manager.RemoveRequest(this); |
279 } | 279 } |
280 | 280 |
281 bool URLRequestChromeJob::GetMimeType(std::string* mime_type) { | 281 bool URLRequestChromeJob::GetMimeType(std::string* mime_type) const { |
282 *mime_type = mime_type_; | 282 *mime_type = mime_type_; |
283 return !mime_type_.empty(); | 283 return !mime_type_.empty(); |
284 } | 284 } |
285 | 285 |
286 void URLRequestChromeJob::DataAvailable(RefCountedBytes* bytes) { | 286 void URLRequestChromeJob::DataAvailable(RefCountedBytes* bytes) { |
287 if (bytes) { | 287 if (bytes) { |
288 // The request completed, and we have all the data. | 288 // The request completed, and we have all the data. |
289 // Clear any IO pending status. | 289 // Clear any IO pending status. |
290 SetStatus(URLRequestStatus()); | 290 SetStatus(URLRequestStatus()); |
291 | 291 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 } | 341 } |
342 } | 342 } |
343 | 343 |
344 URLRequestChromeFileJob::URLRequestChromeFileJob(URLRequest* request, | 344 URLRequestChromeFileJob::URLRequestChromeFileJob(URLRequest* request, |
345 const FilePath& path) | 345 const FilePath& path) |
346 : URLRequestFileJob(request, path) { | 346 : URLRequestFileJob(request, path) { |
347 } | 347 } |
348 | 348 |
349 URLRequestChromeFileJob::~URLRequestChromeFileJob() { } | 349 URLRequestChromeFileJob::~URLRequestChromeFileJob() { } |
350 | 350 |
OLD | NEW |