Commit 71f717eb authored by tzik's avatar tzik Committed by Commit Bot

Replace base::Timer with behavior-specific timers in extensions/

This CL replaces base::Timer with its subclasses.
As base::Timer changes its behavior subject to its construction time
flags, that makes hard to see the actual timer behavior, especially
it's unclear when a timer is injected from other components.
Also, that OnceCallback support of base::Timer is hard to implement on
the dynamically determined invocation pattern.

Bug: 850247
Change-Id: I2a7a85a39ba25da01cec2b151d2911f7dba8029a
Reviewed-on: https://chromium-review.googlesource.com/1128691Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#573524}
parent 8eaa4c54
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// Implementations for chrome.easyUnlockPrivate API functions. // Implementations for chrome.easyUnlockPrivate API functions.
namespace base { namespace base {
class Timer; class OneShotTimer;
} }
namespace content { namespace content {
...@@ -139,7 +139,7 @@ class EasyUnlockPrivateFindSetupConnectionFunction ...@@ -139,7 +139,7 @@ class EasyUnlockPrivateFindSetupConnectionFunction
connection_finder_; connection_finder_;
// Used for timing out when waiting for the connection finder to return. // Used for timing out when waiting for the connection finder to return.
std::unique_ptr<base::Timer> timer_; std::unique_ptr<base::OneShotTimer> timer_;
DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateFindSetupConnectionFunction); DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateFindSetupConnectionFunction);
}; };
......
...@@ -94,7 +94,6 @@ OffscreenTab::OffscreenTab(OffscreenTabsOwner* owner) ...@@ -94,7 +94,6 @@ OffscreenTab::OffscreenTab(OffscreenTabsOwner* owner)
owner->extension_web_contents()->GetBrowserContext()), owner->extension_web_contents()->GetBrowserContext()),
base::BindOnce(&OffscreenTab::DieIfOriginalProfileDestroyed, base::BindOnce(&OffscreenTab::DieIfOriginalProfileDestroyed,
base::Unretained(this)))), base::Unretained(this)))),
capture_poll_timer_(false, false),
content_capture_was_detected_(false), content_capture_was_detected_(false),
navigation_policy_( navigation_policy_(
std::make_unique<media_router::DefaultNavigationPolicy>()) { std::make_unique<media_router::DefaultNavigationPolicy>()) {
......
...@@ -219,7 +219,7 @@ class OffscreenTab : protected content::WebContentsDelegate, ...@@ -219,7 +219,7 @@ class OffscreenTab : protected content::WebContentsDelegate,
// TODO(miu): Add a method to WebContentsObserver to report capturer count // TODO(miu): Add a method to WebContentsObserver to report capturer count
// changes and get rid of this polling-based approach. // changes and get rid of this polling-based approach.
// http://crbug.com/540965 // http://crbug.com/540965
base::Timer capture_poll_timer_; base::OneShotTimer capture_poll_timer_;
// This is false until after the Start() method is called, and capture of the // This is false until after the Start() method is called, and capture of the
// |offscreen_tab_web_contents_| is first detected. // |offscreen_tab_web_contents_| is first detected.
......
...@@ -111,7 +111,7 @@ class RequestQueue { ...@@ -111,7 +111,7 @@ class RequestQueue {
// Timer to schedule calls to StartNextRequest, if the first pending request // Timer to schedule calls to StartNextRequest, if the first pending request
// hasn't passed its release time yet. // hasn't passed its release time yet.
base::Timer timer_; base::OneShotTimer timer_;
}; };
// Iterator class that wraps a base::circular_deque<> iterator, only giving // Iterator class that wraps a base::circular_deque<> iterator, only giving
......
...@@ -22,9 +22,7 @@ RequestQueue<T>::RequestQueue( ...@@ -22,9 +22,7 @@ RequestQueue<T>::RequestQueue(
const net::BackoffEntry::Policy* const backoff_policy, const net::BackoffEntry::Policy* const backoff_policy,
const base::Closure& start_request_callback) const base::Closure& start_request_callback)
: backoff_policy_(backoff_policy), : backoff_policy_(backoff_policy),
start_request_callback_(start_request_callback), start_request_callback_(start_request_callback) {}
timer_(false, false) {
}
template <typename T> template <typename T>
RequestQueue<T>::~RequestQueue() { RequestQueue<T>::~RequestQueue() {
......
...@@ -140,8 +140,9 @@ void WiFiDisplaySession::SendRTSPData(const std::string& message) { ...@@ -140,8 +140,9 @@ void WiFiDisplaySession::SendRTSPData(const std::string& message) {
} }
unsigned WiFiDisplaySession::CreateTimer(int seconds) { unsigned WiFiDisplaySession::CreateTimer(int seconds) {
std::unique_ptr<base::Timer> timer(new base::Timer(true, true)); std::unique_ptr<base::RepeatingTimer> timer(new base::RepeatingTimer());
auto insert_ret = timers_.insert(std::pair<int, std::unique_ptr<base::Timer>>( auto insert_ret =
timers_.insert(std::pair<int, std::unique_ptr<base::RepeatingTimer>>(
++timer_id_, std::move(timer))); ++timer_id_, std::move(timer)));
DCHECK(insert_ret.second); DCHECK(insert_ret.second);
insert_ret.first->second->Start(FROM_HERE, insert_ret.first->second->Start(FROM_HERE,
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "third_party/wds/src/libwds/public/source.h" #include "third_party/wds/src/libwds/public/source.h"
namespace base { namespace base {
class Timer; class RepeatingTimer;
} // namespace base } // namespace base
namespace extensions { namespace extensions {
...@@ -77,7 +77,7 @@ class WiFiDisplaySession : public DisplaySourceSession, ...@@ -77,7 +77,7 @@ class WiFiDisplaySession : public DisplaySourceSession,
mojom::WiFiDisplaySessionServicePtr service_; mojom::WiFiDisplaySessionServicePtr service_;
mojo::Binding<WiFiDisplaySessionServiceClient> binding_; mojo::Binding<WiFiDisplaySessionServiceClient> binding_;
std::string local_ip_address_; std::string local_ip_address_;
std::map<int, std::unique_ptr<base::Timer>> timers_; std::map<int, std::unique_ptr<base::RepeatingTimer>> timers_;
DisplaySourceSessionParams params_; DisplaySourceSessionParams params_;
CompletionCallback start_completion_callback_; CompletionCallback start_completion_callback_;
......
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