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

Side by Side Diff: Source/web/AsyncFileSystemChromium.cpp

Issue 18411005: Use the async version of WebFileSystem::createFileWriter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
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 | « no previous file | Source/web/AsyncFileWriterChromium.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 void AsyncFileSystemChromium::directoryExists(const KURL& path, PassOwnPtr<Async FileSystemCallbacks> callbacks) 102 void AsyncFileSystemChromium::directoryExists(const KURL& path, PassOwnPtr<Async FileSystemCallbacks> callbacks)
103 { 103 {
104 m_webFileSystem->directoryExists(path, new WebKit::WebFileSystemCallbacksImp l(callbacks)); 104 m_webFileSystem->directoryExists(path, new WebKit::WebFileSystemCallbacksImp l(callbacks));
105 } 105 }
106 106
107 void AsyncFileSystemChromium::readDirectory(const KURL& path, PassOwnPtr<AsyncFi leSystemCallbacks> callbacks) 107 void AsyncFileSystemChromium::readDirectory(const KURL& path, PassOwnPtr<AsyncFi leSystemCallbacks> callbacks)
108 { 108 {
109 m_webFileSystem->readDirectory(path, new WebKit::WebFileSystemCallbacksImpl( callbacks)); 109 m_webFileSystem->readDirectory(path, new WebKit::WebFileSystemCallbacksImpl( callbacks));
110 } 110 }
111 111
112 class FileWriterHelperCallbacks : public WebKit::WebFileSystemCallbacks {
113 public:
114 FileWriterHelperCallbacks(AsyncFileWriterClient* client, const KURL& path, W ebKit::WebFileSystem* webFileSystem, PassOwnPtr<WebCore::AsyncFileSystemCallback s> callbacks)
115 : m_client(client)
116 , m_path(path)
117 , m_webFileSystem(webFileSystem)
118 , m_callbacks(callbacks)
119 {
120 }
121
122 virtual void didSucceed()
123 {
124 ASSERT_NOT_REACHED();
125 delete this;
126 }
127 virtual void didReadMetadata(const WebKit::WebFileInfo& info)
128 {
129 ASSERT(m_callbacks);
130 if (info.type != WebKit::WebFileInfo::TypeFile || info.length < 0)
131 m_callbacks->didFail(WebKit::WebFileErrorInvalidState);
132 else {
133 OwnPtr<AsyncFileWriterChromium> asyncFileWriterChromium = adoptPtr(n ew AsyncFileWriterChromium(m_client));
134 OwnPtr<WebKit::WebFileWriter> webFileWriter = adoptPtr(m_webFileSyst em->createFileWriter(m_path, asyncFileWriterChromium.get()));
135 asyncFileWriterChromium->setWebFileWriter(webFileWriter.release());
136 m_callbacks->didCreateFileWriter(asyncFileWriterChromium.release(), info.length);
137 }
138 delete this;
139 }
140 virtual void didCreateSnapshotFile(const WebKit::WebFileInfo& info)
141 {
142 ASSERT_NOT_REACHED();
143 delete this;
144 }
145 virtual void didReadDirectory(const WebKit::WebVector<WebKit::WebFileSystemE ntry>& entries, bool hasMore)
146 {
147 ASSERT_NOT_REACHED();
148 delete this;
149 }
150 virtual void didOpenFileSystem(const WebKit::WebString& name, const WebKit:: WebURL& rootURL)
151 {
152 ASSERT_NOT_REACHED();
153 delete this;
154 }
155
156 virtual void didFail(WebKit::WebFileError error)
157 {
158 ASSERT(m_callbacks);
159 m_callbacks->didFail(error);
160 delete this;
161 }
162
163 virtual bool shouldBlockUntilCompletion() const
164 {
165 return m_callbacks->shouldBlockUntilCompletion();
166 }
167
168 private:
169 AsyncFileWriterClient* m_client;
170 KURL m_path;
171 WebKit::WebFileSystem* m_webFileSystem;
172 OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks;
173 };
174
175 void AsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 112 void AsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
176 { 113 {
177 m_webFileSystem->readMetadata(path, new FileWriterHelperCallbacks(client, pa th, m_webFileSystem, callbacks)); 114 OwnPtr<AsyncFileWriterChromium> asyncFileWriter = AsyncFileWriterChromium::c reate(client);
115 WebKit::WebFileWriterClient* writerClient = asyncFileWriter.get();
116
117 m_webFileSystem->createFileWriter(path, writerClient, new WebKit::WebFileSys temCallbacksImpl(callbacks, asyncFileWriter.release()));
abarth-chromium 2013/07/12 22:53:48 scary "naked" new. We need to fix that about the
kinuko 2013/07/16 02:35:22 Yep... this needs API fix, I'd like to address the
178 } 118 }
179 119
180 void AsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const KURL& path , PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 120 void AsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const KURL& path , PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
181 { 121 {
182 m_webFileSystem->createSnapshotFileAndReadMetadata(path, new WebKit::WebFile SystemCallbacksImpl(callbacks)); 122 m_webFileSystem->createSnapshotFileAndReadMetadata(path, new WebKit::WebFile SystemCallbacksImpl(callbacks));
183 } 123 }
184 124
185 } // namespace WebCore 125 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/web/AsyncFileWriterChromium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698