OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/pepper/v8_var_converter.h" | 5 #include "content/renderer/pepper/v8_var_converter.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <cmath> | 10 #include <cmath> |
| 11 #include <memory> |
11 | 12 |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "content/renderer/pepper/resource_converter.h" | 19 #include "content/renderer/pepper/resource_converter.h" |
20 #include "ppapi/c/pp_bool.h" | 20 #include "ppapi/c/pp_bool.h" |
21 #include "ppapi/c/pp_var.h" | 21 #include "ppapi/c/pp_var.h" |
22 #include "ppapi/shared_impl/array_var.h" | 22 #include "ppapi/shared_impl/array_var.h" |
23 #include "ppapi/shared_impl/dictionary_var.h" | 23 #include "ppapi/shared_impl/dictionary_var.h" |
24 #include "ppapi/shared_impl/ppapi_globals.h" | 24 #include "ppapi/shared_impl/ppapi_globals.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 VarHandleMap var_handle_map; | 164 VarHandleMap var_handle_map; |
165 return Equals(var, val, &var_handle_map); | 165 return Equals(var, val, &var_handle_map); |
166 } | 166 } |
167 | 167 |
168 class V8VarConverterTest : public testing::Test { | 168 class V8VarConverterTest : public testing::Test { |
169 public: | 169 public: |
170 V8VarConverterTest() | 170 V8VarConverterTest() |
171 : isolate_(v8::Isolate::GetCurrent()) { | 171 : isolate_(v8::Isolate::GetCurrent()) { |
172 PP_Instance dummy = 1234; | 172 PP_Instance dummy = 1234; |
173 converter_.reset(new V8VarConverter( | 173 converter_.reset(new V8VarConverter( |
174 dummy, scoped_ptr<ResourceConverter>(new MockResourceConverter))); | 174 dummy, std::unique_ptr<ResourceConverter>(new MockResourceConverter))); |
175 } | 175 } |
176 ~V8VarConverterTest() override {} | 176 ~V8VarConverterTest() override {} |
177 | 177 |
178 // testing::Test implementation. | 178 // testing::Test implementation. |
179 void SetUp() override { | 179 void SetUp() override { |
180 ProxyLock::Acquire(); | 180 ProxyLock::Acquire(); |
181 v8::HandleScope handle_scope(isolate_); | 181 v8::HandleScope handle_scope(isolate_); |
182 v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate_); | 182 v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate_); |
183 context_.Reset(isolate_, v8::Context::New(isolate_, NULL, global)); | 183 context_.Reset(isolate_, v8::Context::New(isolate_, NULL, global)); |
184 } | 184 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 return false; | 226 return false; |
227 ScopedPPVar actual(ScopedPPVar::PassRef(), actual_var); | 227 ScopedPPVar actual(ScopedPPVar::PassRef(), actual_var); |
228 return TestEqual(expected.get(), actual.get(), false); | 228 return TestEqual(expected.get(), actual.get(), false); |
229 } | 229 } |
230 | 230 |
231 v8::Isolate* isolate_; | 231 v8::Isolate* isolate_; |
232 | 232 |
233 // Context for the JavaScript in the test. | 233 // Context for the JavaScript in the test. |
234 v8::Persistent<v8::Context> context_; | 234 v8::Persistent<v8::Context> context_; |
235 | 235 |
236 scoped_ptr<V8VarConverter> converter_; | 236 std::unique_ptr<V8VarConverter> converter_; |
237 | 237 |
238 private: | 238 private: |
239 base::MessageLoop message_loop_; // Required to receive callbacks. | 239 base::MessageLoop message_loop_; // Required to receive callbacks. |
240 | 240 |
241 TestGlobals globals_; | 241 TestGlobals globals_; |
242 }; | 242 }; |
243 | 243 |
244 } // namespace | 244 } // namespace |
245 | 245 |
246 TEST_F(V8VarConverterTest, SimpleRoundTripTest) { | 246 TEST_F(V8VarConverterTest, SimpleRoundTripTest) { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 expected->SetWithStringKey("null", quux.get()); | 441 expected->SetWithStringKey("null", quux.get()); |
442 ScopedPPVar oops(ScopedPPVar::PassRef(), StringVar::StringToPPVar("oops")); | 442 ScopedPPVar oops(ScopedPPVar::PassRef(), StringVar::StringToPPVar("oops")); |
443 expected->SetWithStringKey("undefined", oops.get()); | 443 expected->SetWithStringKey("undefined", oops.get()); |
444 ScopedPPVar release_expected(ScopedPPVar::PassRef(), expected->GetPPVar()); | 444 ScopedPPVar release_expected(ScopedPPVar::PassRef(), expected->GetPPVar()); |
445 | 445 |
446 ASSERT_TRUE(TestEqual(release_expected.get(), release_actual.get(), true)); | 446 ASSERT_TRUE(TestEqual(release_expected.get(), release_actual.get(), true)); |
447 } | 447 } |
448 } | 448 } |
449 | 449 |
450 } // namespace content | 450 } // namespace content |
OLD | NEW |