Commit cd0ae84e authored by avi's avatar avi Committed by Commit bot

Include the host in PowerSaveBlockResourceThrottle.

This allows us to diagnose through system tools unexpected sleep prevention until a more proper UI solution (such as in bug http://crbug.com/571426) is implemented.

BUG=571250

Review URL: https://codereview.chromium.org/1546253002

Cr-Commit-Position: refs/heads/master@{#366945}
parent dae49253
...@@ -14,8 +14,9 @@ const int kPowerSaveBlockDelaySeconds = 30; ...@@ -14,8 +14,9 @@ const int kPowerSaveBlockDelaySeconds = 30;
} // namespace } // namespace
PowerSaveBlockResourceThrottle::PowerSaveBlockResourceThrottle() { PowerSaveBlockResourceThrottle::PowerSaveBlockResourceThrottle(
} const std::string& host)
: host_(host) {}
PowerSaveBlockResourceThrottle::~PowerSaveBlockResourceThrottle() { PowerSaveBlockResourceThrottle::~PowerSaveBlockResourceThrottle() {
} }
...@@ -41,7 +42,7 @@ const char* PowerSaveBlockResourceThrottle::GetNameForLogging() const { ...@@ -41,7 +42,7 @@ const char* PowerSaveBlockResourceThrottle::GetNameForLogging() const {
void PowerSaveBlockResourceThrottle::ActivatePowerSaveBlocker() { void PowerSaveBlockResourceThrottle::ActivatePowerSaveBlocker() {
power_save_blocker_ = PowerSaveBlocker::Create( power_save_blocker_ = PowerSaveBlocker::Create(
PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
PowerSaveBlocker::kReasonOther, "Uploading data"); PowerSaveBlocker::kReasonOther, "Uploading data to " + host_);
} }
} // namespace content } // namespace content
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef CONTENT_BROWSER_LOADER_POWER_SAVE_BLOCK_RESOURCE_THROTTLE_H_ #ifndef CONTENT_BROWSER_LOADER_POWER_SAVE_BLOCK_RESOURCE_THROTTLE_H_
#define CONTENT_BROWSER_LOADER_POWER_SAVE_BLOCK_RESOURCE_THROTTLE_H_ #define CONTENT_BROWSER_LOADER_POWER_SAVE_BLOCK_RESOURCE_THROTTLE_H_
#include <string>
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
...@@ -18,7 +20,7 @@ class PowerSaveBlocker; ...@@ -18,7 +20,7 @@ class PowerSaveBlocker;
// This ResourceThrottle blocks power save until large upload request finishes. // This ResourceThrottle blocks power save until large upload request finishes.
class PowerSaveBlockResourceThrottle : public ResourceThrottle { class PowerSaveBlockResourceThrottle : public ResourceThrottle {
public: public:
PowerSaveBlockResourceThrottle(); explicit PowerSaveBlockResourceThrottle(const std::string& host);
~PowerSaveBlockResourceThrottle() override; ~PowerSaveBlockResourceThrottle() override;
// ResourceThrottle overrides: // ResourceThrottle overrides:
...@@ -29,6 +31,7 @@ class PowerSaveBlockResourceThrottle : public ResourceThrottle { ...@@ -29,6 +31,7 @@ class PowerSaveBlockResourceThrottle : public ResourceThrottle {
private: private:
void ActivatePowerSaveBlocker(); void ActivatePowerSaveBlocker();
const std::string host_;
base::OneShotTimer timer_; base::OneShotTimer timer_;
scoped_ptr<PowerSaveBlocker> power_save_blocker_; scoped_ptr<PowerSaveBlocker> power_save_blocker_;
......
...@@ -1594,7 +1594,8 @@ scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::AddStandardHandlers( ...@@ -1594,7 +1594,8 @@ scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::AddStandardHandlers(
if (request->has_upload()) { if (request->has_upload()) {
// Block power save while uploading data. // Block power save while uploading data.
throttles.push_back(new PowerSaveBlockResourceThrottle()); throttles.push_back(
new PowerSaveBlockResourceThrottle(request->url().host()));
} }
// TODO(ricea): Stop looking this up so much. // TODO(ricea): Stop looking this up so much.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment