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_
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"
19 class FileSystemContext
;
22 namespace extensions
{
24 class SyncFileSystemDeleteFileSystemFunction
25 : public ChromeAsyncExtensionFunction
{
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)
33 ~SyncFileSystemDeleteFileSystemFunction() override
{}
34 bool RunAsync() override
;
37 void DidDeleteFileSystem(base::File::Error error
);
40 class SyncFileSystemGetFileStatusFunction
41 : public ChromeAsyncExtensionFunction
{
43 DECLARE_EXTENSION_FUNCTION("syncFileSystem.getFileStatus",
44 SYNCFILESYSTEM_GETFILESYNCSTATUS
)
47 ~SyncFileSystemGetFileStatusFunction() override
{}
48 bool RunAsync() override
;
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
{
59 DECLARE_EXTENSION_FUNCTION("syncFileSystem.getFileStatuses",
60 SYNCFILESYSTEM_GETFILESYNCSTATUSES
)
61 SyncFileSystemGetFileStatusesFunction();
64 ~SyncFileSystemGetFileStatusesFunction() override
;
65 bool RunAsync() override
;
68 typedef std::pair
<sync_file_system::SyncStatusCode
,
69 sync_file_system::SyncFileStatus
> FileStatusPair
;
70 typedef std::map
<storage::FileSystemURL
,
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
{
86 DECLARE_EXTENSION_FUNCTION("syncFileSystem.getUsageAndQuota",
87 SYNCFILESYSTEM_GETUSAGEANDQUOTA
)
90 ~SyncFileSystemGetUsageAndQuotaFunction() override
{}
91 bool RunAsync() override
;
94 void DidGetUsageAndQuota(storage::QuotaStatusCode status
,
99 class SyncFileSystemRequestFileSystemFunction
100 : public ChromeAsyncExtensionFunction
{
102 DECLARE_EXTENSION_FUNCTION("syncFileSystem.requestFileSystem",
103 SYNCFILESYSTEM_REQUESTFILESYSTEM
)
106 ~SyncFileSystemRequestFileSystemFunction() override
{}
107 bool RunAsync() override
;
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
{
123 DECLARE_EXTENSION_FUNCTION("syncFileSystem.setConflictResolutionPolicy",
124 SYNCFILESYSTEM_SETCONFLICTRESOLUTIONPOLICY
)
127 ~SyncFileSystemSetConflictResolutionPolicyFunction() override
{}
128 bool RunSync() override
;
131 class SyncFileSystemGetConflictResolutionPolicyFunction
132 : public ChromeSyncExtensionFunction
{
134 DECLARE_EXTENSION_FUNCTION("syncFileSystem.getConflictResolutionPolicy",
135 SYNCFILESYSTEM_GETCONFLICTRESOLUTIONPOLICY
)
138 ~SyncFileSystemGetConflictResolutionPolicyFunction() override
{}
139 bool RunSync() override
;
142 class SyncFileSystemGetServiceStatusFunction
143 : public ChromeSyncExtensionFunction
{
145 DECLARE_EXTENSION_FUNCTION("syncFileSystem.getServiceStatus",
146 SYNCFILESYSTEM_GETSERVICESTATUS
)
149 ~SyncFileSystemGetServiceStatusFunction() override
{}
150 bool RunSync() override
;
153 } // namespace extensions
155 #endif // CHROME_BROWSER_EXTENSIONS_API_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_API_H_