OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/proxy/ppb_message_loop_proxy.h" | 5 #include "ppapi/proxy/ppb_message_loop_proxy.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 tracked_objects::Location from_here; | 48 tracked_objects::Location from_here; |
49 base::Closure closure; | 49 base::Closure closure; |
50 int64 delay_ms; | 50 int64 delay_ms; |
51 }; | 51 }; |
52 | 52 |
53 // Returns true if the object is associated with the current thread. | 53 // Returns true if the object is associated with the current thread. |
54 bool IsCurrent() const; | 54 bool IsCurrent() const; |
55 | 55 |
56 // Handles posting to the message loop if there is one, or the pending queue | 56 // Handles posting to the message loop if there is one, or the pending queue |
57 // if there isn't. | 57 // if there isn't. |
58 // NOTE: The given closure will be run *WITHOUT* acquiring the Proxy lock. | |
59 // This only makes sense for user code and completely thread-safe | |
60 // proxy operations (e.g., MessageLoop::QuitClosure). | |
61 void PostClosure(const tracked_objects::Location& from_here, | 58 void PostClosure(const tracked_objects::Location& from_here, |
62 const base::Closure& closure, | 59 const base::Closure& closure, |
63 int64 delay_ms); | 60 int64 delay_ms); |
64 | 61 |
65 // TLS destructor function. | 62 // TLS destructor function. |
66 static void ReleaseMessageLoop(void* value); | 63 static void ReleaseMessageLoop(void* value); |
67 | 64 |
68 // Created when we attach to the current thread, since MessageLoop assumes | 65 // Created when we attach to the current thread, since MessageLoop assumes |
69 // that it's created on the thread it will run on. | 66 // that it's created on the thread it will run on. |
70 scoped_ptr<MessageLoop> loop_; | 67 scoped_ptr<MessageLoop> loop_; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 return false; // Can't be current if there's nothing in the slot. | 190 return false; // Can't be current if there's nothing in the slot. |
194 return static_cast<const void*>(globals->msg_loop_slot()->Get()) == | 191 return static_cast<const void*>(globals->msg_loop_slot()->Get()) == |
195 static_cast<const void*>(this); | 192 static_cast<const void*>(this); |
196 } | 193 } |
197 | 194 |
198 void MessageLoopResource::PostClosure( | 195 void MessageLoopResource::PostClosure( |
199 const tracked_objects::Location& from_here, | 196 const tracked_objects::Location& from_here, |
200 const base::Closure& closure, | 197 const base::Closure& closure, |
201 int64 delay_ms) { | 198 int64 delay_ms) { |
202 if (loop_.get()) { | 199 if (loop_.get()) { |
203 loop_->PostDelayedTask(from_here, | 200 loop_->PostDelayedTask( |
204 closure, | 201 from_here, closure, base::TimeDelta::FromMilliseconds(delay_ms)); |
205 base::TimeDelta::FromMilliseconds(delay_ms)); | |
206 } else { | 202 } else { |
207 TaskInfo info; | 203 TaskInfo info; |
208 info.from_here = FROM_HERE; | 204 info.from_here = FROM_HERE; |
209 info.closure = closure; | 205 info.closure = closure; |
210 info.delay_ms = delay_ms; | 206 info.delay_ms = delay_ms; |
211 pending_tasks_.push_back(info); | 207 pending_tasks_.push_back(info); |
212 } | 208 } |
213 } | 209 } |
214 | 210 |
215 // static | 211 // static |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 PPB_MessageLoop_Proxy::~PPB_MessageLoop_Proxy() { | 286 PPB_MessageLoop_Proxy::~PPB_MessageLoop_Proxy() { |
291 } | 287 } |
292 | 288 |
293 // static | 289 // static |
294 const PPB_MessageLoop_Dev_0_1* PPB_MessageLoop_Proxy::GetInterface() { | 290 const PPB_MessageLoop_Dev_0_1* PPB_MessageLoop_Proxy::GetInterface() { |
295 return &ppb_message_loop_interface; | 291 return &ppb_message_loop_interface; |
296 } | 292 } |
297 | 293 |
298 } // namespace proxy | 294 } // namespace proxy |
299 } // namespace ppapi | 295 } // namespace ppapi |
OLD | NEW |