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 class FilePath; | |
15 | |
14 namespace gdata { | 16 namespace gdata { |
15 | 17 |
16 class DocumentsServiceInterface; | 18 class DocumentsServiceInterface; |
17 class DriveWebAppsRegistry; | 19 class DriveWebAppsRegistry; |
18 class GDataCache; | 20 class GDataCache; |
19 class GDataDownloadObserver; | 21 class GDataDownloadObserver; |
20 class GDataFileSystemInterface; | 22 class GDataFileSystemInterface; |
21 class GDataSyncClient; | 23 class GDataSyncClient; |
22 class GDataUploader; | 24 class GDataUploader; |
23 | 25 |
(...skipping 22 matching lines...) Expand all Loading... | |
46 | 48 |
47 // ProfileKeyedService override: | 49 // ProfileKeyedService override: |
48 virtual void Shutdown() OVERRIDE; | 50 virtual void Shutdown() OVERRIDE; |
49 | 51 |
50 private: | 52 private: |
51 explicit GDataSystemService(Profile* profile); | 53 explicit GDataSystemService(Profile* profile); |
52 virtual ~GDataSystemService(); | 54 virtual ~GDataSystemService(); |
53 | 55 |
54 // Initializes the object. This function should be called before any | 56 // Initializes the object. This function should be called before any |
55 // other functions. | 57 // other functions. |
56 void Initialize(DocumentsServiceInterface* documents_service); | 58 void Initialize(DocumentsServiceInterface* documents_service, |
59 const FilePath& cache_root); | |
57 | 60 |
58 // Registers remote file system proxy for drive mount point. | 61 // Registers remote file system proxy for drive mount point. |
59 void AddDriveMountPoint(); | 62 void AddDriveMountPoint(); |
60 // Unregisters drive mount point from File API. | 63 // Unregisters drive mount point from File API. |
61 void RemoveDriveMountPoint(); | 64 void RemoveDriveMountPoint(); |
62 | 65 |
63 friend class GDataSystemServiceFactory; | 66 friend class GDataSystemServiceFactory; |
64 | 67 |
65 Profile* profile_; | 68 Profile* profile_; |
66 const base::SequencedWorkerPool::SequenceToken sequence_token_; | 69 const base::SequencedWorkerPool::SequenceToken sequence_token_; |
(...skipping 15 matching lines...) Expand all Loading... | |
82 // Returns the GDataSystemService for |profile|, creating it if it is not | 85 // Returns the GDataSystemService for |profile|, creating it if it is not |
83 // yet created. | 86 // yet created. |
84 static GDataSystemService* GetForProfile(Profile* profile); | 87 static GDataSystemService* GetForProfile(Profile* profile); |
85 // Returns the GDataSystemService that is already associated with |profile|, | 88 // Returns the GDataSystemService that is already associated with |profile|, |
86 // if it is not yet created it will return NULL. | 89 // if it is not yet created it will return NULL. |
87 static GDataSystemService* FindForProfile(Profile* profile); | 90 static GDataSystemService* FindForProfile(Profile* profile); |
88 | 91 |
89 // Returns the GDataSystemServiceFactory instance. | 92 // Returns the GDataSystemServiceFactory instance. |
90 static GDataSystemServiceFactory* GetInstance(); | 93 static GDataSystemServiceFactory* GetInstance(); |
91 | 94 |
92 // Just creates a new instance without initializing most of the fields. | 95 // Sets documents service that should be used to initialize file system in |
93 // This is useful for tests such as injecting mocks. | 96 // test. Should be called before the service is created. |
94 static ProfileKeyedService* CreateInstance(Profile* profile); | 97 static void set_documents_service_for_test( |
98 DocumentsServiceInterface* documents_service); | |
95 | 99 |
96 // Returns GDataSystemService for testing, with |documents_service| injected | 100 // Sets root path for the cache used in test. Should be called before the |
97 // to GDataFileSystem. | 101 // service is created. |
98 GDataSystemService* GetWithCustomDocumentsServiceForTesting( | 102 static void set_cache_root_for_test(const char* cache_root); |
satorux1
2012/07/20 17:01:25
let's use a std::string.
const std::string&
tbarzic
2012/07/20 18:34:06
Done.
| |
99 Profile* profile, | |
100 DocumentsServiceInterface* documents_service); | |
101 | 103 |
102 private: | 104 private: |
103 friend struct DefaultSingletonTraits<GDataSystemServiceFactory>; | 105 friend struct DefaultSingletonTraits<GDataSystemServiceFactory>; |
104 | 106 |
105 GDataSystemServiceFactory(); | 107 GDataSystemServiceFactory(); |
106 virtual ~GDataSystemServiceFactory(); | 108 virtual ~GDataSystemServiceFactory(); |
107 | 109 |
108 // ProfileKeyedServiceFactory: | 110 // ProfileKeyedServiceFactory: |
109 virtual ProfileKeyedService* BuildServiceInstanceFor( | 111 virtual ProfileKeyedService* BuildServiceInstanceFor( |
110 Profile* profile) const OVERRIDE; | 112 Profile* profile) const OVERRIDE; |
113 | |
114 static DocumentsServiceInterface* test_documents_service_; | |
115 static const char* test_cache_root_; | |
satorux1
2012/07/20 17:01:25
static std::string* test_cache_root_
can we just
tbarzic
2012/07/20 18:34:06
Done.
| |
111 }; | 116 }; |
112 | 117 |
113 } // namespace gdata | 118 } // namespace gdata |
114 | 119 |
115 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_SYSTEM_SERVICE_H_ | 120 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_SYSTEM_SERVICE_H_ |
OLD | NEW |