OLD | NEW |
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 25 matching lines...) Expand all Loading... |
36 #include "modules/filesystem/DOMFilePath.h" | 36 #include "modules/filesystem/DOMFilePath.h" |
37 #include "modules/filesystem/DirectoryEntrySync.h" | 37 #include "modules/filesystem/DirectoryEntrySync.h" |
38 #include "modules/filesystem/ErrorCallback.h" | 38 #include "modules/filesystem/ErrorCallback.h" |
39 #include "modules/filesystem/FileEntrySync.h" | 39 #include "modules/filesystem/FileEntrySync.h" |
40 #include "modules/filesystem/FileSystemCallbacks.h" | 40 #include "modules/filesystem/FileSystemCallbacks.h" |
41 #include "modules/filesystem/FileWriterBaseCallback.h" | 41 #include "modules/filesystem/FileWriterBaseCallback.h" |
42 #include "modules/filesystem/FileWriterSync.h" | 42 #include "modules/filesystem/FileWriterSync.h" |
43 #include "platform/FileMetadata.h" | 43 #include "platform/FileMetadata.h" |
44 #include "public/platform/WebFileSystem.h" | 44 #include "public/platform/WebFileSystem.h" |
45 #include "public/platform/WebFileSystemCallbacks.h" | 45 #include "public/platform/WebFileSystemCallbacks.h" |
46 #include "wtf/PtrUtil.h" | |
47 #include <memory> | |
48 | 46 |
49 namespace blink { | 47 namespace blink { |
50 | 48 |
51 class FileWriterBase; | 49 class FileWriterBase; |
52 | 50 |
53 DOMFileSystemSync* DOMFileSystemSync::create(DOMFileSystemBase* fileSystem) | 51 DOMFileSystemSync* DOMFileSystemSync::create(DOMFileSystemBase* fileSystem) |
54 { | 52 { |
55 return new DOMFileSystemSync(fileSystem->m_context, fileSystem->name(), file
System->type(), fileSystem->rootURL()); | 53 return new DOMFileSystemSync(fileSystem->m_context, fileSystem->name(), file
System->type(), fileSystem->rootURL()); |
56 } | 54 } |
57 | 55 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 94 } |
97 | 95 |
98 private: | 96 private: |
99 CreateFileResult() | 97 CreateFileResult() |
100 : m_failed(false) | 98 : m_failed(false) |
101 , m_code(0) | 99 , m_code(0) |
102 { | 100 { |
103 } | 101 } |
104 }; | 102 }; |
105 | 103 |
106 static std::unique_ptr<AsyncFileSystemCallbacks> create(CreateFileResult* re
sult, const String& name, const KURL& url, FileSystemType type) | 104 static PassOwnPtr<AsyncFileSystemCallbacks> create(CreateFileResult* result,
const String& name, const KURL& url, FileSystemType type) |
107 { | 105 { |
108 return wrapUnique(static_cast<AsyncFileSystemCallbacks*>(new CreateFileH
elper(result, name, url, type))); | 106 return adoptPtr(static_cast<AsyncFileSystemCallbacks*>(new CreateFileHel
per(result, name, url, type))); |
109 } | 107 } |
110 | 108 |
111 void didFail(int code) override | 109 void didFail(int code) override |
112 { | 110 { |
113 m_result->m_failed = true; | 111 m_result->m_failed = true; |
114 m_result->m_code = code; | 112 m_result->m_code = code; |
115 } | 113 } |
116 | 114 |
117 ~CreateFileHelper() override | 115 ~CreateFileHelper() override |
118 { | 116 { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 205 |
208 FileWriterSync* DOMFileSystemSync::createWriter(const FileEntrySync* fileEntry,
ExceptionState& exceptionState) | 206 FileWriterSync* DOMFileSystemSync::createWriter(const FileEntrySync* fileEntry,
ExceptionState& exceptionState) |
209 { | 207 { |
210 ASSERT(fileEntry); | 208 ASSERT(fileEntry); |
211 | 209 |
212 FileWriterSync* fileWriter = FileWriterSync::create(); | 210 FileWriterSync* fileWriter = FileWriterSync::create(); |
213 ReceiveFileWriterCallback* successCallback = ReceiveFileWriterCallback::crea
te(); | 211 ReceiveFileWriterCallback* successCallback = ReceiveFileWriterCallback::crea
te(); |
214 FileError::ErrorCode errorCode = FileError::OK; | 212 FileError::ErrorCode errorCode = FileError::OK; |
215 LocalErrorCallback* errorCallback = LocalErrorCallback::create(errorCode); | 213 LocalErrorCallback* errorCallback = LocalErrorCallback::create(errorCode); |
216 | 214 |
217 std::unique_ptr<AsyncFileSystemCallbacks> callbacks = FileWriterBaseCallback
s::create(fileWriter, successCallback, errorCallback, m_context); | 215 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileWriterBaseCallbacks::create
(fileWriter, successCallback, errorCallback, m_context); |
218 callbacks->setShouldBlockUntilCompletion(true); | 216 callbacks->setShouldBlockUntilCompletion(true); |
219 | 217 |
220 fileSystem()->createFileWriter(createFileSystemURL(fileEntry), fileWriter, s
td::move(callbacks)); | 218 fileSystem()->createFileWriter(createFileSystemURL(fileEntry), fileWriter, s
td::move(callbacks)); |
221 if (errorCode != FileError::OK) { | 219 if (errorCode != FileError::OK) { |
222 FileError::throwDOMException(exceptionState, errorCode); | 220 FileError::throwDOMException(exceptionState, errorCode); |
223 return 0; | 221 return 0; |
224 } | 222 } |
225 return fileWriter; | 223 return fileWriter; |
226 } | 224 } |
227 | 225 |
228 DEFINE_TRACE(DOMFileSystemSync) | 226 DEFINE_TRACE(DOMFileSystemSync) |
229 { | 227 { |
230 DOMFileSystemBase::trace(visitor); | 228 DOMFileSystemBase::trace(visitor); |
231 visitor->trace(m_rootEntry); | 229 visitor->trace(m_rootEntry); |
232 } | 230 } |
233 | 231 |
234 } // namespace blink | 232 } // namespace blink |
OLD | NEW |