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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h " 5 #include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h "
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "content/browser/renderer_host/pepper/pepper_file_io_host.h" 9 #include "content/browser/renderer_host/pepper/pepper_file_io_host.h"
10 #include "content/browser/renderer_host/pepper/quota_reservation.h" 10 #include "content/browser/renderer_host/pepper/quota_reservation.h"
11 #include "content/common/pepper_file_util.h" 11 #include "content/common/pepper_file_util.h"
12 #include "content/public/browser/browser_ppapi_host.h" 12 #include "content/public/browser/browser_ppapi_host.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/plugin_service.h" 14 #include "content/public/browser/plugin_service.h"
15 #include "content/public/browser/render_process_host.h" 15 #include "content/public/browser/render_process_host.h"
16 #include "content/public/browser/storage_partition.h" 16 #include "content/public/browser/storage_partition.h"
17 #include "content/public/common/pepper_plugin_info.h" 17 #include "content/public/common/pepper_plugin_info.h"
18 #include "net/base/mime_util.h" 18 #include "net/base/mime_util.h"
19 #include "ppapi/c/pp_errors.h" 19 #include "ppapi/c/pp_errors.h"
20 #include "ppapi/host/dispatch_host_message.h" 20 #include "ppapi/host/dispatch_host_message.h"
21 #include "ppapi/host/ppapi_host.h" 21 #include "ppapi/host/ppapi_host.h"
22 #include "ppapi/proxy/ppapi_messages.h" 22 #include "ppapi/proxy/ppapi_messages.h"
23 #include "ppapi/shared_impl/file_system_util.h" 23 #include "ppapi/shared_impl/file_system_util.h"
24 #include "ppapi/shared_impl/file_type_conversion.h" 24 #include "ppapi/shared_impl/file_type_conversion.h"
25 #include "webkit/browser/fileapi/file_system_operation_runner.h" 25 #include "storage/browser/fileapi/file_system_operation_runner.h"
26 #include "webkit/browser/fileapi/isolated_context.h" 26 #include "storage/browser/fileapi/isolated_context.h"
27 #include "webkit/browser/quota/quota_manager_proxy.h" 27 #include "storage/browser/quota/quota_manager_proxy.h"
28 #include "webkit/common/fileapi/file_system_util.h" 28 #include "storage/common/fileapi/file_system_util.h"
29 #include "webkit/common/quota/quota_types.h" 29 #include "storage/common/quota/quota_types.h"
30 30
31 namespace content { 31 namespace content {
32 32
33 namespace { 33 namespace {
34 34
35 // This is the minimum amount of quota we reserve per file system. 35 // This is the minimum amount of quota we reserve per file system.
36 const int64_t kMinimumQuotaReservationSize = 1024 * 1024; // 1 MB 36 const int64_t kMinimumQuotaReservationSize = 1024 * 1024; // 1 MB
37 37
38 scoped_refptr<fileapi::FileSystemContext> GetFileSystemContextFromRenderId( 38 scoped_refptr<storage::FileSystemContext> GetFileSystemContextFromRenderId(
39 int render_process_id) { 39 int render_process_id) {
40 DCHECK_CURRENTLY_ON(BrowserThread::UI); 40 DCHECK_CURRENTLY_ON(BrowserThread::UI);
41 RenderProcessHost* host = RenderProcessHost::FromID(render_process_id); 41 RenderProcessHost* host = RenderProcessHost::FromID(render_process_id);
42 if (!host) 42 if (!host)
43 return NULL; 43 return NULL;
44 StoragePartition* storage_partition = host->GetStoragePartition(); 44 StoragePartition* storage_partition = host->GetStoragePartition();
45 if (!storage_partition) 45 if (!storage_partition)
46 return NULL; 46 return NULL;
47 return storage_partition->GetFileSystemContext(); 47 return storage_partition->GetFileSystemContext();
48 } 48 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileSystem_ReserveQuota, 111 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileSystem_ReserveQuota,
112 OnHostMsgReserveQuota) 112 OnHostMsgReserveQuota)
113 PPAPI_END_MESSAGE_MAP() 113 PPAPI_END_MESSAGE_MAP()
114 return PP_ERROR_FAILED; 114 return PP_ERROR_FAILED;
115 } 115 }
116 116
117 bool PepperFileSystemBrowserHost::IsFileSystemHost() { return true; } 117 bool PepperFileSystemBrowserHost::IsFileSystemHost() { return true; }
118 118
119 void PepperFileSystemBrowserHost::OpenQuotaFile( 119 void PepperFileSystemBrowserHost::OpenQuotaFile(
120 PepperFileIOHost* file_io_host, 120 PepperFileIOHost* file_io_host,
121 const fileapi::FileSystemURL& url, 121 const storage::FileSystemURL& url,
122 const OpenQuotaFileCallback& callback) { 122 const OpenQuotaFileCallback& callback) {
123 int32_t id = file_io_host->pp_resource(); 123 int32_t id = file_io_host->pp_resource();
124 std::pair<FileMap::iterator, bool> insert_result = 124 std::pair<FileMap::iterator, bool> insert_result =
125 files_.insert(std::make_pair(id, file_io_host)); 125 files_.insert(std::make_pair(id, file_io_host));
126 if (insert_result.second) { 126 if (insert_result.second) {
127 base::PostTaskAndReplyWithResult( 127 base::PostTaskAndReplyWithResult(
128 file_system_context_->default_file_task_runner(), 128 file_system_context_->default_file_task_runner(),
129 FROM_HERE, 129 FROM_HERE,
130 base::Bind(&QuotaReservation::OpenFile, quota_reservation_, id, url), 130 base::Bind(&QuotaReservation::OpenFile, quota_reservation_, id, url),
131 callback); 131 callback);
(...skipping 24 matching lines...) Expand all
156 ppapi::host::HostMessageContext* context, 156 ppapi::host::HostMessageContext* context,
157 int64_t /* unused */) { 157 int64_t /* unused */) {
158 // TODO(raymes): The file system size is now unused by FileSystemDispatcher. 158 // TODO(raymes): The file system size is now unused by FileSystemDispatcher.
159 // Figure out why. Why is the file system size signed? 159 // Figure out why. Why is the file system size signed?
160 160
161 // Not allow multiple opens. 161 // Not allow multiple opens.
162 if (called_open_) 162 if (called_open_)
163 return PP_ERROR_INPROGRESS; 163 return PP_ERROR_INPROGRESS;
164 called_open_ = true; 164 called_open_ = true;
165 165
166 fileapi::FileSystemType file_system_type = 166 storage::FileSystemType file_system_type =
167 PepperFileSystemTypeToFileSystemType(type_); 167 PepperFileSystemTypeToFileSystemType(type_);
168 if (file_system_type == fileapi::kFileSystemTypeUnknown) 168 if (file_system_type == storage::kFileSystemTypeUnknown)
169 return PP_ERROR_FAILED; 169 return PP_ERROR_FAILED;
170 170
171 int render_process_id = 0; 171 int render_process_id = 0;
172 int unused; 172 int unused;
173 if (!browser_ppapi_host_->GetRenderFrameIDsForInstance( 173 if (!browser_ppapi_host_->GetRenderFrameIDsForInstance(
174 pp_instance(), &render_process_id, &unused)) { 174 pp_instance(), &render_process_id, &unused)) {
175 return PP_ERROR_FAILED; 175 return PP_ERROR_FAILED;
176 } 176 }
177 177
178 BrowserThread::PostTaskAndReplyWithResult( 178 BrowserThread::PostTaskAndReplyWithResult(
179 BrowserThread::UI, 179 BrowserThread::UI,
180 FROM_HERE, 180 FROM_HERE,
181 base::Bind(&GetFileSystemContextFromRenderId, render_process_id), 181 base::Bind(&GetFileSystemContextFromRenderId, render_process_id),
182 base::Bind(&PepperFileSystemBrowserHost::OpenFileSystem, 182 base::Bind(&PepperFileSystemBrowserHost::OpenFileSystem,
183 weak_factory_.GetWeakPtr(), 183 weak_factory_.GetWeakPtr(),
184 context->MakeReplyMessageContext(), 184 context->MakeReplyMessageContext(),
185 file_system_type)); 185 file_system_type));
186 return PP_OK_COMPLETIONPENDING; 186 return PP_OK_COMPLETIONPENDING;
187 } 187 }
188 188
189 void PepperFileSystemBrowserHost::OpenExistingFileSystem( 189 void PepperFileSystemBrowserHost::OpenExistingFileSystem(
190 const base::Closure& callback, 190 const base::Closure& callback,
191 scoped_refptr<fileapi::FileSystemContext> file_system_context) { 191 scoped_refptr<storage::FileSystemContext> file_system_context) {
192 if (file_system_context.get()) { 192 if (file_system_context.get()) {
193 opened_ = true; 193 opened_ = true;
194 } else { 194 } else {
195 // If there is no file system context, we log a warning and continue with an 195 // If there is no file system context, we log a warning and continue with an
196 // invalid resource (which will produce errors when used), since we have no 196 // invalid resource (which will produce errors when used), since we have no
197 // way to communicate the error to the caller. 197 // way to communicate the error to the caller.
198 LOG(WARNING) << "Could not retrieve file system context."; 198 LOG(WARNING) << "Could not retrieve file system context.";
199 } 199 }
200 SetFileSystemContext(file_system_context); 200 SetFileSystemContext(file_system_context);
201 201
202 if (ShouldCreateQuotaReservation()) 202 if (ShouldCreateQuotaReservation())
203 CreateQuotaReservation(callback); 203 CreateQuotaReservation(callback);
204 else 204 else
205 callback.Run(); 205 callback.Run();
206 } 206 }
207 207
208 void PepperFileSystemBrowserHost::OpenFileSystem( 208 void PepperFileSystemBrowserHost::OpenFileSystem(
209 ppapi::host::ReplyMessageContext reply_context, 209 ppapi::host::ReplyMessageContext reply_context,
210 fileapi::FileSystemType file_system_type, 210 storage::FileSystemType file_system_type,
211 scoped_refptr<fileapi::FileSystemContext> file_system_context) { 211 scoped_refptr<storage::FileSystemContext> file_system_context) {
212 if (!file_system_context.get()) { 212 if (!file_system_context.get()) {
213 OpenFileSystemComplete( 213 OpenFileSystemComplete(
214 reply_context, GURL(), std::string(), base::File::FILE_ERROR_FAILED); 214 reply_context, GURL(), std::string(), base::File::FILE_ERROR_FAILED);
215 return; 215 return;
216 } 216 }
217 217
218 SetFileSystemContext(file_system_context); 218 SetFileSystemContext(file_system_context);
219 219
220 GURL origin = 220 GURL origin =
221 browser_ppapi_host_->GetDocumentURLForInstance(pp_instance()).GetOrigin(); 221 browser_ppapi_host_->GetDocumentURLForInstance(pp_instance()).GetOrigin();
222 file_system_context_->OpenFileSystem( 222 file_system_context_->OpenFileSystem(
223 origin, 223 origin,
224 file_system_type, 224 file_system_type,
225 fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, 225 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
226 base::Bind(&PepperFileSystemBrowserHost::OpenFileSystemComplete, 226 base::Bind(&PepperFileSystemBrowserHost::OpenFileSystemComplete,
227 weak_factory_.GetWeakPtr(), 227 weak_factory_.GetWeakPtr(),
228 reply_context)); 228 reply_context));
229 } 229 }
230 230
231 void PepperFileSystemBrowserHost::OpenFileSystemComplete( 231 void PepperFileSystemBrowserHost::OpenFileSystemComplete(
232 ppapi::host::ReplyMessageContext reply_context, 232 ppapi::host::ReplyMessageContext reply_context,
233 const GURL& root, 233 const GURL& root,
234 const std::string& /* unused */, 234 const std::string& /* unused */,
235 base::File::Error error) { 235 base::File::Error error) {
(...skipping 11 matching lines...) Expand all
247 return; 247 return;
248 } 248 }
249 } 249 }
250 SendReplyForFileSystem(reply_context, pp_error); 250 SendReplyForFileSystem(reply_context, pp_error);
251 } 251 }
252 252
253 void PepperFileSystemBrowserHost::OpenIsolatedFileSystem( 253 void PepperFileSystemBrowserHost::OpenIsolatedFileSystem(
254 ppapi::host::ReplyMessageContext reply_context, 254 ppapi::host::ReplyMessageContext reply_context,
255 const std::string& fsid, 255 const std::string& fsid,
256 PP_IsolatedFileSystemType_Private type, 256 PP_IsolatedFileSystemType_Private type,
257 scoped_refptr<fileapi::FileSystemContext> file_system_context) { 257 scoped_refptr<storage::FileSystemContext> file_system_context) {
258 if (!file_system_context.get()) { 258 if (!file_system_context.get()) {
259 SendReplyForIsolatedFileSystem(reply_context, fsid, PP_ERROR_FAILED); 259 SendReplyForIsolatedFileSystem(reply_context, fsid, PP_ERROR_FAILED);
260 return; 260 return;
261 } 261 }
262 SetFileSystemContext(file_system_context); 262 SetFileSystemContext(file_system_context);
263 263
264 root_url_ = GURL(fileapi::GetIsolatedFileSystemRootURIString( 264 root_url_ = GURL(storage::GetIsolatedFileSystemRootURIString(
265 browser_ppapi_host_->GetDocumentURLForInstance(pp_instance()).GetOrigin(), 265 browser_ppapi_host_->GetDocumentURLForInstance(pp_instance()).GetOrigin(),
266 fsid, 266 fsid,
267 ppapi::IsolatedFileSystemTypeToRootName(type))); 267 ppapi::IsolatedFileSystemTypeToRootName(type)));
268 if (!root_url_.is_valid()) { 268 if (!root_url_.is_valid()) {
269 SendReplyForIsolatedFileSystem(reply_context, fsid, PP_ERROR_FAILED); 269 SendReplyForIsolatedFileSystem(reply_context, fsid, PP_ERROR_FAILED);
270 return; 270 return;
271 } 271 }
272 272
273 switch (type) { 273 switch (type) {
274 case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_CRX: 274 case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_CRX:
275 opened_ = true; 275 opened_ = true;
276 SendReplyForIsolatedFileSystem(reply_context, fsid, PP_OK); 276 SendReplyForIsolatedFileSystem(reply_context, fsid, PP_OK);
277 return; 277 return;
278 case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_PLUGINPRIVATE: 278 case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_PLUGINPRIVATE:
279 OpenPluginPrivateFileSystem(reply_context, fsid, file_system_context_); 279 OpenPluginPrivateFileSystem(reply_context, fsid, file_system_context_);
280 return; 280 return;
281 default: 281 default:
282 NOTREACHED(); 282 NOTREACHED();
283 SendReplyForIsolatedFileSystem(reply_context, fsid, PP_ERROR_BADARGUMENT); 283 SendReplyForIsolatedFileSystem(reply_context, fsid, PP_ERROR_BADARGUMENT);
284 return; 284 return;
285 } 285 }
286 } 286 }
287 287
288 void PepperFileSystemBrowserHost::OpenPluginPrivateFileSystem( 288 void PepperFileSystemBrowserHost::OpenPluginPrivateFileSystem(
289 ppapi::host::ReplyMessageContext reply_context, 289 ppapi::host::ReplyMessageContext reply_context,
290 const std::string& fsid, 290 const std::string& fsid,
291 scoped_refptr<fileapi::FileSystemContext> file_system_context) { 291 scoped_refptr<storage::FileSystemContext> file_system_context) {
292 GURL origin = 292 GURL origin =
293 browser_ppapi_host_->GetDocumentURLForInstance(pp_instance()).GetOrigin(); 293 browser_ppapi_host_->GetDocumentURLForInstance(pp_instance()).GetOrigin();
294 if (!origin.is_valid()) { 294 if (!origin.is_valid()) {
295 SendReplyForIsolatedFileSystem(reply_context, fsid, PP_ERROR_FAILED); 295 SendReplyForIsolatedFileSystem(reply_context, fsid, PP_ERROR_FAILED);
296 return; 296 return;
297 } 297 }
298 298
299 const std::string& plugin_id = GeneratePluginId(GetPluginMimeType()); 299 const std::string& plugin_id = GeneratePluginId(GetPluginMimeType());
300 if (plugin_id.empty()) { 300 if (plugin_id.empty()) {
301 SendReplyForIsolatedFileSystem(reply_context, fsid, PP_ERROR_BADARGUMENT); 301 SendReplyForIsolatedFileSystem(reply_context, fsid, PP_ERROR_BADARGUMENT);
302 return; 302 return;
303 } 303 }
304 304
305 file_system_context->OpenPluginPrivateFileSystem( 305 file_system_context->OpenPluginPrivateFileSystem(
306 origin, 306 origin,
307 fileapi::kFileSystemTypePluginPrivate, 307 storage::kFileSystemTypePluginPrivate,
308 fsid, 308 fsid,
309 plugin_id, 309 plugin_id,
310 fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, 310 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
311 base::Bind( 311 base::Bind(
312 &PepperFileSystemBrowserHost::OpenPluginPrivateFileSystemComplete, 312 &PepperFileSystemBrowserHost::OpenPluginPrivateFileSystemComplete,
313 weak_factory_.GetWeakPtr(), 313 weak_factory_.GetWeakPtr(),
314 reply_context, 314 reply_context,
315 fsid)); 315 fsid));
316 } 316 }
317 317
318 void PepperFileSystemBrowserHost::OpenPluginPrivateFileSystemComplete( 318 void PepperFileSystemBrowserHost::OpenPluginPrivateFileSystemComplete(
319 ppapi::host::ReplyMessageContext reply_context, 319 ppapi::host::ReplyMessageContext reply_context,
320 const std::string& fsid, 320 const std::string& fsid,
321 base::File::Error error) { 321 base::File::Error error) {
322 int32 pp_error = ppapi::FileErrorToPepperError(error); 322 int32 pp_error = ppapi::FileErrorToPepperError(error);
323 if (pp_error == PP_OK) 323 if (pp_error == PP_OK)
324 opened_ = true; 324 opened_ = true;
325 SendReplyForIsolatedFileSystem(reply_context, fsid, pp_error); 325 SendReplyForIsolatedFileSystem(reply_context, fsid, pp_error);
326 } 326 }
327 327
328 int32_t PepperFileSystemBrowserHost::OnHostMsgInitIsolatedFileSystem( 328 int32_t PepperFileSystemBrowserHost::OnHostMsgInitIsolatedFileSystem(
329 ppapi::host::HostMessageContext* context, 329 ppapi::host::HostMessageContext* context,
330 const std::string& fsid, 330 const std::string& fsid,
331 PP_IsolatedFileSystemType_Private type) { 331 PP_IsolatedFileSystemType_Private type) {
332 // Do not allow multiple opens. 332 // Do not allow multiple opens.
333 if (called_open_) 333 if (called_open_)
334 return PP_ERROR_INPROGRESS; 334 return PP_ERROR_INPROGRESS;
335 called_open_ = true; 335 called_open_ = true;
336 336
337 // Do a sanity check. 337 // Do a sanity check.
338 if (!fileapi::ValidateIsolatedFileSystemId(fsid)) 338 if (!storage::ValidateIsolatedFileSystemId(fsid))
339 return PP_ERROR_BADARGUMENT; 339 return PP_ERROR_BADARGUMENT;
340 340
341 int render_process_id = 0; 341 int render_process_id = 0;
342 int unused; 342 int unused;
343 if (!browser_ppapi_host_->GetRenderFrameIDsForInstance( 343 if (!browser_ppapi_host_->GetRenderFrameIDsForInstance(
344 pp_instance(), &render_process_id, &unused)) { 344 pp_instance(), &render_process_id, &unused)) {
345 fileapi::IsolatedContext::GetInstance()->RevokeFileSystem(fsid); 345 storage::IsolatedContext::GetInstance()->RevokeFileSystem(fsid);
346 return PP_ERROR_FAILED; 346 return PP_ERROR_FAILED;
347 } 347 }
348 348
349 root_url_ = GURL(fileapi::GetIsolatedFileSystemRootURIString( 349 root_url_ = GURL(storage::GetIsolatedFileSystemRootURIString(
350 browser_ppapi_host_->GetDocumentURLForInstance(pp_instance()).GetOrigin(), 350 browser_ppapi_host_->GetDocumentURLForInstance(pp_instance()).GetOrigin(),
351 fsid, 351 fsid,
352 ppapi::IsolatedFileSystemTypeToRootName(type))); 352 ppapi::IsolatedFileSystemTypeToRootName(type)));
353 353
354 BrowserThread::PostTaskAndReplyWithResult( 354 BrowserThread::PostTaskAndReplyWithResult(
355 BrowserThread::UI, 355 BrowserThread::UI,
356 FROM_HERE, 356 FROM_HERE,
357 base::Bind(&GetFileSystemContextFromRenderId, render_process_id), 357 base::Bind(&GetFileSystemContextFromRenderId, render_process_id),
358 base::Bind(&PepperFileSystemBrowserHost::OpenIsolatedFileSystem, 358 base::Bind(&PepperFileSystemBrowserHost::OpenIsolatedFileSystem,
359 weak_factory_.GetWeakPtr(), 359 weak_factory_.GetWeakPtr(),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 int32_t pp_error) { 394 int32_t pp_error) {
395 reply_context.params.set_result(pp_error); 395 reply_context.params.set_result(pp_error);
396 host()->SendReply(reply_context, PpapiPluginMsg_FileSystem_OpenReply()); 396 host()->SendReply(reply_context, PpapiPluginMsg_FileSystem_OpenReply());
397 } 397 }
398 398
399 void PepperFileSystemBrowserHost::SendReplyForIsolatedFileSystem( 399 void PepperFileSystemBrowserHost::SendReplyForIsolatedFileSystem(
400 ppapi::host::ReplyMessageContext reply_context, 400 ppapi::host::ReplyMessageContext reply_context,
401 const std::string& fsid, 401 const std::string& fsid,
402 int32_t error) { 402 int32_t error) {
403 if (error != PP_OK) 403 if (error != PP_OK)
404 fileapi::IsolatedContext::GetInstance()->RevokeFileSystem(fsid); 404 storage::IsolatedContext::GetInstance()->RevokeFileSystem(fsid);
405 reply_context.params.set_result(error); 405 reply_context.params.set_result(error);
406 host()->SendReply(reply_context, 406 host()->SendReply(reply_context,
407 PpapiPluginMsg_FileSystem_InitIsolatedFileSystemReply()); 407 PpapiPluginMsg_FileSystem_InitIsolatedFileSystemReply());
408 } 408 }
409 409
410 void PepperFileSystemBrowserHost::SetFileSystemContext( 410 void PepperFileSystemBrowserHost::SetFileSystemContext(
411 scoped_refptr<fileapi::FileSystemContext> file_system_context) { 411 scoped_refptr<storage::FileSystemContext> file_system_context) {
412 file_system_context_ = file_system_context; 412 file_system_context_ = file_system_context;
413 if (type_ != PP_FILESYSTEMTYPE_EXTERNAL || root_url_.is_valid()) { 413 if (type_ != PP_FILESYSTEMTYPE_EXTERNAL || root_url_.is_valid()) {
414 file_system_operation_runner_ = 414 file_system_operation_runner_ =
415 file_system_context_->CreateFileSystemOperationRunner(); 415 file_system_context_->CreateFileSystemOperationRunner();
416 } 416 }
417 } 417 }
418 418
419 bool PepperFileSystemBrowserHost::ShouldCreateQuotaReservation() const { 419 bool PepperFileSystemBrowserHost::ShouldCreateQuotaReservation() const {
420 // Some file system types don't have quota. 420 // Some file system types don't have quota.
421 if (!ppapi::FileSystemTypeHasQuota(type_)) 421 if (!ppapi::FileSystemTypeHasQuota(type_))
422 return false; 422 return false;
423 423
424 // For file system types with quota, some origins have unlimited storage. 424 // For file system types with quota, some origins have unlimited storage.
425 quota::QuotaManagerProxy* quota_manager_proxy = 425 quota::QuotaManagerProxy* quota_manager_proxy =
426 file_system_context_->quota_manager_proxy(); 426 file_system_context_->quota_manager_proxy();
427 CHECK(quota_manager_proxy); 427 CHECK(quota_manager_proxy);
428 CHECK(quota_manager_proxy->quota_manager()); 428 CHECK(quota_manager_proxy->quota_manager());
429 fileapi::FileSystemType file_system_type = 429 storage::FileSystemType file_system_type =
430 PepperFileSystemTypeToFileSystemType(type_); 430 PepperFileSystemTypeToFileSystemType(type_);
431 return !quota_manager_proxy->quota_manager()->IsStorageUnlimited( 431 return !quota_manager_proxy->quota_manager()->IsStorageUnlimited(
432 root_url_.GetOrigin(), 432 root_url_.GetOrigin(),
433 fileapi::FileSystemTypeToQuotaStorageType(file_system_type)); 433 storage::FileSystemTypeToQuotaStorageType(file_system_type));
434 } 434 }
435 435
436 void PepperFileSystemBrowserHost::CreateQuotaReservation( 436 void PepperFileSystemBrowserHost::CreateQuotaReservation(
437 const base::Closure& callback) { 437 const base::Closure& callback) {
438 DCHECK(root_url_.is_valid()); 438 DCHECK(root_url_.is_valid());
439 base::PostTaskAndReplyWithResult( 439 base::PostTaskAndReplyWithResult(
440 file_system_context_->default_file_task_runner(), 440 file_system_context_->default_file_task_runner(),
441 FROM_HERE, 441 FROM_HERE,
442 base::Bind(&QuotaReservation::Create, 442 base::Bind(&QuotaReservation::Create,
443 file_system_context_, 443 file_system_context_,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it) && *it != '.' && *it != '_' && 501 if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it) && *it != '.' && *it != '_' &&
502 *it != '-') { 502 *it != '-') {
503 LOG(WARNING) << "Failed to generate a plugin id."; 503 LOG(WARNING) << "Failed to generate a plugin id.";
504 return std::string(); 504 return std::string();
505 } 505 }
506 } 506 }
507 return output; 507 return output;
508 } 508 }
509 509
510 } // namespace content 510 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698