Skip to content

Commit

Permalink
Revert of Move content/browser/power_save_blocker to //device/power_s…
Browse files Browse the repository at this point in the history
…ave_blocker (patchset chromium#19 id:400001 of https://codereview.chromium.org/1999953002/ )

Reason for revert:
Broke https://build.chromium.org/p/chromium.webkit/builders/WebKit%20Mac%20Builder%20%28dbg%29/builds/158097 but not CQ bots

Original issue's description:
> Move content/browser/power_save_blocker to //device/power_save_blocker
>
> This is mostly a mechanical move. The only "new" code is the new build
> files, and the Android JNI registration that has its own version in
> //device now instead of being part of the //content registration.
>
> R=jam@chromium.org
> TBR=rockot,tedchoc
> BUG=612337, 612563, 257943
>
> Committed: https://crrev.com/327630a7735fc91aedea5e164064c4dd18c04cc4
> Cr-Commit-Position: refs/heads/master@{#400361}

TBR=jam@chromium.org,hashimoto@chromium.org,tedchoc@chromium.org,sadrul@chromium.org,rockot@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=612337, 612563, 257943

Review-Url: https://codereview.chromium.org/2075973002
Cr-Commit-Position: refs/heads/master@{#400364}
  • Loading branch information
sgraham authored and Commit bot committed Jun 17, 2016
1 parent 43df003 commit 38c8d5e
Show file tree
Hide file tree
Showing 64 changed files with 259 additions and 516 deletions.
1 change: 0 additions & 1 deletion chrome/browser/media/DEPS
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
include_rules = [
"+device/power_save_blocker",
"+media/audio",
"+media/base",
"+media/cast",
Expand Down
15 changes: 5 additions & 10 deletions chrome/browser/media/cast_transport_host_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/common/cast_messages.h"
#include "components/net_log/chrome_net_log.h"
#include "content/public/browser/browser_thread.h"
#include "device/power_save_blocker/power_save_blocker.h"
#include "content/public/browser/power_save_blocker_factory.h"
#include "media/cast/net/cast_transport.h"

namespace {
Expand Down Expand Up @@ -149,14 +148,10 @@ void CastTransportHostFilter::OnNew(int32_t channel_id,
if (!power_save_blocker_) {
DVLOG(1) << ("Preventing the application from being suspended while one or "
"more transports are active for Cast Streaming.");
power_save_blocker_ = device::PowerSaveBlocker::CreateWithTaskRunners(
device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
device::PowerSaveBlocker::kReasonOther,
"Cast is streaming content to a remote receiver",
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI),
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::FILE));
power_save_blocker_ = content::CreatePowerSaveBlocker(
content::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
content::PowerSaveBlocker::kReasonOther,
"Cast is streaming content to a remote receiver");
}

if (id_map_.Lookup(channel_id)) {
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/media/cast_transport_host_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include "media/cast/net/cast_transport.h"
#include "media/cast/net/udp_transport.h"

namespace device {
namespace content {
class PowerSaveBlocker;
} // namespace device
} // namespace content

namespace cast {

Expand Down Expand Up @@ -91,9 +91,9 @@ class CastTransportHostFilter : public content::BrowserMessageFilter {
base::DefaultTickClock clock_;

// While |id_map_| is non-empty, hold an instance of
// device::PowerSaveBlocker. This prevents Chrome from being suspended while
// content::PowerSaveBlocker. This prevents Chrome from being suspended while
// remoting content.
std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_;
std::unique_ptr<content::PowerSaveBlocker> power_save_blocker_;

base::WeakPtrFactory<CastTransportHostFilter> weak_factory_;

Expand Down
1 change: 0 additions & 1 deletion components/drive/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ source_set("drive") {

# TODO(lukasza): Remove this dependency (see DEPS file for more info).
"//content/public/browser",
"//device/power_save_blocker",
"//google_apis:google_apis",
"//net:net",
"//third_party/cacheinvalidation",
Expand Down
13 changes: 9 additions & 4 deletions components/drive/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ include_rules = [
"+components/invalidation",
"+components/keyed_service",
"+components/prefs",
"+device/power_save_blocker",
"+google_apis",
"+google/cacheinvalidation/types.pb.h",
"+net",
Expand All @@ -11,6 +10,13 @@ include_rules = [
]

specific_include_rules = {
# The following dependency should be removed to fully make this
# directory chrome/ and content/ and storage/ independent.
# crbug.com/257943
"drive_uploader\.cc": [
"+content/public/browser/power_save_blocker_factory.h",
],

# The following test dependencies should be removed to fully componentize this
# directory. crbug.com/498951
r"(copy_operation_unittest\.cc"
Expand Down Expand Up @@ -56,9 +62,8 @@ specific_include_rules = {

# The following test dependencies should be removed to fully componentize this
# directory. crbug.com/498951
r"(drive_uploader\.cc"
r"|fake_file_system\.cc"
r"|file_system_unittest\.cc"
r"(fake_file_system\.cc"
r"|file_system_unittest.cc"
r"|file_write_watcher_unittest\.cc"
r"|get_file_for_saving_operation_unittest\.cc"
r"|operation_test_base\.cc"
Expand Down
17 changes: 6 additions & 11 deletions components/drive/drive_uploader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/task_runner_util.h"
#include "components/drive/service/drive_service_interface.h"
#include "content/public/browser/browser_thread.h"
#include "device/power_save_blocker/power_save_blocker.h"
#include "content/public/browser/power_save_blocker_factory.h"
#include "google_apis/drive/drive_api_parser.h"

using google_apis::CancelCallback;
Expand Down Expand Up @@ -99,14 +98,10 @@ struct DriveUploader::UploadFileInfo {
progress_callback(progress_callback),
content_length(0),
next_start_position(-1),
power_save_blocker(device::PowerSaveBlocker::CreateWithTaskRunners(
device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
device::PowerSaveBlocker::kReasonOther,
"Upload in progress",
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI),
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::FILE))),
power_save_blocker(content::CreatePowerSaveBlocker(
content::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
content::PowerSaveBlocker::kReasonOther,
"Upload in progress")),
cancelled(false),
weak_ptr_factory_(this) {}

Expand Down Expand Up @@ -148,7 +143,7 @@ struct DriveUploader::UploadFileInfo {
int64_t next_start_position;

// Blocks system suspend while upload is in progress.
std::unique_ptr<device::PowerSaveBlocker> power_save_blocker;
std::unique_ptr<content::PowerSaveBlocker> power_save_blocker;

// Fields for implementing cancellation. |cancel_callback| is non-null if
// there is an in-flight HTTP request. In that case, |cancell_callback| will
Expand Down
1 change: 0 additions & 1 deletion content/app/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ include_rules = [
"+content",
"+device/battery",
"+device/bluetooth",
"+device/power_save_blocker",
"+device/usb",
"+device/vibration",
# For loading V8's initial snapshot from external files.
Expand Down
4 changes: 0 additions & 4 deletions content/app/android/library_loader_hooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/result_codes.h"
#include "device/bluetooth/android/bluetooth_jni_registrar.h"
#include "device/power_save_blocker/power_save_blocker_jni_registrar.h"
#include "device/usb/android/usb_jni_registrar.h"
#include "media/base/android/media_jni_registrar.h"
#include "media/capture/video/android/capture_jni_registrar.h"
Expand Down Expand Up @@ -78,9 +77,6 @@ bool EnsureJniRegistered(JNIEnv* env) {
if (!device::android::RegisterBluetoothJni(env))
return false;

if (!device::android::RegisterPowerSaveBlockerJni(env))
return false;

if (!device::android::RegisterUsbJni(env))
return false;

Expand Down
14 changes: 13 additions & 1 deletion content/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ source_set("browser") {
"//crypto",
"//device/battery",
"//device/bluetooth",
"//device/power_save_blocker",
"//device/vibration",
"//gin",
"//google_apis",
Expand Down Expand Up @@ -292,9 +291,22 @@ source_set("browser") {

if (use_x11) {
configs += [ "//build/config/linux:x11" ]
if (!is_chromeos) {
configs += [ "//build/config/linux:xscrnsaver" ]
}
deps += [ "//ui/gfx/x" ]
}

# Dealing with power_save_blocker_{x11,ozone}.cc is a little complicated
# given the interaction between os_chromeos and the feature flags for X11 and
# ozone, so do it all in one spot.
if (is_chromeos || !use_ozone) {
sources -= [ "power_save_blocker_ozone.cc" ]
}
if (is_chromeos || !use_x11) {
sources -= [ "power_save_blocker_x11.cc" ]
}

# Dealing with *wifi_data_provider_*.cc is also a bit complicated given
# android, chromeos, linux and use_dbus.
if (is_android) {
Expand Down
1 change: 0 additions & 1 deletion content/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ include_rules = [
"+content/app/strings/grit", # For generated headers
"+content/public/browser",
"+device/battery", # For battery status service.
"+device/power_save_blocker",
"+device/vibration", # For Vibration API
"+device/vr", # For WebVR API
"+gin/v8_initializer.h",
Expand Down
8 changes: 5 additions & 3 deletions content/browser/android/browser_jni_registrar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
#include "content/browser/media/android/media_resource_getter_impl.h"
#include "content/browser/media/session/media_session_delegate_android.h"
#include "content/browser/mojo/service_registrar_android.h"
#include "content/browser/power_save_blocker_android.h"
#include "content/browser/renderer_host/ime_adapter_android.h"
#include "content/browser/renderer_host/input/synthetic_gesture_target_android.h"
#include "content/browser/screen_orientation/screen_orientation_delegate_android.h"
#include "content/browser/speech/speech_recognizer_impl_android.h"
#include "content/browser/time_zone_monitor_android.h"
#include "content/browser/web_contents/web_contents_android.h"
#include "device/power_save_blocker/power_save_blocker_android.h"
#include "mojo/android/system/core_impl.h"

namespace {
Expand All @@ -63,8 +63,9 @@ base::android::RegistrationMethod kContentRegisteredMethods[] = {
{"DateTimePickerAndroid", content::RegisterDateTimeChooserAndroid},
{"DownloadControllerAndroidImpl",
content::DownloadControllerAndroidImpl::RegisterDownloadController},
{"GamepadList", content::GamepadPlatformDataFetcherAndroid::
RegisterGamepadPlatformDataFetcherAndroid},
{"GamepadList",
content::GamepadPlatformDataFetcherAndroid::
RegisterGamepadPlatformDataFetcherAndroid},
{"HandleViewResources",
content::CompositedTouchHandleDrawable::RegisterHandleViewResources},
{"InterstitialPageDelegateAndroid",
Expand All @@ -77,6 +78,7 @@ base::android::RegistrationMethod kContentRegisteredMethods[] = {
content::NavigationControllerAndroid::Register},
{"PopupTouchHandleDrawable",
content::PopupTouchHandleDrawable::RegisterPopupTouchHandleDrawable},
{"PowerSaveBlock", content::RegisterPowerSaveBlocker},
{"RegisterImeAdapter", content::RegisterImeAdapter},
{"ScreenOrientationProvider",
content::ScreenOrientationDelegateAndroid::Register},
Expand Down
10 changes: 5 additions & 5 deletions content/browser/devtools/render_frame_devtools_agent_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
#include "content/public/common/browser_side_navigation_policy.h"

#if defined(OS_ANDROID)
#include "content/browser/power_save_blocker_factory.h"
#include "content/browser/power_save_blocker_impl.h"
#include "content/public/browser/power_save_blocker_factory.h"
#include "content/public/browser/render_widget_host_view.h"
#include "device/power_save_blocker/power_save_blocker_impl.h"
#endif

namespace content {
Expand Down Expand Up @@ -501,10 +501,10 @@ void RenderFrameDevToolsAgentHost::OnClientAttached() {

frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder());
#if defined(OS_ANDROID)
power_save_blocker_.reset(static_cast<device::PowerSaveBlockerImpl*>(
power_save_blocker_.reset(static_cast<PowerSaveBlockerImpl*>(
CreatePowerSaveBlocker(
device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
device::PowerSaveBlocker::kReasonOther, "DevTools")
PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
PowerSaveBlocker::kReasonOther, "DevTools")
.release()));
if (web_contents()->GetNativeView()) {
view_weak_factory_.reset(new base::WeakPtrFactory<ui::ViewAndroid>(
Expand Down
12 changes: 5 additions & 7 deletions content/browser/devtools/render_frame_devtools_agent_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ namespace cc {
class CompositorFrameMetadata;
}

#if defined(OS_ANDROID)
namespace device {
class PowerSaveBlockerImpl;
} // namespace device
#endif

namespace content {

class BrowserContext;
Expand All @@ -38,6 +32,10 @@ class FrameTreeNode;
class NavigationHandle;
class RenderFrameHostImpl;

#if defined(OS_ANDROID)
class PowerSaveBlockerImpl;
#endif

namespace devtools {
namespace browser { class BrowserHandler; }
namespace dom { class DOMHandler; }
Expand Down Expand Up @@ -173,7 +171,7 @@ class CONTENT_EXPORT RenderFrameDevToolsAgentHost
std::unique_ptr<devtools::emulation::EmulationHandler> emulation_handler_;
std::unique_ptr<DevToolsFrameTraceRecorder> frame_trace_recorder_;
#if defined(OS_ANDROID)
std::unique_ptr<device::PowerSaveBlockerImpl> power_save_blocker_;
std::unique_ptr<PowerSaveBlockerImpl> power_save_blocker_;
std::unique_ptr<base::WeakPtrFactory<ui::ViewAndroid>> view_weak_factory_;
#endif
std::unique_ptr<DevToolsProtocolHandler> protocol_handler_;
Expand Down
44 changes: 21 additions & 23 deletions content/browser/download/download_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
#include "content/browser/download/download_manager_impl.h"
#include "content/browser/download/download_resource_handler.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#include "content/browser/power_save_blocker_factory.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/download_danger_type.h"
#include "content/public/browser/power_save_blocker_factory.h"
#include "content/public/browser/resource_dispatcher_host_delegate.h"
#include "content/public/browser/resource_throttle.h"
#include "content/public/common/content_features.h"
Expand Down Expand Up @@ -122,14 +122,13 @@ static DownloadManagerImpl* DownloadManagerForShell(Shell* shell) {

class DownloadFileWithDelay : public DownloadFileImpl {
public:
DownloadFileWithDelay(
std::unique_ptr<DownloadSaveInfo> save_info,
const base::FilePath& default_download_directory,
std::unique_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
std::unique_ptr<device::PowerSaveBlocker> power_save_blocker,
base::WeakPtr<DownloadDestinationObserver> observer,
base::WeakPtr<DownloadFileWithDelayFactory> owner);
DownloadFileWithDelay(std::unique_ptr<DownloadSaveInfo> save_info,
const base::FilePath& default_download_directory,
std::unique_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
std::unique_ptr<PowerSaveBlocker> power_save_blocker,
base::WeakPtr<DownloadDestinationObserver> observer,
base::WeakPtr<DownloadFileWithDelayFactory> owner);

~DownloadFileWithDelay() override;

Expand Down Expand Up @@ -194,7 +193,7 @@ DownloadFileWithDelay::DownloadFileWithDelay(
const base::FilePath& default_download_directory,
std::unique_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
std::unique_ptr<device::PowerSaveBlocker> power_save_blocker,
std::unique_ptr<PowerSaveBlocker> power_save_blocker,
base::WeakPtr<DownloadDestinationObserver> observer,
base::WeakPtr<DownloadFileWithDelayFactory> owner)
: DownloadFileImpl(std::move(save_info),
Expand Down Expand Up @@ -255,9 +254,9 @@ DownloadFile* DownloadFileWithDelayFactory::CreateFile(
std::unique_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
base::WeakPtr<DownloadDestinationObserver> observer) {
std::unique_ptr<device::PowerSaveBlocker> psb(CreatePowerSaveBlocker(
device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
device::PowerSaveBlocker::kReasonOther, "Download in progress"));
std::unique_ptr<PowerSaveBlocker> psb(CreatePowerSaveBlocker(
PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
PowerSaveBlocker::kReasonOther, "Download in progress"));
return new DownloadFileWithDelay(std::move(save_info),
default_download_directory,
std::move(stream),
Expand Down Expand Up @@ -292,13 +291,12 @@ void DownloadFileWithDelayFactory::WaitForSomeCallback() {

class CountingDownloadFile : public DownloadFileImpl {
public:
CountingDownloadFile(
std::unique_ptr<DownloadSaveInfo> save_info,
const base::FilePath& default_downloads_directory,
std::unique_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
std::unique_ptr<device::PowerSaveBlocker> power_save_blocker,
base::WeakPtr<DownloadDestinationObserver> observer)
CountingDownloadFile(std::unique_ptr<DownloadSaveInfo> save_info,
const base::FilePath& default_downloads_directory,
std::unique_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
std::unique_ptr<PowerSaveBlocker> power_save_blocker,
base::WeakPtr<DownloadDestinationObserver> observer)
: DownloadFileImpl(std::move(save_info),
default_downloads_directory,
std::move(stream),
Expand Down Expand Up @@ -352,9 +350,9 @@ class CountingDownloadFileFactory : public DownloadFileFactory {
std::unique_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
base::WeakPtr<DownloadDestinationObserver> observer) override {
std::unique_ptr<device::PowerSaveBlocker> psb(CreatePowerSaveBlocker(
device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
device::PowerSaveBlocker::kReasonOther, "Download in progress"));
std::unique_ptr<PowerSaveBlocker> psb(CreatePowerSaveBlocker(
PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
PowerSaveBlocker::kReasonOther, "Download in progress"));
return new CountingDownloadFile(std::move(save_info),
default_downloads_directory,
std::move(stream),
Expand Down
Loading

0 comments on commit 38c8d5e

Please sign in to comment.