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

Side by Side Diff: base/threading/thread_local_storage_unittest.cc

Issue 9297010: Make it possible to use ThreadLocalStorage::Slot as a static without (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #if defined(OS_WIN) 5 #if defined(OS_WIN)
6 #include <windows.h> 6 #include <windows.h>
7 #include <process.h> 7 #include <process.h>
8 #endif 8 #endif
9 9
10 #include "base/threading/simple_thread.h" 10 #include "base/threading/simple_thread.h"
11 #include "base/threading/thread_local_storage.h" 11 #include "base/threading/thread_local_storage.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 #if defined(OS_WIN) 14 #if defined(OS_WIN)
15 // Ignore warnings about ptr->int conversions that we use when 15 // Ignore warnings about ptr->int conversions that we use when
16 // storing ints into ThreadLocalStorage. 16 // storing ints into ThreadLocalStorage.
17 #pragma warning(disable : 4311 4312) 17 #pragma warning(disable : 4311 4312)
18 #endif 18 #endif
19 19
20 namespace base { 20 namespace base {
21 21
22 namespace { 22 namespace {
23 23
24 const int kInitialTlsValue = 0x5555; 24 const int kInitialTlsValue = 0x5555;
25 const int kFinalTlsValue = 0x7777; 25 const int kFinalTlsValue = 0x7777;
26 // How many times must a destructor be called before we really are done. 26 // How many times must a destructor be called before we really are done.
27 const int kNumberDestructorCallRepetitions = 3; 27 const int kNumberDestructorCallRepetitions = 3;
28 28
29 static ThreadLocalStorage::Slot tls_slot(LINKER_INITIALIZED); 29 static ThreadLocalStorage::StaticSlot tls_slot = TLS_INITIALIZER;
30 30
31 class ThreadLocalStorageRunner : public DelegateSimpleThread::Delegate { 31 class ThreadLocalStorageRunner : public DelegateSimpleThread::Delegate {
32 public: 32 public:
33 explicit ThreadLocalStorageRunner(int* tls_value_ptr) 33 explicit ThreadLocalStorageRunner(int* tls_value_ptr)
34 : tls_value_ptr_(tls_value_ptr) {} 34 : tls_value_ptr_(tls_value_ptr) {}
35 35
36 virtual ~ThreadLocalStorageRunner() {} 36 virtual ~ThreadLocalStorageRunner() {}
37 37
38 virtual void Run() { 38 virtual void Run() {
39 *tls_value_ptr_ = kInitialTlsValue; 39 *tls_value_ptr_ = kInitialTlsValue;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 delete threads[index]; 105 delete threads[index];
106 delete thread_delegates[index]; 106 delete thread_delegates[index];
107 107
108 // Verify that the destructor was called and that we reset. 108 // Verify that the destructor was called and that we reset.
109 EXPECT_EQ(values[index], kFinalTlsValue); 109 EXPECT_EQ(values[index], kFinalTlsValue);
110 } 110 }
111 tls_slot.Free(); // Stop doing callbacks to cleanup threads. 111 tls_slot.Free(); // Stop doing callbacks to cleanup threads.
112 } 112 }
113 113
114 } // namespace base 114 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/thread_local_storage_posix.cc ('k') | base/threading/thread_local_storage_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698