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

Side by Side Diff: Source/modules/filesystem/WorkerGlobalScopeFileSystem.cpp

Issue 23704004: Make WebFileSystemCallbacks not self-destruct, deprecate AsyncFileSystem (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/modules/filesystem/SyncCallbackHelper.h ('k') | Source/web/AsyncFileSystemChromium.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 14 matching lines...) Expand all
25 * 25 *
26 */ 26 */
27 27
28 #include "config.h" 28 #include "config.h"
29 #include "modules/filesystem/WorkerGlobalScopeFileSystem.h" 29 #include "modules/filesystem/WorkerGlobalScopeFileSystem.h"
30 30
31 #include "bindings/v8/ExceptionMessages.h" 31 #include "bindings/v8/ExceptionMessages.h"
32 #include "bindings/v8/ExceptionState.h" 32 #include "bindings/v8/ExceptionState.h"
33 #include "core/dom/ExceptionCode.h" 33 #include "core/dom/ExceptionCode.h"
34 #include "core/fileapi/FileError.h" 34 #include "core/fileapi/FileError.h"
35 #include "core/platform/AsyncFileSystem.h"
36 #include "core/workers/WorkerGlobalScope.h" 35 #include "core/workers/WorkerGlobalScope.h"
37 #include "modules/filesystem/DOMFileSystemBase.h" 36 #include "modules/filesystem/DOMFileSystemBase.h"
38 #include "modules/filesystem/DOMFileSystemSync.h" 37 #include "modules/filesystem/DOMFileSystemSync.h"
39 #include "modules/filesystem/DirectoryEntrySync.h" 38 #include "modules/filesystem/DirectoryEntrySync.h"
40 #include "modules/filesystem/ErrorCallback.h" 39 #include "modules/filesystem/ErrorCallback.h"
41 #include "modules/filesystem/FileEntrySync.h" 40 #include "modules/filesystem/FileEntrySync.h"
42 #include "modules/filesystem/FileSystemCallback.h" 41 #include "modules/filesystem/FileSystemCallback.h"
43 #include "modules/filesystem/FileSystemCallbacks.h" 42 #include "modules/filesystem/FileSystemCallbacks.h"
44 #include "modules/filesystem/FileSystemType.h" 43 #include "modules/filesystem/FileSystemType.h"
45 #include "modules/filesystem/SyncCallbackHelper.h" 44 #include "modules/filesystem/SyncCallbackHelper.h"
(...skipping 27 matching lines...) Expand all
73 return 0; 72 return 0;
74 } 73 }
75 74
76 FileSystemType fileSystemType = static_cast<FileSystemType>(type); 75 FileSystemType fileSystemType = static_cast<FileSystemType>(type);
77 if (!DOMFileSystemBase::isValidType(fileSystemType)) { 76 if (!DOMFileSystemBase::isValidType(fileSystemType)) {
78 es.throwDOMException(InvalidModificationError, ExceptionMessages::failed ToExecute("webkitRequestFileSystemSync", "WorkerGlobalScopeFileSystem", "the typ e must be TEMPORARY or PERSISTENT.")); 77 es.throwDOMException(InvalidModificationError, ExceptionMessages::failed ToExecute("webkitRequestFileSystemSync", "WorkerGlobalScopeFileSystem", "the typ e must be TEMPORARY or PERSISTENT."));
79 return 0; 78 return 0;
80 } 79 }
81 80
82 FileSystemSyncCallbackHelper helper; 81 FileSystemSyncCallbackHelper helper;
83 OwnPtr<FileSystemCallbacks> callbacks = FileSystemCallbacks::create(helper.s uccessCallback(), helper.errorCallback(), worker, fileSystemType); 82 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileSystemCallbacks::create(hel per.successCallback(), helper.errorCallback(), worker, fileSystemType);
84 callbacks->setShouldBlockUntilCompletion(true); 83 callbacks->setShouldBlockUntilCompletion(true);
85 84
86 WorkerLocalFileSystem::from(worker)->requestFileSystem(worker, fileSystemTyp e, size, callbacks.release()); 85 WorkerLocalFileSystem::from(worker)->requestFileSystem(worker, fileSystemTyp e, size, callbacks.release());
87 return helper.getResult(es); 86 return helper.getResult(es);
88 } 87 }
89 88
90 void WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemURL(WorkerGlobalSc ope* worker, const String& url, PassRefPtr<EntryCallback> successCallback, PassR efPtr<ErrorCallback> errorCallback) 89 void WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemURL(WorkerGlobalSc ope* worker, const String& url, PassRefPtr<EntryCallback> successCallback, PassR efPtr<ErrorCallback> errorCallback)
91 { 90 {
92 KURL completedURL = worker->completeURL(url); 91 KURL completedURL = worker->completeURL(url);
93 ScriptExecutionContext* secureContext = worker->scriptExecutionContext(); 92 ScriptExecutionContext* secureContext = worker->scriptExecutionContext();
(...skipping 22 matching lines...) Expand all
116 } 115 }
117 116
118 FileSystemType type; 117 FileSystemType type;
119 String filePath; 118 String filePath;
120 if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(comple tedURL, type, filePath)) { 119 if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(comple tedURL, type, filePath)) {
121 es.throwDOMException(EncodingError, ExceptionMessages::failedToExecute(" webkitResolveLocalFileSystemSyncURL", "WorkerGlobalScopeFileSystem", "the URL '" + url + "' is invalid.")); 120 es.throwDOMException(EncodingError, ExceptionMessages::failedToExecute(" webkitResolveLocalFileSystemSyncURL", "WorkerGlobalScopeFileSystem", "the URL '" + url + "' is invalid."));
122 return 0; 121 return 0;
123 } 122 }
124 123
125 FileSystemSyncCallbackHelper readFileSystemHelper; 124 FileSystemSyncCallbackHelper readFileSystemHelper;
126 OwnPtr<FileSystemCallbacks> callbacks = FileSystemCallbacks::create(readFile SystemHelper.successCallback(), readFileSystemHelper.errorCallback(), worker, ty pe); 125 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileSystemCallbacks::create(rea dFileSystemHelper.successCallback(), readFileSystemHelper.errorCallback(), worke r, type);
127 callbacks->setShouldBlockUntilCompletion(true); 126 callbacks->setShouldBlockUntilCompletion(true);
128 127
129 WorkerLocalFileSystem::from(worker)->readFileSystem(worker, type, callbacks. release()); 128 WorkerLocalFileSystem::from(worker)->readFileSystem(worker, type, callbacks. release());
130 RefPtr<DOMFileSystemSync> fileSystem = readFileSystemHelper.getResult(es); 129 RefPtr<DOMFileSystemSync> fileSystem = readFileSystemHelper.getResult(es);
131 if (!fileSystem) 130 if (!fileSystem)
132 return 0; 131 return 0;
133 132
134 RefPtr<EntrySync> entry = fileSystem->root()->getDirectory(filePath, Diction ary(), es); 133 RefPtr<EntrySync> entry = fileSystem->root()->getDirectory(filePath, Diction ary(), es);
135 if (es.code() == TypeMismatchError) { 134 if (es.code() == TypeMismatchError) {
136 es.clearException(); 135 es.clearException();
137 return fileSystem->root()->getFile(filePath, Dictionary(), es); 136 return fileSystem->root()->getFile(filePath, Dictionary(), es);
138 } 137 }
139 138
140 return entry.release(); 139 return entry.release();
141 } 140 }
142 141
143 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::TEMPORARY) == stati c_cast<int>(FileSystemTypeTemporary), enum_mismatch); 142 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::TEMPORARY) == stati c_cast<int>(FileSystemTypeTemporary), enum_mismatch);
144 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::PERSISTENT) == stat ic_cast<int>(FileSystemTypePersistent), enum_mismatch); 143 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::PERSISTENT) == stat ic_cast<int>(FileSystemTypePersistent), enum_mismatch);
145 144
146 } // namespace WebCore 145 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/filesystem/SyncCallbackHelper.h ('k') | Source/web/AsyncFileSystemChromium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698