OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "content/common/android/gin_java_bridge_value.h" | 5 #include "content/common/android/gin_java_bridge_value.h" |
6 | 6 |
7 namespace content { | 7 namespace content { |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 header->type >= TYPE_FIRST_VALUE && header->type < TYPE_LAST_VALUE); | 70 header->type >= TYPE_FIRST_VALUE && header->type < TYPE_LAST_VALUE); |
71 } | 71 } |
72 | 72 |
73 // static | 73 // static |
74 scoped_ptr<const GinJavaBridgeValue> GinJavaBridgeValue::FromValue( | 74 scoped_ptr<const GinJavaBridgeValue> GinJavaBridgeValue::FromValue( |
75 const base::Value* value) { | 75 const base::Value* value) { |
76 return scoped_ptr<const GinJavaBridgeValue>( | 76 return scoped_ptr<const GinJavaBridgeValue>( |
77 value->IsType(base::Value::TYPE_BINARY) | 77 value->IsType(base::Value::TYPE_BINARY) |
78 ? new GinJavaBridgeValue( | 78 ? new GinJavaBridgeValue( |
79 reinterpret_cast<const base::BinaryValue*>(value)) | 79 reinterpret_cast<const base::BinaryValue*>(value)) |
80 : NULL); | 80 : nullptr); |
81 } | 81 } |
82 | 82 |
83 GinJavaBridgeValue::Type GinJavaBridgeValue::GetType() const { | 83 GinJavaBridgeValue::Type GinJavaBridgeValue::GetType() const { |
84 const Header* header = pickle_.headerT<Header>(); | 84 const Header* header = pickle_.headerT<Header>(); |
85 DCHECK(header->type >= TYPE_FIRST_VALUE && header->type < TYPE_LAST_VALUE); | 85 DCHECK(header->type >= TYPE_FIRST_VALUE && header->type < TYPE_LAST_VALUE); |
86 return static_cast<Type>(header->type); | 86 return static_cast<Type>(header->type); |
87 } | 87 } |
88 | 88 |
89 bool GinJavaBridgeValue::IsType(Type type) const { | 89 bool GinJavaBridgeValue::IsType(Type type) const { |
90 return GetType() == type; | 90 return GetType() == type; |
(...skipping 28 matching lines...) Expand all Loading... |
119 : pickle_(value->GetBuffer(), value->GetSize()) { | 119 : pickle_(value->GetBuffer(), value->GetSize()) { |
120 DCHECK(ContainsGinJavaBridgeValue(value)); | 120 DCHECK(ContainsGinJavaBridgeValue(value)); |
121 } | 121 } |
122 | 122 |
123 base::BinaryValue* GinJavaBridgeValue::SerializeToBinaryValue() { | 123 base::BinaryValue* GinJavaBridgeValue::SerializeToBinaryValue() { |
124 return base::BinaryValue::CreateWithCopiedBuffer( | 124 return base::BinaryValue::CreateWithCopiedBuffer( |
125 reinterpret_cast<const char*>(pickle_.data()), pickle_.size()); | 125 reinterpret_cast<const char*>(pickle_.data()), pickle_.size()); |
126 } | 126 } |
127 | 127 |
128 } // namespace content | 128 } // namespace content |
OLD | NEW |