OLD | NEW |
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 "content/browser/devtools/protocol/tethering_handler.h" | 5 #include "content/browser/devtools/protocol/tethering_handler.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 | 313 |
314 | 314 |
315 // TetheringHandler ---------------------------------------------------------- | 315 // TetheringHandler ---------------------------------------------------------- |
316 | 316 |
317 // static | 317 // static |
318 TetheringHandler::TetheringImpl* TetheringHandler::impl_ = nullptr; | 318 TetheringHandler::TetheringImpl* TetheringHandler::impl_ = nullptr; |
319 | 319 |
320 TetheringHandler::TetheringHandler( | 320 TetheringHandler::TetheringHandler( |
321 const CreateServerSocketCallback& socket_callback, | 321 const CreateServerSocketCallback& socket_callback, |
322 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 322 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
323 : socket_callback_(socket_callback), | 323 : DevToolsDomainHandler(Tethering::Metainfo::domainName), |
| 324 socket_callback_(socket_callback), |
324 task_runner_(task_runner), | 325 task_runner_(task_runner), |
325 is_active_(false), | 326 is_active_(false), |
326 weak_factory_(this) { | 327 weak_factory_(this) { |
327 } | 328 } |
328 | 329 |
329 TetheringHandler::~TetheringHandler() { | 330 TetheringHandler::~TetheringHandler() { |
330 if (is_active_) { | 331 if (is_active_) { |
331 task_runner_->DeleteSoon(FROM_HERE, impl_); | 332 task_runner_->DeleteSoon(FROM_HERE, impl_); |
332 impl_ = nullptr; | 333 impl_ = nullptr; |
333 } | 334 } |
334 } | 335 } |
335 | 336 |
336 void TetheringHandler::Wire(UberDispatcher* dispatcher) { | 337 void TetheringHandler::Wire(UberDispatcher* dispatcher) { |
337 frontend_.reset(new Tethering::Frontend(dispatcher->channel())); | 338 frontend_.reset(new Tethering::Frontend(dispatcher->channel())); |
338 Tethering::Dispatcher::wire(dispatcher, this); | 339 Tethering::Dispatcher::wire(dispatcher, this); |
339 } | 340 } |
340 | 341 |
341 Response TetheringHandler::Disable() { | |
342 return Response::OK(); | |
343 } | |
344 | |
345 void TetheringHandler::Accepted(uint16_t port, const std::string& name) { | 342 void TetheringHandler::Accepted(uint16_t port, const std::string& name) { |
346 frontend_->Accepted(port, name); | 343 frontend_->Accepted(port, name); |
347 } | 344 } |
348 | 345 |
349 bool TetheringHandler::Activate() { | 346 bool TetheringHandler::Activate() { |
350 if (is_active_) | 347 if (is_active_) |
351 return true; | 348 return true; |
352 if (impl_) | 349 if (impl_) |
353 return false; | 350 return false; |
354 is_active_ = true; | 351 is_active_ = true; |
(...skipping 29 matching lines...) Expand all Loading... |
384 } | 381 } |
385 | 382 |
386 DCHECK(impl_); | 383 DCHECK(impl_); |
387 task_runner_->PostTask( | 384 task_runner_->PostTask( |
388 FROM_HERE, base::Bind(&TetheringImpl::Unbind, base::Unretained(impl_), | 385 FROM_HERE, base::Bind(&TetheringImpl::Unbind, base::Unretained(impl_), |
389 port, base::Passed(std::move(callback)))); | 386 port, base::Passed(std::move(callback)))); |
390 } | 387 } |
391 | 388 |
392 } // namespace protocol | 389 } // namespace protocol |
393 } // namespace content | 390 } // namespace content |
OLD | NEW |