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

Unified Diff: ppapi/host/file_system_registry.cc

Issue 14188019: CRX FileSystem Pepper private API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 8 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: ppapi/host/file_system_registry.cc
diff --git a/ppapi/host/file_system_registry.cc b/ppapi/host/file_system_registry.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fbc9d5fda1fb8a9f3cf036f9f07e5b39481541ff
--- /dev/null
+++ b/ppapi/host/file_system_registry.cc
@@ -0,0 +1,62 @@
+// Copyright (c) 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 "ppapi/host/file_system_registry.h"
+
+#include "googleurl/src/gurl.h"
+
+namespace ppapi {
+namespace host {
+
+namespace {
+
+class NullFileSystemPeeker : public FileSystemRegistry::FileSystemPeeker {
+ public:
+ virtual PP_FileSystemType GetType() const OVERRIDE {
+ return PP_FILESYSTEMTYPE_INVALID;
+ }
+ virtual bool IsOpened() const OVERRIDE { return false; }
+ virtual const GURL& GetRootUrl() const OVERRIDE { return null_gurl_; }
+
+ private:
+ const GURL null_gurl_;
+};
+
+NullFileSystemPeeker kNullObject;
+
+} // namespace
+
+FileSystemRegistry::FileSystemRegistry() {
+}
+
+FileSystemRegistry::~FileSystemRegistry() {
+}
+
+FileSystemRegistry* FileSystemRegistry::GetInstance() {
+ return Singleton<FileSystemRegistry>::get();
+}
+
+void FileSystemRegistry::Register(
+ PP_Instance instance,
+ PP_Resource resource,
+ const FileSystemRegistry::FileSystemPeeker* peeker) {
+ mapping_[std::make_pair(instance, resource)] = peeker;
+}
+
+void FileSystemRegistry::Unregister(PP_Instance instance,
+ PP_Resource resource) {
+ mapping_.erase(std::make_pair(instance, resource));
+}
+
+const FileSystemRegistry::FileSystemPeeker&
+FileSystemRegistry::LookUp(
+ PP_Instance instance,
+ PP_Resource resource) const {
+ ResourceMap::const_iterator iter =
+ mapping_.find(std::make_pair(instance, resource));
+ return (iter != mapping_.end()) ? *(iter->second) : kNullObject;
+}
+
+} // namespace host
+} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698