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

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: Simplify DialService::SendNetworkList 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
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 fb9924d46a127fb07fd984298d78e0c897a61b73..adc202984de307a4908a35e72a95caeb8e489349 100644
--- a/chrome/browser/extensions/api/dial/dial_service.h
+++ b/chrome/browser/extensions/api/dial/dial_service.h
@@ -102,13 +102,16 @@ class DialServiceImpl : public DialService {
private:
virtual ~DialServiceImpl();
- // 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);
@@ -161,6 +164,10 @@ class DialServiceImpl : public DialService {
// The NetLog source for this service.
net::NetLog::Source net_log_source_;
+ // NOTE(mfoltz): It would make this class cleaner to refactor most of the
justinlin 2013/02/08 08:56:20 Move this TODO to the top of this class or somewhe
mark a. foltz 2013/02/08 22:07:58 Done, and elaborated it a bit.
+ // following state into its own |DiscoveryOperation| object that was managed
+ // by the DialServiceImpl object.
+
// Buffer for socket writes.
scoped_refptr<net::StringIOBuffer> send_buffer_;
@@ -182,18 +189,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') | chrome/browser/extensions/api/dial/dial_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698