Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: webkit/blob/blob_url_request_job.cc

Issue 8311010: base::Bind: Convert FileUtilProxy::CreateOrOpenCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/blob/blob_url_request_job.h ('k') | webkit/fileapi/file_system_file_util_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/blob/blob_url_request_job.h" 5 #include "webkit/blob/blob_url_request_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 static const int kFileOpenFlags = base::PLATFORM_FILE_OPEN | 46 static const int kFileOpenFlags = base::PLATFORM_FILE_OPEN |
47 base::PLATFORM_FILE_READ | 47 base::PLATFORM_FILE_READ |
48 base::PLATFORM_FILE_ASYNC; 48 base::PLATFORM_FILE_ASYNC;
49 49
50 BlobURLRequestJob::BlobURLRequestJob( 50 BlobURLRequestJob::BlobURLRequestJob(
51 net::URLRequest* request, 51 net::URLRequest* request,
52 BlobData* blob_data, 52 BlobData* blob_data,
53 base::MessageLoopProxy* file_thread_proxy) 53 base::MessageLoopProxy* file_thread_proxy)
54 : net::URLRequestJob(request), 54 : net::URLRequestJob(request),
55 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 55 ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)),
56 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
56 blob_data_(blob_data), 57 blob_data_(blob_data),
57 file_thread_proxy_(file_thread_proxy), 58 file_thread_proxy_(file_thread_proxy),
58 item_index_(0), 59 item_index_(0),
59 total_size_(0), 60 total_size_(0),
60 current_item_offset_(0), 61 current_item_offset_(0),
61 remaining_bytes_(0), 62 remaining_bytes_(0),
62 read_buf_offset_(0), 63 read_buf_offset_(0),
63 read_buf_size_(0), 64 read_buf_size_(0),
64 read_buf_remaining_bytes_(0), 65 read_buf_remaining_bytes_(0),
65 bytes_to_read_(0), 66 bytes_to_read_(0),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 stream_->Close(); 105 stream_->Close();
105 stream_.reset(NULL); 106 stream_.reset(NULL);
106 } 107 }
107 } 108 }
108 109
109 void BlobURLRequestJob::Kill() { 110 void BlobURLRequestJob::Kill() {
110 CloseStream(); 111 CloseStream();
111 112
112 net::URLRequestJob::Kill(); 113 net::URLRequestJob::Kill();
113 callback_factory_.RevokeAll(); 114 callback_factory_.RevokeAll();
115 weak_factory_.InvalidateWeakPtrs();
114 method_factory_.RevokeAll(); 116 method_factory_.RevokeAll();
115 } 117 }
116 118
117 void BlobURLRequestJob::ResolveFile(const FilePath& file_path) { 119 void BlobURLRequestJob::ResolveFile(const FilePath& file_path) {
118 base::FileUtilProxy::GetFileInfo( 120 base::FileUtilProxy::GetFileInfo(
119 file_thread_proxy_, 121 file_thread_proxy_,
120 file_path, 122 file_path,
121 callback_factory_.NewCallback(&BlobURLRequestJob::DidResolve)); 123 callback_factory_.NewCallback(&BlobURLRequestJob::DidResolve));
122 } 124 }
123 125
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 return true; 311 return true;
310 } 312 }
311 313
312 bool BlobURLRequestJob::DispatchReadFile(const BlobData::Item& item) { 314 bool BlobURLRequestJob::DispatchReadFile(const BlobData::Item& item) {
313 // If the stream already exists, keep reading from it. 315 // If the stream already exists, keep reading from it.
314 if (stream_ != NULL) 316 if (stream_ != NULL)
315 return ReadFile(item); 317 return ReadFile(item);
316 318
317 base::FileUtilProxy::CreateOrOpen( 319 base::FileUtilProxy::CreateOrOpen(
318 file_thread_proxy_, item.file_path(), kFileOpenFlags, 320 file_thread_proxy_, item.file_path(), kFileOpenFlags,
319 callback_factory_.NewCallback(&BlobURLRequestJob::DidOpen)); 321 base::Bind(&BlobURLRequestJob::DidOpen, weak_factory_.GetWeakPtr()));
320 SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0)); 322 SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0));
321 return false; 323 return false;
322 } 324 }
323 325
324 void BlobURLRequestJob::DidOpen(base::PlatformFileError rv, 326 void BlobURLRequestJob::DidOpen(base::PlatformFileError rv,
325 base::PassPlatformFile file, 327 base::PassPlatformFile file,
326 bool created) { 328 bool created) {
327 if (rv != base::PLATFORM_FILE_OK) { 329 if (rv != base::PLATFORM_FILE_OK) {
328 NotifyFailure(net::ERR_FAILED); 330 NotifyFailure(net::ERR_FAILED);
329 return; 331 return;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 // We don't support multiple range requests in one single URL request, 563 // We don't support multiple range requests in one single URL request,
562 // because we need to do multipart encoding here. 564 // because we need to do multipart encoding here.
563 // TODO(jianli): Support multipart byte range requests. 565 // TODO(jianli): Support multipart byte range requests.
564 NotifyFailure(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE); 566 NotifyFailure(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE);
565 } 567 }
566 } 568 }
567 } 569 }
568 } 570 }
569 571
570 } // namespace webkit_blob 572 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « webkit/blob/blob_url_request_job.h ('k') | webkit/fileapi/file_system_file_util_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698