| 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 "ppapi/proxy/raw_var_data.h" | 5 #include "ppapi/proxy/raw_var_data.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 11 |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "ppapi/c/pp_bool.h" | 16 #include "ppapi/c/pp_bool.h" |
| 16 #include "ppapi/c/pp_var.h" | 17 #include "ppapi/c/pp_var.h" |
| 17 #include "ppapi/shared_impl/array_var.h" | 18 #include "ppapi/shared_impl/array_var.h" |
| 18 #include "ppapi/shared_impl/dictionary_var.h" | 19 #include "ppapi/shared_impl/dictionary_var.h" |
| 19 #include "ppapi/shared_impl/ppapi_globals.h" | 20 #include "ppapi/shared_impl/ppapi_globals.h" |
| 20 #include "ppapi/shared_impl/proxy_lock.h" | 21 #include "ppapi/shared_impl/proxy_lock.h" |
| 21 #include "ppapi/shared_impl/resource_var.h" | 22 #include "ppapi/shared_impl/resource_var.h" |
| 22 #include "ppapi/shared_impl/scoped_pp_var.h" | 23 #include "ppapi/shared_impl/scoped_pp_var.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 49 ProxyLock::Release(); | 50 ProxyLock::Release(); |
| 50 } | 51 } |
| 51 | 52 |
| 52 private: | 53 private: |
| 53 base::MessageLoop message_loop_; // Required to receive callbacks. | 54 base::MessageLoop message_loop_; // Required to receive callbacks. |
| 54 TestGlobals globals_; | 55 TestGlobals globals_; |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 bool WriteAndRead(const PP_Var& var, PP_Var* result) { | 58 bool WriteAndRead(const PP_Var& var, PP_Var* result) { |
| 58 PP_Instance dummy_instance = 1234; | 59 PP_Instance dummy_instance = 1234; |
| 59 scoped_ptr<RawVarDataGraph> expected_data(RawVarDataGraph::Create( | 60 std::unique_ptr<RawVarDataGraph> expected_data( |
| 60 var, dummy_instance)); | 61 RawVarDataGraph::Create(var, dummy_instance)); |
| 61 if (!expected_data) | 62 if (!expected_data) |
| 62 return false; | 63 return false; |
| 63 IPC::Message m; | 64 IPC::Message m; |
| 64 expected_data->Write(&m, base::Bind(&DefaultHandleWriter)); | 65 expected_data->Write(&m, base::Bind(&DefaultHandleWriter)); |
| 65 base::PickleIterator iter(m); | 66 base::PickleIterator iter(m); |
| 66 scoped_ptr<RawVarDataGraph> actual_data(RawVarDataGraph::Read(&m, &iter)); | 67 std::unique_ptr<RawVarDataGraph> actual_data( |
| 68 RawVarDataGraph::Read(&m, &iter)); |
| 67 *result = actual_data->CreatePPVar(dummy_instance); | 69 *result = actual_data->CreatePPVar(dummy_instance); |
| 68 return true; | 70 return true; |
| 69 } | 71 } |
| 70 | 72 |
| 71 // Assumes a ref for var. | 73 // Assumes a ref for var. |
| 72 bool WriteReadAndCompare(const PP_Var& var) { | 74 bool WriteReadAndCompare(const PP_Var& var) { |
| 73 ScopedPPVar expected(ScopedPPVar::PassRef(), var); | 75 ScopedPPVar expected(ScopedPPVar::PassRef(), var); |
| 74 PP_Var result; | 76 PP_Var result; |
| 75 bool success = WriteAndRead(expected.get(), &result); | 77 bool success = WriteAndRead(expected.get(), &result); |
| 76 if (!success) | 78 if (!success) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 ScopedPPVar::PassRef(), | 200 ScopedPPVar::PassRef(), |
| 199 PpapiGlobals::Get()->GetVarTracker()->MakeResourcePPVar(34)); | 201 PpapiGlobals::Get()->GetVarTracker()->MakeResourcePPVar(34)); |
| 200 EXPECT_TRUE(WriteReadAndCompare(resource.get())); | 202 EXPECT_TRUE(WriteReadAndCompare(resource.get())); |
| 201 | 203 |
| 202 // TODO(mgiuca): Test a host resource with an IPC::Message. It is currently a | 204 // TODO(mgiuca): Test a host resource with an IPC::Message. It is currently a |
| 203 // checkfail to deserialize such a resource. | 205 // checkfail to deserialize such a resource. |
| 204 } | 206 } |
| 205 | 207 |
| 206 } // namespace proxy | 208 } // namespace proxy |
| 207 } // namespace ppapi | 209 } // namespace ppapi |
| OLD | NEW |