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

Side by Side Diff: webkit/fileapi/file_system_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/fileapi/file_system_url_request_job.h" 5 #include "webkit/fileapi/file_system_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_proxy.h" 10 #include "base/file_util_proxy.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 scoped_refptr<FileSystemURLRequestJob> job_; 99 scoped_refptr<FileSystemURLRequestJob> job_;
100 DISALLOW_COPY_AND_ASSIGN(CallbackDispatcher); 100 DISALLOW_COPY_AND_ASSIGN(CallbackDispatcher);
101 }; 101 };
102 102
103 FileSystemURLRequestJob::FileSystemURLRequestJob( 103 FileSystemURLRequestJob::FileSystemURLRequestJob(
104 URLRequest* request, FileSystemContext* file_system_context, 104 URLRequest* request, FileSystemContext* file_system_context,
105 scoped_refptr<base::MessageLoopProxy> file_thread_proxy) 105 scoped_refptr<base::MessageLoopProxy> file_thread_proxy)
106 : URLRequestJob(request), 106 : URLRequestJob(request),
107 file_system_context_(file_system_context), 107 file_system_context_(file_system_context),
108 file_thread_proxy_(file_thread_proxy), 108 file_thread_proxy_(file_thread_proxy),
109 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
110 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 109 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
111 stream_(NULL), 110 stream_(NULL),
112 is_directory_(false), 111 is_directory_(false),
113 remaining_bytes_(0) { 112 remaining_bytes_(0) {
114 } 113 }
115 114
116 FileSystemURLRequestJob::~FileSystemURLRequestJob() { 115 FileSystemURLRequestJob::~FileSystemURLRequestJob() {
117 // Since we use the two-arg constructor of FileStream, we need to call Close() 116 // Since we use the two-arg constructor of FileStream, we need to call Close()
118 // manually: ~FileStream won't call it for us. 117 // manually: ~FileStream won't call it for us.
119 if (stream_ != NULL) 118 if (stream_ != NULL)
120 stream_->Close(); 119 stream_->Close();
121 } 120 }
122 121
123 void FileSystemURLRequestJob::Start() { 122 void FileSystemURLRequestJob::Start() {
124 MessageLoop::current()->PostTask(FROM_HERE, 123 MessageLoop::current()->PostTask(
125 method_factory_.NewRunnableMethod( 124 FROM_HERE,
126 &FileSystemURLRequestJob::StartAsync)); 125 base::Bind(&FileSystemURLRequestJob::StartAsync,
126 weak_factory_.GetWeakPtr()));
127 } 127 }
128 128
129 void FileSystemURLRequestJob::Kill() { 129 void FileSystemURLRequestJob::Kill() {
130 if (stream_ != NULL) { 130 if (stream_ != NULL) {
131 stream_->Close(); 131 stream_->Close();
132 stream_.reset(NULL); 132 stream_.reset(NULL);
133 } 133 }
134 URLRequestJob::Kill(); 134 URLRequestJob::Kill();
135 method_factory_.RevokeAll();
136 weak_factory_.InvalidateWeakPtrs(); 135 weak_factory_.InvalidateWeakPtrs();
137 } 136 }
138 137
139 bool FileSystemURLRequestJob::ReadRawData(net::IOBuffer* dest, int dest_size, 138 bool FileSystemURLRequestJob::ReadRawData(net::IOBuffer* dest, int dest_size,
140 int *bytes_read) { 139 int *bytes_read) {
141 DCHECK_NE(dest_size, 0); 140 DCHECK_NE(dest_size, 0);
142 DCHECK(bytes_read); 141 DCHECK(bytes_read);
143 DCHECK_GE(remaining_bytes_, 0); 142 DCHECK_GE(remaining_bytes_, 0);
144 143
145 if (stream_ == NULL) 144 if (stream_ == NULL)
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 307 }
309 308
310 return false; 309 return false;
311 } 310 }
312 311
313 void FileSystemURLRequestJob::NotifyFailed(int rv) { 312 void FileSystemURLRequestJob::NotifyFailed(int rv) {
314 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); 313 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
315 } 314 }
316 315
317 } // namespace fileapi 316 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698