OLD | NEW |
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 #include "base/worker_pool.h" | 5 #include "base/worker_pool.h" |
6 | 6 |
| 7 #include "base/logging.h" |
7 #include "base/task.h" | 8 #include "base/task.h" |
8 | 9 |
9 namespace { | 10 namespace { |
10 | 11 |
11 DWORD CALLBACK WorkItemCallback(void* param) { | 12 DWORD CALLBACK WorkItemCallback(void* param) { |
12 Task* task = static_cast<Task*>(param); | 13 Task* task = static_cast<Task*>(param); |
13 task->Run(); | 14 task->Run(); |
14 delete task; | 15 delete task; |
15 return 0; | 16 return 0; |
16 } | 17 } |
17 | 18 |
18 } // namespace | 19 } // namespace |
19 | 20 |
20 bool WorkerPool::PostTask(const tracked_objects::Location& from_here, | 21 bool WorkerPool::PostTask(const tracked_objects::Location& from_here, |
21 Task* task, bool task_is_slow) { | 22 Task* task, bool task_is_slow) { |
22 task->SetBirthPlace(from_here); | 23 task->SetBirthPlace(from_here); |
23 | 24 |
24 ULONG flags = 0; | 25 ULONG flags = 0; |
25 if (task_is_slow) | 26 if (task_is_slow) |
26 flags |= WT_EXECUTELONGFUNCTION; | 27 flags |= WT_EXECUTELONGFUNCTION; |
27 | 28 |
28 if (!QueueUserWorkItem(WorkItemCallback, task, flags)) { | 29 if (!QueueUserWorkItem(WorkItemCallback, task, flags)) { |
29 DLOG(ERROR) << "QueueUserWorkItem failed: " << GetLastError(); | 30 DLOG(ERROR) << "QueueUserWorkItem failed: " << GetLastError(); |
30 delete task; | 31 delete task; |
31 return false; | 32 return false; |
32 } | 33 } |
33 | 34 |
34 return true; | 35 return true; |
35 } | 36 } |
OLD | NEW |