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

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

Issue 188503002: Oilpan: add transition types to FileSystem APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 9 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
« no previous file with comments | « Source/modules/filesystem/FileSystemCallbacks.h ('k') | Source/modules/filesystem/FileWriter.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) 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 void FileSystemCallbacksBase::didFail(int code) 69 void FileSystemCallbacksBase::didFail(int code)
70 { 70 {
71 if (m_errorCallback) { 71 if (m_errorCallback) {
72 m_errorCallback->handleEvent(FileError::create(static_cast<FileError::Er rorCode>(code)).get()); 72 m_errorCallback->handleEvent(FileError::create(static_cast<FileError::Er rorCode>(code)).get());
73 m_errorCallback.clear(); 73 m_errorCallback.clear();
74 } 74 }
75 } 75 }
76 76
77 // EntryCallbacks ------------------------------------------------------------- 77 // EntryCallbacks -------------------------------------------------------------
78 78
79 PassOwnPtr<AsyncFileSystemCallbacks> EntryCallbacks::create(PassOwnPtr<EntryCall back> successCallback, PassOwnPtr<ErrorCallback> errorCallback, PassRefPtr<DOMFi leSystemBase> fileSystem, const String& expectedPath, bool isDirectory) 79 PassOwnPtr<AsyncFileSystemCallbacks> EntryCallbacks::create(PassOwnPtr<EntryCall back> successCallback, PassOwnPtr<ErrorCallback> errorCallback, PassRefPtrWillBe RawPtr<DOMFileSystemBase> fileSystem, const String& expectedPath, bool isDirecto ry)
80 { 80 {
81 return adoptPtr(new EntryCallbacks(successCallback, errorCallback, fileSyste m, expectedPath, isDirectory)); 81 return adoptPtr(new EntryCallbacks(successCallback, errorCallback, fileSyste m, expectedPath, isDirectory));
82 } 82 }
83 83
84 EntryCallbacks::EntryCallbacks(PassOwnPtr<EntryCallback> successCallback, PassOw nPtr<ErrorCallback> errorCallback, PassRefPtr<DOMFileSystemBase> fileSystem, con st String& expectedPath, bool isDirectory) 84 EntryCallbacks::EntryCallbacks(PassOwnPtr<EntryCallback> successCallback, PassOw nPtr<ErrorCallback> errorCallback, PassRefPtrWillBeRawPtr<DOMFileSystemBase> fil eSystem, const String& expectedPath, bool isDirectory)
85 : FileSystemCallbacksBase(errorCallback, fileSystem.get()) 85 : FileSystemCallbacksBase(errorCallback, fileSystem.get())
86 , m_successCallback(successCallback) 86 , m_successCallback(successCallback)
87 , m_expectedPath(expectedPath) 87 , m_expectedPath(expectedPath)
88 , m_isDirectory(isDirectory) 88 , m_isDirectory(isDirectory)
89 { 89 {
90 } 90 }
91 91
92 void EntryCallbacks::didSucceed() 92 void EntryCallbacks::didSucceed()
93 { 93 {
94 if (m_successCallback) { 94 if (m_successCallback) {
95 if (m_isDirectory) 95 if (m_isDirectory)
96 m_successCallback->handleEvent(DirectoryEntry::create(m_fileSystem, m_expectedPath).get()); 96 m_successCallback->handleEvent(DirectoryEntry::create(m_fileSystem, m_expectedPath).get());
97 else 97 else
98 m_successCallback->handleEvent(FileEntry::create(m_fileSystem, m_exp ectedPath).get()); 98 m_successCallback->handleEvent(FileEntry::create(m_fileSystem, m_exp ectedPath).get());
99 } 99 }
100 m_successCallback.clear(); 100 m_successCallback.clear();
101 } 101 }
102 102
103 // EntriesCallbacks ----------------------------------------------------------- 103 // EntriesCallbacks -----------------------------------------------------------
104 104
105 PassOwnPtr<AsyncFileSystemCallbacks> EntriesCallbacks::create(PassOwnPtr<Entries Callback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, PassRefPtr<D irectoryReaderBase> directoryReader, const String& basePath) 105 PassOwnPtr<AsyncFileSystemCallbacks> EntriesCallbacks::create(PassOwnPtr<Entries Callback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, PassRefPtrWi llBeRawPtr<DirectoryReaderBase> directoryReader, const String& basePath)
106 { 106 {
107 return adoptPtr(new EntriesCallbacks(successCallback, errorCallback, directo ryReader, basePath)); 107 return adoptPtr(new EntriesCallbacks(successCallback, errorCallback, directo ryReader, basePath));
108 } 108 }
109 109
110 EntriesCallbacks::EntriesCallbacks(PassOwnPtr<EntriesCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, PassRefPtr<DirectoryReaderBase> directo ryReader, const String& basePath) 110 EntriesCallbacks::EntriesCallbacks(PassOwnPtr<EntriesCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, PassRefPtrWillBeRawPtr<DirectoryReaderB ase> directoryReader, const String& basePath)
111 : FileSystemCallbacksBase(errorCallback, directoryReader->filesystem()) 111 : FileSystemCallbacksBase(errorCallback, directoryReader->filesystem())
112 , m_successCallback(successCallback) 112 , m_successCallback(successCallback)
113 , m_directoryReader(directoryReader) 113 , m_directoryReader(directoryReader)
114 , m_basePath(basePath) 114 , m_basePath(basePath)
115 { 115 {
116 ASSERT(m_directoryReader); 116 ASSERT(m_directoryReader);
117 } 117 }
118 118
119 void EntriesCallbacks::didReadDirectoryEntry(const String& name, bool isDirector y) 119 void EntriesCallbacks::didReadDirectoryEntry(const String& name, bool isDirector y)
120 { 120 {
121 if (isDirectory) 121 if (isDirectory)
122 m_entries.append(DirectoryEntry::create(m_directoryReader->filesystem(), DOMFilePath::append(m_basePath, name))); 122 m_entries.append(DirectoryEntry::create(m_directoryReader->filesystem(), DOMFilePath::append(m_basePath, name)));
123 else 123 else
124 m_entries.append(FileEntry::create(m_directoryReader->filesystem(), DOMF ilePath::append(m_basePath, name))); 124 m_entries.append(FileEntry::create(m_directoryReader->filesystem(), DOMF ilePath::append(m_basePath, name)));
125 } 125 }
126 126
127 void EntriesCallbacks::didReadDirectoryEntries(bool hasMore) 127 void EntriesCallbacks::didReadDirectoryEntries(bool hasMore)
128 { 128 {
129 m_directoryReader->setHasMoreEntries(hasMore); 129 m_directoryReader->setHasMoreEntries(hasMore);
130 EntryVector entries; 130 EntryHeapVector entries;
131 entries.swap(m_entries); 131 entries.swap(m_entries);
132 if (m_successCallback) 132 if (m_successCallback)
133 m_successCallback->handleEvent(entries); 133 m_successCallback->handleEvent(entries);
134 } 134 }
135 135
136 // FileSystemCallbacks -------------------------------------------------------- 136 // FileSystemCallbacks --------------------------------------------------------
137 137
138 PassOwnPtr<AsyncFileSystemCallbacks> FileSystemCallbacks::create(PassOwnPtr<File SystemCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, Execut ionContext* executionContext, FileSystemType type) 138 PassOwnPtr<AsyncFileSystemCallbacks> FileSystemCallbacks::create(PassOwnPtr<File SystemCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, Execut ionContext* executionContext, FileSystemType type)
139 { 139 {
140 return adoptPtr(new FileSystemCallbacks(successCallback, errorCallback, exec utionContext, type)); 140 return adoptPtr(new FileSystemCallbacks(successCallback, errorCallback, exec utionContext, type));
141 } 141 }
142 142
143 FileSystemCallbacks::FileSystemCallbacks(PassOwnPtr<FileSystemCallback> successC allback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context, Fil eSystemType type) 143 FileSystemCallbacks::FileSystemCallbacks(PassOwnPtr<FileSystemCallback> successC allback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context, Fil eSystemType type)
144 : FileSystemCallbacksBase(errorCallback, 0) 144 : FileSystemCallbacksBase(errorCallback, 0)
145 , m_successCallback(successCallback) 145 , m_successCallback(successCallback)
146 , m_executionContext(context) 146 , m_executionContext(context)
147 , m_type(type) 147 , m_type(type)
148 { 148 {
149 } 149 }
150 150
151 void FileSystemCallbacks::didOpenFileSystem(const String& name, const KURL& root URL) 151 void FileSystemCallbacks::didOpenFileSystem(const String& name, const KURL& root URL)
152 { 152 {
153 if (m_successCallback) { 153 if (m_successCallback) {
154 RefPtr<DOMFileSystem> fileSystem = DOMFileSystem::create(m_executionCont ext.get(), name, m_type, rootURL); 154 RefPtrWillBeRawPtr<DOMFileSystem> fileSystem = DOMFileSystem::create(m_e xecutionContext.get(), name, m_type, rootURL);
155 m_successCallback->handleEvent(fileSystem.get()); 155 m_successCallback->handleEvent(fileSystem.get());
156 m_executionContext.clear(); 156 m_executionContext.clear();
157 } 157 }
158 m_successCallback.clear(); 158 m_successCallback.clear();
159 } 159 }
160 160
161 // ResolveURICallbacks -------------------------------------------------------- 161 // ResolveURICallbacks --------------------------------------------------------
162 162
163 PassOwnPtr<AsyncFileSystemCallbacks> ResolveURICallbacks::create(PassOwnPtr<Entr yCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionCo ntext* executionContext) 163 PassOwnPtr<AsyncFileSystemCallbacks> ResolveURICallbacks::create(PassOwnPtr<Entr yCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionCo ntext* executionContext)
164 { 164 {
165 return adoptPtr(new ResolveURICallbacks(successCallback, errorCallback, exec utionContext)); 165 return adoptPtr(new ResolveURICallbacks(successCallback, errorCallback, exec utionContext));
166 } 166 }
167 167
168 ResolveURICallbacks::ResolveURICallbacks(PassOwnPtr<EntryCallback> successCallba ck, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context) 168 ResolveURICallbacks::ResolveURICallbacks(PassOwnPtr<EntryCallback> successCallba ck, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context)
169 : FileSystemCallbacksBase(errorCallback, 0) 169 : FileSystemCallbacksBase(errorCallback, 0)
170 , m_successCallback(successCallback) 170 , m_successCallback(successCallback)
171 , m_executionContext(context) 171 , m_executionContext(context)
172 { 172 {
173 } 173 }
174 174
175 void ResolveURICallbacks::didResolveURL(const String& name, const KURL& rootURL, FileSystemType type, const String& filePath, bool isDirectory) 175 void ResolveURICallbacks::didResolveURL(const String& name, const KURL& rootURL, FileSystemType type, const String& filePath, bool isDirectory)
176 { 176 {
177 RefPtr<DOMFileSystem> filesystem = DOMFileSystem::create(m_executionContext. get(), name, type, rootURL); 177 RefPtrWillBeRawPtr<DOMFileSystem> filesystem = DOMFileSystem::create(m_execu tionContext.get(), name, type, rootURL);
178 RefPtr<DirectoryEntry> root = filesystem->root(); 178 RefPtrWillBeRawPtr<DirectoryEntry> root = filesystem->root();
179 179
180 String absolutePath; 180 String absolutePath;
181 if (!DOMFileSystemBase::pathToAbsolutePath(type, root.get(), filePath, absol utePath)) { 181 if (!DOMFileSystemBase::pathToAbsolutePath(type, root.get(), filePath, absol utePath)) {
182 m_errorCallback->handleEvent(FileError::create(FileError::INVALID_MODIFI CATION_ERR).get()); 182 m_errorCallback->handleEvent(FileError::create(FileError::INVALID_MODIFI CATION_ERR).get());
183 m_errorCallback.clear(); 183 m_errorCallback.clear();
184 return; 184 return;
185 } 185 }
186 186
187 if (isDirectory) 187 if (isDirectory)
188 m_successCallback->handleEvent(DirectoryEntry::create(filesystem, absolu tePath).get()); 188 m_successCallback->handleEvent(DirectoryEntry::create(filesystem, absolu tePath).get());
(...skipping 17 matching lines...) Expand all
206 206
207 void MetadataCallbacks::didReadMetadata(const FileMetadata& metadata) 207 void MetadataCallbacks::didReadMetadata(const FileMetadata& metadata)
208 { 208 {
209 if (m_successCallback) 209 if (m_successCallback)
210 m_successCallback->handleEvent(Metadata::create(metadata).get()); 210 m_successCallback->handleEvent(Metadata::create(metadata).get());
211 m_successCallback.clear(); 211 m_successCallback.clear();
212 } 212 }
213 213
214 // FileWriterBaseCallbacks ----------------------------------------------------- ----- 214 // FileWriterBaseCallbacks ----------------------------------------------------- -----
215 215
216 PassOwnPtr<AsyncFileSystemCallbacks> FileWriterBaseCallbacks::create(PassRefPtr< FileWriterBase> fileWriter, PassOwnPtr<FileWriterBaseCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback) 216 PassOwnPtr<AsyncFileSystemCallbacks> FileWriterBaseCallbacks::create(PassRefPtrW illBeRawPtr<FileWriterBase> fileWriter, PassOwnPtr<FileWriterBaseCallback> succe ssCallback, PassOwnPtr<ErrorCallback> errorCallback)
217 { 217 {
218 return adoptPtr(new FileWriterBaseCallbacks(fileWriter, successCallback, err orCallback)); 218 return adoptPtr(new FileWriterBaseCallbacks(fileWriter, successCallback, err orCallback));
219 } 219 }
220 220
221 FileWriterBaseCallbacks::FileWriterBaseCallbacks(PassRefPtr<FileWriterBase> file Writer, PassOwnPtr<FileWriterBaseCallback> successCallback, PassOwnPtr<ErrorCall back> errorCallback) 221 FileWriterBaseCallbacks::FileWriterBaseCallbacks(PassRefPtrWillBeRawPtr<FileWrit erBase> fileWriter, PassOwnPtr<FileWriterBaseCallback> successCallback, PassOwnP tr<ErrorCallback> errorCallback)
222 : FileSystemCallbacksBase(errorCallback, 0) 222 : FileSystemCallbacksBase(errorCallback, 0)
223 , m_fileWriter(fileWriter) 223 , m_fileWriter(fileWriter)
224 , m_successCallback(successCallback) 224 , m_successCallback(successCallback)
225 { 225 {
226 } 226 }
227 227
228 void FileWriterBaseCallbacks::didCreateFileWriter(PassOwnPtr<blink::WebFileWrite r> fileWriter, long long length) 228 void FileWriterBaseCallbacks::didCreateFileWriter(PassOwnPtr<blink::WebFileWrite r> fileWriter, long long length)
229 { 229 {
230 m_fileWriter->initialize(fileWriter, length); 230 m_fileWriter->initialize(fileWriter, length);
231 if (m_successCallback) 231 if (m_successCallback) {
232 m_successCallback->handleEvent(m_fileWriter.release().get()); 232 m_successCallback->handleEvent(m_fileWriter.get());
233 m_fileWriter = nullptr;
234 }
233 m_successCallback.clear(); 235 m_successCallback.clear();
234 } 236 }
235 237
236 // VoidCallbacks -------------------------------------------------------------- 238 // VoidCallbacks --------------------------------------------------------------
237 239
238 PassOwnPtr<AsyncFileSystemCallbacks> VoidCallbacks::create(PassOwnPtr<VoidCallba ck> successCallback, PassOwnPtr<ErrorCallback> errorCallback, DOMFileSystemBase* fileSystem) 240 PassOwnPtr<AsyncFileSystemCallbacks> VoidCallbacks::create(PassOwnPtr<VoidCallba ck> successCallback, PassOwnPtr<ErrorCallback> errorCallback, DOMFileSystemBase* fileSystem)
239 { 241 {
240 return adoptPtr(new VoidCallbacks(successCallback, errorCallback, fileSystem )); 242 return adoptPtr(new VoidCallbacks(successCallback, errorCallback, fileSystem ));
241 } 243 }
242 244
243 VoidCallbacks::VoidCallbacks(PassOwnPtr<VoidCallback> successCallback, PassOwnPt r<ErrorCallback> errorCallback, DOMFileSystemBase* fileSystem) 245 VoidCallbacks::VoidCallbacks(PassOwnPtr<VoidCallback> successCallback, PassOwnPt r<ErrorCallback> errorCallback, DOMFileSystemBase* fileSystem)
244 : FileSystemCallbacksBase(errorCallback, fileSystem) 246 : FileSystemCallbacksBase(errorCallback, fileSystem)
245 , m_successCallback(successCallback) 247 , m_successCallback(successCallback)
246 { 248 {
247 } 249 }
248 250
249 void VoidCallbacks::didSucceed() 251 void VoidCallbacks::didSucceed()
250 { 252 {
251 if (m_successCallback) 253 if (m_successCallback)
252 m_successCallback->handleEvent(); 254 m_successCallback->handleEvent();
253 m_successCallback.clear(); 255 m_successCallback.clear();
254 } 256 }
255 257
256 } // namespace 258 } // namespace
OLDNEW
« no previous file with comments | « Source/modules/filesystem/FileSystemCallbacks.h ('k') | Source/modules/filesystem/FileWriter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698