Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Unified Diff: extensions/browser/api/cast_channel/logger.cc

Issue 580923002: Ignore uninteresting events when recording the last errors to report (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | extensions/browser/api/cast_channel/logger_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/cast_channel/logger.cc
diff --git a/extensions/browser/api/cast_channel/logger.cc b/extensions/browser/api/cast_channel/logger.cc
index 823b4c320877e84c3141879d8ce81d92e9bb8dd9..b5db982c5fd509be859725b9bb2280bfd8d1c427 100644
--- a/extensions/browser/api/cast_channel/logger.cc
+++ b/extensions/browser/api/cast_channel/logger.cc
@@ -4,6 +4,8 @@
#include "extensions/browser/api/cast_channel/logger.h"
+#include <string>
+
#include "base/strings/string_util.h"
#include "base/time/tick_clock.h"
#include "extensions/browser/api/cast_channel/cast_auth_util.h"
@@ -98,6 +100,21 @@ scoped_ptr<char[]> Compress(const std::string& input, size_t* length) {
return out.Pass();
}
+// Returns true if the event type should be reported to the API as the last
+// socket event before an error occurred. Some events are not interesting and
+// should be ignored.
+bool IsInterestingEventType(EventType type) {
+ switch (type) {
+ case proto::READY_STATE_CHANGED:
+ case proto::ERROR_STATE_CHANGED:
imcheng 2014/09/17 22:34:08 Are other state changes (read/write/connect states
mark a. foltz 2014/10/09 23:51:42 Changed this to just check for errors set as you m
+ case proto::NOTIFY_ON_MESSAGE:
+ case proto::NOTIFY_ON_ERROR:
+ return false;
+ default:
+ return true;
+ }
+}
+
} // namespace
Logger::AggregatedSocketEventLog::AggregatedSocketEventLog() {
@@ -290,8 +307,11 @@ AggregatedSocketEvent& Logger::LogSocketEvent(int channel_id,
socket_events.push_back(socket_event);
- it->second->last_errors.event_type = socket_event.type();
- if (socket_event.has_net_return_value()) {
+ if (IsInterestingEventType(socket_event.type())) {
+ it->second->last_errors.event_type = socket_event.type();
+ }
+ if (socket_event.has_net_return_value() &&
+ socket_event.net_return_value() != net::ERR_IO_PENDING) {
it->second->last_errors.net_return_value = socket_event.net_return_value();
}
if (socket_event.has_challenge_reply_error_type()) {
@@ -356,5 +376,5 @@ LastErrors Logger::GetLastErrors(int channel_id) const {
}
} // namespace cast_channel
-} // namespace api
+} // namespace core_api
} // namespace extensions
« no previous file with comments | « no previous file | extensions/browser/api/cast_channel/logger_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698