Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(727)

Side by Side Diff: chrome/browser/extensions/api/sync_file_system/sync_file_system_api.cc

Issue 16190005: [SyncFileSystem] Stop referring to DriveFileSyncService from extension/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "chrome/browser/extensions/api/sync_file_system/extension_sync_event_ob server.h" 13 #include "chrome/browser/extensions/api/sync_file_system/extension_sync_event_ob server.h"
14 #include "chrome/browser/extensions/api/sync_file_system/extension_sync_event_ob server_factory.h" 14 #include "chrome/browser/extensions/api/sync_file_system/extension_sync_event_ob server_factory.h"
15 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api_he lpers.h" 15 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api_he lpers.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/sync_file_system/drive_file_sync_service.h"
18 #include "chrome/browser/sync_file_system/sync_file_system_service.h" 17 #include "chrome/browser/sync_file_system/sync_file_system_service.h"
19 #include "chrome/browser/sync_file_system/sync_file_system_service_factory.h" 18 #include "chrome/browser/sync_file_system/sync_file_system_service_factory.h"
20 #include "chrome/common/extensions/api/sync_file_system.h" 19 #include "chrome/common/extensions/api/sync_file_system.h"
21 #include "content/public/browser/browser_context.h" 20 #include "content/public/browser/browser_context.h"
22 #include "content/public/browser/render_view_host.h" 21 #include "content/public/browser/render_view_host.h"
23 #include "content/public/browser/storage_partition.h" 22 #include "content/public/browser/storage_partition.h"
24 #include "content/public/common/content_client.h" 23 #include "content/public/common/content_client.h"
25 #include "webkit/browser/fileapi/file_system_context.h" 24 #include "webkit/browser/fileapi/file_system_context.h"
26 #include "webkit/browser/fileapi/file_system_url.h" 25 #include "webkit/browser/fileapi/file_system_url.h"
27 #include "webkit/browser/fileapi/syncable/sync_file_status.h" 26 #include "webkit/browser/fileapi/syncable/sync_file_status.h"
28 #include "webkit/common/fileapi/file_system_types.h" 27 #include "webkit/common/fileapi/file_system_types.h"
29 #include "webkit/common/fileapi/file_system_util.h" 28 #include "webkit/common/fileapi/file_system_util.h"
30 #include "webkit/quota/quota_manager.h" 29 #include "webkit/quota/quota_manager.h"
31 30
32 using content::BrowserContext; 31 using content::BrowserContext;
33 using content::BrowserThread; 32 using content::BrowserThread;
34 using sync_file_system::ConflictResolutionPolicy; 33 using sync_file_system::ConflictResolutionPolicy;
35 using sync_file_system::SyncFileStatus; 34 using sync_file_system::SyncFileStatus;
36 using sync_file_system::SyncFileSystemServiceFactory; 35 using sync_file_system::SyncFileSystemServiceFactory;
37 using sync_file_system::SyncStatusCode; 36 using sync_file_system::SyncStatusCode;
38 37
39 namespace extensions { 38 namespace extensions {
40 39
41 namespace { 40 namespace {
42 41
43 // This is the only supported cloud backend service for now.
44 const char* const kDriveCloudService =
45 sync_file_system::DriveFileSyncService::kServiceName;
46
47 // Error messages. 42 // Error messages.
48 const char kFileError[] = "File error %d."; 43 const char kFileError[] = "File error %d.";
49 const char kQuotaError[] = "Quota error %d."; 44 const char kQuotaError[] = "Quota error %d.";
50 const char kUnsupportedConflictResolutionPolicy[] = 45 const char kUnsupportedConflictResolutionPolicy[] =
51 "Policy %s is not supported."; 46 "Policy %s is not supported.";
52 47
53 sync_file_system::SyncFileSystemService* GetSyncFileSystemService( 48 sync_file_system::SyncFileSystemService* GetSyncFileSystemService(
54 Profile* profile) { 49 Profile* profile) {
55 sync_file_system::SyncFileSystemService* service = 50 sync_file_system::SyncFileSystemService* service =
56 SyncFileSystemServiceFactory::GetForProfile(profile); 51 SyncFileSystemServiceFactory::GetForProfile(profile);
57 DCHECK(service); 52 DCHECK(service);
58 ExtensionSyncEventObserver* observer = 53 ExtensionSyncEventObserver* observer =
59 ExtensionSyncEventObserverFactory::GetForProfile(profile); 54 ExtensionSyncEventObserverFactory::GetForProfile(profile);
60 DCHECK(observer); 55 DCHECK(observer);
61 observer->InitializeForService(service, kDriveCloudService); 56 observer->InitializeForService(
57 service,
58 sync_file_system::SyncFileSystemService::GetDefaultServiceName());
kinuko 2013/05/29 14:12:20 I think this parameter can be dropped. (Not used b
62 return service; 59 return service;
63 } 60 }
64 61
65 } // namespace 62 } // namespace
66 63
67 bool SyncFileSystemDeleteFileSystemFunction::RunImpl() { 64 bool SyncFileSystemDeleteFileSystemFunction::RunImpl() {
68 std::string url; 65 std::string url;
69 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); 66 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url));
70 67
71 scoped_refptr<fileapi::FileSystemContext> file_system_context = 68 scoped_refptr<fileapi::FileSystemContext> file_system_context =
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 SetResult(base::Value::CreateBooleanValue(false)); 103 SetResult(base::Value::CreateBooleanValue(false));
107 SendResponse(false); 104 SendResponse(false);
108 return; 105 return;
109 } 106 }
110 107
111 SetResult(base::Value::CreateBooleanValue(true)); 108 SetResult(base::Value::CreateBooleanValue(true));
112 SendResponse(true); 109 SendResponse(true);
113 } 110 }
114 111
115 bool SyncFileSystemRequestFileSystemFunction::RunImpl() { 112 bool SyncFileSystemRequestFileSystemFunction::RunImpl() {
116 // Please note that Google Drive is the only supported cloud backend at this 113 // Please note that the default backing service is the only supported cloud
117 // time. However other functions which have already been written to 114 // backend at this time. However other functions which have already been
118 // accommodate different service names are being left as is to allow easier 115 // written to accommodate different service names are being left as is to
119 // future support for other backend services. (http://crbug.com/172562). 116 // allow easier future support for other backend services.
120 const std::string service_name = sync_file_system::DriveFileSyncService:: 117 // (http://crbug.com/172562).
121 kServiceName; 118 const std::string service_name =
119 sync_file_system::SyncFileSystemService::GetDefaultServiceName();
122 // Initializes sync context for this extension and continue to open 120 // Initializes sync context for this extension and continue to open
123 // a new file system. 121 // a new file system.
124 GetSyncFileSystemService(profile())-> 122 GetSyncFileSystemService(profile())->
125 InitializeForApp( 123 InitializeForApp(
126 GetFileSystemContext(), 124 GetFileSystemContext(),
127 service_name, 125 service_name,
kinuko 2013/05/29 14:12:20 Ditto, I think this parameter can be dropped.
128 source_url().GetOrigin(), 126 source_url().GetOrigin(),
129 base::Bind(&self::DidInitializeFileSystemContext, this, 127 base::Bind(&self::DidInitializeFileSystemContext, this,
130 service_name)); 128 service_name));
131 return true; 129 return true;
132 } 130 }
133 131
134 fileapi::FileSystemContext* 132 fileapi::FileSystemContext*
135 SyncFileSystemRequestFileSystemFunction::GetFileSystemContext() { 133 SyncFileSystemRequestFileSystemFunction::GetFileSystemContext() {
136 DCHECK(render_view_host()); 134 DCHECK(render_view_host());
137 return BrowserContext::GetStoragePartition( 135 return BrowserContext::GetStoragePartition(
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 DCHECK(service); 391 DCHECK(service);
394 api::sync_file_system::ConflictResolutionPolicy policy = 392 api::sync_file_system::ConflictResolutionPolicy policy =
395 ConflictResolutionPolicyToExtensionEnum( 393 ConflictResolutionPolicyToExtensionEnum(
396 service->GetConflictResolutionPolicy()); 394 service->GetConflictResolutionPolicy());
397 SetResult(Value::CreateStringValue( 395 SetResult(Value::CreateStringValue(
398 api::sync_file_system::ToString(policy))); 396 api::sync_file_system::ToString(policy)));
399 return true; 397 return true;
400 } 398 }
401 399
402 } // namespace extensions 400 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698