OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/extensions/api/log_private/log_private_api.h" | 5 #include "chrome/browser/extensions/api/log_private/log_private_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "chrome/browser/chromeos/system_logs/system_logs_fetcher.h" | |
15 #include "chrome/browser/extensions/api/log_private/filter_handler.h" | 14 #include "chrome/browser/extensions/api/log_private/filter_handler.h" |
16 #include "chrome/browser/extensions/api/log_private/log_parser.h" | 15 #include "chrome/browser/extensions/api/log_private/log_parser.h" |
17 #include "chrome/browser/extensions/api/log_private/syslog_parser.h" | 16 #include "chrome/browser/extensions/api/log_private/syslog_parser.h" |
18 #include "chrome/browser/extensions/extension_function.h" | 17 #include "chrome/browser/extensions/extension_function.h" |
19 #include "chrome/common/extensions/api/log_private.h" | 18 #include "chrome/common/extensions/api/log_private.h" |
20 | 19 |
21 namespace extensions { | 20 namespace extensions { |
22 namespace { | 21 namespace { |
23 | 22 |
24 scoped_ptr<LogParser> CreateLogParser(const std::string& log_type) { | 23 scoped_ptr<LogParser> CreateLogParser(const std::string& log_type) { |
(...skipping 30 matching lines...) Expand all Loading... |
55 LogPrivateGetHistoricalFunction::~LogPrivateGetHistoricalFunction() { | 54 LogPrivateGetHistoricalFunction::~LogPrivateGetHistoricalFunction() { |
56 } | 55 } |
57 | 56 |
58 bool LogPrivateGetHistoricalFunction::RunImpl() { | 57 bool LogPrivateGetHistoricalFunction::RunImpl() { |
59 // Get parameters | 58 // Get parameters |
60 scoped_ptr<api::log_private::GetHistorical::Params> params( | 59 scoped_ptr<api::log_private::GetHistorical::Params> params( |
61 api::log_private::GetHistorical::Params::Create(*args_)); | 60 api::log_private::GetHistorical::Params::Create(*args_)); |
62 EXTENSION_FUNCTION_VALIDATE(params.get()); | 61 EXTENSION_FUNCTION_VALIDATE(params.get()); |
63 filter_handler_.reset(new FilterHandler(params->filter)); | 62 filter_handler_.reset(new FilterHandler(params->filter)); |
64 | 63 |
65 chromeos::SystemLogsFetcher* fetcher = new chromeos::SystemLogsFetcher(); | 64 chromeos::AboutSystemLogsFetcher* fetcher = |
| 65 new chromeos::AboutSystemLogsFetcher(); |
66 fetcher->Fetch( | 66 fetcher->Fetch( |
67 base::Bind(&LogPrivateGetHistoricalFunction::OnSystemLogsLoaded, this)); | 67 base::Bind(&LogPrivateGetHistoricalFunction::OnSystemLogsLoaded, this)); |
68 return true; | 68 return true; |
69 } | 69 } |
70 | 70 |
71 void LogPrivateGetHistoricalFunction::OnSystemLogsLoaded( | 71 void LogPrivateGetHistoricalFunction::OnSystemLogsLoaded( |
72 scoped_ptr<chromeos::SystemLogsResponse> sys_info) { | 72 scoped_ptr<chromeos::SystemLogsResponse> sys_info) { |
73 std::vector<linked_ptr<api::log_private::LogEntry> > data; | 73 std::vector<linked_ptr<api::log_private::LogEntry> > data; |
74 | 74 |
75 CollectLogInfo(filter_handler_.get(), sys_info.get(), &data); | 75 CollectLogInfo(filter_handler_.get(), sys_info.get(), &data); |
76 | 76 |
77 // Prepare result | 77 // Prepare result |
78 api::log_private::Result result; | 78 api::log_private::Result result; |
79 result.data = data; | 79 result.data = data; |
80 api::log_private::Filter::Populate( | 80 api::log_private::Filter::Populate( |
81 *((filter_handler_->GetFilter())->ToValue()), &result.filter); | 81 *((filter_handler_->GetFilter())->ToValue()), &result.filter); |
82 SetResult(result.ToValue().release()); | 82 SetResult(result.ToValue().release()); |
83 SendResponse(true); | 83 SendResponse(true); |
84 } | 84 } |
85 | 85 |
86 } // namespace extensions | 86 } // namespace extensions |
OLD | NEW |