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

Side by Side Diff: chrome/browser/sync/util/event_sys_unittest.cc

Issue 251080: Sync: Remove pthreads from event_sys code. Remove asynch version of GaiaAuthe... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/util/event_sys-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <iosfwd> 5 #include <iosfwd>
6 #include <sstream> 6 #include <sstream>
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop.h"
12 #include "base/port.h" 13 #include "base/port.h"
13 #include "build/build_config.h" 14 #include "build/build_config.h"
14 #include "chrome/browser/sync/util/event_sys-inl.h" 15 #include "chrome/browser/sync/util/event_sys-inl.h"
16 #include "chrome/browser/sync/util/pthread_helpers.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 18
17 using std::endl; 19 using std::endl;
18 using std::ostream; 20 using std::ostream;
19 using std::string; 21 using std::string;
20 using std::stringstream; 22 using std::stringstream;
21 using std::vector; 23 using std::vector;
22 24
23 namespace { 25 namespace {
24 26
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 pthread_cond_wait(&(thread_running_cond.condvar_), 191 pthread_cond_wait(&(thread_running_cond.condvar_),
190 &(thread_running_mutex.mutex_)); 192 &(thread_running_mutex.mutex_));
191 } 193 }
192 thread_running_mutex.Unlock(); 194 thread_running_mutex.Unlock();
193 delete args.thread_running; 195 delete args.thread_running;
194 threads_.push_back(info); 196 threads_.push_back(info);
195 return info.thread; 197 return info.thread;
196 } 198 }
197 199
198 static void* ThreadMain(void* arg) { 200 static void* ThreadMain(void* arg) {
201 // Make sure each thread gets a current MessageLoop in TLS.
202 // This test should use chrome threads for testing, but I'll leave it like
203 // this for the moment since it requires a big chunk of rewriting and I
204 // want the test passing while I checkpoint my CL. Technically speaking,
205 // there should be no functional difference.
206 MessageLoop message_loop;
199 ThreadArgs args = *reinterpret_cast<ThreadArgs*>(arg); 207 ThreadArgs args = *reinterpret_cast<ThreadArgs*>(arg);
200 pthread_mutex_lock(args.thread_running_mutex); 208 pthread_mutex_lock(args.thread_running_mutex);
201 *args.thread_running = true; 209 *args.thread_running = true;
202 pthread_cond_signal(args.thread_running_cond); 210 pthread_cond_signal(args.thread_running_cond);
203 pthread_mutex_unlock(args.thread_running_mutex); 211 pthread_mutex_unlock(args.thread_running_mutex);
204 212
205 args.self->remove_event_mutex_.Lock(); 213 args.self->remove_event_mutex_.Lock();
206 while (args.self->remove_event_bool_ == false) { 214 while (args.self->remove_event_bool_ == false) {
207 pthread_cond_wait(&args.self->remove_event_.condvar_, 215 pthread_cond_wait(&args.self->remove_event_.condvar_,
208 &args.self->remove_event_mutex_.mutex_); 216 &args.self->remove_event_mutex_.mutex_);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 Pair sally("Sally"); 271 Pair sally("Sally");
264 HookupDeleter deleter; 272 HookupDeleter deleter;
265 deleter.hookup_ = NewEventListenerHookup(sally.event_channel(), 273 deleter.hookup_ = NewEventListenerHookup(sally.event_channel(),
266 &deleter, 274 &deleter,
267 &HookupDeleter::HandleEvent); 275 &HookupDeleter::HandleEvent);
268 sally.set_a(1); 276 sally.set_a(1);
269 ASSERT_TRUE(NULL == deleter.hookup_); 277 ASSERT_TRUE(NULL == deleter.hookup_);
270 } 278 }
271 279
272 } // namespace 280 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/sync/util/event_sys-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698