Chromium Code Reviews| 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 "content/renderer/media/render_media_log.h" | 5 #include "content/renderer/media/render_media_log.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 // Keep track of the latest buffered extents properties to avoid sending | 30 // Keep track of the latest buffered extents properties to avoid sending |
| 31 // thousands of events over IPC. See http://crbug.com/352585 for details. | 31 // thousands of events over IPC. See http://crbug.com/352585 for details. |
| 32 // | 32 // |
| 33 // TODO(scherkus): We should overhaul MediaLog entirely to have clearer | 33 // TODO(scherkus): We should overhaul MediaLog entirely to have clearer |
| 34 // separation of properties vs. events. | 34 // separation of properties vs. events. |
| 35 if (event->type == media::MediaLogEvent::BUFFERED_EXTENTS_CHANGED) | 35 if (event->type == media::MediaLogEvent::BUFFERED_EXTENTS_CHANGED) |
| 36 last_buffered_extents_changed_event_.swap(event); | 36 last_buffered_extents_changed_event_.swap(event); |
| 37 else | 37 else |
| 38 queued_media_events_.push_back(*event); | 38 queued_media_events_.push_back(*event); |
| 39 | 39 |
| 40 if (event->type != media::MediaLogEvent::BUFFERED_EXTENTS_CHANGED && | |
| 41 event->type != media::MediaLogEvent::PROPERTY_CHANGE && | |
| 42 event->type != media::MediaLogEvent::NETWORK_ACTIVITY_SET) { | |
| 43 LOG(ERROR) << "MediaEvent: " | |
|
wolenetz
2015/02/04 22:04:18
I suspect you can get PRESUBMIT to allow LOG(INFO)
| |
| 44 << media::MediaLog::MediaEventToLogString(*event.get()); | |
| 45 } | |
| 46 | |
| 40 // Limit the send rate of high frequency events. | 47 // Limit the send rate of high frequency events. |
| 41 base::TimeTicks curr_time = tick_clock_->NowTicks(); | 48 base::TimeTicks curr_time = tick_clock_->NowTicks(); |
| 42 if ((curr_time - last_ipc_send_time_) < base::TimeDelta::FromSeconds(1)) | 49 if ((curr_time - last_ipc_send_time_) < base::TimeDelta::FromSeconds(1)) |
| 43 return; | 50 return; |
| 44 last_ipc_send_time_ = curr_time; | 51 last_ipc_send_time_ = curr_time; |
| 45 | 52 |
| 46 if (last_buffered_extents_changed_event_) { | 53 if (last_buffered_extents_changed_event_) { |
| 47 queued_media_events_.push_back(*last_buffered_extents_changed_event_); | 54 queued_media_events_.push_back(*last_buffered_extents_changed_event_); |
| 48 last_buffered_extents_changed_event_.reset(); | 55 last_buffered_extents_changed_event_.reset(); |
| 49 } | 56 } |
| 50 | 57 |
| 51 DVLOG(1) << "media log events array size " << queued_media_events_.size(); | 58 DVLOG(1) << "media log events array size " << queued_media_events_.size(); |
| 52 | 59 |
| 53 RenderThread::Get()->Send( | 60 RenderThread::Get()->Send( |
| 54 new ViewHostMsg_MediaLogEvents(queued_media_events_)); | 61 new ViewHostMsg_MediaLogEvents(queued_media_events_)); |
| 55 queued_media_events_.clear(); | 62 queued_media_events_.clear(); |
| 56 } | 63 } |
| 57 | 64 |
| 58 RenderMediaLog::~RenderMediaLog() {} | 65 RenderMediaLog::~RenderMediaLog() {} |
| 59 | 66 |
| 60 void RenderMediaLog::SetTickClockForTesting( | 67 void RenderMediaLog::SetTickClockForTesting( |
| 61 scoped_ptr<base::TickClock> tick_clock) { | 68 scoped_ptr<base::TickClock> tick_clock) { |
| 62 tick_clock_.swap(tick_clock); | 69 tick_clock_.swap(tick_clock); |
| 63 last_ipc_send_time_ = tick_clock_->NowTicks(); | 70 last_ipc_send_time_ = tick_clock_->NowTicks(); |
| 64 } | 71 } |
| 65 | 72 |
| 66 } // namespace content | 73 } // namespace content |
| OLD | NEW |