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

Side by Side Diff: headless/public/internal/value_conversions.h

Issue 2473073003: [headless] Refactor headless devtools client API. (Closed)
Patch Set: Address nits Created 4 years, 1 month 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
« no previous file with comments | « headless/public/domains/types_unittest.cc ('k') | headless/public/util/dom_tree_extractor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 HEADLESS_PUBLIC_INTERNAL_VALUE_CONVERSIONS_H_ 5 #ifndef HEADLESS_PUBLIC_INTERNAL_VALUE_CONVERSIONS_H_
6 #define HEADLESS_PUBLIC_INTERNAL_VALUE_CONVERSIONS_H_ 6 #define HEADLESS_PUBLIC_INTERNAL_VALUE_CONVERSIONS_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "headless/public/util/error_reporter.h" 11 #include "headless/public/util/error_reporter.h"
12 12
13 namespace headless { 13 namespace headless {
14 namespace internal { 14 namespace internal {
15 15
16 // Generic conversion from a type to a base::Value. Implemented in 16 // Generic conversion from a type to a base::Value. Implemented in
17 // type_conversions.h after all type-specific ToValueImpls have been defined. 17 // types_DOMAIN.cc after all type-specific ToValueImpls have been defined.
18 template <typename T> 18 template <typename T>
19 std::unique_ptr<base::Value> ToValue(const T& value); 19 std::unique_ptr<base::Value> ToValue(const T& value);
20 20
21 // Generic conversion from a base::Value to a type. Note that this generic 21 // Generic conversion from a base::Value to a type. Note that this generic
22 // variant is never defined. Instead, we declare a specific template 22 // variant is never defined. Instead, we declare a specific template
23 // specialization for all the used types. 23 // specialization for all the used types.
24 template <typename T> 24 template <typename T>
25 struct FromValue { 25 struct FromValue {
26 static std::unique_ptr<T> Parse(const base::Value& value, 26 static std::unique_ptr<T> Parse(const base::Value& value,
27 ErrorReporter* errors); 27 ErrorReporter* errors);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 result.push_back(FromValue<T>::Parse(*item, errors)); 154 result.push_back(FromValue<T>::Parse(*item, errors));
155 errors->Pop(); 155 errors->Pop();
156 return result; 156 return result;
157 } 157 }
158 }; 158 };
159 159
160 } // namespace internal 160 } // namespace internal
161 } // namespace headless 161 } // namespace headless
162 162
163 #endif // HEADLESS_PUBLIC_INTERNAL_VALUE_CONVERSIONS_H_ 163 #endif // HEADLESS_PUBLIC_INTERNAL_VALUE_CONVERSIONS_H_
OLDNEW
« no previous file with comments | « headless/public/domains/types_unittest.cc ('k') | headless/public/util/dom_tree_extractor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698