Skip to content

Commit

Permalink
Rationalize WakeLock naming conventions
Browse files Browse the repository at this point in the history
This CL makes some changes of the WakeLock naming conventions.
WakeLockService -> WakeLock
Drop the "Impl" from "WakeLockServiceImpl"

BUG=701414
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation

Review-Url: https://codereview.chromium.org/2921823002
Cr-Commit-Position: refs/heads/master@{#477400}
  • Loading branch information
juncai authored and Commit Bot committed Jun 6, 2017
1 parent 3b05369 commit 8e8d6ec
Show file tree
Hide file tree
Showing 42 changed files with 281 additions and 296 deletions.
9 changes: 4 additions & 5 deletions chrome/browser/media/cast_transport_host_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void CastTransportHostFilter::OnNew(int32_t channel_id,
if (id_map_.IsEmpty()) {
DVLOG(1) << ("Preventing the application from being suspended while one or "
"more transports are active for Cast Streaming.");
GetWakeLockService()->RequestWakeLock();
GetWakeLock()->RequestWakeLock();
}

if (id_map_.Lookup(channel_id)) {
Expand Down Expand Up @@ -211,7 +211,7 @@ void CastTransportHostFilter::OnDelete(int32_t channel_id) {
DVLOG(1)
<< ("Releasing the block on application suspension since no transports "
"are active anymore for Cast Streaming.");
GetWakeLockService()->CancelWakeLock();
GetWakeLock()->CancelWakeLock();
}
}

Expand Down Expand Up @@ -397,11 +397,10 @@ void CastTransportHostFilter::OnCastRemotingSenderEvents(
std::vector<media::cast::PacketEvent>(), events));
}

device::mojom::WakeLockService* CastTransportHostFilter::GetWakeLockService() {
device::mojom::WakeLock* CastTransportHostFilter::GetWakeLock() {
// Here is a lazy binding, and will not reconnect after connection error.
if (!wake_lock_) {
device::mojom::WakeLockServiceRequest request =
mojo::MakeRequest(&wake_lock_);
device::mojom::WakeLockRequest request = mojo::MakeRequest(&wake_lock_);

// Service manager connection might be not initialized in some testing
// contexts.
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/media/cast_transport_host_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "base/time/default_tick_clock.h"
#include "chrome/browser/media/cast_remoting_sender.h"
#include "content/public/browser/browser_message_filter.h"
#include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h"
#include "device/wake_lock/public/interfaces/wake_lock.mojom.h"
#include "media/cast/cast_sender.h"
#include "media/cast/logging/logging_defines.h"
#include "media/cast/net/cast_transport.h"
Expand Down Expand Up @@ -90,7 +90,7 @@ class CastTransportHostFilter : public content::BrowserMessageFilter {
int32_t channel_id,
const std::vector<media::cast::FrameEvent>& events);

device::mojom::WakeLockService* GetWakeLockService();
device::mojom::WakeLock* GetWakeLock();

IDMap<std::unique_ptr<media::cast::CastTransport>> id_map_;

Expand All @@ -101,7 +101,7 @@ class CastTransportHostFilter : public content::BrowserMessageFilter {
// hold a wake lock. This prevents Chrome from being suspended while remoting
// content. If any wake lock is held upon destruction, it's implicitly
// canceled when this object is destroyed.
device::mojom::WakeLockServicePtr wake_lock_;
device::mojom::WakeLockPtr wake_lock_;

// This map records all active remoting senders. It uses the unique RTP
// stream ID as the key.
Expand Down
14 changes: 6 additions & 8 deletions content/browser/devtools/render_frame_devtools_agent_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -604,13 +604,13 @@ void RenderFrameDevToolsAgentHost::OnClientAttached() {

frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder());
#if defined(OS_ANDROID)
GetWakeLockService()->RequestWakeLock();
GetWakeLock()->RequestWakeLock();
#endif
}

void RenderFrameDevToolsAgentHost::OnClientDetached() {
#if defined(OS_ANDROID)
GetWakeLockService()->CancelWakeLock();
GetWakeLock()->CancelWakeLock();
#endif
frame_trace_recorder_.reset();
in_navigation_protocol_message_buffer_.clear();
Expand Down Expand Up @@ -826,12 +826,10 @@ bool RenderFrameDevToolsAgentHost::CheckConsistency() {
}

#if defined(OS_ANDROID)
device::mojom::WakeLockService*
RenderFrameDevToolsAgentHost::GetWakeLockService() {
device::mojom::WakeLock* RenderFrameDevToolsAgentHost::GetWakeLock() {
// Here is a lazy binding, and will not reconnect after connection error.
if (!wake_lock_) {
device::mojom::WakeLockServiceRequest request =
mojo::MakeRequest(&wake_lock_);
device::mojom::WakeLockRequest request = mojo::MakeRequest(&wake_lock_);
device::mojom::WakeLockContext* wake_lock_context =
web_contents()->GetWakeLockContext();
if (wake_lock_context) {
Expand Down Expand Up @@ -914,13 +912,13 @@ void RenderFrameDevToolsAgentHost::DidDetachInterstitialPage() {

void RenderFrameDevToolsAgentHost::WasShown() {
#if defined(OS_ANDROID)
GetWakeLockService()->RequestWakeLock();
GetWakeLock()->RequestWakeLock();
#endif
}

void RenderFrameDevToolsAgentHost::WasHidden() {
#if defined(OS_ANDROID)
GetWakeLockService()->CancelWakeLock();
GetWakeLock()->CancelWakeLock();
#endif
}

Expand Down
6 changes: 3 additions & 3 deletions content/browser/devtools/render_frame_devtools_agent_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CompositorFrameMetadata;
}

#if defined(OS_ANDROID)
#include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h"
#include "device/wake_lock/public/interfaces/wake_lock.mojom.h"
#endif

namespace content {
Expand Down Expand Up @@ -151,7 +151,7 @@ class CONTENT_EXPORT RenderFrameDevToolsAgentHost
bool CheckConsistency();

#if defined(OS_ANDROID)
device::mojom::WakeLockService* GetWakeLockService();
device::mojom::WakeLock* GetWakeLock();
#endif

void SynchronousSwapCompositorFrame(
Expand All @@ -167,7 +167,7 @@ class CONTENT_EXPORT RenderFrameDevToolsAgentHost

std::unique_ptr<DevToolsFrameTraceRecorder> frame_trace_recorder_;
#if defined(OS_ANDROID)
device::mojom::WakeLockServicePtr wake_lock_;
device::mojom::WakeLockPtr wake_lock_;
#endif
RenderFrameHostImpl* handlers_frame_host_;
bool current_frame_crashed_;
Expand Down
4 changes: 2 additions & 2 deletions content/browser/download/download_request_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "content/public/browser/download_interrupt_reasons.h"
#include "content/public/browser/download_save_info.h"
#include "content/public/browser/download_url_parameters.h"
#include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h"
#include "device/wake_lock/public/interfaces/wake_lock.mojom.h"
#include "net/traffic_annotation/network_traffic_annotation.h"

namespace net {
Expand Down Expand Up @@ -148,7 +148,7 @@ class CONTENT_EXPORT DownloadRequestCore
// Used to keep the system from sleeping while a download is ongoing. If the
// system enters power saving mode while a URLRequest is alive, it can cause
// URLRequest to fail and the associated download will be interrupted.
device::mojom::WakeLockServicePtr wake_lock_;
device::mojom::WakeLockPtr wake_lock_;

// The following are used to collect stats.
base::TimeTicks download_start_time_;
Expand Down
2 changes: 1 addition & 1 deletion content/browser/frame_host/render_frame_host_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ RenderFrameHostDelegate::GetGeolocationServiceContext() {
return nullptr;
}

device::mojom::WakeLockService* RenderFrameHostDelegate::GetRendererWakeLock() {
device::mojom::WakeLock* RenderFrameHostDelegate::GetRendererWakeLock() {
return nullptr;
}

Expand Down
6 changes: 3 additions & 3 deletions content/browser/frame_host/render_frame_host_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "content/public/browser/site_instance.h"
#include "content/public/common/javascript_dialog_type.h"
#include "content/public/common/media_stream_request.h"
#include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h"
#include "device/wake_lock/public/interfaces/wake_lock.mojom.h"
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
#include "net/http/http_response_headers.h"
#include "ui/base/window_open_disposition.h"
Expand Down Expand Up @@ -192,8 +192,8 @@ class CONTENT_EXPORT RenderFrameHostDelegate {
// Gets the GeolocationServiceContext associated with this delegate.
virtual device::GeolocationServiceContext* GetGeolocationServiceContext();

// Gets the WakeLockService that serves wake lock requests from the renderer.
virtual device::mojom::WakeLockService* GetRendererWakeLock();
// Gets the WakeLock that serves wake lock requests from the renderer.
virtual device::mojom::WakeLock* GetRendererWakeLock();

#if defined(OS_ANDROID)
// Gets an NFC implementation within the context of this delegate.
Expand Down
13 changes: 6 additions & 7 deletions content/browser/frame_host/render_frame_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@
#include "content/public/common/url_utils.h"
#include "device/geolocation/geolocation_service_context.h"
#include "device/vr/features/features.h"
#include "device/wake_lock/public/interfaces/wake_lock.mojom.h"
#include "device/wake_lock/public/interfaces/wake_lock_context.mojom.h"
#include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h"
#include "media/base/media_switches.h"
#include "media/media_features.h"
#include "media/mojo/interfaces/media_service.mojom.h"
Expand Down Expand Up @@ -2786,9 +2786,8 @@ void RenderFrameHostImpl::RegisterMojoInterfaces() {
base::Unretained(geolocation_service_context)));
}

GetInterfaceRegistry()->AddInterface<device::mojom::WakeLockService>(
base::Bind(&RenderFrameHostImpl::BindWakeLockServiceRequest,
base::Unretained(this)));
GetInterfaceRegistry()->AddInterface<device::mojom::WakeLock>(base::Bind(
&RenderFrameHostImpl::BindWakeLockRequest, base::Unretained(this)));

#if defined(OS_ANDROID)
if (base::FeatureList::IsEnabled(features::kWebNfc)) {
Expand Down Expand Up @@ -3887,10 +3886,10 @@ void RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError() {
media_interface_proxy_.reset();
}

void RenderFrameHostImpl::BindWakeLockServiceRequest(
void RenderFrameHostImpl::BindWakeLockRequest(
const service_manager::BindSourceInfo& source_info,
device::mojom::WakeLockServiceRequest request) {
device::mojom::WakeLockService* renderer_wake_lock =
device::mojom::WakeLockRequest request) {
device::mojom::WakeLock* renderer_wake_lock =
delegate_ ? delegate_->GetRendererWakeLock() : nullptr;
if (renderer_wake_lock)
renderer_wake_lock->AddClient(std::move(request));
Expand Down
5 changes: 2 additions & 3 deletions content/browser/frame_host/render_frame_host_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -920,9 +920,8 @@ class CONTENT_EXPORT RenderFrameHostImpl
// Callback for connection error on the media::mojom::InterfaceFactory client.
void OnMediaInterfaceFactoryConnectionError();

void BindWakeLockServiceRequest(
const service_manager::BindSourceInfo& source_info,
device::mojom::WakeLockServiceRequest request);
void BindWakeLockRequest(const service_manager::BindSourceInfo& source_info,
device::mojom::WakeLockRequest request);

#if defined(OS_ANDROID)
void BindNFCRequest(const service_manager::BindSourceInfo& source_info,
Expand Down
6 changes: 3 additions & 3 deletions content/browser/loader/wake_lock_resource_throttle.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "base/macros.h"
#include "base/timer/timer.h"
#include "content/public/browser/resource_throttle.h"
#include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h"
#include "device/wake_lock/public/interfaces/wake_lock.mojom.h"

namespace content {

Expand All @@ -34,9 +34,9 @@ class WakeLockResourceThrottle : public ResourceThrottle {
base::OneShotTimer timer_;

// Destruction of wake_lock_ will trigger
// WakeLockServicImpl::OnConnectionError on the service side, so there is no
// WakeLock::OnConnectionError on the service side, so there is no
// need to call CancelWakeLock() in the destructor.
device::mojom::WakeLockServicePtr wake_lock_;
device::mojom::WakeLockPtr wake_lock_;

DISALLOW_COPY_AND_ASSIGN(WakeLockResourceThrottle);
};
Expand Down
4 changes: 2 additions & 2 deletions content/browser/media/capture/aura_window_capture_machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "content/browser/media/capture/cursor_renderer_aura.h"
#include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h"
#include "device/wake_lock/public/interfaces/wake_lock.mojom.h"
#include "media/capture/content/screen_capture_device_core.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
Expand Down Expand Up @@ -124,7 +124,7 @@ class AuraWindowCaptureMachine

// TODO(jiayl): Remove wake_lock_ when there is an API to keep the
// screen from sleeping for the drive-by web.
device::mojom::WakeLockServicePtr wake_lock_;
device::mojom::WakeLockPtr wake_lock_;

// False while frame capture has been suspended. All other aspects of the
// machine are maintained.
Expand Down
4 changes: 2 additions & 2 deletions content/browser/media/capture/desktop_capture_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#include "content/public/browser/desktop_media_id.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/service_manager_connection.h"
#include "device/wake_lock/public/interfaces/wake_lock.mojom.h"
#include "device/wake_lock/public/interfaces/wake_lock_provider.mojom.h"
#include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h"
#include "media/base/video_util.h"
#include "media/capture/content/capture_resolution_chooser.h"
#include "services/device/public/interfaces/constants.mojom.h"
Expand Down Expand Up @@ -159,7 +159,7 @@ class DesktopCaptureDevice::Core : public webrtc::DesktopCapturer::Callback {

// TODO(jiayl): Remove wake_lock_ when there is an API to keep the
// screen from sleeping for the drive-by web.
device::mojom::WakeLockServicePtr wake_lock_;
device::mojom::WakeLockPtr wake_lock_;

base::WeakPtrFactory<Core> weak_factory_;

Expand Down
8 changes: 4 additions & 4 deletions content/browser/media/media_web_contents_observer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ void MediaWebContentsObserver::ClearWakeLocks(
}
}

device::mojom::WakeLockService* MediaWebContentsObserver::GetAudioWakeLock() {
device::mojom::WakeLock* MediaWebContentsObserver::GetAudioWakeLock() {
// Here is a lazy binding, and will not reconnect after connection error.
if (!audio_wake_lock_) {
device::mojom::WakeLockServiceRequest request =
device::mojom::WakeLockRequest request =
mojo::MakeRequest(&audio_wake_lock_);
device::mojom::WakeLockContext* wake_lock_context =
web_contents()->GetWakeLockContext();
Expand All @@ -239,10 +239,10 @@ device::mojom::WakeLockService* MediaWebContentsObserver::GetAudioWakeLock() {
return audio_wake_lock_.get();
}

device::mojom::WakeLockService* MediaWebContentsObserver::GetVideoWakeLock() {
device::mojom::WakeLock* MediaWebContentsObserver::GetVideoWakeLock() {
// Here is a lazy binding, and will not reconnect after connection error.
if (!video_wake_lock_) {
device::mojom::WakeLockServiceRequest request =
device::mojom::WakeLockRequest request =
mojo::MakeRequest(&video_wake_lock_);
device::mojom::WakeLockContext* wake_lock_context =
web_contents()->GetWakeLockContext();
Expand Down
10 changes: 5 additions & 5 deletions content/browser/media/media_web_contents_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "content/browser/media/session/media_session_controllers_manager.h"
#include "content/common/content_export.h"
#include "content/public/browser/web_contents_observer.h"
#include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h"
#include "device/wake_lock/public/interfaces/wake_lock.mojom.h"

#if defined(OS_ANDROID)
#include "ui/android/view_android.h"
Expand Down Expand Up @@ -91,8 +91,8 @@ class CONTENT_EXPORT MediaWebContentsObserver : public WebContentsObserver {
// Clear |render_frame_host|'s tracking entry for its WakeLocks.
void ClearWakeLocks(RenderFrameHost* render_frame_host);

device::mojom::WakeLockService* GetAudioWakeLock();
device::mojom::WakeLockService* GetVideoWakeLock();
device::mojom::WakeLock* GetAudioWakeLock();
device::mojom::WakeLock* GetVideoWakeLock();

void LockAudio();
void LockVideo();
Expand All @@ -118,8 +118,8 @@ class CONTENT_EXPORT MediaWebContentsObserver : public WebContentsObserver {
// Tracking variables and associated wake locks for media playback.
ActiveMediaPlayerMap active_audio_players_;
ActiveMediaPlayerMap active_video_players_;
device::mojom::WakeLockServicePtr audio_wake_lock_;
device::mojom::WakeLockServicePtr video_wake_lock_;
device::mojom::WakeLockPtr audio_wake_lock_;
device::mojom::WakeLockPtr video_wake_lock_;
base::Optional<MediaPlayerId> fullscreen_player_;
bool has_audio_wake_lock_for_testing_;
bool has_video_wake_lock_for_testing_;
Expand Down
9 changes: 4 additions & 5 deletions content/browser/renderer_host/render_widget_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ void RenderWidgetHostImpl::GetSnapshotFromBrowser(
// display/GPU are in a power-saving mode, so make sure display
// does not go to sleep for the duration of reading a snapshot.
if (pending_browser_snapshots_.empty())
GetWakeLockService()->RequestWakeLock();
GetWakeLock()->RequestWakeLock();
#endif
pending_browser_snapshots_.insert(std::make_pair(id, callback));
ui::LatencyInfo latency_info;
Expand Down Expand Up @@ -2461,7 +2461,7 @@ void RenderWidgetHostImpl::OnSnapshotReceived(int snapshot_id,
}
#if defined(OS_MACOSX)
if (pending_browser_snapshots_.empty())
GetWakeLockService()->CancelWakeLock();
GetWakeLock()->CancelWakeLock();
#endif
}

Expand Down Expand Up @@ -2643,11 +2643,10 @@ void RenderWidgetHostImpl::ProcessSwapMessages(
}

#if defined(OS_MACOSX)
device::mojom::WakeLockService* RenderWidgetHostImpl::GetWakeLockService() {
device::mojom::WakeLock* RenderWidgetHostImpl::GetWakeLock() {
// Here is a lazy binding, and will not reconnect after connection error.
if (!wake_lock_) {
device::mojom::WakeLockServiceRequest request =
mojo::MakeRequest(&wake_lock_);
device::mojom::WakeLockRequest request = mojo::MakeRequest(&wake_lock_);
// In some testing contexts, the service manager connection isn't
// initialized.
if (ServiceManagerConnection::GetForProcess()) {
Expand Down
Loading

0 comments on commit 8e8d6ec

Please sign in to comment.