Commit f8e57e1e authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

Fix naming conflict in //third_party/cacheinvalidation.

On Windows builds, the method name Scheduler::GetCurrentTime() conflicts
with the GetCurrentTime() macro defined in //base/win/windows_types.h.
Scheduler::GetCurrentTime() is referenced in a MOCK_CONST_METHOD0 macro,
which has been re-implemented recently in googletest. Under the new
implementation, the naming conflict results in the compilation error in
in https://crbug.com/1070043#c2.

This CL fixes the naming conflict by renaming
Scheduler::GetCurrentTime(). No behavior changes are expected.

Bug: 1070043
Change-Id: Ifd9040083b948ed457ddeb156677cfa84ff331c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2146350Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758745}
parent 704169d6
...@@ -167,7 +167,7 @@ HeartbeatTask::HeartbeatTask(InvalidationClientCore* client) ...@@ -167,7 +167,7 @@ HeartbeatTask::HeartbeatTask(InvalidationClientCore* client)
client->config_.heartbeat_interval_ms()), client->config_.heartbeat_interval_ms()),
Scheduler::NoDelay()), Scheduler::NoDelay()),
client_(client) { client_(client) {
next_performance_send_time_ = client_->internal_scheduler_->GetCurrentTime() + next_performance_send_time_ = client_->internal_scheduler_->CurrentTime() +
smearer()->GetSmearedDelay(TimeDelta::FromMilliseconds( smearer()->GetSmearedDelay(TimeDelta::FromMilliseconds(
client_->config_.perf_counter_delay_ms())); client_->config_.perf_counter_delay_ms()));
} }
...@@ -179,9 +179,9 @@ bool HeartbeatTask::RunTask() { ...@@ -179,9 +179,9 @@ bool HeartbeatTask::RunTask() {
client_->ToString().c_str()); client_->ToString().c_str());
Scheduler *scheduler = client_->internal_scheduler_; Scheduler *scheduler = client_->internal_scheduler_;
bool must_send_perf_counters = bool must_send_perf_counters =
next_performance_send_time_ > scheduler->GetCurrentTime(); next_performance_send_time_ > scheduler->CurrentTime();
if (must_send_perf_counters) { if (must_send_perf_counters) {
next_performance_send_time_ = scheduler->GetCurrentTime() + next_performance_send_time_ = scheduler->CurrentTime() +
client_->smearer_.GetSmearedDelay(TimeDelta::FromMilliseconds( client_->smearer_.GetSmearedDelay(TimeDelta::FromMilliseconds(
client_->config_.perf_counter_delay_ms())); client_->config_.perf_counter_delay_ms()));
} }
...@@ -762,7 +762,7 @@ void InvalidationClientCore::HandleErrorMessage( ...@@ -762,7 +762,7 @@ void InvalidationClientCore::HandleErrorMessage(
void InvalidationClientCore::HandleMessageSent() { void InvalidationClientCore::HandleMessageSent() {
CHECK(internal_scheduler_->IsRunningOnThread()) << "Not on internal thread"; CHECK(internal_scheduler_->IsRunningOnThread()) << "Not on internal thread";
last_message_send_time_ = internal_scheduler_->GetCurrentTime(); last_message_send_time_ = internal_scheduler_->CurrentTime();
} }
void InvalidationClientCore::HandleNetworkStatusChange(bool is_online) { void InvalidationClientCore::HandleNetworkStatusChange(bool is_online) {
...@@ -772,13 +772,13 @@ void InvalidationClientCore::HandleNetworkStatusChange(bool is_online) { ...@@ -772,13 +772,13 @@ void InvalidationClientCore::HandleNetworkStatusChange(bool is_online) {
bool was_online = is_online_; bool was_online = is_online_;
is_online_ = is_online; is_online_ = is_online;
if (is_online && !was_online && if (is_online && !was_online &&
(internal_scheduler_->GetCurrentTime() > (internal_scheduler_->CurrentTime() >
last_message_send_time_ + TimeDelta::FromMilliseconds( last_message_send_time_ + TimeDelta::FromMilliseconds(
config_.offline_heartbeat_threshold_ms()))) { config_.offline_heartbeat_threshold_ms()))) {
TLOG(logger_, INFO, TLOG(logger_, INFO,
"Sending heartbeat after reconnection; previous send was %s ms ago", "Sending heartbeat after reconnection; previous send was %s ms ago",
SimpleItoa( SimpleItoa(
(internal_scheduler_->GetCurrentTime() - last_message_send_time_) (internal_scheduler_->CurrentTime() - last_message_send_time_)
.InMilliseconds()).c_str()); .InMilliseconds()).c_str());
SendInfoMessageToServer( SendInfoMessageToServer(
false, !registration_manager_.IsStateInSyncWithServer()); false, !registration_manager_.IsStateInSyncWithServer());
......
...@@ -33,7 +33,7 @@ class InvalidationClientUtil { ...@@ -33,7 +33,7 @@ class InvalidationClientUtil {
/* Returns the current time in the scheduler's epoch in milliseconds. */ /* Returns the current time in the scheduler's epoch in milliseconds. */
static int64_t GetCurrentTimeMs(Scheduler* scheduler) { static int64_t GetCurrentTimeMs(Scheduler* scheduler) {
return GetTimeInMillis(scheduler->GetCurrentTime()); return GetTimeInMillis(scheduler->CurrentTime());
} }
}; };
......
...@@ -52,7 +52,7 @@ void RecurringTask::EnsureScheduled(bool is_retry, string debug_reason) { ...@@ -52,7 +52,7 @@ void RecurringTask::EnsureScheduled(bool is_retry, string debug_reason) {
TLOG(logger_, FINE, "[%s] Scheduling %d with a delay %d, Now = %d", TLOG(logger_, FINE, "[%s] Scheduling %d with a delay %d, Now = %d",
debug_reason.c_str(), name_.c_str(), delay.ToInternalValue(), debug_reason.c_str(), name_.c_str(), delay.ToInternalValue(),
scheduler_->GetCurrentTime().ToInternalValue()); scheduler_->CurrentTime().ToInternalValue());
scheduler_->Schedule(delay, NewPermanentCallback(this, scheduler_->Schedule(delay, NewPermanentCallback(this,
&RecurringTask::RunTaskAndRescheduleIfNeeded)); &RecurringTask::RunTaskAndRescheduleIfNeeded));
is_scheduled_ = true; is_scheduled_ = true;
......
...@@ -68,7 +68,7 @@ class TestTask : public RecurringTask { ...@@ -68,7 +68,7 @@ class TestTask : public RecurringTask {
virtual bool RunTask() { virtual bool RunTask() {
current_runs++; current_runs++;
TLOG(logger_, INFO, "(%d) Task running: %d", TLOG(logger_, INFO, "(%d) Task running: %d",
scheduler_->GetCurrentTime().ToInternalValue(), current_runs); scheduler_->CurrentTime().ToInternalValue(), current_runs);
return current_runs < max_runs_; return current_runs < max_runs_;
} }
......
...@@ -52,7 +52,7 @@ void Throttle::Fire() { ...@@ -52,7 +52,7 @@ void Throttle::Fire() {
// Go through all of the limits to see if we've hit one. If so, schedule a // Go through all of the limits to see if we've hit one. If so, schedule a
// task to try again once that limit won't be violated. If no limits would be // task to try again once that limit won't be violated. If no limits would be
// violated, send. // violated, send.
Time now = scheduler_->GetCurrentTime(); Time now = scheduler_->CurrentTime();
for (size_t i = 0; i < static_cast<size_t>(rate_limits_.size()); ++i) { for (size_t i = 0; i < static_cast<size_t>(rate_limits_.size()); ++i) {
RateLimitP rate_limit = rate_limits_.Get(i); RateLimitP rate_limit = rate_limits_.Get(i);
...@@ -102,7 +102,7 @@ void Throttle::Fire() { ...@@ -102,7 +102,7 @@ void Throttle::Fire() {
listener_->Run(); listener_->Run();
// Record the fact that we're triggering an event now. // Record the fact that we're triggering an event now.
recent_event_times_.push_back(scheduler_->GetCurrentTime()); recent_event_times_.push_back(scheduler_->CurrentTime());
// Only save up to max_recent_events_ event times. // Only save up to max_recent_events_ event times.
if (recent_event_times_.size() > max_recent_events_) { if (recent_event_times_.size() > max_recent_events_) {
......
...@@ -39,7 +39,7 @@ class ThrottleTest : public testing::Test { ...@@ -39,7 +39,7 @@ class ThrottleTest : public testing::Test {
// Increment the call count. // Increment the call count.
++call_count_; ++call_count_;
// Check that we haven't been called within the last one second. // Check that we haven't been called within the last one second.
Time now = scheduler_->GetCurrentTime(); Time now = scheduler_->CurrentTime();
ASSERT_TRUE((now - last_call_time_) >= TimeDelta::FromSeconds(1)); ASSERT_TRUE((now - last_call_time_) >= TimeDelta::FromSeconds(1));
// Update the last time we were called to now. // Update the last time we were called to now.
last_call_time_ = now; last_call_time_ = now;
...@@ -53,7 +53,7 @@ class ThrottleTest : public testing::Test { ...@@ -53,7 +53,7 @@ class ThrottleTest : public testing::Test {
void SetUp() { void SetUp() {
logger_.reset(new TestLogger()); logger_.reset(new TestLogger());
scheduler_.reset(new DeterministicScheduler(logger_.get())); scheduler_.reset(new DeterministicScheduler(logger_.get()));
start_time_ = scheduler_->GetCurrentTime(); start_time_ = scheduler_->CurrentTime();
call_count_ = 0; call_count_ = 0;
last_call_time_ = Time() - TimeDelta::FromHours(1); last_call_time_ = Time() - TimeDelta::FromHours(1);
ProtoHelpers::InitRateLimitP(1000, kMessagesPerSecond, rate_limits_.Add()); ProtoHelpers::InitRateLimitP(1000, kMessagesPerSecond, rate_limits_.Add());
...@@ -115,7 +115,7 @@ TEST_F(ThrottleTest, ThrottlingScripted) { ...@@ -115,7 +115,7 @@ TEST_F(ThrottleTest, ThrottlingScripted) {
// ... until the short throttle interval passes, at which time it should be // ... until the short throttle interval passes, at which time it should be
// called once more. // called once more.
scheduler_->PassTime( scheduler_->PassTime(
start_time_ + TimeDelta::FromSeconds(1) - scheduler_->GetCurrentTime()); start_time_ + TimeDelta::FromSeconds(1) - scheduler_->CurrentTime());
ASSERT_EQ(2, call_count_); ASSERT_EQ(2, call_count_);
...@@ -144,7 +144,7 @@ TEST_F(ThrottleTest, ThrottlingScripted) { ...@@ -144,7 +144,7 @@ TEST_F(ThrottleTest, ThrottlingScripted) {
// Now if we fire slowly, we still shouldn't make calls, since we'd violate // Now if we fire slowly, we still shouldn't make calls, since we'd violate
// the larger rate limit interval. // the larger rate limit interval.
int fire_attempts = int fire_attempts =
((start_time_ + TimeDelta::FromMinutes(1) - scheduler_->GetCurrentTime()) ((start_time_ + TimeDelta::FromMinutes(1) - scheduler_->CurrentTime())
/ long_interval) - 1; / long_interval) - 1;
// This value should be 20. // This value should be 20.
for (int i = 0; i < fire_attempts; ++i) { for (int i = 0; i < fire_attempts; ++i) {
...@@ -154,7 +154,7 @@ TEST_F(ThrottleTest, ThrottlingScripted) { ...@@ -154,7 +154,7 @@ TEST_F(ThrottleTest, ThrottlingScripted) {
} }
Time time_to_send_again = start_time_ + TimeDelta::FromMinutes(1); Time time_to_send_again = start_time_ + TimeDelta::FromMinutes(1);
scheduler_->PassTime(time_to_send_again - scheduler_->GetCurrentTime()); scheduler_->PassTime(time_to_send_again - scheduler_->CurrentTime());
ASSERT_EQ(kMessagesPerMinute + 1, call_count_); ASSERT_EQ(kMessagesPerMinute + 1, call_count_);
} }
......
...@@ -128,7 +128,7 @@ class Scheduler : public ResourceComponent { ...@@ -128,7 +128,7 @@ class Scheduler : public ResourceComponent {
* necessarily the UNIX epoch). The only requirement is that this time * necessarily the UNIX epoch). The only requirement is that this time
* advance at the rate of real time. * advance at the rate of real time.
*/ */
virtual Time GetCurrentTime() const = 0; virtual Time CurrentTime() const = 0;
}; };
/* Interface specifying the network functionality provided by /* Interface specifying the network functionality provided by
......
...@@ -31,7 +31,7 @@ void DeterministicScheduler::Schedule(TimeDelta delay, Closure* task) { ...@@ -31,7 +31,7 @@ void DeterministicScheduler::Schedule(TimeDelta delay, Closure* task) {
CHECK(run_state_.IsStarted()); CHECK(run_state_.IsStarted());
TLOG(logger_, INFO, "(Now: %d) Enqueuing %p with delay %d", TLOG(logger_, INFO, "(Now: %d) Enqueuing %p with delay %d",
current_time_.ToInternalValue(), task, delay.InMilliseconds()); current_time_.ToInternalValue(), task, delay.InMilliseconds());
work_queue_.push(TaskEntry(GetCurrentTime() + delay, current_id_++, task)); work_queue_.push(TaskEntry(CurrentTime() + delay, current_id_++, task));
} }
void DeterministicScheduler::PassTime(TimeDelta delta_time, TimeDelta step) { void DeterministicScheduler::PassTime(TimeDelta delta_time, TimeDelta step) {
...@@ -67,7 +67,7 @@ bool DeterministicScheduler::RunNextTask() { ...@@ -67,7 +67,7 @@ bool DeterministicScheduler::RunNextTask() {
// The queue is not empty, so get the first task and see if its scheduled // The queue is not empty, so get the first task and see if its scheduled
// execution time has passed. // execution time has passed.
TaskEntry top_elt = work_queue_.top(); TaskEntry top_elt = work_queue_.top();
if (top_elt.time <= GetCurrentTime()) { if (top_elt.time <= CurrentTime()) {
// The task is scheduled to run in the past or present, so remove it // The task is scheduled to run in the past or present, so remove it
// from the queue and run the task. // from the queue and run the task.
work_queue_.pop(); work_queue_.pop();
......
...@@ -65,7 +65,7 @@ class DeterministicScheduler : public Scheduler { ...@@ -65,7 +65,7 @@ class DeterministicScheduler : public Scheduler {
// Nothing to do. // Nothing to do.
} }
virtual Time GetCurrentTime() const { virtual Time CurrentTime() const {
return current_time_; return current_time_;
} }
......
...@@ -86,7 +86,7 @@ class MockScheduler : public Scheduler { ...@@ -86,7 +86,7 @@ class MockScheduler : public Scheduler {
public: public:
MOCK_METHOD2(Schedule, void(TimeDelta, Closure*)); // NOLINT MOCK_METHOD2(Schedule, void(TimeDelta, Closure*)); // NOLINT
MOCK_CONST_METHOD0(IsRunningOnThread, bool()); MOCK_CONST_METHOD0(IsRunningOnThread, bool());
MOCK_CONST_METHOD0(GetCurrentTime, Time()); MOCK_CONST_METHOD0(CurrentTime, Time());
MOCK_METHOD1(SetSystemResources, void(SystemResources*)); // NOLINT MOCK_METHOD1(SetSystemResources, void(SystemResources*)); // NOLINT
}; };
......
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