Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2846)

Unified Diff: chrome/browser/sync/notifier/chrome_system_resources.cc

Issue 2827014: Implemented initial version of server-issued notification client. (Closed)
Patch Set: Added DEPS Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/notifier/chrome_system_resources.cc
diff --git a/chrome/browser/sync/notifier/chrome_system_resources.cc b/chrome/browser/sync/notifier/chrome_system_resources.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0ec02108a92975edd285ec9ad596e0ad29a848b5
--- /dev/null
+++ b/chrome/browser/sync/notifier/chrome_system_resources.cc
@@ -0,0 +1,75 @@
+// Copyright (c) 2010 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.
+
+#include "chrome/browser/sync/notifier/chrome_system_resources.h"
+
+#include <cstdlib>
+#include <string>
+
+#include "base/logging.h"
+#include "base/message_loop.h"
+#include "base/string_util.h"
+#include "base/task.h"
+#include "chrome/browser/sync/notifier/invalidation_util.h"
+
+namespace sync_notifier {
+
+ChromeSystemResources::ChromeSystemResources()
+ : scheduler_active_(false) {}
+
+ChromeSystemResources::~ChromeSystemResources() {
+ DCHECK(!scheduler_active_);
+}
+
+invalidation::Time ChromeSystemResources::current_time() {
+ return base::Time::Now();
+}
+
+void ChromeSystemResources::StartScheduler() {
+ DCHECK(!scheduler_active_);
+ scheduler_active_ = true;
+}
+
+void ChromeSystemResources::StopScheduler() {
+ DCHECK(scheduler_active_);
+ scheduler_active_ = false;
+}
+
+void ChromeSystemResources::ScheduleWithDelay(
+ invalidation::TimeDelta delay,
+ invalidation::Closure* task) {
+ if (!scheduler_active_) {
+ delete task;
+ return;
+ }
+ DCHECK(invalidation::IsCallbackRepeatable(task));
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ NewRunnableFunction(&RunAndDeleteClosure, task),
+ delay.InMillisecondsRoundedUp());
+}
+
+void ChromeSystemResources::ScheduleImmediately(
+ invalidation::Closure* task) {
+ if (!scheduler_active_) {
+ delete task;
+ return;
+ }
+ DCHECK(invalidation::IsCallbackRepeatable(task));
+ MessageLoop::current()->PostTask(
+ FROM_HERE, NewRunnableFunction(&RunAndDeleteClosure, task));
+}
+
+void ChromeSystemResources::Log(
+ LogLevel level, const char* file, int line,
+ const char* format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ std::string result;
+ StringAppendV(&result, format, ap);
+ logging::LogMessage(file, line).stream() << result;
+ va_end(ap);
+}
+
+} // namespace sync_notifier
« no previous file with comments | « chrome/browser/sync/notifier/chrome_system_resources.h ('k') | chrome/browser/sync/notifier/invalidation_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698