OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api.h" | 5 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 std::string ErrorToString(SyncStatusCode code) { | 59 std::string ErrorToString(SyncStatusCode code) { |
60 return base::StringPrintf( | 60 return base::StringPrintf( |
61 kErrorMessage, | 61 kErrorMessage, |
62 sync_file_system::SyncStatusCodeToString(code), | 62 sync_file_system::SyncStatusCodeToString(code), |
63 static_cast<int>(code)); | 63 static_cast<int>(code)); |
64 } | 64 } |
65 | 65 |
66 } // namespace | 66 } // namespace |
67 | 67 |
68 bool SyncFileSystemDeleteFileSystemFunction::RunImpl() { | 68 bool SyncFileSystemDeleteFileSystemFunction::RunAsync() { |
69 std::string url; | 69 std::string url; |
70 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); | 70 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); |
71 | 71 |
72 scoped_refptr<fileapi::FileSystemContext> file_system_context = | 72 scoped_refptr<fileapi::FileSystemContext> file_system_context = |
73 BrowserContext::GetStoragePartition(GetProfile(), | 73 BrowserContext::GetStoragePartition(GetProfile(), |
74 render_view_host()->GetSiteInstance()) | 74 render_view_host()->GetSiteInstance()) |
75 ->GetFileSystemContext(); | 75 ->GetFileSystemContext(); |
76 fileapi::FileSystemURL file_system_url( | 76 fileapi::FileSystemURL file_system_url( |
77 file_system_context->CrackURL(GURL(url))); | 77 file_system_context->CrackURL(GURL(url))); |
78 | 78 |
(...skipping 27 matching lines...) Expand all Loading... |
106 error_ = ErrorToString(sync_file_system::FileErrorToSyncStatusCode(error)); | 106 error_ = ErrorToString(sync_file_system::FileErrorToSyncStatusCode(error)); |
107 SetResult(new base::FundamentalValue(false)); | 107 SetResult(new base::FundamentalValue(false)); |
108 SendResponse(false); | 108 SendResponse(false); |
109 return; | 109 return; |
110 } | 110 } |
111 | 111 |
112 SetResult(new base::FundamentalValue(true)); | 112 SetResult(new base::FundamentalValue(true)); |
113 SendResponse(true); | 113 SendResponse(true); |
114 } | 114 } |
115 | 115 |
116 bool SyncFileSystemRequestFileSystemFunction::RunImpl() { | 116 bool SyncFileSystemRequestFileSystemFunction::RunAsync() { |
117 // SyncFileSystem initialization is done in OpenFileSystem below, but we call | 117 // SyncFileSystem initialization is done in OpenFileSystem below, but we call |
118 // GetSyncFileSystemService here too to initialize sync event observer for | 118 // GetSyncFileSystemService here too to initialize sync event observer for |
119 // extensions API. | 119 // extensions API. |
120 GetSyncFileSystemService(GetProfile()); | 120 GetSyncFileSystemService(GetProfile()); |
121 | 121 |
122 // Initializes sync context for this extension and continue to open | 122 // Initializes sync context for this extension and continue to open |
123 // a new file system. | 123 // a new file system. |
124 BrowserThread::PostTask( | 124 BrowserThread::PostTask( |
125 BrowserThread::IO, FROM_HERE, | 125 BrowserThread::IO, FROM_HERE, |
126 Bind(&fileapi::FileSystemContext::OpenFileSystem, | 126 Bind(&fileapi::FileSystemContext::OpenFileSystem, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 return; | 161 return; |
162 } | 162 } |
163 | 163 |
164 base::DictionaryValue* dict = new base::DictionaryValue(); | 164 base::DictionaryValue* dict = new base::DictionaryValue(); |
165 SetResult(dict); | 165 SetResult(dict); |
166 dict->SetString("name", file_system_name); | 166 dict->SetString("name", file_system_name); |
167 dict->SetString("root", root_url.spec()); | 167 dict->SetString("root", root_url.spec()); |
168 SendResponse(true); | 168 SendResponse(true); |
169 } | 169 } |
170 | 170 |
171 bool SyncFileSystemGetFileStatusFunction::RunImpl() { | 171 bool SyncFileSystemGetFileStatusFunction::RunAsync() { |
172 std::string url; | 172 std::string url; |
173 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); | 173 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); |
174 | 174 |
175 scoped_refptr<fileapi::FileSystemContext> file_system_context = | 175 scoped_refptr<fileapi::FileSystemContext> file_system_context = |
176 BrowserContext::GetStoragePartition(GetProfile(), | 176 BrowserContext::GetStoragePartition(GetProfile(), |
177 render_view_host()->GetSiteInstance()) | 177 render_view_host()->GetSiteInstance()) |
178 ->GetFileSystemContext(); | 178 ->GetFileSystemContext(); |
179 fileapi::FileSystemURL file_system_url( | 179 fileapi::FileSystemURL file_system_url( |
180 file_system_context->CrackURL(GURL(url))); | 180 file_system_context->CrackURL(GURL(url))); |
181 | 181 |
(...skipping 18 matching lines...) Expand all Loading... |
200 SyncFileStatusToExtensionEnum(sync_file_status)); | 200 SyncFileStatusToExtensionEnum(sync_file_status)); |
201 SendResponse(true); | 201 SendResponse(true); |
202 } | 202 } |
203 | 203 |
204 SyncFileSystemGetFileStatusesFunction::SyncFileSystemGetFileStatusesFunction() { | 204 SyncFileSystemGetFileStatusesFunction::SyncFileSystemGetFileStatusesFunction() { |
205 } | 205 } |
206 | 206 |
207 SyncFileSystemGetFileStatusesFunction::~SyncFileSystemGetFileStatusesFunction( | 207 SyncFileSystemGetFileStatusesFunction::~SyncFileSystemGetFileStatusesFunction( |
208 ) {} | 208 ) {} |
209 | 209 |
210 bool SyncFileSystemGetFileStatusesFunction::RunImpl() { | 210 bool SyncFileSystemGetFileStatusesFunction::RunAsync() { |
211 // All FileEntries converted into array of URL Strings in JS custom bindings. | 211 // All FileEntries converted into array of URL Strings in JS custom bindings. |
212 base::ListValue* file_entry_urls = NULL; | 212 base::ListValue* file_entry_urls = NULL; |
213 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &file_entry_urls)); | 213 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &file_entry_urls)); |
214 | 214 |
215 scoped_refptr<fileapi::FileSystemContext> file_system_context = | 215 scoped_refptr<fileapi::FileSystemContext> file_system_context = |
216 BrowserContext::GetStoragePartition(GetProfile(), | 216 BrowserContext::GetStoragePartition(GetProfile(), |
217 render_view_host()->GetSiteInstance()) | 217 render_view_host()->GetSiteInstance()) |
218 ->GetFileSystemContext(); | 218 ->GetFileSystemContext(); |
219 | 219 |
220 // Map each file path->SyncFileStatus in the callback map. | 220 // Map each file path->SyncFileStatus in the callback map. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 277 |
278 if (file_error == sync_file_system::SYNC_STATUS_OK) | 278 if (file_error == sync_file_system::SYNC_STATUS_OK) |
279 continue; | 279 continue; |
280 dict->SetString("error", ErrorToString(file_error)); | 280 dict->SetString("error", ErrorToString(file_error)); |
281 } | 281 } |
282 SetResult(status_array); | 282 SetResult(status_array); |
283 | 283 |
284 SendResponse(true); | 284 SendResponse(true); |
285 } | 285 } |
286 | 286 |
287 bool SyncFileSystemGetUsageAndQuotaFunction::RunImpl() { | 287 bool SyncFileSystemGetUsageAndQuotaFunction::RunAsync() { |
288 std::string url; | 288 std::string url; |
289 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); | 289 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); |
290 | 290 |
291 scoped_refptr<fileapi::FileSystemContext> file_system_context = | 291 scoped_refptr<fileapi::FileSystemContext> file_system_context = |
292 BrowserContext::GetStoragePartition(GetProfile(), | 292 BrowserContext::GetStoragePartition(GetProfile(), |
293 render_view_host()->GetSiteInstance()) | 293 render_view_host()->GetSiteInstance()) |
294 ->GetFileSystemContext(); | 294 ->GetFileSystemContext(); |
295 fileapi::FileSystemURL file_system_url( | 295 fileapi::FileSystemURL file_system_url( |
296 file_system_context->CrackURL(GURL(url))); | 296 file_system_context->CrackURL(GURL(url))); |
297 | 297 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 | 376 |
377 bool SyncFileSystemGetServiceStatusFunction::RunSync() { | 377 bool SyncFileSystemGetServiceStatusFunction::RunSync() { |
378 sync_file_system::SyncFileSystemService* service = | 378 sync_file_system::SyncFileSystemService* service = |
379 GetSyncFileSystemService(GetProfile()); | 379 GetSyncFileSystemService(GetProfile()); |
380 results_ = api::sync_file_system::GetServiceStatus::Results::Create( | 380 results_ = api::sync_file_system::GetServiceStatus::Results::Create( |
381 SyncServiceStateToExtensionEnum(service->GetSyncServiceState())); | 381 SyncServiceStateToExtensionEnum(service->GetSyncServiceState())); |
382 return true; | 382 return true; |
383 } | 383 } |
384 | 384 |
385 } // namespace extensions | 385 } // namespace extensions |
OLD | NEW |