| Index: chromecast/shell/browser/cast_browser_main_parts.cc
|
| diff --git a/chromecast/shell/browser/cast_browser_main_parts.cc b/chromecast/shell/browser/cast_browser_main_parts.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..742dc0bfd38c5dffba408edc5d7fe081bfcbd42b
|
| --- /dev/null
|
| +++ b/chromecast/shell/browser/cast_browser_main_parts.cc
|
| @@ -0,0 +1,101 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chromecast/shell/browser/cast_browser_main_parts.h"
|
| +
|
| +#include "base/command_line.h"
|
| +#include "chromecast/net/network_change_notifier_cast.h"
|
| +#include "chromecast/net/network_change_notifier_factory_cast.h"
|
| +#include "chromecast/service/cast_service.h"
|
| +#include "chromecast/shell/browser/cast_browser_context.h"
|
| +#include "chromecast/shell/browser/url_request_context_factory.h"
|
| +
|
| +namespace chromecast {
|
| +namespace shell {
|
| +
|
| +// static
|
| +CastBrowserMainParts* CastBrowserMainParts::instance_ = NULL;
|
| +
|
| +namespace {
|
| +
|
| +struct DefaultCommandLineSwitch {
|
| + const char* const switch_name;
|
| + const char* const switch_value;
|
| +};
|
| +
|
| +DefaultCommandLineSwitch g_default_switches[] = {
|
| + { "enable-webrtc-hw-decoding", "" },
|
| + { "disable-plugins", "" },
|
| + { "enable-threaded-compositing", "" },
|
| + { NULL, NULL }, // Termination
|
| +};
|
| +
|
| +void AddDefaultCommandLineSwitches(CommandLine* command_line) {
|
| + int i = 0;
|
| + while (g_default_switches[i].switch_name != NULL) {
|
| + command_line->AppendSwitchASCII(
|
| + std::string(g_default_switches[i].switch_name),
|
| + std::string(g_default_switches[i].switch_value));
|
| + ++i;
|
| + }
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +CastBrowserMainParts::CastBrowserMainParts(
|
| + const content::MainFunctionParams& parameters,
|
| + URLRequestContextFactory* url_request_context_factory)
|
| + : BrowserMainParts(),
|
| + url_request_context_factory_(url_request_context_factory) {
|
| + CommandLine* command_line = CommandLine::ForCurrentProcess();
|
| + AddDefaultCommandLineSwitches(command_line);
|
| + DCHECK(instance_ == NULL);
|
| + instance_ = this;
|
| +}
|
| +
|
| +CastBrowserMainParts::~CastBrowserMainParts() {
|
| + DCHECK(instance_ == this);
|
| + instance_ = NULL;
|
| +}
|
| +
|
| +void CastBrowserMainParts::PreMainMessageLoopStart() {
|
| + net::NetworkChangeNotifier::SetFactory(
|
| + new NetworkChangeNotifierFactoryCast());
|
| +}
|
| +
|
| +void CastBrowserMainParts::PostMainMessageLoopStart() {
|
| + NOTIMPLEMENTED();
|
| +}
|
| +
|
| +int CastBrowserMainParts::PreCreateThreads() {
|
| + return 0;
|
| +}
|
| +
|
| +void CastBrowserMainParts::PreMainMessageLoopRun() {
|
| + url_request_context_factory_->InitializeOnUIThread();
|
| +
|
| + browser_context_.reset(new CastBrowserContext(url_request_context_factory_));
|
| +
|
| + cast_service_.reset(new CastService(browser_context_.get()));
|
| + cast_service_->Start();
|
| +}
|
| +
|
| +bool CastBrowserMainParts::MainMessageLoopRun(int* result_code) {
|
| + base::MessageLoopForUI::current()->Run();
|
| + return true;
|
| +}
|
| +
|
| +void CastBrowserMainParts::PostMainMessageLoopRun() {
|
| + cast_service_->Stop();
|
| + browser_context_.reset();
|
| +}
|
| +
|
| +// static
|
| +CastBrowserMainParts* CastBrowserMainParts::GetInstance() {
|
| + DCHECK(instance_ != NULL);
|
| + return instance_;
|
| +}
|
| +
|
| +} // namespace shell
|
| +} // namespace chromecast
|
|
|