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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "modules/filesystem/FileWriterBaseCallback.h" | 43 #include "modules/filesystem/FileWriterBaseCallback.h" |
44 #include "modules/filesystem/FileWriterSync.h" | 44 #include "modules/filesystem/FileWriterSync.h" |
45 #include "platform/FileMetadata.h" | 45 #include "platform/FileMetadata.h" |
46 #include "public/platform/WebFileSystem.h" | 46 #include "public/platform/WebFileSystem.h" |
47 #include "public/platform/WebFileSystemCallbacks.h" | 47 #include "public/platform/WebFileSystemCallbacks.h" |
48 | 48 |
49 namespace WebCore { | 49 namespace WebCore { |
50 | 50 |
51 class FileWriterBase; | 51 class FileWriterBase; |
52 | 52 |
53 PassRefPtrWillBeRawPtr<DOMFileSystemSync> DOMFileSystemSync::create(DOMFileSyste
mBase* fileSystem) | 53 DOMFileSystemSync* DOMFileSystemSync::create(DOMFileSystemBase* fileSystem) |
54 { | 54 { |
55 return adoptRefWillBeRefCountedGarbageCollected(new DOMFileSystemSync(fileSy
stem->m_context, fileSystem->name(), fileSystem->type(), fileSystem->rootURL()))
; | 55 return new DOMFileSystemSync(fileSystem->m_context, fileSystem->name(), file
System->type(), fileSystem->rootURL()); |
56 } | 56 } |
57 | 57 |
58 DOMFileSystemSync::DOMFileSystemSync(ExecutionContext* context, const String& na
me, FileSystemType type, const KURL& rootURL) | 58 DOMFileSystemSync::DOMFileSystemSync(ExecutionContext* context, const String& na
me, FileSystemType type, const KURL& rootURL) |
59 : DOMFileSystemBase(context, name, type, rootURL) | 59 : DOMFileSystemBase(context, name, type, rootURL) |
60 { | 60 { |
61 ScriptWrappable::init(this); | 61 ScriptWrappable::init(this); |
62 } | 62 } |
63 | 63 |
64 DOMFileSystemSync::~DOMFileSystemSync() | 64 DOMFileSystemSync::~DOMFileSystemSync() |
65 { | 65 { |
66 } | 66 } |
67 | 67 |
68 void DOMFileSystemSync::reportError(PassOwnPtr<ErrorCallback> errorCallback, Pas
sRefPtrWillBeRawPtr<FileError> fileError) | 68 void DOMFileSystemSync::reportError(PassOwnPtr<ErrorCallback> errorCallback, Pas
sRefPtrWillBeRawPtr<FileError> fileError) |
69 { | 69 { |
70 errorCallback->handleEvent(fileError.get()); | 70 errorCallback->handleEvent(fileError.get()); |
71 } | 71 } |
72 | 72 |
73 PassRefPtrWillBeRawPtr<DirectoryEntrySync> DOMFileSystemSync::root() | 73 DirectoryEntrySync* DOMFileSystemSync::root() |
74 { | 74 { |
75 return DirectoryEntrySync::create(this, DOMFilePath::root); | 75 return DirectoryEntrySync::create(this, DOMFilePath::root); |
76 } | 76 } |
77 | 77 |
78 namespace { | 78 namespace { |
79 | 79 |
80 class CreateFileHelper FINAL : public AsyncFileSystemCallbacks { | 80 class CreateFileHelper FINAL : public AsyncFileSystemCallbacks { |
81 public: | 81 public: |
82 class CreateFileResult : public RefCountedWillBeGarbageCollected<CreateFileR
esult> { | 82 class CreateFileResult : public RefCountedWillBeGarbageCollected<CreateFileR
esult> { |
83 public: | 83 public: |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 explicit LocalErrorCallback(FileError::ErrorCode& errorCode) | 219 explicit LocalErrorCallback(FileError::ErrorCode& errorCode) |
220 : m_errorCode(errorCode) | 220 : m_errorCode(errorCode) |
221 { | 221 { |
222 } | 222 } |
223 | 223 |
224 FileError::ErrorCode& m_errorCode; | 224 FileError::ErrorCode& m_errorCode; |
225 }; | 225 }; |
226 | 226 |
227 } | 227 } |
228 | 228 |
229 PassRefPtrWillBeRawPtr<FileWriterSync> DOMFileSystemSync::createWriter(const Fil
eEntrySync* fileEntry, ExceptionState& exceptionState) | 229 FileWriterSync* DOMFileSystemSync::createWriter(const FileEntrySync* fileEntry,
ExceptionState& exceptionState) |
230 { | 230 { |
231 ASSERT(fileEntry); | 231 ASSERT(fileEntry); |
232 | 232 |
233 RefPtrWillBeRawPtr<FileWriterSync> fileWriter = FileWriterSync::create(); | 233 FileWriterSync* fileWriter = FileWriterSync::create(); |
234 OwnPtr<ReceiveFileWriterCallback> successCallback = ReceiveFileWriterCallbac
k::create(); | 234 OwnPtr<ReceiveFileWriterCallback> successCallback = ReceiveFileWriterCallbac
k::create(); |
235 FileError::ErrorCode errorCode = FileError::OK; | 235 FileError::ErrorCode errorCode = FileError::OK; |
236 OwnPtr<LocalErrorCallback> errorCallback = LocalErrorCallback::create(errorC
ode); | 236 OwnPtr<LocalErrorCallback> errorCallback = LocalErrorCallback::create(errorC
ode); |
237 | 237 |
238 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileWriterBaseCallbacks::create
(fileWriter, successCallback.release(), errorCallback.release(), m_context); | 238 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileWriterBaseCallbacks::create
(fileWriter, successCallback.release(), errorCallback.release(), m_context); |
239 callbacks->setShouldBlockUntilCompletion(true); | 239 callbacks->setShouldBlockUntilCompletion(true); |
240 | 240 |
241 fileSystem()->createFileWriter(createFileSystemURL(fileEntry), fileWriter.ge
t(), callbacks.release()); | 241 fileSystem()->createFileWriter(createFileSystemURL(fileEntry), fileWriter, c
allbacks.release()); |
242 if (errorCode != FileError::OK) { | 242 if (errorCode != FileError::OK) { |
243 FileError::throwDOMException(exceptionState, errorCode); | 243 FileError::throwDOMException(exceptionState, errorCode); |
244 return nullptr; | 244 return 0; |
245 } | 245 } |
246 return fileWriter.release(); | 246 return fileWriter; |
247 } | 247 } |
248 | 248 |
249 } | 249 } |
OLD | NEW |