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