| 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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| 11 #include "chrome/browser/profiles/profile_keyed_service.h" | 11 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 12 #include "chrome/browser/profiles/profile_keyed_service_factory.h" | 12 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
| 13 | 13 |
| 14 namespace gdata { | 14 namespace gdata { |
| 15 | 15 |
| 16 class DocumentsServiceInterface; | 16 class DocumentsServiceInterface; |
| 17 class DriveWebAppsRegistry; | 17 class DriveWebAppsRegistry; |
| 18 class GDataCache; | 18 class GDataCache; |
| 19 class GDataContactsService; |
| 19 class GDataDownloadObserver; | 20 class GDataDownloadObserver; |
| 20 class GDataFileSystemInterface; | 21 class GDataFileSystemInterface; |
| 21 class GDataSyncClient; | 22 class GDataSyncClient; |
| 22 class GDataUploader; | 23 class GDataUploader; |
| 23 | 24 |
| 24 // GDataSystemService runs the GData system, including the GData file system | 25 // GDataSystemService runs the GData system, including the GData file system |
| 25 // implementation for the file manager, and some other sub systems. | 26 // implementation for the file manager, and some other sub systems. |
| 26 // | 27 // |
| 27 // The class is essentially a container that manages lifetime of the objects | 28 // The class is essentially a container that manages lifetime of the objects |
| 28 // that are used to run the GData system. The GDataSystemService object is | 29 // that are used to run the GData system. The GDataSystemService object is |
| 29 // created per-profile. | 30 // created per-profile. |
| 30 class GDataSystemService : public ProfileKeyedService { | 31 class GDataSystemService : public ProfileKeyedService { |
| 31 public: | 32 public: |
| 32 // Returns the documents service instance. | |
| 33 DocumentsServiceInterface* docs_service() { return documents_service_.get(); } | 33 DocumentsServiceInterface* docs_service() { return documents_service_.get(); } |
| 34 | |
| 35 // Returns the cache instance. | |
| 36 GDataCache* cache() { return cache_; } | 34 GDataCache* cache() { return cache_; } |
| 37 | |
| 38 // Returns the file system instance. | |
| 39 GDataFileSystemInterface* file_system() { return file_system_.get(); } | 35 GDataFileSystemInterface* file_system() { return file_system_.get(); } |
| 40 | |
| 41 // Returns the uploader instance. | |
| 42 GDataUploader* uploader() { return uploader_.get(); } | 36 GDataUploader* uploader() { return uploader_.get(); } |
| 43 | 37 GDataContactsService* contacts_service() { return contacts_service_.get(); } |
| 44 // Returns the file system instance. | |
| 45 DriveWebAppsRegistry* webapps_registry() { return webapps_registry_.get(); } | 38 DriveWebAppsRegistry* webapps_registry() { return webapps_registry_.get(); } |
| 46 | 39 |
| 47 // ProfileKeyedService override: | 40 // ProfileKeyedService override: |
| 48 virtual void Shutdown() OVERRIDE; | 41 virtual void Shutdown() OVERRIDE; |
| 49 | 42 |
| 50 private: | 43 private: |
| 51 explicit GDataSystemService(Profile* profile); | 44 explicit GDataSystemService(Profile* profile); |
| 52 virtual ~GDataSystemService(); | 45 virtual ~GDataSystemService(); |
| 53 | 46 |
| 54 // Initializes the object. This function should be called before any | 47 // Initializes the object. This function should be called before any |
| 55 // other functions. | 48 // other functions. |
| 56 void Initialize(DocumentsServiceInterface* documents_service); | 49 void Initialize(DocumentsServiceInterface* documents_service); |
| 57 | 50 |
| 58 // Registers remote file system proxy for drive mount point. | 51 // Registers remote file system proxy for drive mount point. |
| 59 void AddDriveMountPoint(); | 52 void AddDriveMountPoint(); |
| 60 // Unregisters drive mount point from File API. | 53 // Unregisters drive mount point from File API. |
| 61 void RemoveDriveMountPoint(); | 54 void RemoveDriveMountPoint(); |
| 62 | 55 |
| 63 friend class GDataSystemServiceFactory; | 56 friend class GDataSystemServiceFactory; |
| 64 | 57 |
| 65 Profile* profile_; | 58 Profile* profile_; |
| 66 const base::SequencedWorkerPool::SequenceToken sequence_token_; | 59 const base::SequencedWorkerPool::SequenceToken sequence_token_; |
| 67 GDataCache* cache_; | 60 GDataCache* cache_; |
| 68 scoped_ptr<DocumentsServiceInterface> documents_service_; | 61 scoped_ptr<DocumentsServiceInterface> documents_service_; |
| 69 scoped_ptr<GDataUploader> uploader_; | 62 scoped_ptr<GDataUploader> uploader_; |
| 70 scoped_ptr<DriveWebAppsRegistry> webapps_registry_; | 63 scoped_ptr<DriveWebAppsRegistry> webapps_registry_; |
| 71 scoped_ptr<GDataFileSystemInterface> file_system_; | 64 scoped_ptr<GDataFileSystemInterface> file_system_; |
| 72 scoped_ptr<GDataDownloadObserver> download_observer_; | 65 scoped_ptr<GDataDownloadObserver> download_observer_; |
| 73 scoped_ptr<GDataSyncClient> sync_client_; | 66 scoped_ptr<GDataSyncClient> sync_client_; |
| 67 scoped_ptr<GDataContactsService> contacts_service_; |
| 74 | 68 |
| 75 DISALLOW_COPY_AND_ASSIGN(GDataSystemService); | 69 DISALLOW_COPY_AND_ASSIGN(GDataSystemService); |
| 76 }; | 70 }; |
| 77 | 71 |
| 78 // Singleton that owns all GDataSystemServices and associates them with | 72 // Singleton that owns all GDataSystemServices and associates them with |
| 79 // Profiles. | 73 // Profiles. |
| 80 class GDataSystemServiceFactory : public ProfileKeyedServiceFactory { | 74 class GDataSystemServiceFactory : public ProfileKeyedServiceFactory { |
| 81 public: | 75 public: |
| 82 // Returns the GDataSystemService for |profile|, creating it if it is not | 76 // Returns the GDataSystemService for |profile|, creating it if it is not |
| 83 // yet created. | 77 // yet created. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 106 virtual ~GDataSystemServiceFactory(); | 100 virtual ~GDataSystemServiceFactory(); |
| 107 | 101 |
| 108 // ProfileKeyedServiceFactory: | 102 // ProfileKeyedServiceFactory: |
| 109 virtual ProfileKeyedService* BuildServiceInstanceFor( | 103 virtual ProfileKeyedService* BuildServiceInstanceFor( |
| 110 Profile* profile) const OVERRIDE; | 104 Profile* profile) const OVERRIDE; |
| 111 }; | 105 }; |
| 112 | 106 |
| 113 } // namespace gdata | 107 } // namespace gdata |
| 114 | 108 |
| 115 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_SYSTEM_SERVICE_H_ | 109 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_SYSTEM_SERVICE_H_ |
| OLD | NEW |