Chromium Code Reviews| 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. |
|
yzshen1
2013/05/02 23:22:01
You can delete this class entirely.
victorhsieh
2013/05/03 17:26:58
Done.
|
| +// 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 |