summaryrefslogtreecommitdiffstats
path: root/third_party/libjingle/files/talk/base/physicalsocketserver.cc
diff options
context:
space:
mode:
authornick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-16 00:52:50 +0000
committernick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-16 00:52:50 +0000
commitc20610d3cba2e3eaeb01927f39cc9cc21dfa1d33 (patch)
tree7e137e9114786f2dc98869b8723c5a5ccdf3488d /third_party/libjingle/files/talk/base/physicalsocketserver.cc
parentdac3823fca2dd4d2b0aa2184ef918d27cfb536e6 (diff)
downloadchromium_src-c20610d3cba2e3eaeb01927f39cc9cc21dfa1d33.zip
chromium_src-c20610d3cba2e3eaeb01927f39cc9cc21dfa1d33.tar.gz
chromium_src-c20610d3cba2e3eaeb01927f39cc9cc21dfa1d33.tar.bz2
Within libjingle, add an abstraction of winsock initialization.
When building chrome, override the default implementation so that we share the winsock initialization singleton with net/base. Trigger the winsock initialization lazily in a few places. This is intended to fix a startup perf regression that appeared when sync (and libjingle) became linked into chrome.dll, rather than a separate delay-loaded sync dll. BUG=24448 TEST=Verified deferred winsock initialization via debugger. Measured before and after time of the StartupTest.PerfTest. Verified sync notification still work. Review URL: http://codereview.chromium.org/267089 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29228 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/libjingle/files/talk/base/physicalsocketserver.cc')
-rw-r--r--third_party/libjingle/files/talk/base/physicalsocketserver.cc24
1 files changed, 4 insertions, 20 deletions
diff --git a/third_party/libjingle/files/talk/base/physicalsocketserver.cc b/third_party/libjingle/files/talk/base/physicalsocketserver.cc
index 9cdacdfa..1eb9f3a 100644
--- a/third_party/libjingle/files/talk/base/physicalsocketserver.cc
+++ b/third_party/libjingle/files/talk/base/physicalsocketserver.cc
@@ -59,31 +59,12 @@ extern "C" {
#include "talk/base/physicalsocketserver.h"
#include "talk/base/time.h"
#include "talk/base/winping.h"
+#include "talk/base/winsock_initializer.h"
#ifdef __linux
#define IP_MTU 14 // Until this is integrated from linux/in.h to netinet/in.h
#endif // __linux
-#ifdef WIN32
-class WinsockInitializer {
-public:
- WinsockInitializer() {
- WSADATA wsaData;
- WORD wVersionRequested = MAKEWORD(1, 0);
- err_ = WSAStartup(wVersionRequested, &wsaData);
- }
- ~WinsockInitializer() {
- WSACleanup();
- }
- int error() {
- return err_;
- }
-private:
- int err_;
-};
-WinsockInitializer g_winsockinit;
-#endif
-
namespace talk_base {
const int kfRead = 0x0001;
@@ -122,6 +103,9 @@ public:
PhysicalSocket(PhysicalSocketServer* ss, SOCKET s = INVALID_SOCKET)
: ss_(ss), s_(s), enabled_events_(0), error_(0),
state_((s == INVALID_SOCKET) ? CS_CLOSED : CS_CONNECTED) {
+#ifdef WIN32
+ EnsureWinsockInit();
+#endif
if (s != INVALID_SOCKET)
enabled_events_ = kfRead | kfWrite;
}