| 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/performance_monitor/performance_monitor_util.h" | 5 #include "chrome/browser/performance_monitor/performance_monitor_util.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 const tracked_objects::Location& from_here, | 57 const tracked_objects::Location& from_here, |
| 58 const base::Closure& request, | 58 const base::Closure& request, |
| 59 const base::Closure& reply) { | 59 const base::Closure& reply) { |
| 60 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); | 60 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); |
| 61 base::SequencedWorkerPool::SequenceToken token = | 61 base::SequencedWorkerPool::SequenceToken token = |
| 62 pool->GetNamedSequenceToken(Database::kDatabaseSequenceToken); | 62 pool->GetNamedSequenceToken(Database::kDatabaseSequenceToken); |
| 63 return pool->GetSequencedTaskRunner(token)->PostTaskAndReply( | 63 return pool->GetSequencedTaskRunner(token)->PostTaskAndReply( |
| 64 from_here, request, reply); | 64 from_here, request, reply); |
| 65 } | 65 } |
| 66 | 66 |
| 67 scoped_ptr<Event> CreateExtensionInstallEvent(const base::Time& time, | 67 scoped_ptr<Event> CreateExtensionEvent(const EventType type, |
| 68 const std::string& id, | 68 const base::Time& time, |
| 69 const std::string& name, | 69 const std::string& id, |
| 70 const std::string& url, | 70 const std::string& name, |
| 71 const int& location, | 71 const std::string& url, |
| 72 const std::string& version, | 72 const int location, |
| 73 const std::string& description) { | 73 const std::string& version, |
| 74 events::ExtensionInstall event; | 74 const std::string& description) { |
| 75 event.event_type = EVENT_EXTENSION_INSTALL; | 75 events::ExtensionEvent event; |
| 76 event.event_type = type; |
| 76 event.time = static_cast<double>(time.ToInternalValue()); | 77 event.time = static_cast<double>(time.ToInternalValue()); |
| 77 event.extension_id = id; | 78 event.extension_id = id; |
| 78 event.extension_name = name; | 79 event.extension_name = name; |
| 79 event.extension_url = url; | |
| 80 event.extension_location = location; | |
| 81 event.extension_version = version; | |
| 82 event.extension_description = description; | |
| 83 scoped_ptr<base::DictionaryValue> value = event.ToValue(); | |
| 84 return scoped_ptr<Event>(new Event( | |
| 85 EVENT_EXTENSION_INSTALL, time, value.Pass())); | |
| 86 } | |
| 87 | |
| 88 scoped_ptr<Event> CreateExtensionUninstallEvent( | |
| 89 const base::Time& time, | |
| 90 const std::string& id, | |
| 91 const std::string& name, | |
| 92 const std::string& url, | |
| 93 const int& location, | |
| 94 const std::string& version, | |
| 95 const std::string& description) { | |
| 96 events::ExtensionUninstall event; | |
| 97 event.event_type = EVENT_EXTENSION_UNINSTALL; | |
| 98 event.time = static_cast<double>(time.ToInternalValue()); | |
| 99 event.extension_id = id; | |
| 100 event.extension_name = name; | |
| 101 event.extension_url = url; | |
| 102 event.extension_location = location; | |
| 103 event.extension_version = version; | |
| 104 event.extension_description = description; | |
| 105 scoped_ptr<base::DictionaryValue> value = event.ToValue(); | |
| 106 return scoped_ptr<Event>(new Event( | |
| 107 EVENT_EXTENSION_UNINSTALL, time, value.Pass())); | |
| 108 } | |
| 109 | |
| 110 scoped_ptr<Event> CreateExtensionUnloadEvent( | |
| 111 const base::Time& time, | |
| 112 const std::string& id, | |
| 113 const std::string& name, | |
| 114 const std::string& url, | |
| 115 const int& location, | |
| 116 const std::string& version, | |
| 117 const std::string& description, | |
| 118 const extension_misc::UnloadedExtensionReason& reason) { | |
| 119 events::ExtensionUnload event; | |
| 120 event.event_type = EVENT_EXTENSION_UNLOAD; | |
| 121 event.time = static_cast<double>(time.ToInternalValue()); | |
| 122 event.extension_id = id; | |
| 123 event.extension_name = name; | |
| 124 event.extension_url = url; | |
| 125 event.extension_location = location; | |
| 126 event.extension_version = version; | |
| 127 event.extension_description = description; | |
| 128 event.unload_reason = reason; | |
| 129 scoped_ptr<base::DictionaryValue> value = event.ToValue(); | |
| 130 return scoped_ptr<Event>(new Event( | |
| 131 EVENT_EXTENSION_UNLOAD, time, value.Pass())); | |
| 132 } | |
| 133 | |
| 134 scoped_ptr<Event> CreateExtensionEnableEvent( | |
| 135 const base::Time& time, | |
| 136 const std::string& id, | |
| 137 const std::string& name, | |
| 138 const std::string& url, | |
| 139 const int& location, | |
| 140 const std::string& version, | |
| 141 const std::string& description) { | |
| 142 events::ExtensionEnable event; | |
| 143 event.event_type = EVENT_EXTENSION_ENABLE; | |
| 144 event.time = static_cast<double>(time.ToInternalValue()); | |
| 145 event.extension_id = id; | |
| 146 event.extension_name = name; | |
| 147 event.extension_url = url; | |
| 148 event.extension_location = location; | |
| 149 event.extension_version = version; | |
| 150 event.extension_description = description; | |
| 151 scoped_ptr<base::DictionaryValue> value = event.ToValue(); | |
| 152 return scoped_ptr<Event>(new Event( | |
| 153 EVENT_EXTENSION_ENABLE, time, value.Pass())); | |
| 154 } | |
| 155 | |
| 156 scoped_ptr<Event> CreateExtensionUpdateEvent(const base::Time& time, | |
| 157 const std::string& id, | |
| 158 const std::string& name, | |
| 159 const std::string& url, | |
| 160 const int& location, | |
| 161 const std::string& version, | |
| 162 const std::string& description) { | |
| 163 events::ExtensionUpdate event; | |
| 164 event.event_type = EVENT_EXTENSION_UPDATE; | |
| 165 event.time = static_cast<double>(time.ToInternalValue()); | |
| 166 event.extension_id = id; | |
| 167 event.extension_name = name; | |
| 168 event.extension_url = url; | 80 event.extension_url = url; |
| 169 event.extension_location = location; | 81 event.extension_location = location; |
| 170 event.extension_version = version; | 82 event.extension_version = version; |
| 171 event.extension_description = description; | 83 event.extension_description = description; |
| 172 scoped_ptr<base::DictionaryValue> value = event.ToValue(); | 84 scoped_ptr<base::DictionaryValue> value = event.ToValue(); |
| 173 return scoped_ptr<Event>(new Event( | 85 return scoped_ptr<Event>(new Event( |
| 174 EVENT_EXTENSION_UPDATE, time, value.Pass())); | 86 type, time, value.Pass())); |
| 175 } | 87 } |
| 176 | 88 |
| 177 scoped_ptr<Event> CreateRendererFreezeEvent(const base::Time& time, | 89 scoped_ptr<Event> CreateRendererFreezeEvent(const base::Time& time, |
| 178 const std::string& url) { | 90 const std::string& url) { |
| 179 events::RendererFreeze event; | 91 events::RendererFreeze event; |
| 180 event.event_type = EVENT_RENDERER_FREEZE; | 92 event.event_type = EVENT_RENDERER_FREEZE; |
| 181 event.time = static_cast<double>(time.ToInternalValue()); | 93 event.time = static_cast<double>(time.ToInternalValue()); |
| 182 event.url = url; | 94 event.url = url; |
| 183 scoped_ptr<base::DictionaryValue> value = event.ToValue(); | 95 scoped_ptr<base::DictionaryValue> value = event.ToValue(); |
| 184 return scoped_ptr<Event>(new Event( | 96 return scoped_ptr<Event>(new Event( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 213 event.time = static_cast<double>(time.ToInternalValue()); | 125 event.time = static_cast<double>(time.ToInternalValue()); |
| 214 event.previous_version = previous_version; | 126 event.previous_version = previous_version; |
| 215 event.current_version = current_version; | 127 event.current_version = current_version; |
| 216 scoped_ptr<base::DictionaryValue> value = event.ToValue(); | 128 scoped_ptr<base::DictionaryValue> value = event.ToValue(); |
| 217 return scoped_ptr<Event>(new Event( | 129 return scoped_ptr<Event>(new Event( |
| 218 EVENT_CHROME_UPDATE, time, value.Pass())); | 130 EVENT_CHROME_UPDATE, time, value.Pass())); |
| 219 } | 131 } |
| 220 | 132 |
| 221 } // namespace util | 133 } // namespace util |
| 222 } // namespace performance_monitor | 134 } // namespace performance_monitor |
| OLD | NEW |