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

Unified Diff: ppapi/shared_impl/unittest_utils.cc

Issue 23809016: [PPAPI] ResourceVar now reference counts its PP_Resource in the plugin. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Use a ScopedPPResource instead of PP_Resource. Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« ppapi/shared_impl/resource_var.h ('K') | « ppapi/shared_impl/resource_var.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/unittest_utils.cc
diff --git a/ppapi/shared_impl/unittest_utils.cc b/ppapi/shared_impl/unittest_utils.cc
index f613882dde54291c30c4b2ed2e8249a88961aecf..84821093304b66adeaa46a5a6c04af1d33ee3311 100644
--- a/ppapi/shared_impl/unittest_utils.cc
+++ b/ppapi/shared_impl/unittest_utils.cc
@@ -161,27 +161,39 @@ bool Equals(const PP_Var& expected,
<< actual_var->pp_resource();
return false;
}
- IPC::Message actual_message(actual_var->creation_message());
- const IPC::Message& expected_message = expected_var->creation_message();
- if (expected_message.size() != actual_message.size()) {
- LOG(ERROR) << "expected creation message size: "
- << expected_message.size() << " actual: "
- << actual_message.size();
+ HostResourceVar* expected_host_var = expected_var->AsHostResourceVar();
+ HostResourceVar* actual_host_var = expected_var->AsHostResourceVar();
+ if (expected_host_var && !actual_host_var) {
+ LOG(ERROR) << "expected var is host, actual is not host";
+ return false;
+ } else if (!expected_host_var && actual_host_var) {
+ LOG(ERROR) << "expected var is not host, actual is host";
return false;
}
+ if (expected_host_var) {
+ IPC::Message actual_message(actual_host_var->creation_message());
+ const IPC::Message& expected_message =
+ expected_host_var->creation_message();
+ if (expected_message.size() != actual_message.size()) {
+ LOG(ERROR) << "expected creation message size: "
+ << expected_message.size() << " actual: "
+ << actual_message.size();
+ return false;
+ }
- // Set the upper 24 bits of actual creation_message flags to the same as
- // expected. This is an unpredictable reference number that changes
- // between serialization/deserialization, and we do not want it to cause
- // the comparison to fail.
- actual_message.SetHeaderValues(actual_message.routing_id(),
- actual_message.type(),
- (expected_message.flags() & 0xffffff00) |
- (actual_message.flags() & 0xff));
- if (memcmp(expected_message.data(), actual_message.data(),
- expected_message.size()) != 0) {
- LOG(ERROR) << "expected creation message does not match actual.";
- return false;
+ // Set the upper 24 bits of actual creation_message flags to the same as
+ // expected. This is an unpredictable reference number that changes
+ // between serialization/deserialization, and we do not want it to cause
+ // the comparison to fail.
+ actual_message.SetHeaderValues(actual_message.routing_id(),
+ actual_message.type(),
+ (expected_message.flags() & 0xffffff00) |
dmichael (off chromium) 2013/09/13 17:29:03 I think I mentioned this in another CL... would i
raymes 2013/09/13 17:41:33 +1
Matt Giuca 2013/09/13 21:23:11 See my response there: https://codereview.chromium
dmichael (off chromium) 2013/09/13 22:54:45 Okay, thanks. Sorry I missed that. Makes sense.
+ (actual_message.flags() & 0xff));
+ if (memcmp(expected_message.data(), actual_message.data(),
+ expected_message.size()) != 0) {
+ LOG(ERROR) << "expected creation message does not match actual.";
+ return false;
+ }
}
return true;
}
« ppapi/shared_impl/resource_var.h ('K') | « ppapi/shared_impl/resource_var.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698