diff --git a/DEPS b/DEPS index 1db8453b..908515a505 100644 --- a/DEPS +++ b/DEPS
@@ -63,7 +63,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. - 'v8_revision': 'ea01f412c74e35d547b39bedebf5d0338fb060e4', + 'v8_revision': '92b9b498543f7bb6d07fdf18bf8f1f479c57d89a', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling swarming_client # and whatever else without interference from each other.
diff --git a/ash/message_center/message_center_view.cc b/ash/message_center/message_center_view.cc index 2f8db9cf..0f2584cd 100644 --- a/ash/message_center/message_center_view.cc +++ b/ash/message_center/message_center_view.cc
@@ -533,11 +533,10 @@ MessageView* view = message_center::MessageViewFactory::Create( this, notification, false); // Not top-level. - // TODO(yoshiki): Temporary disable context menu on custom notifications. - // See crbug.com/750307 for detail. + // TODO(yoshiki): Temporarily disable context menu on custom (arc) + // notifications. See crbug.com/750307 for details. if (notification.type() != message_center::NOTIFICATION_TYPE_CUSTOM && - notification.delegate() && - notification.delegate()->ShouldDisplaySettingsButton()) { + notification.should_show_settings_button()) { view->set_context_menu_controller(&context_menu_controller_); }
diff --git a/ash/rotator/screen_rotation_animator.cc b/ash/rotator/screen_rotation_animator.cc index d49f367..da752d63 100644 --- a/ash/rotator/screen_rotation_animator.cc +++ b/ash/rotator/screen_rotation_animator.cc
@@ -443,9 +443,9 @@ new ui::CallbackLayerAnimationObserver( base::Bind(&AnimationEndedCallback, weak_factory_.GetWeakPtr())); if (new_layer_tree_owner_) - new_layer_animator->AddObserver(observer); + new_layer_animation_sequence->AddObserver(observer); new_layer_animator->StartAnimation(new_layer_animation_sequence.release()); - old_layer_animator->AddObserver(observer); + old_layer_animation_sequence->AddObserver(observer); old_layer_animator->StartAnimation(old_layer_animation_sequence.release()); observer->SetActive(); }
diff --git a/ash/sticky_keys/sticky_keys_overlay.cc b/ash/sticky_keys/sticky_keys_overlay.cc index d4ff9bc..fbdffd2f 100644 --- a/ash/sticky_keys/sticky_keys_overlay.cc +++ b/ash/sticky_keys/sticky_keys_overlay.cc
@@ -226,12 +226,7 @@ StickyKeysOverlay::~StickyKeysOverlay() { // Remove ourself from the animator to avoid being re-entrantly called in // |overlay_widget_|'s destructor. - ui::Layer* layer = overlay_widget_->GetLayer(); - if (layer) { - ui::LayerAnimator* animator = layer->GetAnimator(); - if (animator) - animator->RemoveObserver(this); - } + StopObservingImplicitAnimations(); } void StickyKeysOverlay::Show(bool visible) { @@ -244,7 +239,6 @@ overlay_widget_->SetBounds(CalculateOverlayBounds()); ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator(); - animator->AddObserver(this); // Ensure transform is correct before beginning animation. if (!animator->is_animating()) { @@ -256,6 +250,7 @@ } ui::ScopedLayerAnimationSettings settings(animator); + settings.AddObserver(this); settings.SetPreemptionStrategy( ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); settings.SetTweenType(visible ? gfx::Tween::EASE_OUT : gfx::Tween::EASE_IN); @@ -293,23 +288,13 @@ return gfx::Rect(gfx::Point(x, kVerticalOverlayOffset), widget_size_); } -void StickyKeysOverlay::OnLayerAnimationEnded( - ui::LayerAnimationSequence* sequence) { - ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator(); - if (animator) - animator->RemoveObserver(this); +void StickyKeysOverlay::OnImplicitAnimationsCompleted() { + if (WasAnimationAbortedForProperty(ui::LayerAnimationElement::TRANSFORM)) + return; + DCHECK( + WasAnimationCompletedForProperty(ui::LayerAnimationElement::TRANSFORM)); if (!is_visible_) overlay_widget_->Hide(); } -void StickyKeysOverlay::OnLayerAnimationAborted( - ui::LayerAnimationSequence* sequence) { - ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator(); - if (animator) - animator->RemoveObserver(this); -} - -void StickyKeysOverlay::OnLayerAnimationScheduled( - ui::LayerAnimationSequence* sequence) {} - } // namespace ash
diff --git a/ash/sticky_keys/sticky_keys_overlay.h b/ash/sticky_keys/sticky_keys_overlay.h index ebfef90..d6577c7 100644 --- a/ash/sticky_keys/sticky_keys_overlay.h +++ b/ash/sticky_keys/sticky_keys_overlay.h
@@ -29,7 +29,7 @@ // use of modifier keys without holding them down. This overlay will appear as // a transparent window on the top left of the screen, showing the state of // each sticky key modifier. -class ASH_EXPORT StickyKeysOverlay : public ui::LayerAnimationObserver { +class ASH_EXPORT StickyKeysOverlay : public ui::ImplicitAnimationObserver { public: StickyKeysOverlay(); ~StickyKeysOverlay() override; @@ -59,10 +59,8 @@ // Returns the current bounds of the overlay, which is based on visibility. gfx::Rect CalculateOverlayBounds(); - // gfx::LayerAnimationObserver overrides: - void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override; - void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override; - void OnLayerAnimationScheduled(ui::LayerAnimationSequence* sequence) override; + // ui::ImplicitAnimationObserver: + void OnImplicitAnimationsCompleted() override; bool is_visible_; std::unique_ptr<views::Widget> overlay_widget_;
diff --git a/ash/wm/overview/window_selector_item.cc b/ash/wm/overview/window_selector_item.cc index 61e4546..2b6f880 100644 --- a/ash/wm/overview/window_selector_item.cc +++ b/ash/wm/overview/window_selector_item.cc
@@ -27,6 +27,7 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/compositor/layer_animation_sequence.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h" +#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/gfx/animation/slide_animation.h" #include "ui/gfx/canvas.h" #include "ui/gfx/color_utils.h" @@ -232,7 +233,7 @@ class WindowSelectorItem::RoundedContainerView : public views::View, public gfx::AnimationDelegate, - public ui::LayerAnimationObserver { + public ui::ImplicitAnimationObserver { public: RoundedContainerView(WindowSelectorItem* item, aura::Window* item_window, @@ -244,36 +245,18 @@ initial_color_(background), target_color_(background), current_value_(0), - layer_(nullptr), animation_(new gfx::SlideAnimation(this)) { SetPaintToLayer(); layer()->SetFillsBoundsOpaquely(false); } - ~RoundedContainerView() override { StopObservingLayerAnimations(); } + ~RoundedContainerView() override { StopObservingImplicitAnimations(); } void OnItemRestored() { item_ = nullptr; item_window_ = nullptr; } - // Starts observing layer animations so that actions can be taken when - // particular animations (opacity) complete. It should only be called once - // when the initial fade in animation is started. - void ObserveLayerAnimations(ui::Layer* layer) { - DCHECK(!layer_); - layer_ = layer; - layer_->GetAnimator()->AddObserver(this); - } - - // Stops observing layer animations - void StopObservingLayerAnimations() { - if (!layer_) - return; - layer_->GetAnimator()->RemoveObserver(this); - layer_ = nullptr; - } - // Used by tests to set animation state. gfx::SlideAnimation* animation() { return animation_.get(); } @@ -288,7 +271,6 @@ // and from |kLabelBackgroundColor| back to the original window header color // on exit from the overview mode. void AnimateColor(gfx::Tween::Type tween_type, int duration) { - DCHECK(!layer_); // layer animations should be completed. animation_->SetSlideDuration(duration); animation_->SetTweenType(tween_type); animation_->Reset(0); @@ -361,34 +343,28 @@ SchedulePaint(); } - // ui::LayerAnimationObserver: - void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override { - if (0 != (sequence->properties() & - ui::LayerAnimationElement::AnimatableProperty::OPACITY)) { - if (item_) - item_->HideHeader(); - StopObservingLayerAnimations(); - AnimateColor(gfx::Tween::EASE_IN, kSelectorColorSlideMilliseconds); + // ui::ImplicitAnimationObserver: + void OnImplicitAnimationsCompleted() override { + // Return if the fade in animation of |item_->item_widget_| was aborted. + if (WasAnimationAbortedForProperty( + ui::LayerAnimationElement::AnimatableProperty::OPACITY)) { + return; } - } + DCHECK(WasAnimationCompletedForProperty( + ui::LayerAnimationElement::AnimatableProperty::OPACITY)); - void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override { - if (0 != (sequence->properties() & - ui::LayerAnimationElement::AnimatableProperty::OPACITY)) { - StopObservingLayerAnimations(); - } + // Otherwise, hide the header and animate the color of this view. + if (item_) + item_->HideHeader(); + AnimateColor(gfx::Tween::EASE_IN, kSelectorColorSlideMilliseconds); } - void OnLayerAnimationScheduled( - ui::LayerAnimationSequence* sequence) override {} - WindowSelectorItem* item_; aura::Window* item_window_; int corner_radius_; SkColor initial_color_; SkColor target_color_; int current_value_; - ui::Layer* layer_; std::unique_ptr<gfx::SlideAnimation> animation_; DISALLOW_COPY_AND_ASSIGN(RoundedContainerView); @@ -748,27 +724,30 @@ (mode != HeaderFadeInMode::ENTER || transform_window_.GetTopInset()) ? -label_rect.height() : 0); - if (background_view_) { - if (mode == HeaderFadeInMode::ENTER) { - background_view_->ObserveLayerAnimations(item_widget_->GetLayer()); - background_view_->set_color(kLabelBackgroundColor); - // The color will be animated only once the label widget is faded in. - } else if (mode == HeaderFadeInMode::EXIT) { - // Normally the observer is disconnected when the fade-in animations - // complete but some tests invoke animations with |NON_ZERO_DURATION| - // without waiting for completion so do it here. - background_view_->StopObservingLayerAnimations(); - // Make the header visible above the window. It will be faded out when - // the Shutdown() is called. - background_view_->AnimateColor(gfx::Tween::EASE_OUT, - kExitFadeInMilliseconds); - background_view_->set_color(kLabelExitColor); + + { + ui::ScopedLayerAnimationSettings layer_animation_settings( + item_widget_->GetLayer()->GetAnimator()); + if (background_view_) { + if (mode == HeaderFadeInMode::ENTER) { + // Animate the color of |background_view_| once the fade in animation of + // |item_widget_| ends. + layer_animation_settings.AddObserver(background_view_); + background_view_->set_color(kLabelBackgroundColor); + } else if (mode == HeaderFadeInMode::EXIT) { + // Make the header visible above the window. It will be faded out when + // the Shutdown() is called. + background_view_->AnimateColor(gfx::Tween::EASE_OUT, + kExitFadeInMilliseconds); + background_view_->set_color(kLabelExitColor); + } + } + if (!label_view_->visible()) { + label_view_->SetVisible(true); + SetupFadeInAfterLayout(item_widget_.get()); } } - if (!label_view_->visible()) { - label_view_->SetVisible(true); - SetupFadeInAfterLayout(item_widget_.get()); - } + aura::Window* widget_window = item_widget_->GetNativeWindow(); ScopedOverviewAnimationSettings animation_settings(animation_type, widget_window);
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/crash/PureJavaExceptionReporter.java b/chrome/android/java/src/org/chromium/chrome/browser/crash/PureJavaExceptionReporter.java index 07c0699..5342fc04 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/crash/PureJavaExceptionReporter.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/crash/PureJavaExceptionReporter.java
@@ -27,7 +27,7 @@ @MainDex public class PureJavaExceptionReporter { // report fields, please keep the name sync with MIME blocks in breakpad_linux.cc - public static final String CHANNEL = "Channel"; + public static final String CHANNEL = "channel"; public static final String VERSION = "ver"; public static final String PRODUCT = "prod"; public static final String ANDROID_BUILD_ID = "android_build_id";
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java index 1f61a7f..2d847a7 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java
@@ -428,6 +428,9 @@ } if (TextUtils.equals(item.getId(), wrapper.getId())) { view.displayItem(mBackendProvider, existingWrapper); + if (item.getDownloadInfo().state() == DownloadState.COMPLETE) { + mSpaceDisplay.onChanged(); + } } } @@ -829,6 +832,9 @@ for (DownloadItemView view : mViews) { if (TextUtils.equals(item.id.id, view.getItem().getId())) { view.displayItem(mBackendProvider, existingWrapper); + if (item.state == OfflineItemState.COMPLETE) { + mSpaceDisplay.onChanged(); + } } }
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/privacy/BrowsingDataBridgeTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/privacy/BrowsingDataBridgeTest.java index 00e3bec6..8e5cbd3 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/privacy/BrowsingDataBridgeTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/privacy/BrowsingDataBridgeTest.java
@@ -100,7 +100,8 @@ assertThat(mActionTester.toString(), getActions(), Matchers.containsInAnyOrder("ClearBrowsingData_LastHour", "ClearBrowsingData_MaskContainsUnprotectedWeb", - "ClearBrowsingData_ChannelIDs", "ClearBrowsingData_Cookies")); + "ClearBrowsingData_ChannelIDs", "ClearBrowsingData_Cookies", + "ClearBrowsingData_SiteUsageData")); } /** @@ -212,6 +213,6 @@ "ClearBrowsingData_ShaderCache", "ClearBrowsingData_Cookies", "ClearBrowsingData_ChannelIDs", "ClearBrowsingData_Autofill", "ClearBrowsingData_History", "ClearBrowsingData_Passwords", - "ClearBrowsingData_ContentSettings")); + "ClearBrowsingData_ContentSettings", "ClearBrowsingData_SiteUsageData")); } -} \ No newline at end of file +}
diff --git a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc index 9d91b57b..5fa98ff9 100644 --- a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc +++ b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc
@@ -456,6 +456,9 @@ (!(remove_mask & DATA_TYPE_HISTORY) && !(remove_mask & content::BrowsingDataRemover::DATA_TYPE_DOWNLOADS))); + HostContentSettingsMap* host_content_settings_map_ = + HostContentSettingsMapFactory::GetForProfile(profile_); + ////////////////////////////////////////////////////////////////////////////// // DATA_TYPE_HISTORY if ((remove_mask & DATA_TYPE_HISTORY) && may_delete_history) { @@ -696,10 +699,9 @@ content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB)) { base::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); - HostContentSettingsMapFactory::GetForProfile(profile_) - ->ClearSettingsForOneTypeWithPredicate( - CONTENT_SETTINGS_TYPE_CLIENT_HINTS, base::Time(), - base::Bind(&WebsiteSettingsFilterAdapter, filter)); + host_content_settings_map_->ClearSettingsForOneTypeWithPredicate( + CONTENT_SETTINGS_TYPE_CLIENT_HINTS, base::Time(), + base::Bind(&WebsiteSettingsFilterAdapter, filter)); // Clear the safebrowsing cookies only if time period is for "all time". It // doesn't make sense to apply the time period of deleting in the last X @@ -744,9 +746,8 @@ base::RecordAction(UserMetricsAction("ClearBrowsingData_ContentSettings")); const auto* registry = content_settings::ContentSettingsRegistry::GetInstance(); - auto* map = HostContentSettingsMapFactory::GetForProfile(profile_); for (const content_settings::ContentSettingsInfo* info : *registry) { - map->ClearSettingsForOneTypeWithPredicate( + host_content_settings_map_->ClearSettingsForOneTypeWithPredicate( info->website_settings_info()->type(), delete_begin_, HostContentSettingsMap::PatternSourcePredicate()); } @@ -760,35 +761,31 @@ ////////////////////////////////////////////////////////////////////////////// // DATA_TYPE_DURABLE_PERMISSION if (remove_mask & DATA_TYPE_DURABLE_PERMISSION) { - HostContentSettingsMapFactory::GetForProfile(profile_) - ->ClearSettingsForOneTypeWithPredicate( - CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, base::Time(), - base::Bind(&WebsiteSettingsFilterAdapter, filter)); - } - - ////////////////////////////////////////////////////////////////////////////// - // Media Engagement - if (remove_mask & DATA_TYPE_SITE_USAGE_DATA && - MediaEngagementService::IsEnabled()) { - MediaEngagementService::Get(profile_)->ClearDataBetweenTime(delete_begin_, - delete_end_); + host_content_settings_map_->ClearSettingsForOneTypeWithPredicate( + CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, base::Time(), + base::Bind(&WebsiteSettingsFilterAdapter, filter)); } ////////////////////////////////////////////////////////////////////////////// // DATA_TYPE_SITE_USAGE_DATA if (remove_mask & DATA_TYPE_SITE_USAGE_DATA) { - HostContentSettingsMapFactory::GetForProfile(profile_) - ->ClearSettingsForOneTypeWithPredicate( - CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, base::Time(), - base::Bind(&WebsiteSettingsFilterAdapter, filter)); + base::RecordAction(UserMetricsAction("ClearBrowsingData_SiteUsageData")); + + host_content_settings_map_->ClearSettingsForOneTypeWithPredicate( + CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, base::Time(), + base::Bind(&WebsiteSettingsFilterAdapter, filter)); + + if (MediaEngagementService::IsEnabled()) { + MediaEngagementService::Get(profile_)->ClearDataBetweenTime(delete_begin_, + delete_end_); + } } if ((remove_mask & DATA_TYPE_SITE_USAGE_DATA) || (remove_mask & DATA_TYPE_HISTORY)) { - HostContentSettingsMapFactory::GetForProfile(profile_) - ->ClearSettingsForOneTypeWithPredicate( - CONTENT_SETTINGS_TYPE_APP_BANNER, base::Time(), - base::Bind(&WebsiteSettingsFilterAdapter, filter)); + host_content_settings_map_->ClearSettingsForOneTypeWithPredicate( + CONTENT_SETTINGS_TYPE_APP_BANNER, base::Time(), + base::Bind(&WebsiteSettingsFilterAdapter, filter)); PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveCountsByUrl( filter);
diff --git a/chrome/browser/media/media_engagement_service.cc b/chrome/browser/media/media_engagement_service.cc index 22d5d82..a0ef8d042 100644 --- a/chrome/browser/media/media_engagement_service.cc +++ b/chrome/browser/media/media_engagement_service.cc
@@ -22,8 +22,18 @@ #include "content/public/browser/web_contents.h" #include "media/base/media_switches.h" +const char MediaEngagementService::kHistogramScoreAtStartupName[] = + "Media.Engagement.ScoreAtStartup"; + +const char MediaEngagementService::kHistogramURLsDeletedScoreReductionName[] = + "Media.Engagement.URLsDeletedScoreReduction"; + namespace { +// The current schema version of the MEI data. If this value is higher +// than the stored value, all MEI data will be wiped. +static const int kSchemaVersion = 3; + // Returns the combined list of origins which have media engagement data. std::set<GURL> GetEngagementOriginsFromContentSettings(Profile* profile) { ContentSettingsForOneType content_settings; @@ -61,15 +71,17 @@ return playback_time >= delete_begin && playback_time <= delete_end; } -// The current schema version of the MEI data. If this value is higher -// than the stored value, all MEI data will be wiped. -static const int kSchemaVersion = 3; +void RecordURLsDeletedScoreReduction(double previous_score, + double current_score) { + int difference = round((previous_score * 100) - (current_score * 100)); + DCHECK_GE(difference, 0); + UMA_HISTOGRAM_PERCENTAGE( + MediaEngagementService::kHistogramURLsDeletedScoreReductionName, + difference); +} } // namespace -const char MediaEngagementService::kHistogramScoreAtStartupName[] = - "Media.Engagement.ScoreAtStartup"; - // static bool MediaEngagementService::IsEnabled() { return base::FeatureList::IsEnabled(media::kRecordMediaEngagementScores); @@ -189,6 +201,8 @@ // If this results in zero visits then clear the score. if (score.visits() <= 0) { + // Score is now set to 0 so the reduction is equal to the original score. + RecordURLsDeletedScoreReduction(original_score, 0); Clear(kv.first); continue; } @@ -197,6 +211,8 @@ // MEI score consistent. score.SetMediaPlaybacks(original_score * score.visits()); score.Commit(); + + RecordURLsDeletedScoreReduction(original_score, score.actual_score()); } }
diff --git a/chrome/browser/media/media_engagement_service.h b/chrome/browser/media/media_engagement_service.h index f0f5e46..ad7e7108 100644 --- a/chrome/browser/media/media_engagement_service.h +++ b/chrome/browser/media/media_engagement_service.h
@@ -92,6 +92,10 @@ // The name of the histogram that scores are logged to on startup. static const char kHistogramScoreAtStartupName[]; + // The name of the histogram that records the reduction in score when history + // is cleared. + static const char kHistogramURLsDeletedScoreReductionName[]; + private: friend class MediaEngagementBrowserTest; friend class MediaEngagementServiceTest;
diff --git a/chrome/browser/media/media_engagement_service_unittest.cc b/chrome/browser/media/media_engagement_service_unittest.cc index 91aa8ed8..e5e4782 100644 --- a/chrome/browser/media/media_engagement_service_unittest.cc +++ b/chrome/browser/media/media_engagement_service_unittest.cc
@@ -347,6 +347,7 @@ EXPECT_TRUE(GetActualScore(origin4)); { + base::HistogramTester histogram_tester; MediaEngagementChangeWaiter waiter(profile()); base::CancelableTaskTracker task_tracker; @@ -369,9 +370,17 @@ ExpectScores(origin3, 0.0, 1, 0, TimeNotSet()); ExpectScores(origin4, 0.4, MediaEngagementScore::GetScoreMinVisits(), 2, TimeNotSet()); + + histogram_tester.ExpectTotalCount( + MediaEngagementService::kHistogramURLsDeletedScoreReductionName, 3); + histogram_tester.ExpectBucketCount( + MediaEngagementService::kHistogramURLsDeletedScoreReductionName, 0, 2); + histogram_tester.ExpectBucketCount( + MediaEngagementService::kHistogramURLsDeletedScoreReductionName, 8, 1); } { + base::HistogramTester histogram_tester; MediaEngagementChangeWaiter waiter(profile()); // Expire origin1b. @@ -393,9 +402,15 @@ ExpectScores(origin3, 0.0, 1, 0, TimeNotSet()); ExpectScores(origin4, 0.4, MediaEngagementScore::GetScoreMinVisits(), 2, TimeNotSet()); + + histogram_tester.ExpectTotalCount( + MediaEngagementService::kHistogramURLsDeletedScoreReductionName, 1); + histogram_tester.ExpectBucketCount( + MediaEngagementService::kHistogramURLsDeletedScoreReductionName, 17, 1); } { + base::HistogramTester histogram_tester; MediaEngagementChangeWaiter waiter(profile()); // Expire origin3. @@ -419,6 +434,11 @@ ExpectScores(origin3, 0.0, 0, 0, TimeNotSet()); ExpectScores(origin4, 0.4, MediaEngagementScore::GetScoreMinVisits(), 2, TimeNotSet()); + + histogram_tester.ExpectTotalCount( + MediaEngagementService::kHistogramURLsDeletedScoreReductionName, 1); + histogram_tester.ExpectBucketCount( + MediaEngagementService::kHistogramURLsDeletedScoreReductionName, 0, 1); } }
diff --git a/chrome/browser/notifications/notification_platform_bridge_linux.cc b/chrome/browser/notifications/notification_platform_bridge_linux.cc index 1c32d79ba..bc38a7e 100644 --- a/chrome/browser/notifications/notification_platform_bridge_linux.cc +++ b/chrome/browser/notifications/notification_platform_bridge_linux.cc
@@ -622,12 +622,10 @@ actions.push_back(id); actions.push_back(label); } - if (notification->clickable()) { - // Special case: the pair ("default", "") will not add a button, - // but instead makes the entire notification clickable. - actions.push_back(kDefaultButtonId); - actions.push_back(""); - } + // Special case: the id "default" will not add a button, but + // instead makes the entire notification clickable. + actions.push_back(kDefaultButtonId); + actions.push_back("Activate"); // Always add a settings button for web notifications. if (notification_type != NotificationCommon::EXTENSION) { actions.push_back(kSettingsButtonId);
diff --git a/chrome/browser/notifications/platform_notification_service_impl.cc b/chrome/browser/notifications/platform_notification_service_impl.cc index e795e88a..2b1d694b7 100644 --- a/chrome/browser/notifications/platform_notification_service_impl.cc +++ b/chrome/browser/notifications/platform_notification_service_impl.cc
@@ -423,6 +423,15 @@ DCHECK_EQ(notification_data.actions.size(), notification_resources.action_icons.size()); + message_center::RichNotificationData optional_fields; +#if defined(OS_CHROMEOS) + optional_fields.settings_button_handler = + message_center::SettingsButtonHandler::TRAY; +#else + optional_fields.settings_button_handler = + message_center::SettingsButtonHandler::DELEGATE; +#endif + // TODO(peter): Handle different screen densities instead of always using the // 1x bitmap - crbug.com/585815. // TODO(estade): The RichNotificationData should set |clickable| if there's a @@ -432,7 +441,7 @@ notification_data.title, notification_data.body, gfx::Image::CreateFrom1xBitmap(notification_resources.notification_icon), base::UTF8ToUTF16(origin.host()), origin, NotifierId(origin), - message_center::RichNotificationData(), delegate); + optional_fields, delegate); notification.set_context_message( DisplayNameForContextMessage(profile, origin));
diff --git a/chrome/browser/notifications/platform_notification_service_interactive_uitest.cc b/chrome/browser/notifications/platform_notification_service_interactive_uitest.cc index ab83f56..44d66aa 100644 --- a/chrome/browser/notifications/platform_notification_service_interactive_uitest.cc +++ b/chrome/browser/notifications/platform_notification_service_interactive_uitest.cc
@@ -329,6 +329,8 @@ EXPECT_EQ(kIconHeight, all_options_notification.buttons()[0].icon.Height()); } +// Chrome OS shows the notification settings inline. +#if !defined(OS_CHROMEOS) IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, WebNotificationSiteSettingsButton) { ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); @@ -361,12 +363,10 @@ // No engagement should be granted for clicking on the settings link. EXPECT_DOUBLE_EQ(5.5, GetEngagementScore(origin)); -// Chrome OS shows the notification settings inline. -#if !defined(OS_CHROMEOS) std::string url = web_contents->GetLastCommittedURL().spec(); ASSERT_EQ("chrome://settings/content/notifications", url); -#endif } +#endif IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, WebNotificationOptionsVibrationPattern) {
diff --git a/chrome/browser/notifications/web_notification_delegate.cc b/chrome/browser/notifications/web_notification_delegate.cc index 67b432d..0232003 100644 --- a/chrome/browser/notifications/web_notification_delegate.cc +++ b/chrome/browser/notifications/web_notification_delegate.cc
@@ -25,19 +25,14 @@ WebNotificationDelegate::~WebNotificationDelegate() {} -bool WebNotificationDelegate::SettingsClick() { -#if !defined(OS_CHROMEOS) - NotificationCommon::OpenNotificationSettings(profile_); - return true; +void WebNotificationDelegate::SettingsClick() { +#if defined(OS_CHROMEOS) + NOTREACHED(); #else - return false; + NotificationCommon::OpenNotificationSettings(profile_); #endif } -bool WebNotificationDelegate::ShouldDisplaySettingsButton() { - return notification_type_ != NotificationCommon::EXTENSION; -} - void WebNotificationDelegate::DisableNotification() { DCHECK_NE(notification_type_, NotificationCommon::EXTENSION); DesktopNotificationProfileUtil::DenyPermission(profile_, origin_);
diff --git a/chrome/browser/notifications/web_notification_delegate.h b/chrome/browser/notifications/web_notification_delegate.h index 221bb860..bcd4da5 100644 --- a/chrome/browser/notifications/web_notification_delegate.h +++ b/chrome/browser/notifications/web_notification_delegate.h
@@ -30,8 +30,7 @@ const GURL& origin); // NotificationDelegate implementation. - bool SettingsClick() override; - bool ShouldDisplaySettingsButton() override; + void SettingsClick() override; void DisableNotification() override; bool ShouldDisplayOverFullscreen() const override; void Close(bool by_user) override;
diff --git a/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.cc b/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.cc index 0348314..8d0405a 100644 --- a/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.cc +++ b/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.cc
@@ -16,6 +16,7 @@ #include "ui/aura/client/aura_constants.h" #include "ui/compositor/layer_animation_observer.h" #include "ui/compositor/layer_tree_owner.h" +#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/display/display.h" #include "ui/wm/core/window_util.h" #include "ui/wm/public/activation_client.h" @@ -49,32 +50,16 @@ // window we encounter while looping through the old user's windows. This is // to observe the end of the animation so that we can destruct the old detached // layer of the window. -class MaximizedWindowAnimationWatcher : public ui::LayerAnimationObserver { +class MaximizedWindowAnimationWatcher : public ui::ImplicitAnimationObserver { public: - MaximizedWindowAnimationWatcher(ui::LayerAnimator* animator_to_watch, - ui::LayerTreeOwner* old_layer) - : animator_(animator_to_watch), old_layer_(old_layer) { - animator_->AddObserver(this); - } + explicit MaximizedWindowAnimationWatcher( + std::unique_ptr<ui::LayerTreeOwner> old_layer) + : old_layer_(std::move(old_layer)) {} - ~MaximizedWindowAnimationWatcher() override { - animator_->RemoveObserver(this); - } - - // ui::LayerAnimationObserver: - void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override { - delete this; - } - - void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override { - delete this; - } - - void OnLayerAnimationScheduled( - ui::LayerAnimationSequence* sequence) override {} + // ui::ImplicitAnimationObserver: + void OnImplicitAnimationsCompleted() override { delete this; } private: - ui::LayerAnimator* animator_; std::unique_ptr<ui::LayerTreeOwner> old_layer_; DISALLOW_COPY_AND_ASSIGN(MaximizedWindowAnimationWatcher); @@ -271,14 +256,20 @@ // We only want to do this for the first (foreground) maximized // window we encounter. found_foreground_maximized_window = true; - ui::LayerTreeOwner* old_layer = - wm::RecreateLayers(window).release(); + std::unique_ptr<ui::LayerTreeOwner> old_layer = + wm::RecreateLayers(window); window->layer()->parent()->StackAtBottom(old_layer->root()); - new MaximizedWindowAnimationWatcher(window->layer()->GetAnimator(), - old_layer); + ui::ScopedLayerAnimationSettings settings( + window->layer()->GetAnimator()); + settings.AddObserver( + new MaximizedWindowAnimationWatcher(std::move(old_layer))); + // Call SetWindowVisibility() within the scope of |settings| so that + // MaximizedWindowAnimationWatcher is notified when the animation + // completes. + owner_->SetWindowVisibility(window, false, duration); + } else { + owner_->SetWindowVisibility(window, false, duration); } - - owner_->SetWindowVisibility(window, false, duration); } }
diff --git a/chromeos/network/network_configuration_handler_unittest.cc b/chromeos/network/network_configuration_handler_unittest.cc index 68bd7cb..0df9a3d6 100644 --- a/chromeos/network/network_configuration_handler_unittest.cc +++ b/chromeos/network/network_configuration_handler_unittest.cc
@@ -18,6 +18,7 @@ #include "base/strings/string_piece.h" #include "base/values.h" #include "chromeos/dbus/dbus_thread_manager.h" +#include "chromeos/dbus/fake_shill_service_client.h" #include "chromeos/dbus/mock_shill_manager_client.h" #include "chromeos/dbus/mock_shill_profile_client.h" #include "chromeos/dbus/mock_shill_service_client.h" @@ -49,6 +50,17 @@ namespace { +// Copies the result of GetProperties(). +void CopyProperties(bool* called, + std::string* service_path_out, + base::Value* result_out, + const std::string& service_path, + const base::DictionaryValue& result) { + *called = true; + *service_path_out = service_path; + *result_out = result.Clone(); +} + static std::string PrettyJson(const base::DictionaryValue& value) { std::string pretty; base::JSONWriter::WriteWithOptions( @@ -84,12 +96,6 @@ EXPECT_EQ(expected_result, service_path); } -void DBusErrorCallback(const std::string& error_name, - const std::string& error_message) { - EXPECT_TRUE(false) << "DBus Error: " << error_name << "(" << error_message - << ")"; -} - class TestCallback { public: TestCallback() : run_count_(0) {} @@ -299,6 +305,11 @@ return true; } + FakeShillServiceClient* GetShillServiceClient() { + return static_cast<FakeShillServiceClient*>( + DBusThreadManager::Get()->GetShillServiceClient()); + } + std::unique_ptr<NetworkStateHandler> network_state_handler_; std::unique_ptr<NetworkConfigurationHandler> network_configuration_handler_; std::unique_ptr<TestNetworkStateHandlerObserver> @@ -469,33 +480,28 @@ property_changed_observers_; }; -TEST_F(NetworkConfigurationHandlerMockTest, GetProperties) { - std::string service_path = "/service/1"; - std::string expected_json = "{\n \"SSID\": \"MyNetwork\"\n}\n"; - std::string networkName = "MyNetwork"; - std::string key = "SSID"; - std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName)); +TEST_F(NetworkConfigurationHandlerTest, GetProperties) { + constexpr char kServicePath[] = "/service/1"; + constexpr char kNetworkName[] = "MyName"; + GetShillServiceClient()->AddService( + kServicePath, std::string() /* guid */, kNetworkName, shill::kTypeWifi, + std::string() /* state */, true /* visible */); - base::DictionaryValue value; - value.SetString(key, networkName); - dictionary_value_result_ = &value; - EXPECT_CALL(*mock_service_client_, - SetProperty(dbus::ObjectPath(service_path), key, - IsEqualTo(networkNameValue.get()), _, _)).Times(1); - mock_service_client_->SetProperty( - dbus::ObjectPath(service_path), key, *networkNameValue, - base::Bind(&base::DoNothing), base::Bind(&DBusErrorCallback)); - base::RunLoop().RunUntilIdle(); - - ShillServiceClient::DictionaryValueCallback get_properties_callback; - EXPECT_CALL(*mock_service_client_, GetProperties(_, _)) - .WillOnce( - Invoke(this, &NetworkConfigurationHandlerMockTest::OnGetProperties)); + bool success = false; + std::string service_path; + base::DictionaryValue result; network_configuration_handler_->GetShillProperties( - service_path, - base::Bind(&DictionaryValueCallback, service_path, expected_json), + kServicePath, + base::Bind(&CopyProperties, &success, &service_path, &result), base::Bind(&ErrorCallback)); base::RunLoop().RunUntilIdle(); + + ASSERT_TRUE(success); + EXPECT_EQ(kServicePath, service_path); + const base::Value* ssid = + result.FindKeyOfType(shill::kSSIDProperty, base::Value::Type::STRING); + ASSERT_TRUE(ssid); + EXPECT_EQ(kNetworkName, ssid->GetString()); } TEST_F(NetworkConfigurationHandlerMockTest, GetProperties_TetherNetwork) {
diff --git a/content/browser/blob_storage/blob_url_loader_factory.cc b/content/browser/blob_storage/blob_url_loader_factory.cc index 920a1ea..e0c58203 100644 --- a/content/browser/blob_storage/blob_url_loader_factory.cc +++ b/content/browser/blob_storage/blob_url_loader_factory.cc
@@ -160,7 +160,7 @@ response.mime_type = mime_type; // TODO(jam): some of this code can be shared with - // content/network/url_loader_impl.h + // content/network/url_loader.h client_->OnReceiveResponse(response, base::nullopt, nullptr); sent_headers_ = true;
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc index e044cac5..1ef5f66 100644 --- a/content/browser/frame_host/render_frame_host_impl.cc +++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -96,7 +96,7 @@ #include "content/common/site_isolation_policy.h" #include "content/common/swapped_out_messages.h" #include "content/common/widget.mojom.h" -#include "content/network/restricted_cookie_manager_impl.h" +#include "content/network/restricted_cookie_manager.h" #include "content/public/browser/ax_event_notification_details.h" #include "content/public/browser/browser_accessibility_state.h" #include "content/public/browser/browser_context.h"
diff --git a/content/browser/loader/navigation_url_loader_network_service_unittest.cc b/content/browser/loader/navigation_url_loader_network_service_unittest.cc index 380bade..244d9e6 100644 --- a/content/browser/loader/navigation_url_loader_network_service_unittest.cc +++ b/content/browser/loader/navigation_url_loader_network_service_unittest.cc
@@ -12,7 +12,7 @@ #include "content/common/navigation_params.h" #include "content/common/service_manager/service_manager_connection_impl.h" #include "content/network/network_context.h" -#include "content/network/url_loader_impl.h" +#include "content/network/url_loader.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_ui_data.h" @@ -51,10 +51,10 @@ mojom::URLLoaderRequest request, mojom::URLLoaderClientPtr client) { *most_recent_resource_request_ = resource_request; - // The URLLoaderImpl will delete itself upon completion. - new URLLoaderImpl(context_.get(), std::move(request), 0 /* options */, - resource_request, false /* report_raw_headers */, - std::move(client), TRAFFIC_ANNOTATION_FOR_TESTS); + // The URLLoader will delete itself upon completion. + new URLLoader(context_.get(), std::move(request), 0 /* options */, + resource_request, false /* report_raw_headers */, + std::move(client), TRAFFIC_ANNOTATION_FOR_TESTS); } bool MaybeCreateLoaderForResponse(
diff --git a/content/network/BUILD.gn b/content/network/BUILD.gn index 539a2a45..cbe249c 100644 --- a/content/network/BUILD.gn +++ b/content/network/BUILD.gn
@@ -35,24 +35,24 @@ sources = [ "cache_url_loader.cc", "cache_url_loader.h", - "cookie_manager_impl.cc", - "cookie_manager_impl.h", + "cookie_manager.cc", + "cookie_manager.h", "http_server_properties_pref_delegate.cc", "http_server_properties_pref_delegate.h", - "network_change_manager_impl.cc", - "network_change_manager_impl.h", + "network_change_manager.cc", + "network_change_manager.h", "network_context.cc", "network_context.h", "network_service_impl.cc", "network_service_impl.h", - "network_service_url_loader_factory_impl.cc", - "network_service_url_loader_factory_impl.h", + "network_service_url_loader_factory.cc", + "network_service_url_loader_factory.h", "proxy_resolver_factory_mojo.cc", "proxy_resolver_factory_mojo.h", "proxy_service_mojo.cc", "proxy_service_mojo.h", - "restricted_cookie_manager_impl.cc", - "restricted_cookie_manager_impl.h", + "restricted_cookie_manager.cc", + "restricted_cookie_manager.h", "throttling/network_conditions.cc", "throttling/network_conditions.h", "throttling/throttling_controller.cc", @@ -67,8 +67,8 @@ "throttling/throttling_upload_data_stream.h", "upload_progress_tracker.cc", "upload_progress_tracker.h", - "url_loader_impl.cc", - "url_loader_impl.h", + "url_loader.cc", + "url_loader.h", ] configs += [ "//content:content_implementation" ]
diff --git a/content/network/cookie_manager_impl.cc b/content/network/cookie_manager.cc similarity index 84% rename from content/network/cookie_manager_impl.cc rename to content/network/cookie_manager.cc index 9584e5d..22b602c7 100644 --- a/content/network/cookie_manager_impl.cc +++ b/content/network/cookie_manager.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/network/cookie_manager_impl.h" +#include "content/network/cookie_manager.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h" #include "net/cookies/canonical_cookie.h" @@ -117,42 +117,40 @@ } // namespace -CookieManagerImpl::NotificationRegistration::NotificationRegistration() {} +CookieManager::NotificationRegistration::NotificationRegistration() {} -CookieManagerImpl::NotificationRegistration::~NotificationRegistration() {} +CookieManager::NotificationRegistration::~NotificationRegistration() {} -CookieManagerImpl::CookieManagerImpl(net::CookieStore* cookie_store) +CookieManager::CookieManager(net::CookieStore* cookie_store) : cookie_store_(cookie_store) {} -CookieManagerImpl::~CookieManagerImpl() {} +CookieManager::~CookieManager() {} -void CookieManagerImpl::AddRequest( - network::mojom::CookieManagerRequest request) { +void CookieManager::AddRequest(network::mojom::CookieManagerRequest request) { bindings_.AddBinding(this, std::move(request)); } -void CookieManagerImpl::GetAllCookies(GetAllCookiesCallback callback) { +void CookieManager::GetAllCookies(GetAllCookiesCallback callback) { cookie_store_->GetAllCookiesAsync(std::move(callback)); } -void CookieManagerImpl::GetCookieList(const GURL& url, - const net::CookieOptions& cookie_options, - GetCookieListCallback callback) { +void CookieManager::GetCookieList(const GURL& url, + const net::CookieOptions& cookie_options, + GetCookieListCallback callback) { cookie_store_->GetCookieListWithOptionsAsync(url, cookie_options, std::move(callback)); } -void CookieManagerImpl::SetCanonicalCookie( - const net::CanonicalCookie& cookie, - bool secure_source, - bool modify_http_only, - SetCanonicalCookieCallback callback) { +void CookieManager::SetCanonicalCookie(const net::CanonicalCookie& cookie, + bool secure_source, + bool modify_http_only, + SetCanonicalCookieCallback callback) { cookie_store_->SetCanonicalCookieAsync( std::make_unique<net::CanonicalCookie>(cookie), secure_source, modify_http_only, std::move(callback)); } -void CookieManagerImpl::DeleteCookies( +void CookieManager::DeleteCookies( network::mojom::CookieDeletionFilterPtr filter, DeleteCookiesCallback callback) { base::Time start_time; @@ -171,7 +169,7 @@ std::move(callback)); } -void CookieManagerImpl::RequestNotification( +void CookieManager::RequestNotification( const GURL& url, const std::string& name, network::mojom::CookieChangeNotificationPtr notification_pointer) { @@ -182,9 +180,9 @@ notification_registration->subscription = cookie_store_->AddCallbackForCookie( url, name, - base::Bind(&CookieManagerImpl::CookieChanged, + base::Bind(&CookieManager::CookieChanged, // base::Unretained is safe as destruction of the - // CookieManagerImpl will also destroy the + // CookieManager will also destroy the // notifications_registered list (which this object will be // inserted into, below), which will destroy the // CookieChangedSubscription, unregistering the callback. @@ -195,9 +193,9 @@ base::Unretained(notification_registration.get()))); notification_registration->notification_pointer.set_connection_error_handler( - base::BindOnce(&CookieManagerImpl::NotificationPipeBroken, + base::BindOnce(&CookieManager::NotificationPipeBroken, // base::Unretained is safe as destruction of the - // CookieManagerImpl will also destroy the + // CookieManager will also destroy the // notifications_registered list (which this object will be // inserted into, below), which will destroy the // notification_pointer, rendering this callback moot. @@ -210,14 +208,14 @@ notifications_registered_.push_back(std::move(notification_registration)); } -void CookieManagerImpl::CookieChanged(NotificationRegistration* registration, - const net::CanonicalCookie& cookie, - net::CookieStore::ChangeCause cause) { +void CookieManager::CookieChanged(NotificationRegistration* registration, + const net::CanonicalCookie& cookie, + net::CookieStore::ChangeCause cause) { registration->notification_pointer->OnCookieChanged( cookie, ChangeCauseTranslation(cause)); } -void CookieManagerImpl::NotificationPipeBroken( +void CookieManager::NotificationPipeBroken( NotificationRegistration* registration) { for (auto it = notifications_registered_.begin(); it != notifications_registered_.end(); ++it) { @@ -232,7 +230,7 @@ NOTREACHED(); } -void CookieManagerImpl::CloneInterface( +void CookieManager::CloneInterface( network::mojom::CookieManagerRequest new_interface) { AddRequest(std::move(new_interface)); }
diff --git a/content/network/cookie_manager_impl.h b/content/network/cookie_manager.h similarity index 89% rename from content/network/cookie_manager_impl.h rename to content/network/cookie_manager.h index 1ef74da..5f9438f 100644 --- a/content/network/cookie_manager_impl.h +++ b/content/network/cookie_manager.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_NETWORK_COOKIE_MANAGER_IMPL_H_ -#define CONTENT_NETWORK_COOKIE_MANAGER_IMPL_H_ +#ifndef CONTENT_NETWORK_COOKIE_MANAGER_H_ +#define CONTENT_NETWORK_COOKIE_MANAGER_H_ #include <memory> #include <string> @@ -24,13 +24,13 @@ // This is an IO thread object; all methods on this object must be called on // the IO thread. Note that this does not restrict the locations from which // mojo messages may be sent to the object. -class CONTENT_EXPORT CookieManagerImpl : public network::mojom::CookieManager { +class CONTENT_EXPORT CookieManager : public network::mojom::CookieManager { public: // Construct a CookieService that can serve mojo requests for the underlying // cookie store. |*cookie_store| must outlive this object. - explicit CookieManagerImpl(net::CookieStore* cookie_store); + explicit CookieManager(net::CookieStore* cookie_store); - ~CookieManagerImpl() override; + ~CookieManager() override; // Bind a cookie request to this object. Mojo messages // coming through the associated pipe will be served by this object. @@ -89,9 +89,9 @@ std::vector<std::unique_ptr<NotificationRegistration>> notifications_registered_; - DISALLOW_COPY_AND_ASSIGN(CookieManagerImpl); + DISALLOW_COPY_AND_ASSIGN(CookieManager); }; } // namespace content -#endif // CONTENT_NETWORK_COOKIE_MANAGER_IMPL_H_ +#endif // CONTENT_NETWORK_COOKIE_MANAGER_H_
diff --git a/content/network/cookie_manager_impl_unittest.cc b/content/network/cookie_manager_unittest.cc similarity index 93% rename from content/network/cookie_manager_impl_unittest.cc rename to content/network/cookie_manager_unittest.cc index 0b6898a..2cf279e 100644 --- a/content/network/cookie_manager_impl_unittest.cc +++ b/content/network/cookie_manager_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/network/cookie_manager_impl.h" +#include "content/network/cookie_manager.h" #include <algorithm> @@ -22,10 +22,10 @@ // * SynchronousMojoCookieWrapper: Takes a network::mojom::CookieManager at // construction; exposes synchronous interfaces that wrap the // network::mojom::CookieManager async interfaces to make testing easier. -// * CookieChangeNotificationImpl: Test class implementing +// * CookieChangeNotification: Test class implementing // the CookieChangeNotification interface and recording // incoming messages on it. -// * CookieManagerImplTest: Test base class. Automatically sets up +// * CookieManagerTest: Test base class. Automatically sets up // a cookie store, a cookie service wrapping it, a mojo pipe // connected to the server, and the cookie service implemented // by the other end of the pipe. @@ -134,19 +134,19 @@ DISALLOW_COPY_AND_ASSIGN(SynchronousCookieManager); }; -class CookieManagerImplTest : public testing::Test { +class CookieManagerTest : public testing::Test { public: - CookieManagerImplTest() + CookieManagerTest() : connection_error_seen_(false), cookie_monster_(nullptr, nullptr), - cookie_service_(std::make_unique<CookieManagerImpl>(&cookie_monster_)) { + cookie_service_(std::make_unique<CookieManager>(&cookie_monster_)) { cookie_service_->AddRequest(mojo::MakeRequest(&cookie_service_ptr_)); service_wrapper_ = std::make_unique<SynchronousCookieManager>(cookie_service_ptr_.get()); cookie_service_ptr_.set_connection_error_handler(base::BindOnce( - &CookieManagerImplTest::OnConnectionError, base::Unretained(this))); + &CookieManagerTest::OnConnectionError, base::Unretained(this))); } - ~CookieManagerImplTest() override {} + ~CookieManagerTest() override {} // Tear down the remote service. void NukeService() { cookie_service_.reset(); } @@ -167,7 +167,7 @@ net::CookieStore* cookie_store() { return &cookie_monster_; } - CookieManagerImpl* service_impl() const { return cookie_service_.get(); } + CookieManager* service() const { return cookie_service_.get(); } // Return the cookie service at the client end of the mojo pipe. network::mojom::CookieManager* cookie_service_client() { @@ -186,11 +186,11 @@ base::MessageLoopForIO message_loop_; net::CookieMonster cookie_monster_; - std::unique_ptr<content::CookieManagerImpl> cookie_service_; + std::unique_ptr<content::CookieManager> cookie_service_; network::mojom::CookieManagerPtr cookie_service_ptr_; std::unique_ptr<SynchronousCookieManager> service_wrapper_; - DISALLOW_COPY_AND_ASSIGN(CookieManagerImplTest); + DISALLOW_COPY_AND_ASSIGN(CookieManagerTest); }; namespace { @@ -204,7 +204,7 @@ // Test the GetAllCookies accessor. Also tests that canonical // cookies come out of the store unchanged. -TEST_F(CookieManagerImplTest, GetAllCookies) { +TEST_F(CookieManagerTest, GetAllCookies) { base::Time before_creation(base::Time::Now()); // Set some cookies for the test to play with. @@ -300,7 +300,7 @@ EXPECT_EQ(net::COOKIE_PRIORITY_MEDIUM, cookies[3].Priority()); } -TEST_F(CookieManagerImplTest, GetCookieList) { +TEST_F(CookieManagerTest, GetCookieList) { // Set some cookies for the test to play with. EXPECT_TRUE(SetCanonicalCookie( net::CanonicalCookie( @@ -342,7 +342,7 @@ EXPECT_EQ("E", cookies[1].Value()); } -TEST_F(CookieManagerImplTest, GetCookieListHttpOnly) { +TEST_F(CookieManagerTest, GetCookieListHttpOnly) { // Create an httponly and a non-httponly cookie. bool result; result = SetCanonicalCookie( @@ -379,7 +379,7 @@ EXPECT_EQ("C", cookies[1].Name()); } -TEST_F(CookieManagerImplTest, GetCookieListSameSite) { +TEST_F(CookieManagerTest, GetCookieListSameSite) { // Create an unrestricted, a lax, and a strict cookie. bool result; result = SetCanonicalCookie( @@ -435,7 +435,7 @@ EXPECT_EQ("E", cookies[2].Name()); } -TEST_F(CookieManagerImplTest, GetCookieListAccessTime) { +TEST_F(CookieManagerTest, GetCookieListAccessTime) { bool result = SetCanonicalCookie( net::CanonicalCookie( "A", "B", "foo_host", "/", base::Time(), base::Time(), base::Time(), @@ -467,7 +467,7 @@ EXPECT_LE(cookies[0].LastAccessDate(), base::Time::Now()); } -TEST_F(CookieManagerImplTest, DeleteThroughSet) { +TEST_F(CookieManagerTest, DeleteThroughSet) { // Set some cookies for the test to play with. EXPECT_TRUE(SetCanonicalCookie( net::CanonicalCookie( @@ -520,7 +520,7 @@ EXPECT_EQ("E", cookies[2].Value()); } -TEST_F(CookieManagerImplTest, ConfirmSecureSetFails) { +TEST_F(CookieManagerTest, ConfirmSecureSetFails) { EXPECT_FALSE(service_wrapper()->SetCanonicalCookie( net::CanonicalCookie( "N", "O", "foo_host", "/", base::Time(), base::Time(), base::Time(), @@ -533,7 +533,7 @@ ASSERT_EQ(0u, cookies.size()); } -TEST_F(CookieManagerImplTest, ConfirmHttpOnlySetFails) { +TEST_F(CookieManagerTest, ConfirmHttpOnlySetFails) { EXPECT_FALSE(service_wrapper()->SetCanonicalCookie( net::CanonicalCookie( "N", "O", "foo_host", "/", base::Time(), base::Time(), base::Time(), @@ -546,7 +546,7 @@ ASSERT_EQ(0u, cookies.size()); } -TEST_F(CookieManagerImplTest, ConfirmHttpOnlyOverwriteFails) { +TEST_F(CookieManagerTest, ConfirmHttpOnlyOverwriteFails) { EXPECT_TRUE(SetCanonicalCookie( net::CanonicalCookie( "HttpOnly", "F", "foo_host", "/with/path", base::Time(), base::Time(), @@ -571,7 +571,7 @@ EXPECT_EQ("F", cookies[0].Value()); } -TEST_F(CookieManagerImplTest, DeleteEverything) { +TEST_F(CookieManagerTest, DeleteEverything) { // Set some cookies for the test to play with. EXPECT_TRUE(SetCanonicalCookie( net::CanonicalCookie( @@ -608,7 +608,7 @@ ASSERT_EQ(0u, cookies.size()); } -TEST_F(CookieManagerImplTest, DeleteByTime) { +TEST_F(CookieManagerTest, DeleteByTime) { base::Time now(base::Time::Now()); // Create three cookies and delete the middle one. @@ -645,7 +645,7 @@ EXPECT_EQ("A3", cookies[1].Name()); } -TEST_F(CookieManagerImplTest, DeleteByExcludingDomains) { +TEST_F(CookieManagerTest, DeleteByExcludingDomains) { // Create three cookies and delete the middle one. EXPECT_TRUE(SetCanonicalCookie( net::CanonicalCookie( @@ -678,7 +678,7 @@ EXPECT_EQ("A2", cookies[0].Name()); } -TEST_F(CookieManagerImplTest, DeleteByIncludingDomains) { +TEST_F(CookieManagerTest, DeleteByIncludingDomains) { // Create three cookies and delete the middle one. EXPECT_TRUE(SetCanonicalCookie( net::CanonicalCookie( @@ -713,7 +713,7 @@ } // Confirm deletion is based on eTLD+1 -TEST_F(CookieManagerImplTest, DeleteDetails_eTLD) { +TEST_F(CookieManagerTest, DeleteDetails_eTLD) { // Two domains on diferent levels of the same eTLD both get deleted. EXPECT_TRUE(SetCanonicalCookie( net::CanonicalCookie( @@ -804,7 +804,7 @@ } // Confirm deletion ignores host/domain distinction. -TEST_F(CookieManagerImplTest, DeleteDetails_HostDomain) { +TEST_F(CookieManagerTest, DeleteDetails_HostDomain) { // Create four cookies: A host (no leading .) and domain cookie // (leading .) for each of two separate domains. Confirm that the // filter deletes both of one domain and leaves the other alone. @@ -845,7 +845,7 @@ EXPECT_EQ("A4", cookies[1].Name()); } -TEST_F(CookieManagerImplTest, DeleteDetails_eTLDvsPrivateRegistry) { +TEST_F(CookieManagerTest, DeleteDetails_eTLDvsPrivateRegistry) { EXPECT_TRUE(SetCanonicalCookie( net::CanonicalCookie( "A1", "val", "random.co.uk", "/", base::Time(), base::Time(), @@ -890,7 +890,7 @@ EXPECT_EQ("A5", cookies[2].Name()); } -TEST_F(CookieManagerImplTest, DeleteDetails_PrivateRegistry) { +TEST_F(CookieManagerTest, DeleteDetails_PrivateRegistry) { EXPECT_TRUE(SetCanonicalCookie( net::CanonicalCookie( "A1", "val", "privatedomain", "/", base::Time(), base::Time(), @@ -930,7 +930,7 @@ // Test to probe and make sure the attributes that deletion should ignore // don't affect the results. -TEST_F(CookieManagerImplTest, DeleteDetails_IgnoredFields) { +TEST_F(CookieManagerTest, DeleteDetails_IgnoredFields) { // Simple deletion filter network::mojom::CookieDeletionFilter filter; filter.including_domains = std::vector<std::string>(); @@ -1031,7 +1031,7 @@ // A set of tests specified by the only consumer of this interface // (BrowsingDataFilterBuilderImpl). -TEST_F(CookieManagerImplTest, DeleteDetails_Consumer) { +TEST_F(CookieManagerTest, DeleteDetails_Consumer) { const char* filter_domains[] = { "google.com", @@ -1149,7 +1149,7 @@ } } -TEST_F(CookieManagerImplTest, DeleteBySessionStatus) { +TEST_F(CookieManagerTest, DeleteBySessionStatus) { base::Time now(base::Time::Now()); // Create three cookies and delete the middle one. @@ -1187,7 +1187,7 @@ EXPECT_EQ("A3", cookies[1].Name()); } -TEST_F(CookieManagerImplTest, DeleteByAll) { +TEST_F(CookieManagerTest, DeleteByAll) { base::Time now(base::Time::Now()); // Add a lot of cookies, only one of which will be deleted by the filter. @@ -1280,7 +1280,7 @@ } // Receives and records notifications from the network::mojom::CookieManager. -class CookieChangeNotificationImpl +class CookieChangeNotification : public network::mojom::CookieChangeNotification { public: struct Notification { @@ -1294,7 +1294,7 @@ network::mojom::CookieChangeCause cause; }; - CookieChangeNotificationImpl( + CookieChangeNotification( network::mojom::CookieChangeNotificationRequest request) : run_loop_(nullptr), binding_(this, std::move(request)) {} @@ -1331,7 +1331,7 @@ mojo::Binding<network::mojom::CookieChangeNotification> binding_; }; -TEST_F(CookieManagerImplTest, Notification) { +TEST_F(CookieManagerTest, Notification) { GURL notification_url("http://www.testing.com/pathele"); std::string notification_domain("testing.com"); std::string notification_name("Cookie_Name"); @@ -1339,13 +1339,13 @@ network::mojom::CookieChangeNotificationRequest request( mojo::MakeRequest(&ptr)); - CookieChangeNotificationImpl notification_impl(std::move(request)); + CookieChangeNotification notification(std::move(request)); cookie_service_client()->RequestNotification( notification_url, notification_name, std::move(ptr)); - std::vector<CookieChangeNotificationImpl::Notification> notifications; - notification_impl.GetCurrentNotifications(¬ifications); + std::vector<CookieChangeNotification::Notification> notifications; + notification.GetCurrentNotifications(¬ifications); EXPECT_EQ(0u, notifications.size()); notifications.clear(); @@ -1359,7 +1359,7 @@ net::COOKIE_PRIORITY_MEDIUM), true, true); base::RunLoop().RunUntilIdle(); - notification_impl.GetCurrentNotifications(¬ifications); + notification.GetCurrentNotifications(¬ifications); EXPECT_EQ(0u, notifications.size()); notifications.clear(); @@ -1374,7 +1374,7 @@ true, true); base::RunLoop().RunUntilIdle(); - notification_impl.GetCurrentNotifications(¬ifications); + notification.GetCurrentNotifications(¬ifications); EXPECT_EQ(0u, notifications.size()); notifications.clear(); @@ -1388,13 +1388,13 @@ true, true); // Expect asynchrony - notification_impl.GetCurrentNotifications(¬ifications); + notification.GetCurrentNotifications(¬ifications); EXPECT_EQ(0u, notifications.size()); notifications.clear(); // Expect notification - notification_impl.WaitForSomeNotification(); - notification_impl.GetCurrentNotifications(¬ifications); + notification.WaitForSomeNotification(); + notification.GetCurrentNotifications(¬ifications); EXPECT_EQ(1u, notifications.size()); EXPECT_EQ(notification_name, notifications[0].cookie.Name()); EXPECT_EQ(notification_url.host(), notifications[0].cookie.Domain()); @@ -1413,8 +1413,8 @@ ASSERT_EQ(2u, service_wrapper()->DeleteCookies(filter)); // The notification may already have arrived, or it may arrive in the future. - notification_impl.WaitForSomeNotification(); - notification_impl.GetCurrentNotifications(¬ifications); + notification.WaitForSomeNotification(); + notification.GetCurrentNotifications(¬ifications); ASSERT_EQ(1u, notifications.size()); EXPECT_EQ(notification_name, notifications[0].cookie.Name()); EXPECT_EQ(notification_url.host(), notifications[0].cookie.Domain()); @@ -1424,7 +1424,7 @@ // Confirm the service operates properly if a returned notification interface // is destroyed. -TEST_F(CookieManagerImplTest, NotificationRequestDestroyed) { +TEST_F(CookieManagerTest, NotificationRequestDestroyed) { // Create two identical notification interfaces. GURL notification_url("http://www.testing.com/pathele"); std::string notification_name("Cookie_Name"); @@ -1432,16 +1432,16 @@ network::mojom::CookieChangeNotificationPtr ptr1; network::mojom::CookieChangeNotificationRequest request1( mojo::MakeRequest(&ptr1)); - std::unique_ptr<CookieChangeNotificationImpl> notification_impl1( - std::make_unique<CookieChangeNotificationImpl>(std::move(request1))); + std::unique_ptr<CookieChangeNotification> notification1( + std::make_unique<CookieChangeNotification>(std::move(request1))); cookie_service_client()->RequestNotification( notification_url, notification_name, std::move(ptr1)); network::mojom::CookieChangeNotificationPtr ptr2; network::mojom::CookieChangeNotificationRequest request2( mojo::MakeRequest(&ptr2)); - std::unique_ptr<CookieChangeNotificationImpl> notification_impl2( - std::make_unique<CookieChangeNotificationImpl>(std::move(request2))); + std::unique_ptr<CookieChangeNotification> notification2( + std::make_unique<CookieChangeNotification>(std::move(request2))); cookie_service_client()->RequestNotification( notification_url, notification_name, std::move(ptr2)); @@ -1454,42 +1454,42 @@ net::COOKIE_PRIORITY_MEDIUM), true, true); - std::vector<CookieChangeNotificationImpl::Notification> notifications; - notification_impl1->GetCurrentNotifications(¬ifications); + std::vector<CookieChangeNotification::Notification> notifications; + notification1->GetCurrentNotifications(¬ifications); EXPECT_EQ(0u, notifications.size()); notifications.clear(); - notification_impl2->GetCurrentNotifications(¬ifications); + notification2->GetCurrentNotifications(¬ifications); EXPECT_EQ(0u, notifications.size()); notifications.clear(); - notification_impl1->WaitForSomeNotification(); - notification_impl1->GetCurrentNotifications(¬ifications); + notification1->WaitForSomeNotification(); + notification1->GetCurrentNotifications(¬ifications); EXPECT_EQ(1u, notifications.size()); notifications.clear(); - notification_impl2->WaitForSomeNotification(); - notification_impl2->GetCurrentNotifications(¬ifications); + notification2->WaitForSomeNotification(); + notification2->GetCurrentNotifications(¬ifications); EXPECT_EQ(1u, notifications.size()); notifications.clear(); - EXPECT_EQ(2u, service_impl()->GetNotificationsBoundForTesting()); + EXPECT_EQ(2u, service()->GetNotificationsBoundForTesting()); // Destroy the first interface - notification_impl1.reset(); + notification1.reset(); // Confirm the second interface can still receive notifications. network::mojom::CookieDeletionFilter filter; EXPECT_EQ(1u, service_wrapper()->DeleteCookies(filter)); - notification_impl2->WaitForSomeNotification(); - notification_impl2->GetCurrentNotifications(¬ifications); + notification2->WaitForSomeNotification(); + notification2->GetCurrentNotifications(¬ifications); EXPECT_EQ(1u, notifications.size()); notifications.clear(); - EXPECT_EQ(1u, service_impl()->GetNotificationsBoundForTesting()); + EXPECT_EQ(1u, service()->GetNotificationsBoundForTesting()); } // Confirm we get a connection error notification if the service dies. -TEST_F(CookieManagerImplTest, ServiceDestructVisible) { +TEST_F(CookieManagerTest, ServiceDestructVisible) { EXPECT_FALSE(connection_error_seen()); NukeService(); base::RunLoop().RunUntilIdle(); @@ -1498,8 +1498,8 @@ // Test service cloning. Also confirm that the service notices if a client // dies. -TEST_F(CookieManagerImplTest, CloningAndClientDestructVisible) { - EXPECT_EQ(1u, service_impl()->GetClientsBoundForTesting()); +TEST_F(CookieManagerTest, CloningAndClientDestructVisible) { + EXPECT_EQ(1u, service()->GetClientsBoundForTesting()); // Clone the interface. network::mojom::CookieManagerPtr new_ptr; @@ -1524,11 +1524,11 @@ // After a synchronous round trip through the new client pointer, it // should be reflected in the bindings seen on the server. - EXPECT_EQ(2u, service_impl()->GetClientsBoundForTesting()); + EXPECT_EQ(2u, service()->GetClientsBoundForTesting()); new_ptr.reset(); base::RunLoop().RunUntilIdle(); - EXPECT_EQ(1u, service_impl()->GetClientsBoundForTesting()); + EXPECT_EQ(1u, service()->GetClientsBoundForTesting()); } } // namespace content
diff --git a/content/network/network_change_manager_impl.cc b/content/network/network_change_manager.cc similarity index 76% rename from content/network/network_change_manager_impl.cc rename to content/network/network_change_manager.cc index 0b431a5..51831589 100644 --- a/content/network/network_change_manager_impl.cc +++ b/content/network/network_change_manager.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/network/network_change_manager_impl.h" +#include "content/network/network_change_manager.h" #include <algorithm> #include <utility> @@ -12,7 +12,7 @@ namespace content { -NetworkChangeManagerImpl::NetworkChangeManagerImpl( +NetworkChangeManager::NetworkChangeManager( std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier) : network_change_notifier_(std::move(network_change_notifier)) { net::NetworkChangeNotifier::AddNetworkChangeObserver(this); @@ -20,21 +20,21 @@ mojom::ConnectionType(net::NetworkChangeNotifier::GetConnectionType()); } -NetworkChangeManagerImpl::~NetworkChangeManagerImpl() { +NetworkChangeManager::~NetworkChangeManager() { net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); } -void NetworkChangeManagerImpl::AddRequest( +void NetworkChangeManager::AddRequest( mojom::NetworkChangeManagerRequest request) { bindings_.AddBinding(this, std::move(request)); } -void NetworkChangeManagerImpl::RequestNotifications( +void NetworkChangeManager::RequestNotifications( mojom::NetworkChangeManagerClientPtr client_ptr) { client_ptr.set_connection_error_handler( - base::Bind(&NetworkChangeManagerImpl::NotificationPipeBroken, + base::Bind(&NetworkChangeManager::NotificationPipeBroken, // base::Unretained is safe as destruction of the - // NetworkChangeManagerImpl will also destroy the + // NetworkChangeManager will also destroy the // |clients_| list (which this object will be // inserted into, below), which will destroy the // client_ptr, rendering this callback moot. @@ -43,11 +43,11 @@ clients_.push_back(std::move(client_ptr)); } -size_t NetworkChangeManagerImpl::GetNumClientsForTesting() const { +size_t NetworkChangeManager::GetNumClientsForTesting() const { return clients_.size(); } -void NetworkChangeManagerImpl::NotificationPipeBroken( +void NetworkChangeManager::NotificationPipeBroken( mojom::NetworkChangeManagerClient* client) { clients_.erase( std::find_if(clients_.begin(), clients_.end(), @@ -56,7 +56,7 @@ })); } -void NetworkChangeManagerImpl::OnNetworkChanged( +void NetworkChangeManager::OnNetworkChanged( net::NetworkChangeNotifier::ConnectionType type) { connection_type_ = mojom::ConnectionType(type); for (const auto& client : clients_) {
diff --git a/content/network/network_change_manager_impl.h b/content/network/network_change_manager.h similarity index 85% rename from content/network/network_change_manager_impl.h rename to content/network/network_change_manager.h index 139ce16..f35dc0a 100644 --- a/content/network/network_change_manager_impl.h +++ b/content/network/network_change_manager.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_NETWORK_NETWORK_CHANGE_MANAGER_IMPL_H_ -#define CONTENT_NETWORK_NETWORK_CHANGE_MANAGER_IMPL_H_ +#ifndef CONTENT_NETWORK_NETWORK_CHANGE_MANAGER_H_ +#define CONTENT_NETWORK_NETWORK_CHANGE_MANAGER_H_ #include <memory> #include <string> @@ -22,16 +22,16 @@ // done through mojo on the main thread. This registers itself to receive // broadcasts from net::NetworkChangeNotifier and rebroadcasts the notifications // to mojom::NetworkChangeManagerClients through mojo pipes. -class CONTENT_EXPORT NetworkChangeManagerImpl +class CONTENT_EXPORT NetworkChangeManager : public mojom::NetworkChangeManager, public net::NetworkChangeNotifier::NetworkChangeObserver { public: // If |network_change_notifier| is not null, |this| will take ownership of it. // Otherwise, the global net::NetworkChangeNotifier will be used. - explicit NetworkChangeManagerImpl( + explicit NetworkChangeManager( std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier); - ~NetworkChangeManagerImpl() override; + ~NetworkChangeManager() override; // Binds a NetworkChangeManager request to this object. Mojo messages // coming through the associated pipe will be served by this object. @@ -56,9 +56,9 @@ std::vector<mojom::NetworkChangeManagerClientPtr> clients_; mojom::ConnectionType connection_type_; - DISALLOW_COPY_AND_ASSIGN(NetworkChangeManagerImpl); + DISALLOW_COPY_AND_ASSIGN(NetworkChangeManager); }; } // namespace content -#endif // CONTENT_NETWORK_NETWORK_CHANGE_MANAGER_IMPL_H_ +#endif // CONTENT_NETWORK_NETWORK_CHANGE_MANAGER_H_
diff --git a/content/network/network_change_manager_impl_unittest.cc b/content/network/network_change_manager_unittest.cc similarity index 91% rename from content/network/network_change_manager_impl_unittest.cc rename to content/network/network_change_manager_unittest.cc index 36681555..6102f05 100644 --- a/content/network/network_change_manager_impl_unittest.cc +++ b/content/network/network_change_manager_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/network/network_change_manager_impl.h" +#include "content/network/network_change_manager.h" #include <algorithm> #include <utility> @@ -33,7 +33,7 @@ : public mojom::NetworkChangeManagerClient { public: explicit TestNetworkChangeManagerClient( - content::NetworkChangeManagerImpl* network_change_manager) + content::NetworkChangeManager* network_change_manager) : num_network_changed_(0), run_loop_(std::make_unique<base::RunLoop>()), notification_type_to_wait_(NONE), @@ -89,23 +89,23 @@ } // namespace -class NetworkChangeManagerImplTest : public testing::Test { +class NetworkChangeManagerTest : public testing::Test { public: - NetworkChangeManagerImplTest() - : network_change_manager_(new NetworkChangeManagerImpl( + NetworkChangeManagerTest() + : network_change_manager_(new NetworkChangeManager( base::WrapUnique(net::NetworkChangeNotifier::CreateMock()))) { network_change_manager_client_ = std::make_unique<TestNetworkChangeManagerClient>( network_change_manager_.get()); } - ~NetworkChangeManagerImplTest() override {} + ~NetworkChangeManagerTest() override {} TestNetworkChangeManagerClient* network_change_manager_client() { return network_change_manager_client_.get(); } - NetworkChangeManagerImpl* network_change_manager() const { + NetworkChangeManager* network_change_manager() const { return network_change_manager_.get(); } @@ -115,14 +115,14 @@ private: base::test::ScopedTaskEnvironment scoped_task_environment_; - std::unique_ptr<NetworkChangeManagerImpl> network_change_manager_; + std::unique_ptr<NetworkChangeManager> network_change_manager_; std::unique_ptr<TestNetworkChangeManagerClient> network_change_manager_client_; - DISALLOW_COPY_AND_ASSIGN(NetworkChangeManagerImplTest); + DISALLOW_COPY_AND_ASSIGN(NetworkChangeManagerTest); }; -TEST_F(NetworkChangeManagerImplTest, ClientNotified) { +TEST_F(NetworkChangeManagerTest, ClientNotified) { // Simulate a new network change. SimulateNetworkChange(net::NetworkChangeNotifier::CONNECTION_3G); network_change_manager_client()->WaitForNotification(NETWORK_CHANGED); @@ -132,7 +132,7 @@ EXPECT_EQ(1u, network_change_manager_client()->num_network_changed()); } -TEST_F(NetworkChangeManagerImplTest, OneClientPipeBroken) { +TEST_F(NetworkChangeManagerTest, OneClientPipeBroken) { auto network_change_manager_client2 = std::make_unique<TestNetworkChangeManagerClient>( network_change_manager()); @@ -165,7 +165,7 @@ EXPECT_EQ(2u, network_change_manager_client()->num_network_changed()); } -TEST_F(NetworkChangeManagerImplTest, NewClientReceivesCurrentType) { +TEST_F(NetworkChangeManagerTest, NewClientReceivesCurrentType) { // Simulate a network change. SimulateNetworkChange(net::NetworkChangeNotifier::CONNECTION_BLUETOOTH);
diff --git a/content/network/network_context.cc b/content/network/network_context.cc index e485aba3..f99d5f4f 100644 --- a/content/network/network_context.cc +++ b/content/network/network_context.cc
@@ -23,12 +23,12 @@ #include "content/network/cache_url_loader.h" #include "content/network/http_server_properties_pref_delegate.h" #include "content/network/network_service_impl.h" -#include "content/network/network_service_url_loader_factory_impl.h" -#include "content/network/restricted_cookie_manager_impl.h" +#include "content/network/network_service_url_loader_factory.h" +#include "content/network/restricted_cookie_manager.h" #include "content/network/throttling/network_conditions.h" #include "content/network/throttling/throttling_controller.h" #include "content/network/throttling/throttling_network_transaction_factory.h" -#include "content/network/url_loader_impl.h" +#include "content/network/url_loader.h" #include "content/public/common/content_client.h" #include "content/public/common/content_switches.h" #include "content/public/network/ignore_errors_cert_verifier.h" @@ -55,7 +55,7 @@ owned_url_request_context_ = MakeURLRequestContext(params_.get()); url_request_context_ = owned_url_request_context_.get(); cookie_manager_ = - std::make_unique<CookieManagerImpl>(url_request_context_->cookie_store()); + std::make_unique<CookieManager>(url_request_context_->cookie_store()); network_service_->RegisterNetworkContext(this); binding_.set_connection_error_handler(base::BindOnce( &NetworkContext::OnConnectionError, base::Unretained(this))); @@ -82,20 +82,20 @@ owned_url_request_context_ = builder->Build(); url_request_context_ = owned_url_request_context_.get(); cookie_manager_ = - std::make_unique<CookieManagerImpl>(url_request_context_->cookie_store()); + std::make_unique<CookieManager>(url_request_context_->cookie_store()); } NetworkContext::NetworkContext(mojom::NetworkContextRequest request, net::URLRequestContext* url_request_context) : network_service_(nullptr), binding_(this, std::move(request)), - cookie_manager_(std::make_unique<CookieManagerImpl>( + cookie_manager_(std::make_unique<CookieManager>( url_request_context->cookie_store())) { url_request_context_ = url_request_context; } NetworkContext::~NetworkContext() { - // Call each URLLoaderImpl and ask it to release its net::URLRequest, as the + // Call each URLLoader and ask it to release its net::URLRequest, as the // corresponding net::URLRequestContext is going away with this // NetworkContext. The loaders can be deregistering themselves in Cleanup(), // so have to be careful. @@ -111,12 +111,12 @@ return base::WrapUnique(new NetworkContext); } -void NetworkContext::RegisterURLLoader(URLLoaderImpl* url_loader) { +void NetworkContext::RegisterURLLoader(URLLoader* url_loader) { DCHECK(url_loaders_.count(url_loader) == 0); url_loaders_.insert(url_loader); } -void NetworkContext::DeregisterURLLoader(URLLoaderImpl* url_loader) { +void NetworkContext::DeregisterURLLoader(URLLoader* url_loader) { size_t removed_count = url_loaders_.erase(url_loader); DCHECK(removed_count); } @@ -125,7 +125,7 @@ mojom::URLLoaderFactoryRequest request, uint32_t process_id) { loader_factory_bindings_.AddBinding( - std::make_unique<NetworkServiceURLLoaderFactoryImpl>(this, process_id), + std::make_unique<NetworkServiceURLLoaderFactory>(this, process_id), std::move(request)); } @@ -143,10 +143,10 @@ network::mojom::RestrictedCookieManagerRequest request, int32_t render_process_id, int32_t render_frame_id) { - // TODO(crbug.com/729800): RestrictedCookieManagerImpl should own its bindings - // and NetworkContext should own the RestrictedCookieManagerImpl + // TODO(crbug.com/729800): RestrictedCookieManager should own its bindings + // and NetworkContext should own the RestrictedCookieManager // instances. - mojo::MakeStrongBinding(std::make_unique<RestrictedCookieManagerImpl>( + mojo::MakeStrongBinding(std::make_unique<RestrictedCookieManager>( url_request_context_->cookie_store(), render_process_id, render_frame_id), std::move(request));
diff --git a/content/network/network_context.h b/content/network/network_context.h index 36cb355..f152de9d 100644 --- a/content/network/network_context.h +++ b/content/network/network_context.h
@@ -15,7 +15,7 @@ #include "base/time/time.h" #include "base/timer/timer.h" #include "content/common/content_export.h" -#include "content/network/cookie_manager_impl.h" +#include "content/network/cookie_manager.h" #include "content/public/common/network_service.mojom.h" #include "content/public/common/url_loader_factory.mojom.h" #include "mojo/public/cpp/bindings/binding.h" @@ -31,7 +31,7 @@ namespace content { class NetworkServiceImpl; -class URLLoaderImpl; +class URLLoader; // A NetworkContext creates and manages access to a URLRequestContext. // @@ -76,8 +76,8 @@ // These are called by individual url loaders as they are being created and // destroyed. - void RegisterURLLoader(URLLoaderImpl* url_loader); - void DeregisterURLLoader(URLLoaderImpl* url_loader); + void RegisterURLLoader(URLLoader* url_loader); + void DeregisterURLLoader(URLLoader* url_loader); // mojom::NetworkContext implementation: void CreateURLLoaderFactory(mojom::URLLoaderFactoryRequest request, @@ -129,20 +129,20 @@ net::URLRequestContext* url_request_context_ = nullptr; // Put it below |url_request_context_| so that it outlives all the - // NetworkServiceURLLoaderFactoryImpl instances. + // NetworkServiceURLLoaderFactory instances. mojo::StrongBindingSet<mojom::URLLoaderFactory> loader_factory_bindings_; - // URLLoaderImpls register themselves with the NetworkContext so that they can + // URLLoaders register themselves with the NetworkContext so that they can // be cleaned up when the NetworkContext goes away. This is needed as - // net::URLRequests held by URLLoaderImpls have to be gone when + // net::URLRequests held by URLLoaders have to be gone when // net::URLRequestContext (held by NetworkContext) is destroyed. - std::set<URLLoaderImpl*> url_loaders_; + std::set<URLLoader*> url_loaders_; mojom::NetworkContextParamsPtr params_; mojo::Binding<mojom::NetworkContext> binding_; - std::unique_ptr<CookieManagerImpl> cookie_manager_; + std::unique_ptr<CookieManager> cookie_manager_; // Temporary class to help diagnose the impact of https://crbug.com/711579. // Every 24-hours, measures the size of the network cache and emits an UMA
diff --git a/content/network/network_service_impl.cc b/content/network/network_service_impl.cc index 4697766..1651f8d 100644 --- a/content/network/network_service_impl.cc +++ b/content/network/network_service_impl.cc
@@ -95,7 +95,7 @@ base::WrapUnique(net::NetworkChangeNotifier::Create()); #endif } - network_change_manager_ = std::make_unique<NetworkChangeManagerImpl>( + network_change_manager_ = std::make_unique<NetworkChangeManager>( std::move(network_change_notifier)); if (net_log) {
diff --git a/content/network/network_service_impl.h b/content/network/network_service_impl.h index 39b5690..0f2454c 100644 --- a/content/network/network_service_impl.h +++ b/content/network/network_service_impl.h
@@ -12,7 +12,7 @@ #include "base/macros.h" #include "build/build_config.h" #include "content/common/content_export.h" -#include "content/network/network_change_manager_impl.h" +#include "content/network/network_change_manager.h" #include "content/public/common/network_service.mojom.h" #include "content/public/network/network_service.h" #include "mojo/public/cpp/bindings/binding.h" @@ -98,7 +98,7 @@ std::unique_ptr<net::NetworkChangeNotifierFactoryAndroid> network_change_notifier_factory_; #endif - std::unique_ptr<NetworkChangeManagerImpl> network_change_manager_; + std::unique_ptr<NetworkChangeManager> network_change_manager_; std::unique_ptr<service_manager::BinderRegistry> registry_;
diff --git a/content/network/network_service_unittest.cc b/content/network/network_service_unittest.cc index e779364..6bb9068 100644 --- a/content/network/network_service_unittest.cc +++ b/content/network/network_service_unittest.cc
@@ -399,7 +399,7 @@ if (name == mojom::kNetworkServiceName) { service_context_.reset(new service_manager::ServiceContext( NetworkServiceImpl::CreateForTesting(), std::move(request))); - // Send a broadcast after NetworkServiceImpl is actually created. + // Send a broadcast after NetworkService is actually created. // Otherwise, this NotifyObservers is a no-op. net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests( net::NetworkChangeNotifier::CONNECTION_3G);
diff --git a/content/network/network_service_url_loader_factory_impl.cc b/content/network/network_service_url_loader_factory.cc similarity index 77% rename from content/network/network_service_url_loader_factory_impl.cc rename to content/network/network_service_url_loader_factory.cc index 16d7ff9..c4a698c 100644 --- a/content/network/network_service_url_loader_factory_impl.cc +++ b/content/network/network_service_url_loader_factory.cc
@@ -2,27 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/network/network_service_url_loader_factory_impl.h" +#include "content/network/network_service_url_loader_factory.h" #include "base/logging.h" #include "content/network/network_context.h" #include "content/network/network_service_impl.h" -#include "content/network/url_loader_impl.h" +#include "content/network/url_loader.h" #include "content/public/common/resource_request.h" namespace content { -NetworkServiceURLLoaderFactoryImpl::NetworkServiceURLLoaderFactoryImpl( +NetworkServiceURLLoaderFactory::NetworkServiceURLLoaderFactory( NetworkContext* context, uint32_t process_id) : context_(context), process_id_(process_id) { ignore_result(process_id_); } -NetworkServiceURLLoaderFactoryImpl::~NetworkServiceURLLoaderFactoryImpl() = - default; +NetworkServiceURLLoaderFactory::~NetworkServiceURLLoaderFactory() = default; -void NetworkServiceURLLoaderFactoryImpl::CreateLoaderAndStart( +void NetworkServiceURLLoaderFactory::CreateLoaderAndStart( mojom::URLLoaderRequest request, int32_t routing_id, int32_t request_id, @@ -37,13 +36,13 @@ if (!report_raw_headers) DLOG(ERROR) << "Denying raw headers request by process " << process_id_; } - new URLLoaderImpl( + new URLLoader( context_, std::move(request), options, url_request, report_raw_headers, std::move(client), static_cast<net::NetworkTrafficAnnotationTag>(traffic_annotation)); } -void NetworkServiceURLLoaderFactoryImpl::Clone( +void NetworkServiceURLLoaderFactory::Clone( mojom::URLLoaderFactoryRequest request) { context_->CreateURLLoaderFactory(std::move(request), process_id_); }
diff --git a/content/network/network_service_url_loader_factory_impl.h b/content/network/network_service_url_loader_factory.h similarity index 69% rename from content/network/network_service_url_loader_factory_impl.h rename to content/network/network_service_url_loader_factory.h index e0b9316..dc177d4b 100644 --- a/content/network/network_service_url_loader_factory_impl.h +++ b/content/network/network_service_url_loader_factory.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_NETWORK_NETWORK_SERVICE_URL_LOADER_FACTORY_IMPL_H_ -#define CONTENT_NETWORK_NETWORK_SERVICE_URL_LOADER_FACTORY_IMPL_H_ +#ifndef CONTENT_NETWORK_NETWORK_SERVICE_URL_LOADER_FACTORY_H_ +#define CONTENT_NETWORK_NETWORK_SERVICE_URL_LOADER_FACTORY_H_ #include "base/macros.h" #include "content/public/common/url_loader_factory.mojom.h" @@ -15,13 +15,12 @@ // This class is an implementation of mojom::URLLoaderFactory that creates // a mojom::URLLoader. -class NetworkServiceURLLoaderFactoryImpl : public mojom::URLLoaderFactory { +class NetworkServiceURLLoaderFactory : public mojom::URLLoaderFactory { public: // NOTE: |context| must outlive this instance. - NetworkServiceURLLoaderFactoryImpl(NetworkContext* context, - uint32_t process_id); + NetworkServiceURLLoaderFactory(NetworkContext* context, uint32_t process_id); - ~NetworkServiceURLLoaderFactoryImpl() override; + ~NetworkServiceURLLoaderFactory() override; // mojom::URLLoaderFactory implementation. void CreateLoaderAndStart(mojom::URLLoaderRequest request, @@ -39,9 +38,9 @@ NetworkContext* context_; int process_id_; - DISALLOW_COPY_AND_ASSIGN(NetworkServiceURLLoaderFactoryImpl); + DISALLOW_COPY_AND_ASSIGN(NetworkServiceURLLoaderFactory); }; } // namespace content -#endif // CONTENT_NETWORK_NETWORK_SERVICE_URL_LOADER_FACTORY_IMPL_H_ +#endif // CONTENT_NETWORK_NETWORK_SERVICE_URL_LOADER_FACTORY_H_
diff --git a/content/network/restricted_cookie_manager_impl.cc b/content/network/restricted_cookie_manager.cc similarity index 84% rename from content/network/restricted_cookie_manager_impl.cc rename to content/network/restricted_cookie_manager.cc index 091367b0..0980188 100644 --- a/content/network/restricted_cookie_manager_impl.cc +++ b/content/network/restricted_cookie_manager.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/network/restricted_cookie_manager_impl.h" +#include "content/network/restricted_cookie_manager.h" #include <memory> #include <utility> @@ -20,18 +20,17 @@ namespace content { -RestrictedCookieManagerImpl::RestrictedCookieManagerImpl( - net::CookieStore* cookie_store, - int render_process_id, - int render_frame_id) +RestrictedCookieManager::RestrictedCookieManager(net::CookieStore* cookie_store, + int render_process_id, + int render_frame_id) : cookie_store_(cookie_store), render_process_id_(render_process_id), render_frame_id_(render_frame_id), weak_ptr_factory_(this) {} -RestrictedCookieManagerImpl::~RestrictedCookieManagerImpl() = default; +RestrictedCookieManager::~RestrictedCookieManager() = default; -void RestrictedCookieManagerImpl::GetAllForUrl( +void RestrictedCookieManager::GetAllForUrl( const GURL& url, const GURL& site_for_cookies, network::mojom::CookieManagerGetOptionsPtr options, @@ -55,13 +54,12 @@ cookie_store_->GetCookieListWithOptionsAsync( url, net_options, - base::BindOnce( - &RestrictedCookieManagerImpl::CookieListToGetAllForUrlCallback, - weak_ptr_factory_.GetWeakPtr(), url, site_for_cookies, - std::move(options), std::move(callback))); + base::BindOnce(&RestrictedCookieManager::CookieListToGetAllForUrlCallback, + weak_ptr_factory_.GetWeakPtr(), url, site_for_cookies, + std::move(options), std::move(callback))); } -void RestrictedCookieManagerImpl::CookieListToGetAllForUrlCallback( +void RestrictedCookieManager::CookieListToGetAllForUrlCallback( const GURL& url, const GURL& site_for_cookies, network::mojom::CookieManagerGetOptionsPtr options, @@ -85,7 +83,7 @@ std::move(callback).Run(std::move(result)); } -void RestrictedCookieManagerImpl::SetCanonicalCookie( +void RestrictedCookieManager::SetCanonicalCookie( const net::CanonicalCookie& cookie, const GURL& url, const GURL& site_for_cookies,
diff --git a/content/network/restricted_cookie_manager_impl.h b/content/network/restricted_cookie_manager.h similarity index 78% rename from content/network/restricted_cookie_manager_impl.h rename to content/network/restricted_cookie_manager.h index c8a13d8d..c2b20cd 100644 --- a/content/network/restricted_cookie_manager_impl.h +++ b/content/network/restricted_cookie_manager.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_NETWORK_RESTRICTED_COOKIE_MANAGER_IMPL_H_ -#define CONTENT_NETWORK_RESTRICTED_COOKIE_MANAGER_IMPL_H_ +#ifndef CONTENT_NETWORK_RESTRICTED_COOKIE_MANAGER_H_ +#define CONTENT_NETWORK_RESTRICTED_COOKIE_MANAGER_H_ #include <string> @@ -28,13 +28,13 @@ // Instances of this class must be created and used on the I/O thread. Instances // are created by CreateMojoService() and are bound to the lifetimes of the // mojo connections that they serve, via mojo::StrongBinding. -class CONTENT_EXPORT RestrictedCookieManagerImpl +class CONTENT_EXPORT RestrictedCookieManager : public network::mojom::RestrictedCookieManager { public: - RestrictedCookieManagerImpl(net::CookieStore* cookie_store, - int render_process_id, - int render_frame_id); - ~RestrictedCookieManagerImpl() override; + RestrictedCookieManager(net::CookieStore* cookie_store, + int render_process_id, + int render_frame_id); + ~RestrictedCookieManager() override; // Implements CookieStore.getAll() in the Async Cookies API. // @@ -63,11 +63,11 @@ const int render_process_id_; const int render_frame_id_; - base::WeakPtrFactory<RestrictedCookieManagerImpl> weak_ptr_factory_; + base::WeakPtrFactory<RestrictedCookieManager> weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(RestrictedCookieManagerImpl); + DISALLOW_COPY_AND_ASSIGN(RestrictedCookieManager); }; } // namespace content -#endif // CONTENT_NETWORK_RESTRICTED_COOKIE_MANAGER_IMPL_H_ +#endif // CONTENT_NETWORK_RESTRICTED_COOKIE_MANAGER_H_
diff --git a/content/network/restricted_cookie_manager_impl_unittest.cc b/content/network/restricted_cookie_manager_unittest.cc similarity index 89% rename from content/network/restricted_cookie_manager_impl_unittest.cc rename to content/network/restricted_cookie_manager_unittest.cc index 08b1ca5..64e0280 100644 --- a/content/network/restricted_cookie_manager_impl_unittest.cc +++ b/content/network/restricted_cookie_manager_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/network/restricted_cookie_manager_impl.h" +#include "content/network/restricted_cookie_manager.h" #include <algorithm> @@ -76,19 +76,18 @@ DISALLOW_COPY_AND_ASSIGN(RestrictedCookieManagerSync); }; -class RestrictedCookieManagerImplTest : public testing::Test { +class RestrictedCookieManagerTest : public testing::Test { public: - RestrictedCookieManagerImplTest() + RestrictedCookieManagerTest() : cookie_monster_(nullptr, nullptr), - service_( - std::make_unique<RestrictedCookieManagerImpl>(&cookie_monster_, - MSG_ROUTING_NONE, - MSG_ROUTING_NONE)), + service_(std::make_unique<RestrictedCookieManager>(&cookie_monster_, + MSG_ROUTING_NONE, + MSG_ROUTING_NONE)), binding_(service_.get(), mojo::MakeRequest(&service_ptr_)) { sync_service_ = std::make_unique<RestrictedCookieManagerSync>(service_ptr_.get()); } - ~RestrictedCookieManagerImplTest() override {} + ~RestrictedCookieManagerTest() override {} void SetUp() override { CHECK(SetCanonicalCookie( @@ -116,7 +115,7 @@ protected: base::MessageLoopForIO message_loop_; net::CookieMonster cookie_monster_; - std::unique_ptr<content::RestrictedCookieManagerImpl> service_; + std::unique_ptr<content::RestrictedCookieManager> service_; network::mojom::RestrictedCookieManagerPtr service_ptr_; mojo::Binding<network::mojom::RestrictedCookieManager> binding_; std::unique_ptr<RestrictedCookieManagerSync> sync_service_; @@ -131,7 +130,7 @@ } // anonymous namespace -TEST_F(RestrictedCookieManagerImplTest, GetAllForUrl) { +TEST_F(RestrictedCookieManagerTest, GetAllForUrl) { auto options = network::mojom::CookieManagerGetOptions::New(); options->name = ""; options->match_type = network::mojom::CookieMatchType::STARTS_WITH; @@ -145,7 +144,7 @@ EXPECT_EQ("42", cookies[0].Value()); } -TEST_F(RestrictedCookieManagerImplTest, SetCanonicalCookie) { +TEST_F(RestrictedCookieManagerTest, SetCanonicalCookie) { EXPECT_TRUE(sync_service_->SetCanonicalCookie( net::CanonicalCookie( "foo", "bar", "example.com", "/", base::Time(), base::Time(),
diff --git a/content/network/url_loader_impl.cc b/content/network/url_loader.cc similarity index 88% rename from content/network/url_loader_impl.cc rename to content/network/url_loader.cc index 012cfdf..d93ded4 100644 --- a/content/network/url_loader_impl.cc +++ b/content/network/url_loader.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/network/url_loader_impl.h" +#include "content/network/url_loader.h" #include <string> @@ -262,14 +262,13 @@ } // namespace -URLLoaderImpl::URLLoaderImpl( - NetworkContext* context, - mojom::URLLoaderRequest url_loader_request, - int32_t options, - const ResourceRequest& request, - bool report_raw_headers, - mojom::URLLoaderClientPtr url_loader_client, - const net::NetworkTrafficAnnotationTag& traffic_annotation) +URLLoader::URLLoader(NetworkContext* context, + mojom::URLLoaderRequest url_loader_request, + int32_t options, + const ResourceRequest& request, + bool report_raw_headers, + mojom::URLLoaderClientPtr url_loader_client, + const net::NetworkTrafficAnnotationTag& traffic_annotation) : context_(context), options_(options), connected_(true), @@ -282,8 +281,8 @@ report_raw_headers_(report_raw_headers), weak_ptr_factory_(this) { context_->RegisterURLLoader(this); - binding_.set_connection_error_handler(base::BindOnce( - &URLLoaderImpl::OnConnectionError, base::Unretained(this))); + binding_.set_connection_error_handler( + base::BindOnce(&URLLoader::OnConnectionError, base::Unretained(this))); url_request_ = context_->url_request_context()->CreateRequest( GURL(request.url), net::DEFAULT_PRIORITY, this, traffic_annotation); @@ -307,7 +306,7 @@ if (request.enable_upload_progress) { upload_progress_tracker_ = std::make_unique<UploadProgressTracker>( FROM_HERE, - base::BindRepeating(&URLLoaderImpl::SendUploadProgress, + base::BindRepeating(&URLLoader::SendUploadProgress, base::Unretained(this)), url_request_.get()); } @@ -319,8 +318,8 @@ url_request_->SetRequestHeadersCallback( base::Bind(&net::HttpRawRequestHeaders::Assign, base::Unretained(&raw_request_headers_))); - url_request_->SetResponseHeadersCallback(base::Bind( - &URLLoaderImpl::SetRawResponseHeaders, base::Unretained(this))); + url_request_->SetResponseHeadersCallback( + base::Bind(&URLLoader::SetRawResponseHeaders, base::Unretained(this))); } AttachAcceptHeader(request.resource_type, url_request_.get()); @@ -328,7 +327,7 @@ url_request_->Start(); } -URLLoaderImpl::~URLLoaderImpl() { +URLLoader::~URLLoader() { context_->DeregisterURLLoader(this); if (update_body_read_before_paused_) @@ -346,13 +345,13 @@ } } -void URLLoaderImpl::Cleanup() { +void URLLoader::Cleanup() { // The associated network context is going away and we have to destroy // net::URLRequest held by this loader. delete this; } -void URLLoaderImpl::FollowRedirect() { +void URLLoader::FollowRedirect() { if (!url_request_) { NotifyCompleted(net::ERR_UNEXPECTED); // |this| may have been deleted. @@ -362,13 +361,13 @@ url_request_->FollowDeferredRedirect(); } -void URLLoaderImpl::SetPriority(net::RequestPriority priority, - int32_t intra_priority_value) { +void URLLoader::SetPriority(net::RequestPriority priority, + int32_t intra_priority_value) { NOTIMPLEMENTED(); } -void URLLoaderImpl::PauseReadingBodyFromNet() { - DVLOG(1) << "URLLoaderImpl pauses fetching response body for " +void URLLoader::PauseReadingBodyFromNet() { + DVLOG(1) << "URLLoader pauses fetching response body for " << (url_request_ ? url_request_->original_url().spec() : "a URL that has completed loading or failed."); // Please note that we pause reading body in all cases. Even if the URL @@ -388,8 +387,8 @@ } } -void URLLoaderImpl::ResumeReadingBodyFromNet() { - DVLOG(1) << "URLLoaderImpl resumes fetching response body for " +void URLLoader::ResumeReadingBodyFromNet() { + DVLOG(1) << "URLLoader resumes fetching response body for " << (url_request_ ? url_request_->original_url().spec() : "a URL that has completed loading or failed."); should_pause_reading_body_ = false; @@ -400,9 +399,9 @@ } } -void URLLoaderImpl::OnReceivedRedirect(net::URLRequest* url_request, - const net::RedirectInfo& redirect_info, - bool* defer_redirect) { +void URLLoader::OnReceivedRedirect(net::URLRequest* url_request, + const net::RedirectInfo& redirect_info, + bool* defer_redirect) { DCHECK(url_request == url_request_.get()); DCHECK(url_request->status().is_success()); @@ -421,8 +420,7 @@ url_loader_client_->OnReceiveRedirect(redirect_info, response->head); } -void URLLoaderImpl::OnResponseStarted(net::URLRequest* url_request, - int net_error) { +void URLLoader::OnResponseStarted(net::URLRequest* url_request, int net_error) { DCHECK(url_request == url_request_.get()); if (net_error != net::OK) { @@ -452,13 +450,13 @@ consumer_handle_ = std::move(data_pipe.consumer_handle); peer_closed_handle_watcher_.Watch( response_body_stream_.get(), MOJO_HANDLE_SIGNAL_PEER_CLOSED, - base::Bind(&URLLoaderImpl::OnResponseBodyStreamConsumerClosed, + base::Bind(&URLLoader::OnResponseBodyStreamConsumerClosed, base::Unretained(this))); peer_closed_handle_watcher_.ArmOrNotify(); writable_handle_watcher_.Watch( response_body_stream_.get(), MOJO_HANDLE_SIGNAL_WRITABLE, - base::Bind(&URLLoaderImpl::OnResponseBodyStreamReady, + base::Bind(&URLLoader::OnResponseBodyStreamReady, base::Unretained(this))); if (!(options_ & mojom::kURLLoadOptionSniffMimeType) || @@ -469,7 +467,7 @@ ReadMore(); } -void URLLoaderImpl::ReadMore() { +void URLLoader::ReadMore() { // Once the MIME type is sniffed, all data is sent as soon as it is read from // the network. DCHECK(consumer_handle_.is_valid() || !pending_write_); @@ -519,7 +517,7 @@ } } -void URLLoaderImpl::DidRead(int num_bytes, bool completed_synchronously) { +void URLLoader::DidRead(int num_bytes, bool completed_synchronously) { if (num_bytes > 0) pending_write_buffer_offset_ += num_bytes; if (update_body_read_before_paused_) { @@ -560,26 +558,25 @@ } if (completed_synchronously) { base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::BindOnce(&URLLoaderImpl::ReadMore, - weak_ptr_factory_.GetWeakPtr())); + FROM_HERE, + base::BindOnce(&URLLoader::ReadMore, weak_ptr_factory_.GetWeakPtr())); } else { ReadMore(); } } -void URLLoaderImpl::OnReadCompleted(net::URLRequest* url_request, - int bytes_read) { +void URLLoader::OnReadCompleted(net::URLRequest* url_request, int bytes_read) { DCHECK(url_request == url_request_.get()); DidRead(bytes_read, false); // |this| may have been deleted. } -base::WeakPtr<URLLoaderImpl> URLLoaderImpl::GetWeakPtrForTests() { +base::WeakPtr<URLLoader> URLLoader::GetWeakPtrForTests() { return weak_ptr_factory_.GetWeakPtr(); } -void URLLoaderImpl::NotifyCompleted(int error_code) { +void URLLoader::NotifyCompleted(int error_code) { // Ensure sending the final upload progress message here, since // OnResponseCompleted can be called without OnResponseStarted on cancellation // or error cases. @@ -605,16 +602,16 @@ DeleteIfNeeded(); } -void URLLoaderImpl::OnConnectionError() { +void URLLoader::OnConnectionError() { connected_ = false; DeleteIfNeeded(); } -void URLLoaderImpl::OnResponseBodyStreamConsumerClosed(MojoResult result) { +void URLLoader::OnResponseBodyStreamConsumerClosed(MojoResult result) { CloseResponseBodyStreamProducer(); } -void URLLoaderImpl::OnResponseBodyStreamReady(MojoResult result) { +void URLLoader::OnResponseBodyStreamReady(MojoResult result) { if (result != MOJO_RESULT_OK) { CloseResponseBodyStreamProducer(); return; @@ -623,7 +620,7 @@ ReadMore(); } -void URLLoaderImpl::CloseResponseBodyStreamProducer() { +void URLLoader::CloseResponseBodyStreamProducer() { url_request_.reset(); peer_closed_handle_watcher_.Cancel(); writable_handle_watcher_.Cancel(); @@ -641,13 +638,13 @@ DeleteIfNeeded(); } -void URLLoaderImpl::DeleteIfNeeded() { +void URLLoader::DeleteIfNeeded() { bool has_data_pipe = pending_write_.get() || response_body_stream_.is_valid(); if (!connected_ && !has_data_pipe) delete this; } -void URLLoaderImpl::SendResponseToClient() { +void URLLoader::SendResponseToClient() { base::Optional<net::SSLInfo> ssl_info; if (options_ & mojom::kURLLoadOptionSendSSLInfo) ssl_info = url_request_->ssl_info(); @@ -668,7 +665,7 @@ response_ = nullptr; } -void URLLoaderImpl::CompletePendingWrite() { +void URLLoader::CompletePendingWrite() { response_body_stream_ = pending_write_->Complete(pending_write_buffer_offset_); total_written_bytes_ += pending_write_buffer_offset_; @@ -676,26 +673,26 @@ pending_write_buffer_offset_ = 0; } -void URLLoaderImpl::SetRawResponseHeaders( +void URLLoader::SetRawResponseHeaders( scoped_refptr<const net::HttpResponseHeaders> headers) { raw_response_headers_ = headers; } -void URLLoaderImpl::UpdateBodyReadBeforePaused() { +void URLLoader::UpdateBodyReadBeforePaused() { DCHECK_GE(pending_write_buffer_offset_ + total_written_bytes_, body_read_before_paused_); body_read_before_paused_ = pending_write_buffer_offset_ + total_written_bytes_; } -void URLLoaderImpl::SendUploadProgress(const net::UploadProgress& progress) { +void URLLoader::SendUploadProgress(const net::UploadProgress& progress) { url_loader_client_->OnUploadProgress( progress.position(), progress.size(), - base::BindOnce(&URLLoaderImpl::OnUploadProgressACK, + base::BindOnce(&URLLoader::OnUploadProgressACK, weak_ptr_factory_.GetWeakPtr())); } -void URLLoaderImpl::OnUploadProgressACK() { +void URLLoader::OnUploadProgressACK() { if (upload_progress_tracker_) upload_progress_tracker_->OnAckReceived(); }
diff --git a/content/network/url_loader_impl.h b/content/network/url_loader.h similarity index 83% rename from content/network/url_loader_impl.h rename to content/network/url_loader.h index 7ae6b58..62dc586 100644 --- a/content/network/url_loader_impl.h +++ b/content/network/url_loader.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_NETWORK_URL_LOADER_IMPL_H_ -#define CONTENT_NETWORK_URL_LOADER_IMPL_H_ +#ifndef CONTENT_NETWORK_URL_LOADER_H_ +#define CONTENT_NETWORK_URL_LOADER_H_ #include <stdint.h> @@ -33,17 +33,17 @@ class NetworkContext; struct ResourceResponse; -class CONTENT_EXPORT URLLoaderImpl : public mojom::URLLoader, - public net::URLRequest::Delegate { +class CONTENT_EXPORT URLLoader : public mojom::URLLoader, + public net::URLRequest::Delegate { public: - URLLoaderImpl(NetworkContext* context, - mojom::URLLoaderRequest url_loader_request, - int32_t options, - const ResourceRequest& request, - bool report_raw_headers, - mojom::URLLoaderClientPtr url_loader_client, - const net::NetworkTrafficAnnotationTag& traffic_annotation); - ~URLLoaderImpl() override; + URLLoader(NetworkContext* context, + mojom::URLLoaderRequest url_loader_request, + int32_t options, + const ResourceRequest& request, + bool report_raw_headers, + mojom::URLLoaderClientPtr url_loader_client, + const net::NetworkTrafficAnnotationTag& traffic_annotation); + ~URLLoader() override; // Called when the associated NetworkContext is going away. void Cleanup(); @@ -63,7 +63,7 @@ void OnReadCompleted(net::URLRequest* url_request, int bytes_read) override; // Returns a WeakPtr so tests can validate that the object was destroyed. - base::WeakPtr<URLLoaderImpl> GetWeakPtrForTests(); + base::WeakPtr<URLLoader> GetWeakPtrForTests(); private: void ReadMore(); @@ -123,11 +123,11 @@ // as BodyReadFromNetBeforePaused. int64_t body_read_before_paused_ = -1; - base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_; + base::WeakPtrFactory<URLLoader> weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(URLLoaderImpl); + DISALLOW_COPY_AND_ASSIGN(URLLoader); }; } // namespace content -#endif // CONTENT_NETWORK_URL_LOADER_IMPL_H_ +#endif // CONTENT_NETWORK_URL_LOADER_H_
diff --git a/content/network/url_loader_unittest.cc b/content/network/url_loader_unittest.cc index ab590cd..c41007cf 100644 --- a/content/network/url_loader_unittest.cc +++ b/content/network/url_loader_unittest.cc
@@ -13,7 +13,7 @@ #include "base/test/scoped_task_environment.h" #include "base/threading/thread_task_runner_handle.h" #include "content/network/network_context.h" -#include "content/network/url_loader_impl.h" +#include "content/network/url_loader.h" #include "content/public/common/appcache_info.h" #include "content/public/common/content_paths.h" #include "content/public/test/controllable_http_response.h" @@ -147,15 +147,15 @@ } // namespace -class URLLoaderImplTest : public testing::Test { +class URLLoaderTest : public testing::Test { public: - URLLoaderImplTest() + URLLoaderTest() : scoped_task_environment_( base::test::ScopedTaskEnvironment::MainThreadType::IO), context_(NetworkContext::CreateForTesting()) { net::URLRequestFailedJob::AddUrlHandler(); } - ~URLLoaderImplTest() override { + ~URLLoaderTest() override { net::URLRequestFilter::GetInstance()->ClearHandlers(); } @@ -164,7 +164,7 @@ base::FilePath(FILE_PATH_LITERAL("content/test/data"))); // This Unretained is safe because test_server_ is owned by |this|. test_server_.RegisterRequestMonitor( - base::Bind(&URLLoaderImplTest::Monitor, base::Unretained(this))); + base::Bind(&URLLoaderTest::Monitor, base::Unretained(this))); ASSERT_TRUE(test_server_.Start()); } @@ -186,9 +186,9 @@ if (add_custom_accept_header_) request.headers.SetHeader("accept", "custom/*"); - URLLoaderImpl loader_impl(context(), mojo::MakeRequest(&loader), options, - request, false, client_.CreateInterfacePtr(), - TRAFFIC_ANNOTATION_FOR_TESTS); + URLLoader loader_impl(context(), mojo::MakeRequest(&loader), options, + request, false, client_.CreateInterfacePtr(), + TRAFFIC_ANNOTATION_FOR_TESTS); ran_ = true; @@ -389,15 +389,15 @@ TestURLLoaderClient client_; }; -TEST_F(URLLoaderImplTest, Basic) { +TEST_F(URLLoaderTest, Basic) { LoadAndCompareFile("simple_page.html"); } -TEST_F(URLLoaderImplTest, Empty) { +TEST_F(URLLoaderTest, Empty) { LoadAndCompareFile("empty.html"); } -TEST_F(URLLoaderImplTest, BasicSSL) { +TEST_F(URLLoaderTest, BasicSSL) { net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); https_server.ServeFilesFromSourceDirectory( base::FilePath(FILE_PATH_LITERAL("content/test/data"))); @@ -412,7 +412,7 @@ ASSERT_TRUE(https_server.GetCertificate()->Equals(ssl_info()->cert.get())); } -TEST_F(URLLoaderImplTest, SSLSentOnlyWhenRequested) { +TEST_F(URLLoaderTest, SSLSentOnlyWhenRequested) { net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); https_server.ServeFilesFromSourceDirectory( base::FilePath(FILE_PATH_LITERAL("content/test/data"))); @@ -424,7 +424,7 @@ } // Test decoded_body_length / encoded_body_length when they're different. -TEST_F(URLLoaderImplTest, GzipTest) { +TEST_F(URLLoaderTest, GzipTest) { std::string body; EXPECT_EQ(net::OK, Load(test_server()->GetURL("/gzip-body?Body"), &body)); EXPECT_EQ("Body", body); @@ -437,13 +437,13 @@ client()->completion_status().encoded_data_length); } -TEST_F(URLLoaderImplTest, ErrorBeforeHeaders) { +TEST_F(URLLoaderTest, ErrorBeforeHeaders) { EXPECT_EQ(net::ERR_EMPTY_RESPONSE, Load(test_server()->GetURL("/close-socket"), nullptr)); EXPECT_FALSE(client()->response_body().is_valid()); } -TEST_F(URLLoaderImplTest, SyncErrorWhileReadingBody) { +TEST_F(URLLoaderTest, SyncErrorWhileReadingBody) { std::string body; EXPECT_EQ(net::ERR_FAILED, Load(net::URLRequestFailedJob::GetMockHttpUrlWithFailurePhase( @@ -452,7 +452,7 @@ EXPECT_EQ("", body); } -TEST_F(URLLoaderImplTest, AsyncErrorWhileReadingBody) { +TEST_F(URLLoaderTest, AsyncErrorWhileReadingBody) { std::string body; EXPECT_EQ(net::ERR_FAILED, Load(net::URLRequestFailedJob::GetMockHttpUrlWithFailurePhase( @@ -461,7 +461,7 @@ EXPECT_EQ("", body); } -TEST_F(URLLoaderImplTest, SyncErrorWhileReadingBodyAfterBytesReceived) { +TEST_F(URLLoaderTest, SyncErrorWhileReadingBodyAfterBytesReceived) { const std::string kBody("Foo."); std::list<std::string> packets; @@ -474,7 +474,7 @@ EXPECT_EQ(kBody, body); } -TEST_F(URLLoaderImplTest, AsyncErrorWhileReadingBodyAfterBytesReceived) { +TEST_F(URLLoaderTest, AsyncErrorWhileReadingBodyAfterBytesReceived) { const std::string kBody("Foo."); std::list<std::string> packets; @@ -487,7 +487,7 @@ EXPECT_EQ(kBody, body); } -TEST_F(URLLoaderImplTest, DestroyContextWithLiveRequest) { +TEST_F(URLLoaderTest, DestroyContextWithLiveRequest) { GURL url = test_server()->GetURL("/hung-after-headers"); ResourceRequest request = CreateResourceRequest("GET", RESOURCE_TYPE_MAIN_FRAME, url); @@ -495,10 +495,10 @@ mojom::URLLoaderPtr loader; // The loader is implicitly owned by the client and the NetworkContext, so // don't hold on to a pointer to it. - base::WeakPtr<URLLoaderImpl> loader_impl = - (new URLLoaderImpl(context(), mojo::MakeRequest(&loader), 0, request, - false, client()->CreateInterfacePtr(), - TRAFFIC_ANNOTATION_FOR_TESTS)) + base::WeakPtr<URLLoader> loader_impl = + (new URLLoader(context(), mojo::MakeRequest(&loader), 0, request, false, + client()->CreateInterfacePtr(), + TRAFFIC_ANNOTATION_FOR_TESTS)) ->GetWeakPtrForTests(); client()->RunUntilResponseReceived(); @@ -518,47 +518,47 @@ EXPECT_EQ(0u, client()->download_data_length()); } -TEST_F(URLLoaderImplTest, DoNotSniffUnlessSpecified) { +TEST_F(URLLoaderTest, DoNotSniffUnlessSpecified) { EXPECT_EQ(net::OK, Load(test_server()->GetURL("/content-sniffer-test0.html"))); ASSERT_TRUE(mime_type().empty()); } -TEST_F(URLLoaderImplTest, SniffMimeType) { +TEST_F(URLLoaderTest, SniffMimeType) { set_sniff(); EXPECT_EQ(net::OK, Load(test_server()->GetURL("/content-sniffer-test0.html"))); ASSERT_EQ(std::string("text/html"), mime_type()); } -TEST_F(URLLoaderImplTest, RespectNoSniff) { +TEST_F(URLLoaderTest, RespectNoSniff) { set_sniff(); EXPECT_EQ(net::OK, Load(test_server()->GetURL("/nosniff-test.html"))); ASSERT_TRUE(mime_type().empty()); } -TEST_F(URLLoaderImplTest, DoNotSniffHTMLFromTextPlain) { +TEST_F(URLLoaderTest, DoNotSniffHTMLFromTextPlain) { set_sniff(); EXPECT_EQ(net::OK, Load(test_server()->GetURL("/content-sniffer-test1.html"))); ASSERT_EQ(std::string("text/plain"), mime_type()); } -TEST_F(URLLoaderImplTest, DoNotSniffHTMLFromImageGIF) { +TEST_F(URLLoaderTest, DoNotSniffHTMLFromImageGIF) { set_sniff(); EXPECT_EQ(net::OK, Load(test_server()->GetURL("/content-sniffer-test2.html"))); ASSERT_EQ(std::string("image/gif"), mime_type()); } -TEST_F(URLLoaderImplTest, EmptyHtmlIsTextPlain) { +TEST_F(URLLoaderTest, EmptyHtmlIsTextPlain) { set_sniff(); EXPECT_EQ(net::OK, Load(test_server()->GetURL("/content-sniffer-test4.html"))); ASSERT_EQ(std::string("text/plain"), mime_type()); } -TEST_F(URLLoaderImplTest, EmptyHtmlIsTextPlainWithAsyncResponse) { +TEST_F(URLLoaderTest, EmptyHtmlIsTextPlainWithAsyncResponse) { set_sniff(); const std::string kBody; @@ -576,7 +576,7 @@ // Tests the case where the first read doesn't have enough data to figure out // the right mime type. The second read would have enough data even though the // total bytes is still smaller than net::kMaxBytesToSniff. -TEST_F(URLLoaderImplTest, FirstReadNotEnoughToSniff1) { +TEST_F(URLLoaderTest, FirstReadNotEnoughToSniff1) { set_sniff(); std::string first(500, 'a'); std::string second(std::string(100, 'b')); @@ -588,7 +588,7 @@ } // Like above, except that the total byte count is > kMaxBytesToSniff. -TEST_F(URLLoaderImplTest, FirstReadNotEnoughToSniff2) { +TEST_F(URLLoaderTest, FirstReadNotEnoughToSniff2) { set_sniff(); std::string first(500, 'a'); std::string second(std::string(1000, 'b')); @@ -601,7 +601,7 @@ // Tests that even if the first and only read is smaller than the minimum number // of bytes needed to sniff, the loader works correctly and returns the data. -TEST_F(URLLoaderImplTest, LoneReadNotEnoughToSniff) { +TEST_F(URLLoaderTest, LoneReadNotEnoughToSniff) { set_sniff(); std::string first(net::kMaxBytesToSniff - 100, 'a'); LoadPacketsAndVerifyContents(first, std::string()); @@ -609,7 +609,7 @@ } // Tests the simple case where the first read is enough to sniff. -TEST_F(URLLoaderImplTest, FirstReadIsEnoughToSniff) { +TEST_F(URLLoaderTest, FirstReadIsEnoughToSniff) { set_sniff(); std::string first(net::kMaxBytesToSniff + 100, 'a'); LoadPacketsAndVerifyContents(first, std::string()); @@ -638,7 +638,7 @@ } }; -TEST_F(URLLoaderImplTest, CloseResponseBodyConsumerBeforeProducer) { +TEST_F(URLLoaderTest, CloseResponseBodyConsumerBeforeProducer) { net::EmbeddedTestServer server; server.RegisterRequestHandler( base::Bind([](const net::test_server::HttpRequest& request) { @@ -653,9 +653,8 @@ mojom::URLLoaderPtr loader; // The loader is implicitly owned by the client and the NetworkContext. - new URLLoaderImpl(context(), mojo::MakeRequest(&loader), 0, request, false, - client()->CreateInterfacePtr(), - TRAFFIC_ANNOTATION_FOR_TESTS); + new URLLoader(context(), mojo::MakeRequest(&loader), 0, request, false, + client()->CreateInterfacePtr(), TRAFFIC_ANNOTATION_FOR_TESTS); client()->RunUntilResponseBodyArrived(); EXPECT_TRUE(client()->has_received_response()); @@ -681,7 +680,7 @@ EXPECT_FALSE(client()->has_received_completion()); } -TEST_F(URLLoaderImplTest, PauseReadingBodyFromNetBeforeRespnoseHeaders) { +TEST_F(URLLoaderTest, PauseReadingBodyFromNetBeforeRespnoseHeaders) { const char* const kPath = "/hello.html"; const char* const kBodyContents = "This is the data as you requested."; @@ -694,9 +693,8 @@ mojom::URLLoaderPtr loader; // The loader is implicitly owned by the client and the NetworkContext. - new URLLoaderImpl(context(), mojo::MakeRequest(&loader), 0, request, false, - client()->CreateInterfacePtr(), - TRAFFIC_ANNOTATION_FOR_TESTS); + new URLLoader(context(), mojo::MakeRequest(&loader), 0, request, false, + client()->CreateInterfacePtr(), TRAFFIC_ANNOTATION_FOR_TESTS); // Pausing reading response body from network stops future reads from the // underlying URLRequest. So no data should be sent using the response body @@ -737,7 +735,7 @@ EXPECT_EQ(kBodyContents, available_data); } -TEST_F(URLLoaderImplTest, PauseReadingBodyFromNetWhenReadIsPending) { +TEST_F(URLLoaderTest, PauseReadingBodyFromNetWhenReadIsPending) { const char* const kPath = "/hello.html"; const char* const kBodyContentsFirstHalf = "This is the first half."; const char* const kBodyContentsSecondHalf = "This is the second half."; @@ -751,9 +749,8 @@ mojom::URLLoaderPtr loader; // The loader is implicitly owned by the client and the NetworkContext. - new URLLoaderImpl(context(), mojo::MakeRequest(&loader), 0, request, false, - client()->CreateInterfacePtr(), - TRAFFIC_ANNOTATION_FOR_TESTS); + new URLLoader(context(), mojo::MakeRequest(&loader), 0, request, false, + client()->CreateInterfacePtr(), TRAFFIC_ANNOTATION_FOR_TESTS); response_controller.WaitForRequest(); response_controller.Send( @@ -784,7 +781,7 @@ ReadBody()); } -TEST_F(URLLoaderImplTest, ResumeReadingBodyFromNetAfterClosingConsumer) { +TEST_F(URLLoaderTest, ResumeReadingBodyFromNetAfterClosingConsumer) { const char* const kPath = "/hello.html"; const char* const kBodyContentsFirstHalf = "This is the first half."; @@ -797,9 +794,8 @@ mojom::URLLoaderPtr loader; // The loader is implicitly owned by the client and the NetworkContext. - new URLLoaderImpl(context(), mojo::MakeRequest(&loader), 0, request, false, - client()->CreateInterfacePtr(), - TRAFFIC_ANNOTATION_FOR_TESTS); + new URLLoader(context(), mojo::MakeRequest(&loader), 0, request, false, + client()->CreateInterfacePtr(), TRAFFIC_ANNOTATION_FOR_TESTS); loader->PauseReadingBodyFromNet(); loader.FlushForTesting(); @@ -823,7 +819,7 @@ loader.FlushForTesting(); } -TEST_F(URLLoaderImplTest, MultiplePauseResumeReadingBodyFromNet) { +TEST_F(URLLoaderTest, MultiplePauseResumeReadingBodyFromNet) { const char* const kPath = "/hello.html"; const char* const kBodyContentsFirstHalf = "This is the first half."; const char* const kBodyContentsSecondHalf = "This is the second half."; @@ -837,9 +833,8 @@ mojom::URLLoaderPtr loader; // The loader is implicitly owned by the client and the NetworkContext. - new URLLoaderImpl(context(), mojo::MakeRequest(&loader), 0, request, false, - client()->CreateInterfacePtr(), - TRAFFIC_ANNOTATION_FOR_TESTS); + new URLLoader(context(), mojo::MakeRequest(&loader), 0, request, false, + client()->CreateInterfacePtr(), TRAFFIC_ANNOTATION_FOR_TESTS); // It is okay to call ResumeReadingBodyFromNet() even if there is no prior // PauseReadingBodyFromNet(). @@ -876,7 +871,7 @@ ReadBody()); } -TEST_F(URLLoaderImplTest, AttachAcceptHeaderForStyleSheet) { +TEST_F(URLLoaderTest, AttachAcceptHeaderForStyleSheet) { set_resource_type(RESOURCE_TYPE_STYLESHEET); EXPECT_EQ(net::OK, Load(test_server()->GetURL("/content-sniffer-test0.html"))); @@ -886,7 +881,7 @@ EXPECT_EQ(it->second, "text/css,*/*;q=0.1"); } -TEST_F(URLLoaderImplTest, AttachAcceptHeaderForXHR) { +TEST_F(URLLoaderTest, AttachAcceptHeaderForXHR) { set_resource_type(RESOURCE_TYPE_XHR); EXPECT_EQ(net::OK, Load(test_server()->GetURL("/content-sniffer-test0.html"))); @@ -896,7 +891,7 @@ EXPECT_EQ(it->second, "*/*"); } -TEST_F(URLLoaderImplTest, DoNotOverrideAcceptHeader) { +TEST_F(URLLoaderTest, DoNotOverrideAcceptHeader) { set_resource_type(RESOURCE_TYPE_XHR); set_add_custom_accept_header(); EXPECT_EQ(net::OK,
diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc index 2421e30..c64d6d48 100644 --- a/content/renderer/gpu/render_widget_compositor.cc +++ b/content/renderer/gpu/render_widget_compositor.cc
@@ -584,8 +584,10 @@ settings.disallow_non_exact_resource_reuse = cmd.HasSwitch(switches::kDisallowNonExactResourceReuse); - settings.wait_for_all_pipeline_stages_before_draw = - cmd.HasSwitch(cc::switches::kRunAllCompositorStagesBeforeDraw); + if (cmd.HasSwitch(cc::switches::kRunAllCompositorStagesBeforeDraw)) { + settings.wait_for_all_pipeline_stages_before_draw = true; + settings.enable_latency_recovery = false; + } settings.enable_image_animations = cmd.HasSwitch(switches::kEnableCompositorImageAnimations);
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index 8df031ae..3c1fe04 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn
@@ -1485,12 +1485,12 @@ "../common/throttling_url_loader_unittest.cc", "../common/unique_name_helper_unittest.cc", "../common/webplugininfo_unittest.cc", - "../network/cookie_manager_impl_unittest.cc", - "../network/network_change_manager_impl_unittest.cc", + "../network/cookie_manager_unittest.cc", + "../network/network_change_manager_unittest.cc", "../network/network_context_unittest.cc", "../network/network_service_unittest.cc", "../network/proxy_resolver_factory_mojo_unittest.cc", - "../network/restricted_cookie_manager_impl_unittest.cc", + "../network/restricted_cookie_manager_unittest.cc", "../network/throttling/throttling_controller_unittest.cc", "../network/upload_progress_tracker_unittest.cc", "../network/url_loader_unittest.cc",
diff --git a/ios/web_view/internal/signin/web_view_account_fetcher_service_factory.cc b/ios/web_view/internal/signin/web_view_account_fetcher_service_factory.cc index 58cab59a..51ccf50 100644 --- a/ios/web_view/internal/signin/web_view_account_fetcher_service_factory.cc +++ b/ios/web_view/internal/signin/web_view_account_fetcher_service_factory.cc
@@ -11,6 +11,7 @@ #include "components/keyed_service/ios/browser_state_dependency_manager.h" #include "components/signin/core/browser/account_fetcher_service.h" #include "components/signin/core/browser/profile_oauth2_token_service.h" +#include "ios/web_view/internal/signin/ios_web_view_signin_client.h" #include "ios/web_view/internal/signin/web_view_account_tracker_service_factory.h" #include "ios/web_view/internal/signin/web_view_oauth2_token_service_factory.h" #include "ios/web_view/internal/signin/web_view_signin_client_factory.h"
diff --git a/ios/web_view/internal/signin/web_view_account_tracker_service_factory.cc b/ios/web_view/internal/signin/web_view_account_tracker_service_factory.cc index a649197..a65af6c0 100644 --- a/ios/web_view/internal/signin/web_view_account_tracker_service_factory.cc +++ b/ios/web_view/internal/signin/web_view_account_tracker_service_factory.cc
@@ -10,6 +10,7 @@ #include "base/memory/singleton.h" #include "components/keyed_service/ios/browser_state_dependency_manager.h" #include "components/signin/core/browser/account_tracker_service.h" +#include "ios/web_view/internal/signin/ios_web_view_signin_client.h" #include "ios/web_view/internal/signin/web_view_signin_client_factory.h" #include "ios/web_view/internal/web_view_browser_state.h"
diff --git a/ios/web_view/internal/signin/web_view_gaia_cookie_manager_service_factory.cc b/ios/web_view/internal/signin/web_view_gaia_cookie_manager_service_factory.cc index 0e503a3f..ca88640b 100644 --- a/ios/web_view/internal/signin/web_view_gaia_cookie_manager_service_factory.cc +++ b/ios/web_view/internal/signin/web_view_gaia_cookie_manager_service_factory.cc
@@ -11,6 +11,7 @@ #include "components/signin/core/browser/gaia_cookie_manager_service.h" #include "components/signin/core/browser/profile_oauth2_token_service.h" #include "google_apis/gaia/gaia_constants.h" +#include "ios/web_view/internal/signin/ios_web_view_signin_client.h" #include "ios/web_view/internal/signin/web_view_oauth2_token_service_factory.h" #include "ios/web_view/internal/signin/web_view_signin_client_factory.h" #include "ios/web_view/internal/web_view_browser_state.h"
diff --git a/ios/web_view/internal/signin/web_view_oauth2_token_service_factory.mm b/ios/web_view/internal/signin/web_view_oauth2_token_service_factory.mm index 69f96931..e509c5e 100644 --- a/ios/web_view/internal/signin/web_view_oauth2_token_service_factory.mm +++ b/ios/web_view/internal/signin/web_view_oauth2_token_service_factory.mm
@@ -11,6 +11,7 @@ #include "components/signin/core/browser/profile_oauth2_token_service.h" #include "components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.h" #import "ios/web_view/internal/cwv_web_view_configuration_internal.h" +#include "ios/web_view/internal/signin/ios_web_view_signin_client.h" #include "ios/web_view/internal/signin/web_view_account_tracker_service_factory.h" #include "ios/web_view/internal/signin/web_view_profile_oauth2_token_service_ios_provider_impl.h" #include "ios/web_view/internal/signin/web_view_signin_client_factory.h"
diff --git a/ios/web_view/internal/signin/web_view_signin_client_factory.cc b/ios/web_view/internal/signin/web_view_signin_client_factory.cc index 2070ee7..d6073d7 100644 --- a/ios/web_view/internal/signin/web_view_signin_client_factory.cc +++ b/ios/web_view/internal/signin/web_view_signin_client_factory.cc
@@ -18,9 +18,9 @@ namespace ios_web_view { // static -SigninClient* WebViewSigninClientFactory::GetForBrowserState( +IOSWebViewSigninClient* WebViewSigninClientFactory::GetForBrowserState( ios_web_view::WebViewBrowserState* browser_state) { - return static_cast<SigninClient*>( + return static_cast<IOSWebViewSigninClient*>( GetInstance()->GetServiceForBrowserState(browser_state, true)); }
diff --git a/ios/web_view/internal/signin/web_view_signin_client_factory.h b/ios/web_view/internal/signin/web_view_signin_client_factory.h index 998163e..793eeb7 100644 --- a/ios/web_view/internal/signin/web_view_signin_client_factory.h +++ b/ios/web_view/internal/signin/web_view_signin_client_factory.h
@@ -15,7 +15,7 @@ struct DefaultSingletonTraits; } // namespace base -class SigninClient; +class IOSWebViewSigninClient; namespace ios_web_view { class WebViewBrowserState; @@ -24,7 +24,7 @@ // a browser state. class WebViewSigninClientFactory : public BrowserStateKeyedServiceFactory { public: - static SigninClient* GetForBrowserState( + static IOSWebViewSigninClient* GetForBrowserState( ios_web_view::WebViewBrowserState* browser_state); static WebViewSigninClientFactory* GetInstance();
diff --git a/ios/web_view/internal/signin/web_view_signin_manager_factory.cc b/ios/web_view/internal/signin/web_view_signin_manager_factory.cc index cb832d5..8ddf187 100644 --- a/ios/web_view/internal/signin/web_view_signin_manager_factory.cc +++ b/ios/web_view/internal/signin/web_view_signin_manager_factory.cc
@@ -14,6 +14,7 @@ #include "components/signin/core/browser/signin_manager.h" #include "components/signin/core/browser/signin_pref_names.h" #include "ios/web_view/internal/app/application_context.h" +#include "ios/web_view/internal/signin/ios_web_view_signin_client.h" #include "ios/web_view/internal/signin/web_view_account_tracker_service_factory.h" #include "ios/web_view/internal/signin/web_view_gaia_cookie_manager_service_factory.h" #include "ios/web_view/internal/signin/web_view_oauth2_token_service_factory.h"
diff --git a/media/audio/win/audio_device_listener_win.cc b/media/audio/win/audio_device_listener_win.cc index e5ea04a..d2b55ac 100644 --- a/media/audio/win/audio_device_listener_win.cc +++ b/media/audio/win/audio_device_listener_win.cc
@@ -35,12 +35,13 @@ : listener_cb_(listener_cb), tick_clock_(new base::DefaultTickClock()) { // CreateDeviceEnumerator can fail on some installations of Windows such // as "Windows Server 2008 R2" where the desktop experience isn't available. - Microsoft::WRL::ComPtr<IMMDeviceEnumerator> device_enumerator( - CoreAudioUtil::CreateDeviceEnumerator()); - if (!device_enumerator.Get()) + Microsoft::WRL::ComPtr<IMMDeviceEnumerator> device_enumerator; + HRESULT hr = + CoreAudioUtil::CreateDeviceEnumerator(device_enumerator.GetAddressOf()); + if (FAILED(hr)) return; - HRESULT hr = device_enumerator->RegisterEndpointNotificationCallback(this); + hr = device_enumerator->RegisterEndpointNotificationCallback(this); if (FAILED(hr)) { LOG(ERROR) << "RegisterEndpointNotificationCallback failed: " << std::hex << hr;
diff --git a/media/audio/win/audio_low_latency_output_win.cc b/media/audio/win/audio_low_latency_output_win.cc index d9ecbdd..4323912 100644 --- a/media/audio/win/audio_low_latency_output_win.cc +++ b/media/audio/win/audio_low_latency_output_win.cc
@@ -134,24 +134,14 @@ DCHECK(!audio_client_.Get()); DCHECK(!audio_render_client_.Get()); - // Will be set to true if we ended up opening the default communications - // device. - bool communications_device = false; + bool communications_device = + device_id_.empty() ? (device_role_ == eCommunications) : false; // Create an IAudioClient interface for the default rendering IMMDevice. Microsoft::WRL::ComPtr<IAudioClient> audio_client; - if (device_id_.empty()) { - audio_client = CoreAudioUtil::CreateDefaultClient(eRender, device_role_); - communications_device = (device_role_ == eCommunications); - } else { - Microsoft::WRL::ComPtr<IMMDevice> device = - CoreAudioUtil::CreateDevice(device_id_); - DLOG_IF(ERROR, !device.Get()) << "Failed to open device: " << device_id_; - if (device.Get()) - audio_client = CoreAudioUtil::CreateClient(device.Get()); - } - - if (!audio_client.Get()) + HRESULT hr = CoreAudioUtil::CreateClient(device_id_, eRender, device_role_, + audio_client.GetAddressOf()); + if (FAILED(hr)) return false; // Extra sanity to ensure that the provided device format is still valid. @@ -161,7 +151,7 @@ return false; } - HRESULT hr = S_FALSE; + hr = S_FALSE; if (share_mode_ == AUDCLNT_SHAREMODE_SHARED) { // Initialize the audio stream between the client and the device in shared // mode and using event-driven buffer handling. @@ -232,9 +222,10 @@ // Create an IAudioRenderClient client for an initialized IAudioClient. // The IAudioRenderClient interface enables us to write output data to // a rendering endpoint buffer. - Microsoft::WRL::ComPtr<IAudioRenderClient> audio_render_client = - CoreAudioUtil::CreateRenderClient(audio_client.Get()); - if (!audio_render_client.Get()) + Microsoft::WRL::ComPtr<IAudioRenderClient> audio_render_client; + hr = CoreAudioUtil::CreateRenderClient(audio_client.Get(), + audio_render_client.GetAddressOf()); + if (FAILED(hr)) return false; // Store valid COM interfaces.
diff --git a/media/audio/win/core_audio_util_win.cc b/media/audio/win/core_audio_util_win.cc index a525b22c..6b28512a 100644 --- a/media/audio/win/core_audio_util_win.cc +++ b/media/audio/win/core_audio_util_win.cc
@@ -175,12 +175,12 @@ return hr; } -ComPtr<IMMDeviceEnumerator> CreateDeviceEnumeratorInternal( - bool allow_reinitialize) { - ComPtr<IMMDeviceEnumerator> device_enumerator; - HRESULT hr = ::CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, - CLSCTX_INPROC_SERVER, - IID_PPV_ARGS(&device_enumerator)); +HRESULT CreateDeviceEnumeratorInternal( + bool allow_reinitialize, + IMMDeviceEnumerator** device_enumerator) { + HRESULT hr = + ::CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, + CLSCTX_INPROC_SERVER, IID_PPV_ARGS(device_enumerator)); if (hr == CO_E_NOTINITIALIZED && allow_reinitialize) { LOG(ERROR) << "CoCreateInstance fails with CO_E_NOTINITIALIZED"; // We have seen crashes which indicates that this method can in fact @@ -191,10 +191,10 @@ if (SUCCEEDED(hr)) { hr = ::CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_INPROC_SERVER, - IID_PPV_ARGS(&device_enumerator)); + IID_PPV_ARGS(device_enumerator)); } } - return device_enumerator; + return hr; } ChannelLayout GetChannelLayout(const WAVEFORMATPCMEX& mix_format) { @@ -224,19 +224,21 @@ return channel_layout; } -ComPtr<IMMDevice> CreateDeviceInternal(const std::string& device_id, - bool is_output_device) { +HRESULT CreateDeviceInternal(const std::string& device_id, + bool is_output_device, + IMMDevice** device) { EDataFlow data_flow = is_output_device ? eRender : eCapture; if (device_id == AudioDeviceDescription::kDefaultDeviceId) { - return CoreAudioUtil::CreateDefaultDevice(data_flow, eConsole); + return CoreAudioUtil::CreateDefaultDevice(data_flow, eConsole, device); } else if (device_id == AudioDeviceDescription::kLoopbackInputDeviceId || device_id == AudioDeviceDescription::kLoopbackWithMuteDeviceId) { DCHECK(!is_output_device); - return CoreAudioUtil::CreateDefaultDevice(eRender, eConsole); + return CoreAudioUtil::CreateDefaultDevice(eRender, eConsole, device); } else if (device_id == AudioDeviceDescription::kCommunicationsDeviceId) { - return CoreAudioUtil::CreateDefaultDevice(data_flow, eCommunications); + return CoreAudioUtil::CreateDefaultDevice(data_flow, eCommunications, + device); } else { - return CoreAudioUtil::CreateDevice(device_id); + return CoreAudioUtil::CreateDevice(device_id, device); } } @@ -261,16 +263,14 @@ // all devices to guarantee Core Audio support. To be 100%, we also verify // that it is possible to a create the IMMDeviceEnumerator interface. If // this works as well we should be home free. - ComPtr<IMMDeviceEnumerator> device_enumerator = - CreateDeviceEnumeratorInternal(false); - if (!device_enumerator) { - LOG(ERROR) - << "Failed to create Core Audio device enumerator on thread with ID " - << GetCurrentThreadId(); - return false; - } + ComPtr<IMMDeviceEnumerator> device_enumerator; + HRESULT hr = + CreateDeviceEnumeratorInternal(false, device_enumerator.GetAddressOf()); + LOG_IF(ERROR, FAILED(hr)) + << "Failed to create Core Audio device enumerator on thread with ID " + << GetCurrentThreadId(); - return true; + return SUCCEEDED(hr); } } // namespace @@ -293,16 +293,17 @@ int CoreAudioUtil::NumberOfActiveDevices(EDataFlow data_flow) { // Create the IMMDeviceEnumerator interface. - ComPtr<IMMDeviceEnumerator> device_enumerator = CreateDeviceEnumerator(); - if (!device_enumerator.Get()) + ComPtr<IMMDeviceEnumerator> device_enumerator; + HRESULT hr = CreateDeviceEnumerator(device_enumerator.GetAddressOf()); + if (FAILED(hr)) return 0; // Generate a collection of active (present and not disabled) audio endpoint // devices for the specified data-flow direction. // This method will succeed even if all devices are disabled. ComPtr<IMMDeviceCollection> collection; - HRESULT hr = device_enumerator->EnumAudioEndpoints( - data_flow, DEVICE_STATE_ACTIVE, collection.GetAddressOf()); + hr = device_enumerator->EnumAudioEndpoints(data_flow, DEVICE_STATE_ACTIVE, + collection.GetAddressOf()); if (FAILED(hr)) { LOG(ERROR) << "IMMDeviceCollection::EnumAudioEndpoints: " << std::hex << hr; return 0; @@ -316,71 +317,71 @@ return static_cast<int>(number_of_active_devices); } -ComPtr<IMMDeviceEnumerator> CoreAudioUtil::CreateDeviceEnumerator() { - return CreateDeviceEnumeratorInternal(true); +HRESULT CoreAudioUtil::CreateDeviceEnumerator( + IMMDeviceEnumerator** device_enumerator) { + return CreateDeviceEnumeratorInternal(true, device_enumerator); } -ComPtr<IMMDevice> CoreAudioUtil::CreateDefaultDevice(EDataFlow data_flow, - ERole role) { - ComPtr<IMMDevice> endpoint_device; - - // Create the IMMDeviceEnumerator interface. - ComPtr<IMMDeviceEnumerator> device_enumerator = CreateDeviceEnumerator(); - if (!device_enumerator.Get()) - return endpoint_device; +HRESULT CoreAudioUtil::CreateDefaultDevice(EDataFlow data_flow, + ERole role, + IMMDevice** endpoint_device) { + ComPtr<IMMDeviceEnumerator> device_enumerator; + HRESULT hr = CreateDeviceEnumerator(device_enumerator.GetAddressOf()); + if (FAILED(hr)) + return hr; // Retrieve the default audio endpoint for the specified data-flow // direction and role. - HRESULT hr = device_enumerator->GetDefaultAudioEndpoint( - data_flow, role, endpoint_device.GetAddressOf()); + hr = device_enumerator->GetDefaultAudioEndpoint(data_flow, role, + endpoint_device); if (FAILED(hr)) { DVLOG(1) << "IMMDeviceEnumerator::GetDefaultAudioEndpoint: " << std::hex << hr; - return endpoint_device; + return hr; } // Verify that the audio endpoint device is active, i.e., that the audio // adapter that connects to the endpoint device is present and enabled. - if (!IsDeviceActive(endpoint_device.Get())) { + if (!IsDeviceActive(*endpoint_device)) { DVLOG(1) << "Selected endpoint device is not active"; - endpoint_device.Reset(); + *endpoint_device = nullptr; + return E_POINTER; } - return endpoint_device; + return hr; } std::string CoreAudioUtil::GetDefaultOutputDeviceID() { - ComPtr<IMMDevice> device(CreateDefaultDevice(eRender, eConsole)); - return device.Get() ? GetDeviceID(device.Get()) : std::string(); + ComPtr<IMMDevice> device; + HRESULT hr = CreateDefaultDevice(eRender, eConsole, device.GetAddressOf()); + return SUCCEEDED(hr) ? GetDeviceID(device.Get()) : std::string(); } -ComPtr<IMMDevice> CoreAudioUtil::CreateDevice(const std::string& device_id) { - ComPtr<IMMDevice> endpoint_device; - - // Create the IMMDeviceEnumerator interface. - ComPtr<IMMDeviceEnumerator> device_enumerator = CreateDeviceEnumerator(); - if (!device_enumerator.Get()) - return endpoint_device; +HRESULT CoreAudioUtil::CreateDevice(const std::string& device_id, + IMMDevice** endpoint_device) { + ComPtr<IMMDeviceEnumerator> device_enumerator; + HRESULT hr = CreateDeviceEnumerator(device_enumerator.GetAddressOf()); + if (FAILED(hr)) + return hr; // Retrieve an audio device specified by an endpoint device-identification // string. - HRESULT hr = device_enumerator->GetDevice( - base::UTF8ToUTF16(device_id).c_str(), endpoint_device.GetAddressOf()); - DVLOG_IF(1, FAILED(hr)) << "IMMDeviceEnumerator::GetDevice: " - << std::hex << hr; + hr = device_enumerator->GetDevice(base::UTF8ToUTF16(device_id).c_str(), + endpoint_device); if (FAILED(hr)) { DVLOG(1) << "IMMDeviceEnumerator::GetDevice: " << std::hex << hr; - return endpoint_device; + return hr; } // Verify that the audio endpoint device is active, i.e., that the audio // adapter that connects to the endpoint device is present and enabled. - if (!IsDeviceActive(endpoint_device.Get())) { + if (!IsDeviceActive(*endpoint_device)) { DVLOG(1) << "Selected endpoint device is not active"; - endpoint_device.Reset(); + *endpoint_device = nullptr; + return E_POINTER; } - return endpoint_device; + return hr; } HRESULT CoreAudioUtil::GetDeviceName(IMMDevice* device, AudioDeviceName* name) { @@ -462,17 +463,21 @@ return AudioDeviceDescription::kCommunicationsDeviceId; ComPtr<IMMDevice> input_device; + HRESULT hr; if (IsDefaultDeviceId(input_device_id)) { - input_device = CreateDefaultDevice(eCapture, eConsole); + hr = CreateDefaultDevice(eCapture, eConsole, input_device.GetAddressOf()); } else { - input_device = CreateDevice(input_device_id); + hr = CreateDevice(input_device_id, input_device.GetAddressOf()); } - if (!input_device.Get()) + if (FAILED(hr)) return std::string(); // See if we can get id of the associated controller. - ComPtr<IMMDeviceEnumerator> enumerator(CreateDeviceEnumerator()); + ComPtr<IMMDeviceEnumerator> enumerator; + hr = CreateDeviceEnumerator(enumerator.GetAddressOf()); + if (FAILED(hr)) + return std::string(); std::string controller_id( GetAudioControllerID(input_device.Get(), enumerator.Get())); if (controller_id.empty()) @@ -481,9 +486,9 @@ // Now enumerate the available (and active) output devices and see if any of // them is associated with the same controller. ComPtr<IMMDeviceCollection> collection; - enumerator->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, - collection.GetAddressOf()); - if (!collection.Get()) + hr = enumerator->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, + collection.GetAddressOf()); + if (FAILED(hr)) return std::string(); UINT count = 0; @@ -502,12 +507,13 @@ } std::string CoreAudioUtil::GetFriendlyName(const std::string& device_id) { - ComPtr<IMMDevice> audio_device = CreateDevice(device_id); - if (!audio_device.Get()) + ComPtr<IMMDevice> audio_device; + HRESULT hr = CreateDevice(device_id, audio_device.GetAddressOf()); + if (FAILED(hr)) return std::string(); AudioDeviceName device_name; - HRESULT hr = GetDeviceName(audio_device.Get(), &device_name); + hr = GetDeviceName(audio_device.Get(), &device_name); if (FAILED(hr)) return std::string(); @@ -517,8 +523,9 @@ bool CoreAudioUtil::DeviceIsDefault(EDataFlow flow, ERole role, const std::string& device_id) { - ComPtr<IMMDevice> device = CreateDefaultDevice(flow, role); - if (!device.Get()) + ComPtr<IMMDevice> device; + HRESULT hr = CreateDefaultDevice(flow, role, device.GetAddressOf()); + if (FAILED(hr)) return false; std::string str_default(GetDeviceID(device.Get())); @@ -542,36 +549,42 @@ return data_flow; } -ComPtr<IAudioClient> CoreAudioUtil::CreateClient(IMMDevice* audio_device) { +HRESULT CoreAudioUtil::CreateClient(IMMDevice* audio_device, + IAudioClient** audio_client) { // Creates and activates an IAudioClient COM object given the selected // endpoint device. - ComPtr<IAudioClient> audio_client; - HRESULT hr = audio_device->Activate(__uuidof(IAudioClient), - CLSCTX_INPROC_SERVER, - NULL, - &audio_client); + HRESULT hr = + audio_device->Activate(__uuidof(IAudioClient), CLSCTX_INPROC_SERVER, NULL, + reinterpret_cast<void**>(audio_client)); DVLOG_IF(1, FAILED(hr)) << "IMMDevice::Activate: " << std::hex << hr; - return audio_client; + return hr; } -ComPtr<IAudioClient> CoreAudioUtil::CreateDefaultClient(EDataFlow data_flow, - ERole role) { - ComPtr<IMMDevice> default_device(CreateDefaultDevice(data_flow, role)); - return (default_device.Get() ? CreateClient(default_device.Get()) - : ComPtr<IAudioClient>()); +HRESULT CoreAudioUtil::CreateDefaultClient(EDataFlow data_flow, + ERole role, + IAudioClient** audio_client) { + ComPtr<IMMDevice> default_device; + HRESULT hr = + CreateDefaultDevice(data_flow, role, default_device.GetAddressOf()); + if (FAILED(hr)) + return hr; + + return CreateClient(default_device.Get(), audio_client); } -ComPtr<IAudioClient> CoreAudioUtil::CreateClient(const std::string& device_id, - EDataFlow data_flow, - ERole role) { +HRESULT CoreAudioUtil::CreateClient(const std::string& device_id, + EDataFlow data_flow, + ERole role, + IAudioClient** audio_client) { if (IsDefaultDeviceId(device_id)) - return CreateDefaultClient(data_flow, role); + return CreateDefaultClient(data_flow, role, audio_client); - ComPtr<IMMDevice> device(CreateDevice(device_id)); - if (!device.Get()) - return ComPtr<IAudioClient>(); + ComPtr<IMMDevice> device; + HRESULT hr = CreateDevice(device_id, device.GetAddressOf()); + if (FAILED(hr)) + return hr; - return CreateClient(device.Get()); + return CreateClient(device.Get(), audio_client); } HRESULT CoreAudioUtil::GetSharedModeMixFormat( @@ -616,12 +629,13 @@ ERole role, ChannelLayout channel_layout) { // First, get the preferred mixing format for shared mode streams. - ComPtr<IAudioClient> client(CreateClient(device_id, data_flow, role)); - if (!client.Get()) + ComPtr<IAudioClient> client; + HRESULT hr = CreateClient(device_id, data_flow, role, client.GetAddressOf()); + if (FAILED(hr)) return false; WAVEFORMATPCMEX format; - HRESULT hr = GetSharedModeMixFormat(client.Get(), &format); + hr = GetSharedModeMixFormat(client.Get(), &format); if (FAILED(hr)) return false; @@ -676,8 +690,8 @@ return hr; } -HRESULT CoreAudioUtil::GetPreferredAudioParameters( - IAudioClient* client, AudioParameters* params) { +HRESULT CoreAudioUtil::GetPreferredAudioParameters(IAudioClient* client, + AudioParameters* params) { WAVEFORMATPCMEX mix_format; HRESULT hr = GetSharedModeMixFormat(client, &mix_format); if (FAILED(hr)) @@ -724,21 +738,18 @@ HRESULT CoreAudioUtil::GetPreferredAudioParameters(const std::string& device_id, bool is_output_device, AudioParameters* params) { - ComPtr<IMMDevice> device = CreateDeviceInternal(device_id, is_output_device); - if (!device.Get()) { - // Map NULL-pointer to new error code which can be different from the - // actual error code. The exact value is not important here. - return AUDCLNT_E_DEVICE_INVALIDATED; - } + ComPtr<IMMDevice> device; + HRESULT hr = + CreateDeviceInternal(device_id, is_output_device, device.GetAddressOf()); + if (FAILED(hr)) + return hr; - ComPtr<IAudioClient> client(CreateClient(device.Get())); - if (!client.Get()) { - // Map NULL-pointer to new error code which can be different from the - // actual error code. The exact value is not important here. - return AUDCLNT_E_ENDPOINT_CREATE_FAILED; - } + ComPtr<IAudioClient> client; + hr = CreateClient(device.Get(), client.GetAddressOf()); + if (FAILED(hr)) + return hr; - HRESULT hr = GetPreferredAudioParameters(client.Get(), params); + hr = GetPreferredAudioParameters(client.Get(), params); if (FAILED(hr) || is_output_device || !params->IsValid()) return hr; @@ -758,10 +769,12 @@ ChannelConfig CoreAudioUtil::GetChannelConfig(const std::string& device_id, EDataFlow data_flow) { - ComPtr<IAudioClient> client(CreateClient(device_id, data_flow, eConsole)); + ComPtr<IAudioClient> client; + HRESULT hr = + CreateClient(device_id, data_flow, eConsole, client.GetAddressOf()); WAVEFORMATPCMEX format = {}; - if (!client.Get() || FAILED(GetSharedModeMixFormat(client.Get(), &format))) + if (FAILED(hr) || FAILED(GetSharedModeMixFormat(client.Get(), &format))) return 0; return static_cast<ChannelConfig>(format.dwChannelMask); @@ -827,30 +840,32 @@ return hr; } -ComPtr<IAudioRenderClient> CoreAudioUtil::CreateRenderClient( - IAudioClient* client) { +HRESULT CoreAudioUtil::CreateRenderClient( + IAudioClient* client, + IAudioRenderClient** audio_render_client) { // Get access to the IAudioRenderClient interface. This interface // enables us to write output data to a rendering endpoint buffer. - ComPtr<IAudioRenderClient> audio_render_client; - HRESULT hr = client->GetService(IID_PPV_ARGS(&audio_render_client)); + HRESULT hr = client->GetService(IID_PPV_ARGS(audio_render_client)); if (FAILED(hr)) { DVLOG(1) << "IAudioClient::GetService: " << std::hex << hr; - return ComPtr<IAudioRenderClient>(); + *audio_render_client = nullptr; + return E_POINTER; } - return audio_render_client; + return hr; } -ComPtr<IAudioCaptureClient> CoreAudioUtil::CreateCaptureClient( - IAudioClient* client) { +HRESULT CoreAudioUtil::CreateCaptureClient( + IAudioClient* client, + IAudioCaptureClient** audio_capture_client) { // Get access to the IAudioCaptureClient interface. This interface // enables us to read input data from a capturing endpoint buffer. - ComPtr<IAudioCaptureClient> audio_capture_client; - HRESULT hr = client->GetService(IID_PPV_ARGS(&audio_capture_client)); + HRESULT hr = client->GetService(IID_PPV_ARGS(audio_capture_client)); if (FAILED(hr)) { DVLOG(1) << "IAudioClient::GetService: " << std::hex << hr; - return ComPtr<IAudioCaptureClient>(); + *audio_capture_client = nullptr; + return E_POINTER; } - return audio_capture_client; + return hr; } bool CoreAudioUtil::FillRenderEndpointBufferWithSilence(
diff --git a/media/audio/win/core_audio_util_win.h b/media/audio/win/core_audio_util_win.h index cdb5d19..cb538ba 100644 --- a/media/audio/win/core_audio_util_win.h +++ b/media/audio/win/core_audio_util_win.h
@@ -59,13 +59,14 @@ // Creates an IMMDeviceEnumerator interface which provides methods for // enumerating audio endpoint devices. - static Microsoft::WRL::ComPtr<IMMDeviceEnumerator> CreateDeviceEnumerator(); + static HRESULT CreateDeviceEnumerator( + IMMDeviceEnumerator** device_enumerator); // Creates a default endpoint device that is specified by a data-flow // direction and role, e.g. default render device. - static Microsoft::WRL::ComPtr<IMMDevice> CreateDefaultDevice( - EDataFlow data_flow, - ERole role); + static HRESULT CreateDefaultDevice(EDataFlow data_flow, + ERole role, + IMMDevice** endpoint_device); // Returns the device id of the default output device or an empty string // if no such device exists or if the default device has been disabled. @@ -73,8 +74,8 @@ // Creates an endpoint device that is specified by a unique endpoint device- // identification string. - static Microsoft::WRL::ComPtr<IMMDevice> CreateDevice( - const std::string& device_id); + static HRESULT CreateDevice(const std::string& device_id, + IMMDevice** endpoint_device); // Returns the unique ID and user-friendly name of a given endpoint device. // Example: "{0.0.1.00000000}.{8db6020f-18e3-4f25-b6f5-7726c9122574}", and @@ -121,19 +122,21 @@ // audio stream between an audio application and the audio engine (for a // shared-mode stream) or the hardware buffer of an audio endpoint device // (for an exclusive-mode stream). - static Microsoft::WRL::ComPtr<IAudioClient> CreateDefaultClient( - EDataFlow data_flow, - ERole role); + static HRESULT CreateDefaultClient(EDataFlow data_flow, + ERole role, + IAudioClient** audio_client); // Create an IAudioClient instance for a specific device _or_ the default // device if |device_id| is empty. - static Microsoft::WRL::ComPtr<IAudioClient> - CreateClient(const std::string& device_id, EDataFlow data_flow, ERole role); + static HRESULT CreateClient(const std::string& device_id, + EDataFlow data_flow, + ERole role, + IAudioClient** audio_client); // Create an IAudioClient interface for an existing IMMDevice given by // |audio_device|. Flow direction and role is define by the |audio_device|. - static Microsoft::WRL::ComPtr<IAudioClient> CreateClient( - IMMDevice* audio_device); + static HRESULT CreateClient(IMMDevice* audio_device, + IAudioClient** audio_client); // Get the mix format that the audio engine uses internally for processing // of shared-mode streams. This format is not necessarily a format that the @@ -215,14 +218,15 @@ // Create an IAudioRenderClient client for an existing IAudioClient given by // |client|. The IAudioRenderClient interface enables a client to write // output data to a rendering endpoint buffer. - static Microsoft::WRL::ComPtr<IAudioRenderClient> CreateRenderClient( - IAudioClient* client); + static HRESULT CreateRenderClient(IAudioClient* client, + IAudioRenderClient** audio_render_client); // Create an IAudioCaptureClient client for an existing IAudioClient given by // |client|. The IAudioCaptureClient interface enables a client to read // input data from a capture endpoint buffer. - static Microsoft::WRL::ComPtr<IAudioCaptureClient> CreateCaptureClient( - IAudioClient* client); + static HRESULT CreateCaptureClient( + IAudioClient* client, + IAudioCaptureClient** audio_capture_client); // Fills up the endpoint rendering buffer with silence for an existing // IAudioClient given by |client| and a corresponding IAudioRenderClient
diff --git a/media/audio/win/core_audio_util_win_unittest.cc b/media/audio/win/core_audio_util_win_unittest.cc index 2c53456a..a595059 100644 --- a/media/audio/win/core_audio_util_win_unittest.cc +++ b/media/audio/win/core_audio_util_win_unittest.cc
@@ -64,9 +64,10 @@ TEST_F(CoreAudioUtilWinTest, CreateDeviceEnumerator) { ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); - ComPtr<IMMDeviceEnumerator> enumerator = - CoreAudioUtil::CreateDeviceEnumerator(); + ComPtr<IMMDeviceEnumerator> enumerator; + HRESULT hr = CoreAudioUtil::CreateDeviceEnumerator(enumerator.GetAddressOf()); EXPECT_TRUE(enumerator.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); } TEST_F(CoreAudioUtilWinTest, CreateDefaultDevice) { @@ -84,35 +85,44 @@ {eCapture, eMultimedia} }; + HRESULT hr; // Create default devices for all flow/role combinations above. ComPtr<IMMDevice> audio_device; for (size_t i = 0; i < arraysize(data); ++i) { - audio_device = - CoreAudioUtil::CreateDefaultDevice(data[i].flow, data[i].role); + hr = CoreAudioUtil::CreateDefaultDevice(data[i].flow, data[i].role, + audio_device.GetAddressOf()); EXPECT_TRUE(audio_device.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); EXPECT_EQ(data[i].flow, CoreAudioUtil::GetDataFlow(audio_device.Get())); } // Only eRender and eCapture are allowed as flow parameter. - audio_device = CoreAudioUtil::CreateDefaultDevice(eAll, eConsole); + hr = CoreAudioUtil::CreateDefaultDevice(eAll, eConsole, + audio_device.GetAddressOf()); EXPECT_FALSE(audio_device.Get()); + EXPECT_FALSE(SUCCEEDED(hr)); } TEST_F(CoreAudioUtilWinTest, CreateDevice) { ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); // Get name and ID of default device used for playback. - ComPtr<IMMDevice> default_render_device = - CoreAudioUtil::CreateDefaultDevice(eRender, eConsole); + ComPtr<IMMDevice> default_render_device; + HRESULT hr = CoreAudioUtil::CreateDefaultDevice( + eRender, eConsole, default_render_device.GetAddressOf()); + EXPECT_TRUE(default_render_device.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); AudioDeviceName default_render_name; EXPECT_TRUE(SUCCEEDED(CoreAudioUtil::GetDeviceName( default_render_device.Get(), &default_render_name))); // Use the uniqe ID as input to CreateDevice() and create a corresponding // IMMDevice. - ComPtr<IMMDevice> audio_device = - CoreAudioUtil::CreateDevice(default_render_name.unique_id); + ComPtr<IMMDevice> audio_device; + hr = CoreAudioUtil::CreateDevice(default_render_name.unique_id, + audio_device.GetAddressOf()); EXPECT_TRUE(audio_device.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); // Verify that the two IMMDevice interfaces represents the same endpoint // by comparing their unique IDs. @@ -139,8 +149,10 @@ ComPtr<IMMDevice> audio_device; AudioDeviceName device_name; for (size_t i = 0; i < arraysize(data); ++i) { - audio_device = - CoreAudioUtil::CreateDefaultDevice(data[i].flow, data[i].role); + HRESULT hr = CoreAudioUtil::CreateDefaultDevice( + data[i].flow, data[i].role, audio_device.GetAddressOf()); + EXPECT_TRUE(audio_device.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); EXPECT_TRUE(SUCCEEDED( CoreAudioUtil::GetDeviceName(audio_device.Get(), &device_name))); EXPECT_FALSE(device_name.device_name.empty()); @@ -151,9 +163,10 @@ TEST_F(CoreAudioUtilWinTest, GetAudioControllerID) { ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); - ComPtr<IMMDeviceEnumerator> enumerator( - CoreAudioUtil::CreateDeviceEnumerator()); + ComPtr<IMMDeviceEnumerator> enumerator; + HRESULT hr = CoreAudioUtil::CreateDeviceEnumerator(enumerator.GetAddressOf()); ASSERT_TRUE(enumerator.Get()); + ASSERT_TRUE(SUCCEEDED(hr)); // Enumerate all active input and output devices and fetch the ID of // the associated device. @@ -178,10 +191,13 @@ ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); // Get name and ID of default device used for recording. - ComPtr<IMMDevice> audio_device = - CoreAudioUtil::CreateDefaultDevice(eCapture, eConsole); + ComPtr<IMMDevice> audio_device; + HRESULT hr = CoreAudioUtil::CreateDefaultDevice(eCapture, eConsole, + audio_device.GetAddressOf()); + EXPECT_TRUE(audio_device.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); AudioDeviceName device_name; - HRESULT hr = CoreAudioUtil::GetDeviceName(audio_device.Get(), &device_name); + hr = CoreAudioUtil::GetDeviceName(audio_device.Get(), &device_name); EXPECT_TRUE(SUCCEEDED(hr)); // Use unique ID as input to GetFriendlyName() and compare the result @@ -191,7 +207,10 @@ EXPECT_EQ(friendly_name, device_name.device_name); // Same test as above but for playback. - audio_device = CoreAudioUtil::CreateDefaultDevice(eRender, eConsole); + hr = CoreAudioUtil::CreateDefaultDevice(eRender, eConsole, + audio_device.GetAddressOf()); + EXPECT_TRUE(audio_device.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); hr = CoreAudioUtil::GetDeviceName(audio_device.Get(), &device_name); EXPECT_TRUE(SUCCEEDED(hr)); friendly_name = CoreAudioUtil::GetFriendlyName(device_name.unique_id); @@ -203,8 +222,11 @@ // Verify that the default render device is correctly identified as a // default device. - ComPtr<IMMDevice> audio_device = - CoreAudioUtil::CreateDefaultDevice(eRender, eConsole); + ComPtr<IMMDevice> audio_device; + HRESULT hr = CoreAudioUtil::CreateDefaultDevice(eRender, eConsole, + audio_device.GetAddressOf()); + EXPECT_TRUE(audio_device.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); AudioDeviceName name; EXPECT_TRUE( SUCCEEDED(CoreAudioUtil::GetDeviceName(audio_device.Get(), &name))); @@ -220,8 +242,10 @@ for (size_t i = 0; i < arraysize(data); ++i) { ComPtr<IAudioClient> client; - client = CoreAudioUtil::CreateDefaultClient(data[i], eConsole); + HRESULT hr = CoreAudioUtil::CreateDefaultClient(data[i], eConsole, + client.GetAddressOf()); EXPECT_TRUE(client.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); } } @@ -233,11 +257,14 @@ for (size_t i = 0; i < arraysize(data); ++i) { ComPtr<IMMDevice> device; ComPtr<IAudioClient> client; - device = CoreAudioUtil::CreateDefaultDevice(data[i], eConsole); + HRESULT hr = CoreAudioUtil::CreateDefaultDevice(data[i], eConsole, + device.GetAddressOf()); EXPECT_TRUE(device.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); EXPECT_EQ(data[i], CoreAudioUtil::GetDataFlow(device.Get())); - client = CoreAudioUtil::CreateClient(device.Get()); + hr = CoreAudioUtil::CreateClient(device.Get(), client.GetAddressOf()); EXPECT_TRUE(client.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); } } @@ -246,10 +273,13 @@ ComPtr<IMMDevice> device; ComPtr<IAudioClient> client; - device = CoreAudioUtil::CreateDefaultDevice(eRender, eConsole); + HRESULT hr = CoreAudioUtil::CreateDefaultDevice(eRender, eConsole, + device.GetAddressOf()); EXPECT_TRUE(device.Get()); - client = CoreAudioUtil::CreateClient(device.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); + hr = CoreAudioUtil::CreateClient(device.Get(), client.GetAddressOf()); EXPECT_TRUE(client.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); // Perform a simple sanity test of the aquired format structure. WAVEFORMATPCMEX format; @@ -299,8 +329,10 @@ ComPtr<IAudioClient> client; REFERENCE_TIME shared_time_period = 0; REFERENCE_TIME exclusive_time_period = 0; - client = CoreAudioUtil::CreateDefaultClient(data[i], eConsole); + HRESULT hr = CoreAudioUtil::CreateDefaultClient(data[i], eConsole, + client.GetAddressOf()); EXPECT_TRUE(client.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); EXPECT_TRUE(SUCCEEDED(CoreAudioUtil::GetDevicePeriod( client.Get(), AUDCLNT_SHAREMODE_SHARED, &shared_time_period))); EXPECT_GT(shared_time_period, 0); @@ -321,8 +353,10 @@ for (size_t i = 0; i < arraysize(data); ++i) { ComPtr<IAudioClient> client; AudioParameters params; - client = CoreAudioUtil::CreateDefaultClient(data[i], eConsole); + HRESULT hr = CoreAudioUtil::CreateDefaultClient(data[i], eConsole, + client.GetAddressOf()); EXPECT_TRUE(client.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); EXPECT_TRUE(SUCCEEDED( CoreAudioUtil::GetPreferredAudioParameters(client.Get(), ¶ms))); EXPECT_TRUE(params.IsValid()); @@ -333,8 +367,10 @@ ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); ComPtr<IAudioClient> client; - client = CoreAudioUtil::CreateDefaultClient(eRender, eConsole); + HRESULT hr = CoreAudioUtil::CreateDefaultClient(eRender, eConsole, + client.GetAddressOf()); EXPECT_TRUE(client.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); WAVEFORMATPCMEX format; EXPECT_TRUE( @@ -342,8 +378,8 @@ // Perform a shared-mode initialization without event-driven buffer handling. uint32_t endpoint_buffer_size = 0; - HRESULT hr = CoreAudioUtil::SharedModeInitialize(client.Get(), &format, NULL, - &endpoint_buffer_size, NULL); + hr = CoreAudioUtil::SharedModeInitialize(client.Get(), &format, NULL, + &endpoint_buffer_size, NULL); EXPECT_TRUE(SUCCEEDED(hr)); EXPECT_GT(endpoint_buffer_size, 0u); @@ -354,8 +390,10 @@ EXPECT_EQ(hr, AUDCLNT_E_ALREADY_INITIALIZED); // Verify that it is possible to reinitialize the client after releasing it. - client = CoreAudioUtil::CreateDefaultClient(eRender, eConsole); + hr = CoreAudioUtil::CreateDefaultClient(eRender, eConsole, + client.GetAddressOf()); EXPECT_TRUE(client.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); hr = CoreAudioUtil::SharedModeInitialize(client.Get(), &format, NULL, &endpoint_buffer_size, NULL); EXPECT_TRUE(SUCCEEDED(hr)); @@ -364,8 +402,10 @@ // Use a non-supported format and verify that initialization fails. // A simple way to emulate an invalid format is to use the shared-mode // mixing format and modify the preferred sample. - client = CoreAudioUtil::CreateDefaultClient(eRender, eConsole); + hr = CoreAudioUtil::CreateDefaultClient(eRender, eConsole, + client.GetAddressOf()); EXPECT_TRUE(client.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); format.Format.nSamplesPerSec = format.Format.nSamplesPerSec + 1; EXPECT_FALSE(CoreAudioUtil::IsFormatSupported( client.Get(), AUDCLNT_SHAREMODE_SHARED, &format)); @@ -379,8 +419,10 @@ // to be processed by the client (not verified here). // The event handle should be in the nonsignaled state. base::win::ScopedHandle event_handle(::CreateEvent(NULL, TRUE, FALSE, NULL)); - client = CoreAudioUtil::CreateDefaultClient(eRender, eConsole); + hr = CoreAudioUtil::CreateDefaultClient(eRender, eConsole, + client.GetAddressOf()); EXPECT_TRUE(client.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); EXPECT_TRUE( SUCCEEDED(CoreAudioUtil::GetSharedModeMixFormat(client.Get(), &format))); EXPECT_TRUE(CoreAudioUtil::IsFormatSupported( @@ -404,33 +446,43 @@ ComPtr<IAudioRenderClient> render_client; ComPtr<IAudioCaptureClient> capture_client; - client = CoreAudioUtil::CreateDefaultClient(data[i], eConsole); + HRESULT hr = CoreAudioUtil::CreateDefaultClient(data[i], eConsole, + client.GetAddressOf()); EXPECT_TRUE(client.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); EXPECT_TRUE(SUCCEEDED( CoreAudioUtil::GetSharedModeMixFormat(client.Get(), &format))); if (data[i] == eRender) { // It is not possible to create a render client using an unitialized // client interface. - render_client = CoreAudioUtil::CreateRenderClient(client.Get()); + hr = CoreAudioUtil::CreateRenderClient(client.Get(), + render_client.GetAddressOf()); EXPECT_FALSE(render_client.Get()); + EXPECT_FALSE(SUCCEEDED(hr)); // Do a proper initialization and verify that it works this time. CoreAudioUtil::SharedModeInitialize(client.Get(), &format, NULL, &endpoint_buffer_size, NULL); - render_client = CoreAudioUtil::CreateRenderClient(client.Get()); + hr = CoreAudioUtil::CreateRenderClient(client.Get(), + render_client.GetAddressOf()); EXPECT_TRUE(render_client.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); EXPECT_GT(endpoint_buffer_size, 0u); } else if (data[i] == eCapture) { // It is not possible to create a capture client using an unitialized // client interface. - capture_client = CoreAudioUtil::CreateCaptureClient(client.Get()); + hr = CoreAudioUtil::CreateCaptureClient(client.Get(), + capture_client.GetAddressOf()); EXPECT_FALSE(capture_client.Get()); + EXPECT_FALSE(SUCCEEDED(hr)); // Do a proper initialization and verify that it works this time. CoreAudioUtil::SharedModeInitialize(client.Get(), &format, NULL, &endpoint_buffer_size, NULL); - capture_client = CoreAudioUtil::CreateCaptureClient(client.Get()); + hr = CoreAudioUtil::CreateCaptureClient(client.Get(), + capture_client.GetAddressOf()); EXPECT_TRUE(capture_client.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); EXPECT_GT(endpoint_buffer_size, 0u); } } @@ -440,9 +492,11 @@ ABORT_AUDIO_TEST_IF_NOT(DevicesAvailable()); // Create default clients using the default mixing format for shared mode. - ComPtr<IAudioClient> client( - CoreAudioUtil::CreateDefaultClient(eRender, eConsole)); + ComPtr<IAudioClient> client; + HRESULT hr = CoreAudioUtil::CreateDefaultClient(eRender, eConsole, + client.GetAddressOf()); EXPECT_TRUE(client.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); WAVEFORMATPCMEX format; uint32_t endpoint_buffer_size = 0; @@ -452,9 +506,11 @@ &endpoint_buffer_size, NULL); EXPECT_GT(endpoint_buffer_size, 0u); - ComPtr<IAudioRenderClient> render_client( - CoreAudioUtil::CreateRenderClient(client.Get())); - EXPECT_TRUE(render_client.Get()); + ComPtr<IAudioRenderClient> render_client; + hr = CoreAudioUtil::CreateRenderClient(client.Get(), + render_client.GetAddressOf()); + EXPECT_TRUE(client.Get()); + EXPECT_TRUE(SUCCEEDED(hr)); // The endpoint audio buffer should not be filled up by default after being // created. @@ -479,9 +535,10 @@ bool found_a_pair = false; - ComPtr<IMMDeviceEnumerator> enumerator( - CoreAudioUtil::CreateDeviceEnumerator()); + ComPtr<IMMDeviceEnumerator> enumerator; + HRESULT hr = CoreAudioUtil::CreateDeviceEnumerator(enumerator.GetAddressOf()); ASSERT_TRUE(enumerator.Get()); + ASSERT_TRUE(SUCCEEDED(hr)); // Enumerate all active input and output devices and fetch the ID of // the associated device.
diff --git a/testing/buildbot/chromium.perf.fyi.json b/testing/buildbot/chromium.perf.fyi.json index 678a877..543bcaf 100644 --- a/testing/buildbot/chromium.perf.fyi.json +++ b/testing/buildbot/chromium.perf.fyi.json
@@ -1226,7 +1226,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -1256,7 +1256,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -1288,7 +1288,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -1318,7 +1318,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -5310,7 +5310,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -5340,7 +5340,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -5372,7 +5372,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -5402,7 +5402,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ],
diff --git a/testing/buildbot/chromium.perf.json b/testing/buildbot/chromium.perf.json index 972b91a5..3eb566b2 100644 --- a/testing/buildbot/chromium.perf.json +++ b/testing/buildbot/chromium.perf.json
@@ -1054,7 +1054,7 @@ "-v", "--upload-results", "--browser=android-chromium", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -1083,7 +1083,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -1114,7 +1114,7 @@ "-v", "--upload-results", "--browser=android-chromium", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -1143,7 +1143,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -5865,7 +5865,7 @@ "-v", "--upload-results", "--browser=android-chromium", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -5894,7 +5894,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -5925,7 +5925,7 @@ "-v", "--upload-results", "--browser=android-chromium", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -5954,7 +5954,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -10166,7 +10166,7 @@ "-v", "--upload-results", "--browser=android-webview", - "--output-format=chartjson", + "--output-format=histograms", "--webview-embedder-apk=../../out/Release/apks/SystemWebViewShell.apk" ], "isolate_name": "telemetry_perf_webview_tests", @@ -10196,7 +10196,7 @@ "-v", "--upload-results", "--browser=android-webview", - "--output-format=chartjson", + "--output-format=histograms", "--webview-embedder-apk=../../out/Release/apks/SystemWebViewShell.apk" ], "isolate_name": "telemetry_perf_webview_tests", @@ -13040,7 +13040,7 @@ "-v", "--upload-results", "--browser=android-chromium", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -13069,7 +13069,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -13100,7 +13100,7 @@ "-v", "--upload-results", "--browser=android-chromium", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -13129,7 +13129,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -17341,7 +17341,7 @@ "-v", "--upload-results", "--browser=android-webview", - "--output-format=chartjson", + "--output-format=histograms", "--webview-embedder-apk=../../out/Release/apks/SystemWebViewShell.apk" ], "isolate_name": "telemetry_perf_webview_tests", @@ -17371,7 +17371,7 @@ "-v", "--upload-results", "--browser=android-webview", - "--output-format=chartjson", + "--output-format=histograms", "--webview-embedder-apk=../../out/Release/apks/SystemWebViewShell.apk" ], "isolate_name": "telemetry_perf_webview_tests", @@ -20215,7 +20215,7 @@ "-v", "--upload-results", "--browser=android-chromium", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -20244,7 +20244,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -20275,7 +20275,7 @@ "-v", "--upload-results", "--browser=android-chromium", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -20304,7 +20304,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -25026,7 +25026,7 @@ "-v", "--upload-results", "--browser=android-chromium", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -25055,7 +25055,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -25086,7 +25086,7 @@ "-v", "--upload-results", "--browser=android-chromium", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -25115,7 +25115,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -29876,7 +29876,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -29906,7 +29906,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -29938,7 +29938,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -29968,7 +29968,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -34146,7 +34146,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -34176,7 +34176,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -34208,7 +34208,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -34238,7 +34238,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -38291,7 +38291,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -38321,7 +38321,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -38353,7 +38353,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -38383,7 +38383,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -42436,7 +42436,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -42466,7 +42466,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -42498,7 +42498,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -42528,7 +42528,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -46581,7 +46581,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -46611,7 +46611,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -46643,7 +46643,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -46673,7 +46673,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -50705,7 +50705,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -50735,7 +50735,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -50767,7 +50767,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -50797,7 +50797,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -54850,7 +54850,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -54880,7 +54880,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -54912,7 +54912,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -54942,7 +54942,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -58871,7 +58871,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -58901,7 +58901,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -58933,7 +58933,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -58963,7 +58963,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -62871,7 +62871,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -62901,7 +62901,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -62933,7 +62933,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -62963,7 +62963,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -66913,7 +66913,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -66943,7 +66943,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -66975,7 +66975,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -67005,7 +67005,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -70997,7 +70997,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -71027,7 +71027,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -71059,7 +71059,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -71089,7 +71089,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -75060,7 +75060,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -75090,7 +75090,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -75122,7 +75122,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -75152,7 +75152,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -79150,7 +79150,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -79180,7 +79180,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -79212,7 +79212,7 @@ "-v", "--upload-results", "--browser=release", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -79242,7 +79242,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -83192,7 +83192,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -83222,7 +83222,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -83254,7 +83254,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -83284,7 +83284,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -87234,7 +87234,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.noisy_benchmark_1", @@ -87264,7 +87264,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ], @@ -87296,7 +87296,7 @@ "-v", "--upload-results", "--browser=release_x64", - "--output-format=chartjson" + "--output-format=histograms" ], "isolate_name": "telemetry_perf_tests", "name": "dummy_benchmark.stable_benchmark_1", @@ -87326,7 +87326,7 @@ "-v", "--upload-results", "--browser=reference", - "--output-format=chartjson", + "--output-format=histograms", "--max-failures=5", "--output-trace-tag=_ref" ],
diff --git a/testing/buildbot/chromium.webkit.json b/testing/buildbot/chromium.webkit.json index 320fb842..a691dec 100644 --- a/testing/buildbot/chromium.webkit.json +++ b/testing/buildbot/chromium.webkit.json
@@ -409,6 +409,29 @@ "test": "wtf_unittests" } ], + "isolated_scripts": [ + { + "isolate_name": "webkit_layout_tests_exparchive", + "merge": { + "args": [ + "--verbose" + ], + "script": "//third_party/WebKit/Tools/Scripts/merge-layout-test-results" + }, + "name": "webkit_layout_tests", + "results_handler": "layout tests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "none", + "os": "Mac-10.11.6" + } + ], + "shards": 4 + } + } + ], "scripts": [ { "name": "webkit_lint", @@ -435,6 +458,31 @@ "test": "wtf_unittests" } ], + "isolated_scripts": [ + { + "isolate_name": "webkit_layout_tests_exparchive", + "merge": { + "args": [ + "--verbose" + ], + "script": "//third_party/WebKit/Tools/Scripts/merge-layout-test-results" + }, + "name": "webkit_layout_tests", + "results_handler": "layout tests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "1002:6821", + "hidpi": "1", + "os": "Mac-10.12.6", + "pool": "Chrome-GPU" + } + ], + "shards": 4 + } + } + ], "scripts": [ { "name": "webkit_lint",
diff --git a/third_party/WebKit/LayoutTests/fast/css3-text/css3-text-indent/text-indent-anonymous.html b/third_party/WebKit/LayoutTests/fast/css3-text/css3-text-indent/text-indent-anonymous.html new file mode 100644 index 0000000..4b60bdb --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/css3-text/css3-text-indent/text-indent-anonymous.html
@@ -0,0 +1,24 @@ +<!DOCTYPE html> +<script src="../../../resources/testharness.js"></script> +<script src="../../../resources/testharnessreport.js"></script> +<style> +#container { + outline: blue solid; + font-size: 20px; + line-height: 1; + text-indent: -3ch; + width: 5ch; +} +</style> +<p>For the <a href="https://drafts.csswg.org/css-text-3/#text-indent-property">text-indent</a> property, + the first line of an anonymous block box is only affected if it is the first child of its parent element.</p> +<div id=container> + <div></div> + 00 00 00 +</div> +<script> +test(() => { + let element = document.getElementById('container'); + assert_equals(element.offsetHeight, 40); +}, "first formatted line of an anonymous block"); +</script>
diff --git a/third_party/WebKit/Source/core/css/StyleEngine.cpp b/third_party/WebKit/Source/core/css/StyleEngine.cpp index 7754bf0..9ad810f 100644 --- a/third_party/WebKit/Source/core/css/StyleEngine.cpp +++ b/third_party/WebKit/Source/core/css/StyleEngine.cpp
@@ -275,7 +275,7 @@ } bool StyleEngine::ShouldUpdateDocumentStyleSheetCollection() const { - return all_tree_scopes_dirty_ || document_scope_dirty_; + return all_tree_scopes_dirty_ || document_scope_dirty_ || font_cache_dirty_; } bool StyleEngine::ShouldUpdateShadowTreeStyleSheetCollection() const { @@ -523,6 +523,20 @@ resolver_->InvalidateMatchedPropertiesCache(); } +void StyleEngine::RefreshFontCache() { + DCHECK(IsFontCacheDirty()); + + ClearFontCache(); + + // Rebuild the font cache with @font-face rules from user style sheets. + for (unsigned i = 0; i < active_user_style_sheets_.size(); ++i) { + DCHECK(active_user_style_sheets_[i].second); + AddFontFaceRules(*active_user_style_sheets_[i].second); + } + + font_cache_dirty_ = false; +} + void StyleEngine::UpdateGenericFontFamilySettings() { // FIXME: we should not update generic font family settings when // document is inactive. @@ -1148,6 +1162,13 @@ tree_scope.GetScopedStyleResolver()) append_all_sheets = scoped_resolver->NeedsAppendAllSheets(); + // When the font cache is dirty we have to rebuild it and then add all the + // @font-face rules in the document scope. + if (IsFontCacheDirty()) { + DCHECK(tree_scope.RootNode().IsDocumentNode()); + append_all_sheets = true; + } + if (change == kNoActiveSheetsChanged && !append_all_sheets) return; } @@ -1158,13 +1179,35 @@ unsigned changed_rule_flags = GetRuleSetFlags(changed_rule_sets); bool fonts_changed = tree_scope.RootNode().IsDocumentNode() && (changed_rule_flags & kFontFaceRules); + bool keyframes_changed = changed_rule_flags & kKeyframesRules; unsigned append_start_index = 0; - // We don't need to clear the font cache if new sheets are appended. - if (fonts_changed && change == kActiveSheetsChanged) - ClearFontCache(); + // We don't need to mark the font cache dirty if new sheets are appended. + if (fonts_changed && (invalidation_scope == kInvalidateAllScopes || + change == kActiveSheetsChanged)) { + MarkFontCacheDirty(); + } + + if (invalidation_scope == kInvalidateAllScopes) { + if (keyframes_changed) { + if (change == kActiveSheetsChanged) + ClearKeyframeRules(); + + for (auto it = new_style_sheets.begin(); + it != new_style_sheets.end(); it++) { + DCHECK(it->second); + AddKeyframeRules(*it->second); + } + } + } if (invalidation_scope == kInvalidateCurrentScope) { + if (IsFontCacheDirty()) { + DCHECK(tree_scope.RootNode().IsDocumentNode()); + DCHECK(change != kActiveSheetsAppended || append_all_sheets); + RefreshFontCache(); + } + // - If all sheets were removed, we remove the ScopedStyleResolver. // - If new sheets were appended to existing ones, start appending after the // common prefix. @@ -1199,20 +1242,8 @@ if (changed_rule_sets.IsEmpty()) return; - if (changed_rule_flags & kKeyframesRules) { - if (invalidation_scope == kInvalidateAllScopes) { - if (change == kActiveSheetsChanged) - ClearKeyframeRules(); - - for (auto it = new_style_sheets.begin(); - it != new_style_sheets.end(); it++) { - DCHECK(it->second); - AddKeyframeRules(*it->second); - } - } - + if (keyframes_changed) ScopedStyleResolver::KeyframesRulesAdded(tree_scope); - } Node& invalidation_root = ScopedStyleResolver::InvalidationRootForTreeScope(tree_scope); @@ -1340,6 +1371,20 @@ } } +void StyleEngine::AddFontFaceRules(const RuleSet& rule_set) { + if (!font_selector_) + return; + + const HeapVector<Member<StyleRuleFontFace>> font_face_rules = + rule_set.FontFaceRules(); + for (auto& font_face_rule : font_face_rules) { + if (FontFace* font_face = FontFace::Create(document_, font_face_rule)) + font_selector_->GetFontFaceCache()->Add(font_face_rule, font_face); + } + if (resolver_ && font_face_rules.size()) + resolver_->InvalidateMatchedPropertiesCache(); +} + void StyleEngine::AddKeyframeRules(const RuleSet& rule_set) { const HeapVector<Member<StyleRuleKeyframes>> keyframes_rules = rule_set.KeyframesRules();
diff --git a/third_party/WebKit/Source/core/css/StyleEngine.h b/third_party/WebKit/Source/core/css/StyleEngine.h index 4e91f56..3aeaddb 100644 --- a/third_party/WebKit/Source/core/css/StyleEngine.h +++ b/third_party/WebKit/Source/core/css/StyleEngine.h
@@ -215,7 +215,6 @@ void SetFontSelector(CSSFontSelector*); void RemoveFontFaceRules(const HeapVector<Member<const StyleRuleFontFace>>&); - void ClearFontCache(); // updateGenericFontFamilySettings is used from WebSettingsImpl. void UpdateGenericFontFamilySettings(); @@ -364,8 +363,14 @@ const MediaQueryEvaluator& EnsureMediaQueryEvaluator(); void UpdateStyleSheetList(TreeScope&); + void ClearFontCache(); + void RefreshFontCache(); + void MarkFontCacheDirty() { font_cache_dirty_ = true; } + bool IsFontCacheDirty() const { return font_cache_dirty_; } + void ClearKeyframeRules() { keyframes_rule_map_.clear(); } + void AddFontFaceRules(const RuleSet&); void AddKeyframeRules(const RuleSet&); void AddKeyframeStyle(StyleRuleKeyframes*); @@ -419,6 +424,7 @@ HeapHashSet<Member<Element>> whitespace_reattach_set_; Member<CSSFontSelector> font_selector_; + bool font_cache_dirty_ = false; HeapHashMap<AtomicString, WeakMember<StyleSheetContents>> text_to_sheet_cache_;
diff --git a/third_party/WebKit/Source/core/css/StyleEngineTest.cpp b/third_party/WebKit/Source/core/css/StyleEngineTest.cpp index a8e13e61..24c494c0 100644 --- a/third_party/WebKit/Source/core/css/StyleEngineTest.cpp +++ b/third_party/WebKit/Source/core/css/StyleEngineTest.cpp
@@ -6,6 +6,7 @@ #include <memory> #include "bindings/core/v8/V8BindingForCore.h" +#include "core/css/CSSFontSelector.h" #include "core/css/CSSRuleList.h" #include "core/css/CSSStyleRule.h" #include "core/css/CSSStyleSheet.h" @@ -82,14 +83,21 @@ TEST_F(StyleEngineTest, AnalyzedInject) { GetDocument().body()->SetInnerHTMLFromString(R"HTML( <style> + @font-face { + font-family: 'Cool Font'; + src: local(monospace); + font-weight: bold; + } #t1 { color: red !important } #t2 { color: black } - #t4 { animation-name: dummy-animation } + #t4 { font-family: 'Cool Font'; font-weight: bold; font-style: italic } + #t5 { animation-name: dummy-animation } </style> <div id='t1'>Green</div> <div id='t2'>White</div> <div id='t3' style='color: black !important'>White</div> - <div id='t4'>I animate!</div> + <div id='t4'>I look cool.</div> + <div id='t5'>I animate!</div> <div></div> )HTML"); GetDocument().View()->UpdateAllLifecyclePhases(); @@ -191,14 +199,108 @@ EXPECT_EQ(MakeRGB(0, 0, 0), t3->GetComputedStyle()->VisitedDependentColor(CSSPropertyColor)); - // @keyframes rules + // @font-face rules Element* t4 = GetDocument().getElementById("t4"); ASSERT_TRUE(t4); + ASSERT_TRUE(t4->GetComputedStyle()); + + // There's only one font and it's bold and normal. + EXPECT_EQ(1u, GetStyleEngine().GetFontSelector()->GetFontFaceCache() + ->GetNumSegmentedFacesForTesting()); + CSSSegmentedFontFace* font_face = + GetStyleEngine().GetFontSelector()->GetFontFaceCache() + ->Get(t4->GetComputedStyle()->GetFontDescription(), + AtomicString("Cool Font")); + EXPECT_TRUE(font_face); + FontSelectionCapabilities capabilities = + font_face->GetFontSelectionCapabilities(); + ASSERT_EQ(capabilities.weight, + FontSelectionRange({BoldWeightValue(), BoldWeightValue()})); + ASSERT_EQ(capabilities.slope, + FontSelectionRange({NormalSlopeValue(), NormalSlopeValue()})); + + StyleSheetContents* font_face_parsed_sheet = + StyleSheetContents::Create(CSSParserContext::Create(GetDocument())); + font_face_parsed_sheet->ParseString( + "@font-face {" + " font-family: 'Cool Font';" + " src: local(monospace);" + " font-weight: bold;" + " font-style: italic;" + "}" + ); + WebStyleSheetId font_face_id = + GetStyleEngine().AddUserSheet(font_face_parsed_sheet); + GetDocument().View()->UpdateAllLifecyclePhases(); + + // After injecting a more specific font, now there are two and the + // bold-italic one is selected. + EXPECT_EQ(2u, GetStyleEngine().GetFontSelector()->GetFontFaceCache() + ->GetNumSegmentedFacesForTesting()); + font_face = GetStyleEngine().GetFontSelector()->GetFontFaceCache() + ->Get(t4->GetComputedStyle()->GetFontDescription(), + AtomicString("Cool Font")); + EXPECT_TRUE(font_face); + capabilities = font_face->GetFontSelectionCapabilities(); + ASSERT_EQ(capabilities.weight, + FontSelectionRange({BoldWeightValue(), BoldWeightValue()})); + ASSERT_EQ(capabilities.slope, + FontSelectionRange({ItalicSlopeValue(), ItalicSlopeValue()})); + + HTMLStyleElement* style_element = HTMLStyleElement::Create( + GetDocument(), false); + style_element->SetInnerHTMLFromString( + "@font-face {" + " font-family: 'Cool Font';" + " src: local(monospace);" + " font-weight: normal;" + " font-style: italic;" + "}" + ); + GetDocument().body()->AppendChild(style_element); + GetDocument().View()->UpdateAllLifecyclePhases(); + + // Now there are three fonts, but the newest one does not override the older, + // better matching one. + EXPECT_EQ(3u, GetStyleEngine().GetFontSelector()->GetFontFaceCache() + ->GetNumSegmentedFacesForTesting()); + font_face = GetStyleEngine().GetFontSelector()->GetFontFaceCache() + ->Get(t4->GetComputedStyle()->GetFontDescription(), + AtomicString("Cool Font")); + EXPECT_TRUE(font_face); + capabilities = font_face->GetFontSelectionCapabilities(); + ASSERT_EQ(capabilities.weight, + FontSelectionRange({BoldWeightValue(), BoldWeightValue()})); + ASSERT_EQ(capabilities.slope, + FontSelectionRange({ItalicSlopeValue(), ItalicSlopeValue()})); + + GetStyleEngine().RemoveUserSheet(font_face_id); + GetDocument().View()->UpdateAllLifecyclePhases(); + + // After removing the injected style sheet we're left with a bold-normal and + // a normal-italic font, and the latter is selected by the matching algorithm + // as font-style trumps font-weight. + EXPECT_EQ(2u, GetStyleEngine().GetFontSelector()->GetFontFaceCache() + ->GetNumSegmentedFacesForTesting()); + font_face = GetStyleEngine().GetFontSelector()->GetFontFaceCache() + ->Get(t4->GetComputedStyle()->GetFontDescription(), + AtomicString("Cool Font")); + EXPECT_TRUE(font_face); + capabilities = font_face->GetFontSelectionCapabilities(); + ASSERT_EQ(capabilities.weight, + FontSelectionRange({NormalWeightValue(), NormalWeightValue()})); + ASSERT_EQ(capabilities.slope, + FontSelectionRange({ItalicSlopeValue(), ItalicSlopeValue()})); + + // @keyframes rules + + Element* t5 = GetDocument().getElementById("t5"); + ASSERT_TRUE(t5); // There's no @keyframes rule named dummy-animation ASSERT_FALSE(GetStyleEngine().Resolver()->FindKeyframesRule( - t4, AtomicString("dummy-animation"))); + t5, AtomicString("dummy-animation"))); StyleSheetContents* keyframes_parsed_sheet = StyleSheetContents::Create(CSSParserContext::Create(GetDocument())); @@ -211,12 +313,11 @@ // is found with one keyframe. StyleRuleKeyframes* keyframes = GetStyleEngine().Resolver()->FindKeyframesRule( - t4, AtomicString("dummy-animation")); + t5, AtomicString("dummy-animation")); ASSERT_TRUE(keyframes); EXPECT_EQ(1u, keyframes->Keyframes().size()); - HTMLStyleElement* style_element = HTMLStyleElement::Create( - GetDocument(), false); + style_element = HTMLStyleElement::Create(GetDocument(), false); style_element->SetInnerHTMLFromString( "@keyframes dummy-animation { from {} to {} }"); GetDocument().body()->AppendChild(style_element); @@ -225,7 +326,7 @@ // Author @keyframes rules take precedence; now there are two keyframes (from // and to). keyframes = GetStyleEngine().Resolver()->FindKeyframesRule( - t4, AtomicString("dummy-animation")); + t5, AtomicString("dummy-animation")); ASSERT_TRUE(keyframes); EXPECT_EQ(2u, keyframes->Keyframes().size()); @@ -233,7 +334,7 @@ GetDocument().View()->UpdateAllLifecyclePhases(); keyframes = GetStyleEngine().Resolver()->FindKeyframesRule( - t4, AtomicString("dummy-animation")); + t5, AtomicString("dummy-animation")); ASSERT_TRUE(keyframes); EXPECT_EQ(1u, keyframes->Keyframes().size()); @@ -242,7 +343,7 @@ // Injected @keyframes rules are no longer available once removed. ASSERT_FALSE(GetStyleEngine().Resolver()->FindKeyframesRule( - t4, AtomicString("dummy-animation"))); + t5, AtomicString("dummy-animation"))); } TEST_F(StyleEngineTest, TextToSheetCache) {
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h index 9cab842..7fd44ce 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h +++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h
@@ -110,6 +110,8 @@ void DeleteLineBoxTree(); + bool CanContainFirstFormattedLine() const; + LayoutUnit AvailableLogicalWidthForLine( LayoutUnit position, IndentTextOrNot indent_text,
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp b/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp index e6667e3..8c4b15b 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp
@@ -727,6 +727,18 @@ logical_left += VerticalScrollbarWidthClampedToContentBox(); } +bool LayoutBlockFlow::CanContainFirstFormattedLine() const { + // The 'text-indent' only affects a line if it is the first formatted + // line of an element. For example, the first line of an anonymous block + // box is only affected if it is the first child of its parent element. + // https://drafts.csswg.org/css-text-3/#text-indent-property + + // TODO(kojii): In LayoutNG, leading OOF creates a block box. + // text-indent-first-line-002.html fails for this reason. + // crbug.com/734554 + return !(IsAnonymousBlock() && PreviousSibling()); +} + static void UpdateLogicalInlinePositions(LayoutBlockFlow* block, LayoutUnit& line_logical_left, LayoutUnit& line_logical_right, @@ -752,15 +764,8 @@ GlyphOverflowAndFallbackFontsMap& text_box_data_map, VerticalPositionCache& vertical_position_cache, const WordMeasurements& word_measurements) { - // CSS 2.1: "'Text-indent' only affects a line if it is the first formatted - // line of an element. For example, the first line of an anonymous block - // box is only affected if it is the first child of its parent element." - // CSS3 "text-indent", "each-line" affects the first line of the block - // container as well as each line after a forced line break, but does not - // affect lines after a soft wrap break. bool is_first_line = - line_info.IsFirstLine() && - !(IsAnonymousBlock() && Parent()->SlowFirstChild() != this); + line_info.IsFirstLine() && CanContainFirstFormattedLine(); bool is_after_hard_line_break = line_box->PrevRootBox() && line_box->PrevRootBox()->EndsWithBreak(); IndentTextOrNot indent_text =
diff --git a/third_party/WebKit/Source/core/layout/api/LineLayoutBlockFlow.h b/third_party/WebKit/Source/core/layout/api/LineLayoutBlockFlow.h index bc1966a..a712e7c1 100644 --- a/third_party/WebKit/Source/core/layout/api/LineLayoutBlockFlow.h +++ b/third_party/WebKit/Source/core/layout/api/LineLayoutBlockFlow.h
@@ -42,6 +42,10 @@ return ToBlockFlow()->StartAlignedOffsetForLine(position, indent_text); } + bool CanContainFirstFormattedLine() const { + return ToBlockFlow()->CanContainFirstFormattedLine(); + } + LayoutUnit TextIndentOffset() const { return ToBlockFlow()->TextIndentOffset(); }
diff --git a/third_party/WebKit/Source/core/layout/line/LineBreaker.cpp b/third_party/WebKit/Source/core/layout/line/LineBreaker.cpp index c7d5abb9..28428ec 100644 --- a/third_party/WebKit/Source/core/layout/line/LineBreaker.cpp +++ b/third_party/WebKit/Source/core/layout/line/LineBreaker.cpp
@@ -68,9 +68,11 @@ bool applied_start_width = resolver.GetPosition().Offset() > 0; + bool is_first_formatted_line = + line_info.IsFirstLine() && block_.CanContainFirstFormattedLine(); LineWidth width( block_, line_info.IsFirstLine(), - RequiresIndent(line_info.IsFirstLine(), + RequiresIndent(is_first_formatted_line, line_info.PreviousLineBrokeCleanly(), block_.StyleRef())); SkipLeadingWhitespace(resolver, line_info, width);
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc index df0a3cd..d975046d 100644 --- a/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc +++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc
@@ -45,17 +45,7 @@ bool NGLineBreaker::IsFirstFormattedLine() const { if (item_index_ || offset_) return false; - // The first line of an anonymous block box is only affected if it is the - // first child of its parent element. - // https://drafts.csswg.org/css-text-3/#text-indent-property - LayoutBlockFlow* block = node_.GetLayoutBlockFlow(); - if (block->IsAnonymousBlock() && block->PreviousSibling()) { - // TODO(kojii): In NG, leading OOF creates a block box. - // text-indent-first-line-002.html fails for this reason. - // crbug.com/734554 - return false; - } - return true; + return node_.GetLayoutBlockFlow()->CanContainFirstFormattedLine(); } // Compute the base direction for bidi algorithm for this line.
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_layout_test.h b/third_party/WebKit/Source/core/layout/ng/ng_layout_test.h index 1ae7e381..ecd6433 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_layout_test.h +++ b/third_party/WebKit/Source/core/layout/ng/ng_layout_test.h
@@ -11,6 +11,10 @@ namespace blink { +// The NGLayoutTest is intended to let all NGFooTest classes easiy inherit +// ScopedLayoutNGForTest as well as RenderingTest. The ScopedLayoutNGForTest +// ensures original settings are restored for other tests. +// See http://crbug.com/769541 for more details. class NGLayoutTest : public RenderingTest, private ScopedLayoutNGForTest { public: NGLayoutTest(LocalFrameClient* local_frame_client = nullptr)
diff --git a/third_party/WebKit/Source/core/paint/ng/ng_text_fragment_painter_test.cc b/third_party/WebKit/Source/core/paint/ng/ng_text_fragment_painter_test.cc index f214577f..6882a83d 100644 --- a/third_party/WebKit/Source/core/paint/ng/ng_text_fragment_painter_test.cc +++ b/third_party/WebKit/Source/core/paint/ng/ng_text_fragment_painter_test.cc
@@ -21,34 +21,20 @@ namespace blink { class NGTextFragmentPainterTest : public PaintControllerPaintTest, - private ScopedLayoutNGForTest { + private ScopedLayoutNGForTest, + private ScopedLayoutNGPaintFragmentsForTest { public: NGTextFragmentPainterTest(LocalFrameClient* local_frame_client = nullptr) : PaintControllerPaintTest(local_frame_client), - ScopedLayoutNGForTest(true) {} + ScopedLayoutNGForTest(true), + ScopedLayoutNGPaintFragmentsForTest(true) {} }; INSTANTIATE_TEST_CASE_P(All, NGTextFragmentPainterTest, ::testing::Values(0, kRootLayerScrolling)); -class EnableLayoutNGForScope { - public: - EnableLayoutNGForScope() { - paint_fragments_ = RuntimeEnabledFeatures::LayoutNGPaintFragmentsEnabled(); - RuntimeEnabledFeatures::SetLayoutNGPaintFragmentsEnabled(true); - } - ~EnableLayoutNGForScope() { - RuntimeEnabledFeatures::SetLayoutNGPaintFragmentsEnabled(paint_fragments_); - } - - private: - bool paint_fragments_; -}; - TEST_P(NGTextFragmentPainterTest, TestTextStyle) { - EnableLayoutNGForScope enable_layout_ng; - SetBodyInnerHTML(R"HTML( <!DOCTYPE html> <body>
diff --git a/third_party/WebKit/Source/modules/BUILD.gn b/third_party/WebKit/Source/modules/BUILD.gn index 1a295eae..a647725f 100644 --- a/third_party/WebKit/Source/modules/BUILD.gn +++ b/third_party/WebKit/Source/modules/BUILD.gn
@@ -287,6 +287,7 @@ "media_controls/MediaControlsRotateToFullscreenDelegateTest.cpp", "media_controls/elements/MediaControlInputElementTest.cpp", "mediastream/MediaConstraintsTest.cpp", + "mediastream/MediaDevicesTest.cpp", "notifications/NotificationDataTest.cpp", "notifications/NotificationImageLoaderTest.cpp", "notifications/NotificationResourcesLoaderTest.cpp",
diff --git a/third_party/WebKit/Source/modules/mediastream/MediaDevicesTest.cpp b/third_party/WebKit/Source/modules/mediastream/MediaDevicesTest.cpp new file mode 100644 index 0000000..78b6189 --- /dev/null +++ b/third_party/WebKit/Source/modules/mediastream/MediaDevicesTest.cpp
@@ -0,0 +1,89 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "bindings/core/v8/ExceptionState.h" +#include "bindings/core/v8/V8BindingForTesting.h" +#include "core/testing/NullExecutionContext.h" +#include "modules/mediastream/MediaDevices.h" +#include "modules/mediastream/MediaStreamConstraints.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace blink { + +class PromiseObserver { + public: + PromiseObserver(ScriptState* script_state, ScriptPromise promise) + : is_rejected_(false), is_fulfilled_(false) { + v8::Local<v8::Function> on_fulfilled = MyScriptFunction::CreateFunction( + script_state, &is_fulfilled_, &saved_arg_); + v8::Local<v8::Function> on_rejected = MyScriptFunction::CreateFunction( + script_state, &is_rejected_, &saved_arg_); + promise.Then(on_fulfilled, on_rejected); + } + + bool isDecided() { return is_rejected_ || is_fulfilled_; } + + bool isFulfilled() { return is_fulfilled_; } + bool isRejected() { return is_rejected_; } + ScriptValue argument() { return saved_arg_; } + + private: + class MyScriptFunction : public ScriptFunction { + public: + static v8::Local<v8::Function> CreateFunction(ScriptState* script_state, + bool* flag_to_set, + ScriptValue* arg_to_set) { + MyScriptFunction* self = + new MyScriptFunction(script_state, flag_to_set, arg_to_set); + return self->BindToV8Function(); + } + + private: + MyScriptFunction(ScriptState* script_state, + bool* flag_to_set, + ScriptValue* arg_to_set) + : ScriptFunction(script_state), + flag_to_set_(flag_to_set), + arg_to_set_(arg_to_set) {} + ScriptValue Call(ScriptValue arg) { + *flag_to_set_ = true; + *arg_to_set_ = arg; + return arg; + } + bool* flag_to_set_; + ScriptValue* arg_to_set_; + }; + + bool is_rejected_; + bool is_fulfilled_; + ScriptValue saved_arg_; +}; + +TEST(MediaDevicesTest, GetUserMediaCanBeCalled) { + V8TestingScope scope; + auto devices = MediaDevices::Create(scope.GetExecutionContext()); + MediaStreamConstraints constraints; + ScriptPromise promise = devices->getUserMedia( + scope.GetScriptState(), constraints, scope.GetExceptionState()); + ASSERT_FALSE(promise.IsEmpty()); + PromiseObserver promise_observer(scope.GetScriptState(), promise); + EXPECT_FALSE(promise_observer.isDecided()); + v8::MicrotasksScope::PerformCheckpoint(scope.GetIsolate()); + EXPECT_TRUE(promise_observer.isDecided()); + // In the default test environment, we expect a DOM rejection because + // the script state's execution context's document's frame doesn't + // have an UserMediaController. + EXPECT_TRUE(promise_observer.isRejected()); + // TODO(hta): Check that the correct error ("not supported") is returned. + EXPECT_FALSE(promise_observer.argument().IsNull()); + // This log statement is included as a demonstration of how to get the string + // value of the argument. + VLOG(1) << "Argument is" + << ToCoreString(promise_observer.argument() + .V8Value() + ->ToString(scope.GetContext()) + .ToLocalChecked()); +} + +} // namespace blink
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioParam.cpp b/third_party/WebKit/Source/modules/webaudio/AudioParam.cpp index 1d7731a9..569e655 100644 --- a/third_party/WebKit/Source/modules/webaudio/AudioParam.cpp +++ b/third_party/WebKit/Source/modules/webaudio/AudioParam.cpp
@@ -363,26 +363,12 @@ // TODO(crbug.com/764396): Remove this when fixed. void AudioParam::WarnIfSetterOverlapsEvent() { - // Find if there's an event at the current time. - bool has_overlap; - size_t current_event_index; + DCHECK(IsMainThread()); - std::tie(has_overlap, current_event_index) = - Handler().Timeline().EventAtFrame(Context()->CurrentSampleFrame(), - Context()->sampleRate()); - - Context()->CountValueSetterConflict(has_overlap); - - // Print a depecation message once, and also a more detailed message - // about the conflict so the developer knows. - if (!s_value_setter_warning_done_) { - Deprecation::CountDeprecation(Context()->GetExecutionContext(), - WebFeature::kWebAudioValueSetterIsSetValue); - if (has_overlap) { - Handler().Timeline().WarnSetterOverlapsEvent( - Handler().GetParamName(), current_event_index, *Context()); - } - } + // Check for overlap and print a warning only if we haven't already + // printed a warning. + Handler().Timeline().WarnIfSetterOverlapsEvent( + Context(), Handler().GetParamName(), !s_value_setter_warning_done_); } float AudioParam::defaultValue() const {
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp index 56e2bb6..95974ab 100644 --- a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp +++ b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
@@ -30,6 +30,7 @@ #include "bindings/core/v8/ExceptionState.h" #include "build/build_config.h" #include "core/dom/ExceptionCode.h" +#include "core/frame/Deprecation.h" #include "core/inspector/ConsoleMessage.h" #include "platform/audio/AudioUtilities.h" #include "platform/wtf/CPU.h" @@ -1784,10 +1785,39 @@ } // TODO(crbug.com/764396): Remove this when fixed. +bool AudioParamTimeline::WarnIfSetterOverlapsEvent(BaseAudioContext* context, + String param_name, + bool print_warning) { + DCHECK(IsMainThread()); + + // Don't let the audio thread mutate the event list while we're + // examining the event list. + MutexLocker locker(events_lock_); + + // Find if there's an event at the current time. + bool has_overlap; + size_t current_event_index; + + std::tie(has_overlap, current_event_index) = + EventAtFrame(context->CurrentSampleFrame(), context->sampleRate()); + + context->CountValueSetterConflict(has_overlap); + + // Print a depecation message once, and also a more detailed message + // about the conflict so the developer knows. + Deprecation::CountDeprecation(context->GetExecutionContext(), + WebFeature::kWebAudioValueSetterIsSetValue); + if (print_warning && has_overlap) { + WarnSetterOverlapsEvent(param_name, current_event_index, *context); + return true; + } + + return false; +} + std::tuple<bool, size_t> AudioParamTimeline::EventAtFrame( size_t current_frame, float sample_rate) const { - MutexLocker locker(events_lock_); size_t number_of_events = events_.size(); ParamEvent* event = nullptr; @@ -1867,7 +1897,6 @@ String param_name, size_t event_index, BaseAudioContext& context) const { - MutexLocker locker(events_lock_); DCHECK_LT(event_index, events_.size());
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.h b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.h index f23c2fa..df2e0dbd 100644 --- a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.h +++ b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.h
@@ -99,22 +99,13 @@ float SmoothedValue() { return smoothed_value_; } void SetSmoothedValue(float v) { smoothed_value_ = v; } - // TODO(crbug.com/764396): Remove these two methods when the bug is - // fixed. + // TODO(crbug.com/764396): Remove this when the bug is fixed. - // |EventAtFrame| finds the current event that would run at the specified - // |frame|. The first return value is true if a setValueAtTime call would - // overlap some ongoing event. The second return value is the index of the - // current event. The second value must be ignored if the first value is - // false. - std::tuple<bool, size_t> EventAtFrame(size_t frame, float sample_rate) const; - - // Prints a console warning that a call to the AudioParam value setter - // overlaps the event at |event_index|. |param_name| is the name of the - // AudioParam where the where this is happening. - void WarnSetterOverlapsEvent(String param_name, - size_t event_index, - BaseAudioContext&) const; + // Print a warning if the value setter overlaps an event. Returns + // true if a warning was printed. + bool WarnIfSetterOverlapsEvent(BaseAudioContext*, + String param_name, + bool print_warning); private: class ParamEvent { @@ -461,6 +452,22 @@ size_t end_frame, unsigned write_index); + // TODO(crbug.com/764396): Remove these two methods when the bug is fixed. + + // |EventAtFrame| finds the current event that would run at the specified + // |frame|. The first return value is true if a setValueAtTime call would + // overlap some ongoing event. The second return value is the index of the + // current event. The second value must be ignored if the first value is + // false. + std::tuple<bool, size_t> EventAtFrame(size_t frame, float sample_rate) const; + + // Prints a console warning that a call to the AudioParam value setter + // overlaps the event at |event_index|. |param_name| is the name of the + // AudioParam where the where this is happening. + void WarnSetterOverlapsEvent(String param_name, + size_t event_index, + BaseAudioContext&) const; + // Vector of all automation events for the AudioParam. Access must // be locked via m_eventsLock. Vector<std::unique_ptr<ParamEvent>> events_;
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/update_flaky_expectations_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/update_flaky_expectations_unittest.py index 1b25a4b..6720a55 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/update_flaky_expectations_unittest.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/update_flaky_expectations_unittest.py
@@ -466,7 +466,7 @@ def test_multiple_builders_and_platform_specifiers(self): """Tests correct operation with platform specifiers.""" test_expectations_before = ( - """# Keep since it's failing on Mac results. + """# Keep since it's failing in the Mac10.10 results. Bug(test) [ Mac ] test/a.html [ Failure Pass ] # Keep since it's failing on the Windows builder. Bug(test) [ Linux Win ] test/b.html [ Failure Pass ] @@ -476,10 +476,6 @@ Bug(test) [ Mac ] test/d.html [ Failure Pass ]""") self._define_builders({ - 'WebKit Win7': { - 'port_name': 'win-win7', - 'specifiers': ['Win7', 'Release'] - }, 'WebKit Linux Trusty': { 'port_name': 'linux-trusty', 'specifiers': ['Trusty', 'Release'] @@ -488,11 +484,22 @@ 'port_name': 'mac-mac10.10', 'specifiers': ['Mac10.10', 'Release'] }, + 'WebKit Mac10.11': { + 'port_name': 'mac-mac10.11', + 'specifiers': ['Mac10.11', 'Release'] + }, + 'WebKit Win7': { + 'port_name': 'win-win7', + 'specifiers': ['Win7', 'Release'] + }, }) self._port.all_build_types = ('release',) - self._port.all_systems = (('mac10.10', 'x86'), - ('win7', 'x86'), - ('trusty', 'x86_64')) + self._port.all_systems = ( + ('mac10.10', 'x86'), + ('mac10.11', 'x86'), + ('trusty', 'x86_64'), + ('win7', 'x86'), + ) self._parse_expectations(test_expectations_before) self._expectation_factory.all_results_by_builder = { @@ -508,6 +515,12 @@ 'test/c.html': ['PASS', 'IMAGE', 'PASS'], 'test/d.html': ['PASS', 'PASS', 'PASS'], }, + 'WebKit Mac10.11': { + 'test/a.html': ['PASS', 'PASS', 'PASS'], + 'test/b.html': ['PASS', 'PASS', 'PASS'], + 'test/c.html': ['PASS', 'PASS', 'PASS'], + 'test/d.html': ['PASS', 'PASS', 'PASS'], + }, 'WebKit Win7': { 'test/a.html': ['PASS', 'PASS', 'PASS'], 'test/b.html': ['IMAGE', 'PASS', 'PASS'], @@ -518,7 +531,7 @@ updated_expectations = ( self._flake_remover.get_updated_test_expectations()) self._assert_expectations_match(updated_expectations, ( - """# Keep since it's failing on Mac results. + """# Keep since it's failing in the Mac10.10 results. Bug(test) [ Mac ] test/a.html [ Failure Pass ] # Keep since it's failing on the Windows builder. Bug(test) [ Linux Win ] test/b.html [ Failure Pass ]"""))
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py index f7f1d5e..4beeed82 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
@@ -95,13 +95,11 @@ self.assertEqual(cpp_style._convert_to_lower_with_underscores('aB'), 'a_b') self.assertEqual(cpp_style._convert_to_lower_with_underscores('isAName'), 'is_a_name') self.assertEqual(cpp_style._convert_to_lower_with_underscores('AnotherTest'), 'another_test') - self.assertEqual(cpp_style._convert_to_lower_with_underscores('PassRefPtr<MyClass>'), 'pass_ref_ptr<my_class>') self.assertEqual(cpp_style._convert_to_lower_with_underscores('_ABC'), '_abc') def test_create_acronym(self): self.assertEqual(cpp_style._create_acronym('ABC'), 'ABC') self.assertEqual(cpp_style._create_acronym('IsAName'), 'IAN') - self.assertEqual(cpp_style._create_acronym('PassRefPtr<MyClass>'), 'PRP<MC>') def test_is_c_or_objective_c(self): clean_lines = cpp_style.CleansedLines(['']) @@ -121,8 +119,8 @@ self.assertEqual(parameter.row, 1) # Test type and name. - parameter = cpp_style.Parameter('PassRefPtr<MyClass> parent', 19, 1) - self.assertEqual(parameter.type, 'PassRefPtr<MyClass>') + parameter = cpp_style.Parameter('scoped_refptr<MyClass> parent', 22, 1) + self.assertEqual(parameter.type, 'scoped_refptr<MyClass>') self.assertEqual(parameter.name, 'parent') self.assertEqual(parameter.row, 1) @@ -166,7 +164,7 @@ self.assertEqual(cpp_style.create_skeleton_parameters('long'), 'long,') self.assertEqual(cpp_style.create_skeleton_parameters('const unsigned long int'), ' int,') self.assertEqual(cpp_style.create_skeleton_parameters('long int*'), ' int ,') - self.assertEqual(cpp_style.create_skeleton_parameters('PassRefPtr<Foo> a'), 'PassRefPtr a,') + self.assertEqual(cpp_style.create_skeleton_parameters('scoped_refptr<Foo> a'), 'scoped_refptr a,') self.assertEqual(cpp_style.create_skeleton_parameters( 'ComplexTemplate<NestedTemplate1<MyClass1, MyClass2>, NestedTemplate1<MyClass1, MyClass2> > param, int second'), 'ComplexTemplate param, int second,') @@ -181,11 +179,11 @@ def test_find_parameter_name_index(self): self.assertEqual(cpp_style.find_parameter_name_index(' int a '), 5) - self.assertEqual(cpp_style.find_parameter_name_index(' PassRefPtr '), 16) + self.assertEqual(cpp_style.find_parameter_name_index(' scoped_refptr '), 19) self.assertEqual(cpp_style.find_parameter_name_index('double'), 6) def test_parameter_list(self): - elided_lines = ['int blah(PassRefPtr<MyClass> paramName,', + elided_lines = ['int blah(scoped_refptr<MyClass> paramName,', 'const Other1Class& foo,', ('const ComplexTemplate<Class1, NestedTemplate<P1, P2> >* const * param = ' 'new ComplexTemplate<Class1, NestedTemplate<P1, P2> >(34, 42),'), @@ -193,7 +191,7 @@ start_position = cpp_style.Position(row=0, column=8) end_position = cpp_style.Position(row=3, column=16) - expected_parameters = ({'type': 'PassRefPtr<MyClass>', 'name': 'paramName', 'row': 0}, + expected_parameters = ({'type': 'scoped_refptr<MyClass>', 'name': 'paramName', 'row': 0}, {'type': 'const Other1Class&', 'name': 'foo', 'row': 1}, {'type': 'const ComplexTemplate<Class1, NestedTemplate<P1, P2> >* const *', 'name': 'param', @@ -568,7 +566,7 @@ self.perform_function_detection( ['#define MyMacro(a) a', 'virtual', - 'AnotherTemplate<Class1, Class2> aFunctionName(PassRefPtr<MyClass> paramName,', + 'AnotherTemplate<Class1, Class2> aFunctionName(scoped_refptr<MyClass> paramName,', 'const Other1Class& foo,', ('const ComplexTemplate<Class1, NestedTemplate<P1, P2> >* const * param = ' 'new ComplexTemplate<Class1, NestedTemplate<P1, P2> >(34, 42),'), @@ -582,7 +580,7 @@ 'is_pure': False, 'is_declaration': True, 'parameter_list': - ({'type': 'PassRefPtr<MyClass>', 'name': 'paramName', 'row': 2}, + ({'type': 'scoped_refptr<MyClass>', 'name': 'paramName', 'row': 2}, {'type': 'const Other1Class&', 'name': 'foo', 'row': 3}, {'type': 'const ComplexTemplate<Class1, NestedTemplate<P1, P2> >* const *', 'name': 'param', 'row': 4}, {'type': 'int*', 'name': 'myCount', 'row': 5})}, @@ -2356,85 +2354,58 @@ self.assertEqual(expected_message, self.perform_pass_ptr_check(code)) - def test_pass_ref_ptr_in_function(self): - self.assert_pass_ptr_check( - 'int myFunction()\n' - '{\n' - ' PassRefPtr<Type1> variable = variable2;\n' - '}', - 'Local variables should never be PassRefPtr (see ' - 'http://webkit.org/coding/RefPtr.html). [readability/pass_ptr] [5]') - - def test_pass_own_ptr_in_function(self): - self.assert_pass_ptr_check( - 'int myFunction()\n' - '{\n' - ' PassOwnPtr<Type1> variable = variable2;\n' - '}', - 'Local variables should never be PassOwnPtr (see ' - 'http://webkit.org/coding/RefPtr.html). [readability/pass_ptr] [5]') - - def test_pass_other_type_ptr_in_function(self): - self.assert_pass_ptr_check( - 'int myFunction()\n' - '{\n' - ' PassOtherTypePtr<Type1> variable;\n' - '}', - 'Local variables should never be PassOtherTypePtr (see ' - 'http://webkit.org/coding/RefPtr.html). [readability/pass_ptr] [5]') - def test_pass_ref_ptr_return_value(self): self.assert_pass_ptr_check( - 'PassRefPtr<Type1>\n' + 'scoped_refptr<Type1>\n' 'myFunction(int)\n' '{\n' '}', '') self.assert_pass_ptr_check( - 'PassRefPtr<Type1> myFunction(int)\n' + 'scoped_refptr<Type1> myFunction(int)\n' '{\n' '}', '') self.assert_pass_ptr_check( - 'PassRefPtr<Type1> myFunction();\n', + 'scoped_refptr<Type1> myFunction();\n', '') self.assert_pass_ptr_check( - 'OwnRefPtr<Type1> myFunction();\n', + 'Ownscoped_refptr<Type1> myFunction();\n', '') def test_ref_ptr_parameter_value(self): self.assert_pass_ptr_check( - 'int myFunction(PassRefPtr<Type1>)\n' + 'int myFunction(scoped_refptr<Type1>)\n' '{\n' '}', '') self.assert_pass_ptr_check( - 'int myFunction(RefPtr<Type1>&)\n' + 'int myFunction(scoped_refptr<Type1>&)\n' '{\n' '}', '') self.assert_pass_ptr_check( - 'int myFunction(RefPtr<Type1>*)\n' + 'int myFunction(scoped_refptr<Type1>*)\n' '{\n' '}', '') self.assert_pass_ptr_check( - 'int myFunction(RefPtr<Type1>* = 0)\n' + 'int myFunction(scoped_refptr<Type1>* = 0)\n' '{\n' '}', '') self.assert_pass_ptr_check( - 'int myFunction(RefPtr<Type1>* = 0)\n' + 'int myFunction(scoped_refptr<Type1>* = 0)\n' '{\n' '}', '') self.assert_pass_ptr_check( - 'int myFunction(RefPtr<Type1>* = nullptr)\n' + 'int myFunction(scoped_refptr<Type1>* = nullptr)\n' '{\n' '}', '') self.assert_pass_ptr_check( - 'int myFunction(RefPtr<Type1>* = nullptr)\n' + 'int myFunction(scoped_refptr<Type1>* = nullptr)\n' '{\n' '}', '') @@ -2454,7 +2425,7 @@ def test_ref_ptr_member_variable(self): self.assert_pass_ptr_check( 'class Foo {' - ' RefPtr<Type1> m_other;\n' + ' scoped_refptr<Type1> m_other;\n' '};\n', '') @@ -2954,7 +2925,7 @@ # Verify that copying a type name will trigger the warning (even if the type is a template parameter). self.assertEqual( meaningless_variable_name_error_message % 'context', - self.perform_lint('void funct(PassRefPtr<ScriptExecutionContext> context);', 'test.cpp', parameter_error_rules)) + self.perform_lint('void funct(scoped_refptr<ScriptExecutionContext> context);', 'test.cpp', parameter_error_rules)) # Verify that acronyms as variable names trigger the error (for both set functions and type names). self.assertEqual( @@ -2991,7 +2962,8 @@ # Don't have generate warnings for functions (only declarations). self.assertEqual( '', - self.perform_lint('void funct(PassRefPtr<ScriptExecutionContext> context)\n{\n}\n', 'test.cpp', parameter_error_rules)) + self.perform_lint( + 'void funct(scoped_refptr<ScriptExecutionContext> context)\n{\n}\n', 'test.cpp', parameter_error_rules)) def test_redundant_virtual(self): self.assert_lint('virtual void fooMethod() override;',
diff --git a/third_party/WebKit/public/platform/WebAudioBus.h b/third_party/WebKit/public/platform/WebAudioBus.h index 68b88bb4..a46161e 100644 --- a/third_party/WebKit/public/platform/WebAudioBus.h +++ b/third_party/WebKit/public/platform/WebAudioBus.h
@@ -71,7 +71,7 @@ float* ChannelData(unsigned channel_index); #if INSIDE_BLINK - WTF::RefPtr<AudioBus> Release(); + scoped_refptr<AudioBus> Release(); #endif private:
diff --git a/third_party/WebKit/public/platform/WebBlobInfo.h b/third_party/WebKit/public/platform/WebBlobInfo.h index af18ba9e..fe0512a 100644 --- a/third_party/WebKit/public/platform/WebBlobInfo.h +++ b/third_party/WebKit/public/platform/WebBlobInfo.h
@@ -75,23 +75,23 @@ BLINK_EXPORT mojo::ScopedMessagePipeHandle CloneBlobHandle() const; #if INSIDE_BLINK - BLINK_EXPORT WebBlobInfo(RefPtr<BlobDataHandle>); - BLINK_EXPORT WebBlobInfo(RefPtr<BlobDataHandle>, + BLINK_EXPORT WebBlobInfo(scoped_refptr<BlobDataHandle>); + BLINK_EXPORT WebBlobInfo(scoped_refptr<BlobDataHandle>, const WebString& file_path, const WebString& file_name, double last_modified); // TODO(mek): Get rid of these constructors after ensuring that the // BlobDataHandle always has the correct type and size. - BLINK_EXPORT WebBlobInfo(RefPtr<BlobDataHandle>, + BLINK_EXPORT WebBlobInfo(scoped_refptr<BlobDataHandle>, const WebString& type, long long size); - BLINK_EXPORT WebBlobInfo(RefPtr<BlobDataHandle>, + BLINK_EXPORT WebBlobInfo(scoped_refptr<BlobDataHandle>, const WebString& file_path, const WebString& file_name, const WebString& type, double last_modified, long long size); - BLINK_EXPORT RefPtr<BlobDataHandle> GetBlobHandle() const; + BLINK_EXPORT scoped_refptr<BlobDataHandle> GetBlobHandle() const; #endif private:
diff --git a/third_party/WebKit/public/platform/WebCrypto.h b/third_party/WebKit/public/platform/WebCrypto.h index 32fce31..062ecddbf 100644 --- a/third_party/WebKit/public/platform/WebCrypto.h +++ b/third_party/WebKit/public/platform/WebCrypto.h
@@ -96,7 +96,7 @@ #if INSIDE_BLINK BLINK_PLATFORM_EXPORT WebCryptoResult(CryptoResult*, - RefPtr<CryptoResultCancel>); + scoped_refptr<CryptoResultCancel>); #endif private:
diff --git a/third_party/WebKit/public/platform/WebData.h b/third_party/WebKit/public/platform/WebData.h index 3fa994c..b9a506ca 100644 --- a/third_party/WebKit/public/platform/WebData.h +++ b/third_party/WebKit/public/platform/WebData.h
@@ -98,9 +98,9 @@ bool IsNull() const { return private_.IsNull(); } #if INSIDE_BLINK - WebData(RefPtr<SharedBuffer>); - WebData& operator=(RefPtr<SharedBuffer>); - operator RefPtr<SharedBuffer>() const; + WebData(scoped_refptr<SharedBuffer>); + WebData& operator=(scoped_refptr<SharedBuffer>); + operator scoped_refptr<SharedBuffer>() const; operator const SharedBuffer&() const; #else template <class C>
diff --git a/third_party/WebKit/public/platform/WebHTTPBody.h b/third_party/WebKit/public/platform/WebHTTPBody.h index 2d53d99..e39cb4d 100644 --- a/third_party/WebKit/public/platform/WebHTTPBody.h +++ b/third_party/WebKit/public/platform/WebHTTPBody.h
@@ -99,9 +99,9 @@ BLINK_PLATFORM_EXPORT void SetContainsPasswordData(bool); #if INSIDE_BLINK - BLINK_PLATFORM_EXPORT WebHTTPBody(WTF::RefPtr<EncodedFormData>); - BLINK_PLATFORM_EXPORT WebHTTPBody& operator=(WTF::RefPtr<EncodedFormData>); - BLINK_PLATFORM_EXPORT operator WTF::RefPtr<EncodedFormData>() const; + BLINK_PLATFORM_EXPORT WebHTTPBody(scoped_refptr<EncodedFormData>); + BLINK_PLATFORM_EXPORT WebHTTPBody& operator=(scoped_refptr<EncodedFormData>); + BLINK_PLATFORM_EXPORT operator scoped_refptr<EncodedFormData>() const; #endif private:
diff --git a/third_party/WebKit/public/platform/WebHTTPLoadInfo.h b/third_party/WebKit/public/platform/WebHTTPLoadInfo.h index 770dffca..f243c63 100644 --- a/third_party/WebKit/public/platform/WebHTTPLoadInfo.h +++ b/third_party/WebKit/public/platform/WebHTTPLoadInfo.h
@@ -74,8 +74,8 @@ BLINK_PLATFORM_EXPORT void SetNPNNegotiatedProtocol(const WebString&); #if INSIDE_BLINK - BLINK_PLATFORM_EXPORT WebHTTPLoadInfo(WTF::RefPtr<ResourceLoadInfo>); - BLINK_PLATFORM_EXPORT operator WTF::RefPtr<ResourceLoadInfo>() const; + BLINK_PLATFORM_EXPORT WebHTTPLoadInfo(scoped_refptr<ResourceLoadInfo>); + BLINK_PLATFORM_EXPORT operator scoped_refptr<ResourceLoadInfo>() const; #endif private:
diff --git a/third_party/WebKit/public/platform/WebImage.h b/third_party/WebKit/public/platform/WebImage.h index 00999ed8..ad99748 100644 --- a/third_party/WebKit/public/platform/WebImage.h +++ b/third_party/WebKit/public/platform/WebImage.h
@@ -92,7 +92,7 @@ BLINK_PLATFORM_EXPORT WebSize Size() const; #if INSIDE_BLINK - BLINK_PLATFORM_EXPORT WebImage(WTF::RefPtr<Image>); + BLINK_PLATFORM_EXPORT WebImage(scoped_refptr<Image>); #endif WebImage(const SkBitmap& bitmap) : bitmap_(bitmap) {}
diff --git a/third_party/WebKit/public/platform/WebMediaStreamSource.h b/third_party/WebKit/public/platform/WebMediaStreamSource.h index 80a4ce05..ac9295b 100644 --- a/third_party/WebKit/public/platform/WebMediaStreamSource.h +++ b/third_party/WebKit/public/platform/WebMediaStreamSource.h
@@ -125,7 +125,7 @@ #if INSIDE_BLINK BLINK_PLATFORM_EXPORT WebMediaStreamSource(MediaStreamSource*); BLINK_PLATFORM_EXPORT WebMediaStreamSource& operator=(MediaStreamSource*); - BLINK_PLATFORM_EXPORT operator WTF::RefPtr<MediaStreamSource>() const; + BLINK_PLATFORM_EXPORT operator scoped_refptr<MediaStreamSource>() const; BLINK_PLATFORM_EXPORT operator MediaStreamSource*() const; #endif
diff --git a/third_party/WebKit/public/platform/WebMediaStreamTrack.h b/third_party/WebKit/public/platform/WebMediaStreamTrack.h index 494991d4..790d6fa 100644 --- a/third_party/WebKit/public/platform/WebMediaStreamTrack.h +++ b/third_party/WebKit/public/platform/WebMediaStreamTrack.h
@@ -132,7 +132,7 @@ #if INSIDE_BLINK BLINK_PLATFORM_EXPORT WebMediaStreamTrack(MediaStreamComponent*); BLINK_PLATFORM_EXPORT WebMediaStreamTrack& operator=(MediaStreamComponent*); - BLINK_PLATFORM_EXPORT operator WTF::RefPtr<MediaStreamComponent>() const; + BLINK_PLATFORM_EXPORT operator scoped_refptr<MediaStreamComponent>() const; BLINK_PLATFORM_EXPORT operator MediaStreamComponent*() const; #endif
diff --git a/third_party/WebKit/public/platform/WebPrivatePtr.h b/third_party/WebKit/public/platform/WebPrivatePtr.h index 75c6dde..59c4318 100644 --- a/third_party/WebKit/public/platform/WebPrivatePtr.h +++ b/third_party/WebKit/public/platform/WebPrivatePtr.h
@@ -95,7 +95,7 @@ strongOrWeak, kRefCountedLifetime> { public: - typedef RefPtr<T> BlinkPtrType; + typedef scoped_refptr<T> BlinkPtrType; void Assign(BlinkPtrType&& val) { static_assert( @@ -260,7 +260,7 @@ // // Methods that are used only by other Blink classes should only be // // declared when INSIDE_BLINK is set. // #if INSIDE_BLINK -// WebFoo(WTF::RefPtr<Foo>); +// WebFoo(scoped_refptr<Foo>); // #endif // // private:
diff --git a/third_party/WebKit/public/platform/WebSecurityOrigin.h b/third_party/WebKit/public/platform/WebSecurityOrigin.h index 93c0aa4fde..bf64cf28 100644 --- a/third_party/WebKit/public/platform/WebSecurityOrigin.h +++ b/third_party/WebKit/public/platform/WebSecurityOrigin.h
@@ -111,10 +111,10 @@ BLINK_PLATFORM_EXPORT void GrantLoadLocalResources() const; #if INSIDE_BLINK - BLINK_PLATFORM_EXPORT WebSecurityOrigin(WTF::RefPtr<SecurityOrigin>); + BLINK_PLATFORM_EXPORT WebSecurityOrigin(scoped_refptr<SecurityOrigin>); BLINK_PLATFORM_EXPORT WebSecurityOrigin& operator=( - WTF::RefPtr<SecurityOrigin>); - BLINK_PLATFORM_EXPORT operator WTF::RefPtr<SecurityOrigin>() const; + scoped_refptr<SecurityOrigin>); + BLINK_PLATFORM_EXPORT operator scoped_refptr<SecurityOrigin>() const; BLINK_PLATFORM_EXPORT SecurityOrigin* Get() const; #else // TODO(mkwst): A number of properties don't survive a round-trip
diff --git a/third_party/WebKit/public/platform/WebThreadSafeData.h b/third_party/WebKit/public/platform/WebThreadSafeData.h index 8cac7f4..fb3d62d 100644 --- a/third_party/WebKit/public/platform/WebThreadSafeData.h +++ b/third_party/WebKit/public/platform/WebThreadSafeData.h
@@ -65,9 +65,9 @@ BLINK_PLATFORM_EXPORT WebThreadSafeData& operator=(const WebThreadSafeData&); #if INSIDE_BLINK - BLINK_PLATFORM_EXPORT WebThreadSafeData(WTF::RefPtr<RawData>); - BLINK_PLATFORM_EXPORT WebThreadSafeData(WTF::RefPtr<RawData>&&); - BLINK_PLATFORM_EXPORT WebThreadSafeData& operator=(WTF::RefPtr<RawData>); + BLINK_PLATFORM_EXPORT WebThreadSafeData(scoped_refptr<RawData>); + BLINK_PLATFORM_EXPORT WebThreadSafeData(scoped_refptr<RawData>&&); + BLINK_PLATFORM_EXPORT WebThreadSafeData& operator=(scoped_refptr<RawData>); #else operator std::string() const { size_t len = size();
diff --git a/third_party/WebKit/public/platform/WebURLLoadTiming.h b/third_party/WebKit/public/platform/WebURLLoadTiming.h index 171e41c..e4a288c3 100644 --- a/third_party/WebKit/public/platform/WebURLLoadTiming.h +++ b/third_party/WebKit/public/platform/WebURLLoadTiming.h
@@ -108,10 +108,10 @@ BLINK_PLATFORM_EXPORT void SetPushEnd(double); #if INSIDE_BLINK - BLINK_PLATFORM_EXPORT WebURLLoadTiming(WTF::RefPtr<ResourceLoadTiming>); + BLINK_PLATFORM_EXPORT WebURLLoadTiming(scoped_refptr<ResourceLoadTiming>); BLINK_PLATFORM_EXPORT WebURLLoadTiming& operator=( - WTF::RefPtr<ResourceLoadTiming>); - BLINK_PLATFORM_EXPORT operator WTF::RefPtr<ResourceLoadTiming>() const; + scoped_refptr<ResourceLoadTiming>); + BLINK_PLATFORM_EXPORT operator scoped_refptr<ResourceLoadTiming>() const; #endif private:
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerRequest.h b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerRequest.h index 1a918f1..87ad212 100644 --- a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerRequest.h +++ b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerRequest.h
@@ -102,7 +102,7 @@ #if INSIDE_BLINK const HTTPHeaderMap& Headers() const; - RefPtr<BlobDataHandle> GetBlobDataHandle() const; + scoped_refptr<BlobDataHandle> GetBlobDataHandle() const; const Referrer& GetReferrer() const; void SetBlob(const WebString& uuid, long long size,
diff --git a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h index 77231f1e..7853822d 100644 --- a/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h +++ b/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h
@@ -93,8 +93,8 @@ #if INSIDE_BLINK const HTTPHeaderMap& Headers() const; - void SetBlobDataHandle(RefPtr<BlobDataHandle>); - RefPtr<BlobDataHandle> GetBlobDataHandle() const; + void SetBlobDataHandle(scoped_refptr<BlobDataHandle>); + scoped_refptr<BlobDataHandle> GetBlobDataHandle() const; #endif private:
diff --git a/third_party/WebKit/public/web/WebSerializedScriptValue.h b/third_party/WebKit/public/web/WebSerializedScriptValue.h index 84206d00..f3e4048a 100644 --- a/third_party/WebKit/public/web/WebSerializedScriptValue.h +++ b/third_party/WebKit/public/web/WebSerializedScriptValue.h
@@ -79,10 +79,10 @@ BLINK_EXPORT v8::Local<v8::Value> Deserialize(v8::Isolate*); #if INSIDE_BLINK - BLINK_EXPORT WebSerializedScriptValue(WTF::RefPtr<SerializedScriptValue>); + BLINK_EXPORT WebSerializedScriptValue(scoped_refptr<SerializedScriptValue>); BLINK_EXPORT WebSerializedScriptValue& operator=( - WTF::RefPtr<SerializedScriptValue>); - BLINK_EXPORT operator WTF::RefPtr<SerializedScriptValue>() const; + scoped_refptr<SerializedScriptValue>); + BLINK_EXPORT operator scoped_refptr<SerializedScriptValue>() const; #endif private:
diff --git a/third_party/WebKit/public/web/WebUserGestureToken.h b/third_party/WebKit/public/web/WebUserGestureToken.h index c5f3d99..5a20709 100644 --- a/third_party/WebKit/public/web/WebUserGestureToken.h +++ b/third_party/WebKit/public/web/WebUserGestureToken.h
@@ -54,8 +54,8 @@ bool IsNull() const { return token_.IsNull(); } #if INSIDE_BLINK - explicit WebUserGestureToken(RefPtr<UserGestureToken>); - operator RefPtr<UserGestureToken>() const; + explicit WebUserGestureToken(scoped_refptr<UserGestureToken>); + operator scoped_refptr<UserGestureToken>() const; #endif private:
diff --git a/tools/metrics/actions/actions.xml b/tools/metrics/actions/actions.xml index 52f1a676..3aed64ad 100644 --- a/tools/metrics/actions/actions.xml +++ b/tools/metrics/actions/actions.xml
@@ -3339,6 +3339,11 @@ <description>Please enter the description of this user action.</description> </action> +<action name="ClearBrowsingData_SiteUsageData"> + <owner>mlamouri@chromium.org</owner> + <description>Recorded when the user clears site usage data.</description> +</action> + <action name="ClearBrowsingData_SwitchTo_AdvancedTab"> <owner>dullweber@chromium.org</owner> <owner>msramek@chromium.org</owner>
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 4f5e1c8..320c3e7 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml
@@ -33099,6 +33099,18 @@ </summary> </histogram> +<histogram name="Media.Engagement.URLsDeletedScoreReduction" units="%"> + <owner>beccahughes@chromium.org</owner> + <owner>media-dev@chromium.org</owner> + <summary> + Recorded when the history is cleared and the media engagement data are + similarly cleared. It records the reduction in score for each affected + origin. The algorithm is made to reduce the score by 0.0 as much as possible + and if it fails, the score will actually become 0.0 so every reduction also + represent the value of the previous score. + </summary> +</histogram> + <histogram name="Media.FallbackHardwareAudioBitsPerChannel"> <owner>dalecurtis@chromium.org</owner> <summary>
diff --git a/tools/perf/core/perf_data_generator.py b/tools/perf/core/perf_data_generator.py index c8b658c..1cf72e6 100755 --- a/tools/perf/core/perf_data_generator.py +++ b/tools/perf/core/perf_data_generator.py
@@ -642,7 +642,10 @@ ] -BENCHMARKS_TO_OUTPUT_HISTOGRAMS = [] +BENCHMARKS_TO_OUTPUT_HISTOGRAMS = [ + 'dummy_benchmark.noisy_benchmark_1', + 'dummy_benchmark.stable_benchmark_1', +] def generate_telemetry_test(swarming_dimensions, benchmark_name, browser):
diff --git a/tools/perf/page_sets/system_health/expectations.py b/tools/perf/page_sets/system_health/expectations.py index e85979e..7b9e7668 100644 --- a/tools/perf/page_sets/system_health/expectations.py +++ b/tools/perf/page_sets/system_health/expectations.py
@@ -52,10 +52,6 @@ [expectations.ALL], 'crbug.com/769809') self.DisableStory('browse:tools:maps', [expectations.ALL_MAC], 'crbug.com/773084') - self.DisableStory('load:news:wikipedia', - [expectations.ALL_WIN], 'crbug.com/777931') - self.DisableStory('load_accessibility:media:wikipedia', - [expectations.ALL_WIN], 'crbug.com/777931') class SystemHealthMobileCommonExpectations(expectations.StoryExpectations):
diff --git a/ui/arc/notification/arc_notification_delegate.cc b/ui/arc/notification/arc_notification_delegate.cc index e9dbb13..50a23bc 100644 --- a/ui/arc/notification/arc_notification_delegate.cc +++ b/ui/arc/notification/arc_notification_delegate.cc
@@ -45,15 +45,9 @@ item_->Click(); } -bool ArcNotificationDelegate::SettingsClick() { +void ArcNotificationDelegate::SettingsClick() { DCHECK(item_); item_->OpenSettings(); - return true; -} - -bool ArcNotificationDelegate::ShouldDisplaySettingsButton() { - DCHECK(item_); - return item_->IsOpeningSettingsSupported(); } } // namespace arc
diff --git a/ui/arc/notification/arc_notification_delegate.h b/ui/arc/notification/arc_notification_delegate.h index fffb31bf..89f623c 100644 --- a/ui/arc/notification/arc_notification_delegate.h +++ b/ui/arc/notification/arc_notification_delegate.h
@@ -35,8 +35,7 @@ // message_center::NotificationDelegate overrides: void Close(bool by_user) override; void Click() override; - bool SettingsClick() override; - bool ShouldDisplaySettingsButton() override; + void SettingsClick() override; private: // The destructor is private since this class is ref-counted.
diff --git a/ui/arc/notification/arc_notification_item_impl.cc b/ui/arc/notification/arc_notification_item_impl.cc index 0e35f05..b78352d 100644 --- a/ui/arc/notification/arc_notification_item_impl.cc +++ b/ui/arc/notification/arc_notification_item_impl.cc
@@ -85,6 +85,10 @@ base::ASCIIToUTF16("\n")); } rich_data.accessible_name = accessible_name_; + if (IsOpeningSettingsSupported()) { + rich_data.settings_button_handler = + message_center::SettingsButtonHandler::DELEGATE; + } message_center::NotifierId notifier_id( message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId);
diff --git a/ui/arc/notification/arc_notification_view.cc b/ui/arc/notification/arc_notification_view.cc index ca4f00fb..4eff0d6 100644 --- a/ui/arc/notification/arc_notification_view.cc +++ b/ui/arc/notification/arc_notification_view.cc
@@ -205,8 +205,7 @@ return; GetControlButtonsView()->ShowSettingsButton( - notification.delegate() && - notification.delegate()->ShouldDisplaySettingsButton()); + notification.should_show_settings_button()); GetControlButtonsView()->ShowCloseButton(!GetPinned()); UpdateControlButtonsVisibility(); }
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc index 3f49796..b7b1c69 100644 --- a/ui/compositor/compositor.cc +++ b/ui/compositor/compositor.cc
@@ -182,8 +182,11 @@ settings.disallow_non_exact_resource_reuse = command_line->HasSwitch(switches::kDisallowNonExactResourceReuse); - settings.wait_for_all_pipeline_stages_before_draw = - command_line->HasSwitch(cc::switches::kRunAllCompositorStagesBeforeDraw); + if (command_line->HasSwitch( + cc::switches::kRunAllCompositorStagesBeforeDraw)) { + settings.wait_for_all_pipeline_stages_before_draw = true; + settings.enable_latency_recovery = false; + } base::TimeTicks before_create = base::TimeTicks::Now();
diff --git a/ui/compositor/scoped_layer_animation_settings.cc b/ui/compositor/scoped_layer_animation_settings.cc index c6daf2b..a01a2ef 100644 --- a/ui/compositor/scoped_layer_animation_settings.cc +++ b/ui/compositor/scoped_layer_animation_settings.cc
@@ -127,10 +127,13 @@ animator_->set_tween_type(old_tween_type_); animator_->set_preemption_strategy(old_preemption_strategy_); - for (std::set<ImplicitAnimationObserver*>::const_iterator i = - observers_.begin(); i != observers_.end(); ++i) { - animator_->observers_.RemoveObserver(*i); - (*i)->SetActive(true); + for (auto* observer : observers_) { + // Directly remove |observer| from |LayerAnimator::observers_| rather than + // calling LayerAnimator::RemoveObserver(), to avoid removing it from the + // observer list of LayerAnimationSequences that have already been + // scheduled. + animator_->observers_.RemoveObserver(observer); + observer->SetActive(true); } }
diff --git a/ui/display/manager/forwarding_display_delegate.cc b/ui/display/manager/forwarding_display_delegate.cc index 5f3a7d9f..26b04bd 100644 --- a/ui/display/manager/forwarding_display_delegate.cc +++ b/ui/display/manager/forwarding_display_delegate.cc
@@ -38,7 +38,7 @@ void ForwardingDisplayDelegate::RelinquishDisplayControl( const DisplayControlCallback& callback) { - delegate_->TakeDisplayControl(callback); + delegate_->RelinquishDisplayControl(callback); } void ForwardingDisplayDelegate::GetDisplays(
diff --git a/ui/message_center/cocoa/notification_controller.mm b/ui/message_center/cocoa/notification_controller.mm index 580f722..1b9ff3e6 100644 --- a/ui/message_center/cocoa/notification_controller.mm +++ b/ui/message_center/cocoa/notification_controller.mm
@@ -340,8 +340,7 @@ [rootView addSubview:[self createSmallImageInFrame:rootFrame]]; // Create the settings button. - if (notification_->delegate() && - notification_->delegate()->ShouldDisplaySettingsButton()) { + if (notification_->should_show_settings_button()) { [self configureSettingsButtonInFrame:rootFrame]; [rootView addSubview:settingsButton_]; }
diff --git a/ui/message_center/cocoa/notification_controller_unittest.mm b/ui/message_center/cocoa/notification_controller_unittest.mm index 0d3c733..5b385a5e 100644 --- a/ui/message_center/cocoa/notification_controller_unittest.mm +++ b/ui/message_center/cocoa/notification_controller_unittest.mm
@@ -24,16 +24,6 @@ namespace { -// A test delegate used for tests that deal with the notification settings -// button. -class NotificationSettingsDelegate - : public message_center::NotificationDelegate { - bool ShouldDisplaySettingsButton() override { return true; } - - private: - ~NotificationSettingsDelegate() override {} -}; - class MockMessageCenter : public message_center::FakeMessageCenter { public: MockMessageCenter() @@ -157,14 +147,14 @@ } TEST_F(NotificationControllerTest, NotificationSetttingsButtonLayout) { + message_center::RichNotificationData data; + data.settings_button_handler = SettingsButtonHandler::TRAY; std::unique_ptr<message_center::Notification> notification( new message_center::Notification( message_center::NOTIFICATION_TYPE_SIMPLE, "", ASCIIToUTF16("Added to circles"), ASCIIToUTF16("Jonathan and 5 others"), gfx::Image(), base::string16(), - GURL("https://plus.com"), DummyNotifierId(), - message_center::RichNotificationData(), - new NotificationSettingsDelegate())); + GURL("https://plus.com"), DummyNotifierId(), data, NULL)); base::scoped_nsobject<MCNotificationController> controller( [[MCNotificationController alloc] initWithNotification:notification.get()
diff --git a/ui/message_center/message_center_impl.cc b/ui/message_center/message_center_impl.cc index bce1443..67ce2fac 100644 --- a/ui/message_center/message_center_impl.cc +++ b/ui/message_center/message_center_impl.cc
@@ -540,12 +540,13 @@ void MessageCenterImpl::ClickOnSettingsButton(const std::string& id) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK(!iterating_); - scoped_refptr<NotificationDelegate> delegate = - notification_list_->GetNotificationDelegate(id); + Notification* notification = notification_list_->GetNotificationById(id); - bool handled_by_delegate = false; - if (delegate.get()) - handled_by_delegate = delegate->SettingsClick(); + bool handled_by_delegate = + notification->rich_notification_data().settings_button_handler == + SettingsButtonHandler::DELEGATE; + if (handled_by_delegate) + notification->delegate()->SettingsClick(); { internal::ScopedNotificationsIterationLock lock(this);
diff --git a/ui/message_center/notification.cc b/ui/message_center/notification.cc index d5a030cb..a59fd91 100644 --- a/ui/message_center/notification.cc +++ b/ui/message_center/notification.cc
@@ -75,7 +75,8 @@ silent(other.silent), accessible_name(other.accessible_name), accent_color(other.accent_color), - use_image_as_icon(other.use_image_as_icon) { + use_image_as_icon(other.use_image_as_icon), + settings_button_handler(other.settings_button_handler) { } RichNotificationData::~RichNotificationData() = default;
diff --git a/ui/message_center/notification.h b/ui/message_center/notification.h index 55749586c..67446bbd 100644 --- a/ui/message_center/notification.h +++ b/ui/message_center/notification.h
@@ -54,6 +54,12 @@ TEXT }; +enum class SettingsButtonHandler { + NONE, // No button. This is the default. + TRAY, // Button shown, the tray handles clicks. Only used on Chrome OS. + DELEGATE // Button shown, notification's delegate handles action. +}; + enum class SystemNotificationWarningLevel { NORMAL, WARNING, CRITICAL_WARNING }; // Represents a button to be shown as part of a notification. @@ -179,6 +185,11 @@ // and hides the icon when the notification is expanded. // This is only effective when new style notification is enabled. bool use_image_as_icon = false; + + // Controls whether a settings button should appear on the notification. See + // enum definition. TODO(estade): turn this into a boolean. See + // crbug.com/780342 + SettingsButtonHandler settings_button_handler = SettingsButtonHandler::NONE; }; class MESSAGE_CENTER_EXPORT Notification { @@ -410,6 +421,11 @@ optional_fields_.use_image_as_icon = use_image_as_icon; } + bool should_show_settings_button() const { + return optional_fields_.settings_button_handler != + SettingsButtonHandler::NONE; + } + NotificationDelegate* delegate() const { return delegate_.get(); } const RichNotificationData& rich_notification_data() const {
diff --git a/ui/message_center/notification_delegate.cc b/ui/message_center/notification_delegate.cc index d6532ed..c2f3e00 100644 --- a/ui/message_center/notification_delegate.cc +++ b/ui/message_center/notification_delegate.cc
@@ -23,13 +23,7 @@ NOTIMPLEMENTED(); } -bool NotificationDelegate::SettingsClick() { - return false; -} - -bool NotificationDelegate::ShouldDisplaySettingsButton() { - return false; -} +void NotificationDelegate::SettingsClick() {} void NotificationDelegate::DisableNotification() {}
diff --git a/ui/message_center/notification_delegate.h b/ui/message_center/notification_delegate.h index 9bb58acb..6ccf9a70 100644 --- a/ui/message_center/notification_delegate.h +++ b/ui/message_center/notification_delegate.h
@@ -41,14 +41,9 @@ virtual void ButtonClickWithReply(int button_index, const base::string16& reply); - // To be called when the user clicks the settings button in a notification. - // Returns whether the settings click was handled by the delegate. - virtual bool SettingsClick(); - - // To be called in order to detect if a settings button should be displayed. - // This also controls whether a context menu is enabled (as the context menu - // is also used for controlling settings). - virtual bool ShouldDisplaySettingsButton(); + // To be called when the user clicks the settings button in a notification + // which has a CUSTOM settings button action. + virtual void SettingsClick(); // Called when the user attempts to disable the notification. virtual void DisableNotification();
diff --git a/ui/message_center/views/message_popup_collection.cc b/ui/message_center/views/message_popup_collection.cc index c32e4ef..b036486 100644 --- a/ui/message_center/views/message_popup_collection.cc +++ b/ui/message_center/views/message_popup_collection.cc
@@ -198,11 +198,10 @@ #endif // defined(OS_CHROMEOS) view->SetExpanded(true); - // TODO(yoshiki): Temporary disable context menu on custom notifications. - // See crbug.com/750307 for detail. + // TODO(yoshiki): Temporarily disable context menu on custom (arc) + // notifications. See crbug.com/750307 for detail. if (notification.type() != NOTIFICATION_TYPE_CUSTOM && - notification.delegate() && - notification.delegate()->ShouldDisplaySettingsButton()) { + notification.should_show_settings_button()) { view->set_context_menu_controller(context_menu_controller_.get()); }
diff --git a/ui/message_center/views/notification_view.cc b/ui/message_center/views/notification_view.cc index adf775c..9f00400 100644 --- a/ui/message_center/views/notification_view.cc +++ b/ui/message_center/views/notification_view.cc
@@ -640,8 +640,7 @@ void NotificationView::UpdateControlButtonsVisibilityWithNotification( const Notification& notification) { control_buttons_view_->ShowSettingsButton( - notification.delegate() && - notification.delegate()->ShouldDisplaySettingsButton()); + notification.should_show_settings_button()); control_buttons_view_->ShowCloseButton(!GetPinned()); UpdateControlButtonsVisibility(); }
diff --git a/ui/message_center/views/notification_view_md.cc b/ui/message_center/views/notification_view_md.cc index e254566a..bb2011b 100644 --- a/ui/message_center/views/notification_view_md.cc +++ b/ui/message_center/views/notification_view_md.cc
@@ -501,8 +501,7 @@ void NotificationViewMD::UpdateControlButtonsVisibilityWithNotification( const Notification& notification) { control_buttons_view_->ShowSettingsButton( - notification.delegate() && - notification.delegate()->ShouldDisplaySettingsButton()); + notification.should_show_settings_button()); control_buttons_view_->ShowCloseButton(!GetPinned()); UpdateControlButtonsVisibility(); }
diff --git a/ui/message_center/views/notification_view_unittest.cc b/ui/message_center/views/notification_view_unittest.cc index 276de957..bf7d950d 100644 --- a/ui/message_center/views/notification_view_unittest.cc +++ b/ui/message_center/views/notification_view_unittest.cc
@@ -45,15 +45,6 @@ namespace message_center { -// A test delegate used for tests that deal with the notification settings -// button. -class NotificationSettingsDelegate : public NotificationDelegate { - bool ShouldDisplaySettingsButton() override { return true; } - - private: - ~NotificationSettingsDelegate() override {} -}; - /* Test fixture ***************************************************************/ class NotificationViewTest : public views::ViewsTestBase, @@ -339,15 +330,13 @@ } TEST_F(NotificationViewTest, CreateOrUpdateTestSettingsButton) { - scoped_refptr<NotificationSettingsDelegate> delegate = - new NotificationSettingsDelegate(); - Notification notf(NOTIFICATION_TYPE_BASE_FORMAT, - std::string("notification id"), base::UTF8ToUTF16("title"), - base::UTF8ToUTF16("message"), CreateTestImage(80, 80), - base::UTF8ToUTF16("display source"), - GURL("https://hello.com"), - NotifierId(NotifierId::APPLICATION, "extension_id"), - *data(), delegate.get()); + data()->settings_button_handler = SettingsButtonHandler::TRAY; + Notification notf( + NOTIFICATION_TYPE_BASE_FORMAT, std::string("notification id"), + base::UTF8ToUTF16("title"), base::UTF8ToUTF16("message"), + CreateTestImage(80, 80), base::UTF8ToUTF16("display source"), + GURL("https://hello.com"), + NotifierId(NotifierId::APPLICATION, "extension_id"), *data(), nullptr); notification_view()->UpdateWithNotification(notf); EXPECT_TRUE(NULL != notification_view()->title_view_); @@ -549,15 +538,13 @@ } TEST_F(NotificationViewTest, SettingsButtonTest) { - scoped_refptr<NotificationSettingsDelegate> delegate = - new NotificationSettingsDelegate(); - Notification notf(NOTIFICATION_TYPE_BASE_FORMAT, - std::string("notification id"), base::UTF8ToUTF16("title"), - base::UTF8ToUTF16("message"), CreateTestImage(80, 80), - base::UTF8ToUTF16("display source"), - GURL("https://hello.com"), - NotifierId(NotifierId::APPLICATION, "extension_id"), - *data(), delegate.get()); + data()->settings_button_handler = SettingsButtonHandler::TRAY; + Notification notf( + NOTIFICATION_TYPE_BASE_FORMAT, std::string("notification id"), + base::UTF8ToUTF16("title"), base::UTF8ToUTF16("message"), + CreateTestImage(80, 80), base::UTF8ToUTF16("display source"), + GURL("https://hello.com"), + NotifierId(NotifierId::APPLICATION, "extension_id"), *data(), nullptr); notification_view()->UpdateWithNotification(notf); widget()->Show();
diff --git a/ui/ozone/platform/drm/host/host_drm_device.cc b/ui/ozone/platform/drm/host/host_drm_device.cc index 3eea882..9d1311b 100644 --- a/ui/ozone/platform/drm/host/host_drm_device.cc +++ b/ui/ozone/platform/drm/host/host_drm_device.cc
@@ -236,7 +236,7 @@ auto callback = base::BindOnce(&HostDrmDevice::GpuRelinquishDisplayControlCallback, weak_ptr_factory_.GetWeakPtr()); - drm_device_ptr_->TakeDisplayControl(std::move(callback)); + drm_device_ptr_->RelinquishDisplayControl(std::move(callback)); return true; }