OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/system/syslogs_provider.h" | 5 #include "chrome/browser/chromeos/system/syslogs_provider.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 // Compress the logs file if requested. | 136 // Compress the logs file if requested. |
137 if (zip_file_name) { | 137 if (zip_file_name) { |
138 cmd = std::string(kBzip2Command) + " -c " + temp_filename.value() + " > " + | 138 cmd = std::string(kBzip2Command) + " -c " + temp_filename.value() + " > " + |
139 zip_file_name->value(); | 139 zip_file_name->value(); |
140 if (::system(cmd.c_str()) == -1) | 140 if (::system(cmd.c_str()) == -1) |
141 LOG(WARNING) << "Command " << cmd << " failed to run"; | 141 LOG(WARNING) << "Command " << cmd << " failed to run"; |
142 } | 142 } |
143 // Read logs from the temp file | 143 // Read logs from the temp file |
144 std::string data; | 144 std::string data; |
145 bool read_success = file_util::ReadFileToString(temp_filename, | 145 bool read_success = base::ReadFileToString(temp_filename, &data); |
146 &data); | |
147 // if we were using an internal temp file, the user does not need the | 146 // if we were using an internal temp file, the user does not need the |
148 // logs to stay past the ReadFile call - delete the file | 147 // logs to stay past the ReadFile call - delete the file |
149 base::DeleteFile(temp_filename, false); | 148 base::DeleteFile(temp_filename, false); |
150 | 149 |
151 if (!read_success) | 150 if (!read_success) |
152 return NULL; | 151 return NULL; |
153 | 152 |
154 // Parse the return data into a dictionary | 153 // Parse the return data into a dictionary |
155 LogDictionaryType* logs = new LogDictionaryType(); | 154 LogDictionaryType* logs = new LogDictionaryType(); |
156 while (data.length() > 0) { | 155 while (data.length() > 0) { |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 // request->ForwardResult(logs, zip_content). | 340 // request->ForwardResult(logs, zip_content). |
342 scoped_refptr<SyslogsMemoryHandler> | 341 scoped_refptr<SyslogsMemoryHandler> |
343 handler(new SyslogsMemoryHandler(callback, logs, zip_content)); | 342 handler(new SyslogsMemoryHandler(callback, logs, zip_content)); |
344 // TODO(jamescook): Maybe we don't need to update histograms here? | 343 // TODO(jamescook): Maybe we don't need to update histograms here? |
345 handler->StartFetch(MemoryDetails::UPDATE_USER_METRICS); | 344 handler->StartFetch(MemoryDetails::UPDATE_USER_METRICS); |
346 } | 345 } |
347 | 346 |
348 void SyslogsProviderImpl::LoadCompressedLogs(const base::FilePath& zip_file, | 347 void SyslogsProviderImpl::LoadCompressedLogs(const base::FilePath& zip_file, |
349 std::string* zip_content) { | 348 std::string* zip_content) { |
350 DCHECK(zip_content); | 349 DCHECK(zip_content); |
351 if (!file_util::ReadFileToString(zip_file, zip_content)) { | 350 if (!base::ReadFileToString(zip_file, zip_content)) { |
352 LOG(ERROR) << "Cannot read compressed logs file from " << | 351 LOG(ERROR) << "Cannot read compressed logs file from " << |
353 zip_file.value().c_str(); | 352 zip_file.value().c_str(); |
354 } | 353 } |
355 } | 354 } |
356 | 355 |
357 const char* SyslogsProviderImpl::GetSyslogsContextString( | 356 const char* SyslogsProviderImpl::GetSyslogsContextString( |
358 SyslogsContext context) { | 357 SyslogsContext context) { |
359 switch (context) { | 358 switch (context) { |
360 case(SYSLOGS_FEEDBACK): | 359 case(SYSLOGS_FEEDBACK): |
361 return kContextFeedback; | 360 return kContextFeedback; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 return Singleton<SyslogsProviderImpl, | 397 return Singleton<SyslogsProviderImpl, |
399 DefaultSingletonTraits<SyslogsProviderImpl> >::get(); | 398 DefaultSingletonTraits<SyslogsProviderImpl> >::get(); |
400 } | 399 } |
401 | 400 |
402 SyslogsProvider* SyslogsProvider::GetInstance() { | 401 SyslogsProvider* SyslogsProvider::GetInstance() { |
403 return SyslogsProviderImpl::GetInstance(); | 402 return SyslogsProviderImpl::GetInstance(); |
404 } | 403 } |
405 | 404 |
406 } // namespace system | 405 } // namespace system |
407 } // namespace chromeos | 406 } // namespace chromeos |
OLD | NEW |