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

Side by Side Diff: webkit/tools/test_shell/simple_file_writer.cc

Issue 6767010: More filesystem cleanup: convert URL-encoded-as-FilePath to actual URL, where (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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/tools/test_shell/simple_file_writer.h ('k') | no next file » | 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/tools/test_shell/simple_file_writer.h" 5 #include "webkit/tools/test_shell/simple_file_writer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "net/url_request/url_request_context.h" 9 #include "net/url_request/url_request_context.h"
10 #include "webkit/fileapi/file_system_callback_dispatcher.h" 10 #include "webkit/fileapi/file_system_callback_dispatcher.h"
(...skipping 27 matching lines...) Expand all
38 file_system_context_(file_system_context) { 38 file_system_context_(file_system_context) {
39 // The IO thread needs to be running for this class to work. 39 // The IO thread needs to be running for this class to work.
40 SimpleResourceLoaderBridge::EnsureIOThread(); 40 SimpleResourceLoaderBridge::EnsureIOThread();
41 io_thread_ = SimpleResourceLoaderBridge::GetIoThread(); 41 io_thread_ = SimpleResourceLoaderBridge::GetIoThread();
42 main_thread_ = base::MessageLoopProxy::CreateForCurrentThread(); 42 main_thread_ = base::MessageLoopProxy::CreateForCurrentThread();
43 } 43 }
44 44
45 virtual ~IOThreadProxy() { 45 virtual ~IOThreadProxy() {
46 } 46 }
47 47
48 void Truncate(const FilePath& path, int64 offset) { 48 void Truncate(const GURL& path, int64 offset) {
49 if (!io_thread_->BelongsToCurrentThread()) { 49 if (!io_thread_->BelongsToCurrentThread()) {
50 io_thread_->PostTask(FROM_HERE, NewRunnableMethod( 50 io_thread_->PostTask(FROM_HERE, NewRunnableMethod(
51 this, &IOThreadProxy::Truncate, path, offset)); 51 this, &IOThreadProxy::Truncate, path, offset));
52 return; 52 return;
53 } 53 }
54 DCHECK(!operation_); 54 DCHECK(!operation_);
55 operation_ = GetNewOperation(); 55 operation_ = GetNewOperation();
56 operation_->Truncate(path, offset); 56 operation_->Truncate(path, offset);
57 } 57 }
58 58
59 void Write(const FilePath& path, const GURL& blob_url, int64 offset) { 59 void Write(const GURL& path, const GURL& blob_url, int64 offset) {
60 if (!io_thread_->BelongsToCurrentThread()) { 60 if (!io_thread_->BelongsToCurrentThread()) {
61 io_thread_->PostTask(FROM_HERE, NewRunnableMethod( 61 io_thread_->PostTask(FROM_HERE, NewRunnableMethod(
62 this, &IOThreadProxy::Write, path, blob_url, offset)); 62 this, &IOThreadProxy::Write, path, blob_url, offset));
63 return; 63 return;
64 } 64 }
65 DCHECK(request_context_); 65 DCHECK(request_context_);
66 DCHECK(!operation_); 66 DCHECK(!operation_);
67 operation_ = GetNewOperation(); 67 operation_ = GetNewOperation();
68 operation_->Write(request_context_, path, blob_url, offset); 68 operation_->Write(request_context_, path, blob_url, offset);
69 } 69 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 112
113 virtual void DidReadDirectory( 113 virtual void DidReadDirectory(
114 const std::vector<base::FileUtilProxy::Entry>& entries, 114 const std::vector<base::FileUtilProxy::Entry>& entries,
115 bool has_more) { 115 bool has_more) {
116 NOTREACHED(); 116 NOTREACHED();
117 } 117 }
118 118
119 virtual void DidOpenFileSystem( 119 virtual void DidOpenFileSystem(
120 const std::string& name, 120 const std::string& name,
121 const FilePath& root_path) { 121 const GURL& root) {
122 NOTREACHED(); 122 NOTREACHED();
123 } 123 }
124 124
125 scoped_refptr<IOThreadProxy> proxy_; 125 scoped_refptr<IOThreadProxy> proxy_;
126 }; 126 };
127 127
128 FileSystemOperation* GetNewOperation() { 128 FileSystemOperation* GetNewOperation() {
129 // The FileSystemOperation takes ownership of the CallbackDispatcher. 129 // The FileSystemOperation takes ownership of the CallbackDispatcher.
130 return new FileSystemOperation(new CallbackDispatcher(this), 130 return new FileSystemOperation(new CallbackDispatcher(this),
131 io_thread_, file_system_context_.get(), 131 io_thread_, file_system_context_.get(),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 base::WeakPtr<SimpleFileWriter> simple_writer_; 174 base::WeakPtr<SimpleFileWriter> simple_writer_;
175 175
176 // Only used on the io thread. 176 // Only used on the io thread.
177 FileSystemOperation* operation_; 177 FileSystemOperation* operation_;
178 178
179 scoped_refptr<FileSystemContext> file_system_context_; 179 scoped_refptr<FileSystemContext> file_system_context_;
180 }; 180 };
181 181
182 182
183 SimpleFileWriter::SimpleFileWriter( 183 SimpleFileWriter::SimpleFileWriter(
184 const WebString& path, 184 const GURL& path,
185 WebFileWriterClient* client, 185 WebFileWriterClient* client,
186 FileSystemContext* file_system_context) 186 FileSystemContext* file_system_context)
187 : WebFileWriterBase(path, client), 187 : WebFileWriterBase(path, client),
188 io_thread_proxy_(new IOThreadProxy(AsWeakPtr(), file_system_context)) { 188 io_thread_proxy_(new IOThreadProxy(AsWeakPtr(), file_system_context)) {
189 } 189 }
190 190
191 SimpleFileWriter::~SimpleFileWriter() { 191 SimpleFileWriter::~SimpleFileWriter() {
192 } 192 }
193 193
194 void SimpleFileWriter::DoTruncate(const FilePath& path, int64 offset) { 194 void SimpleFileWriter::DoTruncate(const GURL& path, int64 offset) {
195 io_thread_proxy_->Truncate(path, offset); 195 io_thread_proxy_->Truncate(path, offset);
196 } 196 }
197 197
198 void SimpleFileWriter::DoWrite( 198 void SimpleFileWriter::DoWrite(
199 const FilePath& path, const GURL& blob_url, int64 offset) { 199 const GURL& path, const GURL& blob_url, int64 offset) {
200 io_thread_proxy_->Write(path, blob_url, offset); 200 io_thread_proxy_->Write(path, blob_url, offset);
201 } 201 }
202 202
203 void SimpleFileWriter::DoCancel() { 203 void SimpleFileWriter::DoCancel() {
204 io_thread_proxy_->Cancel(); 204 io_thread_proxy_->Cancel();
205 } 205 }
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/simple_file_writer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698