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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBleClient.java

Issue 2552143002: Refactor Nearby Message listener (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/physicalweb/NearbyMessageIntentService.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBleClient.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBleClient.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBleClient.java
index 2335cfcbfb25c12043ac47824352e99ddf5d7345..9ad9c8913e4dbb3d4746211d2cc98f362165f57e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBleClient.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBleClient.java
@@ -34,6 +34,24 @@ public class PhysicalWebBleClient {
public void onFound(Message message) {}
}
+ protected static class BackgroundMessageListener extends MessageListener {
+ @Override
+ public void onFound(Message message) {
+ String url = PhysicalWebBleClient.getInstance().getUrlFromMessage(message);
+ if (url != null) {
+ UrlManager.getInstance().addUrl(new UrlInfo(url));
+ }
+ }
+
+ @Override
+ public void onLost(Message message) {
+ String url = PhysicalWebBleClient.getInstance().getUrlFromMessage(message);
+ if (url != null) {
+ UrlManager.getInstance().removeUrl(new UrlInfo(url));
+ }
+ }
+ };
+
/**
* Get a singleton instance of this class.
* @return an instance of this class (or subclass).
@@ -89,6 +107,14 @@ public class PhysicalWebBleClient {
}
/**
+ * Create a MessageListener that listens during a background scan.
+ * @return the MessageListener.
+ */
+ MessageListener createBackgroundMessageListener() {
+ return new BackgroundMessageListener();
+ }
+
+ /**
* Begin a foreground subscription to URLs broadcasted from BLE beacons.
* This currently does nothing and should be overridden by a subclass.
* @param activity The Activity that is performing the scan.
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/physicalweb/NearbyMessageIntentService.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698