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

Side by Side Diff: chrome/browser/extensions/extension_setting_changes.h

Issue 8177022: Add onChanged events to the extension settings API, both from sync and between (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 9 years, 2 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTING_CHANGES_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTING_CHANGES_H_
7 #pragma once
8
9 #include "base/memory/ref_counted.h"
10 #include "base/values.h"
11
12 // A list of changes to extension settings. Create using the Builder class.
13 // The Changes object is thread-safe and efficient to copy, while the Builder
14 // object isn't.
15 class ExtensionSettingChanges {
16 public:
17 // Non-thread-safe builder for ExtensionSettingChanges.
18 class Builder {
19 public:
20 Builder() {}
21
22 // Appends a change for a setting.
23 void AppendChange(
24 const std::string& key,
25 // Ownership taken. May be NULL to imply there is no old value.
26 Value* old_value,
27 // Ownership taken. May be NULL to imply there is no new value.
28 Value* new_value);
29
30 // Creates an ExtensionSettingChanges object. The Builder should not be
31 // used after calling this.
32 ExtensionSettingChanges Build();
33
34 private:
35 ListValue changes_;
36
37 DISALLOW_COPY_AND_ASSIGN(Builder);
38 };
39
40 ~ExtensionSettingChanges();
41
42 // Gets the JSON serialized form of the changes, for example:
43 // [ { "key": "foo", "oldValue": "bar", "newValue": "baz" } ]
44 std::string ToJson() const;
45
46 private:
47 // Create using the Builder class. |changes| will be cleared.
48 explicit ExtensionSettingChanges(ListValue* changes);
49
50 // Ref-counted inner class, a wrapper over a non-thread-safe string.
51 class Inner : public base::RefCountedThreadSafe<Inner> {
52 public:
53 Inner() {}
54
55 // swap() this with the changes from the Builder after construction.
56 ListValue changes_;
57
58 private:
59 virtual ~Inner() {}
60 friend class base::RefCountedThreadSafe<Inner>;
61 };
62
63 scoped_refptr<Inner> inner_;
64 };
65
66 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTING_CHANGES_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/extension_setting_changes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698