| Index: content/browser/loader/wake_lock_resource_throttle.h
|
| diff --git a/content/browser/loader/wake_lock_resource_throttle.h b/content/browser/loader/wake_lock_resource_throttle.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1bef48cfe39b23691482ca25eae1ea956ef2bdd6
|
| --- /dev/null
|
| +++ b/content/browser/loader/wake_lock_resource_throttle.h
|
| @@ -0,0 +1,46 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CONTENT_BROWSER_LOADER_WAKE_LOCK_RESOURCE_THROTTLE_H_
|
| +#define CONTENT_BROWSER_LOADER_WAKE_LOCK_RESOURCE_THROTTLE_H_
|
| +
|
| +#include <memory>
|
| +#include <string>
|
| +
|
| +#include "base/compiler_specific.h"
|
| +#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"
|
| +
|
| +namespace content {
|
| +
|
| +// This ResourceThrottle holds wake lock until large upload request finishes.
|
| +class WakeLockResourceThrottle : public ResourceThrottle {
|
| + public:
|
| + WakeLockResourceThrottle(const std::string& host);
|
| + ~WakeLockResourceThrottle() override;
|
| +
|
| + // ResourceThrottle overrides:
|
| + void WillStartRequest(bool* defer) override;
|
| + void WillProcessResponse(bool* defer) override;
|
| + const char* GetNameForLogging() const override;
|
| +
|
| + private:
|
| + void RequestWakeLock();
|
| +
|
| + const std::string host_;
|
| + base::OneShotTimer timer_;
|
| +
|
| + // Destruction of wake_lock_ will trigger
|
| + // WakeLockServicImpl::OnConnectionError on the service side, so there is no
|
| + // need to call CancelWakeLock() in the destructor.
|
| + device::mojom::WakeLockServicePtr wake_lock_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WakeLockResourceThrottle);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_LOADER_WAKE_LOCK_RESOURCE_THROTTLE_H_
|
|
|