| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/translate/core/common/translation_logging_helper.h" | 5 #include "components/translate/core/common/translation_logging_helper.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "components/metrics/proto/translate_event.pb.h" | 9 #include "components/metrics/proto/translate_event.pb.h" |
| 10 #include "components/sync/protocol/user_event_specifics.pb.h" | 10 #include "components/sync/protocol/user_event_specifics.pb.h" |
| 11 | 11 |
| 12 namespace translate { | 12 namespace translate { |
| 13 namespace { | 13 namespace { |
| 14 using metrics::TranslateEventProto; | 14 using metrics::TranslateEventProto; |
| 15 } // namespace | 15 } // namespace |
| 16 | 16 |
| 17 bool ConstructTranslateEvent(const int64_t navigation_id, | 17 bool ConstructTranslateEvent(const int64_t navigation_id, |
| 18 const TranslateEventProto& translate_event, | 18 const TranslateEventProto& translate_event, |
| 19 sync_pb::UserEventSpecifics* const specifics) { | 19 sync_pb::UserEventSpecifics* const specifics) { |
| 20 specifics->set_event_time_usec(base::Time::Now().ToInternalValue()); | 20 specifics->set_event_time_usec(base::Time::Now().ToInternalValue()); |
| 21 | 21 |
| 22 // TODO(renjieliu): Revisit this field when the best way to identify | 22 // TODO(renjieliu): Revisit this field when the best way to identify |
| 23 // navigations is determined. | 23 // navigations is determined. |
| 24 specifics->set_navigation_id(navigation_id); | 24 specifics->set_navigation_id(navigation_id); |
| 25 auto* const translation = specifics->mutable_translation(); | 25 auto* const translation = specifics->mutable_translation_event(); |
| 26 translation->set_from_language_code(translate_event.source_language()); | 26 translation->set_from_language_code(translate_event.source_language()); |
| 27 translation->set_to_language_code(translate_event.target_language()); | 27 translation->set_to_language_code(translate_event.target_language()); |
| 28 switch (translate_event.event_type()) { | 28 switch (translate_event.event_type()) { |
| 29 case TranslateEventProto::UNKNOWN: | 29 case TranslateEventProto::UNKNOWN: |
| 30 translation->set_interaction(sync_pb::Translation::UNKNOWN); | 30 translation->set_interaction(sync_pb::Translation::UNKNOWN); |
| 31 break; | 31 break; |
| 32 case TranslateEventProto::USER_ACCEPT: | 32 case TranslateEventProto::USER_ACCEPT: |
| 33 if (translate_event.has_modified_source_language() || | 33 if (translate_event.has_modified_source_language() || |
| 34 translate_event.has_modified_target_language()) { | 34 translate_event.has_modified_target_language()) { |
| 35 // Special case, since we don't have event enum telling us it's actually | 35 // Special case, since we don't have event enum telling us it's actually |
| (...skipping 30 matching lines...) Expand all Loading... |
| 66 break; | 66 break; |
| 67 case TranslateEventProto::AUTO_TRANSLATION_BY_LINK: | 67 case TranslateEventProto::AUTO_TRANSLATION_BY_LINK: |
| 68 translation->set_interaction( | 68 translation->set_interaction( |
| 69 sync_pb::Translation::AUTO_TRANSLATION_BY_LINK); | 69 sync_pb::Translation::AUTO_TRANSLATION_BY_LINK); |
| 70 break; | 70 break; |
| 71 default: // We don't care about other events. | 71 default: // We don't care about other events. |
| 72 return false; | 72 return false; |
| 73 } | 73 } |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 } // namespace translate | 76 } // namespace translate |
| OLD | NEW |