OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_SYNC_JS_JS_ARG_LIST_H_ | 5 #ifndef CHROME_BROWSER_SYNC_JS_JS_ARG_LIST_H_ |
6 #define CHROME_BROWSER_SYNC_JS_JS_ARG_LIST_H_ | 6 #define CHROME_BROWSER_SYNC_JS_JS_ARG_LIST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 // See README.js for design comments. | 9 // See README.js for design comments. |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/memory/ref_counted.h" | |
14 #include "base/values.h" | 13 #include "base/values.h" |
15 #include "chrome/browser/sync/util/shared_value.h" | 14 #include "chrome/browser/sync/util/immutable.h" |
16 | 15 |
17 namespace browser_sync { | 16 namespace browser_sync { |
18 | 17 |
19 // A thread-safe wrapper around an immutable ListValue. Used for | 18 // A thin wrapper around Immutable<ListValue>. Used for passing |
20 // passing around argument lists to different threads. | 19 // around argument lists to different threads. |
21 class JsArgList { | 20 class JsArgList { |
22 public: | 21 public: |
23 // Uses an empty argument list. | 22 // Uses an empty argument list. |
24 JsArgList(); | 23 JsArgList(); |
25 | 24 |
26 // Takes over the data in |args|, leaving |args| empty. | 25 // Takes over the data in |args|, leaving |args| empty. |
27 explicit JsArgList(ListValue* args); | 26 explicit JsArgList(ListValue* args); |
28 | 27 |
29 ~JsArgList(); | 28 ~JsArgList(); |
30 | 29 |
31 const ListValue& Get() const; | 30 const ListValue& Get() const; |
32 | 31 |
33 std::string ToString() const; | 32 std::string ToString() const; |
34 | 33 |
35 // Copy constructor and assignment operator welcome. | 34 // Copy constructor and assignment operator welcome. |
36 | 35 |
37 private: | 36 private: |
38 typedef SharedValue<ListValue, HasSwapMemFnTraits<ListValue> > | 37 typedef Immutable<ListValue, HasSwapMemFnByPtr<ListValue> > |
39 SharedListValue; | 38 ImmutableListValue; |
40 scoped_refptr<const SharedListValue> args_; | 39 ImmutableListValue args_; |
41 }; | 40 }; |
42 | 41 |
43 } // namespace browser_sync | 42 } // namespace browser_sync |
44 | 43 |
45 #endif // CHROME_BROWSER_SYNC_JS_JS_ARG_LIST_H_ | 44 #endif // CHROME_BROWSER_SYNC_JS_JS_ARG_LIST_H_ |
OLD | NEW |