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

Side by Side Diff: third_party/libjingle/overrides/talk/base/thread.cc

Issue 9455070: Remove the dependency to ws2_32.dll from talk_base::ThreadManager and talk_base::Thread. (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 79
80 void ThreadManager::SetCurrentThread(Thread *thread) { 80 void ThreadManager::SetCurrentThread(Thread *thread) {
81 pthread_setspecific(key_, thread); 81 pthread_setspecific(key_, thread);
82 } 82 }
83 #endif 83 #endif
84 84
85 #ifdef WIN32 85 #ifdef WIN32
86 ThreadManager::ThreadManager() { 86 ThreadManager::ThreadManager() {
87 key_ = TlsAlloc(); 87 key_ = TlsAlloc();
88 WrapCurrentThread();
89 } 88 }
90 89
91 ThreadManager::~ThreadManager() { 90 ThreadManager::~ThreadManager() {
92 UnwrapCurrentThread(); 91 UnwrapCurrentThread();
93 TlsFree(key_); 92 TlsFree(key_);
94 } 93 }
95 94
96 Thread *ThreadManager::CurrentThread() { 95 Thread *ThreadManager::CurrentThread() {
97 return static_cast<Thread *>(TlsGetValue(key_)); 96 return static_cast<Thread *>(TlsGetValue(key_));
98 } 97 }
(...skipping 20 matching lines...) Expand all
119 t->UnwrapCurrent(); 118 t->UnwrapCurrent();
120 delete t; 119 delete t;
121 } 120 }
122 } 121 }
123 122
124 struct ThreadInit { 123 struct ThreadInit {
125 Thread* thread; 124 Thread* thread;
126 Runnable* runnable; 125 Runnable* runnable;
127 }; 126 };
128 127
128 Thread::Thread() {
129 Construct();
130 }
131
129 Thread::Thread(SocketServer* ss) 132 Thread::Thread(SocketServer* ss)
130 : MessageQueue(ss), 133 : MessageQueue(ss) {
131 priority_(PRIORITY_NORMAL), 134 Construct();
132 started_(false), 135 }
133 has_sends_(false), 136
137 void Thread::Construct() {
138 priority_ = PRIORITY_NORMAL;
139 started_ = false;
140 has_sends_ = false;
134 #if defined(WIN32) 141 #if defined(WIN32)
135 thread_(NULL), 142 thread_ = NULL;
136 #endif 143 #endif
137 owned_(true), 144 owned_ = true;
138 delete_self_when_complete_(false) { 145 delete_self_when_complete_ = false;
139 SetName("Thread", this); // default name 146 SetName("Thread", this); // default name
140 } 147 }
141 148
142 Thread::~Thread() { 149 Thread::~Thread() {
143 Stop(); 150 Stop();
144 if (active_) 151 if (active_)
145 Clear(NULL); 152 Clear(NULL);
146 } 153 }
147 154
148 bool Thread::SleepMs(int milliseconds) { 155 bool Thread::SleepMs(int milliseconds) {
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 if (SUCCEEDED(hr)) { 551 if (SUCCEEDED(hr)) {
545 Thread::Run(); 552 Thread::Run();
546 CoUninitialize(); 553 CoUninitialize();
547 } else { 554 } else {
548 LOG(LS_ERROR) << "CoInitialize failed, hr=" << hr; 555 LOG(LS_ERROR) << "CoInitialize failed, hr=" << hr;
549 } 556 }
550 } 557 }
551 #endif 558 #endif
552 559
553 } // namespace talk_base 560 } // namespace talk_base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698