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

Unified Diff: chrome/browser/extensions/api/dial/dial_service.h

Issue 12150002: - Invoke FinishDiscovery() if no network interfaces are detected. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with r181795 Created 7 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/dial/dial_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/dial/dial_service.h
diff --git a/chrome/browser/extensions/api/dial/dial_service.h b/chrome/browser/extensions/api/dial/dial_service.h
index 54ac715761d34fa5d73673b763b7b85b2954d5ca..a714f3590710d8e88c625327ece89a77ce473a8f 100644
--- a/chrome/browser/extensions/api/dial/dial_service.h
+++ b/chrome/browser/extensions/api/dial/dial_service.h
@@ -91,6 +91,12 @@ class DialService {
virtual bool HasObserver(Observer* observer) = 0;
};
+// Implements DialService.
+//
+// NOTE(mfoltz): It would make this class cleaner to refactor most of the state
+// associated with a single discovery cycle into its own |DiscoveryOperation|
+// object. This would also simplify lifetime of the object w.r.t. DialRegistry;
+// the Registry would not need to create/destroy the Service on demand.
class DialServiceImpl : public DialService,
public base::SupportsWeakPtr<DialServiceImpl> {
public:
@@ -104,13 +110,16 @@ class DialServiceImpl : public DialService,
virtual bool HasObserver(Observer* observer) OVERRIDE;
private:
- // Starts the flow to construct and send a discovery request.
- void StartRequest();
+ // Starts the control flow for one discovery cycle.
+ void StartDiscovery();
- // Establishes the UDP socket that is used for requests and responses, then
- // sends a discovery request on the bound socket. Returns |true| if
- // successful.
- bool BindAndWriteSocket(const net::NetworkInterface& bind_interface);
+ // Establishes the UDP socket that is used for requests and responses,
+ // establishes a read callback on the socket, and sends the first discovery
+ // request. Returns true if successful.
+ bool BindSocketAndSendRequest(const net::IPAddressNumber& bind_ip_address);
+
+ // Sends a single discovery request over the socket.
+ void SendOneRequest();
// Callback invoked for socket writes.
void OnSocketWrite(int result);
@@ -181,18 +190,30 @@ class DialServiceImpl : public DialService,
// The number of requests that have been sent in the current discovery.
int num_requests_sent_;
+ // The maximum number of requests to send per discovery cycle.
+ int max_requests_;
+
// Timer for finishing discovery.
base::OneShotTimer<DialServiceImpl> finish_timer_;
// The delay for |finish_timer_|; how long to wait for discovery to finish.
+ // Setting this to zero disables the timer.
base::TimeDelta finish_delay_;
+ // Timer for sending multiple requests at fixed intervals.
+ base::RepeatingTimer<DialServiceImpl> request_timer_;
+
+ // The delay for |request_timer_|; how long to wait between successive
+ // requests.
+ base::TimeDelta request_interval_;
+
// List of observers.
ObserverList<Observer> observer_list_;
// Thread checker.
base::ThreadChecker thread_checker_;
+ FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestSendMultipleRequests);
FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestOnDeviceDiscovered);
FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestOnDiscoveryFinished);
FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestOnDiscoveryRequest);
« no previous file with comments | « no previous file | chrome/browser/extensions/api/dial/dial_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698