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

Side by Side Diff: content/renderer/pepper/pepper_file_system_host.cc

Issue 26803004: PPAPI: Add PluginPrivateFileSystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: overhaul 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/renderer/pepper/pepper_file_system_host.h" 5 #include "content/renderer/pepper/pepper_file_system_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/child/child_thread.h" 9 #include "content/child/child_thread.h"
10 #include "content/child/fileapi/file_system_dispatcher.h" 10 #include "content/child/fileapi/file_system_dispatcher.h"
11 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 11 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
12 #include "content/public/renderer/render_view.h" 12 #include "content/public/renderer/render_view.h"
13 #include "content/public/renderer/renderer_ppapi_host.h" 13 #include "content/public/renderer/renderer_ppapi_host.h"
14 #include "ppapi/c/pp_errors.h" 14 #include "ppapi/c/pp_errors.h"
15 #include "ppapi/host/dispatch_host_message.h" 15 #include "ppapi/host/dispatch_host_message.h"
16 #include "ppapi/host/ppapi_host.h" 16 #include "ppapi/host/ppapi_host.h"
17 #include "ppapi/proxy/ppapi_messages.h" 17 #include "ppapi/proxy/ppapi_messages.h"
18 #include "ppapi/shared_impl/file_system_util.h"
18 #include "ppapi/shared_impl/file_type_conversion.h" 19 #include "ppapi/shared_impl/file_type_conversion.h"
19 #include "third_party/WebKit/public/web/WebDocument.h" 20 #include "third_party/WebKit/public/web/WebDocument.h"
20 #include "third_party/WebKit/public/web/WebFrame.h" 21 #include "third_party/WebKit/public/web/WebFrame.h"
21 #include "third_party/WebKit/public/web/WebView.h" 22 #include "third_party/WebKit/public/web/WebView.h"
22 #include "webkit/common/fileapi/file_system_util.h" 23 #include "webkit/common/fileapi/file_system_util.h"
23 24
24 namespace content { 25 namespace content {
25 26
26 namespace {
27
28 // TODO(nhiroki): Move this function somewhere else to be shared.
29 std::string IsolatedFileSystemTypeToRootName(
30 PP_IsolatedFileSystemType_Private type) {
31 switch (type) {
32 case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_INVALID:
33 break;
34 case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_CRX:
35 return "crxfs";
36 }
37 NOTREACHED() << type;
38 return std::string();
39 }
40
41 } // namespace
42
43 PepperFileSystemHost::PepperFileSystemHost(RendererPpapiHost* host, 27 PepperFileSystemHost::PepperFileSystemHost(RendererPpapiHost* host,
44 PP_Instance instance, 28 PP_Instance instance,
45 PP_Resource resource, 29 PP_Resource resource,
46 PP_FileSystemType type) 30 PP_FileSystemType type)
47 : ResourceHost(host->GetPpapiHost(), instance, resource), 31 : ResourceHost(host->GetPpapiHost(), instance, resource),
48 renderer_ppapi_host_(host), 32 renderer_ppapi_host_(host),
49 type_(type), 33 type_(type),
50 opened_(false), 34 opened_(false),
51 called_open_(false), 35 called_open_(false),
52 weak_factory_(this) { 36 weak_factory_(this) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // Do a sanity check. 142 // Do a sanity check.
159 if (!fileapi::ValidateIsolatedFileSystemId(fsid)) 143 if (!fileapi::ValidateIsolatedFileSystemId(fsid))
160 return PP_ERROR_BADARGUMENT; 144 return PP_ERROR_BADARGUMENT;
161 145
162 RenderView* view = 146 RenderView* view =
163 renderer_ppapi_host_->GetRenderViewForInstance(pp_instance()); 147 renderer_ppapi_host_->GetRenderViewForInstance(pp_instance());
164 if (!view) 148 if (!view)
165 return PP_ERROR_FAILED; 149 return PP_ERROR_FAILED;
166 150
167 const GURL& url = view->GetWebView()->mainFrame()->document().url(); 151 const GURL& url = view->GetWebView()->mainFrame()->document().url();
168 const std::string root_name = IsolatedFileSystemTypeToRootName(type); 152 const std::string root_name = ppapi::IsolatedFileSystemTypeToRootName(type);
169 if (root_name.empty()) 153 if (root_name.empty())
170 return PP_ERROR_BADARGUMENT; 154 return PP_ERROR_BADARGUMENT;
171 root_url_ = GURL(fileapi::GetIsolatedFileSystemRootURIString( 155 root_url_ = GURL(fileapi::GetIsolatedFileSystemRootURIString(
172 url.GetOrigin(), fsid, root_name)); 156 url.GetOrigin(), fsid, root_name));
173 opened_ = true; 157 opened_ = true;
174 return PP_OK; 158 return PP_OK;
175 } 159 }
176 160
177 } // namespace content 161 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698