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

Side by Side Diff: chromecast/shell/browser/cast_browser_main_parts.cc

Issue 223143003: Initial checkin of chromecast content embedder (cast_shell) and related build scripts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add an additional function in gl_surface_cast.cc Created 6 years, 8 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
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chromecast/shell/browser/cast_browser_main_parts.h"
6
7 #include "base/command_line.h"
8 #include "chromecast/service/cast_service.h"
9 #include "chromecast/shell/browser/cast_browser_context.h"
10 #include "chromecast/shell/browser/url_request_context_factory.h"
11
12 namespace chromecast {
13 namespace shell {
14
15 // static
16 CastBrowserMainParts* CastBrowserMainParts::instance_ = NULL;
17
18 namespace {
19
20 struct DefaultCommandLineSwitch {
21 const char* const switch_name;
22 const char* const switch_value;
23 };
24
25 DefaultCommandLineSwitch defaultSwitches[] = {
26 { "enable-encrypted-media", "" },
27 { "enable-webrtc-hw-decoding", "" },
28 { "disable-plugins", "" },
29 { "enable-threaded-compositing", "" },
30 { "force-compositing-mode", "" },
31 { "enable-software-compositing", "" },
32 { NULL, NULL }, // Termination
33 };
34
35 void AddDefaultCommandLineSwitches(CommandLine* command_line) {
36 int i = 0;
37 while (defaultSwitches[i].switch_name != NULL) {
38 command_line->AppendSwitchASCII(
39 std::string(defaultSwitches[i].switch_name),
40 std::string(defaultSwitches[i].switch_value));
41 ++i;
42 }
43 }
44
45 } // namespace
46
47 CastBrowserMainParts::CastBrowserMainParts(
48 const content::MainFunctionParams& parameters,
49 URLRequestContextFactory* url_request_context_factory)
50 : BrowserMainParts(),
51 url_request_context_factory_(url_request_context_factory) {
52 CommandLine* command_line = CommandLine::ForCurrentProcess();
53 AddDefaultCommandLineSwitches(command_line);
54 DCHECK(instance_ == NULL);
55 instance_ = this;
56 }
57
58 CastBrowserMainParts::~CastBrowserMainParts() {
59 DCHECK(instance_ == this);
60 instance_ = NULL;
61 }
62
63 void CastBrowserMainParts::PreMainMessageLoopStart() {
64 NOTIMPLEMENTED();
65 }
66
67 void CastBrowserMainParts::PostMainMessageLoopStart() {
68 NOTIMPLEMENTED();
69 }
70
71 int CastBrowserMainParts::PreCreateThreads() {
72 return 0;
73 }
74
75 void CastBrowserMainParts::PreMainMessageLoopRun() {
76 url_request_context_factory_->InitializeOnUIThread();
77
78 browser_context_.reset(new CastBrowserContext(url_request_context_factory_));
79
80 cast_service_.reset(new CastService(browser_context_.get()));
81 cast_service_->Start();
82 }
83
84 bool CastBrowserMainParts::MainMessageLoopRun(int* result_code) {
85 base::MessageLoopForUI::current()->Run();
86 return true;
87 }
88
89 void CastBrowserMainParts::PostMainMessageLoopRun() {
90 cast_service_->Stop();
91 browser_context_.reset();
92 }
93
94 // static
95 CastBrowserMainParts* CastBrowserMainParts::GetInstance() {
96 DCHECK(instance_ != NULL);
97 return instance_;
98 }
99
100 } // namespace shell
101 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698