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

Side by Side Diff: blimp/client/app/linux/blimp_main.cc

Issue 2363153002: Migrate Linux Blimp client to use BlimpClientContext (Closed)
Patch Set: Fix dependency issue found by gn check Created 4 years, 2 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <string> 5 #include <string>
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "blimp/client/app/blimp_startup.h" 12 #include "blimp/client/app/blimp_startup.h"
13 #include "blimp/client/app/linux/blimp_client_session_linux.h" 13 #include "blimp/client/app/linux/blimp_client_context_delegate_linux.h"
14 #include "blimp/client/core/contents/navigation_feature.h" 14 #include "blimp/client/app/linux/blimp_display_manager.h"
15 #include "blimp/client/core/contents/tab_control_feature.h" 15 #include "blimp/client/app/linux/blimp_display_manager_delegate_main.h"
16 #include "blimp/client/core/session/assignment_source.h" 16 #include "blimp/client/public/blimp_client_context.h"
17 #include "blimp/client/public/contents/blimp_navigation_controller.h"
18 #include "blimp/client/support/compositor/compositor_dependencies_impl.h"
17 #include "ui/gfx/x/x11_connection.h" 19 #include "ui/gfx/x/x11_connection.h"
18 20
19 namespace { 21 namespace {
20 const char kDummyLoginToken[] = "";
21 const char kDefaultUrl[] = "https://www.google.com"; 22 const char kDefaultUrl[] = "https://www.google.com";
22 const int kDummyTabId = 0; 23 constexpr int kWindowWidth = 800;
24 constexpr int kWindowHeight = 600;
23 } 25 }
24 26
25 int main(int argc, const char**argv) { 27 int main(int argc, const char**argv) {
26 base::AtExitManager at_exit; 28 base::AtExitManager at_exit;
27 base::CommandLine::Init(argc, argv); 29 base::CommandLine::Init(argc, argv);
28 30
29 CHECK(gfx::InitializeThreadedX11()); 31 CHECK(gfx::InitializeThreadedX11());
30 32
31 blimp::client::InitializeLogging(); 33 blimp::client::InitializeLogging();
32 blimp::client::InitializeMainMessageLoop(); 34 blimp::client::InitializeMainMessageLoop();
33 35
34 blimp::client::BlimpClientSessionLinux session; 36 base::Thread io_thread("BlimpIOThread");
35 session.GetTabControlFeature()->CreateTab(kDummyTabId); 37 base::Thread::Options options;
36 session.Connect(kDummyLoginToken); 38 options.message_loop_type = base::MessageLoop::TYPE_IO;
39 io_thread.StartWithOptions(options);
40
41 // Creating this using "new" and passing to context using "WrapUnique" as
42 // opposed to "MakeUnique" because we'll need to pass the compositor
43 // dependencies to the display manager as well.
44 blimp::client::CompositorDependencies* compositor_dependencies =
45 new blimp::client::CompositorDependenciesImpl();
46 // Creating the context delegate before the context so that the context is
47 // destroyed before the delegate.
48 std::unique_ptr<blimp::client::BlimpClientContextDelegate> context_delegate =
49 base::MakeUnique<blimp::client::BlimpClientContextDelegateLinux>();
50 std::unique_ptr<blimp::client::BlimpClientContext> context =
51 base::WrapUnique<blimp::client::BlimpClientContext>(
52 blimp::client::BlimpClientContext::Create(
53 io_thread.task_runner(), io_thread.task_runner(),
54 base::WrapUnique(compositor_dependencies)));
55 context->SetDelegate(context_delegate.get());
56
57 context->Connect();
37 58
38 // If there is a non-switch argument to the command line, load that url. 59 // If there is a non-switch argument to the command line, load that url.
39 base::CommandLine::StringVector args = 60 base::CommandLine::StringVector args =
40 base::CommandLine::ForCurrentProcess()->GetArgs(); 61 base::CommandLine::ForCurrentProcess()->GetArgs();
41 std::string url = args.size() > 0 ? args[0] : kDefaultUrl; 62 std::string url = args.size() > 0 ? args[0] : kDefaultUrl;
42 session.GetNavigationFeature()->NavigateToUrlText(kDummyTabId, url); 63 std::unique_ptr<blimp::client::BlimpContents> contents =
64 context->CreateBlimpContents(nullptr);
65 contents->GetNavigationController().LoadURL(GURL(url));
66
67 std::unique_ptr<blimp::client::BlimpDisplayManagerDelegate>
68 display_manager_delegate =
69 base::MakeUnique<blimp::client::BlimpDisplayManagerDelegateMain>();
70 blimp::client::BlimpDisplayManager display_manager(
71 display_manager_delegate.get(), compositor_dependencies);
72 display_manager.SetWindowSize(gfx::Size(kWindowWidth, kWindowHeight));
73 display_manager.SetBlimpContents(std::move(contents));
43 74
44 base::RunLoop().Run(); 75 base::RunLoop().Run();
45 } 76 }
OLDNEW
« no previous file with comments | « blimp/client/app/linux/blimp_display_manager_delegate_main.cc ('k') | blimp/client/support/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698