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

Side by Side Diff: third_party/protobuf/src/google/protobuf/stubs/once_unittest.cc

Issue 2590803003: Revert "third_party/protobuf: Update to HEAD (83d681ee2c)" (Closed)
Patch Set: Created 4 years 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 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
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 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 25 matching lines...) Expand all
36 #include <unistd.h> 36 #include <unistd.h>
37 #include <pthread.h> 37 #include <pthread.h>
38 #endif 38 #endif
39 39
40 #include <google/protobuf/stubs/once.h> 40 #include <google/protobuf/stubs/once.h>
41 #include <google/protobuf/testing/googletest.h> 41 #include <google/protobuf/testing/googletest.h>
42 #include <gtest/gtest.h> 42 #include <gtest/gtest.h>
43 43
44 namespace google { 44 namespace google {
45 namespace protobuf { 45 namespace protobuf {
46 using internal::NewCallback;
46 namespace { 47 namespace {
47 48
48 class OnceInitTest : public testing::Test { 49 class OnceInitTest : public testing::Test {
49 protected: 50 protected:
50 void SetUp() { 51 void SetUp() {
51 state_ = INIT_NOT_STARTED; 52 state_ = INIT_NOT_STARTED;
52 current_test_ = this; 53 current_test_ = this;
53 } 54 }
54 55
55 // Since ProtobufOnceType is only allowed to be allocated in static storage, 56 // Since ProtobufOnceType is only allowed to be allocated in static storage,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 121 }
121 122
122 void Run() { 123 void Run() {
123 callback_->Run(); 124 callback_->Run();
124 MutexLock lock(&done_mutex_); 125 MutexLock lock(&done_mutex_);
125 done_ = true; 126 done_ = true;
126 } 127 }
127 }; 128 };
128 129
129 TestThread* RunInitOnceInNewThread() { 130 TestThread* RunInitOnceInNewThread() {
130 return new TestThread(NewCallback(this, &OnceInitTest::InitOnce)); 131 return new TestThread(internal::NewCallback(this, &OnceInitTest::InitOnce));
131 } 132 }
132 TestThread* RunInitRecursiveOnceInNewThread() { 133 TestThread* RunInitRecursiveOnceInNewThread() {
133 return new TestThread( 134 return new TestThread(
134 NewCallback(this, &OnceInitTest::InitRecursiveOnce)); 135 internal::NewCallback(this, &OnceInitTest::InitRecursiveOnce));
135 } 136 }
136 137
137 enum State { 138 enum State {
138 INIT_NOT_STARTED, 139 INIT_NOT_STARTED,
139 INIT_STARTED, 140 INIT_STARTED,
140 INIT_DONE 141 INIT_DONE
141 }; 142 };
142 State CurrentState() { 143 State CurrentState() {
143 MutexLock lock(&mutex_); 144 MutexLock lock(&mutex_);
144 return state_; 145 return state_;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 246
246 for (int i = 0; i < 8; i++) { 247 for (int i = 0; i < 8; i++) {
247 threads[i]->Join(); 248 threads[i]->Join();
248 } 249 }
249 EXPECT_EQ(INIT_DONE, CurrentState()); 250 EXPECT_EQ(INIT_DONE, CurrentState());
250 } 251 }
251 252
252 } // anonymous namespace 253 } // anonymous namespace
253 } // namespace protobuf 254 } // namespace protobuf
254 } // namespace google 255 } // namespace google
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698