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

Unified Diff: content/child/geofencing/geofencing_message_filter.cc

Issue 476293002: Pass through geofencing API calls to the browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase and add region_id sanity check Created 6 years, 2 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: content/child/geofencing/geofencing_message_filter.cc
diff --git a/content/child/geofencing/geofencing_message_filter.cc b/content/child/geofencing/geofencing_message_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a8334571d5b4f20eb6ca13f3724c760680ddd31b
--- /dev/null
+++ b/content/child/geofencing/geofencing_message_filter.cc
@@ -0,0 +1,43 @@
+// Copyright 2014 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 "content/child/geofencing/geofencing_message_filter.h"
+
+#include "base/message_loop/message_loop_proxy.h"
+#include "content/child/geofencing/geofencing_dispatcher.h"
+#include "content/child/thread_safe_sender.h"
+#include "content/child/worker_thread_task_runner.h"
+#include "ipc/ipc_message_macros.h"
+
+namespace content {
+
+GeofencingMessageFilter::GeofencingMessageFilter(ThreadSafeSender* sender)
+ : main_thread_loop_proxy_(base::MessageLoopProxy::current()),
+ thread_safe_sender_(sender) {
+}
+
+GeofencingMessageFilter::~GeofencingMessageFilter() {
+}
+
+base::TaskRunner* GeofencingMessageFilter::OverrideTaskRunnerForMessage(
+ const IPC::Message& msg) {
+ if (IPC_MESSAGE_CLASS(msg) != GeofencingMsgStart)
+ return NULL;
+ int ipc_thread_id = 0;
+ const bool success = PickleIterator(msg).ReadInt(&ipc_thread_id);
+ DCHECK(success);
+ if (!ipc_thread_id)
+ return main_thread_loop_proxy_.get();
+ return new WorkerThreadTaskRunner(ipc_thread_id);
+}
+
+bool GeofencingMessageFilter::OnMessageReceived(const IPC::Message& msg) {
+ if (IPC_MESSAGE_CLASS(msg) != GeofencingMsgStart)
+ return false;
+ GeofencingDispatcher::GetOrCreateThreadSpecificInstance(
+ thread_safe_sender_.get())->OnMessageReceived(msg);
+ return true;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698