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

Side by Side Diff: base/thread.h

Issue 17246: Add V8 bindings for Worker (Part I). (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 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
« no previous file with comments | « base/scoped_handle_win.h ('k') | webkit/build/JavaScriptCore/SConscript » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #ifndef BASE_THREAD_H_ 5 #ifndef BASE_THREAD_H_
6 #define BASE_THREAD_H_ 6 #define BASE_THREAD_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // the Thread's Stop method instead. 94 // the Thread's Stop method instead.
95 // 95 //
96 MessageLoop* message_loop() const { return message_loop_; } 96 MessageLoop* message_loop() const { return message_loop_; }
97 97
98 // Set the name of this thread (for display in debugger too). 98 // Set the name of this thread (for display in debugger too).
99 const std::string &thread_name() { return name_; } 99 const std::string &thread_name() { return name_; }
100 100
101 // The native thread handle. 101 // The native thread handle.
102 PlatformThreadHandle thread_handle() { return thread_; } 102 PlatformThreadHandle thread_handle() { return thread_; }
103 103
104 // The thread ID.
105 int thread_id() const { return thread_id_; }
106
104 protected: 107 protected:
105 // Called just prior to starting the message loop 108 // Called just prior to starting the message loop
106 virtual void Init() {} 109 virtual void Init() {}
107 110
108 // Called just after the message loop ends 111 // Called just after the message loop ends
109 virtual void CleanUp() {} 112 virtual void CleanUp() {}
110 113
111 static void SetThreadWasQuitProperly(bool flag); 114 static void SetThreadWasQuitProperly(bool flag);
112 static bool GetThreadWasQuitProperly(); 115 static bool GetThreadWasQuitProperly();
113 116
114 private: 117 private:
115 // PlatformThread::Delegate methods: 118 // PlatformThread::Delegate methods:
116 virtual void ThreadMain(); 119 virtual void ThreadMain();
117 120
118 // We piggy-back on the startup_data_ member to know if we successfully 121 // We piggy-back on the startup_data_ member to know if we successfully
119 // started the thread. This way we know that we need to call Join. 122 // started the thread. This way we know that we need to call Join.
120 bool thread_was_started() const { return startup_data_ != NULL; } 123 bool thread_was_started() const { return startup_data_ != NULL; }
121 124
122 // Used to pass data to ThreadMain. 125 // Used to pass data to ThreadMain.
123 struct StartupData; 126 struct StartupData;
124 StartupData* startup_data_; 127 StartupData* startup_data_;
125 128
126 // The thread's handle. 129 // The thread's handle.
127 PlatformThreadHandle thread_; 130 PlatformThreadHandle thread_;
128 131
129 // The thread's message loop. Valid only while the thread is alive. Set 132 // The thread's message loop. Valid only while the thread is alive. Set
130 // by the created thread. 133 // by the created thread.
131 MessageLoop* message_loop_; 134 MessageLoop* message_loop_;
132 135
133 // Our thread's ID. Used for debugging purposes. 136 // Our thread's ID.
134 int thread_id_; 137 int thread_id_;
135 138
136 // The name of the thread. Used for debugging purposes. 139 // The name of the thread. Used for debugging purposes.
137 std::string name_; 140 std::string name_;
138 141
139 friend class ThreadQuitTask; 142 friend class ThreadQuitTask;
140 143
141 DISALLOW_COPY_AND_ASSIGN(Thread); 144 DISALLOW_COPY_AND_ASSIGN(Thread);
142 }; 145 };
143 146
144 } // namespace base 147 } // namespace base
145 148
146 #endif // BASE_THREAD_H_ 149 #endif // BASE_THREAD_H_
147 150
OLDNEW
« no previous file with comments | « base/scoped_handle_win.h ('k') | webkit/build/JavaScriptCore/SConscript » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698