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

Side by Side Diff: media/blink/webmediaplayer_impl.h

Issue 2568303002: Report WMPI components memory usage to UMA (Closed)
Patch Set: Call ReportMemoryUsage from WMPI::OnMemoryPressure Created 4 years 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 | « no previous file | media/blink/webmediaplayer_impl.cc » ('j') | media/blink/webmediaplayer_impl.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 5 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
6 #define MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 6 #define MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/cancelable_callback.h" 14 #include "base/cancelable_callback.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/linked_ptr.h" 17 #include "base/memory/linked_ptr.h"
18 #include "base/memory/memory_pressure_listener.h"
18 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
19 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
21 #include "base/optional.h"
20 #include "base/threading/thread.h" 22 #include "base/threading/thread.h"
21 #include "base/time/default_tick_clock.h" 23 #include "base/time/default_tick_clock.h"
22 #include "base/timer/elapsed_timer.h" 24 #include "base/timer/elapsed_timer.h"
23 #include "base/timer/timer.h" 25 #include "base/timer/timer.h"
24 #include "build/build_config.h" 26 #include "build/build_config.h"
25 #include "media/base/media_observer.h" 27 #include "media/base/media_observer.h"
26 #include "media/base/media_tracks.h" 28 #include "media/base/media_tracks.h"
27 #include "media/base/pipeline_impl.h" 29 #include "media/base/pipeline_impl.h"
28 #include "media/base/renderer_factory.h" 30 #include "media/base/renderer_factory.h"
29 #include "media/base/surface_manager.h" 31 #include "media/base/surface_manager.h"
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 bool is_streaming, 340 bool is_streaming,
339 bool is_suspended, 341 bool is_suspended,
340 bool is_backgrounded); 342 bool is_backgrounded);
341 void SetDelegateState(DelegateState new_state); 343 void SetDelegateState(DelegateState new_state);
342 void SetMemoryReportingState(bool is_memory_reporting_enabled); 344 void SetMemoryReportingState(bool is_memory_reporting_enabled);
343 void SetSuspendState(bool is_suspended); 345 void SetSuspendState(bool is_suspended);
344 346
345 // Called at low frequency to tell external observers how much memory we're 347 // Called at low frequency to tell external observers how much memory we're
346 // using for video playback. Called by |memory_usage_reporting_timer_|. 348 // using for video playback. Called by |memory_usage_reporting_timer_|.
347 // Memory usage reporting is done in two steps, because |demuxer_| must be 349 // Memory usage reporting is done in two steps, because |demuxer_| must be
348 // accessed on the media thread. 350 // accessed on the media thread. Also called when we get notified about memory
watk 2016/12/13 23:34:31 nit: merge the "Also called when" sentence with th
servolk 2016/12/14 00:07:23 Done.
349 void ReportMemoryUsage(); 351 // pressure level changes.
350 void FinishMemoryUsageReport(int64_t demuxer_memory_usage); 352 void ReportMemoryUsageOnTimer();
353 using MaybeMemPressureLvl =
watk 2016/12/13 23:34:31 nit: It's probably more obvious if you call this O
servolk 2016/12/14 00:07:23 Done.
354 base::Optional<base::MemoryPressureListener::MemoryPressureLevel>;
355 void ReportMemoryUsage(MaybeMemPressureLvl maybe_mem_pressure_lvl);
356 void FinishMemoryUsageReport(MaybeMemPressureLvl maybe_mem_pressure_lvl,
357 int64_t demuxer_memory_usage);
watk 2016/12/13 23:34:31 nit: This is minor but I'd s/lvl/level and s/mem/m
servolk 2016/12/14 00:07:23 Done.
351 358
352 // Called during OnHidden() when we want a suspended player to enter the 359 // Called during OnHidden() when we want a suspended player to enter the
353 // paused state after some idle timeout. 360 // paused state after some idle timeout.
354 void ScheduleIdlePauseTimer(); 361 void ScheduleIdlePauseTimer();
355 362
356 void CreateWatchTimeReporter(); 363 void CreateWatchTimeReporter();
357 364
358 // Returns true if the player is hidden. 365 // Returns true if the player is hidden.
359 bool IsHidden() const; 366 bool IsHidden() const;
360 367
368 void OnMemoryPressure(base::MemoryPressureListener::MemoryPressureLevel lvl);
369
361 blink::WebLocalFrame* frame_; 370 blink::WebLocalFrame* frame_;
362 371
363 // The playback state last reported to |delegate_|, to avoid setting duplicate 372 // The playback state last reported to |delegate_|, to avoid setting duplicate
364 // states. (Which can have undesired effects like resetting the idle timer.) 373 // states. (Which can have undesired effects like resetting the idle timer.)
365 DelegateState delegate_state_; 374 DelegateState delegate_state_;
366 375
367 // Set when OnSuspendRequested() is called with |must_suspend| unset. 376 // Set when OnSuspendRequested() is called with |must_suspend| unset.
368 bool is_idle_; 377 bool is_idle_;
369 378
370 // Set when OnSuspendRequested() is called with |must_suspend| set. 379 // Set when OnSuspendRequested() is called with |must_suspend| set.
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 base::TimeTicks last_time_loading_progressed_; 581 base::TimeTicks last_time_loading_progressed_;
573 582
574 std::unique_ptr<base::TickClock> tick_clock_; 583 std::unique_ptr<base::TickClock> tick_clock_;
575 584
576 // Monitors the player events. 585 // Monitors the player events.
577 base::WeakPtr<MediaObserver> observer_; 586 base::WeakPtr<MediaObserver> observer_;
578 587
579 // Whether the player is currently in autoplay muted state. 588 // Whether the player is currently in autoplay muted state.
580 bool autoplay_muted_ = false; 589 bool autoplay_muted_ = false;
581 590
591 std::unique_ptr<base::MemoryPressureListener> mem_pressure_listener_;
592
582 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); 593 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
583 }; 594 };
584 595
585 } // namespace media 596 } // namespace media
586 597
587 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 598 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | media/blink/webmediaplayer_impl.cc » ('j') | media/blink/webmediaplayer_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698