| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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 // A utility for testing locally the retrieval of system session events. |
| 6 |
| 7 #include <iostream> |
| 8 |
| 9 #include "base/logging.h" |
| 10 #include "base/strings/stringprintf.h" |
| 11 #include "base/time/time.h" |
| 12 #include "components/browser_watcher/system_session_analyzer_win.h" |
| 13 |
| 14 using browser_watcher::SystemSessionEventFetcher; |
| 15 |
| 16 int main(int argc, char** argv) { |
| 17 // Retrieve events for the last 5 sessions. |
| 18 SystemSessionEventFetcher fetcher(5U); |
| 19 std::vector<SystemSessionEventFetcher::EventInfo> events; |
| 20 if (!fetcher.FetchEvents(&events)) { |
| 21 std::cerr << "Failed to fetch events." << std::endl; |
| 22 return 1; |
| 23 } |
| 24 |
| 25 // Print the event ids and times. |
| 26 for (const SystemSessionEventFetcher::EventInfo& event : events) { |
| 27 base::Time::Exploded exploded = {}; |
| 28 event.event_time.LocalExplode(&exploded); |
| 29 std::string time = base::StringPrintf( |
| 30 "%d/%d/%d %d:%02d:%02d", exploded.month, exploded.day_of_month, |
| 31 exploded.year, exploded.hour, exploded.minute, exploded.second); |
| 32 std::cout << "Event: " << event.event_id << " (" << time << ")" |
| 33 << std::endl; |
| 34 } |
| 35 |
| 36 return 0; |
| 37 } |
| OLD | NEW |