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

Side by Side Diff: mojo/common/common_type_converters.h

Issue 209453003: Add support for mojo::TypeConverter to control how convenient conversion should be. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_ 5 #ifndef MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_
6 #define MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_ 6 #define MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_
7 7
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
10 #include "mojo/common/mojo_common_export.h" 10 #include "mojo/common/mojo_common_export.h"
11 #include "mojo/public/cpp/bindings/array.h" 11 #include "mojo/public/cpp/bindings/array.h"
12 #include "mojo/public/cpp/bindings/type_converter.h" 12 #include "mojo/public/cpp/bindings/type_converter.h"
13 13
14 namespace mojo { 14 namespace mojo {
15 15
16 template <> 16 template <>
17 class MOJO_COMMON_EXPORT TypeConverter<String, base::StringPiece> { 17 class MOJO_COMMON_EXPORT TypeConverter<String, base::StringPiece> {
18 public: 18 public:
19 static String ConvertFrom(const base::StringPiece& input, Buffer* buf); 19 static String ConvertFrom(const base::StringPiece& input, Buffer* buf);
20 static base::StringPiece ConvertTo(const String& input); 20 static base::StringPiece ConvertTo(const String& input);
21
22 MOJO_ALLOW_DIRECT_TYPE_CONVERSION();
darin (slow to review) 2014/04/23 18:01:01 Why don't you like using the term "implicit" here?
yzshen1 2014/04/23 18:20:57 Because it sounds like we allow "explicit conversi
21 }; 23 };
22 24
23 template <> 25 template <>
24 class MOJO_COMMON_EXPORT TypeConverter<String, base::string16> { 26 class MOJO_COMMON_EXPORT TypeConverter<String, base::string16> {
25 public: 27 public:
26 static String ConvertFrom(const base::string16& input, Buffer* buf); 28 static String ConvertFrom(const base::string16& input, Buffer* buf);
27 static base::string16 ConvertTo(const String& input); 29 static base::string16 ConvertTo(const String& input);
30
31 MOJO_ALLOW_DIRECT_TYPE_CONVERSION();
28 }; 32 };
29 33
30 } // namespace mojo 34 } // namespace mojo
31 35
32 #endif // MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_ 36 #endif // MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698