| OLD | NEW |
| 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 #include "content/browser/power_save_blocker.h" | 5 #include "content/browser/power_save_blocker.h" |
| 6 | 6 |
| 7 #include <IOKit/pwr_mgt/IOPMLib.h> | 7 #include <IOKit/pwr_mgt/IOPMLib.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "content/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // Power management cannot be done on the UI thread. IOPMAssertionCreate does a | 16 // Power management cannot be done on the UI thread. IOPMAssertionCreate does a |
| 17 // synchronous MIG call to configd, so if it is called on the main thread the UI | 17 // synchronous MIG call to configd, so if it is called on the main thread the UI |
| 18 // is at the mercy of another process. See http://crbug.com/79559 and | 18 // is at the mercy of another process. See http://crbug.com/79559 and |
| 19 // http://www.opensource.apple.com/source/IOKitUser/IOKitUser-514.16.31/pwr_mgt.
subproj/IOPMLibPrivate.c . | 19 // http://www.opensource.apple.com/source/IOKitUser/IOKitUser-514.16.31/pwr_mgt.
subproj/IOPMLibPrivate.c . |
| 20 base::Thread* g_power_thread; | 20 base::Thread* g_power_thread; |
| 21 IOPMAssertionID g_power_assertion; | 21 IOPMAssertionID g_power_assertion; |
| 22 | 22 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 if (!g_power_thread) { | 63 if (!g_power_thread) { |
| 64 g_power_assertion = kIOPMNullAssertionID; | 64 g_power_assertion = kIOPMNullAssertionID; |
| 65 g_power_thread = new base::Thread("PowerSaveBlocker"); | 65 g_power_thread = new base::Thread("PowerSaveBlocker"); |
| 66 g_power_thread->Start(); | 66 g_power_thread->Start(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 g_power_thread->message_loop()-> | 69 g_power_thread->message_loop()-> |
| 70 PostTask(FROM_HERE, base::Bind(CreateSleepAssertion, type)); | 70 PostTask(FROM_HERE, base::Bind(CreateSleepAssertion, type)); |
| 71 } | 71 } |
| OLD | NEW |