OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mandoline/ui/browser/browser_manager.h" | 5 #include "mandoline/ui/browser/browser_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/time/time.h" | |
8 #include "components/view_manager/public/cpp/view.h" | 9 #include "components/view_manager/public/cpp/view.h" |
9 #include "components/view_manager/public/cpp/view_observer.h" | 10 #include "components/view_manager/public/cpp/view_observer.h" |
10 #include "mandoline/ui/browser/browser.h" | 11 #include "mandoline/ui/browser/browser.h" |
12 #include "mojo/runner/switches.h" | |
13 #include "mojo/services/tracing/tracing.mojom.h" | |
11 | 14 |
12 namespace mandoline { | 15 namespace mandoline { |
13 | 16 |
14 namespace { | 17 namespace { |
15 | 18 |
16 const char kGoogleURL[] = "http://www.google.com"; | 19 const char kGoogleURL[] = "http://www.google.com"; |
17 | 20 |
18 } // namespace | 21 } // namespace |
19 | 22 |
20 BrowserManager::BrowserManager() | 23 BrowserManager::BrowserManager() |
(...skipping 26 matching lines...) Expand all Loading... | |
47 // Create a Browser for each valid URL in the command line. | 50 // Create a Browser for each valid URL in the command line. |
48 for (const auto& arg : command_line->GetArgs()) { | 51 for (const auto& arg : command_line->GetArgs()) { |
49 GURL url(arg); | 52 GURL url(arg); |
50 if (url.is_valid()) | 53 if (url.is_valid()) |
51 CreateBrowser(url); | 54 CreateBrowser(url); |
52 } | 55 } |
53 // If there were no valid URLs in the command line create a Browser with the | 56 // If there were no valid URLs in the command line create a Browser with the |
54 // default URL. | 57 // default URL. |
55 if (browsers_.empty()) | 58 if (browsers_.empty()) |
56 CreateBrowser(GURL(kGoogleURL)); | 59 CreateBrowser(GURL(kGoogleURL)); |
60 | |
61 // Record the browser startup time metrics for performance testing. | |
62 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
63 switches::kStatsCollectionController)) { | |
64 mojo::URLRequestPtr request(mojo::URLRequest::New()); | |
65 request->url = mojo::String::From("mojo:tracing"); | |
66 tracing::StartupPerformanceControllerPtr controller; | |
67 app_->ConnectToService(request.Pass(), &controller); | |
68 // TODO(msw): When to record the browser message loop start time? | |
69 const base::Time startup_time = base::Time::Now(); | |
yzshen1
2015/08/13 15:59:12
Why do we need to call base::Time::Now() three tim
msw
2015/08/14 23:20:35
This is just a placeholder with TODOs. I'm not ent
yzshen1
2015/08/17 05:46:38
SGTM. Thanks!
| |
70 controller->SetBrowserMessageLoopStartTime(startup_time.ToInternalValue()); | |
71 // TODO(msw): When to record the browser window display time? | |
72 const base::Time display_time = base::Time::Now(); | |
73 controller->SetBrowserWindowDisplayTime(display_time.ToInternalValue()); | |
74 // TODO(msw): When to record the browser open tabs time? | |
75 const base::Time open_tabs_time = base::Time::Now(); | |
76 controller->SetBrowserOpenTabsTime(open_tabs_time.ToInternalValue()); | |
77 } | |
57 } | 78 } |
58 | 79 |
59 bool BrowserManager::ConfigureIncomingConnection( | 80 bool BrowserManager::ConfigureIncomingConnection( |
60 mojo::ApplicationConnection* connection) { | 81 mojo::ApplicationConnection* connection) { |
61 connection->AddService<LaunchHandler>(this); | 82 connection->AddService<LaunchHandler>(this); |
62 return true; | 83 return true; |
63 } | 84 } |
64 | 85 |
65 void BrowserManager::BrowserClosed(Browser* browser) { | 86 void BrowserManager::BrowserClosed(Browser* browser) { |
66 scoped_ptr<Browser> browser_owner(browser); | 87 scoped_ptr<Browser> browser_owner(browser); |
(...skipping 10 matching lines...) Expand all Loading... | |
77 aura_init_.reset(new AuraInit(view, app_->shell())); | 98 aura_init_.reset(new AuraInit(view, app_->shell())); |
78 #endif | 99 #endif |
79 } | 100 } |
80 | 101 |
81 void BrowserManager::Create(mojo::ApplicationConnection* connection, | 102 void BrowserManager::Create(mojo::ApplicationConnection* connection, |
82 mojo::InterfaceRequest<LaunchHandler> request) { | 103 mojo::InterfaceRequest<LaunchHandler> request) { |
83 launch_handler_bindings_.AddBinding(this, request.Pass()); | 104 launch_handler_bindings_.AddBinding(this, request.Pass()); |
84 } | 105 } |
85 | 106 |
86 } // namespace mandoline | 107 } // namespace mandoline |
OLD | NEW |