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

Side by Side Diff: chrome/browser/local_discovery/service_discovery_client_mdns.cc

Issue 1143343005: chrome/browser: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/local_discovery/service_discovery_client_mdns.h" 5 #include "chrome/browser/local_discovery/service_discovery_client_mdns.h"
6 6
7 #include "base/location.h"
7 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
8 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h"
9 #include "chrome/common/local_discovery/service_discovery_client_impl.h" 12 #include "chrome/common/local_discovery/service_discovery_client_impl.h"
10 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
11 #include "net/dns/mdns_client.h" 14 #include "net/dns/mdns_client.h"
12 #include "net/udp/datagram_server_socket.h" 15 #include "net/udp/datagram_server_socket.h"
13 16
14 namespace local_discovery { 17 namespace local_discovery {
15 18
16 using content::BrowserThread; 19 using content::BrowserThread;
17 20
18 // Base class for objects returned by ServiceDiscoveryClient implementation. 21 // Base class for objects returned by ServiceDiscoveryClient implementation.
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 DCHECK_CURRENTLY_ON(BrowserThread::UI); 363 DCHECK_CURRENTLY_ON(BrowserThread::UI);
361 // Only network changes resets counter. 364 // Only network changes resets counter.
362 restart_attempts_ = 0; 365 restart_attempts_ = 0;
363 ScheduleStartNewClient(); 366 ScheduleStartNewClient();
364 } 367 }
365 368
366 void ServiceDiscoveryClientMdns::ScheduleStartNewClient() { 369 void ServiceDiscoveryClientMdns::ScheduleStartNewClient() {
367 DCHECK_CURRENTLY_ON(BrowserThread::UI); 370 DCHECK_CURRENTLY_ON(BrowserThread::UI);
368 OnBeforeMdnsDestroy(); 371 OnBeforeMdnsDestroy();
369 if (restart_attempts_ < kMaxRestartAttempts) { 372 if (restart_attempts_ < kMaxRestartAttempts) {
370 base::MessageLoop::current()->PostDelayedTask( 373 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
371 FROM_HERE, 374 FROM_HERE, base::Bind(&ServiceDiscoveryClientMdns::StartNewClient,
372 base::Bind(&ServiceDiscoveryClientMdns::StartNewClient, 375 weak_ptr_factory_.GetWeakPtr()),
373 weak_ptr_factory_.GetWeakPtr()), 376 base::TimeDelta::FromSeconds(kRestartDelayOnNetworkChangeSeconds *
374 base::TimeDelta::FromSeconds( 377 (1 << restart_attempts_)));
375 kRestartDelayOnNetworkChangeSeconds * (1 << restart_attempts_)));
376 } else { 378 } else {
377 ReportSuccess(); 379 ReportSuccess();
378 } 380 }
379 } 381 }
380 382
381 void ServiceDiscoveryClientMdns::StartNewClient() { 383 void ServiceDiscoveryClientMdns::StartNewClient() {
382 DCHECK_CURRENTLY_ON(BrowserThread::UI); 384 DCHECK_CURRENTLY_ON(BrowserThread::UI);
383 ++restart_attempts_; 385 ++restart_attempts_;
384 DestroyMdns(); 386 DestroyMdns();
385 mdns_.reset(net::MDnsClient::CreateDefault().release()); 387 mdns_.reset(net::MDnsClient::CreateDefault().release());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 OnBeforeMdnsDestroy(); 434 OnBeforeMdnsDestroy();
433 // After calling |Proxy::OnMdnsDestroy| all references to client_ and mdns_ 435 // After calling |Proxy::OnMdnsDestroy| all references to client_ and mdns_
434 // should be destroyed. 436 // should be destroyed.
435 if (client_) 437 if (client_)
436 mdns_runner_->DeleteSoon(FROM_HERE, client_.release()); 438 mdns_runner_->DeleteSoon(FROM_HERE, client_.release());
437 if (mdns_) 439 if (mdns_)
438 mdns_runner_->DeleteSoon(FROM_HERE, mdns_.release()); 440 mdns_runner_->DeleteSoon(FROM_HERE, mdns_.release());
439 } 441 }
440 442
441 } // namespace local_discovery 443 } // namespace local_discovery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698