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

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

Issue 33053002: Pepper: Move FileIO host from renderer to browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 1 month 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_ref_host.h" 5 #include "content/browser/renderer_host/pepper/pepper_file_ref_host.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "content/browser/renderer_host/pepper/pepper_external_file_ref_backend. h" 9 #include "content/browser/renderer_host/pepper/pepper_external_file_ref_backend. h"
10 #include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h " 10 #include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h "
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 47
48 ResourceHost* fs_resource_host = 48 ResourceHost* fs_resource_host =
49 host->GetPpapiHost()->GetResourceHost(file_system); 49 host->GetPpapiHost()->GetResourceHost(file_system);
50 if (fs_resource_host == NULL) { 50 if (fs_resource_host == NULL) {
51 DLOG(ERROR) << "Couldn't find FileSystem host: " << resource 51 DLOG(ERROR) << "Couldn't find FileSystem host: " << resource
52 << " path: " << path; 52 << " path: " << path;
53 return; 53 return;
54 } 54 }
55 55
56 PepperFileSystemBrowserHost* fs_host = NULL; 56 if (!fs_resource_host->IsFileSystemHost()) {
57 if (fs_resource_host->IsFileSystemHost())
58 fs_host = static_cast<PepperFileSystemBrowserHost*>(fs_resource_host);
59 if (fs_host == NULL) {
60 DLOG(ERROR) << "Filesystem PP_Resource is not PepperFileSystemBrowserHost"; 57 DLOG(ERROR) << "Filesystem PP_Resource is not PepperFileSystemBrowserHost";
61 return; 58 return;
62 } 59 }
63 60
64 fs_type_ = fs_host->GetType(); 61 PepperFileSystemBrowserHost* file_system_host =
62 static_cast<PepperFileSystemBrowserHost*>(fs_resource_host);
63 fs_type_ = file_system_host->GetType();
65 if ((fs_type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT) && 64 if ((fs_type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT) &&
66 (fs_type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY) && 65 (fs_type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY) &&
67 (fs_type_ != PP_FILESYSTEMTYPE_ISOLATED)) { 66 (fs_type_ != PP_FILESYSTEMTYPE_ISOLATED)) {
68 DLOG(ERROR) << "Unsupported filesystem type: " << fs_type_; 67 DLOG(ERROR) << "Unsupported filesystem type: " << fs_type_;
69 return; 68 return;
70 } 69 }
71 70
72 backend_.reset(new PepperInternalFileRefBackend( 71 backend_.reset(new PepperInternalFileRefBackend(
73 host->GetPpapiHost(), 72 host->GetPpapiHost(),
74 render_process_id, 73 render_process_id,
75 base::AsWeakPtr(fs_host), 74 file_system_host->AsWeakPtr(),
76 path)); 75 path));
77 } 76 }
78 77
79 PepperFileRefHost::PepperFileRefHost(BrowserPpapiHost* host, 78 PepperFileRefHost::PepperFileRefHost(BrowserPpapiHost* host,
80 PP_Instance instance, 79 PP_Instance instance,
81 PP_Resource resource, 80 PP_Resource resource,
82 const base::FilePath& external_path) 81 const base::FilePath& external_path)
83 : ResourceHost(host->GetPpapiHost(), instance, resource), 82 : ResourceHost(host->GetPpapiHost(), instance, resource),
84 host_(host), 83 host_(host),
85 fs_type_(PP_FILESYSTEMTYPE_EXTERNAL) { 84 fs_type_(PP_FILESYSTEMTYPE_EXTERNAL) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 244
246 int32_t PepperFileRefHost::OnGetAbsolutePath( 245 int32_t PepperFileRefHost::OnGetAbsolutePath(
247 ppapi::host::HostMessageContext* context) { 246 ppapi::host::HostMessageContext* context) {
248 if (!host_->GetPpapiHost()->permissions().HasPermission( 247 if (!host_->GetPpapiHost()->permissions().HasPermission(
249 ppapi::PERMISSION_PRIVATE)) 248 ppapi::PERMISSION_PRIVATE))
250 return PP_ERROR_NOACCESS; 249 return PP_ERROR_NOACCESS;
251 return backend_->GetAbsolutePath(context->MakeReplyMessageContext()); 250 return backend_->GetAbsolutePath(context->MakeReplyMessageContext());
252 } 251 }
253 252
254 } // namespace content 253 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698