Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Side by Side Diff: third_party/WebKit/Source/modules/filesystem/LocalFileSystem.cpp

Issue 2614143002: Use a new Supplement constructor for LocalFrame's supplements (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 std::unique_ptr<AsyncFileSystemCallbacks> release() { 65 std::unique_ptr<AsyncFileSystemCallbacks> release() {
66 return std::move(m_callbacks); 66 return std::move(m_callbacks);
67 } 67 }
68 68
69 DEFINE_INLINE_TRACE() {} 69 DEFINE_INLINE_TRACE() {}
70 70
71 private: 71 private:
72 std::unique_ptr<AsyncFileSystemCallbacks> m_callbacks; 72 std::unique_ptr<AsyncFileSystemCallbacks> m_callbacks;
73 }; 73 };
74 74
75 LocalFileSystem* LocalFileSystem::create(
76 std::unique_ptr<FileSystemClient> client) {
77 return new LocalFileSystem(std::move(client));
78 }
79
80 LocalFileSystem::~LocalFileSystem() {} 75 LocalFileSystem::~LocalFileSystem() {}
81 76
82 void LocalFileSystem::resolveURL( 77 void LocalFileSystem::resolveURL(
83 ExecutionContext* context, 78 ExecutionContext* context,
84 const KURL& fileSystemURL, 79 const KURL& fileSystemURL,
85 std::unique_ptr<AsyncFileSystemCallbacks> callbacks) { 80 std::unique_ptr<AsyncFileSystemCallbacks> callbacks) {
86 CallbackWrapper* wrapper = new CallbackWrapper(std::move(callbacks)); 81 CallbackWrapper* wrapper = new CallbackWrapper(std::move(callbacks));
87 requestFileSystemAccessInternal( 82 requestFileSystemAccessInternal(
88 context, 83 context,
89 WTF::bind(&LocalFileSystem::resolveURLInternal, 84 WTF::bind(&LocalFileSystem::resolveURLInternal,
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 fileSystemNotAvailable(context, callbacks); 202 fileSystemNotAvailable(context, callbacks);
208 return; 203 return;
209 } 204 }
210 KURL storagePartition = 205 KURL storagePartition =
211 KURL(KURL(), context->getSecurityOrigin()->toString()); 206 KURL(KURL(), context->getSecurityOrigin()->toString());
212 fileSystem->deleteFileSystem(storagePartition, 207 fileSystem->deleteFileSystem(storagePartition,
213 static_cast<WebFileSystemType>(type), 208 static_cast<WebFileSystemType>(type),
214 callbacks->release()); 209 callbacks->release());
215 } 210 }
216 211
217 LocalFileSystem::LocalFileSystem(std::unique_ptr<FileSystemClient> client) 212 LocalFileSystem::LocalFileSystem(LocalFrame& frame,
218 : m_client(std::move(client)) {} 213 std::unique_ptr<FileSystemClient> client)
214 : Supplement<LocalFrame>(frame), m_client(std::move(client)) {}
215
216 LocalFileSystem::LocalFileSystem(WorkerClients& workerClients,
217 std::unique_ptr<FileSystemClient> client)
218 : Supplement<WorkerClients>(workerClients), m_client(std::move(client)) {}
219 219
220 DEFINE_TRACE(LocalFileSystem) { 220 DEFINE_TRACE(LocalFileSystem) {
221 Supplement<LocalFrame>::trace(visitor); 221 Supplement<LocalFrame>::trace(visitor);
222 Supplement<WorkerClients>::trace(visitor); 222 Supplement<WorkerClients>::trace(visitor);
223 } 223 }
224 224
225 const char* LocalFileSystem::supplementName() { 225 const char* LocalFileSystem::supplementName() {
226 return "LocalFileSystem"; 226 return "LocalFileSystem";
227 } 227 }
228 228
229 LocalFileSystem* LocalFileSystem::from(ExecutionContext& context) { 229 LocalFileSystem* LocalFileSystem::from(ExecutionContext& context) {
230 if (context.isDocument()) 230 if (context.isDocument()) {
231 return static_cast<LocalFileSystem*>(Supplement<LocalFrame>::from( 231 LocalFileSystem* fileSystem =
232 toDocument(context).frame(), supplementName())); 232 static_cast<LocalFileSystem*>(Supplement<LocalFrame>::from(
233 toDocument(context).frame(), supplementName()));
234 DCHECK(fileSystem);
235 return fileSystem;
236 }
233 237
234 WorkerClients* clients = toWorkerGlobalScope(context).clients(); 238 WorkerClients* clients = toWorkerGlobalScope(context).clients();
235 ASSERT(clients); 239 ASSERT(clients);
236 return static_cast<LocalFileSystem*>( 240 LocalFileSystem* fileSystem = static_cast<LocalFileSystem*>(
237 Supplement<WorkerClients>::from(clients, supplementName())); 241 Supplement<WorkerClients>::from(clients, supplementName()));
242 DCHECK(fileSystem);
243 return fileSystem;
238 } 244 }
239 245
240 void provideLocalFileSystemTo(LocalFrame& frame, 246 void provideLocalFileSystemTo(LocalFrame& frame,
241 std::unique_ptr<FileSystemClient> client) { 247 std::unique_ptr<FileSystemClient> client) {
242 frame.provideSupplement(LocalFileSystem::supplementName(), 248 frame.provideSupplement(LocalFileSystem::supplementName(),
243 LocalFileSystem::create(std::move(client))); 249 new LocalFileSystem(frame, std::move(client)));
244 } 250 }
245 251
246 void provideLocalFileSystemToWorker(WorkerClients* clients, 252 void provideLocalFileSystemToWorker(WorkerClients* workerClients,
247 std::unique_ptr<FileSystemClient> client) { 253 std::unique_ptr<FileSystemClient> client) {
248 clients->provideSupplement(LocalFileSystem::supplementName(), 254 Supplement<WorkerClients>::provideTo(
249 LocalFileSystem::create(std::move(client))); 255 *workerClients, LocalFileSystem::supplementName(),
256 new LocalFileSystem(*workerClients, std::move(client)));
250 } 257 }
251 258
252 } // namespace blink 259 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698