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

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

Issue 1676703002: Stop using macros to paste together names for static_asserts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: static-asserts-enums: a,b,#a Created 4 years, 10 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/render_widget.cc ('k') | pdf/pdfium/pdfium_assert_matching_enums.cc » ('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 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 #include "media/blink/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 60 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
61 #include "third_party/WebKit/public/web/WebView.h" 61 #include "third_party/WebKit/public/web/WebView.h"
62 62
63 using blink::WebCanvas; 63 using blink::WebCanvas;
64 using blink::WebMediaPlayer; 64 using blink::WebMediaPlayer;
65 using blink::WebRect; 65 using blink::WebRect;
66 using blink::WebSize; 66 using blink::WebSize;
67 using blink::WebString; 67 using blink::WebString;
68 using gpu::gles2::GLES2Interface; 68 using gpu::gles2::GLES2Interface;
69 69
70 #define STATIC_ASSERT_ENUM(a, b) \
71 static_assert(static_cast<int>(a) == static_cast<int>(b), \
72 "mismatching enums: " #a)
73
70 namespace media { 74 namespace media {
71 75
72 namespace { 76 namespace {
73 77
74 // Limits the range of playback rate. 78 // Limits the range of playback rate.
75 // 79 //
76 // TODO(kylep): Revisit these. 80 // TODO(kylep): Revisit these.
77 // 81 //
78 // Vista has substantially lower performance than XP or Windows7. If you speed 82 // Vista has substantially lower performance than XP or Windows7. If you speed
79 // up a video too much, it can't keep up, and rendering stops updating except on 83 // up a video too much, it can't keep up, and rendering stops updating except on
(...skipping 19 matching lines...) Expand all
99 callback); 103 callback);
100 } else { 104 } else {
101 callback.Run(OUTPUT_DEVICE_STATUS_ERROR_INTERNAL); 105 callback.Run(OUTPUT_DEVICE_STATUS_ERROR_INTERNAL);
102 } 106 }
103 } 107 }
104 108
105 } // namespace 109 } // namespace
106 110
107 class BufferedDataSourceHostImpl; 111 class BufferedDataSourceHostImpl;
108 112
109 #define STATIC_ASSERT_MATCHING_ENUM(name, name2) \ 113 STATIC_ASSERT_ENUM(WebMediaPlayer::CORSModeUnspecified,
110 static_assert(static_cast<int>(WebMediaPlayer::CORSMode##name) == \ 114 UrlData::CORS_UNSPECIFIED);
111 static_cast<int>(UrlData::name2), \ 115 STATIC_ASSERT_ENUM(WebMediaPlayer::CORSModeAnonymous, UrlData::CORS_ANONYMOUS);
112 "mismatching enum values: " #name) 116 STATIC_ASSERT_ENUM(WebMediaPlayer::CORSModeUseCredentials,
113 STATIC_ASSERT_MATCHING_ENUM(Unspecified, CORS_UNSPECIFIED); 117 UrlData::CORS_USE_CREDENTIALS);
114 STATIC_ASSERT_MATCHING_ENUM(Anonymous, CORS_ANONYMOUS);
115 STATIC_ASSERT_MATCHING_ENUM(UseCredentials, CORS_USE_CREDENTIALS);
116 #undef STATIC_ASSERT_MATCHING_ENUM
117 118
118 #define BIND_TO_RENDER_LOOP(function) \ 119 #define BIND_TO_RENDER_LOOP(function) \
119 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ 120 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \
120 BindToCurrentLoop(base::Bind(function, AsWeakPtr()))) 121 BindToCurrentLoop(base::Bind(function, AsWeakPtr())))
121 122
122 #define BIND_TO_RENDER_LOOP1(function, arg1) \ 123 #define BIND_TO_RENDER_LOOP1(function, arg1) \
123 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ 124 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \
124 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1))) 125 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1)))
125 126
126 WebMediaPlayerImpl::WebMediaPlayerImpl( 127 WebMediaPlayerImpl::WebMediaPlayerImpl(
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 509
509 media::SwitchOutputDeviceCB callback = 510 media::SwitchOutputDeviceCB callback =
510 media::ConvertToSwitchOutputDeviceCB(web_callback); 511 media::ConvertToSwitchOutputDeviceCB(web_callback);
511 media_task_runner_->PostTask( 512 media_task_runner_->PostTask(
512 FROM_HERE, 513 FROM_HERE,
513 base::Bind(&SetSinkIdOnMediaThread, audio_source_provider_, 514 base::Bind(&SetSinkIdOnMediaThread, audio_source_provider_,
514 sink_id.utf8(), static_cast<url::Origin>(security_origin), 515 sink_id.utf8(), static_cast<url::Origin>(security_origin),
515 callback)); 516 callback));
516 } 517 }
517 518
518 #define STATIC_ASSERT_MATCHING_ENUM(webkit_name, chromium_name) \ 519 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadNone, BufferedDataSource::NONE);
519 static_assert(static_cast<int>(WebMediaPlayer::webkit_name) == \ 520 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadMetaData,
520 static_cast<int>(BufferedDataSource::chromium_name), \ 521 BufferedDataSource::METADATA);
521 "mismatching enum values: " #webkit_name) 522 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadAuto, BufferedDataSource::AUTO);
522 STATIC_ASSERT_MATCHING_ENUM(PreloadNone, NONE);
523 STATIC_ASSERT_MATCHING_ENUM(PreloadMetaData, METADATA);
524 STATIC_ASSERT_MATCHING_ENUM(PreloadAuto, AUTO);
525 #undef STATIC_ASSERT_MATCHING_ENUM
526 523
527 void WebMediaPlayerImpl::setPreload(WebMediaPlayer::Preload preload) { 524 void WebMediaPlayerImpl::setPreload(WebMediaPlayer::Preload preload) {
528 DVLOG(1) << __FUNCTION__ << "(" << preload << ")"; 525 DVLOG(1) << __FUNCTION__ << "(" << preload << ")";
529 DCHECK(main_task_runner_->BelongsToCurrentThread()); 526 DCHECK(main_task_runner_->BelongsToCurrentThread());
530 527
531 preload_ = static_cast<BufferedDataSource::Preload>(preload); 528 preload_ = static_cast<BufferedDataSource::Preload>(preload);
532 if (data_source_) 529 if (data_source_)
533 data_source_->SetPreload(preload_); 530 data_source_->SetPreload(preload_);
534 } 531 }
535 532
536 #define STATIC_ASSERT_MATCHING_ENUM(webkit_name, chromium_name) \ 533 STATIC_ASSERT_ENUM(WebMediaPlayer::BufferingStrategy::Normal,
537 static_assert(static_cast<int>(WebMediaPlayer::webkit_name) == \ 534 BufferedDataSource::BUFFERING_STRATEGY_NORMAL);
538 static_cast<int>(BufferedDataSource::chromium_name), \ 535 STATIC_ASSERT_ENUM(WebMediaPlayer::BufferingStrategy::Aggressive,
539 "mismatching enum values: " #webkit_name) 536 BufferedDataSource::BUFFERING_STRATEGY_AGGRESSIVE);
540 STATIC_ASSERT_MATCHING_ENUM(BufferingStrategy::Normal,
541 BUFFERING_STRATEGY_NORMAL);
542 STATIC_ASSERT_MATCHING_ENUM(BufferingStrategy::Aggressive,
543 BUFFERING_STRATEGY_AGGRESSIVE);
544 #undef STATIC_ASSERT_MATCHING_ENUM
545 537
546 void WebMediaPlayerImpl::setBufferingStrategy( 538 void WebMediaPlayerImpl::setBufferingStrategy(
547 WebMediaPlayer::BufferingStrategy buffering_strategy) { 539 WebMediaPlayer::BufferingStrategy buffering_strategy) {
548 DVLOG(1) << __FUNCTION__; 540 DVLOG(1) << __FUNCTION__;
549 DCHECK(main_task_runner_->BelongsToCurrentThread()); 541 DCHECK(main_task_runner_->BelongsToCurrentThread());
550 542
551 buffering_strategy_ = 543 buffering_strategy_ =
552 static_cast<BufferedDataSource::BufferingStrategy>(buffering_strategy); 544 static_cast<BufferedDataSource::BufferingStrategy>(buffering_strategy);
553 if (data_source_) 545 if (data_source_)
554 data_source_->SetBufferingStrategy(buffering_strategy_); 546 data_source_->SetBufferingStrategy(buffering_strategy_);
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 << ", Video: " << stats.video_memory_usage << ", DataSource: " 1541 << ", Video: " << stats.video_memory_usage << ", DataSource: "
1550 << (data_source_ ? data_source_->GetMemoryUsage() : 0) 1542 << (data_source_ ? data_source_->GetMemoryUsage() : 0)
1551 << ", Demuxer: " << demuxer_memory_usage; 1543 << ", Demuxer: " << demuxer_memory_usage;
1552 1544
1553 const int64_t delta = current_memory_usage - last_reported_memory_usage_; 1545 const int64_t delta = current_memory_usage - last_reported_memory_usage_;
1554 last_reported_memory_usage_ = current_memory_usage; 1546 last_reported_memory_usage_ = current_memory_usage;
1555 adjust_allocated_memory_cb_.Run(delta); 1547 adjust_allocated_memory_cb_.Run(delta);
1556 } 1548 }
1557 1549
1558 } // namespace media 1550 } // namespace media
OLDNEW
« no previous file with comments | « content/renderer/render_widget.cc ('k') | pdf/pdfium/pdfium_assert_matching_enums.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698