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

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

Issue 2687583002: Add support for single sample metrics. (Closed)
Patch Set: Use thread local storage. 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
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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/single_value_histograms.h"
12 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
14 #include "base/time/default_tick_clock.h" 15 #include "base/time/default_tick_clock.h"
15 #include "content/common/view_messages.h" 16 #include "content/common/view_messages.h"
16 #include "content/public/common/content_client.h" 17 #include "content/public/common/content_client.h"
18 #include "content/public/common/service_names.mojom.h"
17 #include "content/public/renderer/content_renderer_client.h" 19 #include "content/public/renderer/content_renderer_client.h"
18 #include "content/public/renderer/render_thread.h" 20 #include "content/public/renderer/render_thread.h"
19 21
20 #ifndef MEDIA_EVENT_LOG_UTILITY 22 #ifndef MEDIA_EVENT_LOG_UTILITY
21 #define MEDIA_EVENT_LOG_UTILITY DVLOG(1) 23 #define MEDIA_EVENT_LOG_UTILITY DVLOG(1)
22 #endif 24 #endif
23 25
24 namespace { 26 namespace {
25 27
26 // Print an event to the chromium log. 28 // Print an event to the chromium log.
(...skipping 17 matching lines...) Expand all
44 46
45 RenderMediaLog::RenderMediaLog(const GURL& security_origin) 47 RenderMediaLog::RenderMediaLog(const GURL& security_origin)
46 : security_origin_(security_origin), 48 : security_origin_(security_origin),
47 task_runner_(base::ThreadTaskRunnerHandle::Get()), 49 task_runner_(base::ThreadTaskRunnerHandle::Get()),
48 tick_clock_(new base::DefaultTickClock()), 50 tick_clock_(new base::DefaultTickClock()),
49 last_ipc_send_time_(tick_clock_->NowTicks()), 51 last_ipc_send_time_(tick_clock_->NowTicks()),
50 ipc_send_pending_(false), 52 ipc_send_pending_(false),
51 weak_factory_(this) { 53 weak_factory_(this) {
52 DCHECK(RenderThread::Get()) 54 DCHECK(RenderThread::Get())
53 << "RenderMediaLog must be constructed on the render thread"; 55 << "RenderMediaLog must be constructed on the render thread";
56
57 std::unique_ptr<base::SingleValueCountsHistogram> metric_1(
58 base::SingleValueHistogramsFactory::Get()
59 ->CreateSingleValueCountsHistogram(
60 "Media.VideoRenderer.CadenceChanges", 1, 10, 10));
61 metric_1->SetSample(3);
62 metric_1->SetSample(2);
63
64 std::unique_ptr<base::SingleValueCountsHistogram> metric_2(
65 base::SingleValueHistogramsFactory::Get()
66 ->CreateSingleValueCountsHistogram(
67 "Media.VideoRenderer.CadenceChanges", 1, 10, 10));
68 metric_2->SetSample(5);
69 metric_2->SetSample(8);
70
54 // Pre-bind the WeakPtr on the right thread since we'll receive calls from 71 // Pre-bind the WeakPtr on the right thread since we'll receive calls from
55 // other threads and don't want races. 72 // other threads and don't want races.
56 weak_this_ = weak_factory_.GetWeakPtr(); 73 weak_this_ = weak_factory_.GetWeakPtr();
57 } 74 }
58 75
59 RenderMediaLog::~RenderMediaLog() { 76 RenderMediaLog::~RenderMediaLog() {
60 DCHECK(task_runner_->BelongsToCurrentThread()); 77 DCHECK(task_runner_->BelongsToCurrentThread());
61 78
62 // There's no further chance to handle this, so send them now. This should not 79 // There's no further chance to handle this, so send them now. This should not
63 // be racy since nothing should have a pointer to the media log on another 80 // be racy since nothing should have a pointer to the media log on another
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 tick_clock_.swap(tick_clock); 221 tick_clock_.swap(tick_clock);
205 last_ipc_send_time_ = tick_clock_->NowTicks(); 222 last_ipc_send_time_ = tick_clock_->NowTicks();
206 } 223 }
207 224
208 void RenderMediaLog::SetTaskRunnerForTesting( 225 void RenderMediaLog::SetTaskRunnerForTesting(
209 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { 226 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
210 task_runner_ = task_runner; 227 task_runner_ = task_runner;
211 } 228 }
212 229
213 } // namespace content 230 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698