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

Side by Side Diff: device/wake_lock/wake_lock_service_context.cc

Issue 2389743002: Content Modularization Project: Move Wake Lock to //device (Closed)
Patch Set: Eliminate frame reference Created 4 years, 2 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/wake_lock/wake_lock_service_context.h" 5 #include "device/wake_lock/wake_lock_service_context.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "device/power_save_blocker/power_save_blocker.h" 12 #include "device/power_save_blocker/power_save_blocker.h"
13 #include "mojo/public/cpp/bindings/strong_binding.h" 13 #include "mojo/public/cpp/bindings/strong_binding.h"
14 14
15 namespace content { 15 namespace device {
16 16
17 WakeLockServiceContext::WakeLockServiceContext( 17 WakeLockServiceContext::WakeLockServiceContext(
18 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, 18 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner,
19 base::Callback<gfx::NativeView()> native_view_getter) 19 base::Callback<gfx::NativeView()> native_view_getter)
20 : main_task_runner_(base::ThreadTaskRunnerHandle::Get()), 20 : main_task_runner_(base::ThreadTaskRunnerHandle::Get()),
21 file_task_runner_(file_task_runner), 21 file_task_runner_(file_task_runner),
22 num_lock_requests_(0), 22 num_lock_requests_(0),
23 native_view_getter_(native_view_getter), 23 native_view_getter_(native_view_getter),
24 weak_factory_(this) {} 24 weak_factory_(this) {}
25 25
26 WakeLockServiceContext::~WakeLockServiceContext() {} 26 WakeLockServiceContext::~WakeLockServiceContext() {}
27 27
28 void WakeLockServiceContext::CreateService( 28 void WakeLockServiceContext::CreateService(
29 mojo::InterfaceRequest<blink::mojom::WakeLockService> request) { 29 mojo::InterfaceRequest<mojom::WakeLockService> request) {
30 mojo::MakeStrongBinding( 30 mojo::MakeStrongBinding(
31 base::MakeUnique<WakeLockServiceImpl>(weak_factory_.GetWeakPtr()), 31 base::MakeUnique<WakeLockServiceImpl>(weak_factory_.GetWeakPtr()),
32 std::move(request)); 32 std::move(request));
33 } 33 }
34 34
35 void WakeLockServiceContext::RequestWakeLock() { 35 void WakeLockServiceContext::RequestWakeLock() {
36 DCHECK(main_task_runner_->RunsTasksOnCurrentThread()); 36 DCHECK(main_task_runner_->RunsTasksOnCurrentThread());
37 num_lock_requests_++; 37 num_lock_requests_++;
38 UpdateWakeLock(); 38 UpdateWakeLock();
39 } 39 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 DCHECK(num_lock_requests_ >= 0); 72 DCHECK(num_lock_requests_ >= 0);
73 if (num_lock_requests_) { 73 if (num_lock_requests_) {
74 if (!wake_lock_) 74 if (!wake_lock_)
75 CreateWakeLock(); 75 CreateWakeLock();
76 } else { 76 } else {
77 if (wake_lock_) 77 if (wake_lock_)
78 RemoveWakeLock(); 78 RemoveWakeLock();
79 } 79 }
80 } 80 }
81 81
82 } // namespace content 82 } // namespace device
OLDNEW
« no previous file with comments | « device/wake_lock/wake_lock_service_context.h ('k') | device/wake_lock/wake_lock_service_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698