| 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_ARG_LIST_H_ | 5 #ifndef CHROME_BROWSER_SYNC_JS_ARG_LIST_H_ |
| 6 #define CHROME_BROWSER_SYNC_JS_ARG_LIST_H_ | 6 #define CHROME_BROWSER_SYNC_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 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/ref_counted.h" | 14 #include "base/ref_counted.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 | 16 |
| 17 namespace browser_sync { | 17 namespace browser_sync { |
| 18 | 18 |
| 19 // A thread-safe ref-counted wrapper around an immutable ListValue. | 19 // A thread-safe ref-counted wrapper around an immutable ListValue. |
| 20 // Used for passing around argument lists to different threads. | 20 // Used for passing around argument lists to different threads. |
| 21 class JsArgList { | 21 class JsArgList { |
| 22 public: | 22 public: |
| 23 JsArgList(); | 23 JsArgList(); |
| 24 explicit JsArgList(const ListValue& args); | 24 explicit JsArgList(const ListValue& args); |
| 25 explicit JsArgList(const std::vector<const Value*>& args); | 25 explicit JsArgList(const std::vector<const Value*>& args); |
| 26 ~JsArgList(); |
| 26 | 27 |
| 27 const ListValue& Get() const; | 28 const ListValue& Get() const; |
| 28 | 29 |
| 29 std::string ToString() const; | 30 std::string ToString() const; |
| 30 | 31 |
| 31 private: | 32 private: |
| 32 class SharedListValue : public base::RefCountedThreadSafe<SharedListValue> { | 33 class SharedListValue : public base::RefCountedThreadSafe<SharedListValue> { |
| 33 public: | 34 public: |
| 34 SharedListValue(); | 35 SharedListValue(); |
| 35 explicit SharedListValue(const ListValue& list_value); | 36 explicit SharedListValue(const ListValue& list_value); |
| 36 explicit SharedListValue(const std::vector<const Value*>& value_list); | 37 explicit SharedListValue(const std::vector<const Value*>& value_list); |
| 37 | 38 |
| 38 const ListValue& Get() const; | 39 const ListValue& Get() const; |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 virtual ~SharedListValue(); | 42 virtual ~SharedListValue(); |
| 42 friend class base::RefCountedThreadSafe<SharedListValue>; | 43 friend class base::RefCountedThreadSafe<SharedListValue>; |
| 43 | 44 |
| 44 ListValue list_value_; | 45 ListValue list_value_; |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 scoped_refptr<const SharedListValue> args_; | 48 scoped_refptr<const SharedListValue> args_; |
| 48 | 49 |
| 49 // Copy constructor and assignment operator welcome. | 50 // Copy constructor and assignment operator welcome. |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 } // namespace browser_sync | 53 } // namespace browser_sync |
| 53 | 54 |
| 54 #endif // CHROME_BROWSER_SYNC_JS_ARG_LIST_H_ | 55 #endif // CHROME_BROWSER_SYNC_JS_ARG_LIST_H_ |
| OLD | NEW |