OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 package org.chromium.net; | |
6 | |
7 /** | |
8 * Abstract class for providing a policy regarding when the NetworkChangeNotifie r | |
9 * should listen for network changes. | |
10 */ | |
11 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
| |
12 private Listener mListener; | |
13 | |
14 /** | |
15 * Listener is notified by the policy when it should start/stop listening to network changes. | |
16 */ | |
17 public interface Listener { | |
18 // Notifies the listener to start listening to network changes. | |
19 void register(); | |
20 // Notifies the listener tp stop listening to network changes. | |
21 void unregister(); | |
22 } | |
23 | |
24 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.
| |
25 | |
26 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.
| |
27 assert mListener != null; | |
28 mListener.register(); | |
29 } | |
30 | |
31 protected final void notifyUnregister() { | |
32 assert mListener != null; | |
33 mListener.unregister(); | |
34 } | |
35 | |
36 protected void init(Listener listener) { | |
37 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
| |
38 } | |
39 | |
40 protected abstract void destroy(); | |
41 } | |
OLD | NEW |