Chromium Code Reviews| 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); |