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

Side by Side Diff: chrome/browser/extensions/api/dial/dial_service.h

Issue 697953002: ObserverList::HasObserver now takes a const pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile errors (ChromeOS unit tests). Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_EXTENSIONS_API_DIAL_DIAL_SERVICE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_SERVICE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 virtual ~DialService() {} 83 virtual ~DialService() {}
84 84
85 // Starts a new round of discovery. Returns |true| if discovery was started 85 // Starts a new round of discovery. Returns |true| if discovery was started
86 // successfully or there is already one active. Returns |false| on error. 86 // successfully or there is already one active. Returns |false| on error.
87 virtual bool Discover() = 0; 87 virtual bool Discover() = 0;
88 88
89 // Called by listeners to this service to add/remove themselves as observers. 89 // Called by listeners to this service to add/remove themselves as observers.
90 virtual void AddObserver(Observer* observer) = 0; 90 virtual void AddObserver(Observer* observer) = 0;
91 virtual void RemoveObserver(Observer* observer) = 0; 91 virtual void RemoveObserver(Observer* observer) = 0;
92 virtual bool HasObserver(Observer* observer) = 0; 92 virtual bool HasObserver(const Observer* observer) const = 0;
93 }; 93 };
94 94
95 // Implements DialService. 95 // Implements DialService.
96 // 96 //
97 // NOTE(mfoltz): It would make this class cleaner to refactor most of the state 97 // NOTE(mfoltz): It would make this class cleaner to refactor most of the state
98 // associated with a single discovery cycle into its own |DiscoveryOperation| 98 // associated with a single discovery cycle into its own |DiscoveryOperation|
99 // object. This would also simplify lifetime of the object w.r.t. DialRegistry; 99 // object. This would also simplify lifetime of the object w.r.t. DialRegistry;
100 // the Registry would not need to create/destroy the Service on demand. 100 // the Registry would not need to create/destroy the Service on demand.
101 class DialServiceImpl : public DialService, 101 class DialServiceImpl : public DialService,
102 public base::SupportsWeakPtr<DialServiceImpl> { 102 public base::SupportsWeakPtr<DialServiceImpl> {
103 public: 103 public:
104 explicit DialServiceImpl(net::NetLog* net_log); 104 explicit DialServiceImpl(net::NetLog* net_log);
105 ~DialServiceImpl() override; 105 ~DialServiceImpl() override;
106 106
107 // DialService implementation 107 // DialService implementation
108 bool Discover() override; 108 bool Discover() override;
109 void AddObserver(Observer* observer) override; 109 void AddObserver(Observer* observer) override;
110 void RemoveObserver(Observer* observer) override; 110 void RemoveObserver(Observer* observer) override;
111 bool HasObserver(Observer* observer) override; 111 bool HasObserver(const Observer* observer) const override;
112 112
113 private: 113 private:
114 // Represents a socket binding to a single network interface. 114 // Represents a socket binding to a single network interface.
115 class DialSocket { 115 class DialSocket {
116 public: 116 public:
117 // TODO(imcheng): Consider writing a DialSocket::Delegate interface that 117 // TODO(imcheng): Consider writing a DialSocket::Delegate interface that
118 // declares methods for these callbacks, and taking a ptr to the delegate 118 // declares methods for these callbacks, and taking a ptr to the delegate
119 // here. 119 // here.
120 DialSocket( 120 DialSocket(
121 const base::Closure& discovery_request_cb, 121 const base::Closure& discovery_request_cb,
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestOnDeviceDiscovered); 294 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestOnDeviceDiscovered);
295 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestOnDiscoveryFinished); 295 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestOnDiscoveryFinished);
296 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestOnDiscoveryRequest); 296 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestOnDiscoveryRequest);
297 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestResponseParsing); 297 FRIEND_TEST_ALL_PREFIXES(DialServiceTest, TestResponseParsing);
298 DISALLOW_COPY_AND_ASSIGN(DialServiceImpl); 298 DISALLOW_COPY_AND_ASSIGN(DialServiceImpl);
299 }; 299 };
300 300
301 } // namespace extensions 301 } // namespace extensions
302 302
303 #endif // CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_SERVICE_H_ 303 #endif // CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/dial/dial_registry_unittest.cc ('k') | chrome/browser/extensions/api/dial/dial_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698