Chromium Code Reviews| Index: components/browser_watcher/fetch_system_session_events_main_win.cc |
| diff --git a/components/browser_watcher/fetch_system_session_events_main_win.cc b/components/browser_watcher/fetch_system_session_events_main_win.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d52f6b3a41961982cb69901eadb37cf06f9cb51e |
| --- /dev/null |
| +++ b/components/browser_watcher/fetch_system_session_events_main_win.cc |
| @@ -0,0 +1,37 @@ |
| +// Copyright 2017 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. |
| + |
| +// A utility for testing locally the retrieval of system session events. |
| + |
| +#include <iostream> |
| + |
| +#include "base/logging.h" |
| +#include "base/strings/stringprintf.h" |
| +#include "base/time/time.h" |
| +#include "components/browser_watcher/system_session_analyzer_win.h" |
| + |
| +using browser_watcher::SystemSessionEventFetcher; |
|
Sigurður Ásgeirsson
2017/03/07 14:38:39
ubernit: put this in the sole scope where it's use
manzagop (departed)
2017/03/07 15:49:02
Actually this doesn't exist anymore. Changed a few
|
| + |
| +int main(int argc, char** argv) { |
| + // Retrieve events for the last 5 sessions. |
| + SystemSessionEventFetcher fetcher(5U); |
| + std::vector<SystemSessionEventFetcher::EventInfo> events; |
| + if (!fetcher.FetchEvents(&events)) { |
| + std::cerr << "Failed to fetch events." << std::endl; |
| + return 1; |
| + } |
| + |
| + // Print the event ids and times. |
| + for (const SystemSessionEventFetcher::EventInfo& event : events) { |
| + base::Time::Exploded exploded = {}; |
| + event.event_time.LocalExplode(&exploded); |
| + std::string time = base::StringPrintf( |
| + "%d/%d/%d %d:%02d:%02d", exploded.month, exploded.day_of_month, |
| + exploded.year, exploded.hour, exploded.minute, exploded.second); |
| + std::cout << "Event: " << event.event_id << " (" << time << ")" |
| + << std::endl; |
| + } |
| + |
| + return 0; |
| +} |