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