OLD | NEW |
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 Loading... |
69 errorCallback->handleEvent(fileError); | 69 errorCallback->handleEvent(fileError); |
70 } | 70 } |
71 | 71 |
72 DirectoryEntrySync* DOMFileSystemSync::root() | 72 DirectoryEntrySync* DOMFileSystemSync::root() |
73 { | 73 { |
74 return DirectoryEntrySync::create(this, DOMFilePath::root); | 74 return DirectoryEntrySync::create(this, DOMFilePath::root); |
75 } | 75 } |
76 | 76 |
77 namespace { | 77 namespace { |
78 | 78 |
79 class CreateFileHelper FINAL : public AsyncFileSystemCallbacks { | 79 class CreateFileHelper final : public AsyncFileSystemCallbacks { |
80 public: | 80 public: |
81 class CreateFileResult : public GarbageCollectedFinalized<CreateFileResult>
{ | 81 class CreateFileResult : public GarbageCollectedFinalized<CreateFileResult>
{ |
82 public: | 82 public: |
83 static CreateFileResult* create() | 83 static CreateFileResult* create() |
84 { | 84 { |
85 return new CreateFileResult(); | 85 return new CreateFileResult(); |
86 } | 86 } |
87 | 87 |
88 bool m_failed; | 88 bool m_failed; |
89 int m_code; | 89 int m_code; |
(...skipping 10 matching lines...) Expand all Loading... |
100 , m_code(0) | 100 , m_code(0) |
101 { | 101 { |
102 } | 102 } |
103 }; | 103 }; |
104 | 104 |
105 static PassOwnPtr<AsyncFileSystemCallbacks> create(CreateFileResult* result,
const String& name, const KURL& url, FileSystemType type) | 105 static PassOwnPtr<AsyncFileSystemCallbacks> create(CreateFileResult* result,
const String& name, const KURL& url, FileSystemType type) |
106 { | 106 { |
107 return adoptPtr(static_cast<AsyncFileSystemCallbacks*>(new CreateFileHel
per(result, name, url, type))); | 107 return adoptPtr(static_cast<AsyncFileSystemCallbacks*>(new CreateFileHel
per(result, name, url, type))); |
108 } | 108 } |
109 | 109 |
110 virtual void didFail(int code) OVERRIDE | 110 virtual void didFail(int code) override |
111 { | 111 { |
112 m_result->m_failed = true; | 112 m_result->m_failed = true; |
113 m_result->m_code = code; | 113 m_result->m_code = code; |
114 } | 114 } |
115 | 115 |
116 virtual ~CreateFileHelper() | 116 virtual ~CreateFileHelper() |
117 { | 117 { |
118 } | 118 } |
119 | 119 |
120 virtual void didCreateSnapshotFile(const FileMetadata& metadata, PassRefPtr<
BlobDataHandle> snapshot) OVERRIDE | 120 virtual void didCreateSnapshotFile(const FileMetadata& metadata, PassRefPtr<
BlobDataHandle> snapshot) override |
121 { | 121 { |
122 // We can't directly use the snapshot blob data handle because the conte
nt type on it hasn't been set. | 122 // We can't directly use the snapshot blob data handle because the conte
nt type on it hasn't been set. |
123 // The |snapshot| param is here to provide a a chain of custody thru thr
ead bridging that is held onto until | 123 // The |snapshot| param is here to provide a a chain of custody thru thr
ead bridging that is held onto until |
124 // *after* we've coined a File with a new handle that has the correct ty
pe set on it. This allows the | 124 // *after* we've coined a File with a new handle that has the correct ty
pe set on it. This allows the |
125 // blob storage system to track when a temp file can and can't be safely
deleted. | 125 // blob storage system to track when a temp file can and can't be safely
deleted. |
126 | 126 |
127 m_result->m_file = DOMFileSystemBase::createFile(metadata, m_url, m_type
, m_name); | 127 m_result->m_file = DOMFileSystemBase::createFile(metadata, m_url, m_type
, m_name); |
128 } | 128 } |
129 | 129 |
130 virtual bool shouldBlockUntilCompletion() const OVERRIDE | 130 virtual bool shouldBlockUntilCompletion() const override |
131 { | 131 { |
132 return true; | 132 return true; |
133 } | 133 } |
134 | 134 |
135 private: | 135 private: |
136 CreateFileHelper(CreateFileResult* result, const String& name, const KURL& u
rl, FileSystemType type) | 136 CreateFileHelper(CreateFileResult* result, const String& name, const KURL& u
rl, FileSystemType type) |
137 : m_result(result) | 137 : m_result(result) |
138 , m_name(name) | 138 , m_name(name) |
139 , m_url(url) | 139 , m_url(url) |
140 , m_type(type) | 140 , m_type(type) |
(...skipping 15 matching lines...) Expand all Loading... |
156 fileSystem()->createSnapshotFileAndReadMetadata(fileSystemURL, CreateFileHel
per::create(result, fileEntry->name(), fileSystemURL, type())); | 156 fileSystem()->createSnapshotFileAndReadMetadata(fileSystemURL, CreateFileHel
per::create(result, fileEntry->name(), fileSystemURL, type())); |
157 if (result->m_failed) { | 157 if (result->m_failed) { |
158 exceptionState.throwDOMException(result->m_code, "Could not create '" +
fileEntry->name() + "'."); | 158 exceptionState.throwDOMException(result->m_code, "Could not create '" +
fileEntry->name() + "'."); |
159 return nullptr; | 159 return nullptr; |
160 } | 160 } |
161 return result->m_file.get(); | 161 return result->m_file.get(); |
162 } | 162 } |
163 | 163 |
164 namespace { | 164 namespace { |
165 | 165 |
166 class ReceiveFileWriterCallback FINAL : public FileWriterBaseCallback { | 166 class ReceiveFileWriterCallback final : public FileWriterBaseCallback { |
167 public: | 167 public: |
168 static ReceiveFileWriterCallback* create() | 168 static ReceiveFileWriterCallback* create() |
169 { | 169 { |
170 return new ReceiveFileWriterCallback(); | 170 return new ReceiveFileWriterCallback(); |
171 } | 171 } |
172 | 172 |
173 virtual void handleEvent(FileWriterBase*) OVERRIDE | 173 virtual void handleEvent(FileWriterBase*) override |
174 { | 174 { |
175 } | 175 } |
176 | 176 |
177 private: | 177 private: |
178 ReceiveFileWriterCallback() | 178 ReceiveFileWriterCallback() |
179 { | 179 { |
180 } | 180 } |
181 }; | 181 }; |
182 | 182 |
183 class LocalErrorCallback FINAL : public ErrorCallback { | 183 class LocalErrorCallback final : public ErrorCallback { |
184 public: | 184 public: |
185 static LocalErrorCallback* create(FileError::ErrorCode& errorCode) | 185 static LocalErrorCallback* create(FileError::ErrorCode& errorCode) |
186 { | 186 { |
187 return new LocalErrorCallback(errorCode); | 187 return new LocalErrorCallback(errorCode); |
188 } | 188 } |
189 | 189 |
190 virtual void handleEvent(FileError* error) OVERRIDE | 190 virtual void handleEvent(FileError* error) override |
191 { | 191 { |
192 ASSERT(error->code() != FileError::OK); | 192 ASSERT(error->code() != FileError::OK); |
193 m_errorCode = error->code(); | 193 m_errorCode = error->code(); |
194 } | 194 } |
195 | 195 |
196 private: | 196 private: |
197 explicit LocalErrorCallback(FileError::ErrorCode& errorCode) | 197 explicit LocalErrorCallback(FileError::ErrorCode& errorCode) |
198 : m_errorCode(errorCode) | 198 : m_errorCode(errorCode) |
199 { | 199 { |
200 } | 200 } |
(...skipping 17 matching lines...) Expand all Loading... |
218 | 218 |
219 fileSystem()->createFileWriter(createFileSystemURL(fileEntry), fileWriter, c
allbacks.release()); | 219 fileSystem()->createFileWriter(createFileSystemURL(fileEntry), fileWriter, c
allbacks.release()); |
220 if (errorCode != FileError::OK) { | 220 if (errorCode != FileError::OK) { |
221 FileError::throwDOMException(exceptionState, errorCode); | 221 FileError::throwDOMException(exceptionState, errorCode); |
222 return 0; | 222 return 0; |
223 } | 223 } |
224 return fileWriter; | 224 return fileWriter; |
225 } | 225 } |
226 | 226 |
227 } | 227 } |
OLD | NEW |