summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/system_logs/device_event_log_source.cc
blob: 30e57a2c6aeb9d15e6aa2622e50f57de1c3e1dcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2014 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.

#include "chrome/browser/chromeos/system_logs/device_event_log_source.h"

#include "base/message_loop/message_loop.h"
#include "components/device_event_log/device_event_log.h"
#include "content/public/browser/browser_thread.h"

namespace system_logs {

const char kNetworkEventLogEntry[] = "network_event_log";
const char kDeviceEventLogEntry[] = "device_event_log";

DeviceEventLogSource::DeviceEventLogSource() : SystemLogsSource("DeviceEvent") {
}

DeviceEventLogSource::~DeviceEventLogSource() {
}

void DeviceEventLogSource::Fetch(const SysLogsSourceCallback& callback) {
  DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
  DCHECK(!callback.is_null());

  scoped_ptr<SystemLogsResponse> response(new SystemLogsResponse);
  const int kMaxDeviceEventsForAboutSystem = 400;
  (*response)[kNetworkEventLogEntry] = device_event_log::GetAsString(
      device_event_log::OLDEST_FIRST, "time,file,level", "network",
      device_event_log::kDefaultLogLevel, kMaxDeviceEventsForAboutSystem);
  (*response)[kDeviceEventLogEntry] = device_event_log::GetAsString(
      device_event_log::OLDEST_FIRST, "time,file,type,level", "non-network",
      device_event_log::LOG_LEVEL_DEBUG, kMaxDeviceEventsForAboutSystem);
  callback.Run(response.get());
}

}  // namespace system_logs