OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/storage/sync_value_store_cache.h" | 5 #include "chrome/browser/extensions/api/storage/sync_value_store_cache.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "chrome/browser/extensions/api/storage/sync_storage_backend.h" | 9 #include "chrome/browser/extensions/api/storage/sync_storage_backend.h" |
10 #include "chrome/browser/sync/glue/sync_start_util.h" | 10 #include "chrome/browser/sync/glue/sync_start_util.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 static_cast<size_t>(api::storage::sync::MAX_ITEMS)}; | 28 static_cast<size_t>(api::storage::sync::MAX_ITEMS)}; |
29 return limits; | 29 return limits; |
30 } | 30 } |
31 | 31 |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 SyncValueStoreCache::SyncValueStoreCache( | 34 SyncValueStoreCache::SyncValueStoreCache( |
35 const scoped_refptr<ValueStoreFactory>& factory, | 35 const scoped_refptr<ValueStoreFactory>& factory, |
36 const scoped_refptr<SettingsObserverList>& observers, | 36 const scoped_refptr<SettingsObserverList>& observers, |
37 const base::FilePath& profile_path) | 37 const base::FilePath& profile_path) |
38 : initialized_(false), weak_ptr_factory_(this) { | 38 : initialized_(false) { |
39 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 39 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
40 | 40 |
41 // This post is safe since the destructor can only be invoked from the | 41 // This post is safe since the destructor can only be invoked from the |
42 // same message loop, and any potential post of a deletion task must come | 42 // same message loop, and any potential post of a deletion task must come |
43 // after the constructor returns. | 43 // after the constructor returns. |
44 BrowserThread::PostTask( | 44 BrowserThread::PostTask( |
45 BrowserThread::FILE, FROM_HERE, | 45 BrowserThread::FILE, FROM_HERE, |
46 base::Bind(&SyncValueStoreCache::InitOnFileThread, | 46 base::Bind(&SyncValueStoreCache::InitOnFileThread, |
47 base::Unretained(this), | 47 base::Unretained(this), |
48 factory, observers, profile_path)); | 48 factory, observers, profile_path)); |
49 } | 49 } |
50 | 50 |
51 SyncValueStoreCache::~SyncValueStoreCache() { | 51 SyncValueStoreCache::~SyncValueStoreCache() { |
52 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 52 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
53 } | 53 } |
54 | 54 |
55 base::WeakPtr<SyncValueStoreCache> SyncValueStoreCache::AsWeakPtr() { | |
56 return weak_ptr_factory_.GetWeakPtr(); | |
57 } | |
58 | |
59 syncer::SyncableService* SyncValueStoreCache::GetSyncableService( | 55 syncer::SyncableService* SyncValueStoreCache::GetSyncableService( |
60 syncer::ModelType type) const { | 56 syncer::ModelType type) const { |
61 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 57 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
62 DCHECK(initialized_); | 58 DCHECK(initialized_); |
63 | 59 |
64 switch (type) { | 60 switch (type) { |
65 case syncer::APP_SETTINGS: | 61 case syncer::APP_SETTINGS: |
66 return app_backend_.get(); | 62 return app_backend_.get(); |
67 case syncer::EXTENSION_SETTINGS: | 63 case syncer::EXTENSION_SETTINGS: |
68 return extension_backend_.get(); | 64 return extension_backend_.get(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 extension_backend_.reset(new SyncStorageBackend( | 99 extension_backend_.reset(new SyncStorageBackend( |
104 factory, | 100 factory, |
105 GetSyncQuotaLimits(), | 101 GetSyncQuotaLimits(), |
106 observers, | 102 observers, |
107 syncer::EXTENSION_SETTINGS, | 103 syncer::EXTENSION_SETTINGS, |
108 sync_start_util::GetFlareForSyncableService(profile_path))); | 104 sync_start_util::GetFlareForSyncableService(profile_path))); |
109 initialized_ = true; | 105 initialized_ = true; |
110 } | 106 } |
111 | 107 |
112 } // namespace extensions | 108 } // namespace extensions |
OLD | NEW |