diff options
author | jbudorick <jbudorick@chromium.org> | 2015-10-26 17:54:50 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-27 00:55:49 +0000 |
commit | 625f6c8cd6bda5cd7a5b1691376956bb8f300785 (patch) | |
tree | e55af27b12e2500027ceb63d4e95a0b36ea1f36f | |
parent | 1f53541bbd81aa282eaa1bbdb2094edd43d425a0 (diff) | |
download | chromium_src-625f6c8cd6bda5cd7a5b1691376956bb8f300785.zip chromium_src-625f6c8cd6bda5cd7a5b1691376956bb8f300785.tar.gz chromium_src-625f6c8cd6bda5cd7a5b1691376956bb8f300785.tar.bz2 |
Revert of Remove DCHECK_IMPLIES/CHECK_IMPLIES. (patchset #3 id:40001 of https://codereview.chromium.org/1421483005/ )
Reason for revert:
breaks compilation on multiple builders, including but not limited to:
http://build.chromium.org/p/chromium.webkit/builders/WebKit%20Mac%20Builder%20%28dbg%29/builds/132580
http://build.chromium.org/p/chromium.linux/builders/Android%20Builder%20%28dbg%29/builds/91670
Original issue's description:
> Remove DCHECK_IMPLIES/CHECK_IMPLIES.
>
> This patch removes both DCHECK_IMPLIES and CHECK_IMPLIES macros.
>
> R=thakis, sky, jam
> CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
>
> Committed: https://crrev.com/cc8936ba36ee29b5859f65c936e16f87eeac82b4
> Cr-Commit-Position: refs/heads/master@{#356193}
TBR=thakis@chromium.org,sky@chromium.org,jam@chromium.org,vmpstr@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1417903005
Cr-Commit-Position: refs/heads/master@{#356202}
53 files changed, 150 insertions, 134 deletions
diff --git a/base/logging.h b/base/logging.h index 8c7f20a..f495118 100644 --- a/base/logging.h +++ b/base/logging.h @@ -571,6 +571,7 @@ DEFINE_CHECK_OP_IMPL(GT, > ) #define CHECK_LT(val1, val2) CHECK_OP(LT, < , val1, val2) #define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2) #define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2) +#define CHECK_IMPLIES(val1, val2) CHECK(!(val1) || (val2)) #if defined(NDEBUG) #define ENABLE_DLOG 0 @@ -724,6 +725,7 @@ const LogSeverity LOG_DCHECK = LOG_INFO; #define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2) #define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2) #define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2) +#define DCHECK_IMPLIES(val1, val2) DCHECK(!(val1) || (val2)) #if !DCHECK_IS_ON() && defined(OS_CHROMEOS) // Implement logging of NOTREACHED() as a dedicated function to get function diff --git a/base/trace_event/memory_dump_manager.cc b/base/trace_event/memory_dump_manager.cc index 874e629..cb38093 100644 --- a/base/trace_event/memory_dump_manager.cc +++ b/base/trace_event/memory_dump_manager.cc @@ -206,9 +206,9 @@ void MemoryDumpManager::UnregisterDumpProvider(MemoryDumpProvider* mdp) { // and OnMemoryDump() at the same time). // Otherwise, it is not possible to guarantee that its unregistration is // race-free. If you hit this DCHECK, your MDP has a bug. - DCHECK(!subtle::NoBarrier_Load(&memory_tracing_enabled_) || - (mdp_iter->task_runner && - mdp_iter->task_runner->BelongsToCurrentThread())) + DCHECK_IMPLIES( + subtle::NoBarrier_Load(&memory_tracing_enabled_), + mdp_iter->task_runner && mdp_iter->task_runner->BelongsToCurrentThread()) << "The MemoryDumpProvider attempted to unregister itself in a racy way. " << "Please file a crbug."; diff --git a/base/trace_event/trace_log.cc b/base/trace_event/trace_log.cc index 032bc77..d1fb70e 100644 --- a/base/trace_event/trace_log.cc +++ b/base/trace_event/trace_log.cc @@ -879,7 +879,7 @@ void TraceLog::FlushInternal(const TraceLog::OutputCallback& cb, flush_task_runner_ = ThreadTaskRunnerHandle::IsSet() ? ThreadTaskRunnerHandle::Get() : nullptr; - DCHECK(!thread_message_loops_.size() || flush_task_runner_); + DCHECK_IMPLIES(thread_message_loops_.size(), flush_task_runner_); flush_output_callback_ = cb; if (thread_shared_chunk_) { diff --git a/cc/animation/animation_player.cc b/cc/animation/animation_player.cc index 0c38011..0bec926 100644 --- a/cc/animation/animation_player.cc +++ b/cc/animation/animation_player.cc @@ -119,8 +119,9 @@ void AnimationPlayer::UnbindElementAnimations() { } void AnimationPlayer::AddAnimation(scoped_ptr<Animation> animation) { - DCHECK(animation->target_property() != Animation::SCROLL_OFFSET || - (animation_host_ && animation_host_->SupportsScrollAnimations())); + DCHECK_IMPLIES( + animation->target_property() == Animation::SCROLL_OFFSET, + animation_host_ && animation_host_->SupportsScrollAnimations()); if (element_animations_) { element_animations_->layer_animation_controller()->AddAnimation( diff --git a/cc/input/top_controls_manager.cc b/cc/input/top_controls_manager.cc index 5fe1267..1a961b5 100644 --- a/cc/input/top_controls_manager.cc +++ b/cc/input/top_controls_manager.cc @@ -176,8 +176,8 @@ void TopControlsManager::ResetAnimations() { void TopControlsManager::SetupAnimation(AnimationDirection direction) { DCHECK_NE(NO_ANIMATION, direction); - DCHECK(direction != HIDING_CONTROLS || TopControlsShownRatio() > 0.f); - DCHECK(direction != SHOWING_CONTROLS || TopControlsShownRatio() < 1.f); + DCHECK_IMPLIES(direction == HIDING_CONTROLS, TopControlsShownRatio() > 0.f); + DCHECK_IMPLIES(direction == SHOWING_CONTROLS, TopControlsShownRatio() < 1.f); if (top_controls_animation_ && animation_direction_ == direction) return; diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc index 0b92ff4..81ae0b1 100644 --- a/cc/layers/picture_layer.cc +++ b/cc/layers/picture_layer.cc @@ -57,8 +57,8 @@ void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { // If update called, then recording source size must match bounds pushed to // impl layer. - DCHECK(update_source_frame_number_ != source_frame_number || - impl_bounds == recording_source_bounds) + DCHECK_IMPLIES(update_source_frame_number_ == source_frame_number, + impl_bounds == recording_source_bounds) << " bounds " << impl_bounds.ToString() << " recording source " << recording_source_bounds.ToString(); diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index 732b822..34357ff 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -100,8 +100,8 @@ void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { LayerImpl::PushPropertiesTo(base_layer); // Twin relationships should never change once established. - DCHECK(!twin_layer_ || twin_layer_ == layer_impl); - DCHECK(!twin_layer_ || layer_impl->twin_layer_ == this); + DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl); + DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); // The twin relationship does not need to exist before the first // PushPropertiesTo from pending to active layer since before that the active // layer can not have a pile or tilings, it has only been created and inserted @@ -112,7 +112,7 @@ void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { layer_impl->SetNearestNeighbor(nearest_neighbor_); // Solid color layers have no tilings. - DCHECK(!raster_source_->IsSolidColor() || tilings_->num_tilings() == 0); + DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); // The pending tree should only have a high res (and possibly low res) tiling. DCHECK_LE(tilings_->num_tilings(), layer_tree_impl()->create_low_res_tiling() ? 2u : 1u); @@ -123,8 +123,8 @@ void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { DCHECK(invalidation_.IsEmpty()); // After syncing a solid color layer, the active layer has no tilings. - DCHECK(!raster_source_->IsSolidColor() || - layer_impl->tilings_->num_tilings() == 0); + DCHECK_IMPLIES(raster_source_->IsSolidColor(), + layer_impl->tilings_->num_tilings() == 0); layer_impl->raster_page_scale_ = raster_page_scale_; layer_impl->raster_device_scale_ = raster_device_scale_; @@ -144,8 +144,8 @@ void PictureLayerImpl::AppendQuads(RenderPass* render_pass, AppendQuadsData* append_quads_data) { // The bounds and the pile size may differ if the pile wasn't updated (ie. // PictureLayer::Update didn't happen). In that case the pile will be empty. - DCHECK(raster_source_->GetSize().IsEmpty() || - bounds() == raster_source_->GetSize()) + DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(), + bounds() == raster_source_->GetSize()) << " bounds " << bounds().ToString() << " pile " << raster_source_->GetSize().ToString(); @@ -529,8 +529,8 @@ void PictureLayerImpl::UpdateRasterSource( const PictureLayerTilingSet* pending_set) { // The bounds and the pile size may differ if the pile wasn't updated (ie. // PictureLayer::Update didn't happen). In that case the pile will be empty. - DCHECK(raster_source->GetSize().IsEmpty() || - bounds() == raster_source->GetSize()) + DCHECK_IMPLIES(!raster_source->GetSize().IsEmpty(), + bounds() == raster_source->GetSize()) << " bounds " << bounds().ToString() << " pile " << raster_source->GetSize().ToString(); @@ -545,8 +545,9 @@ void PictureLayerImpl::UpdateRasterSource( invalidation_.Swap(new_invalidation); bool can_have_tilings = CanHaveTilings(); - DCHECK(!pending_set || - can_have_tilings == GetPendingOrActiveTwinLayer()->CanHaveTilings()); + DCHECK_IMPLIES( + pending_set, + can_have_tilings == GetPendingOrActiveTwinLayer()->CanHaveTilings()); // Need to call UpdateTiles again if CanHaveTilings changed. if (could_have_tilings != can_have_tilings) @@ -778,8 +779,8 @@ void PictureLayerImpl::GetContentsResourceId(ResourceId* resource_id, gfx::Size* resource_size) const { // The bounds and the pile size may differ if the pile wasn't updated (ie. // PictureLayer::Update didn't happen). In that case the pile will be empty. - DCHECK(raster_source_->GetSize().IsEmpty() || - bounds() == raster_source_->GetSize()) + DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(), + bounds() == raster_source_->GetSize()) << " bounds " << bounds().ToString() << " pile " << raster_source_->GetSize().ToString(); gfx::Rect content_rect(bounds()); @@ -919,7 +920,7 @@ void PictureLayerImpl::AddLowResolutionTilingIfNeeded() { PictureLayerTiling* low_res = tilings_->FindTilingWithScale(low_res_raster_contents_scale_); - DCHECK(!low_res || low_res->resolution() != HIGH_RESOLUTION); + DCHECK_IMPLIES(low_res, low_res->resolution() != HIGH_RESOLUTION); // Only create new low res tilings when the transform is static. This // prevents wastefully creating a paired low res tiling for every new high diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index 872db91..6e1b4c9 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -232,7 +232,7 @@ class PictureLayerImplTest : public testing::Test { // Steal from the recycled tree if possible. scoped_ptr<LayerImpl> pending_root = pending_tree->DetachLayerTree(); scoped_ptr<FakePictureLayerImpl> pending_layer; - DCHECK(!pending_root || pending_root->id() == root_id_); + DCHECK_IMPLIES(pending_root, pending_root->id() == root_id_); if (!pending_root) { pending_root = LayerImpl::Create(pending_tree, root_id_); pending_layer = FakePictureLayerImpl::Create(pending_tree, id_); diff --git a/cc/layers/video_layer_impl.cc b/cc/layers/video_layer_impl.cc index 220a9da..82e32f8 100644 --- a/cc/layers/video_layer_impl.cc +++ b/cc/layers/video_layer_impl.cc @@ -243,10 +243,11 @@ void VideoLayerImpl::AppendQuads(RenderPass* render_pass, DCHECK(uv_tex_size == media::VideoFrame::PlaneSize( frame_->format(), media::VideoFrame::kVPlane, coded_size)); - DCHECK(frame_resources_.size() <= 3 || - ya_tex_size == media::VideoFrame::PlaneSize( - frame_->format(), media::VideoFrame::kAPlane, - coded_size)); + DCHECK_IMPLIES( + frame_resources_.size() > 3, + ya_tex_size == + media::VideoFrame::PlaneSize( + frame_->format(), media::VideoFrame::kAPlane, coded_size)); } // Compute the UV sub-sampling factor based on the ratio between diff --git a/cc/output/direct_renderer.cc b/cc/output/direct_renderer.cc index 0083427..1be41e9 100644 --- a/cc/output/direct_renderer.cc +++ b/cc/output/direct_renderer.cc @@ -436,8 +436,8 @@ void DirectRenderer::DrawRenderPass(DrawingFrame* frame, // If |has_external_stencil_test| we can't discard or clear. Make sure we // don't need to. - DCHECK(!has_external_stencil_test || - !frame->current_render_pass->has_transparent_background); + DCHECK_IMPLIES(has_external_stencil_test, + !frame->current_render_pass->has_transparent_background); SurfaceInitializationMode mode; if (should_clear_surface && render_pass_is_clipped) { diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index 1d56429..81cc323 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc @@ -3534,7 +3534,7 @@ void GLRenderer::ScheduleOverlays(DrawingFrame* frame) { unsigned texture_id = 0; if (overlay.use_output_surface_for_resource) { texture_id = output_surface_->GetOverlayTextureId(); - DCHECK(texture_id || IsContextLost()); + DCHECK_IMPLIES(!texture_id, IsContextLost()); } else { pending_overlay_resources_.push_back( make_scoped_ptr(new ResourceProvider::ScopedReadLockGL( diff --git a/cc/playback/display_item_list.cc b/cc/playback/display_item_list.cc index 40194f7..7614bfd 100644 --- a/cc/playback/display_item_list.cc +++ b/cc/playback/display_item_list.cc @@ -203,7 +203,7 @@ size_t DisplayItemList::ApproximateMemoryUsage() const { if (use_cached_picture_ && retain_individual_display_items_) return 0; - DCHECK(!use_cached_picture_ || picture_); + DCHECK_IMPLIES(use_cached_picture_, picture_); size_t memory_usage = sizeof(*this); @@ -273,7 +273,7 @@ void DisplayItemList::GenerateDiscardableImagesMetadata() { DCHECK(ProcessAppendedItemsCalled()); // This should be only called once, and only after CreateAndCacheSkPicture. DCHECK(image_map_.empty()); - DCHECK(!use_cached_picture_ || picture_); + DCHECK_IMPLIES(use_cached_picture_, picture_); if (use_cached_picture_ && !picture_->willPlayBackBitmaps()) return; diff --git a/cc/resources/texture_mailbox.cc b/cc/resources/texture_mailbox.cc index ad008b8..ff4c6f9 100644 --- a/cc/resources/texture_mailbox.cc +++ b/cc/resources/texture_mailbox.cc @@ -36,7 +36,7 @@ TextureMailbox::TextureMailbox(const gpu::Mailbox& mailbox, size_in_pixels_(size_in_pixels), is_overlay_candidate_(is_overlay_candidate), nearest_neighbor_(false) { - DCHECK(!is_overlay_candidate || !size_in_pixels.IsEmpty()); + DCHECK_IMPLIES(is_overlay_candidate, !size_in_pixels.IsEmpty()); } TextureMailbox::TextureMailbox(SharedBitmap* shared_bitmap, diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc index 28f99ed..b21eacb 100644 --- a/cc/scheduler/scheduler.cc +++ b/cc/scheduler/scheduler.cc @@ -75,8 +75,10 @@ Scheduler::Scheduler( TRACE_EVENT1("cc", "Scheduler::Scheduler", "settings", settings_.AsValue()); DCHECK(client_); DCHECK(!state_machine_.BeginFrameNeeded()); - DCHECK(!settings_.use_external_begin_frame_source || external_frame_source_); - DCHECK(settings_.use_external_begin_frame_source || synthetic_frame_source_); + DCHECK_IMPLIES(settings_.use_external_begin_frame_source, + external_frame_source_); + DCHECK_IMPLIES(!settings_.use_external_begin_frame_source, + synthetic_frame_source_); DCHECK(unthrottled_frame_source_); begin_retro_frame_closure_ = diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc index 2e4ad85d..8e4fed8 100644 --- a/cc/scheduler/scheduler_state_machine.cc +++ b/cc/scheduler/scheduler_state_machine.cc @@ -493,7 +493,8 @@ bool SchedulerStateMachine::ShouldCommit() const { // If we only have an active tree, it is incorrect to replace it // before we've drawn it. - DCHECK(!settings_.commit_to_active_tree || !active_tree_needs_first_draw_); + DCHECK_IMPLIES(settings_.commit_to_active_tree, + !active_tree_needs_first_draw_); return true; } diff --git a/cc/test/fake_display_list_raster_source.cc b/cc/test/fake_display_list_raster_source.cc index 163559b..de69afa 100644 --- a/cc/test/fake_display_list_raster_source.cc +++ b/cc/test/fake_display_list_raster_source.cc @@ -82,8 +82,8 @@ scoped_refptr<FakeDisplayListRasterSource> FakeDisplayListRasterSource::CreatePartiallyFilled( const gfx::Size& size, const gfx::Rect& recorded_viewport) { - DCHECK(recorded_viewport.IsEmpty() || - gfx::Rect(size).Contains(recorded_viewport)); + DCHECK_IMPLIES(!recorded_viewport.IsEmpty(), + gfx::Rect(size).Contains(recorded_viewport)); auto recording_source = FakeDisplayListRecordingSource::CreateRecordingSource( recorded_viewport, size); diff --git a/cc/tiles/picture_layer_tiling.cc b/cc/tiles/picture_layer_tiling.cc index 50a478f..62e7da8 100644 --- a/cc/tiles/picture_layer_tiling.cc +++ b/cc/tiles/picture_layer_tiling.cc @@ -284,7 +284,8 @@ void PictureLayerTiling::SetRasterSourceAndResize( } void PictureLayerTiling::Invalidate(const Region& layer_invalidation) { - DCHECK(tree_ != ACTIVE_TREE || !client_->GetPendingOrActiveTwinTiling(this)); + DCHECK_IMPLIES(tree_ == ACTIVE_TREE, + !client_->GetPendingOrActiveTwinTiling(this)); RemoveTilesInRegion(layer_invalidation, true /* recreate tiles */); } @@ -685,8 +686,8 @@ bool PictureLayerTiling::ComputeTilePriorityRects( eventually_rect = tiling_data_.ExpandRectIgnoringBordersToTileBounds(eventually_rect); - DCHECK(eventually_rect.IsEmpty() || - gfx::Rect(tiling_size()).Contains(eventually_rect)) + DCHECK_IMPLIES(!eventually_rect.IsEmpty(), + gfx::Rect(tiling_size()).Contains(eventually_rect)) << "tiling_size: " << tiling_size().ToString() << " eventually_rect: " << eventually_rect.ToString(); diff --git a/cc/tiles/picture_layer_tiling_set.cc b/cc/tiles/picture_layer_tiling_set.cc index 0848e61..9facf9f2 100644 --- a/cc/tiles/picture_layer_tiling_set.cc +++ b/cc/tiles/picture_layer_tiling_set.cc @@ -140,7 +140,7 @@ void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForCommit( // Invalidate tiles and update them to the new raster source. for (PictureLayerTiling* tiling : tilings_) { - DCHECK(tree_ != PENDING_TREE || !tiling->has_tiles()); + DCHECK_IMPLIES(tree_ == PENDING_TREE, !tiling->has_tiles()); tiling->SetRasterSourceAndResize(raster_source); // We can commit on either active or pending trees, but only active one can diff --git a/cc/tiles/tile_manager.cc b/cc/tiles/tile_manager.cc index eccf3f0..56e6971 100644 --- a/cc/tiles/tile_manager.cc +++ b/cc/tiles/tile_manager.cc @@ -521,8 +521,8 @@ void TileManager::AssignGpuMemoryToTiles( tile->scheduled_priority_ = schedule_priority++; - DCHECK(tile->draw_info().mode() == TileDrawInfo::OOM_MODE || - !tile->draw_info().IsReadyToDraw()); + DCHECK_IMPLIES(tile->draw_info().mode() != TileDrawInfo::OOM_MODE, + !tile->draw_info().IsReadyToDraw()); // If the tile already has a raster_task, then the memory used by it is // already accounted for in memory_usage. Otherwise, we'll have to acquire @@ -795,8 +795,8 @@ bool TileManager::AreRequiredTilesReadyToDraw( client_->BuildRasterQueue(global_state_.tree_priority, type)); for (; !all_queue->IsEmpty(); all_queue->Pop()) { Tile* tile = all_queue->Top().tile(); - DCHECK(!tile->required_for_activation() || - tile->draw_info().IsReadyToDraw()); + DCHECK_IMPLIES(tile->required_for_activation(), + tile->draw_info().IsReadyToDraw()); } #endif return true; diff --git a/cc/tiles/tile_manager_unittest.cc b/cc/tiles/tile_manager_unittest.cc index 0a06830..95c3e56 100644 --- a/cc/tiles/tile_manager_unittest.cc +++ b/cc/tiles/tile_manager_unittest.cc @@ -125,7 +125,7 @@ class TileManagerTilePriorityQueueTest : public testing::Test { // Steal from the recycled tree. scoped_ptr<LayerImpl> old_pending_root = pending_tree->DetachLayerTree(); - DCHECK(!old_pending_root || old_pending_root->id() == id_); + DCHECK_IMPLIES(old_pending_root, old_pending_root->id() == id_); scoped_ptr<FakePictureLayerImpl> pending_layer; if (old_pending_root) { diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index e00c15e..7641fe8 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -955,8 +955,8 @@ void LayerTreeHost::RegisterViewportLayers( scoped_refptr<Layer> page_scale_layer, scoped_refptr<Layer> inner_viewport_scroll_layer, scoped_refptr<Layer> outer_viewport_scroll_layer) { - DCHECK(!inner_viewport_scroll_layer || - inner_viewport_scroll_layer != outer_viewport_scroll_layer); + DCHECK_IMPLIES(inner_viewport_scroll_layer, + inner_viewport_scroll_layer != outer_viewport_scroll_layer); overscroll_elasticity_layer_ = overscroll_elasticity_layer; page_scale_layer_ = page_scale_layer; inner_viewport_scroll_layer_ = inner_viewport_scroll_layer; diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index e02cf8b..5af5fc1 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -415,8 +415,8 @@ void UpdateAccumulatedSurfaceState( current_target->render_surface()->draw_transform(); // If we have unclipped descendants, the draw transform is a translation. - DCHECK(!current_target->num_unclipped_descendants() || - current_draw_transform.IsIdentityOrTranslation()); + DCHECK_IMPLIES(current_target->num_unclipped_descendants(), + current_draw_transform.IsIdentityOrTranslation()); target_rect = MathUtil::MapEnclosingClippedRect(current_draw_transform, target_rect); diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index c598dcd..235817d 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -477,8 +477,8 @@ void LayerTreeHostImpl::StartPageScaleAnimation( } void LayerTreeHostImpl::SetNeedsAnimateInput() { - DCHECK(!IsCurrentlyScrollingInnerViewport() || - !settings_.ignore_root_layer_flings); + DCHECK_IMPLIES(IsCurrentlyScrollingInnerViewport(), + !settings_.ignore_root_layer_flings); SetNeedsAnimate(); } @@ -1019,7 +1019,7 @@ DrawResult LayerTreeHostImpl::CalculateRenderPasses( // destroyed. // TODO(weiliangc): Test copy request w/ output surface recreation. Would // trigger this DCHECK. - DCHECK(!have_copy_request || draw_result == DRAW_SUCCESS); + DCHECK_IMPLIES(have_copy_request, draw_result == DRAW_SUCCESS); return draw_result; } diff --git a/cc/trees/property_tree_builder.cc b/cc/trees/property_tree_builder.cc index 2f1d954..f92be58 100644 --- a/cc/trees/property_tree_builder.cc +++ b/cc/trees/property_tree_builder.cc @@ -236,7 +236,7 @@ bool AddTransformNodeIfNeeded( is_page_scale_layer; LayerType* transform_parent = GetTransformParent(data_from_ancestor, layer); - DCHECK(is_root || transform_parent); + DCHECK_IMPLIES(!is_root, transform_parent); int parent_index = kRootPropertyTreeNodeId; if (transform_parent) diff --git a/chrome/browser/captive_portal/captive_portal_tab_helper_unittest.cc b/chrome/browser/captive_portal/captive_portal_tab_helper_unittest.cc index e9e6389..96cd8b2 100644 --- a/chrome/browser/captive_portal/captive_portal_tab_helper_unittest.cc +++ b/chrome/browser/captive_portal/captive_portal_tab_helper_unittest.cc @@ -127,7 +127,7 @@ class CaptivePortalTabHelperTest : public ChromeRenderViewHostTestHarness { content::WebContentsTester* web_contents_tester = content::WebContentsTester::For(web_contents()); web_contents_tester->StartNavigation(url); - DCHECK(navigation_type != kSameProcess || !pending_main_rfh()); + DCHECK_IMPLIES(navigation_type == kSameProcess, !pending_main_rfh()); EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); content::RenderFrameHost* rfh = @@ -156,7 +156,7 @@ class CaptivePortalTabHelperTest : public ChromeRenderViewHostTestHarness { content::WebContentsTester* web_contents_tester = content::WebContentsTester::For(web_contents()); web_contents_tester->StartNavigation(url); - DCHECK(navigation_type != kSameProcess || !pending_main_rfh()); + DCHECK_IMPLIES(navigation_type == kSameProcess, !pending_main_rfh()); EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); content::RenderFrameHost* rfh = diff --git a/chrome/browser/ui/passwords/manage_passwords_ui_controller.cc b/chrome/browser/ui/passwords/manage_passwords_ui_controller.cc index e3bb65a..26c5c96 100644 --- a/chrome/browser/ui/passwords/manage_passwords_ui_controller.cc +++ b/chrome/browser/ui/passwords/manage_passwords_ui_controller.cc @@ -122,7 +122,7 @@ bool ManagePasswordsUIController::OnChooseCredentials( ScopedVector<autofill::PasswordForm> federated_credentials, const GURL& origin, base::Callback<void(const password_manager::CredentialInfo&)> callback) { - DCHECK(!local_credentials.empty() || !federated_credentials.empty()); + DCHECK_IMPLIES(local_credentials.empty(), !federated_credentials.empty()); passwords_data_.OnRequestCredentials(local_credentials.Pass(), federated_credentials.Pass(), origin); diff --git a/components/page_load_metrics/browser/metrics_web_contents_observer.cc b/components/page_load_metrics/browser/metrics_web_contents_observer.cc index 6fed6ca..d19d332 100644 --- a/components/page_load_metrics/browser/metrics_web_contents_observer.cc +++ b/components/page_load_metrics/browser/metrics_web_contents_observer.cc @@ -49,8 +49,9 @@ bool IsValidPageLoadTiming(const PageLoadTiming& timing) { DCHECK(!timing.navigation_start.is_null()); // If we have a DOM content loaded event, we should have a response start. - DCHECK(timing.dom_content_loaded_event_start.is_zero() || - timing.response_start <= timing.dom_content_loaded_event_start); + DCHECK_IMPLIES( + !timing.dom_content_loaded_event_start.is_zero(), + timing.response_start <= timing.dom_content_loaded_event_start); // If we have a load event, we should have both a response start and a DCL. // TODO(csharrison) crbug.com/536203 shows that sometimes we can get a load diff --git a/components/tracing/child_memory_dump_manager_delegate_impl.h b/components/tracing/child_memory_dump_manager_delegate_impl.h index 8150a07..007776a 100644 --- a/components/tracing/child_memory_dump_manager_delegate_impl.h +++ b/components/tracing/child_memory_dump_manager_delegate_impl.h @@ -41,11 +41,11 @@ class TRACING_EXPORT ChildMemoryDumpManagerDelegateImpl // Pass kInvalidTracingProcessId to invalidate the id. void set_tracing_process_id(uint64 id) { - DCHECK(tracing_process_id_ == - base::trace_event::MemoryDumpManager::kInvalidTracingProcessId || - id == - base::trace_event::MemoryDumpManager::kInvalidTracingProcessId || - id == tracing_process_id_); + DCHECK_IMPLIES( + tracing_process_id_ != + base::trace_event::MemoryDumpManager::kInvalidTracingProcessId, + id == base::trace_event::MemoryDumpManager::kInvalidTracingProcessId || + id == tracing_process_id_); tracing_process_id_ = id; } diff --git a/content/browser/frame_host/navigation_entry_impl.cc b/content/browser/frame_host/navigation_entry_impl.cc index 3c20692..3b1f6d8 100644 --- a/content/browser/frame_host/navigation_entry_impl.cc +++ b/content/browser/frame_host/navigation_entry_impl.cc @@ -602,8 +602,8 @@ NavigationEntryImpl::TreeNode* NavigationEntryImpl::FindFrameEntry( work_queue.pop(); if (node->MatchesFrame(frame_tree_node)) { // Only the root TreeNode should have a FTN ID of -1. - DCHECK(node->frame_entry->frame_tree_node_id() != -1 || - node == root_node()); + DCHECK_IMPLIES(node->frame_entry->frame_tree_node_id() == -1, + node == root_node()); return node; } // Enqueue any children and keep looking. diff --git a/content/browser/frame_host/navigation_handle_impl.cc b/content/browser/frame_host/navigation_handle_impl.cc index dde92ee..d253d5f 100644 --- a/content/browser/frame_host/navigation_handle_impl.cc +++ b/content/browser/frame_host/navigation_handle_impl.cc @@ -248,7 +248,7 @@ void NavigationHandleImpl::ReadyToCommitNavigation( void NavigationHandleImpl::DidCommitNavigation( bool same_page, RenderFrameHostImpl* render_frame_host) { - CHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); + CHECK_IMPLIES(render_frame_host_, render_frame_host_ == render_frame_host); is_same_page_ = same_page; render_frame_host_ = render_frame_host; state_ = net_error_code_ == net::OK ? DID_COMMIT : DID_COMMIT_ERROR_PAGE; @@ -257,8 +257,8 @@ void NavigationHandleImpl::DidCommitNavigation( NavigationThrottle::ThrottleCheckResult NavigationHandleImpl::CheckWillStartRequest() { DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); - DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); - DCHECK(state_ != DEFERRING_START || next_index_ != 0); + DCHECK_IMPLIES(state_ == WILL_SEND_REQUEST, next_index_ == 0); + DCHECK_IMPLIES(state_ == DEFERRING_START, next_index_ != 0); for (size_t i = next_index_; i < throttles_.size(); ++i) { NavigationThrottle::ThrottleCheckResult result = throttles_[i]->WillStartRequest(); @@ -286,8 +286,8 @@ NavigationHandleImpl::CheckWillStartRequest() { NavigationThrottle::ThrottleCheckResult NavigationHandleImpl::CheckWillRedirectRequest() { DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); - DCHECK(state_ != WILL_REDIRECT_REQUEST || next_index_ == 0); - DCHECK(state_ != DEFERRING_REDIRECT || next_index_ != 0); + DCHECK_IMPLIES(state_ == WILL_REDIRECT_REQUEST, next_index_ == 0); + DCHECK_IMPLIES(state_ == DEFERRING_REDIRECT, next_index_ != 0); for (size_t i = next_index_; i < throttles_.size(); ++i) { NavigationThrottle::ThrottleCheckResult result = throttles_[i]->WillRedirectRequest(); diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc index 4fb2eb9..171b1b5 100644 --- a/content/browser/frame_host/navigation_request.cc +++ b/content/browser/frame_host/navigation_request.cc @@ -158,7 +158,7 @@ NavigationRequest::NavigationRequest( restore_type_(NavigationEntryImpl::RESTORE_NONE), is_view_source_(false), bindings_(NavigationEntryImpl::kInvalidBindings) { - DCHECK(!browser_initiated || (entry != nullptr && frame_entry != nullptr)); + DCHECK_IMPLIES(browser_initiated, entry != nullptr && frame_entry != nullptr); if (browser_initiated) { // TODO(clamy): use the FrameNavigationEntry for the source SiteInstance // once it has been moved from the NavigationEntry. diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc index a9cd3bf..06a15f8 100644 --- a/content/browser/frame_host/render_frame_host_impl.cc +++ b/content/browser/frame_host/render_frame_host_impl.cc @@ -2073,7 +2073,7 @@ bool RenderFrameHostImpl::IsRenderFrameLive() { bool is_live = GetProcess()->HasConnection() && render_frame_created_; // Sanity check: the RenderView should always be live if the RenderFrame is. - DCHECK(!is_live || render_view_host_->IsRenderViewLive()); + DCHECK_IMPLIES(is_live, render_view_host_->IsRenderViewLive()); return is_live; } diff --git a/content/browser/frame_host/render_frame_host_manager.cc b/content/browser/frame_host/render_frame_host_manager.cc index 8dc0cca..b38cc53 100644 --- a/content/browser/frame_host/render_frame_host_manager.cc +++ b/content/browser/frame_host/render_frame_host_manager.cc @@ -670,7 +670,7 @@ void RenderFrameHostManager::CommitPendingIfNecessary( RenderFrameHostImpl* render_frame_host, bool was_caused_by_user_gesture) { if (!pending_render_frame_host_ && !speculative_render_frame_host_) { - DCHECK(!should_reuse_web_ui_ || web_ui_); + DCHECK_IMPLIES(should_reuse_web_ui_, web_ui_); // We should only hear this from our current renderer. DCHECK_EQ(render_frame_host_, render_frame_host); @@ -1783,12 +1783,12 @@ scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame( SiteIsolationPolicy::IsSwappedOutStateForbidden(); CHECK(instance); - CHECK(!swapped_out_forbidden || !swapped_out); - CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible() || - frame_tree_node_->IsMainFrame()); + CHECK_IMPLIES(swapped_out_forbidden, !swapped_out); + CHECK_IMPLIES(!SiteIsolationPolicy::AreCrossProcessFramesPossible(), + frame_tree_node_->IsMainFrame()); // Swapped out views should always be hidden. - DCHECK(!swapped_out || (flags & CREATE_RF_HIDDEN)); + DCHECK_IMPLIES(swapped_out, (flags & CREATE_RF_HIDDEN)); scoped_ptr<RenderFrameHostImpl> new_render_frame_host; bool success = true; diff --git a/content/browser/frame_host/render_frame_proxy_host.cc b/content/browser/frame_host/render_frame_proxy_host.cc index 8f9e57f..2ef3d26 100644 --- a/content/browser/frame_host/render_frame_proxy_host.cc +++ b/content/browser/frame_host/render_frame_proxy_host.cc @@ -57,9 +57,9 @@ RenderFrameProxyHost::RenderFrameProxyHost(SiteInstance* site_instance, std::make_pair( RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_), this)).second); - CHECK(render_view_host || - (frame_tree_node_->render_manager()->ForInnerDelegate() && - frame_tree_node_->IsMainFrame())); + CHECK_IMPLIES(!render_view_host, + frame_tree_node_->render_manager()->ForInnerDelegate() && + frame_tree_node_->IsMainFrame()); if (render_view_host) frame_tree_node_->frame_tree()->AddRenderViewHostRef(render_view_host_); diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc index 850a244..b83800b 100644 --- a/content/browser/renderer_host/compositor_impl_android.cc +++ b/content/browser/renderer_host/compositor_impl_android.cc @@ -709,7 +709,7 @@ void CompositorImpl::ScheduleComposite() { if (ignore_schedule_composite_ || !host_->visible()) return; - DCHECK(!needs_composite_ || WillComposite()); + DCHECK_IMPLIES(needs_composite_, WillComposite()); needs_composite_ = true; // We currently expect layer tree invalidations at most once per frame // during normal operation and therefore try to composite immediately diff --git a/content/child/web_url_loader_impl.cc b/content/child/web_url_loader_impl.cc index bea6020..193797b 100644 --- a/content/child/web_url_loader_impl.cc +++ b/content/child/web_url_loader_impl.cc @@ -450,10 +450,10 @@ void WebURLLoaderImpl::Context::Start(const WebURLRequest& request, // the WebURLLoader are the ones created by CommitNavigation. Several browser // tests load HTML directly through a data url which will be handled by the // block above. - DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableBrowserSideNavigation) || - stream_override_.get() || - request.frameType() == WebURLRequest::FrameTypeNone); + DCHECK_IMPLIES(base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableBrowserSideNavigation), + stream_override_.get() || + request.frameType() == WebURLRequest::FrameTypeNone); GURL referrer_url( request.httpHeaderField(WebString::fromUTF8("Referer")).latin1()); diff --git a/content/common/discardable_shared_memory_heap.cc b/content/common/discardable_shared_memory_heap.cc index 61f05d3..bf124f7 100644 --- a/content/common/discardable_shared_memory_heap.cc +++ b/content/common/discardable_shared_memory_heap.cc @@ -176,8 +176,8 @@ DiscardableSharedMemoryHeap::Split(Span* span, size_t blocks) { scoped_ptr<Span> leftover(new Span( span->shared_memory_, span->start_ + blocks, span->length_ - blocks)); - DCHECK(leftover->length_ == 1 || - spans_.find(leftover->start_) == spans_.end()); + DCHECK_IMPLIES(leftover->length_ > 1, + spans_.find(leftover->start_) == spans_.end()); RegisterSpan(leftover.get()); spans_[span->start_ + blocks - 1] = span; span->length_ = blocks; @@ -281,7 +281,7 @@ DiscardableSharedMemoryHeap::Carve(Span* span, size_t blocks) { scoped_ptr<Span> leftover( new Span(serving->shared_memory_, serving->start_ + blocks, extra)); leftover->set_is_locked(false); - DCHECK(extra == 1 || spans_.find(leftover->start_) == spans_.end()); + DCHECK_IMPLIES(extra > 1, spans_.find(leftover->start_) == spans_.end()); RegisterSpan(leftover.get()); // No need to coalesce as the previous span of |leftover| was just split diff --git a/content/common/gpu/client/gl_helper_scaling.cc b/content/common/gpu/client/gl_helper_scaling.cc index 49cab49..7b7338d 100644 --- a/content/common/gpu/client/gl_helper_scaling.cc +++ b/content/common/gpu/client/gl_helper_scaling.cc @@ -870,7 +870,8 @@ void ShaderProgram::Setup(const GLchar* vertex_shader_text, // The only reason fetching these attribute locations should fail is // if the context was spontaneously lost (i.e., because the GPU // process crashed, perhaps deliberately for testing). - DCHECK(Initialized() || gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR); + DCHECK_IMPLIES(!Initialized(), + gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR); } void ShaderProgram::UseProgram(const gfx::Size& src_size, diff --git a/content/common/gpu/media/vp9_decoder.cc b/content/common/gpu/media/vp9_decoder.cc index c1adc84..7c25832 100644 --- a/content/common/gpu/media/vp9_decoder.cc +++ b/content/common/gpu/media/vp9_decoder.cc @@ -138,7 +138,8 @@ VP9Decoder::DecodeResult VP9Decoder::Decode() { void VP9Decoder::RefreshReferenceFrames(const scoped_refptr<VP9Picture>& pic) { for (size_t i = 0; i < media::kVp9NumRefFrames; ++i) { - DCHECK(!pic->frame_hdr->IsKeyframe() || pic->frame_hdr->RefreshFlag(i)); + DCHECK_IMPLIES(pic->frame_hdr->IsKeyframe(), + pic->frame_hdr->RefreshFlag(i)); if (pic->frame_hdr->RefreshFlag(i)) ref_frames_[i] = pic; } diff --git a/content/renderer/gpu/mailbox_output_surface.cc b/content/renderer/gpu/mailbox_output_surface.cc index a536f99..fe6bd6a 100644 --- a/content/renderer/gpu/mailbox_output_surface.cc +++ b/content/renderer/gpu/mailbox_output_surface.cc @@ -200,9 +200,9 @@ void MailboxOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { DCHECK(!surface_size_.IsEmpty()); DCHECK(surface_size_ == current_backing_.size); DCHECK(frame->gl_frame_data->size == current_backing_.size); - DCHECK(!current_backing_.mailbox.IsZero() || - context_provider_->ContextGL()->GetGraphicsResetStatusKHR() != - GL_NO_ERROR); + DCHECK_IMPLIES(current_backing_.mailbox.IsZero(), + context_provider_->ContextGL()->GetGraphicsResetStatusKHR() != + GL_NO_ERROR); frame->gl_frame_data->mailbox = current_backing_.mailbox; context_provider_->ContextGL()->Flush(); diff --git a/content/renderer/input/input_handler_proxy.cc b/content/renderer/input/input_handler_proxy.cc index 255492f..d4d3268 100644 --- a/content/renderer/input/input_handler_proxy.cc +++ b/content/renderer/input/input_handler_proxy.cc @@ -757,8 +757,8 @@ void InputHandlerProxy::ExtendBoostedFlingTimeout( void InputHandlerProxy::Animate(base::TimeTicks time) { // If using synchronous animate, then only expect Animate attempts started by // the synchronous system. Don't let the InputHandler try to Animate also. - DCHECK(!input_handler_->IsCurrentlyScrollingInnerViewport() || - allow_root_animate_); + DCHECK_IMPLIES(input_handler_->IsCurrentlyScrollingInnerViewport(), + allow_root_animate_); if (scroll_elasticity_controller_) scroll_elasticity_controller_->Animate(time); diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 9172453..255684a 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -644,7 +644,7 @@ void RenderFrameImpl::CreateFrame( replicated_state.sandbox_flags); } render_frame->SetWebFrame(web_frame); - CHECK(parent_routing_id != MSG_ROUTING_NONE || !web_frame->parent()); + CHECK_IMPLIES(parent_routing_id == MSG_ROUTING_NONE, !web_frame->parent()); WebFrame* opener = ResolveOpener(opener_routing_id, nullptr); web_frame->setOpener(opener); @@ -1256,7 +1256,8 @@ void RenderFrameImpl::OnSwapOut( SiteIsolationPolicy::IsSwappedOutStateForbidden(); // This codepath should only be hit for subframes when in --site-per-process. - CHECK(is_main_frame_ || SiteIsolationPolicy::AreCrossProcessFramesPossible()); + CHECK_IMPLIES(!is_main_frame_, + SiteIsolationPolicy::AreCrossProcessFramesPossible()); // Only run unload if we're not swapped out yet, but send the ack either way. if (!is_swapped_out_) { @@ -2676,7 +2677,7 @@ void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame, DocumentState* document_state = DocumentState::FromDataSource(ds); // We should only navigate to swappedout:// when is_swapped_out_ is true. - CHECK(ds->request().url() != GURL(kSwappedOutURL) || is_swapped_out_) + CHECK_IMPLIES(ds->request().url() == GURL(kSwappedOutURL), is_swapped_out_) << "Heard swappedout:// when not swapped out."; // Update the request time if WebKit has better knowledge of it. @@ -2842,8 +2843,9 @@ void RenderFrameImpl::didCommitProvisionalLoad( // SendUpdateState and update page_id_ even in this case, so that // the current entry gets a state update and so that we don't send a // state update to the wrong entry when we swap back in. - DCHECK(!navigation_state->common_params().should_replace_current_entry || - render_view_->history_list_length_ > 0); + DCHECK_IMPLIES( + navigation_state->common_params().should_replace_current_entry, + render_view_->history_list_length_ > 0); if (GetLoadingUrl() != GURL(kSwappedOutURL) && !navigation_state->common_params().should_replace_current_entry) { // Advance our offset in session history, applying the length limit. @@ -5007,12 +5009,12 @@ void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request) { GetFetchCredentialsModeForWebURLRequest(*request)); DCHECK(GetFetchRedirectModeForWebURLRequest(*request) == FetchRedirectMode::MANUAL_MODE); - DCHECK(frame_->parent() || - GetRequestContextFrameTypeForWebURLRequest(*request) == - REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); - DCHECK(!frame_->parent() || - GetRequestContextFrameTypeForWebURLRequest(*request) == - REQUEST_CONTEXT_FRAME_TYPE_NESTED); + DCHECK_IMPLIES(!frame_->parent(), + GetRequestContextFrameTypeForWebURLRequest(*request) == + REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); + DCHECK_IMPLIES(frame_->parent(), + GetRequestContextFrameTypeForWebURLRequest(*request) == + REQUEST_CONTEXT_FRAME_TYPE_NESTED); Send(new FrameHostMsg_BeginNavigation( routing_id_, diff --git a/content/test/test_render_frame_host.cc b/content/test/test_render_frame_host.cc index e785d0a..0c89a13 100644 --- a/content/test/test_render_frame_host.cc +++ b/content/test/test_render_frame_host.cc @@ -321,8 +321,9 @@ void TestRenderFrameHost::NavigateAndCommitRendererInitiated( bool browser_side_navigation = base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableBrowserSideNavigation); - CHECK(!browser_side_navigation || is_loading()); - CHECK(!browser_side_navigation || !frame_tree_node()->navigation_request()); + CHECK_IMPLIES(browser_side_navigation, is_loading()); + CHECK_IMPLIES(browser_side_navigation, + !frame_tree_node()->navigation_request()); SendNavigate(page_id, 0, did_create_new_entry, url); } @@ -396,8 +397,8 @@ void TestRenderFrameHost::PrepareForCommitWithServerRedirect( int32 TestRenderFrameHost::ComputeNextPageID() { const NavigationEntryImpl* entry = static_cast<NavigationEntryImpl*>( frame_tree_node()->navigator()->GetController()->GetPendingEntry()); - DCHECK(!(entry && entry->site_instance()) || - entry->site_instance() == GetSiteInstance()); + DCHECK_IMPLIES(entry && entry->site_instance(), + entry->site_instance() == GetSiteInstance()); // Entry can be null when committing an error page (the pending entry was // cleared during DidFailProvisionalLoad). int page_id = entry ? entry->GetPageID() : -1; diff --git a/content/test/test_web_contents.cc b/content/test/test_web_contents.cc index 59ef7a5..e69d806 100644 --- a/content/test/test_web_contents.cc +++ b/content/test/test_web_contents.cc @@ -226,9 +226,9 @@ void TestWebContents::CommitPendingNavigation() { TestRenderFrameHost* rfh = GetPendingMainFrame(); if (!rfh) rfh = old_rfh; - CHECK(!browser_side_navigation || rfh->is_loading()); - CHECK(!browser_side_navigation || - !rfh->frame_tree_node()->navigation_request()); + CHECK_IMPLIES(browser_side_navigation, rfh->is_loading()); + CHECK_IMPLIES(browser_side_navigation, + !rfh->frame_tree_node()->navigation_request()); int page_id = entry->GetPageID(); if (page_id == -1) { diff --git a/content/test/web_contents_observer_sanity_checker.cc b/content/test/web_contents_observer_sanity_checker.cc index 1935d2e..2754dde 100644 --- a/content/test/web_contents_observer_sanity_checker.cc +++ b/content/test/web_contents_observer_sanity_checker.cc @@ -157,16 +157,16 @@ void WebContentsObserverSanityChecker::DidFinishNavigation( NavigationHandle* navigation_handle) { CHECK(NavigationIsOngoing(navigation_handle)); - CHECK(!(navigation_handle->HasCommitted() && - !navigation_handle->IsErrorPage()) || - navigation_handle->GetNetErrorCode() == net::OK); - CHECK(!(navigation_handle->HasCommitted() && - navigation_handle->IsErrorPage()) || - navigation_handle->GetNetErrorCode() != net::OK); + CHECK_IMPLIES( + navigation_handle->HasCommitted() && !navigation_handle->IsErrorPage(), + navigation_handle->GetNetErrorCode() == net::OK); + CHECK_IMPLIES( + navigation_handle->HasCommitted() && navigation_handle->IsErrorPage(), + navigation_handle->GetNetErrorCode() != net::OK); CHECK_EQ(navigation_handle->GetWebContents(), web_contents()); - CHECK(!navigation_handle->HasCommitted() || - navigation_handle->GetRenderFrameHost() != nullptr); + CHECK_IMPLIES(navigation_handle->HasCommitted(), + navigation_handle->GetRenderFrameHost() != nullptr); ongoing_navigations_.erase(navigation_handle); } diff --git a/gpu/command_buffer/service/mailbox_manager_sync.cc b/gpu/command_buffer/service/mailbox_manager_sync.cc index 94aa1d7..a48d032 100644 --- a/gpu/command_buffer/service/mailbox_manager_sync.cc +++ b/gpu/command_buffer/service/mailbox_manager_sync.cc @@ -287,7 +287,7 @@ void MailboxManagerSync::UpdateDefinitionLocked( if (definition.Matches(texture)) return; - DCHECK(!image || image_buffer.get()); + DCHECK_IMPLIES(image, image_buffer.get()); if (image && !image_buffer->IsClient(image)) { LOG(ERROR) << "MailboxSync: Incompatible attachment"; return; diff --git a/gpu/command_buffer/service/texture_definition.cc b/gpu/command_buffer/service/texture_definition.cc index 3f16e85..ad9fe8a 100644 --- a/gpu/command_buffer/service/texture_definition.cc +++ b/gpu/command_buffer/service/texture_definition.cc @@ -334,7 +334,7 @@ TextureDefinition::TextureDefinition( usage_(texture->usage()), immutable_(texture->IsImmutable()), defined_(texture->IsDefined()) { - DCHECK(!image_buffer_.get() || defined_); + DCHECK_IMPLIES(image_buffer_.get(), defined_); if (!image_buffer_.get() && defined_) { image_buffer_ = NativeImageBuffer::Create(texture->service_id()); DCHECK(image_buffer_.get()); diff --git a/ui/aura/window.cc b/ui/aura/window.cc index 79ef0ce..c67c0a8 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -223,7 +223,7 @@ void Window::Show() { // It is not allowed that a window is visible but the layers alpha is fully // transparent since the window would still be considered to be active but // could not be seen. - DCHECK(!visible_ || layer()->GetTargetOpacity() > 0.0f); + DCHECK_IMPLIES(visible_, layer()->GetTargetOpacity() > 0.0f); SetVisible(true); } diff --git a/ui/events/blink/blink_event_util.cc b/ui/events/blink/blink_event_util.cc index 659adf3..4b19b3e 100644 --- a/ui/events/blink/blink_event_util.cc +++ b/ui/events/blink/blink_event_util.cc @@ -123,7 +123,7 @@ WebTouchPoint CreateWebTouchPoint(const MotionEvent& event, float minor_radius = event.GetTouchMinor(pointer_index) / 2.f; DCHECK_LE(minor_radius, major_radius); - DCHECK(!major_radius || minor_radius); + DCHECK_IMPLIES(major_radius, minor_radius); float orientation_deg = event.GetOrientation(pointer_index) * 180.f / M_PI; DCHECK_GE(major_radius, 0); diff --git a/ui/gl/gl_fence_egl.cc b/ui/gl/gl_fence_egl.cc index ce6583d..641b8c2 100644 --- a/ui/gl/gl_fence_egl.cc +++ b/ui/gl/gl_fence_egl.cc @@ -44,7 +44,8 @@ void GLFenceEGL::ClientWait() { EGLint flags = 0; EGLTimeKHR time = EGL_FOREVER_KHR; EGLint result = eglClientWaitSyncKHR(display_, sync_, flags, time); - DCHECK(g_ignore_egl_sync_failures || EGL_TIMEOUT_EXPIRED_KHR != result); + DCHECK_IMPLIES(!g_ignore_egl_sync_failures, + EGL_TIMEOUT_EXPIRED_KHR != result); if (result == EGL_FALSE) { LOG(ERROR) << "Failed to wait for EGLSync. error:" << ui::GetLastEGLErrorString(); diff --git a/ui/gl/gl_image_memory.cc b/ui/gl/gl_image_memory.cc index 2ced365..ad1e6b9 100644 --- a/ui/gl/gl_image_memory.cc +++ b/ui/gl/gl_image_memory.cc @@ -258,8 +258,8 @@ bool GLImageMemory::Initialize(const unsigned char* memory, DCHECK(memory); DCHECK(!memory_); - DCHECK(!IsCompressedFormat(format) || size_.width() % 4 == 0); - DCHECK(!IsCompressedFormat(format) || size_.height() % 4 == 0); + DCHECK_IMPLIES(IsCompressedFormat(format), size_.width() % 4 == 0); + DCHECK_IMPLIES(IsCompressedFormat(format), size_.height() % 4 == 0); memory_ = memory; format_ = format; return true; diff --git a/ui/views/touchui/touch_selection_menu_runner_views.cc b/ui/views/touchui/touch_selection_menu_runner_views.cc index 55b532c..6f44e52 100644 --- a/ui/views/touchui/touch_selection_menu_runner_views.cc +++ b/ui/views/touchui/touch_selection_menu_runner_views.cc @@ -195,7 +195,7 @@ void TouchSelectionMenuRunnerViews::Menu::OnPaint(gfx::Canvas* canvas) { } void TouchSelectionMenuRunnerViews::Menu::WindowClosing() { - DCHECK(!owner_ || owner_->menu_ == this); + DCHECK_IMPLIES(owner_, owner_->menu_ == this); BubbleDelegateView::WindowClosing(); if (owner_) owner_->menu_ = nullptr; diff --git a/ui/views/view.cc b/ui/views/view.cc index 0fc7559..6378432 100644 --- a/ui/views/view.cc +++ b/ui/views/view.cc @@ -742,7 +742,7 @@ void View::Paint(const ui::PaintContext& parent_context) { if (!layer()) { // If the View has a layer() then it is a paint root. Otherwise, we need to // add the offset from the parent into the total offset from the paint root. - DCHECK(parent() || bounds().origin() == gfx::Point()); + DCHECK_IMPLIES(!parent(), bounds().origin() == gfx::Point()); offset_to_parent = GetMirroredPosition().OffsetFromOrigin(); } ui::PaintContext context(parent_context, offset_to_parent); |