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

Side by Side Diff: Source/modules/filesystem/DOMFileSystemSync.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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "modules/filesystem/FileWriterBaseCallback.h" 43 #include "modules/filesystem/FileWriterBaseCallback.h"
44 #include "modules/filesystem/FileWriterSync.h" 44 #include "modules/filesystem/FileWriterSync.h"
45 #include "platform/FileMetadata.h" 45 #include "platform/FileMetadata.h"
46 #include "public/platform/WebFileSystem.h" 46 #include "public/platform/WebFileSystem.h"
47 #include "public/platform/WebFileSystemCallbacks.h" 47 #include "public/platform/WebFileSystemCallbacks.h"
48 48
49 namespace WebCore { 49 namespace WebCore {
50 50
51 class FileWriterBase; 51 class FileWriterBase;
52 52
53 PassRefPtr<DOMFileSystemSync> DOMFileSystemSync::create(DOMFileSystemBase* fileS ystem) 53 PassRefPtrWillBeRawPtr<DOMFileSystemSync> DOMFileSystemSync::create(DOMFileSyste mBase* fileSystem)
54 { 54 {
55 return adoptRef(new DOMFileSystemSync(fileSystem->m_context, fileSystem->nam e(), fileSystem->type(), fileSystem->rootURL())); 55 return adoptRefWillBeRefCountedGarbageCollected(new DOMFileSystemSync(fileSy stem->m_context, fileSystem->name(), fileSystem->type(), fileSystem->rootURL())) ;
56 } 56 }
57 57
58 DOMFileSystemSync::DOMFileSystemSync(ExecutionContext* context, const String& na me, FileSystemType type, const KURL& rootURL) 58 DOMFileSystemSync::DOMFileSystemSync(ExecutionContext* context, const String& na me, FileSystemType type, const KURL& rootURL)
59 : DOMFileSystemBase(context, name, type, rootURL) 59 : DOMFileSystemBase(context, name, type, rootURL)
60 { 60 {
61 ScriptWrappable::init(this); 61 ScriptWrappable::init(this);
62 } 62 }
63 63
64 DOMFileSystemSync::~DOMFileSystemSync() 64 DOMFileSystemSync::~DOMFileSystemSync()
65 { 65 {
66 } 66 }
67 67
68 void DOMFileSystemSync::reportError(PassOwnPtr<ErrorCallback> errorCallback, Pas sRefPtrWillBeRawPtr<FileError> fileError) 68 void DOMFileSystemSync::reportError(PassOwnPtr<ErrorCallback> errorCallback, Pas sRefPtrWillBeRawPtr<FileError> fileError)
69 { 69 {
70 errorCallback->handleEvent(fileError.get()); 70 errorCallback->handleEvent(fileError.get());
71 } 71 }
72 72
73 PassRefPtr<DirectoryEntrySync> DOMFileSystemSync::root() 73 PassRefPtrWillBeRawPtr<DirectoryEntrySync> DOMFileSystemSync::root()
74 { 74 {
75 return DirectoryEntrySync::create(this, DOMFilePath::root); 75 return DirectoryEntrySync::create(this, DOMFilePath::root);
76 } 76 }
77 77
78 namespace { 78 namespace {
79 79
80 class CreateFileHelper FINAL : public AsyncFileSystemCallbacks { 80 class CreateFileHelper FINAL : public AsyncFileSystemCallbacks {
81 public: 81 public:
82 class CreateFileResult : public RefCounted<CreateFileResult> { 82 class CreateFileResult : public RefCountedWillBeGarbageCollected<CreateFileR esult> {
83 public: 83 public:
84 static PassRefPtr<CreateFileResult> create() 84 static PassRefPtrWillBeRawPtr<CreateFileResult> create()
85 { 85 {
86 return adoptRef(new CreateFileResult()); 86 return adoptRefWillBeNoop(new CreateFileResult());
87 } 87 }
88 88
89 bool m_failed; 89 bool m_failed;
90 int m_code; 90 int m_code;
91 RefPtrWillBePersistent<File> m_file; 91 RefPtrWillBeMember<File> m_file;
92
93 void trace(Visitor* visitor)
94 {
95 visitor->trace(m_file);
96 }
92 97
93 private: 98 private:
94 CreateFileResult() 99 CreateFileResult()
95 : m_failed(false) 100 : m_failed(false)
96 , m_code(0) 101 , m_code(0)
97 { 102 {
98 } 103 }
99 104
100 ~CreateFileResult() 105 ~CreateFileResult()
101 { 106 {
102 } 107 }
103 friend class WTF::RefCounted<CreateFileResult>; 108 friend class RefCountedWillBeGarbageCollected<CreateFileResult>;
104 }; 109 };
105 110
106 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassRefPtr<CreateFileResu lt> result, const String& name, const KURL& url, FileSystemType type) 111 static PassOwnPtr<AsyncFileSystemCallbacks> create(PassRefPtrWillBeRawPtr<Cr eateFileResult> result, const String& name, const KURL& url, FileSystemType type )
107 { 112 {
108 return adoptPtr(static_cast<AsyncFileSystemCallbacks*>(new CreateFileHel per(result, name, url, type))); 113 return adoptPtr(static_cast<AsyncFileSystemCallbacks*>(new CreateFileHel per(result, name, url, type)));
109 } 114 }
110 115
111 virtual void didFail(int code) OVERRIDE 116 virtual void didFail(int code) OVERRIDE
112 { 117 {
113 m_result->m_failed = true; 118 m_result->m_failed = true;
114 m_result->m_code = code; 119 m_result->m_code = code;
115 } 120 }
116 121
(...skipping 23 matching lines...) Expand all
140 m_result->m_file = File::createForFileSystemFile(m_url, metadata).ge t(); 145 m_result->m_file = File::createForFileSystemFile(m_url, metadata).ge t();
141 } 146 }
142 } 147 }
143 148
144 virtual bool shouldBlockUntilCompletion() const OVERRIDE 149 virtual bool shouldBlockUntilCompletion() const OVERRIDE
145 { 150 {
146 return true; 151 return true;
147 } 152 }
148 153
149 private: 154 private:
150 CreateFileHelper(PassRefPtr<CreateFileResult> result, const String& name, co nst KURL& url, FileSystemType type) 155 CreateFileHelper(PassRefPtrWillBeRawPtr<CreateFileResult> result, const Stri ng& name, const KURL& url, FileSystemType type)
151 : m_result(result) 156 : m_result(result)
152 , m_name(name) 157 , m_name(name)
153 , m_url(url) 158 , m_url(url)
154 , m_type(type) 159 , m_type(type)
155 { 160 {
156 } 161 }
157 162
158 RefPtr<CreateFileResult> m_result; 163 RefPtrWillBePersistent<CreateFileResult> m_result;
159 String m_name; 164 String m_name;
160 KURL m_url; 165 KURL m_url;
161 FileSystemType m_type; 166 FileSystemType m_type;
162 }; 167 };
163 168
164 } // namespace 169 } // namespace
165 170
166 PassRefPtrWillBeRawPtr<File> DOMFileSystemSync::createFile(const FileEntrySync* fileEntry, ExceptionState& exceptionState) 171 PassRefPtrWillBeRawPtr<File> DOMFileSystemSync::createFile(const FileEntrySync* fileEntry, ExceptionState& exceptionState)
167 { 172 {
168 KURL fileSystemURL = createFileSystemURL(fileEntry); 173 KURL fileSystemURL = createFileSystemURL(fileEntry);
169 RefPtr<CreateFileHelper::CreateFileResult> result(CreateFileHelper::CreateFi leResult::create()); 174 RefPtrWillBeRawPtr<CreateFileHelper::CreateFileResult> result(CreateFileHelp er::CreateFileResult::create());
170 fileSystem()->createSnapshotFileAndReadMetadata(fileSystemURL, CreateFileHel per::create(result, fileEntry->name(), fileSystemURL, type())); 175 fileSystem()->createSnapshotFileAndReadMetadata(fileSystemURL, CreateFileHel per::create(result, fileEntry->name(), fileSystemURL, type()));
171 if (result->m_failed) { 176 if (result->m_failed) {
172 exceptionState.throwDOMException(result->m_code, "Could not create '" + fileEntry->name() + "'."); 177 exceptionState.throwDOMException(result->m_code, "Could not create '" + fileEntry->name() + "'.");
173 return nullptr; 178 return nullptr;
174 } 179 }
175 return result->m_file.get(); 180 return result->m_file.get();
176 } 181 }
177 182
178 namespace { 183 namespace {
179 184
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 explicit LocalErrorCallback(FileError::ErrorCode& errorCode) 216 explicit LocalErrorCallback(FileError::ErrorCode& errorCode)
212 : m_errorCode(errorCode) 217 : m_errorCode(errorCode)
213 { 218 {
214 } 219 }
215 220
216 FileError::ErrorCode& m_errorCode; 221 FileError::ErrorCode& m_errorCode;
217 }; 222 };
218 223
219 } 224 }
220 225
221 PassRefPtr<FileWriterSync> DOMFileSystemSync::createWriter(const FileEntrySync* fileEntry, ExceptionState& exceptionState) 226 PassRefPtrWillBeRawPtr<FileWriterSync> DOMFileSystemSync::createWriter(const Fil eEntrySync* fileEntry, ExceptionState& exceptionState)
222 { 227 {
223 ASSERT(fileEntry); 228 ASSERT(fileEntry);
224 229
225 RefPtr<FileWriterSync> fileWriter = FileWriterSync::create(); 230 RefPtrWillBeRawPtr<FileWriterSync> fileWriter = FileWriterSync::create();
226 OwnPtr<ReceiveFileWriterCallback> successCallback = ReceiveFileWriterCallbac k::create(); 231 OwnPtr<ReceiveFileWriterCallback> successCallback = ReceiveFileWriterCallbac k::create();
227 FileError::ErrorCode errorCode = FileError::OK; 232 FileError::ErrorCode errorCode = FileError::OK;
228 OwnPtr<LocalErrorCallback> errorCallback = LocalErrorCallback::create(errorC ode); 233 OwnPtr<LocalErrorCallback> errorCallback = LocalErrorCallback::create(errorC ode);
229 234
230 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileWriterBaseCallbacks::create (fileWriter, successCallback.release(), errorCallback.release()); 235 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileWriterBaseCallbacks::create (fileWriter, successCallback.release(), errorCallback.release());
231 callbacks->setShouldBlockUntilCompletion(true); 236 callbacks->setShouldBlockUntilCompletion(true);
232 237
233 fileSystem()->createFileWriter(createFileSystemURL(fileEntry), fileWriter.ge t(), callbacks.release()); 238 fileSystem()->createFileWriter(createFileSystemURL(fileEntry), fileWriter.ge t(), callbacks.release());
234 if (errorCode != FileError::OK) { 239 if (errorCode != FileError::OK) {
235 FileError::throwDOMException(exceptionState, errorCode); 240 FileError::throwDOMException(exceptionState, errorCode);
236 return nullptr; 241 return nullptr;
237 } 242 }
238 return fileWriter.release(); 243 return fileWriter.release();
239 } 244 }
240 245
241 } 246 }
OLDNEW
« no previous file with comments | « Source/modules/filesystem/DOMFileSystemSync.h ('k') | Source/modules/filesystem/DOMFileSystemSync.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698