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

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

Issue 314333002: Enable Oilpan by default in modules/filesystem/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove consts from conversion ctor + copy assignment op Created 6 years, 6 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "modules/filesystem/FileSystemCallback.h" 46 #include "modules/filesystem/FileSystemCallback.h"
47 #include "modules/filesystem/FileWriterBase.h" 47 #include "modules/filesystem/FileWriterBase.h"
48 #include "modules/filesystem/FileWriterBaseCallback.h" 48 #include "modules/filesystem/FileWriterBaseCallback.h"
49 #include "modules/filesystem/Metadata.h" 49 #include "modules/filesystem/Metadata.h"
50 #include "modules/filesystem/MetadataCallback.h" 50 #include "modules/filesystem/MetadataCallback.h"
51 #include "platform/FileMetadata.h" 51 #include "platform/FileMetadata.h"
52 #include "public/platform/WebFileWriter.h" 52 #include "public/platform/WebFileWriter.h"
53 53
54 namespace WebCore { 54 namespace WebCore {
55 55
56 FileSystemCallbacksBase::FileSystemCallbacksBase(PassOwnPtr<ErrorCallback> error Callback, PassRefPtrWillBeRawPtr<DOMFileSystemBase> fileSystem, ExecutionContext * context) 56 FileSystemCallbacksBase::FileSystemCallbacksBase(PassOwnPtr<ErrorCallback> error Callback, DOMFileSystemBase* fileSystem, ExecutionContext* context)
57 : m_errorCallback(errorCallback) 57 : m_errorCallback(errorCallback)
58 , m_fileSystem(fileSystem) 58 , m_fileSystem(fileSystem)
59 , m_executionContext(context) 59 , m_executionContext(context)
60 { 60 {
61 if (m_fileSystem) 61 if (m_fileSystem)
62 m_fileSystem->addPendingCallbacks(); 62 m_fileSystem->addPendingCallbacks();
63 } 63 }
64 64
65 FileSystemCallbacksBase::~FileSystemCallbacksBase() 65 FileSystemCallbacksBase::~FileSystemCallbacksBase()
66 { 66 {
67 if (m_fileSystem) 67 if (m_fileSystem)
68 m_fileSystem->removePendingCallbacks(); 68 m_fileSystem->removePendingCallbacks();
69 } 69 }
70 70
71 void FileSystemCallbacksBase::didFail(int code) 71 void FileSystemCallbacksBase::didFail(int code)
72 { 72 {
73 if (m_errorCallback) 73 if (m_errorCallback)
74 handleEventOrScheduleCallback(m_errorCallback.release(), FileError::crea te(static_cast<FileError::ErrorCode>(code))); 74 handleEventOrScheduleCallback(m_errorCallback.release(), FileError::crea te(static_cast<FileError::ErrorCode>(code)));
75 } 75 }
76 76
77 bool FileSystemCallbacksBase::shouldScheduleCallback() const 77 bool FileSystemCallbacksBase::shouldScheduleCallback() const
78 { 78 {
79 return !shouldBlockUntilCompletion() && m_executionContext && m_executionCon text->activeDOMObjectsAreSuspended(); 79 return !shouldBlockUntilCompletion() && m_executionContext && m_executionCon text->activeDOMObjectsAreSuspended();
80 } 80 }
81 81
82 template <typename CB, typename CBArg> 82 template <typename CB, typename CBArg>
83 void FileSystemCallbacksBase::handleEventOrScheduleCallback(PassOwnPtr<CB> callb ack, CBArg* arg)
84 {
85 ASSERT(callback.get());
86 if (shouldScheduleCallback())
87 DOMFileSystem::scheduleCallback(m_executionContext.get(), callback, arg) ;
88 else if (callback)
89 callback->handleEvent(arg);
90 m_executionContext.clear();
91 }
92
93 template <typename CB, typename CBArg>
83 void FileSystemCallbacksBase::handleEventOrScheduleCallback(PassOwnPtr<CB> callb ack, PassRefPtrWillBeRawPtr<CBArg> arg) 94 void FileSystemCallbacksBase::handleEventOrScheduleCallback(PassOwnPtr<CB> callb ack, PassRefPtrWillBeRawPtr<CBArg> arg)
84 { 95 {
85 ASSERT(callback.get()); 96 ASSERT(callback.get());
86 if (shouldScheduleCallback()) 97 if (shouldScheduleCallback())
87 DOMFileSystem::scheduleCallback(m_executionContext.get(), callback, arg) ; 98 DOMFileSystem::scheduleCallback(m_executionContext.get(), callback, arg) ;
88 else if (callback) 99 else if (callback)
89 callback->handleEvent(arg.get()); 100 callback->handleEvent(arg.get());
90 m_executionContext.clear(); 101 m_executionContext.clear();
91 } 102 }
92 103
93 template <typename CB> 104 template <typename CB>
94 void FileSystemCallbacksBase::handleEventOrScheduleCallback(PassOwnPtr<CB> callb ack) 105 void FileSystemCallbacksBase::handleEventOrScheduleCallback(PassOwnPtr<CB> callb ack)
95 { 106 {
96 ASSERT(callback.get()); 107 ASSERT(callback.get());
97 if (shouldScheduleCallback()) 108 if (shouldScheduleCallback())
98 DOMFileSystem::scheduleCallback(m_executionContext.get(), callback); 109 DOMFileSystem::scheduleCallback(m_executionContext.get(), callback);
99 else if (callback) 110 else if (callback)
100 callback->handleEvent(); 111 callback->handleEvent();
101 m_executionContext.clear(); 112 m_executionContext.clear();
102 } 113 }
103 114
104 // EntryCallbacks ------------------------------------------------------------- 115 // EntryCallbacks -------------------------------------------------------------
105 116
106 PassOwnPtr<AsyncFileSystemCallbacks> EntryCallbacks::create(PassOwnPtr<EntryCall back> successCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext * context, PassRefPtrWillBeRawPtr<DOMFileSystemBase> fileSystem, const String& e xpectedPath, bool isDirectory) 117 PassOwnPtr<AsyncFileSystemCallbacks> EntryCallbacks::create(PassOwnPtr<EntryCall back> successCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext * context, DOMFileSystemBase* fileSystem, const String& expectedPath, bool isDir ectory)
107 { 118 {
108 return adoptPtr(new EntryCallbacks(successCallback, errorCallback, context, fileSystem, expectedPath, isDirectory)); 119 return adoptPtr(new EntryCallbacks(successCallback, errorCallback, context, fileSystem, expectedPath, isDirectory));
109 } 120 }
110 121
111 EntryCallbacks::EntryCallbacks(PassOwnPtr<EntryCallback> successCallback, PassOw nPtr<ErrorCallback> errorCallback, ExecutionContext* context, PassRefPtrWillBeRa wPtr<DOMFileSystemBase> fileSystem, const String& expectedPath, bool isDirectory ) 122 EntryCallbacks::EntryCallbacks(PassOwnPtr<EntryCallback> successCallback, PassOw nPtr<ErrorCallback> errorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem, const String& expectedPath, bool isDirectory)
112 : FileSystemCallbacksBase(errorCallback, fileSystem, context) 123 : FileSystemCallbacksBase(errorCallback, fileSystem, context)
113 , m_successCallback(successCallback) 124 , m_successCallback(successCallback)
114 , m_expectedPath(expectedPath) 125 , m_expectedPath(expectedPath)
115 , m_isDirectory(isDirectory) 126 , m_isDirectory(isDirectory)
116 { 127 {
117 } 128 }
118 129
119 void EntryCallbacks::didSucceed() 130 void EntryCallbacks::didSucceed()
120 { 131 {
121 if (m_successCallback) { 132 if (m_successCallback) {
122 if (m_isDirectory) 133 if (m_isDirectory)
123 handleEventOrScheduleCallback(m_successCallback.release(), Directory Entry::create(m_fileSystem, m_expectedPath)); 134 handleEventOrScheduleCallback(m_successCallback.release(), Directory Entry::create(m_fileSystem, m_expectedPath));
124 else 135 else
125 handleEventOrScheduleCallback(m_successCallback.release(), FileEntry ::create(m_fileSystem, m_expectedPath)); 136 handleEventOrScheduleCallback(m_successCallback.release(), FileEntry ::create(m_fileSystem, m_expectedPath));
126 } 137 }
127 } 138 }
128 139
129 // EntriesCallbacks ----------------------------------------------------------- 140 // EntriesCallbacks -----------------------------------------------------------
130 141
131 PassOwnPtr<AsyncFileSystemCallbacks> EntriesCallbacks::create(PassOwnPtr<Entries Callback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionCon text* context, PassRefPtrWillBeRawPtr<DirectoryReaderBase> directoryReader, cons t String& basePath) 142 PassOwnPtr<AsyncFileSystemCallbacks> EntriesCallbacks::create(PassOwnPtr<Entries Callback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionCon text* context, DirectoryReaderBase* directoryReader, const String& basePath)
132 { 143 {
133 return adoptPtr(new EntriesCallbacks(successCallback, errorCallback, context , directoryReader, basePath)); 144 return adoptPtr(new EntriesCallbacks(successCallback, errorCallback, context , directoryReader, basePath));
134 } 145 }
135 146
136 EntriesCallbacks::EntriesCallbacks(PassOwnPtr<EntriesCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context, PassRefPtrWi llBeRawPtr<DirectoryReaderBase> directoryReader, const String& basePath) 147 EntriesCallbacks::EntriesCallbacks(PassOwnPtr<EntriesCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context, DirectoryRea derBase* directoryReader, const String& basePath)
137 : FileSystemCallbacksBase(errorCallback, directoryReader->filesystem(), cont ext) 148 : FileSystemCallbacksBase(errorCallback, directoryReader->filesystem(), cont ext)
138 , m_successCallback(successCallback) 149 , m_successCallback(successCallback)
139 , m_directoryReader(directoryReader) 150 , m_directoryReader(directoryReader)
140 , m_basePath(basePath) 151 , m_basePath(basePath)
141 { 152 {
142 ASSERT(m_directoryReader); 153 ASSERT(m_directoryReader);
143 } 154 }
144 155
145 void EntriesCallbacks::didReadDirectoryEntry(const String& name, bool isDirector y) 156 void EntriesCallbacks::didReadDirectoryEntry(const String& name, bool isDirector y)
146 { 157 {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 199 }
189 200
190 ResolveURICallbacks::ResolveURICallbacks(PassOwnPtr<EntryCallback> successCallba ck, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context) 201 ResolveURICallbacks::ResolveURICallbacks(PassOwnPtr<EntryCallback> successCallba ck, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context)
191 : FileSystemCallbacksBase(errorCallback, nullptr, context) 202 : FileSystemCallbacksBase(errorCallback, nullptr, context)
192 , m_successCallback(successCallback) 203 , m_successCallback(successCallback)
193 { 204 {
194 } 205 }
195 206
196 void ResolveURICallbacks::didResolveURL(const String& name, const KURL& rootURL, FileSystemType type, const String& filePath, bool isDirectory) 207 void ResolveURICallbacks::didResolveURL(const String& name, const KURL& rootURL, FileSystemType type, const String& filePath, bool isDirectory)
197 { 208 {
198 RefPtrWillBeRawPtr<DOMFileSystem> filesystem = DOMFileSystem::create(m_execu tionContext.get(), name, type, rootURL); 209 DOMFileSystem* filesystem = DOMFileSystem::create(m_executionContext.get(), name, type, rootURL);
199 RefPtrWillBeRawPtr<DirectoryEntry> root = filesystem->root(); 210 DirectoryEntry* root = filesystem->root();
200 211
201 String absolutePath; 212 String absolutePath;
202 if (!DOMFileSystemBase::pathToAbsolutePath(type, root.get(), filePath, absol utePath)) { 213 if (!DOMFileSystemBase::pathToAbsolutePath(type, root, filePath, absolutePat h)) {
203 handleEventOrScheduleCallback(m_errorCallback.release(), FileError::crea te(FileError::INVALID_MODIFICATION_ERR)); 214 handleEventOrScheduleCallback(m_errorCallback.release(), FileError::crea te(FileError::INVALID_MODIFICATION_ERR));
204 return; 215 return;
205 } 216 }
206 217
207 if (isDirectory) 218 if (isDirectory)
208 handleEventOrScheduleCallback(m_successCallback.release(), DirectoryEntr y::create(filesystem, absolutePath)); 219 handleEventOrScheduleCallback(m_successCallback.release(), DirectoryEntr y::create(filesystem, absolutePath));
209 else 220 else
210 handleEventOrScheduleCallback(m_successCallback.release(), FileEntry::cr eate(filesystem, absolutePath)); 221 handleEventOrScheduleCallback(m_successCallback.release(), FileEntry::cr eate(filesystem, absolutePath));
211 } 222 }
212 223
213 // MetadataCallbacks ---------------------------------------------------------- 224 // MetadataCallbacks ----------------------------------------------------------
214 225
215 PassOwnPtr<AsyncFileSystemCallbacks> MetadataCallbacks::create(PassOwnPtr<Metada taCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionC ontext* context, PassRefPtrWillBeRawPtr<DOMFileSystemBase> fileSystem) 226 PassOwnPtr<AsyncFileSystemCallbacks> MetadataCallbacks::create(PassOwnPtr<Metada taCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionC ontext* context, DOMFileSystemBase* fileSystem)
216 { 227 {
217 return adoptPtr(new MetadataCallbacks(successCallback, errorCallback, contex t, fileSystem)); 228 return adoptPtr(new MetadataCallbacks(successCallback, errorCallback, contex t, fileSystem));
218 } 229 }
219 230
220 MetadataCallbacks::MetadataCallbacks(PassOwnPtr<MetadataCallback> successCallbac k, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context, PassRefPt rWillBeRawPtr<DOMFileSystemBase> fileSystem) 231 MetadataCallbacks::MetadataCallbacks(PassOwnPtr<MetadataCallback> successCallbac k, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context, DOMFileSy stemBase* fileSystem)
221 : FileSystemCallbacksBase(errorCallback, fileSystem, context) 232 : FileSystemCallbacksBase(errorCallback, fileSystem, context)
222 , m_successCallback(successCallback) 233 , m_successCallback(successCallback)
223 { 234 {
224 } 235 }
225 236
226 void MetadataCallbacks::didReadMetadata(const FileMetadata& metadata) 237 void MetadataCallbacks::didReadMetadata(const FileMetadata& metadata)
227 { 238 {
228 if (m_successCallback) 239 if (m_successCallback)
229 handleEventOrScheduleCallback(m_successCallback.release(), Metadata::cre ate(metadata)); 240 handleEventOrScheduleCallback(m_successCallback.release(), Metadata::cre ate(metadata));
230 } 241 }
231 242
232 // FileWriterBaseCallbacks ----------------------------------------------------- ----- 243 // FileWriterBaseCallbacks ----------------------------------------------------- -----
233 244
234 PassOwnPtr<AsyncFileSystemCallbacks> FileWriterBaseCallbacks::create(PassRefPtrW illBeRawPtr<FileWriterBase> fileWriter, PassOwnPtr<FileWriterBaseCallback> succe ssCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context) 245 PassOwnPtr<AsyncFileSystemCallbacks> FileWriterBaseCallbacks::create(PassRefPtrW illBeRawPtr<FileWriterBase> fileWriter, PassOwnPtr<FileWriterBaseCallback> succe ssCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context)
235 { 246 {
236 return adoptPtr(new FileWriterBaseCallbacks(fileWriter, successCallback, err orCallback, context)); 247 return adoptPtr(new FileWriterBaseCallbacks(fileWriter, successCallback, err orCallback, context));
237 } 248 }
238 249
239 FileWriterBaseCallbacks::FileWriterBaseCallbacks(PassRefPtrWillBeRawPtr<FileWrit erBase> fileWriter, PassOwnPtr<FileWriterBaseCallback> successCallback, PassOwnP tr<ErrorCallback> errorCallback, ExecutionContext* context) 250 FileWriterBaseCallbacks::FileWriterBaseCallbacks(PassRefPtrWillBeRawPtr<FileWrit erBase> fileWriter, PassOwnPtr<FileWriterBaseCallback> successCallback, PassOwnP tr<ErrorCallback> errorCallback, ExecutionContext* context)
240 : FileSystemCallbacksBase(errorCallback, nullptr, context) 251 : FileSystemCallbacksBase(errorCallback, nullptr, context)
241 , m_fileWriter(fileWriter) 252 , m_fileWriter(fileWriter.get())
242 , m_successCallback(successCallback) 253 , m_successCallback(successCallback)
243 { 254 {
244 } 255 }
245 256
246 void FileWriterBaseCallbacks::didCreateFileWriter(PassOwnPtr<blink::WebFileWrite r> fileWriter, long long length) 257 void FileWriterBaseCallbacks::didCreateFileWriter(PassOwnPtr<blink::WebFileWrite r> fileWriter, long long length)
247 { 258 {
248 m_fileWriter->initialize(fileWriter, length); 259 m_fileWriter->initialize(fileWriter, length);
249 if (m_successCallback) 260 if (m_successCallback)
250 handleEventOrScheduleCallback(m_successCallback.release(), PassRefPtrWil lBeRawPtr<FileWriterBase>(m_fileWriter.release())); 261 handleEventOrScheduleCallback(m_successCallback.release(), m_fileWriter. release());
251 } 262 }
252 263
253 // VoidCallbacks -------------------------------------------------------------- 264 // VoidCallbacks --------------------------------------------------------------
254 265
255 PassOwnPtr<AsyncFileSystemCallbacks> VoidCallbacks::create(PassOwnPtr<VoidCallba ck> successCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context, PassRefPtrWillBeRawPtr<DOMFileSystemBase> fileSystem) 266 PassOwnPtr<AsyncFileSystemCallbacks> VoidCallbacks::create(PassOwnPtr<VoidCallba ck> successCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem)
256 { 267 {
257 return adoptPtr(new VoidCallbacks(successCallback, errorCallback, context, f ileSystem)); 268 return adoptPtr(new VoidCallbacks(successCallback, errorCallback, context, f ileSystem));
258 } 269 }
259 270
260 VoidCallbacks::VoidCallbacks(PassOwnPtr<VoidCallback> successCallback, PassOwnPt r<ErrorCallback> errorCallback, ExecutionContext* context, PassRefPtrWillBeRawPt r<DOMFileSystemBase> fileSystem) 271 VoidCallbacks::VoidCallbacks(PassOwnPtr<VoidCallback> successCallback, PassOwnPt r<ErrorCallback> errorCallback, ExecutionContext* context, DOMFileSystemBase* fi leSystem)
261 : FileSystemCallbacksBase(errorCallback, fileSystem, context) 272 : FileSystemCallbacksBase(errorCallback, fileSystem, context)
262 , m_successCallback(successCallback) 273 , m_successCallback(successCallback)
263 { 274 {
264 } 275 }
265 276
266 void VoidCallbacks::didSucceed() 277 void VoidCallbacks::didSucceed()
267 { 278 {
268 if (m_successCallback) 279 if (m_successCallback)
269 handleEventOrScheduleCallback(m_successCallback.release()); 280 handleEventOrScheduleCallback(m_successCallback.release());
270 } 281 }
271 282
272 } // namespace 283 } // 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