OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 24 matching lines...) Expand all Loading... |
35 #include "core/dom/ExecutionContextTask.h" | 35 #include "core/dom/ExecutionContextTask.h" |
36 #include "core/fileapi/FileError.h" | 36 #include "core/fileapi/FileError.h" |
37 #include "core/frame/LocalFrame.h" | 37 #include "core/frame/LocalFrame.h" |
38 #include "core/workers/WorkerGlobalScope.h" | 38 #include "core/workers/WorkerGlobalScope.h" |
39 #include "modules/filesystem/FileSystemClient.h" | 39 #include "modules/filesystem/FileSystemClient.h" |
40 #include "platform/AsyncFileSystemCallbacks.h" | 40 #include "platform/AsyncFileSystemCallbacks.h" |
41 #include "platform/ContentSettingCallbacks.h" | 41 #include "platform/ContentSettingCallbacks.h" |
42 #include "public/platform/Platform.h" | 42 #include "public/platform/Platform.h" |
43 #include "public/platform/WebFileSystem.h" | 43 #include "public/platform/WebFileSystem.h" |
44 #include "wtf/Functional.h" | 44 #include "wtf/Functional.h" |
| 45 #include <memory> |
45 | 46 |
46 namespace blink { | 47 namespace blink { |
47 | 48 |
48 namespace { | 49 namespace { |
49 | 50 |
50 void reportFailure(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, FileError::Er
rorCode error) | 51 void reportFailure(std::unique_ptr<AsyncFileSystemCallbacks> callbacks, FileErro
r::ErrorCode error) |
51 { | 52 { |
52 callbacks->didFail(error); | 53 callbacks->didFail(error); |
53 } | 54 } |
54 | 55 |
55 } // namespace | 56 } // namespace |
56 | 57 |
57 class CallbackWrapper final : public GarbageCollectedFinalized<CallbackWrapper>
{ | 58 class CallbackWrapper final : public GarbageCollectedFinalized<CallbackWrapper>
{ |
58 public: | 59 public: |
59 CallbackWrapper(PassOwnPtr<AsyncFileSystemCallbacks> c) | 60 CallbackWrapper(std::unique_ptr<AsyncFileSystemCallbacks> c) |
60 : m_callbacks(std::move(c)) | 61 : m_callbacks(std::move(c)) |
61 { | 62 { |
62 } | 63 } |
63 virtual ~CallbackWrapper() { } | 64 virtual ~CallbackWrapper() { } |
64 PassOwnPtr<AsyncFileSystemCallbacks> release() | 65 std::unique_ptr<AsyncFileSystemCallbacks> release() |
65 { | 66 { |
66 return std::move(m_callbacks); | 67 return std::move(m_callbacks); |
67 } | 68 } |
68 | 69 |
69 DEFINE_INLINE_TRACE() { } | 70 DEFINE_INLINE_TRACE() { } |
70 | 71 |
71 private: | 72 private: |
72 OwnPtr<AsyncFileSystemCallbacks> m_callbacks; | 73 std::unique_ptr<AsyncFileSystemCallbacks> m_callbacks; |
73 }; | 74 }; |
74 | 75 |
75 LocalFileSystem* LocalFileSystem::create(PassOwnPtr<FileSystemClient> client) | 76 LocalFileSystem* LocalFileSystem::create(std::unique_ptr<FileSystemClient> clien
t) |
76 { | 77 { |
77 return new LocalFileSystem(std::move(client)); | 78 return new LocalFileSystem(std::move(client)); |
78 } | 79 } |
79 | 80 |
80 LocalFileSystem::~LocalFileSystem() | 81 LocalFileSystem::~LocalFileSystem() |
81 { | 82 { |
82 } | 83 } |
83 | 84 |
84 void LocalFileSystem::resolveURL(ExecutionContext* context, const KURL& fileSyst
emURL, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) | 85 void LocalFileSystem::resolveURL(ExecutionContext* context, const KURL& fileSyst
emURL, std::unique_ptr<AsyncFileSystemCallbacks> callbacks) |
85 { | 86 { |
86 CallbackWrapper* wrapper = new CallbackWrapper(std::move(callbacks)); | 87 CallbackWrapper* wrapper = new CallbackWrapper(std::move(callbacks)); |
87 requestFileSystemAccessInternal(context, | 88 requestFileSystemAccessInternal(context, |
88 bind(&LocalFileSystem::resolveURLInternal, this, context, fileSystemURL,
wrapper), | 89 bind(&LocalFileSystem::resolveURLInternal, this, context, fileSystemURL,
wrapper), |
89 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, context, wrap
per)); | 90 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, context, wrap
per)); |
90 } | 91 } |
91 | 92 |
92 void LocalFileSystem::requestFileSystem(ExecutionContext* context, FileSystemTyp
e type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) | 93 void LocalFileSystem::requestFileSystem(ExecutionContext* context, FileSystemTyp
e type, long long size, std::unique_ptr<AsyncFileSystemCallbacks> callbacks) |
93 { | 94 { |
94 CallbackWrapper* wrapper = new CallbackWrapper(std::move(callbacks)); | 95 CallbackWrapper* wrapper = new CallbackWrapper(std::move(callbacks)); |
95 requestFileSystemAccessInternal(context, | 96 requestFileSystemAccessInternal(context, |
96 bind(&LocalFileSystem::fileSystemAllowedInternal, this, context, type, w
rapper), | 97 bind(&LocalFileSystem::fileSystemAllowedInternal, this, context, type, w
rapper), |
97 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, context, wrap
per)); | 98 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, context, wrap
per)); |
98 } | 99 } |
99 | 100 |
100 void LocalFileSystem::deleteFileSystem(ExecutionContext* context, FileSystemType
type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) | 101 void LocalFileSystem::deleteFileSystem(ExecutionContext* context, FileSystemType
type, std::unique_ptr<AsyncFileSystemCallbacks> callbacks) |
101 { | 102 { |
102 ASSERT(context); | 103 ASSERT(context); |
103 ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument()); | 104 ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument()); |
104 | 105 |
105 CallbackWrapper* wrapper = new CallbackWrapper(std::move(callbacks)); | 106 CallbackWrapper* wrapper = new CallbackWrapper(std::move(callbacks)); |
106 requestFileSystemAccessInternal(context, | 107 requestFileSystemAccessInternal(context, |
107 bind(&LocalFileSystem::deleteFileSystemInternal, this, context, type, wr
apper), | 108 bind(&LocalFileSystem::deleteFileSystemInternal, this, context, type, wr
apper), |
108 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, context, wrap
per)); | 109 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, context, wrap
per)); |
109 } | 110 } |
110 | 111 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 { | 183 { |
183 WebFileSystem* fileSystem = getFileSystem(); | 184 WebFileSystem* fileSystem = getFileSystem(); |
184 if (!fileSystem) { | 185 if (!fileSystem) { |
185 fileSystemNotAvailable(context, callbacks); | 186 fileSystemNotAvailable(context, callbacks); |
186 return; | 187 return; |
187 } | 188 } |
188 KURL storagePartition = KURL(KURL(), context->getSecurityOrigin()->toString(
)); | 189 KURL storagePartition = KURL(KURL(), context->getSecurityOrigin()->toString(
)); |
189 fileSystem->deleteFileSystem(storagePartition, static_cast<WebFileSystemType
>(type), callbacks->release()); | 190 fileSystem->deleteFileSystem(storagePartition, static_cast<WebFileSystemType
>(type), callbacks->release()); |
190 } | 191 } |
191 | 192 |
192 LocalFileSystem::LocalFileSystem(PassOwnPtr<FileSystemClient> client) | 193 LocalFileSystem::LocalFileSystem(std::unique_ptr<FileSystemClient> client) |
193 : m_client(std::move(client)) | 194 : m_client(std::move(client)) |
194 { | 195 { |
195 } | 196 } |
196 | 197 |
197 const char* LocalFileSystem::supplementName() | 198 const char* LocalFileSystem::supplementName() |
198 { | 199 { |
199 return "LocalFileSystem"; | 200 return "LocalFileSystem"; |
200 } | 201 } |
201 | 202 |
202 LocalFileSystem* LocalFileSystem::from(ExecutionContext& context) | 203 LocalFileSystem* LocalFileSystem::from(ExecutionContext& context) |
203 { | 204 { |
204 if (context.isDocument()) | 205 if (context.isDocument()) |
205 return static_cast<LocalFileSystem*>(Supplement<LocalFrame>::from(toDocu
ment(context).frame(), supplementName())); | 206 return static_cast<LocalFileSystem*>(Supplement<LocalFrame>::from(toDocu
ment(context).frame(), supplementName())); |
206 | 207 |
207 WorkerClients* clients = toWorkerGlobalScope(context).clients(); | 208 WorkerClients* clients = toWorkerGlobalScope(context).clients(); |
208 ASSERT(clients); | 209 ASSERT(clients); |
209 return static_cast<LocalFileSystem*>(Supplement<WorkerClients>::from(clients
, supplementName())); | 210 return static_cast<LocalFileSystem*>(Supplement<WorkerClients>::from(clients
, supplementName())); |
210 } | 211 } |
211 | 212 |
212 void provideLocalFileSystemTo(LocalFrame& frame, PassOwnPtr<FileSystemClient> cl
ient) | 213 void provideLocalFileSystemTo(LocalFrame& frame, std::unique_ptr<FileSystemClien
t> client) |
213 { | 214 { |
214 frame.provideSupplement(LocalFileSystem::supplementName(), LocalFileSystem::
create(std::move(client))); | 215 frame.provideSupplement(LocalFileSystem::supplementName(), LocalFileSystem::
create(std::move(client))); |
215 } | 216 } |
216 | 217 |
217 void provideLocalFileSystemToWorker(WorkerClients* clients, PassOwnPtr<FileSyste
mClient> client) | 218 void provideLocalFileSystemToWorker(WorkerClients* clients, std::unique_ptr<File
SystemClient> client) |
218 { | 219 { |
219 clients->provideSupplement(LocalFileSystem::supplementName(), LocalFileSyste
m::create(std::move(client))); | 220 clients->provideSupplement(LocalFileSystem::supplementName(), LocalFileSyste
m::create(std::move(client))); |
220 } | 221 } |
221 | 222 |
222 } // namespace blink | 223 } // namespace blink |
OLD | NEW |