| OLD | NEW |
| 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 // This file implements a standalone host process for Me2Me. | 5 // This file implements a standalone host process for Me2Me. |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 gtk_init(nullptr, nullptr); | 1508 gtk_init(nullptr, nullptr); |
| 1509 #endif | 1509 #endif |
| 1510 | 1510 |
| 1511 // Enable support for SSL server sockets, which must be done while still | 1511 // Enable support for SSL server sockets, which must be done while still |
| 1512 // single-threaded. | 1512 // single-threaded. |
| 1513 net::EnableSSLServerSockets(); | 1513 net::EnableSSLServerSockets(); |
| 1514 | 1514 |
| 1515 // Ensures runtime specific CPU features are initialized. | 1515 // Ensures runtime specific CPU features are initialized. |
| 1516 media::InitializeCPUSpecificMediaFeatures(); | 1516 media::InitializeCPUSpecificMediaFeatures(); |
| 1517 | 1517 |
| 1518 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier( | |
| 1519 net::NetworkChangeNotifier::Create()); | |
| 1520 | |
| 1521 // Create the main message loop and start helper threads. | 1518 // Create the main message loop and start helper threads. |
| 1522 base::MessageLoopForUI message_loop; | 1519 base::MessageLoopForUI message_loop; |
| 1523 scoped_ptr<ChromotingHostContext> context = | 1520 scoped_ptr<ChromotingHostContext> context = |
| 1524 ChromotingHostContext::Create(new AutoThreadTaskRunner( | 1521 ChromotingHostContext::Create(new AutoThreadTaskRunner( |
| 1525 message_loop.message_loop_proxy(), base::MessageLoop::QuitClosure())); | 1522 message_loop.message_loop_proxy(), base::MessageLoop::QuitClosure())); |
| 1526 if (!context) | 1523 if (!context) |
| 1527 return kInitializationFailed; | 1524 return kInitializationFailed; |
| 1528 | 1525 |
| 1526 // NetworkChangeNotifier must be initialized after MessageLoop. |
| 1527 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier( |
| 1528 net::NetworkChangeNotifier::Create()); |
| 1529 |
| 1529 // BasicURLRequestContext holds references to threads, so it needs to be | 1530 // BasicURLRequestContext holds references to threads, so it needs to be |
| 1530 // dereferences on UI threads. Store the reference to the URLRequestGetter to | 1531 // dereferences on UI threads. Store the reference to the URLRequestGetter to |
| 1531 // make sure it's not destroyed on other threads. | 1532 // make sure it's not destroyed on other threads. |
| 1532 // TODO(sergeyu): Consider fixing it in BasicURLRequestContext. | 1533 // TODO(sergeyu): Consider fixing it in BasicURLRequestContext. |
| 1533 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter = | 1534 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter = |
| 1534 context->url_request_context_getter(); | 1535 context->url_request_context_getter(); |
| 1535 | 1536 |
| 1536 // Create & start the HostProcess using these threads. | 1537 // Create & start the HostProcess using these threads. |
| 1537 // TODO(wez): The HostProcess holds a reference to itself until Shutdown(). | 1538 // TODO(wez): The HostProcess holds a reference to itself until Shutdown(). |
| 1538 // Remove this hack as part of the multi-process refactoring. | 1539 // Remove this hack as part of the multi-process refactoring. |
| 1539 int exit_code = kSuccessExitCode; | 1540 int exit_code = kSuccessExitCode; |
| 1540 ShutdownWatchdog shutdown_watchdog( | 1541 ShutdownWatchdog shutdown_watchdog( |
| 1541 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); | 1542 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); |
| 1542 new HostProcess(context.Pass(), &exit_code, &shutdown_watchdog); | 1543 new HostProcess(context.Pass(), &exit_code, &shutdown_watchdog); |
| 1543 | 1544 |
| 1544 // Run the main (also UI) message loop until the host no longer needs it. | 1545 // Run the main (also UI) message loop until the host no longer needs it. |
| 1545 message_loop.Run(); | 1546 message_loop.Run(); |
| 1546 | 1547 |
| 1547 return exit_code; | 1548 return exit_code; |
| 1548 } | 1549 } |
| 1549 | 1550 |
| 1550 } // namespace remoting | 1551 } // namespace remoting |
| OLD | NEW |