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

Side by Side Diff: content/renderer/pepper/pepper_file_system_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 (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/common/pepper_file_util.h" 11 #include "content/common/pepper_file_util.h"
12 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 12 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
13 #include "content/public/renderer/render_view.h" 13 #include "content/public/renderer/render_view.h"
14 #include "content/public/renderer/renderer_ppapi_host.h" 14 #include "content/public/renderer/renderer_ppapi_host.h"
15 #include "ppapi/c/pp_errors.h" 15 #include "ppapi/c/pp_errors.h"
16 #include "ppapi/host/dispatch_host_message.h" 16 #include "ppapi/host/dispatch_host_message.h"
17 #include "ppapi/host/ppapi_host.h" 17 #include "ppapi/host/ppapi_host.h"
18 #include "ppapi/proxy/ppapi_messages.h" 18 #include "ppapi/proxy/ppapi_messages.h"
19 #include "ppapi/shared_impl/file_system_util.h" 19 #include "ppapi/shared_impl/file_system_util.h"
20 #include "ppapi/shared_impl/file_type_conversion.h" 20 #include "ppapi/shared_impl/file_type_conversion.h"
21 #include "third_party/WebKit/public/web/WebDocument.h" 21 #include "third_party/WebKit/public/web/WebDocument.h"
22 #include "third_party/WebKit/public/web/WebFrame.h" 22 #include "third_party/WebKit/public/web/WebFrame.h"
23 #include "third_party/WebKit/public/web/WebView.h" 23 #include "third_party/WebKit/public/web/WebView.h"
24 #include "webkit/common/fileapi/file_system_util.h" 24 #include "storage/common/fileapi/file_system_util.h"
25 25
26 namespace content { 26 namespace content {
27 27
28 PepperFileSystemHost::PepperFileSystemHost(RendererPpapiHost* host, 28 PepperFileSystemHost::PepperFileSystemHost(RendererPpapiHost* host,
29 PP_Instance instance, 29 PP_Instance instance,
30 PP_Resource resource, 30 PP_Resource resource,
31 PP_FileSystemType type) 31 PP_FileSystemType type)
32 : ResourceHost(host->GetPpapiHost(), instance, resource), 32 : ResourceHost(host->GetPpapiHost(), instance, resource),
33 renderer_ppapi_host_(host), 33 renderer_ppapi_host_(host),
34 type_(type), 34 type_(type),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 86
87 int32_t PepperFileSystemHost::OnHostMsgOpen( 87 int32_t PepperFileSystemHost::OnHostMsgOpen(
88 ppapi::host::HostMessageContext* context, 88 ppapi::host::HostMessageContext* context,
89 int64_t expected_size) { 89 int64_t expected_size) {
90 // Not allow multiple opens. 90 // Not allow multiple opens.
91 if (called_open_) 91 if (called_open_)
92 return PP_ERROR_INPROGRESS; 92 return PP_ERROR_INPROGRESS;
93 called_open_ = true; 93 called_open_ = true;
94 94
95 fileapi::FileSystemType file_system_type = 95 storage::FileSystemType file_system_type =
96 PepperFileSystemTypeToFileSystemType(type_); 96 PepperFileSystemTypeToFileSystemType(type_);
97 if (file_system_type == fileapi::kFileSystemTypeUnknown) 97 if (file_system_type == storage::kFileSystemTypeUnknown)
98 return PP_ERROR_FAILED; 98 return PP_ERROR_FAILED;
99 99
100 GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance()); 100 GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance());
101 if (!document_url.is_valid()) 101 if (!document_url.is_valid())
102 return PP_ERROR_FAILED; 102 return PP_ERROR_FAILED;
103 103
104 FileSystemDispatcher* file_system_dispatcher = 104 FileSystemDispatcher* file_system_dispatcher =
105 ChildThread::current()->file_system_dispatcher(); 105 ChildThread::current()->file_system_dispatcher();
106 reply_context_ = context->MakeReplyMessageContext(); 106 reply_context_ = context->MakeReplyMessageContext();
107 file_system_dispatcher->OpenFileSystem( 107 file_system_dispatcher->OpenFileSystem(
108 document_url.GetOrigin(), 108 document_url.GetOrigin(),
109 file_system_type, 109 file_system_type,
110 base::Bind(&PepperFileSystemHost::DidOpenFileSystem, 110 base::Bind(&PepperFileSystemHost::DidOpenFileSystem,
111 weak_factory_.GetWeakPtr()), 111 weak_factory_.GetWeakPtr()),
112 base::Bind(&PepperFileSystemHost::DidFailOpenFileSystem, 112 base::Bind(&PepperFileSystemHost::DidFailOpenFileSystem,
113 weak_factory_.GetWeakPtr())); 113 weak_factory_.GetWeakPtr()));
114 return PP_OK_COMPLETIONPENDING; 114 return PP_OK_COMPLETIONPENDING;
115 } 115 }
116 116
117 int32_t PepperFileSystemHost::OnHostMsgInitIsolatedFileSystem( 117 int32_t PepperFileSystemHost::OnHostMsgInitIsolatedFileSystem(
118 ppapi::host::HostMessageContext* context, 118 ppapi::host::HostMessageContext* context,
119 const std::string& fsid, 119 const std::string& fsid,
120 PP_IsolatedFileSystemType_Private type) { 120 PP_IsolatedFileSystemType_Private type) {
121 // Do not allow multiple opens. 121 // Do not allow multiple opens.
122 if (called_open_) 122 if (called_open_)
123 return PP_ERROR_INPROGRESS; 123 return PP_ERROR_INPROGRESS;
124 called_open_ = true; 124 called_open_ = true;
125 125
126 // Do a sanity check. 126 // Do a sanity check.
127 if (!fileapi::ValidateIsolatedFileSystemId(fsid)) 127 if (!storage::ValidateIsolatedFileSystemId(fsid))
128 return PP_ERROR_BADARGUMENT; 128 return PP_ERROR_BADARGUMENT;
129 129
130 RenderView* view = 130 RenderView* view =
131 renderer_ppapi_host_->GetRenderViewForInstance(pp_instance()); 131 renderer_ppapi_host_->GetRenderViewForInstance(pp_instance());
132 if (!view) 132 if (!view)
133 return PP_ERROR_FAILED; 133 return PP_ERROR_FAILED;
134 134
135 const GURL& url = view->GetWebView()->mainFrame()->document().url(); 135 const GURL& url = view->GetWebView()->mainFrame()->document().url();
136 const std::string root_name = ppapi::IsolatedFileSystemTypeToRootName(type); 136 const std::string root_name = ppapi::IsolatedFileSystemTypeToRootName(type);
137 if (root_name.empty()) 137 if (root_name.empty())
138 return PP_ERROR_BADARGUMENT; 138 return PP_ERROR_BADARGUMENT;
139 root_url_ = GURL(fileapi::GetIsolatedFileSystemRootURIString( 139 root_url_ = GURL(storage::GetIsolatedFileSystemRootURIString(
140 url.GetOrigin(), fsid, root_name)); 140 url.GetOrigin(), fsid, root_name));
141 opened_ = true; 141 opened_ = true;
142 return PP_OK; 142 return PP_OK;
143 } 143 }
144 144
145 } // namespace content 145 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_file_system_options.cc ('k') | content/renderer/pepper/resource_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698