OLD | NEW |
---|---|
(Empty) | |
1 // 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.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ppapi/host/file_system_registry.h" | |
6 | |
7 #include "googleurl/src/gurl.h" | |
8 | |
9 namespace ppapi { | |
10 namespace host { | |
11 | |
12 namespace { | |
13 | |
14 class NullFileSystemPeeker : public FileSystemRegistry::FileSystemPeeker { | |
15 public: | |
16 virtual PP_FileSystemType GetType() const OVERRIDE { | |
17 return PP_FILESYSTEMTYPE_INVALID; | |
18 } | |
19 virtual bool IsOpened() const OVERRIDE { return false; } | |
20 virtual const GURL& GetRootUrl() const OVERRIDE { return null_gurl_; } | |
21 | |
22 private: | |
23 const GURL null_gurl_; | |
24 }; | |
25 | |
26 NullFileSystemPeeker kNullObject; | |
27 | |
28 } // namespace | |
29 | |
30 FileSystemRegistry::FileSystemRegistry() { | |
31 } | |
32 | |
33 FileSystemRegistry::~FileSystemRegistry() { | |
34 } | |
35 | |
36 FileSystemRegistry* FileSystemRegistry::GetInstance() { | |
37 return Singleton<FileSystemRegistry>::get(); | |
38 } | |
39 | |
40 void FileSystemRegistry::Register( | |
41 PP_Instance instance, | |
42 PP_Resource resource, | |
43 const FileSystemRegistry::FileSystemPeeker* peeker) { | |
44 mapping_[std::make_pair(instance, resource)] = peeker; | |
45 } | |
46 | |
47 void FileSystemRegistry::Unregister(PP_Instance instance, | |
48 PP_Resource resource) { | |
49 mapping_.erase(std::make_pair(instance, resource)); | |
50 } | |
51 | |
52 const FileSystemRegistry::FileSystemPeeker& | |
53 FileSystemRegistry::LookUp( | |
54 PP_Instance instance, | |
55 PP_Resource resource) const { | |
56 ResourceMap::const_iterator iter = | |
57 mapping_.find(std::make_pair(instance, resource)); | |
58 return (iter != mapping_.end()) ? *(iter->second) : kNullObject; | |
59 } | |
60 | |
61 } // namespace host | |
62 } // namespace ppapi | |
OLD | NEW |