Update libjingle to CL 53398036.
Review URL: https://webrtc-codereview.appspot.com/2323004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@4872 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/base/linuxwindowpicker_unittest.cc b/talk/base/linuxwindowpicker_unittest.cc
index 5ea9c93..c248bba 100644
--- a/talk/base/linuxwindowpicker_unittest.cc
+++ b/talk/base/linuxwindowpicker_unittest.cc
@@ -28,6 +28,7 @@
#include "talk/base/gunit.h"
#include "talk/base/linuxwindowpicker.h"
#include "talk/base/logging.h"
+#include "talk/base/testutils.h"
#include "talk/base/windowpicker.h"
#ifndef LINUX
@@ -37,6 +38,7 @@
namespace talk_base {
TEST(LinuxWindowPickerTest, TestGetWindowList) {
+ MAYBE_SKIP_SCREENCAST_TEST();
LinuxWindowPicker window_picker;
WindowDescriptionList descriptions;
window_picker.Init();
@@ -44,6 +46,7 @@
}
TEST(LinuxWindowPickerTest, TestGetDesktopList) {
+ MAYBE_SKIP_SCREENCAST_TEST();
LinuxWindowPicker window_picker;
DesktopDescriptionList descriptions;
EXPECT_TRUE(window_picker.Init());
diff --git a/talk/base/network.cc b/talk/base/network.cc
index d6367c3..cbfcb5f 100644
--- a/talk/base/network.cc
+++ b/talk/base/network.cc
@@ -32,10 +32,18 @@
#include "talk/base/network.h"
#ifdef POSIX
+// linux/if.h can't be included at the same time as the posix sys/if.h, and
+// it's transitively required by linux/route.h, so include that version on
+// linux instead of the standard posix one.
+#if defined(ANDROID) || defined(LINUX)
+#include <linux/if.h>
+#include <linux/route.h>
+#else
+#include <net/if.h>
+#endif
#include <sys/socket.h>
#include <sys/utsname.h>
#include <sys/ioctl.h>
-#include <net/if.h>
#include <unistd.h>
#include <errno.h>
#ifdef ANDROID
@@ -173,7 +181,8 @@
}
BasicNetworkManager::BasicNetworkManager()
- : thread_(NULL), sent_first_update_(false), start_count_(0) {
+ : thread_(NULL), sent_first_update_(false), start_count_(0),
+ ignore_non_default_routes_(false) {
}
BasicNetworkManager::~BasicNetworkManager() {
@@ -397,14 +406,52 @@
}
#endif // WIN32
-bool BasicNetworkManager::IsIgnoredNetwork(const Network& network) {
+#if defined(ANDROID) || defined(LINUX)
+bool IsDefaultRoute(const std::string& network_name) {
+ FileStream fs;
+ if (!fs.Open("/proc/net/route", "r", NULL)) {
+ LOG(LS_WARNING) << "Couldn't read /proc/net/route, skipping default "
+ << "route check (assuming everything is a default route).";
+ return true;
+ } else {
+ std::string line;
+ while (fs.ReadLine(&line) == SR_SUCCESS) {
+ char iface_name[256];
+ unsigned int iface_ip, iface_gw, iface_mask, iface_flags;
+ if (sscanf(line.c_str(),
+ "%255s %8X %8X %4X %*d %*u %*d %8X",
+ iface_name, &iface_ip, &iface_gw,
+ &iface_flags, &iface_mask) == 5 &&
+ network_name == iface_name &&
+ iface_mask == 0 &&
+ (iface_flags & (RTF_UP | RTF_HOST)) == RTF_UP) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+#endif
+
+bool BasicNetworkManager::IsIgnoredNetwork(const Network& network) const {
+ // Ignore networks on the explicit ignore list.
+ for (size_t i = 0; i < network_ignore_list_.size(); ++i) {
+ if (network.name() == network_ignore_list_[i]) {
+ return true;
+ }
+ }
#ifdef POSIX
- // Ignore local networks (lo, lo0, etc)
- // Also filter out VMware interfaces, typically named vmnet1 and vmnet8
+ // Filter out VMware interfaces, typically named vmnet1 and vmnet8
if (strncmp(network.name().c_str(), "vmnet", 5) == 0 ||
strncmp(network.name().c_str(), "vnic", 4) == 0) {
return true;
}
+#if defined(ANDROID) || defined(LINUX)
+ // Make sure this is a default route, if we're ignoring non-defaults.
+ if (ignore_non_default_routes_ && !IsDefaultRoute(network.name())) {
+ return true;
+ }
+#endif
#elif defined(WIN32)
// Ignore any HOST side vmware adapters with a description like:
// VMware Virtual Ethernet Adapter for VMnet1
diff --git a/talk/base/network.h b/talk/base/network.h
index f87063d..63f3e73 100644
--- a/talk/base/network.h
+++ b/talk/base/network.h
@@ -127,6 +127,18 @@
virtual void OnMessage(Message* msg);
bool started() { return start_count_ > 0; }
+ // Sets the network ignore list, which is empty by default. Any network on
+ // the ignore list will be filtered from network enumeration results.
+ void set_network_ignore_list(const std::vector<std::string>& list) {
+ network_ignore_list_ = list;
+ }
+#if defined(ANDROID) || defined(LINUX)
+ // Sets the flag for ignoring non-default routes.
+ void set_ignore_non_default_routes(bool value) {
+ ignore_non_default_routes_ = true;
+ }
+#endif
+
protected:
#if defined(POSIX)
// Separated from CreateNetworks for tests.
@@ -139,7 +151,7 @@
bool CreateNetworks(bool include_ignored, NetworkList* networks) const;
// Determines if a network should be ignored.
- static bool IsIgnoredNetwork(const Network& network);
+ bool IsIgnoredNetwork(const Network& network) const;
private:
friend class NetworkTest;
@@ -149,6 +161,8 @@
Thread* thread_;
bool sent_first_update_;
int start_count_;
+ std::vector<std::string> network_ignore_list_;
+ bool ignore_non_default_routes_;
};
// Represents a Unix-type network interface, with a name and single address.
diff --git a/talk/base/network_unittest.cc b/talk/base/network_unittest.cc
index ee0f0aa..d12a1eb 100644
--- a/talk/base/network_unittest.cc
+++ b/talk/base/network_unittest.cc
@@ -54,8 +54,9 @@
network_manager.MergeNetworkList(list, changed);
}
- bool IsIgnoredNetwork(const Network& network) {
- return BasicNetworkManager::IsIgnoredNetwork(network);
+ bool IsIgnoredNetwork(BasicNetworkManager& network_manager,
+ const Network& network) {
+ return network_manager.IsIgnoredNetwork(network);
}
NetworkManager::NetworkList GetNetworks(
@@ -96,8 +97,24 @@
IPAddress(0x12345600U), 24);
Network ipv4_network2("test_eth1", "Test Network Adapter 2",
IPAddress(0x00010000U), 16);
- EXPECT_FALSE(IsIgnoredNetwork(ipv4_network1));
- EXPECT_TRUE(IsIgnoredNetwork(ipv4_network2));
+ BasicNetworkManager network_manager;
+ EXPECT_FALSE(IsIgnoredNetwork(network_manager, ipv4_network1));
+ EXPECT_TRUE(IsIgnoredNetwork(network_manager, ipv4_network2));
+}
+
+TEST_F(NetworkTest, TestIgnoreList) {
+ Network ignore_me("ignore_me", "Ignore me please!",
+ IPAddress(0x12345600U), 24);
+ Network include_me("include_me", "Include me please!",
+ IPAddress(0x12345600U), 24);
+ BasicNetworkManager network_manager;
+ EXPECT_FALSE(IsIgnoredNetwork(network_manager, ignore_me));
+ EXPECT_FALSE(IsIgnoredNetwork(network_manager, include_me));
+ std::vector<std::string> ignore_list;
+ ignore_list.push_back("ignore_me");
+ network_manager.set_network_ignore_list(ignore_list);
+ EXPECT_TRUE(IsIgnoredNetwork(network_manager, ignore_me));
+ EXPECT_FALSE(IsIgnoredNetwork(network_manager, include_me));
}
TEST_F(NetworkTest, TestCreateNetworks) {
diff --git a/talk/base/openssladapter.cc b/talk/base/openssladapter.cc
index af92f0c..50391e5 100644
--- a/talk/base/openssladapter.cc
+++ b/talk/base/openssladapter.cc
@@ -233,10 +233,7 @@
bool OpenSSLAdapter::InitializeSSL(VerificationCallback callback) {
if (!InitializeSSLThread() || !SSL_library_init())
return false;
-#if !defined(ADDRESS_SANITIZER) || !defined(OSX)
- // Loading the error strings crashes mac_asan. Omit this debugging aid there.
SSL_load_error_strings();
-#endif
ERR_load_BIO_strings();
OpenSSL_add_all_algorithms();
RAND_poll();
diff --git a/talk/base/testutils.h b/talk/base/testutils.h
index 769d95f..e8ad720 100644
--- a/talk/base/testutils.h
+++ b/talk/base/testutils.h
@@ -30,6 +30,13 @@
// Utilities for testing talk_base infrastructure in unittests
+#ifdef LINUX
+#include <X11/Xlib.h>
+// X defines a few macros that stomp on types that gunit.h uses.
+#undef None
+#undef Bool
+#endif
+
#include <map>
#include <vector>
#include "talk/base/asyncsocket.h"
@@ -565,6 +572,38 @@
///////////////////////////////////////////////////////////////////////////////
+// Helpers for determining if X/screencasting is available (on linux).
+
+#define MAYBE_SKIP_SCREENCAST_TEST() \
+ if (!testing::IsScreencastingAvailable()) { \
+ LOG(LS_WARNING) << "Skipping test, since it doesn't have the requisite " \
+ << "X environment for screen capture."; \
+ return; \
+ } \
+
+#ifdef LINUX
+struct XDisplay {
+ XDisplay() : display_(XOpenDisplay(NULL)) { }
+ ~XDisplay() { if (display_) XCloseDisplay(display_); }
+ bool IsValid() const { return display_ != NULL; }
+ operator Display*() { return display_; }
+ private:
+ Display* display_;
+};
+#endif
+
+// Returns true if screencasting is available. When false, anything that uses
+// screencasting features may fail.
+inline bool IsScreencastingAvailable() {
+#ifdef LINUX
+ XDisplay display;
+ if (!display.IsValid()) {
+ LOG(LS_WARNING) << "No X Display available.";
+ return false;
+ }
+#endif
+ return true;
+}
} // namespace testing
#endif // TALK_BASE_TESTUTILS_H__
diff --git a/talk/base/thread.cc b/talk/base/thread.cc
index d21d5f1..0c43e63 100644
--- a/talk/base/thread.cc
+++ b/talk/base/thread.cc
@@ -146,7 +146,6 @@
: MessageQueue(ss),
priority_(PRIORITY_NORMAL),
started_(false),
- has_sends_(false),
#if defined(WIN32)
thread_(NULL),
thread_id_(0),
@@ -405,7 +404,6 @@
smsg.msg = msg;
smsg.ready = &ready;
sendlist_.push_back(smsg);
- has_sends_ = true;
}
// Wait for a reply
@@ -436,11 +434,6 @@
}
void Thread::ReceiveSends() {
- // Before entering critical section, check boolean.
-
- if (!has_sends_)
- return;
-
// Receive a sent message. Cleanup scenarios:
// - thread sending exits: We don't allow this, since thread can exit
// only via Join, so Send must complete.
@@ -456,7 +449,6 @@
*smsg.ready = true;
smsg.thread->socketserver()->WakeUp();
}
- has_sends_ = false;
crit_.Leave();
}
diff --git a/talk/base/thread.h b/talk/base/thread.h
index 55ec0da..e679ea4 100644
--- a/talk/base/thread.h
+++ b/talk/base/thread.h
@@ -255,7 +255,6 @@
std::string name_;
ThreadPriority priority_;
bool started_;
- bool has_sends_;
#ifdef POSIX
pthread_t thread_;
diff --git a/talk/base/virtualsocket_unittest.cc b/talk/base/virtualsocket_unittest.cc
index 7f233df..7bbb5f0 100644
--- a/talk/base/virtualsocket_unittest.cc
+++ b/talk/base/virtualsocket_unittest.cc
@@ -46,7 +46,7 @@
Sender(Thread* th, AsyncSocket* s, uint32 rt)
: thread(th), socket(new AsyncUDPSocket(s)),
done(false), rate(rt), count(0) {
- last_send = Time();
+ last_send = talk_base::Time();
thread->PostDelayed(NextDelay(), this, 1);
}
@@ -61,7 +61,7 @@
if (done)
return;
- uint32 cur_time = Time();
+ uint32 cur_time = talk_base::Time();
uint32 delay = cur_time - last_send;
uint32 size = rate * delay / 1000;
size = std::min<uint32>(size, 4096);
@@ -105,7 +105,7 @@
sec_count += size;
uint32 send_time = *reinterpret_cast<const uint32*>(data);
- uint32 recv_time = Time();
+ uint32 recv_time = talk_base::Time();
uint32 delay = recv_time - send_time;
sum += delay;
sum_sq += delay * delay;
diff --git a/talk/base/windowpicker_unittest.cc b/talk/base/windowpicker_unittest.cc
index e1a815d..436854a 100644
--- a/talk/base/windowpicker_unittest.cc
+++ b/talk/base/windowpicker_unittest.cc
@@ -1,4 +1,5 @@
#include "talk/base/gunit.h"
+#include "talk/base/testutils.h"
#include "talk/base/window.h"
#include "talk/base/windowpicker.h"
#include "talk/base/windowpickerfactory.h"
@@ -10,6 +11,7 @@
#endif
TEST(WindowPickerTest, GetWindowList) {
+ MAYBE_SKIP_SCREENCAST_TEST();
if (!talk_base::WindowPickerFactory::IsSupported()) {
LOG(LS_INFO) << "skipping test: window capturing is not supported with "
<< "current configuration.";
@@ -24,6 +26,7 @@
// TODO(hughv) Investigate why this fails on pulse but not locally after
// upgrading to XCode 4.5. The failure is GetDesktopList returning FALSE.
TEST(WindowPickerTest, DISABLE_ON_MAC(GetDesktopList)) {
+ MAYBE_SKIP_SCREENCAST_TEST();
if (!talk_base::WindowPickerFactory::IsSupported()) {
LOG(LS_INFO) << "skipping test: window capturing is not supported with "
<< "current configuration.";