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

Unified Diff: content/renderer/pepper/pepper_file_ref_renderer_host.cc

Issue 21966004: Pepper: Move FileRef to the "new" resource proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor fixes for dmichael Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/pepper/pepper_file_ref_renderer_host.cc
diff --git a/content/renderer/pepper/pepper_file_ref_renderer_host.cc b/content/renderer/pepper/pepper_file_ref_renderer_host.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f2964eaa0dcfcb15405b4506612fec7fec14c039
--- /dev/null
+++ b/content/renderer/pepper/pepper_file_ref_renderer_host.cc
@@ -0,0 +1,90 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/pepper/pepper_file_ref_renderer_host.h"
+
+#include <string>
+
+#include "base/files/file_path.h"
yzshen1 2013/09/04 18:31:49 nit: There are some duplicate includes. There is n
teravest 2013/09/04 19:28:46 Done.
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "net/base/escape.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/pp_file_info.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_resource.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/host/resource_host.h"
+#include "ppapi/shared_impl/file_ref_util.h"
+
+namespace content {
+
+PepperFileRefRendererHost::PepperFileRefRendererHost(
+ RendererPpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource,
+ PP_Resource file_system,
+ const std::string& internal_path)
+ : ResourceHost(host->GetPpapiHost(), instance, resource),
+ file_system_type_(PP_FILESYSTEMTYPE_INVALID),
+ internal_path_(internal_path) {
+ if (!ppapi::IsValidInternalPath(internal_path))
+ return;
+ ResourceHost* fs_host = host->GetPpapiHost()->GetResourceHost(file_system);
+ if (fs_host && fs_host->IsFileSystemHost()) {
+ fs_host_ = base::AsWeakPtr(static_cast<PepperFileSystemHost*>(fs_host));
+ file_system_type_ = fs_host_->GetType();
+ }
+}
+
yzshen1 2013/09/04 18:31:49 extra empty line.
teravest 2013/09/04 19:28:46 Done.
+
+PepperFileRefRendererHost::PepperFileRefRendererHost(
+ RendererPpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource,
+ const base::FilePath& external_path)
+ : ResourceHost(host->GetPpapiHost(), instance, resource),
+ file_system_type_(PP_FILESYSTEMTYPE_EXTERNAL),
+ external_path_(external_path) {
+ if (!ppapi::IsValidExternalPath(external_path))
+ file_system_type_ = PP_FILESYSTEMTYPE_INVALID;
+}
+
+PepperFileRefRendererHost::~PepperFileRefRendererHost() {
+}
+
+PP_FileSystemType PepperFileRefRendererHost::GetFileSystemType() const {
+ return file_system_type_;
+}
+
+GURL PepperFileRefRendererHost::GetFileSystemURL() const {
+ if (fs_host_.get() && fs_host_->IsOpened() &&
+ fs_host_->GetRootUrl().is_valid()) {
+ CHECK(!internal_path_.empty() && internal_path_[0] == '/');
+ // We strip off the leading slash when passing the URL to Resolve().
+ // Internal paths are required to be absolute, so we can require this.
+ return fs_host_->GetRootUrl().Resolve(
+ net::EscapePath(internal_path_.substr(1)));
+ }
+ return GURL();
+}
+
+base::FilePath PepperFileRefRendererHost::GetExternalFilePath() const {
+ if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL)
+ return base::FilePath();
+ return external_path_;
+}
+
+int32_t PepperFileRefRendererHost::OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) {
+ // We don't handle any messages from the plugin in this host.
+ NOTREACHED();
+ return PP_ERROR_FAILED;
+}
+
+bool PepperFileRefRendererHost::IsFileRefHost() {
+ return true;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698