| 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..0df0c111f1702a7a5466641c2904ec07ceda2965
|
| --- /dev/null
|
| +++ b/ppapi/host/file_system_registry.cc
|
| @@ -0,0 +1,59 @@
|
| +// 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 GURL GetRootUrl() const OVERRIDE { return 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
|
|
|