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

Side by Side Diff: content/renderer/media/render_media_log.cc

Issue 2660003003: Add MediaError.message (Closed)
Patch Set: Update message format to be code: detail Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « content/renderer/media/render_media_log.h ('k') | content/renderer/media/webmediaplayer_ms.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/renderer/media/render_media_log.h" 5 #include "content/renderer/media/render_media_log.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // SendQueuedMediaEvents() will enqueue the most recent event of this 85 // SendQueuedMediaEvents() will enqueue the most recent event of this
86 // kind, if any, prior to sending the event batch. 86 // kind, if any, prior to sending the event batch.
87 break; 87 break;
88 88
89 case media::MediaLogEvent::DURATION_SET: 89 case media::MediaLogEvent::DURATION_SET:
90 // Similar to the extents changed message, this may fire many times for 90 // Similar to the extents changed message, this may fire many times for
91 // badly muxed media. Suppress within our rate limits here. 91 // badly muxed media. Suppress within our rate limits here.
92 last_duration_changed_event_.swap(event); 92 last_duration_changed_event_.swap(event);
93 break; 93 break;
94 94
95 // Hold onto the most recent PIPELINE_ERROR and MEDIA_LOG_ERROR_ENTRY for 95 // Hold onto the most recent PIPELINE_ERROR and the first, if any,
DaleCurtis 2017/04/20 20:57:13 I thought we wanted the earliest one ?
wolenetz 2017/04/20 21:09:03 Interesting. I hadn't considered that we might rep
wolenetz 2017/04/20 21:23:40 I dug a little further: it looks like we only repo
96 // use in GetLastErrorMessage(). 96 // MEDIA_LOG_ERROR_ENTRY for use in GetErrorMessage().
97 case media::MediaLogEvent::PIPELINE_ERROR: 97 case media::MediaLogEvent::PIPELINE_ERROR:
98 queued_media_events_.push_back(*event); 98 queued_media_events_.push_back(*event);
99 last_pipeline_error_.swap(event); 99 last_pipeline_error_.swap(event);
100 break; 100 break;
101 case media::MediaLogEvent::MEDIA_ERROR_LOG_ENTRY: 101 case media::MediaLogEvent::MEDIA_ERROR_LOG_ENTRY:
102 queued_media_events_.push_back(*event); 102 queued_media_events_.push_back(*event);
103 last_media_error_log_entry_.swap(event); 103 if (!cached_media_error_for_message_)
104 cached_media_error_for_message_ = std::move(event);
104 break; 105 break;
105 106
106 // Just enqueue all other event types for throttled transmission. 107 // Just enqueue all other event types for throttled transmission.
107 default: 108 default:
108 queued_media_events_.push_back(*event); 109 queued_media_events_.push_back(*event);
109 } 110 }
110 111
111 if (ipc_send_pending_) 112 if (ipc_send_pending_)
112 return; 113 return;
113 114
(...skipping 13 matching lines...) Expand all
127 // It's been more than a second so send ASAP. 128 // It's been more than a second so send ASAP.
128 if (task_runner_->BelongsToCurrentThread()) { 129 if (task_runner_->BelongsToCurrentThread()) {
129 SendQueuedMediaEvents(); 130 SendQueuedMediaEvents();
130 return; 131 return;
131 } 132 }
132 task_runner_->PostTask( 133 task_runner_->PostTask(
133 FROM_HERE, 134 FROM_HERE,
134 base::Bind(&RenderMediaLog::SendQueuedMediaEvents, weak_this_)); 135 base::Bind(&RenderMediaLog::SendQueuedMediaEvents, weak_this_));
135 } 136 }
136 137
137 std::string RenderMediaLog::GetLastErrorMessage() { 138 std::string RenderMediaLog::GetErrorMessage() {
138 base::AutoLock auto_lock(lock_); 139 base::AutoLock auto_lock(lock_);
139 140
140 // Return the conditional concatenation of the last pipeline error and the 141 // Keep message structure in sync with
141 // last media error log. 142 // HTMLMediaElement::BuildElementErrorMessage().
142 std::stringstream result; 143
144 std::string result = "";
DaleCurtis 2017/04/20 20:57:13 Why did you drop the std::stringstream? Generally
wolenetz 2017/04/20 21:09:03 Before a MediaError is constructed by the HTMLMedi
wolenetz 2017/04/20 21:58:08 w.r.t. my not using std::stringstream here: Oops!
wolenetz 2017/04/20 22:13:38 In patch set 10, I've added a comment to media_log
143 if (last_pipeline_error_) { 145 if (last_pipeline_error_) {
144 result << MediaEventToLogString(*last_pipeline_error_) 146 result += MediaEventToMessageString(*last_pipeline_error_);
145 << (last_media_error_log_entry_ ? ", " : "");
146 } 147 }
147 if (last_media_error_log_entry_) 148
148 result << MediaEventToLogString(*last_media_error_log_entry_); 149 if (cached_media_error_for_message_) {
149 return result.str(); 150 DCHECK(last_pipeline_error_)
151 << "Message with detail should be associated with a pipeline error";
152 // This ':' lets web apps extract the UA-specific-error-code from the
153 // MediaError.message prefix.
154 result += ": ";
155 result += MediaEventToMessageString(*cached_media_error_for_message_);
156 }
157
158 return result;
150 } 159 }
151 160
152 void RenderMediaLog::RecordRapporWithSecurityOrigin(const std::string& metric) { 161 void RenderMediaLog::RecordRapporWithSecurityOrigin(const std::string& metric) {
153 if (!task_runner_->BelongsToCurrentThread()) { 162 if (!task_runner_->BelongsToCurrentThread()) {
154 task_runner_->PostTask( 163 task_runner_->PostTask(
155 FROM_HERE, base::Bind(&RenderMediaLog::RecordRapporWithSecurityOrigin, 164 FROM_HERE, base::Bind(&RenderMediaLog::RecordRapporWithSecurityOrigin,
156 weak_this_, metric)); 165 weak_this_, metric));
157 return; 166 return;
158 } 167 }
159 168
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 tick_clock_.swap(tick_clock); 205 tick_clock_.swap(tick_clock);
197 last_ipc_send_time_ = tick_clock_->NowTicks(); 206 last_ipc_send_time_ = tick_clock_->NowTicks();
198 } 207 }
199 208
200 void RenderMediaLog::SetTaskRunnerForTesting( 209 void RenderMediaLog::SetTaskRunnerForTesting(
201 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { 210 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
202 task_runner_ = task_runner; 211 task_runner_ = task_runner;
203 } 212 }
204 213
205 } // namespace content 214 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/render_media_log.h ('k') | content/renderer/media/webmediaplayer_ms.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698