| 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/boot_times_recorder.h" | 5 #include "chrome/browser/chromeos/boot_times_recorder.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
| 14 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
| 15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
| 19 #include "base/prefs/pref_service.h" | 19 #include "base/prefs/pref_service.h" |
| 20 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
| 23 #include "base/sys_info.h" |
| 23 #include "base/thread_task_runner_handle.h" | 24 #include "base/thread_task_runner_handle.h" |
| 24 #include "base/threading/thread.h" | 25 #include "base/threading/thread.h" |
| 25 #include "base/threading/thread_restrictions.h" | 26 #include "base/threading/thread_restrictions.h" |
| 26 #include "base/time/time.h" | 27 #include "base/time/time.h" |
| 27 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
| 28 #include "chrome/browser/chrome_notification_types.h" | 29 #include "chrome/browser/chrome_notification_types.h" |
| 29 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
| 30 #include "chrome/browser/ui/browser_iterator.h" | 31 #include "chrome/browser/ui/browser_iterator.h" |
| 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 32 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 32 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 74 } |
| 74 } | 75 } |
| 75 } | 76 } |
| 76 return std::string(); | 77 return std::string(); |
| 77 } | 78 } |
| 78 | 79 |
| 79 // Appends the given buffer into the file. Returns the number of bytes | 80 // Appends the given buffer into the file. Returns the number of bytes |
| 80 // written, or -1 on error. | 81 // written, or -1 on error. |
| 81 // TODO(satorux): Move this to file_util. | 82 // TODO(satorux): Move this to file_util. |
| 82 int AppendFile(const base::FilePath& file_path, const char* data, int size) { | 83 int AppendFile(const base::FilePath& file_path, const char* data, int size) { |
| 84 // Appending boot times to symlink in /tmp is a security risk for |
| 85 // developers with chromeos=1 builds. |
| 86 if (!base::SysInfo::IsRunningOnChromeOS() && base::IsLink(file_path)) |
| 87 return -1; |
| 88 |
| 83 FILE* file = base::OpenFile(file_path, "a"); | 89 FILE* file = base::OpenFile(file_path, "a"); |
| 84 if (!file) | 90 if (!file) |
| 85 return -1; | 91 return -1; |
| 86 | 92 |
| 87 const int num_bytes_written = fwrite(data, 1, size, file); | 93 const int num_bytes_written = fwrite(data, 1, size, file); |
| 88 base::CloseFile(file); | 94 base::CloseFile(file); |
| 89 return num_bytes_written; | 95 return num_bytes_written; |
| 90 } | 96 } |
| 91 | 97 |
| 92 } // namespace | 98 } // namespace |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 GetRenderWidgetHost(&web_contents->GetController()); | 522 GetRenderWidgetHost(&web_contents->GetController()); |
| 517 render_widget_hosts_loading_.erase(render_widget_host); | 523 render_widget_hosts_loading_.erase(render_widget_host); |
| 518 break; | 524 break; |
| 519 } | 525 } |
| 520 default: | 526 default: |
| 521 break; | 527 break; |
| 522 } | 528 } |
| 523 } | 529 } |
| 524 | 530 |
| 525 } // namespace chromeos | 531 } // namespace chromeos |
| OLD | NEW |