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

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

Issue 8231004: Remaining cleanup (base::Bind): Replacing FileUtilProxy calls with new callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 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
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 item_index_(0), 58 item_index_(0),
59 total_size_(0), 59 total_size_(0),
60 current_item_offset_(0), 60 current_item_offset_(0),
61 remaining_bytes_(0), 61 remaining_bytes_(0),
62 read_buf_offset_(0), 62 read_buf_offset_(0),
63 read_buf_size_(0), 63 read_buf_size_(0),
64 read_buf_remaining_bytes_(0), 64 read_buf_remaining_bytes_(0),
65 bytes_to_read_(0), 65 bytes_to_read_(0),
66 error_(false), 66 error_(false),
67 headers_set_(false), 67 headers_set_(false),
68 byte_range_set_(false), 68 byte_range_set_(false) {
69 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
70 DCHECK(file_thread_proxy_); 69 DCHECK(file_thread_proxy_);
71 } 70 }
72 71
73 BlobURLRequestJob::~BlobURLRequestJob() { 72 BlobURLRequestJob::~BlobURLRequestJob() {
74 // FileStream's destructor won't close it for us because we passed in our own 73 // FileStream's destructor won't close it for us because we passed in our own
75 // file handle. 74 // file handle.
76 CloseStream(); 75 CloseStream();
77 } 76 }
78 77
79 void BlobURLRequestJob::Start() { 78 void BlobURLRequestJob::Start() {
80 // Continue asynchronously. 79 // Continue asynchronously.
81 MessageLoop::current()->PostTask( 80 MessageLoop::current()->PostTask(
82 FROM_HERE, 81 FROM_HERE,
83 method_factory_.NewRunnableMethod(&BlobURLRequestJob::DidStart)); 82 base::Bind(&BlobURLRequestJob::DidStart,
83 weak_factory_.GetWeakPtr()));
84 } 84 }
85 85
86 void BlobURLRequestJob::DidStart() { 86 void BlobURLRequestJob::DidStart() {
87 // We only support GET request per the spec. 87 // We only support GET request per the spec.
88 if (request()->method() != "GET") { 88 if (request()->method() != "GET") {
89 NotifyFailure(net::ERR_METHOD_NOT_SUPPORTED); 89 NotifyFailure(net::ERR_METHOD_NOT_SUPPORTED);
90 return; 90 return;
91 } 91 }
92 92
93 // If the blob data is not present, bail out. 93 // If the blob data is not present, bail out.
(...skipping 10 matching lines...) Expand all
104 stream_->Close(); 104 stream_->Close();
105 stream_.reset(NULL); 105 stream_.reset(NULL);
106 } 106 }
107 } 107 }
108 108
109 void BlobURLRequestJob::Kill() { 109 void BlobURLRequestJob::Kill() {
110 CloseStream(); 110 CloseStream();
111 111
112 net::URLRequestJob::Kill(); 112 net::URLRequestJob::Kill();
113 weak_factory_.InvalidateWeakPtrs(); 113 weak_factory_.InvalidateWeakPtrs();
114 method_factory_.RevokeAll();
115 } 114 }
116 115
117 void BlobURLRequestJob::ResolveFile(const FilePath& file_path) { 116 void BlobURLRequestJob::ResolveFile(const FilePath& file_path) {
118 base::FileUtilProxy::GetFileInfo( 117 base::FileUtilProxy::GetFileInfo(
119 file_thread_proxy_, file_path, 118 file_thread_proxy_, file_path,
120 base::Bind(&BlobURLRequestJob::DidResolve, weak_factory_.GetWeakPtr())); 119 base::Bind(&BlobURLRequestJob::DidResolve, weak_factory_.GetWeakPtr()));
121 } 120 }
122 121
123 void BlobURLRequestJob::DidResolve(base::PlatformFileError rv, 122 void BlobURLRequestJob::DidResolve(base::PlatformFileError rv,
124 const base::PlatformFileInfo& file_info) { 123 const base::PlatformFileInfo& file_info) {
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 // We don't support multiple range requests in one single URL request, 559 // We don't support multiple range requests in one single URL request,
561 // because we need to do multipart encoding here. 560 // because we need to do multipart encoding here.
562 // TODO(jianli): Support multipart byte range requests. 561 // TODO(jianli): Support multipart byte range requests.
563 NotifyFailure(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE); 562 NotifyFailure(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE);
564 } 563 }
565 } 564 }
566 } 565 }
567 } 566 }
568 567
569 } // namespace webkit_blob 568 } // namespace webkit_blob
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698