Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_UI_WRAPPER_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_UI_WRAPPER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/file_path.h" | |
|
akalin
2011/09/20 14:53:11
forward-declare FilePath instead
not at google - send to devlin
2011/09/21 00:20:14
Done.
| |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "base/callback.h" | |
| 12 #include "chrome/browser/extensions/extension_settings.h" | |
|
akalin
2011/09/20 14:53:11
forward-declare extension settings
not at google - send to devlin
2011/09/21 00:20:14
Done.
| |
| 13 #include "chrome/browser/sync/api/syncable_service.h" | |
| 14 | |
| 15 // Wrapper for an ExtensionSettings object for dealing with thread ownership. | |
| 16 // This class lives on the UI thread while ExtensionSettings object live on | |
| 17 // the FILE thread. | |
| 18 class ExtensionSettingsUIWrapper { | |
| 19 public: | |
| 20 explicit ExtensionSettingsUIWrapper(const FilePath& base_path); | |
| 21 | |
| 22 typedef base::Callback<void(ExtensionSettingsStorage*)> Callback; | |
|
akalin
2011/09/20 14:53:11
StorageCallback would be a better name
not at google - send to devlin
2011/09/21 00:20:14
Done.
| |
| 23 | |
| 24 // Runs |callback| on the FILE thread with the storage area for the extension | |
| 25 // with ID |extension_id|. | |
| 26 void RunWithStorage( | |
| 27 const std::string& extension_id, const Callback& callback); | |
| 28 | |
| 29 // Gets the SyncableService component of the ExtensionSettings. The service | |
| 30 // itself lives on the FILE thread. | |
| 31 SyncableService* GetSyncableService(); | |
|
akalin
2011/09/20 14:53:11
Add a comment saying this is needed for ProfileSyn
not at google - send to devlin
2011/09/21 00:20:14
Done.
| |
| 32 | |
| 33 ~ExtensionSettingsUIWrapper(); | |
| 34 | |
| 35 private: | |
| 36 // Ref-counted container for the ExtensionSettings object. Delegates | |
| 37 // SyncableService calls. | |
| 38 class Core : public base::RefCountedThreadSafe<Core>, public SyncableService { | |
| 39 public: | |
| 40 // Constructed on UI thread. | |
| 41 explicit Core(const FilePath& base_path); | |
| 42 | |
| 43 // Runs |callback| with the storage area for the extension with ID | |
| 44 // |extension_id|. Must be run on the FILE thread. | |
| 45 void RunWithStorageOnFileThread( | |
| 46 const std::string& extension_id, const Callback& callback); | |
| 47 | |
| 48 // SyncableService implementation (just delegates to |extension_settings_|). | |
| 49 // All run on the FILE thread. | |
| 50 // Note that when any of these methods are called, |extension_settings_| is | |
| 51 // guaranteed to have already been created, since |extension_settings_| is | |
| 52 // constructed on the FILE thread. | |
| 53 virtual SyncDataList GetAllSyncData( | |
| 54 syncable::ModelType type) const OVERRIDE; | |
|
akalin
2011/09/20 14:53:11
#include base/compiler_specific.h for OVERRIDE
not at google - send to devlin
2011/09/21 00:20:14
Done.
| |
| 55 virtual SyncError MergeDataAndStartSyncing( | |
| 56 syncable::ModelType type, | |
| 57 const SyncDataList& initial_sync_data, | |
| 58 SyncChangeProcessor* sync_processor) OVERRIDE; | |
| 59 virtual SyncError ProcessSyncChanges( | |
| 60 const tracked_objects::Location& from_here, | |
| 61 const SyncChangeList& change_list) OVERRIDE; | |
| 62 virtual void StopSyncing(syncable::ModelType type) OVERRIDE; | |
| 63 | |
| 64 private: | |
| 65 // Can be destroyed on either the UI or FILE thread. | |
| 66 virtual ~Core(); | |
| 67 friend class base::RefCountedThreadSafe<Core>; | |
| 68 | |
| 69 // Does any FILE thread specific initialization, such as construction of | |
| 70 // |extension_settings_|. | |
| 71 void InitOnFileThread(const FilePath& base_path); | |
| 72 | |
| 73 // Lives on the FILE thread. | |
| 74 ExtensionSettings* extension_settings_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(Core); | |
| 77 }; | |
| 78 | |
| 79 scoped_refptr<Core> core_; | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsUIWrapper); | |
| 82 }; | |
| 83 | |
| 84 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_UI_WRAPPER_H_ | |
| OLD | NEW |