OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_TRAFFIC_DETECTOR_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_PRIVET_TRAFFIC_DETECTOR_H_ |
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_TRAFFIC_DETECTOR_H_ | 6 #define CHROME_BROWSER_PRINTING_CLOUD_PRINT_PRIVET_TRAFFIC_DETECTOR_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/cancelable_callback.h" | 9 #include "base/cancelable_callback.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "net/base/address_family.h" | 12 #include "net/base/address_family.h" |
13 #include "net/base/ip_endpoint.h" | 13 #include "net/base/ip_endpoint.h" |
14 #include "net/base/network_change_notifier.h" | 14 #include "net/base/network_change_notifier.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 class DatagramServerSocket; | 17 class DatagramServerSocket; |
18 class IOBufferWithSize; | 18 class IOBufferWithSize; |
19 } | 19 } |
20 | 20 |
21 namespace local_discovery { | 21 namespace cloud_print { |
22 | 22 |
23 // Detects mDns traffic that looks like "Privet" protocol. | 23 // Detects mDns traffic that looks like "Privet" protocol. |
24 // Can produce false positives results, but main task of the class is to avoid | 24 // Can produce false positives results, but main task of the class is to avoid |
25 // running full mDns listener if user doesn't have devices. | 25 // running full mDns listener if user doesn't have devices. |
26 // When traffic is detected, class fires callback and shutdowns itself. | 26 // When traffic is detected, class fires callback and shutdowns itself. |
27 class PrivetTrafficDetector | 27 class PrivetTrafficDetector |
28 : public base::RefCountedThreadSafe< | 28 : public base::RefCountedThreadSafe< |
29 PrivetTrafficDetector, content::BrowserThread::DeleteOnIOThread>, | 29 PrivetTrafficDetector, content::BrowserThread::DeleteOnIOThread>, |
30 private net::NetworkChangeNotifier::NetworkChangeObserver { | 30 private net::NetworkChangeNotifier::NetworkChangeObserver { |
31 public: | 31 public: |
(...skipping 28 matching lines...) Expand all Loading... |
60 scoped_ptr<net::DatagramServerSocket> socket_; | 60 scoped_ptr<net::DatagramServerSocket> socket_; |
61 scoped_refptr<net::IOBufferWithSize> io_buffer_; | 61 scoped_refptr<net::IOBufferWithSize> io_buffer_; |
62 base::Time start_time_; | 62 base::Time start_time_; |
63 int restart_attempts_; | 63 int restart_attempts_; |
64 | 64 |
65 base::WeakPtrFactory<PrivetTrafficDetector> weak_ptr_factory_; | 65 base::WeakPtrFactory<PrivetTrafficDetector> weak_ptr_factory_; |
66 | 66 |
67 DISALLOW_COPY_AND_ASSIGN(PrivetTrafficDetector); | 67 DISALLOW_COPY_AND_ASSIGN(PrivetTrafficDetector); |
68 }; | 68 }; |
69 | 69 |
70 } // namespace local_discovery | 70 } // namespace cloud_print |
71 | 71 |
72 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_TRAFFIC_DETECTOR_H_ | 72 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_PRIVET_TRAFFIC_DETECTOR_H_ |
OLD | NEW |