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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 }; | 50 }; |
51 | 51 |
52 bool WriteAndRead(const PP_Var& var, PP_Var* result) { | 52 bool WriteAndRead(const PP_Var& var, PP_Var* result) { |
53 PP_Instance dummy_instance = 1234; | 53 PP_Instance dummy_instance = 1234; |
54 scoped_ptr<RawVarDataGraph> expected_data(RawVarDataGraph::Create( | 54 scoped_ptr<RawVarDataGraph> expected_data(RawVarDataGraph::Create( |
55 var, dummy_instance)); | 55 var, dummy_instance)); |
56 if (!expected_data) | 56 if (!expected_data) |
57 return false; | 57 return false; |
58 IPC::Message m; | 58 IPC::Message m; |
59 expected_data->Write(&m, base::Bind(&DefaultHandleWriter)); | 59 expected_data->Write(&m, base::Bind(&DefaultHandleWriter)); |
60 PickleIterator iter(m); | 60 base::PickleIterator iter(m); |
61 scoped_ptr<RawVarDataGraph> actual_data(RawVarDataGraph::Read(&m, &iter)); | 61 scoped_ptr<RawVarDataGraph> actual_data(RawVarDataGraph::Read(&m, &iter)); |
62 *result = actual_data->CreatePPVar(dummy_instance); | 62 *result = actual_data->CreatePPVar(dummy_instance); |
63 return true; | 63 return true; |
64 } | 64 } |
65 | 65 |
66 // Assumes a ref for var. | 66 // Assumes a ref for var. |
67 bool WriteReadAndCompare(const PP_Var& var) { | 67 bool WriteReadAndCompare(const PP_Var& var) { |
68 ScopedPPVar expected(ScopedPPVar::PassRef(), var); | 68 ScopedPPVar expected(ScopedPPVar::PassRef(), var); |
69 PP_Var result; | 69 PP_Var result; |
70 bool success = WriteAndRead(expected.get(), &result); | 70 bool success = WriteAndRead(expected.get(), &result); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 ScopedPPVar::PassRef(), | 193 ScopedPPVar::PassRef(), |
194 PpapiGlobals::Get()->GetVarTracker()->MakeResourcePPVar(34)); | 194 PpapiGlobals::Get()->GetVarTracker()->MakeResourcePPVar(34)); |
195 EXPECT_TRUE(WriteReadAndCompare(resource.get())); | 195 EXPECT_TRUE(WriteReadAndCompare(resource.get())); |
196 | 196 |
197 // TODO(mgiuca): Test a host resource with an IPC::Message. It is currently a | 197 // TODO(mgiuca): Test a host resource with an IPC::Message. It is currently a |
198 // checkfail to deserialize such a resource. | 198 // checkfail to deserialize such a resource. |
199 } | 199 } |
200 | 200 |
201 } // namespace proxy | 201 } // namespace proxy |
202 } // namespace ppapi | 202 } // namespace ppapi |
OLD | NEW |