Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Side by Side Diff: chrome/browser/extensions/extension_settings_ui_wrapper.cc

Issue 7775008: Enable sync for the settings from the Extension Settings API. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Sync to tip. Latest comments. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 #include "chrome/browser/extensions/extension_settings_ui_wrapper.h"
6
7 #include "base/bind.h"
8 #include "base/file_path.h"
9 #include "chrome/browser/extensions/extension_settings.h"
10 #include "content/browser/browser_thread.h"
11
12 ExtensionSettingsUIWrapper::ExtensionSettingsUIWrapper(
13 const FilePath& base_path)
14 : core_(new ExtensionSettingsUIWrapper::Core(base_path)) {
15 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
16 }
17
18 void ExtensionSettingsUIWrapper::RunWithSettings(
19 const SettingsCallback& callback) {
20 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
21 BrowserThread::PostTask(
22 BrowserThread::FILE,
23 FROM_HERE,
24 base::Bind(
25 &ExtensionSettingsUIWrapper::Core::RunWithSettingsOnFileThread,
26 core_.get(),
27 callback));
28 }
29
30 ExtensionSettingsUIWrapper::~ExtensionSettingsUIWrapper() {
31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
32 }
33
34 ExtensionSettingsUIWrapper::Core::Core(const FilePath& base_path)
35 : extension_settings_(NULL) {
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
37 BrowserThread::PostTask(
38 BrowserThread::FILE,
39 FROM_HERE,
40 base::Bind(
41 &ExtensionSettingsUIWrapper::Core::InitOnFileThread,
42 this,
43 base_path));
44 }
45
46 void ExtensionSettingsUIWrapper::Core::RunWithSettingsOnFileThread(
47 const SettingsCallback& callback) {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
49 DCHECK(extension_settings_);
50 callback.Run(extension_settings_);
51 }
52
53 ExtensionSettingsUIWrapper::Core::~Core() {
54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
55 BrowserThread::CurrentlyOn(BrowserThread::FILE));
56 BrowserThread::DeleteSoon(
57 BrowserThread::FILE, FROM_HERE, extension_settings_);
58 }
59
60 void ExtensionSettingsUIWrapper::Core::InitOnFileThread(
61 const FilePath& base_path) {
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
63 DCHECK(!extension_settings_);
64 extension_settings_ = new ExtensionSettings(base_path);
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698