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)
client->config_.heartbeat_interval_ms()),
Scheduler::NoDelay()),
client_(client) {
next_performance_send_time_ = client_->internal_scheduler_->GetCurrentTime() +
next_performance_send_time_ = client_->internal_scheduler_->CurrentTime() +
smearer()->GetSmearedDelay(TimeDelta::FromMilliseconds(
client_->config_.perf_counter_delay_ms()));
}
......@@ -179,9 +179,9 @@ bool HeartbeatTask::RunTask() {
client_->ToString().c_str());
Scheduler *scheduler = client_->internal_scheduler_;
bool must_send_perf_counters =
next_performance_send_time_ > scheduler->GetCurrentTime();
next_performance_send_time_ > scheduler->CurrentTime();
if (must_send_perf_counters) {
next_performance_send_time_ = scheduler->GetCurrentTime() +
next_performance_send_time_ = scheduler->CurrentTime() +
client_->smearer_.GetSmearedDelay(TimeDelta::FromMilliseconds(
client_->config_.perf_counter_delay_ms()));
}
......@@ -762,7 +762,7 @@ void InvalidationClientCore::HandleErrorMessage(
void InvalidationClientCore::HandleMessageSent() {
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) {
......@@ -772,13 +772,13 @@ void InvalidationClientCore::HandleNetworkStatusChange(bool is_online) {
bool was_online = is_online_;
is_online_ = is_online;
if (is_online && !was_online &&
(internal_scheduler_->GetCurrentTime() >
(internal_scheduler_->CurrentTime() >
last_message_send_time_ + TimeDelta::FromMilliseconds(
config_.offline_heartbeat_threshold_ms()))) {
TLOG(logger_, INFO,
"Sending heartbeat after reconnection; previous send was %s ms ago",
SimpleItoa(
(internal_scheduler_->GetCurrentTime() - last_message_send_time_)
(internal_scheduler_->CurrentTime() - last_message_send_time_)
.InMilliseconds()).c_str());
SendInfoMessageToServer(
false, !registration_manager_.IsStateInSyncWithServer());
......
......@@ -33,7 +33,7 @@ class InvalidationClientUtil {
/* Returns the current time in the scheduler's epoch in milliseconds. */
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) {
TLOG(logger_, FINE, "[%s] Scheduling %d with a delay %d, Now = %d",
debug_reason.c_str(), name_.c_str(), delay.ToInternalValue(),
scheduler_->GetCurrentTime().ToInternalValue());
scheduler_->CurrentTime().ToInternalValue());
scheduler_->Schedule(delay, NewPermanentCallback(this,
&RecurringTask::RunTaskAndRescheduleIfNeeded));
is_scheduled_ = true;
......
......@@ -68,7 +68,7 @@ class TestTask : public RecurringTask {
virtual bool RunTask() {
current_runs++;
TLOG(logger_, INFO, "(%d) Task running: %d",
scheduler_->GetCurrentTime().ToInternalValue(), current_runs);
scheduler_->CurrentTime().ToInternalValue(), current_runs);
return current_runs < max_runs_;
}
......
......@@ -52,7 +52,7 @@ void Throttle::Fire() {
// 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
// violated, send.
Time now = scheduler_->GetCurrentTime();
Time now = scheduler_->CurrentTime();
for (size_t i = 0; i < static_cast<size_t>(rate_limits_.size()); ++i) {
RateLimitP rate_limit = rate_limits_.Get(i);
......@@ -102,7 +102,7 @@ void Throttle::Fire() {
listener_->Run();
// 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.
if (recent_event_times_.size() > max_recent_events_) {
......
......@@ -39,7 +39,7 @@ class ThrottleTest : public testing::Test {
// Increment the call count.
++call_count_;
// 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));
// Update the last time we were called to now.
last_call_time_ = now;
......@@ -53,7 +53,7 @@ class ThrottleTest : public testing::Test {
void SetUp() {
logger_.reset(new TestLogger());
scheduler_.reset(new DeterministicScheduler(logger_.get()));
start_time_ = scheduler_->GetCurrentTime();
start_time_ = scheduler_->CurrentTime();
call_count_ = 0;
last_call_time_ = Time() - TimeDelta::FromHours(1);
ProtoHelpers::InitRateLimitP(1000, kMessagesPerSecond, rate_limits_.Add());
......@@ -115,7 +115,7 @@ TEST_F(ThrottleTest, ThrottlingScripted) {
// ... until the short throttle interval passes, at which time it should be
// called once more.
scheduler_->PassTime(
start_time_ + TimeDelta::FromSeconds(1) - scheduler_->GetCurrentTime());
start_time_ + TimeDelta::FromSeconds(1) - scheduler_->CurrentTime());
ASSERT_EQ(2, call_count_);
......@@ -144,7 +144,7 @@ TEST_F(ThrottleTest, ThrottlingScripted) {
// Now if we fire slowly, we still shouldn't make calls, since we'd violate
// the larger rate limit interval.
int fire_attempts =
((start_time_ + TimeDelta::FromMinutes(1) - scheduler_->GetCurrentTime())
((start_time_ + TimeDelta::FromMinutes(1) - scheduler_->CurrentTime())
/ long_interval) - 1;
// This value should be 20.
for (int i = 0; i < fire_attempts; ++i) {
......@@ -154,7 +154,7 @@ TEST_F(ThrottleTest, ThrottlingScripted) {
}
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_);
}
......
......@@ -128,7 +128,7 @@ class Scheduler : public ResourceComponent {
* necessarily the UNIX epoch). The only requirement is that this 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
......
......@@ -31,7 +31,7 @@ void DeterministicScheduler::Schedule(TimeDelta delay, Closure* task) {
CHECK(run_state_.IsStarted());
TLOG(logger_, INFO, "(Now: %d) Enqueuing %p with delay %d",
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) {
......@@ -67,7 +67,7 @@ bool DeterministicScheduler::RunNextTask() {
// The queue is not empty, so get the first task and see if its scheduled
// execution time has passed.
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
// from the queue and run the task.
work_queue_.pop();
......
......@@ -65,7 +65,7 @@ class DeterministicScheduler : public Scheduler {
// Nothing to do.
}
virtual Time GetCurrentTime() const {
virtual Time CurrentTime() const {
return current_time_;
}
......
......@@ -86,7 +86,7 @@ class MockScheduler : public Scheduler {
public:
MOCK_METHOD2(Schedule, void(TimeDelta, Closure*)); // NOLINT
MOCK_CONST_METHOD0(IsRunningOnThread, bool());
MOCK_CONST_METHOD0(GetCurrentTime, Time());
MOCK_CONST_METHOD0(CurrentTime, Time());
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