| OLD | NEW |
| 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 "content/browser/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 "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/browser/render_frame_host.h" | 12 #include "content/public/browser/render_frame_host.h" |
| 13 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "device/power_save_blocker/power_save_blocker.h" | 15 #include "device/power_save_blocker/power_save_blocker.h" |
| 16 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 WakeLockServiceContext::WakeLockServiceContext(WebContents* web_contents) | 20 WakeLockServiceContext::WakeLockServiceContext(WebContents* web_contents) |
| 20 : WebContentsObserver(web_contents), weak_factory_(this) {} | 21 : WebContentsObserver(web_contents), weak_factory_(this) {} |
| 21 | 22 |
| 22 WakeLockServiceContext::~WakeLockServiceContext() {} | 23 WakeLockServiceContext::~WakeLockServiceContext() {} |
| 23 | 24 |
| 24 void WakeLockServiceContext::CreateService( | 25 void WakeLockServiceContext::CreateService( |
| 25 int render_process_id, | 26 int render_process_id, |
| 26 int render_frame_id, | 27 int render_frame_id, |
| 27 mojo::InterfaceRequest<blink::mojom::WakeLockService> request) { | 28 mojo::InterfaceRequest<blink::mojom::WakeLockService> request) { |
| 28 new WakeLockServiceImpl(weak_factory_.GetWeakPtr(), render_process_id, | 29 mojo::MakeStrongBinding( |
| 29 render_frame_id, std::move(request)); | 30 base::MakeUnique<WakeLockServiceImpl>(weak_factory_.GetWeakPtr(), |
| 31 render_process_id, render_frame_id), |
| 32 std::move(request)); |
| 30 } | 33 } |
| 31 | 34 |
| 32 void WakeLockServiceContext::RenderFrameDeleted( | 35 void WakeLockServiceContext::RenderFrameDeleted( |
| 33 RenderFrameHost* render_frame_host) { | 36 RenderFrameHost* render_frame_host) { |
| 34 CancelWakeLock(render_frame_host->GetProcess()->GetID(), | 37 CancelWakeLock(render_frame_host->GetProcess()->GetID(), |
| 35 render_frame_host->GetRoutingID()); | 38 render_frame_host->GetRoutingID()); |
| 36 } | 39 } |
| 37 | 40 |
| 38 void WakeLockServiceContext::WebContentsDestroyed() { | 41 void WakeLockServiceContext::WebContentsDestroyed() { |
| 39 #if defined(OS_ANDROID) | 42 #if defined(OS_ANDROID) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 if (!frames_requesting_lock_.empty()) { | 96 if (!frames_requesting_lock_.empty()) { |
| 94 if (!wake_lock_) | 97 if (!wake_lock_) |
| 95 CreateWakeLock(); | 98 CreateWakeLock(); |
| 96 } else { | 99 } else { |
| 97 if (wake_lock_) | 100 if (wake_lock_) |
| 98 RemoveWakeLock(); | 101 RemoveWakeLock(); |
| 99 } | 102 } |
| 100 } | 103 } |
| 101 | 104 |
| 102 } // namespace content | 105 } // namespace content |
| OLD | NEW |