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

Unified Diff: net/android/java/src/org/chromium/net/RegistrationPolicy.java

Issue 1358163004: [Android] Introduce RegistrationPolicy for NetworkChangeNotifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean-up and rebase Created 5 years, 3 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: net/android/java/src/org/chromium/net/RegistrationPolicy.java
diff --git a/net/android/java/src/org/chromium/net/RegistrationPolicy.java b/net/android/java/src/org/chromium/net/RegistrationPolicy.java
new file mode 100644
index 0000000000000000000000000000000000000000..265db21942fdd4ec1a789369cb38e690ec24cfe6
--- /dev/null
+++ b/net/android/java/src/org/chromium/net/RegistrationPolicy.java
@@ -0,0 +1,41 @@
+// Copyright 2015 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.
+
+package org.chromium.net;
+
+/**
+ * Abstract class for providing a policy regarding when the NetworkChangeNotifier
+ * should listen for network changes.
+ */
+public abstract class RegistrationPolicy {
pauljensen 2015/10/01 12:06:36 Can we move this to be a static subclass of Networ
timvolodine 2015/10/05 17:26:45 made it inner static to NCNAD and removed the List
+ private Listener mListener;
+
+ /**
+ * Listener is notified by the policy when it should start/stop listening to network changes.
+ */
+ public interface Listener {
+ // Notifies the listener to start listening to network changes.
+ void register();
+ // Notifies the listener tp stop listening to network changes.
+ void unregister();
+ }
+
+ protected RegistrationPolicy() {}
pauljensen 2015/10/01 12:06:37 why do we need a constructor?
timvolodine 2015/10/05 17:26:45 yup no need, removed. done.
+
+ protected final void notifyRegister() {
pauljensen 2015/10/01 12:06:36 Can we rename notifyRegister to register? ditto fo
pauljensen 2015/10/01 12:06:37 Please add a comments for these functions; they re
timvolodine 2015/10/05 17:26:45 Done.
timvolodine 2015/10/05 17:26:45 Done.
+ assert mListener != null;
+ mListener.register();
+ }
+
+ protected final void notifyUnregister() {
+ assert mListener != null;
+ mListener.unregister();
+ }
+
+ protected void init(Listener listener) {
+ mListener = listener;
pauljensen 2015/10/01 12:06:37 move this line of code to constructor and make thi
timvolodine 2015/10/05 17:26:45 we should be able to pass the registration policy
+ }
+
+ protected abstract void destroy();
+}

Powered by Google App Engine
This is Rietveld 408576698