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

Side by Side Diff: chrome/browser/extensions/api/dial/dial_registry.cc

Issue 1810433002: [DIAL API] Force increment registry generation on discoverNow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/extensions/api/dial/dial_registry.h" 5 #include "chrome/browser/extensions/api/dial/dial_registry.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 if (!ReadyToDiscover()) { 99 if (!ReadyToDiscover()) {
100 return false; 100 return false;
101 } 101 }
102 if (!dial_.get()) { 102 if (!dial_.get()) {
103 dial_api_->OnDialError(DIAL_UNKNOWN); 103 dial_api_->OnDialError(DIAL_UNKNOWN);
104 return false; 104 return false;
105 } 105 }
106 106
107 if (!dial_->HasObserver(this)) 107 if (!dial_->HasObserver(this))
108 NOTREACHED() << "DiscoverNow() called without observing dial_"; 108 NOTREACHED() << "DiscoverNow() called without observing dial_";
109 return dial_->Discover(); 109
110 // Force increment |registry_generation_| to ensure an event is sent even if
111 // the device list did not change.
112 bool started = dial_->Discover();
113 if (started)
114 ++registry_generation_;
115
116 return started;
110 } 117 }
111 118
112 void DialRegistry::StartPeriodicDiscovery() { 119 void DialRegistry::StartPeriodicDiscovery() {
113 DCHECK(thread_checker_.CalledOnValidThread()); 120 DCHECK(thread_checker_.CalledOnValidThread());
114 if (!ReadyToDiscover() || dial_.get()) 121 if (!ReadyToDiscover() || dial_.get())
115 return; 122 return;
116 123
117 dial_.reset(CreateDialService()); 124 dial_.reset(CreateDialService());
118 dial_->AddObserver(this); 125 dial_->AddObserver(this);
119 DoDiscovery(); 126 DoDiscovery();
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 case NetworkChangeNotifier::CONNECTION_BLUETOOTH: 320 case NetworkChangeNotifier::CONNECTION_BLUETOOTH:
314 if (!dial_.get()) { 321 if (!dial_.get()) {
315 VLOG(2) << "Connection detected, restarting discovery."; 322 VLOG(2) << "Connection detected, restarting discovery.";
316 StartPeriodicDiscovery(); 323 StartPeriodicDiscovery();
317 } 324 }
318 break; 325 break;
319 } 326 }
320 } 327 }
321 328
322 } // namespace extensions 329 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698