Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / extensions / api / sync_file_system / sync_file_system_api.h
blob2d6ffd0cb81ad727341b1e502bb627b3fa891473
1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_API_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_API_H_
8 #include <map>
10 #include "chrome/browser/extensions/chrome_extension_function.h"
11 #include "chrome/browser/sync_file_system/conflict_resolution_policy.h"
12 #include "chrome/browser/sync_file_system/sync_file_status.h"
13 #include "chrome/browser/sync_file_system/sync_status_code.h"
14 #include "chrome/common/extensions/api/sync_file_system.h"
15 #include "storage/browser/fileapi/file_system_url.h"
16 #include "storage/common/quota/quota_types.h"
18 namespace storage {
19 class FileSystemContext;
22 namespace extensions {
24 class SyncFileSystemDeleteFileSystemFunction
25 : public ChromeAsyncExtensionFunction {
26 public:
27 // TODO(kinuko,calvinlo): Uncomment this or delete this class when
28 // we decide if we want to revive this function.
29 // DECLARE_EXTENSION_FUNCTION("syncFileSystem.deleteFileSystem",
30 // SYNCFILESYSTEM_DELETEFILESYSTEM)
32 protected:
33 ~SyncFileSystemDeleteFileSystemFunction() override {}
34 bool RunAsync() override;
36 private:
37 void DidDeleteFileSystem(base::File::Error error);
40 class SyncFileSystemGetFileStatusFunction
41 : public ChromeAsyncExtensionFunction {
42 public:
43 DECLARE_EXTENSION_FUNCTION("syncFileSystem.getFileStatus",
44 SYNCFILESYSTEM_GETFILESYNCSTATUS)
46 protected:
47 ~SyncFileSystemGetFileStatusFunction() override {}
48 bool RunAsync() override;
50 private:
51 void DidGetFileStatus(
52 const sync_file_system::SyncStatusCode sync_service_status,
53 const sync_file_system::SyncFileStatus sync_file_status);
56 class SyncFileSystemGetFileStatusesFunction
57 : public ChromeAsyncExtensionFunction {
58 public:
59 DECLARE_EXTENSION_FUNCTION("syncFileSystem.getFileStatuses",
60 SYNCFILESYSTEM_GETFILESYNCSTATUSES)
61 SyncFileSystemGetFileStatusesFunction();
63 protected:
64 ~SyncFileSystemGetFileStatusesFunction() override;
65 bool RunAsync() override;
67 private:
68 typedef std::pair<sync_file_system::SyncStatusCode,
69 sync_file_system::SyncFileStatus> FileStatusPair;
70 typedef std::map<storage::FileSystemURL,
71 FileStatusPair,
72 storage::FileSystemURL::Comparator> URLToStatusMap;
74 void DidGetFileStatus(const storage::FileSystemURL& file_system_url,
75 sync_file_system::SyncStatusCode sync_status_code,
76 sync_file_system::SyncFileStatus sync_file_statuses);
78 unsigned int num_expected_results_;
79 unsigned int num_results_received_;
80 URLToStatusMap file_sync_statuses_;
83 class SyncFileSystemGetUsageAndQuotaFunction
84 : public ChromeAsyncExtensionFunction {
85 public:
86 DECLARE_EXTENSION_FUNCTION("syncFileSystem.getUsageAndQuota",
87 SYNCFILESYSTEM_GETUSAGEANDQUOTA)
89 protected:
90 ~SyncFileSystemGetUsageAndQuotaFunction() override {}
91 bool RunAsync() override;
93 private:
94 void DidGetUsageAndQuota(storage::QuotaStatusCode status,
95 int64 usage,
96 int64 quota);
99 class SyncFileSystemRequestFileSystemFunction
100 : public ChromeAsyncExtensionFunction {
101 public:
102 DECLARE_EXTENSION_FUNCTION("syncFileSystem.requestFileSystem",
103 SYNCFILESYSTEM_REQUESTFILESYSTEM)
105 protected:
106 ~SyncFileSystemRequestFileSystemFunction() override {}
107 bool RunAsync() override;
109 private:
110 typedef SyncFileSystemRequestFileSystemFunction self;
112 // Returns the file system context for this extension.
113 storage::FileSystemContext* GetFileSystemContext();
115 void DidOpenFileSystem(const GURL& root_url,
116 const std::string& file_system_name,
117 base::File::Error error);
120 class SyncFileSystemSetConflictResolutionPolicyFunction
121 : public ChromeSyncExtensionFunction {
122 public:
123 DECLARE_EXTENSION_FUNCTION("syncFileSystem.setConflictResolutionPolicy",
124 SYNCFILESYSTEM_SETCONFLICTRESOLUTIONPOLICY)
126 protected:
127 ~SyncFileSystemSetConflictResolutionPolicyFunction() override {}
128 bool RunSync() override;
131 class SyncFileSystemGetConflictResolutionPolicyFunction
132 : public ChromeSyncExtensionFunction {
133 public:
134 DECLARE_EXTENSION_FUNCTION("syncFileSystem.getConflictResolutionPolicy",
135 SYNCFILESYSTEM_GETCONFLICTRESOLUTIONPOLICY)
137 protected:
138 ~SyncFileSystemGetConflictResolutionPolicyFunction() override {}
139 bool RunSync() override;
142 class SyncFileSystemGetServiceStatusFunction
143 : public ChromeSyncExtensionFunction {
144 public:
145 DECLARE_EXTENSION_FUNCTION("syncFileSystem.getServiceStatus",
146 SYNCFILESYSTEM_GETSERVICESTATUS)
148 protected:
149 ~SyncFileSystemGetServiceStatusFunction() override {}
150 bool RunSync() override;
153 } // namespace extensions
155 #endif // CHROME_BROWSER_EXTENSIONS_API_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_API_H_