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

Side by Side Diff: content/child/fileapi/webfilesystem_impl.cc

Issue 18427005: Implement async version of WebFileSystem::createFileWriter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | « content/child/fileapi/webfilesystem_impl.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/child/fileapi/webfilesystem_impl.h" 5 #include "content/child/fileapi/webfilesystem_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/child/child_thread.h" 8 #include "content/child/child_thread.h"
9 #include "content/child/fileapi/file_system_dispatcher.h" 9 #include "content/child/fileapi/file_system_dispatcher.h"
10 #include "content/child/fileapi/webfilesystem_callback_adapters.h" 10 #include "content/child/fileapi/webfilesystem_callback_adapters.h"
11 #include "content/child/fileapi/webfilewriter_impl.h" 11 #include "content/child/fileapi/webfilewriter_impl.h"
12 #include "third_party/WebKit/public/web/WebFileSystemCallbacks.h" 12 #include "third_party/WebKit/public/web/WebFileSystemCallbacks.h"
13 #include "third_party/WebKit/public/platform/WebFileInfo.h" 13 #include "third_party/WebKit/public/platform/WebFileInfo.h"
14 #include "third_party/WebKit/public/platform/WebString.h" 14 #include "third_party/WebKit/public/platform/WebString.h"
15 #include "third_party/WebKit/public/platform/WebURL.h" 15 #include "third_party/WebKit/public/platform/WebURL.h"
16 #include "webkit/glue/webkit_glue.h" 16 #include "webkit/glue/webkit_glue.h"
17 17
18 using WebKit::WebFileInfo; 18 using WebKit::WebFileInfo;
19 using WebKit::WebFileSystemCallbacks; 19 using WebKit::WebFileSystemCallbacks;
20 using WebKit::WebFileSystemEntry; 20 using WebKit::WebFileSystemEntry;
21 using WebKit::WebString; 21 using WebKit::WebString;
22 using WebKit::WebURL; 22 using WebKit::WebURL;
23 using WebKit::WebVector; 23 using WebKit::WebVector;
24 24
25 namespace content { 25 namespace content {
26 26
27 namespace {
28
29 void DidReadMetadataForCreateFileWriter(
30 const GURL& path,
31 WebKit::WebFileWriterClient* client,
32 WebKit::WebFileSystemCallbacks* callbacks,
33 const base::PlatformFileInfo& file_info) {
34 if (file_info.is_directory || file_info.size < 0) {
35 callbacks->didFail(WebKit::WebFileErrorInvalidState);
36 return;
37 }
38 callbacks->didCreateFileWriter(new WebFileWriterImpl(path, client),
39 file_info.size);
40 }
41
42 } // namespace
43
27 WebFileSystemImpl::WebFileSystemImpl() { 44 WebFileSystemImpl::WebFileSystemImpl() {
28 } 45 }
29 46
30 void WebFileSystemImpl::move(const WebURL& src_path, 47 void WebFileSystemImpl::move(const WebURL& src_path,
31 const WebURL& dest_path, 48 const WebURL& dest_path,
32 WebFileSystemCallbacks* callbacks) { 49 WebFileSystemCallbacks* callbacks) {
33 FileSystemDispatcher* dispatcher = 50 FileSystemDispatcher* dispatcher =
34 ChildThread::current()->file_system_dispatcher(); 51 ChildThread::current()->file_system_dispatcher();
35 dispatcher->Move(GURL(src_path), 52 dispatcher->Move(GURL(src_path),
36 GURL(dest_path), 53 GURL(dest_path),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 GURL(path), 140 GURL(path),
124 base::Bind(&ReadDirectoryCallbackAdapater, callbacks), 141 base::Bind(&ReadDirectoryCallbackAdapater, callbacks),
125 base::Bind(&FileStatusCallbackAdapter, callbacks)); 142 base::Bind(&FileStatusCallbackAdapter, callbacks));
126 } 143 }
127 144
128 WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter( 145 WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter(
129 const WebURL& path, WebKit::WebFileWriterClient* client) { 146 const WebURL& path, WebKit::WebFileWriterClient* client) {
130 return new WebFileWriterImpl(GURL(path), client); 147 return new WebFileWriterImpl(GURL(path), client);
131 } 148 }
132 149
150 void WebFileSystemImpl::createFileWriter(
151 const WebURL& path,
152 WebKit::WebFileWriterClient* client,
153 WebKit::WebFileSystemCallbacks* callbacks) {
154 FileSystemDispatcher* dispatcher =
155 ChildThread::current()->file_system_dispatcher();
156 dispatcher->ReadMetadata(
157 GURL(path),
158 base::Bind(&DidReadMetadataForCreateFileWriter,
159 GURL(path), client, callbacks),
160 base::Bind(&FileStatusCallbackAdapter, callbacks));
161 }
162
133 void WebFileSystemImpl::createSnapshotFileAndReadMetadata( 163 void WebFileSystemImpl::createSnapshotFileAndReadMetadata(
134 const WebKit::WebURL& path, 164 const WebKit::WebURL& path,
135 WebKit::WebFileSystemCallbacks* callbacks) { 165 WebKit::WebFileSystemCallbacks* callbacks) {
136 FileSystemDispatcher* dispatcher = 166 FileSystemDispatcher* dispatcher =
137 ChildThread::current()->file_system_dispatcher(); 167 ChildThread::current()->file_system_dispatcher();
138 dispatcher->CreateSnapshotFile( 168 dispatcher->CreateSnapshotFile(
139 GURL(path), 169 GURL(path),
140 base::Bind(&CreateSnapshotFileCallbackAdapter, callbacks), 170 base::Bind(&CreateSnapshotFileCallbackAdapter, callbacks),
141 base::Bind(&FileStatusCallbackAdapter, callbacks)); 171 base::Bind(&FileStatusCallbackAdapter, callbacks));
142 } 172 }
143 173
144 } // namespace content 174 } // namespace content
OLDNEW
« no previous file with comments | « content/child/fileapi/webfilesystem_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698