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/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
14 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" | |
13 #include "chrome/browser/profiles/profile_keyed_service.h" | 15 #include "chrome/browser/profiles/profile_keyed_service.h" |
14 #include "chrome/browser/profiles/profile_keyed_service_factory.h" | 16 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
15 | 17 |
16 class FilePath; | 18 class FilePath; |
17 | 19 |
18 namespace gdata { | 20 namespace gdata { |
19 | 21 |
20 class DocumentsServiceInterface; | 22 class DocumentsServiceInterface; |
21 class DriveWebAppsRegistry; | 23 class DriveWebAppsRegistry; |
22 class GDataCache; | 24 class GDataCache; |
(...skipping 11 matching lines...) Expand all Loading... | |
34 // created per-profile. | 36 // created per-profile. |
35 class GDataSystemService : public ProfileKeyedService { | 37 class GDataSystemService : public ProfileKeyedService { |
36 public: | 38 public: |
37 DocumentsServiceInterface* docs_service() { return documents_service_.get(); } | 39 DocumentsServiceInterface* docs_service() { return documents_service_.get(); } |
38 GDataCache* cache() { return cache_; } | 40 GDataCache* cache() { return cache_; } |
39 GDataFileSystemInterface* file_system() { return file_system_.get(); } | 41 GDataFileSystemInterface* file_system() { return file_system_.get(); } |
40 GDataUploader* uploader() { return uploader_.get(); } | 42 GDataUploader* uploader() { return uploader_.get(); } |
41 GDataContactsService* contacts_service() { return contacts_service_.get(); } | 43 GDataContactsService* contacts_service() { return contacts_service_.get(); } |
42 DriveWebAppsRegistry* webapps_registry() { return webapps_registry_.get(); } | 44 DriveWebAppsRegistry* webapps_registry() { return webapps_registry_.get(); } |
43 | 45 |
46 // Clears all the local cache files and resets cache-related information in | |
47 // the memory. | |
48 void ClearCache(const base::Callback<void(bool)>& callback); | |
satorux1
2012/08/03 17:17:31
I changed my mind. I think we should give it a mor
yoshiki
2012/08/03 18:23:15
Done.
| |
49 | |
44 // ProfileKeyedService override: | 50 // ProfileKeyedService override: |
45 virtual void Shutdown() OVERRIDE; | 51 virtual void Shutdown() OVERRIDE; |
46 | 52 |
47 private: | 53 private: |
48 explicit GDataSystemService(Profile* profile); | 54 explicit GDataSystemService(Profile* profile); |
49 virtual ~GDataSystemService(); | 55 virtual ~GDataSystemService(); |
50 | 56 |
51 // Initializes the object. This function should be called before any | 57 // Initializes the object. This function should be called before any |
52 // other functions. | 58 // other functions. |
53 void Initialize(DocumentsServiceInterface* documents_service, | 59 void Initialize(DocumentsServiceInterface* documents_service, |
54 const FilePath& cache_root); | 60 const FilePath& cache_root); |
55 | 61 |
56 // Registers remote file system proxy for drive mount point. | 62 // Registers remote file system proxy for drive mount point. |
57 void AddDriveMountPoint(); | 63 void AddDriveMountPoint(); |
58 // Unregisters drive mount point from File API. | 64 // Unregisters drive mount point from File API. |
59 void RemoveDriveMountPoint(); | 65 void RemoveDriveMountPoint(); |
60 | 66 |
67 // Adds back the drive mount point. Used to implement ClearCache(). | |
68 void AddBackDriveMountPoint(const base::Callback<void(bool)>& callback, | |
69 GDataFileError error, | |
70 const FilePath& file_path); | |
71 | |
61 friend class GDataSystemServiceFactory; | 72 friend class GDataSystemServiceFactory; |
62 | 73 |
63 Profile* profile_; | 74 Profile* profile_; |
64 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 75 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
65 GDataCache* cache_; | 76 GDataCache* cache_; |
66 scoped_ptr<DocumentsServiceInterface> documents_service_; | 77 scoped_ptr<DocumentsServiceInterface> documents_service_; |
67 scoped_ptr<GDataUploader> uploader_; | 78 scoped_ptr<GDataUploader> uploader_; |
68 scoped_ptr<DriveWebAppsRegistry> webapps_registry_; | 79 scoped_ptr<DriveWebAppsRegistry> webapps_registry_; |
69 scoped_ptr<GDataFileSystemInterface> file_system_; | 80 scoped_ptr<GDataFileSystemInterface> file_system_; |
70 scoped_ptr<GDataDownloadObserver> download_observer_; | 81 scoped_ptr<GDataDownloadObserver> download_observer_; |
71 scoped_ptr<GDataSyncClient> sync_client_; | 82 scoped_ptr<GDataSyncClient> sync_client_; |
72 scoped_ptr<GDataContactsService> contacts_service_; | 83 scoped_ptr<GDataContactsService> contacts_service_; |
84 base::WeakPtrFactory<GDataSystemService> weak_ptr_factory_; | |
73 | 85 |
74 DISALLOW_COPY_AND_ASSIGN(GDataSystemService); | 86 DISALLOW_COPY_AND_ASSIGN(GDataSystemService); |
75 }; | 87 }; |
76 | 88 |
77 // Singleton that owns all GDataSystemServices and associates them with | 89 // Singleton that owns all GDataSystemServices and associates them with |
78 // Profiles. | 90 // Profiles. |
79 class GDataSystemServiceFactory : public ProfileKeyedServiceFactory { | 91 class GDataSystemServiceFactory : public ProfileKeyedServiceFactory { |
80 public: | 92 public: |
81 // Returns the GDataSystemService for |profile|, creating it if it is not | 93 // Returns the GDataSystemService for |profile|, creating it if it is not |
82 // yet created. | 94 // yet created. |
(...skipping 26 matching lines...) Expand all Loading... | |
109 virtual ~GDataSystemServiceFactory(); | 121 virtual ~GDataSystemServiceFactory(); |
110 | 122 |
111 // ProfileKeyedServiceFactory: | 123 // ProfileKeyedServiceFactory: |
112 virtual ProfileKeyedService* BuildServiceInstanceFor( | 124 virtual ProfileKeyedService* BuildServiceInstanceFor( |
113 Profile* profile) const OVERRIDE; | 125 Profile* profile) const OVERRIDE; |
114 }; | 126 }; |
115 | 127 |
116 } // namespace gdata | 128 } // namespace gdata |
117 | 129 |
118 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_SYSTEM_SERVICE_H_ | 130 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_SYSTEM_SERVICE_H_ |
OLD | NEW |