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

Unified Diff: chrome/browser/local_discovery/service_discovery_client_mdns.h

Issue 256913005: In browser process implementation of ServiceDiscoveryClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tue 04/29/2014 14:32:52.76 Created 6 years, 8 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/local_discovery/service_discovery_client_mdns.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/local_discovery/service_discovery_client_mdns.h
diff --git a/chrome/browser/local_discovery/service_discovery_client_utility.h b/chrome/browser/local_discovery/service_discovery_client_mdns.h
similarity index 58%
copy from chrome/browser/local_discovery/service_discovery_client_utility.h
copy to chrome/browser/local_discovery/service_discovery_client_mdns.h
index beb3f2e040c90e0795b919cc6e8588a17f8796b3..c741f51ab5e81a765716e2bb81fe50eaaea54f6f 100644
--- a/chrome/browser/local_discovery/service_discovery_client_utility.h
+++ b/chrome/browser/local_discovery/service_discovery_client_mdns.h
@@ -2,27 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_CLIENT_UTILITY_H_
-#define CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_CLIENT_UTILITY_H_
+#ifndef CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_CLIENT_MDNS_H_
+#define CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_CLIENT_MDNS_H_
+#include <set>
#include <string>
#include "base/cancelable_callback.h"
#include "chrome/browser/local_discovery/service_discovery_shared_client.h"
#include "chrome/common/local_discovery/service_discovery_client.h"
#include "net/base/network_change_notifier.h"
+#include "net/dns/mdns_client.h"
namespace local_discovery {
-class ServiceDiscoveryHostClient;
-
-// Wrapper for ServiceDiscoveryHostClient to hide restarting of utility process
-// from mdns users.
-class ServiceDiscoveryClientUtility
+// Implementation of ServiceDiscoverySharedClient with front-end of UI thread
+// and networking code on IO thread.
+class ServiceDiscoveryClientMdns
: public ServiceDiscoverySharedClient,
public net::NetworkChangeNotifier::NetworkChangeObserver {
public:
- ServiceDiscoveryClientUtility();
+ class Proxy;
+ ServiceDiscoveryClientMdns();
// ServiceDiscoveryClient implementation.
virtual scoped_ptr<ServiceWatcher> CreateServiceWatcher(
@@ -41,20 +42,43 @@ class ServiceDiscoveryClientUtility
net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
private:
- friend class base::RefCounted<ServiceDiscoveryClientUtility>;
+ virtual ~ServiceDiscoveryClientMdns();
- virtual ~ServiceDiscoveryClientUtility();
void ScheduleStartNewClient();
void StartNewClient();
+ void OnInterfaceListReady(const net::InterfaceIndexFamilyList& interfaces);
+ void OnMdnsInitialized(bool success);
void ReportSuccess();
+ void InvalidateWeakPtrs();
+ void Reset();
+
+ bool PostToMdnsThread(const base::Closure& task);
+
+ std::set<Proxy*> proxies_;
+
+ scoped_refptr<base::SequencedTaskRunner> mdns_runner_;
+
+ // Access only on |mdns_runner_| thread.
+ scoped_ptr<net::MDnsClient> mdns_;
- scoped_refptr<ServiceDiscoveryHostClient> host_client_;
+ // Access only on |mdns_runner_| thread.
+ scoped_ptr<ServiceDiscoveryClient> client_;
+
+ // Counter of restart attempts we have made after network change.
int restart_attempts_;
- base::WeakPtrFactory<ServiceDiscoveryClientUtility> weak_ptr_factory_;
- DISALLOW_COPY_AND_ASSIGN(ServiceDiscoveryClientUtility);
+ // If false delay tasks until initialization is posted to |mdns_runner_|
+ // thread.
+ bool need_dalay_mdns_tasks_;
+
+ // Delayed |mdns_runner_| tasks.
+ std::vector<base::Closure> delayed_tasks_;
+
+ base::WeakPtrFactory<ServiceDiscoveryClientMdns> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ServiceDiscoveryClientMdns);
};
} // namespace local_discovery
-#endif // CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_CLIENT_UTILITY_H_
+#endif // CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_CLIENT_MDNS_H_
« no previous file with comments | « no previous file | chrome/browser/local_discovery/service_discovery_client_mdns.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698