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

Unified Diff: ppapi/tests/test_utils.cc

Issue 16331007: Introduce PPB_NetAddress_Dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 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
« no previous file with comments | « ppapi/tests/test_utils.h ('k') | ppapi/thunk/interfaces_ppb_public_dev.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_utils.cc
diff --git a/ppapi/tests/test_utils.cc b/ppapi/tests/test_utils.cc
index 4d251d2aa5b1ece2fa011739f0d8c708a380df1c..86a9bc192f0b26f6cb9a606f3a15fb5463a9c3b1 100644
--- a/ppapi/tests/test_utils.cc
+++ b/ppapi/tests/test_utils.cc
@@ -16,6 +16,19 @@
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/var.h"
+namespace {
+
+bool IsBigEndian() {
+ union {
+ uint32_t integer32;
+ uint8_t integer8[4];
+ } data = { 0x01020304 };
+
+ return data.integer8[0] == 1;
+}
+
+} // namespace
+
const int kActionTimeoutMs = 10000;
const PPB_Testing_Dev* GetTestingInterface() {
@@ -71,6 +84,20 @@ bool GetLocalHostPort(PP_Instance instance, std::string* host, uint16_t* port) {
return true;
}
+uint16_t ConvertFromNetEndian16(uint16_t x) {
+ if (IsBigEndian())
+ return x;
+ else
+ return (x << 8) | (x >> 8);
+}
+
+uint16_t ConvertToNetEndian16(uint16_t x) {
+ if (IsBigEndian())
+ return x;
+ else
+ return (x << 8) | (x >> 8);
+}
+
void NestedEvent::Wait() {
PP_DCHECK(pp::Module::Get()->core()->IsMainThread());
// Don't allow nesting more than once; it doesn't work with the code as-is,
« no previous file with comments | « ppapi/tests/test_utils.h ('k') | ppapi/thunk/interfaces_ppb_public_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698