Add logs and small change in BasicPortAllocator.

The added logs will be helpful for debugging.
If a session has stopped, terminate DoAllocate early.
Session::init always returns true, so there is no need to check the return value.

R=deadbeef@webrtc.org, skvlad@webrtc.org

Review URL: https://codereview.webrtc.org/2267163002 .

Cr-Commit-Position: refs/heads/master@{#13871}
diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc
index ebe59bf..d4d0e5e 100644
--- a/webrtc/p2p/base/p2ptransportchannel.cc
+++ b/webrtc/p2p/base/p2ptransportchannel.cc
@@ -461,6 +461,7 @@
     } else {
       AddAllocatorSession(allocator_->CreateSession(
           transport_name(), component(), ice_ufrag_, ice_pwd_));
+      LOG(LS_INFO) << "Start getting ports";
       allocator_sessions_.back()->StartGettingPorts();
     }
   }
diff --git a/webrtc/p2p/client/basicportallocator.cc b/webrtc/p2p/client/basicportallocator.cc
index 55b1fd8..6234d77 100644
--- a/webrtc/p2p/client/basicportallocator.cc
+++ b/webrtc/p2p/client/basicportallocator.cc
@@ -549,10 +549,14 @@
   bool done_signal_needed = false;
   std::vector<rtc::Network*> networks = GetNetworks();
 
+  if (IsStopped()) {
+    return;
+  }
   if (networks.empty()) {
     LOG(LS_WARNING) << "Machine has no networks; no ports will be allocated";
     done_signal_needed = true;
   } else {
+    LOG(LS_INFO) << "Allocate ports on "<< networks.size() << " networks";
     PortConfiguration* config = configs_.empty() ? nullptr : configs_.back();
     for (uint32_t i = 0; i < networks.size(); ++i) {
       uint32_t sequence_flags = flags();
@@ -585,17 +589,12 @@
 
       AllocationSequence* sequence =
           new AllocationSequence(this, networks[i], config, sequence_flags);
-      if (!sequence->Init()) {
-        delete sequence;
-        continue;
-      }
-      done_signal_needed = true;
       sequence->SignalPortAllocationComplete.connect(
           this, &BasicPortAllocatorSession::OnPortAllocationComplete);
-      if (!IsStopped()) {
-        sequence->Start();
-      }
+      sequence->Init();
+      sequence->Start();
       sequences_.push_back(sequence);
+      done_signal_needed = true;
     }
   }
   if (done_signal_needed) {
@@ -618,7 +617,10 @@
   }
   RemovePortsAndCandidates(failed_networks);
 
-  network_manager_started_ = true;
+  if (!network_manager_started_) {
+    LOG(LS_INFO) << "Network manager is started";
+    network_manager_started_ = true;
+  }
   if (allocation_started_)
     DoAllocate();
 }
@@ -986,7 +988,7 @@
       phase_(0) {
 }
 
-bool AllocationSequence::Init() {
+void AllocationSequence::Init() {
   if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) {
     udp_socket_.reset(session_->socket_factory()->CreateUdpSocket(
         rtc::SocketAddress(ip_, 0), session_->allocator()->min_port(),
@@ -998,7 +1000,6 @@
     // Continuing if |udp_socket_| is NULL, as local TCP and RelayPort using TCP
     // are next available options to setup a communication channel.
   }
-  return true;
 }
 
 void AllocationSequence::Clear() {
diff --git a/webrtc/p2p/client/basicportallocator.h b/webrtc/p2p/client/basicportallocator.h
index ebba4db..204ff04 100644
--- a/webrtc/p2p/client/basicportallocator.h
+++ b/webrtc/p2p/client/basicportallocator.h
@@ -288,7 +288,7 @@
                      PortConfiguration* config,
                      uint32_t flags);
   ~AllocationSequence();
-  bool Init();
+  void Init();
   void Clear();
   void OnNetworkFailed();