OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/automation/automation_provider_observers.h" | 5 #include "chrome/browser/automation/automation_provider_observers.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 break; | 966 break; |
967 } | 967 } |
968 } | 968 } |
969 } | 969 } |
970 | 970 |
971 MetricEventDurationObserver::MetricEventDurationObserver() { | 971 MetricEventDurationObserver::MetricEventDurationObserver() { |
972 registrar_.Add(this, NotificationType::METRIC_EVENT_DURATION, | 972 registrar_.Add(this, NotificationType::METRIC_EVENT_DURATION, |
973 NotificationService::AllSources()); | 973 NotificationService::AllSources()); |
974 } | 974 } |
975 | 975 |
| 976 MetricEventDurationObserver::~MetricEventDurationObserver() {} |
| 977 |
976 int MetricEventDurationObserver::GetEventDurationMs( | 978 int MetricEventDurationObserver::GetEventDurationMs( |
977 const std::string& event_name) { | 979 const std::string& event_name) { |
978 EventDurationMap::const_iterator it = durations_.find(event_name); | 980 EventDurationMap::const_iterator it = durations_.find(event_name); |
979 if (it == durations_.end()) | 981 if (it == durations_.end()) |
980 return -1; | 982 return -1; |
981 return it->second; | 983 return it->second; |
982 } | 984 } |
983 | 985 |
984 void MetricEventDurationObserver::Observe(NotificationType type, | 986 void MetricEventDurationObserver::Observe(NotificationType type, |
985 const NotificationSource& source, const NotificationDetails& details) { | 987 const NotificationSource& source, const NotificationDetails& details) { |
986 if (type != NotificationType::METRIC_EVENT_DURATION) { | 988 if (type != NotificationType::METRIC_EVENT_DURATION) { |
987 NOTREACHED(); | 989 NOTREACHED(); |
988 return; | 990 return; |
989 } | 991 } |
990 MetricEventDurationDetails* metric_event_duration = | 992 MetricEventDurationDetails* metric_event_duration = |
991 Details<MetricEventDurationDetails>(details).ptr(); | 993 Details<MetricEventDurationDetails>(details).ptr(); |
992 durations_[metric_event_duration->event_name] = | 994 durations_[metric_event_duration->event_name] = |
993 metric_event_duration->duration_ms; | 995 metric_event_duration->duration_ms; |
994 } | 996 } |
995 | 997 |
996 PageTranslatedObserver::PageTranslatedObserver(AutomationProvider* automation, | 998 PageTranslatedObserver::PageTranslatedObserver(AutomationProvider* automation, |
997 IPC::Message* reply_message, | 999 IPC::Message* reply_message, |
998 TabContents* tab_contents) | 1000 TabContents* tab_contents) |
999 : automation_(automation), | 1001 : automation_(automation), |
1000 reply_message_(reply_message) { | 1002 reply_message_(reply_message) { |
1001 registrar_.Add(this, NotificationType::PAGE_TRANSLATED, | 1003 registrar_.Add(this, NotificationType::PAGE_TRANSLATED, |
1002 Source<TabContents>(tab_contents)); | 1004 Source<TabContents>(tab_contents)); |
1003 } | 1005 } |
1004 | 1006 |
| 1007 PageTranslatedObserver::~PageTranslatedObserver() {} |
| 1008 |
1005 void PageTranslatedObserver::Observe(NotificationType type, | 1009 void PageTranslatedObserver::Observe(NotificationType type, |
1006 const NotificationSource& source, | 1010 const NotificationSource& source, |
1007 const NotificationDetails& details) { | 1011 const NotificationDetails& details) { |
1008 DCHECK(type == NotificationType::PAGE_TRANSLATED); | 1012 DCHECK(type == NotificationType::PAGE_TRANSLATED); |
1009 AutomationJSONReply reply(automation_, reply_message_); | 1013 AutomationJSONReply reply(automation_, reply_message_); |
1010 | 1014 |
1011 PageTranslatedDetails* translated_details = | 1015 PageTranslatedDetails* translated_details = |
1012 Details<PageTranslatedDetails>(details).ptr(); | 1016 Details<PageTranslatedDetails>(details).ptr(); |
1013 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 1017 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
1014 return_value->SetBoolean( | 1018 return_value->SetBoolean( |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 NotificationType type, | 1339 NotificationType type, |
1336 const NotificationSource& source, | 1340 const NotificationSource& source, |
1337 const NotificationDetails& details) { | 1341 const NotificationDetails& details) { |
1338 DCHECK(type == NotificationType::AUTOCOMPLETE_EDIT_FOCUSED); | 1342 DCHECK(type == NotificationType::AUTOCOMPLETE_EDIT_FOCUSED); |
1339 AutomationMsg_WaitForAutocompleteEditFocus::WriteReplyParams( | 1343 AutomationMsg_WaitForAutocompleteEditFocus::WriteReplyParams( |
1340 reply_message_, true); | 1344 reply_message_, true); |
1341 automation_->Send(reply_message_); | 1345 automation_->Send(reply_message_); |
1342 delete this; | 1346 delete this; |
1343 } | 1347 } |
1344 | 1348 |
OLD | NEW |