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

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

Issue 8315012: base::Bind: Convert FileUtilProxy::GetFileInfoCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pipelining. 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 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 ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)),
56 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 55 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
57 blob_data_(blob_data), 56 blob_data_(blob_data),
58 file_thread_proxy_(file_thread_proxy), 57 file_thread_proxy_(file_thread_proxy),
59 item_index_(0), 58 item_index_(0),
60 total_size_(0), 59 total_size_(0),
61 current_item_offset_(0), 60 current_item_offset_(0),
62 remaining_bytes_(0), 61 remaining_bytes_(0),
63 read_buf_offset_(0), 62 read_buf_offset_(0),
64 read_buf_size_(0), 63 read_buf_size_(0),
65 read_buf_remaining_bytes_(0), 64 read_buf_remaining_bytes_(0),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 if (stream_ != NULL) { 103 if (stream_ != NULL) {
105 stream_->Close(); 104 stream_->Close();
106 stream_.reset(NULL); 105 stream_.reset(NULL);
107 } 106 }
108 } 107 }
109 108
110 void BlobURLRequestJob::Kill() { 109 void BlobURLRequestJob::Kill() {
111 CloseStream(); 110 CloseStream();
112 111
113 net::URLRequestJob::Kill(); 112 net::URLRequestJob::Kill();
114 callback_factory_.RevokeAll();
115 weak_factory_.InvalidateWeakPtrs(); 113 weak_factory_.InvalidateWeakPtrs();
116 method_factory_.RevokeAll(); 114 method_factory_.RevokeAll();
117 } 115 }
118 116
119 void BlobURLRequestJob::ResolveFile(const FilePath& file_path) { 117 void BlobURLRequestJob::ResolveFile(const FilePath& file_path) {
120 base::FileUtilProxy::GetFileInfo( 118 base::FileUtilProxy::GetFileInfo(
121 file_thread_proxy_, 119 file_thread_proxy_, file_path,
122 file_path, 120 base::Bind(&BlobURLRequestJob::DidResolve, weak_factory_.GetWeakPtr()));
123 callback_factory_.NewCallback(&BlobURLRequestJob::DidResolve));
124 } 121 }
125 122
126 void BlobURLRequestJob::DidResolve(base::PlatformFileError rv, 123 void BlobURLRequestJob::DidResolve(base::PlatformFileError rv,
127 const base::PlatformFileInfo& file_info) { 124 const base::PlatformFileInfo& file_info) {
128 // If an error occured, bail out. 125 // If an error occured, bail out.
129 if (rv == base::PLATFORM_FILE_ERROR_NOT_FOUND) { 126 if (rv == base::PLATFORM_FILE_ERROR_NOT_FOUND) {
130 NotifyFailure(net::ERR_FILE_NOT_FOUND); 127 NotifyFailure(net::ERR_FILE_NOT_FOUND);
131 return; 128 return;
132 } else if (rv != base::PLATFORM_FILE_OK) { 129 } else if (rv != base::PLATFORM_FILE_OK) {
133 NotifyFailure(net::ERR_FAILED); 130 NotifyFailure(net::ERR_FAILED);
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 // We don't support multiple range requests in one single URL request, 560 // We don't support multiple range requests in one single URL request,
564 // because we need to do multipart encoding here. 561 // because we need to do multipart encoding here.
565 // TODO(jianli): Support multipart byte range requests. 562 // TODO(jianli): Support multipart byte range requests.
566 NotifyFailure(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE); 563 NotifyFailure(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE);
567 } 564 }
568 } 565 }
569 } 566 }
570 } 567 }
571 568
572 } // namespace webkit_blob 569 } // namespace webkit_blob
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698