Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / webkit / chromeos / fileapi / file_access_permissions.h
blob5b6d010a4cdea3ae2839a35db179571065a0b3dd
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef WEBKIT_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_
6 #define WEBKIT_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_
8 #include <map>
9 #include <set>
10 #include <string>
12 #include "base/files/file_path.h"
13 #include "base/synchronization/lock.h"
15 namespace chromeos {
17 class FileAccessPermissions {
18 public:
19 FileAccessPermissions();
20 virtual ~FileAccessPermissions();
22 // Grants |extension_id| access to |path|.
23 void GrantAccessPermission(const std::string& extension_id,
24 const base::FilePath& path);
25 // Checks id |extension_id| has permission to access to |path|.
26 bool HasAccessPermission(const std::string& extension_id,
27 const base::FilePath& path) const;
28 // Revokes all file permissions for |extension_id|.
29 void RevokePermissions(const std::string& extension_id);
31 private:
32 typedef std::set<base::FilePath> PathSet;
33 typedef std::map<std::string, PathSet> PathAccessMap;
35 mutable base::Lock lock_; // Synchronize all access to path_map_.
36 PathAccessMap path_map_;
39 } // namespace chromeos
41 #endif // WEBKIT_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_