| 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 namespace { |
| 15 |
| 16 using browser_watcher::SystemSessionAnalyzer; |
| 17 |
| 18 class SystemSessionEventFetcher : public SystemSessionAnalyzer { |
| 19 public: |
| 20 explicit SystemSessionEventFetcher(uint32_t session_cnt) |
| 21 : SystemSessionAnalyzer(session_cnt) {} |
| 22 using SystemSessionAnalyzer::FetchEvents; |
| 23 }; |
| 24 |
| 25 } // namespace |
| 26 |
| 27 int main(int argc, char** argv) { |
| 28 // Retrieve events for the last 5 sessions. |
| 29 SystemSessionEventFetcher fetcher(5U); |
| 30 std::vector<SystemSessionEventFetcher::EventInfo> events; |
| 31 if (!fetcher.FetchEvents(&events)) { |
| 32 std::cerr << "Failed to fetch events." << std::endl; |
| 33 return 1; |
| 34 } |
| 35 |
| 36 // Print the event ids and times. |
| 37 for (const SystemSessionEventFetcher::EventInfo& event : events) { |
| 38 base::Time::Exploded exploded = {}; |
| 39 event.event_time.LocalExplode(&exploded); |
| 40 std::string time = base::StringPrintf( |
| 41 "%d/%d/%d %d:%02d:%02d", exploded.month, exploded.day_of_month, |
| 42 exploded.year, exploded.hour, exploded.minute, exploded.second); |
| 43 std::cout << "Event: " << event.event_id << " (" << time << ")" |
| 44 << std::endl; |
| 45 } |
| 46 |
| 47 return 0; |
| 48 } |
| OLD | NEW |