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 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_SYSTEM_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_SYSTEM_SERVICE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_SYSTEM_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_SYSTEM_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
14 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" | 14 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" |
15 #include "chrome/browser/profiles/profile_keyed_service.h" | 15 #include "chrome/browser/profiles/profile_keyed_service.h" |
16 #include "chrome/browser/profiles/profile_keyed_service_factory.h" | 16 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
17 | 17 |
18 class FilePath; | 18 class FilePath; |
19 | 19 |
20 namespace gdata { | 20 namespace gdata { |
21 | 21 |
22 class DriveCache; | 22 class DriveCache; |
23 class DriveServiceInterface; | 23 class DriveServiceInterface; |
24 class DriveWebAppsRegistry; | 24 class DriveWebAppsRegistry; |
25 class FileWriteHelper; | 25 class FileWriteHelper; |
26 class GDataContactsService; | |
27 class GDataDownloadObserver; | 26 class GDataDownloadObserver; |
28 class GDataFileSystemInterface; | 27 class GDataFileSystemInterface; |
29 class GDataSyncClient; | 28 class GDataSyncClient; |
30 class GDataUploader; | 29 class GDataUploader; |
31 | 30 |
32 // GDataSystemService runs the GData system, including the GData file system | 31 // GDataSystemService runs the GData system, including the GData file system |
33 // implementation for the file manager, and some other sub systems. | 32 // implementation for the file manager, and some other sub systems. |
34 // | 33 // |
35 // The class is essentially a container that manages lifetime of the objects | 34 // The class is essentially a container that manages lifetime of the objects |
36 // that are used to run the GData system. The GDataSystemService object is | 35 // that are used to run the GData system. The GDataSystemService object is |
37 // created per-profile. | 36 // created per-profile. |
38 class GDataSystemService : public ProfileKeyedService { | 37 class GDataSystemService : public ProfileKeyedService { |
39 public: | 38 public: |
40 DriveServiceInterface* drive_service() { return drive_service_.get(); } | 39 DriveServiceInterface* drive_service() { return drive_service_.get(); } |
41 DriveCache* cache() { return cache_; } | 40 DriveCache* cache() { return cache_; } |
42 GDataFileSystemInterface* file_system() { return file_system_.get(); } | 41 GDataFileSystemInterface* file_system() { return file_system_.get(); } |
43 FileWriteHelper* file_write_helper() { return file_write_helper_.get(); } | 42 FileWriteHelper* file_write_helper() { return file_write_helper_.get(); } |
44 GDataUploader* uploader() { return uploader_.get(); } | 43 GDataUploader* uploader() { return uploader_.get(); } |
45 GDataContactsService* contacts_service() { return contacts_service_.get(); } | |
46 DriveWebAppsRegistry* webapps_registry() { return webapps_registry_.get(); } | 44 DriveWebAppsRegistry* webapps_registry() { return webapps_registry_.get(); } |
47 | 45 |
48 // Clears all the local cache files and in-memory data, and remounts the file | 46 // Clears all the local cache files and in-memory data, and remounts the file |
49 // system. | 47 // system. |
50 void ClearCacheAndRemountFileSystem( | 48 void ClearCacheAndRemountFileSystem( |
51 const base::Callback<void(bool)>& callback); | 49 const base::Callback<void(bool)>& callback); |
52 | 50 |
53 // ProfileKeyedService override: | 51 // ProfileKeyedService override: |
54 virtual void Shutdown() OVERRIDE; | 52 virtual void Shutdown() OVERRIDE; |
55 | 53 |
(...skipping 21 matching lines...) Expand all Loading... |
77 Profile* profile_; | 75 Profile* profile_; |
78 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 76 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
79 DriveCache* cache_; | 77 DriveCache* cache_; |
80 scoped_ptr<DriveServiceInterface> drive_service_; | 78 scoped_ptr<DriveServiceInterface> drive_service_; |
81 scoped_ptr<GDataUploader> uploader_; | 79 scoped_ptr<GDataUploader> uploader_; |
82 scoped_ptr<DriveWebAppsRegistry> webapps_registry_; | 80 scoped_ptr<DriveWebAppsRegistry> webapps_registry_; |
83 scoped_ptr<GDataFileSystemInterface> file_system_; | 81 scoped_ptr<GDataFileSystemInterface> file_system_; |
84 scoped_ptr<FileWriteHelper> file_write_helper_; | 82 scoped_ptr<FileWriteHelper> file_write_helper_; |
85 scoped_ptr<GDataDownloadObserver> download_observer_; | 83 scoped_ptr<GDataDownloadObserver> download_observer_; |
86 scoped_ptr<GDataSyncClient> sync_client_; | 84 scoped_ptr<GDataSyncClient> sync_client_; |
87 scoped_ptr<GDataContactsService> contacts_service_; | |
88 base::WeakPtrFactory<GDataSystemService> weak_ptr_factory_; | 85 base::WeakPtrFactory<GDataSystemService> weak_ptr_factory_; |
89 | 86 |
90 DISALLOW_COPY_AND_ASSIGN(GDataSystemService); | 87 DISALLOW_COPY_AND_ASSIGN(GDataSystemService); |
91 }; | 88 }; |
92 | 89 |
93 // Singleton that owns all GDataSystemServices and associates them with | 90 // Singleton that owns all GDataSystemServices and associates them with |
94 // Profiles. | 91 // Profiles. |
95 class GDataSystemServiceFactory : public ProfileKeyedServiceFactory { | 92 class GDataSystemServiceFactory : public ProfileKeyedServiceFactory { |
96 public: | 93 public: |
97 // Returns the GDataSystemService for |profile|, creating it if it is not | 94 // Returns the GDataSystemService for |profile|, creating it if it is not |
(...skipping 26 matching lines...) Expand all Loading... |
124 virtual ~GDataSystemServiceFactory(); | 121 virtual ~GDataSystemServiceFactory(); |
125 | 122 |
126 // ProfileKeyedServiceFactory: | 123 // ProfileKeyedServiceFactory: |
127 virtual ProfileKeyedService* BuildServiceInstanceFor( | 124 virtual ProfileKeyedService* BuildServiceInstanceFor( |
128 Profile* profile) const OVERRIDE; | 125 Profile* profile) const OVERRIDE; |
129 }; | 126 }; |
130 | 127 |
131 } // namespace gdata | 128 } // namespace gdata |
132 | 129 |
133 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_SYSTEM_SERVICE_H_ | 130 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_SYSTEM_SERVICE_H_ |
OLD | NEW |