diff --git a/BUILD.gn b/BUILD.gn index 0a85f36e..4d57603 100644 --- a/BUILD.gn +++ b/BUILD.gn
@@ -332,6 +332,7 @@ "//chrome/android/webapk/shell_apk:webapk", "//chrome/android/webapk/shell_apk/prepare_upload_dir:prepare_webapk_shell_upload_dir", "//chrome/test:android_browsertests", + "//components/embedder_support/android:components_embedder_support_junit_tests", "//components/permissions/android:components_permissions_junit_tests", "//components/policy/android:components_policy_junit_tests", "//components/signin/core/browser/android:components_signin_junit_tests",
diff --git a/DEPS b/DEPS index 4a8a4bf..8617a69 100644 --- a/DEPS +++ b/DEPS
@@ -175,11 +175,11 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Skia # and whatever else without interference from each other. - 'skia_revision': '141ac68fa0f7c5438f198bcbafa7b08e517e1779', + 'skia_revision': '56015e01150eaab826a8ef2526a34cfe67868b6a', # 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': 'f94348167d818f8f14d853ff31a6621d74ef7833', + 'v8_revision': '47d5b94beb4bdd89019366fb9afb785335986d0e', # 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. @@ -187,7 +187,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. - 'angle_revision': '273f9c7c26d701f4a9953594d15753f8a5d88538', + 'angle_revision': 'f98084edfc01f77be2d4bb1251246020662850a9', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling SwiftShader # and whatever else without interference from each other. @@ -195,7 +195,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling PDFium # and whatever else without interference from each other. - 'pdfium_revision': 'e6420a42159089bb02e5a91b17ea39c7df5ffbb0', + 'pdfium_revision': '56686c32e74301752e76e4ef8b52b012fe76ea45', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling BoringSSL # and whatever else without interference from each other. @@ -246,7 +246,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling devtools-frontend # and whatever else without interference from each other. - 'devtools_frontend_revision': '80517cb9ee4c901d7bab92ee66beb12f63ce0567', + 'devtools_frontend_revision': '29781ded1b6f0b58b414ea941f9c4363afc047c1', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libprotobuf-mutator # and whatever else without interference from each other. @@ -298,15 +298,15 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'shaderc_revision': 'a7657e4fa2feca67e535bfb20d4fa89fd704921e', + 'shaderc_revision': '95185d920a0b3d5a493f6f705ad8f0245c7d55cf', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'dawn_revision': '971a6233c2a459eb8f9a5f088c17dfb0cd70ee75', + 'dawn_revision': 'b988e0398277daa1f3938494d5ed1bf4c7328838', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'quiche_revision': '639a4bf5ff46e4b49a6ccc3677fd0f8122419503', + 'quiche_revision': '5efb965c1b4d8e7fda64d7b41ce2ca3c601fc3fb', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ios_webkit # and whatever else without interference from each other. @@ -777,17 +777,6 @@ 'condition': 'checkout_android', }, - 'src/third_party/apk-patch-size-estimator': { - 'packages': [ - { - 'package': 'chromium/third_party/apk-patch-size-estimator', - 'version': 'b603e99dca9b90d6a99519c232cd811878283b08', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - 'src/third_party/bazel': { 'packages': [ { @@ -1222,7 +1211,7 @@ Var('chromium_git') + '/external/github.com/cisco/openh264' + '@' + '6f26bce0b1c4e8ce0e13332f7c0083788def5fdf', 'src/third_party/openscreen/src': - Var('chromium_git') + '/openscreen' + '@' + '1aa882626c3dbd6c9c3349dd3f99f7da0b2d7028', + Var('chromium_git') + '/openscreen' + '@' + 'e43a73b009bdd06a43538c0f417fcf493c5beec1', 'src/third_party/openxr/src': { 'url': Var('chromium_git') + '/external/github.com/KhronosGroup/OpenXR-SDK' + '@' + '9e97b73e7dd2bfc07745489d728f6a36665c648f', @@ -1459,7 +1448,7 @@ Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + '84ee597cdeae08bb26e578fc66a35bcf35f633f4', 'src/third_party/webrtc': - Var('webrtc_git') + '/src.git' + '@' + '469205e1adafdc9cbe5942cd9a1c1af77e44fa82', + Var('webrtc_git') + '/src.git' + '@' + '570330361a17618924e1ad524211cef920eb4bac', 'src/third_party/libgifcodec': Var('skia_git') + '/libgifcodec' + '@'+ Var('libgifcodec_revision'),
diff --git a/ash/public/cpp/ash_typography.cc b/ash/public/cpp/ash_typography.cc index faa3425..cc2b11ec 100644 --- a/ash/public/cpp/ash_typography.cc +++ b/ash/public/cpp/ash_typography.cc
@@ -24,6 +24,12 @@ *size_delta = 15; break; } + + switch (style) { + case STYLE_EMPHASIZED: + *font_weight = gfx::Font::Weight::SEMIBOLD; + break; + } } } // namespace ash
diff --git a/ash/public/cpp/ash_typography.h b/ash/public/cpp/ash_typography.h index df33923..8cde6547 100644 --- a/ash/public/cpp/ash_typography.h +++ b/ash/public/cpp/ash_typography.h
@@ -29,6 +29,16 @@ ASH_TEXT_CONTEXT_END }; +enum AshTextStyle { + ASH_TEXT_STYLE_START = views::style::VIEWS_TEXT_STYLE_END, + + // Used to draw attention to a section of body text such as a matched search + // string. + STYLE_EMPHASIZED = ASH_TEXT_STYLE_START, + + ASH_TEXT_STYLE_END +}; + // Sets the |size_delta| and |font_weight| for ash-specific text contexts. // Values are only set for contexts specific to ash. void ASH_PUBLIC_EXPORT ApplyAshFontStyles(int context,
diff --git a/ash/shelf/README.md b/ash/shelf/README.md new file mode 100644 index 0000000..5b455f6f --- /dev/null +++ b/ash/shelf/README.md
@@ -0,0 +1,151 @@ +# Shelf + +This is the ash shelf, the system interface surface that allows users to launch +application shortcuts or go to the home screen, among other things. + +## Components + +The shelf contains the following components, each of which lives in its own +widget: + +* The **shelf widget** contains no actionable UI but contains the semi-opaque +background shown behind the whole shelf as well as the drag handle (in certain +circumstances) to give users a hint that gestures can be performed. In that +sense, even though the shelf widget does not actually contain other components, +it usually serves as a backdrop for them. + +* The **navigation widget** contains the home and back buttons. It is usually +shown in clamshell mode (but only with the home button) and hidden in tablet +mode, unless the activation of select accessibility features forces it to be +shown. When the navigation widget is not shown, the user can achieve the same +actions by performing gestures. + +* The **hotseat widget** contains icons for application shortcuts and running +applications. In clamshell mode, it is always visually contained within the +shelf widget; in tablet mode, it can appear and move independently. + +* The **status area widget** (whose code lives in `ash/system`) shows +information such as the clock or current battery level, and can toggle the +system tray. + +## Alignment + +The shelf is aligned to the bottom of the screen by default, but the user can +choose (only in clamshell mode) to align it to the left or right of the screen. +It always occupies the entirety of the corresponding dimension (width for a +horizontal shelf, height otherwise), with the navigation widget shown at the +start (top or left in left-to-right interfaces, bottom or right in +right-to-left) and the status area at the other end. + +## Auto-hiding + +The system allows the user to set a boolean preference, on a per-display basis, +specifying whether the shelf should "auto-hide". In that case, the shelf and its +components will be hidden from the screen most of the time, unless there are no +un-minimized windows or unless the user actively brings up the shelf with the +mouse or with a swipe. + +## Centering + +The hotseat widget is centered on the screen according to the following +principle: + +* All icons are placed at the center of the whole display if they can fit +without overlapping with any other shelf component. + +* Otherwise, they are centered within the space available to the hotseat. + +* If there are too many icons to fit in that space, the hotseat becomes +scrollable. + +## Responsive layout + +The shelf and its components need to adjust to a certain number of changes that +may or may not be user-triggered: + +* Switching between clamshell and tablet mode. + +* Changing the display size (for smaller displays, the shelf becomes more +compact) or orientation. + +* Changing the shelf alignment. + +* User events (clicks, taps, swipes). + +### Coordination + +All shelf components need to react to these changes in a coordinated manner to +maintain the smoothness of animations. + +Components should not register themselves as observers of these changes and +react to them on their own, because an adequate reaction may involve other +components as well. For instance, whether the navigation widget is shown (or is +scheduled to be shown at the end of the animation) will influence the amount of +space the hotseat widget can occupy. + +Instead, listening to those changes are handled at the `ShelfLayoutManager` +level, which is then responsible for making the changes trickling down to each +component as necessary. + +### Aim first, move second + +In reaction to any of these global changes, each component must first determine +where it wants to be at the end of the animation ("aim"). That calculation may +depend on the other shelf components. Then, and only then, should the change of +bounds be actually committed to each widget and the animations triggered +("move"). Failing to respect this "two-phase" approach may lead to janky +animations as each component may realize, only after it has started moving, that +another component's movement forces it to alter its final destination. + +### `ShelfComponent` interface + +Each of the shelf components exposes an API to other classes in order to ease +the process of responding to layout changes: + +* `CalculateTargetBounds` is the "aim" phase, where each component figures out +where it wants to be given the new conditions. This method must be called on +each component by order of dependency (a component B "depends" on another +component A if B needs to know A's target bounds before calculating its own). + +* `GetTargetBounds` allows for components depending on this one to calculate +their own target bounds accordingly. + +* `UpdateLayout` is the "move" phase, where each component actually changes it +bounds according to its target. + +* `UpdateTargetBoundsForGesture` allows each component to respond to a gesture +in progress by determining how (and whether) it should follow other components +along in the gesture. + +### Layout inputs + +Each shelf component is aware of the set of inputs that can cause its layout to +change. Each time the `UpdateLayout` method is called on it, it determines +whether any of its inputs has changed. If not, the method returns early and +avoids any actual re-layout for itself as well as other components that depend +solely on it. + +## Keyboard navigation + +In order for keyboard users to navigate smoothly between the various parts of +the shelf as they would expect, the `ShelfFocusCycler` class passes the focus to +each shelf component as appropriate, depending on which component has just +reliquished focus and on which direction the focus is going. The `ShelfWidget` +class is the only shelf component that doesn't receive keyboard focus since it +does not have any activatable elements. + +## Buttons + +The base class for all buttons on shelf components is `ShelfButton`, which +handles basic logic for keyboard navigation and ink drops. This class is then +derived into `ShelfControlButton` for things like the home or back button, and +`ShelfAppButton` for application shortcuts. + + +## Tooltips + +Tooltips for elements on the shelf require some specific logic on top of the +common tooltips because as a user hovers over each app shortcut, trying to +figure out what each one does, we do not want to adopt the default tooltip +behavior which would be to dismiss the previous tooltip and make the user wait +for the common timeout before showing the next one.
diff --git a/ash/shelf/drag_handle.cc b/ash/shelf/drag_handle.cc index ca00da8..05e5627d 100644 --- a/ash/shelf/drag_handle.cc +++ b/ash/shelf/drag_handle.cc
@@ -12,6 +12,7 @@ #include "ash/shell.h" #include "ash/strings/grit/ash_strings.h" #include "ash/style/ash_color_provider.h" +#include "ash/wm/overview/overview_controller.h" #include "base/bind.h" #include "base/debug/stack_trace.h" #include "base/timer/timer.h" @@ -103,11 +104,18 @@ } bool DragHandle::ShowDragHandleNudge() { + // Stop observing overview state if nudge show timer has fired. + if (!show_drag_handle_nudge_timer_.IsRunning()) + overview_observer_.RemoveAll(); + // Do not show drag handle nudge if it is already shown or drag handle is not // visible. - if (ShowingNudge() || !GetVisible()) + if (ShowingNudge() || window_drag_from_shelf_in_progress_ || !GetVisible()) return false; showing_nudge_ = true; + + StopDragHandleNudgeShowTimer(); + PrefService* pref = Shell::Get()->session_controller()->GetLastActiveUserPrefService(); base::TimeDelta nudge_duration = contextual_tooltip::GetNudgeTimeout( @@ -127,8 +135,16 @@ } void DragHandle::ScheduleShowDragHandleNudge() { - if (showing_nudge_) + if (showing_nudge_ || show_drag_handle_nudge_timer_.IsRunning() || + window_drag_from_shelf_in_progress_ || + Shell::Get()->overview_controller()->InOverviewSession()) { return; + } + + // Observe overview controller to detect overview session start - this should + // cancel the scheduled nudge show. + overview_observer_.Add(Shell::Get()->overview_controller()); + show_drag_handle_nudge_timer_.Start( FROM_HERE, kShowNudgeDelay, base::BindOnce(base::IgnoreResult(&DragHandle::ShowDragHandleNudge), @@ -141,7 +157,8 @@ } void DragHandle::HideDragHandleNudge(bool hidden_by_tap) { - show_drag_handle_nudge_timer_.Stop(); + StopDragHandleNudgeShowTimer(); + if (!ShowingNudge()) return; hide_drag_handle_nudge_timer_.Stop(); @@ -149,6 +166,28 @@ showing_nudge_ = false; } +void DragHandle::SetWindowDragFromShelfInProgress(bool gesture_in_progress) { + if (window_drag_from_shelf_in_progress_ == gesture_in_progress) + return; + + window_drag_from_shelf_in_progress_ = gesture_in_progress; + + // If the contextual nudge is not yet shown, make sure that any scheduled + // nudge show request is canceled. + if (!ShowingNudge()) { + StopDragHandleNudgeShowTimer(); + return; + } + + // If the drag handle nudge is shown when the gesture to home or overview + // starts, keep it around until the gesture completes. + if (window_drag_from_shelf_in_progress_) { + hide_drag_handle_nudge_timer_.Stop(); + } else { + HideDragHandleNudge(/*hidden_by_tap=*/false); + } +} + void DragHandle::OnGestureEvent(ui::GestureEvent* event) { if (!features::AreContextualNudgesEnabled()) return; @@ -180,6 +219,10 @@ return anchor_bounds; } +void DragHandle::OnOverviewModeStarting() { + StopDragHandleNudgeShowTimer(); +} + void DragHandle::ShowDragHandleTooltip() { DCHECK(!drag_handle_nudge_); drag_handle_nudge_ = new ContextualNudge( @@ -251,7 +294,7 @@ ui::ScopedLayerAnimationSettings opacity_animation_settings( opacity_animator); opacity_animation_settings.SetPreemptionStrategy( - ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); + ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); opacity_animation_settings.SetTweenType(gfx::Tween::LINEAR); opacity_animation_settings.SetTransitionDuration( hidden_by_tap ? kDragHandleHideOnTapAnimationDuration @@ -304,4 +347,9 @@ HideDragHandleNudge(true /*hidden_by_tap*/); } +void DragHandle::StopDragHandleNudgeShowTimer() { + show_drag_handle_nudge_timer_.Stop(); + overview_observer_.RemoveAll(); +} + } // namespace ash
diff --git a/ash/shelf/drag_handle.h b/ash/shelf/drag_handle.h index 20c00a0..19a0655 100644 --- a/ash/shelf/drag_handle.h +++ b/ash/shelf/drag_handle.h
@@ -8,7 +8,10 @@ #include "ash/ash_export.h" #include "ash/shelf/contextual_nudge.h" #include "ash/shelf/shelf_widget.h" +#include "ash/wm/overview/overview_controller.h" +#include "ash/wm/overview/overview_observer.h" #include "base/memory/weak_ptr.h" +#include "base/scoped_observer.h" #include "base/timer/timer.h" #include "ui/compositor/layer_animator.h" #include "ui/views/view.h" @@ -17,7 +20,8 @@ namespace ash { class ASH_EXPORT DragHandle : public views::View, - public views::ViewTargeterDelegate { + public views::ViewTargeterDelegate, + public OverviewObserver { public: explicit DragHandle(int drag_handle_corner_radius); DragHandle(const DragHandle&) = delete; @@ -45,10 +49,17 @@ // tapping the nudge. void HideDragHandleNudge(bool hidden_by_tap); + // Called when the window drag from shelf starts or ends. The drag handle + // contextual nudge will remain visible while the gesture is in progress. + void SetWindowDragFromShelfInProgress(bool gesture_in_progress); + // views::View: void OnGestureEvent(ui::GestureEvent* event) override; gfx::Rect GetAnchorBoundsInScreen() const override; + // OverviewObserver: + void OnOverviewModeStarting() override; + bool ShowingNudge() { return showing_nudge_; } bool has_show_drag_handle_timer_for_testing() { @@ -63,6 +74,10 @@ return hide_drag_handle_nudge_timer_.IsRunning(); } + void fire_hide_drag_handle_timer_for_testing() { + hide_drag_handle_nudge_timer_.FireNow(); + } + ContextualNudge* drag_handle_nudge_for_testing() { return drag_handle_nudge_; } @@ -90,6 +105,9 @@ // Handler for tap gesture on the contextual nudge widget. It hides the nudge. void HandleTapOnNudge(); + // Stops the timer to show the drag handle nudge. + void StopDragHandleNudgeShowTimer(); + // Timer to hide drag handle nudge if it has a timed life. base::OneShotTimer hide_drag_handle_nudge_timer_; @@ -98,9 +116,16 @@ bool showing_nudge_ = false; + // Whether window drag from shelf (i.e. gesture from in-app shelf to home or + // overview) is currently in progress. If the contextual nudge is shown when + // the gesture starts, it should remain shown until the gesture ends. + // Set by ShelfLayoutManager using SetWindowDragFromShelfInProgress(). + bool window_drag_from_shelf_in_progress_ = false; + // A label used to educate users about swipe gestures on the drag handle. ContextualNudge* drag_handle_nudge_ = nullptr; + ScopedObserver<OverviewController, OverviewObserver> overview_observer_{this}; base::WeakPtrFactory<DragHandle> weak_factory_{this}; };
diff --git a/ash/shelf/shelf_drag_handle_unittest.cc b/ash/shelf/shelf_drag_handle_unittest.cc index f6773455..aa1167a 100644 --- a/ash/shelf/shelf_drag_handle_unittest.cc +++ b/ash/shelf/shelf_drag_handle_unittest.cc
@@ -2,10 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "ash/app_list/test/app_list_test_helper.h" +#include "ash/home_screen/drag_window_from_shelf_controller.h" +#include "ash/home_screen/drag_window_from_shelf_controller_test_api.h" #include "ash/public/cpp/ash_features.h" #include "ash/session/session_controller_impl.h" #include "ash/shelf/contextual_tooltip.h" #include "ash/shelf/drag_handle.h" +#include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/test/shelf_layout_manager_test_base.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" @@ -20,6 +24,10 @@ return AshTestBase::GetPrimaryShelf()->shelf_widget(); } +ShelfLayoutManager* GetShelfLayoutManager() { + return AshTestBase::GetPrimaryShelf()->shelf_layout_manager(); +} + } // namespace // Test base for unit test related to drag handle contextual nudges. @@ -377,4 +385,241 @@ EXPECT_LE(nudge_bounds.bottom(), drag_handle_bounds.y()); } +// Tests that drag handle does not hide during the window drag from shelf +// gesture. +TEST_F(DragHandleContextualNudgeTest, + DragHandleNudgeNotHiddenDuringWindowDragFromShelf) { + TabletModeControllerTestApi().EnterTabletMode(); + + // Creates a widget that will become maximized in tablet mode. + views::Widget* widget = CreateTestWidget(); + widget->Maximize(); + + ShelfWidget* const shelf_widget = GetShelfWidget(); + DragHandle* const drag_handle = shelf_widget->GetDragHandle(); + + ASSERT_TRUE(drag_handle->has_show_drag_handle_timer_for_testing()); + drag_handle->fire_show_drag_handle_timer_for_testing(); + EXPECT_TRUE(drag_handle->ShowingNudge()); + + TabletModeControllerTestApi().LeaveTabletMode(); + // Advance time for more than a day (which should enable the nudge again). + test_clock_.Advance(base::TimeDelta::FromHours(25)); + TabletModeControllerTestApi().EnterTabletMode(); + EXPECT_TRUE(drag_handle->has_show_drag_handle_timer_for_testing()); + drag_handle->fire_show_drag_handle_timer_for_testing(); + EXPECT_TRUE(drag_handle->has_hide_drag_handle_timer_for_testing()); + + const gfx::Point start = drag_handle->GetBoundsInScreen().CenterPoint(); + // Simulates window drag from shelf gesture, and verifies that the timer to + // hide the drag handle nudge is canceled when the window drag from shelf + // starts. + GetEventGenerator()->GestureScrollSequenceWithCallback( + start, start + gfx::Vector2d(0, -200), + base::TimeDelta::FromMilliseconds(50), + /*num_steps = */ 6, + base::BindRepeating( + [](DragHandle* drag_handle, ui::EventType type, + const gfx::Vector2dF& offset) { + DragWindowFromShelfController* window_drag_controller = + GetShelfLayoutManager()->window_drag_controller_for_testing(); + if (window_drag_controller && + window_drag_controller->dragged_window()) { + EXPECT_FALSE( + drag_handle->has_hide_drag_handle_timer_for_testing()); + } + const bool scroll_end = type == ui::ET_GESTURE_SCROLL_END; + EXPECT_EQ(!scroll_end, drag_handle->ShowingNudge()); + }, + drag_handle)); + + // The nudge should be hidden when the gesture completes. + EXPECT_FALSE(drag_handle->ShowingNudge()); +} + +// Tests that window drag from shelf cancels drag handle contextual nudge from +// showing. +TEST_F(DragHandleContextualNudgeTest, + DragHandleNudgeNotShownDuringWindowDragFromShelf) { + TabletModeControllerTestApi().EnterTabletMode(); + + // Creates a widget that will become maximized in tablet mode. + views::Widget* widget = CreateTestWidget(); + widget->Maximize(); + + ShelfWidget* const shelf_widget = GetShelfWidget(); + DragHandle* const drag_handle = shelf_widget->GetDragHandle(); + + EXPECT_TRUE(drag_handle->has_show_drag_handle_timer_for_testing()); + + const gfx::Point start = + GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); + // Simulates window drag from shelf gesture, and verifies that the timer to + // show the drag handle nudge is canceled when the window drag from shelf + // starts. + GetEventGenerator()->GestureScrollSequenceWithCallback( + start, start + gfx::Vector2d(0, -200), + base::TimeDelta::FromMilliseconds(50), + /*num_steps = */ 6, + base::BindRepeating( + [](DragHandle* drag_handle, ui::EventType type, + const gfx::Vector2dF& offset) { + DragWindowFromShelfController* window_drag_controller = + GetShelfLayoutManager()->window_drag_controller_for_testing(); + if (window_drag_controller && + window_drag_controller->dragged_window()) { + EXPECT_FALSE( + drag_handle->has_show_drag_handle_timer_for_testing()); + + // Attempt to schedule the nudge should fail. + if (type != ui::ET_GESTURE_SCROLL_END) { + drag_handle->ScheduleShowDragHandleNudge(); + EXPECT_FALSE( + drag_handle->has_show_drag_handle_timer_for_testing()); + } + } + EXPECT_FALSE(drag_handle->ShowingNudge()); + }, + drag_handle)); + + // The nudge should be hidden when the gesture completes. + EXPECT_FALSE(drag_handle->ShowingNudge()); +} + +// Tests that drag handle nudge gets hidden when the user performs window drag +// from shelf to home. +TEST_F(DragHandleContextualNudgeTest, FlingFromShelfToHomeHidesTheNudge) { + TabletModeControllerTestApi().EnterTabletMode(); + + // Creates a widget that will become maximized in tablet mode. + views::Widget* widget = CreateTestWidget(); + widget->Maximize(); + + ShelfWidget* const shelf_widget = GetShelfWidget(); + DragHandle* const drag_handle = shelf_widget->GetDragHandle(); + + ASSERT_TRUE(drag_handle->has_show_drag_handle_timer_for_testing()); + drag_handle->fire_show_drag_handle_timer_for_testing(); + EXPECT_TRUE(drag_handle->ShowingNudge()); + + const gfx::Point start = drag_handle->GetBoundsInScreen().CenterPoint(); + // Simulates window drag from shelf gesture, and verifies that the timer to + // hide the drag handle nudge is canceled when the window drag from shelf + // starts. + GetEventGenerator()->GestureScrollSequenceWithCallback( + start, start + gfx::Vector2d(0, -300), + base::TimeDelta::FromMilliseconds(10), + /*num_steps = */ 6, + base::BindRepeating( + [](DragHandle* drag_handle, ui::EventType type, + const gfx::Vector2dF& offset) { + const bool scroll_end = type == ui::ET_GESTURE_SCROLL_END; + EXPECT_EQ(!scroll_end, drag_handle->ShowingNudge()); + }, + drag_handle)); + + // The nudge should be hidden when the gesture completes. + EXPECT_FALSE(drag_handle->ShowingNudge()); + GetAppListTestHelper()->CheckVisibility(true); +} + +// Tests that drag handle nudge gets hidden when the user performs window drag +// from shelf, even if the gesture does not end up going home. +TEST_F(DragHandleContextualNudgeTest, DragFromShelfToHomeHidesTheNudge) { + TabletModeControllerTestApi().EnterTabletMode(); + + // Creates a widget that will become maximized in tablet mode. + views::Widget* widget = CreateTestWidget(); + widget->Maximize(); + + ShelfWidget* const shelf_widget = GetShelfWidget(); + DragHandle* const drag_handle = shelf_widget->GetDragHandle(); + + ASSERT_TRUE(drag_handle->has_show_drag_handle_timer_for_testing()); + drag_handle->fire_show_drag_handle_timer_for_testing(); + EXPECT_TRUE(drag_handle->ShowingNudge()); + + const gfx::Point start = drag_handle->GetBoundsInScreen().CenterPoint(); + // Simulates window drag from shelf gesture, and verifies that the timer to + // hide the drag handle nudge is canceled when the window drag from shelf + // starts. + GetEventGenerator()->GestureScrollSequenceWithCallback( + start, start + gfx::Vector2d(0, -150), + base::TimeDelta::FromMilliseconds(500), + /*num_steps = */ 20, + base::BindRepeating( + [](DragHandle* drag_handle, ui::EventType type, + const gfx::Vector2dF& offset) { + DragWindowFromShelfController* window_drag_controller = + GetShelfLayoutManager()->window_drag_controller_for_testing(); + if (window_drag_controller && + window_drag_controller->dragged_window()) { + DragWindowFromShelfControllerTestApi().WaitUntilOverviewIsShown( + window_drag_controller); + } + const bool scroll_end = type == ui::ET_GESTURE_SCROLL_END; + EXPECT_EQ(!scroll_end, drag_handle->ShowingNudge()); + }, + drag_handle)); + + // The nudge should be hidden when the gesture completes. + EXPECT_FALSE(drag_handle->ShowingNudge()); + + GetAppListTestHelper()->CheckVisibility(false); + EXPECT_TRUE(Shell::Get()->overview_controller()->InOverviewSession()); +} + +// Tests that scheduled drag handle nudge show is canceled when overview starts. +TEST_F(DragHandleContextualNudgeTest, OverviewCancelsNudgeShow) { + TabletModeControllerTestApi().EnterTabletMode(); + + // Creates a widget that will become maximized in tablet mode. + views::Widget* widget = CreateTestWidget(); + widget->Maximize(); + + ShelfWidget* const shelf_widget = GetShelfWidget(); + DragHandle* const drag_handle = shelf_widget->GetDragHandle(); + + ASSERT_TRUE(drag_handle->has_show_drag_handle_timer_for_testing()); + Shell::Get()->overview_controller()->StartOverview(); + ASSERT_FALSE(drag_handle->has_show_drag_handle_timer_for_testing()); +} + +// Tests that tapping the drag handle can shown drag handle nudge in overview. +TEST_F(DragHandleContextualNudgeTest, DragHandleTapShowNudgeInOverview) { + TabletModeControllerTestApi().EnterTabletMode(); + + // Creates a widget that will become maximized in tablet mode. + views::Widget* widget = CreateTestWidget(); + widget->Maximize(); + + ShelfWidget* const shelf_widget = GetShelfWidget(); + DragHandle* const drag_handle = shelf_widget->GetDragHandle(); + + ASSERT_TRUE(drag_handle->has_show_drag_handle_timer_for_testing()); + drag_handle->fire_show_drag_handle_timer_for_testing(); + EXPECT_TRUE(drag_handle->ShowingNudge()); + + TabletModeControllerTestApi().LeaveTabletMode(); + TabletModeControllerTestApi().EnterTabletMode(); + + Shell::Get()->overview_controller()->StartOverview(); + ASSERT_FALSE(drag_handle->has_show_drag_handle_timer_for_testing()); + + GetEventGenerator()->GestureTapAt( + drag_handle->GetBoundsInScreen().CenterPoint()); + + EXPECT_TRUE(drag_handle->GetVisible()); + EXPECT_TRUE(drag_handle->ShowingNudge()); + + EXPECT_TRUE(drag_handle->has_hide_drag_handle_timer_for_testing()); + drag_handle->fire_hide_drag_handle_timer_for_testing(); + EXPECT_FALSE(drag_handle->ShowingNudge()); + + // Tapping the drag handle again will show the nudge again. + GetEventGenerator()->GestureTapAt( + drag_handle->GetBoundsInScreen().CenterPoint()); + EXPECT_TRUE(drag_handle->ShowingNudge()); +} + } // namespace ash
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc index 3a57bf0..4d19f4d1 100644 --- a/ash/shelf/shelf_layout_manager.cc +++ b/ash/shelf/shelf_layout_manager.cc
@@ -1569,14 +1569,7 @@ if (drag_status_ == kDragInProgress) UpdateTargetBoundsForGesture(hotseat_target_state); - - // TODO(manucornet): Snap bounds in the shelf widget directly, and adjust - // tests that don't expect snapped bounds. const gfx::Rect shelf_bounds = shelf_->shelf_widget()->GetTargetBounds(); - gfx::Rect snapped_shelf_bounds(shelf_bounds); - screen_util::SnapBoundsToDisplayEdge( - snapped_shelf_bounds, shelf_->shelf_widget()->GetNativeWindow()); - shelf_->shelf_widget()->set_target_bounds(snapped_shelf_bounds); return shelf_->SelectValueForShelfAlignment( gfx::Insets(0, 0, @@ -2603,6 +2596,8 @@ return false; } + shelf_widget_->GetDragHandle()->SetWindowDragFromShelfInProgress(true); + aura::Window* window = GetWindowForDragToHomeOrOverview(event_in_screen.location()); allow_fling_from_overview_to_home_ = !window; @@ -2632,6 +2627,8 @@ if (!IsWindowDragInProgress()) return base::nullopt; + shelf_widget_->GetDragHandle()->SetWindowDragFromShelfInProgress(false); + DCHECK_EQ(drag_status_, kDragInProgress); base::Optional<float> velocity_y; if (event_in_screen.type() == ui::ET_SCROLL_FLING_START) { @@ -2653,6 +2650,8 @@ return false; } + shelf_widget_->GetDragHandle()->SetWindowDragFromShelfInProgress(false); + if (event_in_screen.type() != ui::ET_SCROLL_FLING_START) return false; @@ -2685,6 +2684,7 @@ return; DCHECK_EQ(drag_status_, kDragInProgress); + shelf_widget_->GetDragHandle()->SetWindowDragFromShelfInProgress(false); window_drag_controller_->CancelDrag(); }
diff --git a/ash/shelf/shelf_view.h b/ash/shelf/shelf_view.h index 1c66527..5e35f3a 100644 --- a/ash/shelf/shelf_view.h +++ b/ash/shelf/shelf_view.h
@@ -67,40 +67,6 @@ // ShelfView contains the shelf items visible within an active user session. // ShelfView and LoginShelfView should never be shown together. -// In the following example, there are 12 apps to place on the shelf, plus -// the app list and back buttons, which make 14 shelf items in total. -// -// If there is enough screen space, all icons can fit: -// -// ------------------------------------------------------------ -// | o | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -// ------------------------------------------------------------ -// ^ ^ -// | | -// first_visible_index = 0 last_visible_index = 10 -// -// Where "o" is the home button (back button is hidden). -// -// If screen space is more constrained, some icons are placed in an overflow -// menu (which holds its own instance of ShelfView): -// -// first_visible_index = 8 last_visible_index = 11 -// (for the overflow) (for overflow) -// | | -// v v -// --------------------- -// | 8 | 9 | 10 | 11 | -// --------------------- -// ^ -// -------------------------------------------------- -// | o | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | ... | -// -------------------------------------------------- -// ^ ^ ^ -// | | L-- overflow button -// first_visible_index = 0 | -// (for the main shelf) last_visible_index = 7 -// - class ASH_EXPORT ShelfView : public views::AccessiblePaneView, public ShelfButtonDelegate, public ShelfModelObserver,
diff --git a/ash/shelf/shelf_widget.cc b/ash/shelf/shelf_widget.cc index bd12a4f..9ed568c 100644 --- a/ash/shelf/shelf_widget.cc +++ b/ash/shelf/shelf_widget.cc
@@ -843,6 +843,7 @@ target_bounds_ = gfx::Rect(shelf_origin.x(), shelf_origin.y(), shelf_width, shelf_height); + screen_util::SnapBoundsToDisplayEdge(target_bounds_, GetNativeWindow()); } void ShelfWidget::UpdateLayout(bool animate) {
diff --git a/ash/shortcut_viewer/views/keyboard_shortcut_view.cc b/ash/shortcut_viewer/views/keyboard_shortcut_view.cc index bb4073d..7a505dc 100644 --- a/ash/shortcut_viewer/views/keyboard_shortcut_view.cc +++ b/ash/shortcut_viewer/views/keyboard_shortcut_view.cc
@@ -12,6 +12,7 @@ #include "ash/display/privacy_screen_controller.h" #include "ash/public/cpp/app_list/internal_app_id_constants.h" #include "ash/public/cpp/app_types.h" +#include "ash/public/cpp/ash_typography.h" #include "ash/public/cpp/resources/grit/ash_public_unscaled_resources.h" #include "ash/public/cpp/shelf_item.h" #include "ash/public/cpp/window_properties.h" @@ -516,7 +517,8 @@ search_query); ShortcutCategory current_category = ShortcutCategory::kUnknown; bool has_category_item = false; - std::vector<KeyboardShortcutItemView*> shortcut_items; + found_shortcut_items_.clear(); + for (const auto& item_view : shortcut_views_) { base::string16 description_text = item_view->description_label_view()->GetText(); @@ -547,8 +549,7 @@ item_view->description_label_view(); // Clear previous styles. description_label_view->ClearStyleRanges(); - style.custom_font = description_label_view->GetDefaultFontList().Derive( - 0, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::BOLD); + style.text_style = ash::AshTextStyle::STYLE_EMPHASIZED; description_label_view->AddStyleRange( gfx::Range(match_index, match_index + match_length), style); // Apply new styles to highlight matched search query. @@ -556,14 +557,14 @@ } found_items_list_view->AddChildView(item_view.get()); - shortcut_items.emplace_back(item_view.get()); + found_shortcut_items_.emplace_back(item_view.get()); } } std::vector<base::string16> replacement_strings; - const int number_search_results = shortcut_items.size(); + const int number_search_results = found_shortcut_items_.size(); if (!found_items_list_view->children().empty()) { - UpdateAXNodeDataPosition(shortcut_items); + UpdateAXNodeDataPosition(found_shortcut_items_); replacement_strings.emplace_back( base::NumberToString16(number_search_results)); @@ -624,6 +625,11 @@ return search_box_view_.get(); } +const std::vector<KeyboardShortcutItemView*>& +KeyboardShortcutView::GetFoundShortcutItemsForTesting() const { + return found_shortcut_items_; +} + } // namespace keyboard_shortcut_viewer namespace ash {
diff --git a/ash/shortcut_viewer/views/keyboard_shortcut_view.h b/ash/shortcut_viewer/views/keyboard_shortcut_view.h index 6ffbea2..e8c1f00 100644 --- a/ash/shortcut_viewer/views/keyboard_shortcut_view.h +++ b/ash/shortcut_viewer/views/keyboard_shortcut_view.h
@@ -91,6 +91,8 @@ const std::vector<std::unique_ptr<KeyboardShortcutItemView>>& GetShortcutViewsForTesting() const; KSVSearchBoxView* GetSearchBoxViewForTesting(); + const std::vector<KeyboardShortcutItemView*>& + GetFoundShortcutItemsForTesting() const; // Owned by views hierarchy. // The container for category tabs and lists of KeyboardShortcutItemViews. @@ -107,6 +109,9 @@ // KeyboardShortcutItemView layout when switching between tabs and search. std::vector<std::unique_ptr<KeyboardShortcutItemView>> shortcut_views_; + // Contains all the found shortcut items. + std::vector<KeyboardShortcutItemView*> found_shortcut_items_; + // An illustration to indicate no search results found. Since this view need // to be added and removed frequently from the |search_results_container_|, it // is not owned by view hierarchy to avoid recreating it.
diff --git a/ash/shortcut_viewer/views/keyboard_shortcut_view_unittest.cc b/ash/shortcut_viewer/views/keyboard_shortcut_view_unittest.cc index 7bf89e4..0336ad9 100644 --- a/ash/shortcut_viewer/views/keyboard_shortcut_view_unittest.cc +++ b/ash/shortcut_viewer/views/keyboard_shortcut_view_unittest.cc
@@ -12,6 +12,7 @@ #include "ash/test/ash_test_base.h" #include "base/bind.h" #include "base/test/metrics/histogram_tester.h" +#include "base/test/task_environment.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/aura/window.h" #include "ui/compositor/test/test_utils.h" @@ -26,7 +27,8 @@ class KeyboardShortcutViewTest : public ash::AshTestBase { public: - KeyboardShortcutViewTest() = default; + KeyboardShortcutViewTest() + : ash::AshTestBase(base::test::TaskEnvironment::TimeSource::MOCK_TIME) {} ~KeyboardShortcutViewTest() override = default; views::Widget* Toggle() { return KeyboardShortcutView::Toggle(GetContext()); } @@ -45,7 +47,7 @@ } const std::vector<std::unique_ptr<KeyboardShortcutItemView>>& - GetShortcutViews() { + GetShortcutViews() const { DCHECK(GetView()); return GetView()->GetShortcutViewsForTesting(); } @@ -55,6 +57,11 @@ return GetView()->GetSearchBoxViewForTesting(); } + const std::vector<KeyboardShortcutItemView*>& GetFoundShortcutItems() const { + DCHECK(GetView()); + return GetView()->GetFoundShortcutItemsForTesting(); + } + void KeyPress(ui::KeyboardCode key_code, bool should_insert) { ui::KeyEvent event(ui::ET_KEY_PRESSED, key_code, ui::EF_NONE); GetSearchBoxView()->OnKeyEvent(&event); @@ -232,4 +239,44 @@ EXPECT_TRUE(widget->IsClosed()); } +// Test that the sub-labels of the |description_label_view| in the search +// results page have the same height and are vertically aligned. +TEST_F(KeyboardShortcutViewTest, ShouldAlignSubLabelsInSearchResults) { + // Show the widget. + Toggle(); + + EXPECT_TRUE(GetFoundShortcutItems().empty()); + // Type a letter and show the search results. + KeyPress(ui::VKEY_A, /*should_insert=*/true); + auto time_out = base::TimeDelta::FromMilliseconds(300); + task_environment_->FastForwardBy(time_out); + base::RunLoop().RunUntilIdle(); + EXPECT_FALSE(GetFoundShortcutItems().empty()); + + for (const auto* item_view : GetFoundShortcutItems()) { + ASSERT_EQ(2u, item_view->children().size()); + + const views::View* description = item_view->children()[0]; + // Skip if it only has one label. + if (description->children().size() == 1) + continue; + + // The sub-labels in |description_label_view_| have the same height and are + // vertically aligned in each line. + int height = 0; + int center_y = 0; + for (const auto* child : description->children()) { + // The first view in each line. + if (child->bounds().x() == 0) { + height = child->bounds().height(); + center_y = child->bounds().CenterPoint().y(); + continue; + } + + EXPECT_EQ(height, child->GetPreferredSize().height()); + EXPECT_EQ(center_y, child->bounds().CenterPoint().y()); + } + } +} + } // namespace keyboard_shortcut_viewer
diff --git a/base/android/android_image_reader_compat.cc b/base/android/android_image_reader_compat.cc index 032aa122..a64a38d 100644 --- a/base/android/android_image_reader_compat.cc +++ b/base/android/android_image_reader_compat.cc
@@ -22,8 +22,6 @@ namespace base { namespace android { -bool AndroidImageReader::disable_support_ = false; - AndroidImageReader& AndroidImageReader::GetInstance() { // C++11 static local variable initialization is // thread-safe. @@ -31,12 +29,8 @@ return *instance; } -void AndroidImageReader::DisableSupport() { - disable_support_ = true; -} - bool AndroidImageReader::IsSupported() { - return !disable_support_ && is_supported_; + return is_supported_; } AndroidImageReader::AndroidImageReader() {
diff --git a/base/android/android_image_reader_compat.h b/base/android/android_image_reader_compat.h index b882188..77d5458 100644 --- a/base/android/android_image_reader_compat.h +++ b/base/android/android_image_reader_compat.h
@@ -22,9 +22,6 @@ // Thread safe GetInstance. static AndroidImageReader& GetInstance(); - // Disable image reader support. - static void DisableSupport(); - // Check if the image reader usage is supported. This function returns TRUE // if android version is >=OREO, image reader support is not disabled and all // the required functions are loaded. @@ -67,7 +64,6 @@ AndroidImageReader(); bool LoadFunctions(); - static bool disable_support_; bool is_supported_; pAImage_delete AImage_delete_; pAImage_deleteAsync AImage_deleteAsync_;
diff --git a/base/android/java/src/org/chromium/base/metrics/CachingUmaRecorder.java b/base/android/java/src/org/chromium/base/metrics/CachingUmaRecorder.java index 00b417f..949cae42 100644 --- a/base/android/java/src/org/chromium/base/metrics/CachingUmaRecorder.java +++ b/base/android/java/src/org/chromium/base/metrics/CachingUmaRecorder.java
@@ -473,4 +473,21 @@ final int numBuckets = 0; cacheOrRecordSample(Histogram.Type.SPARSE, name, sample, min, max, numBuckets); } + + @Override + public void recordUserAction(String name, long elapsedRealtimeMillis) { + mRwLock.readLock().lock(); + try { + if (mDelegate != null) { + mDelegate.recordUserAction(name, elapsedRealtimeMillis); + } else { + // TODO(crbug.com/1048429): Implement caching. Existing code hitting this branch + // would have crashed in the previous implementation. + Log.d(TAG, "recordUserAction(%s, %d) called, but cache is not implemented yet", + name, elapsedRealtimeMillis); + } + } finally { + mRwLock.readLock().unlock(); + } + } }
diff --git a/base/android/java/src/org/chromium/base/metrics/NativeUmaRecorder.java b/base/android/java/src/org/chromium/base/metrics/NativeUmaRecorder.java index ee7f7e63..9979f61 100644 --- a/base/android/java/src/org/chromium/base/metrics/NativeUmaRecorder.java +++ b/base/android/java/src/org/chromium/base/metrics/NativeUmaRecorder.java
@@ -4,6 +4,8 @@ package org.chromium.base.metrics; +import android.os.SystemClock; + import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.MainDex; import org.chromium.base.annotations.NativeMethods; @@ -61,6 +63,13 @@ maybeUpdateNativeHint(name, oldHint, newHint); } + @Override + public void recordUserAction(String name, long elapsedRealtimeMillis) { + // Java and native code use different clocks. We need a relative elapsed time. + long millisSinceEvent = SystemClock.elapsedRealtime() - elapsedRealtimeMillis; + NativeUmaRecorderJni.get().recordUserAction(name, millisSinceEvent); + } + private long getNativeHint(String name) { Long hint = mNativeHints.get(name); // Note: If key is null, we don't have it cached. In that case, pass 0 @@ -85,5 +94,16 @@ long recordLinearHistogram( String name, long nativeHint, int sample, int min, int max, int numBuckets); long recordSparseHistogram(String name, long nativeHint, int sample); + + /** + * Records that the user performed an action. See {@code base::RecordComputedActionAt}. + * <p> + * Uses relative time, because Java and native code can use different clocks. + * + * @param name Name of the user-generated event. + * @param millisSinceEvent difference between now and the time when the event was observed. + * Should be positive. + */ + void recordUserAction(String name, long millisSinceEvent); } }
diff --git a/base/android/java/src/org/chromium/base/metrics/NoopUmaRecorder.java b/base/android/java/src/org/chromium/base/metrics/NoopUmaRecorder.java index cb8cee9b..196a729 100644 --- a/base/android/java/src/org/chromium/base/metrics/NoopUmaRecorder.java +++ b/base/android/java/src/org/chromium/base/metrics/NoopUmaRecorder.java
@@ -18,4 +18,7 @@ @Override public void recordSparseHistogram(String name, int sample) {} + + @Override + public void recordUserAction(String name, long elapsedRealtimeMillis) {} }
diff --git a/base/android/java/src/org/chromium/base/metrics/RecordUserAction.java b/base/android/java/src/org/chromium/base/metrics/RecordUserAction.java index 9c610ca..e75f92bb 100644 --- a/base/android/java/src/org/chromium/base/metrics/RecordUserAction.java +++ b/base/android/java/src/org/chromium/base/metrics/RecordUserAction.java
@@ -4,7 +4,7 @@ package org.chromium.base.metrics; -import androidx.annotation.VisibleForTesting; +import android.os.SystemClock; import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.JNINamespace; @@ -12,32 +12,23 @@ /** * Java API for recording UMA actions. - * - * WARNINGS: - * JNI calls are relatively costly - avoid using in performance-critical code. - * - * We use a script (extract_actions.py) to scan the source code and extract actions. A string - * literal (not a variable) must be passed to record(). + * <p> + * WARNINGS: JNI calls are relatively costly - avoid using in performance-critical code. + * <p> + * Action names must be documented in {@code actions.xml}. See {@link + * https://source.chromium.org/chromium/chromium/src/+/master:tools/metrics/actions/README.md} <p> + * We use a script ({@code extract_actions.py{}) to scan the source code and extract actions. A + * string literal (not a variable) must be passed to {@link #record(String)}. */ @JNINamespace("base::android") public class RecordUserAction { - private static Throwable sDisabledBy; - /** - * Tests may not have native initialized, so they may need to disable metrics. The value should - * be reset after the test done, to avoid carrying over state to unrelated tests. + * Similar to {@code base::RecordAction()} in C++. + * <p> + * Record that the user performed an action. See tools/metrics/actions/README.md */ - @VisibleForTesting - public static void setDisabledForTests(boolean disabled) { - if (disabled && sDisabledBy != null) { - throw new IllegalStateException("UserActions are already disabled.", sDisabledBy); - } - sDisabledBy = disabled ? new Throwable() : null; - } - public static void record(final String action) { - if (sDisabledBy != null) return; - RecordUserActionJni.get().recordUserAction(action); + UmaRecorderHolder.get().recordUserAction(action, SystemClock.elapsedRealtime()); } /** @@ -71,7 +62,6 @@ @NativeMethods interface Natives { - void recordUserAction(String action); long addActionCallbackForTesting(UserActionCallback callback); void removeActionCallbackForTesting(long callbackId); }
diff --git a/base/android/java/src/org/chromium/base/metrics/UmaRecorder.java b/base/android/java/src/org/chromium/base/metrics/UmaRecorder.java index 167d799..b4f3cd5 100644 --- a/base/android/java/src/org/chromium/base/metrics/UmaRecorder.java +++ b/base/android/java/src/org/chromium/base/metrics/UmaRecorder.java
@@ -17,11 +17,11 @@ * This is the default histogram type used by "counts", "times" and "memory" histograms in * {@code base/metrics/histogram_functions.h} * - * @param min the smallest value recorded in the first bucket; should be greater than zero - * @param max the smallest value recorded in the overflow bucket + * @param min the smallest value recorded in the first bucket; should be greater than zero. + * @param max the smallest value recorded in the overflow bucket. * @param numBuckets number of histogram buckets: Two buckets are used for underflow and - * overflow, and the remaining buckets cover the range {@code [min, max)}; - * {@code numBuckets} should be {@code 100} or less. + * overflow, and the remaining buckets cover the range {@code [min, max)}; {@code + * numBuckets} should be {@code 100} or less. */ void recordExponentialHistogram(String name, int sample, int min, int max, int numBuckets); @@ -33,11 +33,11 @@ * This histogram type is best suited for recording enums, percentages and ratios. * * @param min the smallest value recorded in the first bucket; should be equal to one, but will - * work with values greater than zero - * @param max the smallest value recorded in the overflow bucket + * work with values greater than zero. + * @param max the smallest value recorded in the overflow bucket. * @param numBuckets number of histogram buckets: Two buckets are used for underflow and - * overflow, and the remaining buckets evenly cover the range - * {@code [min, max)}; {@code numBuckets} should be {@code 100} or less. + * overflow, and the remaining buckets evenly cover the range {@code [min, max)}; {@code + * numBuckets} should be {@code 100} or less. */ void recordLinearHistogram(String name, int sample, int min, int max, int numBuckets); @@ -47,4 +47,14 @@ * https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md#when-to-use-sparse-histograms} */ void recordSparseHistogram(String name, int sample); + + /** + * Records a user action. Action names must be documented in {@code actions.xml}. See {@link + * https://source.chromium.org/chromium/chromium/src/+/master:tools/metrics/actions/README.md} + * + * @param name Name of the user action. + * @param elapsedRealtimeMillis Value of {@link android.os.SystemClock.elapsedRealtime()} when + * the action was observed. + */ + void recordUserAction(String name, long elapsedRealtimeMillis); }
diff --git a/base/android/junit/src/org/chromium/base/metrics/CachingUmaRecorderTest.java b/base/android/junit/src/org/chromium/base/metrics/CachingUmaRecorderTest.java index bfa7fda..cb5544b7 100644 --- a/base/android/junit/src/org/chromium/base/metrics/CachingUmaRecorderTest.java +++ b/base/android/junit/src/org/chromium/base/metrics/CachingUmaRecorderTest.java
@@ -159,6 +159,17 @@ } @Test + public void testRecordUserActionDelegated() { + CachingUmaRecorder cachingUmaRecorder = new CachingUmaRecorder(); + cachingUmaRecorder.setDelegate(mUmaRecorder); + + cachingUmaRecorder.recordUserAction("ActionTested", 72); + + verify(mUmaRecorder).recordUserAction("ActionTested", 72); + verifyNoMoreInteractions(mUmaRecorder); + } + + @Test public void testSetDelegateStopsOldDelegation() { CachingUmaRecorder cachingUmaRecorder = new CachingUmaRecorder(); cachingUmaRecorder.setDelegate(mUmaRecorder); @@ -278,6 +289,11 @@ public void recordSparseHistogram(String name, int sample) { recordedSamples.addAndGet(sample, 1); } + + @Override + public void recordUserAction(String name, long elapsedRealtimeMillis) { + throw new UnsupportedOperationException(); + } } @Test
diff --git a/base/android/native_uma_recorder.cc b/base/android/native_uma_recorder.cc index b8b728a..16901cb 100644 --- a/base/android/native_uma_recorder.cc +++ b/base/android/native_uma_recorder.cc
@@ -10,6 +10,7 @@ #include "base/metrics/histogram.h" #include "base/metrics/histogram_base.h" #include "base/metrics/sparse_histogram.h" +#include "base/metrics/user_metrics.h" #include "base/strings/stringprintf.h" #include "base/synchronization/lock.h" #include "base/time/time.h" @@ -207,5 +208,14 @@ return reinterpret_cast<jlong>(histogram); } +void JNI_NativeUmaRecorder_RecordUserAction( + JNIEnv* env, + const JavaParamRef<jstring>& j_user_action_name, + jlong j_millis_since_event) { + // Time values coming from Java need to be synchronized with TimeTick clock. + RecordComputedActionSince(ConvertJavaStringToUTF8(env, j_user_action_name), + TimeDelta::FromMilliseconds(j_millis_since_event)); +} + } // namespace android } // namespace base
diff --git a/base/android/record_user_action.cc b/base/android/record_user_action.cc index ea12b1b..898a613b 100644 --- a/base/android/record_user_action.cc +++ b/base/android/record_user_action.cc
@@ -17,12 +17,6 @@ namespace base { namespace android { -static void JNI_RecordUserAction_RecordUserAction( - JNIEnv* env, - const JavaParamRef<jstring>& j_action) { - RecordComputedAction(ConvertJavaStringToUTF8(env, j_action)); -} - static void OnActionRecorded(const JavaRef<jobject>& callback, const std::string& action, TimeTicks action_time) {
diff --git a/base/metrics/user_metrics.cc b/base/metrics/user_metrics.cc index 96183ac4..b007d62 100644 --- a/base/metrics/user_metrics.cc +++ b/base/metrics/user_metrics.cc
@@ -34,6 +34,11 @@ RecordComputedActionAt(action, TimeTicks::Now()); } +void RecordComputedActionSince(const std::string& action, + TimeDelta time_since) { + RecordComputedActionAt(action, TimeTicks::Now() - time_since); +} + void RecordComputedActionAt(const std::string& action, TimeTicks action_time) { TRACE_EVENT_INSTANT1("ui", "UserEvent", TRACE_EVENT_SCOPE_GLOBAL, "action", action);
diff --git a/base/metrics/user_metrics.h b/base/metrics/user_metrics.h index 3d9cb8a..fed08279 100644 --- a/base/metrics/user_metrics.h +++ b/base/metrics/user_metrics.h
@@ -62,6 +62,11 @@ BASE_EXPORT void RecordComputedActionAt(const std::string& action, TimeTicks action_time); +// Similar to RecordComputedActionAt, but takes the amount of time elasped since +// the action was observed. +BASE_EXPORT void RecordComputedActionSince(const std::string& action, + TimeDelta time_since); + // Called with the action string. using ActionCallback = RepeatingCallback<void(const std::string&, TimeTicks)>;
diff --git a/base/test/android/javatests/src/org/chromium/base/test/DisableNativeTestRule.java b/base/test/android/javatests/src/org/chromium/base/test/DisableNativeTestRule.java index 6ccf21c..9d5d2f4 100644 --- a/base/test/android/javatests/src/org/chromium/base/test/DisableNativeTestRule.java +++ b/base/test/android/javatests/src/org/chromium/base/test/DisableNativeTestRule.java
@@ -9,7 +9,6 @@ import org.junit.runners.model.Statement; import org.chromium.base.Log; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.metrics.UmaRecorderHolder; /** @@ -27,7 +26,6 @@ if (loadNative == null) { Log.i(TAG, "Disable RecordHistogram and RecordUserAction for testing"); UmaRecorderHolder.setDisabledForTests(true); - RecordUserAction.setDisabledForTests(true); } else { Log.i(TAG, "Test will run with native libraries"); } @@ -37,7 +35,6 @@ if (loadNative == null) { Log.i(TAG, "Re-enable RecordHistogram and RecordUserAction after test"); UmaRecorderHolder.setDisabledForTests(false); - RecordUserAction.setDisabledForTests(false); } } }
diff --git a/base/test/metrics/user_action_tester.cc b/base/test/metrics/user_action_tester.cc index c667a8e7..8ae69f9 100644 --- a/base/test/metrics/user_action_tester.cc +++ b/base/test/metrics/user_action_tester.cc
@@ -23,17 +23,26 @@ } int UserActionTester::GetActionCount(const std::string& user_action) const { - auto iter = count_map_.find(user_action); - return iter == count_map_.end() ? 0 : iter->second; + return times_map_.count(user_action); +} + +std::vector<TimeTicks> UserActionTester::GetActionTimes( + const std::string& user_action) const { + std::vector<TimeTicks> result; + auto range = times_map_.equal_range(user_action); + for (auto it = range.first; it != range.second; it++) { + result.push_back(it->second); + } + return result; } void UserActionTester::ResetCounts() { - count_map_.clear(); + times_map_.clear(); } void UserActionTester::OnUserAction(const std::string& user_action, TimeTicks action_time) { - ++(count_map_[user_action]); + times_map_.insert({user_action, action_time}); } } // namespace base
diff --git a/base/test/metrics/user_action_tester.h b/base/test/metrics/user_action_tester.h index 905fdc9..150983d 100644 --- a/base/test/metrics/user_action_tester.h +++ b/base/test/metrics/user_action_tester.h
@@ -7,9 +7,13 @@ #include <map> #include <string> +#include <vector> #include "base/macros.h" +#include "base/memory/scoped_refptr.h" #include "base/metrics/user_metrics.h" +#include "base/single_thread_task_runner.h" +#include "base/time/time.h" namespace base { @@ -26,17 +30,21 @@ // Returns the number of times the given |user_action| occurred. int GetActionCount(const std::string& user_action) const; + // Returns the time values at which the given |user_action| has occurred. + // The order of returned values is unspecified. + std::vector<TimeTicks> GetActionTimes(const std::string& user_action) const; + // Resets all user action counts to 0. void ResetCounts(); private: - typedef std::map<std::string, int> UserActionCountMap; + typedef std::multimap<std::string, TimeTicks> UserActionTimesMap; // The callback that is notified when a user actions occurs. void OnUserAction(const std::string& user_action, TimeTicks action_time); - // A map that tracks the number of times a user action has occurred. - UserActionCountMap count_map_; + // A map that tracks the times when a user action has occurred. + UserActionTimesMap times_map_; // A test task runner used by user metrics. scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
diff --git a/base/test/metrics/user_action_tester_unittest.cc b/base/test/metrics/user_action_tester_unittest.cc index 14557d2..77e91a3 100644 --- a/base/test/metrics/user_action_tester_unittest.cc +++ b/base/test/metrics/user_action_tester_unittest.cc
@@ -6,8 +6,13 @@ #include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics_action.h" +#include "base/test/scoped_mock_clock_override.h" +#include "base/time/time.h" +#include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +using ::testing::UnorderedElementsAre; + namespace base { namespace { @@ -29,6 +34,12 @@ EXPECT_EQ(0, user_action_tester.GetActionCount(kUserAction1)); } +// Verify user action counts are zero initially. +TEST(UserActionTesterTest, GetActionTimesWhenNoActionsHaveBeenRecorded) { + UserActionTester user_action_tester; + EXPECT_TRUE(user_action_tester.GetActionTimes(kUserAction1).empty()); +} + // Verify user action counts are tracked properly. TEST(UserActionTesterTest, GetActionCountWhenActionsHaveBeenRecorded) { UserActionTester user_action_tester; @@ -42,6 +53,30 @@ EXPECT_EQ(0, user_action_tester.GetActionCount(kUserAction3)); } +// Verify user action times are tracked properly. +TEST(UserActionTesterTest, GetActionTimesWhenActionsHaveBeenRecorded) { + ScopedMockClockOverride clock; + UserActionTester user_action_tester; + + TimeTicks t1 = TimeTicks::Now(); + RecordAction(kUserAction1); + clock.Advance(TimeDelta::FromMinutes(10)); + + TimeTicks t2 = TimeTicks::Now(); + RecordAction(kUserAction2); + clock.Advance(TimeDelta::FromMinutes(20)); + + TimeTicks t3 = TimeTicks::Now(); + RecordAction(kUserAction3); + + EXPECT_THAT(user_action_tester.GetActionTimes(kUserAction1), + UnorderedElementsAre(t1)); + EXPECT_THAT(user_action_tester.GetActionTimes(kUserAction2), + UnorderedElementsAre(t2)); + EXPECT_THAT(user_action_tester.GetActionTimes(kUserAction3), + UnorderedElementsAre(t3)); +} + // Verify no seg faults occur when resetting action counts when none have been // recorded. TEST(UserActionTesterTest, ResetCountsWhenNoActionsHaveBeenRecorded) { @@ -63,24 +98,76 @@ EXPECT_EQ(0, user_action_tester.GetActionCount(kUserAction3)); } -// Verify the UserActionsTester is notified when base::RecordAction is called. -TEST(UserActionTesterTest, VerifyUserActionTesterListensForUserActions) { +// Verify user action times are cleared on a ResetCounts. +TEST(UserActionTesterTest, ResetTimesWhenActionsHaveBeenRecorded) { UserActionTester user_action_tester; + RecordAction(kUserAction1); + RecordAction(kUserAction1); + RecordAction(kUserAction2); + user_action_tester.ResetCounts(); + + EXPECT_TRUE(user_action_tester.GetActionTimes(kUserAction1).empty()); + EXPECT_TRUE(user_action_tester.GetActionTimes(kUserAction2).empty()); + EXPECT_TRUE(user_action_tester.GetActionTimes(kUserAction3).empty()); +} + +// Verify the UserActionsTester is notified when base::RecordAction is called. +TEST(UserActionTesterTest, VerifyUserActionTesterListensForUserActions) { + ScopedMockClockOverride clock; + UserActionTester user_action_tester; + + TimeTicks time = TimeTicks::Now(); base::RecordAction(base::UserMetricsAction(kUserAction1)); EXPECT_EQ(1, user_action_tester.GetActionCount(kUserAction1)); + EXPECT_THAT(user_action_tester.GetActionTimes(kUserAction1), + UnorderedElementsAre(time)); } // Verify the UserActionsTester is notified when base::RecordComputedAction is // called. TEST(UserActionTesterTest, VerifyUserActionTesterListensForComputedUserActions) { + ScopedMockClockOverride clock; UserActionTester user_action_tester; + TimeTicks time = TimeTicks::Now(); base::RecordComputedAction(kUserAction1); EXPECT_EQ(1, user_action_tester.GetActionCount(kUserAction1)); + EXPECT_THAT(user_action_tester.GetActionTimes(kUserAction1), + UnorderedElementsAre(time)); +} + +// Verify the UserActionsTester is notified when base::RecordComputedActionAt is +// called. +TEST(UserActionTesterTest, + VerifyUserActionTesterListensForComputedUserActionAt) { + UserActionTester user_action_tester; + + TimeTicks time = TimeTicks::Now() - TimeDelta::FromMinutes(10); + base::RecordComputedActionAt(kUserAction1, time); + + EXPECT_EQ(1, user_action_tester.GetActionCount(kUserAction1)); + EXPECT_THAT(user_action_tester.GetActionTimes(kUserAction1), + UnorderedElementsAre(time)); +} + +// Verify the UserActionsTester is notified when base::RecordComputedActionSince +// is called. +TEST(UserActionTesterTest, + VerifyUserActionTesterListensForComputedUserActionSince) { + ScopedMockClockOverride clock; + UserActionTester user_action_tester; + + TimeTicks time = TimeTicks::Now(); + base::RecordComputedActionSince(kUserAction1, TimeDelta::FromMinutes(20)); + TimeTicks expected_time = time - TimeDelta::FromMinutes(20); + + EXPECT_EQ(1, user_action_tester.GetActionCount(kUserAction1)); + EXPECT_THAT(user_action_tester.GetActionTimes(kUserAction1), + UnorderedElementsAre(expected_time)); } } // namespace base
diff --git a/base/win/windows_types.h b/base/win/windows_types.h index 8b663bb..022c6a2 100644 --- a/base/win/windows_types.h +++ b/base/win/windows_types.h
@@ -93,6 +93,7 @@ typedef LPVOID HINTERNET; typedef HINSTANCE HMODULE; typedef PVOID LSA_HANDLE; +typedef PVOID HDEVINFO; // Forward declare some Windows struct/typedef sets. @@ -114,6 +115,8 @@ typedef struct tagNMHDR NMHDR; +typedef struct _SP_DEVINFO_DATA SP_DEVINFO_DATA; + typedef PVOID PSID; // Declare Chrome versions of some Windows structures. These are needed for
diff --git a/build/android/binary_size/__init__.py b/build/android/binary_size/__init__.py deleted file mode 100644 index a22a6ee..0000000 --- a/build/android/binary_size/__init__.py +++ /dev/null
@@ -1,3 +0,0 @@ -# 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.
diff --git a/build/android/binary_size/apk_downloader.py b/build/android/binary_size/apk_downloader.py deleted file mode 100755 index 12898343..0000000 --- a/build/android/binary_size/apk_downloader.py +++ /dev/null
@@ -1,140 +0,0 @@ -#!/usr/bin/env python -# 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. - -from __future__ import print_function - -import argparse -import os -import sys -import zipfile - -_BUILD_ANDROID = os.path.join(os.path.dirname(__file__), os.pardir) -sys.path.append(_BUILD_ANDROID) -from pylib.constants import host_paths - -sys.path.append(os.path.join(_BUILD_ANDROID, 'gyp')) -from util import build_utils - -sys.path.append( - os.path.join(host_paths.DIR_SOURCE_ROOT, 'third_party', 'depot_tools')) -import download_from_google_storage -import upload_to_google_storage - -CURRENT_MILESTONE = '67' -DEFAULT_BUCKET = 'gs://chromium-android-tools/apks' -DEFAULT_DOWNLOAD_PATH = os.path.join(os.path.dirname(__file__), 'apks') -DEFAULT_BUILDER = 'Android_Builder' -DEFAULT_APK = 'MonochromePublic.apk' -_ALL_BUILDER_APKS = { - 'Android Builder': ['ChromePublic.apk', 'ChromeModernPublic.apk', - 'MonochromePublic.apk'], - 'Android arm64 Builder': ['ChromePublic.apk', 'ChromeModernPublic.apk'], -} - - -def MaybeDownloadApk(builder, milestone, apk, download_path, bucket): - """Returns path to the downloaded APK or None if not found.""" - apk_path = os.path.join(download_path, builder, milestone, apk) - sha1_path = apk_path + '.sha1' - base_url = os.path.join(bucket, builder, milestone) - if os.path.exists(apk_path): - print('%s already exists' % apk_path) - return apk_path - elif not os.path.exists(sha1_path): - print('Skipping %s, file not found' % sha1_path) - return None - else: - download_from_google_storage.download_from_google_storage( - input_filename=sha1_path, - sha1_file=sha1_path, - base_url=base_url, - gsutil=download_from_google_storage.Gsutil( - download_from_google_storage.GSUTIL_DEFAULT_PATH), - num_threads=1, - directory=False, - recursive=False, - force=False, - output=apk_path, - ignore_errors=False, - verbose=True, - auto_platform=False, - extract=False) - return apk_path - - -def _UpdateReferenceApks(milestones): - """Update reference APKs and creates .sha1 files ready for commit. - - Will fail if perf builders were broken for the given milestone (use next - passing build in this case). - """ - with build_utils.TempDir() as temp_dir: - for milestone, crrev in milestones: - for builder, apks in _ALL_BUILDER_APKS.iteritems(): - tools_builder_path = builder.replace(' ', '_') - zip_path = os.path.join(temp_dir, 'build_product.zip') - commit = build_utils.CheckOutput(['git', 'crrev-parse', crrev]).strip() - # Download build product from perf builders. - build_utils.CheckOutput([ - 'gsutil', 'cp', 'gs://chrome-perf/%s/full-build-linux_%s.zip' % ( - builder, commit), zip_path]) - - # Extract desired .apks. - with zipfile.ZipFile(zip_path) as z: - in_zip_paths = z.namelist() - out_dir = os.path.commonprefix(in_zip_paths) - for apk_name in apks: - output_path = os.path.join( - DEFAULT_DOWNLOAD_PATH, tools_builder_path, milestone) - apk_path = os.path.join(out_dir, 'apks', apk_name) - zip_info = z.getinfo(apk_path) - zip_info.filename = apk_path.replace(apk_path, apk_name) - z.extract(zip_info, output_path) - input_files = [os.path.join(output_path, apk_name)] - bucket_path = os.path.join( - DEFAULT_BUCKET, tools_builder_path, milestone) - - # Upload .apks to chromium-android-tools so that they aren't - # automatically removed in the future. - upload_to_google_storage.upload_to_google_storage( - input_files, - bucket_path, - upload_to_google_storage.Gsutil( - upload_to_google_storage.GSUTIL_DEFAULT_PATH), - False, # force - False, # use_md5 - 10, # num_threads - False, # skip_hashing - None) # gzip - - -def main(): - argparser = argparse.ArgumentParser( - description='Utility for downloading archived APKs used for measuring ' - 'per-milestone patch size growth.', - formatter_class=argparse.ArgumentDefaultsHelpFormatter) - argparser.add_argument('--download-path', default=DEFAULT_DOWNLOAD_PATH, - help='Directory to store downloaded APKs.') - argparser.add_argument('--milestone', default=CURRENT_MILESTONE, - help='Download reference APK for this milestone.') - argparser.add_argument('--apk', default=DEFAULT_APK, help='APK name.') - argparser.add_argument('--builder', default=DEFAULT_BUILDER, - help='Builder name.') - argparser.add_argument('--bucket', default=DEFAULT_BUCKET, - help='Google storage bucket where APK is stored.') - argparser.add_argument('--update', action='append', nargs=2, - help='List of MILESTONE CRREV pairs to upload ' - 'reference APKs for. Mutally exclusive with ' - 'downloading reference APKs.') - args = argparser.parse_args() - if args.update: - _UpdateReferenceApks(args.update) - else: - MaybeDownloadApk(args.builder, args.milestone, args.apk, - args.download_path, args.bucket) - - -if __name__ == '__main__': - sys.exit(main())
diff --git a/build/android/binary_size/apks/Android_Builder/56/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/56/ChromePublic.apk.sha1 deleted file mode 100644 index c2629a6..0000000 --- a/build/android/binary_size/apks/Android_Builder/56/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -f6a9731abe16df80a4026843a850d3c721414b96 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/57/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/57/ChromeModernPublic.apk.sha1 deleted file mode 100644 index 8c0ab5d..0000000 --- a/build/android/binary_size/apks/Android_Builder/57/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -a168708620b6370e0325a00c0bc3b4b53ad86a18 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/57/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/57/ChromePublic.apk.sha1 deleted file mode 100644 index 119dc0e..0000000 --- a/build/android/binary_size/apks/Android_Builder/57/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -75bc1faae7eff3c3781d1e0343414c1e42d8aeef \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/58/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/58/ChromeModernPublic.apk.sha1 deleted file mode 100644 index 28ddb43..0000000 --- a/build/android/binary_size/apks/Android_Builder/58/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -3e9673008a930aa8bb2bcd7e26f8da91a0448ec3 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/58/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/58/ChromePublic.apk.sha1 deleted file mode 100644 index 935e09d..0000000 --- a/build/android/binary_size/apks/Android_Builder/58/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -ec034225a5e637fc83944b5ada634aba8075d1b2 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/58/MonochromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/58/MonochromePublic.apk.sha1 deleted file mode 100644 index 8ac82edc..0000000 --- a/build/android/binary_size/apks/Android_Builder/58/MonochromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -68925703102a2ff5a55e3b00e90a086dfd6d7ee6 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/59/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/59/ChromeModernPublic.apk.sha1 deleted file mode 100644 index 2e24ec0..0000000 --- a/build/android/binary_size/apks/Android_Builder/59/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -286671da954e55a708481042276d209f769d3af8 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/59/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/59/ChromePublic.apk.sha1 deleted file mode 100644 index 4ed75c8c..0000000 --- a/build/android/binary_size/apks/Android_Builder/59/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -b7d2c8299b263d33e76b9d845bfea7631cca1fc2 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/59/MonochromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/59/MonochromePublic.apk.sha1 deleted file mode 100644 index caee66c..0000000 --- a/build/android/binary_size/apks/Android_Builder/59/MonochromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -e292bd4db30461f755188059a5ca31053b6720b8 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/60/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/60/ChromeModernPublic.apk.sha1 deleted file mode 100644 index a51316d..0000000 --- a/build/android/binary_size/apks/Android_Builder/60/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -bfa2c1c1750c5d6bbe40591ac8914a3b848d4e5b \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/60/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/60/ChromePublic.apk.sha1 deleted file mode 100644 index e85b68e..0000000 --- a/build/android/binary_size/apks/Android_Builder/60/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -c546e0cccae5b2da3834466337f7c2872889e6c8 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/60/MonochromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/60/MonochromePublic.apk.sha1 deleted file mode 100644 index 10cc649..0000000 --- a/build/android/binary_size/apks/Android_Builder/60/MonochromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -3b847e7aeafc265640d5092ef40852cf47fe743b \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/61/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/61/ChromeModernPublic.apk.sha1 deleted file mode 100644 index b26d738..0000000 --- a/build/android/binary_size/apks/Android_Builder/61/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -d4f1347c5baea6ebb296b450cf54abb629030328 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/61/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/61/ChromePublic.apk.sha1 deleted file mode 100644 index 0de158d0..0000000 --- a/build/android/binary_size/apks/Android_Builder/61/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -b2644c78846d1297c61bf75b1543d74e24f777b6 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/61/MonochromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/61/MonochromePublic.apk.sha1 deleted file mode 100644 index 4473f6e2..0000000 --- a/build/android/binary_size/apks/Android_Builder/61/MonochromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -80413a607555c33960241ef10f5897b02383fe2e \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/62/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/62/ChromeModernPublic.apk.sha1 deleted file mode 100644 index 3c50afe..0000000 --- a/build/android/binary_size/apks/Android_Builder/62/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -a819a1ca4da0ae9e3accdbf38a6fad00814ab1c9 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/62/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/62/ChromePublic.apk.sha1 deleted file mode 100644 index dd379384b..0000000 --- a/build/android/binary_size/apks/Android_Builder/62/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -8023a7eeaf30a4cdbdfcc309e6f89ad99cf0e9d0 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/62/MonochromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/62/MonochromePublic.apk.sha1 deleted file mode 100644 index 0a1ff4d..0000000 --- a/build/android/binary_size/apks/Android_Builder/62/MonochromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -f726d0a312f934b94fb6b8e9e2e6a81011cdf922 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/63/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/63/ChromeModernPublic.apk.sha1 deleted file mode 100644 index 92ec9d1e..0000000 --- a/build/android/binary_size/apks/Android_Builder/63/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -e7b3d22b0d20ceec9307cbf734bc6ee98b2433e3 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/63/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/63/ChromePublic.apk.sha1 deleted file mode 100644 index b3f545e..0000000 --- a/build/android/binary_size/apks/Android_Builder/63/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -1ec72262d91b86f3569bdf6b6ca49a6212c629d8 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/63/MonochromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/63/MonochromePublic.apk.sha1 deleted file mode 100644 index fb8ac39f..0000000 --- a/build/android/binary_size/apks/Android_Builder/63/MonochromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -8fe3e9821006688f8caebfaae912c19338b8641a \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/64/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/64/ChromeModernPublic.apk.sha1 deleted file mode 100644 index 92e9519e..0000000 --- a/build/android/binary_size/apks/Android_Builder/64/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -98af8f2265f68dea89eecd1d93410fd36bf233c4 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/64/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/64/ChromePublic.apk.sha1 deleted file mode 100644 index 7bbf28ae..0000000 --- a/build/android/binary_size/apks/Android_Builder/64/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -d5c209e967fa2f6b98fd4e3d6882a85ad67a9d87 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/64/MonochromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/64/MonochromePublic.apk.sha1 deleted file mode 100644 index 123d071..0000000 --- a/build/android/binary_size/apks/Android_Builder/64/MonochromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -a5059a9bbe1dd9b6750bee7c2728a366bf9864e9 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/65/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/65/ChromeModernPublic.apk.sha1 deleted file mode 100644 index 696f05d..0000000 --- a/build/android/binary_size/apks/Android_Builder/65/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -f7cd8a90f4b0f038e3c4165c9111757bbd357e23 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/65/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/65/ChromePublic.apk.sha1 deleted file mode 100644 index 406a044..0000000 --- a/build/android/binary_size/apks/Android_Builder/65/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -415533c239b40780156fed15c4760b748b8752a5 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/65/MonochromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/65/MonochromePublic.apk.sha1 deleted file mode 100644 index 7ecb21e..0000000 --- a/build/android/binary_size/apks/Android_Builder/65/MonochromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -743e67eda110f303e48826d059352dac7e6837a4 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/66/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/66/ChromeModernPublic.apk.sha1 deleted file mode 100644 index 01556e8f..0000000 --- a/build/android/binary_size/apks/Android_Builder/66/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -f0bdfb932b1136c408f7a4f4ba8054e98b128eb6 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/66/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/66/ChromePublic.apk.sha1 deleted file mode 100644 index 7319f7d..0000000 --- a/build/android/binary_size/apks/Android_Builder/66/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -4af2534cd223be64c17f2ffff04340e093690d78 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/66/MonochromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/66/MonochromePublic.apk.sha1 deleted file mode 100644 index 23b3125b..0000000 --- a/build/android/binary_size/apks/Android_Builder/66/MonochromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -ef9cce8af1cc4fb533e5a19c206cc40185602a7f \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/67/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/67/ChromeModernPublic.apk.sha1 deleted file mode 100644 index 2127fdc9..0000000 --- a/build/android/binary_size/apks/Android_Builder/67/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -b266b4168dd50384c39b57a6ac9c6c260edd225f \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/67/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/67/ChromePublic.apk.sha1 deleted file mode 100644 index 05fd194..0000000 --- a/build/android/binary_size/apks/Android_Builder/67/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -443888b240953a9c0cac582b82587e06cc9c1af9 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_Builder/67/MonochromePublic.apk.sha1 b/build/android/binary_size/apks/Android_Builder/67/MonochromePublic.apk.sha1 deleted file mode 100644 index 563969c3..0000000 --- a/build/android/binary_size/apks/Android_Builder/67/MonochromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -7c930a47e9b48c21bd2c09cddc6e9326b8dc15ef \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/56/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/56/ChromePublic.apk.sha1 deleted file mode 100644 index 432f6aef..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/56/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -c980519b19f3eb010fe0e54a436272e3c94656be \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/57/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/57/ChromeModernPublic.apk.sha1 deleted file mode 100644 index aa40702..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/57/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -c1f4797decdd33465d671cf2fb5f266f4c9e1c7a \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/57/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/57/ChromePublic.apk.sha1 deleted file mode 100644 index 7e7ddf5b..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/57/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -47f902113feb297714ba22d25d7cb51754990923 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/58/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/58/ChromeModernPublic.apk.sha1 deleted file mode 100644 index b97041a..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/58/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -255104059ee2e51541d67a504ff22327b945768b \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/58/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/58/ChromePublic.apk.sha1 deleted file mode 100644 index bd8ffec..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/58/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -0a18193a6534ccc31deaffecb817b8b6c991647a \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/59/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/59/ChromeModernPublic.apk.sha1 deleted file mode 100644 index 1026ad71..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/59/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -62897dbec4761546b9c94e258c99c51dc816c1a9 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/59/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/59/ChromePublic.apk.sha1 deleted file mode 100644 index 05052bd..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/59/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -9f2e5aee1ca7d8a88e05587137a0f4859e76296b \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/60/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/60/ChromeModernPublic.apk.sha1 deleted file mode 100644 index ad52e8e..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/60/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -241970643e7cc8a5078946092298229bce422c5c \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/60/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/60/ChromePublic.apk.sha1 deleted file mode 100644 index 3d1dff8..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/60/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -3dd1e9be5c64c97e3a5d93b7c43e0cddb5548003 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/61/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/61/ChromeModernPublic.apk.sha1 deleted file mode 100644 index 13d4b6a..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/61/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -8e30941b4fc3a33701dba26aac2d686120bb9588 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/61/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/61/ChromePublic.apk.sha1 deleted file mode 100644 index 4e72ae7..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/61/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -d2ed32c20b65f86a839cc01839a6f258e8fe909f \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/62/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/62/ChromeModernPublic.apk.sha1 deleted file mode 100644 index 0f14fdc..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/62/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -b7d6363def07dbff34424f7df52bfe492b354569 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/62/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/62/ChromePublic.apk.sha1 deleted file mode 100644 index 9f8d7453..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/62/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -f46c29b53910ec5094860d820b8b99540706e9e4 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/63/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/63/ChromeModernPublic.apk.sha1 deleted file mode 100644 index a19ee65..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/63/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -172e8f53695780960ab50908b262c7763bbd2bad \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/63/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/63/ChromePublic.apk.sha1 deleted file mode 100644 index 739baa8..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/63/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -4db69a57e34287ab21e8f5fae282cf861316384c \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/64/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/64/ChromeModernPublic.apk.sha1 deleted file mode 100644 index e0df57b..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/64/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -3e4b8fd75aea0a22fa769c6686dd153d72741e91 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/64/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/64/ChromePublic.apk.sha1 deleted file mode 100644 index e65c26f..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/64/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -b7b222a6650e98dda980dd9bc922763e4102d0b6 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/65/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/65/ChromeModernPublic.apk.sha1 deleted file mode 100644 index e3921ca..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/65/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -112273d8bb6942a89d47f4ada5f85cc9d5e69073 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/65/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/65/ChromePublic.apk.sha1 deleted file mode 100644 index 7c78ee8..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/65/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -fde7bd26a11ab8d301efe1ae7115c615f03ed3d0 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/66/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/66/ChromeModernPublic.apk.sha1 deleted file mode 100644 index b9960e0..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/66/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -1abaf4fea673cd75031ee6bcb8382abc7ffe2b92 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/66/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/66/ChromePublic.apk.sha1 deleted file mode 100644 index 9844582..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/66/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -ce72e18b9a9028cbde71a3ab36580d6bf3c8e531 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/67/ChromeModernPublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/67/ChromeModernPublic.apk.sha1 deleted file mode 100644 index 6d8e57c6..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/67/ChromeModernPublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -9ecb48a44c57c9bbbe85dcf0d9cd446529640807 \ No newline at end of file
diff --git a/build/android/binary_size/apks/Android_arm64_Builder/67/ChromePublic.apk.sha1 b/build/android/binary_size/apks/Android_arm64_Builder/67/ChromePublic.apk.sha1 deleted file mode 100644 index a06d22d3..0000000 --- a/build/android/binary_size/apks/Android_arm64_Builder/67/ChromePublic.apk.sha1 +++ /dev/null
@@ -1 +0,0 @@ -60f7ca1ebf019bf3a77b372c5f4c80592e36b942 \ No newline at end of file
diff --git a/build/android/binary_size/apks/README.md b/build/android/binary_size/apks/README.md deleted file mode 100644 index d6e4f58..0000000 --- a/build/android/binary_size/apks/README.md +++ /dev/null
@@ -1,45 +0,0 @@ -## Milestone Reference APKs - -This folder contains APKs for official (upstream) builds for each milestone. -The primary use for these APKs is per-milestone binary size analysis. - * `//build/android/resource_sizes.py` uses them for calculating patch size - * They can be used with `tools/binary_size/diagnose_bloat.py` for analyzing - what grew in an APK milestone-to-milestone - -## Downloading Reference APKs - -```bash -# Downloads ARM 32 MonochromePublic.apk for the latest milestone that we've -# uploaded APKs for. -build/android/binary_size/apk_downloader.py - -# Print usage and see all options. -build/android/binary_size/apk_downloader.py -h -``` - -## Updating Reference APKs -```bash -# Downloads build products from perf builders and uploads the following APKs -# for M62 and M63: -# ARM 32 - ChromePublic.apk, ChromeModernPublic.apk, MonochromePublic.apk -# ARM 64 - ChromePublic.apk ChromeModernPublic.apk -build/android/binary_size/apk_downloader.py --update 63 508578 --update 62 499187 -``` - - * **Remember to commit the generated .sha1 files, update the - CURRENT_MILESTONE variable in apk_downloader.py, and update the list of - revisions below** - -## Chromium revisions for each APK - * [M56](https://crrev.com/433059) - * [M57](https://crrev.com/444943) - * [M58](https://crrev.com/454471) - * [M59](https://crrev.com/464641) - * [M60](https://crrev.com/474934) - * [M61](https://crrev.com/488528) - * [M62](https://crrev.com/499187) - * [M63](https://crrev.com/508578) - * [M64](https://crrev.com/520840) - * [M65](https://crrev.com/530369) - * [M66](https://crrev.com/540276) - * [M67](https://crrev.com/550428)
diff --git a/build/android/resource_sizes.py b/build/android/resource_sizes.py index 79ee5274..d7915c3 100755 --- a/build/android/resource_sizes.py +++ b/build/android/resource_sizes.py
@@ -21,7 +21,6 @@ import zipfile import zlib -from binary_size import apk_downloader import devil_chromium from devil.android.sdk import build_tools from devil.utils import cmd_helper @@ -33,8 +32,6 @@ _AAPT_PATH = lazy.WeakConstant(lambda: build_tools.GetPath('aapt')) _BUILD_UTILS_PATH = os.path.join( host_paths.DIR_SOURCE_ROOT, 'build', 'android', 'gyp') -_APK_PATCH_SIZE_ESTIMATOR_PATH = os.path.join( - host_paths.DIR_SOURCE_ROOT, 'third_party', 'apk-patch-size-estimator') with host_paths.SysPath(host_paths.BUILD_COMMON_PATH): import perf_tests_results_helper # pylint: disable=import-error @@ -46,9 +43,6 @@ from util import build_utils # pylint: disable=import-error from util import zipalign # pylint: disable=import-error -with host_paths.SysPath(_APK_PATCH_SIZE_ESTIMATOR_PATH): - import apk_patch_size_estimator # pylint: disable=import-error - zipalign.ApplyZipFileZipAlignFix() @@ -555,25 +549,6 @@ report_func('DexCache', 'DexCache', total_size, 'bytes') -def _PrintPatchSizeEstimate(new_apk, builder, bucket, report_func): - apk_name = os.path.basename(new_apk) - # Reference APK paths have spaces replaced by underscores. - builder = builder.replace(' ', '_') - old_apk = apk_downloader.MaybeDownloadApk( - builder, apk_downloader.CURRENT_MILESTONE, apk_name, - apk_downloader.DEFAULT_DOWNLOAD_PATH, bucket) - if old_apk: - # Use a temp dir in case patch size functions fail to clean up temp files. - with build_utils.TempDir() as tmp: - tmp_name = os.path.join(tmp, 'patch.tmp') - bsdiff = apk_patch_size_estimator.calculate_bsdiff( - old_apk, new_apk, None, tmp_name) - report_func('PatchSizeEstimate', 'BSDiff (gzipped)', bsdiff, 'bytes') - fbf = apk_patch_size_estimator.calculate_filebyfile( - old_apk, new_apk, None, tmp_name) - report_func('PatchSizeEstimate', 'FileByFile (gzipped)', fbf, 'bytes') - - @contextmanager def Unzip(zip_file, filename=None): """Utility for temporary use of a single file in a zip archive.""" @@ -613,9 +588,6 @@ apks_path = args.input if args.input.endswith('.apks') else None _DoApkAnalysis(apk_path, apks_path, tool_prefix, out_dir, report_func) _DoDexAnalysis(apk_path, report_func) - if args.estimate_patch_size: - _PrintPatchSizeEstimate(apk_path, args.reference_apk_builder, - args.reference_apk_bucket, report_func) def ResourceSizes(args): @@ -698,21 +670,6 @@ help='Output the results to a file in the given ' 'format instead of printing the results.') argparser.add_argument('--loadable_module', help='Obsolete (ignored).') - argparser.add_argument( - '--estimate-patch-size', - action='store_true', - help='Include patch size estimates. Useful for perf ' - 'builders where a reference APK is available but adds ' - '~3 mins to run time.') - argparser.add_argument( - '--reference-apk-builder', - default=apk_downloader.DEFAULT_BUILDER, - help='Builder name to use for reference APK for patch ' - 'size estimates.') - argparser.add_argument( - '--reference-apk-bucket', - default=apk_downloader.DEFAULT_BUCKET, - help='Storage bucket holding reference APKs.') # Accepted to conform to the isolated script interface, but ignored. argparser.add_argument(
diff --git a/build/android/resource_sizes.pydeps b/build/android/resource_sizes.pydeps index 5c6784a..8be61c4 100644 --- a/build/android/resource_sizes.pydeps +++ b/build/android/resource_sizes.pydeps
@@ -1,6 +1,5 @@ # Generated by running: # build/print_python_deps.py --root build/android --output build/android/resource_sizes.pydeps build/android/resource_sizes.py -../../third_party/apk-patch-size-estimator/apk_patch_size_estimator.py ../../third_party/catapult/common/py_utils/py_utils/__init__.py ../../third_party/catapult/common/py_utils/py_utils/cloud_storage.py ../../third_party/catapult/common/py_utils/py_utils/cloud_storage_global_lock.py @@ -43,14 +42,9 @@ ../../third_party/catapult/tracing/tracing/value/__init__.py ../../third_party/catapult/tracing/tracing/value/convert_chart_json.py ../../third_party/catapult/tracing/tracing_project.py -../../third_party/depot_tools/download_from_google_storage.py -../../third_party/depot_tools/subprocess2.py -../../third_party/depot_tools/upload_to_google_storage.py ../gn_helpers.py ../util/lib/common/perf_result_data_type.py ../util/lib/common/perf_tests_results_helper.py -binary_size/__init__.py -binary_size/apk_downloader.py devil_chromium.py gyp/util/__init__.py gyp/util/build_utils.py
diff --git a/build/fuchsia/linux.sdk.sha1 b/build/fuchsia/linux.sdk.sha1 index 36c9c7b..4e964fa5a 100644 --- a/build/fuchsia/linux.sdk.sha1 +++ b/build/fuchsia/linux.sdk.sha1
@@ -1 +1 @@ -0.20200317.2.1 \ No newline at end of file +0.20200318.1.1 \ No newline at end of file
diff --git a/build/fuchsia/mac.sdk.sha1 b/build/fuchsia/mac.sdk.sha1 index b2a172e..4e964fa5a 100644 --- a/build/fuchsia/mac.sdk.sha1 +++ b/build/fuchsia/mac.sdk.sha1
@@ -1 +1 @@ -0.20200317.1.1 \ No newline at end of file +0.20200318.1.1 \ No newline at end of file
diff --git a/cc/input/input_handler.h b/cc/input/input_handler.h index fd0bbc7..c031f16b 100644 --- a/cc/input/input_handler.h +++ b/cc/input/input_handler.h
@@ -16,7 +16,6 @@ #include "cc/input/scroll_state.h" #include "cc/input/scrollbar.h" #include "cc/input/touch_action.h" -#include "cc/metrics/event_metrics.h" #include "cc/metrics/events_metrics_manager.h" #include "cc/paint/element_id.h" #include "cc/trees/swap_promise_monitor.h" @@ -36,6 +35,7 @@ namespace cc { +class EventMetrics; class ScrollElasticityHelper; enum PointerResultType { kUnhandled = 0, kScrollbarScroll };
diff --git a/cc/input/scroll_input_type.h b/cc/input/scroll_input_type.h index a2a14051..88e56c8 100644 --- a/cc/input/scroll_input_type.h +++ b/cc/input/scroll_input_type.h
@@ -8,11 +8,11 @@ namespace cc { enum class ScrollInputType { - kTouchscreen, + kTouchscreen = 0, kWheel, kAutoscroll, kScrollbar, - kUnknown, + kMaxValue = kScrollbar, }; } // namespace cc
diff --git a/cc/input/scrollbar_controller.cc b/cc/input/scrollbar_controller.cc index 15774d88..58fcc96 100644 --- a/cc/input/scrollbar_controller.cc +++ b/cc/input/scrollbar_controller.cc
@@ -615,6 +615,9 @@ const ScrollbarPart scrollbar_part, const bool shift_modifier) { int scroll_delta = 0; + if (layer_tree_host_impl_->settings().percent_based_scrolling) { + // TODO(arakeri): Implement percent based deltas. + } switch (scrollbar_part) { case ScrollbarPart::BACK_BUTTON:
diff --git a/cc/metrics/compositor_frame_reporter.cc b/cc/metrics/compositor_frame_reporter.cc index cbfe50c..dd89d8b 100644 --- a/cc/metrics/compositor_frame_reporter.cc +++ b/cc/metrics/compositor_frame_reporter.cc
@@ -136,8 +136,12 @@ constexpr int kCompositorLatencyHistogramMax = 350000; constexpr int kCompositorLatencyHistogramBucketCount = 50; -constexpr int kMaxEventLatencyHistogramIndex = +constexpr int kEventLatencyEventTypeCount = static_cast<int>(ui::EventType::ET_LAST); +constexpr int kEventLatencyScrollTypeCount = + static_cast<int>(ScrollInputType::kMaxValue) + 1; +constexpr int kMaxEventLatencyHistogramIndex = + kEventLatencyEventTypeCount * kEventLatencyScrollTypeCount; constexpr int kEventLatencyHistogramMin = 1; constexpr int kEventLatencyHistogramMax = 5000000; constexpr int kEventLatencyHistogramBucketCount = 100; @@ -165,8 +169,11 @@ } std::string GetEventLatencyHistogramName(const EventMetrics& event_metrics) { - return base::StrCat( - {"EventLatency.", event_metrics.GetTypeName(), ".TotalLatency"}); + const bool is_scroll = event_metrics.scroll_input_type().has_value(); + return base::StrCat({"EventLatency.", event_metrics.GetTypeName(), + is_scroll ? "." : nullptr, + is_scroll ? event_metrics.GetScrollTypeName() : nullptr, + ".TotalLatency"}); } } // namespace @@ -513,8 +520,14 @@ "cc,input", "EventLatency", trace_id, event_metrics.time_stamp(), "event", event_metrics.GetTypeName()); const int type_index = static_cast<int>(event_metrics.type()); + const int scroll_type_index = + event_metrics.scroll_input_type() + ? static_cast<int>(*event_metrics.scroll_input_type()) + : 0; + const int histogram_index = + type_index * kEventLatencyScrollTypeCount + scroll_type_index; STATIC_HISTOGRAM_POINTER_GROUP( - GetEventLatencyHistogramName(event_metrics), type_index, + GetEventLatencyHistogramName(event_metrics), histogram_index, kMaxEventLatencyHistogramIndex, AddTimeMicrosecondsGranularity(total_latency), base::Histogram::FactoryGet(
diff --git a/cc/metrics/compositor_frame_reporter_unittest.cc b/cc/metrics/compositor_frame_reporter_unittest.cc index 0e91673..6e00be8 100644 --- a/cc/metrics/compositor_frame_reporter_unittest.cc +++ b/cc/metrics/compositor_frame_reporter_unittest.cc
@@ -10,6 +10,7 @@ #include "base/strings/strcat.h" #include "base/test/metrics/histogram_tester.h" +#include "cc/input/scroll_input_type.h" #include "cc/metrics/compositor_frame_reporting_controller.h" #include "cc/metrics/event_metrics.h" #include "testing/gmock/include/gmock/gmock.h" @@ -195,9 +196,9 @@ const base::TimeTicks event_time = Now(); std::vector<EventMetrics> events_metrics = { - {ui::ET_TOUCH_PRESSED, event_time}, - {ui::ET_TOUCH_MOVED, event_time}, - {ui::ET_TOUCH_MOVED, event_time}, + {ui::ET_TOUCH_PRESSED, event_time, base::nullopt}, + {ui::ET_TOUCH_MOVED, event_time, base::nullopt}, + {ui::ET_TOUCH_MOVED, event_time, base::nullopt}, }; EXPECT_THAT(events_metrics, ::testing::Each(IsWhitelisted())); @@ -236,6 +237,56 @@ latency_ms, 2); } +// Tests that when a frame is presented to the user, scroll event latency +// metrics are reported properly. +TEST_F(CompositorFrameReporterTest, + EventLatencyScrollForPresentedFrameReported) { + base::HistogramTester histogram_tester; + + const base::TimeTicks event_time = Now(); + std::vector<EventMetrics> events_metrics = { + {ui::ET_GESTURE_SCROLL_BEGIN, event_time, ScrollInputType::kWheel}, + {ui::ET_GESTURE_SCROLL_UPDATE, event_time, ScrollInputType::kWheel}, + {ui::ET_GESTURE_SCROLL_UPDATE, event_time, ScrollInputType::kWheel}, + }; + EXPECT_THAT(events_metrics, ::testing::Each(IsWhitelisted())); + + AdvanceNowByMs(3); + pipeline_reporter_->StartStage( + CompositorFrameReporter::StageType::kBeginImplFrameToSendBeginMainFrame, + Now()); + + AdvanceNowByMs(3); + pipeline_reporter_->StartStage( + CompositorFrameReporter::StageType::kEndActivateToSubmitCompositorFrame, + Now()); + + AdvanceNowByMs(3); + pipeline_reporter_->StartStage( + CompositorFrameReporter::StageType:: + kSubmitCompositorFrameToPresentationCompositorFrame, + Now()); + pipeline_reporter_->SetEventsMetrics(std::move(events_metrics)); + + AdvanceNowByMs(3); + const base::TimeTicks presentation_time = Now(); + pipeline_reporter_->TerminateFrame( + CompositorFrameReporter::FrameTerminationStatus::kPresentedFrame, + presentation_time); + + pipeline_reporter_ = nullptr; + + const int latency_ms = (presentation_time - event_time).InMicroseconds(); + histogram_tester.ExpectTotalCount( + "EventLatency.GestureScrollBegin.Wheel.TotalLatency", 1); + histogram_tester.ExpectTotalCount( + "EventLatency.GestureScrollUpdate.Wheel.TotalLatency", 2); + histogram_tester.ExpectBucketCount( + "EventLatency.GestureScrollBegin.Wheel.TotalLatency", latency_ms, 1); + histogram_tester.ExpectBucketCount( + "EventLatency.GestureScrollUpdate.Wheel.TotalLatency", latency_ms, 2); +} + // Tests that when the frame is not presented to the user, event latency metrics // are not reported. TEST_F(CompositorFrameReporterTest, @@ -244,9 +295,9 @@ const base::TimeTicks event_time = Now(); std::vector<EventMetrics> events_metrics = { - {ui::ET_TOUCH_PRESSED, event_time}, - {ui::ET_TOUCH_MOVED, event_time}, - {ui::ET_TOUCH_MOVED, event_time}, + {ui::ET_TOUCH_PRESSED, event_time, base::nullopt}, + {ui::ET_TOUCH_MOVED, event_time, base::nullopt}, + {ui::ET_TOUCH_MOVED, event_time, base::nullopt}, }; EXPECT_THAT(events_metrics, ::testing::Each(IsWhitelisted()));
diff --git a/cc/metrics/compositor_frame_reporting_controller_unittest.cc b/cc/metrics/compositor_frame_reporting_controller_unittest.cc index dd96349..53c2dcc 100644 --- a/cc/metrics/compositor_frame_reporting_controller_unittest.cc +++ b/cc/metrics/compositor_frame_reporting_controller_unittest.cc
@@ -10,6 +10,7 @@ #include "base/macros.h" #include "base/strings/strcat.h" #include "base/test/metrics/histogram_tester.h" +#include "cc/input/scroll_input_type.h" #include "cc/metrics/event_metrics.h" #include "components/viz/common/frame_timing_details.h" #include "components/viz/common/quads/compositor_frame_metadata.h" @@ -447,9 +448,9 @@ const base::TimeTicks event_time = base::TimeTicks::Now(); std::vector<EventMetrics> events_metrics = { - {ui::ET_TOUCH_PRESSED, event_time}, - {ui::ET_TOUCH_MOVED, event_time}, - {ui::ET_TOUCH_MOVED, event_time}, + {ui::ET_TOUCH_PRESSED, event_time, base::nullopt}, + {ui::ET_TOUCH_MOVED, event_time, base::nullopt}, + {ui::ET_TOUCH_MOVED, event_time, base::nullopt}, }; EXPECT_THAT(events_metrics, ::testing::Each(IsWhitelisted())); @@ -475,6 +476,43 @@ latency_ms, 2); } +// Tests that EventLatency histograms are reported properly for scroll events +// when a frame is presented to the user. +TEST_F(CompositorFrameReportingControllerTest, + EventLatencyScrollForPresentedFrameReported) { + base::HistogramTester histogram_tester; + + const base::TimeTicks event_time = base::TimeTicks::Now(); + std::vector<EventMetrics> events_metrics = { + {ui::ET_GESTURE_SCROLL_BEGIN, event_time, ScrollInputType::kWheel}, + {ui::ET_GESTURE_SCROLL_UPDATE, event_time, ScrollInputType::kWheel}, + {ui::ET_GESTURE_SCROLL_UPDATE, event_time, ScrollInputType::kWheel}, + }; + EXPECT_THAT(events_metrics, ::testing::Each(IsWhitelisted())); + + // Submit a compositor frame and notify CompositorFrameReporter of the events + // affecting the frame. + ++next_token_; + SimulateSubmitCompositorFrame(*next_token_, events_metrics); + + // Present the submitted compositor frame to the user. + const base::TimeTicks presentation_time = base::TimeTicks::Now(); + viz::FrameTimingDetails details; + details.presentation_feedback.timestamp = presentation_time; + reporting_controller_.DidPresentCompositorFrame(*next_token_, details); + + // Verify that EventLatency histograms are recorded. + const int latency_ms = (presentation_time - event_time).InMicroseconds(); + histogram_tester.ExpectTotalCount( + "EventLatency.GestureScrollBegin.Wheel.TotalLatency", 1); + histogram_tester.ExpectTotalCount( + "EventLatency.GestureScrollUpdate.Wheel.TotalLatency", 2); + histogram_tester.ExpectBucketCount( + "EventLatency.GestureScrollBegin.Wheel.TotalLatency", latency_ms, 1); + histogram_tester.ExpectBucketCount( + "EventLatency.GestureScrollUpdate.Wheel.TotalLatency", latency_ms, 2); +} + // Tests that EventLatency histograms are not reported when the frame is dropped // and not presented to the user. TEST_F(CompositorFrameReportingControllerTest, @@ -483,9 +521,9 @@ const base::TimeTicks event_time = base::TimeTicks::Now(); std::vector<EventMetrics> events_metrics = { - {ui::ET_TOUCH_PRESSED, event_time}, - {ui::ET_TOUCH_MOVED, event_time}, - {ui::ET_TOUCH_MOVED, event_time}, + {ui::ET_TOUCH_PRESSED, event_time, base::nullopt}, + {ui::ET_TOUCH_MOVED, event_time, base::nullopt}, + {ui::ET_TOUCH_MOVED, event_time, base::nullopt}, }; EXPECT_THAT(events_metrics, ::testing::Each(IsWhitelisted()));
diff --git a/cc/metrics/event_metrics.cc b/cc/metrics/event_metrics.cc index ebdddd7..8b7466a 100644 --- a/cc/metrics/event_metrics.cc +++ b/cc/metrics/event_metrics.cc
@@ -10,8 +10,34 @@ namespace cc { -EventMetrics::EventMetrics(ui::EventType type, base::TimeTicks time_stamp) - : type_(type), time_stamp_(time_stamp) {} +EventMetrics::EventMetrics(ui::EventType type, + base::TimeTicks time_stamp, + base::Optional<ScrollInputType> scroll_input_type) + : type_(type), + time_stamp_(time_stamp), + scroll_input_type_(scroll_input_type) {} + +EventMetrics::EventMetrics(const EventMetrics&) = default; +EventMetrics& EventMetrics::operator=(const EventMetrics&) = default; + +bool EventMetrics::IsWhitelisted() const { + switch (type_) { + case ui::ET_MOUSE_PRESSED: + case ui::ET_MOUSE_RELEASED: + case ui::ET_MOUSEWHEEL: + case ui::ET_KEY_PRESSED: + case ui::ET_KEY_RELEASED: + case ui::ET_TOUCH_PRESSED: + case ui::ET_TOUCH_RELEASED: + case ui::ET_TOUCH_MOVED: + case ui::ET_GESTURE_SCROLL_BEGIN: + case ui::ET_GESTURE_SCROLL_UPDATE: + case ui::ET_GESTURE_SCROLL_END: + return true; + default: + return false; + } +} const char* EventMetrics::GetTypeName() const { DCHECK(IsWhitelisted()) << "Event type is not whitelisted for event metrics: " @@ -34,31 +60,38 @@ return "TouchReleased"; case ui::ET_TOUCH_MOVED: return "TouchMoved"; + case ui::ET_GESTURE_SCROLL_BEGIN: + return "GestureScrollBegin"; + case ui::ET_GESTURE_SCROLL_UPDATE: + return "GestureScrollUpdate"; + case ui::ET_GESTURE_SCROLL_END: + return "GestureScrollEnd"; default: NOTREACHED(); return nullptr; } } -bool EventMetrics::IsWhitelisted() const { - switch (type_) { - case ui::ET_MOUSE_PRESSED: - case ui::ET_MOUSE_RELEASED: - case ui::ET_MOUSEWHEEL: - case ui::ET_KEY_PRESSED: - case ui::ET_KEY_RELEASED: - case ui::ET_TOUCH_PRESSED: - case ui::ET_TOUCH_RELEASED: - case ui::ET_TOUCH_MOVED: - return true; - default: - return false; +const char* EventMetrics::GetScrollTypeName() const { + DCHECK(IsWhitelisted()) << "Event type is not whitelisted for event metrics: " + << type_; + DCHECK(scroll_input_type_) << "Event is not a scroll event"; + + switch (*scroll_input_type_) { + case ScrollInputType::kTouchscreen: + return "Touchscreen"; + case ScrollInputType::kWheel: + return "Wheel"; + case ScrollInputType::kAutoscroll: + return "Autoscroll"; + case ScrollInputType::kScrollbar: + return "Scrollbar"; } } bool EventMetrics::operator==(const EventMetrics& other) const { - return std::tie(type_, time_stamp_) == - std::tie(other.type_, other.time_stamp_); + return std::tie(type_, time_stamp_, scroll_input_type_) == + std::tie(other.type_, other.time_stamp_, other.scroll_input_type_); } } // namespace cc
diff --git a/cc/metrics/event_metrics.h b/cc/metrics/event_metrics.h index ea3e78b..422cd94 100644 --- a/cc/metrics/event_metrics.h +++ b/cc/metrics/event_metrics.h
@@ -5,28 +5,55 @@ #ifndef CC_METRICS_EVENT_METRICS_H_ #define CC_METRICS_EVENT_METRICS_H_ +#include "base/optional.h" #include "base/time/time.h" #include "cc/cc_export.h" +#include "cc/input/scroll_input_type.h" #include "ui/events/types/event_type.h" namespace cc { -// Data about an event useful in generating event latency metrics. +// Data about an event used by CompositorFrameReporter in generating event +// latency metrics. class CC_EXPORT EventMetrics { public: - EventMetrics(ui::EventType type, base::TimeTicks time_stamp); + EventMetrics(ui::EventType type, + base::TimeTicks time_stamp, + base::Optional<ScrollInputType> scroll_input_type); - const char* GetTypeName() const; + EventMetrics(const EventMetrics&); + EventMetrics& operator=(const EventMetrics&); + + // Determines if the event is whitelisted for event latency reporting. If not, + // this event is ignored in histogram reporting. bool IsWhitelisted() const; + // Returns a string representing event type. Should only be called for + // whitelisted event types. + const char* GetTypeName() const; + + // Returns a string representing scroll input type. Should only be called for + // scroll events. + const char* GetScrollTypeName() const; + ui::EventType type() const { return type_; } + base::TimeTicks time_stamp() const { return time_stamp_; } + const base::Optional<ScrollInputType>& scroll_input_type() const { + return scroll_input_type_; + } + + // Used in tests to check expectations on EventMetrics objects. bool operator==(const EventMetrics& other) const; private: ui::EventType type_; base::TimeTicks time_stamp_; + + // Only available for scroll events and represents the type of input device + // for the event. + base::Optional<ScrollInputType> scroll_input_type_; }; } // namespace cc
diff --git a/cc/metrics/events_metrics_manager_unittest.cc b/cc/metrics/events_metrics_manager_unittest.cc index 46aeec4..d2f38aa3 100644 --- a/cc/metrics/events_metrics_manager_unittest.cc +++ b/cc/metrics/events_metrics_manager_unittest.cc
@@ -7,6 +7,7 @@ #include <utility> #include <vector> +#include "cc/input/scroll_input_type.h" #include "cc/metrics/event_metrics.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -41,19 +42,23 @@ std::vector<std::pair<EventMetrics, Behavior>> events = { // A whitelisted event type for which SaveActiveEventMetrics() is not // called. - {{ui::ET_MOUSE_PRESSED, TimeAtMs(0)}, Behavior::kDoNotSave}, + {{ui::ET_MOUSE_PRESSED, TimeAtMs(0), base::nullopt}, + Behavior::kDoNotSave}, // A whitelisted event type for which SaveActiveEventMetrics() is called // inside its monitor scope. - {{ui::ET_MOUSE_PRESSED, TimeAtMs(1)}, Behavior::kSaveInsideScope}, + {{ui::ET_MOUSE_PRESSED, TimeAtMs(1), base::nullopt}, + Behavior::kSaveInsideScope}, // A whitelisted event type for which SaveActiveEventMetrics() is called // after its monitor scope is finished. - {{ui::ET_MOUSE_PRESSED, TimeAtMs(2)}, Behavior::kSaveOutsideScope}, + {{ui::ET_MOUSE_PRESSED, TimeAtMs(2), base::nullopt}, + Behavior::kSaveOutsideScope}, // A non-whitelisted event type for which SaveActiveEventMetrics() is // called inside its monitor scope. - {{ui::ET_MOUSE_MOVED, TimeAtMs(3)}, Behavior::kSaveInsideScope}, + {{ui::ET_MOUSE_MOVED, TimeAtMs(3), base::nullopt}, + Behavior::kSaveInsideScope}, }; EXPECT_TRUE(events[0].first.IsWhitelisted()); EXPECT_TRUE(events[1].first.IsWhitelisted());
diff --git a/cc/metrics/frame_sequence_tracker.cc b/cc/metrics/frame_sequence_tracker.cc index bf1be87..d47241a2 100644 --- a/cc/metrics/frame_sequence_tracker.cc +++ b/cc/metrics/frame_sequence_tracker.cc
@@ -941,8 +941,13 @@ DCHECK_GE(main_throughput().frames_expected, main_frames_.size()) << TRACKER_DCHECK_MSG; - if (begin_main_frame_data_.previous_sequence == args.frame_id.sequence_number) - begin_main_frame_data_.previous_sequence = 0; + // Could be 0 if there were a pause frame production. + if (begin_main_frame_data_.previous_sequence != 0) { + DCHECK_EQ(begin_main_frame_data_.previous_sequence, + args.frame_id.sequence_number) + << TRACKER_DCHECK_MSG; + } + begin_main_frame_data_.previous_sequence = 0; } void FrameSequenceTracker::PauseFrameProduction() {
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 71e241a..25fb219 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc
@@ -147,7 +147,6 @@ case ScrollInputType::kScrollbar: return FrameSequenceTrackerType::kScrollbarScroll; case ScrollInputType::kAutoscroll: - case ScrollInputType::kUnknown: return FrameSequenceTrackerType::kMaxType; } } @@ -224,7 +223,6 @@ void RecordCompositorSlowScrollMetric(ScrollInputType type, ScrollThread scroll_thread) { - DCHECK_NE(type, ScrollInputType::kUnknown); bool scroll_on_main_thread = (scroll_thread == MAIN_THREAD); if (type == ScrollInputType::kWheel) { UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorWheelScrollUpdateThread", @@ -404,10 +402,7 @@ } void LayerTreeHostImpl::DidSendBeginMainFrame(const viz::BeginFrameArgs& args) { - if (!begin_main_frame_sent_during_impl_) { - begin_main_frame_sent_during_impl_ = true; - frame_trackers_.NotifyBeginMainFrame(args); - } + frame_trackers_.NotifyBeginMainFrame(args); } void LayerTreeHostImpl::BeginMainFrameAborted( @@ -2715,9 +2710,6 @@ current_begin_frame_tracker_.Start(args); frame_trackers_.NotifyBeginImplFrame(args); - begin_main_frame_expected_during_impl_ = client_->IsBeginMainFrameExpected(); - begin_main_frame_sent_during_impl_ = false; - if (is_likely_to_require_a_draw_) { // Optimistically schedule a draw. This will let us expect the tile manager // to complete its work so that we can draw new tiles within the impl frame @@ -2784,10 +2776,6 @@ const auto& args = current_begin_frame_tracker_.Current(); if (args.frame_id == ack.frame_id) { frame_trackers_.NotifyImplFrameCausedNoDamage(ack); - if (begin_main_frame_sent_during_impl_ && - reason == FrameSkippedReason::kNoDamage) { - frame_trackers_.NotifyMainFrameCausedNoDamage(args); - } } } }
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 8f439cf..df9811e 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h
@@ -1275,12 +1275,6 @@ ImplThreadPhase impl_thread_phase_ = ImplThreadPhase::IDLE; - // Tracks whether a BeginMainFrame is expected to be dispatched during an - // 'impl frame' (i.e. between WillBeginImplFrame() and DidFinishImplFrame()), - // and whether it was actually dispatched during the impl frame. - bool begin_main_frame_expected_during_impl_ = false; - bool begin_main_frame_sent_during_impl_ = false; - ImageAnimationController image_animation_controller_; std::unique_ptr<UkmManager> ukm_manager_;
diff --git a/cc/trees/layer_tree_settings.h b/cc/trees/layer_tree_settings.h index 499d5f1..ed5484e 100644 --- a/cc/trees/layer_tree_settings.h +++ b/cc/trees/layer_tree_settings.h
@@ -142,6 +142,9 @@ // on the compositor thread. bool compositor_threaded_scrollbar_scrolling = true; + // If enabled, the scroll deltas will be a percentage of the target scroller. + bool percent_based_scrolling = false; + // Determines whether animated scrolling is supported. If true, and the // incoming gesture scroll is of a type that would normally be animated (e.g. // coarse granularity scrolls like those coming from an external mouse wheel),
diff --git a/chrome/VERSION b/chrome/VERSION index f455247..5034acac 100644 --- a/chrome/VERSION +++ b/chrome/VERSION
@@ -1,4 +1,4 @@ MAJOR=83 MINOR=0 -BUILD=4088 +BUILD=4089 PATCH=0
diff --git a/chrome/android/chrome_java_sources.gni b/chrome/android/chrome_java_sources.gni index 08a6e7a..3dc234f 100644 --- a/chrome/android/chrome_java_sources.gni +++ b/chrome/android/chrome_java_sources.gni
@@ -806,6 +806,10 @@ "java/src/org/chromium/chrome/browser/historyreport/SearchJniBridge.java", "java/src/org/chromium/chrome/browser/historyreport/UsageReport.java", "java/src/org/chromium/chrome/browser/homepage/HomepagePolicyManager.java", + "java/src/org/chromium/chrome/browser/homepage/settings/HomepageEditor.java", + "java/src/org/chromium/chrome/browser/homepage/settings/HomepageMetricsEnums.java", + "java/src/org/chromium/chrome/browser/homepage/settings/HomepageSettings.java", + "java/src/org/chromium/chrome/browser/homepage/settings/RadioButtonGroupHomepagePreference.java", "java/src/org/chromium/chrome/browser/identity/SettingsSecureBasedIdentificationGenerator.java", "java/src/org/chromium/chrome/browser/identity/UniqueIdentificationGenerator.java", "java/src/org/chromium/chrome/browser/identity/UniqueIdentificationGeneratorFactory.java", @@ -1420,10 +1424,6 @@ "java/src/org/chromium/chrome/browser/settings/MainSettings.java", "java/src/org/chromium/chrome/browser/settings/SettingsActivity.java", "java/src/org/chromium/chrome/browser/settings/SettingsLauncher.java", - "java/src/org/chromium/chrome/browser/settings/homepage/HomepageEditor.java", - "java/src/org/chromium/chrome/browser/settings/homepage/HomepageMetricsEnums.java", - "java/src/org/chromium/chrome/browser/settings/homepage/HomepageSettings.java", - "java/src/org/chromium/chrome/browser/settings/homepage/RadioButtonGroupHomepagePreference.java", "java/src/org/chromium/chrome/browser/share/LensUtils.java", "java/src/org/chromium/chrome/browser/share/OptionalShareTargetsManager.java", "java/src/org/chromium/chrome/browser/share/ShareActivity.java",
diff --git a/chrome/android/chrome_junit_test_java_sources.gni b/chrome/android/chrome_junit_test_java_sources.gni index 143d4b20..cba76b7 100644 --- a/chrome/android/chrome_junit_test_java_sources.gni +++ b/chrome/android/chrome_junit_test_java_sources.gni
@@ -17,7 +17,6 @@ "junit/src/org/chromium/chrome/browser/browserservices/ClearDataDialogResultRecorderTest.java", "junit/src/org/chromium/chrome/browser/browserservices/ClientAppBroadcastReceiverTest.java", "junit/src/org/chromium/chrome/browser/browserservices/ClientAppDataRegisterTest.java", - "junit/src/org/chromium/chrome/browser/browserservices/OriginTest.java", "junit/src/org/chromium/chrome/browser/browserservices/SessionDataHolderTest.java", "junit/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClientTest.java", "junit/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationChannelPreserverTest.java",
diff --git a/chrome/android/chrome_test_java_sources.gni b/chrome/android/chrome_test_java_sources.gni index df2afe521..57e0592 100644 --- a/chrome/android/chrome_test_java_sources.gni +++ b/chrome/android/chrome_test_java_sources.gni
@@ -203,6 +203,8 @@ "javatests/src/org/chromium/chrome/browser/history/HistoryActivityTest.java", "javatests/src/org/chromium/chrome/browser/homepage/HomepagePolicyIntegrationTest.java", "javatests/src/org/chromium/chrome/browser/homepage/HomepageTestRule.java", + "javatests/src/org/chromium/chrome/browser/homepage/settings/HomepageSettingsFragmentTest.java", + "javatests/src/org/chromium/chrome/browser/homepage/settings/HomepageSettingsFragmentWithEditorTest.java", "javatests/src/org/chromium/chrome/browser/identity/SettingsSecureBasedIdentificationGeneratorTest.java", "javatests/src/org/chromium/chrome/browser/identity/UniqueIdentificationGeneratorFactoryTest.java", "javatests/src/org/chromium/chrome/browser/identity/UuidBasedUniqueIdentificationGeneratorTest.java", @@ -424,9 +426,6 @@ "javatests/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProviderTest.java", "javatests/src/org/chromium/chrome/browser/services/GoogleServicesManagerIntegrationTest.java", "javatests/src/org/chromium/chrome/browser/settings/SettingsActivityTest.java", - "javatests/src/org/chromium/chrome/browser/settings/homepage/HomepageSettingsFragmentTest.java", - "javatests/src/org/chromium/chrome/browser/settings/homepage/HomepageSettingsFragmentWithEditorTest.java", - "javatests/src/org/chromium/chrome/browser/shape_detection/ShapeDetectionTest.java", "javatests/src/org/chromium/chrome/browser/share/LensUtilsTest.java", "javatests/src/org/chromium/chrome/browser/share/ShareButtonControllerTest.java", "javatests/src/org/chromium/chrome/browser/share/ShareDelegateImplIntegrationTest.java",
diff --git a/chrome/android/features/autofill_assistant/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantClient.java b/chrome/android/features/autofill_assistant/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantClient.java index 0a7711a..123c47d7 100644 --- a/chrome/android/features/autofill_assistant/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantClient.java +++ b/chrome/android/features/autofill_assistant/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantClient.java
@@ -104,13 +104,14 @@ * still fail after this method returns true; the failure will be displayed on the UI. */ boolean start(String initialUrl, Map<String, String> parameters, String experimentIds, - Bundle intentExtras, @Nullable AssistantOnboardingCoordinator onboardingCoordinator) { + @Nullable String callerAccount, Bundle intentExtras, + @Nullable AssistantOnboardingCoordinator onboardingCoordinator) { if (mNativeClientAndroid == 0) return false; checkNativeClientIsAliveOrThrow(); chooseAccountAsyncIfNecessary(parameters.get(PARAMETER_USER_EMAIL), intentExtras); return AutofillAssistantClientJni.get().start(mNativeClientAndroid, - AutofillAssistantClient.this, initialUrl, experimentIds, + AutofillAssistantClient.this, initialUrl, experimentIds, callerAccount, parameters.keySet().toArray(new String[parameters.size()]), parameters.values().toArray(new String[parameters.size()]), onboardingCoordinator, /* onboardingShown= */ @@ -381,7 +382,8 @@ interface Natives { AutofillAssistantClient fromWebContents(WebContents webContents); boolean start(long nativeClientAndroid, AutofillAssistantClient caller, String initialUrl, - String experimentIds, String[] parameterNames, String[] parameterValues, + String experimentIds, String callerAccount, String[] parameterNames, + String[] parameterValues, @Nullable AssistantOnboardingCoordinator onboardingCoordinator, boolean onboardingShown, long nativeService); void onAccessToken(long nativeClientAndroid, AutofillAssistantClient caller,
diff --git a/chrome/android/features/autofill_assistant/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantModuleEntryImpl.java b/chrome/android/features/autofill_assistant/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantModuleEntryImpl.java index a43ef1d..59422d0d 100644 --- a/chrome/android/features/autofill_assistant/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantModuleEntryImpl.java +++ b/chrome/android/features/autofill_assistant/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantModuleEntryImpl.java
@@ -8,6 +8,7 @@ import android.os.Bundle; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.chromium.base.annotations.UsedByReflection; import org.chromium.chrome.browser.ChromeActivity; @@ -29,11 +30,12 @@ @Override public void start(@NonNull Tab tab, @NonNull WebContents webContents, boolean skipOnboarding, String initialUrl, Map<String, String> parameters, String experimentIds, - Bundle intentExtras) { + @Nullable String callerAccount, Bundle intentExtras) { if (skipOnboarding) { AutofillAssistantMetrics.recordOnBoarding(OnBoarding.OB_NOT_SHOWN); AutofillAssistantClient.fromWebContents(tab.getWebContents()) - .start(initialUrl, parameters, experimentIds, intentExtras, null); + .start(initialUrl, parameters, experimentIds, callerAccount, intentExtras, + null); return; } @@ -44,7 +46,7 @@ if (!accepted) return; AutofillAssistantClient.fromWebContents(tab.getWebContents()) - .start(initialUrl, parameters, experimentIds, intentExtras, + .start(initialUrl, parameters, experimentIds, callerAccount, intentExtras, onboardingCoordinator); }); }
diff --git a/chrome/android/features/autofill_assistant/javatests/src/org/chromium/chrome/browser/autofill_assistant/TestingAutofillAssistantModuleEntryProvider.java b/chrome/android/features/autofill_assistant/javatests/src/org/chromium/chrome/browser/autofill_assistant/TestingAutofillAssistantModuleEntryProvider.java index f196dd2..e55dfe5 100644 --- a/chrome/android/features/autofill_assistant/javatests/src/org/chromium/chrome/browser/autofill_assistant/TestingAutofillAssistantModuleEntryProvider.java +++ b/chrome/android/features/autofill_assistant/javatests/src/org/chromium/chrome/browser/autofill_assistant/TestingAutofillAssistantModuleEntryProvider.java
@@ -8,6 +8,7 @@ import android.os.Bundle; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.chromium.base.Callback; import org.chromium.chrome.browser.tab.Tab; @@ -59,7 +60,7 @@ @Override public void start(@NonNull Tab tab, @NonNull WebContents webContents, boolean skipOnboarding, String initialUrl, Map<String, String> parameters, - String experimentIds, Bundle intentExtras) {} + String experimentIds, @Nullable String callerAccount, Bundle intentExtras) {} @Override public AutofillAssistantActionHandler createActionHandler(Context context,
diff --git a/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantFacade.java b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantFacade.java index 9962036..9176386 100644 --- a/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantFacade.java +++ b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantFacade.java
@@ -67,6 +67,8 @@ private static final String EXPERIMENTS_SYNTHETIC_TRIAL = "AutofillAssistantExperimentsTrial"; + private static final String CALLER_ACCOUNT_IDENTIFIER = "CALLER_ACCOUNT"; + /** Returns true if conditions are satisfied to attempt to start Autofill Assistant. */ private static boolean isConfigured(@Nullable Bundle intentExtras) { return getBooleanParameter(intentExtras, PARAMETER_ENABLED); @@ -112,12 +114,13 @@ DropOutReason.DFM_INSTALL_FAILED); return; } - Map<String, String> parameters = extractParameters(bundleExtras); - parameters.remove(PARAMETER_ENABLED); + String callerAccount = parameters.get(CALLER_ACCOUNT_IDENTIFIER); + moduleEntry.start(tab, tab.getWebContents(), !AutofillAssistantPreferencesUtil.getShowOnboarding(), initialUrl, - parameters, experimentIds, bundleExtras); + filterParameters(parameters), experimentIds, callerAccount, + bundleExtras); }); }); } @@ -199,6 +202,13 @@ return result; } + /** Removes the parameters we don't want to send to the client */ + private static Map<String, String> filterParameters(Map<String, String> paramenters) { + paramenters.remove(PARAMETER_ENABLED); + paramenters.remove(CALLER_ACCOUNT_IDENTIFIER); + return paramenters; + } + /** Provides the callback with a tab that has a web contents, waits if necessary. */ private static void waitForTabWithWebContents(ChromeActivity activity, Callback<Tab> callback) { if (activity.getActivityTab() != null
diff --git a/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantModuleEntry.java b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantModuleEntry.java index cac90ed6..dcf0bd80 100644 --- a/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantModuleEntry.java +++ b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantModuleEntry.java
@@ -8,6 +8,7 @@ import android.os.Bundle; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.widget.ScrimView; @@ -32,7 +33,7 @@ */ void start(@NonNull Tab tab, @NonNull WebContents webContents, boolean skipOnboarding, String initialUrl, Map<String, String> parameters, String experimentIds, - Bundle intentExtras); + @Nullable String callerAccount, Bundle intentExtras); /** * Returns a {@link AutofillAssistantActionHandler} instance tied to the activity owning the * given bottom sheet, and scrim view.
diff --git a/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/sheet_tabs/AddressAccessorySheetControllerTest.java b/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/sheet_tabs/AddressAccessorySheetControllerTest.java index 73b6354..f034b3cd 100644 --- a/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/sheet_tabs/AddressAccessorySheetControllerTest.java +++ b/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/sheet_tabs/AddressAccessorySheetControllerTest.java
@@ -27,6 +27,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -46,19 +47,22 @@ import org.chromium.chrome.browser.keyboard_accessory.data.KeyboardAccessoryData.UserInfo; import org.chromium.chrome.browser.keyboard_accessory.data.PropertyProvider; import org.chromium.chrome.browser.keyboard_accessory.data.UserInfoField; +import org.chromium.chrome.test.util.browser.Features; import org.chromium.ui.modelutil.ListObservable; -import java.util.HashMap; - /** * Controller tests for the address accessory sheet. */ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE, shadows = {CustomShadowAsyncTask.class, ShadowRecordHistogram.class}) +@Features.EnableFeatures({ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY}) public class AddressAccessorySheetControllerTest { @Rule public JniMocker mocker = new JniMocker(); + @Rule + public TestRule mFeaturesProcessorRule = new Features.JUnitProcessor(); + @Mock private RecyclerView mMockView; @Mock @@ -75,7 +79,6 @@ MockitoAnnotations.initMocks(this); mocker.mock(RecordHistogramJni.TEST_HOOKS, mMockRecordHistogramNatives); AccessorySheetTabCoordinator.IconProvider.setIconForTesting(mock(Drawable.class)); - setAutofillFeature(true); mCoordinator = new AddressAccessorySheetCoordinator(RuntimeEnvironment.application, null); assertNotNull(mCoordinator); mSheetDataPieces = mCoordinator.getSheetDataPiecesForTesting(); @@ -223,10 +226,4 @@ return RecordHistogram.getHistogramValueCountForTesting( getHistogramForType(UMA_KEYBOARD_ACCESSORY_SHEET_SUGGESTIONS, type), sample); } - - private void setAutofillFeature(boolean enabled) { - HashMap<String, Boolean> features = new HashMap<>(); - features.put(ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY, enabled); - ChromeFeatureList.setTestFeatures(features); - } }
diff --git a/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/sheet_tabs/CreditCardAccessorySheetControllerTest.java b/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/sheet_tabs/CreditCardAccessorySheetControllerTest.java index b9480b7..cc7559b 100644 --- a/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/sheet_tabs/CreditCardAccessorySheetControllerTest.java +++ b/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/sheet_tabs/CreditCardAccessorySheetControllerTest.java
@@ -27,6 +27,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -46,19 +47,21 @@ import org.chromium.chrome.browser.keyboard_accessory.data.KeyboardAccessoryData.UserInfo; import org.chromium.chrome.browser.keyboard_accessory.data.PropertyProvider; import org.chromium.chrome.browser.keyboard_accessory.data.UserInfoField; +import org.chromium.chrome.test.util.browser.Features; import org.chromium.ui.modelutil.ListObservable; -import java.util.HashMap; - /** * Controller tests for the credit card accessory sheet. */ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE, shadows = {CustomShadowAsyncTask.class, ShadowRecordHistogram.class}) +@Features.EnableFeatures(ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY) public class CreditCardAccessorySheetControllerTest { @Rule public JniMocker mocker = new JniMocker(); + @Rule + public TestRule mFeaturesProcessorRule = new Features.JUnitProcessor(); @Mock private RecyclerView mMockView; @Mock @@ -75,7 +78,6 @@ MockitoAnnotations.initMocks(this); mocker.mock(RecordHistogramJni.TEST_HOOKS, mMockRecordHistogramNatives); AccessorySheetTabCoordinator.IconProvider.setIconForTesting(mock(Drawable.class)); - setAutofillFeature(true); mCoordinator = new CreditCardAccessorySheetCoordinator(RuntimeEnvironment.application, null); assertNotNull(mCoordinator); @@ -224,10 +226,4 @@ return RecordHistogram.getHistogramValueCountForTesting( getHistogramForType(UMA_KEYBOARD_ACCESSORY_SHEET_SUGGESTIONS, type), sample); } - - private void setAutofillFeature(boolean enabled) { - HashMap<String, Boolean> features = new HashMap<>(); - features.put(ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY, enabled); - ChromeFeatureList.setTestFeatures(features); - } }
diff --git a/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/sheet_tabs/PasswordAccessorySheetControllerTest.java b/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/sheet_tabs/PasswordAccessorySheetControllerTest.java index e98e11a..b7728390 100644 --- a/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/sheet_tabs/PasswordAccessorySheetControllerTest.java +++ b/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/sheet_tabs/PasswordAccessorySheetControllerTest.java
@@ -30,6 +30,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -52,9 +53,9 @@ import org.chromium.chrome.browser.keyboard_accessory.data.KeyboardAccessoryData.UserInfo; import org.chromium.chrome.browser.keyboard_accessory.data.PropertyProvider; import org.chromium.chrome.browser.keyboard_accessory.data.UserInfoField; +import org.chromium.chrome.test.util.browser.Features; import org.chromium.ui.modelutil.ListObservable; -import java.util.HashMap; import java.util.concurrent.atomic.AtomicReference; /** @@ -63,9 +64,12 @@ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE, shadows = {CustomShadowAsyncTask.class, ShadowRecordHistogram.class}) +@Features.EnableFeatures(ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY) public class PasswordAccessorySheetControllerTest { @Rule public JniMocker mocker = new JniMocker(); + @Rule + public TestRule mFeaturesProcessorRule = new Features.JUnitProcessor(); @Mock private RecyclerView mMockView; @Mock @@ -78,7 +82,6 @@ @Before public void setUp() { - setAutofillFeature(true); ShadowRecordHistogram.reset(); MockitoAnnotations.initMocks(this); mocker.mock(RecordHistogramJni.TEST_HOOKS, mMockRecordHistogramNatives); @@ -136,8 +139,8 @@ } @Test + @Features.DisableFeatures(ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY) public void testSplitsTabDataToList() { - setAutofillFeature(false); final PropertyProvider<AccessorySheetData> testProvider = new PropertyProvider<>(); final AccessorySheetData testData = new AccessorySheetData(AccessoryTabType.PASSWORDS, "Passwords for this site", ""); @@ -161,8 +164,8 @@ } @Test + @Features.EnableFeatures(ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY) public void testUsesTabTitleOnlyForEmptyListsForModernDesign() { - setAutofillFeature(true); final PropertyProvider<AccessorySheetData> testProvider = new PropertyProvider<>(); final AccessorySheetData testData = new AccessorySheetData(AccessoryTabType.PASSWORDS, "No passwords for this", ""); @@ -276,10 +279,4 @@ return RecordHistogram.getHistogramValueCountForTesting( getHistogramForType(UMA_KEYBOARD_ACCESSORY_SHEET_SUGGESTIONS, type), sample); } - - private void setAutofillFeature(boolean enabled) { - HashMap<String, Boolean> features = new HashMap<>(); - features.put(ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY, enabled); - ChromeFeatureList.setTestFeatures(features); - } }
diff --git a/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/tab_layout_component/KeyboardAccessoryTabLayoutControllerTest.java b/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/tab_layout_component/KeyboardAccessoryTabLayoutControllerTest.java index 1fdcd27..3c62218 100644 --- a/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/tab_layout_component/KeyboardAccessoryTabLayoutControllerTest.java +++ b/chrome/android/features/keyboard_accessory/junit/src/org/chromium/chrome/browser/keyboard_accessory/tab_layout_component/KeyboardAccessoryTabLayoutControllerTest.java
@@ -18,7 +18,9 @@ import com.google.android.material.tabs.TabLayout; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -29,20 +31,23 @@ import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.keyboard_accessory.data.KeyboardAccessoryData; +import org.chromium.chrome.test.util.browser.Features; import org.chromium.ui.modelutil.ListObservable; import org.chromium.ui.modelutil.PropertyKey; import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyObservable.PropertyObserver; -import java.util.HashMap; - /** * Controller tests for the keyboard accessory tab layout component. */ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE, shadows = {CustomShadowAsyncTask.class, ShadowRecordHistogram.class}) +@Features.EnableFeatures(ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY) public class KeyboardAccessoryTabLayoutControllerTest { + @Rule + public TestRule mFeaturesProcessorRule = new Features.JUnitProcessor(); + @Mock private PropertyObserver<PropertyKey> mMockPropertyObserver; @Mock @@ -63,9 +68,6 @@ public void setUp() { ShadowRecordHistogram.reset(); MockitoAnnotations.initMocks(this); - HashMap<String, Boolean> features = new HashMap<>(); - features.put(ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY, true); - ChromeFeatureList.setTestFeatures(features); mCoordinator = new KeyboardAccessoryTabLayoutCoordinator(); mMediator = mCoordinator.getMediatorForTesting();
diff --git a/chrome/android/features/start_surface/internal/junit/src/org/chromium/chrome/features/start_surface/StartSurfaceMediatorUnitTest.java b/chrome/android/features/start_surface/internal/junit/src/org/chromium/chrome/features/start_surface/StartSurfaceMediatorUnitTest.java index 48d6ba6..dfd792d 100644 --- a/chrome/android/features/start_surface/internal/junit/src/org/chromium/chrome/features/start_surface/StartSurfaceMediatorUnitTest.java +++ b/chrome/android/features/start_surface/internal/junit/src/org/chromium/chrome/features/start_surface/StartSurfaceMediatorUnitTest.java
@@ -41,7 +41,6 @@ import org.mockito.MockitoAnnotations; import org.robolectric.annotation.Config; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.chrome.browser.compositor.layouts.OverviewModeState; import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; @@ -109,7 +108,6 @@ @Before public void setUp() { - RecordUserAction.setDisabledForTests(true); MockitoAnnotations.initMocks(this); ArrayList<PropertyKey> allProperties = @@ -130,7 +128,6 @@ @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); mPropertyModel = null; }
diff --git a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupPopupUiMediator.java b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupPopupUiMediator.java index d05ab593..33811b91 100644 --- a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupPopupUiMediator.java +++ b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupPopupUiMediator.java
@@ -111,10 +111,7 @@ @Override public void didAddTab(Tab tab, int type, @TabCreationState int creationState) { - // TODO(crbug.com/1050846): The popup tab strip doesn't update accordingly when tab - // is opened in background. This might require us to specify how the view measures - // in this case. Skip it for now to avoid crash crbug.com/1045944. - if (isTabStripShowing() && type != TabLaunchType.FROM_LONGPRESS_BACKGROUND) { + if (isTabStripShowing()) { mUiUpdater.updateTabGroupPopUi(); return; }
diff --git a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListCoordinator.java b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListCoordinator.java index 40a4a3d..15a3ccf 100644 --- a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListCoordinator.java +++ b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListCoordinator.java
@@ -230,7 +230,7 @@ mMediator = new TabListMediator(context, mModel, tabModelSelector, thumbnailProvider, titleProvider, tabListFaviconProvider, actionOnRelatedTabs, selectionDelegateProvider, gridCardOnClickListenerProvider, dialogHandler, - this::endItemAnimationForPosition, componentName, itemType); + componentName, itemType); if (mMode == TabListMode.GRID) { GridLayoutManager gridLayoutManager = @@ -416,12 +416,4 @@ void removeSpecialListItem(@UiType int uiType, int itemIdentifier) { mMediator.removeSpecialItemFromModel(uiType, itemIdentifier); } - - private void endItemAnimationForPosition(int pos) { - RecyclerView.ViewHolder viewHolder = mRecyclerView.findViewHolderForAdapterPosition(pos); - if (viewHolder == null || mRecyclerView.getItemAnimator() == null) { - return; - } - mRecyclerView.getItemAnimator().endAnimation(viewHolder); - } }
diff --git a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediator.java b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediator.java index 8cadd8ca..41caf5ffd7 100644 --- a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediator.java +++ b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediator.java
@@ -31,7 +31,6 @@ import androidx.appcompat.content.res.AppCompatResources; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.ItemTouchHelper; -import androidx.recyclerview.widget.RecyclerView; import org.chromium.base.Callback; import org.chromium.base.Log; @@ -203,19 +202,6 @@ } /** - * An interface used to end current item animation in {@link RecyclerView} at certain position. - */ - interface ItemAnimationStopper { - /** - * This method stops the item animation from {@link RecyclerView.ItemAnimator} for item in - * {@code position}. - * - * @param position The position of the item whose animation will end. - */ - void endItemAnimationForPosition(int position); - } - - /** * An interface to show IPH for a tab. */ public interface IphProvider { void showIPH(View anchor); } @@ -451,8 +437,8 @@ TabListFaviconProvider tabListFaviconProvider, boolean actionOnRelatedTabs, @Nullable SelectionDelegateProvider selectionDelegateProvider, @Nullable GridCardOnClickListenerProvider gridCardOnClickListenerProvider, - @Nullable TabGridDialogHandler dialogHandler, ItemAnimationStopper itemAnimationStopper, - String componentName, @UiType int uiType) { + @Nullable TabGridDialogHandler dialogHandler, String componentName, + @UiType int uiType) { mContext = context; mTabModelSelector = tabModelSelector; mThumbnailProvider = thumbnailProvider; @@ -552,14 +538,9 @@ @Override public void willCloseTab(Tab tab, boolean animate) { - int index = mModel.indexFromId(tab.getId()); - if (index == TabModel.INVALID_TAB_INDEX) return; + if (mModel.indexFromId(tab.getId()) == TabModel.INVALID_TAB_INDEX) return; tab.removeObserver(mTabObserver); - // TODO(crbug.com/1045944): This line is for a specific crash, it should not be - // needed. Investigate why the crash is happening only in pop-up tab strip. Maybe - // related to how RecyclerView layouts in a wrap_content PopupWindow. - if (uiType == UiType.STRIP) itemAnimationStopper.endItemAnimationForPosition(index); - mModel.removeAt(index); + mModel.removeAt(mModel.indexFromId(tab.getId())); } @Override
diff --git a/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupPopupUiTest.java b/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupPopupUiTest.java index d7bcee9..22a3bbbe 100644 --- a/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupPopupUiTest.java +++ b/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupPopupUiTest.java
@@ -40,7 +40,6 @@ import org.junit.rules.TestRule; import org.junit.runner.RunWith; -import org.chromium.base.test.util.CloseableOnMainThread; import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.Restriction; import org.chromium.chrome.browser.ChromeTabbedActivity; @@ -57,7 +56,6 @@ import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeTabbedActivityTestRule; import org.chromium.chrome.test.util.browser.Features; -import org.chromium.chrome.test.util.browser.contextmenu.RevampedContextMenuUtils; import org.chromium.content_public.browser.test.util.CriteriaHelper; import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.net.test.EmbeddedTestServer; @@ -212,10 +210,16 @@ // Click on the current tab in strip to close, and the closure should trigger tab strip // update. - clickOnNthItemInStrip(cta, getCurrentTabIndexInGroup(cta)); + onView(withId(R.id.tab_list_view)) + .inRoot(withDecorView(not(cta.getWindow().getDecorView()))) + .perform(RecyclerViewActions.actionOnItemAtPosition( + getCurrentTabIndexInGroup(cta), click())); verifyShowingTabStrip(cta, 3); - clickOnNthItemInStrip(cta, getCurrentTabIndexInGroup(cta)); + onView(withId(R.id.tab_list_view)) + .inRoot(withDecorView(not(cta.getWindow().getDecorView()))) + .perform(RecyclerViewActions.actionOnItemAtPosition( + getCurrentTabIndexInGroup(cta), click())); verifyShowingTabStrip(cta, 2); } @@ -255,44 +259,6 @@ }); } - @Test - @MediumTest - public void testAddTabFromBackground() throws Throwable { - launchActivity(); - final ChromeTabbedActivity cta = mActivityTestRule.getActivity(); - EmbeddedTestServer embeddedTestServer = - EmbeddedTestServer.createAndStartServer(InstrumentationRegistry.getContext()); - String contextMenuTestUrl = embeddedTestServer.getURL( - "/chrome/test/data/android/contextmenu/context_menu_test.html"); - - mActivityTestRule.loadUrl(contextMenuTestUrl); - try (CloseableOnMainThread ignored = CloseableOnMainThread.StrictMode.allowDiskWrites()) { - RevampedContextMenuUtils.selectContextMenuItem( - InstrumentationRegistry.getInstrumentation(), cta, - cta.getTabModelSelector().getCurrentTab(), "testLink", - R.id.contextmenu_open_in_new_tab); - } - verifyShowingTabStrip(cta, 2); - - // Add enough tabs so that adding new items later requires recyclerView to recycle old - // views. - for (int i = 0; i < 6; i++) { - onView(withId(R.id.toolbar_right_button)) - .inRoot(withDecorView(not(cta.getWindow().getDecorView()))) - .perform(click()); - } - verifyShowingTabStrip(cta, 8); - - clickOnNthItemInStrip(cta, 0); - try (CloseableOnMainThread ignored = CloseableOnMainThread.StrictMode.allowDiskWrites()) { - RevampedContextMenuUtils.selectContextMenuItem( - InstrumentationRegistry.getInstrumentation(), cta, - cta.getTabModelSelector().getCurrentTab(), "testLink", - R.id.contextmenu_open_in_new_tab); - } - verifyShowingTabStrip(cta, 9); - } - private void createTabGroupAndEnterTabPage(ChromeTabbedActivity cta, int tabCount, String url) { if (url == null) { createTabs(cta, false, tabCount); @@ -384,10 +350,4 @@ .getTabModelFilterProvider() .getCurrentTabModelFilter()::isTabModelRestored); } - - private void clickOnNthItemInStrip(ChromeTabbedActivity cta, int index) { - onView(withId(R.id.tab_list_view)) - .inRoot(withDecorView(not(cta.getWindow().getDecorView()))) - .perform(RecyclerViewActions.actionOnItemAtPosition(index, click())); - } }
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/TasksSurfaceMediatorUnitTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/TasksSurfaceMediatorUnitTest.java index 8498dbd5..c2c6cd8 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/TasksSurfaceMediatorUnitTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/TasksSurfaceMediatorUnitTest.java
@@ -38,7 +38,6 @@ import org.mockito.MockitoAnnotations; import org.robolectric.annotation.Config; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.chrome.browser.ntp.FakeboxDelegate; import org.chromium.chrome.browser.ntp.IncognitoCookieControlsManager; @@ -75,7 +74,6 @@ @Before public void setUp() { - RecordUserAction.setDisabledForTests(true); MockitoAnnotations.initMocks(this); mMediator = new TasksSurfaceMediator(mPropertyModel, mFakeboxDelegate, @@ -84,7 +82,6 @@ @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); mMediator = null; }
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/pseudotab/TabAttributeCacheUnitTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/pseudotab/TabAttributeCacheUnitTest.java index 893be436..165c065d 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/pseudotab/TabAttributeCacheUnitTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/pseudotab/TabAttributeCacheUnitTest.java
@@ -26,7 +26,6 @@ import org.robolectric.annotation.Config; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory; import org.chromium.chrome.browser.tab.TabImpl; @@ -84,7 +83,6 @@ @Before public void setUp() { - RecordUserAction.setDisabledForTests(true); RecordHistogram.setDisabledForTests(true); MockitoAnnotations.initMocks(this); @@ -118,7 +116,6 @@ @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); RecordHistogram.setDisabledForTests(false); mCache.destroy(); TabAttributeCache.setLastSearchTermMockForTesting(null);
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilterUnitTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilterUnitTest.java index c893223..ab9a733 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilterUnitTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilterUnitTest.java
@@ -35,7 +35,6 @@ import org.robolectric.annotation.Config; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.TabCreationState; @@ -264,7 +263,6 @@ // After setUp, TabModel has 6 tabs in the following order: mTab1, mTab2, mTab3, mTab4, // mTab5, mTab6. While mTab2 and mTab3 are in a group, and mTab5 and mTab6 are in a separate // group. - RecordUserAction.setDisabledForTests(true); RecordHistogram.setDisabledForTests(true); MockitoAnnotations.initMocks(this); @@ -276,7 +274,6 @@ @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); RecordHistogram.setDisabledForTests(false); }
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupUtilsUnitTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupUtilsUnitTest.java index 29403512..eb83cfc 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupUtilsUnitTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupUtilsUnitTest.java
@@ -28,7 +28,6 @@ import org.chromium.base.ContextUtils; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.TabImpl; import org.chromium.chrome.browser.tabmodel.TabModel; @@ -86,7 +85,6 @@ @Before public void setUp() { - RecordUserAction.setDisabledForTests(true); RecordHistogram.setDisabledForTests(true); MockitoAnnotations.initMocks(this); @@ -111,7 +109,6 @@ @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); RecordHistogram.setDisabledForTests(false); }
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGridDialogMediatorUnitTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGridDialogMediatorUnitTest.java index f378ea2..5c147d0 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGridDialogMediatorUnitTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGridDialogMediatorUnitTest.java
@@ -45,7 +45,6 @@ import org.chromium.base.Callback; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.supplier.ObservableSupplier; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.chrome.browser.flags.CachedFeatureFlags; @@ -142,7 +141,6 @@ @Before public void setUp() { - RecordUserAction.setDisabledForTests(true); RecordHistogram.setDisabledForTests(true); MockitoAnnotations.initMocks(this); @@ -205,7 +203,6 @@ @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); RecordHistogram.setDisabledForTests(false); CachedFeatureFlags.setForTesting(ChromeFeatureList.TAB_GROUPS_ANDROID, null); }
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGridIphDialogMediatorUnitTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGridIphDialogMediatorUnitTest.java index df9ddfe..26a693a 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGridIphDialogMediatorUnitTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGridIphDialogMediatorUnitTest.java
@@ -21,7 +21,6 @@ import org.robolectric.annotation.Config; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.chrome.browser.widget.ScrimView; import org.chromium.chrome.test.util.browser.Features; import org.chromium.testing.local.LocalRobolectricTestRunner; @@ -44,7 +43,6 @@ @Before public void setUp() { - RecordUserAction.setDisabledForTests(true); RecordHistogram.setDisabledForTests(true); MockitoAnnotations.initMocks(this); @@ -55,7 +53,6 @@ @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); RecordHistogram.setDisabledForTests(false); }
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGridItemTouchHelperCallbackUnitTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGridItemTouchHelperCallbackUnitTest.java index 6fee49ff..036ac59 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGridItemTouchHelperCallbackUnitTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGridItemTouchHelperCallbackUnitTest.java
@@ -40,7 +40,6 @@ import org.robolectric.annotation.Config; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.chrome.browser.feature_engagement.TrackerFactory; import org.chromium.chrome.browser.flags.CachedFeatureFlags; @@ -132,7 +131,6 @@ @Before public void setUp() { - RecordUserAction.setDisabledForTests(true); RecordHistogram.setDisabledForTests(true); MockitoAnnotations.initMocks(this); @@ -210,7 +208,6 @@ @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); RecordHistogram.setDisabledForTests(false); CachedFeatureFlags.setForTesting(ChromeFeatureList.TAB_GROUPS_ANDROID, null); }
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupPopupUiMediatorUnitTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupPopupUiMediatorUnitTest.java index 5ec1522..3041a30 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupPopupUiMediatorUnitTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupPopupUiMediatorUnitTest.java
@@ -30,7 +30,6 @@ import org.robolectric.annotation.Config; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior; import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; import org.chromium.chrome.browser.tab.Tab; @@ -114,7 +113,6 @@ @Before public void setUp() { - RecordUserAction.setDisabledForTests(true); RecordHistogram.setDisabledForTests(true); MockitoAnnotations.initMocks(this); @@ -146,7 +144,6 @@ @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); RecordHistogram.setDisabledForTests(false); } @@ -312,22 +309,6 @@ } @Test - public void tabAddition_NotUpdate_Background() { - // Mock that the strip is showing. - mModel.set(TabGroupPopupUiProperties.IS_VISIBLE, true); - // Mock that tab1, tab2 and tab3 are in the same group, and tab3 has just been created from - // background. - List<Tab> tabGroup = new ArrayList<>(Arrays.asList(mTab1, mTab2, mTab3)); - createTabGroup(tabGroup, TAB1_ID); - - mTabModelObserverCaptor.getValue().didAddTab(mTab3, TabLaunchType.FROM_LONGPRESS_BACKGROUND, - TabCreationState.LIVE_IN_BACKGROUND); - - assertThat(mModel.get(TabGroupPopupUiProperties.IS_VISIBLE), equalTo(true)); - verify(mUpdater, never()).updateTabGroupPopUi(); - } - - @Test public void tabClosureUndone_Show() { // Mock that the strip is hiding. mModel.set(TabGroupPopupUiProperties.IS_VISIBLE, false);
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupTitleEditorUnitTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupTitleEditorUnitTest.java index a0a0e37..c6f417c 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupTitleEditorUnitTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupTitleEditorUnitTest.java
@@ -24,7 +24,6 @@ import org.robolectric.annotation.Config; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.TabImpl; import org.chromium.chrome.browser.tabmodel.TabModel; @@ -83,7 +82,6 @@ @Before public void setUp() { - RecordUserAction.setDisabledForTests(true); RecordHistogram.setDisabledForTests(true); MockitoAnnotations.initMocks(this); @@ -128,7 +126,6 @@ @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); RecordHistogram.setDisabledForTests(false); }
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupUiMediatorUnitTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupUiMediatorUnitTest.java index 041cdcfc..e3e04e7 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupUiMediatorUnitTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupUiMediatorUnitTest.java
@@ -39,7 +39,6 @@ import org.robolectric.annotation.Config; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.chrome.browser.ThemeColorProvider; import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior; @@ -196,7 +195,6 @@ // initAndAssertProperties(true), TabModel has 3 tabs in the following order: mTab1, mTab2, // and mTab3, while mTab2 and mTab3 are in a group. By default mTab1 is selected. If // initAndAssertProperties(false) is called instead, there's no tabs in TabModel. - RecordUserAction.setDisabledForTests(true); RecordHistogram.setDisabledForTests(true); MockitoAnnotations.initMocks(this); @@ -282,7 +280,6 @@ @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); RecordHistogram.setDisabledForTests(false); }
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediatorUnitTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediatorUnitTest.java index 8a3b9bf..a2611f3 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediatorUnitTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediatorUnitTest.java
@@ -77,7 +77,6 @@ import org.chromium.base.ContextUtils; import org.chromium.base.UserDataHost; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.base.test.util.JniMocker; import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; @@ -215,8 +214,6 @@ @Mock TabListMediator.TabGridAccessibilityHelper mTabGridAccessibilityHelper; @Mock - TabListMediator.ItemAnimationStopper mItemAnimationStopper; - @Mock TemplateUrlService mTemplateUrlService; @Captor @@ -249,7 +246,6 @@ @Before public void setUp() { - RecordUserAction.setDisabledForTests(true); RecordHistogram.setDisabledForTests(true); MockitoAnnotations.initMocks(this); @@ -326,14 +322,13 @@ mMediator = new TabListMediator(mContext, mModel, mTabModelSelector, mTabContentManager::getTabThumbnailWithCallback, mTitleProvider, mTabListFaviconProvider, false, null, mGridCardOnClickListenerProvider, null, - mItemAnimationStopper, getClass().getSimpleName(), UiType.CLOSABLE); + getClass().getSimpleName(), UiType.CLOSABLE); mMediator.registerOrientationListener(mGridLayoutManager); TrackerFactory.setTrackerForTests(mTracker); } @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); RecordHistogram.setDisabledForTests(false); CachedFeatureFlags.setForTesting(TAB_GROUPS_ANDROID, null); CachedFeatureFlags.setForTesting(ChromeFeatureList.START_SURFACE_ANDROID, null); @@ -586,16 +581,6 @@ } @Test - public void tabClosure_ForceStopItemAnimationForStrip() { - setUpForTabGroupOperation(TabListMediatorType.TAB_STRIP); - - mMediatorTabModelObserver.willCloseTab(mTab2, false); - - assertThat(mModel.size(), equalTo(1)); - verify(mItemAnimationStopper).endItemAnimationForPosition(eq(1)); - } - - @Test public void tabAddition_RestoreNotComplete() { initAndAssertAllProperties(); mMediator.setActionOnAllRelatedTabsForTesting(true); @@ -1934,8 +1919,8 @@ // Re-initialize the mediator to setup TemplateUrlServiceObserver if needed. mMediator = new TabListMediator(mContext, mModel, mTabModelSelector, mTabContentManager::getTabThumbnailWithCallback, mTitleProvider, - mTabListFaviconProvider, true, null, null, null, mItemAnimationStopper, - getClass().getSimpleName(), TabProperties.UiType.CLOSABLE); + mTabListFaviconProvider, true, null, null, null, getClass().getSimpleName(), + TabProperties.UiType.CLOSABLE); initAndAssertAllProperties(); @@ -1957,8 +1942,8 @@ // Re-initialize the mediator to setup TemplateUrlServiceObserver if needed. mMediator = new TabListMediator(mContext, mModel, mTabModelSelector, mTabContentManager::getTabThumbnailWithCallback, mTitleProvider, - mTabListFaviconProvider, true, null, null, null, mItemAnimationStopper, - getClass().getSimpleName(), TabProperties.UiType.CLOSABLE); + mTabListFaviconProvider, true, null, null, null, getClass().getSimpleName(), + TabProperties.UiType.CLOSABLE); initAndAssertAllProperties(); @@ -2092,7 +2077,7 @@ mMediator = new TabListMediator(mContext, mModel, mTabModelSelector, mTabContentManager::getTabThumbnailWithCallback, mTitleProvider, mTabListFaviconProvider, actionOnRelatedTabs, null, null, handler, - mItemAnimationStopper, getClass().getSimpleName(), uiType); + getClass().getSimpleName(), uiType); // There are two TabModelObserver and two TabGroupModelFilter.Observer added when // initializing TabListMediator, one set from TabListMediator and the other from
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabSelectionEditorActionProviderUnitTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabSelectionEditorActionProviderUnitTest.java index 66c44b75..1abac1fc 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabSelectionEditorActionProviderUnitTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabSelectionEditorActionProviderUnitTest.java
@@ -25,7 +25,6 @@ import org.chromium.base.UserDataHost; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.TabImpl; import org.chromium.chrome.browser.tabmodel.TabModel; @@ -73,7 +72,6 @@ @Before public void setUp() { - RecordUserAction.setDisabledForTests(true); RecordHistogram.setDisabledForTests(true); MockitoAnnotations.initMocks(this); @@ -94,7 +92,6 @@ @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); RecordHistogram.setDisabledForTests(false); }
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabSwitcherMediatorUnitTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabSwitcherMediatorUnitTest.java index 4148c3e..1296c41c 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabSwitcherMediatorUnitTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabSwitcherMediatorUnitTest.java
@@ -41,7 +41,6 @@ import org.chromium.base.UserDataHost; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.metrics.test.ShadowRecordHistogram; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.chrome.browser.compositor.CompositorViewHolder; @@ -142,7 +141,6 @@ @Before public void setUp() { ShadowRecordHistogram.reset(); - RecordUserAction.setDisabledForTests(true); RecordHistogram.setDisabledForTests(true); CachedFeatureFlags.setForTesting(ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID, true); @@ -197,7 +195,6 @@ @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); RecordHistogram.setDisabledForTests(false); CachedFeatureFlags.setForTesting(ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID, null); CachedFeatureFlags.setForTesting(ChromeFeatureList.TAB_GROUPS_ANDROID, null);
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/suggestions/TabSuggestionsOrchestratorTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/suggestions/TabSuggestionsOrchestratorTest.java index 3184508..2899478 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/suggestions/TabSuggestionsOrchestratorTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/suggestions/TabSuggestionsOrchestratorTest.java
@@ -25,7 +25,6 @@ import org.chromium.base.Callback; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.test.util.InMemorySharedPreferences; import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher; import org.chromium.chrome.browser.tab.Tab; @@ -95,13 +94,11 @@ doReturn(Arrays.asList(sTabs[0])).when(mTabModelFilter).getRelatedTabList(0); doReturn(Arrays.asList(sTabs[1])).when(mTabModelFilter).getRelatedTabList(1); doReturn(Arrays.asList(sTabs[2])).when(mTabModelFilter).getRelatedTabList(2); - RecordUserAction.setDisabledForTests(true); RecordHistogram.setDisabledForTests(true); } @After public void tearDown() throws Exception { - RecordUserAction.setDisabledForTests(false); RecordHistogram.setDisabledForTests(false); }
diff --git a/chrome/android/feed/core/javatests/src/org/chromium/chrome/browser/feed/FeedJournalStorageConformanceTest.java b/chrome/android/feed/core/javatests/src/org/chromium/chrome/browser/feed/FeedJournalStorageConformanceTest.java index 0aeb0854..71fd9ae 100644 --- a/chrome/android/feed/core/javatests/src/org/chromium/chrome/browser/feed/FeedJournalStorageConformanceTest.java +++ b/chrome/android/feed/core/javatests/src/org/chromium/chrome/browser/feed/FeedJournalStorageConformanceTest.java
@@ -85,7 +85,7 @@ public void setUp() { TestThreadUtils.runOnUiThreadBlocking(() -> { // journalStorage is declared and tested in JournalStorageConformanceTest. - mJournalStorage = new JournalStorageWrapper(Profile.getLastUsedProfile()); + mJournalStorage = new JournalStorageWrapper(Profile.getLastUsedRegularProfile()); }); }
diff --git a/chrome/android/feed/core/javatests/src/org/chromium/chrome/browser/feed/FeedNetworkBridgeConformanceTest.java b/chrome/android/feed/core/javatests/src/org/chromium/chrome/browser/feed/FeedNetworkBridgeConformanceTest.java index 53d52e1..61810dc4 100644 --- a/chrome/android/feed/core/javatests/src/org/chromium/chrome/browser/feed/FeedNetworkBridgeConformanceTest.java +++ b/chrome/android/feed/core/javatests/src/org/chromium/chrome/browser/feed/FeedNetworkBridgeConformanceTest.java
@@ -100,7 +100,7 @@ private void createNetworkClient() { // The networkClient is declared and tested in NetworkClientConformanceTest - mNetworkClient = new FeedTestNetworkBridge(Profile.getLastUsedProfile()); + mNetworkClient = new FeedTestNetworkBridge(Profile.getLastUsedRegularProfile()); } private void destroyNetworkClient() {
diff --git a/chrome/android/feed/core/javatests/src/org/chromium/chrome/browser/feed/FeedSchedulerBridgeConformanceTest.java b/chrome/android/feed/core/javatests/src/org/chromium/chrome/browser/feed/FeedSchedulerBridgeConformanceTest.java index 03ffed7..6fc3262 100644 --- a/chrome/android/feed/core/javatests/src/org/chromium/chrome/browser/feed/FeedSchedulerBridgeConformanceTest.java +++ b/chrome/android/feed/core/javatests/src/org/chromium/chrome/browser/feed/FeedSchedulerBridgeConformanceTest.java
@@ -65,7 +65,7 @@ @Before public void setUp() { // The scheduler is declared and tested in SchedulerConformanceTest. - mScheduler = new FeedSchedulerBridge(Profile.getLastUsedProfile()); + mScheduler = new FeedSchedulerBridge(Profile.getLastUsedRegularProfile()); if (mUseRequestManager) { ((FeedSchedulerBridge) mScheduler).initializeFeedDependencies(mRequestManager); }
diff --git a/chrome/android/java/res/xml/homepage_preferences.xml b/chrome/android/java/res/xml/homepage_preferences.xml index 14f411fc..f641eb2 100644 --- a/chrome/android/java/res/xml/homepage_preferences.xml +++ b/chrome/android/java/res/xml/homepage_preferences.xml
@@ -18,7 +18,7 @@ android:visibility="gone" android:fragment="org.chromium.chrome.browser.settings.homepage.HomepageEditor" /> - <org.chromium.chrome.browser.settings.homepage.RadioButtonGroupHomepagePreference + <org.chromium.chrome.browser.homepage.settings.RadioButtonGroupHomepagePreference android:key="homepage_radio_group" android:visibility="gone" android:selectable="false"
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/ClientAppBroadcastReceiver.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/ClientAppBroadcastReceiver.java index 53fd6a7..203f796 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/ClientAppBroadcastReceiver.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/ClientAppBroadcastReceiver.java
@@ -14,6 +14,7 @@ import org.chromium.chrome.browser.ChromeVersionInfo; import org.chromium.chrome.browser.browserservices.permissiondelegation.NotificationPermissionUpdater; import org.chromium.chrome.browser.metrics.WebApkUma; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.webapk.lib.common.WebApkConstants; import java.util.Arrays;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/ClientAppDataRegister.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/ClientAppDataRegister.java index 42c691ec..2b56c42 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/ClientAppDataRegister.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/ClientAppDataRegister.java
@@ -13,6 +13,7 @@ import org.chromium.base.StrictModeContext; import org.chromium.base.task.PostTask; import org.chromium.base.task.TaskTraits; +import org.chromium.components.embedder_support.util.Origin; import java.util.Collections; import java.util.HashSet;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/Origin.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/Origin.java index 52385bc..cc84bb0 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/Origin.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/Origin.java
@@ -8,36 +8,21 @@ import androidx.annotation.Nullable; -import org.chromium.components.embedder_support.util.UrlConstants; - /** - * A class to canonically represent a HTTP or HTTPS web origin in Java. In comparison to - * {@link org.chromium.net.GURLUtils#getOrigin} it can be used before native is loaded and lets us - * ensure conversion to an origin has been done with the type system. - * - * {@link #toString()} does <b>not</b> match {@link org.chromium.net.GURLUtils#getOrigin}. The - * latter will return a String with a trailing "/". Not having a trailing slash matches RFC - * behaviour (https://tools.ietf.org/html/rfc6454), it seems that - * {@link org.chromium.net.GURLUtils#getOrigin} adds it as a bug, but as its result is saved to - * user's Android Preferences, it is not trivial to change. + * @see org.chromium.components.embedder_support.util.Origin */ -public class Origin { - private static final int HTTP_DEFAULT_PORT = 80; - private static final int HTTPS_DEFAULT_PORT = 443; - - private final Uri mOrigin; - - private Origin(Uri origin) { - mOrigin = origin; +// TODO(crbug.com/1058597): Delete this class once Clank migrates to the embedder_support version. +public class Origin extends org.chromium.components.embedder_support.util.Origin { + protected Origin(Uri origin) { + super(origin); } - /** - * Constructs a canonical Origin from a String. Will return {@code null} for origins that are - * not HTTP or HTTPS. - */ @Nullable - public static Origin create(String uri) { - return create(Uri.parse(uri)); + public static Origin create(org.chromium.components.embedder_support.util.Origin origin) { + if (origin == null) { + return null; + } + return new Origin(origin.uri()); } /** @@ -46,78 +31,6 @@ */ @Nullable public static Origin create(Uri uri) { - if (uri == null || uri.getScheme() == null || uri.getAuthority() == null) { - return null; - } - - // This class can only correctly handle certain origins, see https://crbug.com/1019244. - String scheme = uri.getScheme(); - if (!scheme.equals(UrlConstants.HTTP_SCHEME) && !scheme.equals(UrlConstants.HTTPS_SCHEME)) { - return null; - } - - // Make explicit ports implicit and remove any user:password. - int port = uri.getPort(); - if (scheme.equals(UrlConstants.HTTP_SCHEME) && port == HTTP_DEFAULT_PORT) port = -1; - if (scheme.equals(UrlConstants.HTTPS_SCHEME) && port == HTTPS_DEFAULT_PORT) port = -1; - - String authority = uri.getHost(); - if (port != -1) authority += ":" + port; - - try { - return new Origin(uri.normalizeScheme() - .buildUpon() - .opaquePart("") - .fragment("") - .path("") - .encodedAuthority(authority) - .clearQuery() - .build()); - } catch (UnsupportedOperationException e) { - return null; - } - } - - /** - * Constructs a canonical Origin from a String, throwing an exception if parsing fails. - */ - public static Origin createOrThrow(String uri) { - return createOrThrow(Uri.parse(uri)); - } - - /** - * Constructs a canonical Origin from an Uri, throwing an exception if parsing fails. - */ - public static Origin createOrThrow(Uri uri) { - Origin origin = Origin.create(uri); - if (origin == null) throw new IllegalArgumentException("Could not parse: " + uri); - return origin; - } - - /* - * Returns a Uri representing the Origin. - */ - public Uri uri() { - return mOrigin; - } - - @Override - public int hashCode() { - return mOrigin.hashCode(); - } - - /** - * Returns a String representing the Origin. - */ - @Override - public String toString() { - return mOrigin.toString(); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - if (other == null || getClass() != other.getClass()) return false; - return mOrigin.equals(((Origin) other).mOrigin); + return create(org.chromium.components.embedder_support.util.Origin.create(uri)); } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/OriginVerifier.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/OriginVerifier.java index 97ffbd7..bf1e62f 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/OriginVerifier.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/OriginVerifier.java
@@ -29,6 +29,7 @@ import org.chromium.chrome.browser.IntentHandler; import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.browser.profiles.Profile; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.components.embedder_support.util.UrlConstants; import org.chromium.content_public.browser.BrowserStartupController; import org.chromium.content_public.browser.UiThreadTaskTraits;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/PostMessageHandler.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/PostMessageHandler.java index 2dd5be3..e4ec459 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/PostMessageHandler.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/PostMessageHandler.java
@@ -15,6 +15,7 @@ import org.chromium.base.task.PostTask; import org.chromium.chrome.browser.browserservices.OriginVerifier.OriginVerificationListener; import org.chromium.chrome.browser.tab.Tab; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.content_public.browser.MessagePort; import org.chromium.content_public.browser.MessagePort.MessageCallback; import org.chromium.content_public.browser.NavigationHandle;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/Relationship.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/Relationship.java index 674bfd5..eabe7b4 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/Relationship.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/Relationship.java
@@ -4,6 +4,8 @@ package org.chromium.chrome.browser.browserservices; +import org.chromium.components.embedder_support.util.Origin; + /** * This is a plain-old-data class to store a Digital Asset Link relationship [1]. *
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClient.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClient.java index d969b858..96fc72ce 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClient.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClient.java
@@ -38,6 +38,7 @@ import org.chromium.chrome.browser.notifications.NotificationBuilderBase; import org.chromium.chrome.browser.notifications.NotificationMetadata; import org.chromium.chrome.browser.notifications.NotificationUmaTracker; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.components.embedder_support.util.UrlConstants; import org.chromium.content_public.browser.UiThreadTaskTraits;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/InstalledWebappBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/InstalledWebappBridge.java index 40570e1..dcda7639 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/InstalledWebappBridge.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/InstalledWebappBridge.java
@@ -6,8 +6,8 @@ import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.NativeMethods; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.site_settings.ContentSettingValues; +import org.chromium.components.embedder_support.util.Origin; /** * Provides Trusted Web Activity Client App permissions for native. The C++ counterpart is the
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationChannelPreserver.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationChannelPreserver.java index 160d584d..a5bd36f 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationChannelPreserver.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationChannelPreserver.java
@@ -6,10 +6,10 @@ import android.os.Build; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.notifications.NotificationChannelStatus; import org.chromium.chrome.browser.notifications.channels.ChannelDefinitions; import org.chromium.chrome.browser.notifications.channels.SiteChannelsManager; +import org.chromium.components.embedder_support.util.Origin; import javax.inject.Inject; import javax.inject.Singleton;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationPermissionUpdater.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationPermissionUpdater.java index 2600f69..88ec065 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationPermissionUpdater.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationPermissionUpdater.java
@@ -14,8 +14,8 @@ import org.chromium.base.PackageManagerUtils; import org.chromium.base.task.PostTask; import org.chromium.chrome.browser.browserservices.BrowserServicesMetrics; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.TrustedWebActivityClient; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.content_public.browser.UiThreadTaskTraits; import javax.inject.Inject;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPermissionManager.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPermissionManager.java index 76bfb902..8ebd075 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPermissionManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPermissionManager.java
@@ -19,8 +19,8 @@ import org.chromium.base.ContextUtils; import org.chromium.base.Log; import org.chromium.chrome.browser.ChromeApplication; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.site_settings.ContentSettingValues; +import org.chromium.components.embedder_support.util.Origin; import java.util.ArrayList; import java.util.List;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPermissionStore.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPermissionStore.java index feda245..4ae6969 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPermissionStore.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPermissionStore.java
@@ -8,19 +8,19 @@ import android.content.SharedPreferences; import android.util.Base64; -import org.chromium.base.ContextUtils; -import org.chromium.base.StrictModeContext; -import org.chromium.chrome.browser.browserservices.Origin; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.annotation.WorkerThread; import androidx.browser.trusted.Token; +import org.chromium.base.ContextUtils; +import org.chromium.base.StrictModeContext; +import org.chromium.components.embedder_support.util.Origin; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + /** * Stores data about origins associated with a Trusted Web Activity for the purpose of Permission * Delegation. Primarily we store (indexed by origin):
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/TrustedWebActivityCoordinator.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/TrustedWebActivityCoordinator.java index e82fc38..426d2ec 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/TrustedWebActivityCoordinator.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/TrustedWebActivityCoordinator.java
@@ -9,7 +9,6 @@ import androidx.browser.trusted.TrustedWebActivityDisplayMode.ImmersiveMode; import org.chromium.chrome.browser.browserservices.BrowserServicesIntentDataProvider; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.TrustedWebActivityUmaRecorder; import org.chromium.chrome.browser.browserservices.trustedwebactivityui.controller.ClientPackageNameProvider; import org.chromium.chrome.browser.browserservices.trustedwebactivityui.controller.CurrentPageVerifier; @@ -32,6 +31,7 @@ import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher; import org.chromium.chrome.browser.lifecycle.InflationObserver; import org.chromium.chrome.browser.lifecycle.NativeInitObserver; +import org.chromium.components.embedder_support.util.Origin; import javax.inject.Inject;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/ClientAppDataRecorder.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/ClientAppDataRecorder.java index 84310ae1..a3efece 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/ClientAppDataRecorder.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/ClientAppDataRecorder.java
@@ -13,8 +13,8 @@ import org.chromium.base.Log; import org.chromium.chrome.browser.browserservices.ClientAppDataRegister; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.dependency_injection.ActivityScope; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.components.embedder_support.util.UrlUtilities; import java.util.HashSet;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TwaRegistrar.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TwaRegistrar.java index 1f80a69..caa3ed8 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TwaRegistrar.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TwaRegistrar.java
@@ -8,8 +8,8 @@ import android.content.Context; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.permissiondelegation.NotificationPermissionUpdater; +import org.chromium.components.embedder_support.util.Origin; import java.util.HashSet; import java.util.Set;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TwaVerifier.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TwaVerifier.java index e7766f35..4d433dbd 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TwaVerifier.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TwaVerifier.java
@@ -4,14 +4,17 @@ package org.chromium.chrome.browser.browserservices.trustedwebactivityui.controller; +import androidx.annotation.Nullable; +import androidx.browser.customtabs.CustomTabsService; + import org.chromium.base.Promise; import org.chromium.chrome.browser.browserservices.BrowserServicesIntentDataProvider; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.OriginVerifier; import org.chromium.chrome.browser.customtabs.content.CustomTabActivityTabProvider; import org.chromium.chrome.browser.dependency_injection.ActivityScope; import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher; import org.chromium.chrome.browser.lifecycle.Destroyable; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.content_public.browser.WebContents; import java.util.HashSet; @@ -20,9 +23,6 @@ import javax.inject.Inject; -import androidx.annotation.Nullable; -import androidx.browser.customtabs.CustomTabsService; - /** * Provides Trusted Web Activity specific behaviour for the {@link CurrentPageVerifier}. */
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ClientManager.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ClientManager.java index ed60e55..940b54f1 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ClientManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ClientManager.java
@@ -30,12 +30,12 @@ import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.task.PostTask; import org.chromium.chrome.browser.IntentHandler; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.OriginVerifier; import org.chromium.chrome.browser.browserservices.OriginVerifier.OriginVerificationListener; import org.chromium.chrome.browser.browserservices.PostMessageHandler; import org.chromium.chrome.browser.installedapp.InstalledAppProviderImpl; import org.chromium.chrome.browser.installedapp.PackageManagerDelegate; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.components.embedder_support.util.UrlUtilities; import org.chromium.content_public.browser.UiThreadTaskTraits; import org.chromium.content_public.browser.WebContents;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabSessionHandler.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabSessionHandler.java index 654022e2..02785be 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabSessionHandler.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabSessionHandler.java
@@ -19,7 +19,6 @@ import org.chromium.base.Log; import org.chromium.chrome.browser.browserservices.BrowserServicesIntentDataProvider; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.OriginVerifier; import org.chromium.chrome.browser.browserservices.SessionDataHolder; import org.chromium.chrome.browser.browserservices.SessionHandler; @@ -30,6 +29,7 @@ import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher; import org.chromium.chrome.browser.lifecycle.StartStopWithNativeObserver; import org.chromium.chrome.browser.tab.Tab; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.content_public.browser.NavigationEntry; import javax.inject.Inject;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java index b73b53a..23f4798 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java
@@ -51,7 +51,6 @@ import org.chromium.chrome.browser.ChromeApplication; import org.chromium.chrome.browser.IntentHandler; import org.chromium.chrome.browser.WarmupManager; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.PostMessageHandler; import org.chromium.chrome.browser.browserservices.SessionDataHolder; import org.chromium.chrome.browser.browserservices.SessionHandler; @@ -66,6 +65,7 @@ import org.chromium.chrome.browser.privacy.settings.PrivacyPreferencesManager; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.tab.Tab; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.components.embedder_support.util.UrlConstants; import org.chromium.content_public.browser.BrowserStartupController; import org.chromium.content_public.browser.ChildProcessLauncherHelper; @@ -687,7 +687,8 @@ // Attempt to verify origin synchronously. If successful directly initialize postMessage // channel for session. - Uri verifiedOrigin = verifyOriginForSession(session, uid, postMessageOrigin); + Uri verifiedOrigin = verifyOriginForSession(session, uid, + org.chromium.chrome.browser.browserservices.Origin.create(postMessageOrigin)); if (verifiedOrigin == null) { mClientManager.verifyAndInitializeWithPostMessageOriginForSession( session, postMessageOrigin, CustomTabsService.RELATION_USE_AS_ORIGIN); @@ -712,6 +713,12 @@ return null; } + // TODO(crbug.com/1058597): Delete this once Clank switches to the new Origin class. + protected Uri verifyOriginForSession(CustomTabsSessionToken session, int clientUid, + org.chromium.chrome.browser.browserservices.Origin origin) { + return verifyOriginForSession(session, clientUid, (Origin) origin); + } + public int postMessage(CustomTabsSessionToken session, String message, Bundle extras) { int result; if (!mWarmupHasBeenCalled.get()) result = CustomTabsService.RESULT_FAILURE_DISALLOWED;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnectionService.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnectionService.java index 0cf4d276..1ebfd9f 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnectionService.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnectionService.java
@@ -14,9 +14,9 @@ import androidx.browser.customtabs.CustomTabsService; import androidx.browser.customtabs.CustomTabsSessionToken; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer; import org.chromium.chrome.browser.init.ProcessInitializationHandler; +import org.chromium.components.embedder_support.util.Origin; import java.util.List;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/settings/homepage/HomepageEditor.java b/chrome/android/java/src/org/chromium/chrome/browser/homepage/settings/HomepageEditor.java similarity index 98% rename from chrome/android/java/src/org/chromium/chrome/browser/settings/homepage/HomepageEditor.java rename to chrome/android/java/src/org/chromium/chrome/browser/homepage/settings/HomepageEditor.java index b8def92c..5efd4a5 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/settings/homepage/HomepageEditor.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/homepage/settings/HomepageEditor.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.settings.homepage; +package org.chromium.chrome.browser.homepage.settings; import android.os.Bundle; import android.text.Editable;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/settings/homepage/HomepageMetricsEnums.java b/chrome/android/java/src/org/chromium/chrome/browser/homepage/settings/HomepageMetricsEnums.java similarity index 97% rename from chrome/android/java/src/org/chromium/chrome/browser/settings/homepage/HomepageMetricsEnums.java rename to chrome/android/java/src/org/chromium/chrome/browser/homepage/settings/HomepageMetricsEnums.java index 3084079..2d95728 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/settings/homepage/HomepageMetricsEnums.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/homepage/settings/HomepageMetricsEnums.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.settings.homepage; +package org.chromium.chrome.browser.homepage.settings; import androidx.annotation.IntDef;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/settings/homepage/HomepageSettings.java b/chrome/android/java/src/org/chromium/chrome/browser/homepage/settings/HomepageSettings.java similarity index 97% rename from chrome/android/java/src/org/chromium/chrome/browser/settings/homepage/HomepageSettings.java rename to chrome/android/java/src/org/chromium/chrome/browser/homepage/settings/HomepageSettings.java index 92505ee..6b98884 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/settings/homepage/HomepageSettings.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/homepage/settings/HomepageSettings.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.settings.homepage; +package org.chromium.chrome.browser.homepage.settings; import android.os.Bundle; @@ -14,14 +14,14 @@ import org.chromium.chrome.R; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.homepage.HomepagePolicyManager; +import org.chromium.chrome.browser.homepage.settings.RadioButtonGroupHomepagePreference.HomepageOption; +import org.chromium.chrome.browser.homepage.settings.RadioButtonGroupHomepagePreference.PreferenceValues; import org.chromium.chrome.browser.ntp.NewTabPage; import org.chromium.chrome.browser.partnercustomizations.HomepageManager; import org.chromium.chrome.browser.settings.ChromeSwitchPreference; import org.chromium.chrome.browser.settings.ManagedPreferenceDelegate; import org.chromium.chrome.browser.settings.SettingsUtils; import org.chromium.chrome.browser.settings.TextMessagePreference; -import org.chromium.chrome.browser.settings.homepage.RadioButtonGroupHomepagePreference.HomepageOption; -import org.chromium.chrome.browser.settings.homepage.RadioButtonGroupHomepagePreference.PreferenceValues; import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarVariationManager; import org.chromium.components.url_formatter.UrlFormatter;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/settings/homepage/RadioButtonGroupHomepagePreference.java b/chrome/android/java/src/org/chromium/chrome/browser/homepage/settings/RadioButtonGroupHomepagePreference.java similarity index 99% rename from chrome/android/java/src/org/chromium/chrome/browser/settings/homepage/RadioButtonGroupHomepagePreference.java rename to chrome/android/java/src/org/chromium/chrome/browser/homepage/settings/RadioButtonGroupHomepagePreference.java index 6ea4c0eb..a30c301 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/settings/homepage/RadioButtonGroupHomepagePreference.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/homepage/settings/RadioButtonGroupHomepagePreference.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.settings.homepage; +package org.chromium.chrome.browser.homepage.settings; import android.content.Context; import android.util.AttributeSet;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java index 9ea8a61a..9399588 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java
@@ -29,12 +29,38 @@ public abstract class InfoBar implements InfoBarInteractionHandler, InfoBarUiItem { private static final String TAG = "InfoBar"; + /** + * Interface for InfoBar to interact with its container. + */ + public interface Container { + /** + * @return True if the infobar is in front. + */ + boolean isFrontInfoBar(InfoBar infoBar); + + /** + * Remove the infobar from its container. + * @param infoBar InfoBar to remove from the View hierarchy. + */ + void removeInfoBar(InfoBar infoBar); + + /** + * Notifies that an infobar's View ({@link InfoBar#getView}) has changed. + */ + void notifyInfoBarViewChanged(); + + /** + * @return True if the container's destroy() method has been called. + */ + boolean isDestroyed(); + } + private final int mIconDrawableId; private final Bitmap mIconBitmap; private final @ColorRes int mIconTintId; private final CharSequence mMessage; - private @Nullable InfoBarContainer mContainer; + private @Nullable Container mContainer; private @Nullable View mView; private @Nullable Context mContext; @@ -205,7 +231,7 @@ private boolean closeInfoBar() { if (!mIsDismissed) { mIsDismissed = true; - if (!mContainer.hasBeenDestroyed()) { + if (!mContainer.isDestroyed()) { // If the container was destroyed, it's already been emptied of all its infobars. onStartedHiding(); mContainer.removeInfoBar(this); @@ -223,7 +249,7 @@ * infobars). */ public boolean isFrontInfoBar() { - return mContainer.getFrontInfoBar() == this; + return mContainer.isFrontInfoBar(this); } /** @@ -236,7 +262,7 @@ return mNativeInfoBarPtr; } - void setInfoBarContainer(InfoBarContainer container) { + void setContainer(Container container) { mContainer = container; }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java index 8675326..3a82830 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java
@@ -37,7 +37,7 @@ * When initiated from native code, special code is needed to keep the Java and native infobar in * sync, see NativeInfoBar. */ -public class InfoBarContainer implements UserData, KeyboardVisibilityListener { +public class InfoBarContainer implements UserData, KeyboardVisibilityListener, InfoBar.Container { private static final String TAG = "InfoBarContainer"; private static final Class<InfoBarContainer> USER_DATA_KEY = InfoBarContainer.class; @@ -291,7 +291,7 @@ } infoBar.setContext(mInfoBarContainerView.getContext()); - infoBar.setInfoBarContainer(this); + infoBar.setContainer(this); // We notify observers immediately (before the animation starts). for (InfoBarContainerObserver observer : mObservers) { @@ -317,10 +317,7 @@ addInfoBar(infoBar); } - /** - * Notifies that an infobar's View ({@link InfoBar#getView}) has changed. If the infobar is - * visible, a view swapping animation will be run. - */ + @Override public void notifyInfoBarViewChanged() { assert !mDestroyed; if (mInfoBarContainerView != null) mInfoBarContainerView.notifyInfoBarViewChanged(); @@ -341,12 +338,8 @@ return mInfoBarContainerView != null ? mInfoBarContainerView.getVisibility() : View.GONE; } - /** - * Called by {@link InfoBar} to remove itself from the view hierarchy. - * - * @param infoBar InfoBar to remove from the View hierarchy. - */ - void removeInfoBar(InfoBar infoBar) { + @Override + public void removeInfoBar(InfoBar infoBar) { assert !mDestroyed; if (!mInfoBars.remove(infoBar)) { @@ -364,11 +357,8 @@ mInfoBarContainerView.removeInfoBar(infoBar); } - /** - * @return True when this container has been emptied and its native counterpart has been - * destroyed. - */ - public boolean hasBeenDestroyed() { + @Override + public boolean isDestroyed() { return mDestroyed; } @@ -542,13 +532,10 @@ } } - /** - * @return The infobar in front. - */ - @Nullable - InfoBar getFrontInfoBar() { - if (mInfoBars.isEmpty()) return null; - return mInfoBars.get(0); + @Override + public boolean isFrontInfoBar(InfoBar infoBar) { + if (mInfoBars.isEmpty()) return false; + return mInfoBars.get(0) == infoBar; } /**
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java index c17be854..e5fb55d8 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
@@ -183,7 +183,7 @@ } }); - Profile profile = Profile.getLastUsedProfile(); + Profile profile = Profile.getLastUsedRegularProfile(); OfflinePageBridge offlinePageBridge = SuggestionsDependencyFactory.getInstance().getOfflinePageBridge(profile);
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/page_info/PermissionParamsListBuilder.java b/chrome/android/java/src/org/chromium/chrome/browser/page_info/PermissionParamsListBuilder.java index 2932fa6..d471aff6 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/page_info/PermissionParamsListBuilder.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/page_info/PermissionParamsListBuilder.java
@@ -17,13 +17,13 @@ import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.Callback; import org.chromium.chrome.R; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.permissiondelegation.TrustedWebActivityPermissionManager; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.site_settings.ContentSettingValues; import org.chromium.chrome.browser.site_settings.ContentSettingsResources; import org.chromium.chrome.browser.site_settings.WebsitePreferenceBridge; import org.chromium.components.content_settings.ContentSettingsType; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.components.location.LocationUtils; import org.chromium.components.page_info.PageInfoView; import org.chromium.components.page_info.SystemSettingsActivityRequiredListener;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/partnercustomizations/HomepageManager.java b/chrome/android/java/src/org/chromium/chrome/browser/partnercustomizations/HomepageManager.java index 8aa58321..c749d8a 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/partnercustomizations/HomepageManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/partnercustomizations/HomepageManager.java
@@ -15,11 +15,11 @@ import org.chromium.chrome.browser.flags.CachedFeatureFlags; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.homepage.HomepagePolicyManager; +import org.chromium.chrome.browser.homepage.settings.HomepageMetricsEnums.HomeButtonPreferenceState; +import org.chromium.chrome.browser.homepage.settings.HomepageMetricsEnums.HomepageLocationType; import org.chromium.chrome.browser.ntp.NewTabPage; import org.chromium.chrome.browser.preferences.ChromePreferenceKeys; import org.chromium.chrome.browser.preferences.SharedPreferencesManager; -import org.chromium.chrome.browser.settings.homepage.HomepageMetricsEnums.HomeButtonPreferenceState; -import org.chromium.chrome.browser.settings.homepage.HomepageMetricsEnums.HomepageLocationType; import org.chromium.components.embedder_support.util.UrlConstants; /**
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java index 417a3c0..52a60091 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
@@ -1370,8 +1370,8 @@ URI url, PaymentHandlerWebContentsObserver paymentHandlerWebContentsObserver) { assert mInvokedPaymentApp != null; assert mInvokedPaymentApp instanceof ServiceWorkerPaymentApp; - assert org.chromium.chrome.browser.browserservices.Origin.create(url.toString()) - .equals(org.chromium.chrome.browser.browserservices.Origin.create( + assert org.chromium.components.embedder_support.util.Origin.create(url.toString()) + .equals(org.chromium.components.embedder_support.util.Origin.create( ((ServiceWorkerPaymentApp) mInvokedPaymentApp).getScope().toString())); if (mPaymentHandlerUi != null) return false;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/send_tab_to_self/NotificationManager.java b/chrome/android/java/src/org/chromium/chrome/browser/send_tab_to_self/NotificationManager.java index cec525262..6c07225 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/send_tab_to_self/NotificationManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/send_tab_to_self/NotificationManager.java
@@ -63,21 +63,22 @@ final String action = intent.getAction(); final String guid = IntentUtils.safeGetStringExtra(intent, NOTIFICATION_GUID_EXTRA); + // TODO(https://crbug.com/1041781): Use the current profile (i.e., + // regular profile or incognito profile) instead of always using + // regular profile. It is wrong and need to be fixed. + final Profile profile = Profile.getLastUsedRegularProfile(); switch (action) { case NOTIFICATION_ACTION_TAP: openUrl(intent.getData()); hideNotification(guid, InteractionType.OPENED); - SendTabToSelfAndroidBridge.deleteEntry( - Profile.getLastUsedProfile(), guid); + SendTabToSelfAndroidBridge.deleteEntry(profile, guid); break; case NOTIFICATION_ACTION_DISMISS: hideNotification(guid, InteractionType.DISMISSED); - SendTabToSelfAndroidBridge.dismissEntry( - Profile.getLastUsedProfile(), guid); + SendTabToSelfAndroidBridge.dismissEntry(profile, guid); break; case NOTIFICATION_ACTION_TIMEOUT: - SendTabToSelfAndroidBridge.dismissEntry( - Profile.getLastUsedProfile(), guid); + SendTabToSelfAndroidBridge.dismissEntry(profile, guid); break; } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/site_settings/SingleWebsiteSettings.java b/chrome/android/java/src/org/chromium/chrome/browser/site_settings/SingleWebsiteSettings.java index e2be311..a02b573 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/site_settings/SingleWebsiteSettings.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/site_settings/SingleWebsiteSettings.java
@@ -28,7 +28,6 @@ import org.chromium.base.Callback; import org.chromium.base.metrics.RecordHistogram; import org.chromium.chrome.R; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.permissiondelegation.TrustedWebActivityPermissionManager; import org.chromium.chrome.browser.notifications.channels.SiteChannelsManager; import org.chromium.chrome.browser.profiles.Profile; @@ -37,6 +36,7 @@ import org.chromium.chrome.browser.settings.ManagedPreferencesUtils; import org.chromium.chrome.browser.settings.SettingsUtils; import org.chromium.components.content_settings.ContentSettingsType; +import org.chromium.components.embedder_support.util.Origin; import java.util.Arrays; import java.util.Collection;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/HomeButton.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/HomeButton.java index 74c5fde..0b9ef9e 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/HomeButton.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/HomeButton.java
@@ -28,10 +28,10 @@ import org.chromium.chrome.browser.compositor.layouts.OverviewModeState; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.homepage.HomepagePolicyManager; +import org.chromium.chrome.browser.homepage.settings.HomepageSettings; import org.chromium.chrome.browser.ntp.NewTabPage; import org.chromium.chrome.browser.partnercustomizations.HomepageManager; import org.chromium.chrome.browser.settings.SettingsLauncher; -import org.chromium.chrome.browser.settings.homepage.HomepageSettings; import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarConfiguration; import org.chromium.ui.widget.ChromeImageButton;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java index 8cac2d1..f1b5eec 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java
@@ -375,6 +375,11 @@ mActivityTabProvider) { @Override public void onObservingDifferentTab(Tab tab) { + // ActivityTabProvider will null out the tab passed to onObservingDifferentTab when + // the tab is non-interactive (e.g. when entering the TabSwitcher), but in those + // cases we actually still want to use the most recently selected tab. + if (tab == null) return; + refreshSelectedTab(tab); } @@ -585,14 +590,17 @@ public void onControlsOffsetChanged(int topOffset, int topControlsMinHeightOffset, int bottomOffset, int bottomControlsMinHeightOffset, boolean needsAnimate) { // For now, this is only useful for the offline indicator v2 feature. - if (ChromeFeatureList.isInitialized() - && !ChromeFeatureList.isEnabled(ChromeFeatureList.OFFLINE_INDICATOR_V2)) { + if (!ChromeFeatureList.isInitialized() + || !ChromeFeatureList.isEnabled(ChromeFeatureList.OFFLINE_INDICATOR_V2)) { return; } // If the browser controls can't be animated, we shouldn't listen for the offset // changes. - if (!mCanAnimateNativeBrowserControls.get()) return; + if (mCanAnimateNativeBrowserControls == null + || !mCanAnimateNativeBrowserControls.get()) { + return; + } // Controls need to be offset to match the composited layer, which is // anchored at the bottom of the controls container. @@ -603,15 +611,18 @@ public void onTopControlsHeightChanged( int topControlsHeight, int topControlsMinHeight) { // For now, this is only useful for the offline indicator v2 feature. - if (ChromeFeatureList.isInitialized() - && !ChromeFeatureList.isEnabled(ChromeFeatureList.OFFLINE_INDICATOR_V2)) { + if (!ChromeFeatureList.isInitialized() + || !ChromeFeatureList.isEnabled(ChromeFeatureList.OFFLINE_INDICATOR_V2)) { return; } // If the browser controls can be animated, we shouldn't set the extra offset here. // Instead, that should happen when the animation starts (i.e. we get new offsets) // to prevent the Android view from jumping before the animation starts. - if (mCanAnimateNativeBrowserControls.get()) return; + if (mCanAnimateNativeBrowserControls == null + || mCanAnimateNativeBrowserControls.get()) { + return; + } // Controls need to be offset to match the composited layer, which is // anchored at the bottom of the controls container.
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/OriginVerifierTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/OriginVerifierTest.java index 582cdc7b..69166cf 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/OriginVerifierTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/OriginVerifierTest.java
@@ -26,6 +26,7 @@ import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.test.ChromeActivityTestRule; import org.chromium.chrome.test.ChromeJUnit4ClassRunner; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.content_public.browser.UiThreadTaskTraits; import org.chromium.content_public.browser.test.mock.MockWebContents; import org.chromium.content_public.browser.test.util.TestThreadUtils;
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClientTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClientTest.java index a40ba37..fa18eab2 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClientTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClientTest.java
@@ -35,6 +35,7 @@ import org.chromium.chrome.browser.dependency_injection.ChromeAppComponent; import org.chromium.chrome.browser.notifications.NotificationUmaTracker; import org.chromium.chrome.browser.notifications.StandardNotificationBuilder; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.content_public.browser.UiThreadTaskTraits; import java.util.Collections;
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityTestUtil.java b/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityTestUtil.java index 54d8955..62300720 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityTestUtil.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityTestUtil.java
@@ -15,6 +15,7 @@ import org.chromium.chrome.browser.customtabs.CustomTabsConnection; import org.chromium.chrome.browser.customtabs.CustomTabsTestUtils; import org.chromium.chrome.browser.tab.TabBrowserControlsConstraintsHelper; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.common.BrowserControlsState;
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPermissionsTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPermissionsTest.java index 5da89db..2f56ff58 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPermissionsTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPermissionsTest.java
@@ -22,11 +22,11 @@ import org.chromium.base.test.util.CommandLineFlags; import org.chromium.chrome.browser.ChromeApplication; import org.chromium.chrome.browser.background_sync.BackgroundSyncPwaDetector; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.customtabs.CustomTabActivityTestRule; import org.chromium.chrome.browser.customtabs.CustomTabsTestUtils; import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.test.ChromeJUnit4ClassRunner; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.net.test.EmbeddedTestServer; import org.chromium.net.test.ServerCertificate;
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPreferencesUiTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPreferencesUiTest.java index b5846f4..a802fd5 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPreferencesUiTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/browserservices/permissiondelegation/TrustedWebActivityPreferencesUiTest.java
@@ -18,7 +18,6 @@ import org.chromium.base.test.util.RetryOnFailure; import org.chromium.chrome.browser.ChromeActivity; import org.chromium.chrome.browser.ChromeApplication; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.browser.settings.ChromeImageViewPreference; import org.chromium.chrome.browser.settings.ExpandablePreferenceGroup; @@ -31,6 +30,7 @@ import org.chromium.chrome.browser.site_settings.WebsiteAddress; import org.chromium.chrome.test.ChromeActivityTestRule; import org.chromium.chrome.test.ChromeJUnit4ClassRunner; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.content_public.browser.test.util.Criteria; import org.chromium.content_public.browser.test.util.CriteriaHelper; import org.chromium.content_public.browser.test.util.TestThreadUtils;
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/browsing_data/ClearBrowsingDataFragmentTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/browsing_data/ClearBrowsingDataFragmentTest.java index 45cdd34e..a790066f 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/browsing_data/ClearBrowsingDataFragmentTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/browsing_data/ClearBrowsingDataFragmentTest.java
@@ -31,7 +31,6 @@ import org.junit.runner.RunWith; import org.chromium.base.test.util.CommandLineFlags; -import org.chromium.base.test.util.DisableIf; import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.RetryOnFailure; @@ -278,6 +277,7 @@ */ @Test @LargeTest + @DisabledTest(message = "https://crbug.com/1062568") public void testDialogAboutOtherFormsOfBrowsingHistory() { // Sign in. SigninTestUtil.addAndSignInTestAccount(); @@ -397,7 +397,7 @@ @Test @MediumTest @Feature({"SiteEngagement"}) - @DisableIf.Build(sdk_is_greater_than = 25, message = "crbug.com/999361") + @DisabledTest(message = "https://crbug.com/999361 and https://crbug.com/1062568") public void testImportantSitesDialogNoFiltering() throws Exception { // Sign in. SigninTestUtil.addAndSignInTestAccount();
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/ClientManagerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/ClientManagerTest.java index c697a9c..7790229 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/ClientManagerTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/ClientManagerTest.java
@@ -10,6 +10,10 @@ import android.support.test.InstrumentationRegistry; import android.support.test.filters.SmallTest; +import androidx.browser.customtabs.CustomTabsService; +import androidx.browser.customtabs.CustomTabsSessionToken; +import androidx.browser.customtabs.PostMessageServiceConnection; + import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -21,18 +25,14 @@ import org.chromium.base.test.util.MetricsUtils; import org.chromium.base.test.util.RetryOnFailure; import org.chromium.chrome.browser.IntentHandler; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.OriginVerifier; import org.chromium.chrome.browser.browserservices.PostMessageHandler; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.content_public.browser.test.NativeLibraryTestRule; import org.chromium.content_public.browser.test.util.Criteria; import org.chromium.content_public.browser.test.util.CriteriaHelper; import org.chromium.content_public.browser.test.util.TestThreadUtils; -import androidx.browser.customtabs.CustomTabsService; -import androidx.browser.customtabs.CustomTabsSessionToken; -import androidx.browser.customtabs.PostMessageServiceConnection; - /** Tests for ClientManager. */ @RunWith(BaseJUnit4ClassRunner.class) public class ClientManagerTest {
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java index 3bbde85..3bc3033 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java
@@ -86,7 +86,6 @@ import org.chromium.chrome.browser.WarmupManager; import org.chromium.chrome.browser.browserservices.BrowserServicesIntentDataProvider; import org.chromium.chrome.browser.browserservices.BrowserServicesIntentDataProvider.CustomTabsUiType; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.OriginVerifier; import org.chromium.chrome.browser.browserservices.SessionDataHolder; import org.chromium.chrome.browser.customtabs.content.CustomTabActivityNavigationController.FinishReason; @@ -119,6 +118,7 @@ import org.chromium.chrome.test.util.ChromeTabUtils; import org.chromium.chrome.test.util.browser.LocationSettingsTestUtil; import org.chromium.chrome.test.util.browser.contextmenu.ContextMenuUtils; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.UiThreadTaskTraits; import org.chromium.content_public.browser.WebContentsObserver;
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/DetachedResourceRequestTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/DetachedResourceRequestTest.java index 392c34cf..6395e10 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/DetachedResourceRequestTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/DetachedResourceRequestTest.java
@@ -30,7 +30,6 @@ import org.chromium.base.test.util.CallbackHelper; import org.chromium.base.test.util.MetricsUtils.HistogramDelta; import org.chromium.chrome.browser.MockSafeBrowsingApiHandler; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.OriginVerifier; import org.chromium.chrome.browser.document.ChromeLauncherActivity; import org.chromium.chrome.browser.firstrun.FirstRunStatus; @@ -42,6 +41,7 @@ import org.chromium.chrome.test.util.browser.Features; import org.chromium.chrome.test.util.browser.Features.DisableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.components.safe_browsing.SafeBrowsingApiBridge; import org.chromium.content_public.browser.UiThreadTaskTraits; import org.chromium.content_public.browser.WebContents;
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadUtilsTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadUtilsTest.java index f28d0e8..4d5839c 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadUtilsTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadUtilsTest.java
@@ -12,22 +12,24 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.test.util.Feature; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.test.ChromeJUnit4ClassRunner; +import org.chromium.chrome.test.util.browser.Features; import org.chromium.components.offline_items_collection.OfflineItem.Progress; import org.chromium.components.offline_items_collection.OfflineItemProgressUnit; -import java.util.HashMap; - /** * Tests of {@link DownloadUtils}. */ @RunWith(ChromeJUnit4ClassRunner.class) +@Features.DisableFeatures(ChromeFeatureList.DOWNLOAD_FILE_PROVIDER) public class DownloadUtilsTest { private static final String OFFLINE_ITEM_TITLE = "Some Web Page Title.mhtml"; private static final String OFFLINE_ITEM_DESCRIPTION = "Our web page"; @@ -38,13 +40,12 @@ private static final String MULTIPART_RELATED = "multipart/related"; private static final String ITEM_ID = "42"; + @Rule + public TestRule mFeaturesProcessorRule = new Features.InstrumentationProcessor(); + @Before public void setUp() { RecordHistogram.setDisabledForTests(true); - - HashMap<String, Boolean> features = new HashMap<String, Boolean>(); - features.put(ChromeFeatureList.DOWNLOAD_FILE_PROVIDER, false); - ChromeFeatureList.setTestFeatures(features); } @After
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/homepage/HomepagePolicyIntegrationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/homepage/HomepagePolicyIntegrationTest.java index 625f9ef..be1605e 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/homepage/HomepagePolicyIntegrationTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/homepage/HomepagePolicyIntegrationTest.java
@@ -27,14 +27,14 @@ import org.chromium.chrome.browser.ChromeTabbedActivity; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.flags.ChromeSwitches; +import org.chromium.chrome.browser.homepage.settings.HomepageMetricsEnums.HomeButtonPreferenceState; +import org.chromium.chrome.browser.homepage.settings.HomepageMetricsEnums.HomepageLocationType; +import org.chromium.chrome.browser.homepage.settings.HomepageSettings; import org.chromium.chrome.browser.partnercustomizations.HomepageManager; import org.chromium.chrome.browser.preferences.ChromePreferenceKeys; import org.chromium.chrome.browser.preferences.SharedPreferencesManager; import org.chromium.chrome.browser.settings.ChromeSwitchPreference; import org.chromium.chrome.browser.settings.SettingsActivity; -import org.chromium.chrome.browser.settings.homepage.HomepageMetricsEnums.HomeButtonPreferenceState; -import org.chromium.chrome.browser.settings.homepage.HomepageMetricsEnums.HomepageLocationType; -import org.chromium.chrome.browser.settings.homepage.HomepageSettings; import org.chromium.chrome.browser.toolbar.HomeButton; import org.chromium.chrome.browser.toolbar.ToolbarManager; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/settings/homepage/HomepageSettingsFragmentTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/homepage/settings/HomepageSettingsFragmentTest.java similarity index 99% rename from chrome/android/javatests/src/org/chromium/chrome/browser/settings/homepage/HomepageSettingsFragmentTest.java rename to chrome/android/javatests/src/org/chromium/chrome/browser/homepage/settings/HomepageSettingsFragmentTest.java index 616f7e6..ae2a5ed7 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/settings/homepage/HomepageSettingsFragmentTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/homepage/settings/HomepageSettingsFragmentTest.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.settings.homepage; +package org.chromium.chrome.browser.homepage.settings; import android.support.test.filters.SmallTest; import android.view.View; @@ -21,13 +21,13 @@ import org.chromium.chrome.browser.flags.CachedFeatureFlags; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.homepage.HomepageTestRule; +import org.chromium.chrome.browser.homepage.settings.HomepageMetricsEnums.HomepageLocationType; import org.chromium.chrome.browser.ntp.NewTabPage; import org.chromium.chrome.browser.partnercustomizations.HomepageManager; import org.chromium.chrome.browser.partnercustomizations.PartnerBrowserCustomizations; import org.chromium.chrome.browser.settings.ChromeSwitchPreference; import org.chromium.chrome.browser.settings.SettingsActivity; import org.chromium.chrome.browser.settings.TextMessagePreference; -import org.chromium.chrome.browser.settings.homepage.HomepageMetricsEnums.HomepageLocationType; import org.chromium.chrome.test.ChromeActivityTestRule; import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.util.browser.Features;
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/settings/homepage/HomepageSettingsFragmentWithEditorTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/homepage/settings/HomepageSettingsFragmentWithEditorTest.java similarity index 98% rename from chrome/android/javatests/src/org/chromium/chrome/browser/settings/homepage/HomepageSettingsFragmentWithEditorTest.java rename to chrome/android/javatests/src/org/chromium/chrome/browser/homepage/settings/HomepageSettingsFragmentWithEditorTest.java index a7acb9d..5879902 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/settings/homepage/HomepageSettingsFragmentWithEditorTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/homepage/settings/HomepageSettingsFragmentWithEditorTest.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.settings.homepage; +package org.chromium.chrome.browser.homepage.settings; import android.support.test.filters.SmallTest;
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/partnercustomizations/PartnerHomepageIntegrationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/partnercustomizations/PartnerHomepageIntegrationTest.java index a52504c..8fef4631 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/partnercustomizations/PartnerHomepageIntegrationTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/partnercustomizations/PartnerHomepageIntegrationTest.java
@@ -27,10 +27,10 @@ import org.chromium.chrome.R; import org.chromium.chrome.browser.ChromeTabbedActivity; import org.chromium.chrome.browser.flags.ChromeSwitches; +import org.chromium.chrome.browser.homepage.settings.HomepageEditor; +import org.chromium.chrome.browser.homepage.settings.HomepageSettings; import org.chromium.chrome.browser.settings.ChromeSwitchPreference; import org.chromium.chrome.browser.settings.SettingsActivity; -import org.chromium.chrome.browser.settings.homepage.HomepageEditor; -import org.chromium.chrome.browser.settings.homepage.HomepageSettings; import org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver; import org.chromium.chrome.browser.tabmodel.TabList; import org.chromium.chrome.browser.tabmodel.TabModel;
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/partnercustomizations/PartnerHomepageUnitTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/partnercustomizations/PartnerHomepageUnitTest.java index 46c4b45..c99a462 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/partnercustomizations/PartnerHomepageUnitTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/partnercustomizations/PartnerHomepageUnitTest.java
@@ -20,7 +20,6 @@ import org.junit.runner.RunWith; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.RetryOnFailure; @@ -57,7 +56,6 @@ public void setUp() { mHomepageManager = HomepageManager.getInstance(); RecordHistogram.setDisabledForTests(true); - RecordUserAction.setDisabledForTests(true); Assert.assertNotNull(mHomepageManager); Assert.assertNotSame( @@ -68,7 +66,6 @@ @After public void tearDown() { RecordHistogram.setDisabledForTests(false); - RecordUserAction.setDisabledForTests(false); } @Test
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/site_settings/SiteSettingsTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/site_settings/SiteSettingsTest.java index 1004b75..d65d37da 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/site_settings/SiteSettingsTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/site_settings/SiteSettingsTest.java
@@ -28,7 +28,6 @@ import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.RetryOnFailure; import org.chromium.chrome.browser.ChromeActivity; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.browser.infobar.InfoBarContainer; @@ -48,6 +47,7 @@ import org.chromium.chrome.test.util.browser.Features.EnableFeatures; import org.chromium.chrome.test.util.browser.LocationSettingsTestUtil; import org.chromium.components.content_settings.ContentSettingsType; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.components.permissions.nfc.NfcSystemLevelSetting; import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.common.ContentSwitches;
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/HomeButtonTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/HomeButtonTest.java index 500f103..fa6e726 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/HomeButtonTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/HomeButtonTest.java
@@ -28,9 +28,9 @@ import org.chromium.chrome.R; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.homepage.HomepageTestRule; +import org.chromium.chrome.browser.homepage.settings.HomepageSettings; import org.chromium.chrome.browser.partnercustomizations.HomepageManager; import org.chromium.chrome.browser.settings.SettingsLauncher; -import org.chromium.chrome.browser.settings.homepage.HomepageSettings; import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.util.browser.Features; import org.chromium.chrome.test.util.browser.Features.DisableFeatures;
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/ChromeActionModeCallbackTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/ChromeActionModeCallbackTest.java index b7e1e5ce..adaf0fa 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/ChromeActionModeCallbackTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/ChromeActionModeCallbackTest.java
@@ -28,7 +28,6 @@ import org.chromium.base.Callback; import org.chromium.base.PackageManagerUtils; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.chrome.browser.firstrun.FirstRunStatus; import org.chromium.chrome.browser.locale.LocaleManager; @@ -75,7 +74,6 @@ @Before public void setUp() { MockitoAnnotations.initMocks(this); - RecordUserAction.setDisabledForTests(true); mActionModeCallback = Mockito.spy(new TestChromeActionModeCallback(mTab, mActionModeCallbackHelper)); @@ -84,7 +82,6 @@ @After public void tearDown() { FirstRunStatus.setFirstRunFlowComplete(false); - RecordUserAction.setDisabledForTests(false); } @Test
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/background_sync/BackgroundSyncBackgroundTaskSchedulerTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/background_sync/BackgroundSyncBackgroundTaskSchedulerTest.java index 0f55c181..6c87f01 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/background_sync/BackgroundSyncBackgroundTaskSchedulerTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/background_sync/BackgroundSyncBackgroundTaskSchedulerTest.java
@@ -16,6 +16,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; @@ -30,21 +31,23 @@ import org.chromium.chrome.browser.background_sync.BackgroundSyncBackgroundTaskScheduler.BackgroundSyncTask; import org.chromium.chrome.browser.background_task_scheduler.ChromeBackgroundTaskFactory; import org.chromium.chrome.browser.flags.ChromeFeatureList; +import org.chromium.chrome.test.util.browser.Features; import org.chromium.components.background_task_scheduler.BackgroundTaskScheduler; import org.chromium.components.background_task_scheduler.BackgroundTaskSchedulerFactory; import org.chromium.components.background_task_scheduler.TaskIds; import org.chromium.components.background_task_scheduler.TaskInfo; -import java.util.HashMap; import java.util.concurrent.TimeUnit; /** Unit tests for BackgroundSyncBackgroundTaskScheduler. */ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE) +@Features.EnableFeatures(ChromeFeatureList.BACKGROUND_TASK_SCHEDULER_FOR_BACKGROUND_SYNC) public class BackgroundSyncBackgroundTaskSchedulerTest { @Rule + public TestRule mFeaturesProcessorRule = new Features.JUnitProcessor(); + @Rule public DisableHistogramsRule mDisableHistogramsRule = new DisableHistogramsRule(); - @Mock private BackgroundTaskScheduler mTaskScheduler; @Captor @@ -58,9 +61,6 @@ MockitoAnnotations.initMocks(this); BackgroundTaskSchedulerFactory.setSchedulerForTesting(mTaskScheduler); ChromeBackgroundTaskFactory.setAsDefault(); - HashMap<String, Boolean> features = new HashMap<String, Boolean>(); - features.put(ChromeFeatureList.BACKGROUND_TASK_SCHEDULER_FOR_BACKGROUND_SYNC, true); - ChromeFeatureList.setTestFeatures(features); doReturn(true) .when(mTaskScheduler) .schedule(eq(ContextUtils.getApplicationContext()), mTaskInfo.capture());
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/background_sync/BackgroundSyncBackgroundTaskTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/background_sync/BackgroundSyncBackgroundTaskTest.java index 9b343fd8..cd48b17b 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/background_sync/BackgroundSyncBackgroundTaskTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/background_sync/BackgroundSyncBackgroundTaskTest.java
@@ -19,6 +19,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; @@ -37,6 +38,7 @@ import org.chromium.base.test.util.JniMocker; import org.chromium.chrome.browser.ShadowDeviceConditions; import org.chromium.chrome.browser.flags.ChromeFeatureList; +import org.chromium.chrome.test.util.browser.Features; import org.chromium.components.background_task_scheduler.BackgroundTask; import org.chromium.components.background_task_scheduler.BackgroundTaskScheduler; import org.chromium.components.background_task_scheduler.BackgroundTaskSchedulerFactory; @@ -46,13 +48,12 @@ import org.chromium.components.background_task_scheduler.TaskParameters; import org.chromium.net.ConnectionType; -import java.util.HashMap; - /** * Unit tests for BackgroundSyncBackgroundTask. */ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE, shadows = {ShadowDeviceConditions.class}) +@Features.EnableFeatures(ChromeFeatureList.BACKGROUND_TASK_SCHEDULER_FOR_BACKGROUND_SYNC) public class BackgroundSyncBackgroundTaskTest { private static final String IS_LOW_END_DEVICE_SWITCH = "--" + BaseSwitches.ENABLE_LOW_END_DEVICE_MODE; @@ -61,6 +62,9 @@ public DisableHistogramsRule mDisableHistogramsRule = new DisableHistogramsRule(); @Rule + public TestRule mFeaturesProcessorRule = new Features.JUnitProcessor(); + + @Rule public JniMocker mocker = new JniMocker(); private Bundle mTaskExtras; @@ -82,9 +86,6 @@ MockitoAnnotations.initMocks(this); BackgroundTaskSchedulerFactory.setSchedulerForTesting(mTaskScheduler); - HashMap<String, Boolean> features = new HashMap<>(); - features.put(ChromeFeatureList.BACKGROUND_TASK_SCHEDULER_FOR_BACKGROUND_SYNC, true); - ChromeFeatureList.setTestFeatures(features); mTaskExtras = new Bundle(); doReturn(true)
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/ClientAppBroadcastReceiverTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/ClientAppBroadcastReceiverTest.java index 458740e..5a27bd3e 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/ClientAppBroadcastReceiverTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/ClientAppBroadcastReceiverTest.java
@@ -30,6 +30,7 @@ import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.base.test.util.Feature; import org.chromium.chrome.browser.browserservices.permissiondelegation.NotificationPermissionUpdater; +import org.chromium.components.embedder_support.util.Origin; import java.util.Arrays; import java.util.HashSet;
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/ClientAppDataRegisterTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/ClientAppDataRegisterTest.java index 9e5c9995..0e98d4ec 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/ClientAppDataRegisterTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/ClientAppDataRegisterTest.java
@@ -12,6 +12,7 @@ import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.base.test.util.Feature; +import org.chromium.components.embedder_support.util.Origin; import java.util.Set;
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationChannelPreserverTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationChannelPreserverTest.java index bc54af7..6c4ad07 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationChannelPreserverTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationChannelPreserverTest.java
@@ -22,10 +22,10 @@ import org.robolectric.annotation.Config; import org.chromium.base.test.BaseRobolectricTestRunner; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.notifications.NotificationChannelStatus; import org.chromium.chrome.browser.notifications.channels.ChannelDefinitions; import org.chromium.chrome.browser.notifications.channels.SiteChannelsManager; +import org.chromium.components.embedder_support.util.Origin; /** * Tests for {@link NotificationChannelPreserverTest}.
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationPermissionUpdaterTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationPermissionUpdaterTest.java index 321b654..64fef3db 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationPermissionUpdaterTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationPermissionUpdaterTest.java
@@ -31,11 +31,11 @@ import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.base.test.util.Feature; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.TrustedWebActivityClient; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.test.util.browser.Features; import org.chromium.chrome.test.util.browser.Features.EnableFeatures; +import org.chromium.components.embedder_support.util.Origin; /** * Tests for {@link NotificationPermissionUpdater}.
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/ClientAppDataRecorderTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/ClientAppDataRecorderTest.java index df673e19..a19baf66 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/ClientAppDataRecorderTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/ClientAppDataRecorderTest.java
@@ -30,7 +30,7 @@ import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.base.test.util.Feature; import org.chromium.chrome.browser.browserservices.ClientAppDataRegister; -import org.chromium.chrome.browser.browserservices.Origin; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.components.embedder_support.util.ShadowUrlUtilities; /**
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/CurrentPageVerifierTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/CurrentPageVerifierTest.java index 83ab3ae4..9d295cc 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/CurrentPageVerifierTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/CurrentPageVerifierTest.java
@@ -21,7 +21,6 @@ import org.robolectric.annotation.Config; import org.chromium.base.test.BaseRobolectricTestRunner; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.trustedwebactivityui.controller.CurrentPageVerifier.VerificationStatus; import org.chromium.chrome.browser.customtabs.CustomTabIntentDataProvider; import org.chromium.chrome.browser.customtabs.content.CustomTabActivityTabProvider; @@ -33,6 +32,7 @@ import org.chromium.chrome.test.util.browser.Features; import org.chromium.chrome.test.util.browser.Features.DisableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.content_public.browser.NavigationHandle; import java.util.Collections;
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TestVerifier.java b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TestVerifier.java index 98b6370..4c4f190f 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TestVerifier.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TestVerifier.java
@@ -5,7 +5,7 @@ package org.chromium.chrome.browser.browserservices.trustedwebactivityui.controller; import org.chromium.base.Promise; -import org.chromium.chrome.browser.browserservices.Origin; +import org.chromium.components.embedder_support.util.Origin; import java.util.HashMap; import java.util.HashSet;
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TwaVerifierTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TwaVerifierTest.java index 6e95acd0..9b93efb 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TwaVerifierTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/trustedwebactivityui/controller/TwaVerifierTest.java
@@ -28,7 +28,6 @@ import org.chromium.base.Promise; import org.chromium.base.test.BaseRobolectricTestRunner; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.OriginVerifier; import org.chromium.chrome.browser.browserservices.OriginVerifier.OriginVerificationListener; import org.chromium.chrome.browser.customtabs.CustomTabIntentDataProvider; @@ -38,6 +37,7 @@ import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher; import org.chromium.chrome.test.util.browser.Features; import org.chromium.chrome.test.util.browser.Features.DisableFeatures; +import org.chromium.components.embedder_support.util.Origin; import java.util.Collections;
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/customtabs/content/CustomTabActivityContentTestEnvironment.java b/chrome/android/junit/src/org/chromium/chrome/browser/customtabs/content/CustomTabActivityContentTestEnvironment.java index 8a91baf..21a8dae3 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/customtabs/content/CustomTabActivityContentTestEnvironment.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/customtabs/content/CustomTabActivityContentTestEnvironment.java
@@ -27,7 +27,6 @@ import org.chromium.base.UserDataHost; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.chrome.browser.ActivityTabProvider; import org.chromium.chrome.browser.ActivityTabProvider.ActivityTabObserver; import org.chromium.chrome.browser.ChromeActivity; @@ -111,7 +110,6 @@ @Override protected void starting(Description description) { RecordHistogram.setDisabledForTests(true); - RecordUserAction.setDisabledForTests(true); MockitoAnnotations.initMocks(this); tabFromFactory = prepareTab(); @@ -137,7 +135,6 @@ @Override protected void finished(Description description) { RecordHistogram.setDisabledForTests(false); - RecordUserAction.setDisabledForTests(false); AsyncTabParamsManager.getAsyncTabParams().clear(); ShadowExternalNavigationDelegateImpl.setWillChromeHandleIntent(false); }
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/feed/action/FeedActionHandlerTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/feed/action/FeedActionHandlerTest.java index 03133dbd..e689436c 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/feed/action/FeedActionHandlerTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/feed/action/FeedActionHandlerTest.java
@@ -18,11 +18,11 @@ import static org.mockito.Mockito.when; import android.support.test.filters.SmallTest; -import android.util.ArrayMap; -import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; @@ -40,6 +40,7 @@ import org.chromium.chrome.browser.offlinepages.OfflinePageBridge; import org.chromium.chrome.browser.suggestions.SuggestionsNavigationDelegate; import org.chromium.chrome.browser.tab.TabImpl; +import org.chromium.chrome.test.util.browser.Features; import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.NavigationController; import org.chromium.content_public.browser.WebContents; @@ -47,17 +48,20 @@ import org.chromium.ui.mojom.WindowOpenDisposition; import java.util.Collections; -import java.util.Map; /** * Unit tests for {@link FeedActionHandler}. */ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE) +@Features.EnableFeatures(ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS) public class FeedActionHandlerTest { private static final String TEST_URL = "http://www.one.com/"; private static final Long OFFLINE_ID = 12345L; + @Rule + public TestRule mFeaturesProcessorRule = new Features.JUnitProcessor(); + @Mock private SuggestionsNavigationDelegate mDelegate; @Mock @@ -126,10 +130,6 @@ }) .when(mWebContents) .addObserver(mWebContentsObserverCaptor.capture()); - - Map<String, Boolean> featureMap = new ArrayMap<>(); - featureMap.put(ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, true); - ChromeFeatureList.setTestFeatures(featureMap); } private void answerWithGoodParams() { @@ -150,11 +150,6 @@ mLoadUrlParamsCallbackCaptor.capture()); } - @After - public void tearDown() { - ChromeFeatureList.setTestFeatures(null); - } - @Test @SmallTest public void testOpenUrlOffline() {
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencerTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencerTest.java index 9941d670..84bd836b 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencerTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencerTest.java
@@ -15,7 +15,9 @@ import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.robolectric.Robolectric; import org.robolectric.android.controller.ActivityController; @@ -26,12 +28,11 @@ import org.chromium.base.test.util.Feature; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarConfiguration; +import org.chromium.chrome.test.util.browser.Features; import org.chromium.components.signin.ChildAccountStatus; import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * Tests FirstRunFlowSequencer which contains the core logic of what should be shown during the @@ -39,7 +40,11 @@ */ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE, shadows = {ShadowMultiDex.class}) +@Features.EnableFeatures(ChromeFeatureList.CHROME_DUET) public class FirstRunFlowSequencerTest { + @Rule + public TestRule mFeaturesProcessorRule = new Features.JUnitProcessor(); + /** Information for Google OS account */ private static final String GOOGLE_ACCOUNT_TYPE = "com.google"; private static final String DEFAULT_ACCOUNT = "test@gmail.com"; @@ -137,7 +142,6 @@ public void setUp() { mActivityController = Robolectric.buildActivity(Activity.class); mSequencer = new TestFirstRunFlowSequencer(mActivityController.setup().get()); - setupFeatureList(); } @After @@ -145,15 +149,6 @@ mActivityController.pause().stop().destroy(); } - // We need to initialize ChromeFeatureList here, otherwise test will crash/assert during - // FirstRunFlowSequencer::onNativeInitialized. - // TODO(crbug.com/1021705): Remove this method after duet fully launched. - private void setupFeatureList() { - Map<String, Boolean> featureList = new HashMap<>(); - featureList.put(ChromeFeatureList.CHROME_DUET, true); - ChromeFeatureList.setTestFeatures(featureList); - } - @Test @Feature({"FirstRun"}) public void testFirstRunComplete() {
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSectionTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSectionTest.java index ba7e423..46dee15 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSectionTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSectionTest.java
@@ -44,7 +44,6 @@ import org.robolectric.annotation.Config; import org.chromium.base.Callback; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.metrics.test.DisableHistogramsRule; import org.chromium.base.task.test.CustomShadowAsyncTask; import org.chromium.base.test.BaseRobolectricTestRunner; @@ -117,7 +116,6 @@ @Before public void setUp() { - RecordUserAction.setDisabledForTests(true); MockitoAnnotations.initMocks(this); mBridge = new FakeOfflinePageBridge(); @@ -144,7 +142,6 @@ @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); PrefServiceBridge.setInstanceForTesting(null); }
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/prefetch/OfflineNotificationBackgroundTaskUnitTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/prefetch/OfflineNotificationBackgroundTaskUnitTest.java index 94822de..48eb708 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/prefetch/OfflineNotificationBackgroundTaskUnitTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/prefetch/OfflineNotificationBackgroundTaskUnitTest.java
@@ -27,7 +27,9 @@ import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; @@ -49,6 +51,7 @@ import org.chromium.chrome.browser.init.BrowserParts; import org.chromium.chrome.browser.init.ChromeBrowserInitializer; import org.chromium.chrome.browser.offlinepages.OfflinePageBridge; +import org.chromium.chrome.test.util.browser.Features; import org.chromium.components.background_task_scheduler.BackgroundTaskScheduler; import org.chromium.components.background_task_scheduler.BackgroundTaskSchedulerFactory; import org.chromium.components.background_task_scheduler.TaskIds; @@ -59,12 +62,12 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; -import java.util.Map; import java.util.concurrent.TimeUnit; /** Unit tests for {@link OfflineNotificationBackgroundTask}. */ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE, shadows = {ShadowMultiDex.class, ShadowDeviceConditions.class}) +@Features.DisableFeatures(ChromeFeatureList.PREFETCH_NOTIFICATION_SCHEDULING_INTEGRATION) public class OfflineNotificationBackgroundTaskUnitTest { /** * Fake of BackgroundTaskScheduler system service. @@ -97,7 +100,8 @@ mTaskInfos = new HashMap<>(); } } - + @Rule + public TestRule mFeaturesProcessorRule = new Features.JUnitProcessor(); @Spy private OfflineNotificationBackgroundTask mOfflineNotificationBackgroundTask = new OfflineNotificationBackgroundTask(); @@ -118,10 +122,6 @@ @SuppressWarnings("unchecked") @Before public void setUp() { - Map<String, Boolean> features = new HashMap<>(); - features.put(ChromeFeatureList.PREFETCH_NOTIFICATION_SCHEDULING_INTEGRATION, false); - ChromeFeatureList.setTestFeatures(features); - MockitoAnnotations.initMocks(this); mOfflineNotificationBackgroundTask.setDelegate(new ChromeNativeBackgroundTaskDelegate()); // Set up the context.
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/omaha/metrics/UpdateSuccessMetricsTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/omaha/metrics/UpdateSuccessMetricsTest.java index b114348d..bee1ea8 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/omaha/metrics/UpdateSuccessMetricsTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/omaha/metrics/UpdateSuccessMetricsTest.java
@@ -19,6 +19,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.mockito.ArgumentMatcher; import org.mockito.InOrder; @@ -40,14 +41,13 @@ import org.chromium.chrome.browser.omaha.metrics.UpdateProtos.Tracking.Source; import org.chromium.chrome.browser.omaha.metrics.UpdateProtos.Tracking.Type; import org.chromium.chrome.browser.omaha.metrics.UpdateSuccessMetrics.UpdateType; +import org.chromium.chrome.test.util.browser.Features; import org.chromium.components.version_info.VersionConstants; -import java.util.HashMap; -import java.util.Map; - /** Tests the API surface of UpdateSuccessMetrics. */ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE, shadows = {ShadowRecordHistogram.class}) +@Features.DisableFeatures(ChromeFeatureList.INLINE_UPDATE_FLOW) public class UpdateSuccessMetricsTest { private static final int FAILED = 0; private static final int SUCCESS = 1; @@ -63,13 +63,11 @@ @Rule public MockitoRule mMockitoRule = MockitoJUnit.rule(); + @Rule + public TestRule mFeaturesProcessorRule = new Features.JUnitProcessor(); + @Before public void setUp() { - Map<String, Boolean> featureList = new HashMap<>(); - // The value we use does not matter. ChromeFeatureList just needs to be initialized. - featureList.put(ChromeFeatureList.INLINE_UPDATE_FLOW, false); - ChromeFeatureList.setTestFeatures(featureList); - mMetrics = new UpdateSuccessMetrics(mProvider); }
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/omnibox/UrlBarMediatorUnitTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/omnibox/UrlBarMediatorUnitTest.java index 0a2d8cbd..e43c7469 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/omnibox/UrlBarMediatorUnitTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/omnibox/UrlBarMediatorUnitTest.java
@@ -23,7 +23,6 @@ import org.robolectric.annotation.Config; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.components.omnibox.OmniboxUrlEmphasizer; import org.chromium.components.omnibox.OmniboxUrlEmphasizer.UrlEmphasisColorSpan; @@ -52,7 +51,6 @@ @Before public void setUp() { RecordHistogram.setDisabledForTests(true); - RecordUserAction.setDisabledForTests(true); MockitoAnnotations.initMocks(this); mModel = new PropertyModel(UrlBarProperties.ALL_KEYS); @@ -67,7 +65,6 @@ @After public void tearDown() { RecordHistogram.setDisabledForTests(false); - RecordUserAction.setDisabledForTests(false); } @Test
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/search_engines/SearchEngineChoiceNotificationTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/search_engines/SearchEngineChoiceNotificationTest.java index 6c7a446c..d73204a 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/search_engines/SearchEngineChoiceNotificationTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/search_engines/SearchEngineChoiceNotificationTest.java
@@ -20,6 +20,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; @@ -34,27 +35,29 @@ import org.chromium.base.metrics.test.ShadowRecordHistogram; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.chrome.browser.ChromeVersionInfo; -import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.preferences.ChromePreferenceKeys; import org.chromium.chrome.browser.preferences.SharedPreferencesManager; import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar; import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager; +import org.chromium.chrome.test.util.browser.Features; import org.chromium.components.search_engines.TemplateUrl; import org.chromium.components.search_engines.TemplateUrlService; -import java.util.HashMap; - /** * Unit tests for {@link SearchEngineChoiceNotification}. */ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE, shadows = {ShadowRecordHistogram.class}) +@Features.EnableFeatures({}) public final class SearchEngineChoiceNotificationTest { private static final String TEST_INITIAL_ENGINE = "google.com"; private static final String TEST_ALTERNATIVE_ENGINE = "duckduckgo.com"; @Rule public DisableHistogramsRule mDisableHistogramsRule = new DisableHistogramsRule(); + @Rule + public TestRule mFeaturesProcessorRule = new Features.JUnitProcessor(); + @Spy private Context mContext = RuntimeEnvironment.application.getApplicationContext(); @Mock @@ -73,7 +76,6 @@ MockitoAnnotations.initMocks(this); ContextUtils.initApplicationContextForTests(mContext); - ChromeFeatureList.setTestFeatures(new HashMap<String, Boolean>()); ShadowRecordHistogram.reset(); // Sets up appropriate responses from Template URL service.
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/survey/ChromeSurveyControllerTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/survey/ChromeSurveyControllerTest.java index d264f26..9da647e 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/survey/ChromeSurveyControllerTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/survey/ChromeSurveyControllerTest.java
@@ -10,12 +10,12 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import android.util.ArrayMap; - import org.junit.After; import org.junit.Assert; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -28,15 +28,15 @@ import org.chromium.chrome.browser.preferences.SharedPreferencesManager; import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tabmodel.TabModelSelector; +import org.chromium.chrome.test.util.browser.Features; import org.chromium.content_public.browser.WebContents; -import java.util.Map; - /** * Unit tests for ChromeSurveyController.java. */ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE) +@Features.EnableFeatures(ChromeFeatureList.HORIZONTAL_TAB_SWITCHER_ANDROID) public class ChromeSurveyControllerTest { private static final String STUDY_NAME = "HorizontalTabSwitcherStudyName"; private static final String GROUP_NAME = "HorizontalTabSwitcherGroupName"; @@ -45,6 +45,9 @@ private RiggedSurveyController mRiggedController; private SharedPreferencesManager mSharedPreferences; + @Rule + public TestRule mFeaturesProcessorRule = new Features.JUnitProcessor(); + @Mock Tab mTab; @@ -63,9 +66,6 @@ mTestController.setTabModelSelector(mSelector); mSharedPreferences = SharedPreferencesManager.getInstance(); Assert.assertNull("Tab should be null", mTestController.getLastTabInfobarShown()); - Map<String, Boolean> featureMap = new ArrayMap<>(); - featureMap.put(ChromeFeatureList.HORIZONTAL_TAB_SWITCHER_ANDROID, true); - ChromeFeatureList.setTestFeatures(featureMap); } @After
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/tab/TabUnitTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/tab/TabUnitTest.java index 71d9ffc..680ba0a4 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/tab/TabUnitTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/tab/TabUnitTest.java
@@ -17,30 +17,34 @@ import android.support.test.filters.SmallTest; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.annotation.Config; import org.chromium.base.test.BaseRobolectricTestRunner; -import org.chromium.chrome.browser.flags.ChromeFeatureList; +import org.chromium.chrome.test.util.browser.Features; import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.ui.base.WindowAndroid; import java.lang.ref.WeakReference; -import java.util.HashMap; -import java.util.Map; /** * Tests for {@link Tab}. */ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE) +@Features.EnableFeatures("ShoppingAssist") public class TabUnitTest { private static final int TAB1_ID = 456; private static final int TAB2_ID = 789; + @Rule + public TestRule mFeaturesProcessorRule = new Features.JUnitProcessor(); + @Mock private WindowAndroid mWindowAndroid; @Mock @@ -68,11 +72,6 @@ doReturn(mContext).when(mWeakReferenceContext).get(); doReturn(mContext).when(mContext).getApplicationContext(); - // Bypass feature checks. - Map<String, Boolean> features = new HashMap<>(); - features.put("ShoppingAssist", true); - ChromeFeatureList.setTestFeatures(features); - mTab = new TabImpl(TAB1_ID, null, false, null); mTab.addObserver(mObserver); }
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/toolbar/top/StartSurfaceToolbarMediatorUnitTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/toolbar/top/StartSurfaceToolbarMediatorUnitTest.java index 9af4b3e..69713668 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/toolbar/top/StartSurfaceToolbarMediatorUnitTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/toolbar/top/StartSurfaceToolbarMediatorUnitTest.java
@@ -40,7 +40,6 @@ import org.robolectric.annotation.Config; import org.chromium.base.Callback; -import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior; import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior.OverviewModeObserver; @@ -134,7 +133,6 @@ @After public void tearDown() { - RecordUserAction.setDisabledForTests(false); } @Test
diff --git a/chrome/android/profiles/newest.txt b/chrome/android/profiles/newest.txt index d5cf392..9c5f627 100644 --- a/chrome/android/profiles/newest.txt +++ b/chrome/android/profiles/newest.txt
@@ -1 +1 @@ -chromeos-chrome-amd64-82.0.4085.8_rc-r1-merged.afdo.bz2 \ No newline at end of file +chromeos-chrome-amd64-82.0.4085.10_rc-r1-merged.afdo.bz2 \ No newline at end of file
diff --git a/chrome/app/extensions_strings.grdp b/chrome/app/extensions_strings.grdp index 4e6f3ea5..a9a94ad 100644 --- a/chrome/app/extensions_strings.grdp +++ b/chrome/app/extensions_strings.grdp
@@ -16,9 +16,6 @@ <message name="IDS_EXTENSIONS_BACKGROUND_PAGE" desc="Display name for an autogenerated background page."> background page </message> - <message name="IDS_EXTENSIONS_DISABLE_BLOCKED_MATURE" desc="The tooltip displayed when the extension is blocked due to mature content for child users."> - This extension is blocked due to mature content. - </message> <message name="IDS_EXTENSIONS_CORRUPTED_EXTENSION" desc="The warning for the user that an extension may have been tampered with on disk."> This extension may have been corrupted. </message>
diff --git a/chrome/app/extensions_strings_grdp/IDS_EXTENSIONS_DISABLE_BLOCKED_MATURE.png.sha1 b/chrome/app/extensions_strings_grdp/IDS_EXTENSIONS_DISABLE_BLOCKED_MATURE.png.sha1 deleted file mode 100644 index a65a2aa..0000000 --- a/chrome/app/extensions_strings_grdp/IDS_EXTENSIONS_DISABLE_BLOCKED_MATURE.png.sha1 +++ /dev/null
@@ -1 +0,0 @@ -883dbf3381877642a62fb2ebf9a063460c66c64c \ No newline at end of file
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 41547255..a05c96a 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd
@@ -10652,24 +10652,28 @@ <!-- App pause prompt --> <message name="IDS_APP_PAUSE_PROMPT_TITLE" desc="Titlebar of the app pause prompt window"> - App paused + <ph name="APP_NAME">$1<ex>Gmail Checker</ex></ph> is paused </message> <message name="IDS_APP_PAUSE_HEADING" desc="Tells the user the app will be paused."> - The limit on "<ph name="APP_NAME">$1<ex>Google Photos</ex></ph>" that your parent set ran out. You can use it for <ph name="TIME_LIMIT">$2<ex>2 hours and 30 minutes</ex></ph> tomorrow. + You reached the time limit your parent set for <ph name="APP_NAME">$1<ex>Google Photos</ex></ph>. You can use it for <ph name="TIME_LIMIT">$2<ex>2 hours and 30 minutes</ex></ph> tomorrow. + </message> + + <message name="IDS_APP_PAUSE_HEADING_FOR_WEB_APPS" desc="Tells the user the app will be paused."> + You reached the time limit your parent set for <ph name="APP_NAME">$1<ex>Google Photos</ex></ph> Chrome app. You can use it for <ph name="TIME_LIMIT">$2<ex>2 hours and 30 minutes</ex></ph> tomorrow. </message> <!-- App block prompt --> <message name="IDS_APP_BLOCK_PROMPT_TITLE" desc="Titlebar of the app block prompt window"> - App blocked + <ph name="APP_NAME">$1<ex>Gmail Checker</ex></ph> is blocked </message> <message name="IDS_APP_BLOCK_HEADING_FOR_CHILD" desc="Tells the child the app is blocked."> - "<ph name="APP_NAME">$1<ex>Google Photos</ex></ph>" is blocked by your parent. Ask your parent for permission to use this app. + <ph name="APP_NAME">$1<ex>Google Photos</ex></ph> is blocked by your parent. Ask your parent for permission to use this app. </message> <message name="IDS_APP_BLOCK_HEADING" desc="Tells the user the app is blocked."> - "<ph name="APP_NAME">$1<ex>Google Photos</ex></ph>" is blocked by admin. Ask admin for permission to use this app. + <ph name="APP_NAME">$1<ex>Google Photos</ex></ph> is blocked by admin. Ask admin for permission to use this app. </message> <!-- Extension request -->
diff --git a/chrome/app/generated_resources_grd/IDS_APP_BLOCK_HEADING.png.sha1 b/chrome/app/generated_resources_grd/IDS_APP_BLOCK_HEADING.png.sha1 index f91e4a9..c8de8b7 100644 --- a/chrome/app/generated_resources_grd/IDS_APP_BLOCK_HEADING.png.sha1 +++ b/chrome/app/generated_resources_grd/IDS_APP_BLOCK_HEADING.png.sha1
@@ -1 +1 @@ -9cba8feaf00659d841e96d7cce2945a2130286c5 \ No newline at end of file +c6777ec876cde8d7b206ee369f192a3fa13f64a6 \ No newline at end of file
diff --git a/chrome/app/generated_resources_grd/IDS_APP_BLOCK_HEADING_FOR_CHILD.png.sha1 b/chrome/app/generated_resources_grd/IDS_APP_BLOCK_HEADING_FOR_CHILD.png.sha1 index ec254a5..05e0f574 100644 --- a/chrome/app/generated_resources_grd/IDS_APP_BLOCK_HEADING_FOR_CHILD.png.sha1 +++ b/chrome/app/generated_resources_grd/IDS_APP_BLOCK_HEADING_FOR_CHILD.png.sha1
@@ -1 +1 @@ -e01582a77561339d6b9797143a9bf776b30f2611 \ No newline at end of file +5d8c0d09639bb4cec85a62328da635bab1ef2933 \ No newline at end of file
diff --git a/chrome/app/generated_resources_grd/IDS_APP_BLOCK_PROMPT_TITLE.png.sha1 b/chrome/app/generated_resources_grd/IDS_APP_BLOCK_PROMPT_TITLE.png.sha1 index ec254a5..c8de8b7 100644 --- a/chrome/app/generated_resources_grd/IDS_APP_BLOCK_PROMPT_TITLE.png.sha1 +++ b/chrome/app/generated_resources_grd/IDS_APP_BLOCK_PROMPT_TITLE.png.sha1
@@ -1 +1 @@ -e01582a77561339d6b9797143a9bf776b30f2611 \ No newline at end of file +c6777ec876cde8d7b206ee369f192a3fa13f64a6 \ No newline at end of file
diff --git a/chrome/app/generated_resources_grd/IDS_APP_PAUSE_HEADING.png.sha1 b/chrome/app/generated_resources_grd/IDS_APP_PAUSE_HEADING.png.sha1 new file mode 100644 index 0000000..f09feba --- /dev/null +++ b/chrome/app/generated_resources_grd/IDS_APP_PAUSE_HEADING.png.sha1
@@ -0,0 +1 @@ +ed4e7c59be83601ba613b1ab5632bdbc37239dda \ No newline at end of file
diff --git a/chrome/app/generated_resources_grd/IDS_APP_PAUSE_HEADING_FOR_WEB_APPS.png.sha1 b/chrome/app/generated_resources_grd/IDS_APP_PAUSE_HEADING_FOR_WEB_APPS.png.sha1 new file mode 100644 index 0000000..b4c1e910c --- /dev/null +++ b/chrome/app/generated_resources_grd/IDS_APP_PAUSE_HEADING_FOR_WEB_APPS.png.sha1
@@ -0,0 +1 @@ +2111eb8caa4225b883c4fd534c2520263cee0f80 \ No newline at end of file
diff --git a/chrome/app/generated_resources_grd/IDS_APP_PAUSE_PROMPT_TITLE.png.sha1 b/chrome/app/generated_resources_grd/IDS_APP_PAUSE_PROMPT_TITLE.png.sha1 index 6b005f9..b4c1e910c 100644 --- a/chrome/app/generated_resources_grd/IDS_APP_PAUSE_PROMPT_TITLE.png.sha1 +++ b/chrome/app/generated_resources_grd/IDS_APP_PAUSE_PROMPT_TITLE.png.sha1
@@ -1 +1 @@ -5b713d24b0c6a493d8cbe52a3bb7e5127290b587 \ No newline at end of file +2111eb8caa4225b883c4fd534c2520263cee0f80 \ No newline at end of file
diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp index 6a88bfe..3c2c6aeb 100644 --- a/chrome/app/settings_strings.grdp +++ b/chrome/app/settings_strings.grdp
@@ -362,9 +362,6 @@ =1 {{COUNT} compromised password} other {{COUNT} compromised passwords}} </message> - <message name="IDS_SETTINGS_LEAKED_PASSWORDS_COUNT" desc="Number of compromised passwords found during bulk check."> - <ph name="COUNT">$1<ex>5</ex></ph> compromised passwords - </message> <message name="IDS_SETTINGS_CHECK_PASSWORDS_AGAIN" desc="Button to start bulk password check manually in passwords check section."> Check again </message> @@ -2377,13 +2374,13 @@ {COUNT, plural, =0 {Cookies are allowed} =1 {Cookies are allowed, 1 exception} - other {Cookies are allowed, # exceptions}} + other {Cookies are allowed, {COUNT} exceptions}} </message> <message name="IDS_SETTINGS_SITE_SETTINGS_COOKIES_BLOCK" desc="The sub-label for links to manage cookies when the current cookie setting is allow."> {COUNT, plural, =0 {Cookies are blocked.} =1 {Cookies are blocked, 1 exception} - other {Cookies are blocked, # exceptions}} + other {Cookies are blocked, {COUNT} exceptions}} </message> <message name="IDS_SETTINGS_SITE_SETTINGS_COOKIES_BLOCK_THIRD_PARTY" desc="The sub-label for links to manage cookies when the current cookie setting is to block third party cookies."> Third-party cookies are blocked @@ -2818,7 +2815,7 @@ <message name="IDS_SETTINGS_SITE_SETTINGS_NUM_COOKIES" desc="A label showing the number of cookies set on a site."> {NUM_COOKIES, plural, =1 {1 cookie} - other {# cookies}} + other {{NUM_COOKIES} cookies}} </message> <message name="IDS_SETTINGS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL" desc="The Local Storage Origin label"> Origin @@ -3167,15 +3164,15 @@ <message name="IDS_SETTINGS_RESET_CLEANUP_DETAILS_ITEMS_TO_BE_REMOVED" desc="Label for an expansion arrow. On expansion, the screen displays a list of files and programs that Chrome will remove or quarantine. Placeholder can be 2 or more items."> {NUM_ITEMS, plural, =1 {1 item} - other {# items}} + other {{NUM_ITEMS} items}} </message> <message name="IDS_SETTINGS_RESET_CLEANUP_DETAILS_REGISTRY_ENTRIES" desc="Introduces a bullet list containing the names of registry entries to be removed/changed by Chrome."> Registry entries to be removed or changed: </message> <message name="IDS_SETTINGS_RESET_CLEANUP_DETAILS_MORE" desc="Link; on click, the screen shows items to be removed by Chrome. Items could include files, programs, or registry entries. This link is for advanced users. Placeholder can be 2 or more items."> - {NUM_DOWNLOAD, plural, + {NUM_DOWNLOADS, plural, =1 {1 more} - other {# more}} + other {{NUM_DOWNLOADS} more}} </message> <message name="IDS_SETTINGS_RESET_CLEANUP_EXPLANATION_CLEANUP_ERROR" desc="Body of a generic error message that could appear during the cleanup of harmful software. Multiple causes for the error are possible."> An error occurred while Chrome was removing harmful software
diff --git a/chrome/app/theme/default_100_percent/common/password_check.png b/chrome/app/theme/default_100_percent/common/password_check.png new file mode 100644 index 0000000..2f5575b1 --- /dev/null +++ b/chrome/app/theme/default_100_percent/common/password_check.png Binary files differ
diff --git a/chrome/app/theme/default_100_percent/common/password_check_dark.png b/chrome/app/theme/default_100_percent/common/password_check_dark.png new file mode 100644 index 0000000..eeb5c72 --- /dev/null +++ b/chrome/app/theme/default_100_percent/common/password_check_dark.png Binary files differ
diff --git a/chrome/app/theme/default_200_percent/common/password_check.png b/chrome/app/theme/default_200_percent/common/password_check.png new file mode 100644 index 0000000..e8f81cc1 --- /dev/null +++ b/chrome/app/theme/default_200_percent/common/password_check.png Binary files differ
diff --git a/chrome/app/theme/default_200_percent/common/password_check_dark.png b/chrome/app/theme/default_200_percent/common/password_check_dark.png new file mode 100644 index 0000000..cff305f --- /dev/null +++ b/chrome/app/theme/default_200_percent/common/password_check_dark.png Binary files differ
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd index ca3a9c6..34c1bf0 100644 --- a/chrome/app/theme/theme_resources.grd +++ b/chrome/app/theme/theme_resources.grd
@@ -158,6 +158,10 @@ <structure type="chrome_scaled_image" name="IDR_ARC_PLAY_STORE_OPTIN_IN_PROGRESS_NOTIFICATION" file="cros/notification_play_store_optin_in_progress.png" /> <structure type="chrome_scaled_image" name="IDR_NOTIFICATION_EASYUNLOCK_ENABLED" file="cros/notification_easyunlock_enabled.png" /> </if> + <if expr="not is_android"> + <structure type="chrome_scaled_image" name="IDR_PASSWORD_CHECK" file="common/password_check.png" /> + <structure type="chrome_scaled_image" name="IDR_PASSWORD_CHECK_DARK" file="common/password_check_dark.png" /> + </if> <structure type="chrome_scaled_image" name="IDR_PLUGINS_FAVICON" file="common/favicon_extensions.png" /> <if expr="not is_android"> <structure type="chrome_scaled_image" name="IDR_PRERENDER" file="common/prerender_succeed_icon.png" />
diff --git a/chrome/app/vector_icons/BUILD.gn b/chrome/app/vector_icons/BUILD.gn index 8242da0..07b593fa 100644 --- a/chrome/app/vector_icons/BUILD.gn +++ b/chrome/app/vector_icons/BUILD.gn
@@ -75,8 +75,6 @@ "overflow_chevron.icon", "page_info_content_paste.icon", "paintbrush.icon", - "password_check_warning.icon", - "password_check_warning_dark.icon", "photo.icon", "photo_camera.icon", "picture_in_picture_control_background.icon",
diff --git a/chrome/app/vector_icons/password_check_warning.icon b/chrome/app/vector_icons/password_check_warning.icon deleted file mode 100644 index 021c0c2b..0000000 --- a/chrome/app/vector_icons/password_check_warning.icon +++ /dev/null
@@ -1,486 +0,0 @@ -CANVAS_DIMENSIONS, 448, -NEW_PATH, -MOVE_TO, 0, 0, -R_H_LINE_TO, 448, -R_V_LINE_TO, 148, -H_LINE_TO, 0, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xFF, 0xFF, 0xFF, -ROUND_RECT, 139, 25, 58, 82, 5, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xE8, 0xEA, 0xED, -MOVE_TO, 192, 26, -R_ARC_TO, 4, 4, 0, 0, 1, 4, 4, -R_V_LINE_TO, 72, -R_ARC_TO, 4.01f, 4.01f, 0, 0, 1, -4, 4, -R_H_LINE_TO, -48, -R_ARC_TO, 4.01f, 4.01f, 0, 0, 1, -4, -4, -V_LINE_TO, 30, -R_ARC_TO, 4, 4, 0, 0, 1, 4, -4, -R_H_LINE_TO, 48, -CLOSE, -R_MOVE_TO, 0, -2, -R_H_LINE_TO, -48, -R_ARC_TO, 6, 6, 0, 0, 0, -6, 6, -R_V_LINE_TO, 72, -R_ARC_TO, 6, 6, 0, 0, 0, 6, 6, -R_H_LINE_TO, 48, -R_ARC_TO, 6, 6, 0, 0, 0, 6, -6, -V_LINE_TO, 30, -R_ARC_TO, 6, 6, 0, 0, 0, -6, -6, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xF8, 0xF9, 0xFA, -MOVE_TO, 145, 31, -R_H_LINE_TO, 46, -R_V_LINE_TO, 70, -R_H_LINE_TO, -46, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xE8, 0xEA, 0xED, -MOVE_TO, 190, 32, -R_V_LINE_TO, 68, -R_H_LINE_TO, -44, -V_LINE_TO, 32, -R_H_LINE_TO, 44, -CLOSE, -R_MOVE_TO, 2, -2, -R_H_LINE_TO, -48, -R_V_LINE_TO, 72, -R_H_LINE_TO, 48, -V_LINE_TO, 30, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xFF, 0xFF, 0xFF, -ROUND_RECT, 115, 45, 34, 62, 5, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xE8, 0xEA, 0xED, -MOVE_TO, 144, 46, -R_ARC_TO, 4, 4, 0, 0, 1, 4, 4, -R_V_LINE_TO, 52, -R_ARC_TO, 4.01f, 4.01f, 0, 0, 1, -4, 4, -R_H_LINE_TO, -24, -R_ARC_TO, 4.01f, 4.01f, 0, 0, 1, -4, -4, -V_LINE_TO, 50, -R_ARC_TO, 4, 4, 0, 0, 1, 4, -4, -R_H_LINE_TO, 24, -CLOSE, -R_MOVE_TO, 0, -2, -R_H_LINE_TO, -24, -R_ARC_TO, 6, 6, 0, 0, 0, -6, 6, -R_V_LINE_TO, 52, -R_ARC_TO, 6, 6, 0, 0, 0, 6, 6, -R_H_LINE_TO, 24, -R_ARC_TO, 6, 6, 0, 0, 0, 6, -6, -V_LINE_TO, 50, -R_ARC_TO, 6, 6, 0, 0, 0, -6, -6, -CLOSE, -MOVE_TO, 116, 54, -R_H_LINE_TO, 32, -R_V_LINE_TO, 2, -R_H_LINE_TO, -32, -CLOSE, -MOVE_TO, 116, 98, -R_H_LINE_TO, 32, -R_V_LINE_TO, 2, -R_H_LINE_TO, -32, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xF8, 0xF9, 0xFA, -MOVE_TO, 116, 56, -R_H_LINE_TO, 32, -R_V_LINE_TO, 42, -R_H_LINE_TO, -32, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xE8, 0xEA, 0xED, -ROUND_RECT, 124, 49, 16, 2, 1, -CLOSE, -MOVE_TO, 131.99f, 87, -R_ARC_TO, 13.75f, 13.75f, 0, 0, 0, 7.84f, -10.63f, -R_CUBIC_TO, 0.1f, -0.76f, 0.16f, -1.52f, 0.17f, -2.29f, -V_LINE_TO, 69, -R_LINE_TO, -8, -3, -R_LINE_TO, -8, 3, -R_V_LINE_TO, 5.07f, -R_CUBIC_TO, 0.02f, 0.77f, 0.07f, 1.53f, 0.17f, 2.29f, -ARC_TO, 13.72f, 13.72f, 0, 0, 0, 131.99f, 87, -CLOSE, -MOVE_TO, 168, 71, -R_ARC_TO, 2, 2, 0, 1, 0, 0, -4, -R_ARC_TO, 2, 2, 0, 0, 0, 0, 4, -CLOSE, -R_MOVE_TO, 6, 3, -R_H_LINE_TO, -12, -V_LINE_TO, 64, -R_H_LINE_TO, 12, -R_V_LINE_TO, 10, -CLOSE, -R_MOVE_TO, -9, -14, -R_ARC_TO, 3, 3, 0, 0, 1, 6, 0, -R_V_LINE_TO, 2, -R_H_LINE_TO, -6, -R_V_LINE_TO, -2, -CLOSE, -R_MOVE_TO, 9, 2, -R_H_LINE_TO, -1, -R_V_LINE_TO, -2, -R_ARC_TO, 5, 5, 0, 1, 0, -10, 0, -R_V_LINE_TO, 2, -R_H_LINE_TO, -1, -R_ARC_TO, 2.01f, 2.01f, 0, 0, 0, -2, 2, -R_V_LINE_TO, 10, -R_ARC_TO, 2.01f, 2.01f, 0, 0, 0, 2, 2, -R_H_LINE_TO, 12, -R_ARC_TO, 2.01f, 2.01f, 0, 0, 0, 2, -2, -V_LINE_TO, 64, -R_ARC_TO, 2.01f, 2.01f, 0, 0, 0, -2, -2, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xF8, 0xF9, 0xFA, -MOVE_TO, 247, 101, -V_LINE_TO, 48, -R_ARC_TO, 5.01f, 5.01f, 0, 0, 1, 5, -5, -R_H_LINE_TO, 5, -R_V_LINE_TO, 58, -R_H_LINE_TO, -10, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xE8, 0xEA, 0xED, -MOVE_TO, 256, 44, -R_V_LINE_TO, 56, -R_H_LINE_TO, -8, -V_LINE_TO, 48, -R_ARC_TO, 4, 4, 0, 0, 1, 4, -4, -R_H_LINE_TO, 4, -CLOSE, -R_MOVE_TO, 2, -2, -R_H_LINE_TO, -6, -R_ARC_TO, 6, 6, 0, 0, 0, -6, 6, -R_V_LINE_TO, 54, -R_H_LINE_TO, 12, -V_LINE_TO, 42, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xFF, 0xFF, 0xFF, -MOVE_TO, 251, 101, -V_LINE_TO, 48, -R_ARC_TO, 5.01f, 5.01f, 0, 0, 1, 5, -5, -R_H_LINE_TO, 64, -R_ARC_TO, 5.01f, 5.01f, 0, 0, 1, 5, 5, -R_V_LINE_TO, 53, -R_H_LINE_TO, -74, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xE8, 0xEA, 0xED, -MOVE_TO, 320, 44, -R_ARC_TO, 4, 4, 0, 0, 1, 4, 4, -R_V_LINE_TO, 52, -R_H_LINE_TO, -72, -V_LINE_TO, 48, -R_ARC_TO, 4, 4, 0, 0, 1, 4, -4, -R_H_LINE_TO, 64, -CLOSE, -R_MOVE_TO, 0, -2, -R_H_LINE_TO, -64, -R_ARC_TO, 6, 6, 0, 0, 0, -6, 6, -R_V_LINE_TO, 54, -R_H_LINE_TO, 76, -V_LINE_TO, 48, -R_ARC_TO, 6, 6, 0, 0, 0, -6, -6, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xF8, 0xF9, 0xFA, -MOVE_TO, 252, 107, -R_ARC_TO, 5.01f, 5.01f, 0, 0, 1, -5, -5, -R_V_LINE_TO, -1, -R_H_LINE_TO, 52, -R_V_LINE_TO, 6, -R_H_LINE_TO, -47, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xE8, 0xEA, 0xED, -MOVE_TO, 298, 102, -R_V_LINE_TO, 4, -R_H_LINE_TO, -46, -R_ARC_TO, 4.01f, 4.01f, 0, 0, 1, -4, -4, -R_H_LINE_TO, 50, -CLOSE, -R_MOVE_TO, 2, -2, -R_H_LINE_TO, -54, -R_V_LINE_TO, 2, -R_ARC_TO, 6, 6, 0, 0, 0, 6, 6, -R_H_LINE_TO, 48, -R_V_LINE_TO, -8, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xFF, 0xFF, 0xFF, -MOVE_TO, 298, 107, -R_ARC_TO, 5.01f, 5.01f, 0, 0, 1, -5, -5, -R_V_LINE_TO, -1, -R_H_LINE_TO, 76, -R_V_LINE_TO, 1, -R_ARC_TO, 5.01f, 5.01f, 0, 0, 1, -5, 5, -R_H_LINE_TO, -66, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xE8, 0xEA, 0xED, -MOVE_TO, 368, 102, -R_ARC_TO, 4.01f, 4.01f, 0, 0, 1, -4, 4, -R_H_LINE_TO, -66, -R_ARC_TO, 4.01f, 4.01f, 0, 0, 1, -4, -4, -R_H_LINE_TO, 74, -CLOSE, -R_MOVE_TO, 2, -2, -R_H_LINE_TO, -78, -R_V_LINE_TO, 2, -R_ARC_TO, 6, 6, 0, 0, 0, 6, 6, -R_H_LINE_TO, 66, -R_ARC_TO, 6, 6, 0, 0, 0, 6, -6, -R_V_LINE_TO, -2, -CLOSE, -MOVE_TO, 337.35f, 104, -R_H_LINE_TO, -12.7f, -R_ARC_TO, 3.65f, 3.65f, 0, 0, 1, -3.65f, -3.65f, -V_LINE_TO, 100, -R_H_LINE_TO, 20, -R_V_LINE_TO, 0.35f, -R_ARC_TO, 3.65f, 3.65f, 0, 0, 1, -3.65f, 3.65f, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xF8, 0xF9, 0xFA, -MOVE_TO, 257, 49, -R_H_LINE_TO, 62, -R_V_LINE_TO, 46, -R_H_LINE_TO, -62, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xE8, 0xEA, 0xED, -MOVE_TO, 318, 50, -R_V_LINE_TO, 44, -R_H_LINE_TO, -60, -V_LINE_TO, 50, -R_H_LINE_TO, 60, -CLOSE, -R_MOVE_TO, 2, -2, -R_H_LINE_TO, -64, -R_V_LINE_TO, 48, -R_H_LINE_TO, 64, -V_LINE_TO, 48, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xFF, 0xFF, 0xFF, -ROUND_RECT, 267, 61, 74, 22, 3, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xE8, 0xEA, 0xED, -MOVE_TO, 338, 62, -R_ARC_TO, 2, 2, 0, 0, 1, 2, 2, -R_V_LINE_TO, 16, -R_ARC_TO, 2, 2, 0, 0, 1, -2, 2, -R_H_LINE_TO, -68, -R_ARC_TO, 2, 2, 0, 0, 1, -2, -2, -V_LINE_TO, 64, -R_ARC_TO, 2, 2, 0, 0, 1, 2, -2, -R_H_LINE_TO, 68, -CLOSE, -R_MOVE_TO, 0, -2, -R_H_LINE_TO, -68, -R_ARC_TO, 4, 4, 0, 0, 0, -4, 4, -R_V_LINE_TO, 16, -R_ARC_TO, 4, 4, 0, 0, 0, 4, 4, -R_H_LINE_TO, 68, -R_ARC_TO, 4, 4, 0, 0, 0, 4, -4, -V_LINE_TO, 64, -R_ARC_TO, 4, 4, 0, 0, 0, -4, -4, -CLOSE, -ROUND_RECT, 332, 66, 2, 12, 1, -MOVE_TO, 274, 71, -R_H_LINE_TO, 10, -R_V_LINE_TO, 2, -R_H_LINE_TO, -10, -CLOSE, -MOVE_TO, 275.63f, 75.83f, -R_LINE_TO, 5, -8.66f, -R_LINE_TO, 1.73f, 1, -R_LINE_TO, -5, 8.66f, -CLOSE, -MOVE_TO, 280.63f, 76.83f, -R_LINE_TO, -5, -8.66f, -R_LINE_TO, 1.73f, -1, -R_LINE_TO, 5, 8.66f, -CLOSE, -MOVE_TO, 274, 67, -R_H_LINE_TO, 10, -R_V_LINE_TO, 10, -R_H_LINE_TO, -10, -CLOSE, -MOVE_TO, 288, 71, -R_H_LINE_TO, 10, -R_V_LINE_TO, 2, -R_H_LINE_TO, -10, -CLOSE, -MOVE_TO, 289.63f, 75.83f, -R_LINE_TO, 5, -8.66f, -R_LINE_TO, 1.73f, 1, -R_LINE_TO, -5, 8.66f, -CLOSE, -MOVE_TO, 294.63f, 76.83f, -R_LINE_TO, -5, -8.66f, -R_LINE_TO, 1.73f, -1, -R_LINE_TO, 5, 8.66f, -CLOSE, -MOVE_TO, 288, 67, -R_H_LINE_TO, 10, -R_V_LINE_TO, 10, -R_H_LINE_TO, -10, -CLOSE, -MOVE_TO, 302, 71, -R_H_LINE_TO, 10, -R_V_LINE_TO, 2, -R_H_LINE_TO, -10, -CLOSE, -MOVE_TO, 303.63f, 75.83f, -R_LINE_TO, 5, -8.66f, -R_LINE_TO, 1.73f, 1, -R_LINE_TO, -5, 8.66f, -CLOSE, -MOVE_TO, 308.63f, 76.83f, -R_LINE_TO, -5, -8.66f, -R_LINE_TO, 1.73f, -1, -R_LINE_TO, 5, 8.66f, -CLOSE, -MOVE_TO, 302, 67, -R_H_LINE_TO, 10, -R_V_LINE_TO, 10, -R_H_LINE_TO, -10, -CLOSE, -MOVE_TO, 316, 71, -R_H_LINE_TO, 10, -R_V_LINE_TO, 2, -R_H_LINE_TO, -10, -CLOSE, -MOVE_TO, 317.63f, 75.83f, -R_LINE_TO, 5, -8.66f, -R_LINE_TO, 1.73f, 1, -R_LINE_TO, -5, 8.66f, -CLOSE, -MOVE_TO, 322.63f, 76.83f, -R_LINE_TO, -5, -8.66f, -R_LINE_TO, 1.73f, -1, -R_LINE_TO, 5, 8.66f, -CLOSE, -MOVE_TO, 316, 67, -R_H_LINE_TO, 10, -R_V_LINE_TO, 10, -R_H_LINE_TO, -10, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x3A, 0x7B, 0xEE, -ROUND_RECT, 190, 38, 68, 92, 6, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xFF, 0xFF, 0xFF, -MOVE_TO, 196, 50, -R_H_LINE_TO, 56, -R_V_LINE_TO, 68, -R_H_LINE_TO, -56, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x18, 0x5A, 0xBC, -MOVE_TO, 202, 85, -R_H_LINE_TO, 12, -R_V_LINE_TO, 2, -R_H_LINE_TO, -12, -CLOSE, -MOVE_TO, 204.13f, 90.7f, -R_LINE_TO, 6, -10.39f, -R_LINE_TO, 1.73f, 1, -R_LINE_TO, -6, 10.39f, -CLOSE, -MOVE_TO, 210.13f, 91.7f, -R_LINE_TO, -6, -10.39f, -R_LINE_TO, 1.73f, -1, -R_LINE_TO, 6, 10.39f, -CLOSE, -MOVE_TO, 218, 85, -R_H_LINE_TO, 12, -R_V_LINE_TO, 2, -R_H_LINE_TO, -12, -CLOSE, -MOVE_TO, 220.13f, 90.7f, -R_LINE_TO, 6, -10.39f, -R_LINE_TO, 1.73f, 1, -R_LINE_TO, -6, 10.39f, -CLOSE, -MOVE_TO, 226.13f, 91.7f, -R_LINE_TO, -6, -10.39f, -R_LINE_TO, 1.73f, -1, -R_LINE_TO, 6, 10.39f, -CLOSE, -MOVE_TO, 234, 85, -R_H_LINE_TO, 12, -R_V_LINE_TO, 2, -R_H_LINE_TO, -12, -CLOSE, -MOVE_TO, 236.13f, 90.7f, -R_LINE_TO, 6, -10.39f, -R_LINE_TO, 1.73f, 1, -R_LINE_TO, -6, 10.39f, -CLOSE, -MOVE_TO, 242.13f, 91.7f, -R_LINE_TO, -6, -10.39f, -R_LINE_TO, 1.73f, -1, -R_LINE_TO, 6, 10.39f, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xBD, 0xC1, 0xC6, -ROUND_RECT, 202, 96, 44, 2, 1, -ROUND_RECT, 202, 64, 16, 2, 1, -ROUND_RECT, 202, 70, 28, 2, 1, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xEA, 0x43, 0x35, -MOVE_TO, 258, 90, -R_CUBIC_TO, -9.94f, 0, -18, 8.06f, -18, 18, -R_CUBIC_TO, 0, 9.94f, 8.06f, 18, 18, 18, -R_CUBIC_TO, 9.94f, 0, 18, -8.06f, 18, -18, -R_CUBIC_TO, 0, -9.94f, -8.06f, -18, -18, -18, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xFF, 0xFF, 0xFF, -MOVE_TO, 259.38f, 116.38f, -R_H_LINE_TO, -2.75f, -R_V_LINE_TO, -2.75f, -R_H_LINE_TO, 2.75f, -CLOSE, -MOVE_TO, 259.38f, 111, -R_H_LINE_TO, -2.75f, -R_V_LINE_TO, -11, -R_H_LINE_TO, 2.75f, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xBD, 0xC1, 0xC6, -MOVE_TO, 224, 30, -R_ARC_TO, 7, 7, 0, 0, 1, 7, 7, -R_V_LINE_TO, 7, -R_H_LINE_TO, -14, -R_V_LINE_TO, -7, -R_ARC_TO, 7, 7, 0, 0, 1, 7, -7, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xF8, 0xF9, 0xFA, -CIRCLE, 224, 37, 3, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xBD, 0xC1, 0xC6, -MOVE_TO, 240, 44, -R_H_LINE_TO, -32, -R_ARC_TO, 6, 6, 0, 0, 0, -6, 6, -R_V_LINE_TO, 4, -R_H_LINE_TO, 44, -R_V_LINE_TO, -4, -R_ARC_TO, 6, 6, 0, 0, 0, -6, -6, -CLOSE \ No newline at end of file
diff --git a/chrome/app/vector_icons/password_check_warning_dark.icon b/chrome/app/vector_icons/password_check_warning_dark.icon deleted file mode 100644 index 1a35195..0000000 --- a/chrome/app/vector_icons/password_check_warning_dark.icon +++ /dev/null
@@ -1,456 +0,0 @@ -CANVAS_DIMENSIONS, 448, -NEW_PATH, -MOVE_TO, 0, 0, -R_H_LINE_TO, 448, -R_V_LINE_TO, 148, -H_LINE_TO, 0, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x38, 0x38, 0x38, -ROUND_RECT, 139, 25, 58, 82, 5, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x4E, 0x51, 0x54, -MOVE_TO, 192, 26, -R_ARC_TO, 4, 4, 0, 0, 1, 4, 4, -R_V_LINE_TO, 72, -R_ARC_TO, 4.01f, 4.01f, 0, 0, 1, -4, 4, -R_H_LINE_TO, -48, -R_ARC_TO, 4.01f, 4.01f, 0, 0, 1, -4, -4, -V_LINE_TO, 30, -R_ARC_TO, 4, 4, 0, 0, 1, 4, -4, -R_H_LINE_TO, 48, -CLOSE, -R_MOVE_TO, 0, -2, -R_H_LINE_TO, -48, -R_ARC_TO, 6, 6, 0, 0, 0, -6, 6, -R_V_LINE_TO, 72, -R_ARC_TO, 6, 6, 0, 0, 0, 6, 6, -R_H_LINE_TO, 48, -R_ARC_TO, 6, 6, 0, 0, 0, 6, -6, -V_LINE_TO, 30, -R_ARC_TO, 6, 6, 0, 0, 0, -6, -6, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x38, 0x38, 0x38, -MOVE_TO, 145, 31, -R_H_LINE_TO, 46, -R_V_LINE_TO, 70, -R_H_LINE_TO, -46, -CLOSE, -MOVE_TO, 190, 32, -R_V_LINE_TO, 68, -R_H_LINE_TO, -44, -V_LINE_TO, 32, -R_H_LINE_TO, 44, -CLOSE, -R_MOVE_TO, 2, -2, -R_H_LINE_TO, -48, -R_V_LINE_TO, 72, -R_H_LINE_TO, 48, -V_LINE_TO, 30, -CLOSE, -ROUND_RECT, 115, 45, 34, 62, 5, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x4E, 0x51, 0x54, -MOVE_TO, 144, 46, -R_ARC_TO, 4, 4, 0, 0, 1, 4, 4, -R_V_LINE_TO, 52, -R_ARC_TO, 4.01f, 4.01f, 0, 0, 1, -4, 4, -R_H_LINE_TO, -24, -R_ARC_TO, 4.01f, 4.01f, 0, 0, 1, -4, -4, -V_LINE_TO, 50, -R_ARC_TO, 4, 4, 0, 0, 1, 4, -4, -R_H_LINE_TO, 24, -CLOSE, -R_MOVE_TO, 0, -2, -R_H_LINE_TO, -24, -R_ARC_TO, 6, 6, 0, 0, 0, -6, 6, -R_V_LINE_TO, 52, -R_ARC_TO, 6, 6, 0, 0, 0, 6, 6, -R_H_LINE_TO, 24, -R_ARC_TO, 6, 6, 0, 0, 0, 6, -6, -V_LINE_TO, 50, -R_ARC_TO, 6, 6, 0, 0, 0, -6, -6, -CLOSE, -MOVE_TO, 114, 54, -R_H_LINE_TO, 36, -R_V_LINE_TO, 2, -R_H_LINE_TO, -36, -CLOSE, -MOVE_TO, 114, 98, -R_H_LINE_TO, 36, -R_V_LINE_TO, 2, -R_H_LINE_TO, -36, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x38, 0x38, 0x38, -MOVE_TO, 116, 56, -R_H_LINE_TO, 32, -R_V_LINE_TO, 42, -R_H_LINE_TO, -32, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x4E, 0x51, 0x54, -ROUND_RECT, 124, 49, 16, 2, 1, -MOVE_TO, 131.99f, 87, -R_ARC_TO, 13.75f, 13.75f, 0, 0, 0, 7.84f, -10.63f, -R_CUBIC_TO, 0.1f, -0.76f, 0.16f, -1.52f, 0.17f, -2.29f, -V_LINE_TO, 69, -R_LINE_TO, -8, -3, -R_LINE_TO, -8, 3, -R_V_LINE_TO, 5.07f, -R_CUBIC_TO, 0.02f, 0.77f, 0.07f, 1.53f, 0.17f, 2.29f, -ARC_TO, 13.72f, 13.72f, 0, 0, 0, 131.99f, 87, -CLOSE, -MOVE_TO, 168, 71, -R_ARC_TO, 2, 2, 0, 1, 0, 0, -4, -R_ARC_TO, 2, 2, 0, 0, 0, 0, 4, -CLOSE, -R_MOVE_TO, 6, 3, -R_H_LINE_TO, -12, -V_LINE_TO, 64, -R_H_LINE_TO, 12, -R_V_LINE_TO, 10, -CLOSE, -R_MOVE_TO, -9, -14, -R_ARC_TO, 3, 3, 0, 0, 1, 6, 0, -R_V_LINE_TO, 2, -R_H_LINE_TO, -6, -R_V_LINE_TO, -2, -CLOSE, -R_MOVE_TO, 9, 2, -R_H_LINE_TO, -1, -R_V_LINE_TO, -2, -R_ARC_TO, 5, 5, 0, 1, 0, -10, 0, -R_V_LINE_TO, 2, -R_H_LINE_TO, -1, -R_ARC_TO, 2.01f, 2.01f, 0, 0, 0, -2, 2, -R_V_LINE_TO, 10, -R_ARC_TO, 2.01f, 2.01f, 0, 0, 0, 2, 2, -R_H_LINE_TO, 12, -R_ARC_TO, 2.01f, 2.01f, 0, 0, 0, 2, -2, -V_LINE_TO, 64, -R_ARC_TO, 2.01f, 2.01f, 0, 0, 0, -2, -2, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xF8, 0xF9, 0xFA, -MOVE_TO, 247, 101, -V_LINE_TO, 48, -R_ARC_TO, 5.01f, 5.01f, 0, 0, 1, 5, -5, -R_H_LINE_TO, 5, -R_V_LINE_TO, 58, -R_H_LINE_TO, -10, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xE8, 0xEA, 0xED, -MOVE_TO, 256, 44, -R_V_LINE_TO, 56, -R_H_LINE_TO, -8, -V_LINE_TO, 48, -R_ARC_TO, 4, 4, 0, 0, 1, 4, -4, -R_H_LINE_TO, 4, -CLOSE, -R_MOVE_TO, 2, -2, -R_H_LINE_TO, -6, -R_ARC_TO, 6, 6, 0, 0, 0, -6, 6, -R_V_LINE_TO, 54, -R_H_LINE_TO, 12, -V_LINE_TO, 42, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x38, 0x38, 0x38, -MOVE_TO, 251, 101, -V_LINE_TO, 48, -R_ARC_TO, 5.01f, 5.01f, 0, 0, 1, 5, -5, -R_H_LINE_TO, 64, -R_ARC_TO, 5.01f, 5.01f, 0, 0, 1, 5, 5, -R_V_LINE_TO, 53, -R_H_LINE_TO, -74, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x4E, 0x51, 0x54, -MOVE_TO, 320, 44, -R_ARC_TO, 4, 4, 0, 0, 1, 4, 4, -R_V_LINE_TO, 52, -R_H_LINE_TO, -72, -V_LINE_TO, 48, -R_ARC_TO, 4, 4, 0, 0, 1, 4, -4, -R_H_LINE_TO, 64, -CLOSE, -R_MOVE_TO, 0, -2, -R_H_LINE_TO, -64, -R_ARC_TO, 6, 6, 0, 0, 0, -6, 6, -R_V_LINE_TO, 54, -R_H_LINE_TO, 76, -V_LINE_TO, 48, -R_ARC_TO, 6, 6, 0, 0, 0, -6, -6, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x38, 0x38, 0x38, -MOVE_TO, 252, 107, -R_ARC_TO, 5.01f, 5.01f, 0, 0, 1, -5, -5, -R_V_LINE_TO, -1, -R_H_LINE_TO, 52, -R_V_LINE_TO, 6, -R_H_LINE_TO, -47, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x4E, 0x51, 0x54, -MOVE_TO, 298, 102, -R_V_LINE_TO, 4, -R_H_LINE_TO, -46, -R_ARC_TO, 4.01f, 4.01f, 0, 0, 1, -4, -4, -R_H_LINE_TO, 50, -CLOSE, -R_MOVE_TO, 2, -2, -R_H_LINE_TO, -54, -R_V_LINE_TO, 2, -R_ARC_TO, 6, 6, 0, 0, 0, 6, 6, -R_H_LINE_TO, 48, -R_V_LINE_TO, -8, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x38, 0x38, 0x38, -MOVE_TO, 298, 107, -R_ARC_TO, 5.01f, 5.01f, 0, 0, 1, -5, -5, -R_V_LINE_TO, -1, -R_H_LINE_TO, 76, -R_V_LINE_TO, 1, -R_ARC_TO, 5.01f, 5.01f, 0, 0, 1, -5, 5, -R_H_LINE_TO, -66, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x4E, 0x51, 0x54, -MOVE_TO, 368, 102, -R_ARC_TO, 4.01f, 4.01f, 0, 0, 1, -4, 4, -R_H_LINE_TO, -66, -R_ARC_TO, 4.01f, 4.01f, 0, 0, 1, -4, -4, -R_H_LINE_TO, 74, -CLOSE, -R_MOVE_TO, 2, -2, -R_H_LINE_TO, -78, -R_V_LINE_TO, 2, -R_ARC_TO, 6, 6, 0, 0, 0, 6, 6, -R_H_LINE_TO, 66, -R_ARC_TO, 6, 6, 0, 0, 0, 6, -6, -R_V_LINE_TO, -2, -CLOSE, -MOVE_TO, 337.35f, 104, -R_H_LINE_TO, -12.7f, -R_ARC_TO, 3.65f, 3.65f, 0, 0, 1, -3.65f, -3.65f, -V_LINE_TO, 100, -R_H_LINE_TO, 20, -R_V_LINE_TO, 0.35f, -R_ARC_TO, 3.65f, 3.65f, 0, 0, 1, -3.65f, 3.65f, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x38, 0x38, 0x38, -MOVE_TO, 257, 49, -R_H_LINE_TO, 62, -R_V_LINE_TO, 46, -R_H_LINE_TO, -62, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x4E, 0x51, 0x54, -MOVE_TO, 318, 50, -R_V_LINE_TO, 44, -R_H_LINE_TO, -60, -V_LINE_TO, 50, -R_H_LINE_TO, 60, -CLOSE, -R_MOVE_TO, 2, -2, -R_H_LINE_TO, -64, -R_V_LINE_TO, 48, -R_H_LINE_TO, 64, -V_LINE_TO, 48, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x38, 0x38, 0x38, -ROUND_RECT, 267, 61, 74, 22, 3, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x4E, 0x51, 0x54, -MOVE_TO, 338, 62, -R_ARC_TO, 2, 2, 0, 0, 1, 2, 2, -R_V_LINE_TO, 16, -R_ARC_TO, 2, 2, 0, 0, 1, -2, 2, -R_H_LINE_TO, -68, -R_ARC_TO, 2, 2, 0, 0, 1, -2, -2, -V_LINE_TO, 64, -R_ARC_TO, 2, 2, 0, 0, 1, 2, -2, -R_H_LINE_TO, 68, -CLOSE, -R_MOVE_TO, 0, -2, -R_H_LINE_TO, -68, -R_ARC_TO, 4, 4, 0, 0, 0, -4, 4, -R_V_LINE_TO, 16, -R_ARC_TO, 4, 4, 0, 0, 0, 4, 4, -R_H_LINE_TO, 68, -R_ARC_TO, 4, 4, 0, 0, 0, 4, -4, -V_LINE_TO, 64, -R_ARC_TO, 4, 4, 0, 0, 0, -4, -4, -CLOSE, -ROUND_RECT, 332, 66, 2, 12, 1, -MOVE_TO, 274, 71, -R_H_LINE_TO, 10, -R_V_LINE_TO, 2, -R_H_LINE_TO, -10, -CLOSE, -MOVE_TO, 275.63f, 75.83f, -R_LINE_TO, 5, -8.66f, -R_LINE_TO, 1.73f, 1, -R_LINE_TO, -5, 8.66f, -CLOSE, -MOVE_TO, 280.63f, 76.83f, -R_LINE_TO, -5, -8.66f, -R_LINE_TO, 1.73f, -1, -R_LINE_TO, 5, 8.66f, -CLOSE, -MOVE_TO, 288, 71, -R_H_LINE_TO, 10, -R_V_LINE_TO, 2, -R_H_LINE_TO, -10, -CLOSE, -MOVE_TO, 289.63f, 75.83f, -R_LINE_TO, 5, -8.66f, -R_LINE_TO, 1.73f, 1, -R_LINE_TO, -5, 8.66f, -CLOSE, -MOVE_TO, 294.63f, 76.83f, -R_LINE_TO, -5, -8.66f, -R_LINE_TO, 1.73f, -1, -R_LINE_TO, 5, 8.66f, -CLOSE, -MOVE_TO, 302, 71, -R_H_LINE_TO, 10, -R_V_LINE_TO, 2, -R_H_LINE_TO, -10, -CLOSE, -MOVE_TO, 303.63f, 75.83f, -R_LINE_TO, 5, -8.66f, -R_LINE_TO, 1.73f, 1, -R_LINE_TO, -5, 8.66f, -CLOSE, -MOVE_TO, 308.63f, 76.83f, -R_LINE_TO, -5, -8.66f, -R_LINE_TO, 1.73f, -1, -R_LINE_TO, 5, 8.66f, -CLOSE, -MOVE_TO, 316, 71, -R_H_LINE_TO, 10, -R_V_LINE_TO, 2, -R_H_LINE_TO, -10, -CLOSE, -MOVE_TO, 317.63f, 75.83f, -R_LINE_TO, 5, -8.66f, -R_LINE_TO, 1.73f, 1, -R_LINE_TO, -5, 8.66f, -CLOSE, -MOVE_TO, 322.63f, 76.83f, -R_LINE_TO, -5, -8.66f, -R_LINE_TO, 1.73f, -1, -R_LINE_TO, 5, 8.66f, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x8A, 0xB4, 0xF8, -ROUND_RECT, 190, 38, 68, 92, 6, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x38, 0x38, 0x38, -MOVE_TO, 196, 50, -R_H_LINE_TO, 56, -R_V_LINE_TO, 68, -R_H_LINE_TO, -56, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x8A, 0xB4, 0xF8, -MOVE_TO, 202, 85, -R_H_LINE_TO, 12, -R_V_LINE_TO, 2, -R_H_LINE_TO, -12, -CLOSE, -MOVE_TO, 204.13f, 90.7f, -R_LINE_TO, 6, -10.39f, -R_LINE_TO, 1.73f, 1, -R_LINE_TO, -6, 10.39f, -CLOSE, -MOVE_TO, 210.13f, 91.7f, -R_LINE_TO, -6, -10.39f, -R_LINE_TO, 1.73f, -1, -R_LINE_TO, 6, 10.39f, -CLOSE, -MOVE_TO, 218, 85, -R_H_LINE_TO, 12, -R_V_LINE_TO, 2, -R_H_LINE_TO, -12, -CLOSE, -MOVE_TO, 220.13f, 90.7f, -R_LINE_TO, 6, -10.39f, -R_LINE_TO, 1.73f, 1, -R_LINE_TO, -6, 10.39f, -CLOSE, -MOVE_TO, 226.13f, 91.7f, -R_LINE_TO, -6, -10.39f, -R_LINE_TO, 1.73f, -1, -R_LINE_TO, 6, 10.39f, -CLOSE, -MOVE_TO, 234, 85, -R_H_LINE_TO, 12, -R_V_LINE_TO, 2, -R_H_LINE_TO, -12, -CLOSE, -MOVE_TO, 236.13f, 90.7f, -R_LINE_TO, 6, -10.39f, -R_LINE_TO, 1.73f, 1, -R_LINE_TO, -6, 10.39f, -CLOSE, -MOVE_TO, 242.13f, 91.7f, -R_LINE_TO, -6, -10.39f, -R_LINE_TO, 1.73f, -1, -R_LINE_TO, 6, 10.39f, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x4E, 0x51, 0x54, -ROUND_RECT, 202, 96, 44, 2, 1, -ROUND_RECT, 202, 64, 16, 2, 1, -ROUND_RECT, 202, 70, 28, 2, 1, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0xF2, 0x8B, 0x82, -MOVE_TO, 258, 90, -R_CUBIC_TO, -9.94f, 0, -18, 8.06f, -18, 18, -R_CUBIC_TO, 0, 9.94f, 8.06f, 18, 18, 18, -R_CUBIC_TO, 9.94f, 0, 18, -8.06f, 18, -18, -R_CUBIC_TO, 0, -9.94f, -8.06f, -18, -18, -18, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x38, 0x38, 0x38, -MOVE_TO, 259.38f, 116.38f, -R_H_LINE_TO, -2.75f, -R_V_LINE_TO, -2.75f, -R_H_LINE_TO, 2.75f, -CLOSE, -MOVE_TO, 259.38f, 111, -R_H_LINE_TO, -2.75f, -R_V_LINE_TO, -11, -R_H_LINE_TO, 2.75f, -CLOSE, -NEW_PATH, -PATH_COLOR_ARGB, 0xFF, 0x4E, 0x51, 0x54, -MOVE_TO, 224, 30, -R_ARC_TO, 7, 7, 0, 0, 1, 7, 7, -R_V_LINE_TO, 7, -R_H_LINE_TO, -14, -R_V_LINE_TO, -7, -R_ARC_TO, 7, 7, 0, 0, 1, 7, -7, -CLOSE, -CIRCLE, 224, 37, 3, -MOVE_TO, 240, 44, -R_H_LINE_TO, -32, -R_ARC_TO, 6, 6, 0, 0, 0, -6, 6, -R_V_LINE_TO, 4, -R_H_LINE_TO, 44, -R_V_LINE_TO, -4, -R_ARC_TO, 6, 6, 0, 0, 0, -6, -6, -CLOSE - \ No newline at end of file
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index e608e3a9..1f82920 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn
@@ -3352,7 +3352,8 @@ "performance_manager/graph/policies/urgent_page_discarding_policy.h", "performance_manager/mechanisms/page_discarder.cc", "performance_manager/mechanisms/page_discarder.h", - "performance_manager/mechanisms/tab_loader.h", + "performance_manager/mechanisms/page_loader.cc", + "performance_manager/mechanisms/page_loader.h", "performance_manager/persistence/site_data/exponential_moving_average.cc", "performance_manager/persistence/site_data/exponential_moving_average.h", "performance_manager/persistence/site_data/feature_usage.h", @@ -5561,7 +5562,7 @@ source = "browser_resources.grd" # Required due to flattenhtml="true" on a generated file. - source_is_generated = true + enable_input_discovery_for_gn_analyze = false use_brotli = true
diff --git a/chrome/browser/android/autofill_assistant/client_android.cc b/chrome/browser/android/autofill_assistant/client_android.cc index f24ef38..a7983fff 100644 --- a/chrome/browser/android/autofill_assistant/client_android.cc +++ b/chrome/browser/android/autofill_assistant/client_android.cc
@@ -132,6 +132,7 @@ const JavaParamRef<jobject>& jcaller, const JavaParamRef<jstring>& jinitial_url, const JavaParamRef<jstring>& jexperiment_ids, + const JavaParamRef<jstring>& jcaller_account, const JavaParamRef<jobjectArray>& jparameter_names, const JavaParamRef<jobjectArray>& jparameter_values, const JavaParamRef<jobject>& jonboarding_coordinator, @@ -158,6 +159,10 @@ env, jexperiment_ids, jparameter_names, jparameter_values); trigger_context->SetCCT(true); trigger_context->SetOnboardingShown(jonboarding_shown); + if (jcaller_account) { + trigger_context->SetCallerAccountHash( + base::android::ConvertJavaStringToUTF8(env, jcaller_account)); + } if (VLOG_IS_ON(2)) { std::string experiment_ids = @@ -434,7 +439,7 @@ ui_controller_android_.reset(); } -std::string ClientAndroid::GetApiKey() { +std::string ClientAndroid::GetApiKey() const { std::string api_key; if (google_apis::IsGoogleChromeAPIKeyUsed()) { api_key = chrome::GetChannel() == version_info::Channel::STABLE @@ -449,7 +454,7 @@ return api_key; } -std::string ClientAndroid::GetAccountEmailAddress() { +std::string ClientAndroid::GetAccountEmailAddress() const { JNIEnv* env = AttachCurrentThread(); return base::android::ConvertJavaStringToUTF8( Java_AutofillAssistantClient_getAccountEmailAddress(env, java_object_)); @@ -459,13 +464,13 @@ return this; } -autofill::PersonalDataManager* ClientAndroid::GetPersonalDataManager() { +autofill::PersonalDataManager* ClientAndroid::GetPersonalDataManager() const { return autofill::PersonalDataManagerFactory::GetForProfile( ProfileManager::GetLastUsedProfile()); } password_manager::PasswordManagerClient* -ClientAndroid::GetPasswordManagerClient() { +ClientAndroid::GetPasswordManagerClient() const { if (!password_manager_client_) { password_manager_client_ = ChromePasswordManagerClient::FromWebContents(web_contents_); @@ -473,7 +478,7 @@ return password_manager_client_; } -WebsiteLoginFetcher* ClientAndroid::GetWebsiteLoginFetcher() { +WebsiteLoginFetcher* ClientAndroid::GetWebsiteLoginFetcher() const { if (!website_login_fetcher_) { auto* client = GetPasswordManagerClient(); auto* factory = @@ -489,21 +494,21 @@ return website_login_fetcher_.get(); } -std::string ClientAndroid::GetServerUrl() { +std::string ClientAndroid::GetServerUrl() const { return server_url_; } -std::string ClientAndroid::GetLocale() { +std::string ClientAndroid::GetLocale() const { return base::android::GetDefaultLocaleString(); } -std::string ClientAndroid::GetCountryCode() { +std::string ClientAndroid::GetCountryCode() const { return base::android::ConvertJavaStringToUTF8( Java_AutofillAssistantClient_getCountryCode(AttachCurrentThread(), java_object_)); } -DeviceContext ClientAndroid::GetDeviceContext() { +DeviceContext ClientAndroid::GetDeviceContext() const { DeviceContext context; Version version; version.sdk_int = Java_AutofillAssistantClient_getSdkInt( @@ -519,7 +524,7 @@ return context; } -content::WebContents* ClientAndroid::GetWebContents() { +content::WebContents* ClientAndroid::GetWebContents() const { return web_contents_; }
diff --git a/chrome/browser/android/autofill_assistant/client_android.h b/chrome/browser/android/autofill_assistant/client_android.h index 84b8fa17..826305c6 100644 --- a/chrome/browser/android/autofill_assistant/client_android.h +++ b/chrome/browser/android/autofill_assistant/client_android.h
@@ -47,6 +47,7 @@ const base::android::JavaParamRef<jobject>& jcaller, const base::android::JavaParamRef<jstring>& jinitial_url, const base::android::JavaParamRef<jstring>& jexperiment_ids, + const base::android::JavaParamRef<jstring>& jcaller_account, const base::android::JavaParamRef<jobjectArray>& parameter_names, const base::android::JavaParamRef<jobjectArray>& parameter_values, const base::android::JavaParamRef<jobject>& jonboarding_coordinator, @@ -95,17 +96,18 @@ // Overrides Client void AttachUI() override; void DestroyUI() override; - std::string GetApiKey() override; - std::string GetAccountEmailAddress() override; + std::string GetApiKey() const override; + std::string GetAccountEmailAddress() const override; AccessTokenFetcher* GetAccessTokenFetcher() override; - autofill::PersonalDataManager* GetPersonalDataManager() override; - password_manager::PasswordManagerClient* GetPasswordManagerClient() override; - WebsiteLoginFetcher* GetWebsiteLoginFetcher() override; - std::string GetServerUrl() override; - std::string GetLocale() override; - std::string GetCountryCode() override; - DeviceContext GetDeviceContext() override; - content::WebContents* GetWebContents() override; + autofill::PersonalDataManager* GetPersonalDataManager() const override; + password_manager::PasswordManagerClient* GetPasswordManagerClient() + const override; + WebsiteLoginFetcher* GetWebsiteLoginFetcher() const override; + std::string GetServerUrl() const override; + std::string GetLocale() const override; + std::string GetCountryCode() const override; + DeviceContext GetDeviceContext() const override; + content::WebContents* GetWebContents() const override; void Shutdown(Metrics::DropOutReason reason) override; // Overrides AccessTokenFetcher @@ -141,8 +143,8 @@ base::android::ScopedJavaGlobalRef<jobject> java_object_; std::unique_ptr<Controller> controller_; - std::unique_ptr<WebsiteLoginFetcher> website_login_fetcher_; - password_manager::PasswordManagerClient* password_manager_client_; + mutable std::unique_ptr<WebsiteLoginFetcher> website_login_fetcher_; + mutable password_manager::PasswordManagerClient* password_manager_client_; // True if Start() was called. This turns on the tracking of dropouts. bool started_ = false;
diff --git a/chrome/browser/apps/app_service/app_service_proxy.cc b/chrome/browser/apps/app_service/app_service_proxy.cc index e80a0a8f..77f913d 100644 --- a/chrome/browser/apps/app_service/app_service_proxy.cc +++ b/chrome/browser/apps/app_service/app_service_proxy.cc
@@ -27,6 +27,7 @@ #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/child_accounts/time_limits/app_time_limit_interface.h" #include "chrome/browser/supervised_user/grit/supervised_user_unscaled_resources.h" +#include "extensions/common/constants.h" #endif namespace apps { @@ -525,6 +526,10 @@ #if defined(OS_CHROMEOS) bool AppServiceProxy::MaybeShowLaunchPreventionDialog( const apps::AppUpdate& update) { + if (update.AppId() == extension_misc::kChromeAppId) { + return false; + } + // Return true, and load the icon for the app block dialog when the app // is blocked by policy. if (update.Readiness() == apps::mojom::Readiness::kDisabledByPolicy) { @@ -617,7 +622,7 @@ } AppServiceProxy::CreatePauseDialog( - app_name, icon_value->uncompressed, pause_data, + app_type, app_name, icon_value->uncompressed, pause_data, base::BindOnce(&AppServiceProxy::OnPauseDialogClosed, weak_ptr_factory_.GetWeakPtr(), app_type, app_id));
diff --git a/chrome/browser/apps/app_service/app_service_proxy.h b/chrome/browser/apps/app_service/app_service_proxy.h index 4ec3fd1..7124481 100644 --- a/chrome/browser/apps/app_service/app_service_proxy.h +++ b/chrome/browser/apps/app_service/app_service_proxy.h
@@ -244,7 +244,8 @@ const gfx::ImageSkia& image, Profile* profile); - static void CreatePauseDialog(const std::string& app_name, + static void CreatePauseDialog(apps::mojom::AppType app_type, + const std::string& app_name, const gfx::ImageSkia& image, const PauseData& pause_data, OnPauseDialogClosedCallback pause_callback);
diff --git a/chrome/browser/apps/app_service/uninstall_dialog.h b/chrome/browser/apps/app_service/uninstall_dialog.h index ab9e8968d..d1baf1a 100644 --- a/chrome/browser/apps/app_service/uninstall_dialog.h +++ b/chrome/browser/apps/app_service/uninstall_dialog.h
@@ -46,8 +46,8 @@ // the icon image, and the callback function. class UiBase { public: - explicit UiBase(gfx::ImageSkia image, UninstallDialog* uninstall_dialog) - : image_(image), uninstall_dialog_(uninstall_dialog) {} + explicit UiBase(UninstallDialog* uninstall_dialog) + : uninstall_dialog_(uninstall_dialog) {} virtual ~UiBase() = default; @@ -59,11 +59,9 @@ gfx::NativeWindow parent_window, UninstallDialog* uninstall_dialog); - gfx::ImageSkia image() const { return image_; } UninstallDialog* uninstall_dialog() const { return uninstall_dialog_; } private: - gfx::ImageSkia image_; UninstallDialog* uninstall_dialog_; DISALLOW_COPY_AND_ASSIGN(UiBase);
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 50fa8a3..a9365ae9 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc
@@ -384,6 +384,7 @@ #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" #include "chrome/browser/chromeos/profiles/profile_helper.h" +#include "chrome/browser/chromeos/smb_client/fileapi/smbfs_file_system_backend_delegate.h" #include "chrome/browser/chromeos/system/input_device_settings.h" #include "chrome/browser/speech/tts_chromeos.h" #include "chrome/browser/ui/ash/chrome_browser_main_extra_parts_ash.h" @@ -3538,6 +3539,8 @@ std::make_unique<arc::ArcDocumentsProviderBackendDelegate>(), std::make_unique<drive::DriveFsFileSystemBackendDelegate>( Profile::FromBrowserContext(browser_context)), + std::make_unique<chromeos::smb_client::SmbFsFileSystemBackendDelegate>( + Profile::FromBrowserContext(browser_context)), external_mount_points, storage::ExternalMountPoints::GetSystemInstance()); backend->AddSystemMountPoints(); DCHECK(backend->CanHandleType(storage::kFileSystemTypeExternal));
diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn index b06546f..4072808 100644 --- a/chrome/browser/chromeos/BUILD.gn +++ b/chrome/browser/chromeos/BUILD.gn
@@ -2223,6 +2223,10 @@ "smb_client/discovery/netbios_host_locator.h", "smb_client/discovery/network_scanner.cc", "smb_client/discovery/network_scanner.h", + "smb_client/fileapi/smbfs_async_file_util.cc", + "smb_client/fileapi/smbfs_async_file_util.h", + "smb_client/fileapi/smbfs_file_system_backend_delegate.cc", + "smb_client/fileapi/smbfs_file_system_backend_delegate.h", "smb_client/smb_constants.cc", "smb_client/smb_constants.h", "smb_client/smb_errors.cc",
diff --git a/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge.cc b/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge.cc index fa1a11a..6bc7cbb 100644 --- a/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge.cc +++ b/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge.cc
@@ -780,14 +780,14 @@ arc::mojom::AccessibilityEventType::ANNOUNCEMENT || event_data->event_type == arc::mojom::AccessibilityEventType::NOTIFICATION_STATE_CHANGED) { - if (!event_data->eventText.has_value()) + if (!event_data->event_text.has_value()) return; extensions::EventRouter* event_router = GetEventRouter(); // OnAnnounceForAccessibility is used to force speech output. std::unique_ptr<base::ListValue> event_args( extensions::api::accessibility_private::OnAnnounceForAccessibility:: - Create(*(event_data->eventText))); + Create(*(event_data->event_text))); std::unique_ptr<extensions::Event> event(new extensions::Event( extensions::events::ACCESSIBILITY_PRIVATE_ON_ANNOUNCE_FOR_ACCESSIBILITY, extensions::api::accessibility_private::OnAnnounceForAccessibility::
diff --git a/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge_unittest.cc b/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge_unittest.cc index eeede2cc..09d66f6b0 100644 --- a/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge_unittest.cc +++ b/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge_unittest.cc
@@ -325,7 +325,7 @@ std::vector<std::string> text({announce_text}); auto event = arc::mojom::AccessibilityEventData::New(); event->event_type = arc::mojom::AccessibilityEventType::ANNOUNCEMENT; - event->eventText = + event->event_text = base::make_optional<std::vector<std::string>>(std::move(text)); helper_bridge->OnAccessibilityEvent(event.Clone()); @@ -400,7 +400,7 @@ auto event = arc::mojom::AccessibilityEventData::New(); event->event_type = arc::mojom::AccessibilityEventType::NOTIFICATION_STATE_CHANGED; - event->eventText = + event->event_text = base::make_optional<std::vector<std::string>>(std::move(text)); helper_bridge->OnAccessibilityEvent(event.Clone());
diff --git a/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc b/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc index e4fd6342..2a7f5d7 100644 --- a/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc +++ b/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc
@@ -155,8 +155,8 @@ if (IsValid(new_focus)) android_focused_id_ = new_focus->GetId(); - if (event_data->eventText) - UpdateAXNameCache(focused_node, *event_data->eventText); + if (event_data->event_text) + UpdateAXNameCache(focused_node, *event_data->event_text); } if (!android_focused_id_ || !GetFromId(*android_focused_id_)) {
diff --git a/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc_unittest.cc b/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc_unittest.cc index ee4776e..49df50a 100644 --- a/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc_unittest.cc +++ b/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc_unittest.cc
@@ -1055,7 +1055,7 @@ event->source_id = 10; // root event->task_id = 1; event->event_type = AXEventType::WINDOW_STATE_CHANGED; - event->eventText = std::vector<std::string>({"Navigation"}); + event->event_text = std::vector<std::string>({"Navigation"}); event->window_data = std::vector<mojom::AccessibilityWindowInfoDataPtr>(); event->window_data->emplace_back(AXWindowInfoData::New()); @@ -1108,7 +1108,7 @@ EXPECT_EQ("Navigation", name); // Validate that the drawer title is cached. - event->eventText.reset(); + event->event_text.reset(); event->event_type = AXEventType::WINDOW_CONTENT_CHANGED; CallNotifyAccessibilityEvent(event.get());
diff --git a/chrome/browser/chromeos/child_accounts/time_limits/web_time_limit_error_page/web_time_limit_error_page.cc b/chrome/browser/chromeos/child_accounts/time_limits/web_time_limit_error_page/web_time_limit_error_page.cc index 13f7223..1784571 100644 --- a/chrome/browser/chromeos/child_accounts/time_limits/web_time_limit_error_page/web_time_limit_error_page.cc +++ b/chrome/browser/chromeos/child_accounts/time_limits/web_time_limit_error_page/web_time_limit_error_page.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/chromeos/child_accounts/time_limits/web_time_limit_error_page/web_time_limit_error_page.h" +#include "base/strings/strcat.h" #include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" @@ -32,19 +33,20 @@ base::string16 block_message, base::TimeDelta time_limit, const std::string& app_locale) { - block_message += - l10n_util::GetStringFUTF16(IDS_WEB_TIME_LIMIT_ERROR_PAGE_NEXT_ACCESS_TIME, - GetTimeLimitMessage(time_limit)); - base::DictionaryValue strings; - strings.SetString("blockPageTitle", l10n_util::GetStringFUTF16( IDS_WEB_TIME_LIMIT_ERROR_PAGE_TITLE, l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); strings.SetString("blockPageHeader", block_header); - strings.SetString("blockPageMessage", block_message); + strings.SetString( + "blockPageMessage", + base::StrCat({block_message, base::UTF8ToUTF16(" "), + l10n_util::GetStringFUTF16( + IDS_WEB_TIME_LIMIT_ERROR_PAGE_NEXT_ACCESS_TIME, + GetTimeLimitMessage(time_limit))})); + webui::SetLoadTimeDataDefaults(app_locale, &strings); std::string html = ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
diff --git a/chrome/browser/chromeos/drive/file_system_util.cc b/chrome/browser/chromeos/drive/file_system_util.cc index 058dc23..e27f14e7 100644 --- a/chrome/browser/chromeos/drive/file_system_util.cc +++ b/chrome/browser/chromeos/drive/file_system_util.cc
@@ -44,26 +44,22 @@ } bool IsUnderDriveMountPoint(const base::FilePath& path) { - return !ExtractDrivePath(path).empty(); -} - -base::FilePath ExtractDrivePath(const base::FilePath& path) { std::vector<base::FilePath::StringType> components; path.GetComponents(&components); - if (components.size() < 3) - return base::FilePath(); + if (components.size() < 4) + return false; if (components[0] != FILE_PATH_LITERAL("/")) - return base::FilePath(); - if (components[1] != FILE_PATH_LITERAL("special")) - return base::FilePath(); - static const base::FilePath::CharType kPrefix[] = FILE_PATH_LITERAL("drive"); - if (components[2].compare(0, base::size(kPrefix) - 1, kPrefix) != 0) - return base::FilePath(); + return false; + if (components[1] != FILE_PATH_LITERAL("media")) + return false; + if (components[2] != FILE_PATH_LITERAL("fuse")) + return false; + static const base::FilePath::CharType kPrefix[] = + FILE_PATH_LITERAL("drivefs"); + if (components[3].compare(0, base::size(kPrefix) - 1, kPrefix) != 0) + return false; - base::FilePath drive_path = GetDriveGrandRootPath(); - for (size_t i = 3; i < components.size(); ++i) - drive_path = drive_path.Append(components[i]); - return drive_path; + return true; } base::FilePath GetCacheRootPath(Profile* profile) {
diff --git a/chrome/browser/chromeos/drive/file_system_util.h b/chrome/browser/chromeos/drive/file_system_util.h index d823016b2..02b58a7 100644 --- a/chrome/browser/chromeos/drive/file_system_util.h +++ b/chrome/browser/chromeos/drive/file_system_util.h
@@ -27,11 +27,6 @@ // Returns true if the given path is under the Drive mount point. bool IsUnderDriveMountPoint(const base::FilePath& path); -// Extracts the Drive path from the given path located under the Drive mount -// point. Returns an empty path if |path| is not under the Drive mount point. -// Examples: ExtractDrivePath("/special/drive-xxx/foo.txt") => "drive/foo.txt" -base::FilePath ExtractDrivePath(const base::FilePath& path); - // Gets the cache root path (i.e. <user_profile_dir>/GCache/v1) from the // profile. base::FilePath GetCacheRootPath(Profile* profile);
diff --git a/chrome/browser/chromeos/drive/file_system_util_unittest.cc b/chrome/browser/chromeos/drive/file_system_util_unittest.cc index 0bfe949f..ef2bcda 100644 --- a/chrome/browser/chromeos/drive/file_system_util_unittest.cc +++ b/chrome/browser/chromeos/drive/file_system_util_unittest.cc
@@ -31,39 +31,18 @@ EXPECT_FALSE(IsUnderDriveMountPoint( base::FilePath::FromUTF8Unsafe("/wherever/foo.txt"))); EXPECT_FALSE(IsUnderDriveMountPoint( - base::FilePath::FromUTF8Unsafe("/special/foo.txt"))); + base::FilePath::FromUTF8Unsafe("/media/fuse/foo.txt"))); EXPECT_FALSE(IsUnderDriveMountPoint( - base::FilePath::FromUTF8Unsafe("special/drive/foo.txt"))); + base::FilePath::FromUTF8Unsafe("media/fuse/drivefs/foo.txt"))); - EXPECT_TRUE( - IsUnderDriveMountPoint(base::FilePath::FromUTF8Unsafe("/special/drive"))); EXPECT_TRUE(IsUnderDriveMountPoint( - base::FilePath::FromUTF8Unsafe("/special/drive/foo.txt"))); + base::FilePath::FromUTF8Unsafe("/media/fuse/drivefs"))); EXPECT_TRUE(IsUnderDriveMountPoint( - base::FilePath::FromUTF8Unsafe("/special/drive/subdir/foo.txt"))); + base::FilePath::FromUTF8Unsafe("/media/fuse/drivefs/foo.txt"))); EXPECT_TRUE(IsUnderDriveMountPoint( - base::FilePath::FromUTF8Unsafe("/special/drive-xxx/foo.txt"))); -} - -TEST_F(ProfileRelatedFileSystemUtilTest, ExtractDrivePath) { - EXPECT_EQ( - base::FilePath(), - ExtractDrivePath(base::FilePath::FromUTF8Unsafe("/wherever/foo.txt"))); - EXPECT_EQ( - base::FilePath(), - ExtractDrivePath(base::FilePath::FromUTF8Unsafe("/special/foo.txt"))); - - EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive"), - ExtractDrivePath(base::FilePath::FromUTF8Unsafe("/special/drive"))); - EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/foo.txt"), - ExtractDrivePath( - base::FilePath::FromUTF8Unsafe("/special/drive/foo.txt"))); - EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/subdir/foo.txt"), - ExtractDrivePath(base::FilePath::FromUTF8Unsafe( - "/special/drive/subdir/foo.txt"))); - EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/foo.txt"), - ExtractDrivePath( - base::FilePath::FromUTF8Unsafe("/special/drive-xxx/foo.txt"))); + base::FilePath::FromUTF8Unsafe("/media/fuse/drivefs/subdir/foo.txt"))); + EXPECT_TRUE(IsUnderDriveMountPoint( + base::FilePath::FromUTF8Unsafe("/media/fuse/drivefs-xxx/foo.txt"))); } TEST_F(ProfileRelatedFileSystemUtilTest, GetCacheRootPath) {
diff --git a/chrome/browser/chromeos/file_manager/path_util.cc b/chrome/browser/chromeos/file_manager/path_util.cc index 932152f..c8aeae2a 100644 --- a/chrome/browser/chromeos/file_manager/path_util.cc +++ b/chrome/browser/chromeos/file_manager/path_util.cc
@@ -108,6 +108,30 @@ return false; } +// Extracts the Drive path from the given path located under the legacy Drive +// mount point. Returns an empty path if |path| is not under the legacy Drive +// mount point. +// Example: ExtractLegacyDrivePath("/special/drive-xxx/foo.txt") => +// "drive/foo.txt" +base::FilePath ExtractLegacyDrivePath(const base::FilePath& path) { + std::vector<base::FilePath::StringType> components; + path.GetComponents(&components); + if (components.size() < 3) + return base::FilePath(); + if (components[0] != FILE_PATH_LITERAL("/")) + return base::FilePath(); + if (components[1] != FILE_PATH_LITERAL("special")) + return base::FilePath(); + static const base::FilePath::CharType kPrefix[] = FILE_PATH_LITERAL("drive"); + if (components[2].compare(0, base::size(kPrefix) - 1, kPrefix) != 0) + return base::FilePath(); + + base::FilePath drive_path = drive::util::GetDriveGrandRootPath(); + for (size_t i = 3; i < components.size(); ++i) + drive_path = drive_path.Append(components[i]); + return drive_path; +} + } // namespace const base::FilePath::CharType kRemovableMediaPath[] = @@ -221,7 +245,7 @@ } *new_path = integration_service->GetMountPointPath(); return drive::util::GetDriveGrandRootPath().AppendRelativePath( - drive::util::ExtractDrivePath(old_path), new_path); + ExtractLegacyDrivePath(old_path), new_path); } std::string GetDownloadsMountPointName(Profile* profile) {
diff --git a/chrome/browser/chromeos/fileapi/file_system_backend.cc b/chrome/browser/chromeos/fileapi/file_system_backend.cc index 49da5066..aeee1f2 100644 --- a/chrome/browser/chromeos/fileapi/file_system_backend.cc +++ b/chrome/browser/chromeos/fileapi/file_system_backend.cc
@@ -69,6 +69,7 @@ std::unique_ptr<FileSystemBackendDelegate> arc_content_delegate, std::unique_ptr<FileSystemBackendDelegate> arc_documents_provider_delegate, std::unique_ptr<FileSystemBackendDelegate> drivefs_delegate, + std::unique_ptr<FileSystemBackendDelegate> smbfs_delegate, scoped_refptr<storage::ExternalMountPoints> mount_points, storage::ExternalMountPoints* system_mount_points) : file_access_permissions_(new FileAccessPermissions()), @@ -79,6 +80,7 @@ arc_documents_provider_delegate_( std::move(arc_documents_provider_delegate)), drivefs_delegate_(std::move(drivefs_delegate)), + smbfs_delegate_(std::move(smbfs_delegate)), mount_points_(mount_points), system_mount_points_(system_mount_points) {} @@ -282,7 +284,6 @@ return file_system_provider_delegate_->GetAsyncFileUtil(type); case storage::kFileSystemTypeNativeLocal: case storage::kFileSystemTypeRestrictedNativeLocal: - case storage::kFileSystemTypeSmbFs: return local_file_util_.get(); case storage::kFileSystemTypeDeviceMediaAsFileStorage: return mtp_delegate_->GetAsyncFileUtil(type); @@ -292,6 +293,8 @@ return arc_documents_provider_delegate_->GetAsyncFileUtil(type); case storage::kFileSystemTypeDriveFs: return drivefs_delegate_->GetAsyncFileUtil(type); + case storage::kFileSystemTypeSmbFs: + return smbfs_delegate_->GetAsyncFileUtil(type); default: NOTREACHED(); }
diff --git a/chrome/browser/chromeos/fileapi/file_system_backend.h b/chrome/browser/chromeos/fileapi/file_system_backend.h index 9868772..eae2bff 100644 --- a/chrome/browser/chromeos/fileapi/file_system_backend.h +++ b/chrome/browser/chromeos/fileapi/file_system_backend.h
@@ -79,6 +79,7 @@ std::unique_ptr<FileSystemBackendDelegate> arc_documents_provider_delegate, std::unique_ptr<FileSystemBackendDelegate> drivefs_delegate, + std::unique_ptr<FileSystemBackendDelegate> smbfs_delegate, scoped_refptr<storage::ExternalMountPoints> mount_points, storage::ExternalMountPoints* system_mount_points); ~FileSystemBackend() override; @@ -163,6 +164,9 @@ // The delegate instance for the DriveFS file system related operations. std::unique_ptr<FileSystemBackendDelegate> drivefs_delegate_; + // The delegate instance for the SmbFs file system related operations. + std::unique_ptr<FileSystemBackendDelegate> smbfs_delegate_; + // Mount points specific to the owning context (i.e. per-profile mount // points). //
diff --git a/chrome/browser/chromeos/fileapi/file_system_backend_unittest.cc b/chrome/browser/chromeos/fileapi/file_system_backend_unittest.cc index 391058be..bf4ea629 100644 --- a/chrome/browser/chromeos/fileapi/file_system_backend_unittest.cc +++ b/chrome/browser/chromeos/fileapi/file_system_backend_unittest.cc
@@ -45,6 +45,7 @@ nullptr, // arc_content_delegate nullptr, // arc_documents_provider_delegate nullptr, // drivefs_delegate + nullptr, // smbfs_delegate mount_points.get(), storage::ExternalMountPoints::GetSystemInstance()); backend.AddSystemMountPoints(); std::vector<base::FilePath> root_dirs = backend.GetRootDirectories(); @@ -73,6 +74,7 @@ nullptr, // arc_content_delegate nullptr, // arc_documents_provider_delegate nullptr, // drivefs_delegate + nullptr, // smbfs_delegate mount_points.get(), system_mount_points.get()); const size_t initial_root_dirs_size = backend.GetRootDirectories().size(); @@ -117,6 +119,7 @@ nullptr, // arc_content_delegate nullptr, // arc_documents_provider_delegate nullptr, // drivefs_delegate + nullptr, // smbfs_delegate mount_points.get(), system_mount_points.get()); std::string extension("ddammdhioacbehjngdmkjcjbnfginlla"); @@ -187,6 +190,7 @@ nullptr, // arc_content_delegate nullptr, // arc_documents_provider_delegate nullptr, // drivefs_delegate + nullptr, // smbfs_delegate mount_points.get(), system_mount_points.get()); const storage::FileSystemType type = storage::kFileSystemTypeNativeLocal;
diff --git a/chrome/browser/chromeos/smb_client/fileapi/smbfs_async_file_util.cc b/chrome/browser/chromeos/smb_client/fileapi/smbfs_async_file_util.cc new file mode 100644 index 0000000..ee57a1ec --- /dev/null +++ b/chrome/browser/chromeos/smb_client/fileapi/smbfs_async_file_util.cc
@@ -0,0 +1,21 @@ +// Copyright 2020 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 "chrome/browser/chromeos/smb_client/fileapi/smbfs_async_file_util.h" + +#include "base/logging.h" +#include "storage/browser/file_system/local_file_util.h" + +namespace chromeos { +namespace smb_client { + +SmbFsAsyncFileUtil::SmbFsAsyncFileUtil(Profile* profile) + : AsyncFileUtilAdapter(new storage::LocalFileUtil), profile_(profile) { + DCHECK(profile_); +} + +SmbFsAsyncFileUtil::~SmbFsAsyncFileUtil() = default; + +} // namespace smb_client +} // namespace chromeos
diff --git a/chrome/browser/chromeos/smb_client/fileapi/smbfs_async_file_util.h b/chrome/browser/chromeos/smb_client/fileapi/smbfs_async_file_util.h new file mode 100644 index 0000000..bf24b291 --- /dev/null +++ b/chrome/browser/chromeos/smb_client/fileapi/smbfs_async_file_util.h
@@ -0,0 +1,31 @@ +// Copyright 2020 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. + +#ifndef CHROME_BROWSER_CHROMEOS_SMB_CLIENT_FILEAPI_SMBFS_ASYNC_FILE_UTIL_H_ +#define CHROME_BROWSER_CHROMEOS_SMB_CLIENT_FILEAPI_SMBFS_ASYNC_FILE_UTIL_H_ + +#include "storage/browser/file_system/async_file_util_adapter.h" + +class Profile; + +namespace chromeos { +namespace smb_client { + +class SmbFsAsyncFileUtil : public storage::AsyncFileUtilAdapter { + public: + explicit SmbFsAsyncFileUtil(Profile* profile); + ~SmbFsAsyncFileUtil() override; + + SmbFsAsyncFileUtil() = delete; + SmbFsAsyncFileUtil(const SmbFsAsyncFileUtil&) = delete; + SmbFsAsyncFileUtil& operator=(const SmbFsAsyncFileUtil&) = delete; + + private: + Profile* const profile_; +}; + +} // namespace smb_client +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_SMB_CLIENT_FILEAPI_SMBFS_ASYNC_FILE_UTIL_H_
diff --git a/chrome/browser/chromeos/smb_client/fileapi/smbfs_file_system_backend_delegate.cc b/chrome/browser/chromeos/smb_client/fileapi/smbfs_file_system_backend_delegate.cc new file mode 100644 index 0000000..ac0632d --- /dev/null +++ b/chrome/browser/chromeos/smb_client/fileapi/smbfs_file_system_backend_delegate.cc
@@ -0,0 +1,61 @@ +// Copyright 2020 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 "chrome/browser/chromeos/smb_client/fileapi/smbfs_file_system_backend_delegate.h" + +#include "base/logging.h" +#include "chrome/browser/chromeos/smb_client/fileapi/smbfs_async_file_util.h" +#include "content/public/browser/browser_thread.h" +#include "storage/browser/file_system/file_stream_reader.h" +#include "storage/browser/file_system/file_stream_writer.h" + +namespace chromeos { +namespace smb_client { + +SmbFsFileSystemBackendDelegate::SmbFsFileSystemBackendDelegate(Profile* profile) + : async_file_util_(std::make_unique<SmbFsAsyncFileUtil>(profile)) {} + +SmbFsFileSystemBackendDelegate::~SmbFsFileSystemBackendDelegate() = default; + +storage::AsyncFileUtil* SmbFsFileSystemBackendDelegate::GetAsyncFileUtil( + storage::FileSystemType type) { + DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + DCHECK_EQ(storage::kFileSystemTypeSmbFs, type); + return async_file_util_.get(); +} + +std::unique_ptr<storage::FileStreamReader> +SmbFsFileSystemBackendDelegate::CreateFileStreamReader( + const storage::FileSystemURL& url, + int64_t offset, + int64_t max_bytes_to_read, + const base::Time& expected_modification_time, + storage::FileSystemContext* context) { + NOTREACHED(); + return nullptr; +} + +std::unique_ptr<storage::FileStreamWriter> +SmbFsFileSystemBackendDelegate::CreateFileStreamWriter( + const storage::FileSystemURL& url, + int64_t offset, + storage::FileSystemContext* context) { + NOTREACHED(); + return nullptr; +} + +storage::WatcherManager* SmbFsFileSystemBackendDelegate::GetWatcherManager( + storage::FileSystemType type) { + NOTREACHED(); + return nullptr; +} + +void SmbFsFileSystemBackendDelegate::GetRedirectURLForContents( + const storage::FileSystemURL& url, + storage::URLCallback callback) { + NOTREACHED(); +} + +} // namespace smb_client +} // namespace chromeos
diff --git a/chrome/browser/chromeos/smb_client/fileapi/smbfs_file_system_backend_delegate.h b/chrome/browser/chromeos/smb_client/fileapi/smbfs_file_system_backend_delegate.h new file mode 100644 index 0000000..1eadffb --- /dev/null +++ b/chrome/browser/chromeos/smb_client/fileapi/smbfs_file_system_backend_delegate.h
@@ -0,0 +1,50 @@ +// Copyright 2020 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. + +#ifndef CHROME_BROWSER_CHROMEOS_SMB_CLIENT_FILEAPI_SMBFS_FILE_SYSTEM_BACKEND_DELEGATE_H_ +#define CHROME_BROWSER_CHROMEOS_SMB_CLIENT_FILEAPI_SMBFS_FILE_SYSTEM_BACKEND_DELEGATE_H_ + +#include <memory> + +#include "chrome/browser/chromeos/fileapi/file_system_backend_delegate.h" + +class Profile; + +namespace chromeos { +namespace smb_client { + +class SmbFsAsyncFileUtil; + +class SmbFsFileSystemBackendDelegate + : public chromeos::FileSystemBackendDelegate { + public: + explicit SmbFsFileSystemBackendDelegate(Profile* profile); + ~SmbFsFileSystemBackendDelegate() override; + + // FileSystemBackend::Delegate overrides. + storage::AsyncFileUtil* GetAsyncFileUtil( + storage::FileSystemType type) override; + std::unique_ptr<storage::FileStreamReader> CreateFileStreamReader( + const storage::FileSystemURL& url, + int64_t offset, + int64_t max_bytes_to_read, + const base::Time& expected_modification_time, + storage::FileSystemContext* context) override; + std::unique_ptr<storage::FileStreamWriter> CreateFileStreamWriter( + const storage::FileSystemURL& url, + int64_t offset, + storage::FileSystemContext* context) override; + storage::WatcherManager* GetWatcherManager( + storage::FileSystemType type) override; + void GetRedirectURLForContents(const storage::FileSystemURL& url, + storage::URLCallback callback) override; + + private: + std::unique_ptr<SmbFsAsyncFileUtil> async_file_util_; +}; + +} // namespace smb_client +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_SMB_CLIENT_FILEAPI_SMBFS_FILE_SYSTEM_BACKEND_DELEGATE_H_
diff --git a/chrome/browser/data_reduction_proxy/data_reduction_proxy_browsertest.cc b/chrome/browser/data_reduction_proxy/data_reduction_proxy_browsertest.cc index a697e694..c4dc3aa 100644 --- a/chrome/browser/data_reduction_proxy/data_reduction_proxy_browsertest.cc +++ b/chrome/browser/data_reduction_proxy/data_reduction_proxy_browsertest.cc
@@ -110,7 +110,6 @@ return CreateEmptyProxyConfig(kSessionKey, 1000, 0, 0.5f, false); } - class TestSettingsObserver : public DataReductionProxySettingsObserver { public: TestSettingsObserver() = default; @@ -533,7 +532,6 @@ EXPECT_EQ(result, kDummyBody); } - IN_PROC_BROWSER_TEST_F(DataReductionProxyBrowsertest, ProxyNotUsedWhenDisabled) { net::EmbeddedTestServer test_server; @@ -627,8 +625,6 @@ EXPECT_EQ(GetBody(), kDummyBody); } - - // Test that enabling the holdback disables the proxy and that the client config // is fetched when lite page redirect preview is enabled. class DataReductionProxyWithHoldbackBrowsertest @@ -636,39 +632,36 @@ public DataReductionProxyBrowsertest { public: DataReductionProxyWithHoldbackBrowsertest() - : DataReductionProxyBrowsertest(), - // Consider the holdback as enabled if holdback is enabled or the - // |force_enable_config_service_fetches_| is enabled. + : // Consider the holdback as enabled if holdback is enabled or the + // |enable_config_service_fetches_| is enabled. data_reduction_proxy_holdback_enabled_(std::get<2>(GetParam()) || std::get<0>(GetParam())), lite_page_redirect_previews_enabled_(std::get<1>(GetParam())), - force_enable_config_service_fetches_(std::get<2>(GetParam())) {} + enable_config_service_fetches_(std::get<2>(GetParam())) {} void SetUp() override { - if (force_enable_config_service_fetches_) { - scoped_feature_list_.InitAndEnableFeatureWithParameters( - data_reduction_proxy::features::kDataReductionProxyHoldback, - {{"force_enable_config_service_fetches", "true"}}); - } - if (!force_enable_config_service_fetches_ && - data_reduction_proxy_holdback_enabled_) { - scoped_feature_list_.InitAndEnableFeature( - data_reduction_proxy::features::kDataReductionProxyHoldback); - } - if (lite_page_redirect_previews_enabled_) { - previews_lite_page_redirect_feature_list_.InitAndEnableFeature( - previews::features::kLitePageServerPreviews); - } + data_reduction_proxy_holdback_feature_list_.InitWithFeatureState( + data_reduction_proxy::features::kDataReductionProxyHoldback, + data_reduction_proxy_holdback_enabled_); + + fetch_client_config_feature_list_.InitWithFeatureState( + data_reduction_proxy::features::kFetchClientConfig, + enable_config_service_fetches_); + + previews_lite_page_redirect_feature_list_.InitWithFeatureState( + previews::features::kLitePageServerPreviews, + lite_page_redirect_previews_enabled_); InProcessBrowserTest::SetUp(); } const bool data_reduction_proxy_holdback_enabled_; const bool lite_page_redirect_previews_enabled_; - const bool force_enable_config_service_fetches_; + const bool enable_config_service_fetches_; private: - base::test::ScopedFeatureList scoped_feature_list_; + base::test::ScopedFeatureList data_reduction_proxy_holdback_feature_list_; + base::test::ScopedFeatureList fetch_client_config_feature_list_; base::test::ScopedFeatureList previews_lite_page_redirect_feature_list_; }; @@ -717,7 +710,6 @@ } }; - class DataReductionProxyExpFeatureBrowsertest : public DataReductionProxyBrowsertest { public: @@ -741,7 +733,6 @@ const std::string experiment_name = "foo_feature_experiment"; }; - // Threadsafe log for recording a sequence of events as newline separated text. class EventLog { public: @@ -859,7 +850,6 @@ EXPECT_FALSE(observer.last_initiator_origin().has_value()); } - // Simulate clicking on a same-site link. { content::TestNavigationObserver observer( @@ -883,5 +873,4 @@ } } - } // namespace data_reduction_proxy
diff --git a/chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry_unittest.cc b/chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry_unittest.cc index b60f7e4..e75b5e1 100644 --- a/chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry_unittest.cc +++ b/chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry_unittest.cc
@@ -161,25 +161,23 @@ // Add a rule. api::events::Rule rule; - api::events::Rule::Populate( - *base::test::ParseJsonDeprecated( - "{\n" - " \"id\": \"rule1\",\n" - " \"priority\": 100,\n" - " \"conditions\": [\n" - " {\n" - " \"instanceType\": \"declarativeContent.PageStateMatcher\",\n" - " \"test_predicate\": []\n" - " }],\n" - " \"actions\": [\n" - " { \"instanceType\": \"declarativeContent.ShowAction\" }\n" - " ]\n" - "}"), - &rule); + api::events::Rule::Populate(base::test::ParseJson(R"({ + "id": "rule1", + "priority": 100, + "conditions": [ + { + "instanceType": "declarativeContent.PageStateMatcher", + "test_predicate": [] + }], + "actions": [ + {"instanceType": "declarativeContent.ShowAction"} + ] + })"), + &rule); std::vector<const api::events::Rule*> rules({&rule}); - const Extension* extension = env()->MakeExtension( - *base::test::ParseJsonDeprecated("{\"page_action\": {}}")); + const Extension* extension = + env()->MakeExtension(base::test::ParseJson("{\"page_action\": {}}")); registry->AddRulesImpl(extension->id(), rules); registry->DidFinishNavigation(tab.get(), &navigation_handle);
diff --git a/chrome/browser/extensions/api/declarative_content/content_action_unittest.cc b/chrome/browser/extensions/api/declarative_content/content_action_unittest.cc index c41bf00..00eb884a 100644 --- a/chrome/browser/extensions/api/declarative_content/content_action_unittest.cc +++ b/chrome/browser/extensions/api/declarative_content/content_action_unittest.cc
@@ -33,7 +33,7 @@ namespace extensions { namespace { -using base::test::ParseJsonDeprecated; +using base::test::ParseJson; using testing::HasSubstr; std::unique_ptr<base::DictionaryValue> SimpleManifest() { @@ -74,27 +74,23 @@ // Test wrong data type passed. error.clear(); - result = ContentAction::Create(&profile, nullptr, *ParseJsonDeprecated("[]"), - &error); + result = ContentAction::Create(&profile, nullptr, ParseJson("[]"), &error); EXPECT_THAT(error, HasSubstr("missing instanceType")); EXPECT_FALSE(result.get()); // Test missing instanceType element. error.clear(); - result = ContentAction::Create(&profile, nullptr, *ParseJsonDeprecated("{}"), - &error); + result = ContentAction::Create(&profile, nullptr, ParseJson("{}"), &error); EXPECT_THAT(error, HasSubstr("missing instanceType")); EXPECT_FALSE(result.get()); // Test wrong instanceType element. error.clear(); - result = ContentAction::Create( - &profile, nullptr, - *ParseJsonDeprecated( - "{\n" - " \"instanceType\": \"declarativeContent.UnknownType\",\n" - "}"), - &error); + result = ContentAction::Create(&profile, nullptr, ParseJson(R"( + { + "instanceType": "declarativeContent.UnknownType", + })"), + &error); EXPECT_THAT(error, HasSubstr("invalid instanceType")); EXPECT_FALSE(result.get()); } @@ -118,13 +114,12 @@ TestingProfile profile; std::string error; - std::unique_ptr<const ContentAction> result = ContentAction::Create( - &profile, extension.get(), - *ParseJsonDeprecated( - "{\n" - " \"instanceType\": \"declarativeContent.ShowAction\",\n" - "}"), - &error); + std::unique_ptr<const ContentAction> result = + ContentAction::Create(&profile, extension.get(), ParseJson(R"( + { + "instanceType": "declarativeContent.ShowAction", + })"), + &error); EXPECT_THAT(error, testing::HasSubstr("without an action")); ASSERT_FALSE(result.get()); } @@ -148,8 +143,7 @@ TestingProfile profile; std::unique_ptr<const ContentAction> result = ContentAction::Create( nullptr, extension.get(), - *ParseJsonDeprecated( - R"({"instanceType": "declarativeContent.ShowAction"})"), + ParseJson(R"({"instanceType": "declarativeContent.ShowAction"})"), &error); EXPECT_TRUE(error.empty()) << error; ASSERT_TRUE(result.get()); @@ -220,8 +214,8 @@ .Set("imageData", DictionaryBuilder().Set("19", data64).Build()) .Build(); - const Extension* extension = env.MakeExtension(*ParseJsonDeprecated( - "{\"page_action\": { \"default_title\": \"Extension\" } }")); + const Extension* extension = env.MakeExtension( + ParseJson(R"({"page_action": {"default_title": "Extension"}})")); base::HistogramTester histogram_tester; TestingProfile profile; std::string error; @@ -279,8 +273,8 @@ .Build(); // Expect an error and no instance to be created. - const Extension* extension = env.MakeExtension(*ParseJsonDeprecated( - R"({"page_action": {"default_title": "Extension"}})")); + const Extension* extension = env.MakeExtension( + ParseJson(R"({"page_action": {"default_title": "Extension"}})")); base::HistogramTester histogram_tester; TestingProfile profile; std::string error; @@ -301,15 +295,14 @@ TEST_F(RequestContentScriptTest, MissingScripts) { Init(); std::string error; - std::unique_ptr<const ContentAction> result = ContentAction::Create( - profile(), extension(), - *ParseJsonDeprecated( - "{\n" - " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" - " \"allFrames\": true,\n" - " \"matchAboutBlank\": true\n" - "}"), - &error); + std::unique_ptr<const ContentAction> result = + ContentAction::Create(profile(), extension(), ParseJson(R"( + { + "instanceType": "declarativeContent.RequestContentScript", + "allFrames": true, + "matchAboutBlank": true + })"), + &error); EXPECT_THAT(error, testing::HasSubstr("Missing parameter is required")); ASSERT_FALSE(result.get()); } @@ -317,14 +310,13 @@ TEST_F(RequestContentScriptTest, CSS) { Init(); std::string error; - std::unique_ptr<const ContentAction> result = ContentAction::Create( - profile(), extension(), - *ParseJsonDeprecated( - "{\n" - " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" - " \"css\": [\"style.css\"]\n" - "}"), - &error); + std::unique_ptr<const ContentAction> result = + ContentAction::Create(profile(), extension(), ParseJson(R"( + { + "instanceType": "declarativeContent.RequestContentScript", + "css": ["style.css"] + })"), + &error); EXPECT_EQ("", error); ASSERT_TRUE(result.get()); } @@ -332,14 +324,13 @@ TEST_F(RequestContentScriptTest, JS) { Init(); std::string error; - std::unique_ptr<const ContentAction> result = ContentAction::Create( - profile(), extension(), - *ParseJsonDeprecated( - "{\n" - " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" - " \"js\": [\"script.js\"]\n" - "}"), - &error); + std::unique_ptr<const ContentAction> result = + ContentAction::Create(profile(), extension(), ParseJson(R"( + { + "instanceType": "declarativeContent.RequestContentScript", + "js": ["script.js"] + })"), + &error); EXPECT_EQ("", error); ASSERT_TRUE(result.get()); } @@ -347,43 +338,40 @@ TEST_F(RequestContentScriptTest, CSSBadType) { Init(); std::string error; - std::unique_ptr<const ContentAction> result = ContentAction::Create( - profile(), extension(), - *ParseJsonDeprecated( - "{\n" - " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" - " \"css\": \"style.css\"\n" - "}"), - &error); + std::unique_ptr<const ContentAction> result = + ContentAction::Create(profile(), extension(), ParseJson(R"( + { + "instanceType": "declarativeContent.RequestContentScript", + "css": "style.css" + })"), + &error); ASSERT_FALSE(result.get()); } TEST_F(RequestContentScriptTest, JSBadType) { Init(); std::string error; - std::unique_ptr<const ContentAction> result = ContentAction::Create( - profile(), extension(), - *ParseJsonDeprecated( - "{\n" - " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" - " \"js\": \"script.js\"\n" - "}"), - &error); + std::unique_ptr<const ContentAction> result = + ContentAction::Create(profile(), extension(), ParseJson(R"( + { + "instanceType": "declarativeContent.RequestContentScript", + "js": "script.js" + })"), + &error); ASSERT_FALSE(result.get()); } TEST_F(RequestContentScriptTest, AllFrames) { Init(); std::string error; - std::unique_ptr<const ContentAction> result = ContentAction::Create( - profile(), extension(), - *ParseJsonDeprecated( - "{\n" - " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" - " \"js\": [\"script.js\"],\n" - " \"allFrames\": true\n" - "}"), - &error); + std::unique_ptr<const ContentAction> result = + ContentAction::Create(profile(), extension(), ParseJson(R"( + { + "instanceType": "declarativeContent.RequestContentScript", + "js": ["script.js"], + "allFrames": true + })"), + &error); EXPECT_EQ("", error); ASSERT_TRUE(result.get()); } @@ -391,15 +379,14 @@ TEST_F(RequestContentScriptTest, MatchAboutBlank) { Init(); std::string error; - std::unique_ptr<const ContentAction> result = ContentAction::Create( - profile(), extension(), - *ParseJsonDeprecated( - "{\n" - " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" - " \"js\": [\"script.js\"],\n" - " \"matchAboutBlank\": true\n" - "}"), - &error); + std::unique_ptr<const ContentAction> result = + ContentAction::Create(profile(), extension(), ParseJson(R"( + { + "instanceType": "declarativeContent.RequestContentScript", + "js": ["script.js"], + "matchAboutBlank": true + })"), + &error); EXPECT_EQ("", error); ASSERT_TRUE(result.get()); } @@ -407,30 +394,28 @@ TEST_F(RequestContentScriptTest, AllFramesBadType) { Init(); std::string error; - std::unique_ptr<const ContentAction> result = ContentAction::Create( - profile(), extension(), - *ParseJsonDeprecated( - "{\n" - " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" - " \"js\": [\"script.js\"],\n" - " \"allFrames\": null\n" - "}"), - &error); + std::unique_ptr<const ContentAction> result = + ContentAction::Create(profile(), extension(), ParseJson(R"( + { + "instanceType": "declarativeContent.RequestContentScript", + "js": ["script.js"], + "allFrames": null + })"), + &error); ASSERT_FALSE(result.get()); } TEST_F(RequestContentScriptTest, MatchAboutBlankBadType) { Init(); std::string error; - std::unique_ptr<const ContentAction> result = ContentAction::Create( - profile(), extension(), - *ParseJsonDeprecated( - "{\n" - " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" - " \"js\": [\"script.js\"],\n" - " \"matchAboutBlank\": null\n" - "}"), - &error); + std::unique_ptr<const ContentAction> result = + ContentAction::Create(profile(), extension(), ParseJson(R"( + { + "instanceType": "declarativeContent.RequestContentScript", + "js": ["script.js"], + "matchAboutBlank": null + })"), + &error); ASSERT_FALSE(result.get()); }
diff --git a/chrome/browser/extensions/api/declarative_content/content_condition_unittest.cc b/chrome/browser/extensions/api/declarative_content/content_condition_unittest.cc index a53f33a..809b1285 100644 --- a/chrome/browser/extensions/api/declarative_content/content_condition_unittest.cc +++ b/chrome/browser/extensions/api/declarative_content/content_condition_unittest.cc
@@ -81,11 +81,10 @@ std::string error; std::unique_ptr<ContentCondition> condition = CreateContentCondition( nullptr, std::map<std::string, ContentPredicateFactory*>(), - *base::test::ParseJsonDeprecated( - "{\n" - " \"invalid\": \"foobar\",\n" - " \"instanceType\": \"declarativeContent.PageStateMatcher\",\n" - "}"), + base::test::ParseJson(R"({ + "invalid": "foobar", + "instanceType": "declarativeContent.PageStateMatcher", + })"), &error); EXPECT_THAT(error, HasSubstr("Unknown condition attribute")); EXPECT_FALSE(condition); @@ -98,12 +97,10 @@ predicate_factories["test_predicate"] = &factory; std::string error; std::unique_ptr<ContentCondition> condition = CreateContentCondition( - nullptr, predicate_factories, - *base::test::ParseJsonDeprecated( - "{\n" - " \"test_predicate\": \"\",\n" - " \"instanceType\": \"declarativeContent.PageStateMatcher\",\n" - "}"), + nullptr, predicate_factories, base::test::ParseJson(R"({ + "test_predicate": "", + "instanceType": "declarativeContent.PageStateMatcher", + })"), &error); EXPECT_EQ("error message", error); EXPECT_FALSE(condition); @@ -116,13 +113,11 @@ predicate_factories["test_predicate2"] = &factory2; std::string error; std::unique_ptr<ContentCondition> condition = CreateContentCondition( - nullptr, predicate_factories, - *base::test::ParseJsonDeprecated( - "{\n" - " \"test_predicate1\": {},\n" - " \"test_predicate2\": [],\n" - " \"instanceType\": \"declarativeContent.PageStateMatcher\",\n" - "}"), + nullptr, predicate_factories, base::test::ParseJson(R"({ + "test_predicate1": {}, + "test_predicate2": [], + "instanceType": "declarativeContent.PageStateMatcher", + })"), &error); ASSERT_TRUE(condition); ASSERT_EQ(1u, factory1.created_predicates().size());
diff --git a/chrome/browser/extensions/api/declarative_content/declarative_content_css_condition_tracker_unittest.cc b/chrome/browser/extensions/api/declarative_content/declarative_content_css_condition_tracker_unittest.cc index 0f5446c1..b6c4337 100644 --- a/chrome/browser/extensions/api/declarative_content/declarative_content_css_condition_tracker_unittest.cc +++ b/chrome/browser/extensions/api/declarative_content/declarative_content_css_condition_tracker_unittest.cc
@@ -107,8 +107,8 @@ void CreatePredicateImpl(const std::string& value, std::unique_ptr<const ContentPredicate>* predicate) { std::string error; - *predicate = tracker_.CreatePredicate( - nullptr, *base::test::ParseJsonDeprecated(value), &error); + *predicate = + tracker_.CreatePredicate(nullptr, base::test::ParseJson(value), &error); EXPECT_EQ("", error); ASSERT_TRUE(*predicate); } @@ -119,8 +119,8 @@ TEST(DeclarativeContentCssPredicateTest, WrongCssDatatype) { std::string error; std::unique_ptr<DeclarativeContentCssPredicate> predicate = - DeclarativeContentCssPredicate::Create( - nullptr, *base::test::ParseJsonDeprecated("\"selector\""), &error); + DeclarativeContentCssPredicate::Create(nullptr, base::Value("selector"), + &error); EXPECT_THAT(error, HasSubstr("invalid type")); EXPECT_FALSE(predicate); } @@ -129,8 +129,7 @@ std::string error; std::unique_ptr<DeclarativeContentCssPredicate> predicate = DeclarativeContentCssPredicate::Create( - nullptr, *base::test::ParseJsonDeprecated("[\"input\", \"a\"]"), - &error); + nullptr, base::test::ParseJson("[\"input\", \"a\"]"), &error); EXPECT_EQ("", error); ASSERT_TRUE(predicate);
diff --git a/chrome/browser/extensions/api/declarative_content/declarative_content_is_bookmarked_condition_tracker_unittest.cc b/chrome/browser/extensions/api/declarative_content/declarative_content_is_bookmarked_condition_tracker_unittest.cc index d8776af..cf7151f0 100644 --- a/chrome/browser/extensions/api/declarative_content/declarative_content_is_bookmarked_condition_tracker_unittest.cc +++ b/chrome/browser/extensions/api/declarative_content/declarative_content_is_bookmarked_condition_tracker_unittest.cc
@@ -13,7 +13,6 @@ #include "base/memory/ref_counted.h" #include "base/stl_util.h" #include "base/strings/utf_string_conversions.h" -#include "base/test/values_test_util.h" #include "chrome/browser/bookmarks/bookmark_model_factory.h" #include "chrome/browser/extensions/api/declarative_content/content_predicate_evaluator.h" #include "chrome/browser/extensions/api/declarative_content/declarative_content_condition_tracker_test.h" @@ -54,9 +53,7 @@ std::string error; std::unique_ptr<DeclarativeContentIsBookmarkedPredicate> predicate = DeclarativeContentIsBookmarkedPredicate::Create( - evaluator, extension, - *base::test::ParseJsonDeprecated(is_bookmarked ? "true" : "false"), - &error); + evaluator, extension, base::Value(is_bookmarked), &error); EXPECT_EQ("", error); EXPECT_TRUE(predicate); EXPECT_EQ(is_bookmarked, predicate->is_bookmarked()); @@ -169,8 +166,7 @@ std::string error; std::unique_ptr<DeclarativeContentIsBookmarkedPredicate> predicate = DeclarativeContentIsBookmarkedPredicate::Create( - nullptr, extension.get(), *base::test::ParseJsonDeprecated("true"), - &error); + nullptr, extension.get(), base::Value(true), &error); EXPECT_THAT(error, HasSubstr("requires 'bookmarks' permission")); EXPECT_FALSE(predicate); } @@ -183,7 +179,7 @@ std::string error; std::unique_ptr<DeclarativeContentIsBookmarkedPredicate> predicate = DeclarativeContentIsBookmarkedPredicate::Create( - nullptr, extension.get(), *base::test::ParseJsonDeprecated("[]"), + nullptr, extension.get(), base::Value(base::Value::Type::LIST), &error); EXPECT_THAT(error, HasSubstr("invalid type")); EXPECT_FALSE(predicate);
diff --git a/chrome/browser/extensions/api/developer_private/extension_info_generator.cc b/chrome/browser/extensions/api/developer_private/extension_info_generator.cc index 11988e0..ae5cfba 100644 --- a/chrome/browser/extensions/api/developer_private/extension_info_generator.cc +++ b/chrome/browser/extensions/api/developer_private/extension_info_generator.cc
@@ -560,8 +560,6 @@ info->disable_reasons.custodian_approval_required = (disable_reasons & disable_reason::DISABLE_CUSTODIAN_APPROVAL_REQUIRED) != 0; - info->disable_reasons.blocked_mature = - (disable_reasons & disable_reason::DISABLE_BLOCKED_MATURE) != 0; // Error collection. bool error_console_enabled =
diff --git a/chrome/browser/extensions/api/passwords_private/password_check_delegate.cc b/chrome/browser/extensions/api/passwords_private/password_check_delegate.cc index abdd113..f6abdc1 100644 --- a/chrome/browser/extensions/api/passwords_private/password_check_delegate.cc +++ b/chrome/browser/extensions/api/passwords_private/password_check_delegate.cc
@@ -4,12 +4,17 @@ #include "chrome/browser/extensions/api/passwords_private/password_check_delegate.h" +#include <stddef.h> + #include <algorithm> #include <memory> +#include "base/containers/flat_map.h" #include "base/containers/flat_set.h" +#include "base/memory/ref_counted.h" #include "base/numerics/safe_conversions.h" #include "base/optional.h" +#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" #include "chrome/browser/extensions/api/passwords_private/passwords_private_event_router.h" @@ -25,6 +30,7 @@ #include "components/password_manager/core/browser/android_affiliation/affiliation_utils.h" #include "components/password_manager/core/browser/bulk_leak_check_service.h" #include "components/password_manager/core/browser/compromised_credentials_table.h" +#include "components/password_manager/core/browser/leak_detection/bulk_leak_check.h" #include "components/password_manager/core/browser/leak_detection/encryption_utils.h" #include "components/password_manager/core/browser/ui/compromised_credentials_provider.h" #include "components/password_manager/core/browser/ui/credential_utils.h" @@ -40,24 +46,94 @@ namespace extensions { -namespace { - using autofill::PasswordForm; using password_manager::BulkLeakCheckService; +using password_manager::CanonicalizedCredential; using password_manager::CanonicalizeUsername; +using password_manager::CompromiseType; using password_manager::CredentialWithPassword; +using password_manager::LeakCheckCredential; using ui::TimeFormat; using CompromisedCredentialsView = password_manager::CompromisedCredentialsProvider::CredentialsView; using SavedPasswordsView = password_manager::SavedPasswordsPresenter::SavedPasswordsView; +// Key used to attach UserData to a LeakCheckCredential. +constexpr char kPasswordCheckDataKey[] = "password-check-data-key"; + +// Class remembering the state required to update the progress of an ongoing +// Password Check. +class PasswordCheckProgress : public base::RefCounted<PasswordCheckProgress> { + public: + base::WeakPtr<PasswordCheckProgress> GetWeakPtr() { + return weak_ptr_factory_.GetWeakPtr(); + } + + size_t remaining_in_queue() const { return remaining_in_queue_; } + size_t already_processed() const { return already_processed_; } + + // Increments the counts corresponding to |password|. Intended to be called + // for each credential that is passed to the bulk check. + void IncrementCounts(const PasswordForm& password) { + ++remaining_in_queue_; + ++counts_[password]; + } + + // Updates the counts after a |credential| has been processed by the bulk + // check. + void OnProcessed(const LeakCheckCredential& credential) { + auto it = counts_.find(credential); + const int num_matching = it != counts_.end() ? it->second : 0; + already_processed_ += num_matching; + remaining_in_queue_ -= num_matching; + } + + private: + friend class base::RefCounted<PasswordCheckProgress>; + ~PasswordCheckProgress() = default; + + // Count variables needed to correctly show the progress of the check to the + // user. |already_processed_| contains the number of credentials that have + // been checked already, while |remaining_in_queue_| remembers how many + // passwords still need to be checked. + // Since the bulk leak check tries to be as efficient as possible, it performs + // a deduplication step before starting to check passwords. In this step it + // canonicalizes each credential, and only processes the combinations that are + // unique. Since this number likely does not match the total number of saved + // passwords, we remember in |counts_| how many saved passwords a given + // canonicalized credential corresponds to. + size_t already_processed_ = 0; + size_t remaining_in_queue_ = 0; + base::flat_map<CanonicalizedCredential, size_t> counts_; + + base::WeakPtrFactory<PasswordCheckProgress> weak_ptr_factory_{this}; +}; + +namespace { + +// A class attached to each LeakCheckCredential that holds a shared handle to +// the PasswordCheckProgress and is able to update the progress accordingly. +class PasswordCheckData : public LeakCheckCredential::Data { + public: + explicit PasswordCheckData(scoped_refptr<PasswordCheckProgress> progress) + : progress_(std::move(progress)) {} + ~PasswordCheckData() override = default; + + std::unique_ptr<Data> Clone() override { + return std::make_unique<PasswordCheckData>(progress_); + } + + private: + scoped_refptr<PasswordCheckProgress> progress_; +}; + api::passwords_private::CompromiseType ConvertCompromiseType( - password_manager::CompromiseType type) { + CompromiseType type) { switch (type) { - case password_manager::CompromiseType::kLeaked: + case CompromiseType::kLeaked: return api::passwords_private::COMPROMISE_TYPE_LEAKED; - case password_manager::CompromiseType::kPhished: + case CompromiseType::kPhished: return api::passwords_private::COMPROMISE_TYPE_PHISHED; } @@ -303,8 +379,21 @@ } bool PasswordCheckDelegate::StartPasswordCheck() { - is_bulk_check_running_ = true; - return bulk_leak_check_service_adapter_.StartBulkLeakCheck(); + if (bulk_leak_check_service_adapter_.GetBulkLeakCheckState() == + BulkLeakCheckService::State::kRunning) { + return false; + } + + auto progress = base::MakeRefCounted<PasswordCheckProgress>(); + for (const auto& password : saved_passwords_presenter_.GetSavedPasswords()) + progress->IncrementCounts(password); + + password_check_progress_ = progress->GetWeakPtr(); + PasswordCheckData data(std::move(progress)); + is_check_running_ = bulk_leak_check_service_adapter_.StartBulkLeakCheck( + kPasswordCheckDataKey, &data); + DCHECK(is_check_running_); + return is_check_running_; } void PasswordCheckDelegate::StopPasswordCheck() { @@ -313,7 +402,6 @@ api::passwords_private::PasswordCheckStatus PasswordCheckDelegate::GetPasswordCheckStatus() const { - // TODO(crbug.com/1047726): Add support for QUOTA_LIMIT state. api::passwords_private::PasswordCheckStatus result; // Obtain the timestamp of the last completed check. This is 0.0 in case the @@ -333,12 +421,17 @@ // Handle the currently running case first, only then consider errors. if (state == BulkLeakCheckService::State::kRunning) { result.state = api::passwords_private::PASSWORD_CHECK_STATE_RUNNING; - result.remaining_in_queue = std::make_unique<int>( - bulk_leak_check_service_adapter_.GetPendingChecksCount()); - // Make sure we'll never surface a negative number in the UI. - result.already_processed = std::make_unique<int>( - std::max(0, base::checked_cast<int>(saved_passwords.size()) - - *result.remaining_in_queue)); + + if (password_check_progress_) { + result.already_processed = + std::make_unique<int>(password_check_progress_->already_processed()); + result.remaining_in_queue = + std::make_unique<int>(password_check_progress_->remaining_in_queue()); + } else { + result.already_processed = std::make_unique<int>(0); + result.remaining_in_queue = std::make_unique<int>(0); + } + return result; } @@ -375,10 +468,10 @@ } void PasswordCheckDelegate::OnStateChanged(BulkLeakCheckService::State state) { - if (is_bulk_check_running_ && state == BulkLeakCheckService::State::kIdle) { + if (is_check_running_ && state == BulkLeakCheckService::State::kIdle) { // When the service transitions from running into idle it has finished a // check. - is_bulk_check_running_ = false; + is_check_running_ = false; profile_->GetPrefs()->SetDouble( password_manager::prefs::kLastTimePasswordCheckCompleted, base::Time::Now().ToDoubleT()); @@ -391,26 +484,36 @@ } void PasswordCheckDelegate::OnCredentialDone( - const password_manager::LeakCheckCredential& credential, + const LeakCheckCredential& credential, password_manager::IsLeaked is_leaked) { - if (!is_leaked) - return; - - const base::string16 canocalized_username = - CanonicalizeUsername(credential.username()); - for (const PasswordForm& saved_password : - saved_passwords_presenter_.GetSavedPasswords()) { - if (saved_password.password_value == credential.password() && - CanonicalizeUsername(saved_password.username_value) == - canocalized_username) { - password_store_->AddCompromisedCredentials({ - .signon_realm = saved_password.signon_realm, - .username = saved_password.username_value, - .create_time = base::Time::Now(), - .compromise_type = password_manager::CompromiseType::kLeaked, - }); + if (is_leaked) { + // In case the credential is leaked, iterate over all currently saved + // credentials and mark those as compromised that have the same + // canonicalized username and password. + const base::string16 canocalized_username = + CanonicalizeUsername(credential.username()); + for (const PasswordForm& saved_password : + saved_passwords_presenter_.GetSavedPasswords()) { + if (saved_password.password_value == credential.password() && + CanonicalizeUsername(saved_password.username_value) == + canocalized_username) { + password_store_->AddCompromisedCredentials({ + .signon_realm = saved_password.signon_realm, + .username = saved_password.username_value, + .create_time = base::Time::Now(), + .compromise_type = CompromiseType::kLeaked, + }); + } } } + + // Update the progress in case there is one. + if (password_check_progress_) + password_check_progress_->OnProcessed(credential); + + // Trigger an update of the check status, considering that the progress has + // changed. + NotifyPasswordCheckStatusChanged(); } const CredentialWithPassword*
diff --git a/chrome/browser/extensions/api/passwords_private/password_check_delegate.h b/chrome/browser/extensions/api/passwords_private/password_check_delegate.h index 433fd4f..224b88c 100644 --- a/chrome/browser/extensions/api/passwords_private/password_check_delegate.h +++ b/chrome/browser/extensions/api/passwords_private/password_check_delegate.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_EXTENSIONS_API_PASSWORDS_PRIVATE_PASSWORD_CHECK_DELEGATE_H_ #include "base/memory/scoped_refptr.h" +#include "base/memory/weak_ptr.h" #include "base/scoped_observer.h" #include "chrome/browser/extensions/api/passwords_private/passwords_private_utils.h" #include "chrome/common/extensions/api/passwords_private.h" @@ -26,6 +27,10 @@ namespace extensions { +extern const char kPasswordCheckDataKey[]; + +class PasswordCheckProgress; + // This class handles the part of the passwordsPrivate extension API that deals // with the bulk password check feature. class PasswordCheckDelegate @@ -131,8 +136,12 @@ password_manager::BulkLeakCheckServiceAdapter bulk_leak_check_service_adapter_; - // Remembers whether the bulk check is running due to explicit user action. - bool is_bulk_check_running_ = false; + // Remembers the progress of the ongoing check. Null if no check is currently + // running. + base::WeakPtr<PasswordCheckProgress> password_check_progress_; + + // Remembers whether a password check is running right now. + bool is_check_running_ = false; // A scoped observer for |saved_passwords_presenter_|. ScopedObserver<password_manager::SavedPasswordsPresenter,
diff --git a/chrome/browser/extensions/api/passwords_private/password_check_delegate_unittest.cc b/chrome/browser/extensions/api/passwords_private/password_check_delegate_unittest.cc index 63aa7ce7..f4ddbfb 100644 --- a/chrome/browser/extensions/api/passwords_private/password_check_delegate_unittest.cc +++ b/chrome/browser/extensions/api/passwords_private/password_check_delegate_unittest.cc
@@ -862,7 +862,7 @@ Pointee(std::string("5 minutes ago"))); } -// Checks that a tranistion into the idle state after starting a check results +// Checks that a transition into the idle state after starting a check results // in resetting the kLastTimePasswordCheckCompleted pref to the current time. TEST_F(PasswordCheckDelegateTest, LastTimePasswordCheckCompletedReset) { delegate().StartPasswordCheck(); @@ -873,4 +873,53 @@ Pointee(std::string("Just now"))); } +// Checks that processing a credential by the leak check updates the progress +// correctly and raises the expected event. +TEST_F(PasswordCheckDelegateTest, OnCredentialDoneUpdatesProgress) { + const char* const kEventName = + api::passwords_private::OnPasswordCheckStatusChanged::kEventName; + + identity_test_env().MakeAccountAvailable(kTestEmail); + store().AddLogin(MakeSavedPassword(kExampleCom, kUsername1, kPassword1)); + store().AddLogin(MakeSavedPassword(kExampleCom, kUsername2, kPassword2)); + store().AddLogin(MakeSavedPassword(kExampleOrg, kUsername1, kPassword1)); + store().AddLogin(MakeSavedPassword(kExampleOrg, kUsername2, kPassword2)); + RunUntilIdle(); + + const auto event_iter = event_router_observer().events().find(kEventName); + delegate().StartPasswordCheck(); + EXPECT_EQ(events::PASSWORDS_PRIVATE_ON_PASSWORD_CHECK_STATUS_CHANGED, + event_iter->second->histogram_value); + auto status = PasswordCheckStatus::FromValue( + event_iter->second->event_args->GetList().front()); + EXPECT_EQ(api::passwords_private::PASSWORD_CHECK_STATE_RUNNING, + status->state); + EXPECT_EQ(0, *status->already_processed); + EXPECT_EQ(4, *status->remaining_in_queue); + + static_cast<BulkLeakCheckDelegateInterface*>(service())->OnFinishedCredential( + LeakCheckCredential(base::ASCIIToUTF16(kUsername1), + base::ASCIIToUTF16(kPassword1)), + IsLeaked(false)); + + status = PasswordCheckStatus::FromValue( + event_iter->second->event_args->GetList().front()); + EXPECT_EQ(api::passwords_private::PASSWORD_CHECK_STATE_RUNNING, + status->state); + EXPECT_EQ(2, *status->already_processed); + EXPECT_EQ(2, *status->remaining_in_queue); + + static_cast<BulkLeakCheckDelegateInterface*>(service())->OnFinishedCredential( + LeakCheckCredential(base::ASCIIToUTF16(kUsername2), + base::ASCIIToUTF16(kPassword2)), + IsLeaked(false)); + + status = PasswordCheckStatus::FromValue( + event_iter->second->event_args->GetList().front()); + EXPECT_EQ(api::passwords_private::PASSWORD_CHECK_STATE_RUNNING, + status->state); + EXPECT_EQ(4, *status->already_processed); + EXPECT_EQ(0, *status->remaining_in_queue); +} + } // namespace extensions
diff --git a/chrome/browser/extensions/api/terminal/terminal_private_browsertest.cc b/chrome/browser/extensions/api/terminal/terminal_private_browsertest.cc index 2736a32..69a7f6b7 100644 --- a/chrome/browser/extensions/api/terminal/terminal_private_browsertest.cc +++ b/chrome/browser/extensions/api/terminal/terminal_private_browsertest.cc
@@ -4,9 +4,11 @@ #include <memory> +#include "base/test/scoped_feature_list.h" #include "chrome/browser/chromeos/crostini/fake_crostini_features.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" +#include "chrome/common/chrome_features.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "content/public/test/browser_test_utils.h" @@ -17,7 +19,9 @@ class TerminalPrivateBrowserTest : public InProcessBrowserTest { public: - TerminalPrivateBrowserTest() = default; + TerminalPrivateBrowserTest() { + scoped_feature_list_.InitAndEnableFeature(features::kTerminalSystemApp); + } protected: void ExpectJsResult(const std::string& script, const std::string& expected) { @@ -30,6 +34,7 @@ } private: + base::test::ScopedFeatureList scoped_feature_list_; DISALLOW_COPY_AND_ASSIGN(TerminalPrivateBrowserTest); };
diff --git a/chrome/browser/extensions/convert_web_app_unittest.cc b/chrome/browser/extensions/convert_web_app_unittest.cc index 61e5791..4ab24e3 100644 --- a/chrome/browser/extensions/convert_web_app_unittest.cc +++ b/chrome/browser/extensions/convert_web_app_unittest.cc
@@ -485,7 +485,10 @@ // Tests that |file_handler| on the WebAppManifest is correctly converted // to |web_app_file_handlers| on an extension manifest. -TEST(ExtensionFromWebApp, WebAppFileHandlersAreCorrectlyConverted) { +// +// TODO(crbug.com/1062239): This test is failing on Windows trunk builds. It can +// be temporarily disabled, since the feature hasn't shipped yet. +TEST(ExtensionFromWebApp, DISABLED_WebAppFileHandlersAreCorrectlyConverted) { base::ScopedTempDir extensions_dir; ASSERT_TRUE(extensions_dir.CreateUniqueTempDir());
diff --git a/chrome/browser/extensions/extension_action_runner_unittest.cc b/chrome/browser/extensions/extension_action_runner_unittest.cc index 9e6f6ad2..477538f 100644 --- a/chrome/browser/extensions/extension_action_runner_unittest.cc +++ b/chrome/browser/extensions/extension_action_runner_unittest.cc
@@ -12,7 +12,6 @@ #include "chrome/browser/extensions/active_tab_permission_granter.h" #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" #include "chrome/browser/extensions/extension_action_runner.h" -#include "chrome/browser/extensions/extension_sync_service_factory.h" #include "chrome/browser/extensions/permissions_updater.h" #include "chrome/browser/extensions/scripting_permissions_modifier.h" #include "chrome/browser/extensions/tab_helper.h" @@ -170,10 +169,6 @@ void ExtensionActionRunnerUnitTest::SetUp() { ChromeRenderViewHostTestHarness::SetUp(); - // Skip syncing for testing purposes. - ExtensionSyncServiceFactory::GetInstance()->SetTestingFactory( - profile(), BrowserContextKeyedServiceFactory::TestingFactory()); - TabHelper::CreateForWebContents(web_contents()); TabHelper* tab_helper = TabHelper::FromWebContents(web_contents()); // These should never be null.
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index 066fcf7..30784c6 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc
@@ -786,8 +786,6 @@ void ExtensionService::DisableExtension(const std::string& extension_id, int disable_reasons) { CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK(disable_reasons != disable_reason::DISABLE_BLOCKED_MATURE || - profile()->IsChild()); extension_registrar_.DisableExtension(extension_id, disable_reasons); } @@ -1032,7 +1030,6 @@ // related disable reasons. if (!profile()->IsChild()) { disable_reasons &= (~disable_reason::DISABLE_CUSTODIAN_APPROVAL_REQUIRED); - disable_reasons &= (~disable_reason::DISABLE_BLOCKED_MATURE); } extension_prefs_->ReplaceDisableReasons(extension->id(), disable_reasons);
diff --git a/chrome/browser/extensions/permission_message_combinations_unittest.cc b/chrome/browser/extensions/permission_message_combinations_unittest.cc index 2f800e4..a1074a2 100644 --- a/chrome/browser/extensions/permission_message_combinations_unittest.cc +++ b/chrome/browser/extensions/permission_message_combinations_unittest.cc
@@ -46,7 +46,7 @@ std::replace(json_manifest_with_double_quotes.begin(), json_manifest_with_double_quotes.end(), '\'', '"'); app_ = env_.MakeExtension( - *base::test::ParseJsonDeprecated(json_manifest_with_double_quotes), + base::test::ParseJson(json_manifest_with_double_quotes), kAllowlistedExtensionID); }
diff --git a/chrome/browser/extensions/service_worker_messaging_apitest.cc b/chrome/browser/extensions/service_worker_messaging_apitest.cc index 2248674..6f28a595 100644 --- a/chrome/browser/extensions/service_worker_messaging_apitest.cc +++ b/chrome/browser/extensions/service_worker_messaging_apitest.cc
@@ -8,9 +8,13 @@ #include "chrome/common/chrome_switches.h" #include "chrome/test/base/ui_test_utils.h" #include "components/version_info/version_info.h" +#include "content/public/browser/storage_partition.h" +#include "content/public/test/service_worker_test_helpers.h" #include "extensions/common/scoped_worker_based_extensions_channel.h" #include "extensions/test/extension_test_message_listener.h" #include "extensions/test/result_catcher.h" +#include "extensions/test/test_extension_dir.h" +#include "net/dns/mock_host_resolver.h" namespace extensions { @@ -19,7 +23,27 @@ ServiceWorkerMessagingTest() = default; ~ServiceWorkerMessagingTest() override = default; + void SetUpOnMainThread() override { + ExtensionApiTest::SetUpOnMainThread(); + host_resolver()->AddRule("*", "127.0.0.1"); + } + protected: + // TODO(lazyboy): Move this to a common place so it can be shared with other + // tests. + void StopServiceWorker(const Extension& extension) { + content::StoragePartition* storage_partition = + content::BrowserContext::GetDefaultStoragePartition( + browser()->profile()); + content::ServiceWorkerContext* context = + storage_partition->GetServiceWorkerContext(); + base::RunLoop run_loop; + // The service worker is registered at the root scope. + content::StopServiceWorkerForScope(context, extension.url(), + run_loop.QuitClosure()); + run_loop.Run(); + } + extensions::ScopedTestNativeMessagingHost test_host_; private: @@ -76,6 +100,63 @@ EXPECT_TRUE(reply_listener.WaitUntilSatisfied()); } +// Tests that a message port disconnects if the extension SW is forcefully +// stopped. +// Regression test for https://crbug.com/1033783. +IN_PROC_BROWSER_TEST_F(ServiceWorkerMessagingTest, + TabToWorker_StopWorkerDisconnects) { + ASSERT_TRUE(StartEmbeddedTestServer()); + + TestExtensionDir test_dir; + test_dir.WriteManifest( + R"({ + "name": "Content script disconnect on worker stop test", + "description": "Tests worker shutdown behavior for messaging", + "version": "0.1", + "manifest_version": 2, + "background": {"service_worker": "service_worker_background.js"}, + "content_scripts": [{ + "matches": ["*://example.com:*/*"], + "js": ["content_script.js"] + }] + })"); + test_dir.WriteFile(FILE_PATH_LITERAL("service_worker_background.js"), + R"(chrome.runtime.onConnect.addListener((port) => { + console.log('background: runtime.onConnect'); + chrome.test.assertNoLastError(); + chrome.test.notifyPass(); + }); + chrome.test.notifyPass(); + )"); + test_dir.WriteFile(FILE_PATH_LITERAL("content_script.js"), + R"(var port = chrome.runtime.connect({name:"foo"}); + port.onDisconnect.addListener(() => { + console.log('content script: port.onDisconnect'); + chrome.test.assertNoLastError(); + chrome.test.notifyPass(); + }); + )"); + ResultCatcher catcher; + const Extension* extension = LoadExtension(test_dir.UnpackedPath()); + ASSERT_TRUE(extension); + + // Wait for the extension to register runtime.onConnect listener. + EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); + + GURL url = + embedded_test_server()->GetURL("example.com", "/extensions/body1.html"); + ui_test_utils::NavigateToURL(browser(), url); + + // Wait for the content script to connect to the worker's port. + EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); + + // Stop the service worker, this will disconnect the port. + StopServiceWorker(*extension); + + // Wait for the port to disconnect in the content script. + EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); +} + // Tests chrome.runtime.sendNativeMessage from SW extension to a native // messaging host. IN_PROC_BROWSER_TEST_F(ServiceWorkerMessagingTest, NativeMessagingBasic) {
diff --git a/chrome/browser/extensions/updater/extension_updater_unittest.cc b/chrome/browser/extensions/updater/extension_updater_unittest.cc index 3e4c5de..7b04247 100644 --- a/chrome/browser/extensions/updater/extension_updater_unittest.cc +++ b/chrome/browser/extensions/updater/extension_updater_unittest.cc
@@ -696,7 +696,7 @@ std::unique_ptr<ManifestFetchData> fetch_data( CreateManifestFetchData(GURL("http://localhost/foo"))); fetch_data->AddExtension(id, version, &kNeverPingedData, std::string(), - std::string(), std::string(), + std::string(), Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); std::map<std::string, std::string> params; @@ -715,7 +715,7 @@ std::unique_ptr<ManifestFetchData> fetch_data( CreateManifestFetchData(GURL("http://localhost/foo"))); fetch_data->AddExtension(id, version, &kNeverPingedData, "bar", - std::string(), std::string(), + std::string(), Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); std::map<std::string, std::string> params; VerifyQueryAndExtractParameters(fetch_data->full_url().query(), ¶ms); @@ -733,7 +733,7 @@ std::unique_ptr<ManifestFetchData> fetch_data( CreateManifestFetchData(GURL("http://localhost/foo"))); fetch_data->AddExtension(id, version, &kNeverPingedData, "a=1&b=2&c", - std::string(), std::string(), + std::string(), Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); std::map<std::string, std::string> params; VerifyQueryAndExtractParameters(fetch_data->full_url().query(), ¶ms); @@ -837,7 +837,8 @@ std::unique_ptr<ManifestFetchData> fetch_data( CreateManifestFetchData(GURL("http://localhost/foo"))); fetch_data->AddExtension(id, version, &kNeverPingedData, - kEmptyUpdateUrlData, install_source, std::string(), + kEmptyUpdateUrlData, install_source, + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); std::map<std::string, std::string> params; VerifyQueryAndExtractParameters(fetch_data->full_url().query(), ¶ms); @@ -854,9 +855,10 @@ // Make sure that installedby= appears in the x= parameter. std::unique_ptr<ManifestFetchData> fetch_data( CreateManifestFetchData(GURL("http://localhost/foo"))); - fetch_data->AddExtension( - id, version, &kNeverPingedData, kEmptyUpdateUrlData, std::string(), - install_location, ManifestFetchData::FetchPriority::BACKGROUND); + fetch_data->AddExtension(id, version, &kNeverPingedData, + kEmptyUpdateUrlData, std::string(), + Manifest::Location::EXTERNAL_PREF_DOWNLOAD, + ManifestFetchData::FetchPriority::BACKGROUND); std::map<std::string, std::string> params; VerifyQueryAndExtractParameters(fetch_data->full_url().query(), ¶ms); EXPECT_EQ(id, params["id"]); @@ -886,11 +888,13 @@ const std::string id1 = crx_file::id_util::GenerateId("1"); const std::string id2 = crx_file::id_util::GenerateId("2"); fetch_data->AddExtension(id1, "1.0.0.0", &kNeverPingedData, - kEmptyUpdateUrlData, std::string(), std::string(), + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); AddParseResult(id1, "1.1", "http://localhost/e1_1.1.crx", &updates); fetch_data->AddExtension(id2, "2.0.0.0", &kNeverPingedData, - kEmptyUpdateUrlData, std::string(), std::string(), + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); AddParseResult(id2, "2.0.0.0", "http://localhost/e2_2.0.crx", &updates); @@ -935,32 +939,38 @@ const std::string id6 = crx_file::id_util::GenerateId("6"); fetch_data->AddExtension(id1, "1.0.0.0", &kNeverPingedData, - kEmptyUpdateUrlData, std::string(), std::string(), + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); AddParseResult(id1, "1.1", "http://localhost/e1_1.1.crx", &updates); fetch_data->AddExtension(id2, "2.0.0.0", &kNeverPingedData, - kEmptyUpdateUrlData, std::string(), std::string(), + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); AddParseResult(id2, "2.0.0.0", "http://localhost/e2_2.0.crx", &updates); fetch_data->AddExtension(id3, "0.0.0.0", &kNeverPingedData, - kEmptyUpdateUrlData, std::string(), std::string(), + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); // Empty update version in manifest. AddParseResult(id3, "", "http://localhost/e3_3.0.crx", &updates); fetch_data->AddExtension(id4, "0.0.0.0", &kNeverPingedData, - kEmptyUpdateUrlData, std::string(), std::string(), + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); fetch_data->AddExtension(id5, "0.0.0.0", &kNeverPingedData, - kEmptyUpdateUrlData, std::string(), std::string(), + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); AddParseResult(id5, "5.0.0.0", "http://localhost/e5_5.0.crx", &updates); fetch_data->AddExtension(id6, "0.0.0.0", &kNeverPingedData, - kEmptyUpdateUrlData, std::string(), std::string(), + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); // Invalid update version in manifest. AddParseResult(id6, "invalid_version", "http://localhost/e6_6.0.crx", @@ -1008,9 +1018,10 @@ &ids_for_update_check); for (const std::string& id : ids_for_update_check) { - fetch_data->AddExtension( - id, "1.0.0.0", &kNeverPingedData, kEmptyUpdateUrlData, std::string(), - std::string(), ManifestFetchData::FetchPriority::BACKGROUND); + fetch_data->AddExtension(id, "1.0.0.0", &kNeverPingedData, + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, + ManifestFetchData::FetchPriority::BACKGROUND); AddParseResult(id, "1.1", "http://localhost/e1_1.1.crx", &updates); } @@ -1045,25 +1056,32 @@ std::unique_ptr<ManifestFetchData> fetch_data( CreateManifestFetchData(GURL("http://localhost/foo"))); fetch_data->AddExtension(id1, "1.1.0.0", &kNeverPingedData, - kEmptyUpdateUrlData, std::string(), std::string(), + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); fetch_data->AddExtension(id2, "1.2.0.0", &kNeverPingedData, - kEmptyUpdateUrlData, std::string(), std::string(), + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); fetch_data->AddExtension(id3, "1.3.0.0", &kNeverPingedData, - kEmptyUpdateUrlData, std::string(), std::string(), + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); fetch_data->AddExtension(id4, "1.4.0.0", &kNeverPingedData, - kEmptyUpdateUrlData, std::string(), std::string(), + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); fetch_data->AddExtension(id5, "1.5.0.0", &kNeverPingedData, - kEmptyUpdateUrlData, std::string(), std::string(), + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); fetch_data->AddExtension(id6, "1.6.0.0", &kNeverPingedData, - kEmptyUpdateUrlData, std::string(), std::string(), + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); fetch_data->AddExtension(id7, "1.7.0.0", &kNeverPingedData, - kEmptyUpdateUrlData, std::string(), std::string(), + kEmptyUpdateUrlData, std::string(), + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); UpdateManifestResults updates; @@ -1122,16 +1140,16 @@ CreateManifestFetchData(kUpdateUrl)); ManifestFetchData::PingData zeroDays(0, 0, true, 0); fetch1->AddExtension("1111", "1.0", &zeroDays, kEmptyUpdateUrlData, - std::string(), std::string(), + std::string(), Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); fetch2->AddExtension("2222", "2.0", &zeroDays, kEmptyUpdateUrlData, - std::string(), std::string(), + std::string(), Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); fetch3->AddExtension("3333", "3.0", &zeroDays, kEmptyUpdateUrlData, - std::string(), std::string(), + std::string(), Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); fetch4->AddExtension("4444", "4.0", &zeroDays, kEmptyUpdateUrlData, - std::string(), std::string(), + std::string(), Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); // This will start the first fetcher and queue the others. The next in queue @@ -1257,7 +1275,7 @@ CreateManifestFetchData(kUpdateUrl)); ManifestFetchData::PingData zeroDays(0, 0, true, 0); fetch->AddExtension("1111", "1.0", &zeroDays, kEmptyUpdateUrlData, - std::string(), std::string(), + std::string(), Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); // This will start the first fetcher. @@ -1291,7 +1309,7 @@ // should not retry. fetch.reset(CreateManifestFetchData(kUpdateUrl)); fetch->AddExtension("1111", "1.0", &zeroDays, kEmptyUpdateUrlData, - std::string(), std::string(), + std::string(), Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); // This will start the first fetcher. @@ -1337,7 +1355,7 @@ CreateManifestFetchData(kUpdateUrl)); ManifestFetchData::PingData zeroDays(0, 0, true, 0); fetch->AddExtension("1111", "1.0", &zeroDays, kEmptyUpdateUrlData, - std::string(), std::string(), + std::string(), Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); helper.downloader().StartUpdateCheck(std::move(fetch)); @@ -1366,7 +1384,7 @@ CreateManifestFetchData(kUpdateUrl)); ManifestFetchData::PingData zeroDays(0, 0, true, 0); fetch->AddExtension("1111", "1.0", &zeroDays, kEmptyUpdateUrlData, - std::string(), std::string(), + std::string(), Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); helper.downloader().StartUpdateCheck(std::move(fetch)); @@ -2039,7 +2057,7 @@ const Extension* extension = tmp[0].get(); fetch_data->AddExtension(extension->id(), extension->VersionString(), &kNeverPingedData, kEmptyUpdateUrlData, - std::string(), std::string(), + std::string(), Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); auto results = std::make_unique<UpdateManifestResults>(); constexpr int kDaystartElapsedSeconds = 750; @@ -2064,9 +2082,9 @@ std::unique_ptr<ManifestFetchData> fetch_data( CreateManifestFetchData(GURL("http://localhost/foo"), data_priority)); - ASSERT_TRUE(fetch_data->AddExtension(id, version, &kNeverPingedData, - std::string(), std::string(), - std::string(), extension_priority)); + ASSERT_TRUE(fetch_data->AddExtension( + id, version, &kNeverPingedData, std::string(), std::string(), + Manifest::Location::INTERNAL, extension_priority)); ASSERT_EQ(expected_priority, fetch_data->fetch_priority()); }
diff --git a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java index 3564369e8..816feb13 100644 --- a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java +++ b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java
@@ -50,9 +50,18 @@ /** * @see FeatureList#setTestFeatures + * Sets the feature flags to use in JUnit tests, since native calls are not available there. + * Do not use directly, prefer using the {@link Features} annotation. + * + * @see Features + * @see Features.Processor + * + * @deprecated + * https://crbug.com/1058993 */ // TODO(crbug.com/1060097): Migrate callers to the FeatureList equivalent function. @VisibleForTesting + @Deprecated public static void setTestFeatures(Map<String, Boolean> features) { FeatureList.setTestFeatures(features); }
diff --git a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureListWithProcessorUnitTest.java b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureListWithProcessorUnitTest.java index 8af1c538..4d47dd0 100644 --- a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureListWithProcessorUnitTest.java +++ b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureListWithProcessorUnitTest.java
@@ -18,8 +18,6 @@ import org.chromium.chrome.test.util.browser.Features.DisableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures; -import java.util.Collections; - /** * Tests the behavior of {@link ChromeFeatureList} in Robolectric unit tests when the rule * Features.JUnitProcessor is present. @@ -28,7 +26,7 @@ @Config(manifest = Config.NONE) public class ChromeFeatureListWithProcessorUnitTest { @Rule - public TestRule mProcessor = new Features.JUnitProcessor(); + public TestRule mFeaturesProcessorRule = new Features.JUnitProcessor(); /** * In unit tests, all flags checked must have their value specified. @@ -69,11 +67,9 @@ * {@link ChromeFeatureList#setTestFeatures(java.util.Map)}. */ @Test + @EnableFeatures(ChromeFeatureList.TEST_DEFAULT_DISABLED) public void testSetTestFeaturesEnabled_returnsEnabled() { - ChromeFeatureList.setTestFeatures( - Collections.singletonMap(ChromeFeatureList.TEST_DEFAULT_DISABLED, true)); assertTrue(ChromeFeatureList.isEnabled(ChromeFeatureList.TEST_DEFAULT_DISABLED)); - ChromeFeatureList.setTestFeatures(null); } /** @@ -81,10 +77,8 @@ * {@link ChromeFeatureList#setTestFeatures(java.util.Map)}. */ @Test + @DisableFeatures(ChromeFeatureList.TEST_DEFAULT_ENABLED) public void testSetTestFeaturesDisabled_returnsDisabled() { - ChromeFeatureList.setTestFeatures( - Collections.singletonMap(ChromeFeatureList.TEST_DEFAULT_ENABLED, false)); assertFalse(ChromeFeatureList.isEnabled(ChromeFeatureList.TEST_DEFAULT_ENABLED)); - ChromeFeatureList.setTestFeatures(null); } }
diff --git a/chrome/browser/media/feeds/media_feeds_browsertest.cc b/chrome/browser/media/feeds/media_feeds_browsertest.cc index 076d0fe..b7c9ee52 100644 --- a/chrome/browser/media/feeds/media_feeds_browsertest.cc +++ b/chrome/browser/media/feeds/media_feeds_browsertest.cc
@@ -8,7 +8,6 @@ #include "base/task/post_task.h" #include "base/test/bind_test_util.h" #include "base/test/scoped_feature_list.h" -#include "build/build_config.h" #include "chrome/browser/media/feeds/media_feeds_contents_observer.h" #include "chrome/browser/media/history/media_history_feeds_table.h" #include "chrome/browser/media/history/media_history_keyed_service.h" @@ -124,31 +123,21 @@ "<link rel=other type=\"application/ld+json\" href=\"/test\"/>", false})); -// Crashes on Mac/Win only. http://crbug.com/1060626 -#if defined(OS_WIN) || defined(OS_MACOSX) -#define MAYBE_Discover DISABLED_Discover -#else -#define MAYBE_Discover Discover -#endif - -IN_PROC_BROWSER_TEST_P(MediaFeedsBrowserTest, MAYBE_Discover) { +IN_PROC_BROWSER_TEST_P(MediaFeedsBrowserTest, Discover) { EXPECT_TRUE(GetDiscoveredFeedURLs().empty()); MediaFeedsContentsObserver* contents_observer = static_cast<MediaFeedsContentsObserver*>( MediaFeedsContentsObserver::FromWebContents(GetWebContents())); - auto* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); GURL test_url(embedded_test_server()->GetURL(kMediaFeedsTestURL)); // The contents observer will call this closure when it has checked for a // media feed. base::RunLoop run_loop; - contents_observer->SetClosureForTest(base::BindLambdaForTesting([&]() { - if (web_contents->GetLastCommittedURL() == test_url) - run_loop.Quit(); - })); + contents_observer->SetClosureForTest( + base::BindLambdaForTesting([&]() { run_loop.Quit(); })); ui_test_utils::NavigateToURL(browser(), test_url);
diff --git a/chrome/browser/media/history/media_history_browsertest.cc b/chrome/browser/media/history/media_history_browsertest.cc index 13af6c3..5d97074 100644 --- a/chrome/browser/media/history/media_history_browsertest.cc +++ b/chrome/browser/media/history/media_history_browsertest.cc
@@ -20,6 +20,8 @@ #include "chrome/browser/ui/browser.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" +#include "components/history/core/common/pref_names.h" +#include "components/prefs/pref_service.h" #include "content/public/browser/media_session.h" #include "content/public/test/test_utils.h" #include "media/base/media_switches.h" @@ -34,11 +36,21 @@ constexpr base::TimeDelta kTestClipDuration = base::TimeDelta::FromMilliseconds(26771); +enum class TestState { + kNormal, + + // Runs the test in incognito mode. + kIncognito, + + // Runs the test with the "SavingBrowserHistoryDisabled" policy enabled. + kSavingBrowserHistoryDisabled, +}; + } // namespace // Runs the test with a param to signify the profile being incognito if true. class MediaHistoryBrowserTest : public InProcessBrowserTest, - public testing::WithParamInterface<bool> { + public testing::WithParamInterface<TestState> { public: MediaHistoryBrowserTest() = default; ~MediaHistoryBrowserTest() override = default; @@ -290,16 +302,28 @@ } Browser* CreateBrowserFromParam() { - return GetParam() ? CreateIncognitoBrowser() : browser(); + if (GetParam() == TestState::kIncognito) { + return CreateIncognitoBrowser(); + } else if (GetParam() == TestState::kSavingBrowserHistoryDisabled) { + browser()->profile()->GetPrefs()->SetBoolean( + prefs::kSavingBrowserHistoryDisabled, true); + } + + return browser(); } - bool IsReadOnly() const { return GetParam(); } + bool IsReadOnly() const { return GetParam() != TestState::kNormal; } private: base::test::ScopedFeatureList scoped_feature_list_; }; -INSTANTIATE_TEST_SUITE_P(All, MediaHistoryBrowserTest, testing::Bool()); +INSTANTIATE_TEST_SUITE_P( + All, + MediaHistoryBrowserTest, + testing::Values(TestState::kNormal, + TestState::kIncognito, + TestState::kSavingBrowserHistoryDisabled)); IN_PROC_BROWSER_TEST_P(MediaHistoryBrowserTest, RecordMediaSession_OnNavigate_Incomplete) {
diff --git a/chrome/browser/media/history/media_history_keyed_service.cc b/chrome/browser/media/history/media_history_keyed_service.cc index b2eb2fa..669cd2b 100644 --- a/chrome/browser/media/history/media_history_keyed_service.cc +++ b/chrome/browser/media/history/media_history_keyed_service.cc
@@ -11,6 +11,8 @@ #include "chrome/browser/media/history/media_history_keyed_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "components/history/core/browser/history_service.h" +#include "components/history/core/common/pref_names.h" +#include "components/prefs/pref_service.h" #include "content/public/browser/browser_context.h" #include "media/base/media_switches.h" @@ -18,13 +20,17 @@ // StoreHolder will in most cases hold a local MediaHistoryStore. However, for // OTR profiles we hold a pointer to the original profile store. When accessing -// MediaHistoryStore you should use GetForRead for read operations and -// GetForWrite for write operations. This can be null if the store is read only. +// MediaHistoryStore you should use GetForRead for read operations, +// GetForWrite for write operations and GetForDelete for delete operations. +// These can be null if the store is read only or we disable storing browsing +// history. class MediaHistoryKeyedService::StoreHolder { public: - explicit StoreHolder(std::unique_ptr<MediaHistoryStore> local) - : local_(std::move(local)) {} - explicit StoreHolder(MediaHistoryKeyedService* remote) : remote_(remote) {} + explicit StoreHolder(Profile* profile, + std::unique_ptr<MediaHistoryStore> local) + : profile_(profile), local_(std::move(local)) {} + explicit StoreHolder(Profile* profile, MediaHistoryKeyedService* remote) + : profile_(profile), remote_(remote) {} ~StoreHolder() = default; StoreHolder(const StoreHolder& t) = delete; @@ -37,12 +43,21 @@ } MediaHistoryStore* GetForWrite() { + if (profile_->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled)) + return nullptr; + if (local_) + return local_.get(); + return nullptr; + } + + MediaHistoryStore* GetForDelete() { if (local_) return local_.get(); return nullptr; } private: + Profile* profile_; std::unique_ptr<MediaHistoryStore> local_; MediaHistoryKeyedService* remote_ = nullptr; }; @@ -60,14 +75,15 @@ MediaHistoryKeyedService::Get(profile->GetOriginalProfile()); DCHECK(original); - store_ = std::make_unique<StoreHolder>(original); + store_ = std::make_unique<StoreHolder>(profile, original); } else { auto db_task_runner = base::ThreadPool::CreateUpdateableSequencedTaskRunner( {base::MayBlock(), base::TaskPriority::USER_VISIBLE, base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}); - store_ = std::make_unique<StoreHolder>(std::make_unique<MediaHistoryStore>( - profile_, std::move(db_task_runner))); + store_ = std::make_unique<StoreHolder>( + profile_, std::make_unique<MediaHistoryStore>( + profile_, std::move(db_task_runner))); } } @@ -93,7 +109,7 @@ history::HistoryService* history_service, const history::DeletionInfo& deletion_info) { // The store might not always be writable. - auto* store = store_->GetForWrite(); + auto* store = store_->GetForDelete(); if (!store) return;
diff --git a/chrome/browser/media/history/media_history_keyed_service_unittest.cc b/chrome/browser/media/history/media_history_keyed_service_unittest.cc index 3724dd9..39fa7014 100644 --- a/chrome/browser/media/history/media_history_keyed_service_unittest.cc +++ b/chrome/browser/media/history/media_history_keyed_service_unittest.cc
@@ -23,7 +23,9 @@ #include "chrome/test/base/testing_profile.h" #include "components/history/core/browser/history_database_params.h" #include "components/history/core/browser/history_service.h" +#include "components/history/core/common/pref_names.h" #include "components/history/core/test/test_history_database.h" +#include "components/prefs/pref_service.h" #include "content/public/browser/media_player_watch_time.h" #include "content/public/test/test_utils.h" #include "services/media_session/public/cpp/media_image.h" @@ -47,9 +49,18 @@ return service; } +enum class TestState { + kNormal, + + // Runs the test with the "SavingBrowserHistoryDisabled" policy enabled. + kSavingBrowserHistoryDisabled, +}; + } // namespace -class MediaHistoryKeyedServiceTest : public ChromeRenderViewHostTestHarness { +class MediaHistoryKeyedServiceTest + : public ChromeRenderViewHostTestHarness, + public testing::WithParamInterface<TestState> { public: void SetUp() override { scoped_feature_list_.InitWithFeatures( @@ -84,6 +95,9 @@ } void TearDown() override { + profile()->GetPrefs()->SetBoolean(prefs::kSavingBrowserHistoryDisabled, + false); + service_->Shutdown(); // Tests that run a history service that uses the mock task runner for @@ -152,6 +166,14 @@ return images; } + void MaybeSetSavingBrowsingHistoryDisabled() { + if (GetParam() != TestState::kSavingBrowserHistoryDisabled) + return; + + profile()->GetPrefs()->SetBoolean(prefs::kSavingBrowserHistoryDisabled, + true); + } + scoped_refptr<base::TestMockTimeTaskRunner> mock_time_task_runner_; private: @@ -162,7 +184,13 @@ base::test::ScopedFeatureList scoped_feature_list_; }; -TEST_F(MediaHistoryKeyedServiceTest, CleanUpDatabaseWhenHistoryIsDeleted) { +INSTANTIATE_TEST_SUITE_P( + All, + MediaHistoryKeyedServiceTest, + testing::Values(TestState::kNormal, + TestState::kSavingBrowserHistoryDisabled)); + +TEST_P(MediaHistoryKeyedServiceTest, CleanUpDatabaseWhenHistoryIsDeleted) { history::HistoryService* history = HistoryServiceFactory::GetForProfile( profile(), ServiceAccessType::IMPLICIT_ACCESS); GURL url("http://google.com/test"); @@ -184,6 +212,8 @@ EXPECT_EQ(2, GetUserDataTableRowCount()); + MaybeSetSavingBrowsingHistoryDisabled(); + { base::CancelableTaskTracker task_tracker; @@ -201,7 +231,7 @@ EXPECT_EQ(0, GetUserDataTableRowCount()); } -TEST_F(MediaHistoryKeyedServiceTest, CleanUpDatabaseWhenOriginIsDeleted) { +TEST_P(MediaHistoryKeyedServiceTest, CleanUpDatabaseWhenOriginIsDeleted) { history::HistoryService* history = HistoryServiceFactory::GetForProfile( profile(), ServiceAccessType::IMPLICIT_ACCESS); @@ -340,6 +370,8 @@ EXPECT_EQ(all_urls, GetURLsInTable(MediaHistorySessionTable::kTableName)); EXPECT_EQ(images, GetURLsInTable(MediaHistoryImagesTable::kTableName)); + MaybeSetSavingBrowsingHistoryDisabled(); + { base::CancelableTaskTracker task_tracker;
diff --git a/chrome/browser/media/history/media_history_store_unittest.cc b/chrome/browser/media/history/media_history_store_unittest.cc index c08001c..6092b36 100644 --- a/chrome/browser/media/history/media_history_store_unittest.cc +++ b/chrome/browser/media/history/media_history_store_unittest.cc
@@ -26,7 +26,9 @@ #include "chrome/test/base/testing_profile.h" #include "components/history/core/browser/history_database_params.h" #include "components/history/core/browser/history_service.h" +#include "components/history/core/common/pref_names.h" #include "components/history/core/test/test_history_database.h" +#include "components/prefs/pref_service.h" #include "content/public/browser/media_player_watch_time.h" #include "content/public/test/browser_task_environment.h" #include "content/public/test/test_utils.h" @@ -56,11 +58,22 @@ return service; } +enum class TestState { + kNormal, + + // Runs the test in incognito mode. + kIncognito, + + // Runs the test with the "SavingBrowserHistoryDisabled" policy enabled. + kSavingBrowserHistoryDisabled, +}; + } // namespace // Runs the test with a param to signify the profile being incognito if true. -class MediaHistoryStoreUnitTest : public testing::Test, - public testing::WithParamInterface<bool> { +class MediaHistoryStoreUnitTest + : public testing::Test, + public testing::WithParamInterface<TestState> { public: MediaHistoryStoreUnitTest() = default; void SetUp() override { @@ -71,6 +84,11 @@ g_temp_history_dir = temp_dir_.GetPath(); profile_ = profile_builder.Build(); + if (GetParam() == TestState::kSavingBrowserHistoryDisabled) { + profile_->GetPrefs()->SetBoolean(prefs::kSavingBrowserHistoryDisabled, + true); + } + HistoryServiceFactory::GetInstance()->SetTestingFactory( profile_.get(), base::BindRepeating(&BuildTestHistoryService)); @@ -162,7 +180,7 @@ MediaHistoryKeyedService* service() const { // If the param is true then we use the OTR service to simulate being in // incognito. - if (GetParam()) + if (GetParam() == TestState::kIncognito) return otr_service(); return MediaHistoryKeyedService::Get(profile_.get()); @@ -170,7 +188,7 @@ MediaHistoryKeyedService* otr_service() const { return otr_service_.get(); } - bool IsReadOnly() const { return GetParam(); } + bool IsReadOnly() const { return GetParam() != TestState::kNormal; } private: base::ScopedTempDir temp_dir_; @@ -185,7 +203,12 @@ std::unique_ptr<TestingProfile> profile_; }; -INSTANTIATE_TEST_SUITE_P(All, MediaHistoryStoreUnitTest, testing::Bool()); +INSTANTIATE_TEST_SUITE_P( + All, + MediaHistoryStoreUnitTest, + testing::Values(TestState::kNormal, + TestState::kIncognito, + TestState::kSavingBrowserHistoryDisabled)); TEST_P(MediaHistoryStoreUnitTest, CreateDatabaseTables) { ASSERT_TRUE(GetDB().DoesTableExist("origin")); @@ -601,7 +624,10 @@ base::test::ScopedFeatureList features_; }; -INSTANTIATE_TEST_SUITE_P(All, MediaHistoryStoreFeedsTest, testing::Bool()); +INSTANTIATE_TEST_SUITE_P(All, + MediaHistoryStoreFeedsTest, + testing::Values(TestState::kNormal, + TestState::kIncognito)); TEST_P(MediaHistoryStoreFeedsTest, CreateDatabaseTables) { ASSERT_TRUE(GetDB().DoesTableExist("mediaFeed"));
diff --git a/chrome/browser/media/router/providers/cast/activity_record.cc b/chrome/browser/media/router/providers/cast/activity_record.cc index a7a64d35..1921eac 100644 --- a/chrome/browser/media/router/providers/cast/activity_record.cc +++ b/chrome/browser/media/router/providers/cast/activity_record.cc
@@ -144,6 +144,14 @@ std::move(callback)); } +void ActivityRecord::CloseConnectionOnReceiver(const std::string& client_id) { + CastSession* session = GetSession(); + if (!session) + return; + message_handler_->CloseConnection(cast_channel_id(), client_id, + session->transport_id()); +} + void ActivityRecord::HandleLeaveSession(const std::string& client_id) { auto client_it = connected_clients_.find(client_id); CHECK(client_it != connected_clients_.end());
diff --git a/chrome/browser/media/router/providers/cast/activity_record.h b/chrome/browser/media/router/providers/cast/activity_record.h index a788014f..be5e459a 100644 --- a/chrome/browser/media/router/providers/cast/activity_record.h +++ b/chrome/browser/media/router/providers/cast/activity_record.h
@@ -116,6 +116,10 @@ virtual void StopSessionOnReceiver(const std::string& client_id, cast_channel::ResultCallback callback); + // Closes any virtual connection between |client_id| and this session on the + // receiver. + virtual void CloseConnectionOnReceiver(const std::string& client_id); + // Called when the client given by |client_id| requests to leave the session. // This will also cause all clients within the session with matching origin // and/or tab ID to leave (i.e., their presentation connections will be
diff --git a/chrome/browser/media/router/providers/cast/cast_activity_record_unittest.cc b/chrome/browser/media/router/providers/cast/cast_activity_record_unittest.cc index f9ae563..8a31249 100644 --- a/chrome/browser/media/router/providers/cast/cast_activity_record_unittest.cc +++ b/chrome/browser/media/router/providers/cast/cast_activity_record_unittest.cc
@@ -455,4 +455,13 @@ record_->OnAppMessage(message); } +TEST_F(CastActivityRecordTest, CloseConnectionOnReceiver) { + SetUpSession(); + AddMockClient("theClientId1"); + + EXPECT_CALL(message_handler_, CloseConnection(kChannelId, "theClientId1", + session_->transport_id())); + record_->CloseConnectionOnReceiver("theClientId1"); +} + } // namespace media_router
diff --git a/chrome/browser/media/router/providers/cast/cast_session_client.cc b/chrome/browser/media/router/providers/cast/cast_session_client.cc index 33ae8ef..869be77 100644 --- a/chrome/browser/media/router/providers/cast/cast_session_client.cc +++ b/chrome/browser/media/router/providers/cast/cast_session_client.cc
@@ -109,9 +109,7 @@ } void CastSessionClientImpl::DidClose(PresentationConnectionCloseReason reason) { - // TODO(https://crbug.com/809249): Implement close connection with this - // method once we make sure Blink calls this on navigation and on - // PresentationConnection::close(). + activity_->CloseConnectionOnReceiver(client_id()); } void CastSessionClientImpl::SendErrorCodeToClient( @@ -250,8 +248,8 @@ PresentationConnectionCloseReason close_reason) { if (connection_remote_) connection_remote_->DidClose(close_reason); - TearDownPresentationConnection(); + activity_->CloseConnectionOnReceiver(client_id()); } void CastSessionClientImpl::TerminateConnection() {
diff --git a/chrome/browser/media/router/providers/cast/cast_session_client_unittest.cc b/chrome/browser/media/router/providers/cast/cast_session_client_unittest.cc index 14adec5f..7776812 100644 --- a/chrome/browser/media/router/providers/cast/cast_session_client_unittest.cc +++ b/chrome/browser/media/router/providers/cast/cast_session_client_unittest.cc
@@ -33,6 +33,7 @@ using base::test::IsJson; using base::test::ParseJson; +using blink::mojom::PresentationConnectionCloseReason; using testing::_; using testing::AllOf; using testing::AnyNumber; @@ -269,4 +270,14 @@ })")); } +TEST_F(CastSessionClientImplTest, CloseConnection) { + EXPECT_CALL(activity_, CloseConnectionOnReceiver("theClientId")); + client_->CloseConnection(PresentationConnectionCloseReason::CLOSED); +} + +TEST_F(CastSessionClientImplTest, DidCloseConnection) { + EXPECT_CALL(activity_, CloseConnectionOnReceiver("theClientId")); + client_->DidClose(PresentationConnectionCloseReason::WENT_AWAY); +} + } // namespace media_router
diff --git a/chrome/browser/media/router/providers/cast/mock_cast_activity_record.h b/chrome/browser/media/router/providers/cast/mock_cast_activity_record.h index 3348ffd9..b9932c6b5 100644 --- a/chrome/browser/media/router/providers/cast/mock_cast_activity_record.h +++ b/chrome/browser/media/router/providers/cast/mock_cast_activity_record.h
@@ -37,6 +37,7 @@ MOCK_METHOD2(StopSessionOnReceiver, void(const std::string& client_id, cast_channel::ResultCallback callback)); + MOCK_METHOD1(CloseConnectionOnReceiver, void(const std::string& client_id)); MOCK_METHOD1(SendStopSessionMessageToClients, void(const std::string& hash_token)); MOCK_METHOD1(HandleLeaveSession, void(const std::string& client_id));
diff --git a/chrome/browser/metrics/extensions_metrics_provider.cc b/chrome/browser/metrics/extensions_metrics_provider.cc index 2bd85854..d25c513 100644 --- a/chrome/browser/metrics/extensions_metrics_provider.cc +++ b/chrome/browser/metrics/extensions_metrics_provider.cc
@@ -250,8 +250,6 @@ ExtensionInstallProto::CUSTODIAN_APPROVAL_REQUIRED}, {extensions::disable_reason::DISABLE_BLOCKED_BY_POLICY, ExtensionInstallProto::BLOCKED_BY_POLICY}, - {extensions::disable_reason::DISABLE_BLOCKED_MATURE, - ExtensionInstallProto::BLOCKED_MATURE}, }; int disable_reasons = prefs->GetDisableReasons(id);
diff --git a/chrome/browser/net/dns_util.cc b/chrome/browser/net/dns_util.cc index aec383e..33e3549 100644 --- a/chrome/browser/net/dns_util.cc +++ b/chrome/browser/net/dns_util.cc
@@ -12,10 +12,33 @@ #if defined(OS_WIN) #include "base/enterprise_util.h" +#include "base/win/windows_version.h" +#include "chrome/browser/win/parental_controls.h" #endif namespace chrome_browser_net { +namespace { + +#if defined(OS_WIN) +bool ShouldDisableDohForWindowsParentalControls() { + const WinParentalControls& parental_controls = GetWinParentalControls(); + if (parental_controls.web_filter) + return true; + + // Some versions before Windows 8 may not fully support |web_filter|, so + // conservatively disable doh for any recognized parental controls. + if (parental_controls.any_restrictions && + base::win::GetVersion() < base::win::Version::WIN8) { + return true; + } + + return false; +} +#endif // defined(OS_WIN) + +} // namespace + bool ShouldDisableDohForManaged() { #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) if (g_browser_process->browser_policy_connector()->HasMachineLevelPolicies()) @@ -28,8 +51,11 @@ return false; } -// TODO(crbug.com/1037961): Implement this method. bool ShouldDisableDohForParentalControls() { +#if defined(OS_WIN) + return ShouldDisableDohForWindowsParentalControls(); +#endif + return false; }
diff --git a/chrome/browser/payments/payment_handler_just_in_time_installation_browsertest.cc b/chrome/browser/payments/payment_handler_just_in_time_installation_browsertest.cc index b020066..ea15d7f 100644 --- a/chrome/browser/payments/payment_handler_just_in_time_installation_browsertest.cc +++ b/chrome/browser/payments/payment_handler_just_in_time_installation_browsertest.cc
@@ -2,7 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/test/metrics/histogram_tester.h" +#include "base/test/scoped_feature_list.h" #include "chrome/test/payments/payment_request_platform_browsertest_base.h" +#include "components/payments/core/features.h" +#include "components/payments/core/journey_logger.h" +#include "testing/gtest/include/gtest/gtest.h" namespace payments { @@ -60,4 +65,82 @@ ExpectBodyContains("kylepay.com/webpay"); } +class AlwaysAllowJustInTimePaymentAppTest + : public PaymentHandlerJustInTimeInstallationTest, + public testing::WithParamInterface<bool> { + protected: + AlwaysAllowJustInTimePaymentAppTest() { + scoped_feature_list_.InitWithFeatureState( + features::kAlwaysAllowJustInTimePaymentApp, GetParam()); + } + + private: + base::test::ScopedFeatureList scoped_feature_list_; +}; + +IN_PROC_BROWSER_TEST_P(AlwaysAllowJustInTimePaymentAppTest, + HybridRequest_NoCreditCard) { + base::HistogramTester histogram_tester; + ResetEventWaiterForSingleEvent(GetParam() ? TestEvent::kPaymentCompleted + : TestEvent::kShowAppsReady); + EXPECT_TRUE( + content::ExecJs(GetActiveWebContents(), + "testPaymentMethods([ " + " {supportedMethods: 'basic-card'}, " + " {supportedMethods: 'https://kylepay.com/webpay'}])")); + WaitForObservedEvent(); + + if (GetParam()) { + // If AlwaysAllowJIT is enabled, kylepay should be installed just-in-time + // and used for testing. + ExpectBodyContains("kylepay.com/webpay"); + } else { + // With AlwaysJIT disabled, the request is expected to stop at the payment + // sheet waiting for user action. + EXPECT_TRUE(content::ExecJs(GetActiveWebContents(), "abort()")); + } + + std::vector<base::Bucket> buckets = + histogram_tester.GetAllSamples("PaymentRequest.Events"); + ASSERT_EQ(1U, buckets.size()); + EXPECT_FALSE(buckets[0].min & + JourneyLogger::EVENT_AVAILABLE_METHOD_BASIC_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_AVAILABLE_METHOD_GOOGLE); + EXPECT_EQ(GetParam(), + (buckets[0].min & JourneyLogger::EVENT_AVAILABLE_METHOD_OTHER) > 0); +} + +IN_PROC_BROWSER_TEST_P(AlwaysAllowJustInTimePaymentAppTest, + HybridRequest_HasCompleteCreditCard) { + CreateAndAddCreditCardForProfile(CreateAndAddAutofillProfile()); + + base::HistogramTester histogram_tester; + ResetEventWaiterForSingleEvent(TestEvent::kShowAppsReady); + + EXPECT_TRUE( + content::ExecJs(GetActiveWebContents(), + "testPaymentMethods([ " + " {supportedMethods: 'basic-card'}, " + " {supportedMethods: 'https://kylepay.com/webpay'}])")); + WaitForObservedEvent(); + + // Regardless whether AlwaysJIT is disabled, beceause there is a complete + // basic card, the request is expected to stop at the payment sheet waiting + // for user action. + EXPECT_TRUE(content::ExecJs(GetActiveWebContents(), "abort()")); + + std::vector<base::Bucket> buckets = + histogram_tester.GetAllSamples("PaymentRequest.Events"); + ASSERT_EQ(1U, buckets.size()); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_AVAILABLE_METHOD_BASIC_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_AVAILABLE_METHOD_GOOGLE); + EXPECT_EQ(GetParam(), + (buckets[0].min & JourneyLogger::EVENT_AVAILABLE_METHOD_OTHER) > 0); +} + +INSTANTIATE_TEST_SUITE_P(All, + AlwaysAllowJustInTimePaymentAppTest, + ::testing::Values(true, false)); + } // namespace payments
diff --git a/chrome/browser/payments/payment_request_minimal_ui_browsertest.cc b/chrome/browser/payments/payment_request_minimal_ui_browsertest.cc index 58637e4..2a5ee5c 100644 --- a/chrome/browser/payments/payment_request_minimal_ui_browsertest.cc +++ b/chrome/browser/payments/payment_request_minimal_ui_browsertest.cc
@@ -80,10 +80,10 @@ GetPaymentMethodForHost("a.com")))); } -IN_PROC_BROWSER_TEST_F(PaymentRequestMinimalUITest, DISABLED_ConfirmPayment) { +IN_PROC_BROWSER_TEST_F(PaymentRequestMinimalUITest, ConfirmPayment) { // TODO(crbug.com/1061574): ConfirmPayment times out on - // android-marshmallow-arm64-rel bot. - if (test_controller()->IsAndroidMarshmallow()) + // android-marshmallow-arm64-rel and "Lollipop Phone Tester" bots. + if (test_controller()->IsAndroidMarshmallowOrLollipop()) return; InstallPaymentHandlerAndSetMinimalUIBehavior(Behavior::CONFIRM_MINIMAL_UI);
diff --git a/chrome/browser/performance_manager/graph/policies/background_tab_loading_policy.cc b/chrome/browser/performance_manager/graph/policies/background_tab_loading_policy.cc index 5c6a5e5..35257a1 100644 --- a/chrome/browser/performance_manager/graph/policies/background_tab_loading_policy.cc +++ b/chrome/browser/performance_manager/graph/policies/background_tab_loading_policy.cc
@@ -4,14 +4,14 @@ #include "chrome/browser/performance_manager/graph/policies/background_tab_loading_policy.h" -#include "chrome/browser/performance_manager/mechanisms/tab_loader.h" +#include "chrome/browser/performance_manager/mechanisms/page_loader.h" namespace performance_manager { namespace policies { BackgroundTabLoadingPolicy::BackgroundTabLoadingPolicy() - : tab_loader_(std::make_unique<mechanism::TabLoader>()) {} + : page_loader_(std::make_unique<mechanism::PageLoader>()) {} BackgroundTabLoadingPolicy::~BackgroundTabLoadingPolicy() = default; void BackgroundTabLoadingPolicy::OnPassedToGraph(Graph* graph) {} @@ -22,13 +22,13 @@ std::vector<PageNode*> page_nodes) { // TODO(https://crbug.com/1059341): DCHECK that |page_node| is in a tab strip. for (auto* page_node : page_nodes) { - tab_loader_->LoadPageNode(page_node); + page_loader_->LoadPageNode(page_node); } } void BackgroundTabLoadingPolicy::SetMockLoaderForTesting( - std::unique_ptr<mechanism::TabLoader> loader) { - tab_loader_ = std::move(loader); + std::unique_ptr<mechanism::PageLoader> loader) { + page_loader_ = std::move(loader); } } // namespace policies
diff --git a/chrome/browser/performance_manager/graph/policies/background_tab_loading_policy.h b/chrome/browser/performance_manager/graph/policies/background_tab_loading_policy.h index 323d647..c8ad748 100644 --- a/chrome/browser/performance_manager/graph/policies/background_tab_loading_policy.h +++ b/chrome/browser/performance_manager/graph/policies/background_tab_loading_policy.h
@@ -13,7 +13,7 @@ namespace performance_manager { namespace mechanism { -class TabLoader; +class PageLoader; } // namespace mechanism namespace policies { @@ -36,10 +36,10 @@ // Schedules the PageNodes in |page_nodes| to be loaded when appropriate. void RestoreTabs(std::vector<PageNode*> page_nodes); - void SetMockLoaderForTesting(std::unique_ptr<mechanism::TabLoader> loader); + void SetMockLoaderForTesting(std::unique_ptr<mechanism::PageLoader> loader); private: - std::unique_ptr<performance_manager::mechanism::TabLoader> tab_loader_; + std::unique_ptr<performance_manager::mechanism::PageLoader> page_loader_; }; } // namespace policies
diff --git a/chrome/browser/performance_manager/graph/policies/background_tab_loading_policy_unittest.cc b/chrome/browser/performance_manager/graph/policies/background_tab_loading_policy_unittest.cc index 763ffbc..7599ac7 100644 --- a/chrome/browser/performance_manager/graph/policies/background_tab_loading_policy_unittest.cc +++ b/chrome/browser/performance_manager/graph/policies/background_tab_loading_policy_unittest.cc
@@ -6,7 +6,7 @@ #include <vector> -#include "chrome/browser/performance_manager/mechanisms/tab_loader.h" +#include "chrome/browser/performance_manager/mechanisms/page_loader.h" #include "components/performance_manager/graph/page_node_impl.h" #include "components/performance_manager/test_support/graph_test_harness.h" #include "testing/gmock/include/gmock/gmock.h" @@ -16,17 +16,18 @@ namespace policies { -// Mock version of a performance_manager::mechanism::TabLoader. -class LenientMockTabLoader : public performance_manager::mechanism::TabLoader { +// Mock version of a performance_manager::mechanism::PageLoader. +class LenientMockPageLoader + : public performance_manager::mechanism::PageLoader { public: - LenientMockTabLoader() = default; - ~LenientMockTabLoader() override = default; - LenientMockTabLoader(const LenientMockTabLoader& other) = delete; - LenientMockTabLoader& operator=(const LenientMockTabLoader&) = delete; + LenientMockPageLoader() = default; + ~LenientMockPageLoader() override = default; + LenientMockPageLoader(const LenientMockPageLoader& other) = delete; + LenientMockPageLoader& operator=(const LenientMockPageLoader&) = delete; MOCK_METHOD1(LoadPageNode, void(const PageNode* page_node)); }; -using MockTabLoader = ::testing::StrictMock<LenientMockTabLoader>; +using MockPageLoader = ::testing::StrictMock<LenientMockPageLoader>; class BackgroundTabLoadingPolicyTest : public GraphTestHarness { public: @@ -43,8 +44,8 @@ policy_ = policy.get(); graph()->PassToGraph(std::move(policy)); - // Make the policy use a mock TabLoader. - auto mock_loader = std::make_unique<MockTabLoader>(); + // Make the policy use a mock PageLoader. + auto mock_loader = std::make_unique<MockPageLoader>(); mock_loader_ = mock_loader.get(); policy_->SetMockLoaderForTesting(std::move(mock_loader)); } @@ -53,11 +54,11 @@ protected: BackgroundTabLoadingPolicy* policy() { return policy_; } - MockTabLoader* loader() { return mock_loader_; } + MockPageLoader* loader() { return mock_loader_; } private: BackgroundTabLoadingPolicy* policy_; - MockTabLoader* mock_loader_; + MockPageLoader* mock_loader_; }; TEST_F(BackgroundTabLoadingPolicyTest, RestoreTabs) {
diff --git a/chrome/browser/performance_manager/mechanisms/page_loader.cc b/chrome/browser/performance_manager/mechanisms/page_loader.cc new file mode 100644 index 0000000..40ef032f --- /dev/null +++ b/chrome/browser/performance_manager/mechanisms/page_loader.cc
@@ -0,0 +1,43 @@ +// Copyright 2020 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 "chrome/browser/performance_manager/mechanisms/page_loader.h" + +#include "base/task/post_task.h" +#include "components/performance_manager/public/decorators/tab_properties_decorator.h" +#include "components/performance_manager/public/graph/page_node.h" +#include "components/performance_manager/public/web_contents_proxy.h" +#include "content/public/browser/browser_task_traits.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/web_contents.h" + +namespace performance_manager { + +namespace mechanism { + +namespace { + +// Load a page on the UI thread. +void LoadPageOnUIThread(const WebContentsProxy& contents_proxy) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + content::WebContents* const contents = contents_proxy.Get(); + if (!contents) + return; + + contents->GetController().LoadIfNecessary(); +} + +} // namespace + +void PageLoader::LoadPageNode(const PageNode* page_node) { + DCHECK(page_node); + DCHECK(TabPropertiesDecorator::Data::FromPageNode(page_node)->IsInTabStrip()); + base::PostTask( + FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(&LoadPageOnUIThread, page_node->GetContentsProxy())); +} + +} // namespace mechanism + +} // namespace performance_manager
diff --git a/chrome/browser/performance_manager/mechanisms/page_loader.h b/chrome/browser/performance_manager/mechanisms/page_loader.h new file mode 100644 index 0000000..7e587db --- /dev/null +++ b/chrome/browser/performance_manager/mechanisms/page_loader.h
@@ -0,0 +1,32 @@ +// Copyright 2020 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. + +#ifndef CHROME_BROWSER_PERFORMANCE_MANAGER_MECHANISMS_PAGE_LOADER_H_ +#define CHROME_BROWSER_PERFORMANCE_MANAGER_MECHANISMS_PAGE_LOADER_H_ + +#include "base/macros.h" + +namespace performance_manager { + +class PageNode; + +namespace mechanism { + +// Mechanism that allows loading of the Page associated with a PageNode. +class PageLoader { + public: + PageLoader() = default; + virtual ~PageLoader() = default; + PageLoader(const PageLoader& other) = delete; + PageLoader& operator=(const PageLoader&) = delete; + + // Starts loading |page_node| if not already loaded. + virtual void LoadPageNode(const PageNode* page_node); +}; + +} // namespace mechanism + +} // namespace performance_manager + +#endif // CHROME_BROWSER_PERFORMANCE_MANAGER_MECHANISMS_PAGE_LOADER_H_
diff --git a/chrome/browser/performance_manager/mechanisms/tab_loader.h b/chrome/browser/performance_manager/mechanisms/tab_loader.h deleted file mode 100644 index d55310b..0000000 --- a/chrome/browser/performance_manager/mechanisms/tab_loader.h +++ /dev/null
@@ -1,32 +0,0 @@ -// Copyright 2020 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. - -#ifndef CHROME_BROWSER_PERFORMANCE_MANAGER_MECHANISMS_TAB_LOADER_H_ -#define CHROME_BROWSER_PERFORMANCE_MANAGER_MECHANISMS_TAB_LOADER_H_ - -#include "base/macros.h" - -namespace performance_manager { - -class PageNode; - -namespace mechanism { - -// Mechanism that allows loading of the tab associated with a PageNode. -class TabLoader { - public: - TabLoader() = default; - virtual ~TabLoader() = default; - TabLoader(const TabLoader& other) = delete; - TabLoader& operator=(const TabLoader&) = delete; - - // Starts loading |page_node| if not already loaded. - virtual void LoadPageNode(const PageNode* page_node) {} -}; - -} // namespace mechanism - -} // namespace performance_manager - -#endif // CHROME_BROWSER_PERFORMANCE_MANAGER_MECHANISMS_TAB_LOADER_H_
diff --git a/chrome/browser/platform_util_unittest.cc b/chrome/browser/platform_util_unittest.cc index 36e97cd..4ca9f11 100644 --- a/chrome/browser/platform_util_unittest.cc +++ b/chrome/browser/platform_util_unittest.cc
@@ -58,7 +58,8 @@ // New FileSystemBackend that uses our MockSpecialStoragePolicy. additional_backends->push_back( std::make_unique<chromeos::FileSystemBackend>( - nullptr, nullptr, nullptr, nullptr, nullptr, external_mount_points, + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + external_mount_points, storage::ExternalMountPoints::GetSystemInstance())); } };
diff --git a/chrome/browser/predictors/loading_predictor_browsertest.cc b/chrome/browser/predictors/loading_predictor_browsertest.cc index 6c655bd5..2964808 100644 --- a/chrome/browser/predictors/loading_predictor_browsertest.cc +++ b/chrome/browser/predictors/loading_predictor_browsertest.cc
@@ -1644,10 +1644,10 @@ } } +// crbug.com/1060966 IN_PROC_BROWSER_TEST_P( LoadingPredictorBrowserTestWithOptimizationGuide, - DISABLE_ON_WIN_MAC_CHROMEOS( - NavigationWithBothLocalPredictionAndOptimizationHint)) { + DISABLED_NavigationWithBothLocalPredictionAndOptimizationHint) { base::HistogramTester histogram_tester; GURL url = embedded_test_server()->GetURL(
diff --git a/chrome/browser/prerender/isolated/isolated_prerender_browsertest.cc b/chrome/browser/prerender/isolated/isolated_prerender_browsertest.cc index 6922771..ec7d2c3 100644 --- a/chrome/browser/prerender/isolated/isolated_prerender_browsertest.cc +++ b/chrome/browser/prerender/isolated/isolated_prerender_browsertest.cc
@@ -131,11 +131,11 @@ } void SetUp() override { - scoped_feature_list_.InitAndEnableFeature(features::kIsolatePrerenders); - - holdback_scoped_feature_list_.InitAndEnableFeatureWithParameters( - data_reduction_proxy::features::kDataReductionProxyHoldback, - {{"force_enable_config_service_fetches", "true"}}); + scoped_feature_list_.InitWithFeatures( + {features::kIsolatePrerenders, + data_reduction_proxy::features::kDataReductionProxyHoldback, + data_reduction_proxy::features::kFetchClientConfig}, + {}); InProcessBrowserTest::SetUp(); } @@ -276,7 +276,6 @@ } base::test::ScopedFeatureList scoped_feature_list_; - base::test::ScopedFeatureList holdback_scoped_feature_list_; std::unique_ptr<net::EmbeddedTestServer> origin_server_; std::unique_ptr<net::EmbeddedTestServer> config_server_; size_t origin_server_request_with_cookies_ = 0;
diff --git a/chrome/browser/profiles/gaia_info_update_service.cc b/chrome/browser/profiles/gaia_info_update_service.cc index 2788dc9..4616e03 100644 --- a/chrome/browser/profiles/gaia_info_update_service.cc +++ b/chrome/browser/profiles/gaia_info_update_service.cc
@@ -28,6 +28,10 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/image/image.h" +#if defined(OS_CHROMEOS) +#include "chromeos/constants/chromeos_features.h" +#endif + GAIAInfoUpdateService::GAIAInfoUpdateService( signin::IdentityManager* identity_manager, ProfileAttributesStorage* profile_attributes_storage, @@ -106,7 +110,7 @@ // static bool GAIAInfoUpdateService::ShouldUseGAIAProfileInfo(Profile* profile) { #if defined(OS_CHROMEOS) - return false; + return base::FeatureList::IsEnabled(chromeos::features::kAvatarToolbarButton); #endif return true; }
diff --git a/chrome/browser/profiles/profile_attributes_entry.cc b/chrome/browser/profiles/profile_attributes_entry.cc index 27d0e1a..843551b7 100644 --- a/chrome/browser/profiles/profile_attributes_entry.cc +++ b/chrome/browser/profiles/profile_attributes_entry.cc
@@ -237,9 +237,9 @@ return *image; } -#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) - // Use the high resolution version of the avatar if it exists. Mobile and - // ChromeOS don't need the high resolution version so no need to fetch it. +#if !defined(OS_ANDROID) + // Use the high resolution version of the avatar if it exists. Mobile doesn't + // need the high resolution version so no need to fetch it. const gfx::Image* image = GetHighResAvatar(); if (image) return *image;
diff --git a/chrome/browser/profiles/profile_attributes_storage.cc b/chrome/browser/profiles/profile_attributes_storage.cc index 898feb78..70d368c 100644 --- a/chrome/browser/profiles/profile_attributes_storage.cc +++ b/chrome/browser/profiles/profile_attributes_storage.cc
@@ -315,8 +315,7 @@ void ProfileAttributesStorage::DownloadHighResAvatarIfNeeded( size_t icon_index, const base::FilePath& profile_path) { -// Downloading is only supported on desktop. -#if defined(OS_ANDROID) || defined(OS_CHROMEOS) +#if defined(OS_ANDROID) return; #endif DCHECK(!disable_avatar_download_for_testing_); @@ -340,8 +339,7 @@ void ProfileAttributesStorage::DownloadHighResAvatar( size_t icon_index, const base::FilePath& profile_path) { -// Downloading is only supported on desktop. -#if defined(OS_ANDROID) || defined(OS_CHROMEOS) +#if defined(OS_ANDROID) return; #endif const char* file_name =
diff --git a/chrome/browser/profiles/profile_info_cache.cc b/chrome/browser/profiles/profile_info_cache.cc index f273824e..c2decc6d 100644 --- a/chrome/browser/profiles/profile_info_cache.cc +++ b/chrome/browser/profiles/profile_info_cache.cc
@@ -112,9 +112,11 @@ if (!disable_avatar_download_for_testing_) DownloadAvatars(); -#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) +#if !defined(OS_ANDROID) LoadGAIAPictureIfNeeded(); +#endif +#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) bool migrate_legacy_profile_names = (!prefs_->GetBoolean(kLegacyProfileNameMigrated) || migration_enabled_for_testing); @@ -534,7 +536,7 @@ image_path); } -#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) +#if !defined(OS_ANDROID) void ProfileInfoCache::LoadGAIAPictureIfNeeded() { std::vector<ProfileAttributesEntry*> entries = GetAllProfilesAttributes(); for (ProfileAttributesEntry* entry : entries) { @@ -548,7 +550,9 @@ entry->GetGAIAPicture(); } } +#endif +#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) void ProfileInfoCache::MigrateLegacyProfileNamesAndRecomputeIfNeeded() { std::vector<ProfileAttributesEntry*> entries = GetAllProfilesAttributes(); for (size_t i = 0; i < entries.size(); i++) { @@ -587,8 +591,7 @@ #endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS) void ProfileInfoCache::DownloadAvatars() { - // Only do this on desktop platforms. -#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) +#if !defined(OS_ANDROID) std::vector<ProfileAttributesEntry*> entries = GetAllProfilesAttributes(); for (ProfileAttributesEntry* entry : entries) { DownloadHighResAvatarIfNeeded(entry->GetAvatarIconIndex(),
diff --git a/chrome/browser/profiles/profile_info_cache.h b/chrome/browser/profiles/profile_info_cache.h index a1e88bb..e5f61879 100644 --- a/chrome/browser/profiles/profile_info_cache.h +++ b/chrome/browser/profiles/profile_info_cache.h
@@ -170,9 +170,11 @@ const std::string& key, const std::string& image_url_with_size, bool image_is_empty) const; +#if !defined(OS_ANDROID) + void LoadGAIAPictureIfNeeded(); +#endif #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) - void LoadGAIAPictureIfNeeded(); // Migrate any legacy profile names ("First user", "Default Profile") to // new style default names ("Person 1"). Rename any duplicates of "Person n" // i.e. Two or more profiles with the profile name "Person 1" would be
diff --git a/chrome/browser/resources/BUILD.gn b/chrome/browser/resources/BUILD.gn index 63277d02..7db1e7a 100644 --- a/chrome/browser/resources/BUILD.gn +++ b/chrome/browser/resources/BUILD.gn
@@ -276,7 +276,7 @@ deps = [ "//chrome/browser/ui/webui/app_management:mojo_bindings_js" ] if (optimize_webui) { # Required due to flattenhtml="true" on a generated file. - source_is_generated = true + enable_input_discovery_for_gn_analyze = false source = "settings/os_settings_resources_vulcanized.grd" deps += [ "//chrome/browser/resources/settings/chromeos:build" ]
diff --git a/chrome/browser/resources/chromeos/camera/.eslintignore b/chrome/browser/resources/chromeos/camera/.eslintignore index 9c1c5a56..c0741c4 100644 --- a/chrome/browser/resources/chromeos/camera/.eslintignore +++ b/chrome/browser/resources/chromeos/camera/.eslintignore
@@ -1 +1,2 @@ google-analytics-bundle.js +comlink.js
diff --git a/chrome/browser/resources/chromeos/camera/BUILD.gn b/chrome/browser/resources/chromeos/camera/BUILD.gn index 4fa82b2..9c8949e 100644 --- a/chrome/browser/resources/chromeos/camera/BUILD.gn +++ b/chrome/browser/resources/chromeos/camera/BUILD.gn
@@ -140,6 +140,7 @@ copy("chrome_camera_app_js_lib") { sources = [ + "src/js/lib/comlink.js", "src/js/lib/google-analytics-bundle.js", ]
diff --git a/chrome/browser/resources/chromeos/camera/camera_resources.grd b/chrome/browser/resources/chromeos/camera/camera_resources.grd index 17b1f4f..8c10fbb 100644 --- a/chrome/browser/resources/chromeos/camera/camera_resources.grd +++ b/chrome/browser/resources/chromeos/camera/camera_resources.grd
@@ -17,6 +17,7 @@ <structure name="IDR_CAMERA_CAMERA3_DEVICE_INFO_JS" file="src/js/device/camera3_device_info.js" type="chrome_html" /> <structure name="IDR_CAMERA_CAMERA_JS" file="src/js/views/camera.js" type="chrome_html" /> <structure name="IDR_CAMERA_CAMERA_INTENT_JS" file="src/js/views/camera_intent.js" type="chrome_html" /> + <structure name="IDR_CAMERA_COMLINK_JS" file="src/js/lib/comlink.js" type="chrome_html" /> <structure name="IDR_CAMERA_CONSTRAINTS_PREFERRER_JS" file="src/js/device/constraints_preferrer.js" type="chrome_html" /> <structure name="IDR_CAMERA_CHROME_HELPER_JS" file="src/js/mojo/chrome_helper.js" type="chrome_html" /> <structure name="IDR_CAMERA_CHROME_UTIL_JS" file="src/js/chrome_util.js" type="chrome_html" />
diff --git a/chrome/browser/resources/chromeos/camera/src/js/lib/README.md b/chrome/browser/resources/chromeos/camera/src/js/lib/README.md index b78abfc..091f4851 100644 --- a/chrome/browser/resources/chromeos/camera/src/js/lib/README.md +++ b/chrome/browser/resources/chromeos/camera/src/js/lib/README.md
@@ -1,3 +1,8 @@ # google-analytics-bundle.js -From https://github.com/googlearchive/chrome-platform-analytics +* [Project Page](https://github.com/googlearchive/chrome-platform-analytics) + +# comlink.js + +* [Project Page](https://github.com/GoogleChromeLabs/comlink) +* The minified ES module build is get from [unpkg](https://unpkg.com/comlink@4.2.0/dist/esm/comlink.min.js).
diff --git a/chrome/browser/resources/chromeos/camera/src/js/lib/comlink.js b/chrome/browser/resources/chromeos/camera/src/js/lib/comlink.js new file mode 100644 index 0000000..a5c35c2 --- /dev/null +++ b/chrome/browser/resources/chromeos/camera/src/js/lib/comlink.js
@@ -0,0 +1,15 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +/* eslint-disable */ +const e=Symbol("Comlink.proxy"),t=Symbol("Comlink.endpoint"),n=Symbol("Comlink.releaseProxy"),r=new WeakSet,a=new Map([["proxy",{canHandle:t=>t&&t[e],serialize(e){const{port1:t,port2:n}=new MessageChannel;return s(e,t),[n,[n]]},deserialize:e=>(e.start(),i(e))}],["throw",{canHandle:e=>r.has(e),serialize(e){const t=e instanceof Error;let n=e;return t&&(n={isError:t,message:e.message,stack:e.stack}),[n,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error,e);throw e}}]]);function s(e,t=self){t.addEventListener("message",(function n(a){if(!a||!a.data)return;const{id:i,type:c,path:u}=Object.assign({path:[]},a.data),p=(a.data.argumentList||[]).map(h);let m;try{const t=u.slice(0,-1).reduce((e,t)=>e[t],e),n=u.reduce((e,t)=>e[t],e);switch(c){case 0:m=n;break;case 1:t[u.slice(-1)[0]]=h(a.data.value),m=!0;break;case 2:m=n.apply(t,p);break;case 3:m=d(new n(...p));break;case 4:{const{port1:t,port2:n}=new MessageChannel;s(e,n),m=l(t,[t])}break;case 5:m=void 0}}catch(e){m=e,r.add(e)}Promise.resolve(m).catch(e=>(r.add(e),e)).then(e=>{const[r,a]=g(e);t.postMessage(Object.assign(Object.assign({},r),{id:i}),a),5===c&&(t.removeEventListener("message",n),o(t))})})),t.start&&t.start()}function o(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function i(e,r){return function e(r,a=[],s=function(){}){let i=!1;const p=new Proxy(s,{get(t,s){if(c(i),s===n)return()=>f(r,{type:5,path:a.map(e=>e.toString())}).then(()=>{o(r),i=!0});if("then"===s){if(0===a.length)return{then:()=>p};const e=f(r,{type:0,path:a.map(e=>e.toString())}).then(h);return e.then.bind(e)}return e(r,[...a,s])},set(e,t,n){c(i);const[s,o]=g(n);return f(r,{type:1,path:[...a,t].map(e=>e.toString()),value:s},o).then(h)},apply(n,s,o){c(i);const p=a[a.length-1];if(p===t)return f(r,{type:4}).then(h);if("bind"===p)return e(r,a.slice(0,-1));const[l,d]=u(o);return f(r,{type:2,path:a.map(e=>e.toString()),argumentList:l},d).then(h)},construct(e,t){c(i);const[n,s]=u(t);return f(r,{type:3,path:a.map(e=>e.toString()),argumentList:n},s).then(h)}});return p}(e,[],r)}function c(e){if(e)throw new Error("Proxy has been released and is not useable")}function u(e){const t=e.map(g);return[t.map(e=>e[0]),(n=t.map(e=>e[1]),Array.prototype.concat.apply([],n))];var n}const p=new WeakMap;function l(e,t){return p.set(e,t),e}function d(t){return Object.assign(t,{[e]:!0})}function m(e,t=self,n="*"){return{postMessage:(t,r)=>e.postMessage(t,n,r),addEventListener:t.addEventListener.bind(t),removeEventListener:t.removeEventListener.bind(t)}}function g(e){for(const[t,n]of a)if(n.canHandle(e)){const[r,a]=n.serialize(e);return[{type:3,name:t,value:r},a]}return[{type:0,value:e},p.get(e)||[]]}function h(e){switch(e.type){case 3:return a.get(e.name).deserialize(e.value);case 0:return e.value}}function f(e,t,n){return new Promise(r=>{const a=new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");e.addEventListener("message",(function t(n){n.data&&n.data.id&&n.data.id===a&&(e.removeEventListener("message",t),r(n.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:a},t),n)})}export{t as createEndpoint,s as expose,d as proxy,e as proxyMarker,n as releaseProxy,l as transfer,a as transferHandlers,m as windowEndpoint,i as wrap};
diff --git a/chrome/browser/resources/extensions/detail_view.html b/chrome/browser/resources/extensions/detail_view.html index c030ae4..f822536b3 100644 --- a/chrome/browser/resources/extensions/detail_view.html +++ b/chrome/browser/resources/extensions/detail_view.html
@@ -168,12 +168,6 @@ $i18n{itemReload} </cr-button> </template> - <cr-tooltip-icon id="blockedMatureToolTip" - hidden$="[[!data.disableReasons.blockedMature]]" - tooltip-text="$i18n{disableBlockedMature}" - icon-class="cr20:kite" - icon-aria-label="$i18n{disableBlockedMature}"> - </cr-tooltip-icon> <cr-toggle id="enableToggle" aria-label$="[[appOrExtension( data.type,
diff --git a/chrome/browser/resources/extensions/item.html b/chrome/browser/resources/extensions/item.html index 8fb22a0b..13c3449 100644 --- a/chrome/browser/resources/extensions/item.html +++ b/chrome/browser/resources/extensions/item.html
@@ -312,12 +312,6 @@ $i18n{itemReload} </cr-button> </template> - <cr-tooltip-icon id="blockedMatureToolTip" - hidden$="[[!data.disableReasons.blockedMature]]" - tooltip-text="$i18n{disableBlockedMature}" - icon-class="cr20:kite" - icon-aria-label="$i18n{disableBlockedMature}"> - </cr-tooltip-icon> <cr-toggle id="enableToggle" aria-label$="[[appOrExtension( data.type,
diff --git a/chrome/browser/resources/extensions/item_util.js b/chrome/browser/resources/extensions/item_util.js index 69d7a5e..a1f91b5 100644 --- a/chrome/browser/resources/extensions/item_util.js +++ b/chrome/browser/resources/extensions/item_util.js
@@ -66,8 +66,7 @@ if (item.disableReasons.corruptInstall || item.disableReasons.suspiciousInstall || item.disableReasons.updateRequired || - item.disableReasons.blockedByPolicy || - item.disableReasons.blockedMature) { + item.disableReasons.blockedByPolicy) { return false; } // An item with dependent extensions can't be disabled (it would bork the
diff --git a/chrome/browser/resources/settings/BUILD.gn b/chrome/browser/resources/settings/BUILD.gn index 4e90d82..322c20a 100644 --- a/chrome/browser/resources/settings/BUILD.gn +++ b/chrome/browser/resources/settings/BUILD.gn
@@ -39,8 +39,15 @@ optimize_webui("build_polymer3") { host = "settings" input = rebase_path("$target_gen_dir/$unpak_folder", root_build_dir) - js_out_files = [ "settings.rollup.js" ] - js_module_in_files = [ "settings.js" ] + js_module_in_files = [ + "settings.js", + "lazy_load.js", + ] + js_out_files = [ + "settings.rollup.js", + "lazy_load.rollup.js", + "shared.rollup.js", + ] deps = [ ":unpak", @@ -246,6 +253,7 @@ "settings_menu:closure_compile_module", "settings_page:closure_compile_module", "settings_ui:closure_compile_module", + "site_settings:closure_compile_module", ] if (!is_chromeos) { deps += [ @@ -416,6 +424,7 @@ "site_settings_page:polymer3_elements", # Local targets + ":ensure_lazy_loaded_module", ":icons_module", ":modulize", ":settings_page_css_module", @@ -471,6 +480,12 @@ [ "ui/webui/resources/html/icon.html|getFavicon,getFaviconForPageURL" ] } +polymer_modulizer("ensure_lazy_loaded") { + js_file = "ensure_lazy_loaded.m.js" + html_file = "ensure_lazy_loaded.html" + html_type = "v3-ready" +} + js_modulizer("modulize") { input_files = [ "extension_control_browser_proxy.js",
diff --git a/chrome/browser/resources/settings/autofill_page/password_check.html b/chrome/browser/resources/settings/autofill_page/password_check.html index a43e9771..bae8450 100644 --- a/chrome/browser/resources/settings/autofill_page/password_check.html +++ b/chrome/browser/resources/settings/autofill_page/password_check.html
@@ -48,6 +48,10 @@ background-size: 16px 16px; } + iron-icon.hidden { + display: none; + } + </style> <!-- The banner is visible if no compromised password was found (yet). --> <template is="dom-if" if="[[shouldShowBanner_(status_, leakedPasswords)]]"> @@ -96,6 +100,7 @@ </div> <cr-button id="controlPasswordCheckButton" on-click="onPasswordCheckButtonClick_" + class$="[[getButtonTypeClass_(status_)]]" hidden$="[[isButtonHidden_(status_, suppressCheckupLink_)]]"> [[getButtonText_(status_)]] </cr-button>
diff --git a/chrome/browser/resources/settings/autofill_page/password_check.js b/chrome/browser/resources/settings/autofill_page/password_check.js index 4c2eb10f..2038376 100644 --- a/chrome/browser/resources/settings/autofill_page/password_check.js +++ b/chrome/browser/resources/settings/autofill_page/password_check.js
@@ -261,7 +261,7 @@ */ getStatusIconClass_(status, leakedPasswords) { if (!this.hasLeaksOrErrors_(status, leakedPasswords)) { - return 'no-leaks'; + return this.waitsForFirstCheck_() ? 'hidden' : 'no-leaks'; } if (this.hasLeakedCredentials_(leakedPasswords)) { return 'has-leaks'; @@ -277,7 +277,9 @@ getTitle_() { switch (this.status_.state) { case CheckState.IDLE: - return this.i18n('checkPasswords'); + return this.waitsForFirstCheck_() ? + this.i18n('checkPasswordsDescription') : + this.i18n('checkedPasswords'); case CheckState.CANCELED: return this.i18n('checkPasswordsCanceled'); case CheckState.RUNNING: @@ -332,6 +334,8 @@ getButtonText_(status) { switch (status.state) { case CheckState.IDLE: + return this.waitsForFirstCheck_() ? this.i18n('checkPasswords') : + this.i18n('checkPasswordsAgain'); case CheckState.CANCELED: case CheckState.TOO_MANY_PASSWORDS: return this.i18n('checkPasswordsAgain'); @@ -350,6 +354,15 @@ }, /** + * Returns 'action-button' only for the very first check. + * @return {string} + * @private + */ + getButtonTypeClass_() { + return this.waitsForFirstCheck_() ? 'action-button' : ' '; + }, + + /** * Returns true iff the check/stop button should be visible for a given state. * @param {!PasswordManagerProxy.PasswordCheckStatus} status * @return {!boolean} @@ -382,7 +395,10 @@ * @private */ bannerImageSrc_(isDarkMode) { - const type = this.status_.state == CheckState.IDLE ? 'positive' : 'neutral'; + const type = + (this.status_.state == CheckState.IDLE && !this.waitsForFirstCheck_()) ? + 'positive' : + 'neutral'; const suffix = isDarkMode ? '_dark' : ''; return `chrome://settings/images/password_check_${type}${suffix}.svg`; }, @@ -442,7 +458,7 @@ } switch (this.status_.state) { case CheckState.IDLE: - return true; + return !this.waitsForFirstCheck_(); case CheckState.CANCELED: case CheckState.RUNNING: case CheckState.OFFLINE: @@ -461,6 +477,15 @@ }, /** + * Returns true iff the leak check was performed at least once before. + * @return {boolean} + * @private + */ + waitsForFirstCheck_() { + return !this.status_.elapsedTimeSinceLastCheck; + }, + + /** * Returns true iff the user cannot retry the password check in their account. * Either because they are syncing or because they use a custom passphrase. * @return {boolean}
diff --git a/chrome/browser/resources/settings/chromeos/os_people_page/BUILD.gn b/chrome/browser/resources/settings/chromeos/os_people_page/BUILD.gn index 4f6ead8..8627b55 100644 --- a/chrome/browser/resources/settings/chromeos/os_people_page/BUILD.gn +++ b/chrome/browser/resources/settings/chromeos/os_people_page/BUILD.gn
@@ -138,7 +138,7 @@ "//chrome/browser/resources/settings/people_page:signout_dialog", "//chrome/browser/resources/settings/people_page:sync_browser_proxy", "//ui/webui/resources/cr_components/chromeos/quick_unlock:lock_screen_constants", - "//ui/webui/resources/cr_elements/chromeos/cr_picture:cr_png_behavior", + "//ui/webui/resources/cr_elements/chromeos/cr_picture:png", "//ui/webui/resources/js:assert", "//ui/webui/resources/js:i18n_behavior", "//ui/webui/resources/js:icon",
diff --git a/chrome/browser/resources/settings/chromeos/os_people_page/os_people_page.html b/chrome/browser/resources/settings/chromeos/os_people_page/os_people_page.html index 3c2be91..0fd79b9 100644 --- a/chrome/browser/resources/settings/chromeos/os_people_page/os_people_page.html +++ b/chrome/browser/resources/settings/chromeos/os_people_page/os_people_page.html
@@ -1,6 +1,6 @@ <link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/chromeos/cr_picture/cr_png_behavior.html"> +<link rel="import" href="chrome://resources/cr_elements/chromeos/cr_picture/png.html"> <link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_link_row/cr_link_row.html"> <link rel="import" href="chrome://resources/cr_elements/icons.html">
diff --git a/chrome/browser/resources/settings/chromeos/os_people_page/os_people_page.js b/chrome/browser/resources/settings/chromeos/os_people_page/os_people_page.js index b7ca770..9d8ef3a 100644 --- a/chrome/browser/resources/settings/chromeos/os_people_page/os_people_page.js +++ b/chrome/browser/resources/settings/chromeos/os_people_page/os_people_page.js
@@ -11,7 +11,6 @@ behaviors: [ settings.RouteObserverBehavior, - CrPngBehavior, I18nBehavior, WebUIListenerBehavior, LockStateBehavior, @@ -232,8 +231,7 @@ // Extract first frame from image by creating a single frame PNG using // url as input if base64 encoded and potentially animated. if (info.iconUrl.startsWith('data:image/png;base64')) { - this.profileIconUrl_ = - CrPngBehavior.convertImageSequenceToPng([info.iconUrl]); + this.profileIconUrl_ = cr.png.convertImageSequenceToPng([info.iconUrl]); return; } this.profileIconUrl_ = info.iconUrl;
diff --git a/chrome/browser/resources/settings/chromeos/personalization_page/BUILD.gn b/chrome/browser/resources/settings/chromeos/personalization_page/BUILD.gn index fc8949f..3850c2c 100644 --- a/chrome/browser/resources/settings/chromeos/personalization_page/BUILD.gn +++ b/chrome/browser/resources/settings/chromeos/personalization_page/BUILD.gn
@@ -21,7 +21,7 @@ "//ui/webui/resources/cr_elements/chromeos/cr_picture:cr_picture_list", "//ui/webui/resources/cr_elements/chromeos/cr_picture:cr_picture_pane", "//ui/webui/resources/cr_elements/chromeos/cr_picture:cr_picture_types", - "//ui/webui/resources/cr_elements/chromeos/cr_picture:cr_png_behavior", + "//ui/webui/resources/cr_elements/chromeos/cr_picture:png", "//ui/webui/resources/js:i18n_behavior", "//ui/webui/resources/js:load_time_data", "//ui/webui/resources/js:util",
diff --git a/chrome/browser/resources/settings/chromeos/personalization_page/change_picture.html b/chrome/browser/resources/settings/chromeos/personalization_page/change_picture.html index 90fa847..5277968f 100644 --- a/chrome/browser/resources/settings/chromeos/personalization_page/change_picture.html +++ b/chrome/browser/resources/settings/chromeos/personalization_page/change_picture.html
@@ -3,7 +3,7 @@ <link rel="import" href="chrome://resources/cr_elements/chromeos/cr_picture/cr_picture_list.html"> <link rel="import" href="chrome://resources/cr_elements/chromeos/cr_picture/cr_picture_pane.html"> <link rel="import" href="chrome://resources/cr_elements/chromeos/cr_picture/cr_picture_types.html"> -<link rel="import" href="chrome://resources/cr_elements/chromeos/cr_picture/cr_png_behavior.html"> +<link rel="import" href="chrome://resources/cr_elements/chromeos/cr_picture/png.html"> <link rel="import" href="chrome://resources/html/i18n_behavior.html"> <link rel="import" href="chrome://resources/html/util.html"> <link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
diff --git a/chrome/browser/resources/settings/chromeos/personalization_page/change_picture.js b/chrome/browser/resources/settings/chromeos/personalization_page/change_picture.js index b394da5..55b2a7c 100644 --- a/chrome/browser/resources/settings/chromeos/personalization_page/change_picture.js +++ b/chrome/browser/resources/settings/chromeos/personalization_page/change_picture.js
@@ -12,7 +12,6 @@ behaviors: [ settings.RouteObserverBehavior, - CrPngBehavior, I18nBehavior, WebUIListenerBehavior, ], @@ -150,8 +149,8 @@ */ receiveOldImage_(imageInfo) { this.oldImageLabel_ = this.i18n( - CrPngBehavior.isEncodedPngDataUrlAnimated(imageInfo.url) ? 'oldVideo' : - 'oldPhoto'); + cr.png.isEncodedPngDataUrlAnimated(imageInfo.url) ? 'oldVideo' : + 'oldPhoto'); this.oldImagePending_ = false; this.pictureList_.setOldImageUrl(imageInfo.url, imageInfo.index); },
diff --git a/chrome/browser/resources/settings/controls/BUILD.gn b/chrome/browser/resources/settings/controls/BUILD.gn index bdc61aa..d8677c75 100644 --- a/chrome/browser/resources/settings/controls/BUILD.gn +++ b/chrome/browser/resources/settings/controls/BUILD.gn
@@ -360,10 +360,13 @@ html_file = "settings_idle_load.html" html_type = "dom-module" auto_imports = [ + "chrome/browser/resources/settings/ensure_lazy_loaded.html|ensureLazyLoaded", "ui/webui/resources/html/assert.html|assert", "ui/webui/resources/html/polymer.html|Polymer,html,templatize,TemplateInstanceBase", ] - namespace_rewrites = [ "Polymer.Templatize.templatize|templatize" ] + namespace_rewrites = settings_namespace_rewrites + [ + "Polymer.Templatize.templatize|templatize", + ] } polymer_modulizer("settings_radio_group") {
diff --git a/chrome/browser/resources/settings/controls/settings_idle_load.html b/chrome/browser/resources/settings/controls/settings_idle_load.html index 33a89eb9..745175a 100644 --- a/chrome/browser/resources/settings/controls/settings_idle_load.html +++ b/chrome/browser/resources/settings/controls/settings_idle_load.html
@@ -1,6 +1,7 @@ <link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/html/assert.html"> +<link rel="import" href="../ensure_lazy_loaded.html"> <dom-module id="settings-idle-load"> <template>
diff --git a/chrome/browser/resources/settings/controls/settings_idle_load.js b/chrome/browser/resources/settings/controls/settings_idle_load.js index de4d80d..5b536b8 100644 --- a/chrome/browser/resources/settings/controls/settings_idle_load.js +++ b/chrome/browser/resources/settings/controls/settings_idle_load.js
@@ -42,16 +42,13 @@ }, /** - * @return {!Promise<Element>} Child element which has been stamped into the - * DOM tree. + * @param {!function():!Promise} requestFn Requests the lazy module. + * @return {!Promise<!Element>} Resolves with the stamped child element after + * the lazy module has been loaded. */ - get() { - if (this.loading_) { - return this.loading_; - } - - this.loading_ = new Promise((resolve, reject) => { - /* #ignore */ this.importHref(this.url, () => { + requestLazyModule_(requestFn) { + return new Promise((resolve, reject) => { + requestFn().then(() => { const template = /** @type {!HTMLTemplateElement} */ (this.getContentChildren()[0]); const TemplateClass = Polymer.Templatize.templatize(template, this, { @@ -68,9 +65,30 @@ resolve(this.child_); this.fire('lazy-loaded'); - /* #ignore */ }, reject, true); + }, reject); }); + }, + /** + * @return {!Promise<Element>} Child element which has been stamped into the + * DOM tree. + */ + get() { + if (this.loading_) { + return this.loading_; + } + + // Polymer 2 codepath + /* #ignore */ const requestLazyModuleFn = () => { + /* #ignore */ return new Promise((resolve, reject) => { + /* #ignore */ this.importHref(this.url, resolve, reject, true); + /* #ignore */ }); + /* #ignore */ }; + + // Polymer 3 codepath, do not delete next line comment. + // #polymer3 const requestLazyModuleFn = ensureLazyLoaded; + + this.loading_ = this.requestLazyModule_(requestLazyModuleFn); return this.loading_; },
diff --git a/chrome/browser/resources/settings/ensure_lazy_loaded.html b/chrome/browser/resources/settings/ensure_lazy_loaded.html new file mode 100644 index 0000000..0c665f4b --- /dev/null +++ b/chrome/browser/resources/settings/ensure_lazy_loaded.html
@@ -0,0 +1 @@ +<!-- This file is used only for Polymer 3 autogeneration. -->
diff --git a/chrome/browser/resources/settings/ensure_lazy_loaded.m.js b/chrome/browser/resources/settings/ensure_lazy_loaded.m.js new file mode 100644 index 0000000..50c7dfe --- /dev/null +++ b/chrome/browser/resources/settings/ensure_lazy_loaded.m.js
@@ -0,0 +1,40 @@ +// Copyright 2020 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. + +let lazyLoadPromise = null; + +/** @return {!Promise<void>} Resolves when the lazy load module is imported. */ +export function ensureLazyLoaded() { + if (!lazyLoadPromise) { + const script = document.createElement('script'); + script.type = 'module'; + script.src = './lazy_load.js'; + document.body.appendChild(script); + + lazyLoadPromise = Promise.all([ + 'settings-appearance-page', + 'settings-autofill-section', + 'settings-password-check', + 'passwords-section', + 'settings-payments-section', + 'settings-clear-browsing-data-dialog', + 'settings-search-engines-page', + // <if expr="use_nss_certs"> + 'certificate-manager', + // </if> + 'settings-a11y-page', + 'settings-downloads-page', + 'settings-languages-page', + 'settings-printing-page', + 'settings-reset-page', + // <if expr="not chromeos"> + 'settings-system-page', + // </if> + // <if expr="not is_macosx"> + 'settings-edit-dictionary-page', + // </if> + ].map(name => customElements.whenDefined(name))); + } + return lazyLoadPromise; +}
diff --git a/chrome/browser/resources/settings/lazy_load.js b/chrome/browser/resources/settings/lazy_load.js new file mode 100644 index 0000000..46e282f --- /dev/null +++ b/chrome/browser/resources/settings/lazy_load.js
@@ -0,0 +1,95 @@ +// Copyright 2020 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. + +// Subpages +import './appearance_page/appearance_fonts_page.m.js'; +import './autofill_page/password_check.m.js'; +import './autofill_page/passwords_section.m.js'; +import './autofill_page/payments_section.m.js'; +import './clear_browsing_data_dialog/clear_browsing_data_dialog.m.js'; +import './search_engines_page/search_engines_page.m.js'; + +// TODO(https://crbug.com/1026426): Uncomment these imports once the pages have +// been migrated to Polymer 3. +// import './privacy_page/cookies_page.m.js'; +// import './privacy_page/security_keys_subpage.m.js'; +// import './privacy_page/security_page.m.js'; +// import './site_settings/all_sites.m.js'; +import './site_settings/site_data_details_subpage.m.js'; +// import 'site_settings_page/site_settings_page.m.js'; +// import 'site_settings/category_default_setting.m.js'; +// import 'site_settings/category_setting_exceptions.m.js'; +// import 'site_settings/chooser_exception_list.m.js'; +// import 'site_settings/media_picker.m.js'; +// import 'site_settings/pdf_documents.m.js'; +// import 'site_settings/protocol_handlers.m.js'; +// import 'site_settings/site_data.m.js'; +// import 'site_settings/site_details.m.js'; +// import 'site_settings/zoom_levels.m.js'; + +// <if expr="not chromeos"> +// import 'people_page/manage_profile.m.js'; +// </if> +// import 'people_page/sync_account_control.m.js'; + +// <if expr="use_nss_certs"> +import 'chrome://resources/cr_components/certificate_manager/certificate_manager.m.js'; +// </if> + +// Sections +import './a11y_page/a11y_page.m.js'; +import './downloads_page/downloads_page.m.js'; +import './languages_page/languages_page.m.js'; +import './printing_page/printing_page.m.js'; +import './reset_page/reset_page.m.js'; + +// <if expr="not chromeos"> +import './system_page/system_page.m.js'; +// </if> + +// <if expr="not is_macosx"> +import './languages_page/edit_dictionary_page.m.js'; +// </if> + +// Dependencies imported separately for tests +import './controls/controlled_button.m.js'; +import './controls/settings_slider.m.js'; +import './controls/settings_textarea.m.js'; +// <if expr="_google_chrome and is_win"> +import './incompatible_applications_page/incompatible_applications_page.m.js'; +// </if> +import './search_engines_page/omnibox_extension_entry.m.js'; +import './search_engines_page/search_engine_dialog.m.js'; +import './search_engines_page/search_engine_entry.m.js'; +import './site_settings/site_list_entry.m.js'; + +// <if expr="_google_chrome and is_win"> +export {CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW} from './chrome_cleanup_page/items_to_remove_list.m.js'; +export {ChromeCleanupIdleReason} from './chrome_cleanup_page/chrome_cleanup_page.m.js'; +export {ChromeCleanupProxyImpl} from './chrome_cleanup_page/chrome_cleanup_proxy.m.js'; +export {IncompatibleApplication, IncompatibleApplicationsBrowserProxyImpl} from './incompatible_applications_page/incompatible_applications_browser_proxy.m.js'; +// </if> + +export {getToastManager} from 'chrome://resources/cr_elements/cr_toast/cr_toast_manager.m.js'; + +export {FontsBrowserProxy, FontsBrowserProxyImpl} from './appearance_page/fonts_browser_proxy.m.js'; +export {CountryDetailManagerImpl} from './autofill_page/address_edit_dialog.m.js'; +export {AutofillManagerImpl} from './autofill_page/autofill_section.m.js'; +export {PaymentsManagerImpl} from './autofill_page/payments_section.m.js'; +export {ClearBrowsingDataBrowserProxyImpl} from './clear_browsing_data_dialog/clear_browsing_data_browser_proxy.m.js'; +export {DownloadsBrowserProxyImpl} from './downloads_page/downloads_browser_proxy.m.js'; +export {kMenuCloseDelay} from './languages_page/languages_page.m.js'; +export {LanguagesBrowserProxyImpl} from './languages_page/languages_browser_proxy.m.js'; +export {ChooserType,ContentSetting,ContentSettingsTypes,SiteSettingSource} from './site_settings/constants.m.js'; +export {cookieInfo} from './site_settings/cookie_info.m.js'; +export {LocalDataBrowserProxyImpl} from './site_settings/local_data_browser_proxy.m.js'; +export {SiteSettingsPrefsBrowserProxyImpl} from './site_settings/site_settings_prefs_browser_proxy.m.js'; + +// <if expr="not chromeos"> +export {SystemPageBrowserProxyImpl} from './system_page/system_page_browser_proxy.m.js'; +// </if> + +// <if expr="chromeos"> +export {BlockingRequestManager} from './autofill_page/blocking_request_manager.m.js'; +// </if>
diff --git a/chrome/browser/resources/settings/os_settings_resources.grd b/chrome/browser/resources/settings/os_settings_resources.grd index 3b32f61..a4b102b 100644 --- a/chrome/browser/resources/settings/os_settings_resources.grd +++ b/chrome/browser/resources/settings/os_settings_resources.grd
@@ -250,6 +250,9 @@ <structure name="IDR_OS_SETTINGS_OS_SETTINGS_PAGE_HTML" file="chromeos/os_settings_page/os_settings_page.html" type="chrome_html" /> + <structure name="IDR_OS_SETTINGS_ENSURE_LAZY_LOADED_HTML" + file="ensure_lazy_loaded.html" + type="chrome_html" /> <structure name="IDR_OS_SETTINGS_EXTENSION_CONTROL_BROWSER_PROXY_JS" file="extension_control_browser_proxy.js" type="chrome_html" />
diff --git a/chrome/browser/resources/settings/people_page/BUILD.gn b/chrome/browser/resources/settings/people_page/BUILD.gn index 7cf1090..9db6fd00 100644 --- a/chrome/browser/resources/settings/people_page/BUILD.gn +++ b/chrome/browser/resources/settings/people_page/BUILD.gn
@@ -69,7 +69,7 @@ "..:router", "../settings_page:settings_animated_pages", "//ui/webui/resources/cr_components/chromeos/quick_unlock:lock_screen_constants", - "//ui/webui/resources/cr_elements/chromeos/cr_picture:cr_png_behavior", + "//ui/webui/resources/cr_elements/chromeos/cr_picture:png", "//ui/webui/resources/cr_elements/cr_toast:cr_toast", "//ui/webui/resources/js:assert", "//ui/webui/resources/js:i18n_behavior",
diff --git a/chrome/browser/resources/settings/people_page/people_page.html b/chrome/browser/resources/settings/people_page/people_page.html index 28bc5ca9..926fdc3 100644 --- a/chrome/browser/resources/settings/people_page/people_page.html +++ b/chrome/browser/resources/settings/people_page/people_page.html
@@ -30,7 +30,7 @@ <if expr="chromeos"> <link rel="import" href="account_manager_browser_proxy.html"> -<link rel="import" href="chrome://resources/cr_elements/chromeos/cr_picture/cr_png_behavior.html"> +<link rel="import" href="chrome://resources/cr_elements/chromeos/cr_picture/png.html"> </if> <if expr="not chromeos"> <link rel="import" href="import_data_dialog.html">
diff --git a/chrome/browser/resources/settings/people_page/people_page.js b/chrome/browser/resources/settings/people_page/people_page.js index 1f8410c1..fc298d9 100644 --- a/chrome/browser/resources/settings/people_page/people_page.js +++ b/chrome/browser/resources/settings/people_page/people_page.js
@@ -11,9 +11,6 @@ behaviors: [ settings.RouteObserverBehavior, I18nBehavior, WebUIListenerBehavior, - // <if expr="chromeos"> - CrPngBehavior, - // </if> ], properties: { @@ -233,8 +230,7 @@ */ // <if expr="chromeos"> if (info.iconUrl.startsWith('data:image/png;base64')) { - this.profileIconUrl_ = - CrPngBehavior.convertImageSequenceToPng([info.iconUrl]); + this.profileIconUrl_ = cr.png.convertImageSequenceToPng([info.iconUrl]); return; } // </if>
diff --git a/chrome/browser/resources/settings/privacy_page/cookies_page.html b/chrome/browser/resources/settings/privacy_page/cookies_page.html index f77d660..5434767 100644 --- a/chrome/browser/resources/settings/privacy_page/cookies_page.html +++ b/chrome/browser/resources/settings/privacy_page/cookies_page.html
@@ -11,8 +11,8 @@ <link rel="import" href="../prefs/prefs.html"> <link rel="import" href="../prefs/prefs_behavior.html"> <link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="../site_settings/category_setting_exceptions.html"> <link rel="import" href="../site_settings/constants.html"> +<link rel="import" href="../site_settings/site_list.html"> <link rel="import" href="../site_settings/site_settings_prefs_browser_proxy.html"> <link rel="import" href="collapse_radio_button.html"> <link rel="import" href="do_not_track_toggle.html"> @@ -127,13 +127,27 @@ numeric-unchecked-value="[[networkPredictionUncheckedValue_]]" on-settings-boolean-control-change="onNetworkPredictionChange_"> </settings-toggle-button> - <div class="settings-box first"> - <h2>$i18n{cookiesManageSiteSpecificExceptions}</h2> - </div> - <category-setting-exceptions - category="[[ContentSettingsTypes.COOKIES]]" - block-header="$i18n{siteSettingsBlock}"> - </category-setting-exceptions> + <site-list id="allowExceptionsList" + category="[[cookiesContentSettingType_]]" + category-subtype="[[contentSetting_.ALLOW]]" + category-header="$i18n{cookiePageAllowExceptions}" + read-only-list="[[cookiesContentSettingManaged_]]" + search-filter="[[searchTerm]]"> + </site-list> + <site-list id="sessionOnlyExceptionsList" + category="[[cookiesContentSettingType_]]" + category-subtype="[[contentSetting_.SESSION_ONLY]]" + category-header="$i18n{cookiePageSessionOnlyExceptions}" + read-only-list="[[cookiesContentSettingManaged_]]" + search-filter="[[searchTerm]]"> + </site-list> + <site-list id="blockExceptionsList" + category="[[cookiesContentSettingType_]]" + category-subtype="[[contentSetting_.BLOCK]]" + category-header="$i18n{cookiePageBlockExceptions}" + read-only-list="[[cookiesContentSettingManaged_]]" + search-filter="[[searchTerm]]"> + </site-list> </template> <script src="cookies_page.js"></script> </dom-module>
diff --git a/chrome/browser/resources/settings/privacy_page/cookies_page.js b/chrome/browser/resources/settings/privacy_page/cookies_page.js index 4556027..8a800c9 100644 --- a/chrome/browser/resources/settings/privacy_page/cookies_page.js +++ b/chrome/browser/resources/settings/privacy_page/cookies_page.js
@@ -47,6 +47,15 @@ }, /** + * Current search term. + */ + searchTerm: { + type: String, + notify: true, + value: '', + }, + + /** * Valid cookie states. * @private */ @@ -86,10 +95,28 @@ notify: true, }, + /** @private */ + contentSetting_: { + type: Object, + value: settings.ContentSetting, + }, + /** * @private {!settings.ContentSettingsTypes} */ - ContentSettingsTypes: {type: Object, value: settings.ContentSettingsTypes}, + cookiesContentSettingType_: { + type: String, + value: settings.ContentSettingsTypes.COOKIES, + }, + + /** + * Whether the cookie content setting is managed. + * @private + */ + cookiesContentSettingManaged_: { + type: Boolean, + notify: false, + }, }, observers: [ @@ -159,6 +186,9 @@ }; this.clearOnExitDisabled_ = contentSetting.setting === settings.ContentSetting.BLOCK; + + this.cookiesContentSettingManaged_ = + contentSetting.source === settings.SiteSettingSource.POLICY; }, /**
diff --git a/chrome/browser/resources/settings/privacy_page/privacy_page.html b/chrome/browser/resources/settings/privacy_page/privacy_page.html index e6fa545..5976a41 100644 --- a/chrome/browser/resources/settings/privacy_page/privacy_page.html +++ b/chrome/browser/resources/settings/privacy_page/privacy_page.html
@@ -249,8 +249,12 @@ no-search="[[!privacySettingsRedesignEnabled_]]"> <settings-subpage id="cookies" page-title="$i18n{cookiePageTitle}" no-search$="[[!privacySettingsRedesignEnabled_]]" + search-label="$i18n{siteSettingsAllSitesSearch}" + search-term="{{searchFilter_}}" associated-control="[[$$('#cookiesLinkRow')]]"> - <settings-cookies-page prefs="{{prefs}}"></settings-cookies-page> + <settings-cookies-page prefs="{{prefs}}" + search-term="[[searchFilter_]]"> + </settings-cookies-page> </settings-subpage> </template> <template is="dom-if" route-path="/content/cookies" no-search>
diff --git a/chrome/browser/resources/settings/settings.gni b/chrome/browser/resources/settings/settings.gni index 867d780..43c5b7a 100644 --- a/chrome/browser/resources/settings/settings.gni +++ b/chrome/browser/resources/settings/settings.gni
@@ -5,6 +5,7 @@ # Common namespace rewrites for all polymer_modulizer() or js_modulizer() # targets in Settings. settings_namespace_rewrites = [ + "// #polymer3 |", "cr_slider.SliderTick|SliderTick", "settings.address.CountryDetailManager|CountryDetailManager", "settings.AboutPageBrowserProxy|AboutPageBrowserProxy", @@ -12,9 +13,11 @@ "settings.AutofillManager|AutofillManager", "settings.BlockingRequestManager|BlockingRequestManager", "settings.CaptionsBrowserProxy|CaptionsBrowserProxy", + "settings.ChooserType|ChooserType", "settings.ChromeCleanupProxy|ChromeCleanupProxy", "settings.ChromeCleanupRemovalListItem|ChromeCleanupRemovalListItem", "settings.ClearBrowsingDataBrowserProxy|ClearBrowsingDataBrowserProxy", + "settings.ContentSetting|ContentSetting", "settings.CreditCardEntry|CreditCardEntry", "settings.BrowserProfile|BrowserProfile", "settings.DefaultBrowserBrowserProxy|DefaultBrowserBrowserProxy", @@ -30,6 +33,7 @@ "settings.IncompatibleApplication|IncompatibleApplication", "settings.LanguagesBrowserProxy|LanguagesBrowserProxy", "settings.LifetimeBrowserProxy|LifetimeBrowserProxy", + "settings.LocalDataBrowserProxy|LocalDataBrowserProxy", "settings.MainPageBehavior|MainPageBehavior", "settings.MetricsBrowserProxy|MetricsBrowserProxy", "settings.MinimumRoutes|MinimumRoutes", @@ -49,6 +53,9 @@ "settings.SearchEnginesBrowserProxy|SearchEnginesBrowserProxy", "settings.SearchRequest|SearchRequest", "settings.SearchResult|SearchResult", + "settings.SITE_EXCEPTION_WILDCARD|SITE_EXCEPTION_WILDCARD", + "settings.SiteSettingSource|SiteSettingSource", + "settings.SiteSettingsPrefsBrowserProxy|SiteSettingsPrefsBrowserProxy", "settings.StartupUrlsPageBrowserProxy|StartupUrlsPageBrowserProxy", "settings.StatusAction|StatusAction", "settings.SyncBrowserProxy|SyncBrowserProxy",
diff --git a/chrome/browser/resources/settings/settings.js b/chrome/browser/resources/settings/settings.js index f0cada4..8c46f9f0 100644 --- a/chrome/browser/resources/settings/settings.js +++ b/chrome/browser/resources/settings/settings.js
@@ -2,35 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import './a11y_page/a11y_page.m.js'; import './about_page/about_page.m.js'; import './appearance_page/appearance_page.m.js'; -import './appearance_page/appearance_fonts_page.m.js'; import './autofill_page/autofill_page.m.js'; -import './autofill_page/password_check.m.js'; -import './autofill_page/passwords_section.m.js'; import './basic_page/basic_page.m.js'; -import './clear_browsing_data_dialog/clear_browsing_data_dialog.m.js'; -import './controls/controlled_button.m.js'; import './controls/controlled_radio_button.m.js'; import './controls/extension_controlled_indicator.m.js'; import './controls/settings_checkbox.m.js'; import './controls/settings_dropdown_menu.m.js'; import './controls/settings_idle_load.m.js'; -import './controls/settings_slider.m.js'; -import './controls/settings_textarea.m.js'; import './controls/settings_toggle_button.m.js'; -import './downloads_page/downloads_page.m.js'; import './on_startup_page/on_startup_page.m.js'; import './on_startup_page/startup_urls_page.m.js'; import './prefs/prefs.m.js'; -import './printing_page/printing_page.m.js'; -import './reset_page/reset_page.m.js'; import './site_favicon.m.js'; -import './search_engines_page/omnibox_extension_entry.m.js'; -import './search_engines_page/search_engine_dialog.m.js'; -import './search_engines_page/search_engine_entry.m.js'; -import './search_engines_page/search_engines_page.m.js'; import './search_page/search_page.m.js'; import './settings_main/settings_main.m.js'; import './settings_menu/settings_menu.m.js'; @@ -38,51 +23,21 @@ import './settings_page/settings_animated_pages.m.js'; import './settings_ui/settings_ui.m.js'; -// <if expr="_google_chrome and is_win"> -import './incompatible_applications_page/incompatible_applications_page.m.js'; -// </if> - // <if expr="not chromeos"> import './default_browser_page/default_browser_page.m.js'; import './people_page/import_data_dialog.m.js'; -import './system_page/system_page.m.js'; -// </if> - -// <if expr="not is_macosx"> -import './languages_page/edit_dictionary_page.m.js'; -// </if> - -export {getToastManager} from 'chrome://resources/cr_elements/cr_toast/cr_toast_manager.m.js'; - -// <if expr="_google_chrome and is_win"> -export {CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW} from './chrome_cleanup_page/items_to_remove_list.m.js'; -export {ChromeCleanupIdleReason} from './chrome_cleanup_page/chrome_cleanup_page.m.js'; -export {ChromeCleanupProxyImpl} from './chrome_cleanup_page/chrome_cleanup_proxy.m.js'; -export {IncompatibleApplication, IncompatibleApplicationsBrowserProxyImpl} from './incompatible_applications_page/incompatible_applications_browser_proxy.m.js'; // </if> // <if expr="not chromeos"> export {DefaultBrowserBrowserProxyImpl} from './default_browser_page/default_browser_browser_proxy.m.js'; -export {SystemPageBrowserProxyImpl} from './system_page/system_page_browser_proxy.m.js'; export {ImportDataBrowserProxyImpl, ImportDataStatus} from './people_page/import_data_browser_proxy.m.js'; // </if> -// <if expr="chromeos"> -export {BlockingRequestManager} from './autofill_page/blocking_request_manager.m.js'; -// </if> - export {AboutPageBrowserProxy, AboutPageBrowserProxyImpl, UpdateStatus} from './about_page/about_page_browser_proxy.m.js'; export {AppearanceBrowserProxy, AppearanceBrowserProxyImpl} from './appearance_page/appearance_browser_proxy.m.js'; -export {AutofillManagerImpl} from './autofill_page/autofill_section.m.js'; -export {ClearBrowsingDataBrowserProxyImpl} from './clear_browsing_data_dialog/clear_browsing_data_browser_proxy.m.js'; -export {CountryDetailManagerImpl} from './autofill_page/address_edit_dialog.m.js'; export {CrSettingsPrefs} from './prefs/prefs_types.m.js'; -export {DownloadsBrowserProxyImpl} from './downloads_page/downloads_browser_proxy.m.js'; export {ExtensionControlBrowserProxyImpl} from './extension_control_browser_proxy.m.js'; -export {FontsBrowserProxy, FontsBrowserProxyImpl} from './appearance_page/fonts_browser_proxy.m.js'; export {getSearchManager, SearchRequest, setSearchManagerForTesting} from './search_settings.m.js'; -export {kMenuCloseDelay} from './languages_page/languages_page.m.js'; -export {LanguagesBrowserProxyImpl} from './languages_page/languages_browser_proxy.m.js'; export {LifetimeBrowserProxyImpl} from './lifetime_browser_proxy.m.js'; export {MetricsBrowserProxyImpl, PrivacyElementInteractions} from './metrics_browser_proxy.m.js'; export {OnStartupBrowserProxy, OnStartupBrowserProxyImpl} from './on_startup_page/on_startup_browser_proxy.m.js'; @@ -92,9 +47,8 @@ export {PageStatus, StatusAction, SyncBrowserProxyImpl} from './people_page/sync_browser_proxy.m.js'; export {pageVisibility} from './page_visibility.m.js'; export {PasswordManagerImpl} from './autofill_page/password_manager_proxy.m.js'; -export {PaymentsManagerImpl} from './autofill_page/payments_section.m.js'; export {prefToString, stringToPrefValue} from './prefs/pref_util.m.js'; -export {routes} from './route.m.js'; export {ResetBrowserProxyImpl} from './reset_page/reset_browser_proxy.m.js'; +export {routes} from './route.m.js'; export {Route, Router} from './router.m.js'; export {SearchEnginesBrowserProxyImpl} from './search_engines_page/search_engines_browser_proxy.m.js';
diff --git a/chrome/browser/resources/settings/settings_page/main_page_behavior.html b/chrome/browser/resources/settings/settings_page/main_page_behavior.html index fb523ca0..5f69656 100644 --- a/chrome/browser/resources/settings/settings_page/main_page_behavior.html +++ b/chrome/browser/resources/settings/settings_page/main_page_behavior.html
@@ -2,4 +2,5 @@ <link rel="import" href="chrome://resources/html/assert.html"> <link rel="import" href="../router.html"> +<link rel="import" href="../ensure_lazy_loaded.html"> <script src="main_page_behavior.js"></script>
diff --git a/chrome/browser/resources/settings/settings_page/main_page_behavior.js b/chrome/browser/resources/settings/settings_page/main_page_behavior.js index 0be3da8..3768946b 100644 --- a/chrome/browser/resources/settings/settings_page/main_page_behavior.js +++ b/chrome/browser/resources/settings/settings_page/main_page_behavior.js
@@ -5,6 +5,7 @@ // clang-format off // #import {assert} from 'chrome://resources/js/assert.m.js'; // #import {beforeNextRender} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +// #import {ensureLazyLoaded} from '../ensure_lazy_loaded.m.js'; // #import {Route, Router} from '../router.m.js'; // #import {SettingsRoutes} from '../settings_routes.m.js'; // clang-format on @@ -206,13 +207,17 @@ // TODO(dpapad): On chrome://os-settings the lazy_load.html file resides // at a different path. Remove conditional logic once this file is not // shared between chrome://settings and chrome://os-settings. - // TODO(rbpotter): Fix this to work correctly in Polymer 3, instead of - // just removing the importHref lines. - const lazyLoadPathPrefix = - window.location.origin === 'chrome://settings' ? '' : '/chromeos'; + // Polymer 2 codepath + /* #ignore */ const lazyLoadPathPrefix = + /* #ignore */ window.location.origin === 'chrome://settings' ? + /* #ignore */ '' : + /* #ignore */ '/chromeos'; /* #ignore */ Polymer.importHref( /* #ignore */ `${lazyLoadPathPrefix}/lazy_load.html`, () => {}); + // Polymer 3 codepath, do not delete next line comment. + // #polymer3 ensureLazyLoaded(); + this.ensureSectionForRoute_(route).then(section => { section.classList.add('expanded'); // Fire event used by a11y tests only.
diff --git a/chrome/browser/resources/settings/settings_resources.grd b/chrome/browser/resources/settings/settings_resources.grd index 50bf731..8117aae3 100644 --- a/chrome/browser/resources/settings/settings_resources.grd +++ b/chrome/browser/resources/settings/settings_resources.grd
@@ -1177,6 +1177,9 @@ preprocess="true" file="lazy_load.html" type="chrome_html" /> + <structure name="IDR_SETTINGS_ENSURE_LAZY_LOADED_HTML" + file="ensure_lazy_loaded.html" + type="chrome_html" /> <structure name="IDR_SETTINGS_WEBSITE_USAGE_PRIVATE_API_HTML" file="site_settings/website_usage_private_api.html" type="chrome_html" />
diff --git a/chrome/browser/resources/settings/settings_resources_v3.grdp b/chrome/browser/resources/settings/settings_resources_v3.grdp index 5dce75fb..1bdca54 100644 --- a/chrome/browser/resources/settings/settings_resources_v3.grdp +++ b/chrome/browser/resources/settings/settings_resources_v3.grdp
@@ -246,6 +246,11 @@ use_base_dir="false" type="BINDATA" preprocess="true" /> + <include name="IDR_SETTINGS_ENSURE_LAZY_LOADED_JS" + file="${root_gen_dir}/chrome/browser/resources/settings/ensure_lazy_loaded.m.js" + preprocess="true" + use_base_dir="false" + type="BINDATA" /> <include name="IDR_SETTINGS_EXTENSION_CONTROL_BROWSER_PROXY_M_JS" file="${root_gen_dir}/chrome/browser/resources/settings/extension_control_browser_proxy.m.js" use_base_dir="false" @@ -301,6 +306,10 @@ use_base_dir="false" type="BINDATA" /> </if> + <include name="IDR_SETTINGS_LAZY_LOAD_V3_JS" + file="lazy_load.js" + type="BINDATA" + preprocess="true" /> <include name="IDR_SETTINGS_LIFETIME_BROWSER_PROXY_M_JS" file="${root_gen_dir}/chrome/browser/resources/settings/lifetime_browser_proxy.m.js" use_base_dir="false" @@ -505,6 +514,37 @@ file="${root_gen_dir}/chrome/browser/resources/settings/site_favicon.m.js" use_base_dir="false" type="BINDATA" /> + <include name="IDR_SETTINGS_SITE_SETTINGS_CONSTANTS_M_JS" + file="${root_gen_dir}/chrome/browser/resources/settings/site_settings/constants.m.js" + use_base_dir="false" + type="BINDATA" /> + <include name="IDR_SETTINGS_SITE_SETTINGS_COOKIE_INFO_M_JS" + file="${root_gen_dir}/chrome/browser/resources/settings/site_settings/cookie_info.m.js" + use_base_dir="false" + type="BINDATA" /> + <include name="IDR_SETTINGS_SITE_SETTINGS_LOCAL_DATA_BROWSER_PROXY_M_JS" + file="${root_gen_dir}/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.m.js" + use_base_dir="false" + type="BINDATA" /> + <include name="IDR_SETTINGS_SITE_SETTINGS_SITE_DATA_DETAILS_SUBPAGE_M_JS" + file="${root_gen_dir}/chrome/browser/resources/settings/site_settings/site_data_details_subpage.m.js" + use_base_dir="false" + type="BINDATA" /> + <include name="IDR_SETTINGS_SITE_SETTINGS_SITE_LIST_ENTRY_M_JS" + file="${root_gen_dir}/chrome/browser/resources/settings/site_settings/site_list_entry.m.js" + use_base_dir="false" + type="BINDATA" + preprocess="true" /> + <include name="IDR_SETTINGS_SITE_SETTINGS_SITE_SETTINGS_BEHAVIOR_M_JS" + file="${root_gen_dir}/chrome/browser/resources/settings/site_settings/site_settings_behavior.m.js" + use_base_dir="false" + type="BINDATA" + preprocess="true" /> + <include name="IDR_SETTINGS_SITE_SETTINGS_SITE_SETTINGS_PREFS_BROWSER_PROXY_M_JS" + file="${root_gen_dir}/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.m.js" + use_base_dir="false" + type="BINDATA" + preprocess="true" /> <include name="IDR_SETTINGS_PEOPLE_PAGE_SYNC_BROWSER_PROXY_M_JS" file="${root_gen_dir}/chrome/browser/resources/settings/people_page/sync_browser_proxy.m.js" use_base_dir="false"
diff --git a/chrome/browser/resources/settings/settings_resources_vulcanized.grd b/chrome/browser/resources/settings/settings_resources_vulcanized.grd index 84d4f2f..fd661ab 100644 --- a/chrome/browser/resources/settings/settings_resources_vulcanized.grd +++ b/chrome/browser/resources/settings/settings_resources_vulcanized.grd
@@ -79,6 +79,18 @@ preprocess="true" compress="gzip" type="BINDATA" /> + <include name="IDR_SETTINGS_LAZY_LOAD_ROLLUP_JS" + file="${root_gen_dir}\chrome\browser\resources\settings\lazy_load.rollup.js" + preprocess="true" + type="BINDATA" + compress="gzip" + use_base_dir="false" /> + <include name="IDR_SETTINGS_SHARED_ROLLUP_JS" + file="${root_gen_dir}\chrome\browser\resources\settings\shared.rollup.js" + preprocess="true" + type="BINDATA" + compress="gzip" + use_base_dir="false" /> </includes> </release> </grit>
diff --git a/chrome/browser/resources/settings/site_settings/BUILD.gn b/chrome/browser/resources/settings/site_settings/BUILD.gn index 7ac6d134..c34e27d8 100644 --- a/chrome/browser/resources/settings/site_settings/BUILD.gn +++ b/chrome/browser/resources/settings/site_settings/BUILD.gn
@@ -3,6 +3,9 @@ # found in the LICENSE file. import("//third_party/closure_compiler/compile_js.gni") +import("//tools/polymer/polymer.gni") +import("//ui/webui/resources/tools/js_modulizer.gni") +import("../settings.gni") js_type_check("closure_compile") { deps = [ @@ -292,38 +295,42 @@ } # TODO(crbug.com/1026426): Fix and enable. -#js_type_check("closure_compile_module") { -# is_polymer3 = true -# deps = [ -# ":add_site_dialog.m", -# ":all_sites.m", -# ":all_sites_icons.m", -# ":android_info_browser_proxy.m", -# ":category_default_setting.m", -# ":category_setting_exceptions.m", -# ":chooser_exception_list.m", -# ":chooser_exception_list_entry.m", -# ":constants.m", -# ":cookie_info.m", -# ":edit_exception_dialog.m", -# ":local_data_browser_proxy.m", -# ":media_picker.m", -# ":pdf_documents.m", -# ":protocol_handlers.m", -# ":site_data.m", -# ":site_data_details_subpage.m", -# ":site_data_entry.m", -# ":site_details.m", -# ":site_details_permission.m", -# ":site_entry.m", -# ":site_list.m", -# ":site_list_entry.m", -# ":site_settings_behavior.m", -# ":site_settings_prefs_browser_proxy.m", -# ":website_usage_private_api.m", -# ":zoom_levels.m", -# ] -#} +js_type_check("closure_compile_module") { + is_polymer3 = true + deps = [ + # ":add_site_dialog.m", + # ":all_sites.m", + # ":all_sites_icons.m", + # ":android_info_browser_proxy.m", + # ":category_default_setting.m", + # ":category_setting_exceptions.m", + # ":chooser_exception_list.m", + # ":chooser_exception_list_entry.m", + ":constants.m", + ":cookie_info.m", + + # ":edit_exception_dialog.m", + ":local_data_browser_proxy.m", + + # ":media_picker.m", + # ":pdf_documents.m", + # ":protocol_handlers.m", + # ":site_data.m", + ":site_data_details_subpage.m", + + # ":site_data_entry.m", + # ":site_details.m", + # ":site_details_permission.m", + # ":site_entry.m", + # ":site_list.m", + ":site_list_entry.m", + ":site_settings_behavior.m", + ":site_settings_prefs_browser_proxy.m", + + # ":website_usage_private_api.m", + # ":zoom_levels.m", + ] +} js_library("add_site_dialog.m") { sources = [ "$root_gen_dir/chrome/browser/resources/settings/site_settings/add_site_dialog.m.js" ] @@ -391,17 +398,12 @@ js_library("constants.m") { sources = [ "$root_gen_dir/chrome/browser/resources/settings/site_settings/constants.m.js" ] - deps = [ - # TODO: Fill those in. - ] extra_deps = [ ":modulize" ] } js_library("cookie_info.m") { sources = [ "$root_gen_dir/chrome/browser/resources/settings/site_settings/cookie_info.m.js" ] - deps = [ - # TODO: Fill those in. - ] + deps = [ "//ui/webui/resources/js:load_time_data.m" ] extra_deps = [ ":modulize" ] } @@ -416,7 +418,8 @@ js_library("local_data_browser_proxy.m") { sources = [ "$root_gen_dir/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.m.js" ] deps = [ - # TODO: Fill those in. + ":cookie_info.m", + "//ui/webui/resources/js:cr.m", ] extra_deps = [ ":modulize" ] } @@ -456,7 +459,13 @@ js_library("site_data_details_subpage.m") { sources = [ "$root_gen_dir/chrome/browser/resources/settings/site_settings/site_data_details_subpage.m.js" ] deps = [ - # TODO: Fill those in. + ":local_data_browser_proxy.m", + "..:route.m", + "..:router.m", + "//third_party/polymer/v3_0/components-chromium/iron-list:iron-list", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:load_time_data.m", + "//ui/webui/resources/js:web_ui_listener_behavior.m", ] extra_deps = [ ":site_data_details_subpage_module" ] } @@ -504,7 +513,13 @@ js_library("site_list_entry.m") { sources = [ "$root_gen_dir/chrome/browser/resources/settings/site_settings/site_list_entry.m.js" ] deps = [ - # TODO: Fill those in. + ":constants.m", + ":site_settings_behavior.m", + "..:route.m", + "..:router.m", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/cr_elements/policy:cr_policy_pref_indicator", + "//ui/webui/resources/js/cr/ui:focus_row_behavior.m", ] extra_deps = [ ":site_list_entry_module" ] } @@ -512,7 +527,11 @@ js_library("site_settings_behavior.m") { sources = [ "$root_gen_dir/chrome/browser/resources/settings/site_settings/site_settings_behavior.m.js" ] deps = [ - # TODO: Fill those in. + ":constants.m", + ":site_settings_prefs_browser_proxy.m", + "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js:icon.m", + "//ui/webui/resources/js:load_time_data.m", ] extra_deps = [ ":modulize" ] } @@ -520,7 +539,8 @@ js_library("site_settings_prefs_browser_proxy.m") { sources = [ "$root_gen_dir/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.m.js" ] deps = [ - # TODO: Fill those in. + ":constants.m", + "//ui/webui/resources/js:cr.m", ] extra_deps = [ ":modulize" ] } @@ -541,8 +561,6 @@ extra_deps = [ ":zoom_levels_module" ] } -import("//tools/polymer/polymer.gni") - group("polymer3_elements") { public_deps = [ ":add_site_dialog_module", @@ -653,6 +671,13 @@ js_file = "site_data_details_subpage.js" html_file = "site_data_details_subpage.html" html_type = "dom-module" + auto_imports = settings_auto_imports + [ + "chrome/browser/resources/settings/route.html|routes", + "chrome/browser/resources/settings/router.html|Route,Router,RouteObserverBehavior", + "chrome/browser/resources/settings/site_settings/cookie_info.html|CookieDataForDisplay,CookieDetails,getCookieData", + "chrome/browser/resources/settings/site_settings/local_data_browser_proxy.html|CookieList,LocalDataBrowserProxy,LocalDataBrowserProxyImpl", + ] + namespace_rewrites = settings_namespace_rewrites } polymer_modulizer("site_data_entry") { @@ -689,6 +714,15 @@ js_file = "site_list_entry.js" html_file = "site_list_entry.html" html_type = "dom-module" + auto_imports = settings_auto_imports + [ + "chrome/browser/resources/settings/route.html|routes", + "chrome/browser/resources/settings/router.html|Router", + "chrome/browser/resources/settings/site_settings/constants.html|ChooserType,ContentSettingsTypes,SITE_EXCEPTION_WILDCARD", + "chrome/browser/resources/settings/site_settings/site_settings_behavior.html|SiteSettingsBehavior", + "chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.html|SiteException", + "ui/webui/resources/html/assert.html|assert", + ] + namespace_rewrites = settings_namespace_rewrites } polymer_modulizer("website_usage_private_api") { @@ -703,8 +737,6 @@ html_type = "dom-module" } -import("//ui/webui/resources/tools/js_modulizer.gni") - js_modulizer("modulize") { input_files = [ "constants.js", @@ -714,4 +746,5 @@ "site_settings_behavior.js", "site_settings_prefs_browser_proxy.js", ] + namespace_rewrites = settings_namespace_rewrites }
diff --git a/chrome/browser/resources/settings/site_settings/all_sites.html b/chrome/browser/resources/settings/site_settings/all_sites.html index 8ce8706..cdc959b 100644 --- a/chrome/browser/resources/settings/site_settings/all_sites.html +++ b/chrome/browser/resources/settings/site_settings/all_sites.html
@@ -24,7 +24,7 @@ align-items: center; display: flex; margin: 0 var(--cr-icon-button-margin-start); - margin-bottom: 50px; + margin-bottom: 8px; padding: 0 var(--cr-section-padding); } @@ -43,6 +43,7 @@ display: flex; height: var(--cr-section-two-line-min-height); justify-content: space-between; + margin: 0 var(--cr-icon-button-margin-start); padding-inline-end: var(--cr-section-padding); padding-inline-start: var(--cr-section-padding); }
diff --git a/chrome/browser/resources/settings/site_settings/constants.js b/chrome/browser/resources/settings/site_settings/constants.js index 6430d2e9..3b03c57b4 100644 --- a/chrome/browser/resources/settings/site_settings/constants.js +++ b/chrome/browser/resources/settings/site_settings/constants.js
@@ -11,7 +11,7 @@ * in chrome/browser/ui/webui/site_settings_helper.cc * @enum {string} */ - const ContentSettingsTypes = { + /* #export */ const ContentSettingsTypes = { COOKIES: 'cookies', IMAGES: 'images', JAVASCRIPT: 'javascript', @@ -50,7 +50,7 @@ * components/content_settings/core/common/content_settings.h * @enum {string} */ - const ContentSetting = { + /* #export */ const ContentSetting = { DEFAULT: 'default', ALLOW: 'allow', BLOCK: 'block', @@ -65,7 +65,7 @@ * chrome/browser/ui/webui/site_settings_helper.cc * @enum {string} */ - const ChooserType = { + /* #export */ const ChooserType = { NONE: '', USB_DEVICES: 'usb-devices-data', SERIAL_PORTS: 'serial-ports-data', @@ -91,7 +91,7 @@ * chrome/browser/ui/webui/site_settings_helper.h * @enum {string} */ - const SiteSettingSource = { + /* #export */ const SiteSettingSource = { ADS_FILTER_BLACKLIST: 'ads-filter-blacklist', DEFAULT: 'default', // This source is for the Protected Media Identifier / Protected Content @@ -172,7 +172,7 @@ * match for SiteExceptions. * @type {string} */ - const SITE_EXCEPTION_WILDCARD = '*'; + /* #export */ const SITE_EXCEPTION_WILDCARD = '*'; // #cr_define_end return {
diff --git a/chrome/browser/resources/settings/site_settings/cookie_info.js b/chrome/browser/resources/settings/site_settings/cookie_info.js index 91289e40..f9a20d2 100644 --- a/chrome/browser/resources/settings/site_settings/cookie_info.js +++ b/chrome/browser/resources/settings/site_settings/cookie_info.js
@@ -2,6 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// clang-format off +// #import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; +// clang-format on + /** * @typedef {{hasChildren: boolean, * id: string, @@ -10,13 +14,13 @@ * totalUsage: string, * type: string}} */ -let CookieDetails; +/* #export */ let CookieDetails; /** * @typedef {{content: string, * label: string}} */ -let CookieDataForDisplay; +/* #export */ let CookieDataForDisplay; // This structure maps the various cookie type names from C++ (hence the // underscores) to arrays of the different types of data each has, along with @@ -25,7 +29,7 @@ // 1) to list what subset of the cookie data we want to show in the UI. // 2) What order to show it in. // 3) What user friendly label to prefix the data with. -const cookieInfo = { +/* #export */ const cookieInfo = { 'cookie': [ ['name', 'cookieName'], ['content', 'cookieContent'], ['domain', 'cookieDomain'], ['path', 'cookiePath'], @@ -73,7 +77,7 @@ * @param {CookieDetails} data The contents of the cookie. * @return {!Array<CookieDataForDisplay>} */ -const getCookieData = function(data) { +/* #export */ const getCookieData = function(data) { /** @type {!Array<CookieDataForDisplay>} */ const out = []; const fields = cookieInfo[data.type];
diff --git a/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.js b/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.js index 183a0c0..cde9761 100644 --- a/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.js +++ b/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.js
@@ -7,6 +7,11 @@ * section. */ +// clang-format off +// #import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js'; +// #import {CookieDetails} from './cookie_info.m.js'; +// clang-format on + /** * @typedef {{ * id: string, @@ -14,7 +19,7 @@ * children: !Array<CookieDetails>, * }} */ -let CookieList; +/* #export */ let CookieList; /** * @typedef {{ @@ -44,7 +49,7 @@ cr.define('settings', function() { /** @interface */ - class LocalDataBrowserProxy { + /* #export */ class LocalDataBrowserProxy { /** * @param {string} filter Search filter (use "" for none). * @return {!Promise<!LocalDataList>} @@ -110,7 +115,7 @@ /** * @implements {settings.LocalDataBrowserProxy} */ - class LocalDataBrowserProxyImpl { + /* #export */ class LocalDataBrowserProxyImpl { /** @override */ getDisplayList(filter) { return cr.sendWithPromise('localData.getDisplayList', filter);
diff --git a/chrome/browser/resources/settings/site_settings/site_data_details_subpage.html b/chrome/browser/resources/settings/site_settings/site_data_details_subpage.html index 755c3341..b37e18a 100644 --- a/chrome/browser/resources/settings/site_settings/site_data_details_subpage.html +++ b/chrome/browser/resources/settings/site_settings/site_data_details_subpage.html
@@ -4,6 +4,7 @@ <link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> <link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html"> +<link rel="import" href="../i18n_setup.html"> <link rel="import" href="../route.html"> <link rel="import" href="../router.html"> <link rel="import" href="../settings_shared_css.html">
diff --git a/chrome/browser/resources/settings/site_settings/site_data_details_subpage.js b/chrome/browser/resources/settings/site_settings/site_data_details_subpage.js index 9ffe4a7..599d5eb 100644 --- a/chrome/browser/resources/settings/site_settings/site_data_details_subpage.js +++ b/chrome/browser/resources/settings/site_settings/site_data_details_subpage.js
@@ -3,7 +3,6 @@ // found in the LICENSE file. (function() { -'use strict'; const categoryLabels = { app_cache: loadTimeData.getString('cookieAppCache'),
diff --git a/chrome/browser/resources/settings/site_settings/site_list_entry.html b/chrome/browser/resources/settings/site_settings/site_list_entry.html index 7dd803e3..bb29123 100644 --- a/chrome/browser/resources/settings/site_settings/site_list_entry.html +++ b/chrome/browser/resources/settings/site_settings/site_list_entry.html
@@ -4,6 +4,7 @@ <link rel="import" href="chrome://resources/cr_elements/icons.html"> <link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html"> <link rel="import" href="chrome://resources/cr_elements/policy/cr_tooltip_icon.html"> +<link rel="import" href="chrome://resources/html/assert.html"> <link rel="import" href="chrome://resources/html/cr/ui/focus_row_behavior.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> <link rel="import" href="../i18n_setup.html">
diff --git a/chrome/browser/resources/settings/site_settings/site_settings_behavior.js b/chrome/browser/resources/settings/site_settings/site_settings_behavior.js index e8aac54..61c9444 100644 --- a/chrome/browser/resources/settings/site_settings/site_settings_behavior.js +++ b/chrome/browser/resources/settings/site_settings/site_settings_behavior.js
@@ -6,6 +6,11 @@ * @fileoverview Behavior common to Site Settings classes. */ +// clang-format off +// #import {ContentSetting,ContentSettingsTypes} from './constants.m.js'; +// #import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; +// #import {RawSiteException,SiteException,SiteSettingsPrefsBrowserProxy,SiteSettingsPrefsBrowserProxyImpl} from './site_settings_prefs_browser_proxy.m.js'; +// clang-format on /** * The source information on site exceptions doesn't exactly match the @@ -238,4 +243,4 @@ }; /** @polymerBehavior */ -const SiteSettingsBehavior = [SiteSettingsBehaviorImpl]; +/* #export */ const SiteSettingsBehavior = [SiteSettingsBehaviorImpl];
diff --git a/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.js b/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.js index d4b76ba7..bc5689d7 100644 --- a/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.js +++ b/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.js
@@ -7,6 +7,11 @@ * interact with the content settings prefs. */ +// clang-format off +// #import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js'; +// #import {ChooserType,ContentSetting,ContentSettingsTypes,SiteSettingSource} from './constants.m.js'; +// clang-format on + /** * The handler will send a policy source that is similar, but not exactly the * same as a ControlledBy value. If the ContentSettingProvider is omitted it @@ -69,7 +74,7 @@ * setting: !settings.ContentSetting, * source: !settings.SiteSettingSource}} */ -let RawSiteException; +/* #export */ let RawSiteException; /** * The site exception after it has been converted/filtered for UI use. @@ -84,7 +89,7 @@ * controlledBy: !chrome.settingsPrivate.ControlledBy, * showAndroidSmsNote: (boolean|undefined)}} */ -let SiteException; +/* #export */ let SiteException; /** * Represents a list of exceptions recently configured for a site, where recent @@ -144,7 +149,7 @@ cr.define('settings', function() { /** @interface */ - class SiteSettingsPrefsBrowserProxy { + /* #export */ class SiteSettingsPrefsBrowserProxy { /** * Sets the default value for a site settings category. * @param {string} contentType The name of the category to change. @@ -406,7 +411,7 @@ /** * @implements {settings.SiteSettingsPrefsBrowserProxy} */ - class SiteSettingsPrefsBrowserProxyImpl { + /* #export */ class SiteSettingsPrefsBrowserProxyImpl { /** @override */ setDefaultValueForContentType(contentType, defaultValue) { chrome.send('setDefaultValueForContentType', [contentType, defaultValue]);
diff --git a/chrome/browser/resources/tab_strip/tab_list.html b/chrome/browser/resources/tab_strip/tab_list.html index 2ed8f04..9b12552 100644 --- a/chrome/browser/resources/tab_strip/tab_list.html +++ b/chrome/browser/resources/tab_strip/tab_list.html
@@ -5,8 +5,8 @@ --tabstrip-tab-width: var(--tabstrip-tab-thumbnail-width); --tabstrip-tab-spacing: 16px; --tabstrip-tab-dragging-shadow: - 0 4px 4px 0 rgba(var(--google-grey-800-rgb), .3), - 0 8px 12px 6px rgba(var(--google-grey-800-rgb), .15); + 0 2px 3px 0 rgba(var(--google-grey-800-rgb), .3), + 0 6px 10px 4px rgba(var(--google-grey-800-rgb), .15); <if expr="not chromeos"> --tabstrip-tab-drag-image-scale: 1.1;
diff --git a/chrome/browser/safe_browsing/download_protection/deep_scanning_request.cc b/chrome/browser/safe_browsing/download_protection/deep_scanning_request.cc index 9a98b1c8..cc7d719 100644 --- a/chrome/browser/safe_browsing/download_protection/deep_scanning_request.cc +++ b/chrome/browser/safe_browsing/download_protection/deep_scanning_request.cc
@@ -192,8 +192,6 @@ MalwareDeepScanningClientRequest malware_request; malware_request.set_population( MalwareDeepScanningClientRequest::POPULATION_TITANIUM); - malware_request.set_download_token( - DownloadProtectionService::GetDownloadPingToken(item_)); request->set_request_malware_scan(std::move(malware_request)); } else if (trigger_ == DeepScanTrigger::TRIGGER_POLICY) { policy::DMToken dm_token = GetDMToken(profile); @@ -215,8 +213,6 @@ MalwareDeepScanningClientRequest malware_request; malware_request.set_population( MalwareDeepScanningClientRequest::POPULATION_ENTERPRISE); - malware_request.set_download_token( - DownloadProtectionService::GetDownloadPingToken(item_)); request->set_request_malware_scan(std::move(malware_request)); } }
diff --git a/chrome/browser/ssl/chrome_expect_ct_reporter_browsertest.cc b/chrome/browser/ssl/chrome_expect_ct_reporter_browsertest.cc index 17255003..b69a13d 100644 --- a/chrome/browser/ssl/chrome_expect_ct_reporter_browsertest.cc +++ b/chrome/browser/ssl/chrome_expect_ct_reporter_browsertest.cc
@@ -17,11 +17,9 @@ #include "content/public/browser/browser_thread.h" #include "net/cert/mock_cert_verifier.h" #include "net/http/transport_security_state.h" -#include "net/test/cert_test_util.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/http_request.h" #include "net/test/embedded_test_server/http_response.h" -#include "net/test/test_data_directory.h" #include "services/network/public/cpp/features.h" namespace { @@ -145,12 +143,7 @@ scoped_refptr<net::X509Certificate> cert(test_server.GetCertificate()); net::CertVerifyResult verify_result; verify_result.is_issued_by_known_root = true; - // TODO(https://crbug.com/848277): Until CT is unified with cert - // verification, the CertVerifier needs to simulate a publicly trusted - // certificate that was issued prior to CT being required, so that the - // connection is successfully made, but an Expect-CT report is triggered. - verify_result.verified_cert = - net::ImportCertFromFile(net::GetTestCertsDirectory(), "expired_cert.pem"); + verify_result.verified_cert = cert; verify_result.cert_status = 0; mock_cert_verifier()->AddResultForCert(cert, verify_result, net::OK); @@ -190,12 +183,7 @@ scoped_refptr<net::X509Certificate> cert(test_server.GetCertificate()); net::CertVerifyResult verify_result; verify_result.is_issued_by_known_root = true; - // TODO(https://crbug.com/848277): Until CT is unified with cert - // verification, the CertVerifier needs to simulate a publicly trusted - // certificate that was issued prior to CT being required, so that the - // connection is successfully made, but an Expect-CT report is triggered. - verify_result.verified_cert = - net::ImportCertFromFile(net::GetTestCertsDirectory(), "expired_cert.pem"); + verify_result.verified_cert = cert; verify_result.cert_status = 0; mock_cert_verifier()->AddResultForCert(cert, verify_result, net::OK);
diff --git a/chrome/browser/ssl/security_state_tab_helper_browsertest.cc b/chrome/browser/ssl/security_state_tab_helper_browsertest.cc index a9dd4f65..8349d81 100644 --- a/chrome/browser/ssl/security_state_tab_helper_browsertest.cc +++ b/chrome/browser/ssl/security_state_tab_helper_browsertest.cc
@@ -501,7 +501,7 @@ int net_result) { scoped_refptr<net::X509Certificate> cert(https_server_.GetCertificate()); net::CertVerifyResult verify_result; - verify_result.is_issued_by_known_root = false; + verify_result.is_issued_by_known_root = true; verify_result.verified_cert = cert; verify_result.cert_status = cert_status;
diff --git a/chrome/browser/sync/sync_ui_util.cc b/chrome/browser/sync/sync_ui_util.cc index 36e080c4..9c79935c 100644 --- a/chrome/browser/sync/sync_ui_util.cc +++ b/chrome/browser/sync/sync_ui_util.cc
@@ -224,7 +224,6 @@ return GetStatusLabels(profile).message_type; } -#if !defined(OS_CHROMEOS) AvatarSyncErrorType GetMessagesForAvatarSyncError( Profile* profile, int* content_string_id, @@ -303,7 +302,6 @@ // There is no error. return NO_SYNC_ERROR; } -#endif // !defined(OS_CHROMEOS) bool ShouldRequestSyncConfirmation(const syncer::SyncService* service) { // This method mostly handles two situations:
diff --git a/chrome/browser/sync/sync_ui_util.h b/chrome/browser/sync/sync_ui_util.h index efb75fb..12edbed75 100644 --- a/chrome/browser/sync/sync_ui_util.h +++ b/chrome/browser/sync/sync_ui_util.h
@@ -97,14 +97,12 @@ // actual labels, only in the return value. MessageType GetStatus(Profile* profile); -#if !defined(OS_CHROMEOS) // Gets the error message and button label for the sync errors that should be // exposed to the user through the titlebar avatar button. AvatarSyncErrorType GetMessagesForAvatarSyncError( Profile* profile, int* content_string_id, int* button_string_id); -#endif // Whether sync is currently blocked from starting because the sync // confirmation dialog hasn't been shown. Note that once the dialog is
diff --git a/chrome/browser/touch_to_fill/android/internal/java/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillMediator.java b/chrome/browser/touch_to_fill/android/internal/java/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillMediator.java index bd5842b..4dca3cab 100644 --- a/chrome/browser/touch_to_fill/android/internal/java/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillMediator.java +++ b/chrome/browser/touch_to_fill/android/internal/java/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillMediator.java
@@ -21,7 +21,6 @@ import androidx.annotation.Px; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.favicon.LargeIconBridge; import org.chromium.chrome.browser.favicon.LargeIconBridge.LargeIconCallback; import org.chromium.chrome.browser.flags.ChromeFeatureList; @@ -31,6 +30,7 @@ import org.chromium.chrome.browser.touch_to_fill.data.Credential; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController.StateChangeReason; +import org.chromium.components.embedder_support.util.Origin; import org.chromium.components.url_formatter.SchemeDisplay; import org.chromium.components.url_formatter.UrlFormatter; import org.chromium.ui.modelutil.ListModel;
diff --git a/chrome/browser/touch_to_fill/android/junit/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillControllerTest.java b/chrome/browser/touch_to_fill/android/junit/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillControllerTest.java index a0345d8..1cb3f54 100644 --- a/chrome/browser/touch_to_fill/android/junit/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillControllerTest.java +++ b/chrome/browser/touch_to_fill/android/junit/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillControllerTest.java
@@ -28,13 +28,13 @@ import static org.chromium.chrome.browser.touch_to_fill.TouchToFillProperties.VISIBLE; import android.graphics.Bitmap; -import android.support.test.espresso.core.deps.guava.collect.ImmutableMap; import androidx.annotation.Px; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; @@ -55,6 +55,7 @@ import org.chromium.chrome.browser.touch_to_fill.TouchToFillProperties.ItemType; import org.chromium.chrome.browser.touch_to_fill.data.Credential; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController; +import org.chromium.chrome.test.util.browser.Features; import org.chromium.components.url_formatter.SchemeDisplay; import org.chromium.components.url_formatter.UrlFormatter; import org.chromium.components.url_formatter.UrlFormatterJni; @@ -71,6 +72,7 @@ */ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE, shadows = {ShadowRecordHistogram.class}) +@Features.EnableFeatures(ChromeFeatureList.TOUCH_TO_FILL_ANDROID) public class TouchToFillControllerTest { private static final String TEST_URL = "https://www.example.xyz"; private static final String TEST_SUBDOMAIN_URL = "https://subdomain.example.xyz"; @@ -84,6 +86,8 @@ @Rule public JniMocker mJniMocker = new JniMocker(); + @Rule + public TestRule mFeaturesProcessorRule = new Features.JUnitProcessor(); @Mock private UrlFormatter.Natives mUrlFormatterJniMock; @Mock @@ -105,8 +109,6 @@ @Before public void setUp() { ShadowRecordHistogram.reset(); - ChromeFeatureList.setTestFeatures( - ImmutableMap.of(ChromeFeatureList.TOUCH_TO_FILL_ANDROID, true)); MockitoAnnotations.initMocks(this); mJniMocker.mock(UrlFormatterJni.TEST_HOOKS, mUrlFormatterJniMock); mJniMocker.mock(RecordHistogramJni.TEST_HOOKS, mMockRecordHistogram);
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index 7e66eec8..e91fd40d9 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -2170,6 +2170,9 @@ "autofill/payments/webauthn_dialog_model_observer.h", "autofill/payments/webauthn_dialog_state.h", "autofill/payments/webauthn_dialog_view.h", + "avatar_button_error_controller.cc", + "avatar_button_error_controller.h", + "avatar_button_error_controller_delegate.h", "frame/window_frame_util.cc", "frame/window_frame_util.h", "signin_view_controller.cc", @@ -2189,6 +2192,8 @@ "views/hats/hats_web_dialog.h", "views/profiles/incognito_menu_view.cc", "views/profiles/incognito_menu_view.h", + "views/profiles/profile_menu_view.cc", + "views/profiles/profile_menu_view.h", "views/profiles/profile_menu_view_base.cc", "views/profiles/profile_menu_view_base.h", "views/profiles/signin_view_controller_delegate_views.cc", @@ -2213,9 +2218,6 @@ if (is_win || is_mac || is_desktop_linux) { sources += [ - "avatar_button_error_controller.cc", - "avatar_button_error_controller.h", - "avatar_button_error_controller_delegate.h", "bookmarks/bookmark_bubble_sign_in_delegate.cc", "bookmarks/bookmark_bubble_sign_in_delegate.h", "startup/default_browser_infobar_delegate.cc", @@ -2231,8 +2233,6 @@ "views/external_protocol_dialog.h", "views/profiles/badged_profile_photo.cc", "views/profiles/badged_profile_photo.h", - "views/profiles/profile_menu_view.cc", - "views/profiles/profile_menu_view.h", "views/profiles/user_manager_view.cc", "views/profiles/user_manager_view.h", "webui/app_launcher_page_ui.cc",
diff --git a/chrome/browser/ui/gtk/gtk_ui.cc b/chrome/browser/ui/gtk/gtk_ui.cc index d51fac4..1985808b 100644 --- a/chrome/browser/ui/gtk/gtk_ui.cc +++ b/chrome/browser/ui/gtk/gtk_ui.cc
@@ -969,6 +969,10 @@ color_map[ThemeProperties::COLOR_DOWNLOAD_SHELF] = tab_color; color_map[ThemeProperties::COLOR_INFOBAR] = tab_color; color_map[ThemeProperties::COLOR_STATUS_BUBBLE] = tab_color; + color_map[ThemeProperties::COLOR_TAB_BACKGROUND_ACTIVE_FRAME_ACTIVE] = + tab_color; + color_map[ThemeProperties::COLOR_TAB_BACKGROUND_ACTIVE_FRAME_INACTIVE] = + tab_color; const SkColor background_tab_text_color = GetFgColor(header_selector + " GtkLabel.title");
diff --git a/chrome/browser/ui/tabs/tab_strip_model.cc b/chrome/browser/ui/tabs/tab_strip_model.cc index 329eedbb..39514ea 100644 --- a/chrome/browser/ui/tabs/tab_strip_model.cc +++ b/chrome/browser/ui/tabs/tab_strip_model.cc
@@ -935,6 +935,11 @@ index = order_controller_->DetermineInsertionIndex(transition, add_types & ADD_ACTIVE); inherit_opener = true; + + // The current active index is our opener. If the tab we are adding is not + // in a group, set the group of the tab to that of its opener. + if (!group.has_value()) + group = GetTabGroupForTab(active_index()); } else { // For all other types, respect what was passed to us, normalizing -1s and // values that are too large.
diff --git a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc index 0252bb8a..84944a0b 100644 --- a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc
@@ -1712,6 +1712,33 @@ EXPECT_TRUE(tabstrip.empty()); } +// Tests whether or not a WebContents in a new tab belongs in the same tab +// group as its opener. +TEST_F(TabStripModelTest, AddWebContents_LinkOpensInSameGroupAsOpener) { + TestTabStripModelDelegate delegate; + TabStripModel tabstrip(&delegate, profile()); + ASSERT_TRUE(tabstrip.empty()); + + // Open the home page and add the tab to a group. + std::unique_ptr<WebContents> homepage_contents = CreateWebContents(); + tabstrip.AddWebContents(std::move(homepage_contents), -1, + ui::PAGE_TRANSITION_AUTO_BOOKMARK, + TabStripModel::ADD_ACTIVE); + ASSERT_EQ(1, tabstrip.count()); + tab_groups::TabGroupId group_id = tabstrip.AddToNewGroup({0}); + ASSERT_EQ(tabstrip.GetTabGroupForTab(0), group_id); + + // Open a tab by simulating a link that opens in a new tab. + std::unique_ptr<WebContents> contents = CreateWebContents(); + tabstrip.AddWebContents(std::move(contents), -1, ui::PAGE_TRANSITION_LINK, + TabStripModel::ADD_ACTIVE); + EXPECT_EQ(2, tabstrip.count()); + EXPECT_EQ(tabstrip.GetTabGroupForTab(1), group_id); + + tabstrip.CloseAllTabs(); + ASSERT_TRUE(tabstrip.empty()); +} + // Added for http://b/issue?id=958960 TEST_F(TabStripModelTest, AppendContentsReselectionTest) { TestTabStripModelDelegate delegate;
diff --git a/chrome/browser/ui/views/apps/app_dialog/app_block_dialog_view.cc b/chrome/browser/ui/views/apps/app_dialog/app_block_dialog_view.cc index 024ef0a..d698bca9 100644 --- a/chrome/browser/ui/views/apps/app_dialog/app_block_dialog_view.cc +++ b/chrome/browser/ui/views/apps/app_dialog/app_block_dialog_view.cc
@@ -32,13 +32,14 @@ AppBlockDialogView::AppBlockDialogView(const std::string& app_name, const gfx::ImageSkia& image, - Profile* profile) { + Profile* profile) + : AppDialogView(app_name, image) { base::string16 heading_text = l10n_util::GetStringFUTF16( profile->IsChild() ? IDS_APP_BLOCK_HEADING_FOR_CHILD : IDS_APP_BLOCK_HEADING, base::UTF8ToUTF16(app_name)); - InitializeView(image, heading_text); + InitializeView(heading_text); g_app_block_dialog_view = this; } @@ -53,5 +54,6 @@ } base::string16 AppBlockDialogView::GetWindowTitle() const { - return l10n_util::GetStringUTF16(IDS_APP_BLOCK_PROMPT_TITLE); + return l10n_util::GetStringFUTF16(IDS_APP_BLOCK_PROMPT_TITLE, + base::UTF8ToUTF16(app_name())); }
diff --git a/chrome/browser/ui/views/apps/app_dialog/app_dialog_view.cc b/chrome/browser/ui/views/apps/app_dialog/app_dialog_view.cc index f017ad5..9f03996 100644 --- a/chrome/browser/ui/views/apps/app_dialog/app_dialog_view.cc +++ b/chrome/browser/ui/views/apps/app_dialog/app_dialog_view.cc
@@ -12,8 +12,11 @@ #include "ui/views/controls/label.h" #include "ui/views/layout/box_layout.h" -AppDialogView::AppDialogView() - : BubbleDialogDelegateView(nullptr, views::BubbleBorder::NONE) {} +AppDialogView::AppDialogView(const std::string& app_name, + const gfx::ImageSkia& image) + : BubbleDialogDelegateView(nullptr, views::BubbleBorder::NONE), + app_name_(app_name), + image_(image) {} AppDialogView::~AppDialogView() = default; @@ -28,23 +31,27 @@ return ui::MODAL_TYPE_SYSTEM; } +gfx::ImageSkia AppDialogView::GetWindowIcon() { + return image_; +} + bool AppDialogView::ShouldShowCloseButton() const { return false; } -void AppDialogView::InitializeView(const gfx::ImageSkia& image, - const base::string16& heading_text) { +bool AppDialogView::ShouldShowWindowIcon() const { + return true; +} + +void AppDialogView::InitializeView(const base::string16& heading_text) { DialogDelegate::SetButtons(ui::DIALOG_BUTTON_OK); ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); SetLayoutManager(std::make_unique<views::BoxLayout>( - views::BoxLayout::Orientation::kHorizontal, - provider->GetDialogInsetsForContentType(views::TEXT, views::TEXT), - provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_HORIZONTAL))); - - auto* icon_view = AddChildView(std::make_unique<views::ImageView>()); - icon_view->SetImage(image); + views::BoxLayout::Orientation::kVertical, gfx::Insets(), + provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL))); auto* label = AddChildView(std::make_unique<views::Label>(heading_text)); label->SetMultiLine(true); label->SetHorizontalAlignment(gfx::ALIGN_LEFT); + label->SetAllowCharacterBreak(true); }
diff --git a/chrome/browser/ui/views/apps/app_dialog/app_dialog_view.h b/chrome/browser/ui/views/apps/app_dialog/app_dialog_view.h index 9568bb4d..92e0ce2 100644 --- a/chrome/browser/ui/views/apps/app_dialog/app_dialog_view.h +++ b/chrome/browser/ui/views/apps/app_dialog/app_dialog_view.h
@@ -16,16 +16,25 @@ // for app related dialog classes, e.g AppBlockDialogView, AppPauseDialogView. class AppDialogView : public views::BubbleDialogDelegateView { public: - AppDialogView(); + explicit AppDialogView(const std::string& app_name, + const gfx::ImageSkia& image); ~AppDialogView() override; // views::BubbleDialogDelegateView: gfx::Size CalculatePreferredSize() const override; ui::ModalType GetModalType() const override; + gfx::ImageSkia GetWindowIcon() override; bool ShouldShowCloseButton() const override; + bool ShouldShowWindowIcon() const override; - void InitializeView(const gfx::ImageSkia& image, - const base::string16& heading_text); + std::string app_name() const { return app_name_; } + + protected: + void InitializeView(const base::string16& heading_text); + + private: + const std::string app_name_; + gfx::ImageSkia image_; }; #endif // CHROME_BROWSER_UI_VIEWS_APPS_APP_DIALOG_APP_DIALOG_VIEW_H_
diff --git a/chrome/browser/ui/views/apps/app_dialog/app_pause_dialog_view.cc b/chrome/browser/ui/views/apps/app_dialog/app_pause_dialog_view.cc index 19f4d2f4..d2adda7 100644 --- a/chrome/browser/ui/views/apps/app_dialog/app_pause_dialog_view.cc +++ b/chrome/browser/ui/views/apps/app_dialog/app_pause_dialog_view.cc
@@ -20,33 +20,39 @@ // static void apps::AppServiceProxy::CreatePauseDialog( + apps::mojom::AppType app_type, const std::string& app_name, const gfx::ImageSkia& image, const apps::PauseData& pause_data, apps::AppServiceProxy::OnPauseDialogClosedCallback closed_callback) { views::DialogDelegate::CreateDialogWidget( - new AppPauseDialogView(app_name, image, pause_data, + new AppPauseDialogView(app_type, app_name, image, pause_data, std::move(closed_callback)), nullptr, nullptr) ->Show(); } AppPauseDialogView::AppPauseDialogView( + apps::mojom::AppType app_type, const std::string& app_name, const gfx::ImageSkia& image, const apps::PauseData& pause_data, apps::AppServiceProxy::OnPauseDialogClosedCallback closed_callback) - : closed_callback_(std::move(closed_callback)) { + : AppDialogView(app_name, image), + closed_callback_(std::move(closed_callback)) { const int cutoff = pause_data.minutes == 0 || pause_data.hours == 0 ? 0 : -1; base::string16 heading_text = l10n_util::GetStringFUTF16( - IDS_APP_PAUSE_HEADING, base::UTF8ToUTF16(app_name), + (app_type == apps::mojom::AppType::kWeb) + ? IDS_APP_PAUSE_HEADING_FOR_WEB_APPS + : IDS_APP_PAUSE_HEADING, + base::UTF8ToUTF16(app_name), ui::TimeFormat::Detailed( ui::TimeFormat::Format::FORMAT_DURATION, ui::TimeFormat::Length::LENGTH_LONG, cutoff, base::TimeDelta::FromHours(pause_data.hours) + base::TimeDelta::FromMinutes(pause_data.minutes))); - InitializeView(image, heading_text); + InitializeView(heading_text); g_app_pause_dialog_view = this; } @@ -66,5 +72,6 @@ } base::string16 AppPauseDialogView::GetWindowTitle() const { - return l10n_util::GetStringUTF16(IDS_APP_PAUSE_PROMPT_TITLE); + return l10n_util::GetStringFUTF16(IDS_APP_PAUSE_PROMPT_TITLE, + base::UTF8ToUTF16(app_name())); }
diff --git a/chrome/browser/ui/views/apps/app_dialog/app_pause_dialog_view.h b/chrome/browser/ui/views/apps/app_dialog/app_pause_dialog_view.h index 9f8b10d..cf7e601 100644 --- a/chrome/browser/ui/views/apps/app_dialog/app_pause_dialog_view.h +++ b/chrome/browser/ui/views/apps/app_dialog/app_pause_dialog_view.h
@@ -17,6 +17,7 @@ class AppPauseDialogView : public AppDialogView { public: AppPauseDialogView( + apps::mojom::AppType app_type, const std::string& app_name, const gfx::ImageSkia& image, const apps::PauseData& pause_data,
diff --git a/chrome/browser/ui/views/apps/app_dialog/app_uninstall_dialog_view.cc b/chrome/browser/ui/views/apps/app_dialog/app_uninstall_dialog_view.cc index daa1b686..d46438b 100644 --- a/chrome/browser/ui/views/apps/app_dialog/app_uninstall_dialog_view.cc +++ b/chrome/browser/ui/views/apps/app_dialog/app_uninstall_dialog_view.cc
@@ -65,9 +65,9 @@ const std::string& app_name, gfx::ImageSkia image, apps::UninstallDialog* uninstall_dialog) - : apps::UninstallDialog::UiBase(image, uninstall_dialog), - app_type_(app_type), - app_name_(app_name) { + : apps::UninstallDialog::UiBase(uninstall_dialog), + AppDialogView(app_name, image), + app_type_(app_type) { DialogDelegate::SetCloseCallback(base::BindOnce( &AppUninstallDialogView::OnDialogCancelled, base::Unretained(this))); DialogDelegate::SetCancelCallback(base::BindOnce( @@ -110,10 +110,6 @@ return ui::MODAL_TYPE_WINDOW; } -gfx::ImageSkia AppUninstallDialogView::GetWindowIcon() { - return image(); -} - base::string16 AppUninstallDialogView::GetWindowTitle() const { switch (app_type_) { case apps::mojom::AppType::kUnknown: @@ -142,14 +138,10 @@ case apps::mojom::AppType::kExtension: case apps::mojom::AppType::kWeb: return l10n_util::GetStringFUTF16(IDS_PROMPT_APP_UNINSTALL_TITLE, - base::UTF8ToUTF16(app_name_)); + base::UTF8ToUTF16(app_name())); } } -bool AppUninstallDialogView::ShouldShowWindowIcon() const { - return true; -} - void AppUninstallDialogView::InitializeView(Profile* profile, apps::mojom::AppType app_type, const std::string& app_id) { @@ -288,7 +280,7 @@ const std::string& app_id) { base::string16 message = l10n_util::GetStringFUTF16( IDS_CROSTINI_APPLICATION_UNINSTALL_CONFIRM_BODY, - base::UTF8ToUTF16(app_name_)); + base::UTF8ToUTF16(app_name())); auto* label = AddChildView(std::make_unique<views::Label>(message)); label->SetMultiLine(true); label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
diff --git a/chrome/browser/ui/views/apps/app_dialog/app_uninstall_dialog_view.h b/chrome/browser/ui/views/apps/app_dialog/app_uninstall_dialog_view.h index f900181..164c19b 100644 --- a/chrome/browser/ui/views/apps/app_dialog/app_uninstall_dialog_view.h +++ b/chrome/browser/ui/views/apps/app_dialog/app_uninstall_dialog_view.h
@@ -54,9 +54,7 @@ // views::BubbleDialogDelegateView: ui::ModalType GetModalType() const override; - gfx::ImageSkia GetWindowIcon() override; base::string16 GetWindowTitle() const override; - bool ShouldShowWindowIcon() const override; private: void InitializeView(Profile* profile, @@ -79,9 +77,6 @@ // The type of apps, e.g. Extension-backed app, Android app. apps::mojom::AppType app_type_; - // The name of apps, e.g. Camera. - const std::string app_name_; - // Whether app represents a shortcut. |shortcut_| is available for the ARC // apps only. #if defined(OS_CHROMEOS)
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 0a8455f..eed096bf 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1735,12 +1735,6 @@ must_regenerate_frame |= theme_change_type == BrowserThemeChangeType::kBrowserTheme && !IsFullscreen(); - - // TODO(https://crbug.com/953982): Remove the need to regenerate the frame - const bool should_use_custom_titlebar = ShouldCustomDrawSystemTitlebar(); - - must_regenerate_frame |= - (using_custom_titlebar_ != should_use_custom_titlebar); #else must_regenerate_frame |= theme_change_type == BrowserThemeChangeType::kBrowserTheme; @@ -1756,10 +1750,6 @@ GetWidget()->ThemeChanged(); } using_native_frame_ = should_use_native_frame; - -#if defined(OS_WIN) - using_custom_titlebar_ = should_use_custom_titlebar; -#endif } void BrowserView::ShowAppMenu() {
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index 5441c0a3..93985c3 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -807,12 +807,6 @@ // True if (as of the last time it was checked) the frame type is native. bool using_native_frame_ = true; -#if defined(OS_WIN) - // True if (as of the last time it was checked) we're using a custom drawn - // title bar. - bool using_custom_titlebar_ = true; -#endif - // True when in ProcessFullscreen(). The flag is used to avoid reentrance and // to ignore requests to layout while in ProcessFullscreen() to reduce // jankiness.
diff --git a/chrome/browser/ui/views/passwords/credential_leak_dialog_view.cc b/chrome/browser/ui/views/passwords/credential_leak_dialog_view.cc index 23a370c..fcd2b72 100644 --- a/chrome/browser/ui/views/passwords/credential_leak_dialog_view.cc +++ b/chrome/browser/ui/views/passwords/credential_leak_dialog_view.cc
@@ -5,7 +5,6 @@ #include "chrome/browser/ui/views/passwords/credential_leak_dialog_view.h" #include "build/build_config.h" -#include "chrome/app/vector_icons/vector_icons.h" #include "chrome/browser/ui/passwords/credential_leak_dialog_controller.h" #include "chrome/browser/ui/views/accessibility/non_accessible_image_view.h" #include "chrome/browser/ui/views/chrome_layout_provider.h" @@ -23,39 +22,19 @@ namespace { -// Fixed height of the illustration shown on the top of the dialog. -constexpr int kIllustrationHeight = 148; - -// Fixed background color of the illustration shown on the top of the dialog in -// normal mode. -constexpr SkColor kPictureBackgroundColor = SkColorSetARGB(0x0A, 0, 0, 0); - -// Fixed background color of the illustration shown on the top of the dialog in -// dark mode. -constexpr SkColor kPictureBackgroundColorDarkMode = - SkColorSetARGB(0x1A, 0x00, 0x00, 0x00); - // Updates the image displayed on the illustration based on the current theme. void UpdateImageView(NonAccessibleImageView* image_view, bool dark_mode_enabled) { image_view->SetImage( - gfx::CreateVectorIcon(dark_mode_enabled ? kPasswordCheckWarningDarkIcon - : kPasswordCheckWarningIcon, - dark_mode_enabled ? kPictureBackgroundColorDarkMode - : kPictureBackgroundColor)); + *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( + dark_mode_enabled ? IDR_PASSWORD_CHECK_DARK : IDR_PASSWORD_CHECK)); } // Creates the illustration which is rendered on top of the dialog. std::unique_ptr<NonAccessibleImageView> CreateIllustration( bool dark_mode_enabled) { - const gfx::Size illustration_size( - ChromeLayoutProvider::Get()->GetDistanceMetric( - DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH), - kIllustrationHeight); auto image_view = std::make_unique<NonAccessibleImageView>(); - image_view->SetPreferredSize(illustration_size); UpdateImageView(image_view.get(), dark_mode_enabled); - image_view->SetSize(illustration_size); image_view->SetVerticalAlignment(views::ImageView::Alignment::kLeading); return image_view; }
diff --git a/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.cc b/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.cc index 545f9d1..ddc7cd9 100644 --- a/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.cc +++ b/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.cc
@@ -95,10 +95,8 @@ Profile* profile) { avatar_toolbar_button_ = button; profile_ = profile; -#if !defined(OS_CHROMEOS) error_controller_ = std::make_unique<AvatarButtonErrorController>(this, profile_); -#endif // !defined(OS_CHROMEOS) profile_observer_.Add(&GetProfileAttributesStorage()); AvatarToolbarButton::State state = GetState(); if (state == AvatarToolbarButton::State::kIncognitoProfile) { @@ -183,16 +181,15 @@ return AvatarToolbarButton::State::kAnimatedUserIdentity; } -#if !defined(OS_CHROMEOS) if (identity_manager->HasPrimaryAccount() && ProfileSyncServiceFactory::IsSyncAllowed(profile_) && error_controller_->HasAvatarError()) { - // When DICE is enabled and the error is an auth error, the sync-paused - // icon is shown. int unused; const sync_ui_util::AvatarSyncErrorType error = sync_ui_util::GetMessagesForAvatarSyncError(profile_, &unused, &unused); + // When DICE is enabled and the error is an auth error, the sync-paused + // icon is shown. if (AccountConsistencyModeManager::IsDiceEnabledForProfile(profile_) && error == sync_ui_util::AUTH_ERROR) { return AvatarToolbarButton::State::kSyncPaused; @@ -204,7 +201,7 @@ return AvatarToolbarButton::State::kSyncError; } -#endif // !defined(OS_CHROMEOS) + return AvatarToolbarButton::State::kNormal; }
diff --git a/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.h b/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.h index c673c834..c572792 100644 --- a/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.h +++ b/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.h
@@ -108,16 +108,13 @@ IdentityAnimationState identity_animation_state_ = IdentityAnimationState::kNotShowing; bool refresh_tokens_loaded_ = false; + std::unique_ptr<AvatarButtonErrorController> error_controller_; // Whether the avatar highlight animation is visible. The animation is shown // when an Autofill datatype is saved. When this is true the avatar button // sync paused/error state will be disabled. bool highlight_animation_visible_ = false; -#if !defined(OS_CHROMEOS) - std::unique_ptr<AvatarButtonErrorController> error_controller_; -#endif // !defined(OS_CHROMEOS) - base::WeakPtrFactory<AvatarToolbarButtonDelegate> weak_ptr_factory_{this}; DISALLOW_COPY_AND_ASSIGN(AvatarToolbarButtonDelegate);
diff --git a/chrome/browser/ui/views/profiles/profile_menu_view.cc b/chrome/browser/ui/views/profiles/profile_menu_view.cc index 751804f2..a305fc44 100644 --- a/chrome/browser/ui/views/profiles/profile_menu_view.cc +++ b/chrome/browser/ui/views/profiles/profile_menu_view.cc
@@ -16,6 +16,7 @@ #include "build/build_config.h" #include "chrome/app/vector_icons/vector_icons.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_avatar_icon_util.h" #include "chrome/browser/profiles/profile_metrics.h" @@ -134,9 +135,13 @@ } BuildFeatureButtons(); + +// ChromeOS doesn't support multi-profile. +#if !defined(OS_CHROMEOS) BuildProfileManagementHeading(); BuildSelectableProfiles(); BuildProfileManagementFeatureButtons(); +#endif } gfx::ImageSkia ProfileMenuView::GetSyncIcon() const { @@ -233,14 +238,6 @@ profiles::SwitchToGuestProfile(ProfileManager::CreateCallback()); } -void ProfileMenuView::OnManageProfilesButtonClicked() { - RecordClick(ActionableItem::kManageProfilesButton); - // TODO(crbug.com/995757): Remove user action. - base::RecordAction(base::UserMetricsAction("ProfileChooser_ManageClicked")); - UserManager::Show(base::FilePath(), - profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); -} - void ProfileMenuView::OnExitProfileButtonClicked() { RecordClick(ActionableItem::kExitProfileButton); // TODO(crbug.com/995757): Remove user action. @@ -255,6 +252,10 @@ void ProfileMenuView::OnSyncErrorButtonClicked( sync_ui_util::AvatarSyncErrorType error) { +#if defined(OS_CHROMEOS) + // On ChromeOS, sync errors are fixed by re-signing into the OS. + chrome::AttemptUserExit(); +#else RecordClick(ActionableItem::kSyncErrorButton); // TODO(crbug.com/995757): Remove user action. base::RecordAction( @@ -303,14 +304,7 @@ NOTREACHED(); break; } -} - -void ProfileMenuView::OnSigninButtonClicked() { - RecordClick(ActionableItem::kSigninButton); - Hide(); - browser()->signin_view_controller()->ShowSignin( - profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, browser(), - signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN); +#endif } void ProfileMenuView::OnSigninAccountButtonClicked(AccountInfo account) { @@ -334,6 +328,15 @@ kUserMenu_SignOutAllAccounts); } +#if !defined(OS_CHROMEOS) +void ProfileMenuView::OnSigninButtonClicked() { + RecordClick(ActionableItem::kSigninButton); + Hide(); + browser()->signin_view_controller()->ShowSignin( + profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, browser(), + signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN); +} + void ProfileMenuView::OnOtherProfileSelected( const base::FilePath& profile_path) { RecordClick(ActionableItem::kOtherProfileButton); @@ -344,6 +347,26 @@ ProfileManager::CreateCallback()); } +void ProfileMenuView::OnAddNewProfileButtonClicked() { + RecordClick(ActionableItem::kAddNewProfileButton); + UserManager::Show(/*profile_path_to_focus=*/base::FilePath(), + profiles::USER_MANAGER_OPEN_CREATE_USER_PAGE); +} + +void ProfileMenuView::OnManageProfilesButtonClicked() { + RecordClick(ActionableItem::kManageProfilesButton); + // TODO(crbug.com/995757): Remove user action. + base::RecordAction(base::UserMetricsAction("ProfileChooser_ManageClicked")); + UserManager::Show(base::FilePath(), + profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); +} + +void ProfileMenuView::OnEditProfileButtonClicked() { + RecordClick(ActionableItem::kEditProfileButton); + chrome::ShowSettingsSubPage(browser(), chrome::kManageProfileSubPage); +} +#endif // defined(OS_CHROMEOS) + void ProfileMenuView::OnCookiesClearedOnExitLinkClicked() { RecordClick(ActionableItem::kCookiesClearedOnExitLink); // TODO(crbug.com/995757): Remove user action. @@ -354,17 +377,6 @@ chrome::kCookieSettingsSubPage); } -void ProfileMenuView::OnAddNewProfileButtonClicked() { - RecordClick(ActionableItem::kAddNewProfileButton); - UserManager::Show(/*profile_path_to_focus=*/base::FilePath(), - profiles::USER_MANAGER_OPEN_CREATE_USER_PAGE); -} - -void ProfileMenuView::OnEditProfileButtonClicked() { - RecordClick(ActionableItem::kEditProfileButton); - chrome::ShowSettingsSubPage(browser(), chrome::kManageProfileSubPage); -} - void ProfileMenuView::BuildIdentity() { Profile* profile = browser()->profile(); signin::IdentityManager* identity_manager = @@ -376,15 +388,18 @@ account); ProfileAttributesEntry* profile_attributes = GetProfileAttributesEntry(profile); + +// Profile names are not supported on ChromeOS. +#if !defined(OS_CHROMEOS) size_t num_of_profiles = g_browser_process->profile_manager()->GetNumberOfProfiles(); - if (num_of_profiles > 1 || !profile_attributes->IsUsingDefaultName()) { SetHeading(profile_attributes->GetLocalProfileName(), l10n_util::GetStringUTF16(IDS_SETTINGS_EDIT_PERSON), base::BindRepeating(&ProfileMenuView::OnEditProfileButtonClicked, base::Unretained(this))); } +#endif if (account_info.has_value()) { SetIdentityInfo( @@ -489,12 +504,17 @@ base::BindRepeating(&ProfileMenuView::OnSigninAccountButtonClicked, base::Unretained(this), account_info.value())); } else { +#if defined(OS_CHROMEOS) + // There is always an account on ChromeOS. + NOTREACHED(); +#else SetSyncInfo(l10n_util::GetStringUTF16(IDS_PROFILES_DICE_SYNC_PROMO), l10n_util::GetStringUTF16(IDS_PROFILES_DICE_SIGNIN_BUTTON), SyncInfoContainerBackgroundState::kNoPrimaryAccount, base::BindRepeating(&ProfileMenuView::OnSigninButtonClicked, base::Unretained(this)), /*show_badge=*/false); +#endif } } @@ -549,6 +569,7 @@ } } +#if !defined(OS_CHROMEOS) void ProfileMenuView::BuildProfileManagementHeading() { SetProfileManagementHeading( l10n_util::GetStringUTF16(IDS_PROFILES_OTHER_PROFILES_TITLE)); @@ -601,3 +622,4 @@ base::Unretained(this))); } } +#endif // defined(OS_CHROMEOS)
diff --git a/chrome/browser/ui/views/profiles/profile_menu_view.h b/chrome/browser/ui/views/profiles/profile_menu_view.h index 0b17dbe..17994ce 100644 --- a/chrome/browser/ui/views/profiles/profile_menu_view.h +++ b/chrome/browser/ui/views/profiles/profile_menu_view.h
@@ -12,6 +12,7 @@ #include <vector> #include "base/macros.h" +#include "build/build_config.h" #include "chrome/browser/profiles/avatar_menu.h" #include "chrome/browser/profiles/avatar_menu_observer.h" #include "chrome/browser/sync/sync_ui_util.h" @@ -50,17 +51,19 @@ void OnCreditCardsButtonClicked(); void OnAddressesButtonClicked(); void OnGuestProfileButtonClicked(); - void OnManageProfilesButtonClicked(); void OnExitProfileButtonClicked(); void OnSyncSettingsButtonClicked(); void OnSyncErrorButtonClicked(sync_ui_util::AvatarSyncErrorType error); - void OnSigninButtonClicked(); void OnSigninAccountButtonClicked(AccountInfo account); void OnSignoutButtonClicked(); - void OnOtherProfileSelected(const base::FilePath& profile_path); void OnCookiesClearedOnExitLinkClicked(); +#if !defined(OS_CHROMEOS) + void OnSigninButtonClicked(); + void OnOtherProfileSelected(const base::FilePath& profile_path); void OnAddNewProfileButtonClicked(); + void OnManageProfilesButtonClicked(); void OnEditProfileButtonClicked(); +#endif // We normally close the bubble any time it becomes inactive but this can lead // to flaky tests where unexpected UI events are triggering this behavior. @@ -73,9 +76,11 @@ void BuildAutofillButtons(); void BuildSyncInfo(); void BuildFeatureButtons(); - void BuildProfileManagementHeading(); +#if !defined(OS_CHROMEOS) void BuildSelectableProfiles(); + void BuildProfileManagementHeading(); void BuildProfileManagementFeatureButtons(); +#endif DISALLOW_COPY_AND_ASSIGN(ProfileMenuView); };
diff --git a/chrome/browser/ui/views/profiles/profile_menu_view_base.cc b/chrome/browser/ui/views/profiles/profile_menu_view_base.cc index 8d32bb0f..1ec634126 100644 --- a/chrome/browser/ui/views/profiles/profile_menu_view_base.cc +++ b/chrome/browser/ui/views/profiles/profile_menu_view_base.cc
@@ -22,6 +22,7 @@ #include "chrome/browser/ui/views/chrome_typography.h" #include "chrome/browser/ui/views/hover_button.h" #include "chrome/browser/ui/views/profiles/incognito_menu_view.h" +#include "chrome/browser/ui/views/profiles/profile_menu_view.h" #include "chrome/grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" #include "ui/display/display.h" @@ -41,7 +42,6 @@ #include "ui/views/view_class_properties.h" #if !defined(OS_CHROMEOS) -#include "chrome/browser/ui/views/profiles/profile_menu_view.h" #include "chrome/browser/ui/views/sync/dice_signin_button_view.h" #endif @@ -319,12 +319,7 @@ bubble = new IncognitoMenuView(anchor_button, browser); } else { DCHECK_EQ(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, view_mode); -#if !defined(OS_CHROMEOS) bubble = new ProfileMenuView(anchor_button, browser); -#else - NOTREACHED(); - return; -#endif } views::BubbleDialogDelegateView::CreateBubble(bubble)->Show();
diff --git a/chrome/browser/ui/views/profiles/profile_menu_view_browsertest.cc b/chrome/browser/ui/views/profiles/profile_menu_view_browsertest.cc index c7dbf1e..1ef0135 100644 --- a/chrome/browser/ui/views/profiles/profile_menu_view_browsertest.cc +++ b/chrome/browser/ui/views/profiles/profile_menu_view_browsertest.cc
@@ -568,8 +568,17 @@ // there are no other buttons at the end. ProfileMenuViewBase::ActionableItem::kPasswordsButton}; -PROFILE_MENU_CLICK_TEST(kActionableItems_WithUnconsentedPrimaryAccount, - ProfileMenuClickTest_WithUnconsentedPrimaryAccount) { +// TODO(https://crbug.com/1021930) flakey on Linux and Windows. +#if defined(OS_LINUX) || defined(OS_WIN) +#define MAYBE_ProfileMenuClickTest_WithUnconsentedPrimaryAccount \ + DISABLED_ProfileMenuClickTest_WithUnconsentedPrimaryAccount +#else +#define MAYBE_ProfileMenuClickTest_WithUnconsentedPrimaryAccount \ + ProfileMenuClickTest_WithUnconsentedPrimaryAccount +#endif +PROFILE_MENU_CLICK_TEST( + kActionableItems_WithUnconsentedPrimaryAccount, + MAYBE_ProfileMenuClickTest_WithUnconsentedPrimaryAccount) { secondary_account_helper::SignInSecondaryAccount( browser()->profile(), &test_url_loader_factory_, "user@example.com"); UnconsentedPrimaryAccountChecker(identity_manager()).Wait();
diff --git a/chrome/browser/ui/views/safe_browsing/password_reuse_modal_warning_dialog.cc b/chrome/browser/ui/views/safe_browsing/password_reuse_modal_warning_dialog.cc index 035f29b..6cf17af 100644 --- a/chrome/browser/ui/views/safe_browsing/password_reuse_modal_warning_dialog.cc +++ b/chrome/browser/ui/views/safe_browsing/password_reuse_modal_warning_dialog.cc
@@ -11,6 +11,7 @@ #include "chrome/browser/ui/views/accessibility/non_accessible_image_view.h" #include "chrome/browser/ui/views/chrome_layout_provider.h" #include "chrome/browser/ui/views/chrome_typography.h" +#include "chrome/grit/theme_resources.h" #include "components/constrained_window/constrained_window_views.h" #include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "components/password_manager/core/common/password_manager_features.h" @@ -20,6 +21,7 @@ #include "components/vector_icons/vector_icons.h" #include "content/public/browser/web_contents.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/resource/resource_bundle.h" #include "ui/gfx/color_palette.h" #include "ui/gfx/image/image.h" #include "ui/gfx/image/image_skia.h" @@ -33,40 +35,19 @@ namespace { -// Fixed height of the illustration shown on the top of the dialog. -constexpr int kSafeBrowsingIllustrationHeight = 148; - -// Fixed background color of the illustration shown on the top of the dialog in -// normal mode. -constexpr SkColor kSafeBrowsingPictureBackgroundColor = - SkColorSetARGB(0x0A, 0, 0, 0); - -// Fixed background color of the illustration shown on the top of the dialog in -// dark mode. -constexpr SkColor kSafeBrowsingPictureBackgroundColorDarkMode = - SkColorSetARGB(0x1A, 0x00, 0x00, 0x00); - // Updates the image displayed on the illustration based on the current theme. void SafeBrowsingUpdateImageView(NonAccessibleImageView* image_view, bool dark_mode_enabled) { - image_view->SetImage(gfx::CreateVectorIcon( - dark_mode_enabled ? kPasswordCheckWarningDarkIcon - : kPasswordCheckWarningIcon, - dark_mode_enabled ? kSafeBrowsingPictureBackgroundColorDarkMode - : kSafeBrowsingPictureBackgroundColor)); + image_view->SetImage( + *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( + dark_mode_enabled ? IDR_PASSWORD_CHECK_DARK : IDR_PASSWORD_CHECK)); } // Creates the illustration which is rendered on top of the dialog. std::unique_ptr<NonAccessibleImageView> SafeBrowsingCreateIllustration( bool dark_mode_enabled) { - const gfx::Size illustration_size( - ChromeLayoutProvider::Get()->GetDistanceMetric( - DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH), - kSafeBrowsingIllustrationHeight); auto image_view = std::make_unique<NonAccessibleImageView>(); - image_view->SetPreferredSize(illustration_size); SafeBrowsingUpdateImageView(image_view.get(), dark_mode_enabled); - image_view->SetSize(illustration_size); image_view->SetVerticalAlignment(views::ImageView::Alignment::kLeading); return image_view; }
diff --git a/chrome/browser/ui/webui/extensions/extensions_ui.cc b/chrome/browser/ui/webui/extensions/extensions_ui.cc index cbcb1be..e8519af 100644 --- a/chrome/browser/ui/webui/extensions/extensions_ui.cc +++ b/chrome/browser/ui/webui/extensions/extensions_ui.cc
@@ -171,7 +171,6 @@ IDS_EXTENSIONS_ACTIVITY_LOG_STREAM_TAB_HEADING}, {"startActivityStream", IDS_EXTENSIONS_START_ACTIVITY_STREAM}, {"stopActivityStream", IDS_EXTENSIONS_STOP_ACTIVITY_STREAM}, - {"disableBlockedMature", IDS_EXTENSIONS_DISABLE_BLOCKED_MATURE}, {"emptyStreamStarted", IDS_EXTENSIONS_EMPTY_STREAM_STARTED}, {"emptyStreamStopped", IDS_EXTENSIONS_EMPTY_STREAM_STOPPED}, {"activityArgumentsHeading", IDS_EXTENSIONS_ACTIVITY_ARGUMENTS_HEADING},
diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc index d63ffc1f..eba0313 100644 --- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc
@@ -1404,6 +1404,10 @@ {"cookiePageBlockAllBulTwo", IDS_SETTINGS_COOKIES_BLOCK_ALL_BULLET_TWO}, {"cookiePageBlockAllBulThree", IDS_SETTINGS_COOKIES_BLOCK_ALL_BULLET_THREE}, {"cookiePageClearOnExit", IDS_SETTINGS_COOKIES_CLEAR_ON_EXIT}, + {"cookiePageAllowExceptions", IDS_SETTINGS_COOKIES_ALLOW_EXCEPTIONS}, + {"cookiePageBlockExceptions", IDS_SETTINGS_COOKIES_BLOCK_EXCEPTIONS}, + {"cookiePageSessionOnlyExceptions", + IDS_SETTINGS_COOKIES_SESSION_ONLY_EXCEPTIONS}, {"cookiesManageSiteSpecificExceptions", IDS_SETTINGS_COOKIES_SITE_SPECIFIC_EXCEPTIONS}, {"siteSettingsCategoryCookies", IDS_SETTINGS_SITE_SETTINGS_COOKIES},
diff --git a/chrome/browser/ui/webui/settings/settings_ui.cc b/chrome/browser/ui/webui/settings/settings_ui.cc index 569b9b93..5af6118d 100644 --- a/chrome/browser/ui/webui/settings/settings_ui.cc +++ b/chrome/browser/ui/webui/settings/settings_ui.cc
@@ -338,6 +338,10 @@ // Only used in Polymer 3, see https://crbug.com/1026426. html_source->AddResourcePath("settings.js", IDR_SETTINGS_SETTINGS_ROLLUP_JS); + html_source->AddResourcePath("shared.rollup.js", + IDR_SETTINGS_SHARED_ROLLUP_JS); + html_source->AddResourcePath("lazy_load.js", + IDR_SETTINGS_LAZY_LOAD_ROLLUP_JS); html_source->AddResourcePath("settings_v3.html", IDR_SETTINGS_SETTINGS_V3_HTML); #else
diff --git a/chrome/browser/upboarding/BUILD.gn b/chrome/browser/upboarding/BUILD.gn index b99fd14..e6d975a 100644 --- a/chrome/browser/upboarding/BUILD.gn +++ b/chrome/browser/upboarding/BUILD.gn
@@ -11,6 +11,11 @@ deps = [ "//chrome/browser/upboarding/query_tiles" ] } +group("unit_tests") { + testonly = true + deps = [ "//chrome/browser/upboarding/query_tiles:unit_tests" ] +} + if (is_android) { java_group("java") { deps = [ "query_tiles:query_tiles_java" ]
diff --git a/chrome/browser/upboarding/query_tiles/BUILD.gn b/chrome/browser/upboarding/query_tiles/BUILD.gn index 38358a95..5494f61 100644 --- a/chrome/browser/upboarding/query_tiles/BUILD.gn +++ b/chrome/browser/upboarding/query_tiles/BUILD.gn
@@ -116,10 +116,8 @@ } } -source_set("unit_tests") { +group("unit_tests") { testonly = true - - sources = [] - + visibility = [ "//chrome/browser/upboarding:unit_tests" ] deps = [ "//chrome/browser/upboarding/query_tiles/internal:unit_tests" ] }
diff --git a/chrome/browser/upboarding/query_tiles/internal/BUILD.gn b/chrome/browser/upboarding/query_tiles/internal/BUILD.gn index a0098af..716370d 100644 --- a/chrome/browser/upboarding/query_tiles/internal/BUILD.gn +++ b/chrome/browser/upboarding/query_tiles/internal/BUILD.gn
@@ -9,6 +9,8 @@ source_set("internal") { sources = [ + "image_decoder.cc", + "image_decoder.h", "image_loader.cc", "image_loader.h", "proto_conversion.cc", @@ -23,6 +25,7 @@ "//chrome/browser/upboarding/query_tiles:public", "//chrome/browser/upboarding/query_tiles/proto", "//components/leveldb_proto", + "//services/data_decoder/public/cpp", "//skia", "//url", ] @@ -30,18 +33,24 @@ source_set("unit_tests") { testonly = true + visibility = [ "//chrome/browser/upboarding/query_tiles:unit_tests" ] + sources = [ + "image_decoder_unittest.cc", "proto_conversion_unittest.cc", "query_tile_store_unittest.cc", ] deps = [ + ":internal", "//base", + "//base/test:test_support", "//chrome/browser/upboarding/query_tiles:public", "//chrome/browser/upboarding/query_tiles/internal", "//chrome/browser/upboarding/query_tiles/proto", "//components/leveldb_proto", "//components/leveldb_proto:test_support", + "//services/data_decoder/public/cpp:test_support", "//skia", "//testing/gmock", "//testing/gtest",
diff --git a/chrome/browser/upboarding/query_tiles/internal/image_decoder.cc b/chrome/browser/upboarding/query_tiles/internal/image_decoder.cc new file mode 100644 index 0000000..13e8d49a --- /dev/null +++ b/chrome/browser/upboarding/query_tiles/internal/image_decoder.cc
@@ -0,0 +1,58 @@ +// Copyright 2020 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 "chrome/browser/upboarding/query_tiles/internal/image_decoder.h" + +#include <utility> + +#include "services/data_decoder/public/cpp/decode_image.h" +#include "ui/gfx/geometry/size.h" + +namespace upboarding { +namespace { + +// The maximum size of data to be decoded. +constexpr size_t kMaximumEncodedDataSize = 10 * 1024 * 1024 /*10MB*/; + +// Decodes an image in a utility process. Destroy the object will release the +// IPC connection. +class SafeImageDecoder : public ImageDecoder { + public: + SafeImageDecoder() = default; + SafeImageDecoder(const SafeImageDecoder&) = delete; + SafeImageDecoder& operator=(const SafeImageDecoder&) = delete; + ~SafeImageDecoder() override = default; + + private: + // ImageDecoder implementation. + void Decode(EncodedData data, + const gfx::Size& output_size, + DecodeCallback decode_callback) override { + DCHECK(decode_callback); + if (data.empty()) { + std::move(decode_callback).Run(SkBitmap()); + return; + } + + // Each decoding operation happens in its own process. + // TODO(xingliu): Consider to use a shared utility process. + data_decoder::DecodeImageIsolated( + std::move(data), data_decoder::mojom::ImageCodec::DEFAULT, + /*shrink_to_fit=*/true, kMaximumEncodedDataSize, output_size, + std::move(decode_callback)); + } +}; + +} // namespace + +// static +std::unique_ptr<ImageDecoder> ImageDecoder::Create() { + return std::make_unique<SafeImageDecoder>(); +} + +ImageDecoder::ImageDecoder() = default; + +ImageDecoder::~ImageDecoder() = default; + +} // namespace upboarding
diff --git a/chrome/browser/upboarding/query_tiles/internal/image_decoder.h b/chrome/browser/upboarding/query_tiles/internal/image_decoder.h new file mode 100644 index 0000000..ed167ee --- /dev/null +++ b/chrome/browser/upboarding/query_tiles/internal/image_decoder.h
@@ -0,0 +1,44 @@ +// Copyright 2020 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. + +#ifndef CHROME_BROWSER_UPBOARDING_QUERY_TILES_INTERNAL_IMAGE_DECODER_H_ +#define CHROME_BROWSER_UPBOARDING_QUERY_TILES_INTERNAL_IMAGE_DECODER_H_ + +#include <memory> +#include <vector> + +#include "base/callback.h" + +namespace gfx { +class Size; +} // namespace gfx + +class SkBitmap; + +namespace upboarding { + +// Decodes an image into bitmap, to be consumed by UI. +class ImageDecoder { + public: + using DecodeCallback = base::OnceCallback<void(const SkBitmap&)>; + using EncodedData = std::vector<uint8_t>; + + static std::unique_ptr<ImageDecoder> Create(); + + ImageDecoder(const ImageDecoder&) = delete; + ImageDecoder& operator=(const ImageDecoder&) = delete; + virtual ~ImageDecoder(); + + // Decodes the image. |data| should be moved into this function. + virtual void Decode(EncodedData data, + const gfx::Size& output_size, + DecodeCallback decode_callback) = 0; + + protected: + ImageDecoder(); +}; + +} // namespace upboarding + +#endif // CHROME_BROWSER_UPBOARDING_QUERY_TILES_INTERNAL_IMAGE_DECODER_H_
diff --git a/chrome/browser/upboarding/query_tiles/internal/image_decoder_unittest.cc b/chrome/browser/upboarding/query_tiles/internal/image_decoder_unittest.cc new file mode 100644 index 0000000..58cb6b6 --- /dev/null +++ b/chrome/browser/upboarding/query_tiles/internal/image_decoder_unittest.cc
@@ -0,0 +1,85 @@ +// Copyright 2020 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 "chrome/browser/upboarding/query_tiles/internal/image_decoder.h" + +#include <string> +#include <utility> + +#include "base/bind.h" +#include "base/files/file_util.h" +#include "base/path_service.h" +#include "base/run_loop.h" +#include "base/test/bind_test_util.h" +#include "base/test/task_environment.h" +#include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "ui/gfx/geometry/size.h" + +namespace upboarding { +namespace { + +const base::FilePath::CharType kTestDataDir[] = + FILE_PATH_LITERAL("chrome/test/data/image_decoding/droids.jpg"); + +class ImageDecoderTest : public testing::Test { + public: + ImageDecoderTest() = default; + ImageDecoderTest(const ImageDecoderTest&) = delete; + ImageDecoderTest& operator=(const ImageDecoderTest&) = delete; + ~ImageDecoderTest() override = default; + + void SetUp() override { image_decoder_ = ImageDecoder::Create(); } + + protected: + void Decode(ImageDecoder::EncodedData data, + const gfx::Size& size, + ImageDecoder::DecodeCallback callback) { + image_decoder_->Decode(std::move(data), size, std::move(callback)); + } + + private: + // Needed test support objects. + base::test::TaskEnvironment task_environment_; + data_decoder::test::InProcessDataDecoder decoder_service; + + std::unique_ptr<ImageDecoder> image_decoder_; +}; + +// Verifies empty input will result in empty output. +TEST_F(ImageDecoderTest, DecodeEmpty) { + base::RunLoop loop; + auto callback = base::BindLambdaForTesting([&](const SkBitmap& bitmap) { + EXPECT_TRUE(bitmap.empty()); + loop.Quit(); + }); + + Decode(ImageDecoder::EncodedData(), gfx::Size(1, 1), std::move(callback)); + loop.Run(); +} + +// Decodes an image. +TEST_F(ImageDecoderTest, Decode) { + // Read in a test image. + base::FilePath data_dir; + ASSERT_TRUE(base::PathService::Get(base::DIR_SOURCE_ROOT, &data_dir)); + base::FilePath file_path = data_dir.Append(base::FilePath(kTestDataDir)); + std::string file_data; + ASSERT_TRUE(base::ReadFileToString(file_path, &file_data)); + EXPECT_FALSE(file_data.empty()); + ImageDecoder::EncodedData data(file_data.begin(), file_data.end()); + EXPECT_FALSE(data.empty()); + + // Decode the image data. + base::RunLoop loop; + auto callback = base::BindLambdaForTesting([&](const SkBitmap& bitmap) { + EXPECT_FALSE(bitmap.empty()); + loop.Quit(); + }); + Decode(std::move(data), gfx::Size(16, 16), std::move(callback)); + loop.Run(); +} + +} // namespace +} // namespace upboarding
diff --git a/chrome/browser/win/parental_controls.cc b/chrome/browser/win/parental_controls.cc index 9dc3aed..a99f68ed 100644 --- a/chrome/browser/win/parental_controls.cc +++ b/chrome/browser/win/parental_controls.cc
@@ -10,12 +10,20 @@ #include <wpcapi.h> #include <wrl/client.h> +#include <string> + #include "base/bind.h" #include "base/location.h" +#include "base/logging.h" #include "base/memory/singleton.h" +#include "base/strings/stringprintf.h" #include "base/task/post_task.h" #include "base/task/task_traits.h" #include "base/threading/scoped_blocking_call.h" +#include "base/win/registry.h" +#include "base/win/win_util.h" +#include "base/win/windows_types.h" +#include "base/win/windows_version.h" namespace { @@ -36,13 +44,6 @@ private: friend struct base::DefaultSingletonTraits<WinParentalControlsValue>; - // Histogram enum for tracking the thread that checked parental controls. - enum class ThreadType { - UI = 0, - BLOCKING, - COUNT, - }; - WinParentalControlsValue() : parental_controls_(GetParentalControls()) {} ~WinParentalControlsValue() = default; @@ -53,7 +54,7 @@ // Returns the Windows Parental control enablements. This feature is available // on Windows 7 and beyond. This function should be called on a COM // Initialized thread and is potentially blocking. - static WinParentalControls GetParentalControls() { + static WinParentalControls GetParentalControlsFromApi() { // Since we can potentially block, make sure the thread is okay with this. base::ScopedBlockingCall scoped_blocking_call( FROM_HERE, base::BlockingType::MAY_BLOCK); @@ -81,6 +82,52 @@ return controls; } + // Update |controls| with parental controls found to be active by reading + // parental controls configuration from the registry. May be necessary on + // Win10 where the APIs are not fully supported and may not always accurately + // report such state. + // + // TODO(ericorth@chromium.org): Detect |logging_required| configuration, + // rather than just web filtering. + static void UpdateParentalControlsFromRegistry( + WinParentalControls* controls) { + DCHECK(controls); + + std::wstring user_sid; + if (!base::win::GetUserSidString(&user_sid)) + return; + + static constexpr wchar_t kWebFilterRegistryPathFormat[] = + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Parental " + "Controls\\Users\\%ls\\Web"; + + std::wstring web_filter_key_path = + base::StringPrintf(kWebFilterRegistryPathFormat, user_sid.c_str()); + base::win::RegKey web_filter_key( + HKEY_LOCAL_MACHINE, web_filter_key_path.c_str(), KEY_QUERY_VALUE); + if (!web_filter_key.Valid()) + return; + + // Web filtering is in use if the key contains any "Filter On" value. + DWORD filter_on_value; + if (web_filter_key.ReadValueDW(L"Filter On", &filter_on_value) == + ERROR_SUCCESS) { + controls->any_restrictions = true; + controls->web_filter = true; + } + } + + static WinParentalControls GetParentalControls() { + WinParentalControls controls = GetParentalControlsFromApi(); + + // Parental controls APIs are not fully supported in Win10 and beyond, so + // check registry properties for restictions. + if (base::win::GetVersion() >= base::win::Version::WIN10) + UpdateParentalControlsFromRegistry(&controls); + + return controls; + } + const WinParentalControls parental_controls_; };
diff --git a/chrome/common/apps/platform_apps/chrome_apps_api_permissions.cc b/chrome/common/apps/platform_apps/chrome_apps_api_permissions.cc index 99e1f55..9c7b568 100644 --- a/chrome/common/apps/platform_apps/chrome_apps_api_permissions.cc +++ b/chrome/common/apps/platform_apps/chrome_apps_api_permissions.cc
@@ -22,18 +22,31 @@ // ChromePermissionMessageProvider::GetPermissionMessages as well. constexpr extensions::APIPermissionInfo::InitInfo permissions_to_register[] = { {extensions::APIPermission::kArcAppsPrivate, "arcAppsPrivate"}, - {extensions::APIPermission::kBrowser, "browser"}, + {extensions::APIPermission::kBrowser, "browser", + extensions::APIPermissionInfo:: + kFlagDoesNotRequireManagedSessionFullLoginWarning}, {extensions::APIPermission::kFirstRunPrivate, "firstRunPrivate", - extensions::APIPermissionInfo::kFlagCannotBeOptional}, + extensions::APIPermissionInfo::kFlagCannotBeOptional | + extensions::APIPermissionInfo:: + kFlagDoesNotRequireManagedSessionFullLoginWarning}, {extensions::APIPermission::kMusicManagerPrivate, "musicManagerPrivate", - extensions::APIPermissionInfo::kFlagCannotBeOptional}, + extensions::APIPermissionInfo::kFlagCannotBeOptional | + extensions::APIPermissionInfo:: + kFlagDoesNotRequireManagedSessionFullLoginWarning}, {extensions::APIPermission::kMediaGalleries, "mediaGalleries", - extensions::APIPermissionInfo::kFlagNone, + extensions::APIPermissionInfo:: + kFlagDoesNotRequireManagedSessionFullLoginWarning, &CreateAPIPermission<chrome_apps::MediaGalleriesPermission>}, - {extensions::APIPermission::kPointerLock, "pointerLock"}, - {extensions::APIPermission::kSyncFileSystem, "syncFileSystem"}, + {extensions::APIPermission::kPointerLock, "pointerLock", + extensions::APIPermissionInfo:: + kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {extensions::APIPermission::kSyncFileSystem, "syncFileSystem", + extensions::APIPermissionInfo:: + kFlagDoesNotRequireManagedSessionFullLoginWarning}, {extensions::APIPermission::kWebstoreWidgetPrivate, "webstoreWidgetPrivate", - extensions::APIPermissionInfo::kFlagCannotBeOptional}, + extensions::APIPermissionInfo::kFlagCannotBeOptional | + extensions::APIPermissionInfo:: + kFlagDoesNotRequireManagedSessionFullLoginWarning}, }; } // namespace
diff --git a/chrome/common/chrome_features.cc b/chrome/common/chrome_features.cc index 878d937e..f7144a3 100644 --- a/chrome/common/chrome_features.cc +++ b/chrome/common/chrome_features.cc
@@ -185,7 +185,7 @@ // OS_CHROMEOS, but this flag must be defined for all platforms since // it is required for SystemWebApp tests. const base::Feature kTerminalSystemApp{"TerminalSystemApp", - base::FEATURE_ENABLED_BY_DEFAULT}; + base::FEATURE_DISABLED_BY_DEFAULT}; // Use the Terminal System App legacy settings page. const base::Feature kTerminalSystemAppLegacySettings{
diff --git a/chrome/common/extensions/api/developer_private.idl b/chrome/common/extensions/api/developer_private.idl index dcdb611..f49c474 100644 --- a/chrome/common/extensions/api/developer_private.idl +++ b/chrome/common/extensions/api/developer_private.idl
@@ -138,7 +138,6 @@ boolean updateRequired; boolean blockedByPolicy; boolean custodianApprovalRequired; - boolean blockedMature; }; dictionary OptionsPage {
diff --git a/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc b/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc index 25887f8..de838f6 100644 --- a/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc +++ b/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc
@@ -5,6 +5,7 @@ #include <memory> #include <utility> +#include "base/test/values_test_util.h" #include "chrome/common/extensions/api/extension_action/action_info.h" #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" #include "extensions/common/constants.h" @@ -112,22 +113,19 @@ TEST_F(BrowserActionManifestTest, BrowserActionManifestIcons_InvalidDefaultIcon) { - std::unique_ptr<base::DictionaryValue> manifest_value = - DictionaryBuilder() - .Set("name", "Invalid default icon") - .Set("version", "1.0.0") - .Set("manifest_version", 2) - .Set("browser_action", - DictionaryBuilder() - .Set("default_icon", - DictionaryBuilder() - .Set("19", std::string()) // Invalid value. - .Set("24", "icon24.png") - .Set("38", "icon38.png") - .Build()) - .Build()) - .Build(); - + base::Value manifest_value = base::test::ParseJson(R"( + { + "name": "Invalid default icon", + "version": "1.0.0", + "manifest_version": 2, + "browser_action": { + "default_icon": { + "19": "", // Invalid value. + "24": "icon24.png", + "38": "icon38.png" + } + } + })"); base::string16 error = ErrorUtils::FormatErrorMessageUTF16( errors::kInvalidIconPath, "19"); LoadAndExpectError(
diff --git a/chrome/common/extensions/manifest_handlers/ui_overrides_handler.cc b/chrome/common/extensions/manifest_handlers/ui_overrides_handler.cc index c0077ed..b42fadd 100644 --- a/chrome/common/extensions/manifest_handlers/ui_overrides_handler.cc +++ b/chrome/common/extensions/manifest_handlers/ui_overrides_handler.cc
@@ -86,6 +86,8 @@ bool RequiresManagementUIWarning() const override { return false; } + bool RequiresManagedSessionFullLoginWarning() const override { return false; } + private: bool override_bookmarks_ui_permission_; };
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc index 5009ec25..90f396d 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc
@@ -39,7 +39,7 @@ ASSERT_TRUE(manifest.is_dict()); scoped_refptr<Extension> extension( - LoadAndExpectSuccess(ManifestData(&manifest, ""))); + LoadAndExpectSuccess(ManifestData(manifest.Clone(), ""))); ASSERT_TRUE(extension.get()); const std::vector<std::string>& background_scripts = BackgroundInfo::GetBackgroundScripts(extension.get()); @@ -53,7 +53,7 @@ BackgroundInfo::GetBackgroundURL(extension.get()).path()); manifest.SetPath({"background", "page"}, base::Value("monkey.html")); - LoadAndExpectError(ManifestData(&manifest, ""), + LoadAndExpectError(ManifestData(std::move(manifest), ""), errors::kInvalidBackgroundCombination); } @@ -86,14 +86,14 @@ manifest.SetPath({"background", "persistent"}, base::Value(false)); manifest.SetKey(keys::kManifestVersion, base::Value(2)); scoped_refptr<Extension> extension( - LoadAndExpectSuccess(ManifestData(&manifest, ""))); + LoadAndExpectSuccess(ManifestData(manifest.Clone(), ""))); ASSERT_TRUE(extension.get()); EXPECT_TRUE(BackgroundInfo::HasLazyBackgroundPage(extension.get())); base::Value permissions(base::Value::Type::LIST); permissions.Append(base::Value("webRequest")); manifest.SetKey(keys::kPermissions, std::move(permissions)); - LoadAndExpectError(ManifestData(&manifest, ""), + LoadAndExpectError(ManifestData(std::move(manifest), ""), errors::kWebRequestConflictsWithLazyBackground); }
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_manifest_version_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_manifest_version_unittest.cc index 6d4809a4b..3a22178 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_manifest_version_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_manifest_version_unittest.cc
@@ -14,28 +14,28 @@ namespace errors = extensions::manifest_errors; TEST_F(ChromeManifestTest, ManifestVersionError) { - std::unique_ptr<base::DictionaryValue> manifest1(new base::DictionaryValue()); - manifest1->SetString("name", "Miles"); - manifest1->SetString("version", "0.55"); + base::Value manifest1(base::Value::Type::DICTIONARY); + manifest1.SetStringKey("name", "Miles"); + manifest1.SetStringKey("version", "0.55"); - std::unique_ptr<base::DictionaryValue> manifest2(manifest1->DeepCopy()); - manifest2->SetInteger("manifest_version", 1); + base::Value manifest2 = manifest1.Clone(); + manifest2.SetIntKey("manifest_version", 1); - std::unique_ptr<base::DictionaryValue> manifest3(manifest1->DeepCopy()); - manifest3->SetInteger("manifest_version", 2); + base::Value manifest3 = manifest1.Clone(); + manifest3.SetIntKey("manifest_version", 2); struct { const char* test_name; bool require_modern_manifest_version; - base::DictionaryValue* manifest; + base::Value manifest; bool expect_error; } test_data[] = { - {"require_modern_with_default", true, manifest1.get(), true}, - {"require_modern_with_v1", true, manifest2.get(), true}, - {"require_modern_with_v2", true, manifest3.get(), false}, - {"dont_require_modern_with_default", false, manifest1.get(), true}, - {"dont_require_modern_with_v1", false, manifest2.get(), true}, - {"dont_require_modern_with_v2", false, manifest3.get(), false}, + {"require_modern_with_default", true, manifest1.Clone(), true}, + {"require_modern_with_v1", true, manifest2.Clone(), true}, + {"require_modern_with_v2", true, manifest3.Clone(), false}, + {"dont_require_modern_with_default", false, manifest1.Clone(), true}, + {"dont_require_modern_with_v1", false, manifest2.Clone(), true}, + {"dont_require_modern_with_v2", false, manifest3.Clone(), false}, }; for (auto& entry : test_data) { @@ -43,12 +43,14 @@ if (entry.require_modern_manifest_version) create_flags |= Extension::REQUIRE_MODERN_MANIFEST_VERSION; if (entry.expect_error) { - LoadAndExpectError(ManifestData(entry.manifest, entry.test_name), - errors::kInvalidManifestVersionOld, - extensions::Manifest::UNPACKED, create_flags); + LoadAndExpectError( + ManifestData(std::move(entry.manifest), entry.test_name), + errors::kInvalidManifestVersionOld, extensions::Manifest::UNPACKED, + create_flags); } else { - LoadAndExpectSuccess(ManifestData(entry.manifest, entry.test_name), - extensions::Manifest::UNPACKED, create_flags); + LoadAndExpectSuccess( + ManifestData(std::move(entry.manifest), entry.test_name), + extensions::Manifest::UNPACKED, create_flags); } } }
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc index 35f5ff9..6cf952d 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc
@@ -129,8 +129,7 @@ permissions.Append(base::Value("experimental")); permissions.Append(base::Value(api_name)); manifest.SetKey("permissions", std::move(permissions)); - manifests.push_back( - std::make_unique<ManifestData>(manifest.CreateDeepCopy(), "")); + manifests.push_back(std::make_unique<ManifestData>(manifest.Clone(), "")); } // First try to load without any flags. This should warn for every API. for (const std::unique_ptr<ManifestData>& manifest : manifests) {
diff --git a/chrome/common/extensions/permissions/chrome_api_permissions.cc b/chrome/common/extensions/permissions/chrome_api_permissions.cc index 641c4b2..8d5abbd 100644 --- a/chrome/common/extensions/permissions/chrome_api_permissions.cc +++ b/chrome/common/extensions/permissions/chrome_api_permissions.cc
@@ -31,55 +31,77 @@ // ChromePermissionMessageProvider::GetPermissionMessages as well. constexpr APIPermissionInfo::InitInfo permissions_to_register[] = { // Register permissions for all extension types. - {APIPermission::kBackground, "background"}, + {APIPermission::kBackground, "background", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kDeclarativeContent, "declarativeContent"}, {APIPermission::kDesktopCapture, "desktopCapture"}, - {APIPermission::kDesktopCapturePrivate, "desktopCapturePrivate"}, + {APIPermission::kDesktopCapturePrivate, "desktopCapturePrivate", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kDownloads, "downloads"}, {APIPermission::kDownloadsOpen, "downloads.open"}, - {APIPermission::kDownloadsShelf, "downloads.shelf"}, + {APIPermission::kDownloadsShelf, "downloads.shelf", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kIdentity, "identity"}, {APIPermission::kIdentityEmail, "identity.email"}, {APIPermission::kExperimental, "experimental", APIPermissionInfo::kFlagCannotBeOptional}, {APIPermission::kGeolocation, "geolocation", APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kNotifications, "notifications"}, - {APIPermission::kGcm, "gcm"}, + {APIPermission::kNotifications, "notifications", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kGcm, "gcm", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, // Register extension permissions. {APIPermission::kAccessibilityFeaturesModify, - "accessibilityFeatures.modify"}, + "accessibilityFeatures.modify", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kAccessibilityFeaturesRead, "accessibilityFeatures.read"}, {APIPermission::kAccessibilityPrivate, "accessibilityPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kActiveTab, "activeTab"}, {APIPermission::kBookmark, "bookmarks"}, {APIPermission::kBrailleDisplayPrivate, "brailleDisplayPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kBrowsingData, "browsingData"}, - {APIPermission::kCertificateProvider, "certificateProvider"}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kBrowsingData, "browsingData", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kCertificateProvider, "certificateProvider", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kContentSettings, "contentSettings"}, - {APIPermission::kContextMenus, "contextMenus"}, - {APIPermission::kCookie, "cookies"}, - {APIPermission::kCryptotokenPrivate, "cryptotokenPrivate"}, + {APIPermission::kContextMenus, "contextMenus", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kCookie, "cookies", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kCryptotokenPrivate, "cryptotokenPrivate", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kDataReductionProxy, "dataReductionProxy", APIPermissionInfo::kFlagImpliesFullURLAccess | - APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kEnterpriseDeviceAttributes, "enterprise.deviceAttributes"}, - {APIPermission::kEnterpriseHardwarePlatform, "enterprise.hardwarePlatform"}, - {APIPermission::kEnterprisePlatformKeys, "enterprise.platformKeys"}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kEnterpriseDeviceAttributes, "enterprise.deviceAttributes", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kEnterpriseHardwarePlatform, "enterprise.hardwarePlatform", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kEnterprisePlatformKeys, "enterprise.platformKeys", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kFileBrowserHandler, "fileBrowserHandler", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kFontSettings, "fontSettings", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kHistory, "history", APIPermissionInfo::kFlagRequiresManagementUIWarning}, {APIPermission::kIdltest, "idltest"}, {APIPermission::kInput, "input"}, {APIPermission::kManagement, "management"}, - {APIPermission::kMDns, "mdns", APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kPlatformKeys, "platformKeys"}, + {APIPermission::kMDns, "mdns", + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kPlatformKeys, "platformKeys", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kPrivacy, "privacy"}, {APIPermission::kProcesses, "processes", APIPermissionInfo::kFlagRequiresManagementUIWarning}, @@ -90,93 +112,134 @@ {APIPermission::kTopSites, "topSites", APIPermissionInfo::kFlagRequiresManagementUIWarning}, {APIPermission::kTransientBackground, "transientBackground", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kTts, "tts", APIPermissionInfo::kFlagCannotBeOptional}, {APIPermission::kTtsEngine, "ttsEngine", APIPermissionInfo::kFlagCannotBeOptional}, {APIPermission::kWallpaper, "wallpaper", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kWebNavigation, "webNavigation", APIPermissionInfo::kFlagRequiresManagementUIWarning}, // Register private permissions. {APIPermission::kActivityLogPrivate, "activityLogPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kAutoTestPrivate, "autotestPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kBookmarkManagerPrivate, "bookmarkManagerPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kCast, "cast", APIPermissionInfo::kFlagCannotBeOptional}, {APIPermission::kChromeosInfoPrivate, "chromeosInfoPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kCommandsAccessibility, "commands.accessibility", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kCommandLinePrivate, "commandLinePrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kDeveloperPrivate, "developerPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kDownloadsInternal, "downloadsInternal"}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kDownloadsInternal, "downloadsInternal", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kFileBrowserHandlerInternal, "fileBrowserHandlerInternal", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kFileManagerPrivate, "fileManagerPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kIdentityPrivate, "identityPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kWebcamPrivate, "webcamPrivate"}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kWebcamPrivate, "webcamPrivate", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kMediaPlayerPrivate, "mediaPlayerPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kMediaRouterPrivate, "mediaRouterPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kNetworkingCastPrivate, "networking.castPrivate"}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kNetworkingCastPrivate, "networking.castPrivate", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kSystemPrivate, "systemPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kCloudPrintPrivate, "cloudPrintPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kInputMethodPrivate, "inputMethodPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kEchoPrivate, "echoPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kImageWriterPrivate, "imageWriterPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kRtcPrivate, "rtcPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kTerminalPrivate, "terminalPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kVirtualKeyboardPrivate, "virtualKeyboardPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kWallpaperPrivate, "wallpaperPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kWebstorePrivate, "webstorePrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kEnterprisePlatformKeysPrivate, "enterprise.platformKeysPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kEnterpriseReportingPrivate, "enterprise.reportingPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kWebrtcAudioPrivate, "webrtcAudioPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kWebrtcDesktopCapturePrivate, "webrtcDesktopCapturePrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kWebrtcLoggingPrivate, "webrtcLoggingPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kWebrtcLoggingPrivateAudioDebug, "webrtcLoggingPrivate.audioDebug", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kSettingsPrivate, "settingsPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kAutofillAssistantPrivate, "autofillAssistantPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kAutofillPrivate, "autofillPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kPasswordsPrivate, "passwordsPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kUsersPrivate, "usersPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kLanguageSettingsPrivate, "languageSettingsPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kResourcesPrivate, "resourcesPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kSafeBrowsingPrivate, "safeBrowsingPrivate"}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kSafeBrowsingPrivate, "safeBrowsingPrivate", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, // Full url access permissions. {APIPermission::kDebugger, "debugger", @@ -199,9 +262,12 @@ // Platform-app permissions. - {APIPermission::kFileSystemProvider, "fileSystemProvider"}, - {APIPermission::kCastStreaming, "cast.streaming"}, - {APIPermission::kLauncherSearchProvider, "launcherSearchProvider"}, + {APIPermission::kFileSystemProvider, "fileSystemProvider", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kCastStreaming, "cast.streaming", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kLauncherSearchProvider, "launcherSearchProvider", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, // Settings override permissions. {APIPermission::kHomepage, "homepage",
diff --git a/chrome/common/extensions/permissions/settings_override_permission_unittest.cc b/chrome/common/extensions/permissions/settings_override_permission_unittest.cc index 5f35e6f..25499d4 100644 --- a/chrome/common/extensions/permissions/settings_override_permission_unittest.cc +++ b/chrome/common/extensions/permissions/settings_override_permission_unittest.cc
@@ -71,7 +71,7 @@ ext_manifest.Set(manifest_keys::kSettingsOverride, std::move(settings_override)); - ManifestData manifest(&ext_manifest, "test"); + ManifestData manifest(std::move(ext_manifest), "test"); return LoadAndExpectSuccess(manifest); }
diff --git a/chrome/common/net/x509_certificate_model_nss_unittest.cc b/chrome/common/net/x509_certificate_model_nss_unittest.cc index 7dbd885..3bc0cc8 100644 --- a/chrome/common/net/x509_certificate_model_nss_unittest.cc +++ b/chrome/common/net/x509_certificate_model_nss_unittest.cc
@@ -383,21 +383,21 @@ ASSERT_TRUE(cert.get()); EXPECT_EQ( - "B1 B1 83 61 AF DB ED 98 CF 3D 43 5F A7 42 B8 6D\n" - "94 36 57 BB AB 04 EE DD 3B B7 6D EC 78 7D 46 59\n" - "B1 E6 2A C3 AA A5 70 A7 E1 0C FA 65 37 C6 CB 7D\n" - "A1 37 35 A1 FF F0 DD CE B6 A4 2C 12 D4 46 A9 9C\n" - "A2 91 3A B0 95 55 97 55 E6 0A DA 63 60 24 19 AC\n" - "20 C9 B1 94 40 E9 99 B1 F5 C3 ED 61 5D DE 4C E4\n" - "EB D9 0E AC 3A 0A FC 44 7D 0F 77 A6 B6 DA 28 D4\n" - "ED EA 3A BC 57 23 9C 72 2B 2D B0 5D 11 02 4D C5\n" - "BC B0 D6 7E 00 8E F7 E7 F5 19 3A 23 DF 33 02 AA\n" - "4B BF 81 F4 5A 99 EE 74 20 F3 77 A1 F0 85 1E A8\n" - "D6 CC A4 CB 31 FA 73 24 A2 0E DD 9F 6F 82 38 5F\n" - "85 AC 8D 76 BD D8 F2 69 73 E3 46 44 42 E3 5E F3\n" - "AA 5E 44 13 51 EA 0B 78 91 77 96 EE 73 FE 2A B5\n" - "88 C1 38 8D 8D A8 19 76 94 05 02 CF D4 6F EB E6\n" - "07 F5 9D 52 24 B8 50 A3 0E C4 45 A6 09 B4 06 2D\n" - "3E 14 A5 3F 1C 1A BC DA B8 40 3E C1 1C F6 3C 05", + "5B 53 FF 6D D5 0A 43 A5 0F D4 7D C6 5D 88 E3 98\n" + "9D 67 EB 32 82 B3 0F F5 C1 78 F8 05 4A BF BC 21\n" + "05 EE 21 08 2C B2 15 A1 B8 B2 F6 A3 15 61 E4 C1\n" + "AD 84 A4 A7 40 0C 87 09 5F 2B 1B F9 4D 6C 92 7D\n" + "CB 7E 2B B0 01 0A ED 40 E5 4E AF 1A F1 0D EC 1D\n" + "9E 96 C7 D4 61 64 39 23 FA 5F 29 C4 2A 3A B8 ED\n" + "8A 72 50 6A AC 45 04 76 09 A8 3D 57 D7 F0 4B AE\n" + "46 B4 83 C1 14 50 2A 19 59 53 B2 4D AE FC 2F 40\n" + "49 C8 AD 4D 9D C8 22 8D 8C 01 DB 31 33 5A F4 BC\n" + "4C 9B ED D7 E3 43 D9 E8 1D 53 8B 30 D8 81 9E 72\n" + "AB 9E CE B8 F5 83 93 F2 72 DB DE CD B0 52 9A 45\n" + "4D CF E7 21 D8 CE 16 64 8F 42 AF C1 87 A8 F9 D5\n" + "E2 03 DD BA 6B 1B 7C 7D A0 38 33 61 39 B4 DD 5C\n" + "69 17 79 02 3A EC 1D 6F 5E BB 13 FB A6 82 5D 07\n" + "20 FC 86 FE 6E 8B AC E1 C2 18 A2 FE 3F 95 66 D3\n" + "69 8A 00 06 2C 56 37 34 B9 B6 31 DE 0F F6 44 39", x509_certificate_model::ProcessRawBitsSignatureWrap(cert.get())); }
diff --git a/chrome/renderer/net/net_error_helper.cc b/chrome/renderer/net/net_error_helper.cc index 6bea263..54a5abf 100644 --- a/chrome/renderer/net/net_error_helper.cc +++ b/chrome/renderer/net/net_error_helper.cc
@@ -167,10 +167,11 @@ !render_frame->IsHidden())); render_frame->GetAssociatedInterfaceRegistry()->AddInterface( - base::Bind(&NetErrorHelper::OnNetworkDiagnosticsClientRequest, - base::Unretained(this))); - render_frame->GetAssociatedInterfaceRegistry()->AddInterface(base::Bind( - &NetErrorHelper::OnNavigationCorrectorRequest, base::Unretained(this))); + base::BindRepeating(&NetErrorHelper::OnNetworkDiagnosticsClientRequest, + base::Unretained(this))); + render_frame->GetAssociatedInterfaceRegistry()->AddInterface( + base::BindRepeating(&NetErrorHelper::OnNavigationCorrectorRequest, + base::Unretained(this))); } NetErrorHelper::~NetErrorHelper() {
diff --git a/chrome/renderer/net/net_error_helper_core.cc b/chrome/renderer/net/net_error_helper_core.cc index f9968ca..31bf15a 100644 --- a/chrome/renderer/net/net_error_helper_core.cc +++ b/chrome/renderer/net/net_error_helper_core.cc
@@ -901,8 +901,8 @@ auto_reload_timer_->Stop(); auto_reload_timer_->Start( FROM_HERE, delay, - base::Bind(&NetErrorHelperCore::AutoReloadTimerFired, - base::Unretained(this))); + base::BindOnce(&NetErrorHelperCore::AutoReloadTimerFired, + base::Unretained(this))); } void NetErrorHelperCore::AutoReloadTimerFired() {
diff --git a/chrome/renderer/sandbox_status_extension_android.cc b/chrome/renderer/sandbox_status_extension_android.cc index 012d373..38db18f 100644 --- a/chrome/renderer/sandbox_status_extension_android.cc +++ b/chrome/renderer/sandbox_status_extension_android.cc
@@ -31,9 +31,9 @@ // Don't do anything else for subframes. if (!frame->IsMainFrame()) return; - frame->GetAssociatedInterfaceRegistry()->AddInterface( - base::Bind(&SandboxStatusExtension::OnSandboxStatusExtensionRequest, - base::RetainedRef(this))); + frame->GetAssociatedInterfaceRegistry()->AddInterface(base::BindRepeating( + &SandboxStatusExtension::OnSandboxStatusExtensionRequest, + base::RetainedRef(this))); } SandboxStatusExtension::~SandboxStatusExtension() {} @@ -81,7 +81,8 @@ v8::Local<v8::Function> function; bool success = gin::CreateFunctionTemplate( - isolate, base::Bind(&SandboxStatusExtension::GetSandboxStatus, this)) + isolate, + base::BindRepeating(&SandboxStatusExtension::GetSandboxStatus, this)) ->GetFunction(context) .ToLocal(&function); if (success) {
diff --git a/chrome/renderer/v8_unwinder_unittest.cc b/chrome/renderer/v8_unwinder_unittest.cc index 568542e..64490cbc 100644 --- a/chrome/renderer/v8_unwinder_unittest.cc +++ b/chrome/renderer/v8_unwinder_unittest.cc
@@ -12,6 +12,7 @@ #include "base/bind.h" #include "base/callback.h" #include "base/location.h" +#include "base/profiler/module_cache.h" #include "base/profiler/stack_sampling_profiler_test_util.h" #include "base/stl_util.h" #include "base/synchronization/waitable_event.h" @@ -24,6 +25,22 @@ namespace { +class TestModule : public base::ModuleCache::Module { + public: + TestModule(uintptr_t base_address, size_t size) + : base_address_(base_address), size_(size) {} + + uintptr_t GetBaseAddress() const override { return base_address_; } + std::string GetId() const override { return ""; } + base::FilePath GetDebugBasename() const override { return base::FilePath(); } + size_t GetSize() const override { return size_; } + bool IsNative() const override { return true; } + + private: + const uintptr_t base_address_; + const size_t size_; +}; + v8::Local<v8::String> ToV8String(const char* str) { return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str, v8::NewStringType::kNormal) @@ -399,13 +416,11 @@ unwinder.OnStackCapture(); unwinder.UpdateModules(&module_cache); - const uintptr_t address_in_this_module = - reinterpret_cast<uintptr_t>(&CreatePointerHolder); - const base::ModuleCache::Module* module = - module_cache.GetModuleForAddress(address_in_this_module); - ASSERT_NE(nullptr, module); + auto other_module = std::make_unique<TestModule>(1, 10); + const base::ModuleCache::Module* other_module_ptr = other_module.get(); + module_cache.AddCustomNativeModule(std::move(other_module)); - base::Frame frame{1, module}; + base::Frame frame{1, other_module_ptr}; EXPECT_FALSE(unwinder.CanUnwindFrom(&frame)); }
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index 7f5f909..a8a08cf 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -3653,7 +3653,7 @@ "//chrome/browser/media/router:unittests", "//chrome/browser/notifications:unit_tests", "//chrome/browser/payments:unittests", - "//chrome/browser/upboarding/query_tiles:unit_tests", + "//chrome/browser/upboarding:unit_tests", "//chrome/browser/updates/announcement_notification:unit_tests", "//chrome/common:test_support", "//chrome/common/media_router:test_support",
diff --git a/chrome/test/android/test_support/src/org/chromium/chrome/test_support/PaymentRequestTestBridge.java b/chrome/test/android/test_support/src/org/chromium/chrome/test_support/PaymentRequestTestBridge.java index a70218f..5dfaf86 100644 --- a/chrome/test/android/test_support/src/org/chromium/chrome/test_support/PaymentRequestTestBridge.java +++ b/chrome/test/android/test_support/src/org/chromium/chrome/test_support/PaymentRequestTestBridge.java
@@ -202,8 +202,10 @@ @CalledByNative @VisibleForTesting(otherwise = VisibleForTesting.NONE) - public static boolean isAndroidMarshmallowForTest() { - return Build.VERSION.SDK_INT == Build.VERSION_CODES.M; + public static boolean isAndroidMarshmallowOrLollipopForTest() { + return Build.VERSION.SDK_INT == Build.VERSION_CODES.M + || Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP + || Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP_MR1; } /**
diff --git a/chrome/test/chromedriver/capabilities.cc b/chrome/test/chromedriver/capabilities.cc index 1ae72ff..9635bff 100644 --- a/chrome/test/chromedriver/capabilities.cc +++ b/chrome/test/chromedriver/capabilities.cc
@@ -31,7 +31,8 @@ namespace { -typedef base::Callback<Status(const base::Value&, Capabilities*)> Parser; +typedef base::RepeatingCallback<Status(const base::Value&, Capabilities*)> + Parser; Status ParseBoolean( bool* to_set, @@ -466,13 +467,14 @@ return Status(kInvalidArgument, "must be a dictionary"); std::map<std::string, Parser> parser_map; - parser_map["bufferUsageReportingInterval"] = base::Bind(&ParseInterval, + parser_map["bufferUsageReportingInterval"] = base::BindRepeating( + &ParseInterval, &capabilities->perf_logging_prefs.buffer_usage_reporting_interval); - parser_map["enableNetwork"] = base::Bind( + parser_map["enableNetwork"] = base::BindRepeating( &ParseInspectorDomainStatus, &capabilities->perf_logging_prefs.network); - parser_map["enablePage"] = base::Bind( + parser_map["enablePage"] = base::BindRepeating( &ParseInspectorDomainStatus, &capabilities->perf_logging_prefs.page); - parser_map["traceCategories"] = base::Bind( + parser_map["traceCategories"] = base::BindRepeating( &ParseString, &capabilities->perf_logging_prefs.trace_categories); for (base::DictionaryValue::Iterator it(*perf_logging_prefs); !it.IsAtEnd(); @@ -532,60 +534,64 @@ std::map<std::string, Parser> parser_map; // Ignore 'args', 'binary' and 'extensions' capabilities by default, since the // Java client always passes them. - parser_map["args"] = base::Bind(&IgnoreCapability); - parser_map["binary"] = base::Bind(&IgnoreCapability); - parser_map["extensions"] = base::Bind(&IgnoreCapability); + parser_map["args"] = base::BindRepeating(&IgnoreCapability); + parser_map["binary"] = base::BindRepeating(&IgnoreCapability); + parser_map["extensions"] = base::BindRepeating(&IgnoreCapability); - parser_map["perfLoggingPrefs"] = base::Bind(&ParsePerfLoggingPrefs); - parser_map["devToolsEventsToLog"] = base::Bind( - &ParseDevToolsEventsLoggingPrefs); - parser_map["windowTypes"] = base::Bind(&ParseWindowTypes); + parser_map["perfLoggingPrefs"] = base::BindRepeating(&ParsePerfLoggingPrefs); + parser_map["devToolsEventsToLog"] = + base::BindRepeating(&ParseDevToolsEventsLoggingPrefs); + parser_map["windowTypes"] = base::BindRepeating(&ParseWindowTypes); // Compliance is read when session is initialized and correct response is // sent if not parsed correctly. - parser_map["w3c"] = base::Bind(&IgnoreCapability); + parser_map["w3c"] = base::BindRepeating(&IgnoreCapability); parser_map["useUnsupportedLaunchAppDeprecationWorkaround"] = base::BindRepeating(&ParseBoolean, &capabilities->enable_launch_app); if (is_android) { parser_map["androidActivity"] = - base::Bind(&ParseString, &capabilities->android_activity); + base::BindRepeating(&ParseString, &capabilities->android_activity); parser_map["androidDeviceSerial"] = - base::Bind(&ParseString, &capabilities->android_device_serial); + base::BindRepeating(&ParseString, &capabilities->android_device_serial); parser_map["androidPackage"] = - base::Bind(&ParseString, &capabilities->android_package); + base::BindRepeating(&ParseString, &capabilities->android_package); parser_map["androidProcess"] = - base::Bind(&ParseString, &capabilities->android_process); + base::BindRepeating(&ParseString, &capabilities->android_process); parser_map["androidExecName"] = base::BindRepeating(&ParseString, &capabilities->android_exec_name); parser_map["androidDeviceSocket"] = base::BindRepeating(&ParseString, &capabilities->android_device_socket); - parser_map["androidUseRunningApp"] = - base::Bind(&ParseBoolean, &capabilities->android_use_running_app); - parser_map["args"] = base::Bind(&ParseSwitches); - parser_map["excludeSwitches"] = base::Bind(&ParseExcludeSwitches); - parser_map["loadAsync"] = base::Bind(&IgnoreDeprecatedOption, "loadAsync"); + parser_map["androidUseRunningApp"] = base::BindRepeating( + &ParseBoolean, &capabilities->android_use_running_app); + parser_map["args"] = base::BindRepeating(&ParseSwitches); + parser_map["excludeSwitches"] = base::BindRepeating(&ParseExcludeSwitches); + parser_map["loadAsync"] = + base::BindRepeating(&IgnoreDeprecatedOption, "loadAsync"); } else if (is_remote) { parser_map["debuggerAddress"] = - base::Bind(&ParseNetAddress, &capabilities->debugger_address); + base::BindRepeating(&ParseNetAddress, &capabilities->debugger_address); } else { - parser_map["args"] = base::Bind(&ParseSwitches); - parser_map["binary"] = base::Bind(&ParseFilePath, &capabilities->binary); - parser_map["detach"] = base::Bind(&ParseBoolean, &capabilities->detach); - parser_map["excludeSwitches"] = base::Bind(&ParseExcludeSwitches); - parser_map["extensions"] = base::Bind(&ParseExtensions); - parser_map["extensionLoadTimeout"] = - base::Bind(&ParseTimeDelta, &capabilities->extension_load_timeout); - parser_map["loadAsync"] = base::Bind(&IgnoreDeprecatedOption, "loadAsync"); + parser_map["args"] = base::BindRepeating(&ParseSwitches); + parser_map["binary"] = + base::BindRepeating(&ParseFilePath, &capabilities->binary); + parser_map["detach"] = + base::BindRepeating(&ParseBoolean, &capabilities->detach); + parser_map["excludeSwitches"] = base::BindRepeating(&ParseExcludeSwitches); + parser_map["extensions"] = base::BindRepeating(&ParseExtensions); + parser_map["extensionLoadTimeout"] = base::BindRepeating( + &ParseTimeDelta, &capabilities->extension_load_timeout); + parser_map["loadAsync"] = + base::BindRepeating(&IgnoreDeprecatedOption, "loadAsync"); parser_map["localState"] = - base::Bind(&ParseDict, &capabilities->local_state); - parser_map["logPath"] = base::Bind(&ParseLogPath); + base::BindRepeating(&ParseDict, &capabilities->local_state); + parser_map["logPath"] = base::BindRepeating(&ParseLogPath); parser_map["minidumpPath"] = - base::Bind(&ParseString, &capabilities->minidump_path); - parser_map["mobileEmulation"] = base::Bind(&ParseMobileEmulation); - parser_map["prefs"] = base::Bind(&ParseDict, &capabilities->prefs); - parser_map["useAutomationExtension"] = - base::Bind(&ParseBoolean, &capabilities->use_automation_extension); + base::BindRepeating(&ParseString, &capabilities->minidump_path); + parser_map["mobileEmulation"] = base::BindRepeating(&ParseMobileEmulation); + parser_map["prefs"] = base::BindRepeating(&ParseDict, &capabilities->prefs); + parser_map["useAutomationExtension"] = base::BindRepeating( + &ParseBoolean, &capabilities->use_automation_extension); } for (base::DictionaryValue::Iterator it(*chrome_options); !it.IsAtEnd(); @@ -611,7 +617,7 @@ if (!capability.GetAsDictionary(&selenium_options)) return Status(kInvalidArgument, "must be a dictionary"); std::map<std::string, Parser> parser_map; - parser_map["loggingPrefs"] = base::Bind(&ParseLoggingPrefs); + parser_map["loggingPrefs"] = base::BindRepeating(&ParseLoggingPrefs); for (base::DictionaryValue::Iterator it(*selenium_options); !it.IsAtEnd(); it.Advance()) {
diff --git a/chrome/test/chromedriver/chrome/chrome_finder.cc b/chrome/test/chromedriver/chrome/chrome_finder.cc index 9b8ab311..3c0dea3 100644 --- a/chrome/test/chromedriver/chrome/chrome_finder.cc +++ b/chrome/test/chromedriver/chrome/chrome_finder.cc
@@ -109,13 +109,13 @@ namespace internal { bool FindExe( - const base::Callback<bool(const base::FilePath&)>& exists_func, + const base::RepeatingCallback<bool(const base::FilePath&)>& exists_func, const std::vector<base::FilePath>& rel_paths, const std::vector<base::FilePath>& locations, base::FilePath* out_path) { - for (size_t i = 0; i < rel_paths.size(); ++i) { - for (size_t j = 0; j < locations.size(); ++j) { - base::FilePath path = locations[j].Append(rel_paths[i]); + for (auto& rel_path : rel_paths) { + for (auto& location : locations) { + base::FilePath path = location.Append(rel_path); if (exists_func.Run(path)) { *out_path = path; return true; @@ -164,9 +164,6 @@ std::vector<base::FilePath> locations; GetApplicationDirs(&locations); GetPathsFromEnvironment(&locations); - return internal::FindExe( - base::Bind(&base::PathExists), - browser_exes, - locations, - browser_exe); + return internal::FindExe(base::BindRepeating(&base::PathExists), browser_exes, + locations, browser_exe); }
diff --git a/chrome/test/chromedriver/chrome/chrome_finder.h b/chrome/test/chromedriver/chrome/chrome_finder.h index c68186a8..7188fa5 100644 --- a/chrome/test/chromedriver/chrome/chrome_finder.h +++ b/chrome/test/chromedriver/chrome/chrome_finder.h
@@ -19,7 +19,7 @@ namespace internal { bool FindExe( - const base::Callback<bool(const base::FilePath&)>& exists_func, + const base::RepeatingCallback<bool(const base::FilePath&)>& exists_func, const std::vector<base::FilePath>& rel_paths, const std::vector<base::FilePath>& locations, base::FilePath* out_path);
diff --git a/chrome/test/chromedriver/chrome/chrome_finder_unittest.cc b/chrome/test/chromedriver/chrome/chrome_finder_unittest.cc index d26a228..c9e83a2 100644 --- a/chrome/test/chromedriver/chrome/chrome_finder_unittest.cc +++ b/chrome/test/chromedriver/chrome/chrome_finder_unittest.cc
@@ -29,11 +29,8 @@ const std::vector<base::FilePath>& rel_paths, const std::vector<base::FilePath>& locations) { base::FilePath exe; - ASSERT_TRUE(internal::FindExe( - base::Bind(&PathIn, existing_paths), - rel_paths, - locations, - &exe)); + ASSERT_TRUE(internal::FindExe(base::BindRepeating(&PathIn, existing_paths), + rel_paths, locations, &exe)); ASSERT_EQ(found, exe); } @@ -95,11 +92,8 @@ std::vector<base::FilePath> locations; locations.push_back(found.DirName()); base::FilePath exe; - ASSERT_FALSE(internal::FindExe( - base::Bind(&PathIn, existing_paths), - rel_paths, - locations, - &exe)); + ASSERT_FALSE(internal::FindExe(base::BindRepeating(&PathIn, existing_paths), + rel_paths, locations, &exe)); } TEST(ChromeFinderTest, NoCrash) {
diff --git a/chrome/test/chromedriver/chrome/device_manager.cc b/chrome/test/chromedriver/chrome/device_manager.cc index e0a1454..411c503 100644 --- a/chrome/test/chromedriver/chrome/device_manager.cc +++ b/chrome/test/chromedriver/chrome/device_manager.cc
@@ -80,6 +80,13 @@ command_line_file = base::StringPrintf("/data/local/tmp/%s_devtools_remote", exec_name.c_str()); use_debug_flag = true; + } else if (package.find("webview") != std::string::npos) { + command_line_file = "/data/local/tmp/webview-command-line"; + // This name isn't really important, what is important is that it's + // non-empty. If empty, it means webview treats the the first value of + // |args| as the executable name, and not an argument (in other words, + // args[0] is effectively ignored as a command line switch). + known_exec_name = "webview"; } else if (package.find("weblayer") != std::string::npos) { command_line_file = "/data/local/tmp/weblayer-command-line"; // This name isn't really important, what is important is that it's
diff --git a/chrome/test/chromedriver/chrome/devtools_client.h b/chrome/test/chromedriver/chrome/devtools_client.h index a7eb32e..493aeb7 100644 --- a/chrome/test/chromedriver/chrome/devtools_client.h +++ b/chrome/test/chromedriver/chrome/devtools_client.h
@@ -22,9 +22,10 @@ // A DevTools client of a single DevTools debugger. class DevToolsClient { public: - typedef base::Callback<Status(bool* is_condition_met)> ConditionalFunc; + typedef base::RepeatingCallback<Status(bool* is_condition_met)> + ConditionalFunc; - virtual ~DevToolsClient() {} + virtual ~DevToolsClient() = default; virtual const std::string& GetId() = 0;
diff --git a/chrome/test/chromedriver/chrome/devtools_client_impl.cc b/chrome/test/chromedriver/chrome/devtools_client_impl.cc index db08e5e8..49df1f3 100644 --- a/chrome/test/chromedriver/chrome/devtools_client_impl.cc +++ b/chrome/test/chromedriver/chrome/devtools_client_impl.cc
@@ -281,7 +281,7 @@ } Status DevToolsClientImpl::HandleReceivedEvents() { - return HandleEventsUntil(base::Bind(&ConditionIsMet), + return HandleEventsUntil(base::BindRepeating(&ConditionIsMet), Timeout(base::TimeDelta())); }
diff --git a/chrome/test/chromedriver/chrome/devtools_client_impl_unittest.cc b/chrome/test/chromedriver/chrome/devtools_client_impl_unittest.cc index 793bd07..c7d9e3b 100644 --- a/chrome/test/chromedriver/chrome/devtools_client_impl_unittest.cc +++ b/chrome/test/chromedriver/chrome/devtools_client_impl_unittest.cc
@@ -690,7 +690,7 @@ client.AddListener(&listener); ASSERT_EQ(kOk, client.ConnectIfNecessary().code()); client.SetParserFuncForTesting(base::Bind(&ReturnEvent)); - Status status = client.HandleEventsUntil(base::Bind(&AlwaysTrue), + Status status = client.HandleEventsUntil(base::BindRepeating(&AlwaysTrue), Timeout(long_timeout_)); ASSERT_EQ(kOk, status.code()); } @@ -702,7 +702,7 @@ base::Bind(&CloserFunc)); ASSERT_EQ(kOk, client.ConnectIfNecessary().code()); client.SetParserFuncForTesting(base::Bind(&ReturnEvent)); - Status status = client.HandleEventsUntil(base::Bind(&AlwaysTrue), + Status status = client.HandleEventsUntil(base::BindRepeating(&AlwaysTrue), Timeout(base::TimeDelta())); ASSERT_EQ(kTimeout, status.code()); } @@ -714,7 +714,7 @@ base::Bind(&CloserFunc), base::Bind(&ReturnCommand)); ASSERT_EQ(kOk, client.ConnectIfNecessary().code()); - Status status = client.HandleEventsUntil(base::Bind(&AlwaysTrue), + Status status = client.HandleEventsUntil(base::BindRepeating(&AlwaysTrue), Timeout(long_timeout_)); ASSERT_EQ(kUnknownError, status.code()); } @@ -726,7 +726,7 @@ base::Bind(&CloserFunc)); ASSERT_EQ(kOk, client.ConnectIfNecessary().code()); client.SetParserFuncForTesting(base::Bind(&ReturnError)); - Status status = client.HandleEventsUntil(base::Bind(&AlwaysTrue), + Status status = client.HandleEventsUntil(base::BindRepeating(&AlwaysTrue), Timeout(long_timeout_)); ASSERT_EQ(kUnknownError, status.code()); } @@ -738,7 +738,7 @@ base::Bind(&CloserFunc)); ASSERT_EQ(kOk, client.ConnectIfNecessary().code()); client.SetParserFuncForTesting(base::Bind(&ReturnEvent)); - Status status = client.HandleEventsUntil(base::Bind(&AlwaysError), + Status status = client.HandleEventsUntil(base::BindRepeating(&AlwaysError), Timeout(long_timeout_)); ASSERT_EQ(kUnknownError, status.code()); }
diff --git a/chrome/test/chromedriver/chrome/web_view_impl.cc b/chrome/test/chromedriver/chrome/web_view_impl.cc index 1b7ce01..a31cb6c4 100644 --- a/chrome/test/chromedriver/chrome/web_view_impl.cc +++ b/chrome/test/chromedriver/chrome/web_view_impl.cc
@@ -775,9 +775,9 @@ return Status(kUnsupportedOperation, "Call WaitForPendingNavigations only on the parent WebView"); VLOG(0) << "Waiting for pending navigations..."; - const auto not_pending_navigation = - base::Bind(&WebViewImpl::IsNotPendingNavigation, base::Unretained(this), - frame_id, base::Unretained(&timeout)); + const auto not_pending_navigation = base::BindRepeating( + &WebViewImpl::IsNotPendingNavigation, base::Unretained(this), frame_id, + base::Unretained(&timeout)); Status status = client_->HandleEventsUntil(not_pending_navigation, timeout); if (status.code() == kTimeout && stop_load_on_timeout) { VLOG(0) << "Timed out. Stopping navigation...";
diff --git a/chrome/test/chromedriver/performance_logger.cc b/chrome/test/chromedriver/performance_logger.cc index 21700573..a038436 100644 --- a/chrome/test/chromedriver/performance_logger.cc +++ b/chrome/test/chromedriver/performance_logger.cc
@@ -261,7 +261,8 @@ // Block up to 30 seconds until Tracing.tracingComplete event is received. status = browser_client_->HandleEventsUntil( - base::Bind(&PerformanceLogger::IsTraceDone, base::Unretained(this)), + base::BindRepeating(&PerformanceLogger::IsTraceDone, + base::Unretained(this)), Timeout(base::TimeDelta::FromSeconds(30))); if (status.IsError()) return status;
diff --git a/chrome/test/chromedriver/window_commands.cc b/chrome/test/chromedriver/window_commands.cc index 273f43a3..56fa70d 100644 --- a/chrome/test/chromedriver/window_commands.cc +++ b/chrome/test/chromedriver/window_commands.cc
@@ -208,7 +208,7 @@ const std::string& domain, const std::string& path, const std::string& samesite, - double expiry, + int64_t expiry, bool http_only, bool secure, bool session) @@ -227,7 +227,7 @@ std::string domain; std::string path; std::string samesite; - double expiry; + int64_t expiry; bool http_only; bool secure; bool session; @@ -243,7 +243,7 @@ if (!cookie.path.empty()) dict->SetString("path", cookie.path); if (!cookie.session) - dict->SetDouble("expiry", cookie.expiry); + SetSafeInt(dict.get(), "expiry", cookie.expiry); dict->SetBoolean("httpOnly", cookie.http_only); dict->SetBoolean("secure", cookie.secure); if (!cookie.samesite.empty()) @@ -279,10 +279,14 @@ cookie_dict->GetString("path", &path); std::string samesite = ""; GetOptionalString(cookie_dict, "sameSite", &samesite); - double expiry = 0; - cookie_dict->GetDouble("expires", &expiry); - if (expiry > 1e12) - expiry /= 1000; // Backwards compatibility ms -> sec. + int64_t expiry = 0; + double temp_double; + if (cookie_dict->GetDouble("expires", &temp_double)) { + // Truncate & convert the value to an integer as required by W3C spec. + int64_t temp_int64 = static_cast<int64_t>(temp_double); + if (!(temp_int64 >= (1ll << 53) || temp_int64 <= -(1ll << 53))) + expiry = temp_int64; + } bool http_only = false; cookie_dict->GetBoolean("httpOnly", &http_only); bool session = false;
diff --git a/chrome/test/data/extensions/api_test/developer/generated_output/behllobkkfkfnphdnhnkndlbkcpglgmj.json b/chrome/test/data/extensions/api_test/developer/generated_output/behllobkkfkfnphdnhnkndlbkcpglgmj.json index b15256a..de0f3f99 100644 --- a/chrome/test/data/extensions/api_test/developer/generated_output/behllobkkfkfnphdnhnkndlbkcpglgmj.json +++ b/chrome/test/data/extensions/api_test/developer/generated_output/behllobkkfkfnphdnhnkndlbkcpglgmj.json
@@ -3,7 +3,6 @@ "description": "The first extension that I made.", "disableReasons": { "blockedByPolicy": false, - "blockedMature": false, "corruptInstall": false, "custodianApprovalRequired": false, "suspiciousInstall": false,
diff --git a/chrome/test/data/extensions/api_test/developer/generated_output/bjafgdebaacbbbecmhlhpofkepfkgcpa.json b/chrome/test/data/extensions/api_test/developer/generated_output/bjafgdebaacbbbecmhlhpofkepfkgcpa.json index 0dc7d98..72544aa 100644 --- a/chrome/test/data/extensions/api_test/developer/generated_output/bjafgdebaacbbbecmhlhpofkepfkgcpa.json +++ b/chrome/test/data/extensions/api_test/developer/generated_output/bjafgdebaacbbbecmhlhpofkepfkgcpa.json
@@ -3,7 +3,6 @@ "description": "", "disableReasons": { "blockedByPolicy": false, - "blockedMature": false, "corruptInstall": false, "custodianApprovalRequired": false, "suspiciousInstall": false,
diff --git a/chrome/test/data/extensions/api_test/developer/generated_output/hpiknbiabeeppbpihjehijgoemciehgk.json b/chrome/test/data/extensions/api_test/developer/generated_output/hpiknbiabeeppbpihjehijgoemciehgk.json index d599b716..560fc5b 100644 --- a/chrome/test/data/extensions/api_test/developer/generated_output/hpiknbiabeeppbpihjehijgoemciehgk.json +++ b/chrome/test/data/extensions/api_test/developer/generated_output/hpiknbiabeeppbpihjehijgoemciehgk.json
@@ -3,7 +3,6 @@ "description": "", "disableReasons": { "blockedByPolicy": false, - "blockedMature": false, "corruptInstall": false, "custodianApprovalRequired": false, "suspiciousInstall": false,
diff --git a/chrome/test/data/policy/policy_test_cases.json b/chrome/test/data/policy/policy_test_cases.json index 47d6f06a..38fb719 100644 --- a/chrome/test/data/policy/policy_test_cases.json +++ b/chrome/test/data/policy/policy_test_cases.json
@@ -6300,7 +6300,8 @@ "name": "Certificate Profile 1", "cert_profile_id":"cert_profile_id_1", "key_algorithm":"rsa", - "renewal_period_seconds": 2592000 + "renewal_period_seconds": 2592000, + "policy_version": "some_hash" }] }, "prefs": { @@ -6309,7 +6310,8 @@ "name": "Certificate Profile 1", "cert_profile_id":"cert_profile_id_1", "key_algorithm":"rsa", - "renewal_period_seconds": 2592000 + "renewal_period_seconds": 2592000, + "policy_version": "some_hash" }] } } @@ -6325,7 +6327,8 @@ "name": "Certificate Profile 1", "cert_profile_id":"cert_profile_id_1", "key_algorithm":"rsa", - "renewal_period_seconds": 2592000 + "renewal_period_seconds": 2592000, + "policy_version": "some_hash" }] }, "prefs": { @@ -6334,7 +6337,8 @@ "name": "Certificate Profile 1", "cert_profile_id":"cert_profile_id_1", "key_algorithm":"rsa", - "renewal_period_seconds": 2592000 + "renewal_period_seconds": 2592000, + "policy_version": "some_hash" }], "local_state": true }
diff --git a/chrome/test/data/webui/BUILD.gn b/chrome/test/data/webui/BUILD.gn index 37557ba71..f3f14ca 100644 --- a/chrome/test/data/webui/BUILD.gn +++ b/chrome/test/data/webui/BUILD.gn
@@ -252,7 +252,10 @@ "$root_gen_dir/chrome/test/data/webui/settings/site_favicon_test.m.js", "$root_gen_dir/chrome/test/data/webui/settings/startup_urls_page_test.m.js", "$root_gen_dir/chrome/test/data/webui/settings/test_about_page_browser_proxy.m.js", + "$root_gen_dir/chrome/test/data/webui/settings/test_local_data_browser_proxy.m.js", "$root_gen_dir/chrome/test/data/webui/settings/test_metrics_browser_proxy.m.js", + "$root_gen_dir/chrome/test/data/webui/settings/site_data_details_subpage_tests.m.js", + "$root_gen_dir/chrome/test/data/webui/settings/site_list_entry_tests.m.js", "$root_gen_dir/chrome/test/data/webui/settings/sync_test_util.m.js", "$root_gen_dir/chrome/test/data/webui/settings/test_extension_control_browser_proxy.m.js", "$root_gen_dir/chrome/test/data/webui/settings/test_languages_browser_proxy.m.js", @@ -261,6 +264,7 @@ "$root_gen_dir/chrome/test/data/webui/settings/test_password_manager_proxy.m.js", "$root_gen_dir/chrome/test/data/webui/settings/test_reset_browser_proxy.m.js", "$root_gen_dir/chrome/test/data/webui/settings/test_search_engines_browser_proxy.m.js", + "$root_gen_dir/chrome/test/data/webui/settings/test_site_settings_prefs_browser_proxy.m.js", "$root_gen_dir/chrome/test/data/webui/settings/test_sync_browser_proxy.m.js", "$root_gen_dir/chrome/test/data/webui/settings/test_util.m.js", "$root_gen_dir/chrome/test/data/webui/test_browser_proxy.m.js",
diff --git a/chrome/test/data/webui/extensions/detail_view_test.js b/chrome/test/data/webui/extensions/detail_view_test.js index 3d0f284..ebe174d18 100644 --- a/chrome/test/data/webui/extensions/detail_view_test.js +++ b/chrome/test/data/webui/extensions/detail_view_test.js
@@ -64,7 +64,6 @@ expectTrue(testIsVisible('#closeButton')); expectTrue(testIsVisible('#icon')); expectTrue(testIsVisible('#enableToggle')); - expectFalse(testIsVisible('#blockedMatureToolTip')); expectFalse(testIsVisible('#extensions-options')); expectTrue( item.$.description.textContent.indexOf('This is an extension') !== -1); @@ -186,14 +185,6 @@ item.set('data.disableReasons.blockedByPolicy', false); flush(); - item.set('data.disableReasons.blockedMature', true); - flush(); - expectTrue(testIsVisible('#enableToggle')); - expectTrue(item.$$('#enableToggle').disabled); - expectTrue(testIsVisible('#blockedMatureToolTip')); - item.set('data.disableReasons.blockedMature', false); - flush(); - item.set('data.disableReasons.custodianApprovalRequired', true); flush(); expectTrue(testIsVisible('#enableToggle'));
diff --git a/chrome/test/data/webui/extensions/item_test.js b/chrome/test/data/webui/extensions/item_test.js index eb904045..5579f53 100644 --- a/chrome/test/data/webui/extensions/item_test.js +++ b/chrome/test/data/webui/extensions/item_test.js
@@ -356,15 +356,6 @@ item.set('data.disableReasons.blockedByPolicy', false); flush(); - testVisible(item, '#blockedMatureToolTip', false); - item.set('data.disableReasons.blockedMature', true); - flush(); - testVisible(item, '#enableToggle', true); - expectTrue(item.$['enableToggle'].disabled); - testVisible(item, '#blockedMatureToolTip', true); - item.set('data.disableReasons.blockedMature', false); - flush(); - item.set('data.disableReasons.custodianApprovalRequired', true); flush(); testVisible(item, '#enableToggle', true);
diff --git a/chrome/test/data/webui/extensions/test_util.js b/chrome/test/data/webui/extensions/test_util.js index ac93848d..d324d89 100644 --- a/chrome/test/data/webui/extensions/test_util.js +++ b/chrome/test/data/webui/extensions/test_util.js
@@ -181,7 +181,6 @@ updateRequired: false, blockedByPolicy: false, custodianApprovalRequired: false, - blockedMature: false, }, homePage: {specified: false, url: ''}, iconUrl: 'chrome://extension-icon/' + id + '/24/0',
diff --git a/chrome/test/data/webui/settings/BUILD.gn b/chrome/test/data/webui/settings/BUILD.gn index 66e11566..8fba081 100644 --- a/chrome/test/data/webui/settings/BUILD.gn +++ b/chrome/test/data/webui/settings/BUILD.gn
@@ -49,6 +49,8 @@ "settings_textarea_tests.js", "settings_toggle_button_tests.js", "settings_ui_tests.js", + "site_data_details_subpage_tests.js", + "site_list_entry_tests.js", "site_favicon_test.js", "startup_urls_page_test.js", "sync_test_util.js", @@ -56,11 +58,13 @@ "test_extension_control_browser_proxy.js", "test_languages_browser_proxy.js", "test_lifetime_browser_proxy.js", + "test_local_data_browser_proxy.js", "test_metrics_browser_proxy.js", "test_open_window_proxy.js", "test_password_manager_proxy.js", "test_reset_browser_proxy.js", "test_search_engines_browser_proxy.js", + "test_site_settings_prefs_browser_proxy.js", "test_sync_browser_proxy.js", "test_util.js", ] @@ -106,6 +110,7 @@ "settings_search.TestSearchEnginesBrowserProxy|TestSearchEnginesBrowserProxy", "sync_test_util.getSyncAllPrefs|getSyncAllPrefs", "sync_test_util.simulateSyncStatus|simulateSyncStatus", + "test_util.createSiteSettingsPrefs|createSiteSettingsPrefs", "test_util.setupPopstateListener|setupPopstateListener", ] }
diff --git a/chrome/test/data/webui/settings/appearance_fonts_page_test.js b/chrome/test/data/webui/settings/appearance_fonts_page_test.js index 7e8b849a..8330728 100644 --- a/chrome/test/data/webui/settings/appearance_fonts_page_test.js +++ b/chrome/test/data/webui/settings/appearance_fonts_page_test.js
@@ -3,7 +3,8 @@ // found in the LICENSE file. // clang-format off -// #import {FontsBrowserProxy, FontsBrowserProxyImpl} from 'chrome://settings/settings.js'; +// #import 'chrome://settings/settings.js'; +// #import {FontsBrowserProxy, FontsBrowserProxyImpl} from 'chrome://settings/lazy_load.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; // #import {TestBrowserProxy} from 'chrome://test/test_browser_proxy.m.js'; // clang-format on
diff --git a/chrome/test/data/webui/settings/autofill_page_test.js b/chrome/test/data/webui/settings/autofill_page_test.js index cd4f5b2..db5e7bec 100644 --- a/chrome/test/data/webui/settings/autofill_page_test.js +++ b/chrome/test/data/webui/settings/autofill_page_test.js
@@ -3,7 +3,8 @@ // found in the LICENSE file. // clang-format off -// #import {AutofillManagerImpl, CrSettingsPrefs, OpenWindowProxyImpl, PasswordManagerImpl, PaymentsManagerImpl, Router, routes} from 'chrome://settings/settings.js'; +// #import {CrSettingsPrefs, OpenWindowProxyImpl, PasswordManagerImpl, Router, routes} from 'chrome://settings/settings.js'; +// #import {AutofillManagerImpl, PaymentsManagerImpl} from 'chrome://settings/lazy_load.js'; // #import {createAddressEntry, createCreditCardEntry, createExceptionEntry, createPasswordEntry, AutofillManagerExpectations, PasswordManagerExpectations, PaymentsManagerExpectations, TestAutofillManager, TestPaymentsManager} from 'chrome://test/settings/passwords_and_autofill_fake_data.m.js'; // #import {FakeSettingsPrivate} from 'chrome://test/settings/fake_settings_private.m.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
diff --git a/chrome/test/data/webui/settings/autofill_section_test.js b/chrome/test/data/webui/settings/autofill_section_test.js index 267297ba..4d0f7d1c1 100644 --- a/chrome/test/data/webui/settings/autofill_section_test.js +++ b/chrome/test/data/webui/settings/autofill_section_test.js
@@ -3,7 +3,8 @@ // found in the LICENSE file. // clang-format off -// #import {AutofillManagerImpl, CountryDetailManagerImpl} from 'chrome://settings/settings.js'; +// #import 'chrome://settings/settings.js'; +// #import {AutofillManagerImpl, CountryDetailManagerImpl} from 'chrome://settings/lazy_load.js'; // #import {createAddressEntry, createEmptyAddressEntry, TestAutofillManager} from 'chrome://test/settings/passwords_and_autofill_fake_data.m.js'; // #import {eventToPromise} from 'chrome://test/test_util.m.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
diff --git a/chrome/test/data/webui/settings/clear_browsing_data_test.js b/chrome/test/data/webui/settings/clear_browsing_data_test.js index f6001848c..3a9144e2 100644 --- a/chrome/test/data/webui/settings/clear_browsing_data_test.js +++ b/chrome/test/data/webui/settings/clear_browsing_data_test.js
@@ -3,7 +3,8 @@ // found in the LICENSE file. // clang-format off -// #import {ClearBrowsingDataBrowserProxyImpl, Router, routes, StatusAction, SyncBrowserProxyImpl} from 'chrome://settings/settings.js'; +// #import {Router, routes, StatusAction, SyncBrowserProxyImpl} from 'chrome://settings/settings.js'; +// #import {ClearBrowsingDataBrowserProxyImpl} from 'chrome://settings/lazy_load.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; // #import {isChromeOS} from 'chrome://resources/js/cr.m.js'; // #import {PromiseResolver} from 'chrome://resources/js/promise_resolver.m.js';
diff --git a/chrome/test/data/webui/settings/controlled_button_tests.js b/chrome/test/data/webui/settings/controlled_button_tests.js index 572fda3b..feca781 100644 --- a/chrome/test/data/webui/settings/controlled_button_tests.js +++ b/chrome/test/data/webui/settings/controlled_button_tests.js
@@ -3,7 +3,7 @@ // found in the LICENSE file. // clang-format off -// #import 'chrome://settings/settings.js'; +// #import 'chrome://settings/lazy_load.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; // clang-format on
diff --git a/chrome/test/data/webui/settings/cookies_page_test.js b/chrome/test/data/webui/settings/cookies_page_test.js index 5631e94..4d85bb3 100644 --- a/chrome/test/data/webui/settings/cookies_page_test.js +++ b/chrome/test/data/webui/settings/cookies_page_test.js
@@ -207,4 +207,79 @@ assertEquals( settings.PrivacyElementInteractions.NETWORK_PREDICTION, result); }); + + test('CookieSettingExceptions_Search', async function() { + exceptionPrefs = test_util.createSiteSettingsPrefs([], [ + test_util.createContentSettingTypeToValuePair( + settings.ContentSettingsTypes.COOKIES, + [ + test_util.createRawSiteException('http://foo-block.com', { + embeddingOrigin: '', + setting: settings.ContentSetting.BLOCK, + }), + test_util.createRawSiteException('http://foo-allow.com', { + embeddingOrigin: '', + }), + test_util.createRawSiteException('http://foo-session.com', { + embeddingOrigin: '', + setting: settings.ContentSetting.SESSION_ONLY, + }), + ]), + ]); + page.searchTerm = 'foo'; + siteSettingsBrowserProxy.setPrefs(exceptionPrefs); + await siteSettingsBrowserProxy.whenCalled('getExceptionList'); + Polymer.dom.flush(); + + const exceptionLists = page.shadowRoot.querySelectorAll('site-list'); + assertEquals(exceptionLists.length, 3); + + for (const list of exceptionLists) { + assertTrue(test_util.isChildVisible(list, 'site-list-entry')); + } + + page.searchTerm = 'unrelated.com'; + Polymer.dom.flush(); + + for (const list of exceptionLists) { + assertFalse(test_util.isChildVisible(list, 'site-list-entry')); + } + }); + + test('CookieSettingExceptions_Managed', async function() { + const managedPrefs = test_util.createSiteSettingsPrefs( + [test_util.createContentSettingTypeToValuePair( + settings.ContentSettingsTypes.COOKIES, + test_util.createDefaultContentSetting({ + setting: settings.ContentSetting.SESSION_ONLY, + source: settings.SiteSettingSource.POLICY + }))], + []); + siteSettingsBrowserProxy.setPrefs(managedPrefs); + await siteSettingsBrowserProxy.whenCalled('getDefaultValueForContentType'); + Polymer.dom.flush(); + + let exceptionLists = page.shadowRoot.querySelectorAll('site-list'); + assertEquals(exceptionLists.length, 3); + for (const list of exceptionLists) { + assertTrue(!!list.readOnlyList); + } + + const unmanagedPrefs = test_util.createSiteSettingsPrefs( + [test_util.createContentSettingTypeToValuePair( + settings.ContentSettingsTypes.COOKIES, + test_util.createDefaultContentSetting({ + setting: settings.ContentSetting.ALLOW, + }))], + []); + siteSettingsBrowserProxy.setPrefs(unmanagedPrefs); + await siteSettingsBrowserProxy.whenCalled('getDefaultValueForContentType'); + Polymer.dom.flush(); + + exceptionLists = page.shadowRoot.querySelectorAll('site-list'); + assertEquals(exceptionLists.length, 3); + for (const list of exceptionLists) { + assertFalse(!!list.readOnlyList); + } + }); });
diff --git a/chrome/test/data/webui/settings/cr_settings_browsertest.js b/chrome/test/data/webui/settings/cr_settings_browsertest.js index ea124aeb..71d3347 100644 --- a/chrome/test/data/webui/settings/cr_settings_browsertest.js +++ b/chrome/test/data/webui/settings/cr_settings_browsertest.js
@@ -395,7 +395,7 @@ ]), }; -TEST_F('CrSettingsPasswordsCheckTest', 'DISABLED_All', function() { +TEST_F('CrSettingsPasswordsCheckTest', 'All', function() { mocha.run(); });
diff --git a/chrome/test/data/webui/settings/cr_settings_v3_browsertest.js b/chrome/test/data/webui/settings/cr_settings_v3_browsertest.js index 86fc7e3..805c3c9 100644 --- a/chrome/test/data/webui/settings/cr_settings_v3_browsertest.js +++ b/chrome/test/data/webui/settings/cr_settings_v3_browsertest.js
@@ -621,3 +621,27 @@ TEST_F('CrSettingsPaymentsSectionV3Test', 'All', function() { mocha.run(); }); + +// eslint-disable-next-line no-var +var CrSettingsSiteDataDetailsV3Test = class extends CrSettingsV3BrowserTest { + /** @override */ + get browsePreload() { + return 'chrome://settings/test_loader.html?module=settings/site_data_details_subpage_tests.m.js'; + } +}; + +TEST_F('CrSettingsSiteDataDetailsV3Test', 'All', function() { + mocha.run(); +}); + +// eslint-disable-next-line no-var +var CrSettingsSiteListEntryV3Test = class extends CrSettingsV3BrowserTest { + /** @override */ + get browsePreload() { + return 'chrome://settings/test_loader.html?module=settings/site_list_entry_tests.m.js'; + } +}; + +TEST_F('CrSettingsSiteListEntryV3Test', 'All', function() { + mocha.run(); +});
diff --git a/chrome/test/data/webui/settings/downloads_page_test.js b/chrome/test/data/webui/settings/downloads_page_test.js index 7522cb7..06fcc15 100644 --- a/chrome/test/data/webui/settings/downloads_page_test.js +++ b/chrome/test/data/webui/settings/downloads_page_test.js
@@ -3,7 +3,8 @@ // found in the LICENSE file. // clang-format off -// #import {DownloadsBrowserProxyImpl} from 'chrome://settings/settings.js'; +// #import 'chrome://settings/settings.js'; +// #import {DownloadsBrowserProxyImpl} from 'chrome://settings/lazy_load.js'; // #import {isChromeOS} from 'chrome://resources/js/cr.m.js'; // #import {TestBrowserProxy} from 'chrome://test/test_browser_proxy.m.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
diff --git a/chrome/test/data/webui/settings/edit_dictionary_page_test.js b/chrome/test/data/webui/settings/edit_dictionary_page_test.js index 9c328bc1..fc371eb 100644 --- a/chrome/test/data/webui/settings/edit_dictionary_page_test.js +++ b/chrome/test/data/webui/settings/edit_dictionary_page_test.js
@@ -3,7 +3,8 @@ // found in the LICENSE file. // clang-format off -// #import {CrSettingsPrefs, LanguagesBrowserProxyImpl} from 'chrome://settings/settings.js'; +// #import {CrSettingsPrefs} from 'chrome://settings/settings.js'; +// #import {LanguagesBrowserProxyImpl} from 'chrome://settings/lazy_load.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; // #import {isChromeOS, isWindows} from 'chrome://resources/js/cr.m.js'; // #import {FakeSettingsPrivate} from 'chrome://test/settings/fake_settings_private.m.js';
diff --git a/chrome/test/data/webui/settings/languages_page_tests.js b/chrome/test/data/webui/settings/languages_page_tests.js index 8e65d66..9d3110ce 100644 --- a/chrome/test/data/webui/settings/languages_page_tests.js +++ b/chrome/test/data/webui/settings/languages_page_tests.js
@@ -3,7 +3,8 @@ // found in the LICENSE file. // clang-format off -// #import {CrSettingsPrefs, kMenuCloseDelay, LanguagesBrowserProxyImpl} from 'chrome://settings/settings.js'; +// #import {CrSettingsPrefs} from 'chrome://settings/settings.js'; +// #import {kMenuCloseDelay, LanguagesBrowserProxyImpl} from 'chrome://settings/lazy_load.js'; // #import {eventToPromise, fakeDataBind} from 'chrome://test/test_util.m.js'; // #import {FakeSettingsPrivate} from 'chrome://test/settings/fake_settings_private.m.js'; // #import {getFakeLanguagePrefs} from 'chrome://test/settings/fake_language_settings_private.m.js';
diff --git a/chrome/test/data/webui/settings/languages_tests.js b/chrome/test/data/webui/settings/languages_tests.js index 3ec48ae..193b9679 100644 --- a/chrome/test/data/webui/settings/languages_tests.js +++ b/chrome/test/data/webui/settings/languages_tests.js
@@ -3,7 +3,8 @@ // found in the LICENSE file. // clang-format off -// #import {CrSettingsPrefs, LanguagesBrowserProxyImpl} from 'chrome://settings/settings.js'; +// #import {CrSettingsPrefs} from 'chrome://settings/settings.js'; +// #import {LanguagesBrowserProxyImpl} from 'chrome://settings/lazy_load.js'; // #import {FakeSettingsPrivate} from 'chrome://test/settings/fake_settings_private.m.js'; // #import {getFakeLanguagePrefs} from 'chrome://test/settings/fake_language_settings_private.m.js'; // #import {TestLanguagesBrowserProxy} from 'chrome://test/settings/test_languages_browser_proxy.m.js';
diff --git a/chrome/test/data/webui/settings/password_check_test.js b/chrome/test/data/webui/settings/password_check_test.js index 3e6e82f..d929610 100644 --- a/chrome/test/data/webui/settings/password_check_test.js +++ b/chrome/test/data/webui/settings/password_check_test.js
@@ -6,6 +6,7 @@ // clang-format off // #import {PasswordManagerImpl} from 'chrome://settings/settings.js'; +// #import 'chrome://settings/lazy_load.js'; // #import {makeCompromisedCredential, makePasswordCheckStatus} from 'chrome://test/settings/passwords_and_autofill_fake_data.m.js'; // #import {getSyncAllPrefs,simulateSyncStatus} from 'chrome://test/settings/sync_test_util.m.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; @@ -130,7 +131,28 @@ // Test verifies that clicking 'Check again' make proper function call to // password manager - test('testCheckAgainButtonWhenIdle', function() { + test('testCheckAgainButtonWhenIdleAfterFirstRun', function() { + const data = passwordManager.data; + data.checkStatus = autofill_test_util.makePasswordCheckStatus( + /*state=*/ PasswordCheckState.IDLE, + /*checked=*/ undefined, + /*remaining=*/ undefined, + /*lastCheck=*/ 'Just now'); + const section = createCheckPasswordSection(); + return passwordManager.whenCalled('getPasswordCheckStatus') + .then(() => { + assertTrue(isElementVisible(section.$.controlPasswordCheckButton)); + expectEquals( + section.i18n('checkPasswordsAgain'), + section.$.controlPasswordCheckButton.innerText); + section.$.controlPasswordCheckButton.click(); + }) + .then(() => passwordManager.whenCalled('startBulkPasswordCheck')); + }); + + // Test verifies that clicking 'Start Check' make proper function call to + // password manager + test('testStartCheckButtonWhenIdle', function() { assertEquals( PasswordCheckState.IDLE, passwordManager.data.checkStatus.state); const section = createCheckPasswordSection(); @@ -138,7 +160,7 @@ .then(() => { assertTrue(isElementVisible(section.$.controlPasswordCheckButton)); expectEquals( - section.i18n('checkPasswordsAgain'), + section.i18n('checkPasswords'), section.$.controlPasswordCheckButton.innerText); section.$.controlPasswordCheckButton.click(); }) @@ -540,8 +562,12 @@ // Tests that the spinner is replaced with a checkmark on successful runs. test('testShowsCheckmarkIconWhenFinishedWithoutLeaks', function() { const data = passwordManager.data; - assertEquals(PasswordCheckState.IDLE, data.checkStatus.state); assertEquals(0, data.leakedCredentials.length); + data.checkStatus = autofill_test_util.makePasswordCheckStatus( + /*state=*/ PasswordCheckState.IDLE, + /*checked=*/ undefined, + /*remaining=*/ undefined, + /*lastCheck=*/ 'Just now'); const checkPasswordSection = createCheckPasswordSection(); return passwordManager.whenCalled('getPasswordCheckStatus').then(() => { @@ -555,6 +581,23 @@ }); }); + // Tests that there is neither spinner nor icon if the check hasn't run yet. + test('testIconWhenFirstRunIsPending', function() { + const data = passwordManager.data; + assertEquals(0, data.leakedCredentials.length); + data.checkStatus = + autofill_test_util.makePasswordCheckStatus(PasswordCheckState.IDLE); + + const checkPasswordSection = createCheckPasswordSection(); + return passwordManager.whenCalled('getPasswordCheckStatus').then(() => { + Polymer.dom.flush(); + const icon = checkPasswordSection.$$('iron-icon'); + const spinner = checkPasswordSection.$$('paper-spinner-lite'); + expectFalse(isElementVisible(spinner)); + expectFalse(isElementVisible(icon)); + }); + }); + // Tests that the spinner is replaced with a triangle if leaks were found. test('testShowsTriangleIconWhenFinishedWithLeaks', function() { const data = passwordManager.data; @@ -681,16 +724,17 @@ }); }); - // After running, show confirmation, timestamp and number of leaks. - test('testDontShowTimeStampIfNotRun', function() { + // Before the first run, show only a description of what the check does. + test('testShowOnlyDescriptionIfNotRun', function() { const section = createCheckPasswordSection(); return passwordManager.whenCalled('getPasswordCheckStatus').then(() => { Polymer.dom.flush(); const title = section.$.title; const subtitle = section.$.subtitle; assertTrue(isElementVisible(title)); - assertTrue(isElementVisible(subtitle)); - expectEquals(section.i18n('checkPasswords'), title.innerText); + assertFalse(isElementVisible(subtitle)); + expectEquals(section.i18n('checkPasswordsDescription'), + title.innerText); }); }); @@ -715,7 +759,7 @@ assertTrue(isElementVisible(title)); assertTrue(isElementVisible(subtitle)); expectEquals( - section.i18n('checkPasswords') + ' • Just now', title.innerText); + section.i18n('checkedPasswords') + ' • Just now', title.innerText); }); }); @@ -847,7 +891,7 @@ return passwordManager.whenCalled('getPasswordCheckStatus').then(() => { assertTrue(isElementVisible(section.$.controlPasswordCheckButton)); expectEquals( - section.i18n('checkPasswordsAgain'), + section.i18n('checkPasswords'), section.$.controlPasswordCheckButton.innerText); // Change status from running to IDLE. @@ -869,6 +913,26 @@ // after a leak check finished. test('testShowsPositiveBannerWhenIdle', function() { const data = passwordManager.data; + assertEquals(0, data.leakedCredentials.length); + data.checkStatus = autofill_test_util.makePasswordCheckStatus( + /*state=*/ PasswordCheckState.IDLE, + /*checked=*/ undefined, + /*remaining=*/ undefined, + /*lastCheck=*/ 'Just now'); + + const checkPasswordSection = createCheckPasswordSection(); + return passwordManager.whenCalled('getPasswordCheckStatus').then(() => { + Polymer.dom.flush(); + assertTrue(isElementVisible(checkPasswordSection.$$('#bannerImage'))); + expectEquals( + 'chrome://settings/images/password_check_positive.svg', + checkPasswordSection.$$('#bannerImage').src); + }); + }); + + // Test that the banner indicates a neutral state if no check was run yet. + test('testShowsNeutralBannerBeforeFirstRun', function() { + const data = passwordManager.data; assertEquals(PasswordCheckState.IDLE, data.checkStatus.state); assertEquals(0, data.leakedCredentials.length); @@ -877,7 +941,7 @@ Polymer.dom.flush(); assertTrue(isElementVisible(checkPasswordSection.$$('#bannerImage'))); expectEquals( - 'chrome://settings/images/password_check_positive.svg', + 'chrome://settings/images/password_check_neutral.svg', checkPasswordSection.$$('#bannerImage').src); }); });
diff --git a/chrome/test/data/webui/settings/passwords_section_test.js b/chrome/test/data/webui/settings/passwords_section_test.js index 0fbe102d..489268c2 100644 --- a/chrome/test/data/webui/settings/passwords_section_test.js +++ b/chrome/test/data/webui/settings/passwords_section_test.js
@@ -5,7 +5,8 @@ /** @fileoverview Runs the Polymer Password Settings tests. */ // clang-format off -// #import {getToastManager, PasswordManagerImpl} from 'chrome://settings/settings.js'; +// #import {PasswordManagerImpl} from 'chrome://settings/settings.js'; +// #import {getToastManager} from 'chrome://settings/lazy_load.js'; // #import {PasswordSectionElementFactory, createExceptionEntry, createPasswordEntry, makeCompromisedCredential, makePasswordCheckStatus} from 'chrome://test/settings/passwords_and_autofill_fake_data.m.js'; // #import {runStartExportTest, runExportFlowFastTest, runExportFlowErrorTest, runExportFlowErrorRetryTest, runExportFlowSlowTest, runCancelExportTest, runFireCloseEventAfterExportCompleteTest} from 'chrome://test/settings/passwords_export_test.m.js'; // #import {eventToPromise} from 'chrome://test/test_util.m.js';
diff --git a/chrome/test/data/webui/settings/passwords_section_test_cros.js b/chrome/test/data/webui/settings/passwords_section_test_cros.js index 5ba25cb1..5e172046c 100644 --- a/chrome/test/data/webui/settings/passwords_section_test_cros.js +++ b/chrome/test/data/webui/settings/passwords_section_test_cros.js
@@ -10,7 +10,8 @@ */ // clang-format off -// #import {BlockingRequestManager, PasswordManagerImpl} from 'chrome://settings/settings.js'; +// #import {PasswordManagerImpl} from 'chrome://settings/settings.js'; +// #import {BlockingRequestManager} from 'chrome://settings/lazy_load.js'; // #import {PasswordSectionElementFactory, createPasswordEntry} from 'chrome://test/settings/passwords_and_autofill_fake_data.m.js'; // #import {runStartExportTest, runExportFlowFastTest, runExportFlowErrorTest, runExportFlowErrorRetryTest, runExportFlowSlowTest, runCancelExportTest, runFireCloseEventAfterExportCompleteTest} from 'chrome://test/settings/passwords_export_test.m.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
diff --git a/chrome/test/data/webui/settings/payments_section_test.js b/chrome/test/data/webui/settings/payments_section_test.js index 44239a6e..efcd7ef 100644 --- a/chrome/test/data/webui/settings/payments_section_test.js +++ b/chrome/test/data/webui/settings/payments_section_test.js
@@ -3,7 +3,8 @@ // found in the LICENSE file. // clang-format off -// #import {MetricsBrowserProxyImpl, PaymentsManagerImpl, PrivacyElementInteractions} from 'chrome://settings/settings.js' +// #import {MetricsBrowserProxyImpl, PrivacyElementInteractions} from 'chrome://settings/settings.js'; +// #import {PaymentsManagerImpl} from 'chrome://settings/lazy_load.js' // #import {TestMetricsBrowserProxy} from 'chrome://test/settings/test_metrics_browser_proxy.m.js'; // #import {TestPaymentsManager, createCreditCardEntry, createEmptyCreditCardEntry} from 'chrome://test/settings/passwords_and_autofill_fake_data.m.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
diff --git a/chrome/test/data/webui/settings/reset_page_test.js b/chrome/test/data/webui/settings/reset_page_test.js index 7d33272..c55dfab 100644 --- a/chrome/test/data/webui/settings/reset_page_test.js +++ b/chrome/test/data/webui/settings/reset_page_test.js
@@ -5,8 +5,8 @@ // clang-format off // #import {eventToPromise} from 'chrome://test/test_util.m.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -// #import {ResetBrowserProxyImpl} from 'chrome://settings/settings.js'; -// #import {Router, routes} from 'chrome://settings/settings.js'; +// #import {Router, routes, ResetBrowserProxyImpl} from 'chrome://settings/settings.js'; +// #import 'chrome://settings/lazy_load.js'; // #import {TestResetBrowserProxy} from 'chrome://test/settings/test_reset_browser_proxy.m.js'; // clang-format on
diff --git a/chrome/test/data/webui/settings/search_engines_page_test.js b/chrome/test/data/webui/settings/search_engines_page_test.js index a8e5b31..71e80761 100644 --- a/chrome/test/data/webui/settings/search_engines_page_test.js +++ b/chrome/test/data/webui/settings/search_engines_page_test.js
@@ -3,10 +3,10 @@ // found in the LICENSE file. // clang-format off +// #import 'chrome://settings/lazy_load.js'; // #import {eventToPromise} from 'chrome://test/test_util.m.js'; -// #import {ExtensionControlBrowserProxyImpl} from 'chrome://settings/settings.js'; +// #import {ExtensionControlBrowserProxyImpl, SearchEnginesBrowserProxyImpl} from 'chrome://settings/settings.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -// #import {SearchEnginesBrowserProxyImpl} from 'chrome://settings/settings.js'; // #import {TestExtensionControlBrowserProxy} from 'chrome://test/settings/test_extension_control_browser_proxy.m.js'; // #import {TestSearchEnginesBrowserProxy} from 'chrome://test/settings/test_search_engines_browser_proxy.m.js'; // clang-format on
diff --git a/chrome/test/data/webui/settings/settings_slider_tests.js b/chrome/test/data/webui/settings/settings_slider_tests.js index 0f726827..edcb25e 100644 --- a/chrome/test/data/webui/settings/settings_slider_tests.js +++ b/chrome/test/data/webui/settings/settings_slider_tests.js
@@ -3,7 +3,7 @@ // found in the LICENSE file. // clang-format off -// #import 'chrome://settings/settings.js'; +// #import 'chrome://settings/lazy_load.js'; // #import {eventToPromise, flushTasks} from 'chrome://test/test_util.m.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; // #import {keyDownOn, keyUpOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
diff --git a/chrome/test/data/webui/settings/settings_textarea_tests.js b/chrome/test/data/webui/settings/settings_textarea_tests.js index bb17775..b42fa56 100644 --- a/chrome/test/data/webui/settings/settings_textarea_tests.js +++ b/chrome/test/data/webui/settings/settings_textarea_tests.js
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// #import 'chrome://settings/settings.js'; +// #import 'chrome://settings/lazy_load.js'; /** @fileoverview Suite of tests for settings-textarea. */ suite('SettingsTextarea', function() {
diff --git a/chrome/test/data/webui/settings/site_data_details_subpage_tests.js b/chrome/test/data/webui/settings/site_data_details_subpage_tests.js index 58e02abf..86e2111 100644 --- a/chrome/test/data/webui/settings/site_data_details_subpage_tests.js +++ b/chrome/test/data/webui/settings/site_data_details_subpage_tests.js
@@ -2,6 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// clang-format off +// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +// #import {cookieInfo, LocalDataBrowserProxyImpl} from 'chrome://settings/lazy_load.js'; +// #import {routes, Router} from 'chrome://settings/settings.js'; +// #import {TestLocalDataBrowserProxy} from 'chrome://test/settings/test_local_data_browser_proxy.m.js'; +// clang-format on + /** @fileoverview Suite of tests for site-data-details-subpage. */ suite('SiteDataDetailsSubpage', function() { /** @type {?SiteDataDetailsSubpageElement} */
diff --git a/chrome/test/data/webui/settings/site_list_entry_tests.js b/chrome/test/data/webui/settings/site_list_entry_tests.js index 338c075..abe04fb 100644 --- a/chrome/test/data/webui/settings/site_list_entry_tests.js +++ b/chrome/test/data/webui/settings/site_list_entry_tests.js
@@ -4,6 +4,17 @@ /** @fileoverview Suite of tests for site-list-entry. */ +// clang-format off +// #import 'chrome://test/cr_elements/cr_policy_strings.js'; +// #import {ContentSettingsTypes,SiteSettingsPrefsBrowserProxyImpl} from 'chrome://settings/lazy_load.js'; +// #import {eventToPromise} from 'chrome://test/test_util.m.js'; +// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +// #import {isChromeOS} from 'chrome://resources/js/cr.m.js'; +// #import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; +// #import {Router, routes} from 'chrome://settings/settings.js'; +// #import {TestSiteSettingsPrefsBrowserProxy} from 'chrome://test/settings/test_site_settings_prefs_browser_proxy.m.js'; +// clang-format on + suite('SiteListEntry', function() { let testElement; @@ -95,7 +106,7 @@ return browserProxy.whenCalled('isOriginValid').then((args) => { assertEquals('http://example.com', args); Polymer.dom.flush(); - settingsRow = testElement.root.querySelector('.settings-row'); + const settingsRow = testElement.root.querySelector('.settings-row'); assertTrue(settingsRow.hasAttribute('actionable')); const subpageArrow = settingsRow.querySelector('.subpage-arrow'); assertFalse(!subpageArrow);
diff --git a/chrome/test/data/webui/settings/system_page_tests.js b/chrome/test/data/webui/settings/system_page_tests.js index a02bcb9..d32dd0f 100644 --- a/chrome/test/data/webui/settings/system_page_tests.js +++ b/chrome/test/data/webui/settings/system_page_tests.js
@@ -4,7 +4,8 @@ // clang-format off -// #import {SystemPageBrowserProxyImpl,LifetimeBrowserProxyImpl} from 'chrome://settings/settings.js'; +// #import {LifetimeBrowserProxyImpl} from 'chrome://settings/settings.js'; +// #import {SystemPageBrowserProxyImpl} from 'chrome://settings/lazy_load.js'; // #import {TestBrowserProxy} from 'chrome://test/test_browser_proxy.m.js'; // #import {TestLifetimeBrowserProxy} from 'chrome://test/settings/test_lifetime_browser_proxy.m.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
diff --git a/chrome/test/data/webui/settings/test_local_data_browser_proxy.js b/chrome/test/data/webui/settings/test_local_data_browser_proxy.js index a9b06655..f069dc9 100644 --- a/chrome/test/data/webui/settings/test_local_data_browser_proxy.js +++ b/chrome/test/data/webui/settings/test_local_data_browser_proxy.js
@@ -2,6 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// clang-format off +// #import {TestBrowserProxy} from 'chrome://test/test_browser_proxy.m.js'; +// clang-format on + /** * A test version of LocalDataBrowserProxy. Provides helper methods * for allowing tests to know when a method was called, as well as @@ -9,7 +13,7 @@ * * @implements {settings.LocalDataBrowserProxy} */ -class TestLocalDataBrowserProxy extends TestBrowserProxy { +/* #export */ class TestLocalDataBrowserProxy extends TestBrowserProxy { constructor() { super([ 'getDisplayList',
diff --git a/chrome/test/data/webui/settings/test_site_settings_prefs_browser_proxy.js b/chrome/test/data/webui/settings/test_site_settings_prefs_browser_proxy.js index 6f78cc7..0000628 100644 --- a/chrome/test/data/webui/settings/test_site_settings_prefs_browser_proxy.js +++ b/chrome/test/data/webui/settings/test_site_settings_prefs_browser_proxy.js
@@ -2,6 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// clang-format off +// #import {ContentSetting} from 'chrome://settings/lazy_load.js'; +// #import {createSiteSettingsPrefs, getContentSettingsTypeFromChooserType} from 'chrome://test/settings/test_util.m.js'; +// #import {TestBrowserProxy} from 'chrome://test/test_browser_proxy.m.js'; +// clang-format on + /** * In the real (non-test) code, this data comes from the C++ handler. * Only used for tests. @@ -21,7 +27,7 @@ * * @implements {settings.SiteSettingsPrefsBrowserProxy} */ -class TestSiteSettingsPrefsBrowserProxy extends TestBrowserProxy { +/* #export */ class TestSiteSettingsPrefsBrowserProxy extends TestBrowserProxy { constructor() { super([ 'clearFlashPref',
diff --git a/chrome/test/data/webui/settings/test_util.js b/chrome/test/data/webui/settings/test_util.js index 576610d05..c3c4953 100644 --- a/chrome/test/data/webui/settings/test_util.js +++ b/chrome/test/data/webui/settings/test_util.js
@@ -2,7 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// clang-format off +// #import {ChooserType,ContentSetting,ContentSettingsTypes,SiteSettingSource} from 'chrome://settings/lazy_load.js'; // #import {Router, Route} from 'chrome://settings/settings.js'; +// clang-format on cr.define('test_util', function() { @@ -97,7 +100,7 @@ * this function. * @return {SiteSettingsPref} */ - function createSiteSettingsPrefs( + /* #export */ function createSiteSettingsPrefs( defaultsList, exceptionsList, chooserExceptionsList = []) { // These test defaults reflect the actual defaults assigned to each // ContentSettingType, but keeping these in sync shouldn't matter for tests. @@ -195,7 +198,7 @@ * permission. * @return {?settings.ContentSettingsType} */ - function getContentSettingsTypeFromChooserType(chooserType) { + /* #export */ function getContentSettingsTypeFromChooserType(chooserType) { switch (chooserType) { case settings.ChooserType.USB_DEVICES: return settings.ContentSettingsTypes.USB_DEVICES;
diff --git a/chrome/test/payments/android/payment_request_test_bridge.cc b/chrome/test/payments/android/payment_request_test_bridge.cc index 2be7d28..8545bd2 100644 --- a/chrome/test/payments/android/payment_request_test_bridge.cc +++ b/chrome/test/payments/android/payment_request_test_bridge.cc
@@ -48,8 +48,8 @@ base::android::AttachCurrentThread()); } -bool IsAndroidMarshmallowForTest() { - return Java_PaymentRequestTestBridge_isAndroidMarshmallowForTest( +bool IsAndroidMarshmallowOrLollipopForTest() { + return Java_PaymentRequestTestBridge_isAndroidMarshmallowOrLollipopForTest( base::android::AttachCurrentThread()); }
diff --git a/chrome/test/payments/android/payment_request_test_bridge.h b/chrome/test/payments/android/payment_request_test_bridge.h index e206c33..2198155 100644 --- a/chrome/test/payments/android/payment_request_test_bridge.h +++ b/chrome/test/payments/android/payment_request_test_bridge.h
@@ -38,8 +38,8 @@ // Dismisses the minimal UI. Returns true on success. bool DismissMinimalUIForTest(); -// Returns true when running on Android M. -bool IsAndroidMarshmallowForTest(); +// Returns true when running on Android M or L. +bool IsAndroidMarshmallowOrLollipopForTest(); // Sets an observer on future Java PaymentRequests that will call these // callbacks when the events occur.
diff --git a/chrome/test/payments/payment_request_test_controller.h b/chrome/test/payments/payment_request_test_controller.h index 6530ff62..a0b55b0 100644 --- a/chrome/test/payments/payment_request_test_controller.h +++ b/chrome/test/payments/payment_request_test_controller.h
@@ -78,8 +78,8 @@ // UI is not implemented on the current platform. bool DismissMinimalUI(); - // Returns true when running on Android M. - bool IsAndroidMarshmallow(); + // Returns true when running on Android M or L. + bool IsAndroidMarshmallowOrLollipop(); private: // Observers that forward through to the PaymentRequestTestObserver.
diff --git a/chrome/test/payments/payment_request_test_controller_android.cc b/chrome/test/payments/payment_request_test_controller_android.cc index 495ec81b..adf4a68 100644 --- a/chrome/test/payments/payment_request_test_controller_android.cc +++ b/chrome/test/payments/payment_request_test_controller_android.cc
@@ -31,8 +31,8 @@ return DismissMinimalUIForTest(); } -bool PaymentRequestTestController::IsAndroidMarshmallow() { - return IsAndroidMarshmallowForTest(); +bool PaymentRequestTestController::IsAndroidMarshmallowOrLollipop() { + return IsAndroidMarshmallowOrLollipopForTest(); } void PaymentRequestTestController::SetUpOnMainThread() {
diff --git a/chrome/test/payments/payment_request_test_controller_desktop.cc b/chrome/test/payments/payment_request_test_controller_desktop.cc index ff7bb47..1b6e654 100644 --- a/chrome/test/payments/payment_request_test_controller_desktop.cc +++ b/chrome/test/payments/payment_request_test_controller_desktop.cc
@@ -92,7 +92,7 @@ return true; } -bool PaymentRequestTestController::IsAndroidMarshmallow() { +bool PaymentRequestTestController::IsAndroidMarshmallowOrLollipop() { return false; }
diff --git a/chrome/updater/server/win/server.cc b/chrome/updater/server/win/server.cc index 48276ab..9ce2dd2f 100644 --- a/chrome/updater/server/win/server.cc +++ b/chrome/updater/server/win/server.cc
@@ -18,6 +18,7 @@ #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/stl_util.h" +#include "base/win/scoped_bstr.h" #include "base/win/scoped_com_initializer.h" #include "chrome/updater/app/app.h" #include "chrome/updater/configurator.h" @@ -68,6 +69,20 @@ scoped_refptr<Configurator> config_; }; +STDMETHODIMP CompleteStatusImpl::get_statusCode(LONG* code) { + DCHECK(code); + + *code = code_; + return S_OK; +} + +STDMETHODIMP CompleteStatusImpl::get_statusMessage(BSTR* message) { + DCHECK(message); + + *message = base::win::ScopedBstr(message_).Release(); + return S_OK; +} + HRESULT UpdaterImpl::CheckForUpdate(const base::char16* app_id) { return E_NOTIMPL; } @@ -85,8 +100,11 @@ } HRESULT UpdaterImpl::UpdateAll(IUpdaterObserver* observer) { - if (observer) - observer->OnComplete(11); + if (observer) { + auto status = Microsoft::WRL::Make<CompleteStatusImpl>(11, L"Test"); + observer->OnComplete(status.Get()); + } + return S_OK; }
diff --git a/chrome/updater/server/win/server.h b/chrome/updater/server/win/server.h index dce92fdc..d1e45e30 100644 --- a/chrome/updater/server/win/server.h +++ b/chrome/updater/server/win/server.h
@@ -14,6 +14,29 @@ namespace updater { +// This class implements the ICompleteStatus interface and exposes it as a COM +// object. +class CompleteStatusImpl + : public Microsoft::WRL::RuntimeClass< + Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, + ICompleteStatus> { + public: + CompleteStatusImpl(int code, const base::string16& message) + : code_(code), message_(message) {} + CompleteStatusImpl(const CompleteStatusImpl&) = delete; + CompleteStatusImpl& operator=(const CompleteStatusImpl&) = delete; + + // Overrides for ICompleteStatus. + IFACEMETHODIMP get_statusCode(LONG* code) override; + IFACEMETHODIMP get_statusMessage(BSTR* message) override; + + private: + const int code_; + const base::string16 message_; + + ~CompleteStatusImpl() override = default; +}; + // This class implements the IUpdater interface and exposes it as a COM object. class UpdaterImpl : public Microsoft::WRL::RuntimeClass<
diff --git a/chrome/updater/server/win/updater_idl.idl b/chrome/updater/server/win/updater_idl.idl index 127b71f..4b7b7d3 100644 --- a/chrome/updater/server/win/updater_idl.idl +++ b/chrome/updater/server/win/updater_idl.idl
@@ -7,13 +7,25 @@ [ object, + dual, + uuid(2FCD14AF-B645-4351-8359-E80A0E202A0B), + helpstring("ICompleteStatus Interface"), + pointer_default(unique) +] +interface ICompleteStatus : IUnknown { + [propget] HRESULT statusCode([out, retval] LONG*); + [propget] HRESULT statusMessage([out, retval] BSTR*); +}; + +[ + object, oleautomation, uuid(7B416CFD-4216-4FD6-BD83-7C586054676E), helpstring("IUpdaterObserver Interface"), pointer_default(unique) ] interface IUpdaterObserver : IUnknown { - HRESULT OnComplete([in] int error_code); + HRESULT OnComplete([in] ICompleteStatus* status); }; [
diff --git a/chrome/updater/win/BUILD.gn b/chrome/updater/win/BUILD.gn index ffee9ee..d99d03f 100644 --- a/chrome/updater/win/BUILD.gn +++ b/chrome/updater/win/BUILD.gn
@@ -102,6 +102,9 @@ libs = [ "winhttp.lib" ] + configs -= [ "//build/config/win:winver" ] + configs += [ "//chrome/updater/server/win:winver" ] + deps = [ ":base", ":constants",
diff --git a/chrome/updater/win/setup/setup.cc b/chrome/updater/win/setup/setup.cc index c03fdb4..dfe8902 100644 --- a/chrome/updater/win/setup/setup.cc +++ b/chrome/updater/win/setup/setup.cc
@@ -84,6 +84,12 @@ base::CommandLine run_com_server_command(com_server_path); run_com_server_command.AppendSwitch(kServerSwitch); +#if !defined(NDEBUG) + run_com_server_command.AppendSwitch(kEnableLoggingSwitch); + run_com_server_command.AppendSwitchASCII(kLoggingModuleSwitch, + "*/chrome/updater/*=2"); +#endif + list->AddSetRegValueWorkItem( root, local_server32_reg_path, WorkItem::kWow64Default, L"", run_com_server_command.GetCommandLineString(), true); @@ -132,7 +138,8 @@ return; } - for (const auto iid : {__uuidof(IUpdater), __uuidof(IUpdaterObserver)}) { + for (const auto iid : {__uuidof(IUpdater), __uuidof(IUpdaterObserver), + __uuidof(ICompleteStatus)}) { const base::string16 iid_reg_path = GetComIidRegistryPath(iid); const base::string16 typelib_reg_path = GetComTypeLibRegistryPath(iid);
diff --git a/chrome/updater/win/setup/uninstall.cc b/chrome/updater/win/setup/uninstall.cc index 948959ce..67b7abe2 100644 --- a/chrome/updater/win/setup/uninstall.cc +++ b/chrome/updater/win/setup/uninstall.cc
@@ -50,9 +50,10 @@ } void DeleteComInterfaces(HKEY root) { - for (const auto iid : {__uuidof(IUpdater), __uuidof(IUpdaterObserver)}) { - for (const auto& reg_path : {GetComIidRegistryPath(iid), - GetComTypeLibRegistryPath(iid)}) { + for (const auto iid : {__uuidof(IUpdater), __uuidof(IUpdaterObserver), + __uuidof(ICompleteStatus)}) { + for (const auto& reg_path : + {GetComIidRegistryPath(iid), GetComTypeLibRegistryPath(iid)}) { InstallUtil::DeleteRegistryKey(root, reg_path, WorkItem::kWow64Default); } }
diff --git a/chrome/updater/win/update_service_out_of_process.cc b/chrome/updater/win/update_service_out_of_process.cc index 34ddfff..905cfcc 100644 --- a/chrome/updater/win/update_service_out_of_process.cc +++ b/chrome/updater/win/update_service_out_of_process.cc
@@ -2,10 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// This macro is used in <wrl/module.h>. Since only the COM functionality is +// used here (while WinRT is not being used), define this macro to optimize +// compilation of <wrl/module.h> for COM-only. +#ifndef __WRL_CLASSIC_COM_STRICT__ +#define __WRL_CLASSIC_COM_STRICT__ +#endif // __WRL_CLASSIC_COM_STRICT__ + #include "chrome/updater/win/update_service_out_of_process.h" #include <windows.h> #include <wrl/client.h> +#include <wrl/module.h> #include <memory> #include <utility> @@ -15,6 +23,7 @@ #include "base/logging.h" #include "base/task/task_traits.h" #include "base/task/thread_pool.h" +#include "base/win/scoped_bstr.h" #include "chrome/updater/server/win/updater_idl.h" namespace { @@ -27,8 +36,16 @@ namespace updater { -HRESULT UpdaterObserverImpl::OnComplete(int error_code) { - VLOG(2) << "UpdaterObserverImpl::OnComplete(" << error_code << ")"; +HRESULT UpdaterObserverImpl::OnComplete(ICompleteStatus* status) { + DCHECK(status); + + LONG code = 0; + base::win::ScopedBstr message; + CHECK(SUCCEEDED(status->get_statusCode(&code))); + CHECK(SUCCEEDED(status->get_statusMessage(message.Receive()))); + + VLOG(2) << "UpdaterObserverImpl::OnComplete(" << code << ", " << message.Get() + << ")"; return S_OK; } @@ -38,8 +55,15 @@ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); } +void UpdateServiceOutOfProcess::ModuleStop() { + VLOG(2) << "UpdateServiceOutOfProcess::ModuleStop"; +} + std::unique_ptr<UpdateServiceOutOfProcess> UpdateServiceOutOfProcess::CreateInstance() { + Microsoft::WRL::Module<Microsoft::WRL::OutOfProc>::Create( + &UpdateServiceOutOfProcess::ModuleStop); + struct Creator : public UpdateServiceOutOfProcess {}; auto instance = std::make_unique<Creator>(); instance->com_task_runner_ = @@ -106,7 +130,6 @@ return; } - ::CoAddRefServerProcess(); auto observer = Microsoft::WRL::Make<UpdaterObserverImpl>(); hr = updater->UpdateAll(observer.Get()); if (FAILED(hr)) { @@ -114,9 +137,6 @@ std::move(callback).Run(static_cast<Result>(hr)); return; } - - observer.Reset(); - ::CoReleaseServerProcess(); } } // namespace updater
diff --git a/chrome/updater/win/update_service_out_of_process.h b/chrome/updater/win/update_service_out_of_process.h index 7fbc895..10a32eb8 100644 --- a/chrome/updater/win/update_service_out_of_process.h +++ b/chrome/updater/win/update_service_out_of_process.h
@@ -26,7 +26,8 @@ namespace updater { -// This class implements the IUpdater interface and exposes it as a COM object. +// This class implements the IUpdaterObserver interface and exposes it as a COM +// object. class UpdaterObserverImpl : public Microsoft::WRL::RuntimeClass< Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, @@ -37,7 +38,7 @@ UpdaterObserverImpl& operator=(const UpdaterObserverImpl&) = delete; // Overrides for IUpdaterObserver. - IFACEMETHODIMP OnComplete(int error_code) override; + IFACEMETHODIMP OnComplete(ICompleteStatus* status) override; private: ~UpdaterObserverImpl() override = default; @@ -55,6 +56,7 @@ ~UpdateServiceOutOfProcess() override; static std::unique_ptr<UpdateServiceOutOfProcess> CreateInstance(); + static void ModuleStop(); // Overrides for updater::UpdateService. // Update-checks all registered applications. Calls |callback| once the
diff --git a/chromeos/BUILD.gn b/chromeos/BUILD.gn index 3cf5f9a..8d1f075 100644 --- a/chromeos/BUILD.gn +++ b/chromeos/BUILD.gn
@@ -276,6 +276,7 @@ # crbug.com/1062289 "security.NetworkListenersARC", + "security.NetworkListenersNonARC", # crbug.com/1054340 "crostini.AudioSanity.artifact",
diff --git a/chromeos/CHROMEOS_LKGM b/chromeos/CHROMEOS_LKGM index 187bba3f..eecd93a 100644 --- a/chromeos/CHROMEOS_LKGM +++ b/chromeos/CHROMEOS_LKGM
@@ -1 +1 @@ -12981.0.0 \ No newline at end of file +12983.0.0 \ No newline at end of file
diff --git a/chromeos/profiles/airmont.afdo.newest.txt b/chromeos/profiles/airmont.afdo.newest.txt index 02e9754..a4159b4 100644 --- a/chromeos/profiles/airmont.afdo.newest.txt +++ b/chromeos/profiles/airmont.afdo.newest.txt
@@ -1 +1 @@ -chromeos-chrome-amd64-airmont-82-4079.0-1584355719-benchmark-82.0.4085.8-r1-redacted.afdo.xz \ No newline at end of file +chromeos-chrome-amd64-airmont-82-4079.0-1584355719-benchmark-82.0.4085.10-r1-redacted.afdo.xz \ No newline at end of file
diff --git a/chromeos/profiles/broadwell.afdo.newest.txt b/chromeos/profiles/broadwell.afdo.newest.txt index bf5dedff..198fb031 100644 --- a/chromeos/profiles/broadwell.afdo.newest.txt +++ b/chromeos/profiles/broadwell.afdo.newest.txt
@@ -1 +1 @@ -chromeos-chrome-amd64-broadwell-82-4044.42-1584352428-benchmark-82.0.4085.8-r1-redacted.afdo.xz \ No newline at end of file +chromeos-chrome-amd64-broadwell-82-4044.42-1584352428-benchmark-82.0.4085.10-r1-redacted.afdo.xz \ No newline at end of file
diff --git a/chromeos/profiles/silvermont.afdo.newest.txt b/chromeos/profiles/silvermont.afdo.newest.txt index 4a7ea72..3b83f44 100644 --- a/chromeos/profiles/silvermont.afdo.newest.txt +++ b/chromeos/profiles/silvermont.afdo.newest.txt
@@ -1 +1 @@ -chromeos-chrome-amd64-silvermont-82-4079.0-1584354054-benchmark-82.0.4085.8-r1-redacted.afdo.xz \ No newline at end of file +chromeos-chrome-amd64-silvermont-82-4079.0-1584354054-benchmark-82.0.4085.10-r1-redacted.afdo.xz \ No newline at end of file
diff --git a/components/arc/mojom/accessibility_helper.mojom b/components/arc/mojom/accessibility_helper.mojom index db9864a8..326a78a 100644 --- a/components/arc/mojom/accessibility_helper.mojom +++ b/components/arc/mojom/accessibility_helper.mojom
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Next MinVersion: 19 +// Next MinVersion: 20 module arc.mojom; @@ -358,7 +358,7 @@ [MinVersion=14] bool is_input_method_window; // Retrieved from AccessibilityRecord.getText(). - [MinVersion=15] array<string>? eventText; + [MinVersion=15] array<string>? event_text; }; // AccessibilityActionData is a struct to contain info of AccessibilityAction in
diff --git a/components/autofill_assistant/browser/BUILD.gn b/components/autofill_assistant/browser/BUILD.gn index b7432b1..57af2e31 100644 --- a/components/autofill_assistant/browser/BUILD.gn +++ b/components/autofill_assistant/browser/BUILD.gn
@@ -196,6 +196,8 @@ "actions/mock_action_delegate.h", "fake_script_executor_delegate.cc", "fake_script_executor_delegate.h", + "mock_client.cc", + "mock_client.h", "mock_controller_observer.cc", "mock_controller_observer.h", "mock_personal_data_manager.cc", @@ -250,6 +252,7 @@ "script_precondition_unittest.cc", "script_tracker_unittest.cc", "selector_unittest.cc", + "service_impl_unittest.cc", "string_conversions_util_unittest.cc", "trigger_context_unittest.cc", "user_data_util_unittest.cc",
diff --git a/components/autofill_assistant/browser/DEPS b/components/autofill_assistant/browser/DEPS index bc88f17..6f760c5 100644 --- a/components/autofill_assistant/browser/DEPS +++ b/components/autofill_assistant/browser/DEPS
@@ -8,6 +8,7 @@ "+content/shell/browser/shell.h", "+components/signin/public/identity_manager", "+components/strings/grit/components_strings.h", + "+crypto", "+google_apis", "+net", "+services/network/public/cpp",
diff --git a/components/autofill_assistant/browser/client.h b/components/autofill_assistant/browser/client.h index c906dac..dfb11fb 100644 --- a/components/autofill_assistant/browser/client.h +++ b/components/autofill_assistant/browser/client.h
@@ -39,39 +39,39 @@ virtual void DestroyUI() = 0; // Returns the API key to be used for requests to the backend. - virtual std::string GetApiKey() = 0; + virtual std::string GetApiKey() const = 0; // Returns the e-mail address that corresponds to the auth credentials. Might // be empty. - virtual std::string GetAccountEmailAddress() = 0; + virtual std::string GetAccountEmailAddress() const = 0; // Returns the AccessTokenFetcher to use to get oauth credentials. virtual AccessTokenFetcher* GetAccessTokenFetcher() = 0; // Returns the current active personal data manager. - virtual autofill::PersonalDataManager* GetPersonalDataManager() = 0; + virtual autofill::PersonalDataManager* GetPersonalDataManager() const = 0; // Return the password manager client for the current WebContents. - virtual password_manager::PasswordManagerClient* - GetPasswordManagerClient() = 0; + virtual password_manager::PasswordManagerClient* GetPasswordManagerClient() + const = 0; // Returns the currently active login fetcher. - virtual WebsiteLoginFetcher* GetWebsiteLoginFetcher() = 0; + virtual WebsiteLoginFetcher* GetWebsiteLoginFetcher() const = 0; // Returns the server URL to be used for requests to the backend. - virtual std::string GetServerUrl() = 0; + virtual std::string GetServerUrl() const = 0; // Returns the locale. - virtual std::string GetLocale() = 0; + virtual std::string GetLocale() const = 0; // Returns the country code. - virtual std::string GetCountryCode() = 0; + virtual std::string GetCountryCode() const = 0; // Returns details about the device. - virtual DeviceContext GetDeviceContext() = 0; + virtual DeviceContext GetDeviceContext() const = 0; // Returns current WebContents. - virtual content::WebContents* GetWebContents() = 0; + virtual content::WebContents* GetWebContents() const = 0; // Stops autofill assistant for the current WebContents, both controller // and UI.
diff --git a/components/autofill_assistant/browser/controller_unittest.cc b/components/autofill_assistant/browser/controller_unittest.cc index c8e795c3..0edce12 100644 --- a/components/autofill_assistant/browser/controller_unittest.cc +++ b/components/autofill_assistant/browser/controller_unittest.cc
@@ -17,6 +17,7 @@ #include "components/autofill/core/browser/autofill_test_utils.h" #include "components/autofill_assistant/browser/device_context.h" #include "components/autofill_assistant/browser/features.h" +#include "components/autofill_assistant/browser/mock_client.h" #include "components/autofill_assistant/browser/mock_controller_observer.h" #include "components/autofill_assistant/browser/mock_personal_data_manager.h" #include "components/autofill_assistant/browser/mock_service.h" @@ -67,31 +68,6 @@ MOCK_CONST_METHOD0(WasCredentialLeakDialogShown, bool()); }; -class FakeClient : public Client { - public: - // Implements Client - std::string GetApiKey() override { return ""; } - AccessTokenFetcher* GetAccessTokenFetcher() override { return nullptr; } - MockPersonalDataManager* GetPersonalDataManager() override { - return &mock_personal_data_manager_; - } - WebsiteLoginFetcher* GetWebsiteLoginFetcher() override { return nullptr; } - std::string GetServerUrl() override { return ""; } - std::string GetAccountEmailAddress() override { return ""; } - std::string GetLocale() override { return ""; } - std::string GetCountryCode() override { return ""; } - DeviceContext GetDeviceContext() override { return DeviceContext(); } - MOCK_METHOD0(GetWebContents, content::WebContents*()); - MOCK_METHOD0(GetPasswordManagerClient, - password_manager::PasswordManagerClient*()); - MOCK_METHOD1(Shutdown, void(Metrics::DropOutReason reason)); - MOCK_METHOD0(AttachUI, void()); - MOCK_METHOD0(DestroyUI, void()); - - private: - MockPersonalDataManager mock_personal_data_manager_; -}; - // Same as non-mock, but provides default mock callbacks. struct MockCollectUserDataOptions : public CollectUserDataOptions { MockCollectUserDataOptions() { @@ -125,12 +101,12 @@ auto service = std::make_unique<NiceMock<MockService>>(); mock_service_ = service.get(); - ON_CALL(fake_client_, GetWebContents).WillByDefault(Return(web_contents())); - ON_CALL(fake_client_, GetPasswordManagerClient) + ON_CALL(mock_client_, GetWebContents).WillByDefault(Return(web_contents())); + ON_CALL(mock_client_, GetPasswordManagerClient) .WillByDefault(Return(&mock_password_manager_client_)); controller_ = std::make_unique<Controller>( - web_contents(), &fake_client_, task_environment()->GetMockTickClock(), + web_contents(), &mock_client_, task_environment()->GetMockTickClock(), std::move(service)); controller_->SetWebControllerForTest(std::move(web_controller)); @@ -247,7 +223,7 @@ std::vector<AutofillAssistantState> states_; MockService* mock_service_; MockWebController* mock_web_controller_; - NiceMock<FakeClient> fake_client_; + NiceMock<MockClient> mock_client_; NiceMock<MockControllerObserver> mock_observer_; MockPasswordManagerClient mock_password_manager_client_; std::unique_ptr<Controller> controller_; @@ -413,7 +389,7 @@ SupportsScriptResponseProto empty; SetNextScriptResponse(empty); - EXPECT_CALL(fake_client_, + EXPECT_CALL(mock_client_, Shutdown(Metrics::DropOutReason::NO_INITIAL_SCRIPTS)); Start("http://a.example.com/path"); EXPECT_EQ(AutofillAssistantState::STOPPED, controller_->GetState()); @@ -427,7 +403,7 @@ ->add_domain("http://otherdomain.com"); SetNextScriptResponse(script_response); - EXPECT_CALL(fake_client_, + EXPECT_CALL(mock_client_, Shutdown(Metrics::DropOutReason::NO_INITIAL_SCRIPTS)); Start("http://a.example.com/path"); EXPECT_EQ(AutofillAssistantState::STOPPED, controller_->GetState()); @@ -545,7 +521,7 @@ ASSERT_THAT(controller_->GetUserActions(), SizeIs(1)); testing::InSequence seq; - EXPECT_CALL(fake_client_, Shutdown(Metrics::DropOutReason::SCRIPT_SHUTDOWN)); + EXPECT_CALL(mock_client_, Shutdown(Metrics::DropOutReason::SCRIPT_SHUTDOWN)); EXPECT_TRUE(controller_->PerformUserAction(0)); } @@ -566,7 +542,7 @@ EXPECT_CALL(mock_observer_, CloseCustomTab()).Times(1); testing::InSequence seq; - EXPECT_CALL(fake_client_, + EXPECT_CALL(mock_client_, Shutdown(Metrics::DropOutReason::CUSTOM_TAB_CLOSED)); EXPECT_TRUE(controller_->PerformUserAction(0)); } @@ -601,7 +577,7 @@ EXPECT_CALL(*mock_service_, OnGetActions(StrEq("autostart"), _, _, _, _, _)) .WillOnce(RunOnceCallback<5>(true, "")); - EXPECT_CALL(fake_client_, AttachUI()); + EXPECT_CALL(mock_client_, AttachUI()); Start("http://a.example.com/path"); EXPECT_EQ(AutofillAssistantState::PROMPT, controller_->GetState()); @@ -611,7 +587,7 @@ SetupActionsForScript("runnable", runnable_script); // The script "runnable" stops the flow and shutdowns the controller. - EXPECT_CALL(fake_client_, Shutdown(Metrics::DropOutReason::SCRIPT_SHUTDOWN)); + EXPECT_CALL(mock_client_, Shutdown(Metrics::DropOutReason::SCRIPT_SHUTDOWN)); controller_->PerformUserAction(0); EXPECT_EQ(AutofillAssistantState::STOPPED, controller_->GetState()); @@ -709,7 +685,7 @@ } TEST_F(ControllerTest, AttachUIWhenStarting) { - EXPECT_CALL(fake_client_, AttachUI()); + EXPECT_CALL(mock_client_, AttachUI()); Start(); } @@ -717,14 +693,14 @@ SimulateWebContentsFocused(); // must not call AttachUI testing::InSequence seq; - EXPECT_CALL(fake_client_, AttachUI()); + EXPECT_CALL(mock_client_, AttachUI()); SupportsScriptResponseProto script_response; AddRunnableScript(&script_response, "script1"); SetNextScriptResponse(script_response); Start(); // must call AttachUI - EXPECT_CALL(fake_client_, AttachUI()); + EXPECT_CALL(mock_client_, AttachUI()); SimulateWebContentsFocused(); // must call AttachUI controller_->OnFatalError("test", Metrics::DropOutReason::TAB_CHANGED); @@ -1062,7 +1038,7 @@ // Execute the script, which requires showing the UI, then go back to tracking // mode - EXPECT_CALL(fake_client_, AttachUI()); + EXPECT_CALL(mock_client_, AttachUI()); EXPECT_TRUE(controller_->PerformUserAction(0)); EXPECT_EQ(AutofillAssistantState::TRACKING, controller_->GetState()); EXPECT_THAT(controller_->GetUserActions(), SizeIs(1)); @@ -1080,13 +1056,13 @@ // Shutdown once we've moved from domain b.example.com, for which we know // there are no scripts, to c.example.com, which we don't want to check. - EXPECT_CALL(fake_client_, Shutdown(Metrics::DropOutReason::NO_SCRIPTS)); + EXPECT_CALL(mock_client_, Shutdown(Metrics::DropOutReason::NO_SCRIPTS)); SimulateNavigateToUrl(GURL("http://c.example.com/")); } TEST_F(ControllerTest, TrackScriptWithNoUI) { // The UI is never shown during this test. - EXPECT_CALL(fake_client_, AttachUI()).Times(0); + EXPECT_CALL(mock_client_, AttachUI()).Times(0); SupportsScriptResponseProto script_response; auto* script = AddRunnableScript(&script_response, "runnable"); @@ -1133,7 +1109,7 @@ ASSERT_THAT(controller_->GetUserActions(), SizeIs(1)); EXPECT_FALSE(controller_->NeedsUI()); - EXPECT_CALL(fake_client_, AttachUI()); + EXPECT_CALL(mock_client_, AttachUI()); EXPECT_TRUE(controller_->PerformUserAction(0)); EXPECT_EQ(AutofillAssistantState::TRACKING, controller_->GetState()); @@ -1164,7 +1140,7 @@ ASSERT_THAT(controller_->GetUserActions(), SizeIs(1)); EXPECT_FALSE(controller_->NeedsUI()); - EXPECT_CALL(fake_client_, AttachUI()); + EXPECT_CALL(mock_client_, AttachUI()); EXPECT_TRUE(controller_->PerformUserAction(0)); EXPECT_EQ(AutofillAssistantState::TRACKING, controller_->GetState()); @@ -1327,7 +1303,7 @@ runnable_script.add_actions()->mutable_stop(); SetupActionsForScript("runnable", runnable_script); - EXPECT_CALL(fake_client_, AttachUI()); + EXPECT_CALL(mock_client_, AttachUI()); Start("http://example.com/"); EXPECT_EQ(AutofillAssistantState::PROMPT, controller_->GetState()); EXPECT_THAT(controller_->GetUserActions(), SizeIs(1)); @@ -1384,7 +1360,7 @@ // Shut down once the user moves to a different domain EXPECT_CALL( - fake_client_, + mock_client_, Shutdown(Metrics::DropOutReason::DOMAIN_CHANGE_DURING_BROWSE_MODE)); SimulateNavigateToUrl(GURL("http://other-example.com/")); } @@ -1415,7 +1391,7 @@ EXPECT_EQ(AutofillAssistantState::PROMPT, controller_->GetState()); // go back. - EXPECT_CALL(fake_client_, Shutdown(Metrics::DropOutReason::NAVIGATION)); + EXPECT_CALL(mock_client_, Shutdown(Metrics::DropOutReason::NAVIGATION)); SetLastCommittedUrl(GURL("http://b.example.com")); content::NavigationSimulator::GoBack(web_contents()); } @@ -1503,7 +1479,7 @@ EXPECT_CALL(mock_observer_, OnStatusMessageChanged(testing::Not(never_shown))) .Times(testing::AnyNumber()); - EXPECT_CALL(fake_client_, Shutdown(Metrics::DropOutReason::NAVIGATION)); + EXPECT_CALL(mock_client_, Shutdown(Metrics::DropOutReason::NAVIGATION)); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL("http://example.com/otherpage"));
diff --git a/components/autofill_assistant/browser/mock_client.cc b/components/autofill_assistant/browser/mock_client.cc new file mode 100644 index 0000000..7541c63e --- /dev/null +++ b/components/autofill_assistant/browser/mock_client.cc
@@ -0,0 +1,13 @@ +// Copyright 2020 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 "components/autofill_assistant/browser/mock_client.h" +#include "components/autofill_assistant/browser/mock_personal_data_manager.h" + +namespace autofill_assistant { + +MockClient::MockClient() = default; +MockClient::~MockClient() = default; + +} // namespace autofill_assistant
diff --git a/components/autofill_assistant/browser/mock_client.h b/components/autofill_assistant/browser/mock_client.h new file mode 100644 index 0000000..3d595ed3 --- /dev/null +++ b/components/autofill_assistant/browser/mock_client.h
@@ -0,0 +1,45 @@ +// Copyright 2020 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. + +#ifndef COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_MOCK_CLIENT_H_ +#define COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_MOCK_CLIENT_H_ + +#include "components/autofill/core/browser/personal_data_manager.h" +#include "components/autofill_assistant/browser/client.h" +#include "components/autofill_assistant/browser/device_context.h" +#include "components/autofill_assistant/browser/metrics.h" +#include "components/autofill_assistant/browser/mock_personal_data_manager.h" +#include "components/autofill_assistant/browser/website_login_fetcher.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace autofill_assistant { + +class MockClient : public Client { + public: + MockClient(); + ~MockClient(); + + MOCK_CONST_METHOD0(GetApiKey, std::string()); + MOCK_CONST_METHOD0(GetServerUrl, std::string()); + MOCK_CONST_METHOD0(GetLocale, std::string()); + MOCK_CONST_METHOD0(GetCountryCode, std::string()); + MOCK_CONST_METHOD0(GetDeviceContext, DeviceContext()); + MOCK_CONST_METHOD0(GetAccountEmailAddress, std::string()); + MOCK_CONST_METHOD0(GetWebContents, content::WebContents*()); + MOCK_CONST_METHOD0(GetPersonalDataManager, autofill::PersonalDataManager*()); + MOCK_CONST_METHOD0(GetWebsiteLoginFetcher, WebsiteLoginFetcher*()); + MOCK_CONST_METHOD0(GetPasswordManagerClient, + password_manager::PasswordManagerClient*()); + MOCK_METHOD0(GetAccessTokenFetcher, AccessTokenFetcher*()); + MOCK_METHOD1(Shutdown, void(Metrics::DropOutReason reason)); + MOCK_METHOD0(AttachUI, void()); + MOCK_METHOD0(DestroyUI, void()); + + private: + std::unique_ptr<MockPersonalDataManager> mock_personal_data_manager_; +}; + +} // namespace autofill_assistant + +#endif // COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_MOCK_CLIENT_H_
diff --git a/components/autofill_assistant/browser/mock_service.cc b/components/autofill_assistant/browser/mock_service.cc index 31d1eb6..5951a6f 100644 --- a/components/autofill_assistant/browser/mock_service.cc +++ b/components/autofill_assistant/browser/mock_service.cc
@@ -17,7 +17,8 @@ nullptr, "en_US", "", - DeviceContext()) {} + DeviceContext(), + nullptr) {} MockService::~MockService() {} } // namespace autofill_assistant
diff --git a/components/autofill_assistant/browser/protocol_utils.cc b/components/autofill_assistant/browser/protocol_utils.cc index ea84e1c..81d55733 100644 --- a/components/autofill_assistant/browser/protocol_utils.cc +++ b/components/autofill_assistant/browser/protocol_utils.cc
@@ -43,6 +43,7 @@ void FillClientContext(const ClientContextProto& client_context, const TriggerContext& trigger_context, + const std::string& client_account_hash, ClientContextProto* proto) { proto->CopyFrom(client_context); std::string experiment_ids = trigger_context.experiment_ids(); @@ -58,6 +59,17 @@ if (trigger_context.is_direct_action()) { proto->set_is_direct_action(true); } + if (trigger_context.get_caller_account_hash().empty()) { + proto->set_accounts_matching_status(ClientContextProto::UNKNOWN); + } else { + if (trigger_context.get_caller_account_hash() == client_account_hash) { + proto->set_accounts_matching_status( + ClientContextProto::ACCOUNTS_MATCHING); + } else { + proto->set_accounts_matching_status( + ClientContextProto::ACCOUNTS_NOT_MATCHING); + } + } } } // namespace @@ -66,12 +78,13 @@ std::string ProtocolUtils::CreateGetScriptsRequest( const GURL& url, const TriggerContext& trigger_context, - const ClientContextProto& client_context) { + const ClientContextProto& client_context, + const std::string& client_account_hash) { DCHECK(!url.is_empty()); SupportsScriptRequestProto script_proto; script_proto.set_url(url.spec()); - FillClientContext(client_context, trigger_context, + FillClientContext(client_context, trigger_context, client_account_hash, script_proto.mutable_client_context()); trigger_context.AddParameters(script_proto.mutable_script_parameters()); std::string serialized_script_proto; @@ -123,7 +136,8 @@ const TriggerContext& trigger_context, const std::string& global_payload, const std::string& script_payload, - const ClientContextProto& client_context) { + const ClientContextProto& client_context, + const std::string& client_account_hash) { ScriptActionRequestProto request_proto; InitialScriptActionsRequestProto* initial_request_proto = request_proto.mutable_initial_request(); @@ -132,7 +146,7 @@ query->add_script_path(script_path); query->set_url(url.spec()); query->set_policy(PolicyType::SCRIPT); - FillClientContext(client_context, trigger_context, + FillClientContext(client_context, trigger_context, client_account_hash, request_proto.mutable_client_context()); trigger_context.AddParameters( initial_request_proto->mutable_script_parameters()); @@ -156,7 +170,8 @@ const std::string& global_payload, const std::string& script_payload, const std::vector<ProcessedActionProto>& processed_actions, - const ClientContextProto& client_context) { + const ClientContextProto& client_context, + const std::string& client_account_hash) { ScriptActionRequestProto request_proto; request_proto.set_global_payload(global_payload); request_proto.set_script_payload(script_payload); @@ -165,7 +180,7 @@ for (const auto& processed_action : processed_actions) { next_request->add_processed_actions()->MergeFrom(processed_action); } - FillClientContext(client_context, trigger_context, + FillClientContext(client_context, trigger_context, client_account_hash, request_proto.mutable_client_context()); std::string serialized_request_proto; bool success = request_proto.SerializeToString(&serialized_request_proto);
diff --git a/components/autofill_assistant/browser/protocol_utils.h b/components/autofill_assistant/browser/protocol_utils.h index 14e460d..0c760fc0 100644 --- a/components/autofill_assistant/browser/protocol_utils.h +++ b/components/autofill_assistant/browser/protocol_utils.h
@@ -27,7 +27,8 @@ static std::string CreateGetScriptsRequest( const GURL& url, const TriggerContext& trigger_context, - const ClientContextProto& client_context); + const ClientContextProto& client_context, + const std::string& client_account); // Convert |script_proto| to a script struct and if the script is valid, add // it to |scripts|. @@ -44,7 +45,8 @@ const TriggerContext& trigger_context, const std::string& global_payload, const std::string& script_payload, - const ClientContextProto& client_context); + const ClientContextProto& client_context, + const std::string& client_account); // Create request to get next sequence of actions for a script. static std::string CreateNextScriptActionsRequest( @@ -52,7 +54,8 @@ const std::string& global_payload, const std::string& script_payload, const std::vector<ProcessedActionProto>& processed_actions, - const ClientContextProto& client_context); + const ClientContextProto& client_context, + const std::string& client_account); // Parse actions from the given |response|, which can be an empty string. //
diff --git a/components/autofill_assistant/browser/protocol_utils_unittest.cc b/components/autofill_assistant/browser/protocol_utils_unittest.cc index 0ad4c7a..4fb14bd0 100644 --- a/components/autofill_assistant/browser/protocol_utils_unittest.cc +++ b/components/autofill_assistant/browser/protocol_utils_unittest.cc
@@ -100,13 +100,16 @@ EXPECT_TRUE( request.ParseFromString(ProtocolUtils::CreateInitialScriptActionsRequest( "script_path", GURL("http://example.com/"), trigger_context, - "global_payload", "script_payload", CreateClientContextProto()))); + "global_payload", "script_payload", CreateClientContextProto(), + "accountsha"))); AssertClientContext(request.client_context()); EXPECT_THAT(request.client_context().experiment_ids(), Eq("1,2,3")); EXPECT_TRUE(request.client_context().is_cct()); EXPECT_FALSE(request.client_context().is_onboarding_shown()); EXPECT_FALSE(request.client_context().is_direct_action()); + EXPECT_THAT(request.client_context().accounts_matching_status(), + Eq(ClientContextProto::UNKNOWN)); const InitialScriptActionsRequestProto& initial = request.initial_request(); EXPECT_THAT(initial.query().script_path(), ElementsAre("script_path")); @@ -130,16 +133,20 @@ trigger_context_flags.SetCCT(true); trigger_context_flags.SetOnboardingShown(true); trigger_context_flags.SetDirectAction(true); + trigger_context_flags.SetCallerAccountHash("accountsha"); EXPECT_TRUE( request.ParseFromString(ProtocolUtils::CreateInitialScriptActionsRequest( "script_path", GURL("http://example.com/"), trigger_context_flags, - "global_payload", "script_payload", CreateClientContextProto()))); + "global_payload", "script_payload", CreateClientContextProto(), + "accountsha"))); AssertClientContext(request.client_context()); EXPECT_TRUE(request.client_context().is_cct()); EXPECT_TRUE(request.client_context().is_onboarding_shown()); EXPECT_TRUE(request.client_context().is_direct_action()); + EXPECT_THAT(request.client_context().accounts_matching_status(), + Eq(ClientContextProto::ACCOUNTS_MATCHING)); // Without flags. TriggerContextImpl trigger_context_no_flags(parameters, std::string()); @@ -147,12 +154,42 @@ EXPECT_TRUE( request.ParseFromString(ProtocolUtils::CreateInitialScriptActionsRequest( "script_path", GURL("http://example.com/"), trigger_context_no_flags, - "global_payload", "script_payload", CreateClientContextProto()))); + "global_payload", "script_payload", CreateClientContextProto(), + "accountsha"))); AssertClientContext(request.client_context()); EXPECT_FALSE(request.client_context().is_cct()); EXPECT_FALSE(request.client_context().is_onboarding_shown()); EXPECT_FALSE(request.client_context().is_direct_action()); + EXPECT_THAT(request.client_context().accounts_matching_status(), + Eq(ClientContextProto::UNKNOWN)); +} + +TEST(ProtocolUtilsTest, + TestCreateInitialScriptActionsRequestAccountsNotMatching) { + std::map<std::string, std::string> parameters; + + ScriptActionRequestProto request; + + // With flags. + TriggerContextImpl trigger_context_flags(parameters, std::string()); + trigger_context_flags.SetCCT(true); + trigger_context_flags.SetOnboardingShown(true); + trigger_context_flags.SetDirectAction(true); + trigger_context_flags.SetCallerAccountHash("accountsha"); + + EXPECT_TRUE( + request.ParseFromString(ProtocolUtils::CreateInitialScriptActionsRequest( + "script_path", GURL("http://example.com/"), trigger_context_flags, + "global_payload", "script_payload", CreateClientContextProto(), + "differentaccountsha"))); + + AssertClientContext(request.client_context()); + EXPECT_TRUE(request.client_context().is_cct()); + EXPECT_TRUE(request.client_context().is_onboarding_shown()); + EXPECT_TRUE(request.client_context().is_direct_action()); + EXPECT_THAT(request.client_context().accounts_matching_status(), + Eq(ClientContextProto::ACCOUNTS_NOT_MATCHING)); } TEST(ProtocolUtilsTest, CreateNextScriptActionsRequest) { @@ -167,7 +204,7 @@ EXPECT_TRUE( request.ParseFromString(ProtocolUtils::CreateNextScriptActionsRequest( trigger_context, "global_payload", "script_payload", - processed_actions, CreateClientContextProto()))); + processed_actions, CreateClientContextProto(), "accountsha"))); AssertClientContext(request.client_context()); EXPECT_THAT(request.client_context().experiment_ids(), Eq("1,2,3")); @@ -187,16 +224,19 @@ trigger_context_flags.SetCCT(true); trigger_context_flags.SetOnboardingShown(true); trigger_context_flags.SetDirectAction(true); + trigger_context_flags.SetCallerAccountHash("accountsha"); EXPECT_TRUE( request.ParseFromString(ProtocolUtils::CreateNextScriptActionsRequest( trigger_context_flags, "global_payload", "script_payload", - processed_actions, CreateClientContextProto()))); + processed_actions, CreateClientContextProto(), "accountsha"))); AssertClientContext(request.client_context()); EXPECT_TRUE(request.client_context().is_cct()); EXPECT_TRUE(request.client_context().is_onboarding_shown()); EXPECT_TRUE(request.client_context().is_direct_action()); + EXPECT_THAT(request.client_context().accounts_matching_status(), + Eq(ClientContextProto::ACCOUNTS_MATCHING)); // Without flags. TriggerContextImpl trigger_context_no_flags(parameters, std::string()); @@ -204,12 +244,14 @@ EXPECT_TRUE( request.ParseFromString(ProtocolUtils::CreateNextScriptActionsRequest( trigger_context_no_flags, "global_payload", "script_payload", - processed_actions, CreateClientContextProto()))); + processed_actions, CreateClientContextProto(), "accountsha"))); AssertClientContext(request.client_context()); EXPECT_FALSE(request.client_context().is_cct()); EXPECT_FALSE(request.client_context().is_onboarding_shown()); EXPECT_FALSE(request.client_context().is_direct_action()); + EXPECT_THAT(request.client_context().accounts_matching_status(), + Eq(ClientContextProto::UNKNOWN)); } TEST(ProtocolUtilsTest, CreateGetScriptsRequest) { @@ -221,14 +263,16 @@ SupportsScriptRequestProto request; EXPECT_TRUE(request.ParseFromString(ProtocolUtils::CreateGetScriptsRequest( - GURL("http://example.com/"), trigger_context, - CreateClientContextProto()))); + GURL("http://example.com/"), trigger_context, CreateClientContextProto(), + "accountsha"))); AssertClientContext(request.client_context()); EXPECT_THAT(request.client_context().experiment_ids(), Eq("1,2,3")); EXPECT_FALSE(request.client_context().is_cct()); EXPECT_FALSE(request.client_context().is_onboarding_shown()); EXPECT_TRUE(request.client_context().is_direct_action()); + EXPECT_THAT(request.client_context().accounts_matching_status(), + Eq(ClientContextProto::UNKNOWN)); EXPECT_EQ("http://example.com/", request.url()); ASSERT_EQ(2, request.script_parameters_size()); @@ -247,27 +291,32 @@ trigger_context_flags.SetCCT(true); trigger_context_flags.SetOnboardingShown(true); trigger_context_flags.SetDirectAction(true); + trigger_context_flags.SetCallerAccountHash("accountsha"); EXPECT_TRUE(request.ParseFromString(ProtocolUtils::CreateGetScriptsRequest( GURL("http://example.com/"), trigger_context_flags, - CreateClientContextProto()))); + CreateClientContextProto(), "accountsha"))); AssertClientContext(request.client_context()); EXPECT_TRUE(request.client_context().is_cct()); EXPECT_TRUE(request.client_context().is_onboarding_shown()); EXPECT_TRUE(request.client_context().is_direct_action()); + EXPECT_THAT(request.client_context().accounts_matching_status(), + Eq(ClientContextProto::ACCOUNTS_MATCHING)); // Without flags. TriggerContextImpl trigger_context_no_flags(parameters, std::string()); EXPECT_TRUE(request.ParseFromString(ProtocolUtils::CreateGetScriptsRequest( GURL("http://example.com/"), trigger_context_no_flags, - CreateClientContextProto()))); + CreateClientContextProto(), "accountsha"))); AssertClientContext(request.client_context()); EXPECT_FALSE(request.client_context().is_cct()); EXPECT_FALSE(request.client_context().is_onboarding_shown()); EXPECT_FALSE(request.client_context().is_direct_action()); + EXPECT_THAT(request.client_context().accounts_matching_status(), + Eq(ClientContextProto::UNKNOWN)); } TEST(ProtocolUtilsTest, AddScriptIgnoreInvalid) {
diff --git a/components/autofill_assistant/browser/service.proto b/components/autofill_assistant/browser/service.proto index 068b88a..5437ddcd 100644 --- a/components/autofill_assistant/browser/service.proto +++ b/components/autofill_assistant/browser/service.proto
@@ -66,6 +66,19 @@ optional string model = 3; } optional DeviceContextProto device_context = 11; + + enum AccountsMatchingStatus { + // The account was not present in the intent. + UNKNOWN = 0; + + // The account in the intent and the current chrome account match. + ACCOUNTS_MATCHING = 1; + + // The account in the intent and the current chrome account DON'T match. + ACCOUNTS_NOT_MATCHING = 2; + } + // Whether the account from the intent and the chrome account match. + optional AccountsMatchingStatus accounts_matching_status = 12; } // Get the list of scripts that can potentially be run on a url.
diff --git a/components/autofill_assistant/browser/service_impl.cc b/components/autofill_assistant/browser/service_impl.cc index 934ea6f..720cecd4 100644 --- a/components/autofill_assistant/browser/service_impl.cc +++ b/components/autofill_assistant/browser/service_impl.cc
@@ -19,6 +19,7 @@ #include "components/version_info/version_info.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/storage_partition.h" +#include "crypto/sha2.h" #include "net/base/load_flags.h" #include "net/http/http_request_headers.h" #include "net/http/http_status_code.h" @@ -66,8 +67,8 @@ return std::make_unique<ServiceImpl>( client->GetApiKey(), server_url, context, client->GetAccessTokenFetcher(), - client->GetLocale(), client->GetCountryCode(), - client->GetDeviceContext()); + client->GetLocale(), client->GetCountryCode(), client->GetDeviceContext(), + client); } ServiceImpl::ServiceImpl(const std::string& api_key, @@ -76,7 +77,8 @@ AccessTokenFetcher* access_token_fetcher, const std::string& locale, const std::string& country_code, - const DeviceContext& device_context) + const DeviceContext& device_context, + const Client* client) : context_(context), api_key_(api_key), access_token_fetcher_(access_token_fetcher), @@ -86,6 +88,7 @@ switches::kAutofillAssistantAuth)), client_context_( CreateClientContext(locale, country_code, device_context)), + client_(client), weak_ptr_factory_(this) { DCHECK(server_url.is_valid()); @@ -106,10 +109,11 @@ ResponseCallback callback) { DCHECK(url.is_valid()); - SendRequest(AddLoader(script_server_url_, - ProtocolUtils::CreateGetScriptsRequest( - url, trigger_context, client_context_), - std::move(callback))); + SendRequest(AddLoader( + script_server_url_, + ProtocolUtils::CreateGetScriptsRequest( + url, trigger_context, client_context_, GetClientAccountHash()), + std::move(callback))); } void ServiceImpl::GetActions(const std::string& script_path, @@ -120,11 +124,12 @@ ResponseCallback callback) { DCHECK(!script_path.empty()); - SendRequest(AddLoader(script_action_server_url_, - ProtocolUtils::CreateInitialScriptActionsRequest( - script_path, url, trigger_context, global_payload, - script_payload, client_context_), - std::move(callback))); + SendRequest( + AddLoader(script_action_server_url_, + ProtocolUtils::CreateInitialScriptActionsRequest( + script_path, url, trigger_context, global_payload, + script_payload, client_context_, GetClientAccountHash()), + std::move(callback))); } void ServiceImpl::GetNextActions( @@ -137,7 +142,7 @@ script_action_server_url_, ProtocolUtils::CreateNextScriptActionsRequest( trigger_context, previous_global_payload, previous_script_payload, - processed_actions, client_context_), + processed_actions, client_context_, GetClientAccountHash()), std::move(callback))); } @@ -276,6 +281,13 @@ } } +std::string ServiceImpl::GetClientAccountHash() const { + std::string chrome_account_sha_bin = + crypto::SHA256HashString(client_->GetAccountEmailAddress()); + return base::ToLowerASCII(base::HexEncode(chrome_account_sha_bin.data(), + chrome_account_sha_bin.size())); +} + // static ClientContextProto ServiceImpl::CreateClientContext( const std::string& locale,
diff --git a/components/autofill_assistant/browser/service_impl.h b/components/autofill_assistant/browser/service_impl.h index 3a0389c1..57aa4b2 100644 --- a/components/autofill_assistant/browser/service_impl.h +++ b/components/autofill_assistant/browser/service_impl.h
@@ -45,7 +45,8 @@ AccessTokenFetcher* token_fetcher, const std::string& locale, const std::string& country_code, - const DeviceContext& device_context); + const DeviceContext& device_context, + const Client* client); ~ServiceImpl() override; // Get scripts for a given |url|, which should be a valid URL. @@ -71,6 +72,8 @@ ResponseCallback callback) override; private: + friend class ServiceImplTest; + // Struct to store scripts and actions request. struct Loader { Loader(); @@ -100,6 +103,7 @@ // in |loaders_|. void FetchAccessToken(); void OnFetchAccessToken(bool success, const std::string& access_token); + std::string GetClientAccountHash() const; // Creates and fills a client context protobuf message. static ClientContextProto CreateClientContext( @@ -134,6 +138,8 @@ // every message. const ClientContextProto client_context_; + const Client* client_; + base::WeakPtrFactory<ServiceImpl> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(ServiceImpl);
diff --git a/components/autofill_assistant/browser/service_impl_unittest.cc b/components/autofill_assistant/browser/service_impl_unittest.cc new file mode 100644 index 0000000..f5616a48 --- /dev/null +++ b/components/autofill_assistant/browser/service_impl_unittest.cc
@@ -0,0 +1,44 @@ +// Copyright 2020 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 "components/autofill_assistant/browser/service_impl.h" + +#include "components/autofill/core/browser/personal_data_manager.h" +#include "components/autofill_assistant/browser/client.h" +#include "components/autofill_assistant/browser/device_context.h" +#include "components/autofill_assistant/browser/metrics.h" +#include "components/autofill_assistant/browser/mock_client.h" +#include "components/autofill_assistant/browser/website_login_fetcher.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace autofill_assistant { + +using ::testing::Return; + +class ServiceImplTest : public ::testing::Test { + public: + ServiceImplTest() { + ON_CALL(mock_client_, GetServerUrl) + .WillByDefault(Return("https://www.google.com/")); + + service_impl_ = ServiceImpl::Create(nullptr, &mock_client_); + } + + protected: + std::string GetClientAccountHash() { + return service_impl_->GetClientAccountHash(); + } + + MockClient mock_client_; + std::unique_ptr<ServiceImpl> service_impl_; +}; + +TEST_F(ServiceImplTest, CreatesValidHashFromEmail) { + ON_CALL(mock_client_, GetAccountEmailAddress) + .WillByDefault(Return("john.doe@chromium.org")); + EXPECT_EQ(GetClientAccountHash(), + "2c8fa87717fab622bb5cc4d18135fe30dae339efd274b450022d361be92b48c3"); +} + +} // namespace autofill_assistant
diff --git a/components/autofill_assistant/browser/trigger_context.cc b/components/autofill_assistant/browser/trigger_context.cc index a2e13813..f3241f2 100644 --- a/components/autofill_assistant/browser/trigger_context.cc +++ b/components/autofill_assistant/browser/trigger_context.cc
@@ -34,6 +34,7 @@ const std::string& experiment_ids) : parameters_(std::move(parameters)), experiment_ids_(std::move(experiment_ids)) {} + TriggerContextImpl::~TriggerContextImpl() = default; void TriggerContextImpl::AddParameters( @@ -70,6 +71,10 @@ return direct_action_; } +std::string TriggerContextImpl::get_caller_account_hash() const { + return caller_account_hash_; +} + MergedTriggerContext::MergedTriggerContext( std::vector<const TriggerContext*> contexts) : contexts_(contexts) {} @@ -132,4 +137,12 @@ return false; } +std::string MergedTriggerContext::get_caller_account_hash() const { + for (const TriggerContext* context : contexts_) { + if (!context->get_caller_account_hash().empty()) + return context->get_caller_account_hash(); + } + return ""; +} + } // namespace autofill_assistant
diff --git a/components/autofill_assistant/browser/trigger_context.h b/components/autofill_assistant/browser/trigger_context.h index 11e78d1..2b62cd3e 100644 --- a/components/autofill_assistant/browser/trigger_context.h +++ b/components/autofill_assistant/browser/trigger_context.h
@@ -59,6 +59,8 @@ // Returns true if the current action was triggered by a direct action. virtual bool is_direct_action() const = 0; + + virtual std::string get_caller_account_hash() const = 0; }; // Straightforward implementation of TriggerContext. @@ -82,11 +84,15 @@ void SetCCT(bool value) { cct_ = value; } void SetOnboardingShown(bool value) { onboarding_shown_ = value; } void SetDirectAction(bool value) { direct_action_ = value; } + void SetCallerAccountHash(const std::string& value) { + caller_account_hash_ = value; + } std::string experiment_ids() const override; bool is_cct() const override; bool is_onboarding_shown() const override; bool is_direct_action() const override; + std::string get_caller_account_hash() const override; private: // Script parameters provided by the caller. @@ -101,6 +107,8 @@ bool direct_action_ = false; bool onboarding_shown_ = false; + + std::string caller_account_hash_ = ""; }; // Merges several TriggerContexts together. @@ -120,6 +128,7 @@ bool is_cct() const override; bool is_onboarding_shown() const override; bool is_direct_action() const override; + std::string get_caller_account_hash() const override; private: std::vector<const TriggerContext*> contexts_;
diff --git a/components/autofill_assistant/browser/trigger_context_unittest.cc b/components/autofill_assistant/browser/trigger_context_unittest.cc index 890841d2d..38b3683 100644 --- a/components/autofill_assistant/browser/trigger_context_unittest.cc +++ b/components/autofill_assistant/browser/trigger_context_unittest.cc
@@ -146,5 +146,20 @@ EXPECT_TRUE(one_direct_action->is_direct_action()); } +TEST(TriggerContextText, MergeAccountsMatchingStatusTest) { + auto empty = TriggerContext::CreateEmpty(); + + auto all_empty = TriggerContext::Merge({empty.get(), empty.get()}); + EXPECT_EQ(all_empty->get_caller_account_hash(), ""); + + TriggerContextImpl context_matching; + context_matching.SetCallerAccountHash("accountsha"); + auto one_with_accounts_matching = + TriggerContext::Merge({empty.get(), &context_matching, empty.get()}); + + EXPECT_EQ(one_with_accounts_matching->get_caller_account_hash(), + "accountsha"); +} + } // namespace } // namespace autofill_assistant
diff --git a/components/browser_ui/modaldialog/android/java/src/org/chromium/components/browser_ui/modaldialog/AppModalPresenter.java b/components/browser_ui/modaldialog/android/java/src/org/chromium/components/browser_ui/modaldialog/AppModalPresenter.java index ef58ec8..fdf19a0c 100644 --- a/components/browser_ui/modaldialog/android/java/src/org/chromium/components/browser_ui/modaldialog/AppModalPresenter.java +++ b/components/browser_ui/modaldialog/android/java/src/org/chromium/components/browser_ui/modaldialog/AppModalPresenter.java
@@ -13,7 +13,6 @@ import androidx.annotation.VisibleForTesting; -import org.chromium.base.StrictModeContext; import org.chromium.ui.modaldialog.DialogDismissalCause; import org.chromium.ui.modaldialog.ModalDialogManager; import org.chromium.ui.modaldialog.ModalDialogProperties; @@ -47,14 +46,6 @@ mContext = context; } - private ModalDialogView loadDialogView() { - // LayoutInflater may access the disk. - try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) { - return (ModalDialogView) LayoutInflater.from(mDialog.getContext()) - .inflate(R.layout.modal_dialog_view, null); - } - } - @Override protected void addDialogView(PropertyModel model) { int style = model.get(ModalDialogProperties.PRIMARY_BUTTON_FILLED) @@ -66,13 +57,11 @@ // Cancel on touch outside should be disabled by default. The ModelChangeProcessor wouldn't // notify change if the property is not set during initialization. mDialog.setCanceledOnTouchOutside(false); - ModalDialogView dialogView = loadDialogView(); + ModalDialogView dialogView = (ModalDialogView) LayoutInflater.from(mDialog.getContext()) + .inflate(R.layout.modal_dialog_view, null); mModelChangeProcessor = PropertyModelChangeProcessor.create(model, dialogView, new ViewBinder()); - // setContentView() can trigger using LayoutInflater, which may read from disk. - try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) { - mDialog.setContentView(dialogView); - } + mDialog.setContentView(dialogView); try { mDialog.show();
diff --git a/components/browser_ui/modaldialog/android/java/src/org/chromium/components/browser_ui/modaldialog/TabModalPresenter.java b/components/browser_ui/modaldialog/android/java/src/org/chromium/components/browser_ui/modaldialog/TabModalPresenter.java index 5788a592..7b2272d 100644 --- a/components/browser_ui/modaldialog/android/java/src/org/chromium/components/browser_ui/modaldialog/TabModalPresenter.java +++ b/components/browser_ui/modaldialog/android/java/src/org/chromium/components/browser_ui/modaldialog/TabModalPresenter.java
@@ -18,7 +18,6 @@ import androidx.annotation.VisibleForTesting; import androidx.core.view.ViewCompat; -import org.chromium.base.StrictModeContext; import org.chromium.content_public.browser.SelectionPopupController; import org.chromium.content_public.browser.WebContents; import org.chromium.ui.interpolators.BakedBezierInterpolator; @@ -106,14 +105,6 @@ return mDialogContainer; } - private ModalDialogView loadDialogView(int style) { - // LayoutInflater may access the disk. - try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) { - return (ModalDialogView) LayoutInflater.from(new ContextThemeWrapper(mContext, style)) - .inflate(R.layout.modal_dialog_view, null); - } - } - @Override protected void addDialogView(PropertyModel model) { if (mDialogContainer == null) mDialogContainer = createDialogContainer(); @@ -121,7 +112,9 @@ int style = model.get(ModalDialogProperties.PRIMARY_BUTTON_FILLED) ? R.style.Theme_Chromium_ModalDialog_FilledPrimaryButton : R.style.Theme_Chromium_ModalDialog_TextPrimaryButton; - mDialogView = loadDialogView(style); + mDialogView = + (ModalDialogView) LayoutInflater.from(new ContextThemeWrapper(mContext, style)) + .inflate(R.layout.modal_dialog_view, null); mModelChangeProcessor = PropertyModelChangeProcessor.create(model, mDialogView, new ViewBinder());
diff --git a/components/cast_channel/cast_message_handler.cc b/components/cast_channel/cast_message_handler.cc index f3a1f34..d009507 100644 --- a/components/cast_channel/cast_message_handler.cc +++ b/components/cast_channel/cast_message_handler.cc
@@ -94,6 +94,33 @@ DoEnsureConnection(socket, source_id, destination_id); } +void CastMessageHandler::CloseConnection(int channel_id, + const std::string& source_id, + const std::string& destination_id) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + CastSocket* socket = socket_service_->GetSocket(channel_id); + if (!socket) { + return; + } + + VirtualConnection connection(socket->id(), source_id, destination_id); + if (virtual_connections_.find(connection) == virtual_connections_.end()) + return; + + VLOG(1) << "Closing VC for channel: " << connection.channel_id + << ", source: " << connection.source_id + << ", dest: " << connection.destination_id; + socket->transport()->SendMessage( + CreateVirtualConnectionClose(connection.source_id, + connection.destination_id), + base::BindOnce(&CastMessageHandler::OnMessageSent, + weak_ptr_factory_.GetWeakPtr())); + + // Assume the virtual connection close will succeed. Eventually the receiver + // will remove the connection even if it doesn't. + virtual_connections_.erase(connection); +} + CastMessageHandler::PendingRequests* CastMessageHandler::GetOrCreatePendingRequests(int channel_id) { CastMessageHandler::PendingRequests* requests = nullptr; @@ -300,9 +327,6 @@ void CastMessageHandler::OnMessage(const CastSocket& socket, const CastMessage& message) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - DVLOG(2) << __func__ << ", channel_id: " << socket.id() - << ", message: " << message; - // TODO(jrw): Splitting internal messages into a separate code path with a // separate data type is pretty questionable, because it causes duplicated // code paths in the downstream logic (manifested as separate OnAppMessage and @@ -310,6 +334,8 @@ if (IsCastInternalNamespace(message.namespace_())) { if (message.payload_type() == cast::channel::CastMessage_PayloadType_STRING) { + VLOG(1) << __func__ << ": channel_id: " << socket.id() + << ", message: " << message; parse_json_.Run( message.payload_utf8(), base::BindOnce(&CastMessageHandler::HandleCastInternalMessage, @@ -390,6 +416,8 @@ // A virtual connection must be opened to the receiver before other messages // can be sent. DoEnsureConnection(socket, message.source_id(), message.destination_id()); + VLOG(1) << __func__ << ": channel_id: " << socket->id() + << ", message: " << message; socket->transport()->SendMessage( message, base::BindOnce(&CastMessageHandler::OnMessageSent, weak_ptr_factory_.GetWeakPtr())); @@ -404,9 +432,9 @@ if (virtual_connections_.find(connection) != virtual_connections_.end()) return; - DVLOG(1) << "Creating VC for channel: " << connection.channel_id - << ", source: " << connection.source_id - << ", dest: " << connection.destination_id; + VLOG(1) << "Creating VC for channel: " << connection.channel_id + << ", source: " << connection.source_id + << ", dest: " << connection.destination_id; CastMessage virtual_connection_request = CreateVirtualConnectionRequest( connection.source_id, connection.destination_id, connection.destination_id == kPlatformReceiverId
diff --git a/components/cast_channel/cast_message_handler.h b/components/cast_channel/cast_message_handler.h index 45437352a..60d8c9b3 100644 --- a/components/cast_channel/cast_message_handler.h +++ b/components/cast_channel/cast_message_handler.h
@@ -153,6 +153,13 @@ const std::string& source_id, const std::string& destination_id); + // Closes any virtual connection on (|source_id|, |destination_id|) on the + // device given by |channel_id|, sending a virtual connection close request to + // the device if necessary. + virtual void CloseConnection(int channel_id, + const std::string& source_id, + const std::string& destination_id); + // Sends an app availability for |app_id| to the device given by |socket|. // |callback| is always invoked asynchronously, and will be invoked when a // response is received, or if the request timed out. No-ops if there is
diff --git a/components/cast_channel/cast_message_handler_unittest.cc b/components/cast_channel/cast_message_handler_unittest.cc index 038cf3f..db9f58a 100644 --- a/components/cast_channel/cast_message_handler_unittest.cc +++ b/components/cast_channel/cast_message_handler_unittest.cc
@@ -277,6 +277,20 @@ handler_.EnsureConnection(channel_id_, kSourceId, kDestinationId); } +TEST_F(CastMessageHandlerTest, CloseConnection) { + ExpectEnsureConnection(); + handler_.EnsureConnection(channel_id_, kSourceId, kDestinationId); + + EXPECT_CALL( + *transport_, + SendMessage(HasMessageType(CastMessageType::kCloseConnection), _)); + handler_.CloseConnection(channel_id_, kSourceId, kDestinationId); + + // Re-open virtual connection should cause CONNECT message to be sent. + ExpectEnsureConnection(); + handler_.EnsureConnection(channel_id_, kSourceId, kDestinationId); +} + TEST_F(CastMessageHandlerTest, CloseConnectionFromReceiver) { ExpectEnsureConnection(); handler_.EnsureConnection(channel_id_, kSourceId, kDestinationId);
diff --git a/components/cast_channel/cast_message_util.cc b/components/cast_channel/cast_message_util.cc index da71cd3..959e504b 100644 --- a/components/cast_channel/cast_message_util.cc +++ b/components/cast_channel/cast_message_util.cc
@@ -107,6 +107,10 @@ // stands for CONNECTION_TYPE_LOCAL, which is the only type used in Chrome. constexpr int kVirtualConnectTypeLocal = 1; +// The reason code passed to the virtual connection CLOSE message indicating +// that the connection has been gracefully closed by the sender. +constexpr int kVirtualConnectionClosedByPeer = 5; + void FillCommonCastMessageFields(CastMessage* message, const std::string& source_id, const std::string& destination_id, @@ -349,6 +353,18 @@ destination_id); } +CastMessage CreateVirtualConnectionClose(const std::string& source_id, + const std::string& destination_id) { + Value dict(Value::Type::DICTIONARY); + dict.SetKey( + "type", + Value( + EnumToString<CastMessageType, CastMessageType::kCloseConnection>())); + dict.SetKey("reasonCode", Value(kVirtualConnectionClosedByPeer)); + return CreateCastMessage(kConnectionNamespace, dict, source_id, + destination_id); +} + CastMessage CreateGetAppAvailabilityRequest(const std::string& source_id, int request_id, const std::string& app_id) {
diff --git a/components/cast_channel/cast_message_util.h b/components/cast_channel/cast_message_util.h index 068211a..695d401 100644 --- a/components/cast_channel/cast_message_util.h +++ b/components/cast_channel/cast_message_util.h
@@ -202,6 +202,9 @@ const std::string& user_agent, const std::string& browser_version); +CastMessage CreateVirtualConnectionClose(const std::string& source_id, + const std::string& destination_id); + // Creates an app availability request for |app_id| from |source_id| with // ID |request_id|. // TODO(imcheng): May not need |source_id|, just use sender-0?
diff --git a/components/cast_channel/cast_message_util_unittest.cc b/components/cast_channel/cast_message_util_unittest.cc index a580675..9515808 100644 --- a/components/cast_channel/cast_message_util_unittest.cc +++ b/components/cast_channel/cast_message_util_unittest.cc
@@ -88,6 +88,23 @@ EXPECT_THAT(message.payload_utf8(), IsJson(expected_message)); } +TEST(CastMessageUtilTest, CreateVirtualConnectionClose) { + std::string expected_message = R"( + { + "type": "CLOSE", + "reasonCode": 5 + } + )"; + + CastMessage message = + CreateVirtualConnectionClose("sourceId", "destinationId"); + ASSERT_TRUE(IsCastMessageValid(message)); + EXPECT_EQ(message.source_id(), "sourceId"); + EXPECT_EQ(message.destination_id(), "destinationId"); + EXPECT_EQ(message.namespace_(), kConnectionNamespace); + EXPECT_THAT(message.payload_utf8(), IsJson(expected_message)); +} + TEST(CastMessageUtilTest, CreateReceiverStatusRequest) { std::string expected_message = R"( {
diff --git a/components/cast_channel/cast_test_util.h b/components/cast_channel/cast_test_util.h index 39fd20c..44a8e0e 100644 --- a/components/cast_channel/cast_test_util.h +++ b/components/cast_channel/cast_test_util.h
@@ -167,6 +167,8 @@ MOCK_METHOD3(EnsureConnection, void(int, const std::string&, const std::string&)); + MOCK_METHOD3(CloseConnection, + void(int, const std::string&, const std::string&)); MOCK_METHOD3(RequestAppAvailability, void(CastSocket* socket, const std::string& app_id,
diff --git a/components/certificate_transparency/chrome_require_ct_delegate_unittest.cc b/components/certificate_transparency/chrome_require_ct_delegate_unittest.cc index 8620c44..4b9ce4d 100644 --- a/components/certificate_transparency/chrome_require_ct_delegate_unittest.cc +++ b/components/certificate_transparency/chrome_require_ct_delegate_unittest.cc
@@ -30,13 +30,12 @@ class ChromeRequireCTDelegateTest : public ::testing::Test { public: void SetUp() override { - // Use a certificate with a notBefore prior to May 2018, so that CT is not - // implicitly required. cert_ = net::CreateCertificateChainFromFile( - net::GetTestCertsDirectory(), "expired_cert.pem", + net::GetTestCertsDirectory(), "ok_cert.pem", net::X509Certificate::FORMAT_PEM_CERT_SEQUENCE); ASSERT_TRUE(cert_); - hashes_.push_back(net::HashValue(net::SHA256HashValue{0})); + hashes_.push_back(net::HashValue( + net::X509Certificate::CalculateFingerprint256(cert_->cert_buffer()))); } protected:
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_features.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_features.cc index 0b365a3..f29a0e1 100644 --- a/components/data_reduction_proxy/core/common/data_reduction_proxy_features.cc +++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_features.cc
@@ -9,7 +9,6 @@ namespace data_reduction_proxy { namespace features { - // Enables the data saver promo for low memory Android devices. const base::Feature kDataReductionProxyLowMemoryDevicePromo{ "DataReductionProxyLowMemoryDevicePromo", @@ -27,9 +26,8 @@ // Enables data reduction proxy when network service is enabled. const base::Feature kDataReductionProxyEnabledWithNetworkService{ - "DataReductionProxyEnabledWithNetworkService", - base::FEATURE_ENABLED_BY_DEFAULT -}; + "DataReductionProxyEnabledWithNetworkService", + base::FEATURE_ENABLED_BY_DEFAULT}; // Enables block action of all proxies when 502 is received with no // Chrome-Proxy header. The block duration is configurable via field trial with @@ -67,5 +65,9 @@ const base::Feature kReportSaveDataSavings{"ReportSaveDataSavings", base::FEATURE_DISABLED_BY_DEFAULT}; +// Enables fetching the Client Config for server-based Lite Mode features. +const base::Feature kFetchClientConfig{"DataReductionProxyFetchClientConfig", + base::FEATURE_ENABLED_BY_DEFAULT}; + } // namespace features } // namespace data_reduction_proxy
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_features.h b/components/data_reduction_proxy/core/common/data_reduction_proxy_features.h index 66c6dff..881b8f52 100644 --- a/components/data_reduction_proxy/core/common/data_reduction_proxy_features.h +++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_features.h
@@ -21,6 +21,7 @@ extern const base::Feature kDataReductionProxyServerExperiments; extern const base::Feature kDataReductionProxyAggressiveConfigFetch; extern const base::Feature kReportSaveDataSavings; +extern const base::Feature kFetchClientConfig; } // namespace features } // namespace data_reduction_proxy
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc index 9f1c5be..e6d8968 100644 --- a/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc +++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc
@@ -91,16 +91,10 @@ } bool ForceEnableClientConfigServiceForAllDataSaverUsers() { - // Client config is enabled for all data users that are not in the - // kDataReductionProxyHoldback. Users that have kDataReductionProxyHoldback - // enabled have config service client enabled only if - // |force_enable_config_service_fetches| is set to true. - return GetFieldTrialParamByFeatureAsBool( - data_reduction_proxy::features::kDataReductionProxyHoldback, - "force_enable_config_service_fetches", false); + return base::FeatureList::IsEnabled( + data_reduction_proxy::features::kFetchClientConfig); } - bool IsForcePingbackEnabledViaFlags() { return base::CommandLine::ForCurrentProcess()->HasSwitch( data_reduction_proxy::switches::kEnableDataReductionProxyForcePingback); @@ -288,8 +282,6 @@ features::kDataReductionProxyServerExperiments, kExperimentsOption); } - - bool IsEnabledWithNetworkService() { return base::FeatureList::IsEnabled( data_reduction_proxy::features::
diff --git a/components/embedder_support/android/BUILD.gn b/components/embedder_support/android/BUILD.gn index e627f3c..bf38a56 100644 --- a/components/embedder_support/android/BUILD.gn +++ b/components/embedder_support/android/BUILD.gn
@@ -15,6 +15,7 @@ android_library("util_java") { sources = [ + "java/src/org/chromium/components/embedder_support/util/Origin.java", "java/src/org/chromium/components/embedder_support/util/UrlConstants.java", "java/src/org/chromium/components/embedder_support/util/UrlUtilities.java", ] @@ -212,3 +213,13 @@ "//third_party/robolectric:robolectric_all_java", ] } + +junit_binary("components_embedder_support_junit_tests") { + sources = [ + "junit/src/org/chromium/components/embedder_support/util/OriginTest.java", + ] + deps = [ + ":util_java", + "//base:base_junit_test_support", + ] +}
diff --git a/components/embedder_support/android/java/src/org/chromium/components/embedder_support/delegate/ColorChooserAndroid.java b/components/embedder_support/android/java/src/org/chromium/components/embedder_support/delegate/ColorChooserAndroid.java index c68c7fe2..8173794f 100644 --- a/components/embedder_support/android/java/src/org/chromium/components/embedder_support/delegate/ColorChooserAndroid.java +++ b/components/embedder_support/android/java/src/org/chromium/components/embedder_support/delegate/ColorChooserAndroid.java
@@ -7,7 +7,6 @@ import android.content.Context; import org.chromium.base.ContextUtils; -import org.chromium.base.StrictModeContext; import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.NativeMethods; @@ -38,10 +37,7 @@ } private void openColorChooser() { - // This triggers LayoutInflater, which may access the disk. - try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) { - mDialog.show(); - } + mDialog.show(); } @CalledByNative
diff --git a/components/embedder_support/android/java/src/org/chromium/components/embedder_support/delegate/ColorPickerDialog.java b/components/embedder_support/android/java/src/org/chromium/components/embedder_support/delegate/ColorPickerDialog.java index 5b25f3a..dca3c3c 100644 --- a/components/embedder_support/android/java/src/org/chromium/components/embedder_support/delegate/ColorPickerDialog.java +++ b/components/embedder_support/android/java/src/org/chromium/components/embedder_support/delegate/ColorPickerDialog.java
@@ -13,8 +13,6 @@ import android.widget.Button; import android.widget.TextView; -import org.chromium.base.StrictModeContext; - /** * UI for the color chooser that shows on the Android platform as a result of * <input type=color > form element. @@ -35,15 +33,6 @@ private int mCurrentColor; - View inflateView(Context context, int id) { - // LayoutInflater may trigger accessing the disk. - try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) { - LayoutInflater inflater = - (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - return inflater.inflate(id, null); - } - } - /** * @param context The context the dialog is to run in. * @param listener The object to notify when the color is set. @@ -59,7 +48,9 @@ mCurrentColor = mInitialColor; // Initialize title - View title = inflateView(context, R.layout.color_picker_dialog_title); + LayoutInflater inflater = + (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + View title = inflater.inflate(R.layout.color_picker_dialog_title, null); setCustomTitle(title); mCurrentColorView = title.findViewById(R.id.selected_color_view); @@ -99,7 +90,7 @@ }); // Initialize main content view - View content = inflateView(context, R.layout.color_picker_dialog_content); + View content = inflater.inflate(R.layout.color_picker_dialog_content, null); setView(content); // Initialize More button.
diff --git a/components/embedder_support/android/java/src/org/chromium/components/embedder_support/util/Origin.java b/components/embedder_support/android/java/src/org/chromium/components/embedder_support/util/Origin.java new file mode 100644 index 0000000..35c86d606 --- /dev/null +++ b/components/embedder_support/android/java/src/org/chromium/components/embedder_support/util/Origin.java
@@ -0,0 +1,122 @@ +// Copyright 2018 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. + +package org.chromium.components.embedder_support.util; + +import android.net.Uri; + +import androidx.annotation.Nullable; + +/** + * A class to canonically represent a HTTP or HTTPS web origin in Java. In comparison to + * {@link org.chromium.net.GURLUtils#getOrigin} it can be used before native is loaded and lets us + * ensure conversion to an origin has been done with the type system. + * + * {@link #toString()} does <b>not</b> match {@link org.chromium.net.GURLUtils#getOrigin}. The + * latter will return a String with a trailing "/". Not having a trailing slash matches RFC + * behaviour (https://tools.ietf.org/html/rfc6454), it seems that + * {@link org.chromium.net.GURLUtils#getOrigin} adds it as a bug, but as its result is saved to + * user's Android Preferences, it is not trivial to change. + */ +public class Origin { + private static final int HTTP_DEFAULT_PORT = 80; + private static final int HTTPS_DEFAULT_PORT = 443; + + private final Uri mOrigin; + + // TODO(crbug.com/1058597): Make this private once it stops needing to be subclassed for Clank. + protected Origin(Uri origin) { + mOrigin = origin; + } + + /** + * Constructs a canonical Origin from a String. Will return {@code null} for origins that are + * not HTTP or HTTPS. + */ + @Nullable + public static Origin create(String uri) { + return create(Uri.parse(uri)); + } + + /** + * Constructs a canonical Origin from an Uri. Will return {@code null} for origins that are not + * HTTP or HTTPS. + */ + @Nullable + public static Origin create(Uri uri) { + if (uri == null || uri.getScheme() == null || uri.getAuthority() == null) { + return null; + } + + // This class can only correctly handle certain origins, see https://crbug.com/1019244. + String scheme = uri.getScheme(); + if (!scheme.equals(UrlConstants.HTTP_SCHEME) && !scheme.equals(UrlConstants.HTTPS_SCHEME)) { + return null; + } + + // Make explicit ports implicit and remove any user:password. + int port = uri.getPort(); + if (scheme.equals(UrlConstants.HTTP_SCHEME) && port == HTTP_DEFAULT_PORT) port = -1; + if (scheme.equals(UrlConstants.HTTPS_SCHEME) && port == HTTPS_DEFAULT_PORT) port = -1; + + String authority = uri.getHost(); + if (port != -1) authority += ":" + port; + + try { + return new Origin(uri.normalizeScheme() + .buildUpon() + .opaquePart("") + .fragment("") + .path("") + .encodedAuthority(authority) + .clearQuery() + .build()); + } catch (UnsupportedOperationException e) { + return null; + } + } + + /** + * Constructs a canonical Origin from a String, throwing an exception if parsing fails. + */ + public static Origin createOrThrow(String uri) { + return createOrThrow(Uri.parse(uri)); + } + + /** + * Constructs a canonical Origin from an Uri, throwing an exception if parsing fails. + */ + public static Origin createOrThrow(Uri uri) { + Origin origin = Origin.create(uri); + if (origin == null) throw new IllegalArgumentException("Could not parse: " + uri); + return origin; + } + + /* + * Returns a Uri representing the Origin. + */ + public Uri uri() { + return mOrigin; + } + + @Override + public int hashCode() { + return mOrigin.hashCode(); + } + + /** + * Returns a String representing the Origin. + */ + @Override + public String toString() { + return mOrigin.toString(); + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + if (other == null || getClass() != other.getClass()) return false; + return mOrigin.equals(((Origin) other).mOrigin); + } +}
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/OriginTest.java b/components/embedder_support/android/junit/src/org/chromium/components/embedder_support/util/OriginTest.java similarity index 95% rename from chrome/android/junit/src/org/chromium/chrome/browser/browserservices/OriginTest.java rename to components/embedder_support/android/junit/src/org/chromium/components/embedder_support/util/OriginTest.java index 11ffe8b..8be1437f 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/OriginTest.java +++ b/components/embedder_support/android/junit/src/org/chromium/components/embedder_support/util/OriginTest.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.browserservices; +package org.chromium.components.embedder_support.util; import android.net.Uri; import android.support.test.filters.SmallTest; @@ -56,8 +56,8 @@ Assert.assertEquals(host, origin.uri().getHost()); Assert.assertEquals(port, origin.uri().getPort()); - Assert.assertEquals(origin.toString(), - scheme + "://" + host + (port == -1 ? "" : ":" + port)); + Assert.assertEquals( + origin.toString(), scheme + "://" + host + (port == -1 ? "" : ":" + port)); } @Test
diff --git a/components/feed/core/v2/stream_model.cc b/components/feed/core/v2/stream_model.cc index 78a8c55..52d8ad0 100644 --- a/components/feed/core/v2/stream_model.cc +++ b/components/feed/core/v2/stream_model.cc
@@ -11,6 +11,7 @@ #include "base/strings/string_number_conversions.h" #include "components/feed/core/proto/v2/store.pb.h" #include "components/feed/core/proto/v2/wire/content_id.pb.h" +#include "components/feed/core/v2/stream_model_update_request.h" namespace feed { @@ -19,10 +20,24 @@ StreamModel::UiUpdate::UiUpdate(const UiUpdate&) = default; StreamModel::UiUpdate& StreamModel::UiUpdate::operator=(const UiUpdate&) = default; +StreamModel::StoreUpdate::StoreUpdate() = default; +StreamModel::StoreUpdate::~StoreUpdate() = default; +StreamModel::StoreUpdate::StoreUpdate(const StoreUpdate&) = default; +StreamModel::StoreUpdate& StreamModel::StoreUpdate::operator=( + const StoreUpdate&) = default; +StreamModel::StoreUpdate::StoreUpdate(StoreUpdate&&) = default; +StreamModel::StoreUpdate& StreamModel::StoreUpdate::operator=(StoreUpdate&&) = + default; StreamModel::StreamModel() = default; StreamModel::~StreamModel() = default; +void StreamModel::SetStoreObserver(StoreObserver* store_observer) { + DCHECK(!store_observer || !store_observer_) + << "Attempting to set store_observer multiple times"; + store_observer_ = store_observer; +} + void StreamModel::SetObserver(Observer* observer) { DCHECK(!observer || !observer_) << "Attempting to set the observer multiple times"; @@ -34,6 +49,36 @@ return GetFinalFeatureTree()->FindContent(revision); } +void StreamModel::Update( + std::unique_ptr<StreamModelUpdateRequest> update_request) { + feedstore::StreamData& stream_data = update_request->stream_data; + for (const feedstore::StreamStructure& structure : stream_data.structures()) { + base_feature_tree_.ApplyStreamStructure(structure); + } + for (feedstore::Content& content : update_request->content) { + base_feature_tree_.AddContent(std::move(content)); + } + + next_page_token_ = stream_data.next_page_token(); + last_added_time_ = + base::Time::UnixEpoch() + + base::TimeDelta::FromMilliseconds(stream_data.last_added_time_millis()); + consistency_token_ = stream_data.consistency_token(); + + // TODO(harringtond): consume shared state. + // TODO(harringtond): Some StreamData fields not yet used. + // next_action_id - do we need to load the model before uploading + // actions? If not, we probably will want to move this out of + // StreamData. + // content_id - probably just ignore for now + + // TODO(harringtond): Figure out how to forward network updates to storage. + // We can either update through |observer_|, or as part of the load stream + // task. + + UpdateFlattenedTree(); +} + EphemeralChangeId StreamModel::CreateEphemeralChange( std::vector<feedstore::DataOperation> operations) { const EphemeralChangeId id = @@ -46,14 +91,21 @@ void StreamModel::ExecuteOperations( std::vector<feedstore::DataOperation> operations) { - for (feedstore::DataOperation& operation : operations) { + for (const feedstore::DataOperation& operation : operations) { if (operation.has_structure()) { base_feature_tree_.ApplyStreamStructure(operation.structure()); } if (operation.has_content()) { - base_feature_tree_.AddContent(std::move(*operation.mutable_content())); + base_feature_tree_.AddContent(operation.content()); } } + + if (store_observer_) { + StoreUpdate store_update; + store_update.operations = std::move(operations); + store_observer_->OnStoreChange(std::move(store_update)); + } + UpdateFlattenedTree(); }
diff --git a/components/feed/core/v2/stream_model.h b/components/feed/core/v2/stream_model.h index 7420610..5e8d809e 100644 --- a/components/feed/core/v2/stream_model.h +++ b/components/feed/core/v2/stream_model.h
@@ -20,6 +20,7 @@ } // namespace feedwire namespace feed { +struct StreamModelUpdateRequest; // An in-memory stream model. class StreamModel { @@ -43,12 +44,29 @@ std::vector<SharedStateInfo> shared_states; }; + struct StoreUpdate { + StoreUpdate(); + ~StoreUpdate(); + StoreUpdate(const StoreUpdate&); + StoreUpdate(StoreUpdate&&); + StoreUpdate& operator=(const StoreUpdate&); + StoreUpdate& operator=(StoreUpdate&&); + + std::vector<feedstore::DataOperation> operations; + }; + class Observer { public: virtual ~Observer() = default; // Called when the UI model changes. virtual void OnUiUpdate(const UiUpdate& update) = 0; }; + class StoreObserver { + public: + // Called when the peristent store should be modified to reflect a model + // change. + virtual void OnStoreChange(const StoreUpdate& update) = 0; + }; explicit StreamModel(); ~StreamModel(); @@ -57,6 +75,7 @@ StreamModel& operator=(const StreamModel&) = delete; void SetObserver(Observer* observer); + void SetStoreObserver(StoreObserver* store_observer); // Data access. @@ -66,6 +85,10 @@ } // Returns the content identified by |ContentRevision|. const feedstore::Content* FindContent(ContentRevision revision) const; + + // Apply an update from the network or storage. + void Update(std::unique_ptr<StreamModelUpdateRequest> update_request); + // Apply |operations| to the model. void ExecuteOperations(std::vector<feedstore::DataOperation> operations); @@ -86,7 +109,7 @@ void UpdateFlattenedTree(); Observer* observer_ = nullptr; // Unowned. - + StoreObserver* store_observer_ = nullptr; // Unowned. stream_model::ContentIdMap id_map_; stream_model::FeatureTree base_feature_tree_{&id_map_}; // |base_feature_tree_| with |ephemeral_changes_| applied. @@ -94,6 +117,13 @@ std::unique_ptr<stream_model::FeatureTree> feature_tree_after_changes_; stream_model::EphemeralChangeList ephemeral_changes_; + // The following data is associated with the stream, but lives outside of the + // tree. + + std::string next_page_token_; // TODO(harringtond): use this value. + std::string consistency_token_; // TODO(harringtond): use this value. + base::Time last_added_time_; // TODO(harringtond): use this value. + // Current state of the flattened tree. // Updated after each tree change. std::vector<ContentRevision> content_list_;
diff --git a/components/feed/core/v2/stream_model/feature_tree.cc b/components/feed/core/v2/stream_model/feature_tree.cc index ad1701c1..7eecc5a7 100644 --- a/components/feed/core/v2/stream_model/feature_tree.cc +++ b/components/feed/core/v2/stream_model/feature_tree.cc
@@ -133,7 +133,6 @@ // these copies. const ContentTag tag = GetContentTag(content.content_id()); DCHECK(!content_.count(revision_id)); - GetOrMakeNode(tag)->content_revision = revision_id; content_[revision_id] = std::move(content); }
diff --git a/components/feed/core/v2/stream_model_unittest.cc b/components/feed/core/v2/stream_model_unittest.cc index 6cc4a24..82c06520 100644 --- a/components/feed/core/v2/stream_model_unittest.cc +++ b/components/feed/core/v2/stream_model_unittest.cc
@@ -7,11 +7,14 @@ #include "base/optional.h" #include "components/feed/core/proto/v2/store.pb.h" #include "components/feed/core/proto/v2/wire/content_id.pb.h" +#include "components/feed/core/v2/stream_model_update_request.h" #include "components/feed/core/v2/test/stream_builder.h" #include "testing/gtest/include/gtest/gtest.h" namespace feed { namespace { +using StoreUpdate = StreamModel::StoreUpdate; +using UiUpdate = StreamModel::UiUpdate; std::vector<std::string> GetContentFrames(const StreamModel& model) { std::vector<std::string> frames; @@ -29,20 +32,35 @@ class TestObserver : public StreamModel::Observer { public: explicit TestObserver(StreamModel* model) { model->SetObserver(this); } - void OnUiUpdate(const StreamModel::UiUpdate& update) override { - update_ = update; - } - const base::Optional<StreamModel::UiUpdate>& GetUiUpdate() const { - return update_; - } + // StreamModel::Observer. + void OnUiUpdate(const UiUpdate& update) override { update_ = update; } + const base::Optional<UiUpdate>& GetUiUpdate() const { return update_; } bool ContentListChanged() const { return update_ && update_->content_list_changed; } + void Clear() { update_ = base::nullopt; } private: - base::Optional<StreamModel::UiUpdate> update_; + base::Optional<UiUpdate> update_; +}; + +class TestStoreObserver : public StreamModel::StoreObserver { + public: + explicit TestStoreObserver(StreamModel* model) { + model->SetStoreObserver(this); + } + + // StreamModel::StoreObserver. + void OnStoreChange(const StoreUpdate& records) override { update_ = records; } + + const base::Optional<StoreUpdate>& GetUpdate() const { return update_; } + + void Clear() { update_ = base::nullopt; } + + private: + base::Optional<StoreUpdate> update_; }; TEST(StreamModelTest, ConstructEmptyModel) { @@ -52,15 +70,17 @@ EXPECT_EQ(0UL, model.GetContentList().size()); } -// Typical stream (Stream -> Cluster -> Content). -TEST(StreamModelTest, AddStreamClusterContent) { +TEST(StreamModelTest, ExecuteOperationsTypicalStream) { StreamModel model; TestObserver observer(&model); + TestStoreObserver store_observer(&model); model.ExecuteOperations(MakeTypicalStreamOperations()); - EXPECT_TRUE(observer.ContentListChanged()); EXPECT_EQ(std::vector<std::string>({"f:0", "f:1"}), GetContentFrames(model)); + ASSERT_TRUE(store_observer.GetUpdate()); + ASSERT_EQ(MakeTypicalStreamOperations().size(), + store_observer.GetUpdate()->operations.size()); } TEST(StreamModelTest, AddContentWithoutRoot) { @@ -264,14 +284,26 @@ TestObserver observer(&model); model.ExecuteOperations(MakeTypicalStreamOperations()); + EphemeralChangeId change_id = model.CreateEphemeralChange({ MakeOperation(MakeCluster(2, MakeRootId())), MakeOperation(MakeContentNode(2, MakeClusterId(2))), MakeOperation(MakeContent(2)), }); + observer.Clear(); + TestStoreObserver store_observer(&model); EXPECT_TRUE(model.CommitEphemeralChange(change_id)); + // Check that the observer's |OnStoreChange()| was called. + ASSERT_TRUE(store_observer.GetUpdate()); + StoreUpdate store_update = *store_observer.GetUpdate(); + ASSERT_EQ(3UL, store_update.operations.size()); + EXPECT_EQ(feedstore::StreamStructure::CLUSTER, + store_update.operations[0].structure().type()); + EXPECT_EQ(feedstore::StreamStructure::CONTENT, + store_update.operations[1].structure().type()); + // Can't reject after commit. EXPECT_FALSE(model.RejectEphemeralChange(change_id)); @@ -326,5 +358,26 @@ GetContentFrames(model)); } +TEST(StreamModelTest, InitialLoad) { + StreamModel model; + TestObserver observer(&model); + TestStoreObserver store_observer(&model); + auto initial_update = std::make_unique<StreamModelUpdateRequest>(); + initial_update->source = + StreamModelUpdateRequest::Source::kInitialLoadFromStore; + initial_update->content.push_back(MakeContent(0)); + *initial_update->stream_data.add_structures() = MakeStream(); + *initial_update->stream_data.add_structures() = MakeCluster(0, MakeRootId()); + *initial_update->stream_data.add_structures() = + MakeContentNode(0, MakeClusterId(0)); + + model.Update(std::move(initial_update)); + + // Check that content was added and the store doesn't receive its own update. + EXPECT_TRUE(observer.ContentListChanged()); + EXPECT_EQ(std::vector<std::string>({"f:0"}), GetContentFrames(model)); + EXPECT_FALSE(store_observer.GetUpdate()); +} + } // namespace } // namespace feed
diff --git a/components/feed/core/v2/stream_model_update_request.h b/components/feed/core/v2/stream_model_update_request.h index f164ae372..c1cb3f9 100644 --- a/components/feed/core/v2/stream_model_update_request.h +++ b/components/feed/core/v2/stream_model_update_request.h
@@ -46,10 +46,12 @@ // If this data originates from the network, this is the server-reported time // at which the request was fulfilled. + // TODO(harringtond): Use this or remove it. int64_t server_response_time; // If this data originates from the network, this is the time taken by the // server to produce the response. + // TODO(harringtond): Use this or remove it. base::TimeDelta response_time; };
diff --git a/components/javascript_dialogs/android/java/src/org/chromium/components/javascript_dialogs/JavascriptModalDialog.java b/components/javascript_dialogs/android/java/src/org/chromium/components/javascript_dialogs/JavascriptModalDialog.java index 13987940..cd2f213 100644 --- a/components/javascript_dialogs/android/java/src/org/chromium/components/javascript_dialogs/JavascriptModalDialog.java +++ b/components/javascript_dialogs/android/java/src/org/chromium/components/javascript_dialogs/JavascriptModalDialog.java
@@ -11,7 +11,6 @@ import androidx.annotation.StringRes; import org.chromium.base.Log; -import org.chromium.base.StrictModeContext; import org.chromium.ui.modaldialog.DialogDismissalCause; import org.chromium.ui.modaldialog.ModalDialogManager; import org.chromium.ui.modaldialog.ModalDialogProperties; @@ -53,11 +52,8 @@ protected void show(Context context, ModalDialogManager manager, @ModalDialogManager.ModalDialogType int dialogType) { assert manager != null; - // LayoutInflater may trigger accessing the disk. - try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) { - mDialogCustomView = (JavascriptDialogCustomView) LayoutInflater.from(context).inflate( - R.layout.js_modal_dialog, null); - } + mDialogCustomView = (JavascriptDialogCustomView) LayoutInflater.from(context).inflate( + R.layout.js_modal_dialog, null); mDialogCustomView.setPromptText(mDefaultPromptText); mDialogCustomView.setSuppressCheckBoxVisibility(mShouldShowSuppressCheckBox);
diff --git a/components/leveldb_proto/public/shared_proto_database_client_list.h b/components/leveldb_proto/public/shared_proto_database_client_list.h index b8aa746..7727fd7 100644 --- a/components/leveldb_proto/public/shared_proto_database_client_list.h +++ b/components/leveldb_proto/public/shared_proto_database_client_list.h
@@ -17,7 +17,8 @@ // The enum values are used to index into the shared database. Do not rearrange // or reuse the integer values. Add new database types at the end of the enum, -// and update the string mapping in ProtoDbTypeToString(). +// and update the string mapping in ProtoDbTypeToString(). Also update the +// suffix LevelDBClients in histograms.xml to match the strings for the types. enum class ProtoDbType { TEST_DATABASE0 = 0, TEST_DATABASE1 = 1,
diff --git a/components/lookalikes/lookalike_url_util.cc b/components/lookalikes/lookalike_url_util.cc index d29251a..a61affd2 100644 --- a/components/lookalikes/lookalike_url_util.cc +++ b/components/lookalikes/lookalike_url_util.cc
@@ -12,6 +12,7 @@ #include "base/memory/scoped_refptr.h" #include "base/memory/singleton.h" #include "base/metrics/histogram_macros.h" +#include "base/strings/string_split.h" #include "base/strings/utf_string_conversions.h" #include "base/task/post_task.h" #include "base/task/thread_pool.h" @@ -128,6 +129,56 @@ UMA_HISTOGRAM_ENUMERATION(lookalikes::kHistogramName, event); } +// Returns the parts of the url that are separated by "." or "-" not including +// the TLD. +std::vector<base::string16> SplitNonTLDDomainIntoTokens( + const base::string16& host) { + // Strip off TLD, and split the remaining URL by '-'s and '.'s. + // This assumes that the eTLD has only one part (eg. bbc.co.uk -> [bbc, co]). + // This increases false positives in ways that we need to investigate, since, + // e.g., google.co.uk will be identified as target embedding of google.co if + // .co is considered an important TLD. + base::string16::size_type last_dot = host.rfind('.'); + DCHECK_NE(base::string16::npos, last_dot); + base::string16 host_without_tld = host.substr(0, last_dot); + + return base::SplitString(host_without_tld, base::ASCIIToUTF16("-."), + base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); +} + +// For each possible e2LD+eTLD pair, check whether it forms a top domain. +bool IsTopDomainCandidate(const std::set<std::string>& important_tlds, + const base::string16& e2LD, + GURL* found_domain) { + // We need to identify top domains, even when the spoof uses the 'wrong' TLD + // (e.g. google.gov). To do that, we check the embedded domain with each + // possible |important_tld| against the top domain list. + for (const auto& tld : important_tlds) { + // Create a GURL so we can get a DomainInfo from it for IsTopDomain + // e2LD is the smallest unit of a domain name that could be registered. + // (e.g. example in example.com) + base::string16 target16 = + e2LD + base::ASCIIToUTF16(".") + base::ASCIIToUTF16(tld); + GURL possible_target(base::ASCIIToUTF16(url::kHttpsScheme) + + base::ASCIIToUTF16(url::kStandardSchemeSeparator) + + target16); + DomainInfo possible_target_domain = GetDomainInfo(possible_target); + if (IsTopDomain(possible_target_domain)) { + *found_domain = GURL(possible_target.spec()); + return true; + } + // If no match is found, check if e2LD is a unicode spoof + std::string top_targeted_domain = + url_formatter::IDNSpoofChecker().GetSimilarTopDomain(target16).domain; + if (!top_targeted_domain.empty()) { + *found_domain = GURL(std::string(url::kHttpsScheme) + + url::kStandardSchemeSeparator + top_targeted_domain); + return true; + } + } + return false; +} + } // namespace DomainInfo::DomainInfo(const std::string& arg_domain_and_registry, @@ -322,3 +373,43 @@ break; } } + +bool IsTargetEmbeddingLookalike(const GURL& url, + const std::set<std::string>& important_tlds, + GURL* safe_url) { + DCHECK(url.SchemeIsHTTPOrHTTPS()); + + // url.host() will give punycode-encoded hostname, as we need all the unicode + // characters to stay in the url for further check we convert host to unicode + base::string16 host = + url_formatter::UnsafeIDNToUnicodeWithDetails(url.host()).result; + const std::vector<base::string16> hostname_tokens_without_tld = + SplitNonTLDDomainIntoTokens(host); + + // When we find a valid TLD, we look backwards to the previous token + // to see if we can use it to build a top domain. + base::string16 prev_part = base::EmptyString16(); + + // We could have domains separated by '-'s or '.'s, in order to find target + // embedding urls with google.com.com or google-com.com, we get url parts as + // anything that is between two '-'s or '.'s. We check to see if an important + // TLD is following an important domain. + // Because of the way this matching is working, we can not identify target + // embedding attacks on legitimate websites that contain '-' in their names + // (e.g programme-tv.net). + for (const auto& token : hostname_tokens_without_tld) { + if (prev_part.empty()) { + prev_part = token; + continue; + } + + const std::string tld = base::UTF16ToUTF8(token); + if (base::Contains(important_tlds, tld) && + IsTopDomainCandidate(important_tlds, prev_part, safe_url)) { + return true; + } + prev_part = token; + } + *safe_url = GURL(); + return false; +}
diff --git a/components/lookalikes/lookalike_url_util.h b/components/lookalikes/lookalike_url_util.h index f1dc700..77a443e 100644 --- a/components/lookalikes/lookalike_url_util.h +++ b/components/lookalikes/lookalike_url_util.h
@@ -119,4 +119,17 @@ void RecordUMAFromMatchType(LookalikeUrlMatchType match_type); +// Checks to see if a URL is a target embedding lookalike. This function sets +// |safe_url| to the url of the embedded target domain. +// At the moment we consider the following cases as Target Embedding: +// example-google.com-site.com, example.google.com-site.com, +// example-google-com-site.com, example.google.com.site.com, +// example-googlé.com-site.com where the embedded target is google.com. In +// addition to these examples, this function also detects domains embedded with +// alternate TLDs, if the TLD is included in |important_tlds| (e.g. google.edu +// instead of google.com in the above examples.) +bool IsTargetEmbeddingLookalike(const GURL& url, + const std::set<std::string>& important_tlds, + GURL* safe_url); + #endif // COMPONENTS_LOOKALIKES_LOOKALIKE_URL_UTIL_H_
diff --git a/components/lookalikes/lookalike_url_util_unittest.cc b/components/lookalikes/lookalike_url_util_unittest.cc index 57f002d..edded75 100644 --- a/components/lookalikes/lookalike_url_util_unittest.cc +++ b/components/lookalikes/lookalike_url_util_unittest.cc
@@ -65,3 +65,110 @@ EXPECT_EQ(test_case.expected, result); } } + +TEST(LookalikeUrlUtilTest, TargetEmbeddingTest) { + const std::set<std::string> important_tlds = {"com", "org", "edu", "gov"}; + const struct TargetEmbeddingHeuristicTestCase { + const GURL url; + bool should_trigger; + } kTestCases[] = { + + // We test everything with the correct TLD and another popular TLD. + + // Scheme should not affect the outcome. + {GURL("http://google.com.com"), true}, + {GURL("https://google.com.com"), true}, + + // The length of the url should not affect the outcome. + {GURL("http://this-is-a-very-long-url-but-it-should-not-affect-the-" + "outcome-of-this-target-embedding-test-google.com-login.com"), + true}, + {GURL( + "http://this-is-a-very-long-url-but-it-should-not-affect-google-the-" + "outcome-of-this-target-embedding-test.com-login.com"), + false}, + {GURL( + "http://google-this-is-a-very-long-url-but-it-should-not-affect-the-" + "outcome-of-this-target-embedding-test.com-login.com"), + false}, + + // We need exact skeleton match for our domain so exclude edit-distance + // matches. + {GURL("http://goog0le.com-login.com"), false}, + + // Unicode characters should be handled + {GURL("http://googlé.com-login.com"), true}, + {GURL("http://sth-googlé.com-sth.com"), true}, + + // The basic state + {GURL("http://google.com.sth.com"), true}, + // - before the domain name should be ignored. + {GURL("http://sth-google.com-sth.com"), true}, + + // The embedded target's TLD doesn't necessarily need to be followed by a + // '-' and could be a subdomain by itself. + {GURL("http://sth-google.com.sth.com"), true}, + {GURL("http://a.b.c.d.e.f.g.h.sth-google.com.sth.com"), true}, + {GURL("http://a.b.c.d.e.f.g.h.google.com-sth.com"), true}, + {GURL("http://1.2.3.4.5.6.google.com-sth.com"), true}, + + // Target domain could be in the middle of subdomains. + {GURL("http://sth.google.com.sth.com"), true}, + {GURL("http://sth.google.com-sth.com"), true}, + + // The target domain and its tld should be next to each other. + {GURL("http://sth-google.l.com-sth.com"), false}, + + {GURL("http://google.edu.com"), true}, + {GURL("https://google.edu.com"), true}, + {GURL("http://this-is-a-very-long-url-but-it-should-not-affect-the-" + "outcome-of-this-target-embedding-test-google.edu-login.com"), + true}, + {GURL( + "http://this-is-a-very-long-url-but-it-should-not-affect-google-the-" + "outcome-of-this-target-embedding-test.edu-login.com"), + false}, + {GURL( + "http://google-this-is-a-very-long-url-but-it-should-not-affect-the-" + "outcome-of-this-target-embedding-test.edu-login.com"), + false}, + {GURL("http://goog0le.edu-login.com"), false}, + {GURL("http://googlé.edu-login.com"), true}, + {GURL("http://sth-googlé.edu-sth.com"), true}, + {GURL("http://google.edu.sth.com"), true}, + {GURL("http://sth-google.edu-sth.com"), true}, + {GURL("http://sth-google.edu.sth.com"), true}, + {GURL("http://a.b.c.d.e.f.g.h.sth-google.edu.sth.com"), true}, + {GURL("http://a.b.c.d.e.f.g.h.google.edu-sth.com"), true}, + {GURL("http://1.2.3.4.5.6.google.edu-sth.com"), true}, + {GURL("http://sth.google.edu.sth.com"), true}, + {GURL("http://sth.google.edu-sth.com"), true}, + {GURL("http://sth-google.l.edu-sth.com"), false}, + {GURL("http://sth-google-l.edu-sth.com"), false}, + {GURL("http://sth-google.l-edu-sth.com"), false}, + + // Target domain might be separated with a dash instead of dot. + {GURL("http://sth.google-com-sth.com"), true}, + + // Ensure legitimate domains don't trigger. + {GURL("http://google.com"), false}, + {GURL("http://google.co.uk"), false}, + {GURL("http://google.randomreg-login.com"), false}, + + }; + + for (const auto& kTestCase : kTestCases) { + GURL safe_url = GURL(); + if (kTestCase.should_trigger) { + EXPECT_TRUE( + IsTargetEmbeddingLookalike(kTestCase.url, important_tlds, &safe_url)) + << "Expected that \"" << kTestCase.url + << " should trigger but it didn't."; + } else { + EXPECT_FALSE( + IsTargetEmbeddingLookalike(kTestCase.url, important_tlds, &safe_url)) + << "Expected that \"" << kTestCase.url + << " shouldn't trigger but it did. For URL: " << safe_url.spec(); + } + } +}
diff --git a/components/password_manager/core/browser/ui/bulk_leak_check_service_adapter.cc b/components/password_manager/core/browser/ui/bulk_leak_check_service_adapter.cc index 95eed08..ba51a3c 100644 --- a/components/password_manager/core/browser/ui/bulk_leak_check_service_adapter.cc +++ b/components/password_manager/core/browser/ui/bulk_leak_check_service_adapter.cc
@@ -13,34 +13,12 @@ #include "components/password_manager/core/browser/leak_detection/bulk_leak_check.h" #include "components/password_manager/core/browser/leak_detection/encryption_utils.h" #include "components/password_manager/core/browser/leak_detection_delegate.h" +#include "components/password_manager/core/browser/ui/credential_utils.h" #include "components/password_manager/core/browser/ui/saved_passwords_presenter.h" #include "components/prefs/pref_service.h" namespace password_manager { -namespace { - -using autofill::PasswordForm; - -// Simple struct that stores a canonicalized credential. Allows implicit -// constructon from PasswordForm for convenience. -struct CanonicalizedCredential { - CanonicalizedCredential(const PasswordForm& form) - : canonicalized_username(CanonicalizeUsername(form.username_value)), - password(form.password_value) {} - - base::string16 canonicalized_username; - base::string16 password; -}; - -bool operator<(const CanonicalizedCredential& lhs, - const CanonicalizedCredential& rhs) { - return std::tie(lhs.canonicalized_username, lhs.password) < - std::tie(rhs.canonicalized_username, rhs.password); -} - -} // namespace - BulkLeakCheckServiceAdapter::BulkLeakCheckServiceAdapter( SavedPasswordsPresenter* presenter, BulkLeakCheckService* service, @@ -56,7 +34,9 @@ presenter_->RemoveObserver(this); } -bool BulkLeakCheckServiceAdapter::StartBulkLeakCheck() { +bool BulkLeakCheckServiceAdapter::StartBulkLeakCheck( + const void* key, + LeakCheckCredential::Data* data) { if (service_->state() == BulkLeakCheckService::State::kRunning) return false; @@ -75,6 +55,10 @@ for (const auto& credential : canonicalized) { credentials.emplace_back(credential.canonicalized_username, credential.password); + if (key) { + DCHECK(data); + credentials.back().SetUserData(key, data->Clone()); + } } service_->CheckUsernamePasswordPairs(std::move(credentials)); @@ -94,7 +78,7 @@ return service_->GetPendingChecksCount(); } -void BulkLeakCheckServiceAdapter::OnEdited(const PasswordForm& form) { +void BulkLeakCheckServiceAdapter::OnEdited(const autofill::PasswordForm& form) { if (CanStartLeakCheck(*prefs_)) { // Here no extra canonicalization is needed, as there are no other forms we // could de-dupe before we pass it on to the service.
diff --git a/components/password_manager/core/browser/ui/bulk_leak_check_service_adapter.h b/components/password_manager/core/browser/ui/bulk_leak_check_service_adapter.h index bd2c6ab..23f0d8fb 100644 --- a/components/password_manager/core/browser/ui/bulk_leak_check_service_adapter.h +++ b/components/password_manager/core/browser/ui/bulk_leak_check_service_adapter.h
@@ -29,9 +29,11 @@ // Instructs the adapter to start a check. This is a no-op in case a check is // already running. Otherwise, this will obtain the list of saved passwords // from |presenter_|, perform de-duplication of username and password pairs - // and then feed it to the |service_| for checking. + // and then feed it to the |service_| for checking. If |key| is present, it + // will append |data->Clone()| to each created LeakCheckCredential. // Returns whether new check was started. - bool StartBulkLeakCheck(); + bool StartBulkLeakCheck(const void* key = nullptr, + LeakCheckCredential::Data* data = nullptr); // This asks |service_| to stop an ongoing check. void StopBulkLeakCheck();
diff --git a/components/password_manager/core/browser/ui/bulk_leak_check_service_adapter_unittest.cc b/components/password_manager/core/browser/ui/bulk_leak_check_service_adapter_unittest.cc index 9228c4e..7cc2d12 100644 --- a/components/password_manager/core/browser/ui/bulk_leak_check_service_adapter_unittest.cc +++ b/components/password_manager/core/browser/ui/bulk_leak_check_service_adapter_unittest.cc
@@ -4,6 +4,7 @@ #include "components/password_manager/core/browser/ui/bulk_leak_check_service_adapter.h" +#include <memory> #include <tuple> #include <vector> @@ -164,6 +165,27 @@ EXPECT_THAT(credentials, CredentialsAre(std::cref(expected))); } +TEST_F(BulkLeakCheckServiceAdapterTest, StartBulkLeakCheckAttachesData) { + constexpr char kKey[] = "key"; + struct UserData : LeakCheckCredential::Data { + std::unique_ptr<Data> Clone() override { return std::make_unique<Data>(); } + } data; + + std::vector<PasswordForm> passwords = { + MakeSavedPassword(kExampleCom, kUsername1, kPassword1)}; + store().AddLogin(passwords[0]); + RunUntilIdle(); + + auto leak_check = std::make_unique<NiceMockBulkLeakCheck>(); + std::vector<LeakCheckCredential> credentials; + EXPECT_CALL(*leak_check, CheckCredentials).WillOnce(MoveArg(&credentials)); + EXPECT_CALL(factory(), TryCreateBulkLeakCheck) + .WillOnce(Return(ByMove(std::move(leak_check)))); + adapter().StartBulkLeakCheck(kKey, &data); + + EXPECT_NE(nullptr, credentials.at(0).GetUserData(kKey)); +} + // Tests that multiple credentials with effectively the same username are // correctly deduped before starting the leak check. TEST_F(BulkLeakCheckServiceAdapterTest, StartBulkLeakCheckDedupes) {
diff --git a/components/password_manager/core/browser/ui/credential_utils.h b/components/password_manager/core/browser/ui/credential_utils.h index 18f6843b..828d92c 100644 --- a/components/password_manager/core/browser/ui/credential_utils.h +++ b/components/password_manager/core/browser/ui/credential_utils.h
@@ -13,6 +13,8 @@ #include "base/strings/string16.h" #include "base/template_util.h" #include "components/autofill/core/common/password_form.h" +#include "components/password_manager/core/browser/leak_detection/bulk_leak_check.h" +#include "components/password_manager/core/browser/leak_detection/encryption_utils.h" namespace password_manager { @@ -29,6 +31,27 @@ base::string16 password; }; +// Simple struct that stores a canonicalized credential. Allows implicit +// constructon from PasswordForm and LeakCheckCredentail for convenience. +struct CanonicalizedCredential { + CanonicalizedCredential(const autofill::PasswordForm& form) + : canonicalized_username(CanonicalizeUsername(form.username_value)), + password(form.password_value) {} + + CanonicalizedCredential(const LeakCheckCredential& credential) + : canonicalized_username(CanonicalizeUsername(credential.username())), + password(credential.password()) {} + + base::string16 canonicalized_username; + base::string16 password; +}; + +inline bool operator<(const CanonicalizedCredential& lhs, + const CanonicalizedCredential& rhs) { + return std::tie(lhs.canonicalized_username, lhs.password) < + std::tie(rhs.canonicalized_username, rhs.password); +} + // Transparent comparator that can compare various types like CredentialView or // CredentialsWithPasswords. struct PasswordCredentialLess {
diff --git a/components/policy/resources/policy_templates.json b/components/policy/resources/policy_templates.json index 1c29db75..045367b4 100644 --- a/components/policy/resources/policy_templates.json +++ b/components/policy/resources/policy_templates.json
@@ -20203,6 +20203,10 @@ 'renewal_period_seconds': { 'description': 'Number of days before expiration of a certificate when renewal should be triggered', 'type': 'integer' + }, + 'policy_version': { + 'description': 'The client should not interpret this data and should forward it verbatim. The DMServer uses policy_version to verify that the policy view of DMServer matches the view of Chrome OS device.', + 'type': 'string' } }, 'required': ['cert_profile_id', 'key_algorithm'] @@ -20216,7 +20220,7 @@ 'can_be_recommended': False, 'can_be_mandatory' : True, }, - 'example_value': [{'name': 'Certificate Profile 1', 'cert_profile_id':'cert_profile_id_1', 'key_algorithm':'rsa', 'renewal_period_seconds': 2592000}], + 'example_value': [{'name': 'Certificate Profile 1', 'cert_profile_id':'cert_profile_id_1', 'key_algorithm':'rsa', 'renewal_period_seconds': 2592000, 'policy_version': 'some_hash'}], 'id': 680, 'caption': '''Required Client Certificates''', 'tags': [], @@ -20247,6 +20251,10 @@ 'renewal_period_seconds': { 'description': 'Number of days before expiration of a certificate when renewal should be triggered', 'type': 'integer' + }, + 'policy_version': { + 'description': 'The client should not interpret this data and should forward it verbatim. The DMServer uses policy_version to verify that the policy view of DMServer matches the view of Chrome OS device.', + 'type': 'string' } }, 'required': ['cert_profile_id', 'key_algorithm'] @@ -20260,7 +20268,7 @@ 'can_be_recommended': False, 'can_be_mandatory' : True, }, - 'example_value': [{'name': 'Certificate Profile 1', 'cert_profile_id':'cert_profile_id_1', 'key_algorithm':'rsa', 'renewal_period_seconds': 2592000}], + 'example_value': [{'name': 'Certificate Profile 1', 'cert_profile_id':'cert_profile_id_1', 'key_algorithm':'rsa', 'renewal_period_seconds': 2592000, 'policy_version': 'some_hash'}], 'id': 681, 'caption': '''Required device-wide Client Certificates''', 'tags': [],
diff --git a/components/safe_browsing/content/web_ui/safe_browsing_ui.cc b/components/safe_browsing/content/web_ui/safe_browsing_ui.cc index 8e67a4e5..bb9de20 100644 --- a/components/safe_browsing/content/web_ui/safe_browsing_ui.cc +++ b/components/safe_browsing/content/web_ui/safe_browsing_ui.cc
@@ -1313,9 +1313,6 @@ break; } - malware_request.SetStringKey( - "download_token", request.malware_scan_request().download_token()); - request_dict.SetKey("malware_scan_request", std::move(malware_request)); }
diff --git a/components/safe_browsing/core/features.cc b/components/safe_browsing/core/features.cc index 1f38072..e29b0f19 100644 --- a/components/safe_browsing/core/features.cc +++ b/components/safe_browsing/core/features.cc
@@ -88,6 +88,10 @@ const base::Feature kRealTimeUrlLookupEnabled{ "SafeBrowsingRealTimeUrlLookupEnabled", base::FEATURE_DISABLED_BY_DEFAULT}; +const base::Feature kRealTimeUrlLookupEnabledForAllAndroidDevices{ + "SafeBrowsingRealTimeUrlLookupEnabledForAllAndroidDevices", + base::FEATURE_DISABLED_BY_DEFAULT}; + const base::Feature kRealTimeUrlLookupEnabledForEP{ "SafeBrowsingRealTimeUrlLookupEnabledForEP", base::FEATURE_ENABLED_BY_DEFAULT}; @@ -140,6 +144,7 @@ {&kPasswordProtectionForSignedInUsers, true}, {&kPromptAppForDeepScanning, true}, {&kRealTimeUrlLookupEnabled, true}, + {&kRealTimeUrlLookupEnabledForAllAndroidDevices, true}, {&kRealTimeUrlLookupEnabledForEP, true}, {&kRealTimeUrlLookupEnabledWithToken, true}, {&kSafeBrowsingAvailableOnIOS, true},
diff --git a/components/safe_browsing/core/features.h b/components/safe_browsing/core/features.h index a4fe609..be2f38c 100644 --- a/components/safe_browsing/core/features.h +++ b/components/safe_browsing/core/features.h
@@ -88,6 +88,10 @@ // Controls whether the real time URL lookup is enabled. extern const base::Feature kRealTimeUrlLookupEnabled; +// Controls whether the real time URL lookup is enabled for all Android devices. +// This flag is in effect only if |kRealTimeUrlLookupEnabled| is true. +extern const base::Feature kRealTimeUrlLookupEnabledForAllAndroidDevices; + // Controls whether the real time URL lookup is enabled for Enhanced Protection // users. extern const base::Feature kRealTimeUrlLookupEnabledForEP;
diff --git a/components/safe_browsing/core/proto/webprotect.proto b/components/safe_browsing/core/proto/webprotect.proto index f107a000..18dd909 100644 --- a/components/safe_browsing/core/proto/webprotect.proto +++ b/components/safe_browsing/core/proto/webprotect.proto
@@ -18,8 +18,7 @@ // Identifies the type of client. optional Population population = 1; - // The download token from the original ClientDownloadResponse. - optional string download_token = 2; + reserved 2; } // DLP-specific scanning information.
diff --git a/components/safe_browsing/core/realtime/policy_engine.cc b/components/safe_browsing/core/realtime/policy_engine.cc index f511275..d518d1a2 100644 --- a/components/safe_browsing/core/realtime/policy_engine.cc +++ b/components/safe_browsing/core/realtime/policy_engine.cc
@@ -26,9 +26,7 @@ namespace safe_browsing { #if defined(OS_ANDROID) -const int kDefaultMemoryLowerThresholdMb = 4096; -// By default, the upper threshold shouldn't be in effect. -const int kDefaultMemoryUpperThresholdMb = INT_MAX; +const int kDefaultMemoryThresholdMb = 4096; #endif // static @@ -37,17 +35,17 @@ return false; #if defined(OS_ANDROID) // On Android, performs real time URL lookup only if - // |kRealTimeUrlLookupEnabled| is enabled, and system memory is between the - // upper threshold and lower threshold. - int memory_lower_threshold_mb = base::GetFieldTrialParamByFeatureAsInt( - kRealTimeUrlLookupEnabled, kRealTimeUrlLookupMemoryLowerThresholdMb, - kDefaultMemoryLowerThresholdMb); - int memory_upper_threshold_mb = base::GetFieldTrialParamByFeatureAsInt( - kRealTimeUrlLookupEnabled, kRealTimeUrlLookupMemoryUpperThresholdMb, - kDefaultMemoryUpperThresholdMb); - return base::SysInfo::AmountOfPhysicalMemoryMB() >= - memory_lower_threshold_mb && - base::SysInfo::AmountOfPhysicalMemoryMB() <= memory_upper_threshold_mb; + // |kRealTimeUrlLookupEnabled| is enabled, and system memory is larger than + // threshold, or the feature flag + // |kRealTimeUrlLookupEnabledForAllAndroidDevices| is enabled. + int memory_threshold_mb = base::GetFieldTrialParamByFeatureAsInt( + kRealTimeUrlLookupEnabled, kRealTimeUrlLookupMemoryThresholdMb, + kDefaultMemoryThresholdMb); + bool is_high_end_device = + base::SysInfo::AmountOfPhysicalMemoryMB() >= memory_threshold_mb; + return is_high_end_device || + base::FeatureList::IsEnabled( + kRealTimeUrlLookupEnabledForAllAndroidDevices); #else return true; #endif
diff --git a/components/safe_browsing/core/realtime/policy_engine.h b/components/safe_browsing/core/realtime/policy_engine.h index fe554e75..4954630 100644 --- a/components/safe_browsing/core/realtime/policy_engine.h +++ b/components/safe_browsing/core/realtime/policy_engine.h
@@ -20,12 +20,9 @@ #if defined(OS_ANDROID) // A parameter controlled by finch experiment. // On Android, performs real time URL lookup only if |kRealTimeUrlLookupEnabled| -// is enabled, and system memory is between the upper threshold and the lower -// threshold. -const char kRealTimeUrlLookupMemoryLowerThresholdMb[] = +// is enabled, and system memory is larger than threshold. +const char kRealTimeUrlLookupMemoryThresholdMb[] = "SafeBrowsingRealTimeUrlLookupMemoryThresholdMb"; -const char kRealTimeUrlLookupMemoryUpperThresholdMb[] = - "SafeBrowsingRealTimeUrlLookupMemoryUpperThresholdMb"; #endif // This class implements the logic to decide whether the real time lookup
diff --git a/components/safe_browsing/core/realtime/policy_engine_unittest.cc b/components/safe_browsing/core/realtime/policy_engine_unittest.cc index d48e709..499d78c 100644 --- a/components/safe_browsing/core/realtime/policy_engine_unittest.cc +++ b/components/safe_browsing/core/realtime/policy_engine_unittest.cc
@@ -59,12 +59,46 @@ TEST_F(RealTimePolicyEngineTest, TestCanPerformFullURLLookup_LargeMemorySize) { base::test::ScopedFeatureList feature_list; int system_memory_size = base::SysInfo::AmountOfPhysicalMemoryMB(); - int memory_size_lower_threshold = system_memory_size - 1; + int memory_size_threshold = system_memory_size - 1; feature_list.InitWithFeaturesAndParameters( /* enabled_features */ {{kRealTimeUrlLookupEnabled, - {{kRealTimeUrlLookupMemoryLowerThresholdMb, + {{kRealTimeUrlLookupMemoryThresholdMb, base::NumberToString( - memory_size_lower_threshold)}}}}, + memory_size_threshold)}}}}, + /* disabled_features */ {}); + pref_service_.SetUserPref( + unified_consent::prefs::kUrlKeyedAnonymizedDataCollectionEnabled, + std::make_unique<base::Value>(true)); + EXPECT_TRUE(CanPerformFullURLLookup(/* is_off_the_record */ false)); +} + +TEST_F(RealTimePolicyEngineTest, TestCanPerformFullURLLookup_SmallMemorySize) { + base::test::ScopedFeatureList feature_list; + int system_memory_size = base::SysInfo::AmountOfPhysicalMemoryMB(); + int memory_size_threshold = system_memory_size + 1; + feature_list.InitWithFeaturesAndParameters( + /* enabled_features */ {{kRealTimeUrlLookupEnabled, + {{kRealTimeUrlLookupMemoryThresholdMb, + base::NumberToString( + memory_size_threshold)}}}}, + /* disabled_features */ {}); + pref_service_.SetUserPref( + unified_consent::prefs::kUrlKeyedAnonymizedDataCollectionEnabled, + std::make_unique<base::Value>(true)); + EXPECT_FALSE(CanPerformFullURLLookup(/* is_off_the_record */ false)); +} + +TEST_F(RealTimePolicyEngineTest, + TestCanPerformFullURLLookup_SmallMemorySizeWithAllDevicesFlagEnabled) { + base::test::ScopedFeatureList feature_list; + int system_memory_size = base::SysInfo::AmountOfPhysicalMemoryMB(); + int memory_size_threshold = system_memory_size + 1; + feature_list.InitWithFeaturesAndParameters( + /* enabled_features */ {{kRealTimeUrlLookupEnabled, + {{kRealTimeUrlLookupMemoryThresholdMb, + base::NumberToString(memory_size_threshold)}}}, + {kRealTimeUrlLookupEnabledForAllAndroidDevices, + {}}}, /* disabled_features */ {}); pref_service_.SetUserPref( unified_consent::prefs::kUrlKeyedAnonymizedDataCollectionEnabled, @@ -73,39 +107,6 @@ } TEST_F(RealTimePolicyEngineTest, - TestCanPerformFullURLLookup_LargeMemorySizeExceedUpperThreshold) { - base::test::ScopedFeatureList feature_list; - int system_memory_size = base::SysInfo::AmountOfPhysicalMemoryMB(); - int memory_size_upper_threshold = system_memory_size - 1; - feature_list.InitWithFeaturesAndParameters( - /* enabled_features */ {{kRealTimeUrlLookupEnabled, - {{kRealTimeUrlLookupMemoryUpperThresholdMb, - base::NumberToString( - memory_size_upper_threshold)}}}}, - /* disabled_features */ {}); - pref_service_.SetUserPref( - unified_consent::prefs::kUrlKeyedAnonymizedDataCollectionEnabled, - std::make_unique<base::Value>(true)); - EXPECT_FALSE(CanPerformFullURLLookup(/* is_off_the_record */ false)); -} - -TEST_F(RealTimePolicyEngineTest, TestCanPerformFullURLLookup_SmallMemorySize) { - base::test::ScopedFeatureList feature_list; - int system_memory_size = base::SysInfo::AmountOfPhysicalMemoryMB(); - int memory_size_lower_threshold = system_memory_size + 1; - feature_list.InitWithFeaturesAndParameters( - /* enabled_features */ {{kRealTimeUrlLookupEnabled, - {{kRealTimeUrlLookupMemoryLowerThresholdMb, - base::NumberToString( - memory_size_lower_threshold)}}}}, - /* disabled_features */ {}); - pref_service_.SetUserPref( - unified_consent::prefs::kUrlKeyedAnonymizedDataCollectionEnabled, - std::make_unique<base::Value>(true)); - EXPECT_FALSE(CanPerformFullURLLookup(/* is_off_the_record */ false)); -} - -TEST_F(RealTimePolicyEngineTest, TestCanPerformFullURLLookup_DisabledUrlLookupWithLargeMemorySize) { base::test::ScopedFeatureList feature_list; feature_list.InitWithFeaturesAndParameters( @@ -113,6 +114,21 @@ /* disabled_features */ {kRealTimeUrlLookupEnabled}); EXPECT_FALSE(CanPerformFullURLLookup(/* is_off_the_record */ false)); } + +TEST_F(RealTimePolicyEngineTest, + TestCanPerformFullURLLookup_DisabledUrlLookupWithAllDevicesFlagEnabled) { + base::test::ScopedFeatureList feature_list; + feature_list.InitWithFeaturesAndParameters( + /* enabled_features */ {{kRealTimeUrlLookupEnabledForAllAndroidDevices, + {}}}, + /* disabled_features */ {kRealTimeUrlLookupEnabled}); + pref_service_.SetUserPref( + unified_consent::prefs::kUrlKeyedAnonymizedDataCollectionEnabled, + std::make_unique<base::Value>(true)); + // |kRealTimeUrlLookupEnabledForAllAndroidDevices| is in effect only if + // |kRealTimeUrlLookupEnabled| is set to true. + EXPECT_FALSE(CanPerformFullURLLookup(/* is_off_the_record */ false)); +} #endif // defined(OS_ANDROID) TEST_F(RealTimePolicyEngineTest, TestCanPerformFullURLLookup_EnabledByPolicy) { @@ -175,12 +191,11 @@ base::test::ScopedFeatureList feature_list; #if defined(OS_ANDROID) int system_memory_size = base::SysInfo::AmountOfPhysicalMemoryMB(); - int memory_size_lower_threshold = system_memory_size - 1; + int memory_size_threshold = system_memory_size - 1; feature_list.InitWithFeaturesAndParameters( /* enabled_features */ {{kRealTimeUrlLookupEnabled, - {{kRealTimeUrlLookupMemoryLowerThresholdMb, - base::NumberToString( - memory_size_lower_threshold)}}}, + {{kRealTimeUrlLookupMemoryThresholdMb, + base::NumberToString(memory_size_threshold)}}}, {kRealTimeUrlLookupEnabledWithToken, {}}}, /* disabled_features */ {kRealTimeUrlLookupEnabledForEP}); #else @@ -202,12 +217,11 @@ base::test::ScopedFeatureList feature_list; #if defined(OS_ANDROID) int system_memory_size = base::SysInfo::AmountOfPhysicalMemoryMB(); - int memory_size_lower_threshold = system_memory_size - 1; + int memory_size_threshold = system_memory_size - 1; feature_list.InitWithFeaturesAndParameters( /* enabled_features */ {{kRealTimeUrlLookupEnabled, - {{kRealTimeUrlLookupMemoryLowerThresholdMb, - base::NumberToString( - memory_size_lower_threshold)}}}, + {{kRealTimeUrlLookupMemoryThresholdMb, + base::NumberToString(memory_size_threshold)}}}, {kRealTimeUrlLookupEnabledWithToken, {}}}, /* disabled_features */ {}); #else
diff --git a/components/safe_browsing/core/realtime/url_lookup_service_unittest.cc b/components/safe_browsing/core/realtime/url_lookup_service_unittest.cc index c59699fb..93dff22 100644 --- a/components/safe_browsing/core/realtime/url_lookup_service_unittest.cc +++ b/components/safe_browsing/core/realtime/url_lookup_service_unittest.cc
@@ -135,15 +135,14 @@ std::make_unique<base::Value>(true)); #if defined(OS_ANDROID) int system_memory_size = base::SysInfo::AmountOfPhysicalMemoryMB(); - int memory_size_lower_threshold = system_memory_size - 1; + int memory_size_threshold = system_memory_size - 1; if (is_with_token_enabled) { feature_list_.InitWithFeaturesAndParameters( /* enabled_features */ {{kRealTimeUrlLookupEnabled, - { - { kRealTimeUrlLookupMemoryLowerThresholdMb, - base::NumberToString( - memory_size_lower_threshold) } - }}, + { { + kRealTimeUrlLookupMemoryThresholdMb, + base::NumberToString(memory_size_threshold) + } }}, { kRealTimeUrlLookupEnabledWithToken, {} }}, /* disabled_features */ {}); @@ -152,8 +151,8 @@ /* enabled_features */ {{ kRealTimeUrlLookupEnabled, { - { kRealTimeUrlLookupMemoryLowerThresholdMb, - base::NumberToString(memory_size_lower_threshold) } + { kRealTimeUrlLookupMemoryThresholdMb, + base::NumberToString(memory_size_threshold) } } }}, /* disabled_features */ {});
diff --git a/components/test/data/payments/bobpay_and_cards.js b/components/test/data/payments/bobpay_and_cards.js index 5dd8806..e0cf94f3 100644 --- a/components/test/data/payments/bobpay_and_cards.js +++ b/components/test/data/payments/bobpay_and_cards.js
@@ -6,6 +6,9 @@ /* global PaymentRequest:false */ +var request = null; +var showPromise = null; + /** * Helper function that launches the PaymentRequest UI with the specified * payment methods. @@ -15,7 +18,7 @@ * @param {boolean} requestShippingContact: Whether or not shipping address and * payer's contact information are required. */ -function testPaymentMethods(methods, requestShippingContact = false) { +async function testPaymentMethods(methods, requestShippingContact = false) { const shippingOptions = requestShippingContact ? [{ id: 'freeShippingOption', @@ -25,7 +28,7 @@ }] : []; try { - new PaymentRequest( + request = new PaymentRequest( methods, {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, shippingOptions}, @@ -34,28 +37,28 @@ requestPayerEmail: requestShippingContact, requestPayerName: requestShippingContact, requestPayerPhone: requestShippingContact, - }) - .show() - .then(function(resp) { - resp.complete('success') - .then(function() { - print( - resp.methodName + '<br>' + - JSON.stringify(resp.details, undefined, 2)); - }) - .catch(function(error) { - print(error.message); - }); - }) - .catch(function(error) { - print(error.message); }); + showPromise = request.show(); + const resp = await showPromise; + await resp.complete('success'); + const json = JSON.stringify(resp.details, undefined, 2); + print(`${resp.methodName}<br>${json}`); } catch (error) { print(error.message); } } /** + * Aborts the PaymentRequest initiated by testPaymentMethods(). + */ +async function abort() { // eslint-disable-line no-unused-vars + await request.abort(); + return await showPromise.catch((e) => { + return e.name == 'AbortError'; + }); +} + +/** * Launches the PaymentRequest UI with Bob Pay and credit cards as payment * methods. */
diff --git a/content/browser/accessibility/browser_accessibility.cc b/content/browser/accessibility/browser_accessibility.cc index 3c285c7..63748104 100644 --- a/content/browser/accessibility/browser_accessibility.cc +++ b/content/browser/accessibility/browser_accessibility.cc
@@ -1649,8 +1649,12 @@ return std::make_unique<PlatformChildIterator>(PlatformChildrenEnd()); } -gfx::NativeViewAccessible BrowserAccessibility::HitTestSync(int x, int y) { - auto* accessible = manager_->CachingAsyncHitTest(gfx::Point(x, y)); +gfx::NativeViewAccessible BrowserAccessibility::HitTestSync(int x, + int y) const { + if (!instance_active()) + return nullptr; + BrowserAccessibility* accessible = + manager_->CachingAsyncHitTest(gfx::Point(x, y)); if (!accessible) return nullptr;
diff --git a/content/browser/accessibility/browser_accessibility.h b/content/browser/accessibility/browser_accessibility.h index e457982..e52e0ec 100644 --- a/content/browser/accessibility/browser_accessibility.h +++ b/content/browser/accessibility/browser_accessibility.h
@@ -211,7 +211,7 @@ // Derivative utils for AXPlatformNodeDelegate::GetBoundsRect gfx::Rect GetClippedScreenBoundsRect( - ui::AXOffscreenResult* offscreen_result = nullptr) const; + ui::AXOffscreenResult* offscreen_result = nullptr) const override; gfx::Rect GetUnclippedScreenBoundsRect( ui::AXOffscreenResult* offscreen_result = nullptr) const; gfx::Rect GetClippedRootFrameBoundsRect( @@ -472,7 +472,7 @@ const ui::AXCoordinateSystem coordinate_system, const ui::AXClippingBehavior clipping_behavior, ui::AXOffscreenResult* offscreen_result = nullptr) const override; - gfx::NativeViewAccessible HitTestSync(int x, int y) override; + gfx::NativeViewAccessible HitTestSync(int x, int y) const override; gfx::NativeViewAccessible GetFocus() override; ui::AXPlatformNode* GetFromNodeID(int32_t id) override; ui::AXPlatformNode* GetFromTreeIDAndNodeID(const ui::AXTreeID& ax_tree_id,
diff --git a/content/browser/accessibility/browser_accessibility_manager.cc b/content/browser/accessibility/browser_accessibility_manager.cc index 902b4611..f741bdc6 100644 --- a/content/browser/accessibility/browser_accessibility_manager.cc +++ b/content/browser/accessibility/browser_accessibility_manager.cc
@@ -878,7 +878,7 @@ delegate_->AccessibilityPerformAction(action_data); } -void BrowserAccessibilityManager::HitTest(const gfx::Point& point) { +void BrowserAccessibilityManager::HitTest(const gfx::Point& point) const { if (!delegate_) return; @@ -892,7 +892,7 @@ delegate_->AccessibilityPerformAction(action_data); } -gfx::Rect BrowserAccessibilityManager::GetViewBounds() { +gfx::Rect BrowserAccessibilityManager::GetViewBounds() const { BrowserAccessibilityDelegate* delegate = GetDelegateFromRootManager(); if (delegate) return delegate->AccessibilityGetViewBounds(); @@ -1462,7 +1462,7 @@ } BrowserAccessibility* BrowserAccessibilityManager::CachingAsyncHitTest( - const gfx::Point& screen_point) { + const gfx::Point& screen_point) const { // TODO(crbug.com/1061323): By starting the hit test on the root frame, // it allows for the possibility that we don't return a descendant as the // hit test result, but AXPlatformNodeDelegate says that it's only supposed @@ -1507,15 +1507,10 @@ } void BrowserAccessibilityManager::CacheHitTestResult( - BrowserAccessibility* hit_test_result) { + BrowserAccessibility* hit_test_result) const { // Walk up to the highest ancestor that's a leaf node; we don't want to // return a node that's hidden from the tree. - BrowserAccessibility* parent = hit_test_result->PlatformGetParent(); - while (parent) { - if (parent->PlatformChildCount() == 0) - hit_test_result = parent; - parent = parent->PlatformGetParent(); - } + hit_test_result = hit_test_result->PlatformGetClosestPlatformObject(); last_hover_ax_tree_id_ = hit_test_result->manager()->ax_tree_id(); last_hover_node_id_ = hit_test_result->GetId();
diff --git a/content/browser/accessibility/browser_accessibility_manager.h b/content/browser/accessibility/browser_accessibility_manager.h index a018678..6bcd6e6 100644 --- a/content/browser/accessibility/browser_accessibility_manager.h +++ b/content/browser/accessibility/browser_accessibility_manager.h
@@ -245,7 +245,7 @@ void DoDefaultAction(const BrowserAccessibility& node); void GetImageData(const BrowserAccessibility& node, const gfx::Size& max_size); - void HitTest(const gfx::Point& point); + void HitTest(const gfx::Point& point) const; void Increment(const BrowserAccessibility& node); void LoadInlineTextBoxes(const BrowserAccessibility& node); void ScrollToMakeVisible( @@ -270,7 +270,7 @@ void SignalEndOfTest(); // Retrieve the bounds of the parent View in screen coordinates. - virtual gfx::Rect GetViewBounds(); + virtual gfx::Rect GetViewBounds() const; // Fire an event telling native assistive technology to move focus to the // given find in page result. @@ -451,13 +451,12 @@ // Given a point in screen coordinates, trigger an asynchronous hit test // but return the best possible match instantly. - // - // - BrowserAccessibility* CachingAsyncHitTest(const gfx::Point& screen_point); + BrowserAccessibility* CachingAsyncHitTest( + const gfx::Point& screen_point) const; // Called in response to a hover event, caches the result for the next // call to CachingAsyncHitTest(). - void CacheHitTestResult(BrowserAccessibility* hit_test_result); + void CacheHitTestResult(BrowserAccessibility* hit_test_result) const; // Called when |this| is an accessibility manager for a portal's main frame, // and when that portal is activated. @@ -510,9 +509,9 @@ // last object found by an asynchronous hit test. Subsequent hit test // requests that remain within this object's bounds will return the same // object, but will also trigger a new asynchronous hit test request. - ui::AXTreeID last_hover_ax_tree_id_; - int last_hover_node_id_; - gfx::Rect last_hover_bounds_; + mutable ui::AXTreeID last_hover_ax_tree_id_; + mutable int last_hover_node_id_; + mutable gfx::Rect last_hover_bounds_; // True if the root's parent is in another accessibility tree and that // parent's child is the root. Ensures that the parent node is notified
diff --git a/content/browser/accessibility/browser_accessibility_manager_android.cc b/content/browser/accessibility/browser_accessibility_manager_android.cc index 717b9cb8..c3251ec2 100644 --- a/content/browser/accessibility/browser_accessibility_manager_android.cc +++ b/content/browser/accessibility/browser_accessibility_manager_android.cc
@@ -411,7 +411,7 @@ wcax->HandleHover(android_node->unique_id()); } -gfx::Rect BrowserAccessibilityManagerAndroid::GetViewBounds() { +gfx::Rect BrowserAccessibilityManagerAndroid::GetViewBounds() const { // We have to take the device scale factor into account on Android. BrowserAccessibilityDelegate* delegate = GetDelegateFromRootManager(); if (delegate) {
diff --git a/content/browser/accessibility/browser_accessibility_manager_android.h b/content/browser/accessibility/browser_accessibility_manager_android.h index 9e458b8..0459f28 100644 --- a/content/browser/accessibility/browser_accessibility_manager_android.h +++ b/content/browser/accessibility/browser_accessibility_manager_android.h
@@ -82,7 +82,7 @@ BrowserAccessibility* node) override; void FireGeneratedEvent(ui::AXEventGenerator::Event event_type, BrowserAccessibility* node) override; - gfx::Rect GetViewBounds() override; + gfx::Rect GetViewBounds() const override; void FireLocationChanged(BrowserAccessibility* node);
diff --git a/content/browser/accessibility/browser_accessibility_manager_win.cc b/content/browser/accessibility/browser_accessibility_manager_win.cc index 8aff2f08..45507b9d 100644 --- a/content/browser/accessibility/browser_accessibility_manager_win.cc +++ b/content/browser/accessibility/browser_accessibility_manager_win.cc
@@ -582,7 +582,7 @@ GetDelegateFromRootManager()->AccessibilityGetAcceleratedWidget(); } -gfx::Rect BrowserAccessibilityManagerWin::GetViewBounds() { +gfx::Rect BrowserAccessibilityManagerWin::GetViewBounds() const { // We have to take the device scale factor into account on Windows. BrowserAccessibilityDelegate* delegate = GetDelegateFromRootManager(); if (delegate) {
diff --git a/content/browser/accessibility/browser_accessibility_manager_win.h b/content/browser/accessibility/browser_accessibility_manager_win.h index ff425504..90df050b 100644 --- a/content/browser/accessibility/browser_accessibility_manager_win.h +++ b/content/browser/accessibility/browser_accessibility_manager_win.h
@@ -47,7 +47,7 @@ void UserIsReloading() override; BrowserAccessibility* GetFocus() const override; bool CanFireEvents() const override; - gfx::Rect GetViewBounds() override; + gfx::Rect GetViewBounds() const override; void FireFocusEvent(BrowserAccessibility* node) override; void FireBlinkEvent(ax::mojom::Event event_type,
diff --git a/content/browser/accessibility/hit_testing_browsertest.cc b/content/browser/accessibility/hit_testing_browsertest.cc index bf13f3f..6b8d4f4 100644 --- a/content/browser/accessibility/hit_testing_browsertest.cc +++ b/content/browser/accessibility/hit_testing_browsertest.cc
@@ -4,6 +4,7 @@ #include "base/logging.h" #include "build/build_config.h" +#include "build/chromecast_buildflags.h" #include "content/browser/accessibility/browser_accessibility.h" #include "content/browser/accessibility/browser_accessibility_manager.h" #include "content/browser/web_contents/web_contents_impl.h" @@ -18,13 +19,14 @@ #include "content/test/content_browser_test_utils_internal.h" #include "net/dns/mock_host_resolver.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/accessibility/platform/ax_platform_node_base.h" namespace content { class AccessibilityHitTestingBrowserTest : public ContentBrowserTest { public: - AccessibilityHitTestingBrowserTest() {} - ~AccessibilityHitTestingBrowserTest() override {} + AccessibilityHitTestingBrowserTest() = default; + ~AccessibilityHitTestingBrowserTest() override = default; BrowserAccessibility* HitTestAndWaitForResultWithEvent( const gfx::Point& point, @@ -74,19 +76,49 @@ return hit_node; } - BrowserAccessibility* CallCachingAsyncHitTest(const gfx::Point& point) { + gfx::Point ToScreenPoint(gfx::Point point) { WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(shell()->web_contents()); BrowserAccessibilityManager* manager = web_contents->GetRootBrowserAccessibilityManager(); - gfx::Point screen_point = - point + manager->GetViewBounds().OffsetFromOrigin(); + return point + manager->GetViewBounds().OffsetFromOrigin(); + } + + BrowserAccessibility* CallCachingAsyncHitTest(const gfx::Point& point) { + gfx::Point screen_point = ToScreenPoint(point); + BrowserAccessibilityManager* manager = + static_cast<WebContentsImpl*>(shell()->web_contents()) + ->GetRootBrowserAccessibilityManager(); // Each call to CachingAsyncHitTest results in at least one HOVER - // event received. Block until we receive it. + // event received. Block until we receive it. CachingAsyncHitTestNearestLeaf + // will call CachingAsyncHitTest. AccessibilityNotificationWaiter hover_waiter( shell()->web_contents(), ui::kAXModeComplete, ax::mojom::Event::kHover); + BrowserAccessibility* result = manager->CachingAsyncHitTest(screen_point); + + hover_waiter.WaitForNotification(); + return result; + } + + ui::AXPlatformNodeBase* CallNearestLeafNode(const gfx::Point& point) { + gfx::Point screen_point = ToScreenPoint(point); + BrowserAccessibilityManager* manager = + static_cast<WebContentsImpl*>(shell()->web_contents()) + ->GetRootBrowserAccessibilityManager(); + + // Each call to CachingAsyncHitTest results in at least one HOVER + // event received. Block until we receive it. CachingAsyncHitTest + // will call CachingAsyncHitTest. + AccessibilityNotificationWaiter hover_waiter( + shell()->web_contents(), ui::kAXModeComplete, ax::mojom::Event::kHover); + ui::AXPlatformNodeBase* result = nullptr; + if (manager->GetRoot()->GetAXPlatformNode()) { + result = static_cast<ui::AXPlatformNodeBase*>( + manager->GetRoot()->GetAXPlatformNode()) + ->NearestLeafToPoint(screen_point); + } hover_waiter.WaitForNotification(); return result; } @@ -589,4 +621,91 @@ #endif // !defined(OS_ANDROID) && !defined(OS_MACOSX) +// GetAXPlatformNode is currently only supported on windows and linux (excluding +// Chrome OS or Chromecast) +#if defined(OS_WIN) || \ + (defined(OS_LINUX) && !defined(OS_CHROMEOS) && !BUILDFLAG(IS_CHROMECAST)) +IN_PROC_BROWSER_TEST_F(AccessibilityHitTestingBrowserTest, + NearestLeafInIframes) { + ASSERT_TRUE(embedded_test_server()->Start()); + + EXPECT_TRUE(NavigateToURL(shell(), GURL(url::kAboutBlankURL))); + + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kLoadComplete); + GURL url(embedded_test_server()->GetURL( + "/accessibility/hit_testing/hit_testing.html")); + EXPECT_TRUE(NavigateToURL(shell(), url)); + waiter.WaitForNotification(); + + WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(), + "Ordinary Button"); + WaitForAccessibilityTreeToContainNodeWithName(shell()->web_contents(), + "Scrolled Button"); + + // For each point we try, the first time we call CachingAsyncHitTest it + // should FAIL and return the wrong object, because this test page has + // been designed to confound local synchronous hit testing using + // z-indexes. However, calling CachingAsyncHitTest a second time should + // return the correct result (since CallCachingAsyncHitTest waits for the + // HOVER event to be received). CachingAsyncHitTest is called by + // GetNearestLeaf + + // (50, 50) -> "Button" + ui::AXPlatformNodeBase* hit_node; + hit_node = CallNearestLeafNode(gfx::Point(50, 50)); + ASSERT_TRUE(hit_node != nullptr); + EXPECT_NE(ax::mojom::Role::kButton, hit_node->GetData().role); + hit_node = CallNearestLeafNode(gfx::Point(50, 50)); + ASSERT_TRUE(hit_node != nullptr); + EXPECT_EQ("Button", + hit_node->GetStringAttribute(ax::mojom::StringAttribute::kName)); + + // (280, 50) -> "Button" is still the closest node to the cursor. + hit_node = CallNearestLeafNode(gfx::Point(280, 50)); + EXPECT_NE(ax::mojom::Role::kButton, hit_node->GetData().role); + hit_node = CallNearestLeafNode(gfx::Point(280, 50)); + EXPECT_EQ("Button", + hit_node->GetStringAttribute(ax::mojom::StringAttribute::kName)); + + // (50, 305) -> "Ordinary Button" is the closest leaf node. + hit_node = CallNearestLeafNode(gfx::Point(50, 305)); + ASSERT_TRUE(hit_node != nullptr); + EXPECT_NE(ax::mojom::Role::kButton, hit_node->GetData().role); + hit_node = CallNearestLeafNode(gfx::Point(50, 305)); + ASSERT_TRUE(hit_node != nullptr); + EXPECT_EQ(ax::mojom::Role::kButton, hit_node->GetData().role); + EXPECT_EQ("Ordinary Button", + hit_node->GetStringAttribute(ax::mojom::StringAttribute::kName)); + + // (50, 350) -> "Ordinary Button". As we are still within the previous cached + // hit test's bounds, the subsequent call correctly gets the descendant. + hit_node = CallNearestLeafNode(gfx::Point(50, 350)); + ASSERT_TRUE(hit_node != nullptr); + EXPECT_EQ(ax::mojom::Role::kButton, hit_node->GetData().role); + EXPECT_EQ("Ordinary Button", + hit_node->GetStringAttribute(ax::mojom::StringAttribute::kName)); + + // (50, 455) -> "Scrolled Button" + hit_node = CallNearestLeafNode(gfx::Point(50, 455)); + ASSERT_TRUE(hit_node != nullptr); + EXPECT_NE(ax::mojom::Role::kButton, hit_node->GetData().role); + hit_node = CallNearestLeafNode(gfx::Point(50, 455)); + ASSERT_TRUE(hit_node != nullptr); + EXPECT_EQ(ax::mojom::Role::kButton, hit_node->GetData().role); + EXPECT_EQ("Scrolled Button", + hit_node->GetStringAttribute(ax::mojom::StringAttribute::kName)); + + // (50, 505) -> "Scrolled Button" + hit_node = CallNearestLeafNode(gfx::Point(50, 505)); + ASSERT_TRUE(hit_node != nullptr); + EXPECT_NE(ax::mojom::Role::kButton, hit_node->GetData().role); + hit_node = CallNearestLeafNode(gfx::Point(50, 505)); + ASSERT_TRUE(hit_node != nullptr); + EXPECT_EQ(ax::mojom::Role::kButton, hit_node->GetData().role); + EXPECT_EQ("Scrolled Button", + hit_node->GetStringAttribute(ax::mojom::StringAttribute::kName)); +} +#endif } // namespace content
diff --git a/content/browser/devtools/BUILD.gn b/content/browser/devtools/BUILD.gn index f8c8a26..2cd01cd 100644 --- a/content/browser/devtools/BUILD.gn +++ b/content/browser/devtools/BUILD.gn
@@ -14,7 +14,9 @@ grit("devtools_resources") { source = "$root_gen_dir/devtools/devtools_resources.grd" - source_is_generated = true + + # Required because the .grd is generated. + enable_input_discovery_for_gn_analyze = false use_brotli = true outputs = [
diff --git a/content/browser/devtools/devtools_manager_unittest.cc b/content/browser/devtools/devtools_manager_unittest.cc index b4718ba..b8c3724 100644 --- a/content/browser/devtools/devtools_manager_unittest.cc +++ b/content/browser/devtools/devtools_manager_unittest.cc
@@ -17,6 +17,7 @@ #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" #include "content/browser/devtools/shared_worker_devtools_manager.h" +#include "content/common/content_constants_internal.h" #include "content/common/view_messages.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/content_browser_client.h" @@ -140,33 +141,18 @@ WebContents::FromRenderViewHost(inspected_rvh))); client_host.InspectAgentHost(agent_host.get()); - // Start with a short timeout. - inspected_rvh->GetWidget()->StartInputEventAckTimeout( - TimeDelta::FromMilliseconds(10)); - { - base::RunLoop run_loop; - // Wait long enough for first timeout and see if it fired. We use quit-when- - // idle so that all tasks due after the timeout get a chance to run. - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, run_loop.QuitWhenIdleClosure(), - TimeDelta::FromMilliseconds(10)); - run_loop.Run(); - } + // Start a timeout. + inspected_rvh->GetWidget()->StartInputEventAckTimeout(); + task_environment()->FastForwardBy( + base::TimeDelta::FromMilliseconds(kHungRendererDelayMs + 10)); EXPECT_FALSE(delegate.renderer_unresponsive_received()); // Now close devtools and check that the notification is delivered. client_host.Close(); - // Start with a short timeout. - inspected_rvh->GetWidget()->StartInputEventAckTimeout( - TimeDelta::FromMilliseconds(10)); - { - base::RunLoop run_loop; - // Wait long enough for first timeout and see if it fired. - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, run_loop.QuitWhenIdleClosure(), - TimeDelta::FromMilliseconds(10)); - run_loop.Run(); - } + // Start a timeout. + inspected_rvh->GetWidget()->StartInputEventAckTimeout(); + task_environment()->FastForwardBy( + base::TimeDelta::FromMilliseconds(kHungRendererDelayMs + 10)); EXPECT_TRUE(delegate.renderer_unresponsive_received()); contents()->SetDelegate(nullptr);
diff --git a/content/browser/renderer_host/input/synthetic_gesture_target_mac.mm b/content/browser/renderer_host/input/synthetic_gesture_target_mac.mm index 2398bc8..5344bde 100644 --- a/content/browser/renderer_host/input/synthetic_gesture_target_mac.mm +++ b/content/browser/renderer_host/input/synthetic_gesture_target_mac.mm
@@ -4,9 +4,10 @@ #include "content/browser/renderer_host/input/synthetic_gesture_target_mac.h" +#import "content/app_shim_remote_cocoa/render_widget_host_view_cocoa.h" #include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_input_event_router.h" -#import "content/app_shim_remote_cocoa/render_widget_host_view_cocoa.h" +#include "ui/events/cocoa/cocoa_event_utils.h" #include "ui/events/gesture_detection/gesture_configuration.h" // Unlike some event APIs, Apple does not provide a way to programmatically @@ -135,7 +136,12 @@ void SyntheticGestureTargetMac::DispatchWebMouseWheelEventToPlatform( const blink::WebMouseWheelEvent& web_wheel, const ui::LatencyInfo& latency_info) { - GetView()->RouteOrProcessWheelEvent(web_wheel); + blink::WebMouseWheelEvent wheel_event = web_wheel; + wheel_event.wheel_ticks_x = + web_wheel.delta_x / ui::kScrollbarPixelsPerCocoaTick; + wheel_event.wheel_ticks_y = + web_wheel.delta_y / ui::kScrollbarPixelsPerCocoaTick; + GetView()->RouteOrProcessWheelEvent(wheel_event); if (web_wheel.phase == blink::WebMouseWheelEvent::kPhaseEnded) { // Send the pending wheel end event immediately. Otherwise, the // MouseWheelPhaseHandler will defer the end event in case of momentum
diff --git a/content/browser/renderer_host/render_process_host_browsertest.cc b/content/browser/renderer_host/render_process_host_browsertest.cc index 1a87f882..7614941c0 100644 --- a/content/browser/renderer_host/render_process_host_browsertest.cc +++ b/content/browser/renderer_host/render_process_host_browsertest.cc
@@ -186,6 +186,11 @@ } void SetUpCommandLine(base::CommandLine* command_line) override { +#if defined(OS_LINUX) + // Due to problems with PulseAudio failing to start, use a fake audio + // stream. https://crbug.com/1047655#c70 + command_line->AppendSwitch(switches::kDisableAudioOutput); +#endif command_line->AppendSwitchASCII( switches::kAutoplayPolicy, switches::autoplay::kNoUserGestureRequiredPolicy); @@ -917,11 +922,6 @@ } void SetUpCommandLine(base::CommandLine* command_line) override { -#if defined(OS_LINUX) - // Due to problems with PulseAudio failing to start, use a fake audio - // stream. https://crbug.com/1047655#c70 - command_line->AppendSwitch(switches::kDisableAudioOutput); -#endif // These flags are necessary to emulate camera input for getUserMedia() // tests. command_line->AppendSwitch(switches::kUseFakeUIForMediaStream);
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index 043bbb8..a7dc1fb 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -449,7 +449,7 @@ } void RenderViewHostImpl::SetBackgroundOpaque(bool opaque) { - Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), opaque)); + GetWidget()->GetAssociatedFrameWidget()->SetBackgroundOpaque(opaque); } bool RenderViewHostImpl::IsMainFrameActive() {
diff --git a/content/browser/renderer_host/render_view_host_unittest.cc b/content/browser/renderer_host/render_view_host_unittest.cc index 2c7cc1e0..a7f76eb7 100644 --- a/content/browser/renderer_host/render_view_host_unittest.cc +++ b/content/browser/renderer_host/render_view_host_unittest.cc
@@ -84,29 +84,54 @@ // The RenderViewHost tells the renderer process about SetBackgroundOpaque() // changes. + +class FakeFrameWidget : public blink::mojom::FrameWidget { + public: + explicit FakeFrameWidget( + mojo::PendingAssociatedReceiver<blink::mojom::FrameWidget> frame_widget) + : receiver_(this, std::move(frame_widget)) {} + FakeFrameWidget(const FakeFrameWidget&) = delete; + void operator=(const FakeFrameWidget&) = delete; + + bool GetBackgroundOpaque() const { + DCHECK_NE(value_, -1); + return value_; + } + void Reset() { value_ = -1; } + + private: + void DragSourceSystemDragEnded() override {} + void SetBackgroundOpaque(bool value) override { value_ = value; } + + mojo::AssociatedReceiver<blink::mojom::FrameWidget> receiver_; + int value_ = -1; +}; + TEST_F(RenderViewHostTest, SetBackgroundOpaque) { + mojo::AssociatedRemote<blink::mojom::FrameWidgetHost> blink_frame_widget_host; + auto blink_frame_widget_host_receiver = + blink_frame_widget_host + .BindNewEndpointAndPassDedicatedReceiverForTesting(); + mojo::AssociatedRemote<blink::mojom::FrameWidget> blink_frame_widget; + auto blink_frame_widget_receiver = + blink_frame_widget.BindNewEndpointAndPassDedicatedReceiverForTesting(); + + test_rvh()->GetWidget()->BindFrameWidgetInterfaces( + std::move(blink_frame_widget_host_receiver), blink_frame_widget.Unbind()); + + FakeFrameWidget fake_frame_widget(std::move(blink_frame_widget_receiver)); + for (bool value : {true, false}) { SCOPED_TRACE(value); // This method is part of RenderWidgetHostOwnerDelegate, provided to the // main frame RenderWidgetHost, which uses it to inform the RenderView // in the renderer process of the background opaque state. - auto* as_owner_delegate = - static_cast<RenderWidgetHostOwnerDelegate*>(test_rvh()); - as_owner_delegate->SetBackgroundOpaque(value); + test_rvh()->GetWidget()->GetAssociatedFrameWidget()->SetBackgroundOpaque( + value); + base::RunLoop().RunUntilIdle(); - // This RenderWidget(View) was a main frame, so it passes along - // transparent background color to the RenderView. - const IPC::Message* set_background = - process()->sink().GetUniqueMessageMatching( - ViewMsg_SetBackgroundOpaque::ID); - ASSERT_TRUE(set_background); - std::tuple<bool> sent_background; - ViewMsg_SetBackgroundOpaque::Read(set_background, &sent_background); - EXPECT_EQ(std::get<0>(sent_background), value); - - // GetUniqueMessageMatching() on the next trip through the loop should - // not find the message from the current loop, so remove that one. - process()->sink().ClearMessages(); + EXPECT_EQ(fake_frame_widget.GetBackgroundOpaque(), value); + fake_frame_widget.Reset(); } }
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index d0d97683..5ad66a6a 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -144,6 +144,11 @@ bool g_check_for_pending_visual_properties_ack = true; +bool ShouldDisableHangMonitor() { + return base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableHangMonitor); +} + // <process id, routing id> using RenderWidgetHostID = std::pair<int32_t, int32_t>; using RoutingIDWidgetMap = @@ -364,12 +369,6 @@ SetWidget(std::move(widget)); const auto* command_line = base::CommandLine::ForCurrentProcess(); - if (!command_line->HasSwitch(switches::kDisableHangMonitor)) { - input_event_ack_timeout_ = std::make_unique<TimeoutMonitor>( - base::BindRepeating(&RenderWidgetHostImpl::OnInputEventAckTimeout, - weak_factory_.GetWeakPtr())); - } - if (!command_line->HasSwitch(switches::kDisableNewContentRenderingTimeout)) { new_content_rendering_timeout_ = std::make_unique<TimeoutMonitor>( base::BindRepeating(&RenderWidgetHostImpl::ClearDisplayedGraphics, @@ -1144,17 +1143,27 @@ RestartInputEventAckTimeoutIfNecessary(); } -void RenderWidgetHostImpl::StartInputEventAckTimeout(TimeDelta delay) { - if (!input_event_ack_timeout_) +void RenderWidgetHostImpl::StartInputEventAckTimeout() { + if (ShouldDisableHangMonitor()) return; - input_event_ack_timeout_->Start(delay); - input_event_ack_start_time_ = clock_->NowTicks(); + + if (!input_event_ack_timeout_.IsRunning()) { + input_event_ack_timeout_.Start( + FROM_HERE, hung_renderer_delay_, + base::BindOnce(&RenderWidgetHostImpl::OnInputEventAckTimeout, + weak_factory_.GetWeakPtr())); + input_event_ack_start_time_ = clock_->NowTicks(); + } } void RenderWidgetHostImpl::RestartInputEventAckTimeoutIfNecessary() { - if (!GetProcess()->IsBlocked() && input_event_ack_timeout_ && - in_flight_event_count_ > 0 && !is_hidden_) - input_event_ack_timeout_->Restart(hung_renderer_delay_); + if (!GetProcess()->IsBlocked() && !ShouldDisableHangMonitor() && + in_flight_event_count_ > 0 && !is_hidden_) { + input_event_ack_timeout_.Start( + FROM_HERE, hung_renderer_delay_, + base::BindOnce(&RenderWidgetHostImpl::OnInputEventAckTimeout, + weak_factory_.GetWeakPtr())); + } } bool RenderWidgetHostImpl::IsCurrentlyUnresponsive() { @@ -1162,8 +1171,7 @@ } void RenderWidgetHostImpl::StopInputEventAckTimeout() { - if (input_event_ack_timeout_) - input_event_ack_timeout_->Stop(); + input_event_ack_timeout_.Stop(); if (!input_event_ack_start_time_.is_null()) { base::TimeDelta elapsed = clock_->NowTicks() - input_event_ack_start_time_; @@ -2693,7 +2701,7 @@ void RenderWidgetHostImpl::IncrementInFlightEventCount() { ++in_flight_event_count_; if (!is_hidden_) - StartInputEventAckTimeout(hung_renderer_delay_); + StartInputEventAckTimeout(); } void RenderWidgetHostImpl::DecrementInFlightEventCount( @@ -2768,6 +2776,11 @@ return false; } +const mojo::AssociatedRemote<blink::mojom::FrameWidget>& +RenderWidgetHostImpl::GetAssociatedFrameWidget() { + return blink_frame_widget_; +} + void RenderWidgetHostImpl::DispatchInputEventWithLatencyInfo( const blink::WebInputEvent& event, ui::LatencyInfo* latency) {
diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h index 0404d8c..013b2165 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h
@@ -29,6 +29,7 @@ #include "base/time/tick_clock.h" #include "base/time/time.h" #include "base/timer/elapsed_timer.h" +#include "base/timer/timer.h" #include "build/build_config.h" #include "components/viz/common/surfaces/frame_sink_id.h" #include "content/browser/renderer_host/event_with_latency_info.h" @@ -178,12 +179,6 @@ // RenderWidgetHostImpl. static RenderWidgetHostImpl* From(RenderWidgetHost* rwh); - void set_hung_renderer_delay(const base::TimeDelta& delay) { - hung_renderer_delay_ = delay; - } - - base::TimeDelta hung_renderer_delay() { return hung_renderer_delay_; } - void set_new_content_rendering_delay_for_testing( const base::TimeDelta& delay) { new_content_rendering_delay_ = delay; @@ -787,6 +782,9 @@ // Add/ClearPendingUserActivation() for details. bool RemovePendingUserActivationIfAvailable(); + const mojo::AssociatedRemote<blink::mojom::FrameWidget>& + GetAssociatedFrameWidget(); + protected: // --------------------------------------------------------------------------- // The following method is overridden by RenderViewHost to send upwards to @@ -958,7 +956,7 @@ // Starts a hang monitor timeout. If there's already a hang monitor timeout // the new one will only fire if it has a shorter delay than the time // left on the existing timeouts. - void StartInputEventAckTimeout(base::TimeDelta delay); + void StartInputEventAckTimeout(); // Stops all existing hang monitor timeouts and assumes the renderer is // responsive. @@ -1181,7 +1179,7 @@ // Receives and handles all input events. std::unique_ptr<InputRouter> input_router_; - std::unique_ptr<TimeoutMonitor> input_event_ack_timeout_; + base::OneShotTimer input_event_ack_timeout_; base::TimeTicks input_event_ack_start_time_; std::unique_ptr<base::CallbackList<void(bool)>::Subscription>
diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc index acff15a55..56974559 100644 --- a/content/browser/renderer_host/render_widget_host_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_unittest.cc
@@ -33,6 +33,7 @@ #include "content/browser/renderer_host/render_view_host_delegate_view.h" #include "content/browser/renderer_host/render_widget_host_delegate.h" #include "content/browser/renderer_host/render_widget_host_view_base.h" +#include "content/common/content_constants_internal.h" #include "content/common/edit_command.h" #include "content/common/input/synthetic_web_input_event_builders.h" #include "content/common/input_messages.h" @@ -1322,53 +1323,43 @@ // Test that the hang monitor timer expires properly if a new timer is started // while one is in progress (see crbug.com/11007). TEST_F(RenderWidgetHostTest, DontPostponeInputEventAckTimeout) { - // Start with a short timeout. - host_->StartInputEventAckTimeout(TimeDelta::FromMilliseconds(10)); + base::TimeDelta delay = + base::TimeDelta::FromMilliseconds(kHungRendererDelayMs); - // Immediately try to add a long 30 second timeout. + // Start a timeout. + host_->StartInputEventAckTimeout(); + + task_environment_.FastForwardBy(delay / 2); + + // Add another timeout. EXPECT_FALSE(delegate_->unresponsive_timer_fired()); - host_->StartInputEventAckTimeout(TimeDelta::FromSeconds(30)); + host_->StartInputEventAckTimeout(); // Wait long enough for first timeout and see if it fired. - task_environment_.FastForwardBy(TimeDelta::FromMilliseconds(10)); + task_environment_.FastForwardBy(delay); EXPECT_TRUE(delegate_->unresponsive_timer_fired()); } // Test that the hang monitor timer expires properly if it is started, stopped, // and then started again. TEST_F(RenderWidgetHostTest, StopAndStartInputEventAckTimeout) { - // Start with a short timeout, then stop it. - host_->StartInputEventAckTimeout(TimeDelta::FromMilliseconds(10)); + // Start a timeout, then stop it. + host_->StartInputEventAckTimeout(); host_->StopInputEventAckTimeout(); // Start it again to ensure it still works. EXPECT_FALSE(delegate_->unresponsive_timer_fired()); - host_->StartInputEventAckTimeout(TimeDelta::FromMilliseconds(10)); + host_->StartInputEventAckTimeout(); // Wait long enough for first timeout and see if it fired. - task_environment_.FastForwardBy(TimeDelta::FromMilliseconds(40)); - EXPECT_TRUE(delegate_->unresponsive_timer_fired()); -} - -// Test that the hang monitor timer expires properly if it is started, then -// updated to a shorter duration. -TEST_F(RenderWidgetHostTest, ShorterDelayInputEventAckTimeout) { - // Start with a timeout. - host_->StartInputEventAckTimeout(TimeDelta::FromMilliseconds(100)); - - // Start it again with shorter delay. - EXPECT_FALSE(delegate_->unresponsive_timer_fired()); - host_->StartInputEventAckTimeout(TimeDelta::FromMilliseconds(20)); - - // Wait long enough for the second timeout and see if it fired. - task_environment_.FastForwardBy(TimeDelta::FromMilliseconds(25)); + task_environment_.FastForwardBy( + base::TimeDelta::FromMilliseconds(kHungRendererDelayMs + 10)); EXPECT_TRUE(delegate_->unresponsive_timer_fired()); } // Test that the hang monitor timer is effectively disabled when the widget is // hidden. TEST_F(RenderWidgetHostTest, InputEventAckTimeoutDisabledForInputWhenHidden) { - host_->set_hung_renderer_delay(base::TimeDelta::FromMicroseconds(1)); SimulateMouseEvent(WebInputEvent::kMouseMove, 10, 10, 0, false); // Hiding the widget should deactivate the timeout. @@ -1376,18 +1367,21 @@ // The timeout should not fire. EXPECT_FALSE(delegate_->unresponsive_timer_fired()); - task_environment_.FastForwardBy(TimeDelta::FromMilliseconds(2)); + task_environment_.FastForwardBy( + base::TimeDelta::FromMilliseconds(kHungRendererDelayMs + 10)); EXPECT_FALSE(delegate_->unresponsive_timer_fired()); // The timeout should never reactivate while hidden. SimulateMouseEvent(WebInputEvent::kMouseMove, 10, 10, 0, false); - task_environment_.FastForwardBy(TimeDelta::FromMilliseconds(2)); + task_environment_.FastForwardBy( + base::TimeDelta::FromMilliseconds(kHungRendererDelayMs + 10)); EXPECT_FALSE(delegate_->unresponsive_timer_fired()); // Showing the widget should restore the timeout, as the events have // not yet been ack'ed. host_->WasShown(base::nullopt /* record_tab_switch_time_request */); - task_environment_.FastForwardBy(TimeDelta::FromMilliseconds(2)); + task_environment_.FastForwardBy( + base::TimeDelta::FromMilliseconds(kHungRendererDelayMs + 10)); EXPECT_TRUE(delegate_->unresponsive_timer_fired()); } @@ -1395,12 +1389,10 @@ // This can happen if the second input event causes the renderer to hang. // This test will catch a regression of crbug.com/111185. TEST_F(RenderWidgetHostTest, MultipleInputEvents) { - // Configure the host to wait 10ms before considering - // the renderer hung. - host_->set_hung_renderer_delay(base::TimeDelta::FromMicroseconds(10)); - // Send two events but only one ack. SimulateKeyboardEvent(WebInputEvent::kRawKeyDown); + task_environment_.FastForwardBy( + base::TimeDelta::FromMilliseconds(kHungRendererDelayMs / 2)); SimulateKeyboardEvent(WebInputEvent::kRawKeyDown); MockWidgetInputHandler::MessageVector dispatched_events = @@ -1411,10 +1403,12 @@ // Send the simulated response from the renderer back. dispatched_events[0]->ToEvent()->CallCallback(INPUT_EVENT_ACK_STATE_CONSUMED); - // Wait long enough for first timeout and see if it fired. - task_environment_.FastForwardBy(TimeDelta::FromMilliseconds(20)); + // Wait long enough for second timeout and see if it fired. + task_environment_.FastForwardBy( + base::TimeDelta::FromMilliseconds(kHungRendererDelayMs + 10)); EXPECT_TRUE(delegate_->unresponsive_timer_fired()); } + TEST_F(RenderWidgetHostTest, IgnoreInputEvent) { host_->SetupForInputRouterTest();
diff --git a/content/browser/security_exploit_browsertest.cc b/content/browser/security_exploit_browsertest.cc index 6328164..7d6e0371 100644 --- a/content/browser/security_exploit_browsertest.cc +++ b/content/browser/security_exploit_browsertest.cc
@@ -81,7 +81,6 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/public/common/blob/blob_utils.h" -#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/navigation/triggering_event_info.h" #include "third_party/blink/public/mojom/appcache/appcache.mojom.h" #include "third_party/blink/public/mojom/blob/blob_url_store.mojom-test-utils.h" @@ -517,10 +516,7 @@ class CorsExploitBrowserTest : public ContentBrowserTest { public: - CorsExploitBrowserTest() { - feature_list_.InitAndEnableFeature( - blink::features::kHtmlImportsRequestInitiatorLock); - } + CorsExploitBrowserTest() = default; void SetUpCommandLine(base::CommandLine* command_line) override { // TODO(yoichio): This is temporary switch to support chrome internal @@ -537,8 +533,6 @@ } private: - base::test::ScopedFeatureList feature_list_; - DISALLOW_COPY_AND_ASSIGN(CorsExploitBrowserTest); };
diff --git a/content/browser/tracing/BUILD.gn b/content/browser/tracing/BUILD.gn index 52e083c7..eac05999 100644 --- a/content/browser/tracing/BUILD.gn +++ b/content/browser/tracing/BUILD.gn
@@ -32,7 +32,9 @@ grit("resources") { source = tracing_grd - source_is_generated = true + + # Required because the .grd is generated. + enable_input_discovery_for_gn_analyze = false outputs = [ "grit/tracing_resources.h",
diff --git a/content/browser/tracing/background_tracing_manager_browsertest.cc b/content/browser/tracing/background_tracing_manager_browsertest.cc index 3114af54..cbd31de 100644 --- a/content/browser/tracing/background_tracing_manager_browsertest.cc +++ b/content/browser/tracing/background_tracing_manager_browsertest.cc
@@ -1098,8 +1098,9 @@ // Test that the tracing sampler profiler running in background tracing mode, // produces stack frames in the expected JSON format. +// TODO(https://crbug.com/1062581) Disabled for being flaky. IN_PROC_BROWSER_TEST_F(BackgroundTracingManagerBrowserTest, - EndToEndStackSampling) { + DISABLED_EndToEndStackSampling) { // In the browser process, the tracing sampler profiler gets constructed by // the chrome/ layer, so we need to do the same manually for testing purposes. auto tracing_sampler_profiler =
diff --git a/content/child/runtime_features.cc b/content/child/runtime_features.cc index d918fb0..c35edb5 100644 --- a/content/child/runtime_features.cc +++ b/content/child/runtime_features.cc
@@ -334,6 +334,7 @@ kEnableOnly}, {"FeaturePolicyForClientHints", features::kFeaturePolicyForClientHints, kUseFeatureState}, + {"FontAccess", blink::features::kFontAccess, kUseFeatureState}, {"FontSrcLocalMatching", features::kFontSrcLocalMatching, kUseFeatureState}, {"HTMLImports", blink::features::kWebComponentsV0Enabled,
diff --git a/content/common/view_messages.h b/content/common/view_messages.h index ee01a44..b75aee16 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h
@@ -95,9 +95,6 @@ // Messages sent from the browser to the renderer. -// Make the RenderWidget background transparent or opaque. -IPC_MESSAGE_ROUTED1(ViewMsg_SetBackgroundOpaque, bool /* opaque */) - // This passes a set of webkit preferences down to the renderer. IPC_MESSAGE_ROUTED1(ViewMsg_UpdateWebPreferences, content::WebPreferences)
diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc index cecd66d..5022acc 100644 --- a/content/public/common/content_features.cc +++ b/content/public/common/content_features.cc
@@ -273,12 +273,6 @@ base::FEATURE_DISABLED_BY_DEFAULT}; const char kIsolateOriginsFieldTrialParamName[] = "OriginsList"; -const base::Feature kBuiltInModuleAll{"BuiltInModuleAll", - base::FEATURE_DISABLED_BY_DEFAULT}; - -const base::Feature kBuiltInModuleInfra{"BuiltInModuleInfra", - base::FEATURE_DISABLED_BY_DEFAULT}; - const base::Feature kLazyFrameLoading{"LazyFrameLoading", base::FEATURE_ENABLED_BY_DEFAULT}; const base::Feature kLazyFrameVisibleLoadTimeMetrics {
diff --git a/content/public/common/content_features.h b/content/public/common/content_features.h index 35a608d..fb8cf5d 100644 --- a/content/public/common/content_features.h +++ b/content/public/common/content_features.h
@@ -68,8 +68,6 @@ CONTENT_EXPORT extern const base::Feature kInstalledAppProvider; CONTENT_EXPORT extern const base::Feature kIsolateOrigins; CONTENT_EXPORT extern const char kIsolateOriginsFieldTrialParamName[]; -CONTENT_EXPORT extern const base::Feature kBuiltInModuleAll; -CONTENT_EXPORT extern const base::Feature kBuiltInModuleInfra; CONTENT_EXPORT extern const base::Feature kLazyFrameLoading; CONTENT_EXPORT extern const base::Feature kLazyFrameVisibleLoadTimeMetrics; CONTENT_EXPORT extern const base::Feature kLazyImageLoading;
diff --git a/content/renderer/input/render_widget_input_handler.cc b/content/renderer/input/render_widget_input_handler.cc index 5eec94d..2c5a218e 100644 --- a/content/renderer/input/render_widget_input_handler.cc +++ b/content/renderer/input/render_widget_input_handler.cc
@@ -379,7 +379,8 @@ auto scoped_event_metrics_monitor = widget_->layer_tree_host()->GetScopedEventMetricsMonitor( {ui::WebEventTypeToEventType(input_event.GetType()), - input_event.TimeStamp()}); + input_event.TimeStamp(), + ui::GetScrollInputTypeForEvent(input_event)}); bool prevent_default = false; bool show_virtual_keyboard_for_mouse = false; @@ -697,9 +698,10 @@ auto scoped_event_metrics_monitor = widget_->layer_tree_host()->GetScopedEventMetricsMonitor( {ui::WebEventTypeToEventType(gesture_event->GetType()), - gesture_event->TimeStamp()}); + gesture_event->TimeStamp(), + ui::GetScrollInputTypeForEvent(*gesture_event)}); widget_->GetWebWidget()->HandleInputEvent( - blink::WebCoalescedInputEvent(*gesture_event.get())); + blink::WebCoalescedInputEvent(*gesture_event)); } } }
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 3a2a940..f0cb483 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc
@@ -1185,7 +1185,6 @@ IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) - IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque) // Page messages. IPC_MESSAGE_HANDLER(PageMsg_VisibilityChanged, OnPageVisibilityChanged) @@ -1874,19 +1873,6 @@ } } -void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { - if (!GetWebView()) - return; - - if (opaque) { - GetWebView()->ClearBaseBackgroundColorOverride(); - GetWebView()->ClearBackgroundColorOverride(); - } else { - GetWebView()->SetBaseBackgroundColorOverride(SK_ColorTRANSPARENT); - GetWebView()->SetBackgroundColorOverride(SK_ColorTRANSPARENT); - } -} - // static scoped_refptr<base::SingleThreadTaskRunner> RenderViewImpl::GetCleanupTaskRunner() {
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index 286e207..701aac4 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h
@@ -417,7 +417,6 @@ void OnUpdateTargetURLAck(); void OnUpdateWebPreferences(const WebPreferences& prefs); void OnAudioStateChanged(bool is_audio_playing); - void OnSetBackgroundOpaque(bool opaque); // Page message handlers ----------------------------------------------------- void OnPageVisibilityChanged(PageVisibilityState visibility_state);
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index b78d5fc5..640945d 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc
@@ -535,8 +535,10 @@ // for a provisional frame, this importantly starts the compositor before // the frame is inserted into the frame tree, which impacts first paint // metrics. - if (!is_hidden_ && !never_composited_) + if (!is_hidden_ && !never_composited_) { + web_widget->SetCompositorVisible(true); layer_tree_view_->SetVisible(true); + } webwidget_ = web_widget; web_widget->SetCompositorHosts(layer_tree_view_->layer_tree_host(), @@ -1026,8 +1028,6 @@ TRACE_EVENT_WITH_FLOW0("renderer", "RenderWidget::OnWasShown", routing_id(), TRACE_EVENT_FLAG_FLOW_IN); - was_shown_time_ = base::TimeTicks::Now(); - SetHidden(false); if (record_tab_switch_time_request) { layer_tree_host_->RequestPresentationTimeForNextFrame( @@ -1240,42 +1240,21 @@ void RenderWidget::UpdateVisualState() { DCHECK(!IsForProvisionalFrame()); - - // We record metrics only when running in multi-threaded mode, not - // single-thread mode for testing. - bool record_main_frame_metrics = - !!compositor_deps_->GetCompositorImplThreadTaskRunner(); - - // When recording main frame metrics set the lifecycle reason to - // kBeginMainFrame, because this is the calller of UpdateLifecycle - // for the main frame. Otherwise, set the reason to kTests, which is - // the only other reason this method is called. - blink::DocumentUpdateReason lifecycle_reason = - record_main_frame_metrics ? blink::DocumentUpdateReason::kBeginMainFrame - : blink::DocumentUpdateReason::kTest; - GetWebWidget()->UpdateLifecycle(blink::WebLifecycleUpdate::kAll, - lifecycle_reason); - GetWebWidget()->SetSuppressFrameRequestsWorkaroundFor704763Only(false); - - if (first_update_visual_state_after_hidden_) { - RecordTimeToFirstActivePaint(); - first_update_visual_state_after_hidden_ = false; - } + GetWebWidget()->UpdateVisualState(); } -void RenderWidget::RecordTimeToFirstActivePaint() { +void RenderWidget::RecordTimeToFirstActivePaint(base::TimeDelta duration) { RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); - base::TimeDelta sample = base::TimeTicks::Now() - was_shown_time_; if (render_thread_impl->NeedsToRecordFirstActivePaint(TTFAP_AFTER_PURGED)) { UMA_HISTOGRAM_TIMES("PurgeAndSuspend.Experimental.TimeToFirstActivePaint", - sample); + duration); } if (render_thread_impl->NeedsToRecordFirstActivePaint( TTFAP_5MIN_AFTER_BACKGROUNDED)) { UMA_HISTOGRAM_TIMES( "PurgeAndSuspend.Experimental.TimeToFirstActivePaint." "AfterBackgrounded.5min", - sample); + duration); } } @@ -1305,7 +1284,7 @@ void RenderWidget::WillBeginCompositorFrame() { TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); - GetWebWidget()->SetSuppressFrameRequestsWorkaroundFor704763Only(true); + GetWebWidget()->WillBeginCompositorFrame(); // The UpdateTextInputState can result in further layout and possibly // enable GPU acceleration so they need to be called before any painting @@ -2441,9 +2420,6 @@ // throttled acks are released in case frame production ceases. is_hidden_ = hidden; - if (is_hidden_) - first_update_visual_state_after_hidden_ = true; - if (render_widget_scheduling_state_) render_widget_scheduling_state_->SetHidden(hidden); @@ -2452,8 +2428,10 @@ if (is_hidden_) widget_input_handler_manager_->InvokeInputProcessedCallback(); - if (!never_composited_) + if (!never_composited_) { + webwidget_->SetCompositorVisible(!is_hidden_); layer_tree_view_->SetVisible(!is_hidden_); + } } void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) { @@ -2688,6 +2666,8 @@ cc::LayerTreeSettings settings; settings.use_zoom_for_dsf = compositor_deps->IsUseZoomForDSFEnabled(); + settings.percent_based_scrolling = + base::FeatureList::IsEnabled(features::kPercentBasedScrolling); settings.compositor_threaded_scrollbar_scrolling = base::FeatureList::IsEnabled( features::kCompositorThreadedScrollbarScrolling);
diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index 28fd49a..fd76b067 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h
@@ -436,6 +436,7 @@ void AddPresentationCallback( uint32_t frame_token, base::OnceCallback<void(base::TimeTicks)> callback) override; + void RecordTimeToFirstActivePaint(base::TimeDelta duration) override; // Returns the scale being applied to the document in blink by the device // emulator. Returns 1 if there is no emulation active. Use this to position @@ -800,7 +801,6 @@ // local root associated with this RenderWidget. PepperPluginInstanceImpl* GetFocusedPepperPluginInsideWidget(); #endif - void RecordTimeToFirstActivePaint(); // This method returns the WebLocalFrame which is currently focused and // belongs to the frame tree associated with this RenderWidget. @@ -1041,9 +1041,6 @@ // session, this info is sent to the browser along with other drag/drop info. DragEventSourceInfo possible_drag_event_info_; - bool first_update_visual_state_after_hidden_ = false; - base::TimeTicks was_shown_time_ = base::TimeTicks::Now(); - // Object to record tab switch time into this RenderWidget ContentToVisibleTimeReporter tab_switch_time_recorder_;
diff --git a/content/renderer/render_widget_fullscreen_pepper.cc b/content/renderer/render_widget_fullscreen_pepper.cc index deb602f..8622d653 100644 --- a/content/renderer/render_widget_fullscreen_pepper.cc +++ b/content/renderer/render_widget_fullscreen_pepper.cc
@@ -157,6 +157,10 @@ void DidResize(const gfx::Size& size) override { widget_->DidResize(size); } + void RecordTimeToFirstActivePaint(base::TimeDelta duration) override { + widget_->RecordTimeToFirstActivePaint(duration); + } + private: RenderWidgetFullscreenPepper* widget_; };
diff --git a/content/test/test_render_view_host.cc b/content/test/test_render_view_host.cc index 4b1e4a02..75bb605 100644 --- a/content/test/test_render_view_host.cc +++ b/content/test/test_render_view_host.cc
@@ -28,6 +28,7 @@ #include "content/public/common/page_state.h" #include "content/public/common/web_preferences.h" #include "content/test/test_render_frame_host.h" +#include "content/test/test_render_view_host.h" #include "content/test/test_web_contents.h" #include "media/base/video_frame.h" #include "mojo/public/cpp/bindings/pending_remote.h" @@ -274,6 +275,15 @@ main_frame->BindInterfaceProviderReceiver( stub_interface_provider_remote.InitWithNewPipeAndPassReceiver()); main_frame->SetRenderFrameCreated(true); + + mojo::AssociatedRemote<blink::mojom::FrameWidgetHost> frame_widget_host; + auto frame_widget_host_receiver = + frame_widget_host.BindNewEndpointAndPassDedicatedReceiverForTesting(); + mojo::AssociatedRemote<blink::mojom::FrameWidget> frame_widget; + auto frame_widget_receiver = + frame_widget.BindNewEndpointAndPassDedicatedReceiverForTesting(); + GetWidget()->BindFrameWidgetInterfaces( + std::move(frame_widget_host_receiver), frame_widget.Unbind()); } return true; @@ -320,7 +330,9 @@ static_cast<RenderFrameHostImpl*>(GetMainFrame())->OnUpdateState(state); } -RenderViewHostImplTestHarness::RenderViewHostImplTestHarness() { +RenderViewHostImplTestHarness::RenderViewHostImplTestHarness() + : RenderViewHostTestHarness( + base::test::TaskEnvironment::TimeSource::MOCK_TIME) { std::vector<ui::ScaleFactor> scale_factors; scale_factors.push_back(ui::SCALE_FACTOR_100P); scoped_set_supported_scale_factors_.reset(
diff --git a/device/base/device_info_query_win.cc b/device/base/device_info_query_win.cc index eaa41a7..b33dac0e 100644 --- a/device/base/device_info_query_win.cc +++ b/device/base/device_info_query_win.cc
@@ -26,9 +26,9 @@ } } -bool DeviceInfoQueryWin::AddDevice(const std::string& device_path) { - return SetupDiOpenDeviceInterfaceA(device_info_list_, device_path.c_str(), 0, - nullptr) != FALSE; +bool DeviceInfoQueryWin::AddDevice(const base::string16& device_path) { + return SetupDiOpenDeviceInterface(device_info_list_, device_path.c_str(), 0, + nullptr) != FALSE; } bool DeviceInfoQueryWin::GetDeviceInfo() { @@ -53,15 +53,15 @@ return false; } - base::string16 buffer16; + base::string16 buffer; if (!SetupDiGetDeviceProperty( device_info_list_, &device_info_data_, &property, &property_type, - reinterpret_cast<PBYTE>(base::WriteInto(&buffer16, required_size)), + reinterpret_cast<PBYTE>(base::WriteInto(&buffer, required_size)), required_size, nullptr, 0)) { return false; } - *property_buffer = base::UTF16ToUTF8(buffer16); + *property_buffer = base::UTF16ToUTF8(buffer); return true; }
diff --git a/device/base/device_info_query_win.h b/device/base/device_info_query_win.h index f9f464a..0066d61 100644 --- a/device/base/device_info_query_win.h +++ b/device/base/device_info_query_win.h
@@ -11,6 +11,7 @@ #include <string> #include "base/macros.h" +#include "base/strings/string16.h" #include "device/base/device_base_export.h" namespace device { @@ -25,7 +26,7 @@ // Add a device to |device_info_list_| using its |device_path| so that // its device info can be retrieved. - bool AddDevice(const std::string& device_path); + bool AddDevice(const base::string16& device_path); // Get the device info and store it into |device_info_data_|, this function // should be called at most once. bool GetDeviceInfo();
diff --git a/device/base/device_monitor_win.cc b/device/base/device_monitor_win.cc index 0b8af15..faf4574 100644 --- a/device/base/device_monitor_win.cc +++ b/device/base/device_monitor_win.cc
@@ -4,9 +4,11 @@ #include "device/base/device_monitor_win.h" -#include <dbt.h> +// windows.h must be included before dbt.h. #include <windows.h> +#include <dbt.h> + #include <map> #include <memory> @@ -121,7 +123,7 @@ if (map_entry != device_monitors_.end()) device_monitor = map_entry->second.get(); - std::string device_path(base::SysWideToUTF8(db->dbcc_name)); + base::string16 device_path(db->dbcc_name); DCHECK(base::IsStringASCII(device_path)); device_path = base::ToLowerASCII(device_path); @@ -152,13 +154,13 @@ DISALLOW_COPY_AND_ASSIGN(DeviceMonitorMessageWindow); }; -void DeviceMonitorWin::Observer::OnDeviceAdded(const GUID& class_guid, - const std::string& device_path) { -} +void DeviceMonitorWin::Observer::OnDeviceAdded( + const GUID& class_guid, + const base::string16& device_path) {} void DeviceMonitorWin::Observer::OnDeviceRemoved( const GUID& class_guid, - const std::string& device_path) {} + const base::string16& device_path) {} // static DeviceMonitorWin* DeviceMonitorWin::GetForDeviceInterface( @@ -194,13 +196,13 @@ DeviceMonitorWin::DeviceMonitorWin() {} void DeviceMonitorWin::NotifyDeviceAdded(const GUID& class_guid, - const std::string& device_path) { + const base::string16& device_path) { for (auto& observer : observer_list_) observer.OnDeviceAdded(class_guid, device_path); } void DeviceMonitorWin::NotifyDeviceRemoved(const GUID& class_guid, - const std::string& device_path) { + const base::string16& device_path) { for (auto& observer : observer_list_) observer.OnDeviceRemoved(class_guid, device_path); }
diff --git a/device/base/device_monitor_win.h b/device/base/device_monitor_win.h index 0f46eb8..648ed8c70 100644 --- a/device/base/device_monitor_win.h +++ b/device/base/device_monitor_win.h
@@ -5,9 +5,11 @@ #ifndef DEVICE_BASE_DEVICE_MONITOR_WIN_H_ #define DEVICE_BASE_DEVICE_MONITOR_WIN_H_ -#include <windows.h> +#include <string> #include "base/observer_list.h" +#include "base/strings/string16.h" +#include "base/win/windows_types.h" #include "device/base/device_base_export.h" namespace device { @@ -19,9 +21,9 @@ class DEVICE_BASE_EXPORT Observer { public: virtual void OnDeviceAdded(const GUID& class_guid, - const std::string& device_path); + const base::string16& device_path); virtual void OnDeviceRemoved(const GUID& class_guid, - const std::string& device_path); + const base::string16& device_path); }; ~DeviceMonitorWin(); @@ -38,9 +40,9 @@ DeviceMonitorWin(); void NotifyDeviceAdded(const GUID& class_guid, - const std::string& device_path); + const base::string16& device_path); void NotifyDeviceRemoved(const GUID& class_guid, - const std::string& device_path); + const base::string16& device_path); base::ObserverList<Observer>::Unchecked observer_list_; };
diff --git a/device/gamepad/nintendo_data_fetcher_unittest.cc b/device/gamepad/nintendo_data_fetcher_unittest.cc index b744105..27d7081 100644 --- a/device/gamepad/nintendo_data_fetcher_unittest.cc +++ b/device/gamepad/nintendo_data_fetcher_unittest.cc
@@ -24,8 +24,10 @@ #if defined(OS_MACOSX) const uint64_t kTestDeviceId = 123; +#elif defined(OS_WIN) +const wchar_t kTestDeviceId[] = L"123"; #else -const char* kTestDeviceId = "123"; +const char kTestDeviceId[] = "123"; #endif const char kPhysicalDeviceId[] = "1";
diff --git a/extensions/browser/api/declarative/declarative_rule_unittest.cc b/extensions/browser/api/declarative/declarative_rule_unittest.cc index 831768e..78e2840a 100644 --- a/extensions/browser/api/declarative/declarative_rule_unittest.cc +++ b/extensions/browser/api/declarative/declarative_rule_unittest.cc
@@ -12,6 +12,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +using base::test::ParseJson; using base::test::ParseJsonDeprecated; using url_matcher::URLMatcher; using url_matcher::URLMatcherConditionFactory; @@ -300,21 +301,21 @@ TEST(DeclarativeRuleTest, Create) { typedef DeclarativeRule<FulfillableCondition, SummingAction> Rule; Rule::JsonRule json_rule; - ASSERT_TRUE(Rule::JsonRule::Populate( - *ParseJsonDeprecated("{ \n" - " \"id\": \"rule1\", \n" - " \"conditions\": [ \n" - " {\"url_id\": 1, \"max\": 3}, \n" - " {\"url_id\": 2, \"max\": 5}, \n" - " ], \n" - " \"actions\": [ \n" - " { \n" - " \"value\": 2 \n" - " } \n" - " ], \n" - " \"priority\": 200 \n" - "}"), - &json_rule)); + ASSERT_TRUE(Rule::JsonRule::Populate(ParseJson(R"( + { + "id": "rule1", + "conditions": [ + {"url_id": 1, "max": 3}, + {"url_id": 2, "max": 5}, + ], + "actions": [ + { + "value": 2 + } + ], + "priority": 200 + })"), + &json_rule)); const char kExtensionId[] = "ext1"; scoped_refptr<const Extension> extension = ExtensionBuilder() @@ -376,40 +377,39 @@ .SetID(kExtensionId) .Build(); - ASSERT_TRUE(Rule::JsonRule::Populate( - *ParseJsonDeprecated("{ \n" - " \"id\": \"rule1\", \n" - " \"conditions\": [ \n" - " {\"url_id\": 1, \"max\": 3}, \n" - " {\"url_id\": 2, \"max\": 5}, \n" - " ], \n" - " \"actions\": [ \n" - " { \n" - " \"value\": 2 \n" - " } \n" - " ], \n" - " \"priority\": 200 \n" - "}"), - &json_rule)); + ASSERT_TRUE(Rule::JsonRule::Populate(ParseJson(R"( + { + "id": "rule1", + "conditions": [ + {"url_id": 1, "max": 3}, + {"url_id": 2, "max": 5}, + ], + "actions": [ + { + "value": 2 + } + ], + "priority": 200 + })"), + &json_rule)); std::unique_ptr<Rule> rule(Rule::Create( matcher.condition_factory(), nullptr, extension.get(), base::Time(), json_rule, base::Bind(AtLeastOneCondition), &error)); EXPECT_TRUE(rule); EXPECT_EQ("", error); - ASSERT_TRUE( - Rule::JsonRule::Populate(*ParseJsonDeprecated("{ \n" - " \"id\": \"rule1\", \n" - " \"conditions\": [ \n" - " ], \n" - " \"actions\": [ \n" - " { \n" - " \"value\": 2 \n" - " } \n" - " ], \n" - " \"priority\": 200 \n" - "}"), - &json_rule)); + ASSERT_TRUE(Rule::JsonRule::Populate(ParseJson(R"({ + "id": "rule1", + "conditions": [ + ], + "actions": [ + { + "value": 2 + } + ], + "priority": 200 + })"), + &json_rule)); rule = Rule::Create(matcher.condition_factory(), nullptr, extension.get(), base::Time(), json_rule, base::Bind(AtLeastOneCondition), &error);
diff --git a/extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc b/extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc index 1c288b4..8e6d4006 100644 --- a/extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc +++ b/extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc
@@ -27,40 +27,38 @@ // Test wrong condition name passed. error.clear(); + constexpr const char kWrongNameCondition[] = R"({ + "invalid": "foobar", + "instanceType": "declarativeWebRequest.RequestMatcher", + })"; result = WebRequestCondition::Create( - NULL, matcher.condition_factory(), - *base::test::ParseJsonDeprecated( - "{ \"invalid\": \"foobar\", \n" - " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n" - "}"), - &error); + nullptr, matcher.condition_factory(), + base::test::ParseJson(kWrongNameCondition), &error); EXPECT_FALSE(error.empty()); EXPECT_FALSE(result.get()); // Test wrong datatype in host_suffix. + constexpr const char kWrongDataTypeCondition[] = R"({ + "url": [], + "instanceType": "declarativeWebRequest.RequestMatcher", + })"; error.clear(); result = WebRequestCondition::Create( - NULL, matcher.condition_factory(), - *base::test::ParseJsonDeprecated( - "{ \n" - " \"url\": [], \n" - " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n" - "}"), - &error); + nullptr, matcher.condition_factory(), + base::test::ParseJson(kWrongDataTypeCondition), &error); EXPECT_FALSE(error.empty()); EXPECT_FALSE(result.get()); // Test success (can we support multiple criteria?) error.clear(); + constexpr const char kMultipleCriteriaCondition[] = R"({ + "resourceType": ["main_frame"], + "url": { "hostSuffix": "example.com" }, + "instanceType": "declarativeWebRequest.RequestMatcher", + })"; result = WebRequestCondition::Create( - NULL, matcher.condition_factory(), - *base::test::ParseJsonDeprecated( - "{ \n" - " \"resourceType\": [\"main_frame\"], \n" - " \"url\": { \"hostSuffix\": \"example.com\" }, \n" - " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n" - "}"), - &error); + nullptr, matcher.condition_factory(), + base::test::ParseJson(kMultipleCriteriaCondition), &error); EXPECT_EQ("", error); ASSERT_TRUE(result.get()); @@ -103,14 +101,13 @@ std::string error; std::unique_ptr<WebRequestCondition> result; - result = WebRequestCondition::Create( - NULL, matcher.condition_factory(), - *base::test::ParseJsonDeprecated( - "{ \n" - " \"firstPartyForCookiesUrl\": { \"hostPrefix\": \"fpfc\"}, \n" - " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n" - "}"), - &error); + constexpr const char kCondition[] = R"({ + "firstPartyForCookiesUrl": { "hostPrefix": "fpfc"}, + "instanceType": "declarativeWebRequest.RequestMatcher", + })"; + result = + WebRequestCondition::Create(nullptr, matcher.condition_factory(), + base::test::ParseJson(kCondition), &error); EXPECT_EQ("", error); ASSERT_TRUE(result.get()); } @@ -127,46 +124,43 @@ // The empty condition. error.clear(); + constexpr const char kEmptyCondition[] = R"({ + "instanceType": "declarativeWebRequest.RequestMatcher", + })"; std::unique_ptr<WebRequestCondition> condition_empty = - WebRequestCondition::Create( - NULL, matcher.condition_factory(), - *base::test::ParseJsonDeprecated( - "{ \n" - " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n" - "}"), - &error); + WebRequestCondition::Create(nullptr, matcher.condition_factory(), + base::test::ParseJson(kEmptyCondition), + &error); EXPECT_EQ("", error); ASSERT_TRUE(condition_empty.get()); // A condition without a UrlFilter attribute, which is always true. error.clear(); + constexpr const char kTrueConditionWithoutUrlFilter[] = R"({ + "instanceType": "declarativeWebRequest.RequestMatcher", + + // There is no "1st party for cookies" URL in the requests below, + // therefore all requests are considered first party for cookies. + "thirdPartyForCookies": false, + })"; std::unique_ptr<WebRequestCondition> condition_no_url_true = WebRequestCondition::Create( - NULL, matcher.condition_factory(), - *base::test::ParseJsonDeprecated( - "{ \n" - " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", " - "\n" - // There is no "1st party for cookies" URL in the requests below, - // therefore all requests are considered first party for cookies. - " \"thirdPartyForCookies\": false, \n" - "}"), - &error); + nullptr, matcher.condition_factory(), + base::test::ParseJson(kTrueConditionWithoutUrlFilter), &error); EXPECT_EQ("", error); ASSERT_TRUE(condition_no_url_true.get()); // A condition without a UrlFilter attribute, which is always false. error.clear(); + constexpr const char kFalseConditionWithoutUrlFilter[] = R"({ + "instanceType": "declarativeWebRequest.RequestMatcher", + + "thirdPartyForCookies": true, + })"; std::unique_ptr<WebRequestCondition> condition_no_url_false = WebRequestCondition::Create( - NULL, matcher.condition_factory(), - *base::test::ParseJsonDeprecated( - "{ \n" - " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", " - "\n" - " \"thirdPartyForCookies\": true, \n" - "}"), - &error); + nullptr, matcher.condition_factory(), + base::test::ParseJson(kFalseConditionWithoutUrlFilter), &error); EXPECT_EQ("", error); ASSERT_TRUE(condition_no_url_false.get()); @@ -217,7 +211,7 @@ // Test insertion std::string error; std::unique_ptr<WebRequestConditionSet> result = - WebRequestConditionSet::Create(NULL, matcher.condition_factory(), + WebRequestConditionSet::Create(nullptr, matcher.condition_factory(), conditions, &error); EXPECT_EQ("", error); ASSERT_TRUE(result.get()); @@ -278,7 +272,7 @@ // Test insertion std::string error; std::unique_ptr<WebRequestConditionSet> result = - WebRequestConditionSet::Create(NULL, matcher.condition_factory(), + WebRequestConditionSet::Create(nullptr, matcher.condition_factory(), conditions, &error); EXPECT_EQ("", error); ASSERT_TRUE(result.get()); @@ -316,21 +310,18 @@ URLMatcher matcher; std::string error; - std::unique_ptr<WebRequestCondition> result; // Test error on incompatible application stages for involved attributes. - error.clear(); - result = WebRequestCondition::Create( - NULL, matcher.condition_factory(), - *base::test::ParseJsonDeprecated( - "{ \n" - " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n" - // Pass a JS array with one empty object to each of the header - // filters. - " \"requestHeaders\": [{}], \n" - " \"responseHeaders\": [{}], \n" - "}"), - &error); + constexpr const char kCondition[] = R"({ + "instanceType": "declarativeWebRequest.RequestMatcher", + // Pass a JS array with one empty object to each of the header + // filters. + "requestHeaders": [{}], + "responseHeaders": [{}], + })"; + std::unique_ptr<WebRequestCondition> result = + WebRequestCondition::Create(nullptr, matcher.condition_factory(), + base::test::ParseJson(kCondition), &error); EXPECT_FALSE(error.empty()); EXPECT_FALSE(result.get()); }
diff --git a/extensions/browser/api/messaging/extension_message_port.cc b/extensions/browser/api/messaging/extension_message_port.cc index 006887d..ae8ec66 100644 --- a/extensions/browser/api/messaging/extension_message_port.cc +++ b/extensions/browser/api/messaging/extension_message_port.cc
@@ -96,6 +96,10 @@ port_->UnregisterFrame(render_frame_host); } + void OnServiceWorkerUnregistered(const WorkerId& worker_id) override { + port_->UnregisterWorker(worker_id); + } + ScopedObserver<ProcessManager, ProcessManagerObserver> pm_observer_; ExtensionMessagePort* port_; // Owns this FrameTracker.
diff --git a/extensions/browser/disable_reason.h b/extensions/browser/disable_reason.h index 2e26ac0..80d3a94d 100644 --- a/extensions/browser/disable_reason.h +++ b/extensions/browser/disable_reason.h
@@ -44,8 +44,7 @@ DISABLE_CUSTODIAN_APPROVAL_REQUIRED = 1 << 15, // Blocked due to management policy. DISABLE_BLOCKED_BY_POLICY = 1 << 16, - // Blocked due to mature content. - DISABLE_BLOCKED_MATURE = 1 << 17, + // DISABLE_BLOCKED_MATURE = 1 << 17, // Deprecated. // This should always be the last value. DISABLE_REASON_LAST = 1LL << 18, };
diff --git a/extensions/browser/extension_registrar.cc b/extensions/browser/extension_registrar.cc index 817ccda7..1783452a 100644 --- a/extensions/browser/extension_registrar.cc +++ b/extensions/browser/extension_registrar.cc
@@ -252,8 +252,7 @@ extensions::disable_reason::DISABLE_CORRUPTED | extensions::disable_reason::DISABLE_UPDATE_REQUIRED_BY_POLICY | extensions::disable_reason::DISABLE_BLOCKED_BY_POLICY | - extensions::disable_reason::DISABLE_CUSTODIAN_APPROVAL_REQUIRED | - extensions::disable_reason::DISABLE_BLOCKED_MATURE; + extensions::disable_reason::DISABLE_CUSTODIAN_APPROVAL_REQUIRED; disable_reasons &= internal_disable_reason_mask; if (disable_reasons == disable_reason::DISABLE_NONE)
diff --git a/extensions/browser/process_manager.cc b/extensions/browser/process_manager.cc index 3c02c62..bc06d55 100644 --- a/extensions/browser/process_manager.cc +++ b/extensions/browser/process_manager.cc
@@ -1009,6 +1009,8 @@ void ProcessManager::UnregisterServiceWorker(const WorkerId& worker_id) { // TODO(lazyboy): DCHECK that |worker_id| exists in |all_extension_workers_|. all_extension_workers_.Remove(worker_id); + for (auto& observer : observer_list_) + observer.OnServiceWorkerUnregistered(worker_id); } bool ProcessManager::HasServiceWorker(const WorkerId& worker_id) const {
diff --git a/extensions/browser/process_manager_observer.h b/extensions/browser/process_manager_observer.h index 9a026ea3..a95c55e 100644 --- a/extensions/browser/process_manager_observer.h +++ b/extensions/browser/process_manager_observer.h
@@ -17,6 +17,7 @@ class Extension; class ExtensionHost; class ProcessManager; +struct WorkerId; class ProcessManagerObserver : public base::CheckedObserver { public: @@ -43,6 +44,9 @@ const std::string& extension_id, content::RenderFrameHost* render_frame_host) {} + // Called when a service worker is no longer part of an extension process. + virtual void OnServiceWorkerUnregistered(const WorkerId& worker_id) {} + // Called when the observed ProcessManager is shutting down. virtual void OnProcessManagerShutdown(ProcessManager* manager) {} };
diff --git a/extensions/browser/updater/extension_downloader.cc b/extensions/browser/updater/extension_downloader.cc index 1850b12..f6b5e14 100644 --- a/extensions/browser/updater/extension_downloader.cc +++ b/extensions/browser/updater/extension_downloader.cc
@@ -396,9 +396,6 @@ if (extra.is_corrupt_reinstall) install_source = kReinstallInstallSource; - const std::string install_location = - ManifestFetchData::GetSimpleLocationString(extension_location); - ManifestFetchData::PingData ping_data; ManifestFetchData::PingData* optional_ping_data = NULL; if (delegate_->GetPingDataForExtension(id, &ping_data)) @@ -414,7 +411,7 @@ ManifestFetchData* existing_fetch = existing_iter->second.back().get(); if (existing_fetch->AddExtension( id, version.GetString(), optional_ping_data, extra.update_url_data, - install_source, install_location, fetch_priority)) { + install_source, extension_location, fetch_priority)) { added = true; } } @@ -428,7 +425,7 @@ std::move(fetch)); added = fetch_ptr->AddExtension(id, version.GetString(), optional_ping_data, extra.update_url_data, install_source, - install_location, fetch_priority); + extension_location, fetch_priority); DCHECK(added); }
diff --git a/extensions/browser/updater/extension_downloader_unittest.cc b/extensions/browser/updater/extension_downloader_unittest.cc index 6f93ab57..4a970082 100644 --- a/extensions/browser/updater/extension_downloader_unittest.cc +++ b/extensions/browser/updater/extension_downloader_unittest.cc
@@ -45,7 +45,8 @@ std::unique_ptr<ManifestFetchData> fetch( CreateManifestFetchData(kUpdateUrl)); ManifestFetchData::PingData zero_days(0, 0, true, 0); - fetch->AddExtension(kTestExtensionId, "1.0", &zero_days, "", "", "", + fetch->AddExtension(kTestExtensionId, "1.0", &zero_days, "", "", + Manifest::Location::INTERNAL, ManifestFetchData::FetchPriority::BACKGROUND); return fetch; }
diff --git a/extensions/browser/updater/manifest_fetch_data.cc b/extensions/browser/updater/manifest_fetch_data.cc index ad35411e..d11f1d83 100644 --- a/extensions/browser/updater/manifest_fetch_data.cc +++ b/extensions/browser/updater/manifest_fetch_data.cc
@@ -126,7 +126,7 @@ const PingData* ping_data, const std::string& update_url_data, const std::string& install_source, - const std::string& install_location, + Manifest::Location extension_location, FetchPriority fetch_priority) { if (extension_ids_.find(id) != extension_ids_.end()) { NOTREACHED() << "Duplicate extension id " << id; @@ -137,6 +137,9 @@ fetch_priority_ = fetch_priority; } + const std::string install_location = + GetSimpleLocationString(extension_location); + // Compute the string we'd append onto the full_url_, and see if it fits. std::vector<std::string> parts; parts.push_back("id=" + id);
diff --git a/extensions/browser/updater/manifest_fetch_data.h b/extensions/browser/updater/manifest_fetch_data.h index 731dd263..b183e2e 100644 --- a/extensions/browser/updater/manifest_fetch_data.h +++ b/extensions/browser/updater/manifest_fetch_data.h
@@ -103,7 +103,7 @@ const PingData* ping_data, const std::string& update_url_data, const std::string& install_source, - const std::string& install_location, + Manifest::Location install_location, FetchPriority fetch_priority); const GURL& base_url() const { return base_url_; }
diff --git a/extensions/common/api/bluetooth/bluetooth_manifest_permission.cc b/extensions/common/api/bluetooth/bluetooth_manifest_permission.cc index f148396..59836aa6 100644 --- a/extensions/common/api/bluetooth/bluetooth_manifest_permission.cc +++ b/extensions/common/api/bluetooth/bluetooth_manifest_permission.cc
@@ -195,4 +195,9 @@ return false; } +bool BluetoothManifestPermission::RequiresManagedSessionFullLoginWarning() + const { + return false; +} + } // namespace extensions
diff --git a/extensions/common/api/bluetooth/bluetooth_manifest_permission.h b/extensions/common/api/bluetooth/bluetooth_manifest_permission.h index 48583706..6b5df07 100644 --- a/extensions/common/api/bluetooth/bluetooth_manifest_permission.h +++ b/extensions/common/api/bluetooth/bluetooth_manifest_permission.h
@@ -54,6 +54,7 @@ std::unique_ptr<ManifestPermission> Intersect( const ManifestPermission* rhs) const override; bool RequiresManagementUIWarning() const override; + bool RequiresManagedSessionFullLoginWarning() const override; const BluetoothUuidSet& uuids() const { return uuids_;
diff --git a/extensions/common/api/declarative/declarative_manifest_unittest.cc b/extensions/common/api/declarative/declarative_manifest_unittest.cc index 56c00c1..fcc7763 100644 --- a/extensions/common/api/declarative/declarative_manifest_unittest.cc +++ b/extensions/common/api/declarative/declarative_manifest_unittest.cc
@@ -4,6 +4,7 @@ #include <utility> +#include "base/test/values_test_util.h" #include "extensions/browser/api_test_utils.h" #include "extensions/common/api/declarative/declarative_manifest_data.h" #include "extensions/common/manifest_test.h" @@ -35,7 +36,7 @@ TEST_F(DeclarativeManifestTest, ConditionMissingType) { // Create extension - std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary( + base::Value manifest_data = base::test::ParseJson( "{" " \"name\": \"Test\"," " \"version\": \"1\"," @@ -58,7 +59,7 @@ TEST_F(DeclarativeManifestTest, ConditionNotDictionary) { // Create extension - std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary( + base::Value manifest_data = base::test::ParseJson( "{" " \"name\": \"Test\"," " \"version\": \"1\"," @@ -79,7 +80,7 @@ TEST_F(DeclarativeManifestTest, ActionMissingType) { // Create extension - std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary( + base::Value manifest_data = base::test::ParseJson( "{" " \"name\": \"Test\"," " \"version\": \"1\"," @@ -101,7 +102,7 @@ TEST_F(DeclarativeManifestTest, ActionNotDictionary) { // Create extension - std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary( + base::Value manifest_data = base::test::ParseJson( "{" " \"name\": \"Test\"," " \"version\": \"1\"," @@ -123,7 +124,7 @@ TEST_F(DeclarativeManifestTest, EventRulesNotList) { // Create extension - std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary( + base::Value manifest_data = base::test::ParseJson( "{" " \"name\": \"Test\"," " \"version\": \"1\"," @@ -136,7 +137,7 @@ TEST_F(DeclarativeManifestTest, EventRuleNotDictionary) { // Create extension - std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary( + base::Value manifest_data = base::test::ParseJson( "{" " \"name\": \"Test\"," " \"version\": \"1\"," @@ -149,7 +150,7 @@ TEST_F(DeclarativeManifestTest, EventMissingFromRule) { // Create extension - std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary( + base::Value manifest_data = base::test::ParseJson( "{" " \"name\": \"Test\"," " \"version\": \"1\"," @@ -172,7 +173,7 @@ TEST_F(DeclarativeManifestTest, RuleFailedToPopulate) { // Create extension - std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary( + base::Value manifest_data = base::test::ParseJson( "{" " \"name\": \"Test\"," " \"version\": \"1\","
diff --git a/extensions/common/api/sockets/sockets_manifest_permission.cc b/extensions/common/api/sockets/sockets_manifest_permission.cc index de0c6f68..9542f91 100644 --- a/extensions/common/api/sockets/sockets_manifest_permission.cc +++ b/extensions/common/api/sockets/sockets_manifest_permission.cc
@@ -318,4 +318,8 @@ return false; } +bool SocketsManifestPermission::RequiresManagedSessionFullLoginWarning() const { + return false; +} + } // namespace extensions
diff --git a/extensions/common/api/sockets/sockets_manifest_permission.h b/extensions/common/api/sockets/sockets_manifest_permission.h index 7ab2ac7c..f1e2bed 100644 --- a/extensions/common/api/sockets/sockets_manifest_permission.h +++ b/extensions/common/api/sockets/sockets_manifest_permission.h
@@ -53,6 +53,7 @@ std::unique_ptr<ManifestPermission> Intersect( const ManifestPermission* rhs) const override; bool RequiresManagementUIWarning() const override; + bool RequiresManagedSessionFullLoginWarning() const override; const SocketPermissionEntrySet& entries() const { return permissions_; }
diff --git a/extensions/common/manifest_handlers/action_handlers_handler_unittest.cc b/extensions/common/manifest_handlers/action_handlers_handler_unittest.cc index 2832c7a..3be0d93 100644 --- a/extensions/common/manifest_handlers/action_handlers_handler_unittest.cc +++ b/extensions/common/manifest_handlers/action_handlers_handler_unittest.cc
@@ -33,8 +33,7 @@ "manifest_version": 2, "action_handlers": )json" + action_handlers + "}"); - return ManifestData(base::Value::ToUniquePtrValue(std::move(manifest)), - "test"); + return ManifestData(std::move(manifest), "test"); } // Returns all action handlers associated with |extension|.
diff --git a/extensions/common/manifest_handlers/automation.cc b/extensions/common/manifest_handlers/automation.cc index 68bcdda..256261d 100644 --- a/extensions/common/manifest_handlers/automation.cc +++ b/extensions/common/manifest_handlers/automation.cc
@@ -66,6 +66,8 @@ bool RequiresManagementUIWarning() const override; + bool RequiresManagedSessionFullLoginWarning() const override; + private: std::unique_ptr<const AutomationInfo> automation_info_; }; @@ -164,6 +166,11 @@ return automation_info_->desktop || !automation_info_->matches.is_empty(); } +bool AutomationManifestPermission::RequiresManagedSessionFullLoginWarning() + const { + return automation_info_->desktop || !automation_info_->matches.is_empty(); +} + AutomationHandler::AutomationHandler() = default; AutomationHandler::~AutomationHandler() = default;
diff --git a/extensions/common/manifest_handlers/icons_handler_unittest.cc b/extensions/common/manifest_handlers/icons_handler_unittest.cc index 8ea883a..b6a28b4 100644 --- a/extensions/common/manifest_handlers/icons_handler_unittest.cc +++ b/extensions/common/manifest_handlers/icons_handler_unittest.cc
@@ -2,8 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/test/values_test_util.h" #include "extensions/common/manifest_handlers/icons_handler.h" +#include "base/strings/stringprintf.h" +#include "base/test/values_test_util.h" #include "extensions/common/manifest_test.h" #include "testing/gtest/include/gtest/gtest.h" @@ -11,22 +12,23 @@ class ProductIconManifestTest : public ManifestTest { public: - ProductIconManifestTest() {} + ProductIconManifestTest() = default; protected: - std::unique_ptr<base::Value> CreateManifest(const std::string& extra_icons) { - std::unique_ptr<base::Value> manifest = base::test::ParseJsonDeprecated( - "{ \n" - " \"name\": \"test\", \n" - " \"version\": \"0.1\", \n" - " \"manifest_version\": 2, \n" - " \"icons\": { \n" + - extra_icons + - " \"16\": \"icon1.png\", \n" - " \"32\": \"icon2.png\" \n" - " } \n" - "} \n"); - EXPECT_TRUE(manifest); + base::Value CreateManifest(const std::string& extra_icons) { + constexpr const char kManifest[] = R"({ + "name": "test", + "version": "0.1", + "manifest_version": 2, + "icons": { + %s + "16": "icon1.png", + "32": "icon2.png" + } + })"; + base::Value manifest = base::test::ParseJson( + base::StringPrintf(kManifest, extra_icons.c_str())); + EXPECT_TRUE(manifest.is_dict()); return manifest; } @@ -37,30 +39,22 @@ TEST_F(ProductIconManifestTest, Sizes) { // Too big. { - std::unique_ptr<base::Value> ext_manifest = - CreateManifest("\"100000\": \"icon3.png\", \n"); - ManifestData manifest(std::move(ext_manifest), "test"); + ManifestData manifest(CreateManifest(R"("100000": "icon3.png",)"), "test"); LoadAndExpectError(manifest, "Invalid key in icons: \"100000\"."); } // Too small. { - std::unique_ptr<base::Value> ext_manifest = - CreateManifest("\"0\": \"icon3.png\", \n"); - ManifestData manifest(std::move(ext_manifest), "test"); + ManifestData manifest(CreateManifest(R"("0": "icon3.png",)"), "test"); LoadAndExpectError(manifest, "Invalid key in icons: \"0\"."); } // NaN. { - std::unique_ptr<base::Value> ext_manifest = - CreateManifest("\"sixteen\": \"icon3.png\", \n"); - ManifestData manifest(std::move(ext_manifest), "test"); + ManifestData manifest(CreateManifest(R"("sixteen": "icon3.png",)"), "test"); LoadAndExpectError(manifest, "Invalid key in icons: \"sixteen\"."); } // Just right. { - std::unique_ptr<base::Value> ext_manifest = - CreateManifest("\"512\": \"icon3.png\", \n"); - ManifestData manifest(std::move(ext_manifest), "test"); + ManifestData manifest(CreateManifest(R"("512": "icon3.png",)"), "test"); scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest); }
diff --git a/extensions/common/manifest_handlers/oauth2_manifest_unittest.cc b/extensions/common/manifest_handlers/oauth2_manifest_unittest.cc index b57bf54..4470a9e 100644 --- a/extensions/common/manifest_handlers/oauth2_manifest_unittest.cc +++ b/extensions/common/manifest_handlers/oauth2_manifest_unittest.cc
@@ -46,50 +46,49 @@ CLIENT_ID_EMPTY }; - std::unique_ptr<base::Value> CreateManifest(AutoApproveValue auto_approve, - bool extension_id_whitelisted, - ClientIdValue client_id) { - std::unique_ptr<base::Value> manifest = base::test::ParseJsonDeprecated( - "{ \n" - " \"name\": \"test\", \n" - " \"version\": \"0.1\", \n" - " \"manifest_version\": 2, \n" - " \"oauth2\": { \n" - " \"scopes\": [ \"scope1\" ], \n" - " }, \n" - "} \n"); - EXPECT_TRUE(manifest); - EXPECT_TRUE(manifest->is_dict()); + base::Value CreateManifest(AutoApproveValue auto_approve, + bool extension_id_whitelisted, + ClientIdValue client_id) { + base::Value manifest = base::test::ParseJson(R"({ + "name": "test", + "version": "0.1", + "manifest_version": 2, + "oauth2": { + "scopes": [ "scope1" ], + }, + })"); + EXPECT_TRUE(manifest.is_dict()); switch (auto_approve) { case AUTO_APPROVE_NOT_SET: break; case AUTO_APPROVE_FALSE: - manifest->SetPath(TokenizeDictionaryPath(keys::kOAuth2AutoApprove), - base::Value(false)); + manifest.SetPath(TokenizeDictionaryPath(keys::kOAuth2AutoApprove), + base::Value(false)); break; case AUTO_APPROVE_TRUE: - manifest->SetPath(TokenizeDictionaryPath(keys::kOAuth2AutoApprove), - base::Value(true)); + manifest.SetPath(TokenizeDictionaryPath(keys::kOAuth2AutoApprove), + base::Value(true)); break; case AUTO_APPROVE_INVALID: - manifest->SetPath(TokenizeDictionaryPath(keys::kOAuth2AutoApprove), - base::Value("incorrect value")); + manifest.SetPath(TokenizeDictionaryPath(keys::kOAuth2AutoApprove), + base::Value("incorrect value")); break; } switch (client_id) { case CLIENT_ID_DEFAULT: - manifest->SetPath(TokenizeDictionaryPath(keys::kOAuth2ClientId), - base::Value("client1")); + manifest.SetPath(TokenizeDictionaryPath(keys::kOAuth2ClientId), + base::Value("client1")); break; case CLIENT_ID_NOT_SET: break; case CLIENT_ID_EMPTY: - manifest->SetPath(TokenizeDictionaryPath(keys::kOAuth2ClientId), - base::Value("")); + manifest.SetPath(TokenizeDictionaryPath(keys::kOAuth2ClientId), + base::Value("")); } - if (extension_id_whitelisted) - manifest->SetPath(TokenizeDictionaryPath(keys::kKey), - base::Value(kExtensionKey)); + if (extension_id_whitelisted) { + manifest.SetPath(TokenizeDictionaryPath(keys::kKey), + base::Value(kExtensionKey)); + } return manifest; } }; @@ -122,7 +121,7 @@ ext_manifest.SetPath(TokenizeDictionaryPath(keys::kOAuth2AutoApprove), base::Value(true)); - ManifestData manifest(&ext_manifest, "test"); + ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest); EXPECT_TRUE(extension->install_warnings().empty()); @@ -140,7 +139,7 @@ base::Value("launch.html")); app_manifest.MergeDictionary(&base_manifest); - ManifestData manifest(&app_manifest, "test"); + ManifestData manifest(std::move(app_manifest), "test"); scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest); EXPECT_TRUE(extension->install_warnings().empty()); @@ -158,7 +157,7 @@ base::Value("http://www.google.com")); app_manifest.MergeDictionary(&base_manifest); - ManifestData manifest(&app_manifest, "test"); + ManifestData manifest(std::move(app_manifest), "test"); scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest); EXPECT_EQ(1U, extension->install_warnings().size()); @@ -174,7 +173,7 @@ } TEST_F(OAuth2ManifestTest, AutoApproveNotSetExtensionNotOnWhitelist) { - std::unique_ptr<base::Value> ext_manifest = + base::Value ext_manifest = CreateManifest(AUTO_APPROVE_NOT_SET, false, CLIENT_ID_DEFAULT); ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = @@ -184,7 +183,7 @@ } TEST_F(OAuth2ManifestTest, AutoApproveFalseExtensionNotOnWhitelist) { - std::unique_ptr<base::Value> ext_manifest = + base::Value ext_manifest = CreateManifest(AUTO_APPROVE_FALSE, false, CLIENT_ID_DEFAULT); ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = @@ -197,7 +196,7 @@ } TEST_F(OAuth2ManifestTest, AutoApproveTrueExtensionNotOnWhitelist) { - std::unique_ptr<base::Value> ext_manifest = + base::Value ext_manifest = CreateManifest(AUTO_APPROVE_TRUE, false, CLIENT_ID_DEFAULT); ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = @@ -210,7 +209,7 @@ } TEST_F(OAuth2ManifestTest, AutoApproveInvalidExtensionNotOnWhitelist) { - std::unique_ptr<base::Value> ext_manifest = + base::Value ext_manifest = CreateManifest(AUTO_APPROVE_INVALID, false, CLIENT_ID_DEFAULT); ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = @@ -223,7 +222,7 @@ } TEST_F(OAuth2ManifestTest, AutoApproveNotSetExtensionOnWhitelist) { - std::unique_ptr<base::Value> ext_manifest = + base::Value ext_manifest = CreateManifest(AUTO_APPROVE_NOT_SET, true, CLIENT_ID_DEFAULT); ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = @@ -233,7 +232,7 @@ } TEST_F(OAuth2ManifestTest, AutoApproveFalseExtensionOnWhitelist) { - std::unique_ptr<base::Value> ext_manifest = + base::Value ext_manifest = CreateManifest(AUTO_APPROVE_FALSE, true, CLIENT_ID_DEFAULT); ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = @@ -243,7 +242,7 @@ } TEST_F(OAuth2ManifestTest, AutoApproveTrueExtensionOnWhitelist) { - std::unique_ptr<base::Value> ext_manifest = + base::Value ext_manifest = CreateManifest(AUTO_APPROVE_TRUE, true, CLIENT_ID_DEFAULT); ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = @@ -253,7 +252,7 @@ } TEST_F(OAuth2ManifestTest, AutoApproveInvalidExtensionOnWhitelist) { - std::unique_ptr<base::Value> ext_manifest = + base::Value ext_manifest = CreateManifest(AUTO_APPROVE_INVALID, true, CLIENT_ID_DEFAULT); ManifestData manifest(std::move(ext_manifest), "test"); std::string error; @@ -266,7 +265,7 @@ TEST_F(OAuth2ManifestTest, InvalidClientId) { { - std::unique_ptr<base::Value> ext_manifest = + base::Value ext_manifest = CreateManifest(AUTO_APPROVE_NOT_SET, false, CLIENT_ID_NOT_SET); ManifestData manifest(std::move(ext_manifest), "test"); std::string error; @@ -274,7 +273,7 @@ } { - std::unique_ptr<base::Value> ext_manifest = + base::Value ext_manifest = CreateManifest(AUTO_APPROVE_NOT_SET, false, CLIENT_ID_EMPTY); ManifestData manifest(std::move(ext_manifest), "test"); std::string error; @@ -285,7 +284,7 @@ TEST_F(OAuth2ManifestTest, ComponentInvalidClientId) { // Component Apps without auto_approve must include a client ID. { - std::unique_ptr<base::Value> ext_manifest = + base::Value ext_manifest = CreateManifest(AUTO_APPROVE_NOT_SET, false, CLIENT_ID_NOT_SET); ManifestData manifest(std::move(ext_manifest), "test"); std::string error; @@ -295,7 +294,7 @@ } { - std::unique_ptr<base::Value> ext_manifest = + base::Value ext_manifest = CreateManifest(AUTO_APPROVE_NOT_SET, false, CLIENT_ID_EMPTY); ManifestData manifest(std::move(ext_manifest), "test"); std::string error; @@ -307,7 +306,7 @@ TEST_F(OAuth2ManifestTest, ComponentWithChromeClientId) { { - std::unique_ptr<base::Value> ext_manifest = + base::Value ext_manifest = CreateManifest(AUTO_APPROVE_TRUE, true, CLIENT_ID_NOT_SET); ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = @@ -316,7 +315,7 @@ } { - std::unique_ptr<base::Value> ext_manifest = + base::Value ext_manifest = CreateManifest(AUTO_APPROVE_TRUE, true, CLIENT_ID_EMPTY); ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = @@ -326,7 +325,7 @@ } TEST_F(OAuth2ManifestTest, ComponentWithStandardClientId) { - std::unique_ptr<base::Value> ext_manifest = + base::Value ext_manifest = CreateManifest(AUTO_APPROVE_TRUE, true, CLIENT_ID_DEFAULT); ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension =
diff --git a/extensions/common/manifest_handlers/replacement_apps_unittest.cc b/extensions/common/manifest_handlers/replacement_apps_unittest.cc index 50cf954..35060be 100644 --- a/extensions/common/manifest_handlers/replacement_apps_unittest.cc +++ b/extensions/common/manifest_handlers/replacement_apps_unittest.cc
@@ -42,8 +42,7 @@ })"; base::Value manifest = base::test::ParseJson(base::StringPrintf( kManifest, replacement_web_app, replacement_android_app)); - return ManifestData(base::Value::ToUniquePtrValue(std::move(manifest)), - "test"); + return ManifestData(std::move(manifest), "test"); } else if (replacement_web_app != nullptr) { // only web replacement app specified constexpr char kManifest[] = @@ -55,8 +54,7 @@ })"; base::Value manifest = base::test::ParseJson( base::StringPrintf(kManifest, replacement_web_app)); - return ManifestData(base::Value::ToUniquePtrValue(std::move(manifest)), - "test"); + return ManifestData(std::move(manifest), "test"); } else if (replacement_android_app != nullptr) { // only Android replacement app specified constexpr char kManifest[] = @@ -73,8 +71,7 @@ })"; base::Value manifest = base::test::ParseJson( base::StringPrintf(kManifest, replacement_android_app)); - return ManifestData(base::Value::ToUniquePtrValue(std::move(manifest)), - "test"); + return ManifestData(std::move(manifest), "test"); } base::Value manifest = base::test::ParseJson( @@ -83,8 +80,7 @@ "version": "1", "manifest_version": 2 })"); - return ManifestData(base::Value::ToUniquePtrValue(std::move(manifest)), - "test"); + return ManifestData(std::move(manifest), "test"); } private:
diff --git a/extensions/common/manifest_test.cc b/extensions/common/manifest_test.cc index f9a8c72..1ad01bc 100644 --- a/extensions/common/manifest_test.cc +++ b/extensions/common/manifest_test.cc
@@ -75,14 +75,6 @@ ManifestTest::ManifestData::ManifestData(ManifestData&& other) = default; -ManifestTest::ManifestData::ManifestData(base::Value* manifest, - const char* name) - : ManifestData(manifest->Clone(), name) {} - -ManifestTest::ManifestData::ManifestData(std::unique_ptr<base::Value> manifest, - const char* name) - : ManifestData(base::Value(std::move(*manifest)), name) {} - ManifestTest::ManifestData::~ManifestData() { }
diff --git a/extensions/common/manifest_test.h b/extensions/common/manifest_test.h index c6e35606..95a337a 100644 --- a/extensions/common/manifest_test.h +++ b/extensions/common/manifest_test.h
@@ -39,11 +39,6 @@ ManifestData(ManifestData&& other); - // DEPRECATED. Use one of the above constructors. - ManifestData(base::Value* manifest, const char* name); - explicit ManifestData(std::unique_ptr<base::Value> manifest, - const char* name); - ~ManifestData(); const std::string& name() const { return name_; }
diff --git a/extensions/common/permissions/api_permission_unittest.cc b/extensions/common/permissions/api_permission_unittest.cc index 89e3ccb..1526eee 100644 --- a/extensions/common/permissions/api_permission_unittest.cc +++ b/extensions/common/permissions/api_permission_unittest.cc
@@ -66,8 +66,6 @@ info->RegisterPermissions(base::make_span(init_info), base::span<const extensions::Alias>()); - EXPECT_TRUE(info->GetByID(APIPermission::kAlwaysOnTopWindows) - ->requires_managed_session_full_login_warning()); EXPECT_FALSE(info->GetByID(APIPermission::kUnknown) ->requires_managed_session_full_login_warning()); }
diff --git a/extensions/common/permissions/extensions_api_permissions.cc b/extensions/common/permissions/extensions_api_permissions.cc index a98e1c5..0cfff01 100644 --- a/extensions/common/permissions/extensions_api_permissions.cc +++ b/extensions/common/permissions/extensions_api_permissions.cc
@@ -28,97 +28,154 @@ // add the corresponding permission message rule to // ChromePermissionMessageRule::GetAllRules as well. constexpr APIPermissionInfo::InitInfo permissions_to_register[] = { - {APIPermission::kAlarms, "alarms"}, - {APIPermission::kAlphaEnabled, "app.window.alpha"}, - {APIPermission::kAlwaysOnTopWindows, "app.window.alwaysOnTop"}, + {APIPermission::kAlarms, "alarms", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kAlphaEnabled, "app.window.alpha", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kAlwaysOnTopWindows, "app.window.alwaysOnTop", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kAppView, "appview", - APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kAudio, "audio"}, - {APIPermission::kAudioCapture, "audioCapture"}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kAudio, "audio", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kAudioCapture, "audioCapture", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kBluetoothPrivate, "bluetoothPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kCecPrivate, "cecPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kClipboard, "clipboard"}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kClipboard, "clipboard", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kClipboardRead, "clipboardRead", APIPermissionInfo::kFlagSupportsContentCapabilities}, {APIPermission::kClipboardWrite, "clipboardWrite", - APIPermissionInfo::kFlagSupportsContentCapabilities}, - {APIPermission::kCrashReportPrivate, "crashReportPrivate"}, + APIPermissionInfo::kFlagSupportsContentCapabilities | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kCrashReportPrivate, "crashReportPrivate", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kDeclarativeWebRequest, "declarativeWebRequest"}, {APIPermission::kDiagnostics, "diagnostics", APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kDisplaySource, "displaySource"}, - {APIPermission::kDns, "dns"}, + {APIPermission::kDisplaySource, "displaySource", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kDns, "dns", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kDocumentScan, "documentScan"}, {APIPermission::kExternallyConnectableAllUrls, - "externally_connectable.all_urls"}, + "externally_connectable.all_urls", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kFeedbackPrivate, "feedbackPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kFullscreen, "app.window.fullscreen"}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kFullscreen, "app.window.fullscreen", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, // The permission string for "fileSystem" is only shown when // "write" or "directory" is present. Read-only access is only // granted after the user has been shown a file or directory // chooser dialog and selected a file or directory. Selecting // the file or directory is considered consent to read it. - {APIPermission::kFileSystem, "fileSystem"}, - {APIPermission::kFileSystemDirectory, "fileSystem.directory"}, + {APIPermission::kFileSystem, "fileSystem", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kFileSystemDirectory, "fileSystem.directory", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kFileSystemRequestFileSystem, - "fileSystem.requestFileSystem"}, - {APIPermission::kFileSystemRetainEntries, "fileSystem.retainEntries"}, - {APIPermission::kFileSystemWrite, "fileSystem.write"}, + "fileSystem.requestFileSystem", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kFileSystemRetainEntries, "fileSystem.retainEntries", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kFileSystemWrite, "fileSystem.write", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, - {APIPermission::kHid, "hid"}, - {APIPermission::kImeWindowEnabled, "app.window.ime"}, - {APIPermission::kOverrideEscFullscreen, - "app.window.fullscreen.overrideEsc"}, - {APIPermission::kIdle, "idle"}, - {APIPermission::kLockScreen, "lockScreen"}, + {APIPermission::kHid, "hid", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kImeWindowEnabled, "app.window.ime", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kOverrideEscFullscreen, "app.window.fullscreen.overrideEsc", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kIdle, "idle", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kLockScreen, "lockScreen", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kLockWindowFullscreenPrivate, "lockWindowFullscreenPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kLogin, "login"}, - {APIPermission::kLoginScreenStorage, "loginScreenStorage"}, - {APIPermission::kLoginScreenUi, "loginScreenUi"}, - {APIPermission::kLoginState, "loginState"}, - {APIPermission::kMediaPerceptionPrivate, "mediaPerceptionPrivate"}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kLogin, "login", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kLoginScreenStorage, "loginScreenStorage", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kLoginScreenUi, "loginScreenUi", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kLoginState, "loginState", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kMediaPerceptionPrivate, "mediaPerceptionPrivate", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kMetricsPrivate, "metricsPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kNativeMessaging, "nativeMessaging"}, - {APIPermission::kNetworkingConfig, "networking.config"}, - {APIPermission::kNetworkingOnc, "networking.onc"}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kNativeMessaging, "nativeMessaging", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kNetworkingConfig, "networking.config", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kNetworkingOnc, "networking.onc", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kNetworkingPrivate, "networkingPrivate", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kNewTabPageOverride, "newTabPageOverride", APIPermissionInfo::kFlagCannotBeOptional | - APIPermissionInfo::kFlagRequiresManagementUIWarning}, - {APIPermission::kPower, "power"}, - {APIPermission::kPrinterProvider, "printerProvider"}, + APIPermissionInfo::kFlagRequiresManagementUIWarning | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kPower, "power", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kPrinterProvider, "printerProvider", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kPrinting, "printing", - APIPermissionInfo::kFlagRequiresManagementUIWarning}, + APIPermissionInfo::kFlagRequiresManagementUIWarning | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kPrintingMetrics, "printingMetrics", - APIPermissionInfo::kFlagRequiresManagementUIWarning}, - {APIPermission::kSerial, "serial"}, - {APIPermission::kSocket, "socket", APIPermissionInfo::kFlagCannotBeOptional, + APIPermissionInfo::kFlagRequiresManagementUIWarning | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kSerial, "serial", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kSocket, "socket", + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning, &CreateAPIPermission<SocketPermission>}, - {APIPermission::kStorage, "storage"}, - {APIPermission::kSystemCpu, "system.cpu"}, - {APIPermission::kSystemMemory, "system.memory"}, - {APIPermission::kSystemNetwork, "system.network"}, - {APIPermission::kSystemDisplay, "system.display"}, - {APIPermission::kSystemPowerSource, "system.powerSource"}, - {APIPermission::kSystemStorage, "system.storage"}, - {APIPermission::kU2fDevices, "u2fDevices"}, + {APIPermission::kStorage, "storage", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kSystemCpu, "system.cpu", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kSystemMemory, "system.memory", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kSystemNetwork, "system.network", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kSystemDisplay, "system.display", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kSystemPowerSource, "system.powerSource", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kSystemStorage, "system.storage", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kU2fDevices, "u2fDevices", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kUnlimitedStorage, "unlimitedStorage", APIPermissionInfo::kFlagCannotBeOptional | - APIPermissionInfo::kFlagSupportsContentCapabilities}, + APIPermissionInfo::kFlagSupportsContentCapabilities | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kUsb, "usb", APIPermissionInfo::kFlagNone}, - {APIPermission::kUsbDevice, "usbDevices", APIPermissionInfo::kFlagNone, + {APIPermission::kUsbDevice, "usbDevices", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning, &CreateAPIPermission<UsbDevicePermission>}, - {APIPermission::kVideoCapture, "videoCapture"}, - {APIPermission::kVirtualKeyboard, "virtualKeyboard"}, + {APIPermission::kVideoCapture, "videoCapture", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kVirtualKeyboard, "virtualKeyboard", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kVpnProvider, "vpnProvider", - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, // NOTE(kalman): This is provided by a manifest property but needs to // appear in the install permission dialogue, so we need a fake // permission for it. See http://crbug.com/247857. @@ -126,14 +183,19 @@ APIPermissionInfo::kFlagCannotBeOptional | APIPermissionInfo::kFlagInternal}, {APIPermission::kWebRequest, "webRequest"}, - {APIPermission::kWebRequestBlocking, "webRequestBlocking"}, + {APIPermission::kWebRequestBlocking, "webRequestBlocking", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kDeclarativeNetRequest, declarative_net_request::kAPIPermission, - APIPermissionInfo::kFlagCannotBeOptional}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kWebView, "webview", - APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kWindowShape, "app.window.shape"}, - {APIPermission::kFileSystemRequestDownloads, "fileSystem.requestDownloads"}, + APIPermissionInfo::kFlagCannotBeOptional | + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kWindowShape, "app.window.shape", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, + {APIPermission::kFileSystemRequestDownloads, "fileSystem.requestDownloads", + APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, {APIPermission::kDeclarativeNetRequestFeedback, declarative_net_request::kFeedbackAPIPermission, APIPermissionInfo::kFlagRequiresManagementUIWarning},
diff --git a/fuchsia/base/BUILD.gn b/fuchsia/base/BUILD.gn index 4968220..2191bdde 100644 --- a/fuchsia/base/BUILD.gn +++ b/fuchsia/base/BUILD.gn
@@ -13,6 +13,7 @@ source_set("base") { sources = [ "config_reader.cc", + "fuchsia_dir_scheme.cc", "init_logging.cc", "mem_buffer_util.cc", "scoped_pseudo_file_publisher.cc", @@ -20,6 +21,7 @@ ] public = [ "config_reader.h", + "fuchsia_dir_scheme.h", "init_logging.h", "mem_buffer_util.h", "scoped_pseudo_file_publisher.h", @@ -28,6 +30,7 @@ deps = [ "//base", "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.mem", + "//url", ] } @@ -62,6 +65,17 @@ ] } +source_set("legacymetrics") { + sources = [ + "legacymetrics_histogram_flattener.cc", + "legacymetrics_histogram_flattener.h", + "legacymetrics_user_event_recorder.cc", + "legacymetrics_user_event_recorder.h", + ] + deps = [ "//base" ] + public_deps = [ "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.legacymetrics" ] +} + # Used to propagate release-qualified package names to integration test code. buildflag_header("release_channel_buildflags") { header = "release_channel.h" @@ -102,8 +116,13 @@ # Unit-tests for all //fuchsia/base utilities. test("cr_fuchsia_base_unittests") { - sources = [ "agent_impl_unittests.cc" ] + sources = [ + "agent_impl_unittests.cc", + "legacymetrics_histogram_flattener_unittest.cc", + "legacymetrics_user_event_recorder_unittest.cc", + ] deps = [ + ":legacymetrics", ":modular", ":test_support", "//base",
diff --git a/fuchsia/base/fuchsia_dir_scheme.cc b/fuchsia/base/fuchsia_dir_scheme.cc new file mode 100644 index 0000000..00c1e0b --- /dev/null +++ b/fuchsia/base/fuchsia_dir_scheme.cc
@@ -0,0 +1,18 @@ +// Copyright 2020 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 "fuchsia/base/fuchsia_dir_scheme.h" + +#include "url/url_util.h" + +namespace cr_fuchsia { + +const char kFuchsiaDirScheme[] = "fuchsia-dir"; + +void RegisterFuchsiaDirScheme() { + url::AddStandardScheme(kFuchsiaDirScheme, url::SCHEME_WITH_HOST); + url::AddLocalScheme(kFuchsiaDirScheme); +} + +} // namespace cr_fuchsia
diff --git a/fuchsia/base/fuchsia_dir_scheme.h b/fuchsia/base/fuchsia_dir_scheme.h new file mode 100644 index 0000000..b9fd9a8 --- /dev/null +++ b/fuchsia/base/fuchsia_dir_scheme.h
@@ -0,0 +1,18 @@ +// Copyright 2020 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. + +#ifndef FUCHSIA_BASE_FUCHSIA_DIR_SCHEME_H_ +#define FUCHSIA_BASE_FUCHSIA_DIR_SCHEME_H_ + +namespace cr_fuchsia { + +// URL scheme used to access content directories. +extern const char kFuchsiaDirScheme[]; + +// Registers kFuchsiaDirScheme as a standard URL scheme. +void RegisterFuchsiaDirScheme(); + +} // namespace cr_fuchsia + +#endif // FUCHSIA_BASE_FUCHSIA_DIR_SCHEME_H_
diff --git a/fuchsia/base/legacymetrics_histogram_flattener.cc b/fuchsia/base/legacymetrics_histogram_flattener.cc new file mode 100644 index 0000000..e05d87c --- /dev/null +++ b/fuchsia/base/legacymetrics_histogram_flattener.cc
@@ -0,0 +1,91 @@ +// Copyright 2020 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 "fuchsia/base/legacymetrics_histogram_flattener.h" + +#include <memory> +#include <utility> +#include <vector> + +#include "base/metrics/statistics_recorder.h" + +namespace cr_fuchsia { +namespace { + +// Serializes changes to histogram metrics as FIDL structs. +// Cannot be used in conjunction with other metrics collection systems (e.g. +// UMA). +class LegacyMetricsHistogramFlattener : public base::HistogramFlattener { + public: + LegacyMetricsHistogramFlattener() : histogram_snapshot_manager_(this) {} + ~LegacyMetricsHistogramFlattener() override = default; + + LegacyMetricsHistogramFlattener(const LegacyMetricsHistogramFlattener&) = + delete; + LegacyMetricsHistogramFlattener& operator=( + const LegacyMetricsHistogramFlattener&) = delete; + + // Returns a vector of changes to histogram data made since the last call to + // this method. Returns all histogram data when invoked for the first time. + std::vector<fuchsia::legacymetrics::Histogram> GetDeltas() { + DCHECK(histogram_deltas_.empty()); + + // Gather all histogram deltas, which will be sent to RecordDelta() and + // buffered in |histogram_deltas_|. + base::StatisticsRecorder::PrepareDeltas( + // Only return in-memory/non-persisted histograms. + false, + // Do not set flags on histograms. + base::Histogram::kNoFlags, + // Only upload metrics marked for UMA upload. + base::Histogram::kUmaTargetedHistogramFlag, + &histogram_snapshot_manager_); + + return std::move(histogram_deltas_); + } + + private: + // base::HistogramFlattener implementation. + // Appends the contents of |snapshot| for the specified |histogram| within + // |histogram_deltas_|. + void RecordDelta(const base::HistogramBase& histogram, + const base::HistogramSamples& snapshot) override { + DCHECK_NE(0, snapshot.TotalCount()); + + DVLOG(3) << "RecordDelta " << histogram.histogram_name(); + + fuchsia::legacymetrics::Histogram converted; + converted.set_name(histogram.histogram_name()); + converted.set_sum(snapshot.sum()); + + for (std::unique_ptr<base::SampleCountIterator> it = snapshot.Iterator(); + !it->Done(); it->Next()) { + base::Histogram::Sample min; + int64_t max = 0; + base::Histogram::Count count; + it->Get(&min, &max, &count); + + fuchsia::legacymetrics::HistogramBucket bucket; + bucket.min = min; + bucket.max = max; + bucket.count = count; + + DVLOG(4) << " Bucket: [" << min << "," << max << ") = " << count; + converted.mutable_buckets()->emplace_back(std::move(bucket)); + } + + histogram_deltas_.emplace_back(std::move(converted)); + } + + base::HistogramSnapshotManager histogram_snapshot_manager_; + std::vector<fuchsia::legacymetrics::Histogram> histogram_deltas_; +}; + +} // namespace + +std::vector<fuchsia::legacymetrics::Histogram> GetLegacyMetricsDeltas() { + return LegacyMetricsHistogramFlattener().GetDeltas(); +} + +} // namespace cr_fuchsia
diff --git a/fuchsia/base/legacymetrics_histogram_flattener.h b/fuchsia/base/legacymetrics_histogram_flattener.h new file mode 100644 index 0000000..d4b147a --- /dev/null +++ b/fuchsia/base/legacymetrics_histogram_flattener.h
@@ -0,0 +1,20 @@ +// Copyright 2020 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. + +#ifndef FUCHSIA_BASE_LEGACYMETRICS_HISTOGRAM_FLATTENER_H_ +#define FUCHSIA_BASE_LEGACYMETRICS_HISTOGRAM_FLATTENER_H_ + +#include <fuchsia/legacymetrics/cpp/fidl.h> +#include <vector> + +#include "base/metrics/histogram_flattener.h" +#include "base/metrics/histogram_snapshot_manager.h" + +namespace cr_fuchsia { + +std::vector<fuchsia::legacymetrics::Histogram> GetLegacyMetricsDeltas(); + +} // namespace cr_fuchsia + +#endif // FUCHSIA_BASE_LEGACYMETRICS_HISTOGRAM_FLATTENER_H_
diff --git a/fuchsia/base/legacymetrics_histogram_flattener_unittest.cc b/fuchsia/base/legacymetrics_histogram_flattener_unittest.cc new file mode 100644 index 0000000..d034712 --- /dev/null +++ b/fuchsia/base/legacymetrics_histogram_flattener_unittest.cc
@@ -0,0 +1,162 @@ +// Copyright 2020 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 "fuchsia/base/legacymetrics_histogram_flattener.h" + +#include "base/metrics/histogram_macros.h" +#include "testing/gtest/include/gtest/gtest.h" + +using fuchsia::legacymetrics::Histogram; +using fuchsia::legacymetrics::HistogramBucket; + +namespace cr_fuchsia { +namespace { + +constexpr char kHistogramCount1M[] = "Foo.Bar"; + +int64_t GetCount(int64_t value, const std::vector<HistogramBucket>& buckets) { + for (const HistogramBucket& bucket : buckets) { + if (value >= bucket.min && value < bucket.max) + return bucket.count; + } + + return 0; +} + +const fuchsia::legacymetrics::Histogram* LookupHistogram( + base::StringPiece name, + const std::vector<Histogram>& histograms) { + for (const auto& histogram : histograms) { + if (histogram.name() == name) + return &histogram; + } + return nullptr; +} + +class LegacyMetricsHistogramFlattenerTest : public testing::Test { + public: + LegacyMetricsHistogramFlattenerTest() = default; + ~LegacyMetricsHistogramFlattenerTest() override = default; +}; + +TEST_F(LegacyMetricsHistogramFlattenerTest, NoHistogramData) { + EXPECT_TRUE(GetLegacyMetricsDeltas().empty()); +} + +TEST_F(LegacyMetricsHistogramFlattenerTest, Boolean) { + constexpr char kBooleanHistogram[] = "Foo.Bar.Boolean"; + UMA_HISTOGRAM_BOOLEAN(kBooleanHistogram, true); + UMA_HISTOGRAM_BOOLEAN(kBooleanHistogram, true); + UMA_HISTOGRAM_BOOLEAN(kBooleanHistogram, false); + + auto deltas = GetLegacyMetricsDeltas(); + EXPECT_EQ(1, + GetCount(0, LookupHistogram(kBooleanHistogram, deltas)->buckets())); + EXPECT_EQ(2, + GetCount(1, LookupHistogram(kBooleanHistogram, deltas)->buckets())); +} + +TEST_F(LegacyMetricsHistogramFlattenerTest, Linear) { + constexpr char kLinearHistogram[] = "Foo.Bar.Linear"; + + for (int i = 0; i < 200; ++i) { + UMA_HISTOGRAM_EXACT_LINEAR(kLinearHistogram, i, 200); + } + + auto deltas = GetLegacyMetricsDeltas(); + + for (int i = 0; i < 200; ++i) { + EXPECT_EQ( + 1, GetCount(i, LookupHistogram(kLinearHistogram, deltas)->buckets())); + } +} + +TEST_F(LegacyMetricsHistogramFlattenerTest, Percentage) { + constexpr char kPercentageHistogram[] = "Foo.Bar.Percentage"; + + for (int i = 0; i <= 100; ++i) { + for (int j = 0; j < i; ++j) + UMA_HISTOGRAM_PERCENTAGE(kPercentageHistogram, i); + } + + auto deltas = GetLegacyMetricsDeltas(); + + for (int i = 0; i <= 100; ++i) { + EXPECT_EQ( + i, + GetCount(i, LookupHistogram(kPercentageHistogram, deltas)->buckets())); + } +} + +enum Fruit { + APPLE, + BANANA, + PEAR, + FRUIT_MAX = PEAR, +}; + +TEST_F(LegacyMetricsHistogramFlattenerTest, Enumeration) { + constexpr char kEnumHistogram[] = "Foo.Bar.Enumeration"; + + UMA_HISTOGRAM_ENUMERATION(kEnumHistogram, APPLE, FRUIT_MAX); + UMA_HISTOGRAM_ENUMERATION(kEnumHistogram, BANANA, FRUIT_MAX); + UMA_HISTOGRAM_ENUMERATION(kEnumHistogram, BANANA, FRUIT_MAX); + UMA_HISTOGRAM_ENUMERATION(kEnumHistogram, BANANA, FRUIT_MAX); + UMA_HISTOGRAM_ENUMERATION(kEnumHistogram, PEAR, FRUIT_MAX); + + auto deltas = GetLegacyMetricsDeltas(); + + EXPECT_EQ( + 1, GetCount(APPLE, LookupHistogram(kEnumHistogram, deltas)->buckets())); + EXPECT_EQ( + 3, GetCount(BANANA, LookupHistogram(kEnumHistogram, deltas)->buckets())); + EXPECT_EQ(1, + GetCount(PEAR, LookupHistogram(kEnumHistogram, deltas)->buckets())); +} + +TEST_F(LegacyMetricsHistogramFlattenerTest, NoNewData) { + UMA_HISTOGRAM_COUNTS_1M(kHistogramCount1M, 20); + + auto deltas = GetLegacyMetricsDeltas(); + EXPECT_EQ( + 1, GetCount(20, LookupHistogram(kHistogramCount1M, deltas)->buckets())); + + // No changes to a histogram means we should not be seeing it in the deltas. + deltas = GetLegacyMetricsDeltas(); + EXPECT_TRUE(deltas.empty()); +} + +TEST_F(LegacyMetricsHistogramFlattenerTest, MultipleHistograms) { + constexpr char kAnotherHistogram[] = "Foo.Bar2"; + + UMA_HISTOGRAM_COUNTS_1M(kHistogramCount1M, 20); + UMA_HISTOGRAM_COUNTS_1M(kAnotherHistogram, 1000); + UMA_HISTOGRAM_COUNTS_1M(kAnotherHistogram, 1000); + + auto deltas = GetLegacyMetricsDeltas(); + EXPECT_EQ( + 1, GetCount(20, LookupHistogram(kHistogramCount1M, deltas)->buckets())); + EXPECT_EQ( + 2, GetCount(1000, LookupHistogram(kAnotherHistogram, deltas)->buckets())); +} + +TEST_F(LegacyMetricsHistogramFlattenerTest, MultipleBuckets) { + UMA_HISTOGRAM_COUNTS_1M(kHistogramCount1M, 20); + UMA_HISTOGRAM_COUNTS_1M(kHistogramCount1M, 1000); + + auto deltas = GetLegacyMetricsDeltas(); + EXPECT_EQ( + 1, GetCount(20, LookupHistogram(kHistogramCount1M, deltas)->buckets())); + EXPECT_EQ( + 1, GetCount(1000, LookupHistogram(kHistogramCount1M, deltas)->buckets())); + + UMA_HISTOGRAM_COUNTS_1M(kHistogramCount1M, 1000); + UMA_HISTOGRAM_COUNTS_1M(kHistogramCount1M, 1000); + deltas = GetLegacyMetricsDeltas(); + EXPECT_EQ( + 2, GetCount(1000, LookupHistogram(kHistogramCount1M, deltas)->buckets())); +} + +} // namespace +} // namespace cr_fuchsia
diff --git a/fuchsia/base/legacymetrics_user_event_recorder.cc b/fuchsia/base/legacymetrics_user_event_recorder.cc new file mode 100644 index 0000000..9f75218 --- /dev/null +++ b/fuchsia/base/legacymetrics_user_event_recorder.cc
@@ -0,0 +1,42 @@ +// Copyright 2019 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 "fuchsia/base/legacymetrics_user_event_recorder.h" + +#include <utility> + +#include "base/callback.h" +#include "base/metrics/user_metrics.h" + +namespace cr_fuchsia { + +LegacyMetricsUserActionRecorder::LegacyMetricsUserActionRecorder() + : on_event_callback_( + base::BindRepeating(&LegacyMetricsUserActionRecorder::OnUserAction, + base::Unretained(this))) { + base::AddActionCallback(on_event_callback_); +} + +LegacyMetricsUserActionRecorder::~LegacyMetricsUserActionRecorder() { + base::RemoveActionCallback(on_event_callback_); +} + +bool LegacyMetricsUserActionRecorder::HasEvents() const { + return !events_.empty(); +} + +std::vector<fuchsia::legacymetrics::UserActionEvent> +LegacyMetricsUserActionRecorder::TakeEvents() { + return std::move(events_); +} + +void LegacyMetricsUserActionRecorder::OnUserAction(const std::string& action, + base::TimeTicks time) { + fuchsia::legacymetrics::UserActionEvent fidl_event; + fidl_event.set_name(action); + fidl_event.set_time(time.ToZxTime()); + events_.push_back(std::move(fidl_event)); +} + +} // namespace cr_fuchsia
diff --git a/fuchsia/base/legacymetrics_user_event_recorder.h b/fuchsia/base/legacymetrics_user_event_recorder.h new file mode 100644 index 0000000..48d9a3e2 --- /dev/null +++ b/fuchsia/base/legacymetrics_user_event_recorder.h
@@ -0,0 +1,41 @@ +// Copyright 2019 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. + +#ifndef FUCHSIA_BASE_LEGACYMETRICS_USER_EVENT_RECORDER_H_ +#define FUCHSIA_BASE_LEGACYMETRICS_USER_EVENT_RECORDER_H_ + +#include <fuchsia/legacymetrics/cpp/fidl.h> +#include <string> +#include <vector> + +#include "base/metrics/user_metrics.h" + +namespace cr_fuchsia { + +// Captures and stores user action events, and converts them to +// fuchsia.legacymetrics equivalent. +class LegacyMetricsUserActionRecorder { + public: + LegacyMetricsUserActionRecorder(); + ~LegacyMetricsUserActionRecorder(); + + LegacyMetricsUserActionRecorder(const LegacyMetricsUserActionRecorder&) = + delete; + LegacyMetricsUserActionRecorder& operator=( + const LegacyMetricsUserActionRecorder&) = delete; + + bool HasEvents() const; + std::vector<fuchsia::legacymetrics::UserActionEvent> TakeEvents(); + + private: + // base::ActionCallback implementation. + void OnUserAction(const std::string& action, base::TimeTicks time); + + std::vector<fuchsia::legacymetrics::UserActionEvent> events_; + const base::ActionCallback on_event_callback_; +}; + +} // namespace cr_fuchsia + +#endif // FUCHSIA_BASE_LEGACYMETRICS_USER_EVENT_RECORDER_H_
diff --git a/fuchsia/base/legacymetrics_user_event_recorder_unittest.cc b/fuchsia/base/legacymetrics_user_event_recorder_unittest.cc new file mode 100644 index 0000000..4a27490 --- /dev/null +++ b/fuchsia/base/legacymetrics_user_event_recorder_unittest.cc
@@ -0,0 +1,76 @@ +// Copyright 2020 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 "fuchsia/base/legacymetrics_user_event_recorder.h" + +#include "base/test/task_environment.h" +#include "base/threading/thread_task_runner_handle.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace cr_fuchsia { +namespace { + +class LegacyMetricsUserActionRecorderTest : public testing::Test { + public: + LegacyMetricsUserActionRecorderTest() = default; + ~LegacyMetricsUserActionRecorderTest() override = default; + + void SetUp() override { + base::SetRecordActionTaskRunner(base::ThreadTaskRunnerHandle::Get()); + } + + private: + base::test::SingleThreadTaskEnvironment task_environment; +}; + +TEST_F(LegacyMetricsUserActionRecorderTest, ProduceAndConsume) { + constexpr char kExpectedUserAction1[] = "Hello"; + constexpr char kExpectedUserAction2[] = "There"; + + zx_time_t time_start = base::TimeTicks::Now().ToZxTime(); + LegacyMetricsUserActionRecorder buffer; + base::RecordComputedAction(kExpectedUserAction1); + EXPECT_TRUE(buffer.HasEvents()); + base::RecordComputedAction(kExpectedUserAction2); + + auto events = buffer.TakeEvents(); + EXPECT_FALSE(buffer.HasEvents()); + EXPECT_EQ(2u, events.size()); + + // Verify the contents of the buffer are as expected. + EXPECT_EQ(kExpectedUserAction1, events[0].name()); + EXPECT_GE(events[0].time(), time_start); + EXPECT_EQ(kExpectedUserAction2, events[1].name()); + EXPECT_GE(events[1].time(), time_start); + EXPECT_GE(events[1].time(), events[0].time()); + + // Verify that the buffer is now empty. + EXPECT_TRUE(buffer.TakeEvents().empty()); + + // Add more data to the buffer, and then verify it, to ensure that recording + // continues to work. + base::RecordComputedAction(kExpectedUserAction2); + EXPECT_TRUE(buffer.HasEvents()); + events = buffer.TakeEvents(); + EXPECT_FALSE(buffer.HasEvents()); + EXPECT_EQ(1u, events.size()); + EXPECT_EQ(kExpectedUserAction2, events[0].name()); +} + +TEST_F(LegacyMetricsUserActionRecorderTest, RecorderDeleted) { + auto buffer = std::make_unique<LegacyMetricsUserActionRecorder>(); + buffer.reset(); + + // |buffer| was destroyed, so check that recording actions doesn't cause a + // use-after-free error. + base::RecordComputedAction("NoCrashingPlz"); +} + +TEST_F(LegacyMetricsUserActionRecorderTest, EmptyBuffer) { + LegacyMetricsUserActionRecorder buffer; + EXPECT_FALSE(buffer.HasEvents()); +} + +} // namespace +} // namespace cr_fuchsia
diff --git a/fuchsia/engine/browser/content_directory_loader_factory.cc b/fuchsia/engine/browser/content_directory_loader_factory.cc index 552b870..f52d82e3 100644 --- a/fuchsia/engine/browser/content_directory_loader_factory.cc +++ b/fuchsia/engine/browser/content_directory_loader_factory.cc
@@ -23,6 +23,7 @@ #include "base/task/post_task.h" #include "base/task/task_traits.h" #include "base/task/thread_pool.h" +#include "fuchsia/base/fuchsia_dir_scheme.h" #include "fuchsia/engine/common/web_engine_content_client.h" #include "fuchsia/engine/switches.h" #include "mojo/public/cpp/bindings/remote.h" @@ -382,8 +383,7 @@ const network::ResourceRequest& request, mojo::PendingRemote<network::mojom::URLLoaderClient> client, const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) { - if (!request.url.SchemeIs( - WebEngineContentClient::kFuchsiaContentDirectoryScheme) || + if (!request.url.SchemeIs(cr_fuchsia::kFuchsiaDirScheme) || !request.url.is_valid()) { mojo::Remote<network::mojom::URLLoaderClient>(std::move(client)) ->OnComplete(network::URLLoaderCompletionStatus(net::ERR_INVALID_URL));
diff --git a/fuchsia/engine/browser/web_engine_content_browser_client.cc b/fuchsia/engine/browser/web_engine_content_browser_client.cc index b1b9d46d..74605b0 100644 --- a/fuchsia/engine/browser/web_engine_content_browser_client.cc +++ b/fuchsia/engine/browser/web_engine_content_browser_client.cc
@@ -15,6 +15,7 @@ #include "content/public/browser/network_service_instance.h" #include "content/public/common/user_agent.h" #include "content/public/common/web_preferences.h" +#include "fuchsia/base/fuchsia_dir_scheme.h" #include "fuchsia/engine/browser/url_request_rewrite_rules_manager.h" #include "fuchsia/engine/browser/web_engine_browser_context.h" #include "fuchsia/engine/browser/web_engine_browser_interface_binders.h" @@ -123,7 +124,7 @@ NonNetworkURLLoaderFactoryMap* factories) { if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kContentDirectories)) { - (*factories)[WebEngineContentClient::kFuchsiaContentDirectoryScheme] = + (*factories)[cr_fuchsia::kFuchsiaDirScheme] = std::make_unique<ContentDirectoryLoaderFactory>(); } } @@ -135,7 +136,7 @@ NonNetworkURLLoaderFactoryMap* factories) { if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kContentDirectories)) { - (*factories)[WebEngineContentClient::kFuchsiaContentDirectoryScheme] = + (*factories)[cr_fuchsia::kFuchsiaDirScheme] = std::make_unique<ContentDirectoryLoaderFactory>(); } }
diff --git a/fuchsia/engine/common/web_engine_content_client.cc b/fuchsia/engine/common/web_engine_content_client.cc index 6c9b4cf..24c9a74 100644 --- a/fuchsia/engine/common/web_engine_content_client.cc +++ b/fuchsia/engine/common/web_engine_content_client.cc
@@ -5,13 +5,11 @@ #include "fuchsia/engine/common/web_engine_content_client.h" #include "base/command_line.h" +#include "fuchsia/base/fuchsia_dir_scheme.h" #include "fuchsia/engine/switches.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" -const char WebEngineContentClient::kFuchsiaContentDirectoryScheme[] = - "fuchsia-dir"; - WebEngineContentClient::WebEngineContentClient() = default; WebEngineContentClient::~WebEngineContentClient() = default; @@ -44,6 +42,7 @@ void WebEngineContentClient::AddAdditionalSchemes(Schemes* schemes) { if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kContentDirectories)) - schemes->standard_schemes.push_back(kFuchsiaContentDirectoryScheme); + switches::kContentDirectories)) { + schemes->standard_schemes.push_back(cr_fuchsia::kFuchsiaDirScheme); + } }
diff --git a/fuchsia/engine/common/web_engine_content_client.h b/fuchsia/engine/common/web_engine_content_client.h index 0dbdb2f..95a9e1d 100644 --- a/fuchsia/engine/common/web_engine_content_client.h +++ b/fuchsia/engine/common/web_engine_content_client.h
@@ -10,9 +10,6 @@ class WebEngineContentClient : public content::ContentClient { public: - // URL scheme used to access content directories. - static const char kFuchsiaContentDirectoryScheme[]; - WebEngineContentClient(); ~WebEngineContentClient() override;
diff --git a/fuchsia/runners/BUILD.gn b/fuchsia/runners/BUILD.gn index d6673c8..e3d08a3 100644 --- a/fuchsia/runners/BUILD.gn +++ b/fuchsia/runners/BUILD.gn
@@ -57,6 +57,8 @@ "cast/api_bindings_client.h", "cast/application_controller_impl.cc", "cast/application_controller_impl.h", + "cast/audio_capturer_redirect.cc", + "cast/audio_capturer_redirect.h", "cast/cast_component.cc", "cast/cast_component.h", "cast/cast_runner.cc",
diff --git a/fuchsia/runners/cast/audio_capturer_redirect.cc b/fuchsia/runners/cast/audio_capturer_redirect.cc new file mode 100644 index 0000000..cb113c8a --- /dev/null +++ b/fuchsia/runners/cast/audio_capturer_redirect.cc
@@ -0,0 +1,47 @@ +// Copyright 2020 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 "fuchsia/runners/cast/audio_capturer_redirect.h" + +#include <lib/sys/cpp/component_context.h> +#include <lib/sys/cpp/service_directory.h> + +#include "base/fuchsia/default_context.h" + +AudioCapturerRedirect::AudioCapturerRedirect( + sys::OutgoingDirectory* outgoing_directory, + CreateCapturerCallback create_capturer_callback) + : binding_(outgoing_directory, this), + create_capturer_callback_(std::move(create_capturer_callback)), + system_audio_(base::fuchsia::ComponentContextForCurrentProcess() + ->svc() + ->Connect<fuchsia::media::Audio>()) {} +AudioCapturerRedirect::~AudioCapturerRedirect() = default; + +void AudioCapturerRedirect::CreateAudioRenderer( + fidl::InterfaceRequest<fuchsia::media::AudioRenderer> + audio_renderer_request) { + system_audio_->CreateAudioRenderer(std::move(audio_renderer_request)); +} + +void AudioCapturerRedirect::CreateAudioCapturer( + fidl::InterfaceRequest<fuchsia::media::AudioCapturer> + audio_capturer_request, + bool loopback) { + // Loopback capture is not supported. + if (loopback) { + NOTREACHED(); + return; + } + + create_capturer_callback_.Run(std::move(audio_capturer_request)); +} + +void AudioCapturerRedirect::SetSystemMute(bool muted) { + system_audio_->SetSystemMute(muted); +} + +void AudioCapturerRedirect::SetSystemGain(float gain_db) { + system_audio_->SetSystemGain(gain_db); +}
diff --git a/fuchsia/runners/cast/audio_capturer_redirect.h b/fuchsia/runners/cast/audio_capturer_redirect.h new file mode 100644 index 0000000..559774b --- /dev/null +++ b/fuchsia/runners/cast/audio_capturer_redirect.h
@@ -0,0 +1,45 @@ +// Copyright 2020 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. + +#ifndef FUCHSIA_RUNNERS_CAST_AUDIO_CAPTURER_REDIRECT_H_ +#define FUCHSIA_RUNNERS_CAST_AUDIO_CAPTURER_REDIRECT_H_ + +#include <fuchsia/media/cpp/fidl.h> + +#include "base/callback.h" +#include "base/fuchsia/scoped_service_binding.h" + +// fuchsia::media::Audio implementation that redirects CreateAudioCapturer() +// calls to a callback. +// TODO(fxb/47249) Remove this once AudioCapturerFactory is defined and +// implemented. +class AudioCapturerRedirect : public fuchsia::media::Audio { + public: + // Callback to be called for CreateAudioRenderer(). + using CreateCapturerCallback = base::RepeatingCallback<void( + fidl::InterfaceRequest<fuchsia::media::AudioCapturer> request)>; + + // Publishes fuchsia.media.Audio to |outgoing_directory| The specified + // |create_capturer_callback|. will be called every time CreateAudioCapturer() + // is called. All other calls are redirected to /svc/fuchsia.media.Audio. + AudioCapturerRedirect(sys::OutgoingDirectory* outgoing_directory, + CreateCapturerCallback create_capturer_callback); + ~AudioCapturerRedirect() final; + + private: + // fuchsia::media::Audio implementation. + void CreateAudioRenderer(fidl::InterfaceRequest<fuchsia::media::AudioRenderer> + audio_renderer_request) final; + void CreateAudioCapturer(fidl::InterfaceRequest<fuchsia::media::AudioCapturer> + audio_capturer_request, + bool loopback) final; + void SetSystemMute(bool muted) final; + void SetSystemGain(float gain_db) final; + + base::fuchsia::ScopedServiceBinding<fuchsia::media::Audio> binding_; + CreateCapturerCallback create_capturer_callback_; + fuchsia::media::AudioPtr system_audio_; +}; + +#endif // FUCHSIA_RUNNERS_CAST_AUDIO_CAPTURER_REDIRECT_H_
diff --git a/fuchsia/runners/cast/cast_component.h b/fuchsia/runners/cast/cast_component.h index 758a62fa..e7c21db 100644 --- a/fuchsia/runners/cast/cast_component.h +++ b/fuchsia/runners/cast/cast_component.h
@@ -65,6 +65,12 @@ on_headless_disconnect_cb_ = std::move(on_headless_disconnect_cb); } + const chromium::cast::ApplicationConfig& application_config() { + return application_config_; + } + + cr_fuchsia::AgentManager* agent_manager() { return agent_manager_.get(); } + private: FRIEND_TEST_ALL_PREFIXES(HeadlessCastRunnerIntegrationTest, Headless);
diff --git a/fuchsia/runners/cast/cast_runner.cc b/fuchsia/runners/cast/cast_runner.cc index 6514ed3..a8aa350e 100644 --- a/fuchsia/runners/cast/cast_runner.cc +++ b/fuchsia/runners/cast/cast_runner.cc
@@ -12,13 +12,42 @@ #include "base/bind.h" #include "base/fuchsia/file_utils.h" +#include "base/fuchsia/filtered_service_directory.h" #include "base/fuchsia/fuchsia_logging.h" #include "base/logging.h" #include "fuchsia/base/agent_manager.h" +#include "fuchsia/runners/cast/audio_capturer_redirect.h" #include "url/gurl.h" namespace { +// List of services provided to the WebEngine context. +// All services must be listed in cast_runner.cmx. +static constexpr const char* kServices[] = { + "fuchsia.accessibility.semantics.SemanticsManager", + "fuchsia.device.NameProvider", + "fuchsia.fonts.Provider", + "fuchsia.intl.PropertyProvider", + "fuchsia.logger.LogSink", + "fuchsia.media.SessionAudioConsumerFactory", + "fuchsia.media.drm.PlayReady", + "fuchsia.media.drm.Widevine", + "fuchsia.mediacodec.CodecFactory", + "fuchsia.memorypressure.Provider", + "fuchsia.net.NameLookup", + "fuchsia.netstack.Netstack", + "fuchsia.posix.socket.Provider", + "fuchsia.process.Launcher", + "fuchsia.sysmem.Allocator", + "fuchsia.ui.input.ImeService", + "fuchsia.ui.input.ImeVisibilityService", + "fuchsia.ui.scenic.Scenic", + "fuchsia.vulkan.loader.Loader", + + // Redirected to the agent. + // fuchsia.media.Audio +}; + bool AreCastComponentParamsValid( const CastComponent::CastComponentParams& params) { return !params.app_config.IsEmpty() && @@ -65,13 +94,30 @@ return output; } +bool IsPermissionGrantedInAppConfig( + const chromium::cast::ApplicationConfig& app_config, + fuchsia::web::PermissionType permission_type) { + if (app_config.has_permissions()) { + for (auto& permission : app_config.permissions()) { + if (permission.has_type() && permission.type() == permission_type) + return true; + } + } + return false; +} + } // namespace +const char CastRunner::kAgentComponentUrl[] = + "fuchsia-pkg://fuchsia.com/cast_agent#meta/cast_agent.cmx"; + CastRunner::CastRunner(fuchsia::web::CreateContextParams create_context_params, sys::OutgoingDirectory* outgoing_directory) : WebContentRunner(std::move(create_context_params), outgoing_directory), common_create_context_params_( - BuildCreateContextParamsForIsolatedRunners(create_params_)) {} + BuildCreateContextParamsForIsolatedRunners(create_params_)) { + InitializeServiceDirectory(); +} CastRunner::CastRunner(OnDestructionCallback on_destruction_callback, fuchsia::web::ContextPtr context, @@ -151,16 +197,15 @@ void CastRunner::DestroyComponent(WebComponent* component) { WebContentRunner::DestroyComponent(component); + if (component == audio_capturer_component_) + audio_capturer_component_ = nullptr; + if (on_destruction_callback_) { // |this| may be deleted and should not be used after this line. std::move(on_destruction_callback_).Run(this); - return; } } -const char CastRunner::kAgentComponentUrl[] = - "fuchsia-pkg://fuchsia.com/cast_agent#meta/cast_agent.cmx"; - void CastRunner::GetConfigCallback( CastComponent::CastComponentParams* pending_component, chromium::cast::ApplicationConfig app_config) { @@ -227,6 +272,26 @@ }); } +void CastRunner::InitializeServiceDirectory() { + service_directory_ = + std::make_unique<base::fuchsia::FilteredServiceDirectory>( + base::fuchsia::ComponentContextForCurrentProcess()->svc().get()); + + for (auto* name : kServices) { + service_directory_->AddService(name); + } + + // Create AudioCapturerRedirect to intercept CreateAudioCapturer() requests. + audio_capturer_redirect_ = std::make_unique<AudioCapturerRedirect>( + service_directory_->outgoing_directory(), + base::BindRepeating(&CastRunner::CreateAudioCapturer, + base::Unretained(this))); + + fidl::InterfaceHandle<fuchsia::io::Directory> client_handle; + service_directory_->ConnectClient(client_handle.NewRequest()); + create_params_.set_service_directory(std::move(client_handle)); +} + void CastRunner::MaybeStartComponent( CastComponent::CastComponentParams* pending_component_params) { if (!AreCastComponentParamsValid(*pending_component_params)) @@ -264,6 +329,13 @@ cast_component->StartComponent(); cast_component->LoadUrl(std::move(app_url), std::vector<fuchsia::net::http::Header>()); + + if (IsPermissionGrantedInAppConfig( + cast_component->application_config(), + fuchsia::web::PermissionType::MICROPHONE)) { + audio_capturer_component_ = cast_component.get(); + } + RegisterComponent(std::move(cast_component)); } @@ -275,14 +347,17 @@ fuchsia::web::CreateContextParams isolated_context_params; zx_status_t status = common_create_context_params_.Clone(&isolated_context_params); - isolated_context_params.set_service_directory(base::fuchsia::OpenDirectory( - base::FilePath(base::fuchsia::kServiceDirectoryPath))); - CHECK(isolated_context_params.service_directory()); if (status != ZX_OK) { ZX_LOG(ERROR, status) << "clone"; return nullptr; } + // Service redirection is not necessary for isolated context. Pass default + // /svc as is, without overriding any services. + isolated_context_params.set_service_directory(base::fuchsia::OpenDirectory( + base::FilePath(base::fuchsia::kServiceDirectoryPath))); + DCHECK(isolated_context_params.service_directory()); + isolated_context_params.set_content_directories( std::move(*params->app_config .mutable_content_directories_for_isolated_application())); @@ -314,3 +389,15 @@ size_t CastRunner::GetChildCastRunnerCountForTest() { return isolated_runners_.size(); } + +void CastRunner::CreateAudioCapturer( + fidl::InterfaceRequest<fuchsia::media::AudioCapturer> request) { + if (!audio_capturer_component_) + return; + + auto audio = + audio_capturer_component_->agent_manager() + ->ConnectToAgentService<fuchsia::media::Audio>( + audio_capturer_component_->application_config().agent_url()); + audio->CreateAudioCapturer(std::move(request), /*loopback=*/false); +} \ No newline at end of file
diff --git a/fuchsia/runners/cast/cast_runner.cmx b/fuchsia/runners/cast/cast_runner.cmx index 43e4234..987ad94 100644 --- a/fuchsia/runners/cast/cast_runner.cmx +++ b/fuchsia/runners/cast/cast_runner.cmx
@@ -3,6 +3,7 @@ "features": [ "config-data" ], + "$comment": "Not all services are passed to WebEngine, see cast_runner.cc", "services": [ "chromium.cast.ApplicationConfigManager", "fuchsia.accessibility.semantics.SemanticsManager",
diff --git a/fuchsia/runners/cast/cast_runner.h b/fuchsia/runners/cast/cast_runner.h index abce20e..82549ec 100644 --- a/fuchsia/runners/cast/cast_runner.h +++ b/fuchsia/runners/cast/cast_runner.h
@@ -20,6 +20,14 @@ #include "fuchsia/runners/cast/cast_component.h" #include "fuchsia/runners/common/web_content_runner.h" +namespace base { +namespace fuchsia { +class FilteredServiceDirectory; +} // namespace fuchsia +} // namespace base + +class AudioCapturerRedirect; + // sys::Runner which instantiates Cast activities specified via cast/casts URIs. class CastRunner : public WebContentRunner { public: @@ -60,6 +68,10 @@ fuchsia::web::ContextPtr context, bool is_headless); + // Initializes the service directory that's passed to the web context. Must be + // called during initialization, before the context is created. + void InitializeServiceDirectory(); + // Starts a component once all configuration data is available. void MaybeStartComponent( CastComponent::CastComponentParams* pending_component_params); @@ -81,6 +93,10 @@ CastRunner* CreateChildRunnerForIsolatedComponent( CastComponent::CastComponentParams* params); + // Callback for |audio_capturer_redirect_|. + void CreateAudioCapturer( + fidl::InterfaceRequest<fuchsia::media::AudioCapturer> request); + // Holds StartComponent() requests while the ApplicationConfig is being // fetched from the ApplicationConfigManager. base::flat_set<std::unique_ptr<CastComponent::CastComponentParams>, @@ -97,6 +113,12 @@ // Manages isolated CastRunners owned by |this| instance. base::flat_set<std::unique_ptr<CastRunner>, base::UniquePtrComparator> isolated_runners_; + + std::unique_ptr<base::fuchsia::FilteredServiceDirectory> service_directory_; + std::unique_ptr<AudioCapturerRedirect> audio_capturer_redirect_; + + // Last component that was created with permission to access MICROPHONE. + CastComponent* audio_capturer_component_ = nullptr; }; #endif // FUCHSIA_RUNNERS_CAST_CAST_RUNNER_H_
diff --git a/fuchsia/runners/cast/cast_runner_integration_test.cc b/fuchsia/runners/cast/cast_runner_integration_test.cc index 8c85220..cc766606 100644 --- a/fuchsia/runners/cast/cast_runner_integration_test.cc +++ b/fuchsia/runners/cast/cast_runner_integration_test.cc
@@ -24,12 +24,14 @@ #include "fuchsia/base/fake_component_context.h" #include "fuchsia/base/fit_adapter.h" #include "fuchsia/base/frame_test_util.h" +#include "fuchsia/base/fuchsia_dir_scheme.h" #include "fuchsia/base/mem_buffer_util.h" #include "fuchsia/base/result_receiver.h" #include "fuchsia/base/string_util.h" #include "fuchsia/base/test_devtools_list_fetcher.h" #include "fuchsia/base/test_navigation_listener.h" #include "fuchsia/base/url_request_rewrite_test_util.h" +#include "fuchsia/runners/cast/audio_capturer_redirect.h" #include "fuchsia/runners/cast/cast_runner.h" #include "fuchsia/runners/cast/fake_application_config_manager.h" #include "fuchsia/runners/cast/test_api_bindings.h" @@ -59,6 +61,21 @@ ADD_FAILURE(); } +// Helper used to ensure that cr_fuchsia::RegisterFuchsiaDirScheme() is called +// once per process to register fuchsia-dir scheme. In cast_runner this function +// is called in main.cc, but that code is not executed in +// cast_runner_integration_tests. +// +// TODO(crbug.com/1062351): Update the tests to start cast_runner component +// instead of creating CastRunner in process. Then remove this function. +void EnsureFuchsiaDirSchemeInitialized() { + class SchemeInitializer { + public: + SchemeInitializer() { cr_fuchsia::RegisterFuchsiaDirScheme(); } + }; + static SchemeInitializer initializer; +} + class FakeUrlRequestRewriteRulesProvider : public chromium::cast::UrlRequestRewriteRulesProvider { public: @@ -143,6 +160,9 @@ FakeComponentState(const FakeComponentState&) = delete; FakeComponentState& operator=(const FakeComponentState&) = delete; + // Make outgoing_directory() public. + using ComponentStateBase::outgoing_directory; + FakeApplicationContext* application_context() { return &application_context_; } @@ -198,6 +218,8 @@ protected: explicit CastRunnerIntegrationTest( fuchsia::web::ContextFeatureFlags feature_flags) { + EnsureFuchsiaDirSchemeInitialized(); + // Create the CastRunner, published into |outgoing_directory_|. fuchsia::web::CreateContextParams create_context_params; create_context_params.set_features(feature_flags); @@ -236,6 +258,10 @@ component_url, &app_config_manager_, &api_bindings_, &url_request_rewrite_rules_provider_); component_state_ = component_state.get(); + + if (init_component_state_callback_) + std::move(init_component_state_callback_).Run(component_state_); + return component_state; } @@ -348,6 +374,8 @@ FakeComponentState* component_state_ = nullptr; CastComponent* cast_component_ = nullptr; + base::OnceCallback<void(FakeComponentState*)> init_component_state_callback_; + // ServiceDirectory into which the CastRunner will publish itself. sys::OutgoingDirectory outgoing_directory_; @@ -672,6 +700,37 @@ EXPECT_FALSE(component_state_->url_request_rules_provider_has_clients()); } +TEST_F(CastRunnerIntegrationTest, MicRedirect) { + GURL app_url = test_server_.GetURL("/mic.html"); + auto app_config = + FakeApplicationConfigManager::CreateConfig(kTestAppId, app_url); + + fuchsia::web::PermissionDescriptor mic_permission; + mic_permission.set_type(fuchsia::web::PermissionType::MICROPHONE); + app_config.mutable_permissions()->push_back(std::move(mic_permission)); + app_config_manager_.AddAppConfig(std::move(app_config)); + + base::RunLoop run_loop; + std::unique_ptr<AudioCapturerRedirect> redirect; + + init_component_state_callback_ = base::BindOnce( + [](std::unique_ptr<AudioCapturerRedirect>* redirect, + base::OnceClosure quit_closure, FakeComponentState* component_state) { + *redirect = std::make_unique<AudioCapturerRedirect>( + component_state->outgoing_directory(), + base::BindRepeating( + [](base::OnceClosure quit_closure, + fidl::InterfaceRequest<fuchsia::media::AudioCapturer> + request) { std::move(quit_closure).Run(); }, + base::Passed(std::move(quit_closure)))); + }, + &redirect, base::Passed(run_loop.QuitClosure())); + + CreateComponentContextAndStartComponent(); + + run_loop.Run(); +} + class HeadlessCastRunnerIntegrationTest : public CastRunnerIntegrationTest { public: HeadlessCastRunnerIntegrationTest()
diff --git a/fuchsia/runners/cast/fake_application_config_manager.cc b/fuchsia/runners/cast/fake_application_config_manager.cc index 07e396c..33ded8a 100644 --- a/fuchsia/runners/cast/fake_application_config_manager.cc +++ b/fuchsia/runners/cast/fake_application_config_manager.cc
@@ -23,6 +23,13 @@ app_config.set_display_name("Dummy test app"); app_config.set_web_url(url.spec()); app_config.set_agent_url(kAgentComponentUrl); + + // Add a PROTECTED_MEDIA_IDENTIFIER permission. This is consistent with the + // real ApplicationConfigManager. + fuchsia::web::PermissionDescriptor permission; + permission.set_type(fuchsia::web::PermissionType::PROTECTED_MEDIA_IDENTIFIER); + app_config.mutable_permissions()->push_back(std::move(permission)); + return app_config; }
diff --git a/fuchsia/runners/cast/main.cc b/fuchsia/runners/cast/main.cc index 3bd65dca..3ef456f 100644 --- a/fuchsia/runners/cast/main.cc +++ b/fuchsia/runners/cast/main.cc
@@ -14,6 +14,7 @@ #include "base/values.h" #include "build/buildflag.h" #include "fuchsia/base/config_reader.h" +#include "fuchsia/base/fuchsia_dir_scheme.h" #include "fuchsia/base/init_logging.h" #include "fuchsia/runners/buildflags.h" #include "fuchsia/runners/cast/cast_runner.h" @@ -43,6 +44,8 @@ *base::CommandLine::ForCurrentProcess())) << "Failed to initialize logging."; + cr_fuchsia::RegisterFuchsiaDirScheme(); + fuchsia::web::ContextFeatureFlags features = fuchsia::web::ContextFeatureFlags::NETWORK | fuchsia::web::ContextFeatureFlags::AUDIO |
diff --git a/fuchsia/runners/cast/testdata/mic.html b/fuchsia/runners/cast/testdata/mic.html new file mode 100644 index 0000000..742b31b --- /dev/null +++ b/fuchsia/runners/cast/testdata/mic.html
@@ -0,0 +1,4 @@ +<script> + navigator.mediaDevices.getUserMedia({ audio: true, video: false }) + .then((stream) => { document.title = 'done'; }); +</script> \ No newline at end of file
diff --git a/fuchsia/runners/web/main.cc b/fuchsia/runners/web/main.cc index 14f10f2..0245c71 100644 --- a/fuchsia/runners/web/main.cc +++ b/fuchsia/runners/web/main.cc
@@ -10,6 +10,7 @@ #include "base/message_loop/message_pump_type.h" #include "base/run_loop.h" #include "base/task/single_thread_task_executor.h" +#include "fuchsia/base/fuchsia_dir_scheme.h" #include "fuchsia/base/init_logging.h" #include "fuchsia/runners/buildflags.h" #include "fuchsia/runners/common/web_content_runner.h" @@ -23,6 +24,8 @@ *base::CommandLine::ForCurrentProcess())) << "Failed to initialize logging."; + cr_fuchsia::RegisterFuchsiaDirScheme(); + fuchsia::web::CreateContextParams create_context_params; create_context_params.set_features( fuchsia::web::ContextFeatureFlags::NETWORK |
diff --git a/gpu/config/gpu_driver_bug_list.json b/gpu/config/gpu_driver_bug_list.json index 4a9f9d64..53aa559 100644 --- a/gpu/config/gpu_driver_bug_list.json +++ b/gpu/config/gpu_driver_bug_list.json
@@ -3569,22 +3569,6 @@ ] }, { - "id":335, - "cr_bugs": [1051705], - "description": "Disable AImageReader on ARM GPUs", - "os": { - "type": "android", - "version": { - "op": "<", - "value": "10" - } - }, - "gl_vendor": "ARM.*", - "features": [ - "disable_aimagereader" - ] - }, - { "id": 336, "cr_bugs": [625785], "description": "Hardware overlays caused crash spike on certain AMD GPUs",
diff --git a/gpu/config/gpu_workaround_list.txt b/gpu/config/gpu_workaround_list.txt index c3b96b8e..2898f28 100644 --- a/gpu/config/gpu_workaround_list.txt +++ b/gpu/config/gpu_workaround_list.txt
@@ -13,7 +13,6 @@ depth_stencil_renderbuffer_resize_emulation disable_2d_canvas_auto_flush disable_accelerated_vpx_decode -disable_aimagereader disable_async_readpixels disable_av_sample_buffer_display_layer disable_blend_equation_advanced
diff --git a/gpu/ipc/service/gpu_init.cc b/gpu/ipc/service/gpu_init.cc index e3eae31..9434d86 100644 --- a/gpu/ipc/service/gpu_init.cc +++ b/gpu/ipc/service/gpu_init.cc
@@ -524,12 +524,6 @@ ui::OzonePlatform::GetInstance()->AfterSandboxEntry(); #endif -#if defined(OS_ANDROID) - // Disable AImageReader if the workaround is enabled. - if (gpu_feature_info_.IsWorkaroundEnabled(DISABLE_AIMAGEREADER)) { - base::android::AndroidImageReader::DisableSupport(); - } -#endif #if defined(USE_OZONE) gpu_feature_info_.supported_buffer_formats_for_allocation_and_texturing = std::move(supported_buffer_formats_for_texturing); @@ -556,11 +550,6 @@ default_offscreen_surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size()); - // Disable AImageReader if the workaround is enabled. - if (gpu_feature_info_.IsWorkaroundEnabled(DISABLE_AIMAGEREADER)) { - base::android::AndroidImageReader::DisableSupport(); - } - UMA_HISTOGRAM_ENUMERATION("GPU.GLImplementation", gl::GetGLImplementation()); } #else
diff --git a/headless/lib/browser/headless_request_context_manager.cc b/headless/lib/browser/headless_request_context_manager.cc index 5b542de..646b0f0 100644 --- a/headless/lib/browser/headless_request_context_manager.cc +++ b/headless/lib/browser/headless_request_context_manager.cc
@@ -182,9 +182,16 @@ HeadlessRequestContextManager::HeadlessRequestContextManager( const HeadlessBrowserContextOptions* options, base::FilePath user_data_path) - : cookie_encryption_enabled_( + : +// On Windows, Cookie encryption requires access to local_state prefs, which are +// unavailable. +#if defined(OS_WIN) + cookie_encryption_enabled_(false), +#else + cookie_encryption_enabled_( !base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisableCookieEncryption)), +#endif user_data_path_(std::move(user_data_path)), accept_language_(options->accept_language()), user_agent_(options->user_agent()),
diff --git a/infra/config/buckets/ci.star b/infra/config/buckets/ci.star index a0a94ce8..2f2a851 100644 --- a/infra/config/buckets/ci.star +++ b/infra/config/buckets/ci.star
@@ -881,7 +881,7 @@ ) ci.fyi_builder( - name = 'linux-bfcache-debug', + name = 'linux-bfcache-rel', ) ci.fyi_builder(
diff --git a/infra/config/buckets/try.star b/infra/config/buckets/try.star index 1a3c911..90bd94c 100644 --- a/infra/config/buckets/try.star +++ b/infra/config/buckets/try.star
@@ -337,7 +337,7 @@ ) try_.chromium_linux_builder( - name = 'linux-bfcache-debug', + name = 'linux-bfcache-rel', ) try_.chromium_linux_builder( @@ -541,6 +541,9 @@ name = 'ios-simulator-code-coverage', executable = 'recipe:chromium_trybot', use_clang_coverage = True, + properties = { + 'xcode_build_version': '11c29', + }, ) try_.chromium_mac_ios_builder(
diff --git a/infra/config/consoles/chromium.fyi.star b/infra/config/consoles/chromium.fyi.star index b9302a0..9084223 100644 --- a/infra/config/consoles/chromium.fyi.star +++ b/infra/config/consoles/chromium.fyi.star
@@ -141,7 +141,7 @@ category = 'linux', ), luci.console_view_entry( - builder = 'ci/linux-bfcache-debug', + builder = 'ci/linux-bfcache-rel', category = 'linux', ), luci.console_view_entry(
diff --git a/infra/config/consoles/chromium.goma.migration.star b/infra/config/consoles/chromium.goma.migration.star index 25c8129..978649675 100644 --- a/infra/config/consoles/chromium.goma.migration.star +++ b/infra/config/consoles/chromium.goma.migration.star
@@ -717,7 +717,7 @@ short_name = 'rel', ), luci.console_view_entry( - builder = 'ci/linux-bfcache-debug', + builder = 'ci/linux-bfcache-rel', category = 'week15a|linux', short_name = 'bfc', ),
diff --git a/infra/config/consoles/tryserver.chromium.linux.star b/infra/config/consoles/tryserver.chromium.linux.star index dea824cea..d8a8cfd 100644 --- a/infra/config/consoles/tryserver.chromium.linux.star +++ b/infra/config/consoles/tryserver.chromium.linux.star
@@ -29,7 +29,7 @@ 'try/layout_test_leak_detection', 'try/leak_detection_linux', 'try/linux-annotator-rel', - 'try/linux-bfcache-debug', + 'try/linux-bfcache-rel', 'try/linux-dcheck-off-rel', 'try/linux-gcc-rel', 'try/linux-libfuzzer-asan-rel',
diff --git a/infra/config/generated/commit-queue.cfg b/infra/config/generated/commit-queue.cfg index 9ba304f..8b58c71 100644 --- a/infra/config/generated/commit-queue.cfg +++ b/infra/config/generated/commit-queue.cfg
@@ -713,7 +713,7 @@ includable_only: true > builders: < - name: "chromium/try/linux-bfcache-debug" + name: "chromium/try/linux-bfcache-rel" includable_only: true > builders: <
diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg index 35f6b5c..60fa68cd 100644 --- a/infra/config/generated/cr-buildbucket.cfg +++ b/infra/config/generated/cr-buildbucket.cfg
@@ -7111,7 +7111,7 @@ service_account: "chromium-ci-builder@chops-service-accounts.iam.gserviceaccount.com" > builders: < - name: "linux-bfcache-debug" + name: "linux-bfcache-rel" swarming_host: "chromium-swarm.appspot.com" swarming_tags: "vpython:native-python-wrapper" dimensions: "builderless:1" @@ -16480,6 +16480,7 @@ properties_j: "$build/code_coverage:{\"use_clang_coverage\":true}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "mastername:\"tryserver.chromium.mac\"" + properties_j: "xcode_build_version:\"11c29\"" > execution_timeout_secs: 14400 expiration_secs: 7200 @@ -16824,7 +16825,7 @@ > > builders: < - name: "linux-bfcache-debug" + name: "linux-bfcache-rel" swarming_host: "chromium-swarm.appspot.com" swarming_tags: "vpython:native-python-wrapper" dimensions: "builderless:1"
diff --git a/infra/config/generated/luci-milo.cfg b/infra/config/generated/luci-milo.cfg index 72bfc45..4defdc8 100644 --- a/infra/config/generated/luci-milo.cfg +++ b/infra/config/generated/luci-milo.cfg
@@ -3193,7 +3193,7 @@ category: "linux" > builders: < - name: "buildbucket/luci.chromium.ci/linux-bfcache-debug" + name: "buildbucket/luci.chromium.ci/linux-bfcache-rel" category: "linux" > builders: < @@ -5044,7 +5044,7 @@ short_name: "rel" > builders: < - name: "buildbucket/luci.chromium.ci/linux-bfcache-debug" + name: "buildbucket/luci.chromium.ci/linux-bfcache-rel" category: "week15a|linux" short_name: "bfc" > @@ -13205,7 +13205,7 @@ name: "buildbucket/luci.chromium.try/linux-annotator-rel" > builders: < - name: "buildbucket/luci.chromium.try/linux-bfcache-debug" + name: "buildbucket/luci.chromium.try/linux-bfcache-rel" > builders: < name: "buildbucket/luci.chromium.try/linux-dcheck-off-rel"
diff --git a/infra/config/generated/luci-scheduler.cfg b/infra/config/generated/luci-scheduler.cfg index b3dd248..4a504601 100644 --- a/infra/config/generated/luci-scheduler.cfg +++ b/infra/config/generated/luci-scheduler.cfg
@@ -5947,12 +5947,12 @@ > > job: < - id: "linux-bfcache-debug" + id: "linux-bfcache-rel" acl_sets: "ci" buildbucket: < server: "cr-buildbucket.appspot.com" bucket: "luci.chromium.ci" - builder: "linux-bfcache-debug" + builder: "linux-bfcache-rel" > > job: < @@ -6971,7 +6971,7 @@ triggers: "linux-annotator-rel" triggers: "linux-archive-dbg" triggers: "linux-archive-rel" - triggers: "linux-bfcache-debug" + triggers: "linux-bfcache-rel" triggers: "linux-blink-animation-use-time-delta" triggers: "linux-blink-cors-rel" triggers: "linux-blink-heap-concurrent-marking-tsan-rel"
diff --git a/ios/chrome/app/BUILD.gn b/ios/chrome/app/BUILD.gn index 07dbf8c..9b2646316 100644 --- a/ios/chrome/app/BUILD.gn +++ b/ios/chrome/app/BUILD.gn
@@ -314,10 +314,7 @@ assert(ios_application_icons_target != "", "ios_application_icons_target must be defined.") bundle_deps += [ ios_application_icons_target ] - - if (ios_firebase_resources_target != "") { - bundle_deps += [ ios_firebase_resources_target ] - } + bundle_deps += ios_providers_resources_targets } else { variants = ios_chrome_app_variants }
diff --git a/ios/chrome/app/main_controller.mm b/ios/chrome/app/main_controller.mm index 875965e..e3575f88 100644 --- a/ios/chrome/app/main_controller.mm +++ b/ios/chrome/app/main_controller.mm
@@ -132,8 +132,6 @@ #import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/webui/chrome_web_ui_ios_controller_factory.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #import "ios/chrome/browser/web/tab_id_tab_helper.h" #import "ios/chrome/browser/web_state_list/web_state_list.h" #import "ios/chrome/browser/web_state_list/web_state_list_observer_bridge.h"
diff --git a/ios/chrome/app/strings/ios_strings.grd b/ios/chrome/app/strings/ios_strings.grd index 78d28a6..30d3d71c 100644 --- a/ios/chrome/app/strings/ios_strings.grd +++ b/ios/chrome/app/strings/ios_strings.grd
@@ -782,6 +782,12 @@ <message name="IDS_IOS_GOOGLE_SERVICES_SETTINGS_AUTOCOMPLETE_SEARCHES_AND_URLS_TEXT" desc="Feature title in the settings for the user to enable/disable, to have autocomplete searches and URLs. Text related to 'Sends searches from the address bar and search box, and some cookies to your default search engine' [iOS only]"> Autocomplete Searches and URLs </message> + <message name="IDS_IOS_GOOGLE_SERVICES_SETTINGS_SAFE_BROWSING_DETAIL" desc="Feature detail text in the setting to enable/disable safe browsing"> + Sends URLs of some pages you visit to Google, when your security is at risk + </message> + <message name="IDS_IOS_GOOGLE_SERVICES_SETTINGS_SAFE_BROWSING_TEXT" desc="The section title of 'Protects you and your device from dangerous sites'"> + Safe Browsing (protects you and your device from dangerous sites) + </message> <message name="IDS_IOS_GOOGLE_SERVICES_SETTINGS_BETTER_SEARCH_AND_BROWSING_DETAIL" desc="Detail text for a feature in the settings for the user to enable/disable, to make searches andn browsing better. Related to 'Make searches and browsing better'. [iOS only]"> Sends URLs of pages you visit to Google. </message>
diff --git a/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_GOOGLE_SERVICES_SETTINGS_SAFE_BROWSING_DETAIL.png.sha1 b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_GOOGLE_SERVICES_SETTINGS_SAFE_BROWSING_DETAIL.png.sha1 new file mode 100644 index 0000000..8af0578 --- /dev/null +++ b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_GOOGLE_SERVICES_SETTINGS_SAFE_BROWSING_DETAIL.png.sha1
@@ -0,0 +1 @@ +8d5ac95eb4a3f7d3ef575f237309e1f8c7a50bae \ No newline at end of file
diff --git a/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_GOOGLE_SERVICES_SETTINGS_SAFE_BROWSING_TEXT.png.sha1 b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_GOOGLE_SERVICES_SETTINGS_SAFE_BROWSING_TEXT.png.sha1 new file mode 100644 index 0000000..8af0578 --- /dev/null +++ b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_GOOGLE_SERVICES_SETTINGS_SAFE_BROWSING_TEXT.png.sha1
@@ -0,0 +1 @@ +8d5ac95eb4a3f7d3ef575f237309e1f8c7a50bae \ No newline at end of file
diff --git a/ios/chrome/browser/app_launcher/app_launcher_tab_helper.mm b/ios/chrome/browser/app_launcher/app_launcher_tab_helper.mm index 4174557..295479e64 100644 --- a/ios/chrome/browser/app_launcher/app_launcher_tab_helper.mm +++ b/ios/chrome/browser/app_launcher/app_launcher_tab_helper.mm
@@ -215,7 +215,7 @@ web_state_->GetNavigationManager()->GetPendingItem(); GURL original_pending_url = pending_item ? pending_item->GetOriginalRequestURL() : GURL::EmptyGURL(); - bool is_link_transition = ui::PageTransitionTypeIncludingQualifiersIs( + bool is_link_transition = ui::PageTransitionCoreTypeIs( request_info.transition_type, ui::PAGE_TRANSITION_LINK); ChromeBrowserState* browser_state =
diff --git a/ios/chrome/browser/app_launcher/app_launcher_tab_helper_unittest.mm b/ios/chrome/browser/app_launcher/app_launcher_tab_helper_unittest.mm index 3a044dc..14086b9 100644 --- a/ios/chrome/browser/app_launcher/app_launcher_tab_helper_unittest.mm +++ b/ios/chrome/browser/app_launcher/app_launcher_tab_helper_unittest.mm
@@ -122,11 +122,13 @@ bool TestShouldAllowRequest(NSString* url_string, bool target_frame_is_main, - bool has_user_gesture) WARN_UNUSED_RESULT { + bool has_user_gesture, + ui::PageTransition transition_type = + ui::PageTransition::PAGE_TRANSITION_LINK) + WARN_UNUSED_RESULT { NSURL* url = [NSURL URLWithString:url_string]; web::WebStatePolicyDecider::RequestInfo request_info( - ui::PageTransition::PAGE_TRANSITION_LINK, target_frame_is_main, - has_user_gesture); + transition_type, target_frame_is_main, has_user_gesture); return tab_helper_->ShouldAllowRequest([NSURLRequest requestWithURL:url], request_info); } @@ -166,9 +168,8 @@ abuse_detector_.policy = is_app_blocked ? ExternalAppLaunchPolicyBlock : ExternalAppLaunchPolicyAllow; ui::PageTransition transition_type = - is_link_transition - ? ui::PageTransition::PAGE_TRANSITION_LINK - : ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT; + is_link_transition ? ui::PageTransition::PAGE_TRANSITION_LINK + : ui::PageTransition::PAGE_TRANSITION_TYPED; NSURL* url = [NSURL URLWithString:@"itms-apps://itunes.apple.com/us/app/appname/id123"]; @@ -410,4 +411,17 @@ EXPECT_EQ(2U, delegate_.countOfAppsLaunched); } +// Tests that launching a SMS URL via a JavaScript redirect in the main frame +// is allowed. Covers the scenario for crbug.com/1058388 +TEST_F(AppLauncherTabHelperTest, LaunchSmsApp_JavaScriptRedirect) { + NSString* sms_url_string = @"sms:?&body=Hello%20World"; + ui::PageTransition page_transition = ui::PageTransitionFromInt( + ui::PageTransition::PAGE_TRANSITION_LINK | + ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT); + EXPECT_FALSE( + TestShouldAllowRequest(sms_url_string, /*target_frame_is_main=*/true, + /*has_user_gesture=*/false, page_transition)); + EXPECT_EQ(1U, delegate_.countOfAppsLaunched); +} + } // namespace
diff --git a/ios/chrome/browser/main/browser_agent_util.mm b/ios/chrome/browser/main/browser_agent_util.mm index a418f7cd..13a3910d 100644 --- a/ios/chrome/browser/main/browser_agent_util.mm +++ b/ios/chrome/browser/main/browser_agent_util.mm
@@ -14,6 +14,7 @@ #import "ios/chrome/browser/sessions/session_restoration_browser_agent.h" #import "ios/chrome/browser/sessions/session_service_ios.h" #include "ios/chrome/browser/tabs/synced_window_delegate_browser_agent.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_notifier_browser_agent.h" #import "ios/chrome/browser/web_state_list/tab_insertion_browser_agent.h" #import "ios/chrome/browser/web_state_list/web_usage_enabler/web_usage_enabler_browser_agent.h" @@ -34,6 +35,9 @@ WebUsageEnablerBrowserAgent::CreateForBrowser(browser); UrlLoadingNotifierBrowserAgent::CreateForBrowser(browser); + // UrlLoadingBrowserAgent requires UrlLoadingNotifierBrowserAgent. + UrlLoadingBrowserAgent::CreateForBrowser(browser); + // SessionRestorartionAgent requires WebUsageEnablerBrowserAgent. SessionRestorationBrowserAgent::CreateForBrowser( browser, [SessionServiceIOS sharedService]);
diff --git a/ios/chrome/browser/prefs/BUILD.gn b/ios/chrome/browser/prefs/BUILD.gn index c56318a..5946cfa 100644 --- a/ios/chrome/browser/prefs/BUILD.gn +++ b/ios/chrome/browser/prefs/BUILD.gn
@@ -82,6 +82,7 @@ "//ios/chrome/browser/voice:prefs", "//ios/chrome/browser/web", "//ios/public/provider/chrome/browser", + "//ios/web/common:features", "//ui/base", ] }
diff --git a/ios/chrome/browser/prefs/browser_prefs.mm b/ios/chrome/browser/prefs/browser_prefs.mm index 5807c99..76ff734 100644 --- a/ios/chrome/browser/prefs/browser_prefs.mm +++ b/ios/chrome/browser/prefs/browser_prefs.mm
@@ -65,6 +65,7 @@ #include "ios/chrome/browser/voice/voice_search_prefs_registration.h" #import "ios/chrome/browser/web/font_size_tab_helper.h" #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" +#import "ios/web/common/features.h" #include "ui/base/l10n/l10n_util.h" #if !defined(__has_feature) || !__has_feature(objc_arc)
diff --git a/ios/chrome/browser/ui/bookmarks/bookmark_home_view_controller.mm b/ios/chrome/browser/ui/bookmarks/bookmark_home_view_controller.mm index eb6fe46d..9389944 100644 --- a/ios/chrome/browser/ui/bookmarks/bookmark_home_view_controller.mm +++ b/ios/chrome/browser/ui/bookmarks/bookmark_home_view_controller.mm
@@ -49,9 +49,8 @@ #import "ios/chrome/browser/ui/util/rtl_geometry.h" #import "ios/chrome/browser/ui/util/ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #import "ios/chrome/browser/web_state_list/web_state_list.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h" #import "ios/chrome/common/ui/favicon/favicon_attributes.h" @@ -1071,7 +1070,7 @@ base::UserMetricsAction("MobileBookmarkManagerEntryOpened")); UrlLoadParams params = UrlLoadParams::InCurrentTab(url); params.web_params.transition_type = ui::PAGE_TRANSITION_AUTO_BOOKMARK; - UrlLoadingServiceFactory::GetForBrowserState(self.browserState)->Load(params); + UrlLoadingBrowserAgent::FromBrowser(self.browser)->Load(params); } - (void)addNewFolder {
diff --git a/ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.mm b/ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.mm index 3bf28a2..2b140b1c 100644 --- a/ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.mm +++ b/ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.mm
@@ -37,9 +37,8 @@ #import "ios/chrome/browser/ui/table_view/table_view_presentation_controller.h" #import "ios/chrome/browser/ui/table_view/table_view_presentation_controller_delegate.h" #include "ios/chrome/browser/ui/util/uikit_ui_util.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #import "ios/chrome/browser/url_loading/url_loading_util.h" #import "ios/chrome/browser/web_state_list/web_state_list.h" #include "ios/chrome/grit/ios_strings.h" @@ -572,8 +571,7 @@ } UrlLoadParams params = UrlLoadParams::InCurrentTab(url); params.web_params.transition_type = ui::PAGE_TRANSITION_AUTO_BOOKMARK; - UrlLoadingServiceFactory::GetForBrowserState(_currentBrowserState) - ->Load(params); + UrlLoadingBrowserAgent::FromBrowser(_browser)->Load(params); } - (void)openURLInNewTab:(const GURL&)url @@ -584,8 +582,7 @@ UrlLoadParams params = UrlLoadParams::InNewTab(url); params.SetInBackground(inBackground); params.in_incognito = inIncognito; - UrlLoadingServiceFactory::GetForBrowserState(_currentBrowserState) - ->Load(params); + UrlLoadingBrowserAgent::FromBrowser(_browser)->Load(params); } @end
diff --git a/ios/chrome/browser/ui/browser_view/browser_coordinator.h b/ios/chrome/browser/ui/browser_view/browser_coordinator.h index 5ab019cd..28666d45 100644 --- a/ios/chrome/browser/ui/browser_view/browser_coordinator.h +++ b/ios/chrome/browser/ui/browser_view/browser_coordinator.h
@@ -11,7 +11,6 @@ @protocol ApplicationCommands; @protocol BrowsingDataCommands; @class BrowserViewController; -@class TabModel; class AppUrlLoadingService;
diff --git a/ios/chrome/browser/ui/browser_view/browser_coordinator.mm b/ios/chrome/browser/ui/browser_view/browser_coordinator.mm index 5f83cca..08b102e8 100644 --- a/ios/chrome/browser/ui/browser_view/browser_coordinator.mm +++ b/ios/chrome/browser/ui/browser_view/browser_coordinator.mm
@@ -61,9 +61,8 @@ #import "ios/chrome/browser/ui/toolbar/accessory/toolbar_accessory_coordinator_delegate.h" #import "ios/chrome/browser/ui/toolbar/accessory/toolbar_accessory_presenter.h" #import "ios/chrome/browser/ui/translate/legacy_translate_infobar_coordinator.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #import "ios/chrome/browser/web/features.h" #import "ios/chrome/browser/web/font_size_tab_helper.h" #import "ios/chrome/browser/web/print_tab_helper.h" @@ -84,7 +83,7 @@ PageInfoCommands, RepostFormTabHelperDelegate, ToolbarAccessoryCoordinatorDelegate, - URLLoadingServiceDelegate, + URLLoadingDelegate, WebStateListObserving> // Whether the coordinator is started. @@ -221,7 +220,7 @@ [self.dispatcher startDispatchingToTarget:self forProtocol:@protocol(PageInfoCommands)]; [self installDelegatesForAllWebStates]; - [self installDelegatesForBrowserState]; + [self installDelegatesForBrowser]; [self addWebStateListObserver]; [super start]; self.started = YES; @@ -232,7 +231,7 @@ return; [super stop]; [self removeWebStateListObserver]; - [self uninstallDelegatesForBrowserState]; + [self uninstallDelegatesForBrowser]; [self uninstallDelegatesForAllWebStates]; [self.dispatcher stopDispatchingToTarget:self]; [self stopChildCoordinators]; @@ -710,7 +709,7 @@ - (void)showSecurityHelpPage { UrlLoadParams params = UrlLoadParams::InNewTab(GURL(kPageInfoHelpCenterURL)); params.in_incognito = self.browserState->IsOffTheRecord(); - UrlLoadingServiceFactory::GetForBrowserState(self.browserState)->Load(params); + UrlLoadingBrowserAgent::FromBrowser(self.browser)->Load(params); [self hidePageInfo]; } @@ -894,25 +893,23 @@ } } -// Installs delegates for self.browserState. -- (void)installDelegatesForBrowserState { - UrlLoadingService* urlLoadingService = - UrlLoadingServiceFactory::GetForBrowserState(self.browserState); - if (urlLoadingService) { - urlLoadingService->SetAppService(self.appURLLoadingService); - urlLoadingService->SetDelegate(self); - urlLoadingService->SetBrowser(self.browser); +// Installs delegates for self.browser. +- (void)installDelegatesForBrowser { + UrlLoadingBrowserAgent* loadingAgent = + UrlLoadingBrowserAgent::FromBrowser(self.browser); + if (loadingAgent) { + loadingAgent->SetAppService(self.appURLLoadingService); + loadingAgent->SetDelegate(self); } } -// Uninstalls delegates for self.browserState. -- (void)uninstallDelegatesForBrowserState { - UrlLoadingService* urlLoadingService = - UrlLoadingServiceFactory::GetForBrowserState(self.browserState); - if (urlLoadingService) { - urlLoadingService->SetAppService(nullptr); - urlLoadingService->SetDelegate(nil); - urlLoadingService->SetBrowser(nil); +// Uninstalls delegates for self.browser. +- (void)uninstallDelegatesForBrowser { + UrlLoadingBrowserAgent* loadingAgent = + UrlLoadingBrowserAgent::FromBrowser(self.browser); + if (loadingAgent) { + loadingAgent->SetAppService(nullptr); + loadingAgent->SetDelegate(nil); } }
diff --git a/ios/chrome/browser/ui/browser_view/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view/browser_view_controller.mm index 4f6b332..3924d45 100644 --- a/ios/chrome/browser/ui/browser_view/browser_view_controller.mm +++ b/ios/chrome/browser/ui/browser_view/browser_view_controller.mm
@@ -151,11 +151,10 @@ #import "ios/chrome/browser/ui/voice/text_to_speech_playback_controller_factory.h" #include "ios/chrome/browser/upgrade/upgrade_center.h" #import "ios/chrome/browser/url_loading/image_search_param_generator.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_notifier_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_observer_bridge.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #import "ios/chrome/browser/url_loading/url_loading_util.h" #import "ios/chrome/browser/voice/voice_search_navigations_tab_helper.h" #import "ios/chrome/browser/web/blocked_popup_tab_helper.h" @@ -1168,7 +1167,7 @@ UrlLoadParams params = UrlLoadParams::InNewTab(GURL(kChromeUINewTabURL)); params.web_params.transition_type = ui::PAGE_TRANSITION_TYPED; params.in_incognito = self.isOffTheRecord; - UrlLoadingServiceFactory::GetForBrowserState(self.browserState)->Load(params); + UrlLoadingBrowserAgent::FromBrowser(self.browser)->Load(params); } - (void)appendTabAddedCompletion:(ProceduralBlock)tabAddedCompletion { @@ -3099,8 +3098,7 @@ params.in_incognito = strongSelf.isOffTheRecord; params.append_to = kCurrentTab; params.origin_point = originPoint; - UrlLoadingServiceFactory::GetForBrowserState(strongSelf.browserState) - ->Load(params); + UrlLoadingBrowserAgent::FromBrowser(self.browser)->Load(params); }; [_contextMenuCoordinator addItemWithTitle:title action:action]; if (!_isOffTheRecord) { @@ -3120,8 +3118,7 @@ params.web_params.referrer = referrer; params.in_incognito = YES; params.append_to = kCurrentTab; - UrlLoadingServiceFactory::GetForBrowserState(strongSelf.browserState) - ->Load(params); + UrlLoadingBrowserAgent::FromBrowser(self.browser)->Load(params); }; [_contextMenuCoordinator addItemWithTitle:title action:action]; } @@ -3188,7 +3185,7 @@ return; Record(ACTION_OPEN_IMAGE, isImage, isLink); - UrlLoadingServiceFactory::GetForBrowserState(strongSelf.browserState) + UrlLoadingBrowserAgent::FromBrowser(self.browser) ->Load(UrlLoadParams::InCurrentTab(imageUrl)); }; [_contextMenuCoordinator addItemWithTitle:title action:action]; @@ -3209,8 +3206,7 @@ params.in_incognito = strongSelf.isOffTheRecord; params.append_to = kCurrentTab; params.origin_point = originPoint; - UrlLoadingServiceFactory::GetForBrowserState(strongSelf.browserState) - ->Load(params); + UrlLoadingBrowserAgent::FromBrowser(self.browser)->Load(params); }; [_contextMenuCoordinator addItemWithTitle:title action:action]; @@ -3338,10 +3334,9 @@ if (inNewTab) { UrlLoadParams params = UrlLoadParams::InNewTab(webParams); params.in_incognito = self.isOffTheRecord; - UrlLoadingServiceFactory::GetForBrowserState(self.browserState) - ->Load(params); + UrlLoadingBrowserAgent::FromBrowser(self.browser)->Load(params); } else { - UrlLoadingServiceFactory::GetForBrowserState(self.browserState) + UrlLoadingBrowserAgent::FromBrowser(self.browser) ->Load(UrlLoadParams::InCurrentTab(webParams)); } } @@ -4079,7 +4074,7 @@ UrlLoadParams params = UrlLoadParams::InNewTab(helpUrl); params.append_to = kCurrentTab; params.user_initiated = NO; - UrlLoadingServiceFactory::GetForBrowserState(self.browserState)->Load(params); + UrlLoadingBrowserAgent::FromBrowser(self.browser)->Load(params); } - (void)showBookmarksManager {
diff --git a/ios/chrome/browser/ui/content_suggestions/BUILD.gn b/ios/chrome/browser/ui/content_suggestions/BUILD.gn index 65fe056..0ad695c 100644 --- a/ios/chrome/browser/ui/content_suggestions/BUILD.gn +++ b/ios/chrome/browser/ui/content_suggestions/BUILD.gn
@@ -208,6 +208,8 @@ "//components/signin/public/identity_manager", "//ios/chrome/browser", "//ios/chrome/browser/browser_state:test_support", + "//ios/chrome/browser/main:public", + "//ios/chrome/browser/main:test_support", "//ios/chrome/browser/ntp_snippets", "//ios/chrome/browser/search_engines", "//ios/chrome/browser/signin", @@ -222,6 +224,7 @@ "//ios/chrome/browser/ui/toolbar/test", "//ios/chrome/browser/ui/util", "//ios/chrome/browser/url_loading", + "//ios/chrome/browser/url_loading:test_support", "//ios/chrome/browser/voice:test_support", "//ios/chrome/browser/web_state_list", "//ios/chrome/browser/web_state_list:test_support",
diff --git a/ios/chrome/browser/ui/content_suggestions/content_suggestions_coordinator.mm b/ios/chrome/browser/ui/content_suggestions/content_suggestions_coordinator.mm index 45635e2b..2f5d6ac 100644 --- a/ios/chrome/browser/ui/content_suggestions/content_suggestions_coordinator.mm +++ b/ios/chrome/browser/ui/content_suggestions/content_suggestions_coordinator.mm
@@ -45,9 +45,8 @@ #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.h" #import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #import "ios/chrome/browser/voice/voice_search_availability.h" #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" #import "ios/public/provider/chrome/browser/url_loading_bridge.h" @@ -116,15 +115,14 @@ ntp_home::RecordNTPImpression(ntp_home::LOCAL_SUGGESTIONS); } - UrlLoadingService* urlLoadingService = - UrlLoadingServiceFactory::GetForBrowserState( - self.browser->GetBrowserState()); + UrlLoadingBrowserAgent* URLLoader = + UrlLoadingBrowserAgent::FromBrowser(self.browser); self.NTPMediator = [[NTPHomeMediator alloc] initWithWebState:self.webState templateURLService:ios::TemplateURLServiceFactory:: GetForBrowserState(self.browserState) - urlLoadingService:urlLoadingService + URLLoader:URLLoader authService:AuthenticationServiceFactory::GetForBrowserState( self.browserState) identityManager:IdentityManagerFactory::GetForBrowserState( @@ -294,8 +292,7 @@ UrlLoadParams params = UrlLoadParams::InCurrentTab(URL); params.web_params.transition_type = ui::PageTransitionFromInt( ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); - UrlLoadingServiceFactory::GetForBrowserState(self.browser->GetBrowserState()) - ->Load(params); + UrlLoadingBrowserAgent::FromBrowser(self.browser)->Load(params); } #pragma mark - Public methods
diff --git a/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator.h b/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator.h index 859f5b03..5e8c112 100644 --- a/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator.h +++ b/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator.h
@@ -36,7 +36,7 @@ @protocol OmniboxFocuser; class TemplateURLService; @protocol SnackbarCommands; -class UrlLoadingService; +class UrlLoadingBrowserAgent; class VoiceSearchAvailability; // Mediator for the NTP Home panel, handling the interactions with the @@ -49,7 +49,7 @@ - (nullable instancetype) initWithWebState:(nonnull web::WebState*)webState templateURLService:(nonnull TemplateURLService*)templateURLService - urlLoadingService:(nonnull UrlLoadingService*)urlLoadingService + URLLoader:(nonnull UrlLoadingBrowserAgent*)URLLoader authService:(nonnull AuthenticationService*)authService identityManager:(nonnull signin::IdentityManager*)identityManager logoVendor:(nonnull id<LogoVendor>)logoVendor
diff --git a/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator.mm b/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator.mm index f89dd086..ba9e886 100644 --- a/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator.mm +++ b/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator.mm
@@ -43,8 +43,8 @@ #import "ios/chrome/browser/ui/ntp/notification_promo_whats_new.h" #import "ios/chrome/browser/ui/toolbar/public/omnibox_focuser.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" #import "ios/chrome/browser/voice/voice_search_availability.h" #import "ios/chrome/common/ui/favicon/favicon_attributes.h" #include "ios/chrome/grit/ios_strings.h" @@ -80,7 +80,7 @@ std::unique_ptr<signin::IdentityManagerObserverBridge> _identityObserverBridge; // Used to load URLs. - UrlLoadingService* _urlLoadingService; + UrlLoadingBrowserAgent* _URLLoader; } @property(nonatomic, strong) AlertCoordinator* alertCoordinator; @@ -103,7 +103,7 @@ - (instancetype)initWithWebState:(web::WebState*)webState templateURLService:(TemplateURLService*)templateURLService - urlLoadingService:(UrlLoadingService*)urlLoadingService + URLLoader:(UrlLoadingBrowserAgent*)URLLoader authService:(AuthenticationService*)authService identityManager:(signin::IdentityManager*)identityManager logoVendor:(id<LogoVendor>)logoVendor @@ -113,7 +113,7 @@ if (self) { _webState = webState; _templateURLService = templateURLService; - _urlLoadingService = urlLoadingService; + _URLLoader = URLLoader; _authService = authService; _identityObserverBridge.reset( new signin::IdentityManagerObserverBridge(identityManager, self)); @@ -234,7 +234,7 @@ params.web_params.referrer = web::Referrer(GURL(ntp_snippets::GetContentSuggestionsReferrerURL()), web::ReferrerPolicyDefault); - _urlLoadingService->Load(params); + _URLLoader->Load(params); [self.NTPMetrics recordAction:new_tab_page_uma::ACTION_OPENED_SUGGESTION]; } @@ -280,7 +280,7 @@ UrlLoadParams params = UrlLoadParams::InCurrentTab(mostVisitedItem.URL); params.web_params.transition_type = ui::PAGE_TRANSITION_AUTO_BOOKMARK; - _urlLoadingService->Load(params); + _URLLoader->Load(params); } - (void)displayContextMenuForSuggestion:(CollectionViewItem*)item @@ -352,7 +352,7 @@ if (notificationPromo->IsURLPromo()) { UrlLoadParams params = UrlLoadParams::InNewTab(notificationPromo->url()); params.append_to = kCurrentTab; - _urlLoadingService->Load(params); + _URLLoader->Load(params); return; } @@ -371,7 +371,7 @@ NewTabPageTabHelper::FromWebState(self.webState); if (NTPHelper && NTPHelper->IgnoreLoadRequests()) return; - _urlLoadingService->Load(UrlLoadParams::InCurrentTab(GURL(kNTPHelpURL))); + _URLLoader->Load(UrlLoadParams::InCurrentTab(GURL(kNTPHelpURL))); [self.NTPMetrics recordAction:new_tab_page_uma::ACTION_OPENED_LEARN_MORE]; } @@ -541,7 +541,7 @@ params.in_incognito = incognito; params.append_to = kCurrentTab; params.origin_point = originPoint; - _urlLoadingService->Load(params); + _URLLoader->Load(params); } // Logs a histogram due to a Most Visited item being opened.
diff --git a/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator_unittest.mm b/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator_unittest.mm index 1ca74a0..cfec53a 100644 --- a/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator_unittest.mm +++ b/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator_unittest.mm
@@ -9,6 +9,8 @@ #include "components/signin/public/identity_manager/identity_manager.h" #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" #include "ios/chrome/browser/chrome_url_constants.h" +#import "ios/chrome/browser/main/browser.h" +#import "ios/chrome/browser/main/test_browser.h" #include "ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.h" #include "ios/chrome/browser/search_engines/template_url_service_factory.h" #include "ios/chrome/browser/signin/authentication_service_factory.h" @@ -23,9 +25,9 @@ #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.h" #import "ios/chrome/browser/ui/content_suggestions/ntp_home_consumer.h" #import "ios/chrome/browser/ui/toolbar/test/toolbar_test_navigation_manager.h" -#include "ios/chrome/browser/url_loading/test_url_loading_service.h" -#include "ios/chrome/browser/url_loading/url_loading_params.h" -#include "ios/chrome/browser/url_loading/url_loading_service_factory.h" +#import "ios/chrome/browser/url_loading/fake_url_loading_browser_agent.h" +#import "ios/chrome/browser/url_loading/url_loading_notifier_browser_agent.h" +#import "ios/chrome/browser/url_loading/url_loading_params.h" #import "ios/chrome/browser/voice/fake_voice_search_availability.h" #import "ios/public/provider/chrome/browser/ui/logo_vendor.h" #import "ios/web/public/test/fakes/test_web_state.h" @@ -52,13 +54,11 @@ IOSChromeContentSuggestionsServiceFactory::GetInstance(), IOSChromeContentSuggestionsServiceFactory::GetDefaultFactory()); test_cbs_builder.AddTestingFactory( - UrlLoadingServiceFactory::GetInstance(), - UrlLoadingServiceFactory::GetDefaultFactory()); - test_cbs_builder.AddTestingFactory( AuthenticationServiceFactory::GetInstance(), base::BindRepeating( &AuthenticationServiceFake::CreateAuthenticationService)); chrome_browser_state_ = test_cbs_builder.Build(); + browser_ = std::make_unique<TestBrowser>(chrome_browser_state_.get()); std::unique_ptr<ToolbarTestNavigationManager> navigation_manager = std::make_unique<ToolbarTestNavigationManager>(); @@ -69,9 +69,12 @@ suggestions_view_controller_ = OCMClassMock([ContentSuggestionsViewController class]); voice_availability_.SetVoiceProviderEnabled(true); - url_loader_ = - (TestUrlLoadingService*)UrlLoadingServiceFactory::GetForBrowserState( - chrome_browser_state_.get()); + + UrlLoadingNotifierBrowserAgent::CreateForBrowser(browser_.get()); + FakeUrlLoadingBrowserAgent::InjectForBrowser(browser_.get()); + url_loader_ = FakeUrlLoadingBrowserAgent::FromUrlLoadingBrowserAgent( + UrlLoadingBrowserAgent::FromBrowser(browser_.get())); + auth_service_ = static_cast<AuthenticationServiceFake*>( AuthenticationServiceFactory::GetInstance()->GetForBrowserState( chrome_browser_state_.get())); @@ -82,7 +85,7 @@ templateURLService:ios::TemplateURLServiceFactory:: GetForBrowserState( chrome_browser_state_.get()) - urlLoadingService:url_loader_ + URLLoader:url_loader_ authService:auth_service_ identityManager:identity_manager_ logoVendor:logo_vendor_ @@ -102,6 +105,7 @@ protected: web::WebTaskEnvironment task_environment_; std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; + std::unique_ptr<Browser> browser_; id consumer_; id logo_vendor_; id dispatcher_; @@ -109,7 +113,7 @@ FakeVoiceSearchAvailability voice_availability_; NTPHomeMediator* mediator_; ToolbarTestNavigationManager* navigation_manager_; - TestUrlLoadingService* url_loader_; + FakeUrlLoadingBrowserAgent* url_loader_; AuthenticationServiceFake* auth_service_; signin::IdentityManager* identity_manager_;
diff --git a/ios/chrome/browser/ui/history/history_clear_browsing_data_coordinator.mm b/ios/chrome/browser/ui/history/history_clear_browsing_data_coordinator.mm index b6ad6ba4..31ee2c7d 100644 --- a/ios/chrome/browser/ui/history/history_clear_browsing_data_coordinator.mm +++ b/ios/chrome/browser/ui/history/history_clear_browsing_data_coordinator.mm
@@ -16,9 +16,8 @@ #import "ios/chrome/browser/ui/table_view/table_view_navigation_controller.h" #import "ios/chrome/browser/ui/table_view/table_view_presentation_controller.h" #import "ios/chrome/browser/ui/table_view/table_view_presentation_controller_delegate.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #import "ios/web/public/navigation/referrer.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -123,9 +122,7 @@ params.load_strategy = self.loadStrategy; [self stopWithCompletion:^() { [self.delegate dismissHistoryWithCompletion:^{ - UrlLoadingServiceFactory::GetForBrowserState( - self.browser->GetBrowserState()) - ->Load(params); + UrlLoadingBrowserAgent::FromBrowser(self.browser)->Load(params); [self.presentationDelegate showActiveRegularTabFromHistory]; }]; }];
diff --git a/ios/chrome/browser/ui/history/history_table_view_controller.mm b/ios/chrome/browser/ui/history/history_table_view_controller.mm index 4dc71c1..39c026a 100644 --- a/ios/chrome/browser/ui/history/history_table_view_controller.mm +++ b/ios/chrome/browser/ui/history/history_table_view_controller.mm
@@ -34,9 +34,8 @@ #import "ios/chrome/browser/ui/table_view/table_view_favicon_data_source.h" #import "ios/chrome/browser/ui/table_view/table_view_navigation_controller_constants.h" #import "ios/chrome/browser/ui/util/pasteboard_util.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #include "ios/chrome/browser/web_state_list/web_state_list.h" #import "ios/chrome/common/ui/colors/UIColor+cr_semantic_colors.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h" @@ -1044,8 +1043,7 @@ base::UserMetricsAction("MobileHistoryPage_EntryLinkOpenNewTab")); UrlLoadParams params = UrlLoadParams::InNewTab(URL); [self.delegate dismissHistoryWithCompletion:^{ - UrlLoadingServiceFactory::GetForBrowserState(_browser->GetBrowserState()) - ->Load(params); + UrlLoadingBrowserAgent::FromBrowser(_browser)->Load(params); [self.presentationDelegate showActiveRegularTabFromHistory]; }]; } @@ -1057,8 +1055,7 @@ UrlLoadParams params = UrlLoadParams::InNewTab(URL); params.in_incognito = YES; [self.delegate dismissHistoryWithCompletion:^{ - UrlLoadingServiceFactory::GetForBrowserState(_browser->GetBrowserState()) - ->Load(params); + UrlLoadingBrowserAgent::FromBrowser(_browser)->Load(params); [self.presentationDelegate showActiveIncognitoTabFromHistory]; }]; } @@ -1075,8 +1072,7 @@ params.web_params.transition_type = ui::PAGE_TRANSITION_AUTO_BOOKMARK; params.load_strategy = self.loadStrategy; [self.delegate dismissHistoryWithCompletion:^{ - UrlLoadingServiceFactory::GetForBrowserState(_browser->GetBrowserState()) - ->Load(params); + UrlLoadingBrowserAgent::FromBrowser(_browser)->Load(params); [self.presentationDelegate showActiveRegularTabFromHistory]; }]; }
diff --git a/ios/chrome/browser/ui/location_bar/BUILD.gn b/ios/chrome/browser/ui/location_bar/BUILD.gn index 56797e6..367110a7 100644 --- a/ios/chrome/browser/ui/location_bar/BUILD.gn +++ b/ios/chrome/browser/ui/location_bar/BUILD.gn
@@ -161,6 +161,7 @@ "//ios/chrome/browser/ui/toolbar", "//ios/chrome/browser/ui/toolbar/test", "//ios/chrome/browser/url_loading", + "//ios/chrome/browser/url_loading:test_support", "//ios/chrome/browser/web_state_list", "//ios/chrome/browser/web_state_list:test_support", "//ios/chrome/test/fakes",
diff --git a/ios/chrome/browser/ui/location_bar/location_bar_coordinator.mm b/ios/chrome/browser/ui/location_bar/location_bar_coordinator.mm index d2a9e42..55a4b26 100644 --- a/ios/chrome/browser/ui/location_bar/location_bar_coordinator.mm +++ b/ios/chrome/browser/ui/location_bar/location_bar_coordinator.mm
@@ -45,9 +45,8 @@ #include "ios/chrome/browser/ui/omnibox/web_omnibox_edit_controller_impl.h" #import "ios/chrome/browser/ui/toolbar/toolbar_coordinator_delegate.h" #import "ios/chrome/browser/ui/util/pasteboard_util.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #import "ios/chrome/browser/url_loading/url_loading_util.h" #import "ios/chrome/browser/web/web_navigation_util.h" #import "ios/chrome/browser/web_state_list/web_state_list.h" @@ -293,8 +292,7 @@ web_params.extra_headers = [combinedExtraHeaders copy]; UrlLoadParams params = UrlLoadParams::InCurrentTab(web_params); params.disposition = disposition; - UrlLoadingServiceFactory::GetForBrowserState(self.browserState) - ->Load(params); + UrlLoadingBrowserAgent::FromBrowser(self.browser)->Load(params); if (google_util::IsGoogleSearchUrl(url)) { UMA_HISTOGRAM_ENUMERATION( @@ -460,8 +458,7 @@ UrlLoadParams params = UrlLoadParams::InCurrentTab(searchURL); params.web_params.transition_type = ui::PageTransitionFromInt( ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); - UrlLoadingServiceFactory::GetForBrowserState(self.browserState) - ->Load(params); + UrlLoadingBrowserAgent::FromBrowser(self.browser)->Load(params); } }
diff --git a/ios/chrome/browser/ui/location_bar/location_bar_coordinator_unittest.mm b/ios/chrome/browser/ui/location_bar/location_bar_coordinator_unittest.mm index b6ad669..d9840268 100644 --- a/ios/chrome/browser/ui/location_bar/location_bar_coordinator_unittest.mm +++ b/ios/chrome/browser/ui/location_bar/location_bar_coordinator_unittest.mm
@@ -19,9 +19,9 @@ #import "ios/chrome/browser/main/test_browser.h" #include "ios/chrome/browser/search_engines/template_url_service_factory.h" #import "ios/chrome/browser/ui/toolbar/toolbar_coordinator_delegate.h" -#include "ios/chrome/browser/url_loading/test_url_loading_service.h" -#include "ios/chrome/browser/url_loading/url_loading_params.h" -#include "ios/chrome/browser/url_loading/url_loading_service_factory.h" +#import "ios/chrome/browser/url_loading/fake_url_loading_browser_agent.h" +#import "ios/chrome/browser/url_loading/url_loading_notifier_browser_agent.h" +#import "ios/chrome/browser/url_loading/url_loading_params.h" #include "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h" #include "ios/chrome/browser/web_state_list/web_state_list.h" #import "ios/chrome/browser/web_state_list/web_state_opener.h" @@ -81,9 +81,6 @@ ios::AutocompleteClassifierFactory::GetInstance(), ios::AutocompleteClassifierFactory::GetDefaultFactory()); test_cbs_builder.AddTestingFactory( - UrlLoadingServiceFactory::GetInstance(), - UrlLoadingServiceFactory::GetDefaultFactory()); - test_cbs_builder.AddTestingFactory( IOSChromeFaviconLoaderFactory::GetInstance(), IOSChromeFaviconLoaderFactory::GetDefaultFactory()); test_cbs_builder.AddTestingFactory( @@ -98,6 +95,8 @@ browser_ = std::make_unique<TestBrowser>(browser_state_.get(), &web_state_list_); + UrlLoadingNotifierBrowserAgent::CreateForBrowser(browser_.get()); + FakeUrlLoadingBrowserAgent::InjectForBrowser(browser_.get()); auto web_state = std::make_unique<web::TestWebState>(); web_state->SetBrowserState(browser_state_.get()); @@ -168,10 +167,9 @@ transition:transition disposition:disposition]; - TestUrlLoadingService* url_loader = - (TestUrlLoadingService*)UrlLoadingServiceFactory::GetForBrowserState( - browser_state_.get()); - + FakeUrlLoadingBrowserAgent* url_loader = + FakeUrlLoadingBrowserAgent::FromUrlLoadingBrowserAgent( + UrlLoadingBrowserAgent::FromBrowser(browser_.get())); EXPECT_EQ(url, url_loader->last_params.web_params.url); EXPECT_TRUE(url_loader->last_params.web_params.referrer.url.is_empty()); EXPECT_EQ(web::ReferrerPolicyDefault, @@ -203,9 +201,9 @@ transition:transition disposition:disposition]; - TestUrlLoadingService* url_loader = - (TestUrlLoadingService*)UrlLoadingServiceFactory::GetForBrowserState( - browser_state_.get()); + FakeUrlLoadingBrowserAgent* url_loader = + FakeUrlLoadingBrowserAgent::FromUrlLoadingBrowserAgent( + UrlLoadingBrowserAgent::FromBrowser(browser_.get())); EXPECT_EQ(url, url_loader->last_params.web_params.url); EXPECT_TRUE(url_loader->last_params.web_params.referrer.url.is_empty());
diff --git a/ios/chrome/browser/ui/main/scene_controller.mm b/ios/chrome/browser/ui/main/scene_controller.mm index 4bdabb9c..3c21eb9 100644 --- a/ios/chrome/browser/ui/main/scene_controller.mm +++ b/ios/chrome/browser/ui/main/scene_controller.mm
@@ -61,9 +61,8 @@ #import "ios/chrome/browser/ui/util/top_view_controller.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/url_loading/app_url_loading_service.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #import "ios/chrome/browser/web_state_list/web_state_list.h" #import "ios/chrome/browser/web_state_list/web_state_list_observer_bridge.h" #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" @@ -1308,8 +1307,7 @@ [targetInterface.bvc appendTabAddedCompletion:tabOpenedCompletion]; UrlLoadParams savedParams = urlLoadParams; savedParams.in_incognito = targetMode == ApplicationMode::INCOGNITO; - UrlLoadingServiceFactory::GetForBrowserState( - [targetInterface.bvc browserState]) + UrlLoadingBrowserAgent::FromBrowser(targetInterface.browser) ->Load(savedParams); } else { // Voice search, QRScanner and the omnibox are presented by the BVC. @@ -1386,12 +1384,13 @@ - (void)openOrReuseTabInMode:(ApplicationMode)targetMode withUrlLoadParams:(const UrlLoadParams&)urlLoadParams tabOpenedCompletion:(ProceduralBlock)tabOpenedCompletion { - BrowserViewController* targetBVC = - targetMode == ApplicationMode::NORMAL - ? self.browserViewWrangler.mainInterface.bvc - : self.browserViewWrangler.incognitoInterface.bvc; + id<BrowserInterface> targetInterface = targetMode == ApplicationMode::NORMAL + ? self.mainInterface + : self.incognitoInterface; + + BrowserViewController* targetBVC = targetInterface.bvc; web::WebState* currentWebState = - targetBVC.tabModel.webStateList->GetActiveWebState(); + targetInterface.browser->GetWebStateList()->GetActiveWebState(); // Don't call loadWithParams for chrome://newtab when it's already loaded. // Note that it's safe to use -GetVisibleURL here, as it doesn't matter if the @@ -1418,7 +1417,7 @@ UrlLoadParams newTabParams = urlLoadParams; newTabParams.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; newTabParams.in_incognito = targetMode == ApplicationMode::INCOGNITO; - UrlLoadingServiceFactory::GetForBrowserState([targetBVC browserState]) + UrlLoadingBrowserAgent::FromBrowser(targetInterface.browser) ->Load(newTabParams); return; } @@ -1426,7 +1425,7 @@ // Otherwise, load |urlLoadParams| in the current tab. UrlLoadParams sameTabParams = urlLoadParams; sameTabParams.disposition = WindowOpenDisposition::CURRENT_TAB; - UrlLoadingServiceFactory::GetForBrowserState([targetBVC browserState]) + UrlLoadingBrowserAgent::FromBrowser(targetInterface.browser) ->Load(sameTabParams); if (tabOpenedCompletion) { tabOpenedCompletion();
diff --git a/ios/chrome/browser/ui/ntp/incognito_view.h b/ios/chrome/browser/ui/ntp/incognito_view.h index 54dbd9e..32133e2 100644 --- a/ios/chrome/browser/ui/ntp/incognito_view.h +++ b/ios/chrome/browser/ui/ntp/incognito_view.h
@@ -7,14 +7,14 @@ #import <UIKit/UIKit.h> -class UrlLoadingService; +class UrlLoadingBrowserAgent; // The scrollview containing the views. Its content's size is constrained on its // superview's size. @interface IncognitoView : UIScrollView - (instancetype)initWithFrame:(CGRect)frame - urlLoadingService:(UrlLoadingService*)urlLoadingService; + URLLoader:(UrlLoadingBrowserAgent*)URLLoader; @end
diff --git a/ios/chrome/browser/ui/ntp/incognito_view.mm b/ios/chrome/browser/ui/ntp/incognito_view.mm index 6eac9616..2cfb4f3 100644 --- a/ios/chrome/browser/ui/ntp/incognito_view.mm +++ b/ios/chrome/browser/ui/ntp/incognito_view.mm
@@ -12,8 +12,8 @@ #include "ios/chrome/browser/ui/util/rtl_geometry.h" #include "ios/chrome/browser/ui/util/ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" #import "ios/chrome/common/string_util.h" #import "ios/chrome/common/ui/colors/dynamic_color_util.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h" @@ -138,14 +138,13 @@ NSArray<NSLayoutConstraint*>* _superViewConstraints; // The UrlLoadingService associated with this view. - UrlLoadingService* _urlLoadingService; // weak + UrlLoadingBrowserAgent* _URLLoader; // weak } - - (instancetype)initWithFrame:(CGRect)frame - urlLoadingService:(UrlLoadingService*)urlLoadingService { + URLLoader:(UrlLoadingBrowserAgent*)URLLoader { self = [super initWithFrame:frame]; if (self) { - _urlLoadingService = urlLoadingService; + _URLLoader = URLLoader; self.alwaysBounceVertical = YES; // The bottom safe area is taken care of with the bottomUnsafeArea guides. @@ -353,7 +352,7 @@ // Triggers a navigation to the help page. - (void)learnMoreButtonPressed { - _urlLoadingService->Load(UrlLoadParams::InCurrentTab( + _URLLoader->Load(UrlLoadParams::InCurrentTab( GetUrlWithLang(GURL(kLearnMoreIncognitoUrl)))); }
diff --git a/ios/chrome/browser/ui/ntp/incognito_view_controller.h b/ios/chrome/browser/ui/ntp/incognito_view_controller.h index 1599cbe0..4b0fa85 100644 --- a/ios/chrome/browser/ui/ntp/incognito_view_controller.h +++ b/ios/chrome/browser/ui/ntp/incognito_view_controller.h
@@ -7,7 +7,7 @@ #import <UIKit/UIKit.h> -class UrlLoadingService; +class UrlLoadingBrowserAgent; @protocol NewTabPageControllerDelegate; @@ -15,7 +15,7 @@ // Init with the given loader object. |loader| may be nil, but isn't // retained so it must outlive this controller. -- (id)initWithUrlLoadingService:(UrlLoadingService*)urlLoadingService; +- (instancetype)initWithUrlLoader:(UrlLoadingBrowserAgent*)URLLoader; @end
diff --git a/ios/chrome/browser/ui/ntp/incognito_view_controller.mm b/ios/chrome/browser/ui/ntp/incognito_view_controller.mm index a0dc7750..6a9ea07 100644 --- a/ios/chrome/browser/ui/ntp/incognito_view_controller.mm +++ b/ios/chrome/browser/ui/ntp/incognito_view_controller.mm
@@ -10,7 +10,7 @@ #import "ios/chrome/browser/ui/commands/browser_commands.h" #import "ios/chrome/browser/ui/ntp/incognito_view.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/common/ui/colors/dynamic_color_util.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h" @@ -25,13 +25,13 @@ @implementation IncognitoViewController { // The UrlLoadingService associated with this view. - UrlLoadingService* _urlLoadingService; // weak + UrlLoadingBrowserAgent* _URLLoader; // weak } -- (id)initWithUrlLoadingService:(UrlLoadingService*)urlLoadingService { +- (instancetype)initWithUrlLoader:(UrlLoadingBrowserAgent*)URLLoader { self = [super init]; if (self) { - _urlLoadingService = urlLoadingService; + _URLLoader = URLLoader; } return self; } @@ -42,7 +42,7 @@ } self.incognitoView = [[IncognitoView alloc] initWithFrame:self.view.bounds - urlLoadingService:_urlLoadingService]; + URLLoader:_URLLoader]; [self.incognitoView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];
diff --git a/ios/chrome/browser/ui/ntp/new_tab_page_coordinator.mm b/ios/chrome/browser/ui/ntp/new_tab_page_coordinator.mm index b9b7307..07a2447 100644 --- a/ios/chrome/browser/ui/ntp/new_tab_page_coordinator.mm +++ b/ios/chrome/browser/ui/ntp/new_tab_page_coordinator.mm
@@ -11,7 +11,7 @@ #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_coordinator.h" #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_header_view_controller.h" #import "ios/chrome/browser/ui/ntp/incognito_view_controller.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/web/public/navigation/navigation_context.h" #import "ios/web/public/navigation/navigation_item.h" #import "ios/web/public/navigation/navigation_manager.h" @@ -50,11 +50,10 @@ if (self.browser->GetBrowserState()->IsOffTheRecord()) { DCHECK(!self.incognitoViewController); - UrlLoadingService* urlLoadingService = - UrlLoadingServiceFactory::GetForBrowserState( - self.browser->GetBrowserState()); - self.incognitoViewController = [[IncognitoViewController alloc] - initWithUrlLoadingService:urlLoadingService]; + UrlLoadingBrowserAgent* URLLoader = + UrlLoadingBrowserAgent::FromBrowser(self.browser); + self.incognitoViewController = + [[IncognitoViewController alloc] initWithUrlLoader:URLLoader]; } else { DCHECK(!self.contentSuggestionsCoordinator); self.contentSuggestionsCoordinator = [[ContentSuggestionsCoordinator alloc]
diff --git a/ios/chrome/browser/ui/page_info/BUILD.gn b/ios/chrome/browser/ui/page_info/BUILD.gn index 96351608..26ef867 100644 --- a/ios/chrome/browser/ui/page_info/BUILD.gn +++ b/ios/chrome/browser/ui/page_info/BUILD.gn
@@ -97,7 +97,6 @@ "//ios/chrome/browser/ui/coordinators:chrome_coordinators", "//ios/chrome/browser/ui/fullscreen:coordinators", "//ios/chrome/browser/ui/page_info/requirements", - "//ios/chrome/browser/url_loading", "//ios/chrome/browser/web_state_list", "//ios/web", "//ios/web/public",
diff --git a/ios/chrome/browser/ui/page_info/page_info_legacy_coordinator.mm b/ios/chrome/browser/ui/page_info/page_info_legacy_coordinator.mm index 4bb7eb81..bbd872e 100644 --- a/ios/chrome/browser/ui/page_info/page_info_legacy_coordinator.mm +++ b/ios/chrome/browser/ui/page_info/page_info_legacy_coordinator.mm
@@ -21,9 +21,6 @@ #import "ios/chrome/browser/ui/page_info/page_info_constants.h" #import "ios/chrome/browser/ui/page_info/page_info_site_security_mediator.h" #import "ios/chrome/browser/ui/page_info/requirements/page_info_presentation.h" -#import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #import "ios/chrome/browser/web_state_list/web_state_list.h" #include "ios/web/public/navigation/navigation_item.h" #include "ios/web/public/navigation/navigation_manager.h"
diff --git a/ios/chrome/browser/ui/qr_scanner/qr_scanner_app_interface.mm b/ios/chrome/browser/ui/qr_scanner/qr_scanner_app_interface.mm index 8778be98..19e9e30 100644 --- a/ios/chrome/browser/ui/qr_scanner/qr_scanner_app_interface.mm +++ b/ios/chrome/browser/ui/qr_scanner/qr_scanner_app_interface.mm
@@ -16,9 +16,8 @@ #include "ios/chrome/browser/ui/qr_scanner/qr_scanner_camera_controller.h" #include "ios/chrome/browser/ui/qr_scanner/qr_scanner_view_controller.h" #include "ios/chrome/browser/ui/scanner/camera_controller.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #include "ios/chrome/grit/ios_chromium_strings.h" #include "ios/chrome/grit/ios_strings.h" #import "ios/chrome/test/app/chrome_test_util.h" @@ -60,19 +59,15 @@ + (id)locationBarCoordinatorLoadGURLFromLocationBarSwizzleBlockForSearchURL: (NSURL*)searchURL { GURL searchGURL = net::GURLWithNSURL(searchURL); - void (^loadGURLFromLocationBarBlock)(LocationBarCoordinator*, - TemplateURLRef::PostContent*, - const GURL&, ui::PageTransition) = - ^void(LocationBarCoordinator* self, - TemplateURLRef::PostContent* postContent, const GURL& url, - ui::PageTransition transition) { - web::NavigationManager::WebLoadParams params(searchGURL); - params.transition_type = transition; - UrlLoadingServiceFactory::GetForBrowserState( - self.browser->GetBrowserState()) - ->Load(UrlLoadParams::InCurrentTab(params)); - [self cancelOmniboxEdit]; - }; + auto loadGURLFromLocationBarBlock = ^void( + LocationBarCoordinator* self, TemplateURLRef::PostContent* postContent, + const GURL& url, ui::PageTransition transition) { + web::NavigationManager::WebLoadParams params(searchGURL); + params.transition_type = transition; + UrlLoadingBrowserAgent::FromBrowser(self.browser) + ->Load(UrlLoadParams::InCurrentTab(params)); + [self cancelOmniboxEdit]; + }; return loadGURLFromLocationBarBlock; }
diff --git a/ios/chrome/browser/ui/reading_list/reading_list_coordinator.mm b/ios/chrome/browser/ui/reading_list/reading_list_coordinator.mm index b81cf88..2f40231 100644 --- a/ios/chrome/browser/ui/reading_list/reading_list_coordinator.mm +++ b/ios/chrome/browser/ui/reading_list/reading_list_coordinator.mm
@@ -34,9 +34,8 @@ #import "ios/chrome/browser/ui/table_view/table_view_navigation_controller_constants.h" #import "ios/chrome/browser/ui/table_view/table_view_presentation_controller.h" #import "ios/chrome/browser/ui/util/pasteboard_util.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #include "ios/chrome/browser/web_state_list/web_state_list.h" #include "ios/chrome/grit/ios_strings.h" #include "ios/web/public/navigation/referrer.h" @@ -385,15 +384,13 @@ params.in_incognito = incognito; params.web_params.referrer = web::Referrer(GURL(kReadingListReferrerURL), web::ReferrerPolicyDefault); - UrlLoadingServiceFactory::GetForBrowserState(self.browserState) - ->Load(params); + UrlLoadingBrowserAgent::FromBrowser(self.browser)->Load(params); } else { UrlLoadParams params = UrlLoadParams::InCurrentTab(loadURL); params.web_params.transition_type = ui::PAGE_TRANSITION_AUTO_BOOKMARK; params.web_params.referrer = web::Referrer(GURL(kReadingListReferrerURL), web::ReferrerPolicyDefault); - UrlLoadingServiceFactory::GetForBrowserState(self.browserState) - ->Load(params); + UrlLoadingBrowserAgent::FromBrowser(self.browser)->Load(params); } [self stop];
diff --git a/ios/chrome/browser/ui/recent_tabs/recent_tabs_coordinator.mm b/ios/chrome/browser/ui/recent_tabs/recent_tabs_coordinator.mm index 6678169..94b1e4b 100644 --- a/ios/chrome/browser/ui/recent_tabs/recent_tabs_coordinator.mm +++ b/ios/chrome/browser/ui/recent_tabs/recent_tabs_coordinator.mm
@@ -19,9 +19,8 @@ #import "ios/chrome/browser/ui/table_view/feature_flags.h" #import "ios/chrome/browser/ui/table_view/table_view_navigation_controller.h" #import "ios/chrome/browser/ui/table_view/table_view_navigation_controller_constants.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support."
diff --git a/ios/chrome/browser/ui/recent_tabs/recent_tabs_table_view_controller.mm b/ios/chrome/browser/ui/recent_tabs/recent_tabs_table_view_controller.mm index 703e892..5e780b3 100644 --- a/ios/chrome/browser/ui/recent_tabs/recent_tabs_table_view_controller.mm +++ b/ios/chrome/browser/ui/recent_tabs/recent_tabs_table_view_controller.mm
@@ -48,9 +48,8 @@ #include "ios/chrome/browser/ui/ui_feature_flags.h" #include "ios/chrome/browser/ui/util/ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #import "ios/chrome/browser/url_loading/url_loading_util.h" #include "ios/chrome/browser/web_state_list/web_state_list.h" #include "ios/chrome/browser/web_state_list/web_state_opener.h" @@ -1107,7 +1106,7 @@ params.web_params.transition_type = ui::PAGE_TRANSITION_AUTO_BOOKMARK; params.load_strategy = self.loadStrategy; params.in_incognito = self.isIncognito; - UrlLoadingServiceFactory::GetForBrowserState(_browserState)->Load(params); + UrlLoadingBrowserAgent::FromBrowser(self.browser)->Load(params); } UMA_HISTOGRAM_COUNTS_100( "Mobile.RecentTabsManager.TotalTabsFromOtherDevicesOpenAll",
diff --git a/ios/chrome/browser/ui/settings/google_services/BUILD.gn b/ios/chrome/browser/ui/settings/google_services/BUILD.gn index fd4130ad..6df9103 100644 --- a/ios/chrome/browser/ui/settings/google_services/BUILD.gn +++ b/ios/chrome/browser/ui/settings/google_services/BUILD.gn
@@ -40,6 +40,8 @@ "//components/metrics", "//components/password_manager/core/common", "//components/prefs", + "//components/safe_browsing/core:features", + "//components/safe_browsing/core/common:safe_browsing_prefs", "//components/signin/public/identity_manager", "//components/signin/public/identity_manager/objc", "//components/strings", @@ -74,6 +76,7 @@ "//ios/public/provider/chrome/browser", "//ios/public/provider/chrome/browser/images", "//ios/public/provider/chrome/browser/signin", + "//ios/web/common:features", "//ui/base", ] allow_circular_includes_from = [
diff --git a/ios/chrome/browser/ui/settings/google_services/google_services_settings_mediator.mm b/ios/chrome/browser/ui/settings/google_services/google_services_settings_mediator.mm index 92356d3..9b00301 100644 --- a/ios/chrome/browser/ui/settings/google_services/google_services_settings_mediator.mm +++ b/ios/chrome/browser/ui/settings/google_services/google_services_settings_mediator.mm
@@ -10,6 +10,8 @@ #include "components/password_manager/core/common/password_manager_features.h" #include "components/password_manager/core/common/password_manager_pref_names.h" #include "components/prefs/pref_service.h" +#include "components/safe_browsing/core/common/safe_browsing_prefs.h" +#include "components/safe_browsing/core/features.h" #import "components/signin/public/identity_manager/objc/identity_manager_observer_bridge.h" #include "components/sync/driver/sync_service.h" #include "components/ukm/ios/features.h" @@ -44,6 +46,7 @@ #endif using l10n_util::GetNSString; +using safe_browsing::kSafeBrowsingAvailableOnIOS; typedef NSArray<TableViewItem*>* ItemArray; @@ -80,6 +83,7 @@ ManageSyncItemType, // NonPersonalizedSectionIdentifier section. AutocompleteSearchesAndURLsItemType, + SafeBrowsingItemType, ImproveChromeItemType, BetterSearchAndBrowsingItemType, ItemTypePasswordLeakCheckSwitch, @@ -135,6 +139,9 @@ // Preference value for the "Autocomplete searches and URLs" feature. @property(nonatomic, strong, readonly) PrefBackedBoolean* autocompleteSearchPreference; +// Preference value for the "Safe Browsing" feature. +@property(nonatomic, strong, readonly) + PrefBackedBoolean* safeBrowsingPreference; // Preference value for the "Help improve Chromium's features" feature. @property(nonatomic, strong, readonly) PrefBackedBoolean* sendDataUsagePreference; @@ -179,6 +186,12 @@ initWithPrefService:userPrefService prefName:prefs::kSearchSuggestEnabled]; _autocompleteSearchPreference.observer = self; + if (base::FeatureList::IsEnabled(kSafeBrowsingAvailableOnIOS)) { + _safeBrowsingPreference = [[PrefBackedBoolean alloc] + initWithPrefService:userPrefService + prefName:prefs::kSafeBrowsingEnabled]; + _safeBrowsingPreference.observer = self; + } _sendDataUsagePreference = [[PrefBackedBoolean alloc] initWithPrefService:localPrefService prefName:metrics::prefs::kMetricsReportingEnabled]; @@ -510,6 +523,9 @@ case AutocompleteSearchesAndURLsItemType: switchItem.on = self.autocompleteSearchPreference.value; break; + case SafeBrowsingItemType: + switchItem.on = self.safeBrowsingPreference.value; + break; case ImproveChromeItemType: switchItem.on = self.sendDataUsagePreference.value; break; @@ -563,13 +579,26 @@ - (ItemArray)nonPersonalizedItems { if (!_nonPersonalizedItems) { - SyncSwitchItem* autocompleteSearchesAndURLsItem = [self + NSMutableArray* items = [NSMutableArray array]; + SyncSwitchItem* autocompleteItem = [self switchItemWithItemType:AutocompleteSearchesAndURLsItemType textStringID: - IDS_IOS_GOOGLE_SERVICES_SETTINGS_AUTOCOMPLETE_SEARCHES_AND_URLS_TEXT + IDS_IOS_GOOGLE_SERVICES_SETTINGS_AUTOCOMPLETE_SEARCHES_AND_URLS_TEXT detailStringID: - IDS_IOS_GOOGLE_SERVICES_SETTINGS_AUTOCOMPLETE_SEARCHES_AND_URLS_DETAIL + IDS_IOS_GOOGLE_SERVICES_SETTINGS_AUTOCOMPLETE_SEARCHES_AND_URLS_DETAIL dataType:0]; + [items addObject:autocompleteItem]; + if (base::FeatureList::IsEnabled(kSafeBrowsingAvailableOnIOS)) { + SyncSwitchItem* safeBrowsingItem = [self + switchItemWithItemType:SafeBrowsingItemType + textStringID: + IDS_IOS_GOOGLE_SERVICES_SETTINGS_SAFE_BROWSING_TEXT + detailStringID: + IDS_IOS_GOOGLE_SERVICES_SETTINGS_SAFE_BROWSING_DETAIL + dataType:0]; + [items addObject:safeBrowsingItem]; + } + [items addObject:self.passwordLeakCheckItem]; SyncSwitchItem* improveChromeItem = [self switchItemWithItemType:ImproveChromeItemType textStringID: @@ -577,19 +606,18 @@ detailStringID: IDS_IOS_GOOGLE_SERVICES_SETTINGS_IMPROVE_CHROME_DETAIL dataType:0]; + [items addObject:improveChromeItem]; SyncSwitchItem* betterSearchAndBrowsingItemType = [self switchItemWithItemType:BetterSearchAndBrowsingItemType textStringID: - IDS_IOS_GOOGLE_SERVICES_SETTINGS_BETTER_SEARCH_AND_BROWSING_TEXT + IDS_IOS_GOOGLE_SERVICES_SETTINGS_BETTER_SEARCH_AND_BROWSING_TEXT detailStringID: - IDS_IOS_GOOGLE_SERVICES_SETTINGS_BETTER_SEARCH_AND_BROWSING_DETAIL + IDS_IOS_GOOGLE_SERVICES_SETTINGS_BETTER_SEARCH_AND_BROWSING_DETAIL dataType:0]; betterSearchAndBrowsingItemType.accessibilityIdentifier = kBetterSearchAndBrowsingItemAccessibilityID; - _nonPersonalizedItems = @[ - autocompleteSearchesAndURLsItem, self.passwordLeakCheckItem, - improveChromeItem, betterSearchAndBrowsingItemType - ]; + [items addObject:betterSearchAndBrowsingItemType]; + _nonPersonalizedItems = items; } return _nonPersonalizedItems; } @@ -732,6 +760,9 @@ case AutocompleteSearchesAndURLsItemType: self.autocompleteSearchPreference.value = value; break; + case SafeBrowsingItemType: + self.safeBrowsingPreference.value = value; + break; case ImproveChromeItemType: self.sendDataUsagePreference.value = value; // Don't set value if sendDataUsageWifiOnlyPreference has not been @@ -810,6 +841,7 @@ case SyncDisabledByAdministratorErrorItemType: case SyncSettingsNotCofirmedErrorItemType: case AutocompleteSearchesAndURLsItemType: + case SafeBrowsingItemType: case ItemTypePasswordLeakCheckSwitch: case ImproveChromeItemType: case BetterSearchAndBrowsingItemType:
diff --git a/ios/chrome/browser/url_loading/BUILD.gn b/ios/chrome/browser/url_loading/BUILD.gn index bf3aaec..5b6c02f 100644 --- a/ios/chrome/browser/url_loading/BUILD.gn +++ b/ios/chrome/browser/url_loading/BUILD.gn
@@ -11,18 +11,14 @@ "image_search_param_generator.mm", "test_app_url_loading_service.h", "test_app_url_loading_service.mm", - "test_url_loading_service.h", - "test_url_loading_service.mm", + "url_loading_browser_agent.h", + "url_loading_browser_agent.mm", "url_loading_notifier_browser_agent.h", "url_loading_notifier_browser_agent.mm", "url_loading_observer_bridge.h", "url_loading_observer_bridge.mm", "url_loading_params.h", "url_loading_params.mm", - "url_loading_service.h", - "url_loading_service.mm", - "url_loading_service_factory.h", - "url_loading_service_factory.mm", "url_loading_util.h", "url_loading_util.mm", ] @@ -51,12 +47,22 @@ ] } +source_set("test_support") { + configs += [ "//build/config/compiler:enable_arc" ] + testonly = true + sources = [ + "fake_url_loading_browser_agent.h", + "fake_url_loading_browser_agent.mm", + ] + deps = [ ":url_loading" ] +} + source_set("unit_tests") { configs += [ "//build/config/compiler:enable_arc" ] testonly = true sources = [ "image_search_param_generator_unittest.mm", - "url_loading_service_unittest.mm", + "url_loading_browser_agent_unittest.mm", ] deps = [ ":url_loading",
diff --git a/ios/chrome/browser/url_loading/app_url_loading_service.mm b/ios/chrome/browser/url_loading/app_url_loading_service.mm index 05d4743c..6bda8b9e 100644 --- a/ios/chrome/browser/url_loading/app_url_loading_service.mm +++ b/ios/chrome/browser/url_loading/app_url_loading_service.mm
@@ -8,9 +8,8 @@ #import "ios/chrome/browser/main/browser.h" #import "ios/chrome/browser/snapshots/snapshot_tab_helper.h" #import "ios/chrome/browser/tabs/tab_model.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #import "ios/chrome/browser/web_state_list/web_state_list.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -27,35 +26,33 @@ void AppUrlLoadingService::LoadUrlInNewTab(const UrlLoadParams& params) { DCHECK(delegate_); - ChromeBrowserState* current_browser_state = - delegate_.currentBrowserForURLLoading->GetBrowserState(); + Browser* browser = delegate_.currentBrowserForURLLoading; + ChromeBrowserState* browser_state = browser->GetBrowserState(); if (params.web_params.url.is_valid()) { UrlLoadParams saved_params = params; saved_params.web_params.transition_type = ui::PAGE_TRANSITION_TYPED; if (params.from_chrome) { - [delegate_ - dismissModalDialogsWithCompletion:^{ - [delegate_ - openSelectedTabInMode:ApplicationModeForTabOpening::NORMAL - withUrlLoadParams:saved_params - completion:nil]; - } - dismissOmnibox:YES]; + auto dismiss_completion = ^{ + [delegate_ openSelectedTabInMode:ApplicationModeForTabOpening::NORMAL + withUrlLoadParams:saved_params + completion:nil]; + }; + [delegate_ dismissModalDialogsWithCompletion:dismiss_completion + dismissOmnibox:YES]; } else { ApplicationMode mode = params.in_incognito ? ApplicationMode::INCOGNITO : ApplicationMode::NORMAL; - [delegate_ - dismissModalDialogsWithCompletion:^{ - [delegate_ setCurrentInterfaceForMode:mode]; - UrlLoadingServiceFactory::GetForBrowserState(current_browser_state) - ->Load(saved_params); - } - dismissOmnibox:YES]; + auto dismiss_completion = ^{ + [delegate_ setCurrentInterfaceForMode:mode]; + UrlLoadingBrowserAgent::FromBrowser(browser)->Load(saved_params); + }; + [delegate_ dismissModalDialogsWithCompletion:dismiss_completion + dismissOmnibox:YES]; } } else { - if (current_browser_state->IsOffTheRecord() != params.in_incognito) { + if (browser_state->IsOffTheRecord() != params.in_incognito) { // Must take a snapshot of the tab before we switch the incognito mode // because the currentTab will change after the switch. web::WebState* currentWebState =
diff --git a/ios/chrome/browser/url_loading/fake_url_loading_browser_agent.h b/ios/chrome/browser/url_loading/fake_url_loading_browser_agent.h new file mode 100644 index 0000000..114386f --- /dev/null +++ b/ios/chrome/browser/url_loading/fake_url_loading_browser_agent.h
@@ -0,0 +1,41 @@ +// Copyright 2019 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. + +#ifndef IOS_CHROME_BROWSER_URL_LOADING_FAKE_URL_LOADING_BROWSER_AGENT_H_ +#define IOS_CHROME_BROWSER_URL_LOADING_FAKE_URL_LOADING_BROWSER_AGENT_H_ + +#include "ios/chrome/browser/url_loading/url_loading_browser_agent.h" +#import "ios/chrome/browser/url_loading/url_loading_params.h" + +class FakeUrlLoadingBrowserAgent : public UrlLoadingBrowserAgent { + public: + // Injects an instance attached to |browser|, using the superclass user data + // key. + static void InjectForBrowser(Browser* browser); + + static FakeUrlLoadingBrowserAgent* FromUrlLoadingBrowserAgent( + UrlLoadingBrowserAgent*); + + // These are the last parameters passed to |OpenUrl|. + UrlLoadParams last_params; + + // Call counts for overridden methods. + int load_current_tab_call_count = 0; + int switch_tab_call_count = 0; + int load_new_tab_call_count = 0; + + private: + explicit FakeUrlLoadingBrowserAgent(Browser* browser); + + // Switches to a tab that matches |params.web_params| or opens in a new tab. + void SwitchToTab(const UrlLoadParams& params) override; + + // Opens a url based on |params| in current tab. + void LoadUrlInCurrentTab(const UrlLoadParams& params) override; + + // Opens a url based on |params| in a new tab. + void LoadUrlInNewTab(const UrlLoadParams& params) override; +}; + +#endif // IOS_CHROME_BROWSER_URL_LOADING_FAKE_URL_LOADING_BROWSER_AGENT_H_
diff --git a/ios/chrome/browser/url_loading/fake_url_loading_browser_agent.mm b/ios/chrome/browser/url_loading/fake_url_loading_browser_agent.mm new file mode 100644 index 0000000..8f4ae7d8 --- /dev/null +++ b/ios/chrome/browser/url_loading/fake_url_loading_browser_agent.mm
@@ -0,0 +1,42 @@ +// Copyright 2019 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. + +#import "ios/chrome/browser/url_loading/fake_url_loading_browser_agent.h" + +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + +void FakeUrlLoadingBrowserAgent::InjectForBrowser(Browser* browser) { + // No other instance should already have been attached. + DCHECK(!FromBrowser(browser)); + browser->SetUserData( + UrlLoadingBrowserAgent::UserDataKey(), + base::WrapUnique(new FakeUrlLoadingBrowserAgent(browser))); +} + +FakeUrlLoadingBrowserAgent* +FakeUrlLoadingBrowserAgent::FromUrlLoadingBrowserAgent( + UrlLoadingBrowserAgent* agent) { + return static_cast<FakeUrlLoadingBrowserAgent*>(agent); +} + +FakeUrlLoadingBrowserAgent::FakeUrlLoadingBrowserAgent(Browser* browser) + : UrlLoadingBrowserAgent(browser) {} + +void FakeUrlLoadingBrowserAgent::LoadUrlInCurrentTab( + const UrlLoadParams& params) { + last_params = params; + load_current_tab_call_count++; +} + +void FakeUrlLoadingBrowserAgent::LoadUrlInNewTab(const UrlLoadParams& params) { + last_params = params; + load_new_tab_call_count++; +} + +void FakeUrlLoadingBrowserAgent::SwitchToTab(const UrlLoadParams& params) { + last_params = params; + switch_tab_call_count++; +}
diff --git a/ios/chrome/browser/url_loading/test_url_loading_service.h b/ios/chrome/browser/url_loading/test_url_loading_service.h deleted file mode 100644 index f015257..0000000 --- a/ios/chrome/browser/url_loading/test_url_loading_service.h +++ /dev/null
@@ -1,32 +0,0 @@ -// Copyright 2019 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. - -#ifndef IOS_CHROME_BROWSER_URL_LOADING_TEST_URL_LOADING_SERVICE_H_ -#define IOS_CHROME_BROWSER_URL_LOADING_TEST_URL_LOADING_SERVICE_H_ - -#import "ios/chrome/browser/url_loading/url_loading_params.h" -#include "ios/chrome/browser/url_loading/url_loading_service.h" - -class TestUrlLoadingService : public UrlLoadingService { - public: - TestUrlLoadingService(); - - // These are the last parameters passed to |OpenUrl|. - UrlLoadParams last_params; - int load_current_tab_call_count = 0; - int switch_tab_call_count = 0; - int load_new_tab_call_count = 0; - - private: - // Switches to a tab that matches |params.web_params| or opens in a new tab. - void SwitchToTab(const UrlLoadParams& params) override; - - // Opens a url based on |params| in current tab. - void LoadUrlInCurrentTab(const UrlLoadParams& params) override; - - // Opens a url based on |params| in a new tab. - void LoadUrlInNewTab(const UrlLoadParams& params) override; -}; - -#endif // IOS_CHROME_BROWSER_URL_LOADING_TEST_URL_LOADING_SERVICE_H_
diff --git a/ios/chrome/browser/url_loading/test_url_loading_service.mm b/ios/chrome/browser/url_loading/test_url_loading_service.mm deleted file mode 100644 index 5276bf7..0000000 --- a/ios/chrome/browser/url_loading/test_url_loading_service.mm +++ /dev/null
@@ -1,29 +0,0 @@ -// Copyright 2019 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. - -#import "ios/chrome/browser/url_loading/test_url_loading_service.h" - -#import "ios/chrome/browser/ui/commands/open_new_tab_command.h" -#import "ios/chrome/browser/url_loading/url_loading_notifier_browser_agent.h" - -#if !defined(__has_feature) || !__has_feature(objc_arc) -#error "This file requires ARC support." -#endif - -TestUrlLoadingService::TestUrlLoadingService() {} - -void TestUrlLoadingService::LoadUrlInCurrentTab(const UrlLoadParams& params) { - last_params = params; - load_current_tab_call_count++; -} - -void TestUrlLoadingService::LoadUrlInNewTab(const UrlLoadParams& params) { - last_params = params; - load_new_tab_call_count++; -} - -void TestUrlLoadingService::SwitchToTab(const UrlLoadParams& params) { - last_params = params; - switch_tab_call_count++; -}
diff --git a/ios/chrome/browser/url_loading/url_loading_browser_agent.h b/ios/chrome/browser/url_loading/url_loading_browser_agent.h new file mode 100644 index 0000000..c637d95f --- /dev/null +++ b/ios/chrome/browser/url_loading/url_loading_browser_agent.h
@@ -0,0 +1,69 @@ +// Copyright 2019 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. + +#ifndef IOS_CHROME_BROWSER_URL_LOADING_URL_LOADING_BROWSER_AGENT_H_ +#define IOS_CHROME_BROWSER_URL_LOADING_URL_LOADING_BROWSER_AGENT_H_ + +#import <Foundation/Foundation.h> + +#import "ios/chrome/browser/main/browser_user_data.h" + +class AppUrlLoadingService; +class Browser; +class UrlLoadingNotifierBrowserAgent; +struct UrlLoadParams; + +// A delegate for URL loading that can handle UI animations that are needed at +// specific points in the loading cycle. +@protocol URLLoadingDelegate + +// Implementing delegate can do an animation using information in |params| when +// opening a background tab, then call |completion|. +- (void)animateOpenBackgroundTabFromParams:(const UrlLoadParams&)params + completion:(void (^)())completion; + +@end + +// Service used to load url in current or new tab. +class UrlLoadingBrowserAgent : public BrowserUserData<UrlLoadingBrowserAgent> { + public: + // Not copyable or moveable. + UrlLoadingBrowserAgent(const UrlLoadingBrowserAgent&) = delete; + UrlLoadingBrowserAgent& operator=(const UrlLoadingBrowserAgent&) = delete; + ~UrlLoadingBrowserAgent() override; + + void SetAppService(AppUrlLoadingService* app_service); + void SetIncognitoLoader(UrlLoadingBrowserAgent* loader); + void SetDelegate(id<URLLoadingDelegate> delegate); + + // Applies load strategy then calls |Dispatch|. + void Load(const UrlLoadParams& params); + + private: + friend class BrowserUserData<UrlLoadingBrowserAgent>; + friend class FakeUrlLoadingBrowserAgent; + explicit UrlLoadingBrowserAgent(Browser* browser); + BROWSER_USER_DATA_KEY_DECL(); + + // Dispatches to one action method below, depending on |params.disposition|. + void Dispatch(const UrlLoadParams& params); + + // Action methods. + // Switches to a tab that matches |params.web_params| or loads in a new tab. + virtual void SwitchToTab(const UrlLoadParams& params); + + // Loads a url based on |params| in current tab. + virtual void LoadUrlInCurrentTab(const UrlLoadParams& params); + + // Loads a url based on |params| in a new tab. + virtual void LoadUrlInNewTab(const UrlLoadParams& params); + + __weak id<URLLoadingDelegate> delegate_; + Browser* browser_; + UrlLoadingNotifierBrowserAgent* notifier_ = nullptr; + UrlLoadingBrowserAgent* incognito_loader_ = nullptr; + AppUrlLoadingService* app_service_ = nullptr; +}; + +#endif // IOS_CHROME_BROWSER_URL_LOADING_URL_LOADING_BROWSER_AGENT_H_
diff --git a/ios/chrome/browser/url_loading/url_loading_service.mm b/ios/chrome/browser/url_loading/url_loading_browser_agent.mm similarity index 88% rename from ios/chrome/browser/url_loading/url_loading_service.mm rename to ios/chrome/browser/url_loading/url_loading_browser_agent.mm index ee688c6..442fb9e 100644 --- a/ios/chrome/browser/url_loading/url_loading_service.mm +++ b/ios/chrome/browser/url_loading/url_loading_browser_agent.mm
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "ios/chrome/browser/url_loading/url_loading_service.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #include "base/strings/string_number_conversions.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h" @@ -15,7 +15,6 @@ #import "ios/chrome/browser/url_loading/app_url_loading_service.h" #import "ios/chrome/browser/url_loading/url_loading_notifier_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #import "ios/chrome/browser/url_loading/url_loading_util.h" #import "ios/chrome/browser/web/load_timing_tab_helper.h" #import "ios/chrome/browser/web_state_list/tab_insertion_browser_agent.h" @@ -26,13 +25,14 @@ #error "This file requires ARC support." #endif +BROWSER_USER_DATA_KEY_IMPL(UrlLoadingBrowserAgent) + namespace { // Helper method for inducing intentional freezes and crashes, in a separate -// function so it will show up in stack traces. -// If a delay parameter is present, the main thread will be frozen for that -// number of seconds. -// If a crash parameter is "true" (which is the default value), the browser will -// crash after this delay. Any other value will not trigger a crash. +// function so it will show up in stack traces. If a delay parameter is present, +// the main thread will be frozen for that number of seconds. If a crash +// parameter is "true" (which is the default value), the browser will crash +// after this delay. Any other value will not trigger a crash. void InduceBrowserCrash(const GURL& url) { int delay = 0; std::string delay_string; @@ -58,25 +58,30 @@ CHECK(true); } } +} // namespace + +UrlLoadingBrowserAgent::UrlLoadingBrowserAgent(Browser* browser) + : browser_(browser), + notifier_(UrlLoadingNotifierBrowserAgent::FromBrowser(browser_)) { + DCHECK(notifier_); } -UrlLoadingService::UrlLoadingService() {} +UrlLoadingBrowserAgent::~UrlLoadingBrowserAgent() {} -void UrlLoadingService::SetAppService(AppUrlLoadingService* app_service) { +void UrlLoadingBrowserAgent::SetAppService(AppUrlLoadingService* app_service) { app_service_ = app_service; } -void UrlLoadingService::SetDelegate(id<URLLoadingServiceDelegate> delegate) { +void UrlLoadingBrowserAgent::SetDelegate(id<URLLoadingDelegate> delegate) { delegate_ = delegate; } -void UrlLoadingService::SetBrowser(Browser* browser) { - browser_ = browser; - if (browser_) - notifier_ = UrlLoadingNotifierBrowserAgent::FromBrowser(browser_); +void UrlLoadingBrowserAgent::SetIncognitoLoader( + UrlLoadingBrowserAgent* loader) { + incognito_loader_ = loader; } -void UrlLoadingService::Load(const UrlLoadParams& params) { +void UrlLoadingBrowserAgent::Load(const UrlLoadParams& params) { // Apply any override load strategy and dispatch. switch (params.load_strategy) { case UrlLoadStrategy::ALWAYS_NEW_FOREGROUND_TAB: { @@ -89,9 +94,8 @@ ChromeBrowserState* browser_state = browser_->GetBrowserState(); if (params.disposition == WindowOpenDisposition::CURRENT_TAB && !browser_state->IsOffTheRecord()) { - UrlLoadingServiceFactory::GetForBrowserState( - browser_state->GetOffTheRecordChromeBrowserState()) - ->Load(params); + DCHECK(incognito_loader_); + incognito_loader_->Load(params); } else { UrlLoadParams fixed_params = params; fixed_params.in_incognito = YES; @@ -106,7 +110,7 @@ } } -void UrlLoadingService::Dispatch(const UrlLoadParams& params) { +void UrlLoadingBrowserAgent::Dispatch(const UrlLoadParams& params) { // Then dispatch. switch (params.disposition) { case WindowOpenDisposition::NEW_BACKGROUND_TAB: @@ -125,7 +129,7 @@ } } -void UrlLoadingService::LoadUrlInCurrentTab(const UrlLoadParams& params) { +void UrlLoadingBrowserAgent::LoadUrlInCurrentTab(const UrlLoadParams& params) { web::NavigationManager::WebLoadParams web_params = params.web_params; ChromeBrowserState* browser_state = browser_->GetBrowserState(); @@ -207,7 +211,7 @@ notifier_->TabDidLoadUrl(web_params.url, web_params.transition_type); } -void UrlLoadingService::SwitchToTab(const UrlLoadParams& params) { +void UrlLoadingBrowserAgent::SwitchToTab(const UrlLoadParams& params) { DCHECK(app_service_); web::NavigationManager::WebLoadParams web_params = params.web_params; @@ -251,7 +255,7 @@ notifier_->DidSwitchToTabWithUrl(web_params.url, new_web_state_index); } -void UrlLoadingService::LoadUrlInNewTab(const UrlLoadParams& params) { +void UrlLoadingBrowserAgent::LoadUrlInNewTab(const UrlLoadParams& params) { DCHECK(app_service_); DCHECK(delegate_); DCHECK(browser_);
diff --git a/ios/chrome/browser/url_loading/url_loading_service_unittest.mm b/ios/chrome/browser/url_loading/url_loading_browser_agent_unittest.mm similarity index 81% rename from ios/chrome/browser/url_loading/url_loading_service_unittest.mm rename to ios/chrome/browser/url_loading/url_loading_browser_agent_unittest.mm index 7ecc283a..1b7d96e 100644 --- a/ios/chrome/browser/url_loading/url_loading_service_unittest.mm +++ b/ios/chrome/browser/url_loading/url_loading_browser_agent_unittest.mm
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "ios/chrome/browser/url_loading/url_loading_service.h" +#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import <Foundation/Foundation.h> #import <PassKit/PassKit.h> @@ -18,7 +18,6 @@ #import "ios/chrome/browser/url_loading/test_app_url_loading_service.h" #import "ios/chrome/browser/url_loading/url_loading_notifier_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/url_loading/url_loading_service_factory.h" #include "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h" #import "ios/chrome/browser/web_state_list/tab_insertion_browser_agent.h" #include "ios/chrome/browser/web_state_list/web_state_list.h" @@ -36,12 +35,12 @@ #error "This file requires ARC support." #endif -@interface URLLoadingServiceTestDelegate : NSObject <URLLoadingServiceDelegate> +@interface URLLoadingTestDelegate : NSObject <URLLoadingDelegate> @end -@implementation URLLoadingServiceTestDelegate +@implementation URLLoadingTestDelegate -#pragma mark - URLLoadingServiceDelegate +#pragma mark - URLLoadingBrowserAgentDelegate - (void)openURLInNewTabWithCommand:(OpenNewTabCommand*)command { } @@ -55,22 +54,18 @@ #pragma mark - namespace { -class URLLoadingServiceTest : public BlockCleanupTest { +class URLLoadingBrowserAgentTest : public BlockCleanupTest { public: - URLLoadingServiceTest() + URLLoadingBrowserAgentTest() : browser_(std::make_unique<TestBrowser>()), chrome_browser_state_(browser_->GetBrowserState()), otr_browser_state_( chrome_browser_state_->GetOffTheRecordChromeBrowserState()), - url_loading_delegate_([[URLLoadingServiceTestDelegate alloc] init]), - app_service_(std::make_unique<TestAppUrlLoadingService>()), - service_(UrlLoadingServiceFactory::GetForBrowserState( - chrome_browser_state_)), - otr_browser_(std::make_unique<TestBrowser>(otr_browser_state_)), - otr_service_( - UrlLoadingServiceFactory::GetForBrowserState(otr_browser_state_)) { + url_loading_delegate_([[URLLoadingTestDelegate alloc] init]), + app_loader_(std::make_unique<TestAppUrlLoadingService>()), + otr_browser_(std::make_unique<TestBrowser>(otr_browser_state_)) { // Configure app service. - app_service_->current_browser_ = browser_.get(); + app_loader_->current_browser_ = browser_.get(); // Disable web usage on both browsers WebUsageEnablerBrowserAgent::CreateForBrowser(browser_.get()); @@ -82,18 +77,22 @@ WebUsageEnablerBrowserAgent::FromBrowser(otr_browser_.get()); otr_enabler->SetWebUsageEnabled(false); - // Create insertion and notifier agents and configure services. - TabInsertionBrowserAgent::CreateForBrowser(browser_.get()); + // Create loaders, insertion and notifier agents. UrlLoadingNotifierBrowserAgent::CreateForBrowser(browser_.get()); - service_->SetDelegate(url_loading_delegate_); - service_->SetBrowser(browser_.get()); - service_->SetAppService(app_service_.get()); + UrlLoadingBrowserAgent::CreateForBrowser(browser_.get()); + TabInsertionBrowserAgent::CreateForBrowser(browser_.get()); + loader_ = UrlLoadingBrowserAgent::FromBrowser(browser_.get()); + loader_->SetDelegate(url_loading_delegate_); + loader_->SetAppService(app_loader_.get()); - TabInsertionBrowserAgent::CreateForBrowser(otr_browser_.get()); UrlLoadingNotifierBrowserAgent::CreateForBrowser(otr_browser_.get()); - otr_service_->SetDelegate(url_loading_delegate_); - otr_service_->SetBrowser(otr_browser_.get()); - otr_service_->SetAppService(app_service_.get()); + UrlLoadingBrowserAgent::CreateForBrowser(otr_browser_.get()); + TabInsertionBrowserAgent::CreateForBrowser(otr_browser_.get()); + otr_loader_ = UrlLoadingBrowserAgent::FromBrowser(otr_browser_.get()); + otr_loader_->SetDelegate(url_loading_delegate_); + otr_loader_->SetAppService(app_loader_.get()); + + loader_->SetIncognitoLoader(otr_loader_); } void TearDown() override { @@ -122,15 +121,14 @@ std::unique_ptr<Browser> browser_; ChromeBrowserState* chrome_browser_state_; ChromeBrowserState* otr_browser_state_; - std::unique_ptr<web::WebState> webState_; - URLLoadingServiceTestDelegate* url_loading_delegate_; - std::unique_ptr<TestAppUrlLoadingService> app_service_; - UrlLoadingService* service_; + URLLoadingTestDelegate* url_loading_delegate_; + std::unique_ptr<TestAppUrlLoadingService> app_loader_; + UrlLoadingBrowserAgent* loader_; std::unique_ptr<Browser> otr_browser_; - UrlLoadingService* otr_service_; + UrlLoadingBrowserAgent* otr_loader_; }; -TEST_F(URLLoadingServiceTest, TestSwitchToTab) { +TEST_F(URLLoadingBrowserAgentTest, TestSwitchToTab) { WebStateList* web_state_list = browser_->GetWebStateList(); ASSERT_EQ(0, web_state_list->count()); @@ -153,15 +151,15 @@ ASSERT_EQ(web_state_ptr, web_state_list->GetActiveWebState()); - service_->Load( + loader_->Load( UrlLoadParams::SwitchToTab(web::NavigationManager::WebLoadParams(url))); EXPECT_EQ(web_state_ptr_2, web_state_list->GetActiveWebState()); - EXPECT_EQ(0, app_service_->load_new_tab_call_count_); + EXPECT_EQ(0, app_loader_->load_new_tab_call_count_); } // Tests that switch to open tab from the NTP close it if it doesn't have // navigation history. -TEST_F(URLLoadingServiceTest, TestSwitchToTabFromNTP) { +TEST_F(URLLoadingBrowserAgentTest, TestSwitchToTabFromNTP) { WebStateList* web_state_list = browser_->GetWebStateList(); ASSERT_EQ(0, web_state_list->count()); @@ -184,16 +182,16 @@ ASSERT_EQ(web_state_ptr, web_state_list->GetActiveWebState()); - service_->Load( + loader_->Load( UrlLoadParams::SwitchToTab(web::NavigationManager::WebLoadParams(url))); EXPECT_EQ(web_state_ptr_2, web_state_list->GetActiveWebState()); EXPECT_EQ(1, web_state_list->count()); - EXPECT_EQ(0, app_service_->load_new_tab_call_count_); + EXPECT_EQ(0, app_loader_->load_new_tab_call_count_); } // Tests that trying to switch to a closed tab open from the NTP opens it in the // NTP. -TEST_F(URLLoadingServiceTest, TestSwitchToClosedTab) { +TEST_F(URLLoadingBrowserAgentTest, TestSwitchToClosedTab) { WebStateList* web_state_list = browser_->GetWebStateList(); ASSERT_EQ(0, web_state_list->count()); @@ -207,27 +205,27 @@ GURL url("http://test/2"); - service_->Load( + loader_->Load( UrlLoadParams::SwitchToTab(web::NavigationManager::WebLoadParams(url))); EXPECT_EQ(1, web_state_list->count()); EXPECT_EQ(web_state_ptr, web_state_list->GetActiveWebState()); - EXPECT_EQ(0, app_service_->load_new_tab_call_count_); + EXPECT_EQ(0, app_loader_->load_new_tab_call_count_); } // Tests open a new url in the NTP or the current tab. -TEST_F(URLLoadingServiceTest, TestOpenInCurrentTab) { +TEST_F(URLLoadingBrowserAgentTest, TestOpenInCurrentTab) { WebStateList* web_state_list = browser_->GetWebStateList(); ASSERT_EQ(0, web_state_list->count()); // Set a new tab, so we can open in it. GURL newtab("chrome://newtab"); - service_->Load( + loader_->Load( UrlLoadParams::InNewTab(web::NavigationManager::WebLoadParams(newtab))); EXPECT_EQ(1, web_state_list->count()); // Test opening this url over NTP. GURL url1("http://test/1"); - service_->Load( + loader_->Load( UrlLoadParams::InCurrentTab(web::NavigationManager::WebLoadParams(url1))); // We won't to wait for the navigation item to be committed, let's just @@ -240,32 +238,32 @@ EXPECT_EQ(1, web_state_list->count()); // Check that we had no app level redirection. - EXPECT_EQ(0, app_service_->load_new_tab_call_count_); + EXPECT_EQ(0, app_loader_->load_new_tab_call_count_); } // Tests opening a url in a new tab. -TEST_F(URLLoadingServiceTest, TestOpenInNewTab) { +TEST_F(URLLoadingBrowserAgentTest, TestOpenInNewTab) { WebStateList* web_state_list = browser_->GetWebStateList(); ASSERT_EQ(0, web_state_list->count()); // Set a new tab. GURL newtab("chrome://newtab"); - service_->Load( + loader_->Load( UrlLoadParams::InNewTab(web::NavigationManager::WebLoadParams(newtab))); EXPECT_EQ(1, web_state_list->count()); // Open another one. GURL url("http://test/2"); - service_->Load( + loader_->Load( UrlLoadParams::InNewTab(web::NavigationManager::WebLoadParams(url))); EXPECT_EQ(2, web_state_list->count()); // Check that we had no app level redirection. - EXPECT_EQ(0, app_service_->load_new_tab_call_count_); + EXPECT_EQ(0, app_loader_->load_new_tab_call_count_); } // Tests open a new url in the current incognito tab. -TEST_F(URLLoadingServiceTest, TestOpenInCurrentIncognitoTab) { +TEST_F(URLLoadingBrowserAgentTest, TestOpenInCurrentIncognitoTab) { WebStateList* web_state_list = browser_->GetWebStateList(); ASSERT_EQ(0, web_state_list->count()); WebStateList* otr_web_state_list = otr_browser_->GetWebStateList(); @@ -274,14 +272,14 @@ // Make app level to be otr. std::unique_ptr<TestBrowser> otr_browser = std::make_unique<TestBrowser>( chrome_browser_state_->GetOffTheRecordChromeBrowserState()); - app_service_->current_browser_ = otr_browser.get(); + app_loader_->current_browser_ = otr_browser.get(); // Set a new tab. GURL newtab("chrome://newtab"); UrlLoadParams new_tab_params = UrlLoadParams::InNewTab(web::NavigationManager::WebLoadParams(newtab)); new_tab_params.in_incognito = YES; - otr_service_->Load(new_tab_params); + otr_loader_->Load(new_tab_params); EXPECT_EQ(0, web_state_list->count()); EXPECT_EQ(1, otr_web_state_list->count()); @@ -290,7 +288,7 @@ UrlLoadParams params1 = UrlLoadParams::InCurrentTab(web::NavigationManager::WebLoadParams(url1)); params1.in_incognito = YES; - otr_service_->Load(params1); + otr_loader_->Load(params1); // We won't to wait for the navigation item to be committed, let's just // make sure it is at least pending. @@ -304,11 +302,11 @@ EXPECT_EQ(1, otr_web_state_list->count()); // Check that we had no app level redirection. - EXPECT_EQ(0, app_service_->load_new_tab_call_count_); + EXPECT_EQ(0, app_loader_->load_new_tab_call_count_); } // Tests opening a url in a new incognito tab. -TEST_F(URLLoadingServiceTest, TestOpenInNewIncognitoTab) { +TEST_F(URLLoadingBrowserAgentTest, TestOpenInNewIncognitoTab) { WebStateList* web_state_list = browser_->GetWebStateList(); ASSERT_EQ(0, web_state_list->count()); WebStateList* otr_web_state_list = otr_browser_->GetWebStateList(); @@ -316,13 +314,13 @@ std::unique_ptr<TestBrowser> otr_browser = std::make_unique<TestBrowser>( chrome_browser_state_->GetOffTheRecordChromeBrowserState()); - app_service_->current_browser_ = otr_browser.get(); + app_loader_->current_browser_ = otr_browser.get(); GURL url1("http://test/1"); UrlLoadParams params1 = UrlLoadParams::InNewTab(web::NavigationManager::WebLoadParams(url1)); params1.in_incognito = YES; - otr_service_->Load(params1); + otr_loader_->Load(params1); EXPECT_EQ(0, web_state_list->count()); EXPECT_EQ(1, otr_web_state_list->count()); @@ -330,16 +328,16 @@ UrlLoadParams params2 = UrlLoadParams::InNewTab(web::NavigationManager::WebLoadParams(url2)); params2.in_incognito = YES; - otr_service_->Load(params2); + otr_loader_->Load(params2); EXPECT_EQ(0, web_state_list->count()); EXPECT_EQ(2, otr_web_state_list->count()); // Check if we had any app level redirection. - EXPECT_EQ(0, app_service_->load_new_tab_call_count_); + EXPECT_EQ(0, app_loader_->load_new_tab_call_count_); } // Test opening a normal url in new tab with incognito service. -TEST_F(URLLoadingServiceTest, TestOpenNormalInNewTabWithIncognitoService) { +TEST_F(URLLoadingBrowserAgentTest, TestOpenNormalInNewTabWithIncognitoService) { WebStateList* web_state_list = browser_->GetWebStateList(); ASSERT_EQ(0, web_state_list->count()); WebStateList* otr_web_state_list = otr_browser_->GetWebStateList(); @@ -347,14 +345,14 @@ std::unique_ptr<TestBrowser> otr_browser = std::make_unique<TestBrowser>( chrome_browser_state_->GetOffTheRecordChromeBrowserState()); - app_service_->current_browser_ = otr_browser.get(); + app_loader_->current_browser_ = otr_browser.get(); // Send to right service. GURL url1("http://test/1"); UrlLoadParams params1 = UrlLoadParams::InNewTab(web::NavigationManager::WebLoadParams(url1)); params1.in_incognito = YES; - otr_service_->Load(params1); + otr_loader_->Load(params1); EXPECT_EQ(0, web_state_list->count()); EXPECT_EQ(1, otr_web_state_list->count()); @@ -363,29 +361,29 @@ UrlLoadParams params2 = UrlLoadParams::InNewTab(web::NavigationManager::WebLoadParams(url2)); params2.in_incognito = NO; - otr_service_->Load(params2); + otr_loader_->Load(params2); EXPECT_EQ(0, web_state_list->count()); EXPECT_EQ(1, otr_web_state_list->count()); // Check that had one app level redirection. - EXPECT_EQ(1, app_service_->load_new_tab_call_count_); + EXPECT_EQ(1, app_loader_->load_new_tab_call_count_); } // Test opening an incognito url in new tab with normal service. -TEST_F(URLLoadingServiceTest, TestOpenIncognitoInNewTabWithNormalService) { +TEST_F(URLLoadingBrowserAgentTest, TestOpenIncognitoInNewTabWithNormalService) { WebStateList* web_state_list = browser_->GetWebStateList(); ASSERT_EQ(0, web_state_list->count()); WebStateList* otr_web_state_list = otr_browser_->GetWebStateList(); ASSERT_EQ(0, otr_web_state_list->count()); - app_service_->current_browser_ = browser_.get(); + app_loader_->current_browser_ = browser_.get(); // Send to wrong service. GURL url1("http://test/1"); UrlLoadParams params1 = UrlLoadParams::InNewTab(web::NavigationManager::WebLoadParams(url1)); params1.in_incognito = YES; - service_->Load(params1); + loader_->Load(params1); EXPECT_EQ(0, web_state_list->count()); EXPECT_EQ(0, otr_web_state_list->count()); @@ -394,40 +392,41 @@ UrlLoadParams params2 = UrlLoadParams::InNewTab(web::NavigationManager::WebLoadParams(url2)); params2.in_incognito = NO; - service_->Load(params2); + loader_->Load(params2); EXPECT_EQ(1, web_state_list->count()); EXPECT_EQ(0, otr_web_state_list->count()); // Check that we had one app level redirection. - EXPECT_EQ(1, app_service_->load_new_tab_call_count_); + EXPECT_EQ(1, app_loader_->load_new_tab_call_count_); } // Test opening an incognito url in new tab with normal service using load // strategy. -TEST_F(URLLoadingServiceTest, TestOpenIncognitoInNewTabWithLoadStrategy) { +TEST_F(URLLoadingBrowserAgentTest, TestOpenIncognitoInNewTabWithLoadStrategy) { WebStateList* web_state_list = browser_->GetWebStateList(); ASSERT_EQ(0, web_state_list->count()); WebStateList* otr_web_state_list = otr_browser_->GetWebStateList(); ASSERT_EQ(0, otr_web_state_list->count()); - app_service_->current_browser_ = browser_.get(); + app_loader_->current_browser_ = browser_.get(); // Send to normal service. GURL url1("http://test/1"); UrlLoadParams params1 = UrlLoadParams::InNewTab(web::NavigationManager::WebLoadParams(url1)); params1.load_strategy = UrlLoadStrategy::ALWAYS_IN_INCOGNITO; - service_->Load(params1); + loader_->Load(params1); EXPECT_EQ(0, web_state_list->count()); EXPECT_EQ(0, otr_web_state_list->count()); // Check that we had one app level redirection. - EXPECT_EQ(1, app_service_->load_new_tab_call_count_); + EXPECT_EQ(1, app_loader_->load_new_tab_call_count_); } // Test opening an incognito url in current tab with normal service using load // strategy. -TEST_F(URLLoadingServiceTest, TestOpenIncognitoInCurrentTabWithLoadStrategy) { +TEST_F(URLLoadingBrowserAgentTest, + TestOpenIncognitoInCurrentTabWithLoadStrategy) { WebStateList* web_state_list = browser_->GetWebStateList(); ASSERT_EQ(0, web_state_list->count()); WebStateList* otr_web_state_list = otr_browser_->GetWebStateList(); @@ -436,14 +435,14 @@ // Make app level to be otr. std::unique_ptr<TestBrowser> otr_browser = std::make_unique<TestBrowser>( chrome_browser_state_->GetOffTheRecordChromeBrowserState()); - app_service_->current_browser_ = otr_browser.get(); + app_loader_->current_browser_ = otr_browser.get(); // Set a new incognito tab. GURL newtab("chrome://newtab"); UrlLoadParams new_tab_params = UrlLoadParams::InNewTab(web::NavigationManager::WebLoadParams(newtab)); new_tab_params.in_incognito = YES; - otr_service_->Load(new_tab_params); + otr_loader_->Load(new_tab_params); EXPECT_EQ(0, web_state_list->count()); EXPECT_EQ(1, otr_web_state_list->count()); @@ -452,7 +451,7 @@ UrlLoadParams params1 = UrlLoadParams::InCurrentTab(web::NavigationManager::WebLoadParams(url1)); params1.load_strategy = UrlLoadStrategy::ALWAYS_IN_INCOGNITO; - service_->Load(params1); + loader_->Load(params1); // We won't to wait for the navigation item to be committed, let's just // make sure it is at least pending. @@ -466,7 +465,7 @@ EXPECT_EQ(1, otr_web_state_list->count()); // Check that we had no app level redirection. - EXPECT_EQ(0, app_service_->load_new_tab_call_count_); + EXPECT_EQ(0, app_loader_->load_new_tab_call_count_); } } // namespace
diff --git a/ios/chrome/browser/url_loading/url_loading_service.h b/ios/chrome/browser/url_loading/url_loading_service.h deleted file mode 100644 index cda8f23f..0000000 --- a/ios/chrome/browser/url_loading/url_loading_service.h +++ /dev/null
@@ -1,62 +0,0 @@ -// Copyright 2019 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. - -#ifndef IOS_CHROME_BROWSER_URL_LOADING_URL_LOADING_SERVICE_H_ -#define IOS_CHROME_BROWSER_URL_LOADING_URL_LOADING_SERVICE_H_ - -#import <Foundation/Foundation.h> -#import <UIKit/UIKit.h> - -#include "components/keyed_service/core/keyed_service.h" -#import "ios/web/public/navigation/navigation_manager.h" -#include "ui/base/page_transition_types.h" -#include "url/gurl.h" - -class AppUrlLoadingService; -class Browser; -class UrlLoadingNotifierBrowserAgent; -struct UrlLoadParams; - -// Objective-C delegate for UrlLoadingService. -@protocol URLLoadingServiceDelegate - -// Implementing delegate can do an animation using information in |params| when -// opening a background tab, then call |completion|. -- (void)animateOpenBackgroundTabFromParams:(const UrlLoadParams&)params - completion:(void (^)())completion; - -@end - -// Service used to load url in current or new tab. -class UrlLoadingService : public KeyedService { - public: - UrlLoadingService(); - - void SetAppService(AppUrlLoadingService* app_service); - void SetDelegate(id<URLLoadingServiceDelegate> delegate); - void SetBrowser(Browser* browser); - - // Applies load strategy then calls |Dispatch|. - virtual void Load(const UrlLoadParams& params); - - private: - // Dispatches to one action method below, depending on |params.disposition|. - void Dispatch(const UrlLoadParams& params); - - // Switches to a tab that matches |params.web_params| or loads in a new tab. - virtual void SwitchToTab(const UrlLoadParams& params); - - // Loads a url based on |params| in current tab. - virtual void LoadUrlInCurrentTab(const UrlLoadParams& params); - - // Loads a url based on |params| in a new tab. - virtual void LoadUrlInNewTab(const UrlLoadParams& params); - - __weak id<URLLoadingServiceDelegate> delegate_; - AppUrlLoadingService* app_service_; - Browser* browser_; - UrlLoadingNotifierBrowserAgent* notifier_; -}; - -#endif // IOS_CHROME_BROWSER_URL_LOADING_URL_LOADING_SERVICE_H_
diff --git a/ios/chrome/browser/url_loading/url_loading_service_factory.h b/ios/chrome/browser/url_loading/url_loading_service_factory.h deleted file mode 100644 index 5999170..0000000 --- a/ios/chrome/browser/url_loading/url_loading_service_factory.h +++ /dev/null
@@ -1,44 +0,0 @@ -// Copyright 2019 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. - -#ifndef IOS_CHROME_BROWSER_URL_LOADING_URL_LOADING_SERVICE_FACTORY_H_ -#define IOS_CHROME_BROWSER_URL_LOADING_URL_LOADING_SERVICE_FACTORY_H_ - -#include <memory> - -#include "base/macros.h" -#include "base/no_destructor.h" -#include "components/keyed_service/ios/browser_state_keyed_service_factory.h" - -class ChromeBrowserState; -class UrlLoadingService; - -// Singleton that owns all UrlLoadingServices and associates them with -// ChromeBrowserState. -class UrlLoadingServiceFactory : public BrowserStateKeyedServiceFactory { - public: - static UrlLoadingService* GetForBrowserState( - ChromeBrowserState* browser_state); - - static UrlLoadingServiceFactory* GetInstance(); - - // Returns the default factory used to build TestUrlLoadingServices. Can be - // registered with SetTestingFactory to use test instances during testing. - static TestingFactory GetDefaultFactory(); - - private: - friend class base::NoDestructor<UrlLoadingServiceFactory>; - - UrlLoadingServiceFactory(); - ~UrlLoadingServiceFactory() override; - - std::unique_ptr<KeyedService> BuildServiceInstanceFor( - web::BrowserState* context) const override; - web::BrowserState* GetBrowserStateToUse( - web::BrowserState* context) const override; - - DISALLOW_COPY_AND_ASSIGN(UrlLoadingServiceFactory); -}; - -#endif // IOS_CHROME_BROWSER_URL_LOADING_URL_LOADING_SERVICE_FACTORY_H_
diff --git a/ios/chrome/browser/url_loading/url_loading_service_factory.mm b/ios/chrome/browser/url_loading/url_loading_service_factory.mm deleted file mode 100644 index 89fad6e..0000000 --- a/ios/chrome/browser/url_loading/url_loading_service_factory.mm +++ /dev/null
@@ -1,57 +0,0 @@ -// Copyright 2019 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 "ios/chrome/browser/url_loading/url_loading_service_factory.h" - -#include "base/no_destructor.h" -#include "components/keyed_service/ios/browser_state_dependency_manager.h" -#include "ios/chrome/browser/browser_state/browser_state_otr_helper.h" -#include "ios/chrome/browser/browser_state/chrome_browser_state.h" -#include "ios/chrome/browser/url_loading/test_url_loading_service.h" -#include "ios/chrome/browser/url_loading/url_loading_service.h" - -#if !defined(__has_feature) || !__has_feature(objc_arc) -#error "This file requires ARC support." -#endif - -// static -UrlLoadingService* UrlLoadingServiceFactory::GetForBrowserState( - ChromeBrowserState* browser_state) { - return static_cast<UrlLoadingService*>( - GetInstance()->GetServiceForBrowserState(browser_state, true)); -} - -// static -UrlLoadingServiceFactory* UrlLoadingServiceFactory::GetInstance() { - static base::NoDestructor<UrlLoadingServiceFactory> instance; - return instance.get(); -} - -std::unique_ptr<KeyedService> BuildTestUrlLoadingService( - web::BrowserState* context) { - return std::make_unique<TestUrlLoadingService>(); -} - -// static -BrowserStateKeyedServiceFactory::TestingFactory -UrlLoadingServiceFactory::GetDefaultFactory() { - return base::BindRepeating(&BuildTestUrlLoadingService); -} - -UrlLoadingServiceFactory::UrlLoadingServiceFactory() - : BrowserStateKeyedServiceFactory( - "UrlLoadingService", - BrowserStateDependencyManager::GetInstance()) {} - -UrlLoadingServiceFactory::~UrlLoadingServiceFactory() {} - -std::unique_ptr<KeyedService> UrlLoadingServiceFactory::BuildServiceInstanceFor( - web::BrowserState* context) const { - return std::make_unique<UrlLoadingService>(); -} - -web::BrowserState* UrlLoadingServiceFactory::GetBrowserStateToUse( - web::BrowserState* context) const { - return GetBrowserStateOwnInstanceInIncognito(context); -}
diff --git a/ios/third_party/earl_grey/ios_eg_test.gni b/ios/third_party/earl_grey/ios_eg_test.gni index 64bade8..108d8046a 100644 --- a/ios/third_party/earl_grey/ios_eg_test.gni +++ b/ios/third_party/earl_grey/ios_eg_test.gni
@@ -24,13 +24,16 @@ if (!defined(bundle_deps)) { bundle_deps = [] } + if (!defined(include_provider_resources)) { + include_provider_resources = true + } bundle_deps += [ "//ios/third_party/earl_grey:earl_grey+bundle", "//ios/third_party/gtx:gtx+bundle", "//ios/third_party/ochamcrest:ochamcrest+bundle", ] - if (ios_firebase_resources_target != "") { - bundle_deps += [ ios_firebase_resources_target ] + if (include_provider_resources) { + bundle_deps += ios_providers_resources_targets } if (!defined(deps)) { deps = []
diff --git a/ios/third_party/earl_grey2/ios_eg2_test.gni b/ios/third_party/earl_grey2/ios_eg2_test.gni index 71879db..71aa6eb 100644 --- a/ios/third_party/earl_grey2/ios_eg2_test.gni +++ b/ios/third_party/earl_grey2/ios_eg2_test.gni
@@ -18,10 +18,12 @@ bundle_deps = [] } bundle_deps += [ "//ios/third_party/earl_grey2:app_framework+bundle" ] - if (ios_firebase_resources_target != "") { - bundle_deps += [ ios_firebase_resources_target ] + if (!defined(include_provider_resources)) { + include_provider_resources = true } - + if (include_provider_resources) { + bundle_deps += ios_providers_resources_targets + } if (!defined(deps)) { deps = [] }
diff --git a/ios/web/BUILD.gn b/ios/web/BUILD.gn index 3cd3ab2..0fc27b6 100644 --- a/ios/web/BUILD.gn +++ b/ios/web/BUILD.gn
@@ -661,7 +661,7 @@ source = "ios_web_resources.grd" # Required due to flattenhtml="true" on a generated file. - source_is_generated = true + enable_input_discovery_for_gn_analyze = false outputs = [ "grit/ios_web_resources.h",
diff --git a/ios/web_view/shell/test/BUILD.gn b/ios/web_view/shell/test/BUILD.gn index b48b3e5..63c4ddf 100644 --- a/ios/web_view/shell/test/BUILD.gn +++ b/ios/web_view/shell/test/BUILD.gn
@@ -14,6 +14,7 @@ ios_eg_test("ios_web_view_shell_egtests") { info_plist = "//ios/web_view/shell/Info.plist" sources = [ "shell_egtest.mm" ] + include_provider_resources = false deps = [ ":earl_grey_test_support",
diff --git a/media/base/media_serializers.h b/media/base/media_serializers.h index d82517db..6333c44 100644 --- a/media/base/media_serializers.h +++ b/media/base/media_serializers.h
@@ -358,16 +358,16 @@ // Class (complex) template <> struct MediaSerializer<media::Status> { - static base::Value Serialize(const media::Status& err) { - if (err.IsOk()) + static base::Value Serialize(const media::Status& status) { + if (status.is_ok()) return base::Value("Ok"); base::Value result(base::Value::Type::DICTIONARY); - FIELD_SERIALIZE("status_code", err.code()); - FIELD_SERIALIZE("status_message", err.message()); - FIELD_SERIALIZE("stack", err.data_->frames); - FIELD_SERIALIZE("data", err.data_->data); - FIELD_SERIALIZE("causes", err.data_->causes); + FIELD_SERIALIZE("status_code", status.code()); + FIELD_SERIALIZE("status_message", status.message()); + FIELD_SERIALIZE("stack", status.data_->frames); + FIELD_SERIALIZE("data", status.data_->data); + FIELD_SERIALIZE("causes", status.data_->causes); return result; } };
diff --git a/media/base/status.cc b/media/base/status.cc index ddcee2b..003b657 100644 --- a/media/base/status.cc +++ b/media/base/status.cc
@@ -25,7 +25,7 @@ } Status& Status::operator=(const Status& copy) { - if (copy.IsOk()) { + if (copy.is_ok()) { data_.reset(); return *this; } @@ -69,4 +69,8 @@ data_->frames.push_back(MediaSerialize(location)); } +Status OkStatus() { + return Status(); +} + } // namespace media
diff --git a/media/base/status.h b/media/base/status.h index 1ee87013..322ec45 100644 --- a/media/base/status.h +++ b/media/base/status.h
@@ -40,11 +40,6 @@ // successful returns. class MEDIA_EXPORT Status { public: - // Convenience function to return |kOk|. - // OK won't have a message, trace, or data associated with them, and DCHECK - // if they are added. - static Status Ok() { return Status(); } - // Default constructor can be used for Status::Ok(); Status(); @@ -69,7 +64,7 @@ // Needs an out of line destructor... ~Status(); - bool IsOk() const { return !data_; } + bool is_ok() const { return !data_; } // Getters for internal fields const std::string& message() const { @@ -148,6 +143,11 @@ std::unique_ptr<StatusInternal> data_; }; +// Convenience function to return |kOk|. +// OK won't have a message, trace, or data associated with them, and DCHECK +// if they are added. +MEDIA_EXPORT Status OkStatus(); + // We need this two step macro to allow calling with no extra args - in a single // step macro we would have no way of removing the trailing comma after the // code.
diff --git a/media/base/status_unittest.cc b/media/base/status_unittest.cc index 57c7722..fa0cf3c 100644 --- a/media/base/status_unittest.cc +++ b/media/base/status_unittest.cc
@@ -36,7 +36,7 @@ // Friend class of MediaLog for access to internal constants. class StatusTest : public testing::Test { public: - Status DontFail() { return Status::Ok(); } + Status DontFail() { return OkStatus(); } Status FailEasily() { return STATUS(kCodeOnlyForTesting, "Message"); }
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc index 9b54b121..0bb025a1 100644 --- a/media/base/video_frame.cc +++ b/media/base/video_frame.cc
@@ -131,6 +131,7 @@ case PIXEL_FORMAT_P016LE: return gfx::Size(2, 2); + case PIXEL_FORMAT_UYVY: case PIXEL_FORMAT_UNKNOWN: case PIXEL_FORMAT_YUY2: case PIXEL_FORMAT_ARGB: @@ -193,6 +194,7 @@ case PIXEL_FORMAT_YUV422P12: case PIXEL_FORMAT_YUV444P12: case PIXEL_FORMAT_I420A: + case PIXEL_FORMAT_UYVY: case PIXEL_FORMAT_P016LE: return true; case PIXEL_FORMAT_UNKNOWN: @@ -863,6 +865,7 @@ case PIXEL_FORMAT_RGB24: return 3; case PIXEL_FORMAT_Y16: + case PIXEL_FORMAT_UYVY: case PIXEL_FORMAT_YUY2: case PIXEL_FORMAT_YUV420P9: case PIXEL_FORMAT_YUV422P9:
diff --git a/media/base/video_frame_layout.cc b/media/base/video_frame_layout.cc index 51e06ff..b7210ce1 100644 --- a/media/base/video_frame_layout.cc +++ b/media/base/video_frame_layout.cc
@@ -43,6 +43,7 @@ // static size_t VideoFrameLayout::NumPlanes(VideoPixelFormat format) { switch (format) { + case PIXEL_FORMAT_UYVY: case PIXEL_FORMAT_YUY2: case PIXEL_FORMAT_ARGB: case PIXEL_FORMAT_BGRA:
diff --git a/media/base/video_frame_unittest.cc b/media/base/video_frame_unittest.cc index c8fbcaf..403061aa 100644 --- a/media/base/video_frame_unittest.cc +++ b/media/base/video_frame_unittest.cc
@@ -603,6 +603,7 @@ EXPECT_EQ(72u, VideoFrame::AllocationSize(format, size)) << VideoPixelFormatToString(format); break; + case PIXEL_FORMAT_UYVY: case PIXEL_FORMAT_YUY2: case PIXEL_FORMAT_I422: EXPECT_EQ(48u, VideoFrame::AllocationSize(format, size))
diff --git a/media/base/video_types.cc b/media/base/video_types.cc index 624f89d..6f23ea7 100644 --- a/media/base/video_types.cc +++ b/media/base/video_types.cc
@@ -27,6 +27,8 @@ return "PIXEL_FORMAT_NV12"; case PIXEL_FORMAT_NV21: return "PIXEL_FORMAT_NV21"; + case PIXEL_FORMAT_UYVY: + return "PIXEL_FORMAT_UYVY"; case PIXEL_FORMAT_YUY2: return "PIXEL_FORMAT_YUY2"; case PIXEL_FORMAT_ARGB: @@ -112,6 +114,7 @@ return true; case PIXEL_FORMAT_UNKNOWN: + case PIXEL_FORMAT_UYVY: case PIXEL_FORMAT_YUY2: case PIXEL_FORMAT_ARGB: case PIXEL_FORMAT_XRGB: @@ -138,6 +141,7 @@ case PIXEL_FORMAT_NV12: case PIXEL_FORMAT_NV21: case PIXEL_FORMAT_YUY2: + case PIXEL_FORMAT_UYVY: case PIXEL_FORMAT_XRGB: case PIXEL_FORMAT_RGB24: case PIXEL_FORMAT_MJPEG: @@ -178,6 +182,7 @@ case PIXEL_FORMAT_NV12: case PIXEL_FORMAT_NV21: case PIXEL_FORMAT_YUY2: + case PIXEL_FORMAT_UYVY: case PIXEL_FORMAT_ARGB: case PIXEL_FORMAT_XRGB: case PIXEL_FORMAT_RGB24:
diff --git a/media/base/video_types.h b/media/base/video_types.h index 8fda6d85..2205036 100644 --- a/media/base/video_types.h +++ b/media/base/video_types.h
@@ -37,7 +37,8 @@ 6, // 12bpp with Y plane followed by a 2x2 interleaved UV plane. PIXEL_FORMAT_NV21 = 7, // 12bpp with Y plane followed by a 2x2 interleaved VU plane. - /* PIXEL_FORMAT_UYVY = 8, Deprecated */ + PIXEL_FORMAT_UYVY = + 8, // 16bpp interleaved 2x1 U, 1x1 Y, 2x1 V, 1x1 Y samples. PIXEL_FORMAT_YUY2 = 9, // 16bpp interleaved 1x1 Y, 2x1 U, 1x1 Y, 2x1 V samples. PIXEL_FORMAT_ARGB = 10, // 32bpp BGRA (byte-order), 1 plane.
diff --git a/media/capture/mojom/video_capture_types.mojom b/media/capture/mojom/video_capture_types.mojom index 6c00f78..5b09aac 100644 --- a/media/capture/mojom/video_capture_types.mojom +++ b/media/capture/mojom/video_capture_types.mojom
@@ -21,6 +21,7 @@ I444, NV12, NV21, + UYVY, YUY2, ARGB, XRGB,
diff --git a/media/capture/mojom/video_capture_types_mojom_traits.cc b/media/capture/mojom/video_capture_types_mojom_traits.cc index cd58d95f..32dc4185 100644 --- a/media/capture/mojom/video_capture_types_mojom_traits.cc +++ b/media/capture/mojom/video_capture_types_mojom_traits.cc
@@ -103,6 +103,8 @@ return media::mojom::VideoCapturePixelFormat::NV12; case media::VideoPixelFormat::PIXEL_FORMAT_NV21: return media::mojom::VideoCapturePixelFormat::NV21; + case media::VideoPixelFormat::PIXEL_FORMAT_UYVY: + return media::mojom::VideoCapturePixelFormat::UYVY; case media::VideoPixelFormat::PIXEL_FORMAT_YUY2: return media::mojom::VideoCapturePixelFormat::YUY2; case media::VideoPixelFormat::PIXEL_FORMAT_ARGB: @@ -180,6 +182,9 @@ case media::mojom::VideoCapturePixelFormat::NV21: *output = media::PIXEL_FORMAT_NV21; return true; + case media::mojom::VideoCapturePixelFormat::UYVY: + *output = media::PIXEL_FORMAT_UYVY; + return true; case media::mojom::VideoCapturePixelFormat::YUY2: *output = media::PIXEL_FORMAT_YUY2; return true;
diff --git a/media/capture/video/chromeos/camera_hal_dispatcher_impl.cc b/media/capture/video/chromeos/camera_hal_dispatcher_impl.cc index 90271c3..cff280c 100644 --- a/media/capture/video/chromeos/camera_hal_dispatcher_impl.cc +++ b/media/capture/video/chromeos/camera_hal_dispatcher_impl.cc
@@ -12,6 +12,7 @@ #include <vector> #include "base/bind.h" +#include "base/files/file.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/posix/eintr_wrapper.h" @@ -237,6 +238,17 @@ return; } + // TODO(crbug.com/1053569): Remove these lines once the issue is solved. + base::File::Info info; + if (!base::GetFileInfo(socket_path, &info)) { + LOG(WARNING) << "Failed to get the socket info after building Mojo channel"; + } else { + LOG(WARNING) << "Building Mojo channel. Socket info:" + << " creation_time: " << info.creation_time + << " last_accessed: " << info.last_accessed + << " last_modified: " << info.last_modified; + } + // Change permissions on the socket. struct group arc_camera_group; struct group* result = nullptr; @@ -392,6 +404,18 @@ void CameraHalDispatcherImpl::StopOnProxyThread() { DCHECK(proxy_task_runner_->BelongsToCurrentThread()); + + // TODO(crbug.com/1053569): Remove these lines once the issue is solved. + base::File::Info info; + if (!base::GetFileInfo(base::FilePath(kArcCamera3SocketPath), &info)) { + LOG(WARNING) << "Failed to get socket info before deleting"; + } else { + LOG(WARNING) << "Delete socket. Socket info:" + << " creation_time: " << info.creation_time + << " last_accessed: " << info.last_accessed + << " last_modified: " << info.last_modified; + } + if (!base::DeleteFile(base::FilePath(kArcCamera3SocketPath), /* recursive */ false)) { LOG(ERROR) << "Failed to delete " << kArcCamera3SocketPath;
diff --git a/media/capture/video/fake_video_capture_device.cc b/media/capture/video/fake_video_capture_device.cc index 4d8eba3b..50d38d3 100644 --- a/media/capture/video/fake_video_capture_device.cc +++ b/media/capture/video/fake_video_capture_device.cc
@@ -132,6 +132,7 @@ gfx::ColorSpace GetDefaultColorSpace(VideoPixelFormat format) { switch (format) { case PIXEL_FORMAT_YUY2: + case PIXEL_FORMAT_UYVY: case PIXEL_FORMAT_YV12: case PIXEL_FORMAT_I420: case PIXEL_FORMAT_I422:
diff --git a/media/capture/video/mac/video_capture_device_avfoundation_mac.mm b/media/capture/video/mac/video_capture_device_avfoundation_mac.mm index 4c315b0..f803ae0 100644 --- a/media/capture/video/mac/video_capture_device_avfoundation_mac.mm +++ b/media/capture/video/mac/video_capture_device_avfoundation_mac.mm
@@ -152,6 +152,8 @@ // formats. media::VideoPixelFormat FourCCToChromiumPixelFormat(FourCharCode code) { switch (code) { + case kCVPixelFormatType_422YpCbCr8: + return media::PIXEL_FORMAT_UYVY; case kCMPixelFormat_422YpCbCr8_yuvs: return media::PIXEL_FORMAT_YUY2; case kCMVideoCodecType_JPEG_OpenDML: @@ -348,7 +350,7 @@ _frameHeight = height; _frameRate = frameRate; - FourCharCode best_fourcc = kCMPixelFormat_422YpCbCr8_yuvs; + FourCharCode best_fourcc = kCMPixelFormat_422YpCbCr8; const bool prefer_mjpeg = width > kMjpegWidthThreshold || height > kMjpegHeightThreshold; for (AVCaptureDeviceFormat* format in [_captureDevice formats]) {
diff --git a/media/capture/video/mac/video_capture_device_decklink_mac.mm b/media/capture/video/mac/video_capture_device_decklink_mac.mm index fd237a7..a237819 100644 --- a/media/capture/video/mac/video_capture_device_decklink_mac.mm +++ b/media/capture/video/mac/video_capture_device_decklink_mac.mm
@@ -260,6 +260,9 @@ media::VideoPixelFormat pixel_format = media::PIXEL_FORMAT_UNKNOWN; switch (video_frame->GetPixelFormat()) { + case bmdFormat8BitYUV: // A.k.a. '2vuy'; + pixel_format = media::PIXEL_FORMAT_UYVY; + break; case bmdFormat8BitARGB: pixel_format = media::PIXEL_FORMAT_ARGB; break;
diff --git a/media/capture/video/video_capture_device_client.cc b/media/capture/video/video_capture_device_client.cc index f783ea5f..618be0e 100644 --- a/media/capture/video/video_capture_device_client.cc +++ b/media/capture/video/video_capture_device_client.cc
@@ -292,6 +292,10 @@ DCHECK(!chopped_width && !chopped_height); fourcc_format = libyuv::FOURCC_YUY2; break; + case PIXEL_FORMAT_UYVY: + DCHECK(!chopped_width && !chopped_height); + fourcc_format = libyuv::FOURCC_UYVY; + break; case PIXEL_FORMAT_RGB24: // Linux RGB24 defines red at lowest byte address, // see http://linuxtv.org/downloads/v4l-dvb-apis/packed-rgb.html.
diff --git a/media/capture/video/video_capture_device_client_unittest.cc b/media/capture/video/video_capture_device_client_unittest.cc index 1dabb542..0e69a632f 100644 --- a/media/capture/video/video_capture_device_client_unittest.cc +++ b/media/capture/video/video_capture_device_client_unittest.cc
@@ -225,6 +225,7 @@ PIXEL_FORMAT_NV12, PIXEL_FORMAT_NV21, PIXEL_FORMAT_YUY2, + PIXEL_FORMAT_UYVY, #if defined(OS_WIN) || defined(OS_LINUX) PIXEL_FORMAT_RGB24, #endif
diff --git a/media/capture/video/win/sink_input_pin_win.cc b/media/capture/video/win/sink_input_pin_win.cc index b3ddc7a..8c3f69e 100644 --- a/media/capture/video/win/sink_input_pin_win.cc +++ b/media/capture/video/win/sink_input_pin_win.cc
@@ -77,6 +77,12 @@ resulting_format_.pixel_format = PIXEL_FORMAT_YUY2; return true; } + // This format is added after http:/crbug.com/508413. + if (sub_type == MEDIASUBTYPE_UYVY && + pvi->bmiHeader.biCompression == MAKEFOURCC('U', 'Y', 'V', 'Y')) { + resulting_format_.pixel_format = PIXEL_FORMAT_UYVY; + return true; + } if (sub_type == MEDIASUBTYPE_MJPG && pvi->bmiHeader.biCompression == MAKEFOURCC('M', 'J', 'P', 'G')) { resulting_format_.pixel_format = PIXEL_FORMAT_MJPEG;
diff --git a/media/capture/video/win/video_capture_device_win.cc b/media/capture/video/win/video_capture_device_win.cc index 9dc8e4f..96421b1 100644 --- a/media/capture/video/win/video_capture_device_win.cc +++ b/media/capture/video/win/video_capture_device_win.cc
@@ -340,7 +340,9 @@ {MEDIASUBTYPE_RGB32, PIXEL_FORMAT_ARGB}, {MEDIASUBTYPE_YUY2, PIXEL_FORMAT_YUY2}, {MEDIASUBTYPE_MJPG, PIXEL_FORMAT_MJPEG}, + {MEDIASUBTYPE_UYVY, PIXEL_FORMAT_UYVY}, {MEDIASUBTYPE_ARGB32, PIXEL_FORMAT_ARGB}, + {kMediaSubTypeHDYC, PIXEL_FORMAT_UYVY}, {kMediaSubTypeY16, PIXEL_FORMAT_Y16}, {kMediaSubTypeZ16, PIXEL_FORMAT_Y16}, {kMediaSubTypeINVZ, PIXEL_FORMAT_Y16},
diff --git a/media/capture/video_capture_types.cc b/media/capture/video_capture_types.cc index d8458ce..585dafba 100644 --- a/media/capture/video_capture_types.cc +++ b/media/capture/video_capture_types.cc
@@ -14,9 +14,9 @@ // This list is ordered by precedence of use. static VideoPixelFormat const kSupportedCapturePixelFormats[] = { - PIXEL_FORMAT_I420, PIXEL_FORMAT_YV12, PIXEL_FORMAT_NV12, - PIXEL_FORMAT_NV21, PIXEL_FORMAT_YUY2, PIXEL_FORMAT_RGB24, - PIXEL_FORMAT_ARGB, PIXEL_FORMAT_MJPEG, + PIXEL_FORMAT_I420, PIXEL_FORMAT_YV12, PIXEL_FORMAT_NV12, + PIXEL_FORMAT_NV21, PIXEL_FORMAT_UYVY, PIXEL_FORMAT_YUY2, + PIXEL_FORMAT_RGB24, PIXEL_FORMAT_ARGB, PIXEL_FORMAT_MJPEG, }; VideoCaptureFormat::VideoCaptureFormat()
diff --git a/media/filters/video_renderer_algorithm_unittest.cc b/media/filters/video_renderer_algorithm_unittest.cc index 4da03072..c17c24a 100644 --- a/media/filters/video_renderer_algorithm_unittest.cc +++ b/media/filters/video_renderer_algorithm_unittest.cc
@@ -1623,4 +1623,36 @@ base::TimeTicks() + kLongDuration + tg.interval(1) * 3); } +// Check that VideoRendererAlgorithm correctly sets WALLCLOCK_FRAME_DURATION +// for each frame. +TEST_F(VideoRendererAlgorithmTest, WallClockDurationMetadataSet) { + int playback_rate = 4; + int frame_count = 10; + TickGenerator tg(tick_clock_->NowTicks(), 25); + + time_source_.SetPlaybackRate(playback_rate); + auto intended_duration = tg.interval(1) / playback_rate; + + for (int i = 0; i < frame_count; i++) { + auto frame = CreateFrame(tg.interval(i)); + frame->metadata()->SetTimeDelta(VideoFrameMetadata::FRAME_DURATION, + tg.interval(1)); + algorithm_.EnqueueFrame(frame); + } + + for (int i = 0; i < frame_count; i++) { + size_t frames_dropped = 0; + auto frame = RenderAndStep(&tg, &frames_dropped); + + SCOPED_TRACE(base::StringPrintf("Frame #%d", i)); + base::TimeDelta wallclock_duration; + EXPECT_TRUE(frame->metadata()->GetTimeDelta( + media::VideoFrameMetadata::WALLCLOCK_FRAME_DURATION, + &wallclock_duration)); + + EXPECT_EQ(wallclock_duration, intended_duration); + EXPECT_EQ(algorithm_.average_frame_duration(), intended_duration); + } +} + } // namespace media
diff --git a/media/gpu/chromeos/fourcc.cc b/media/gpu/chromeos/fourcc.cc index 0a6edae..e8d514d 100644 --- a/media/gpu/chromeos/fourcc.cc +++ b/media/gpu/chromeos/fourcc.cc
@@ -74,6 +74,9 @@ return Fourcc(NV12); case PIXEL_FORMAT_NV21: return Fourcc(NV21); + case PIXEL_FORMAT_UYVY: + NOTREACHED(); + FALLTHROUGH; case PIXEL_FORMAT_I422: case PIXEL_FORMAT_I420A: case PIXEL_FORMAT_I444: @@ -107,6 +110,9 @@ return Fourcc(YM16); case PIXEL_FORMAT_NV21: return Fourcc(NM21); + case PIXEL_FORMAT_UYVY: + NOTREACHED(); + FALLTHROUGH; case PIXEL_FORMAT_I420A: case PIXEL_FORMAT_I444: case PIXEL_FORMAT_YUY2:
diff --git a/media/gpu/v4l2/v4l2_image_processor_backend.cc b/media/gpu/v4l2/v4l2_image_processor_backend.cc index 21b7dbe..5b97ff7e 100644 --- a/media/gpu/v4l2/v4l2_image_processor_backend.cc +++ b/media/gpu/v4l2/v4l2_image_processor_backend.cc
@@ -65,10 +65,6 @@ gmb_handle.native_pixmap_handle.planes; for (size_t i = 0; i < num_planes; ++i) { - const int bytes_used = - VideoFrame::PlaneSize(fourcc.ToVideoPixelFormat(), i, coded_size) - .GetArea(); - if (fourcc.IsMultiPlanar()) { // TODO(crbug.com/901264): The way to pass an offset within a DMA-buf // is not defined in V4L2 specification, so we abuse data_offset for @@ -80,10 +76,10 @@ buffer->SetPlaneSize(i, planes[i].size + planes[i].offset); // Workaround: filling length should not be needed. This is a bug of // videobuf2 library. - buffer->SetPlaneBytesUsed(i, bytes_used + planes[i].offset); + buffer->SetPlaneBytesUsed(i, planes[i].size + planes[i].offset); } else { // There is no need of filling data_offset for a single-planar format. - buffer->SetPlaneBytesUsed(i, bytes_used); + buffer->SetPlaneBytesUsed(i, planes[i].size); } } } @@ -97,6 +93,22 @@ return rect; } +bool AllocateV4L2Buffers(V4L2Queue* queue, + size_t num_buffers, + v4l2_memory memory_type) { + DCHECK(queue); + if (queue->AllocateBuffers(num_buffers, memory_type) == 0u) + return false; + + if (queue->AllocatedBuffersCount() != num_buffers) { + VLOGF(1) << "Failed to allocate buffers. Allocated number=" + << queue->AllocatedBuffersCount() + << ", Requested number=" << num_buffers; + return false; + } + + return true; +} } // namespace V4L2ImageProcessorBackend::JobRecord::JobRecord() @@ -626,20 +638,8 @@ } input_queue_ = device_->GetQueue(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); - if (!input_queue_) - return false; - - if (input_queue_->AllocateBuffers(num_buffers_, input_memory_type_) == 0u) - return false; - - if (input_queue_->AllocatedBuffersCount() != num_buffers_) { - VLOGF(1) << "Failed to allocate the required number of input buffers. " - << "Requested " << num_buffers_ << ", got " - << input_queue_->AllocatedBuffersCount() << "."; - return false; - } - - return true; + return input_queue_ && AllocateV4L2Buffers(input_queue_.get(), num_buffers_, + input_memory_type_); } bool V4L2ImageProcessorBackend::CreateOutputBuffers() { @@ -648,11 +648,6 @@ DCHECK_EQ(output_queue_, nullptr); struct v4l2_rect visible_rect = ToV4L2Rect(output_config_.visible_rect); - - output_queue_ = device_->GetQueue(V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); - if (!output_queue_) - return false; - struct v4l2_selection selection_arg; memset(&selection_arg, 0, sizeof(selection_arg)); selection_arg.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; @@ -667,17 +662,9 @@ IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_CROP, &crop); } - if (output_queue_->AllocateBuffers(num_buffers_, output_memory_type_) == 0) - return false; - - if (output_queue_->AllocatedBuffersCount() != num_buffers_) { - VLOGF(1) << "Failed to allocate output buffers. Allocated number=" - << output_queue_->AllocatedBuffersCount() - << ", Requested number=" << num_buffers_; - return false; - } - - return true; + output_queue_ = device_->GetQueue(V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); + return output_queue_ && AllocateV4L2Buffers(output_queue_.get(), num_buffers_, + output_memory_type_); } void V4L2ImageProcessorBackend::DevicePollTask(bool poll_device) {
diff --git a/media/gpu/v4l2/v4l2_video_encode_accelerator.cc b/media/gpu/v4l2/v4l2_video_encode_accelerator.cc index d0dd564c..c379fecc 100644 --- a/media/gpu/v4l2/v4l2_video_encode_accelerator.cc +++ b/media/gpu/v4l2/v4l2_video_encode_accelerator.cc
@@ -117,6 +117,15 @@ layout.planes(), visible_rect, preferred_storage_types); } + +// Create Layout from |layout| with is_multi_planar = true. +base::Optional<VideoFrameLayout> AsMultiPlanarLayout( + const VideoFrameLayout& layout) { + if (layout.is_multi_planar()) + return base::make_optional<VideoFrameLayout>(layout); + return VideoFrameLayout::CreateMultiPlanar( + layout.format(), layout.coded_size(), layout.planes()); +} } // namespace struct V4L2VideoEncodeAccelerator::BitstreamBufferRef { @@ -282,8 +291,6 @@ VLOGF(2) << "Input format: " << config.input_format << " is not supported " << "by the HW. Will try to convert to " << device_input_layout_->format(); - - // TODO(hiroh): Decide the appropriate planar in some way. auto input_layout = VideoFrameLayout::CreateMultiPlanar( config.input_format, encoder_input_visible_rect_.size(), std::vector<ColorPlaneLayout>( @@ -354,25 +361,25 @@ DCHECK_CALLED_ON_VALID_SEQUENCE(encoder_sequence_checker_); DCHECK_NE(input_layout.format(), output_layout.format()); + auto ip_input_layout = AsMultiPlanarLayout(std::move(input_layout)); + if (!ip_input_layout) + return false; + VideoFrame::StorageType input_storage_type = native_input_mode_ ? VideoFrame::STORAGE_GPU_MEMORY_BUFFER : VideoFrame::STORAGE_MOJO_SHARED_BUFFER; - auto input_config = VideoFrameLayoutToPortConfig( - input_layout, input_visible_rect, {input_storage_type}); + *ip_input_layout, input_visible_rect, {input_storage_type}); if (!input_config) return false; auto output_config = VideoFrameLayoutToPortConfig(output_layout, output_visible_rect, - {VideoFrame::STORAGE_GPU_MEMORY_BUFFER, - VideoFrame::STORAGE_OWNED_MEMORY}); + {VideoFrame::STORAGE_GPU_MEMORY_BUFFER}); if (!output_config) return false; image_processor_ = ImageProcessorFactory::Create( - *input_config, *output_config, - {ImageProcessor::OutputMode::IMPORT, - ImageProcessor::OutputMode::ALLOCATE}, + *input_config, *output_config, {ImageProcessor::OutputMode::IMPORT}, kImageProcBufferCount, encoder_task_runner_, base::BindRepeating(&V4L2VideoEncodeAccelerator::ImageProcessorError, weak_this_)); @@ -406,15 +413,9 @@ size_t count) { DCHECK_CALLED_ON_VALID_SEQUENCE(encoder_sequence_checker_); DCHECK(image_processor_); - // Allocate VideoFrames for image processor output if its mode is IMPORT. - if (image_processor_->output_mode() != ImageProcessor::OutputMode::IMPORT) { - return true; - } - - const ImageProcessor::PortConfig& output_config = - image_processor_->output_config(); - if (output_config.storage_type() == VideoFrame::STORAGE_GPU_MEMORY_BUFFER && - !image_processor_gmb_factory_) { + DCHECK_EQ(image_processor_->output_mode(), + ImageProcessor::OutputMode::IMPORT); + if (!image_processor_gmb_factory_) { image_processor_gmb_factory_ = gpu::GpuMemoryBufferFactory::CreateNativeType(nullptr); if (!image_processor_gmb_factory_) { @@ -424,13 +425,10 @@ } image_processor_output_buffers_.resize(count); + const ImageProcessor::PortConfig& output_config = + image_processor_->output_config(); for (size_t i = 0; i < count; i++) { switch (output_config.storage_type()) { - case VideoFrame::STORAGE_OWNED_MEMORY: - image_processor_output_buffers_[i] = VideoFrame::CreateFrameWithLayout( - *device_input_layout_, output_config.visible_rect, - output_config.visible_rect.size(), base::TimeDelta(), true); - break; case VideoFrame::STORAGE_GPU_MEMORY_BUFFER: image_processor_output_buffers_[i] = CreateGpuMemoryBufferVideoFrame( image_processor_gmb_factory_.get(),
diff --git a/media/gpu/windows/d3d11_texture_wrapper.cc b/media/gpu/windows/d3d11_texture_wrapper.cc index f18affe..6c6bdea 100644 --- a/media/gpu/windows/d3d11_texture_wrapper.cc +++ b/media/gpu/windows/d3d11_texture_wrapper.cc
@@ -73,7 +73,7 @@ // TODO(liberato): Would be nice if SB<> knew how to post and reply, so that // we could get the error code back eventually, and fail later with it. auto result = gpu_resources_->PushNewTexture(std::move(texture), array_slice); - if (!result.IsOk()) + if (!result.is_ok()) return false; // TODO(liberato): make sure that |mailbox_holders_| is zero-initialized in @@ -254,7 +254,7 @@ if (!eglStreamConsumerAcquireKHR(egl_display, stream_)) return Status(StatusCode::kCouldNotPostAcquireStream); - return Status::Ok(); + return OkStatus(); } } // namespace media
diff --git a/media/mojo/mojom/status_mojom_traits.h b/media/mojo/mojom/status_mojom_traits.h index 25889fe3..03eb5ab 100644 --- a/media/mojo/mojom/status_mojom_traits.h +++ b/media/mojo/mojom/status_mojom_traits.h
@@ -21,28 +21,28 @@ } static base::Optional<std::string> message(const media::Status& input) { - if (input.IsOk()) + if (input.is_ok()) return base::nullopt; DCHECK(input.data_); return input.message(); } static base::span<base::Value> frames(const media::Status& input) { - if (input.IsOk()) + if (input.is_ok()) return {}; DCHECK(input.data_); return input.data_->frames; } static base::span<media::Status> causes(const media::Status& input) { - if (input.IsOk()) + if (input.is_ok()) return {}; DCHECK(input.data_); return input.data_->causes; } static base::Optional<base::Value> data(const media::Status& input) { - if (!input.IsOk()) { + if (!input.is_ok()) { DCHECK(input.data_); return input.data_->data.Clone(); }
diff --git a/media/remoting/integration_test.cc b/media/remoting/integration_test.cc index c48ea2a..e56be6a 100644 --- a/media/remoting/integration_test.cc +++ b/media/remoting/integration_test.cc
@@ -16,24 +16,10 @@ constexpr int kAppendTimeSec = 1; -class TestRendererFactory final : public PipelineTestRendererFactory { - public: - explicit TestRendererFactory( - std::unique_ptr<PipelineTestRendererFactory> renderer_factory) - : default_renderer_factory_(std::move(renderer_factory)) {} - ~TestRendererFactory() override = default; - - // PipelineTestRendererFactory implementation. - std::unique_ptr<Renderer> CreateRenderer() override { - return std::make_unique<End2EndTestRenderer>( - default_renderer_factory_->CreateRenderer()); - } - - private: - std::unique_ptr<PipelineTestRendererFactory> default_renderer_factory_; - - DISALLOW_COPY_AND_ASSIGN(TestRendererFactory); -}; +std::unique_ptr<Renderer> CreateEnd2EndTestRenderer( + std::unique_ptr<Renderer> default_renderer) { + return std::make_unique<End2EndTestRenderer>(std::move(default_renderer)); +} } // namespace @@ -41,9 +27,7 @@ public PipelineIntegrationTestBase { public: MediaRemotingIntegrationTest() { - std::unique_ptr<PipelineTestRendererFactory> factory = - std::move(renderer_factory_); - renderer_factory_.reset(new TestRendererFactory(std::move(factory))); + SetWrapRendererCB(base::BindRepeating(&CreateEnd2EndTestRenderer)); } private:
diff --git a/media/renderers/paint_canvas_video_renderer.cc b/media/renderers/paint_canvas_video_renderer.cc index 6f8f515..0fdd0de 100644 --- a/media/renderers/paint_canvas_video_renderer.cc +++ b/media/renderers/paint_canvas_video_renderer.cc
@@ -389,6 +389,15 @@ return SynchronizeAndImportMailbox(ri, mailbox_holder.sync_token, *mailbox); } +gpu::Mailbox SynchronizeVideoFrameSingleMailbox( + gpu::raster::RasterInterface* ri, + VideoFrame* video_frame) { + const gpu::MailboxHolder& mailbox_holder = + GetVideoFrameMailboxHolder(video_frame); + ri->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData()); + return mailbox_holder.mailbox; +} + // Wraps a GL RGBA texture into a SkImage. sk_sp<SkImage> WrapGLTexture( GLenum target, @@ -668,6 +677,7 @@ NOTREACHED(); } break; + case PIXEL_FORMAT_UYVY: case PIXEL_FORMAT_YUV420P9: case PIXEL_FORMAT_YUV422P9: case PIXEL_FORMAT_YUV444P9: @@ -1747,27 +1757,20 @@ } DCHECK(!cache_->texture_ownership_in_skia); - auto* gl = raster_context_provider->ContextGL(); - ScopedSharedImageAccess dest_access( - gl, cache_->source_texture, cache_->source_mailbox, - GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM); if (video_frame->NumTextures() == 1) { - gpu::Mailbox mailbox; - GLuint frame_texture = - ImportVideoFrameSingleMailbox(gl, video_frame.get(), &mailbox); - { - ScopedSharedImageAccess access(gl, frame_texture, mailbox); - gl->CopySubTextureCHROMIUM(frame_texture, 0, GL_TEXTURE_2D, - cache_->source_texture, 0, 0, 0, 0, 0, - video_frame->coded_size().width(), - video_frame->coded_size().height(), - GL_FALSE, GL_FALSE, GL_FALSE); - } - gl->DeleteTextures(1, &frame_texture); + auto frame_mailbox = + SynchronizeVideoFrameSingleMailbox(ri, video_frame.get()); + ri->CopySubTexture( + frame_mailbox, cache_->source_mailbox, GL_TEXTURE_2D, 0, 0, 0, 0, + video_frame->coded_size().width(), + video_frame->coded_size().height(), GL_FALSE, GL_FALSE); source_image = WrapGLTexture( GL_TEXTURE_2D, cache_->source_texture, video_frame->coded_size(), gfx::ColorSpace(), raster_context_provider); } else { + ScopedSharedImageAccess dest_access( + ri, cache_->source_texture, cache_->source_mailbox, + GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM); source_image = NewSkImageFromVideoFrameYUVTexturesWithExternalBackend( video_frame.get(), raster_context_provider, GL_TEXTURE_2D, cache_->source_texture);
diff --git a/media/renderers/video_resource_updater.cc b/media/renderers/video_resource_updater.cc index 913f17e..3df95d9a 100644 --- a/media/renderers/video_resource_updater.cc +++ b/media/renderers/video_resource_updater.cc
@@ -121,6 +121,9 @@ buffer_formats[1] = gfx::BufferFormat::RG_88; return VideoFrameResourceType::YUV; + case PIXEL_FORMAT_UYVY: + NOTREACHED(); + FALLTHROUGH; case PIXEL_FORMAT_YV12: case PIXEL_FORMAT_I422: case PIXEL_FORMAT_I444:
diff --git a/media/test/pipeline_integration_test_base.cc b/media/test/pipeline_integration_test_base.cc index 7cea0be..06448ba7 100644 --- a/media/test/pipeline_integration_test_base.cc +++ b/media/test/pipeline_integration_test_base.cc
@@ -121,23 +121,6 @@ const char kNullVideoHash[] = "d41d8cd98f00b204e9800998ecf8427e"; const char kNullAudioHash[] = "0.00,0.00,0.00,0.00,0.00,0.00,"; -class RendererFactoryImpl final : public PipelineTestRendererFactory { - public: - explicit RendererFactoryImpl(PipelineIntegrationTestBase* integration_test) - : integration_test_(integration_test) {} - ~RendererFactoryImpl() override = default; - - // PipelineTestRendererFactory implementation. - std::unique_ptr<Renderer> CreateRenderer() override { - return integration_test_->CreateRenderer(base::nullopt); - } - - private: - PipelineIntegrationTestBase* integration_test_; - - DISALLOW_COPY_AND_ASSIGN(RendererFactoryImpl); -}; - PipelineIntegrationTestBase::PipelineIntegrationTestBase() : // Use a UI type message loop on macOS, because it doesn't seem to schedule @@ -154,8 +137,7 @@ ended_(false), pipeline_status_(PIPELINE_OK), last_video_frame_format_(PIXEL_FORMAT_UNKNOWN), - current_duration_(kInfiniteDuration), - renderer_factory_(new RendererFactoryImpl(this)) { + current_duration_(kInfiniteDuration) { pipeline_ = std::make_unique<PipelineImpl>( task_environment_.GetMainThreadTaskRunner(), task_environment_.GetMainThreadTaskRunner(), @@ -263,6 +245,11 @@ std::move(on_error_closure_).Run(); } +void PipelineIntegrationTestBase::SetWrapRendererCB( + WrapRendererCB wrap_renderer_cb) { + wrap_renderer_cb_ = std::move(wrap_renderer_cb); +} + PipelineStatus PipelineIntegrationTestBase::StartInternal( std::unique_ptr<DataSource> data_source, CdmContext* cdm_context, @@ -551,7 +538,8 @@ if (clockless_playback_) renderer_impl->EnableClocklessVideoPlaybackForTesting(); - return std::move(renderer_impl); + return wrap_renderer_cb_ ? wrap_renderer_cb_.Run(std::move(renderer_impl)) + : std::move(renderer_impl); } void PipelineIntegrationTestBase::OnVideoFramePaint(
diff --git a/media/test/pipeline_integration_test_base.h b/media/test/pipeline_integration_test_base.h index 0a810318d..718c917 100644 --- a/media/test/pipeline_integration_test_base.h +++ b/media/test/pipeline_integration_test_base.h
@@ -44,14 +44,6 @@ // Empty hash string. Used to verify empty audio tracks. extern const char kNullAudioHash[]; -class PipelineTestRendererFactory { - public: - virtual ~PipelineTestRendererFactory() = default; - - // Creates and returns a Renderer. - virtual std::unique_ptr<Renderer> CreateRenderer() = 0; -}; - // Integration tests for Pipeline. Real demuxers, real decoders, and // base renderer implementations are used to verify pipeline functionality. The // renderers used in these tests rely heavily on the AudioRendererBase & @@ -176,7 +168,15 @@ scoped_refptr<VideoFrame> last_frame_; base::TimeDelta current_duration_; AudioRendererImpl::PlayDelayCBForTesting audio_play_delay_cb_; - std::unique_ptr<PipelineTestRendererFactory> renderer_factory_; + + // A callback that can wrap one Renderer into another Renderer. + using WrapRendererCB = base::RepeatingCallback<std::unique_ptr<Renderer>( + std::unique_ptr<Renderer>)>; + WrapRendererCB wrap_renderer_cb_; + + // Sets |wrap_renderer_cb_| which will be used to wrap the Renderer created by + // CreateRenderer(). + void SetWrapRendererCB(WrapRendererCB wrap_renderer_cb); PipelineStatus StartInternal( std::unique_ptr<DataSource> data_source,
diff --git a/media/video/gpu_memory_buffer_video_frame_pool.cc b/media/video/gpu_memory_buffer_video_frame_pool.cc index 1051f91..cd549e59 100644 --- a/media/video/gpu_memory_buffer_video_frame_pool.cc +++ b/media/video/gpu_memory_buffer_video_frame_pool.cc
@@ -597,6 +597,7 @@ case PIXEL_FORMAT_I444: case PIXEL_FORMAT_NV12: case PIXEL_FORMAT_NV21: + case PIXEL_FORMAT_UYVY: case PIXEL_FORMAT_YUY2: case PIXEL_FORMAT_ARGB: case PIXEL_FORMAT_BGRA:
diff --git a/net/base/proxy_delegate.h b/net/base/proxy_delegate.h index d2f2f5e..5ab89be 100644 --- a/net/base/proxy_delegate.h +++ b/net/base/proxy_delegate.h
@@ -24,11 +24,8 @@ // Delegate for setting up a connection. class NET_EXPORT ProxyDelegate { public: - ProxyDelegate() { - } - - virtual ~ProxyDelegate() { - } + ProxyDelegate() = default; + virtual ~ProxyDelegate() = default; // Called as the proxy is being resolved for |url| for a |method| request. // The caller may pass an empty string to get method agnostic resoulution. @@ -44,23 +41,19 @@ // the network error encountered, if any, and OK if the fallback was // for a reason other than a network error (e.g. the proxy service was // explicitly directed to skip a proxy). - virtual void OnFallback(const ProxyServer& bad_proxy, - int net_error) = 0; + virtual void OnFallback(const ProxyServer& bad_proxy, int net_error) = 0; - // Called immediately before a HTTP/1.x proxy tunnel request is sent. - // Provides the embedder an opportunity to add extra request headers. - // Not called for HTTP/2 or QUIC tunnels. - virtual void OnBeforeHttp1TunnelRequest( - const ProxyServer& proxy_server, - HttpRequestHeaders* extra_headers) = 0; + // Called immediately before a proxy tunnel request is sent. Provides the + // embedder an opportunity to add extra request headers. + virtual void OnBeforeTunnelRequest(const ProxyServer& proxy_server, + HttpRequestHeaders* extra_headers) = 0; - // Called when the response headers for the HTTP/1.x proxy tunnel request - // have been received. Allows the delegate to override the net error code of - // the tunnel request. Returning OK causes the standard tunnel response - // handling to be performed. Implementations should make sure they can trust - // |proxy_server| before making decisions based on |response_headers|. - // Not called for HTTP/2 or QUIC tunnels. - virtual Error OnHttp1TunnelHeadersReceived( + // Called when the response headers for the proxy tunnel request have been + // received. Allows the delegate to override the net error code of the tunnel + // request. Returning OK causes the standard tunnel response handling to be + // performed. Implementations should make sure they can trust |proxy_server| + // before making decisions based on |response_headers|. + virtual Error OnTunnelHeadersReceived( const ProxyServer& proxy_server, const HttpResponseHeaders& response_headers) = 0;
diff --git a/net/base/test_proxy_delegate.cc b/net/base/test_proxy_delegate.cc index e67e86882a..407e11f 100644 --- a/net/base/test_proxy_delegate.cc +++ b/net/base/test_proxy_delegate.cc
@@ -17,7 +17,7 @@ TestProxyDelegate::~TestProxyDelegate() = default; -void TestProxyDelegate::VerifyOnHttp1TunnelHeadersReceived( +void TestProxyDelegate::VerifyOnTunnelHeadersReceived( const ProxyServer& proxy_server, const std::string& response_header_name, const std::string& response_header_value) const { @@ -61,7 +61,7 @@ void TestProxyDelegate::OnFallback(const ProxyServer& bad_proxy, int net_error) {} -void TestProxyDelegate::OnBeforeHttp1TunnelRequest( +void TestProxyDelegate::OnBeforeTunnelRequest( const ProxyServer& proxy_server, HttpRequestHeaders* extra_headers) { on_before_tunnel_request_called_ = true; @@ -69,7 +69,7 @@ extra_headers->SetHeader("Foo", proxy_server.ToURI()); } -Error TestProxyDelegate::OnHttp1TunnelHeadersReceived( +Error TestProxyDelegate::OnTunnelHeadersReceived( const ProxyServer& proxy_server, const HttpResponseHeaders& response_headers) { EXPECT_EQ(on_tunnel_headers_received_headers_.get(), nullptr);
diff --git a/net/base/test_proxy_delegate.h b/net/base/test_proxy_delegate.h index fd14ff1..e966994 100644 --- a/net/base/test_proxy_delegate.h +++ b/net/base/test_proxy_delegate.h
@@ -30,7 +30,7 @@ trusted_spdy_proxy_ = proxy_server; } - void VerifyOnHttp1TunnelHeadersReceived( + void VerifyOnTunnelHeadersReceived( const ProxyServer& proxy_server, const std::string& response_header_name, const std::string& response_header_value) const; @@ -41,9 +41,9 @@ const ProxyRetryInfoMap& proxy_retry_info, ProxyInfo* result) override; void OnFallback(const ProxyServer& bad_proxy, int net_error) override; - void OnBeforeHttp1TunnelRequest(const ProxyServer& proxy_server, - HttpRequestHeaders* extra_headers) override; - Error OnHttp1TunnelHeadersReceived( + void OnBeforeTunnelRequest(const ProxyServer& proxy_server, + HttpRequestHeaders* extra_headers) override; + Error OnTunnelHeadersReceived( const ProxyServer& proxy_server, const HttpResponseHeaders& response_headers) override;
diff --git a/net/cert/cert_verify_proc.cc b/net/cert/cert_verify_proc.cc index b8762226..a2e8cae 100644 --- a/net/cert/cert_verify_proc.cc +++ b/net/cert/cert_verify_proc.cc
@@ -841,9 +841,9 @@ // Not a real certificate - just for testing. // net/data/ssl/certificates/name_constraint_*.pem { - {{0x0d, 0x93, 0x13, 0xa7, 0xd7, 0x0d, 0x35, 0x89, 0x33, 0x50, 0x6e, - 0x9b, 0x68, 0x30, 0x7a, 0x4f, 0x7d, 0x3a, 0x7a, 0x42, 0xd4, 0x60, - 0x9a, 0x5e, 0x10, 0x4b, 0x58, 0xa5, 0xa7, 0x90, 0xa5, 0x81}}, + {{0x8e, 0x9b, 0x14, 0x9f, 0x01, 0x45, 0x4c, 0xee, 0xde, 0xfa, 0x5e, + 0x73, 0x40, 0x36, 0x21, 0xba, 0xd9, 0x1f, 0xee, 0xe0, 0x3e, 0x74, + 0x25, 0x6c, 0x59, 0xf4, 0x6f, 0xbf, 0x45, 0x03, 0x5f, 0x8d}}, kDomainsTest, }, };
diff --git a/net/cert/cert_verify_proc_unittest.cc b/net/cert/cert_verify_proc_unittest.cc index 1439323..7f7de34 100644 --- a/net/cert/cert_verify_proc_unittest.cc +++ b/net/cert/cert_verify_proc_unittest.cc
@@ -1509,8 +1509,8 @@ } // This tests that on successful certificate verification, -// CertVerifyResult::public_key_hashes is filled with a SHA256 hash for each -// of the certificates in the chain. +// CertVerifyResult::public_key_hashes is filled with a SHA1 and SHA256 hash +// for each of the certificates in the chain. TEST_P(CertVerifyProcInternalTest, PublicKeyHashes) { if (!SupportsReturningVerifiedChain()) { LOG(INFO) << "Skipping this test in this platform."; @@ -1548,7 +1548,7 @@ std::vector<std::string> expected_public_key_hashes = { // Target - "sha256/DZMTp9cNNYkzUG6baDB6T306ekLUYJpeEEtYpaeQpYE=", + "sha256/jpsUnwFFTO7e+l5zQDYhutkf7uA+dCVsWfRvv0UDX40=", // Intermediate "sha256/D9u0epgvPYlG9YiVp7V+IMT+xhUpB5BhsS/INjDXc4Y=",
diff --git a/net/cert/crl_set.cc b/net/cert/crl_set.cc index 882c0392..a782f22 100644 --- a/net/cert/crl_set.cc +++ b/net/cert/crl_set.cc
@@ -438,22 +438,8 @@ const std::string spki(reinterpret_cast<const char*>(issuer_spki->data), sizeof(issuer_spki->data)); std::vector<std::string> serials; - if (!serial_number.empty()) { + if (!serial_number.empty()) serials.push_back(serial_number); - // |serial_number| is in DER-encoded form, which means it may have a - // leading 0x00 to indicate it is a positive INTEGER. CRLSets are stored - // without these leading 0x00, as handled in CheckSerial(), so remove - // that here. As DER-encoding means that any sequences of leading zeroes - // should be omitted, except to indicate sign, there should only ever - // be one, and the next byte should have the high bit set. - DCHECK_EQ(serials[0][0] & 0x80, 0); // Negative serials are not allowed. - if (serials[0][0] == 0x00) { - serials[0].erase(0, 1); - // If there was a leading 0x00, then the high-bit of the next byte - // should have been set. - DCHECK(!serials[0].empty() && serials[0][0] & 0x80); - } - } crl_set->crls_.emplace(std::move(spki), std::move(serials)); }
diff --git a/net/cert/crl_set.h b/net/cert/crl_set.h index 06d173d..c012314 100644 --- a/net/cert/crl_set.h +++ b/net/cert/crl_set.h
@@ -42,8 +42,7 @@ // CheckSerial returns the information contained in the set for a given // certificate: - // serial_number: the serial number of the certificate, as the DER-encoded - // value + // serial_number: the serial number of the certificate // issuer_spki_hash: the SHA256 of the SubjectPublicKeyInfo of the CRL // signer Result CheckSerial( @@ -92,7 +91,7 @@ // ForTesting returns a CRLSet for testing. If |is_expired| is true, calling // IsExpired on the result will return true. If |issuer_spki| is not NULL, // the CRLSet will cover certificates issued by that SPKI. If |serial_number| - // is not empty, then that DER-encoded serial number will be considered to + // is not empty, then that big-endian serial number will be considered to // have been revoked by |issuer_spki|. If |common_name| is not empty then the // CRLSet will consider certificates with a subject consisting only of that // common name to be revoked unless they match an SPKI hash from
diff --git a/net/data/ssl/certificates/10_year_validity.pem b/net/data/ssl/certificates/10_year_validity.pem index 99368b9..47e0e10e 100644 --- a/net/data/ssl/certificates/10_year_validity.pem +++ b/net/data/ssl/certificates/10_year_validity.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:ac - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 12 (0xc) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Oct 30 00:00:00 2008 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:b1:03:36:49:f8:96:0d:64:a9:d6:36:4a:c8:24: - b7:5b:75:14:2e:ab:dc:e3:36:13:99:2b:15:b5:31: - f6:04:52:3a:c8:e7:f4:68:f6:ec:a9:28:c8:c5:4c: - 16:6b:5a:a7:fc:ab:7a:52:d1:21:ce:a6:c3:86:b3: - 8e:1d:c6:e5:98:49:ab:81:2d:6b:98:b4:89:78:2c: - c1:33:44:8f:a6:f4:18:69:1d:42:58:f6:cb:9b:42: - 2b:05:5b:98:85:36:80:56:b7:3e:ff:09:72:d5:0e: - 44:9e:38:e4:57:f9:d3:0c:b0:21:c3:49:80:63:10: - 9e:33:b3:07:8a:a5:89:3c:58:f4:78:39:0c:d9:91: - 4d:e1:a5:48:d1:e6:f2:7e:fe:d7:5a:e7:0f:1e:60: - 0d:93:af:c4:d5:16:05:43:89:8a:85:ad:7d:74:e2: - 61:f5:84:43:02:9a:89:f5:fc:56:b8:94:b4:56:ad: - d7:c2:71:a8:64:f2:c8:2c:7c:06:00:51:41:2d:ef: - b8:0e:e6:f0:77:61:af:b2:ac:1f:3d:82:3d:57:2c: - 02:e4:ba:b6:11:cc:07:72:b1:a8:69:a5:d0:a6:d1: - 4d:d5:76:4e:41:80:a6:d8:3e:aa:80:ad:a6:45:de: - 8c:bb:83:b7:7f:a5:e9:8d:78:58:78:4a:4c:73:10: - 20:b9 + 00:ae:21:b3:7f:5c:19:df:fd:97:51:cd:d4:30:35: + eb:50:4e:66:03:78:79:10:82:cb:02:5f:af:63:30: + 4a:54:ef:3e:3b:b8:76:7f:73:23:88:a7:4f:3c:65: + 78:1b:11:ea:49:f1:25:d4:cc:17:67:12:51:ce:a1: + f6:15:57:c6:9c:19:3c:8c:f0:9d:ce:c5:5e:a4:36: + d7:61:d3:21:21:c7:33:78:47:d6:74:e9:fa:b8:d8: + f2:f4:01:b4:ac:9f:69:d0:09:bc:1a:7c:35:7c:12: + c4:54:ba:5b:2b:80:37:6c:75:fe:08:36:44:bc:f1: + 3b:a9:c9:2b:a0:97:f8:75:4f:cd:27:24:f0:66:5e: + 8b:b9:b0:b1:49:50:80:80:00:de:83:e3:cb:09:c5: + 14:6e:9a:1f:28:0d:4a:7a:3b:90:19:13:e6:d0:32: + 08:6f:97:5f:2a:3e:a7:88:ef:98:01:fd:0c:2c:2b: + ba:5c:24:33:1d:b7:c3:48:55:d5:e3:5e:c0:ea:e9: + b2:8b:f5:b4:5d:10:50:48:88:59:0b:48:a5:80:94: + 2a:34:d6:b8:47:e6:ee:23:cc:e1:72:cf:ce:97:34: + 99:01:2f:66:7e:d4:39:be:5a:0a:01:47:8e:1d:5f: + 83:34:bf:69:6b:12:63:4c:47:25:0d:4c:b0:07:db: + 32:c7 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 24:53:64:B9:97:60:01:71:F1:EA:6F:82:9E:63:93:B6:C2:87:CC:72 + 66:B2:C9:2E:D5:94:64:B0:57:CC:2C:7C:47:3E:4C:32:A0:62:1D:ED X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - c5:32:68:ce:13:b6:f5:c3:9d:82:70:a3:b7:1b:0b:d0:4e:8c: - 2f:8d:1b:cb:6e:b9:66:32:a6:1f:3d:c8:b5:bb:b3:10:b9:6c: - 89:78:92:b5:e7:a8:ee:af:d0:8f:09:15:77:a0:45:cf:86:5f: - f7:41:86:97:87:00:8d:e7:55:ea:29:77:95:ea:a5:08:6a:1e: - 3b:e2:cc:63:f2:23:a4:63:ab:dd:e0:ee:0b:6c:dc:d6:ed:9a: - b2:84:a8:b8:0b:6a:9e:d9:78:1d:3f:56:75:ff:55:f8:7c:78: - 9a:88:73:31:64:b0:9b:36:67:7f:6e:5d:18:4b:ab:8d:67:06: - 43:91:19:76:df:f5:c7:4f:58:2a:56:19:f4:81:8a:6e:65:76: - 65:48:e1:3e:11:5b:88:6b:c0:46:b2:5e:79:4e:91:ff:94:d5: - 52:d5:63:66:08:99:2b:2a:7d:f4:f6:19:9c:33:00:ee:03:75: - 74:a9:72:90:c3:26:26:8f:d9:1e:f6:ed:ca:c1:a7:f1:c5:ce: - 12:ec:35:4d:45:db:87:01:d8:d5:31:56:35:5b:6f:9d:b8:18: - b6:61:e8:3c:fb:fb:23:32:a5:62:25:50:61:80:1f:02:0a:28: - 62:78:92:89:58:8d:18:23:6d:7c:ee:93:55:aa:2d:5c:e8:72: - f6:04:0a:9b + 5d:52:44:7e:39:ff:d6:01:44:8a:a3:f2:b2:13:98:d2:cd:e1: + 00:09:23:2d:05:3a:73:39:96:c6:88:c2:c1:5f:b8:8a:2b:18: + 8c:71:df:56:87:ed:8d:d1:14:36:c3:ef:58:8a:99:ce:88:ba: + f3:80:d6:7f:31:2e:3d:3a:22:7d:de:1b:33:94:33:b1:e4:cb: + 30:bc:a6:48:fa:f9:1f:f3:12:a8:9f:38:5c:10:7d:50:d2:65: + ab:10:06:19:de:2f:a5:42:3f:70:1b:99:79:96:9d:e2:74:2a: + 90:b7:a7:37:61:23:3e:b9:c2:ae:d8:1a:a5:00:60:c6:e8:48: + ce:98:3e:0a:04:12:0c:ce:e1:3b:7a:14:e8:0a:44:78:51:37: + 0d:98:05:f5:d6:43:f1:4e:a3:48:0b:ea:44:da:03:6a:90:a2: + be:85:91:b6:07:43:ec:32:f8:d8:36:7f:d9:17:c9:ee:7b:50: + d6:ef:2b:1f:f2:9c:41:35:9d:7d:8a:34:87:df:3e:c7:78:55: + cc:89:b5:30:07:13:66:a8:ab:f8:72:9f:13:ed:58:14:25:85: + 06:1d:56:5b:84:5b:8a:53:22:73:55:17:08:0a:38:d7:1e:2f: + 74:58:d2:2b:72:64:a0:40:eb:ac:1a:bd:c6:65:ea:a4:3e:13: + 62:04:39:e0 -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqrDANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTA4MTAzMDAwMDAwMFoXDTE4MTAyOTAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBALEDNkn4lg1kqdY2Ssgkt1t1FC6r3OM2E5kr -FbUx9gRSOsjn9Gj27KkoyMVMFmtap/yrelLRIc6mw4azjh3G5ZhJq4Eta5i0iXgs -wTNEj6b0GGkdQlj2y5tCKwVbmIU2gFa3Pv8JctUORJ445Ff50wywIcNJgGMQnjOz -B4qliTxY9Hg5DNmRTeGlSNHm8n7+11rnDx5gDZOvxNUWBUOJioWtfXTiYfWEQwKa -ifX8VriUtFat18JxqGTyyCx8BgBRQS3vuA7m8Hdhr7KsHz2CPVcsAuS6thHMB3Kx -qGml0KbRTdV2TkGAptg+qoCtpkXejLuDt3+l6Y14WHhKTHMQILkCAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFCRTZLmXYAFx8epvgp5jk7bCh8xyMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQDFMmjOE7b1w52CcKO3GwvQTowvjRvLbrlmMqYfPci1u7MQuWyJeJK156jur9CP -CRV3oEXPhl/3QYaXhwCN51XqKXeV6qUIah474sxj8iOkY6vd4O4LbNzW7ZqyhKi4 -C2qe2XgdP1Z1/1X4fHiaiHMxZLCbNmd/bl0YS6uNZwZDkRl23/XHT1gqVhn0gYpu -ZXZlSOE+EVuIa8BGsl55TpH/lNVS1WNmCJkrKn309hmcMwDuA3V0qXKQwyYmj9ke -9u3Kwafxxc4S7DVNRduHAdjVMVY1W2+duBi2Yeg8+/sjMqViJVBhgB8CCihieJKJ -WI0YI2187pNVqi1c6HL2BAqb +MIIDvzCCAqegAwIBAgIBDDANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTA4MTAzMDAw +MDAwMFoXDTE4MTAyOTAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAK4hs39cGd/9l1HN1DA161BOZgN4eRCCywJfr2MwSlTvPju4dn9zI4in +TzxleBsR6knxJdTMF2cSUc6h9hVXxpwZPIzwnc7FXqQ212HTISHHM3hH1nTp+rjY +8vQBtKyfadAJvBp8NXwSxFS6WyuAN2x1/gg2RLzxO6nJK6CX+HVPzSck8GZei7mw +sUlQgIAA3oPjywnFFG6aHygNSno7kBkT5tAyCG+XXyo+p4jvmAH9DCwrulwkMx23 +w0hV1eNewOrpsov1tF0QUEiIWQtIpYCUKjTWuEfm7iPM4XLPzpc0mQEvZn7UOb5a +CgFHjh1fgzS/aWsSY0xHJQ1MsAfbMscCAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFGayyS7VlGSwV8wsfEc+TDKgYh3tMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQBdUkR+Of/WAUSKo/Ky +E5jSzeEACSMtBTpzOZbGiMLBX7iKKxiMcd9Wh+2N0RQ2w+9YipnOiLrzgNZ/MS49 +OiJ93hszlDOx5MswvKZI+vkf8xKonzhcEH1Q0mWrEAYZ3i+lQj9wG5l5lp3idCqQ +t6c3YSM+ucKu2BqlAGDG6EjOmD4KBBIMzuE7ehToCkR4UTcNmAX11kPxTqNIC+pE +2gNqkKK+hZG2B0PsMvjYNn/ZF8nue1DW7ysf8pxBNZ19ijSH3z7HeFXMibUwBxNm +qKv4cp8T7VgUJYUGHVZbhFuKUyJzVRcICjjXHi90WNIrcmSgQOusGr3GZeqkPhNi +BDng -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/11_year_validity.pem b/net/data/ssl/certificates/11_year_validity.pem index e18ba63..50eb0894 100644 --- a/net/data/ssl/certificates/11_year_validity.pem +++ b/net/data/ssl/certificates/11_year_validity.pem
@@ -1,42 +1,41 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:ad - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 13 (0xd) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Oct 30 00:00:00 2014 GMT - Not After : Oct 30 00:00:00 2025 GMT + Not After : Jun 2 17:10:52 2028 GMT Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:b1:49:dd:3b:68:74:39:a7:8a:02:e6:32:0d:d9: - 0e:08:5d:77:36:f5:a5:5b:34:aa:84:c5:6e:e4:32: - 9c:3b:bf:36:0c:72:8c:98:a3:59:e1:60:c5:d8:ee: - f2:04:ac:4c:9b:e7:a6:d8:6b:24:cf:87:4b:55:82: - bf:0c:67:c1:9c:63:4e:d8:41:4d:15:5b:44:01:8d: - db:ca:b8:1a:ef:26:36:d0:ad:50:67:5d:4f:2f:ef: - 51:e7:78:0e:40:e9:e7:e0:a6:e8:f9:39:8d:47:a3: - 8c:14:bc:af:dd:f4:f5:64:33:04:78:39:22:b4:a2: - b1:11:71:94:50:a8:2a:98:22:c6:c4:7a:ff:8b:a4: - 54:c0:0c:db:55:5f:2e:58:a5:fd:13:5c:df:9c:bc: - 5f:96:2c:3e:ee:df:71:64:07:c6:60:0d:6c:b5:6f: - 50:d9:21:eb:4c:6e:15:1a:90:2e:11:49:64:36:a3: - 04:03:39:14:1e:ad:32:be:69:8b:26:92:ca:38:a8: - 51:49:c0:1e:5c:d1:2f:d2:e3:b2:11:a6:88:d7:61: - f8:4f:c0:61:d1:6f:41:92:b1:6a:21:38:ff:8b:37: - ba:f3:49:b9:45:74:f5:7c:c5:65:fb:c0:dd:65:b1: - 3c:ba:ed:0c:46:e8:62:06:82:77:8e:df:52:d1:a5: - 7c:c5 + 00:d2:33:c9:3e:ee:c5:00:08:54:d0:a9:26:f1:21: + 21:86:20:92:dc:1f:c9:0f:95:c3:60:8b:72:14:51: + 60:44:6e:b6:bd:f4:59:28:70:4c:df:87:e0:c9:2c: + db:c8:b3:4d:c8:72:92:0e:ab:55:a5:10:8e:e4:cf: + 77:23:77:25:a5:62:95:fc:32:b3:da:66:2f:ae:23: + 5e:3d:aa:1d:87:96:61:a5:eb:86:39:e1:74:a2:1d: + a2:50:e1:93:e6:dc:ab:70:99:e4:e4:49:72:6c:00: + e8:53:06:1f:86:19:37:79:83:2e:a5:69:b7:80:4c: + 06:f4:1c:6f:61:76:6b:71:da:ef:0d:2d:30:20:8c: + d1:69:9b:c1:63:00:6f:8f:af:6e:f0:0f:64:bd:fd: + 3a:17:dd:fe:62:44:b2:74:33:2d:98:de:04:e1:e9: + e7:92:1d:bf:9b:dc:3c:90:b9:db:1d:ba:cf:84:72: + 27:54:e9:59:10:37:44:db:5e:1c:ba:45:16:9c:9b: + 85:7d:c2:8f:74:da:8c:12:4f:fc:64:8f:4d:7b:91: + 84:2b:10:b6:a3:ab:f6:0d:f0:27:73:55:0c:2d:1c: + 2b:2f:7d:bc:46:70:c7:25:c1:b2:0c:2a:21:e5:a2: + 42:7f:91:4c:e7:f6:50:76:26:82:78:f0:50:88:45: + 68:71 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - ED:37:D9:2A:6C:CB:3D:D8:B2:05:8F:1B:D5:10:69:79:95:C0:13:62 + 49:8C:47:E1:3D:FB:65:5C:B5:B9:78:5A:DC:3D:AC:DC:C2:55:84:BA X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 9e:18:73:a8:48:59:21:7d:bc:f4:26:88:2f:45:52:3f:3d:9b: - a8:60:8f:60:96:fa:6d:17:74:87:41:12:da:f7:59:c4:6a:52: - 02:82:f0:b9:a5:b5:f8:36:a0:c1:f7:90:6e:c6:41:9f:28:34: - 13:5e:5e:cd:68:e8:1e:76:f6:3c:16:03:73:f0:5b:ca:22:34: - 90:36:fa:b3:4b:33:16:63:c1:b0:c9:2b:ac:a8:60:4b:ff:4d: - 9b:a0:d4:a9:f9:b1:b2:4a:48:91:06:79:d2:19:45:d2:07:61: - 5e:c4:7b:8b:30:89:14:4f:97:79:c9:a8:f9:0d:90:47:d0:f5: - dd:6d:b3:b7:d0:7e:4a:cf:21:c5:9a:13:2e:b8:d6:bf:5b:bf: - 6c:0e:2c:89:51:02:99:d2:ab:c5:cb:1f:38:91:bc:cd:11:01: - 76:62:66:15:c1:b1:3c:36:e2:d7:13:b1:e0:59:12:54:43:4e: - ba:f3:b7:47:e9:01:ef:f2:82:85:3f:8e:0b:58:70:2b:07:f4: - 37:df:0e:2d:88:48:76:76:4b:33:c6:ce:8b:11:dc:ac:7a:a9: - e8:07:25:1b:12:33:c3:12:8c:1d:31:59:f4:02:fb:d1:97:df: - 7b:ea:20:b7:ef:b0:e8:4b:57:74:21:f8:9e:81:02:ec:bc:d2: - 56:fc:0a:27 + 16:b3:2e:6b:4a:d1:8b:ea:56:72:cd:e7:e7:51:1f:70:19:48: + 52:5c:6f:b6:ba:e0:f1:0a:0f:38:aa:ed:de:8c:32:56:74:1d: + 69:30:ee:68:ba:2b:7e:6b:93:f0:69:7f:5f:bb:18:88:41:3e: + 86:3a:00:f8:23:f9:d1:ab:53:9d:50:ea:2e:37:37:0d:0a:cc: + af:22:90:11:29:f3:b6:d4:28:47:83:75:66:19:19:88:a0:20: + 6b:64:7b:95:32:5d:85:14:c6:a6:77:11:a5:c4:72:72:c1:aa: + 3a:dd:ee:dc:28:71:4e:1e:ae:d5:1d:74:3e:71:8a:da:7e:f8: + 4c:2c:20:6c:01:ee:33:90:27:3a:5d:87:75:73:4c:24:c0:ad: + b0:6e:a3:32:bc:e4:93:53:73:40:cb:37:55:4b:d2:d5:79:b9: + 86:bc:69:35:d1:33:11:4a:33:ad:d1:78:18:99:c8:b0:fb:c6: + 82:40:87:56:47:ff:f1:ec:2a:07:53:ea:7f:17:a8:78:3c:21: + e5:e7:6e:54:16:02:8b:71:c9:fb:41:c4:f7:f0:1d:9d:8e:5b: + 94:6f:2c:25:12:95:02:ca:08:d5:42:16:fd:b8:dc:d8:4b:07: + 8f:bb:b2:4e:51:e8:32:87:61:a1:96:de:ff:24:86:4f:41:38: + 65:18:f0:b8 -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqrTANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE0MTAzMDAwMDAwMFoXDTI1MTAzMDAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBALFJ3TtodDmnigLmMg3ZDghddzb1pVs0qoTF -buQynDu/NgxyjJijWeFgxdju8gSsTJvnpthrJM+HS1WCvwxnwZxjTthBTRVbRAGN -28q4Gu8mNtCtUGddTy/vUed4DkDp5+Cm6Pk5jUejjBS8r9309WQzBHg5IrSisRFx -lFCoKpgixsR6/4ukVMAM21VfLlil/RNc35y8X5YsPu7fcWQHxmANbLVvUNkh60xu -FRqQLhFJZDajBAM5FB6tMr5piyaSyjioUUnAHlzRL9LjshGmiNdh+E/AYdFvQZKx -aiE4/4s3uvNJuUV09XzFZfvA3WWxPLrtDEboYgaCd47fUtGlfMUCAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFO032Spsyz3YsgWPG9UQaXmVwBNiMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQCeGHOoSFkhfbz0JogvRVI/PZuoYI9glvptF3SHQRLa91nEalICgvC5pbX4NqDB -95BuxkGfKDQTXl7NaOgedvY8FgNz8FvKIjSQNvqzSzMWY8GwySusqGBL/02boNSp -+bGySkiRBnnSGUXSB2FexHuLMIkUT5d5yaj5DZBH0PXdbbO30H5KzyHFmhMuuNa/ -W79sDiyJUQKZ0qvFyx84kbzNEQF2YmYVwbE8NuLXE7HgWRJUQ06687dH6QHv8oKF -P44LWHArB/Q33w4tiEh2dkszxs6LEdyseqnoByUbEjPDEowdMVn0AvvRl9976iC3 -77DoS1d0IfiegQLsvNJW/Aon +MIIDvzCCAqegAwIBAgIBDTANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE0MTAzMDAw +MDAwMFoXDTI4MDYwMjE3MTA1MlowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBANIzyT7uxQAIVNCpJvEhIYYgktwfyQ+Vw2CLchRRYERutr30WShwTN+H +4Mks28izTchykg6rVaUQjuTPdyN3JaVilfwys9pmL64jXj2qHYeWYaXrhjnhdKId +olDhk+bcq3CZ5ORJcmwA6FMGH4YZN3mDLqVpt4BMBvQcb2F2a3Ha7w0tMCCM0Wmb +wWMAb4+vbvAPZL39Ohfd/mJEsnQzLZjeBOHp55Idv5vcPJC52x26z4RyJ1TpWRA3 +RNteHLpFFpybhX3Cj3TajBJP/GSPTXuRhCsQtqOr9g3wJ3NVDC0cKy99vEZwxyXB +sgwqIeWiQn+RTOf2UHYmgnjwUIhFaHECAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFEmMR+E9+2Vctbl4Wtw9rNzCVYS6MB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQAWsy5rStGL6lZyzefn +UR9wGUhSXG+2uuDxCg84qu3ejDJWdB1pMO5ouit+a5PwaX9fuxiIQT6GOgD4I/nR +q1OdUOouNzcNCsyvIpARKfO21ChHg3VmGRmIoCBrZHuVMl2FFMamdxGlxHJywao6 +3e7cKHFOHq7VHXQ+cYrafvhMLCBsAe4zkCc6XYd1c0wkwK2wbqMyvOSTU3NAyzdV +S9LVebmGvGk10TMRSjOt0XgYmciw+8aCQIdWR//x7CoHU+p/F6h4PCHl525UFgKL +ccn7QcT38B2djluUbywlEpUCygjVQhb9uNzYSwePu7JOUegyh2Ghlt7/JIZPQThl +GPC4 -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/39_months_after_2015_04.pem b/net/data/ssl/certificates/39_months_after_2015_04.pem index 3e9765e..d988960a 100644 --- a/net/data/ssl/certificates/39_months_after_2015_04.pem +++ b/net/data/ssl/certificates/39_months_after_2015_04.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:ae - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 14 (0xe) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Apr 2 00:00:00 2015 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:b8:6e:8d:68:4f:77:ca:bd:68:33:e0:34:86:88: - c0:77:99:40:10:59:4c:13:26:35:82:ca:a9:95:6d: - 2d:5b:db:08:54:25:9b:89:17:7b:95:f9:76:73:51: - 0f:04:de:ba:d0:24:7d:53:e7:17:87:e7:29:96:23: - f1:79:a6:48:99:e7:f0:58:d1:82:2d:97:33:8f:7f: - 21:7b:33:b8:bb:66:a2:cb:9f:14:12:15:9c:b4:8c: - b4:eb:e3:90:5a:3a:60:fe:0a:cc:60:38:62:75:5b: - 90:15:39:10:19:44:67:c2:bf:e2:00:c1:85:f8:9e: - 2a:66:c7:75:36:d3:f4:c0:9e:aa:1d:2f:6f:17:20: - 35:3d:eb:b6:e1:2a:28:1d:c9:d3:c5:49:a2:e0:30: - 45:09:88:1d:39:c3:ba:f2:fa:de:a6:b6:95:fa:4f: - 1d:cf:8b:35:46:48:24:a6:b0:f0:6f:e6:e2:20:75: - 8a:1b:84:08:90:e6:c4:99:ab:f2:b5:7d:cf:58:b2: - f8:24:fd:70:01:bf:e4:bd:34:9f:54:a7:27:6e:50: - 12:76:0c:05:46:15:46:43:4c:85:79:e1:b0:b4:58: - 5d:0e:82:9e:c0:74:ef:00:6e:7c:87:39:86:c3:7d: - 28:cd:4c:04:c8:04:76:95:74:8a:b9:b9:e5:69:1e: - 4e:bf + 00:ab:bd:7c:d8:34:99:c9:fa:d9:7e:0a:ac:77:89: + fb:de:ee:b0:ec:59:45:f6:a0:15:b9:60:2a:0a:8f: + 77:a7:43:dc:62:e6:20:9e:ef:9f:c3:4f:59:f4:cb: + 23:32:85:0f:a4:66:77:f6:bc:f2:1b:d1:b7:dc:c3: + 66:a0:83:37:73:2a:6a:80:9b:a1:aa:8c:18:ad:49: + b0:44:e8:cf:11:da:0d:52:ab:59:50:d4:87:c8:98: + 4f:fc:7e:46:49:53:e5:3b:10:dd:29:7b:0b:fa:38: + 76:7e:b5:a6:a8:9b:e4:20:b8:99:18:7d:57:46:dd: + 33:46:7a:2a:ae:dc:3b:18:1b:68:b3:36:37:6d:1a: + ec:78:f5:65:0f:5d:f9:1b:ec:68:7d:a4:83:79:ad: + cc:a0:68:4f:6c:5b:36:c1:48:0b:3f:3e:4c:ae:91: + de:4a:db:f6:a9:82:c2:54:9d:6f:28:db:00:bb:0f: + a4:44:43:40:c3:b0:e3:ec:f8:57:8c:c1:db:bb:00: + 64:15:48:06:7b:01:da:34:bc:ac:c1:61:ec:07:76: + 80:08:86:94:34:c4:d8:db:65:80:6a:7f:c0:b9:61: + f5:3c:92:99:45:ce:17:92:81:81:32:43:39:35:ac: + a4:04:5a:d6:f0:5e:01:3e:f2:3f:3b:74:c9:33:77: + 87:c1 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 2B:FE:91:91:29:47:E7:52:B7:72:F9:10:DF:E9:16:03:E5:5E:CB:18 + 10:E9:95:5F:D7:78:0F:A8:F8:3C:89:9A:36:AA:E9:F2:52:C3:60:30 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 37:49:01:63:f6:d0:5d:df:c6:49:f2:3a:4a:62:cc:f9:c2:23: - 07:7f:bf:08:be:84:93:77:6b:b2:93:86:3d:0b:d1:0e:0b:d4: - 8d:2f:eb:b4:a4:f6:19:b3:77:16:f5:29:88:5a:f0:cb:18:98: - 7c:d1:5d:23:7c:65:6c:c2:c9:95:42:1a:06:21:85:46:26:f9: - 45:1e:91:81:32:dd:e5:a3:75:d9:39:14:8a:2e:bb:35:7e:6a: - a8:77:2c:4e:7e:5d:83:05:2c:b3:4b:41:9c:93:4c:d6:74:1c: - 6b:f2:98:e3:48:a4:d3:82:46:62:45:aa:4c:77:e2:7e:f3:0a: - e5:8a:0a:ef:47:d4:4a:f0:47:53:c3:25:87:9d:84:5d:3a:c4: - 79:33:0c:06:5e:98:ec:14:dc:ee:15:ca:f1:3f:b7:f3:ac:a9: - 11:2a:3f:e2:ba:bb:f9:4c:43:b9:7e:01:27:a0:9d:92:4a:02: - 21:cb:21:d7:b7:5d:f8:65:03:24:64:ac:11:d0:11:c3:93:72: - e0:be:11:73:8d:4f:7a:8d:c6:95:49:bd:84:61:95:79:3e:94: - 67:c7:55:19:87:84:c0:04:e4:8e:ce:bd:b5:bb:87:54:9f:10: - 4e:5c:43:52:c4:3c:cb:1d:e9:27:cc:f1:37:bf:cc:99:7f:71: - e5:31:49:bd + 05:a5:b1:fe:ec:c3:19:31:04:40:47:70:79:b6:c3:99:ca:ff: + 26:f8:26:88:fc:c9:fc:30:27:d7:15:4e:cb:df:45:09:1e:ea: + bc:ac:9f:99:3a:a7:cc:bf:dd:93:a7:96:ff:5b:b9:9a:bb:49: + 1d:3c:ab:53:97:c8:83:4a:87:3d:e0:81:d1:47:68:ac:ea:1f: + bc:88:3c:74:17:39:34:23:4d:28:a5:db:20:16:c7:ea:08:ef: + c4:bc:f4:8c:5a:94:b0:f6:1a:23:e3:c3:e3:a6:ef:52:f8:70: + d1:59:95:21:e7:57:b6:bb:c8:05:6a:c7:7e:ba:b8:36:4b:75: + 5c:6c:74:1f:0d:a0:18:c9:ad:db:9a:b6:f8:eb:63:25:b8:88: + 48:b7:43:68:dd:6c:ce:0b:4f:c5:1f:7b:5f:94:c6:29:62:77: + 2a:85:9c:61:8b:a7:67:c8:17:5b:2f:a7:a5:0b:d2:d8:eb:1d: + 8f:ed:67:93:3a:df:f1:29:e9:97:71:a3:01:48:3d:be:f5:15: + 5d:f5:32:bc:18:52:9f:9c:3b:64:e8:a9:55:32:91:6d:c9:cc: + 84:65:16:39:4c:ad:20:2b:e9:e9:46:f3:71:7c:44:45:05:6f: + 68:86:66:5e:0c:e2:7d:86:65:9c:6e:e5:39:2d:a8:03:30:b2: + e2:77:5d:70 -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqrjANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE1MDQwMjAwMDAwMFoXDTE4MDcwMjAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBALhujWhPd8q9aDPgNIaIwHeZQBBZTBMmNYLK -qZVtLVvbCFQlm4kXe5X5dnNRDwTeutAkfVPnF4fnKZYj8XmmSJnn8FjRgi2XM49/ -IXszuLtmosufFBIVnLSMtOvjkFo6YP4KzGA4YnVbkBU5EBlEZ8K/4gDBhfieKmbH -dTbT9MCeqh0vbxcgNT3rtuEqKB3J08VJouAwRQmIHTnDuvL63qa2lfpPHc+LNUZI -JKaw8G/m4iB1ihuECJDmxJmr8rV9z1iy+CT9cAG/5L00n1SnJ25QEnYMBUYVRkNM -hXnhsLRYXQ6CnsB07wBufIc5hsN9KM1MBMgEdpV0irm55WkeTr8CAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFCv+kZEpR+dSt3L5EN/pFgPlXssYMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQA3SQFj9tBd38ZJ8jpKYsz5wiMHf78IvoSTd2uyk4Y9C9EOC9SNL+u0pPYZs3cW -9SmIWvDLGJh80V0jfGVswsmVQhoGIYVGJvlFHpGBMt3lo3XZORSKLrs1fmqodyxO -fl2DBSyzS0Gck0zWdBxr8pjjSKTTgkZiRapMd+J+8wrligrvR9RK8EdTwyWHnYRd -OsR5MwwGXpjsFNzuFcrxP7fzrKkRKj/iurv5TEO5fgEnoJ2SSgIhyyHXt134ZQMk -ZKwR0BHDk3LgvhFzjU96jcaVSb2EYZV5PpRnx1UZh4TABOSOzr21u4dUnxBOXENS -xDzLHeknzPE3v8yZf3HlMUm9 +MIIDvzCCAqegAwIBAgIBDjANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE1MDQwMjAw +MDAwMFoXDTE4MDcwMjAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAKu9fNg0mcn62X4KrHeJ+97usOxZRfagFblgKgqPd6dD3GLmIJ7vn8NP +WfTLIzKFD6Rmd/a88hvRt9zDZqCDN3MqaoCboaqMGK1JsETozxHaDVKrWVDUh8iY +T/x+RklT5TsQ3Sl7C/o4dn61pqib5CC4mRh9V0bdM0Z6Kq7cOxgbaLM2N20a7Hj1 +ZQ9d+RvsaH2kg3mtzKBoT2xbNsFICz8+TK6R3krb9qmCwlSdbyjbALsPpERDQMOw +4+z4V4zB27sAZBVIBnsB2jS8rMFh7Ad2gAiGlDTE2NtlgGp/wLlh9TySmUXOF5KB +gTJDOTWspARa1vBeAT7yPzt0yTN3h8ECAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFBDplV/XeA+o+DyJmjaq6fJSw2AwMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQAFpbH+7MMZMQRAR3B5 +tsOZyv8m+CaI/Mn8MCfXFU7L30UJHuq8rJ+ZOqfMv92Tp5b/W7mau0kdPKtTl8iD +Soc94IHRR2is6h+8iDx0Fzk0I00opdsgFsfqCO/EvPSMWpSw9hoj48Pjpu9S+HDR +WZUh51e2u8gFasd+urg2S3VcbHQfDaAYya3bmrb462MluIhIt0No3WzOC0/FH3tf +lMYpYncqhZxhi6dnyBdbL6elC9LY6x2P7WeTOt/xKemXcaMBSD2+9RVd9TK8GFKf +nDtk6KlVMpFtycyEZRY5TK0gK+npRvNxfERFBW9ohmZeDOJ9hmWcbuU5LagDMLLi +d11w -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/39_months_based_on_last_day.pem b/net/data/ssl/certificates/39_months_based_on_last_day.pem index d2ac9f04..8009696 100644 --- a/net/data/ssl/certificates/39_months_based_on_last_day.pem +++ b/net/data/ssl/certificates/39_months_based_on_last_day.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:b2 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 30 (0x1e) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Feb 28 00:00:00 2017 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:d2:0b:08:4a:9b:6f:11:d7:ff:cf:6f:c5:ab:f7: - 3a:cd:8d:63:4c:eb:15:40:87:cc:fe:fb:39:40:c1: - ca:19:2f:4e:49:ae:53:dd:b7:4a:ae:9a:b2:e6:e5: - 6e:69:8d:0c:22:53:d9:32:a5:9f:f1:3a:62:ea:1d: - 46:ea:03:e4:8d:da:27:5e:85:03:25:16:8e:5e:a2: - ef:3b:87:7c:f9:b6:58:c8:93:2c:24:36:64:e5:96: - 30:3b:88:a1:e9:ef:8d:94:a6:cb:ae:ae:fa:b0:9b: - 9f:e9:7c:c5:d7:b7:9c:04:a3:0a:73:a1:e7:01:6f: - 3e:3b:58:14:bd:63:03:bd:4a:4a:a5:10:0f:02:8f: - 6f:4c:7d:67:c6:d5:8e:2d:95:8f:83:77:10:2a:1e: - 8d:7b:e9:33:0a:41:00:92:8a:88:16:a2:f2:86:0c: - 59:9c:08:84:fd:19:15:c6:ca:87:fe:d9:fd:0a:b4: - e5:a8:5d:47:2c:ee:e0:7f:9b:7e:0e:7e:8f:88:ff: - 31:8c:c9:02:bb:d9:c7:e4:87:e9:0e:fc:89:db:dd: - 68:ed:3f:9f:52:24:37:48:e9:f8:cc:59:74:12:05: - d1:ba:15:b9:aa:61:48:77:41:e9:d7:ed:4f:97:e1: - fd:dc:b8:f1:4b:54:97:2e:a5:0c:bb:8c:6d:4b:fa: - 2f:11 + 00:e0:95:35:0d:8e:3b:c4:7c:1d:ea:d6:1a:41:a9: + 4c:14:6e:3c:12:a3:01:55:fc:b5:ee:d5:7a:d3:4d: + b5:f4:9b:0e:57:50:cc:28:17:4f:68:93:5f:14:e2: + ac:c7:eb:1d:e1:13:82:b6:14:eb:9d:42:26:1e:3c: + 37:c7:73:e2:93:0f:d9:5b:e7:2f:46:60:54:e6:a4: + 1c:89:ac:9c:30:1f:29:bf:36:e2:88:8a:e5:ac:14: + 67:df:d7:93:38:85:d8:71:5a:5c:ae:80:d1:f9:ef: + 12:82:91:08:be:de:07:70:25:be:50:3c:c6:5e:e1: + 15:82:9d:1d:cb:2b:4c:b1:ea:2d:e4:6f:db:33:d8: + d3:27:d0:c1:8f:52:db:91:1a:b6:03:9e:fb:3b:49: + 7e:ef:4a:fd:38:b2:c6:26:ea:63:85:be:0f:50:c3: + 24:4c:36:dc:96:7b:ae:59:1f:c5:44:2a:14:76:71: + 39:ab:ac:0e:ad:bb:ca:32:94:9c:d4:5b:7d:71:6b: + c9:e8:4b:80:8f:e4:b8:07:bf:70:05:2f:52:b7:86: + 7c:ca:de:b3:b3:38:56:5f:35:96:15:94:c3:0d:fd: + 45:2b:38:ee:ca:ee:77:34:62:5d:85:57:d1:e3:30: + 24:0e:b1:5c:21:80:5b:24:82:01:67:25:12:a7:8b: + 3c:11 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 10:8D:94:CF:31:9D:7D:3E:3A:DD:47:D6:87:88:36:B2:20:57:55:9C + 39:50:0A:32:04:A7:EC:70:F4:1B:1E:68:F3:B3:40:57:A7:55:4D:8A X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 5d:08:1a:36:85:35:31:62:46:c4:bd:dd:2c:1e:d3:0d:ed:07: - 5e:d4:7f:06:44:4f:17:f2:7c:32:78:b7:4c:25:a7:c5:81:26: - 65:20:5c:c9:30:53:02:19:05:75:1d:be:ef:a9:9b:53:27:34: - 1c:19:c5:52:cb:c0:c2:ac:78:ff:27:22:b4:e1:8b:32:ae:5b: - cb:08:0b:c2:4f:27:70:89:9f:e3:be:09:d7:e6:33:88:8b:74: - 57:1a:8d:79:5e:8b:20:a3:12:3e:9b:56:73:82:9e:35:00:8a: - 5a:38:0b:4e:e9:9e:43:63:93:61:df:b6:e3:00:4b:b2:4a:f9: - 0a:74:fa:d5:aa:06:b5:44:07:c7:46:6c:4a:2a:69:fc:2a:34: - 77:16:b4:6c:e1:a5:b2:e3:d0:4a:39:87:87:16:ba:6b:ea:ab: - a1:c5:81:64:55:cf:68:74:63:d0:95:2e:2c:39:62:75:b8:f2: - c1:7f:0f:30:50:10:d3:9b:84:bd:07:63:b7:1c:58:de:dc:e4: - b1:74:48:00:b7:89:d9:02:83:37:c7:ea:94:dd:af:3f:fd:47: - 86:70:d1:d0:d0:06:36:6c:3f:b1:8a:e7:db:6a:f0:b7:82:5c: - c0:d9:ca:30:ff:4e:d5:cd:e3:d5:4c:7e:86:7f:7e:5f:2b:d1: - d4:3e:2c:5f + 83:f0:0b:fc:3c:6e:40:6b:00:58:de:43:2a:d4:ea:08:8c:88: + 9c:02:76:7d:9f:55:08:fc:da:c0:fe:9a:07:84:c2:5d:85:06: + ec:ee:e4:8a:c4:c1:f2:6e:6e:a8:bc:8f:de:d2:b4:39:43:c8: + 99:56:57:b8:f7:2e:8c:90:a5:fd:7d:1f:79:8d:e1:2a:59:65: + e6:9b:2b:5d:62:7b:b0:e5:66:45:5e:fe:a3:44:52:34:40:90: + f6:35:dd:51:7d:38:07:0b:cd:84:ec:68:19:c5:c8:b4:0e:19: + 7f:f0:a8:92:33:59:8c:24:a8:7d:f0:b3:4b:3c:20:09:5d:b6: + 78:a2:b3:1e:86:e3:88:ff:94:00:74:97:d0:41:91:45:f5:1d: + 32:e2:3f:fa:cc:90:2a:fd:8d:e2:84:e5:1b:16:83:13:3e:1c: + 6b:9f:55:0a:b9:00:16:b7:3f:07:68:1b:60:cf:46:56:ba:54: + 05:06:90:6b:40:16:cd:4c:67:46:87:f1:05:35:c6:ca:07:fb: + e2:ca:c1:ed:37:1e:a5:ec:87:ca:4f:bf:98:e6:07:8e:66:76: + 26:67:b9:28:5f:95:ef:83:35:09:94:ba:2b:48:53:51:0d:85: + 62:7e:b3:a3:d0:f7:44:62:14:21:bf:b8:99:2b:b6:0b:be:b8: + c9:ee:96:56 -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqsjANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE3MDIyODAwMDAwMFoXDTIwMDUzMDAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBANILCEqbbxHX/89vxav3Os2NY0zrFUCHzP77 -OUDByhkvTkmuU923Sq6asublbmmNDCJT2TKln/E6YuodRuoD5I3aJ16FAyUWjl6i -7zuHfPm2WMiTLCQ2ZOWWMDuIoenvjZSmy66u+rCbn+l8xde3nASjCnOh5wFvPjtY -FL1jA71KSqUQDwKPb0x9Z8bVji2Vj4N3ECoejXvpMwpBAJKKiBai8oYMWZwIhP0Z -FcbKh/7Z/Qq05ahdRyzu4H+bfg5+j4j/MYzJArvZx+SH6Q78idvdaO0/n1IkN0jp -+MxZdBIF0boVuaphSHdB6dftT5fh/dy48UtUly6lDLuMbUv6LxECAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFBCNlM8xnX0+Ot1H1oeINrIgV1WcMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQBdCBo2hTUxYkbEvd0sHtMN7Qde1H8GRE8X8nwyeLdMJafFgSZlIFzJMFMCGQV1 -Hb7vqZtTJzQcGcVSy8DCrHj/JyK04YsyrlvLCAvCTydwiZ/jvgnX5jOIi3RXGo15 -XosgoxI+m1Zzgp41AIpaOAtO6Z5DY5Nh37bjAEuySvkKdPrVqga1RAfHRmxKKmn8 -KjR3FrRs4aWy49BKOYeHFrpr6quhxYFkVc9odGPQlS4sOWJ1uPLBfw8wUBDTm4S9 -B2O3HFje3OSxdEgAt4nZAoM3x+qU3a8//UeGcNHQ0AY2bD+xiufbavC3glzA2cow -/07VzePVTH6Gf35fK9HUPixf +MIIDvzCCAqegAwIBAgIBHjANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE3MDIyODAw +MDAwMFoXDTIwMDUzMDAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAOCVNQ2OO8R8HerWGkGpTBRuPBKjAVX8te7VetNNtfSbDldQzCgXT2iT +XxTirMfrHeETgrYU651CJh48N8dz4pMP2VvnL0ZgVOakHImsnDAfKb824oiK5awU +Z9/XkziF2HFaXK6A0fnvEoKRCL7eB3AlvlA8xl7hFYKdHcsrTLHqLeRv2zPY0yfQ +wY9S25EatgOe+ztJfu9K/TiyxibqY4W+D1DDJEw23JZ7rlkfxUQqFHZxOausDq27 +yjKUnNRbfXFryehLgI/kuAe/cAUvUreGfMres7M4Vl81lhWUww39RSs47srudzRi +XYVX0eMwJA6xXCGAWySCAWclEqeLPBECAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFDlQCjIEp+xw9BseaPOzQFenVU2KMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQCD8Av8PG5AawBY3kMq +1OoIjIicAnZ9n1UI/NrA/poHhMJdhQbs7uSKxMHybm6ovI/e0rQ5Q8iZVle49y6M +kKX9fR95jeEqWWXmmytdYnuw5WZFXv6jRFI0QJD2Nd1RfTgHC82E7GgZxci0Dhl/ +8KiSM1mMJKh98LNLPCAJXbZ4orMehuOI/5QAdJfQQZFF9R0y4j/6zJAq/Y3ihOUb +FoMTPhxrn1UKuQAWtz8HaBtgz0ZWulQFBpBrQBbNTGdGh/EFNcbKB/viysHtNx6l +7IfKT7+Y5geOZnYmZ7koX5XvgzUJlLorSFNRDYVifrOj0PdEYhQhv7iZK7YLvrjJ +7pZW -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/40_months_after_2015_04.pem b/net/data/ssl/certificates/40_months_after_2015_04.pem index d1b165b..df5acc8c 100644 --- a/net/data/ssl/certificates/40_months_after_2015_04.pem +++ b/net/data/ssl/certificates/40_months_after_2015_04.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:af - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 15 (0xf) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Apr 2 00:00:00 2015 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:c6:38:11:5d:02:9c:2e:98:d0:8b:06:27:b3:11: - f2:f3:36:55:3d:e4:4e:6b:6b:0a:99:0d:69:1d:57: - 61:6b:f2:c6:20:6f:b0:bc:50:b3:44:00:13:09:23: - e7:18:5a:49:90:48:cd:b1:c7:9a:e9:a1:ef:9d:92: - 67:c9:ca:a8:ff:43:49:1b:8f:48:4a:63:ec:48:9c: - e2:e6:92:ea:7a:d4:04:92:de:46:88:0d:56:54:4b: - 43:29:54:f6:85:ff:9c:99:83:c2:64:0a:f6:da:cd: - fd:81:29:be:3e:25:99:1a:9c:94:22:52:f0:9c:b8: - 45:32:61:68:b3:5d:e2:9d:f6:3f:04:6f:49:c8:d8: - 22:9b:46:ca:73:99:62:a7:38:fb:27:ec:55:74:5c: - cd:83:b8:be:30:28:f8:18:c4:e5:08:36:09:e6:7e: - 59:e7:cb:2b:f7:b2:8e:2b:46:6b:15:19:61:19:0c: - ba:bf:5d:0d:d3:7a:3a:06:96:79:5e:cb:f4:5b:c8: - 54:f4:0f:e7:68:63:64:bc:69:61:ec:a6:5f:74:18: - 60:a3:7c:86:db:ca:2f:2b:3e:e2:8b:75:21:c4:b8: - 21:a4:65:30:bb:fe:f3:6f:d8:d5:fb:67:d3:65:4d: - 9f:b1:98:5a:3c:ac:6b:4d:d2:32:4e:98:b9:16:a2: - 70:91 + 00:b9:66:bc:55:7c:ca:70:eb:2e:6a:8b:11:8c:af: + 1e:2d:e2:ae:a5:b9:96:be:0a:16:08:2b:98:d6:8c: + a6:24:87:a8:0e:2e:23:f0:5a:8b:fa:6e:b7:dc:b2: + 2a:56:57:d7:76:91:69:c3:23:44:f3:40:74:d7:83: + 6d:fb:94:d9:e8:e6:34:96:2d:cb:43:02:69:c4:5f: + c0:01:09:9a:0f:55:5b:f5:b8:77:5e:ab:0b:58:46: + 1f:d4:42:59:43:3f:5a:92:5a:ca:22:8d:a9:18:ff: + ac:48:e9:f3:a4:a4:f3:d5:9b:e8:23:70:cd:26:f2: + 02:0b:e3:1e:a5:e6:ea:46:0f:39:06:fb:1b:f3:e9: + ce:65:df:15:e6:3f:72:c0:03:72:5e:3d:e0:4c:94: + 27:8c:ee:76:44:49:eb:f0:27:0f:d9:fc:02:fe:e5: + fd:70:d8:fe:8a:a6:99:61:52:76:b9:6b:af:89:50: + 84:ab:2b:c9:2a:13:0d:3b:f8:fe:50:61:a8:e0:57: + e1:f6:14:66:00:55:15:b3:99:03:be:fe:6f:24:39: + 12:b6:8b:bd:d5:60:7f:21:c2:24:68:07:62:dd:73: + 72:49:0a:09:cc:65:27:7c:37:0e:00:9b:b5:8a:4f: + 70:fb:c5:14:34:42:cb:27:4b:22:50:8d:5b:17:0f: + 9b:85 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 5C:12:BB:05:BF:14:14:34:85:67:ED:C5:E3:3B:BF:FC:49:27:AE:E3 + CE:65:A6:37:A7:B6:38:4B:38:A3:6E:80:C7:7C:13:FB:51:C2:45:B6 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 31:3a:7d:11:f7:80:72:df:80:6b:c8:e9:72:e1:f3:b5:3e:09: - a0:79:44:8a:08:5a:3e:e0:f7:7e:59:66:df:99:c6:d8:09:6b: - cc:c8:9e:76:4f:c5:5b:57:db:e0:08:3c:ce:de:3f:87:fd:71: - f6:f9:b2:a1:70:27:a7:60:d7:49:d8:2b:b7:a4:86:a1:e7:ff: - 4e:ee:41:18:1e:2c:aa:14:55:3a:ce:b4:1c:58:c5:28:71:33: - f7:4c:5f:36:f8:de:e7:43:34:92:6e:d6:15:14:43:67:43:94: - f8:79:0d:77:3d:cb:6a:3e:d2:ae:85:3d:9c:f6:b7:93:dc:81: - f1:b3:49:ab:00:47:4f:e9:61:b8:dc:bd:81:7a:d4:d0:07:3a: - 10:d1:7c:93:e9:d2:09:2e:9f:f6:c2:46:6c:63:ec:da:f2:f1: - aa:31:a9:a9:e3:0d:c5:d7:d5:72:a8:77:b6:62:b7:63:84:45: - ce:bc:c9:32:42:8f:71:6c:6a:f0:10:33:25:1d:24:d3:06:f2: - 0b:fc:5b:9c:e3:10:46:bf:00:90:0b:61:cf:5a:f0:ba:0b:fd: - b9:2c:d0:aa:b0:65:b5:ac:21:d1:b1:4b:f2:d0:ca:58:80:f4: - 81:2d:3a:fb:81:0a:71:d1:d4:63:9c:0a:f9:c5:1d:1e:52:40: - 48:e4:ad:46 + 25:63:1e:16:83:f3:48:52:80:be:0b:82:4c:24:27:58:44:b0: + 1a:38:e4:4d:49:b8:86:43:a2:c7:59:31:40:74:3b:a7:18:07: + 30:7d:f6:5c:e5:f3:1f:49:d3:32:1c:f1:b9:47:c8:52:5b:19: + 93:a9:6b:80:41:96:a9:35:ce:d1:ff:9d:82:c6:13:ca:04:56: + 38:fc:df:cf:5a:54:5f:77:a9:28:c5:c6:0b:0b:56:04:e8:37: + 73:d3:8e:b9:6f:c8:92:46:ab:35:07:5e:55:06:d2:fc:ac:8b: + e2:c7:4d:6c:30:1f:db:c1:29:b9:1b:2a:e1:b3:43:37:33:42: + ad:3a:fa:20:96:46:f5:84:ea:15:c2:83:c9:12:c7:71:54:37: + 53:88:45:00:aa:62:d9:c1:f5:1e:c5:f1:11:95:7d:31:54:21: + 56:37:1d:36:b0:42:c8:a8:6d:83:01:8d:14:f8:e3:88:05:b6: + 81:43:d3:19:5d:3b:f4:6b:81:cf:2b:e8:cd:57:54:0e:6f:7a: + ef:fc:47:e6:3c:a9:cb:14:4a:6e:29:c7:00:ae:86:c3:fe:74: + 38:92:37:bd:6a:08:97:f5:5c:26:b6:15:41:11:7a:1e:b9:71: + e7:9e:73:6b:f4:10:03:76:43:86:91:02:f8:30:4c:e7:bc:af: + 55:10:bf:52 -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqrzANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE1MDQwMjAwMDAwMFoXDTE4MDgwMTAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAMY4EV0CnC6Y0IsGJ7MR8vM2VT3kTmtrCpkN -aR1XYWvyxiBvsLxQs0QAEwkj5xhaSZBIzbHHmumh752SZ8nKqP9DSRuPSEpj7Eic -4uaS6nrUBJLeRogNVlRLQylU9oX/nJmDwmQK9trN/YEpvj4lmRqclCJS8Jy4RTJh -aLNd4p32PwRvScjYIptGynOZYqc4+yfsVXRczYO4vjAo+BjE5Qg2CeZ+WefLK/ey -jitGaxUZYRkMur9dDdN6OgaWeV7L9FvIVPQP52hjZLxpYeymX3QYYKN8htvKLys+ -4ot1IcS4IaRlMLv+82/Y1ftn02VNn7GYWjysa03SMk6YuRaicJECAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFFwSuwW/FBQ0hWftxeM7v/xJJ67jMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQAxOn0R94By34BryOly4fO1PgmgeUSKCFo+4Pd+WWbfmcbYCWvMyJ52T8VbV9vg -CDzO3j+H/XH2+bKhcCenYNdJ2Cu3pIah5/9O7kEYHiyqFFU6zrQcWMUocTP3TF82 -+N7nQzSSbtYVFENnQ5T4eQ13PctqPtKuhT2c9reT3IHxs0mrAEdP6WG43L2BetTQ -BzoQ0XyT6dIJLp/2wkZsY+za8vGqMamp4w3F19VyqHe2YrdjhEXOvMkyQo9xbGrw -EDMlHSTTBvIL/Fuc4xBGvwCQC2HPWvC6C/25LNCqsGW1rCHRsUvy0MpYgPSBLTr7 -gQpx0dRjnAr5xR0eUkBI5K1G +MIIDvzCCAqegAwIBAgIBDzANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE1MDQwMjAw +MDAwMFoXDTE4MDgwMTAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBALlmvFV8ynDrLmqLEYyvHi3irqW5lr4KFggrmNaMpiSHqA4uI/Bai/pu +t9yyKlZX13aRacMjRPNAdNeDbfuU2ejmNJYty0MCacRfwAEJmg9VW/W4d16rC1hG +H9RCWUM/WpJayiKNqRj/rEjp86Sk89Wb6CNwzSbyAgvjHqXm6kYPOQb7G/PpzmXf +FeY/csADcl494EyUJ4zudkRJ6/AnD9n8Av7l/XDY/oqmmWFSdrlrr4lQhKsrySoT +DTv4/lBhqOBX4fYUZgBVFbOZA77+byQ5EraLvdVgfyHCJGgHYt1zckkKCcxlJ3w3 +DgCbtYpPcPvFFDRCyydLIlCNWxcPm4UCAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFM5lpjentjhLOKNugMd8E/tRwkW2MB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQAlYx4Wg/NIUoC+C4JM +JCdYRLAaOORNSbiGQ6LHWTFAdDunGAcwffZc5fMfSdMyHPG5R8hSWxmTqWuAQZap +Nc7R/52CxhPKBFY4/N/PWlRfd6koxcYLC1YE6Ddz0465b8iSRqs1B15VBtL8rIvi +x01sMB/bwSm5Gyrhs0M3M0KtOvoglkb1hOoVwoPJEsdxVDdTiEUAqmLZwfUexfER +lX0xVCFWNx02sELIqG2DAY0U+OOIBbaBQ9MZXTv0a4HPK+jNV1QOb3rv/EfmPKnL +FEpuKccArobD/nQ4kje9agiX9VwmthVBEXoeuXHnnnNr9BADdkOGkQL4MEznvK9V +EL9S -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/60_months_after_2012_07.pem b/net/data/ssl/certificates/60_months_after_2012_07.pem index 1dfdc2c6..dab4d76 100644 --- a/net/data/ssl/certificates/60_months_after_2012_07.pem +++ b/net/data/ssl/certificates/60_months_after_2012_07.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:b0 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 16 (0x10) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Oct 30 00:00:00 2014 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:cb:b4:ce:ca:b2:86:ee:9d:20:3f:7f:16:e8:75: - 50:19:d5:e3:dc:c9:0e:7c:b5:9c:62:94:f9:28:8f: - 34:cf:bc:e8:c4:ba:d0:0e:62:3a:50:34:93:9e:24: - fb:14:1c:8b:5a:7e:17:1d:2b:15:cd:4d:5b:c9:60: - 8d:d0:af:bb:29:76:28:97:c4:86:e5:82:6b:55:55: - 17:db:83:01:09:ed:cd:db:34:09:dd:59:6a:2c:13: - eb:3b:13:b0:ac:dc:e2:96:87:1b:04:17:56:bb:a7: - 37:d8:25:3a:b6:96:10:85:b3:ca:29:73:d7:5b:78: - 45:08:ff:92:b1:7a:a5:20:85:71:e5:6e:03:43:3c: - b5:53:b4:09:73:7f:4a:7d:61:5f:e3:17:eb:c6:11: - 6a:14:92:fb:d1:4d:47:30:1d:4d:6b:63:31:d8:9b: - 64:7b:9c:10:16:28:53:ee:3c:d6:65:f5:8a:1b:11: - 26:61:8d:92:e7:e8:a7:d9:01:98:b1:6e:d4:6e:2e: - d1:19:fd:a4:74:e4:5f:c9:b5:6b:e6:68:08:5a:cc: - 19:29:b0:6b:c8:20:40:62:05:9e:94:c4:81:7c:3e: - 64:1d:f1:b9:b0:65:4b:0c:49:c9:3d:30:32:ad:60: - 04:00:65:eb:b2:26:97:f3:8b:25:67:51:cb:e4:76: - 02:ad + 00:d7:ad:de:70:7e:14:f1:ca:94:be:98:67:43:26: + f8:b3:52:cf:da:cf:a3:ef:1b:68:c6:bd:89:ed:dd: + 1d:c0:75:ee:5c:1c:bb:a4:da:d2:68:91:d9:52:ca: + 49:9c:f4:fd:2e:03:de:da:01:51:6e:11:53:e0:9f: + 3b:3b:f9:df:ed:18:ec:9c:54:90:4f:17:39:fd:5f: + d0:b3:37:1f:40:fe:8a:43:17:27:ed:81:d4:36:0b: + 8c:c8:0d:d1:a0:79:0b:2a:36:76:80:c0:11:d0:2c: + 30:2f:e0:97:8f:9a:2a:39:c7:98:81:91:c7:09:30: + 12:10:5f:8c:7f:bd:8f:42:20:e2:82:dd:26:3c:1f: + 2c:d1:9b:3c:92:25:8e:46:54:19:24:87:cc:e4:84: + d1:63:20:06:a9:08:53:cd:a6:81:bd:91:94:2b:4e: + 05:84:32:93:d6:ce:56:1d:80:6d:4f:bc:ef:cb:d0: + bc:d4:c8:ce:ff:ac:1f:41:cc:4e:fb:2e:14:a3:54: + 84:14:e4:5b:8b:f8:a4:d8:40:d9:11:12:1d:c5:6a: + d0:e7:13:e5:cb:97:9e:d2:61:64:c3:58:3a:c1:e2: + 07:5a:b8:32:27:b9:fa:67:4d:69:05:8e:c5:92:03: + c1:e8:b6:0e:94:a4:91:64:99:72:50:bb:d0:5b:68: + 2c:0d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - C8:29:36:3A:9A:AD:3C:CC:49:FA:9B:76:D5:B2:3F:A4:55:E2:2F:10 + BA:4E:4A:D5:D7:99:D0:37:13:7B:64:37:1A:0B:1F:5E:9D:93:1F:F4 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 11:15:89:8f:4a:84:fc:f9:32:5c:52:b1:d6:55:3a:c3:3c:e9: - 01:8e:8e:c1:33:15:9e:6f:1d:99:92:2d:f6:79:65:6e:a8:b4: - 94:32:c8:06:d5:e1:7b:48:d7:ee:e4:69:1c:2a:c4:8b:34:d8: - a4:ed:86:48:bb:38:a6:a7:b5:12:e6:88:3f:70:dd:49:07:5a: - df:63:4f:e9:cb:62:2b:ac:9e:7c:e8:6f:ad:14:7a:64:f6:80: - b7:90:e6:e4:b7:4b:39:9b:f8:be:59:54:a2:55:43:36:c3:94: - bb:61:fd:e1:6a:06:ab:8f:1d:28:92:ef:cf:b4:3a:38:fd:fd: - 33:45:75:4d:0f:2f:83:78:76:34:e1:ce:c1:4d:1e:e4:be:d2: - b7:52:e2:6e:9c:fb:59:41:18:50:3b:34:a4:d0:b6:e5:cc:1e: - 21:45:45:a5:48:f3:55:b6:27:22:51:0a:4c:44:c7:65:91:c7: - 0b:4b:7a:ce:2a:0f:42:09:8b:eb:58:a0:db:fa:b1:cf:5a:4e: - 8a:ac:e7:41:28:1c:b9:fa:62:ec:a0:47:27:e2:31:4a:df:2a: - 95:68:51:e1:62:f2:26:a7:b9:ad:32:e5:cf:20:d8:b2:25:fc: - 2e:c5:ab:68:1f:f8:cd:8e:83:a6:f7:7d:da:0b:7f:b0:3f:f0: - b2:e4:27:39 + a2:e4:6c:8f:21:3b:6c:ee:16:f3:58:41:35:18:e2:a7:88:e5: + d5:7b:a5:4c:e3:36:9d:d9:f5:ba:98:38:6c:da:b8:b3:4e:fa: + c8:38:fa:a9:89:62:90:cb:ec:6a:26:ac:f3:7b:5c:f1:68:06: + dd:34:0f:fc:39:27:8f:fa:e9:c8:8e:81:0e:57:ca:40:6d:ee: + 79:a7:f7:02:28:18:60:2c:a7:81:c6:45:a2:2d:fc:2c:bc:87: + 76:3a:e1:b5:52:67:99:1b:0b:d6:f3:57:d5:29:ec:ee:a5:ea: + 1d:9c:29:ec:f9:f9:cf:48:72:86:15:99:a1:e6:55:e1:b6:e4: + 50:15:25:58:71:5e:26:a7:af:03:21:ce:ca:62:cd:98:d5:d4: + 0c:32:4a:05:82:35:2a:bd:06:ce:c2:05:01:55:82:ee:98:e2: + a7:07:55:1e:0c:4b:48:05:42:89:29:08:13:0a:f5:1d:7c:9f: + a4:09:99:35:bb:9b:44:ad:81:87:75:8a:b1:a0:bf:2d:46:c6: + 5b:90:84:03:20:6f:6e:d3:b9:52:44:06:28:3f:16:f2:75:27: + 66:01:70:39:79:39:84:ed:e5:61:b0:83:22:c9:f1:ad:ca:8a: + 6c:26:4a:c7:05:9a:7f:9f:29:6f:ed:a9:1e:8d:29:b5:08:26: + 21:61:c2:54 -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqsDANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE0MTAzMDAwMDAwMFoXDTE5MDkzMDAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAMu0zsqyhu6dID9/Fuh1UBnV49zJDny1nGKU -+SiPNM+86MS60A5iOlA0k54k+xQci1p+Fx0rFc1NW8lgjdCvuyl2KJfEhuWCa1VV -F9uDAQntzds0Cd1ZaiwT6zsTsKzc4paHGwQXVrunN9glOraWEIWzyilz11t4RQj/ -krF6pSCFceVuA0M8tVO0CXN/Sn1hX+MX68YRahSS+9FNRzAdTWtjMdibZHucEBYo -U+481mX1ihsRJmGNkufop9kBmLFu1G4u0Rn9pHTkX8m1a+ZoCFrMGSmwa8ggQGIF -npTEgXw+ZB3xubBlSwxJyT0wMq1gBABl67Iml/OLJWdRy+R2Aq0CAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFMgpNjqarTzMSfqbdtWyP6RV4i8QMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQARFYmPSoT8+TJcUrHWVTrDPOkBjo7BMxWebx2Zki32eWVuqLSUMsgG1eF7SNfu -5GkcKsSLNNik7YZIuzimp7US5og/cN1JB1rfY0/py2IrrJ586G+tFHpk9oC3kObk -t0s5m/i+WVSiVUM2w5S7Yf3hagarjx0oku/PtDo4/f0zRXVNDy+DeHY04c7BTR7k -vtK3UuJunPtZQRhQOzSk0LblzB4hRUWlSPNVticiUQpMRMdlkccLS3rOKg9CCYvr -WKDb+rHPWk6KrOdBKBy5+mLsoEcn4jFK3yqVaFHhYvImp7mtMuXPINiyJfwuxato -H/jNjoOm933aC3+wP/Cy5Cc5 +MIIDvzCCAqegAwIBAgIBEDANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE0MTAzMDAw +MDAwMFoXDTE5MDkzMDAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBANet3nB+FPHKlL6YZ0Mm+LNSz9rPo+8baMa9ie3dHcB17lwcu6Ta0miR +2VLKSZz0/S4D3toBUW4RU+CfOzv53+0Y7JxUkE8XOf1f0LM3H0D+ikMXJ+2B1DYL +jMgN0aB5Cyo2doDAEdAsMC/gl4+aKjnHmIGRxwkwEhBfjH+9j0Ig4oLdJjwfLNGb +PJIljkZUGSSHzOSE0WMgBqkIU82mgb2RlCtOBYQyk9bOVh2AbU+878vQvNTIzv+s +H0HMTvsuFKNUhBTkW4v4pNhA2RESHcVq0OcT5cuXntJhZMNYOsHiB1q4Mie5+mdN +aQWOxZIDwei2DpSkkWSZclC70FtoLA0CAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFLpOStXXmdA3E3tkNxoLH16dkx/0MB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQCi5GyPITts7hbzWEE1 +GOKniOXVe6VM4zad2fW6mDhs2rizTvrIOPqpiWKQy+xqJqzze1zxaAbdNA/8OSeP ++unIjoEOV8pAbe55p/cCKBhgLKeBxkWiLfwsvId2OuG1UmeZGwvW81fVKezupeod +nCns+fnPSHKGFZmh5lXhtuRQFSVYcV4mp68DIc7KYs2Y1dQMMkoFgjUqvQbOwgUB +VYLumOKnB1UeDEtIBUKJKQgTCvUdfJ+kCZk1u5tErYGHdYqxoL8tRsZbkIQDIG9u +07lSRAYoPxbydSdmAXA5eTmE7eVhsIMiyfGtyopsJkrHBZp/nylv7akejSm1CCYh +YcJU -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/61_months_after_2012_07.pem b/net/data/ssl/certificates/61_months_after_2012_07.pem index e9b7cf8..ef21ce9 100644 --- a/net/data/ssl/certificates/61_months_after_2012_07.pem +++ b/net/data/ssl/certificates/61_months_after_2012_07.pem
@@ -1,42 +1,41 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:b1 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 17 (0x11) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Oct 30 00:00:00 2014 GMT - Not After : Nov 3 00:00:00 2019 GMT + Not After : Jun 9 17:10:52 2022 GMT Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:b9:3e:12:ef:d9:f2:02:be:b4:9e:10:1c:c2:ce: - 7b:68:fb:35:9c:26:b9:d2:19:56:21:26:5d:f2:52: - 13:f8:4e:ff:e7:ef:55:26:eb:2b:61:db:7d:aa:a3: - 7c:7a:b6:bf:f2:be:8d:75:4c:43:d9:56:c7:61:5e: - 6a:8c:2e:af:44:3a:30:2c:ab:31:e0:27:2b:db:ca: - 2d:d4:71:0b:d9:c1:6a:33:6b:f4:59:2e:97:d7:4c: - 09:3e:c9:b2:80:e6:35:60:c6:c3:e8:1a:de:43:18: - 49:48:4a:04:58:21:bb:6e:52:cb:03:79:18:2f:d0: - f2:f8:87:5e:8a:ad:5b:39:7b:03:f2:9b:56:3d:9c: - e6:46:c0:16:ac:38:6e:05:a9:60:7b:41:82:91:09: - 57:45:e6:11:7d:c6:d2:9b:b7:6b:1d:66:d9:b2:79: - 15:17:0d:2e:8f:ef:a4:cc:99:db:1b:56:d1:e4:a3: - 80:13:c9:23:e0:fb:09:ca:b6:b3:44:f2:f7:b6:7c: - 97:e1:70:bb:2b:05:ad:fb:ce:43:43:1e:79:73:9c: - 57:c7:d2:48:70:99:04:45:b2:4c:0f:7d:af:54:8d: - e8:e9:3f:a8:ab:12:e9:ba:29:17:67:4d:40:97:77: - b7:42:05:9f:2b:bf:39:b1:19:81:9f:28:3b:8f:03: - 55:cb + 00:e1:6a:f0:32:d3:9e:18:77:0f:08:d1:d0:03:11: + ac:65:b3:11:e5:dd:5f:ee:74:f5:ff:c8:b1:56:80: + fd:ad:af:82:24:95:c0:7d:99:d2:62:46:bb:fb:9e: + 75:40:5e:15:d0:9e:d9:29:0a:3f:25:bd:83:a5:da: + c6:41:99:59:b2:8e:7b:3e:bb:2d:0c:8f:ea:f9:26: + e5:c6:8f:4a:68:0b:fa:84:3c:1b:57:db:53:eb:6c: + af:9a:8a:7b:9b:b0:fb:cc:92:3e:8a:ea:24:d0:3c: + ff:06:c6:f0:79:b2:1b:8d:3f:3f:d6:ed:08:8c:48: + 9c:40:fa:f9:28:95:d1:f3:5e:8d:1b:4b:63:c4:d3: + 48:77:34:ee:82:db:6e:53:6b:32:ba:db:23:87:07: + 85:ad:26:9b:1b:d0:bb:2f:6b:48:c0:17:d0:2a:af: + 04:c2:87:10:5c:16:71:4c:a5:21:0d:5b:c0:80:1c: + c5:7c:39:4b:ca:93:23:5a:37:e4:fb:d2:7d:2c:f8: + 1b:20:bc:06:01:76:05:63:07:bd:3d:b7:6f:b2:dd: + 68:d9:88:76:9e:23:17:9a:8d:d1:58:b6:a9:9a:81: + 72:c0:8c:2b:8b:b3:e0:c5:93:b1:50:49:d3:ef:de: + 9b:e0:1f:75:77:cb:61:ae:f4:7a:f8:40:2e:88:77: + 67:bf Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - D7:AD:91:9D:C9:B9:1E:52:52:A9:5A:61:C6:47:72:1B:BA:B3:14:0C + ED:25:EF:01:D1:A8:70:5C:5B:FD:6B:2C:9E:5E:69:2F:49:21:C1:DA X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 42:aa:97:1b:b1:d0:9e:07:e0:e8:f7:76:05:61:55:06:ee:e5: - b6:b2:83:c1:b7:83:dc:4d:8d:3d:89:5f:fe:79:e9:78:c5:86: - da:12:94:78:07:a4:3f:b8:9f:8f:76:5d:d8:79:eb:79:0a:68: - 52:aa:a4:45:3e:8e:70:eb:8c:55:86:f7:b0:61:a9:4b:37:49: - 11:a0:02:bf:4d:11:7b:20:78:60:24:cb:76:45:ef:bf:80:63: - 46:83:ec:e2:b6:56:e4:10:03:21:dd:d2:5e:8b:0e:f4:a7:93: - f7:3b:78:b7:33:06:26:33:06:30:fe:f3:ad:b3:66:cf:45:39: - 77:99:a3:7c:0b:1e:fc:cb:5a:43:42:e3:9c:ef:a2:ba:25:dc: - 05:03:d7:7e:80:f9:95:ba:7a:5c:c9:b8:ca:6a:8b:26:4d:e8: - a6:e2:c2:fe:25:c9:30:69:c2:3b:41:0e:7a:04:52:3c:96:5e: - ee:53:c9:b9:44:02:86:4c:70:ca:b6:01:94:99:22:af:42:f9: - ab:4b:c5:07:4d:80:6b:0a:1a:44:5f:cc:43:09:43:e1:34:f2: - b4:70:6b:21:93:c0:8e:53:c5:ef:e4:7d:01:18:d6:bc:23:3f: - 6a:f4:cd:03:31:cd:68:b6:97:04:61:9b:cc:49:77:6e:0c:12: - c9:b9:40:14 + 19:1d:92:62:5e:9f:3a:4b:20:2c:2e:1a:25:31:1d:95:b4:21: + d3:ec:ee:77:60:85:85:40:1c:eb:7f:22:9e:ab:1f:74:74:d5: + cc:4b:af:c4:cc:4f:60:ab:05:14:f1:35:20:b7:ec:92:56:0e: + 2d:b4:de:65:f2:50:31:19:ad:9e:7e:bb:50:05:e4:e7:d8:5d: + ed:d1:f8:58:75:5d:72:23:97:30:e6:e8:ac:83:35:1d:6a:5f: + 94:2f:55:59:1e:a5:a5:a1:90:86:d9:5b:0f:54:59:05:11:01: + ee:a7:fe:c9:a3:13:32:13:d8:c4:55:95:c6:cf:fa:be:a5:ff: + 57:4d:e7:15:de:7e:82:8d:7f:d1:3b:49:0f:98:dc:28:c7:af: + 62:aa:f8:bd:a4:db:aa:a5:56:d3:49:91:5a:86:28:b0:5a:90: + b9:7d:9f:e0:cc:f2:e3:dc:5e:f0:bf:92:38:7d:b8:d2:f4:af: + 83:ef:c7:02:60:e7:6b:12:d7:b9:ea:20:e7:3b:e4:75:61:cf: + 98:58:af:fe:11:81:08:b6:98:cc:ce:4f:d5:9c:93:88:c6:a7: + 52:31:53:d0:d0:cf:c5:65:e4:b3:0a:ef:4b:01:73:e3:8c:40: + 10:a4:52:4d:08:4c:85:8d:27:ad:f6:2f:4a:7a:9c:4b:d4:99: + 94:07:be:90 -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqsTANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE0MTAzMDAwMDAwMFoXDTE5MTEwMzAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBALk+Eu/Z8gK+tJ4QHMLOe2j7NZwmudIZViEm -XfJSE/hO/+fvVSbrK2HbfaqjfHq2v/K+jXVMQ9lWx2Feaowur0Q6MCyrMeAnK9vK -LdRxC9nBajNr9Fkul9dMCT7JsoDmNWDGw+ga3kMYSUhKBFghu25SywN5GC/Q8viH -XoqtWzl7A/KbVj2c5kbAFqw4bgWpYHtBgpEJV0XmEX3G0pu3ax1m2bJ5FRcNLo/v -pMyZ2xtW0eSjgBPJI+D7Ccq2s0Ty97Z8l+FwuysFrfvOQ0MeeXOcV8fSSHCZBEWy -TA99r1SN6Ok/qKsS6bopF2dNQJd3t0IFnyu/ObEZgZ8oO48DVcsCAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFNetkZ3JuR5SUqlaYcZHchu6sxQMMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQBCqpcbsdCeB+Do93YFYVUG7uW2soPBt4PcTY09iV/+eel4xYbaEpR4B6Q/uJ+P -dl3Yeet5CmhSqqRFPo5w64xVhvewYalLN0kRoAK/TRF7IHhgJMt2Re+/gGNGg+zi -tlbkEAMh3dJeiw70p5P3O3i3MwYmMwYw/vOts2bPRTl3maN8Cx78y1pDQuOc76K6 -JdwFA9d+gPmVunpcybjKaosmTeim4sL+JckwacI7QQ56BFI8ll7uU8m5RAKGTHDK -tgGUmSKvQvmrS8UHTYBrChpEX8xDCUPhNPK0cGshk8COU8Xv5H0BGNa8Iz9q9M0D -Mc1otpcEYZvMSXduDBLJuUAU +MIIDvzCCAqegAwIBAgIBETANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE0MTAzMDAw +MDAwMFoXDTIyMDYwOTE3MTA1MlowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAOFq8DLTnhh3DwjR0AMRrGWzEeXdX+509f/IsVaA/a2vgiSVwH2Z0mJG +u/uedUBeFdCe2SkKPyW9g6XaxkGZWbKOez67LQyP6vkm5caPSmgL+oQ8G1fbU+ts +r5qKe5uw+8ySPorqJNA8/wbG8HmyG40/P9btCIxInED6+SiV0fNejRtLY8TTSHc0 +7oLbblNrMrrbI4cHha0mmxvQuy9rSMAX0CqvBMKHEFwWcUylIQ1bwIAcxXw5S8qT +I1o35PvSfSz4GyC8BgF2BWMHvT23b7LdaNmIdp4jF5qN0Vi2qZqBcsCMK4uz4MWT +sVBJ0+/em+AfdXfLYa70evhALoh3Z78CAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFO0l7wHRqHBcW/1rLJ5eaS9JIcHaMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQAZHZJiXp86SyAsLhol +MR2VtCHT7O53YIWFQBzrfyKeqx90dNXMS6/EzE9gqwUU8TUgt+ySVg4ttN5l8lAx +Ga2efrtQBeTn2F3t0fhYdV1yI5cw5uisgzUdal+UL1VZHqWloZCG2VsPVFkFEQHu +p/7JoxMyE9jEVZXGz/q+pf9XTecV3n6CjX/RO0kPmNwox69iqvi9pNuqpVbTSZFa +hiiwWpC5fZ/gzPLj3F7wv5I4fbjS9K+D78cCYOdrEte56iDnO+R1Yc+YWK/+EYEI +tpjMzk/VnJOIxqdSMVPQ0M/FZeSzCu9LAXPjjEAQpFJNCEyFjSet9i9KepxL1JmU +B76Q -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/825_days_1_second_after_2018_03_01.pem b/net/data/ssl/certificates/825_days_1_second_after_2018_03_01.pem index 0ac89a5..2061fd9 100644 --- a/net/data/ssl/certificates/825_days_1_second_after_2018_03_01.pem +++ b/net/data/ssl/certificates/825_days_1_second_after_2018_03_01.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:b9 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 29 (0x1d) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Mar 2 00:00:00 2018 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:ad:80:98:89:16:89:da:7f:11:d0:e7:ac:79:a7: - 9f:a2:31:fa:e6:22:54:5a:1f:bf:04:95:50:16:06: - b2:39:33:c4:e7:cc:0f:ee:71:90:34:64:52:1e:fe: - 30:65:30:3f:28:98:de:1f:72:19:83:37:67:d6:e3: - ed:95:28:a1:53:9c:8f:3e:49:99:98:9c:1b:04:4a: - fe:6f:60:5b:5c:43:a9:0c:fd:b4:04:6f:a3:07:10: - b6:68:4e:49:87:37:e4:d4:c7:61:ed:4a:6c:c4:ea: - 24:d6:33:a6:2c:9d:ae:04:5b:11:60:5d:bd:66:ef: - 4f:82:86:f2:d6:d2:00:12:fa:c0:81:b8:b2:e2:6b: - 11:2e:1d:22:42:fe:0c:ac:60:b9:12:98:c5:41:fb: - 11:e0:1a:fb:fe:fa:72:c9:a9:ce:69:f1:eb:2e:df: - 25:99:05:34:1f:04:11:0b:4c:39:57:a5:3c:7d:4b: - 26:8b:7e:3e:e5:aa:df:ec:64:3c:29:b5:0c:bb:ec: - 3a:f3:79:2f:26:b4:62:07:6d:53:e8:fc:8c:7c:1d: - 76:3f:fe:5f:ec:72:17:a4:c1:4b:be:1b:d5:e5:20: - df:7e:05:04:7c:e4:3c:7c:0d:10:79:a2:f1:b5:dd: - 7f:e1:4b:48:66:b3:4e:df:fa:82:00:8a:c5:7b:4b: - 3d:85 + 00:b1:72:29:83:ff:96:bf:59:ab:e7:e0:a2:c3:eb: + 03:05:2a:34:92:0f:b9:4d:51:7a:4f:2d:3d:4b:24: + f8:d8:17:0e:9f:88:38:aa:fc:5b:bb:13:ab:a1:1d: + c6:1e:58:b2:b1:f5:04:bb:75:7f:70:9e:82:8f:97: + 73:25:c8:ff:35:41:2f:0c:20:f1:4a:98:18:5f:aa: + 8a:14:e8:9b:6c:f4:15:28:15:ad:52:da:f9:18:74: + 70:f9:c7:93:3c:2b:ee:88:37:de:51:af:b7:0e:0c: + a1:4f:00:4f:48:fe:58:47:69:b8:57:98:f9:46:f7: + db:ab:59:02:e6:c5:55:45:04:26:6b:7b:52:41:b7: + 24:4e:d4:c2:f9:bc:1b:ff:6d:fb:37:0f:88:f5:e8: + 4e:24:e1:e5:ce:e7:2b:2d:a7:1c:44:18:cc:56:7d: + 92:06:51:03:56:0f:f6:1c:fa:c6:52:39:aa:f7:f8: + 09:d3:0d:4d:e7:fa:71:f9:79:3a:26:0a:85:cd:5b: + d5:3b:af:cb:49:d8:2c:f9:fb:cb:5e:f9:ca:8c:1d: + 0e:b7:03:70:9b:84:f6:dc:9d:39:6e:19:5a:d1:76: + bb:57:57:be:e0:d1:4f:5b:30:5c:22:6e:5f:e4:27: + 1a:0c:5d:62:65:9a:f3:e1:d9:45:be:6a:38:a4:15: + 49:bb Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 0A:5D:95:5F:6B:5D:7E:D8:97:A8:8B:BF:E3:93:00:FE:C1:77:56:59 + BC:F3:2D:55:5F:B1:CE:8D:5A:05:B4:FC:17:A9:4A:2F:14:8E:1C:F2 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - c0:09:34:ed:6d:08:f7:c7:43:c0:29:b1:58:c4:4f:e4:7a:88: - 3f:a1:c2:74:eb:c0:6a:4b:51:e1:f6:78:b2:7c:aa:f0:e7:87: - d5:0d:c2:71:e0:1c:c7:0a:34:84:22:cb:93:ba:cb:48:5e:53: - 6d:9d:ca:0f:a8:cf:80:7d:e5:ab:76:c7:4d:9e:fa:a7:28:77: - eb:b0:09:51:27:c1:49:59:e3:23:4d:00:1a:37:00:45:e4:17: - 3f:5a:d1:21:39:c5:f2:12:e3:b7:26:ed:e0:99:42:69:ff:a1: - 9c:1e:a8:34:ea:d9:fb:fe:19:2d:c4:1d:8b:ad:30:d6:31:5b: - 37:8a:ed:3e:26:56:01:89:d2:ac:4d:a0:5f:d5:9b:ab:51:f8: - ef:24:1b:4c:67:e4:cd:8e:8f:09:1b:f5:4b:96:f6:7a:e3:b9: - aa:8c:b4:d8:96:b2:87:f7:ed:b4:92:03:68:39:92:24:ca:19: - 18:c7:d8:36:dc:60:31:4e:8f:13:9d:c2:9e:56:78:79:21:03: - 50:9b:86:d3:23:aa:5c:3c:16:e8:16:ae:0c:b3:c4:26:bd:c3: - f2:b1:15:ed:11:b0:91:63:b2:12:a4:73:57:b6:a0:9f:4c:6f: - d5:af:43:28:48:c4:8f:07:fe:b8:ab:a8:db:16:aa:81:a4:e7: - 81:6e:a1:e5 + 76:6e:b9:fe:1c:ee:83:57:f7:cb:b8:51:e9:9a:c5:49:04:79: + d7:fc:1b:8a:53:62:d5:50:fd:f6:11:73:3c:cd:be:49:27:6e: + 26:68:87:f8:2e:a8:de:0d:d4:a2:22:66:fc:f4:5b:fc:7c:e1: + 0b:06:ae:4d:8c:af:20:30:67:b0:2e:99:72:12:ee:54:89:4d: + f8:21:32:d4:0f:50:54:ed:cb:4e:c9:8c:ba:ce:37:ec:a2:92: + 58:b4:6f:bd:98:5f:fd:10:71:39:ac:4e:da:ad:71:13:a4:7b: + af:54:7e:47:11:30:55:93:50:ff:de:10:eb:be:9a:ca:77:cc: + e6:10:3e:bd:a3:c8:ce:42:00:cd:1d:d1:a4:d0:79:b2:f2:df: + 09:7c:c9:8a:57:5e:b5:15:8f:d7:19:ad:5d:d5:9a:a8:5b:2a: + 3e:49:4e:a9:6e:c7:bc:c0:d6:4a:21:02:48:a4:c1:60:0d:dd: + bb:a6:d9:d3:c7:4f:a8:35:63:a4:3c:43:47:3d:68:96:ba:44: + 4f:08:0d:a6:40:0a:c2:c6:76:a8:79:a2:5b:e9:00:da:4a:7e: + 87:46:94:d5:16:bc:08:e7:6f:66:3a:4a:37:fe:99:2f:25:38: + 2b:3a:cd:e9:2d:e4:dc:c0:9d:38:34:42:5a:6a:7b:be:dc:a7: + d0:a7:9a:4f -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFquTANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE4MDMwMjAwMDAwMFoXDTIwMDYwNDAwMDAwMVowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAK2AmIkWidp/EdDnrHmnn6Ix+uYiVFofvwSV -UBYGsjkzxOfMD+5xkDRkUh7+MGUwPyiY3h9yGYM3Z9bj7ZUooVOcjz5JmZicGwRK -/m9gW1xDqQz9tARvowcQtmhOSYc35NTHYe1KbMTqJNYzpiydrgRbEWBdvWbvT4KG -8tbSABL6wIG4suJrES4dIkL+DKxguRKYxUH7EeAa+/76csmpzmnx6y7fJZkFNB8E -EQtMOVelPH1LJot+PuWq3+xkPCm1DLvsOvN5Lya0YgdtU+j8jHwddj/+X+xyF6TB -S74b1eUg334FBHzkPHwNEHmi8bXdf+FLSGazTt/6ggCKxXtLPYUCAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFApdlV9rXX7Yl6iLv+OTAP7Bd1ZZMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQDACTTtbQj3x0PAKbFYxE/keog/ocJ068BqS1Hh9niyfKrw54fVDcJx4BzHCjSE -IsuTustIXlNtncoPqM+AfeWrdsdNnvqnKHfrsAlRJ8FJWeMjTQAaNwBF5Bc/WtEh -OcXyEuO3Ju3gmUJp/6GcHqg06tn7/hktxB2LrTDWMVs3iu0+JlYBidKsTaBf1Zur -UfjvJBtMZ+TNjo8JG/VLlvZ647mqjLTYlrKH9+20kgNoOZIkyhkYx9g23GAxTo8T -ncKeVnh5IQNQm4bTI6pcPBboFq4Ms8QmvcPysRXtEbCRY7ISpHNXtqCfTG/Vr0Mo -SMSPB/64q6jbFqqBpOeBbqHl +MIIDvzCCAqegAwIBAgIBHTANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE4MDMwMjAw +MDAwMFoXDTIwMDYwNDAwMDAwMVowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBALFyKYP/lr9Zq+fgosPrAwUqNJIPuU1Rek8tPUsk+NgXDp+IOKr8W7sT +q6Edxh5YsrH1BLt1f3Cego+XcyXI/zVBLwwg8UqYGF+qihTom2z0FSgVrVLa+Rh0 +cPnHkzwr7og33lGvtw4MoU8AT0j+WEdpuFeY+Ub326tZAubFVUUEJmt7UkG3JE7U +wvm8G/9t+zcPiPXoTiTh5c7nKy2nHEQYzFZ9kgZRA1YP9hz6xlI5qvf4CdMNTef6 +cfl5OiYKhc1b1Tuvy0nYLPn7y175yowdDrcDcJuE9tydOW4ZWtF2u1dXvuDRT1sw +XCJuX+QnGgxdYmWa8+HZRb5qOKQVSbsCAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFLzzLVVfsc6NWgW0/BepSi8UjhzyMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQB2brn+HO6DV/fLuFHp +msVJBHnX/BuKU2LVUP32EXM8zb5JJ24maIf4LqjeDdSiImb89Fv8fOELBq5NjK8g +MGewLplyEu5UiU34ITLUD1BU7ctOyYy6zjfsopJYtG+9mF/9EHE5rE7arXETpHuv +VH5HETBVk1D/3hDrvprKd8zmED69o8jOQgDNHdGk0Hmy8t8JfMmKV161FY/XGa1d +1ZqoWyo+SU6pbse8wNZKIQJIpMFgDd27ptnTx0+oNWOkPENHPWiWukRPCA2mQArC +xnaoeaJb6QDaSn6HRpTVFrwI529mOko3/pkvJTgrOs3pLeTcwJ04NEJaanu+3KfQ +p5pP -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/825_days_after_2018_03_01.pem b/net/data/ssl/certificates/825_days_after_2018_03_01.pem index 5596953..95a57bb 100644 --- a/net/data/ssl/certificates/825_days_after_2018_03_01.pem +++ b/net/data/ssl/certificates/825_days_after_2018_03_01.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:b8 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 28 (0x1c) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Mar 2 00:00:00 2018 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:d8:2b:9b:bd:10:74:a6:6f:9d:2b:1f:c6:f7:10: - 69:fd:8a:13:f4:6b:71:b6:15:3a:66:0e:48:92:4f: - 08:e3:93:d4:0d:6b:79:2e:c1:55:99:73:1c:b6:6f: - b7:92:7f:3a:38:63:15:6b:dc:52:45:8a:cf:f3:f2: - 62:e2:ef:3e:12:cf:98:ca:b1:d2:8e:47:a3:ba:92: - ce:9b:2b:5f:4a:aa:0f:5e:cf:63:58:b7:cf:9b:78: - 2a:f2:8d:8e:24:73:92:2f:ed:dc:19:b0:e4:fe:ed: - 66:4a:4f:5e:3f:cd:d4:9c:96:51:34:37:67:8e:8a: - ed:49:0c:97:2b:db:da:6e:04:a5:56:32:64:74:cb: - d0:09:95:4c:39:df:38:20:ff:fa:87:4b:73:15:ce: - 38:7c:bc:af:47:c2:c8:21:f6:3d:52:98:b0:c5:2c: - b2:cd:87:34:41:ba:4b:f9:19:68:98:2b:4e:0e:88: - 46:a6:79:7e:4e:b3:ca:2c:83:1d:6e:9f:7d:8d:d2: - 79:48:b9:1f:a0:33:11:35:43:96:0f:72:c0:d6:7b: - d8:ad:33:12:6e:a9:32:34:da:91:5a:a9:2c:fe:c8: - 2b:76:99:27:2c:cf:ae:c8:dd:49:99:b5:18:fd:7c: - 0b:c0:1f:86:53:23:1b:25:b2:e8:8a:da:0b:88:19: - 3e:85 + 00:a9:a4:7e:68:33:ea:40:c5:66:fe:cf:92:6c:ab: + fc:dc:2c:e7:42:73:44:1a:f4:0e:8b:3b:3d:23:d7: + 41:aa:21:7e:a6:98:06:9c:05:d3:e6:60:e5:52:5e: + 4f:f2:dd:22:f3:1a:e7:7a:43:91:c5:7a:5b:b9:75: + f0:57:ae:69:73:e3:4d:7b:ec:e1:fa:05:34:93:7f: + 95:84:dd:3b:75:73:ab:fc:fc:2d:84:04:3f:1f:20: + d8:2e:6e:b9:9e:51:b1:8f:57:17:67:56:ec:8c:5a: + 08:36:a5:5e:4f:14:18:87:5f:82:f0:2c:87:d6:de: + 06:d3:f7:7f:99:54:55:3f:ec:fc:51:20:ac:48:89: + 34:22:c2:13:a5:75:20:e6:5b:c3:61:9e:8d:b2:24: + 99:8b:c1:e3:3d:54:7a:5b:d6:68:83:b2:49:a1:9a: + df:70:e2:bb:eb:8c:0c:a8:9a:a0:af:5e:d3:e9:db: + 93:51:9f:1c:48:80:0f:4d:76:20:34:23:fe:2a:8e: + 52:e2:93:9a:e3:fb:6b:73:a6:fa:6f:2d:50:5a:65: + ce:ed:15:ca:94:9d:56:7f:9d:23:f5:ce:0b:54:04: + ad:ff:17:4e:92:4a:d1:1c:ab:a7:c2:9d:99:e7:3b: + f1:98:68:88:a7:5c:e5:c0:39:5f:c3:25:56:85:a6: + 14:c1 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - E5:64:89:76:C4:A8:B3:BF:29:71:0B:83:86:5F:60:77:28:82:AE:52 + 32:7A:77:17:24:D3:A1:E2:D9:79:98:0C:A0:19:65:18:06:7D:74:4B X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 36:dd:82:06:b0:07:79:81:c8:5c:e0:cf:4f:06:a0:03:99:3b: - 41:93:bb:79:3f:7d:ce:3e:e6:d4:78:a0:4e:3b:c4:3f:09:9c: - f5:91:53:84:c9:2d:12:ac:19:ef:d4:d5:83:8f:c8:9c:9f:5d: - d5:d9:02:6b:c2:c2:0e:b3:78:34:9e:58:1d:b8:3b:04:31:e5: - a4:ce:d0:1c:d9:44:81:7f:e2:36:de:30:9f:7d:18:40:2e:9c: - 27:f7:27:43:7e:c2:35:ce:8e:9f:07:bc:9f:f6:2f:57:ab:51: - 2b:5d:aa:74:b2:e9:86:ce:b8:b0:7a:ee:22:e2:fa:29:8d:3b: - 7d:6b:f5:d2:42:66:c8:bc:cd:8e:ff:ca:c4:2d:e6:70:62:52: - 67:e3:89:d7:8f:f9:f4:0c:c0:db:d7:2e:b3:fb:97:d5:38:0c: - 83:88:76:76:fc:43:ab:8e:8b:ee:12:c2:10:b9:37:e7:40:a3: - 2f:2e:bb:d2:5d:c5:04:97:19:bb:0f:f2:80:dc:66:86:b5:6e: - ea:87:ff:d7:5b:13:f0:11:09:92:f4:a8:93:ac:33:75:cc:44: - 3a:9d:a8:d3:5a:d4:06:14:05:7e:3d:5e:32:29:98:9a:45:e1: - 2e:37:3a:39:75:c0:50:fe:9e:b0:e3:d2:16:16:91:64:c0:79: - 99:cd:47:42 + 23:0d:4a:51:cc:45:b5:57:44:4b:db:8b:18:f9:77:85:72:ed: + 94:b8:20:31:52:0e:c3:49:71:2f:0b:1f:fe:a4:d9:39:e4:99: + 52:fd:a5:22:fc:9e:f4:45:9b:be:dd:a5:52:2b:45:74:52:61: + e0:03:66:f2:88:c8:15:79:4a:cf:e1:71:b3:d9:40:21:93:5f: + 1a:a4:08:26:80:32:45:5a:0e:a4:b2:79:1f:02:5a:c1:c7:61: + 32:c4:e0:0d:07:32:71:38:f4:85:b8:55:84:0d:ec:b2:cc:f3: + 8d:a1:df:d2:70:c2:d4:f1:68:4c:b0:87:a7:37:4d:44:b7:d6: + 93:37:bb:d3:0d:9c:11:5e:4c:1e:f9:c5:5a:26:53:82:46:62: + cf:10:fd:9c:c3:5f:48:02:69:90:9e:36:f6:77:fe:53:a6:6d: + 3c:52:ac:38:4b:44:d2:58:df:71:ec:e1:c3:6e:da:08:0c:ae: + c7:19:ef:fe:94:1b:ce:2d:40:c9:e7:ff:9c:c1:8a:f6:0f:79: + d6:bf:59:c3:ea:13:42:24:79:35:d6:85:13:54:d3:96:58:4c: + 8d:0a:01:d9:7d:37:97:9e:66:56:f7:75:f5:b8:8c:8b:a2:73: + e1:07:ca:5b:41:3e:db:2c:c7:8a:ad:97:95:b9:1a:e5:51:2f: + 42:49:88:b4 -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFquDANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE4MDMwMjAwMDAwMFoXDTIwMDYwNDAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBANgrm70QdKZvnSsfxvcQaf2KE/RrcbYVOmYO -SJJPCOOT1A1reS7BVZlzHLZvt5J/OjhjFWvcUkWKz/PyYuLvPhLPmMqx0o5Ho7qS -zpsrX0qqD17PY1i3z5t4KvKNjiRzki/t3Bmw5P7tZkpPXj/N1JyWUTQ3Z46K7UkM -lyvb2m4EpVYyZHTL0AmVTDnfOCD/+odLcxXOOHy8r0fCyCH2PVKYsMUsss2HNEG6 -S/kZaJgrTg6IRqZ5fk6zyiyDHW6ffY3SeUi5H6AzETVDlg9ywNZ72K0zEm6pMjTa -kVqpLP7IK3aZJyzPrsjdSZm1GP18C8AfhlMjGyWy6IraC4gZPoUCAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFOVkiXbEqLO/KXELg4ZfYHcogq5SMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQA23YIGsAd5gchc4M9PBqADmTtBk7t5P33OPubUeKBOO8Q/CZz1kVOEyS0SrBnv -1NWDj8icn13V2QJrwsIOs3g0nlgduDsEMeWkztAc2USBf+I23jCffRhALpwn9ydD -fsI1zo6fB7yf9i9Xq1ErXap0sumGzriweu4i4vopjTt9a/XSQmbIvM2O/8rELeZw -YlJn44nXj/n0DMDb1y6z+5fVOAyDiHZ2/EOrjovuEsIQuTfnQKMvLrvSXcUElxm7 -D/KA3GaGtW7qh//XWxPwEQmS9KiTrDN1zEQ6najTWtQGFAV+PV4yKZiaReEuNzo5 -dcBQ/p6w49IWFpFkwHmZzUdC +MIIDvzCCAqegAwIBAgIBHDANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE4MDMwMjAw +MDAwMFoXDTIwMDYwNDAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAKmkfmgz6kDFZv7Pkmyr/Nws50JzRBr0Dos7PSPXQaohfqaYBpwF0+Zg +5VJeT/LdIvMa53pDkcV6W7l18FeuaXPjTXvs4foFNJN/lYTdO3Vzq/z8LYQEPx8g +2C5uuZ5RsY9XF2dW7IxaCDalXk8UGIdfgvAsh9beBtP3f5lUVT/s/FEgrEiJNCLC +E6V1IOZbw2GejbIkmYvB4z1UelvWaIOySaGa33Diu+uMDKiaoK9e0+nbk1GfHEiA +D012IDQj/iqOUuKTmuP7a3Om+m8tUFplzu0VypSdVn+dI/XOC1QErf8XTpJK0Ryr +p8Kdmec78ZhoiKdc5cA5X8MlVoWmFMECAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFDJ6dxck06Hi2XmYDKAZZRgGfXRLMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQAjDUpRzEW1V0RL24sY ++XeFcu2UuCAxUg7DSXEvCx/+pNk55JlS/aUi/J70RZu+3aVSK0V0UmHgA2byiMgV +eUrP4XGz2UAhk18apAgmgDJFWg6ksnkfAlrBx2EyxOANBzJxOPSFuFWEDeyyzPON +od/ScMLU8WhMsIenN01Et9aTN7vTDZwRXkwe+cVaJlOCRmLPEP2cw19IAmmQnjb2 +d/5Tpm08Uqw4S0TSWN9x7OHDbtoIDK7HGe/+lBvOLUDJ5/+cwYr2D3nWv1nD6hNC +JHk11oUTVNOWWEyNCgHZfTeXnmZW93X1uIyLonPhB8pbQT7bLMeKrZeVuRrlUS9C +SYi0 -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/826_days_after_2018_03_01.pem b/net/data/ssl/certificates/826_days_after_2018_03_01.pem index 2ff7482..e010db2c 100644 --- a/net/data/ssl/certificates/826_days_after_2018_03_01.pem +++ b/net/data/ssl/certificates/826_days_after_2018_03_01.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:b7 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 27 (0x1b) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Mar 2 00:00:00 2018 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:a4:a0:d8:9f:7e:c5:40:3f:86:4d:96:b5:77:01: - ab:1b:6c:de:dd:43:e9:86:5c:24:71:7e:07:d7:20: - a8:eb:31:f1:2b:8d:9a:0a:ed:a6:82:b8:0b:7b:31: - e7:f2:11:b7:b7:1d:e1:b1:05:8a:8e:d8:72:19:57: - 01:f0:e6:94:aa:0a:c7:f1:c1:eb:49:3c:2c:a7:39: - 21:51:5e:4c:d1:d0:76:ad:4d:d9:82:c8:5e:82:ee: - 38:bb:36:84:57:9f:a8:9f:e6:41:0d:97:36:61:96: - 87:e4:c3:ed:eb:58:f3:c1:0f:f1:9e:9c:89:7d:dc: - 16:05:7e:a8:d0:4b:72:64:a8:65:f4:47:77:ea:bd: - 28:ec:57:0b:11:25:4c:c2:5e:de:cf:77:94:78:93: - 53:83:74:33:3e:37:23:27:a5:6e:89:6a:86:4e:6c: - 79:df:44:c3:99:fc:99:e3:2b:1d:a1:9e:16:28:42: - 63:d4:0a:73:1b:05:81:dc:7a:16:7b:7c:7e:aa:d2: - 83:c2:67:03:dd:88:ba:b5:9c:05:9c:ec:df:84:98: - d6:34:4d:58:ba:fc:32:4d:9c:95:0e:35:76:52:3c: - 4c:ff:9d:6d:f2:aa:3b:56:77:66:f8:da:c3:c6:28: - 9e:45:56:4c:54:75:65:a9:cd:e4:2a:73:7a:8c:19: - 23:51 + 00:cf:da:ab:7b:a6:ed:17:b4:7b:14:b9:8c:29:a3: + 7f:25:cb:7c:a4:1c:23:da:c5:fc:8a:29:bd:be:b0: + 3d:40:c1:51:08:46:db:73:8c:dd:5c:06:3e:8c:f2: + b5:d1:eb:b0:94:74:e0:46:14:b6:55:d0:bb:a9:b9: + 63:ae:7c:ee:e6:4c:7a:81:f3:37:1f:37:8b:dc:86: + d1:79:0f:6e:ca:ca:ff:d0:91:e2:e9:f6:0c:38:ca: + 29:18:d2:92:65:88:6d:d6:72:14:b2:8b:06:11:6f: + f7:3d:9d:54:3b:b5:ca:4d:d6:02:d8:1b:28:2c:bd: + 35:09:d3:29:c7:1d:82:9b:12:3b:a8:5c:51:68:69: + 72:d2:03:6a:2e:af:b5:33:fc:f3:57:b6:cb:7f:76: + d6:2d:f7:82:74:50:f0:ef:b0:ac:08:90:be:b1:6c: + 47:ad:cb:e5:e1:fe:9a:c2:e8:0e:7f:e7:40:11:87: + ec:1b:37:cb:d2:6d:77:96:66:48:15:c2:f2:c2:9b: + aa:e0:64:ad:8f:ee:fe:81:ca:26:43:0f:21:f3:33: + 47:0d:be:ab:a4:8f:8f:84:1d:bc:e8:8f:ef:4d:ad: + 7b:39:30:22:c0:67:b2:ec:86:f7:f0:7b:f3:11:3d: + 8d:b3:5e:74:a4:9f:75:e4:4a:6c:c2:b8:d5:91:52: + bf:4f Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 62:3F:A7:B2:91:44:A4:AB:9D:89:48:C1:B9:5D:DA:2B:4B:F4:76:56 + 57:B6:A1:A5:9D:E5:D4:1E:49:10:E6:56:D8:70:E6:A1:D5:74:F2:46 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 1d:a7:66:71:92:5c:d7:57:7e:98:f9:4b:c9:87:e8:24:a0:cd: - 34:ad:95:3b:c2:4b:e5:ae:f3:cd:45:b5:e5:a4:15:13:3e:7e: - 3d:5e:0c:f7:95:b5:c5:9f:6d:0b:bc:95:08:f7:23:ed:a2:43: - 45:9c:48:03:49:ed:81:f7:68:90:a6:f4:29:bc:c5:30:7e:59: - 27:3b:c8:08:5b:ff:48:3e:b3:c4:6b:5e:4b:e8:ec:4e:e4:ce: - c3:84:ca:c9:2d:8a:ed:1c:51:3d:b5:20:20:1e:88:ca:22:c6: - 64:b2:6f:c5:a5:e4:da:8d:14:98:60:e7:22:41:b8:29:f8:ef: - fe:5b:05:8c:55:6a:0c:d3:45:25:a8:6d:24:24:f1:28:e3:40: - 48:1f:71:40:b6:85:c4:62:07:10:0a:9b:92:20:4b:42:9c:26: - f2:37:14:74:ee:a8:b5:f5:db:14:83:be:07:71:ba:b3:91:b6: - 47:b2:57:1f:b5:25:95:d7:6d:4e:a4:78:5a:5a:23:3f:30:54: - 0f:b5:0f:9b:23:e7:5f:29:50:1e:b9:e3:af:71:06:70:36:2b: - 4a:4b:52:ef:b6:db:38:a8:93:85:5f:78:a1:8a:22:b7:dc:4a: - fe:49:1a:59:31:b0:5e:3d:6c:c1:f5:e1:a3:c1:3a:28:3f:a7: - c6:b0:c4:f4 + 92:f9:fd:c1:02:55:b9:61:ac:c5:15:87:4c:24:db:a5:b4:9b: + 33:ab:24:3e:4c:3d:28:f4:f1:2c:50:64:ca:8a:2f:79:df:af: + e7:d8:cb:8e:98:c9:d3:f3:be:b3:40:ec:28:47:66:be:6f:75: + b8:eb:3f:07:18:97:2c:a1:7d:65:3b:4f:d8:c9:4b:ba:21:c2: + af:cf:90:aa:6a:a1:e7:70:3e:c0:54:6e:22:6c:11:ce:55:f2: + d7:9d:6a:bb:4d:40:8c:24:05:04:05:c0:35:c4:28:b7:0b:d6: + c9:39:a1:1b:6b:8a:aa:da:87:8f:ce:be:18:ac:04:1b:31:52: + 39:ab:03:cf:41:07:b5:64:e2:e5:5b:76:52:20:2a:9e:4d:17: + c4:b6:64:09:0e:64:66:f9:d3:23:74:2c:fe:c1:79:15:e0:c0: + 59:a1:ee:71:f7:0a:8e:3a:5c:46:c0:18:20:a0:33:ff:02:37: + 46:61:a8:6a:51:ac:a5:39:a1:cf:49:61:76:6b:df:a9:68:63: + e9:d2:1a:bb:43:60:d4:99:65:1a:91:04:03:42:43:db:2b:28: + dc:c8:af:03:b4:71:5a:c9:17:a5:ff:c9:cc:04:c7:41:7f:b3: + a5:d5:72:3d:77:45:f3:57:a0:1d:24:4f:8a:24:42:a5:9d:49: + f2:18:cc:ac -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqtzANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE4MDMwMjAwMDAwMFoXDTIwMDYwNTAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAKSg2J9+xUA/hk2WtXcBqxts3t1D6YZcJHF+ -B9cgqOsx8SuNmgrtpoK4C3sx5/IRt7cd4bEFio7YchlXAfDmlKoKx/HB60k8LKc5 -IVFeTNHQdq1N2YLIXoLuOLs2hFefqJ/mQQ2XNmGWh+TD7etY88EP8Z6ciX3cFgV+ -qNBLcmSoZfRHd+q9KOxXCxElTMJe3s93lHiTU4N0Mz43Iyelbolqhk5sed9Ew5n8 -meMrHaGeFihCY9QKcxsFgdx6Fnt8fqrSg8JnA92IurWcBZzs34SY1jRNWLr8Mk2c -lQ41dlI8TP+dbfKqO1Z3Zvjaw8YonkVWTFR1ZanN5CpzeowZI1ECAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFGI/p7KRRKSrnYlIwbld2itL9HZWMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQAdp2ZxklzXV36Y+UvJh+gkoM00rZU7wkvlrvPNRbXlpBUTPn49Xgz3lbXFn20L -vJUI9yPtokNFnEgDSe2B92iQpvQpvMUwflknO8gIW/9IPrPEa15L6OxO5M7DhMrJ -LYrtHFE9tSAgHojKIsZksm/FpeTajRSYYOciQbgp+O/+WwWMVWoM00UlqG0kJPEo -40BIH3FAtoXEYgcQCpuSIEtCnCbyNxR07qi19dsUg74HcbqzkbZHslcftSWV121O -pHhaWiM/MFQPtQ+bI+dfKVAeueOvcQZwNitKS1Lvtts4qJOFX3ihiiK33Er+SRpZ -MbBePWzB9eGjwTooP6fGsMT0 +MIIDvzCCAqegAwIBAgIBGzANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE4MDMwMjAw +MDAwMFoXDTIwMDYwNTAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAM/aq3um7Re0exS5jCmjfyXLfKQcI9rF/Iopvb6wPUDBUQhG23OM3VwG +PozytdHrsJR04EYUtlXQu6m5Y6587uZMeoHzNx83i9yG0XkPbsrK/9CR4un2DDjK +KRjSkmWIbdZyFLKLBhFv9z2dVDu1yk3WAtgbKCy9NQnTKccdgpsSO6hcUWhpctID +ai6vtTP881e2y3921i33gnRQ8O+wrAiQvrFsR63L5eH+msLoDn/nQBGH7Bs3y9Jt +d5ZmSBXC8sKbquBkrY/u/oHKJkMPIfMzRw2+q6SPj4QdvOiP702tezkwIsBnsuyG +9/B78xE9jbNedKSfdeRKbMK41ZFSv08CAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFFe2oaWd5dQeSRDmVthw5qHVdPJGMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQCS+f3BAlW5YazFFYdM +JNultJszqyQ+TD0o9PEsUGTKii9536/n2MuOmMnT876zQOwoR2a+b3W46z8HGJcs +oX1lO0/YyUu6IcKvz5CqaqHncD7AVG4ibBHOVfLXnWq7TUCMJAUEBcA1xCi3C9bJ +OaEba4qq2oePzr4YrAQbMVI5qwPPQQe1ZOLlW3ZSICqeTRfEtmQJDmRm+dMjdCz+ +wXkV4MBZoe5x9wqOOlxGwBggoDP/AjdGYahqUaylOaHPSWF2a9+paGPp0hq7Q2DU +mWUakQQDQkPbKyjcyK8DtHFayRel/8nMBMdBf7Ol1XI9d0XzV6AdJE+KJEKlnUny +GMys -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/900_days_after_2019_07_01.pem b/net/data/ssl/certificates/900_days_after_2019_07_01.pem index c26e8739e..14514b06 100644 --- a/net/data/ssl/certificates/900_days_after_2019_07_01.pem +++ b/net/data/ssl/certificates/900_days_after_2019_07_01.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:c0 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 32 (0x20) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Jul 1 00:00:00 2019 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:a4:57:b8:aa:2a:90:a1:4e:5c:cd:df:45:06:fc: - 6d:f9:e5:1c:8b:0f:65:8f:d2:dc:fc:b2:03:38:63: - fb:c4:d6:93:bd:dc:cc:8f:0b:3c:3d:42:32:40:de: - 95:e2:5f:9a:7e:19:0c:06:40:55:b1:7a:e4:fc:80: - 2d:3f:86:8e:d5:a0:6e:e3:21:10:f1:32:eb:cf:41: - 57:5e:4e:2c:52:cc:d7:22:0b:24:f3:10:0d:ad:30: - 2f:2f:e7:83:33:a7:a3:0c:b2:2a:f9:0c:c1:b7:89: - 9c:24:38:cd:6a:bf:c1:c6:d4:aa:4e:5f:17:c1:3a: - 19:d9:84:f7:cf:99:3f:2c:25:d3:ac:4f:b9:9c:35: - 1f:b0:8f:99:c9:09:a6:e5:05:5b:f2:b6:17:32:33: - 6d:8d:24:ca:e3:de:4b:64:4e:77:33:2d:5f:37:89: - e8:cb:f2:1a:c8:62:39:03:e5:f7:30:05:52:1c:3a: - c2:86:1b:dc:fe:83:d1:de:99:8e:b0:6d:2b:f7:1b: - 1c:a2:39:75:25:c6:9c:6e:6e:0b:4b:44:fd:ae:d7: - 57:a8:82:11:36:a2:a4:7b:72:02:ce:eb:fa:eb:ca: - 35:83:3c:93:2f:1a:4b:9f:2d:90:f9:1d:39:65:4a: - 93:99:80:87:77:e0:a7:ee:48:f4:1a:a4:8b:a4:8d: - 5e:0d + 00:d2:76:d1:5f:28:08:6d:97:b7:6c:31:e1:7f:dd: + ff:c9:46:ac:c5:39:26:20:35:6d:50:58:4f:36:1f: + e9:c4:04:03:c3:80:d4:c0:a4:7d:8a:77:a9:72:76: + 66:31:cb:24:5b:ed:cc:e5:b4:25:ec:7d:8c:74:58: + 82:d4:0b:af:09:d6:01:6c:45:d3:d3:3f:d7:c8:87: + f7:91:21:0b:59:fe:40:50:ba:a2:b7:c3:a5:2b:35: + 36:78:e8:b1:73:fe:f4:a3:b6:cc:b0:30:6f:01:cd: + 4a:5c:d4:93:2b:a3:37:c5:c5:55:2c:92:8f:da:5d: + 5b:6e:dc:e0:73:17:35:d6:f5:1c:29:3d:f8:1d:37: + 98:41:65:9f:b1:f2:54:ec:39:35:95:3b:14:fd:60: + 8e:63:0d:6d:3f:63:b7:18:8b:90:73:43:d4:0d:05: + d9:81:c8:5d:09:cc:43:a0:a7:fd:05:5f:fb:f2:b7: + bc:24:54:46:64:01:86:33:ca:45:7a:b0:70:1f:3e: + 04:ad:33:38:74:44:2a:40:f2:e0:6a:e2:de:ed:c1: + 20:3e:af:46:6b:c9:25:a5:15:54:56:7a:3a:7c:8f: + 27:21:4f:d2:b6:5a:1f:21:8e:75:62:8b:40:58:f9: + 54:8d:8e:20:1f:5f:9b:6e:65:44:b4:c3:a6:83:8b: + 6d:d5 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 70:0A:87:A4:15:46:AB:83:13:EB:AD:AB:F2:93:D5:38:90:75:76:14 + D2:C1:43:17:52:15:0E:E2:4C:0C:BA:1B:EB:F5:E6:EF:F5:09:B0:EC X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 1d:90:bc:fe:ea:e3:79:0d:5c:6a:d8:dd:de:84:7d:b2:d3:20: - 8f:31:05:cf:0d:f9:c4:82:d9:db:3d:b9:ee:a4:9f:ff:91:82: - 4a:9a:3c:ab:19:73:be:b7:60:f6:6f:45:7e:4b:93:9e:58:ad: - c1:16:d7:e2:83:26:ce:e7:31:be:80:35:59:c4:1a:06:5c:af: - 27:e8:3b:89:b1:f6:dd:c9:83:de:47:36:78:cc:d8:5b:b8:4e: - 4f:d8:8d:33:86:b7:b5:28:e4:f0:1e:6e:ac:eb:d2:cc:0c:36: - b5:b3:30:17:a2:7a:15:6a:cf:42:e4:09:67:40:bd:27:39:e6: - 01:b8:b4:c5:dd:ce:63:99:67:29:7c:f0:ba:84:74:79:33:1c: - 94:92:63:2a:8a:f6:b7:da:de:33:12:80:58:cd:d4:0c:e6:29: - 78:07:ff:3a:5a:5c:92:d3:69:c5:de:10:56:fb:90:c4:24:86: - 7c:6f:fe:27:35:d9:3b:9b:73:6d:69:37:63:b8:bd:c8:4b:25: - 01:33:77:06:a4:7e:f5:05:2a:47:86:36:c8:7c:ab:17:b4:4e: - 03:42:1d:f6:57:3c:ac:aa:61:56:03:f2:d3:34:7d:0a:71:e5: - 3b:92:54:91:df:06:b9:dc:8a:cb:a2:33:a4:45:7b:c2:c2:b0: - fb:98:6a:40 + bf:d2:85:20:48:0c:a9:b5:6c:76:13:d1:ef:56:6f:0d:42:cd: + ae:97:26:7a:99:f3:d4:72:66:5e:db:ae:28:94:2f:9b:86:d5: + 94:00:5e:aa:c5:f6:f6:40:1b:99:1b:0f:5d:7e:74:95:2e:ef: + b8:bf:df:80:6c:b3:97:f2:e7:c8:4a:da:12:73:f4:ab:ea:a0: + 74:63:57:e0:9f:5f:1e:7e:f3:c7:de:e7:4c:69:54:92:d9:67: + a9:79:8b:c9:b9:ce:23:96:d2:25:85:4a:32:06:ca:6b:db:bb: + 02:12:34:02:f2:85:a8:40:81:f5:42:d3:d3:8c:fa:af:ce:29: + 6a:cd:cf:46:df:88:d6:d4:69:77:19:62:c2:09:b3:a8:00:32: + db:a8:9e:66:c3:5e:56:79:8c:76:50:c4:e8:48:60:48:93:a8: + af:5c:32:d4:e0:e7:91:1f:12:25:9b:a5:67:0e:4a:bf:eb:84: + be:ba:f7:0b:ac:09:60:1b:fe:92:2b:98:1e:23:24:9c:97:fd: + 5e:ee:5a:2f:c2:80:cc:f6:55:31:77:b2:c4:5d:ff:f2:c7:cd: + d8:a8:bb:ee:76:70:7f:04:63:24:df:9f:99:b1:35:79:9e:52: + 17:73:83:95:55:6e:bb:56:4b:76:c4:d0:b2:03:bf:8c:e7:7d: + 40:26:9e:3b -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqwDANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE5MDcwMTAwMDAwMFoXDTIxMTIxNzAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAKRXuKoqkKFOXM3fRQb8bfnlHIsPZY/S3Pyy -Azhj+8TWk73czI8LPD1CMkDeleJfmn4ZDAZAVbF65PyALT+GjtWgbuMhEPEy689B -V15OLFLM1yILJPMQDa0wLy/ngzOnowyyKvkMwbeJnCQ4zWq/wcbUqk5fF8E6GdmE -98+ZPywl06xPuZw1H7CPmckJpuUFW/K2FzIzbY0kyuPeS2ROdzMtXzeJ6MvyGshi -OQPl9zAFUhw6woYb3P6D0d6ZjrBtK/cbHKI5dSXGnG5uC0tE/a7XV6iCETaipHty -As7r+uvKNYM8ky8aS58tkPkdOWVKk5mAh3fgp+5I9Bqki6SNXg0CAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFHAKh6QVRquDE+utq/KT1TiQdXYUMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQAdkLz+6uN5DVxq2N3ehH2y0yCPMQXPDfnEgtnbPbnupJ//kYJKmjyrGXO+t2D2 -b0V+S5OeWK3BFtfigybO5zG+gDVZxBoGXK8n6DuJsfbdyYPeRzZ4zNhbuE5P2I0z -hre1KOTwHm6s69LMDDa1szAXonoVas9C5AlnQL0nOeYBuLTF3c5jmWcpfPC6hHR5 -MxyUkmMqiva32t4zEoBYzdQM5il4B/86WlyS02nF3hBW+5DEJIZ8b/4nNdk7m3Nt -aTdjuL3ISyUBM3cGpH71BSpHhjbIfKsXtE4DQh32VzysqmFWA/LTNH0KceU7klSR -3wa53IrLojOkRXvCwrD7mGpA +MIIDvzCCAqegAwIBAgIBIDANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE5MDcwMTAw +MDAwMFoXDTIxMTIxNzAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBANJ20V8oCG2Xt2wx4X/d/8lGrMU5JiA1bVBYTzYf6cQEA8OA1MCkfYp3 +qXJ2ZjHLJFvtzOW0Jex9jHRYgtQLrwnWAWxF09M/18iH95EhC1n+QFC6orfDpSs1 +NnjosXP+9KO2zLAwbwHNSlzUkyujN8XFVSySj9pdW27c4HMXNdb1HCk9+B03mEFl +n7HyVOw5NZU7FP1gjmMNbT9jtxiLkHND1A0F2YHIXQnMQ6Cn/QVf+/K3vCRURmQB +hjPKRXqwcB8+BK0zOHREKkDy4Gri3u3BID6vRmvJJaUVVFZ6OnyPJyFP0rZaHyGO +dWKLQFj5VI2OIB9fm25lRLTDpoOLbdUCAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFNLBQxdSFQ7iTAy6G+v15u/1CbDsMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQC/0oUgSAyptWx2E9Hv +Vm8NQs2ulyZ6mfPUcmZe264olC+bhtWUAF6qxfb2QBuZGw9dfnSVLu+4v9+AbLOX +8ufIStoSc/Sr6qB0Y1fgn18efvPH3udMaVSS2WepeYvJuc4jltIlhUoyBspr27sC +EjQC8oWoQIH1QtPTjPqvzilqzc9G34jW1Gl3GWLCCbOoADLbqJ5mw15WeYx2UMTo +SGBIk6ivXDLU4OeRHxIlm6VnDkq/64S+uvcLrAlgG/6SK5geIyScl/1e7lovwoDM +9lUxd7LEXf/yx83YqLvudnB/BGMk35+ZsTV5nlIXc4OVVW67Vkt2xNCyA7+M531A +Jp47 -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/bad_validity.pem b/net/data/ssl/certificates/bad_validity.pem index 9fc050e..cb51391 100644 --- a/net/data/ssl/certificates/bad_validity.pem +++ b/net/data/ssl/certificates/bad_validity.pem
@@ -1,37 +1,36 @@ -----BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmWNw2JdGmpJMI -zy07hge1zkTHW3/XEaZRmOyCTGwxRaMEVm/Bd9ZsONs82C3SJapHT/Sk844JmDfT -D3H2rClHewiOaKv8fhACZbaGTLAnBGoVI7M6GbgV8zsLHa3Yn0mxcvKvCN/IAqrL -8yotwP0osJfaSqkidMI6C2RlKsn0ZfdGfzypYZZfDCpmw/LH/mmHL3AMG2Y3ksU/ -hUDY5CZFGD/OUyegl34Rh9xK7Cbr/5UOs+ouZkUKqszFgVkuChsOG1lxytOQ72/K -t4yoyoJVuPtK5bopeM7rzY5PnK+FpO8LZF4+fqDg5bCG8xkI+j/6Hkqb/LUWF4gN -OA7Dpl/VAgMBAAECggEAeqgjGDoisMHBOUmqjK1zmfcSd/1b8nWtMZWVLy6yyFIU -teoWVY3Lqdjyr5anksD7IcIvHkIIhcKbxyEoYz7m4TIzSO6dgnxhyaK+R6Dccqiq -oBPG4Bx+xJCpBLVJruUlLZcYoz/j4lM1JVWT0FDxWsN79RYASMvXO32S9ZXrfC1S -YZjVeUrjyrc7Y2Z6z/n89P9mfWUwqOuuH6fHpNHvBugteFB3pS2oclooOh3hXWIu -ZSHWOyX0wj0Rk1iuOBADqxhec/zR4nQ9IZi3nRbfNyoUYzf2qgqPcS9yROS9PZQw -rESmMXpVJ1aF9sFo0LA5KW2sT7qbVWeLwfF8nZvPgQKBgQDdoAdvu5BPTk4E2jg9 -y/VfESKiVd1BStsw5DWBZtgDGDpLHtkoezcao0hJxGKAsnWJ1EqhqViNXEJcECi6 -Xdr5EF525y9KdKCld7q9ZeQbvvg0QLHXYY0bQhPhbymosFg+qdJCHfn8Wwim8Ibc -JnjpzDdzSKEWELanUrSTEla1TQKBgQDAJe6I4CtEXaBXi06KQHnKHI+9uu1w0TBp -YuM2/3v7CVBcN/lkmK/tnM+RZqgEi/Nhy08uIfIQjWetq7FQjbLEsesy3zlqIlth -Kw4jCcdrPW3XTp/Ru7rUQUjBTWpDh/f1T41OzY4qE5X6v2MQkJP5a614Qi2kqFZ3 -neZtpfNwqQKBgASoFR/q3/ham9cMQrxBqdEqigDBLxntGbfoQ5uJbqZ5/tePOV7Z -X+oGXkF2h99OYJvZwwushDjMJHTMvh5UVIKBLorvBpZY5vszDdBm8KkIlSx744C0 -AwP8mnBVJpntwpzmco2DFbqQqxje2uaLRGUdLlkUwJW3Gi9f1H12mC3NAoGBAJOr -00HwfnAhQHxnfKn12WPCRZo8EgV1T65+qD75ZJBO3SqyfgGY8wQ7Uq7dZV1xLVBI -TwcWYZHlCvxHCpPtAqn2TtsfAWIXG4F29HtrJY6+fC9PprYqf/BmaALfez6BPciT -JfedNJgTy10VP45YftDet0fIHIoCMcnmWVSFiK1ZAoGABYToKrxvwdgzqRt22k0D -OcMTSQqpcO/WZfcpFK9leOLuKBNniow1PSYkymdVgCkSjrY3Oksxh/0V20H62oqU -bJMTvYZFpTcCQgcwSiyQD2o2PgKNxrxIfII4/9H8hjV99uXaafEWFky8ea6GEJaN -4PkKpNDj9dus6J2Hzat2c3E= +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC0v9KXM+UTW3dl +vXMadSibR1nmtzDoRjNtWFvaHwr/5OQt8h34iehkLvbDzdejjtf3zefYDhDD51bS +/OXm007i/4JNGGOHsKPe2u8KN3ustbdDzvIHOd8U6cOkQT5+aEc0m3thxBjmE86z +tKbgugPu5OvnqvRtvpdbqgaXUAHQeLjWkrDk4rlDiLWuFGR9UnDUBRwJJdXiT8mo +gttBMcO+RG8L1P2/we7ZYr87j7UAyNHfXUoTrXHkS1/R2XJMg9iTQL9szS9mDgTW +uUMoJMkl/Vlw/j3yqQpOwpvE3p5XXl0WJeZ4tkRJKZ32v3T7hdYN8WVY8ivWjxBJ +yAAtiOItAgMBAAECggEAXuyGumXEnl/g2oueEX0J8FKOgj4e7z0+8OQAiRLYgf9B +XmfTGZ3DcCnB6p8F6p2wCjIW2j64y0mJLZEnZAwBV/F8CuUOEErSJM2x0BnHV7Kv +JmtebDEWWTNTTcX9/gDhtF0bdQK5WMt6OKJdKZRHUITk52u+pov7jWZDw99+tG5w +InCv1RekWbAGZWLs9hyzpOpvp0tGM2O9+XCWQh/LLeLb5rJkTcH8NKv9Xh+tLeSU +i/FER+rQHsMVA4uHdBmRgPsBnPrJopcKWQImRXDGidEd5AUWLIECQdnZI8pbtmjV +0HZj+UuUlDFdALmCHX+NxR4Z+hyi+E96ZWw/J9FHwQKBgQDYX0e873Sf4tDOn0cZ +Olof3cXPri8ezKoeAD8tfY0bxLIoOwDUtJXZeGEZD3sduDJDCdvS1M/eeW04ePlx +kTmcDecaYm4t3KYzbPauudbMQEQFvsoivp8ct/synPcRtGPTHg+GUHaqWT1d4DjT +WClxx67ugD/YQYs5UY/uLjm4tQKBgQDV2lh1Uk3xBj15FZrzg/7GM7bK3L/Xcxzz +VewAksKuVEyoqHfZAo6P/xOiQkwc9kBoet43MiNyph/kYssQowE+Pg+WffB1Ve4F +kVsq6z1mwAfnYD6m4GHxfrV6VxwM3ItiX+PiKQ4YWsbyjc/vC4ZRSarLwbk8Woya +lNucr2hGmQKBgF5sdioFdaewm98Psz9XL61oYsLXCMkwF60v/mIjwEi19emIljw8 +8ogM+JKvJtM5ZvXKf5vqMyyrYPacFH9zGOj5SDlDa0GoYP9gNebaQtqv0P+Q2zV+ +aoFl6MGVrlyTlFy1aaD7zE1a1GT7TNEuUCfPNI/wd+wv7kn9RgpzMc1hAoGBAJrh +5Zkq/+olc9ZDcJMXsSkJgUURdhvrcjdGroOHx1oNEexA/3P7ZxchTa4ByDBdpS5G +drSRKp05dfWqG5o0BI140z9SfRnuH1KHAPlnoHPPdqn7ycSA1E7cT0GI33btMEIS +YvCEfYHkFRzM2qEtvp0W9o1WA/uTNSwrzZaAb8xZAoGAZZLwniPa8zkd+4WAPSN6 +LVj+1dGasfL/zftFhVxu0/KCpdggghG26Ej0ieG71k8Xg9tpZDJvo9Kj0s8Hu4Zu +TnhwwRVyUHls+Gl0t8XXV/ryRLHB8zY45k6A+Yvc/iOYQVmY2rE4kB4PDsrJ+d5P +wA1o1OPvcx28oBjHViWoWJQ= -----END PRIVATE KEY----- Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:a9 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 8 (0x8) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Jan 1 00:00:00 1 GMT @@ -39,32 +38,32 @@ Subject: CN=Leaf Certificate Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:a6:58:dc:36:25:d1:a6:a4:93:08:cf:2d:3b:86: - 07:b5:ce:44:c7:5b:7f:d7:11:a6:51:98:ec:82:4c: - 6c:31:45:a3:04:56:6f:c1:77:d6:6c:38:db:3c:d8: - 2d:d2:25:aa:47:4f:f4:a4:f3:8e:09:98:37:d3:0f: - 71:f6:ac:29:47:7b:08:8e:68:ab:fc:7e:10:02:65: - b6:86:4c:b0:27:04:6a:15:23:b3:3a:19:b8:15:f3: - 3b:0b:1d:ad:d8:9f:49:b1:72:f2:af:08:df:c8:02: - aa:cb:f3:2a:2d:c0:fd:28:b0:97:da:4a:a9:22:74: - c2:3a:0b:64:65:2a:c9:f4:65:f7:46:7f:3c:a9:61: - 96:5f:0c:2a:66:c3:f2:c7:fe:69:87:2f:70:0c:1b: - 66:37:92:c5:3f:85:40:d8:e4:26:45:18:3f:ce:53: - 27:a0:97:7e:11:87:dc:4a:ec:26:eb:ff:95:0e:b3: - ea:2e:66:45:0a:aa:cc:c5:81:59:2e:0a:1b:0e:1b: - 59:71:ca:d3:90:ef:6f:ca:b7:8c:a8:ca:82:55:b8: - fb:4a:e5:ba:29:78:ce:eb:cd:8e:4f:9c:af:85:a4: - ef:0b:64:5e:3e:7e:a0:e0:e5:b0:86:f3:19:08:fa: - 3f:fa:1e:4a:9b:fc:b5:16:17:88:0d:38:0e:c3:a6: - 5f:d5 + 00:b4:bf:d2:97:33:e5:13:5b:77:65:bd:73:1a:75: + 28:9b:47:59:e6:b7:30:e8:46:33:6d:58:5b:da:1f: + 0a:ff:e4:e4:2d:f2:1d:f8:89:e8:64:2e:f6:c3:cd: + d7:a3:8e:d7:f7:cd:e7:d8:0e:10:c3:e7:56:d2:fc: + e5:e6:d3:4e:e2:ff:82:4d:18:63:87:b0:a3:de:da: + ef:0a:37:7b:ac:b5:b7:43:ce:f2:07:39:df:14:e9: + c3:a4:41:3e:7e:68:47:34:9b:7b:61:c4:18:e6:13: + ce:b3:b4:a6:e0:ba:03:ee:e4:eb:e7:aa:f4:6d:be: + 97:5b:aa:06:97:50:01:d0:78:b8:d6:92:b0:e4:e2: + b9:43:88:b5:ae:14:64:7d:52:70:d4:05:1c:09:25: + d5:e2:4f:c9:a8:82:db:41:31:c3:be:44:6f:0b:d4: + fd:bf:c1:ee:d9:62:bf:3b:8f:b5:00:c8:d1:df:5d: + 4a:13:ad:71:e4:4b:5f:d1:d9:72:4c:83:d8:93:40: + bf:6c:cd:2f:66:0e:04:d6:b9:43:28:24:c9:25:fd: + 59:70:fe:3d:f2:a9:0a:4e:c2:9b:c4:de:9e:57:5e: + 5d:16:25:e6:78:b6:44:49:29:9d:f6:bf:74:fb:85: + d6:0d:f1:65:58:f2:2b:d6:8f:10:49:c8:00:2d:88: + e2:2d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 81:CD:A7:DD:52:43:7F:DF:7A:4B:BA:F5:B0:B6:10:A0:44:0C:EC:6C + E0:DC:E0:2F:07:88:74:3A:9F:D3:30:A3:71:8A:F9:D6:A5:E5:A6:53 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -73,40 +72,39 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - a5:9c:bb:a6:5e:84:75:ff:c7:7c:35:68:dc:46:fd:66:ce:e3: - 0c:1b:58:e8:0a:43:73:bd:d2:77:70:2c:23:73:6e:07:49:4c: - 43:72:bb:1c:9d:53:a6:a8:38:b7:88:b2:c8:5f:df:ec:10:17: - 35:d9:88:4a:85:cc:8f:16:9a:d6:ea:2d:a5:fc:11:48:b9:6f: - db:9f:26:e6:a2:b3:59:31:c0:7e:db:b1:73:e3:ce:5d:50:38: - e9:2f:26:72:5d:a6:14:47:89:f5:d4:b4:d7:05:b3:ad:39:82: - 4d:87:99:2d:93:df:1b:ab:07:b5:bd:e4:f0:ef:72:54:e8:80: - 58:a3:b8:40:49:53:8d:d1:36:4f:21:aa:b1:3d:9b:23:61:c4: - 2f:7f:ec:b5:9b:16:ff:7f:ab:4a:dd:32:ee:63:06:a3:ba:f2: - 05:18:31:62:04:0f:cf:52:88:04:ae:2a:2a:a6:95:7d:4c:aa: - be:4b:ad:d7:41:53:79:5d:cf:12:39:1d:10:3d:f0:74:20:72: - 6f:19:a5:b1:fd:0e:b3:b4:56:5a:ce:69:31:d6:fe:b0:2a:7d: - 89:74:4d:5f:ef:45:c5:69:79:75:62:13:92:ac:10:73:0d:c1: - a3:eb:c3:38:3b:a8:43:cd:3d:d5:ea:a8:0a:68:f9:ba:ef:f5: - 09:76:0f:32 + 86:50:e0:4c:98:8e:43:69:c2:2f:f5:2e:2e:64:30:28:0f:49: + 48:d1:9a:61:bc:49:01:f8:84:0a:04:91:d4:04:ee:9d:02:fd: + 00:2b:6d:57:d5:23:c7:62:eb:e2:96:15:90:bb:1d:3a:8f:98: + 32:1b:0f:04:d1:e8:ce:e6:4f:a3:2b:3a:41:9c:04:15:b2:30: + 3d:ef:f9:d1:8f:73:f2:f6:f9:0b:2e:8a:05:ce:ec:8f:1d:f1: + 84:c0:ba:a3:ef:c3:1a:83:fb:19:1e:03:fd:46:3b:97:28:55: + af:0a:e9:3f:36:90:a0:8a:a6:13:ff:d1:10:ac:d1:7e:79:54: + ae:fe:74:b9:7c:3f:8c:b4:e1:3c:5d:0b:18:92:69:00:04:0a: + be:0a:c9:bd:57:ec:9b:c3:8d:d9:07:fd:97:5b:04:e9:b1:29: + d9:82:8e:f6:fe:ce:76:2c:b3:d4:3b:f3:06:6d:30:a6:b5:1d: + 4b:f0:8c:57:07:1d:0e:23:6e:e4:50:fb:ef:74:d7:78:ff:be: + 31:97:66:ce:9f:a8:98:48:21:97:56:29:d5:c2:6e:66:6f:9e: + f3:ad:cc:92:f0:ad:fb:0b:e7:90:42:f3:27:13:69:35:71:bb: + ee:9d:fd:dc:ee:3b:62:c4:2a:98:ca:15:6f:15:d9:f9:0f:82: + eb:fe:80:03 -----BEGIN CERTIFICATE----- -MIIDjTCCAnWgAwIBAgIQPiydvrBCyM/8mULVTUFqqTANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMCIYDzAwMDEwMTAxMDAwMDAwWhgPMDAwMTAxMDEwMDAwMDBaMBsxGTAXBgNV -BAMMEExlYWYgQ2VydGlmaWNhdGUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK -AoIBAQCmWNw2JdGmpJMIzy07hge1zkTHW3/XEaZRmOyCTGwxRaMEVm/Bd9ZsONs8 -2C3SJapHT/Sk844JmDfTD3H2rClHewiOaKv8fhACZbaGTLAnBGoVI7M6GbgV8zsL -Ha3Yn0mxcvKvCN/IAqrL8yotwP0osJfaSqkidMI6C2RlKsn0ZfdGfzypYZZfDCpm -w/LH/mmHL3AMG2Y3ksU/hUDY5CZFGD/OUyegl34Rh9xK7Cbr/5UOs+ouZkUKqszF -gVkuChsOG1lxytOQ72/Kt4yoyoJVuPtK5bopeM7rzY5PnK+FpO8LZF4+fqDg5bCG -8xkI+j/6Hkqb/LUWF4gNOA7Dpl/VAgMBAAGjgYAwfjAMBgNVHRMBAf8EAjAAMB0G -A1UdDgQWBBSBzafdUkN/33pLuvWwthCgRAzsbDAfBgNVHSMEGDAWgBSbJguKmKm7 -HbkfHOMaQDPtjheIqzAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDwYD -VR0RBAgwBocEfwAAATANBgkqhkiG9w0BAQsFAAOCAQEApZy7pl6Edf/HfDVo3Eb9 -Zs7jDBtY6ApDc73Sd3AsI3NuB0lMQ3K7HJ1Tpqg4t4iyyF/f7BAXNdmISoXMjxaa -1uotpfwRSLlv258m5qKzWTHAftuxc+POXVA46S8mcl2mFEeJ9dS01wWzrTmCTYeZ -LZPfG6sHtb3k8O9yVOiAWKO4QElTjdE2TyGqsT2bI2HEL3/stZsW/3+rSt0y7mMG -o7ryBRgxYgQPz1KIBK4qKqaVfUyqvkut10FTeV3PEjkdED3wdCBybxmlsf0Os7RW -Ws5pMdb+sCp9iXRNX+9FxWl5dWITkqwQcw3Bo+vDODuoQ8091eqoCmj5uu/1CXYP -Mg== +MIIDfjCCAmagAwIBAgIBCDANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMCIYDzAwMDEwMTAx +MDAwMDAwWhgPMDAwMTAxMDEwMDAwMDBaMBsxGTAXBgNVBAMTEExlYWYgQ2VydGlm +aWNhdGUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC0v9KXM+UTW3dl +vXMadSibR1nmtzDoRjNtWFvaHwr/5OQt8h34iehkLvbDzdejjtf3zefYDhDD51bS +/OXm007i/4JNGGOHsKPe2u8KN3ustbdDzvIHOd8U6cOkQT5+aEc0m3thxBjmE86z +tKbgugPu5OvnqvRtvpdbqgaXUAHQeLjWkrDk4rlDiLWuFGR9UnDUBRwJJdXiT8mo +gttBMcO+RG8L1P2/we7ZYr87j7UAyNHfXUoTrXHkS1/R2XJMg9iTQL9szS9mDgTW +uUMoJMkl/Vlw/j3yqQpOwpvE3p5XXl0WJeZ4tkRJKZ32v3T7hdYN8WVY8ivWjxBJ +yAAtiOItAgMBAAGjgYAwfjAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBTg3OAvB4h0 +Op/TMKNxivnWpeWmUzAfBgNVHSMEGDAWgBSbJguKmKm7HbkfHOMaQDPtjheIqzAd +BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDwYDVR0RBAgwBocEfwAAATAN +BgkqhkiG9w0BAQsFAAOCAQEAhlDgTJiOQ2nCL/UuLmQwKA9JSNGaYbxJAfiECgSR +1ATunQL9ACttV9Ujx2Lr4pYVkLsdOo+YMhsPBNHozuZPoys6QZwEFbIwPe/50Y9z +8vb5Cy6KBc7sjx3xhMC6o+/DGoP7GR4D/UY7lyhVrwrpPzaQoIqmE//REKzRfnlU +rv50uXw/jLThPF0LGJJpAAQKvgrJvVfsm8ON2Qf9l1sE6bEp2YKO9v7Odiyz1Dvz +Bm0wprUdS/CMVwcdDiNu5FD773TXeP++MZdmzp+omEghl1Yp1cJuZm+e863MkvCt ++wvnkELzJxNpNXG77p393O47YsQqmMoVbxXZ+Q+C6/6AAw== -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/can_sign_http_exchanges_draft_extension.pem b/net/data/ssl/certificates/can_sign_http_exchanges_draft_extension.pem index 95cdd26..250b88b1 100644 --- a/net/data/ssl/certificates/can_sign_http_exchanges_draft_extension.pem +++ b/net/data/ssl/certificates/can_sign_http_exchanges_draft_extension.pem
@@ -1,21 +1,21 @@ -----BEGIN CERTIFICATE----- -MIIDczCCAlugAwIBAgIUBdr4m5otqGWF8sQcOBHQyV2ukGYwDQYJKoZIhvcNAQEL -BQAwYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcM -DU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4w -LjAuMTAeFw0yMDAzMTMyMDQ2MzBaFw0yMTAzMTMyMDQ2MzBaMGAxCzAJBgNVBAYT -AlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3 -MRAwDgYDVQQKDAdUZXN0IENBMRIwEAYDVQQDDAkxMjcuMC4wLjEwggEiMA0GCSqG -SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCjXA7p3tWcWML9bBmhYteqhMuAtQ/W5/7q -I6o3w1r6VkqH4vkIT9v+4/VgQE4Q2VbmEeK9nBGUQoJXdFcrQ95BY597QjFISULw -qRelmR+tIY23K8JNK0QPFn6CPhPsQz/EPXk2+8gNL/Lj9DybRKDdrfS/xF5jefOT -BiASU1mRUe67y8lPcbcBbuRyaRU6PgZwQx3aPBLTn32bMfZXL+BBA2QTNH1M+YSf -otU6c0qdbGmLp+iEuYv0xFeXIDNhpYhnj3v/6MGbKl/pB5g5sPzOCp5uIw3b+ZL5 -WN8tYY0djgmKbcOEoSAmI8BmWNG7z+i5/Rr9eNAHwvX/T1bZ2ZyBAgMBAAGjJTAj -MA8GA1UdEQQIMAaHBH8AAAEwEAYKKwYBBAHWeQIBFgQCBQAwDQYJKoZIhvcNAQEL -BQADggEBAIJOMJjMtky/DvbAi0kOg9ck0Dsj670+JAvaEC22OtvnCsbTt2KgmYNz -eynR3YEjZkFjV/cDQeaQUFYFmxbctL8vWQ07HfKfpbDalxoP+6XRVf6KpYcQaNvF -o+5fd3AmQHPUIRiQuy0+K8rQklo0vrY4usH1/U40FqqIkgPNIPdugUAeCEcvh14c -dCIumYCDYF0Fa/IEHkEOrByyuNky3LTCOK/r/h166pCYU2ag5udoiRZQn9CHomAF -46g9CLjfMak67GiQQvmbOB8suT6lX+8XBWg4dy2IGEaYAlQ2E9uWtzkC8yGRoPn6 -8jjJn8AdirTOOGxHz65yJdJbYHnpvAs= +MIIDaDCCAlCgAwIBAgIJAL+mLJGnpUF1MA0GCSqGSIb3DQEBCwUAMGAxCzAJBgNV +BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBW +aWV3MRAwDgYDVQQKDAdUZXN0IENBMRIwEAYDVQQDDAkxMjcuMC4wLjEwHhcNMTgw +NjI4MDU0MzM2WhcNMTkwNjI4MDU0MzM2WjBgMQswCQYDVQQGEwJVUzETMBEGA1UE +CAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4GA1UECgwH +VGVzdCBDQTESMBAGA1UEAwwJMTI3LjAuMC4xMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEApHXhhcN/ztDSl5gCN4kKnu0BvMIJuePoHQPK+tSKoZ/KJJlf +dJXh28dPtkCH/Niyuk/n6noyxFnVZe0oPiSS8YxPJl1mq4EBpojxNiag2CxmTtd+ +KpIkVnxxR9sm9gOtkYoWjKS4ZZrMP/NscDOJczWxa4t/J56S+y5Ai0eO+FnA2muh +S0wM0hzTMliB8wziEwrwdG/ALRrq41VP+7ENhrEm0XfQR0HAu6E2EcniG582k6Gk +4K3BhKCA5pPT/wD2F3vtthGkhr6/zNGdHlD3ak/6W8lBpu5m0ZMw0DXDa3AGx8+J +bHC2wensrIiBfPqIWeLZaV5DGw33h0di1FOqtwIDAQABoyUwIzAPBgNVHREECDAG +hwR/AAABMBAGCisGAQQB1nkCARYEAgUAMA0GCSqGSIb3DQEBCwUAA4IBAQAO69by ++kSrwuURVR2oWiWPzL6uFmQ3B6hK9Y1xL1EQDfwQdp734J7lvM+HqtQocwkt9Bu3 +FYnkELXve2QM5eyDtp56NJ6hGuavMFucvBuW26xYmOaeQVVR2TEJDJ8aVZ9j+eRc +UninLwe/tS8bVDgyhVMyAZNRSRNLYcJ4tj69zI5jFfNMOYXFdIkLH43OmS3YDJxZ +LG04e+kGlVYRRhnxbIQwhpnJen7Xrch9s7knLbnWrBnY6p+zHKFXLZU4xEa0i+Oh +nq1J52iUIjJJyCQrNCRergz1BW+8Nupz1f86VHS7eAAdq28//fAiguO+AHCrDIaL +DXQBKUctVk5MY6i7 -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/can_sign_http_exchanges_draft_extension_invalid.pem b/net/data/ssl/certificates/can_sign_http_exchanges_draft_extension_invalid.pem index 082bbb0..9479417 100644 --- a/net/data/ssl/certificates/can_sign_http_exchanges_draft_extension_invalid.pem +++ b/net/data/ssl/certificates/can_sign_http_exchanges_draft_extension_invalid.pem
@@ -1,21 +1,21 @@ -----BEGIN CERTIFICATE----- -MIIDczCCAlugAwIBAgIUQeyVfVMC4fKzl+J67ydMLC1eoIUwDQYJKoZIhvcNAQEL -BQAwYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcM -DU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4w -LjAuMTAeFw0yMDAzMTMyMDQ2MzBaFw0yMTAzMTMyMDQ2MzBaMGAxCzAJBgNVBAYT -AlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3 -MRAwDgYDVQQKDAdUZXN0IENBMRIwEAYDVQQDDAkxMjcuMC4wLjEwggEiMA0GCSqG -SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDhJlsb6DK7dWB6GKhe66bMQGBh9GqMdwWi -+LVDCq4/SJVMP/S9gnzvbX/MoRAuNzSefxy2mB0wIoEfP4gIQw/zoKIlgDFe5oKz -V4kvCxKSeWdpznNuofo0Yi83AzrqP4olRspwGzwaSr0w9TFGLPwtmsfGnE9p2uZ/ -MFDDKyWeLNOHRxGfAOYaaTYEkdGTsIwIUq6/JHyKZwhkZtl5ZW3SrqVPY1TS5dh1 -Hi6kAIGjiw0+kE464RX0to3CJSXOWB9FiOd0MMQ+QaKhEAZ8K0SeRLhDzVsBnX4L -waeiPhm8+COngIuUiwHp+u/S/akwm4RHI62hxS4Hoke+VQWDJ0jlAgMBAAGjJTAj -MA8GA1UdEQQIMAaHBH8AAAEwEAYKKwYBBAHWeQIBFgQCMAAwDQYJKoZIhvcNAQEL -BQADggEBAEOK4hmCXlk8FEbVbz2kAxW3YZkluo+8nEhVEZP3RcY+zDBIhwTSra1u -Ewn9wkzta8WY5axXk4vKPx7RkUdeaHpCdGNOVyGkhxHm5Mrxf9VdXNOvWURiEHoa -rHZ0U4UJxaPJpkRseVGRrkdSz9OA4Sm6kKGrw8Yr66Ij9vfREgVPU60dH+5iFb0Z -SxwIfsV1Q8vGDRDBvv17xbl9MM3tpDeEpAOj4nHGaWOyw3w/ZBkLhGMv10Upc30y -+OANGzwvdalT2uq9k9YogoXw9ytpa9YP8FGcNsWO/g5FNIdVdfmJS7f+DD00jYVp -kVtNMF0MgVKG76ny5PrmUDpWltq7wPQ= +MIIDaDCCAlCgAwIBAgIJAKacjL/rr3TRMA0GCSqGSIb3DQEBCwUAMGAxCzAJBgNV +BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBW +aWV3MRAwDgYDVQQKDAdUZXN0IENBMRIwEAYDVQQDDAkxMjcuMC4wLjEwHhcNMTgw +ODI0MjM0MjM1WhcNMTkwODI0MjM0MjM1WjBgMQswCQYDVQQGEwJVUzETMBEGA1UE +CAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4GA1UECgwH +VGVzdCBDQTESMBAGA1UEAwwJMTI3LjAuMC4xMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEAtrUDSOYujJGYyc9B35JV5panjbG8KOCky14YGdMQWvlo7mCK +mbtefpFzC5EvZERZey8cMdKzUMRtoCDFNtqTS96V5XLxCzNTe6xynu9BHtQuddzS +3E8e4fltfkvV2rz47Q/ciyUhfmXdMEW3RFdj7oohddRJtpF7FdNp9ShCnVILUIPJ +sspaUJBVO3L+O042CwVwOndEt4N/Xd7Bf4516q4sVKAHL/QWpJzauHi50kvCVo6f +b2h/e9eCin50Ydd+A3UjY02pQh6gmHZXvQwxYC9qRTrMI+LsBBnubXcCzloHT9FU +8umggcLjeuPzcXQV5jwBwFiuMhJBUYl1a7USpwIDAQABoyUwIzAPBgNVHREECDAG +hwR/AAABMBAGCisGAQQB1nkCARYEAjAAMA0GCSqGSIb3DQEBCwUAA4IBAQCbrJ6W +lrL6DJdafOjx+7nnqCzcY36r/58EFTyLkpKNBdzOLdpQld66QAsJi/nRlfxtk/2m +AEMZOa0wyuC0jZ+2Z1fDJ0GJwir7QKxedJqm3Oh4x4O5MsNxB3U3u7hiT+mJQhWS +2UWALvCbG4lmSLEv5NR6zNcATJX0jwCVPfibJwTVolpSeFCPfJ1nwVyXnYrNY4Qr +gy5FnZc3o5qZ70QZ5dozhJSZF2gBFlOs3aanWjQwkw6IUzABhnAlwtlgxb6A/XkA +OBvVlrMoSEMWdfTSJ2P6upcjhuVocqnd2UJ4CNDr79nJN63p6GQXPRhlYHpakm5w +/wLqXAxa/mEXqkSQ -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/common_name_only.pem b/net/data/ssl/certificates/common_name_only.pem index eb3caf0..5f7811a0 100644 --- a/net/data/ssl/certificates/common_name_only.pem +++ b/net/data/ssl/certificates/common_name_only.pem
@@ -1,37 +1,36 @@ -----BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCcvBOlD/eaadr5 -NB33MsG0KC5UlkebMSJuurca1kUHzhbZqhxCWTEd3uqDbtJzNaaYLfcWoWnp1nB7 -PiBtvwNanqAuUhlOw5NhVJVdi1KeFGnKxO/fupU20tHRh9z8odbKnKD1TNg9kKZo -Z0PeMaMK8FYf9sJIMhpBoakkQzsllBAxLO1tgo9VmhBgCaCRcj6A6nrpOO3x1HEC -1Q863WhMqYwyy707TSyqiJ2Ipu2/NUxhDeL/ptD+zP9NV9w4iowc3878vQIorxjV -40FhxAdwk4ohG+uPZ3gq/ln8xmGgS/BWSZ5kW+qmJvDRg0a3kO5TR1i4lZh8p7ul -BvrkzOAlAgMBAAECggEAMHs82GIIBQuZYFxuqHha0o9bRW7211prfDTlTrfYwoFN -MCcedqeAOe0qPV2aW2jND2WoeKeVS2+5e2XMQiZDs1Q92BYtHeABRqoTScw+0gce -ckpYqKveXAb6QAX2pW6qMiIg57/NY73Ku6C1rZVNCaUt/tUlY4+b75FB8KWbNhQK -vqsclR+82qQpbx0d8ttAHntF9M1RVpQCJoJWmUM+vAwKwAIg/YyxhBjHoWmYwkQM -Hj9wgCcr0hLmIWYTYV61TJVlPgg7xQQdnYnrZ+/whjLNAJDFchakviqFnAIeK6lF -lcIQZy3rPm8am0NYqg7T8bjWTx60IXJ21xUrYFRaQQKBgQDLRQCGtfn6ACg3I7Ki -dXgMgPieC3bzLZ53/DPny9NZfbpkIhU/YHqYhUOZvJ3Y4UK8Czz+SOtwXXthOFNn -62bBElNrrcDfvOuaY/U2Uq6HpYuZpMQAIwDnZ6u/brzJE9FABFApSfMWeUXllWlx -OHbhDweT69Y+eLAkW7s6N7/VHwKBgQDFZLl+WqLTO5G4qfir39oIDVahdkQGCDwg -SxGIEfiUk2URr/glXCpH9kNzzqWLHqT/B+FGgxydiHuKbcQkMdYe88iTjkJTJnYT -Im2gjdRU4Wqz09wwFcUKIrNWyPBps2GeWY5Kwe6Og23CkTDRfPyT04tv1mH2ZuOv -aXj7M57+OwKBgHoKr8oxsCh9t6eDc1k/FhjLxnl9gKl4llCLx84//mEYr7Q3EnK+ -xlyUhoXjTRJODPdB+BjkRxdryQwR+WHHYCZDjnp0E/1BPGOx6CP5eHhQ2IQi/Nro -KT7Ga8PABPDlSRkafdaMY7r2jRTOpEQqFpYBpBcX3cYcSAVMXhkSJ8cZAoGAGrT1 -D+5tZ00A+04r8f04f6xmUzQwIezNTcU6WwGrc1a57vmzBkMBCXl9SNbluPvtcP/8 -79Bfd8T2ihUt24POp6NuOOCfgqaKhS48TOPDnbRd/nSkrvDTFvr47r4DIRn/FDCj -uuOgRjHsEM4aH83cUpflnr0PxgnHtnz7vGkQku8CgYBUYYD9/t/Et9AyH43XcT+M -XuA42PLk6ksrIs6AusVmbn7HuBBTwFAGhktVTb3zkhecv24y52VLYwGrSMP4EfFy -DNoQFgpgzeXs/qFqsYaNe3jH12NrwlPKuIRf3m5jthB7mkDgC/tc0Gad1A/ziKQF -Wc46d1a/0pS1g30Fe4NNcA== +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCp1J9FuvCmfgoP +pUn3w+iVRBwBOCXlZyzRcfRsiOfEGNnY8gEDNoyccKFHnj5rtJ/kQc9IgcZC2nob +qUSdHBEhUjKZbDZXOTXlBmpVY3qw0edMgwS9SSmaM5axPXEqJn7KShyzEC+3qux1 +T+gH8DBgwiP2qjM1A6nqf0/QDDms15sKhZJm9Z/MBpbpO/4zPjYSdsADv9sc7uyU +xRnNp3PQWu/hZjgg9w0tZWOzBaKHTHJLV+wH8frRqwLdHoB+gSIUfmNnGHKe59ia +rWjGU4l5b4kOVS8e5dSfdvNLbUM8z8dMvRq68fJnCJLkqnV7cehYmi+c6iGvDbkV +y7vVzfWnAgMBAAECggEALyW5+c/GE1KWVHWcrU4T+axo4eXGj4MvLA4ovyDaxtPn +VpUItu2j56JVA97okVoZsXKbqxNsCQ9CKv+47qzmDIwXRASIqXpWffhj+MSfQQtk +3Rbab/optIdx5E6cZgk91cbxZLyvopuu/XprfhiuNY5wEYB6qtMTjug9LhLWyCa3 +N2tTlIi8qMa79HPYcJ3l7en8jXrx+/856hCGGXXNP6H3HP4Kf171tZryDuekJhwt +pm6chDeFMkvJVa8GflKUxC5aVqhb84apCArvuaP/IXlDf0mEcyToyTjQaHitWtYo +BqueC3wMU5e5TvfQ3CKutWP3L9fQzU/mzpbEAuMMcQKBgQDUU47C0xwaIhfTyY2V +j9xDoEyJiRiaw0wUg2WtlNyIfUCOJSFxHeXqCmu1TurBxoNprlWZCf+myBR7hKXV +XbjRSluo7EFe6qF5ZxfVkTgaggSUmqd65kCDGyWQTZQ4tw+qal6T3TekJOwoAPa0 +ifKfPmzW/uleFwsXRJb5ydNA3QKBgQDMw13gt6s9xSAjvmZwdHdwb7712K4RrcoL +vrdOI6HEVDYsu2+zJxEtp0koE1Dk5LBUP4VAaDw1ABcx+Qon29mFy/orc8uH0PEu +SES6kZxr70eKJ67jvgs370m8zM+IJsC4RJ1wu09Q0vsdJ2TZLG5jlQD1no08Ta37 +Wv27zenGUwKBgH7ukPsBj9xDo3D2HlFaFnjLPNZAAliLBlGBF+kEhC6Iim4v3mUs +VYVrw2Y5jnhXf7pPAVcjNhVzqWMKMsVyaQmdZVyAGLhwliXorsP7M8oNDkX0iskb +G1gFg5hX+JNLRO9A9dd5uUjE1fU4VkQp78SpYhHJhKO+LOA1HfioYkV1AoGALHAt +3Iof2M0CN5+nvboY/cbSq6o1xNJxqfDe+U9UWTZpd3XKPRg6ay0F/HOMt9BF0FLk +yWCVyG7XmdnRcWsOHzJwfaOoxTX8Ua4PdGoLh4UrgnkwRG7HIoGFADt2wraeVp9V +h9Su1vyi0OXuxg8VefkpdyTMxAybuJQ7wtliZc8CgYEAouBfKjc3xn/jrf++kgie +taZ+ormKZs2mfTfcEMeQv7Bd7sEUWCoRevdorTlHaw1DKBqFq56Y1v3ppH83C6DH +5v1+43M6zq7qWGSgf5nbQ1ZBMUR0FMcBujc9JFX52Zc7ScvE1hwMT3lBJut/ln5W +h1oQd50MoCr4WE39Em4/H3o= -----END PRIVATE KEY----- Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:bd - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 24 (0x18) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Dec 20 00:00:00 2017 GMT @@ -39,72 +38,72 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:9c:bc:13:a5:0f:f7:9a:69:da:f9:34:1d:f7:32: - c1:b4:28:2e:54:96:47:9b:31:22:6e:ba:b7:1a:d6: - 45:07:ce:16:d9:aa:1c:42:59:31:1d:de:ea:83:6e: - d2:73:35:a6:98:2d:f7:16:a1:69:e9:d6:70:7b:3e: - 20:6d:bf:03:5a:9e:a0:2e:52:19:4e:c3:93:61:54: - 95:5d:8b:52:9e:14:69:ca:c4:ef:df:ba:95:36:d2: - d1:d1:87:dc:fc:a1:d6:ca:9c:a0:f5:4c:d8:3d:90: - a6:68:67:43:de:31:a3:0a:f0:56:1f:f6:c2:48:32: - 1a:41:a1:a9:24:43:3b:25:94:10:31:2c:ed:6d:82: - 8f:55:9a:10:60:09:a0:91:72:3e:80:ea:7a:e9:38: - ed:f1:d4:71:02:d5:0f:3a:dd:68:4c:a9:8c:32:cb: - bd:3b:4d:2c:aa:88:9d:88:a6:ed:bf:35:4c:61:0d: - e2:ff:a6:d0:fe:cc:ff:4d:57:dc:38:8a:8c:1c:df: - ce:fc:bd:02:28:af:18:d5:e3:41:61:c4:07:70:93: - 8a:21:1b:eb:8f:67:78:2a:fe:59:fc:c6:61:a0:4b: - f0:56:49:9e:64:5b:ea:a6:26:f0:d1:83:46:b7:90: - ee:53:47:58:b8:95:98:7c:a7:bb:a5:06:fa:e4:cc: - e0:25 + 00:a9:d4:9f:45:ba:f0:a6:7e:0a:0f:a5:49:f7:c3: + e8:95:44:1c:01:38:25:e5:67:2c:d1:71:f4:6c:88: + e7:c4:18:d9:d8:f2:01:03:36:8c:9c:70:a1:47:9e: + 3e:6b:b4:9f:e4:41:cf:48:81:c6:42:da:7a:1b:a9: + 44:9d:1c:11:21:52:32:99:6c:36:57:39:35:e5:06: + 6a:55:63:7a:b0:d1:e7:4c:83:04:bd:49:29:9a:33: + 96:b1:3d:71:2a:26:7e:ca:4a:1c:b3:10:2f:b7:aa: + ec:75:4f:e8:07:f0:30:60:c2:23:f6:aa:33:35:03: + a9:ea:7f:4f:d0:0c:39:ac:d7:9b:0a:85:92:66:f5: + 9f:cc:06:96:e9:3b:fe:33:3e:36:12:76:c0:03:bf: + db:1c:ee:ec:94:c5:19:cd:a7:73:d0:5a:ef:e1:66: + 38:20:f7:0d:2d:65:63:b3:05:a2:87:4c:72:4b:57: + ec:07:f1:fa:d1:ab:02:dd:1e:80:7e:81:22:14:7e: + 63:67:18:72:9e:e7:d8:9a:ad:68:c6:53:89:79:6f: + 89:0e:55:2f:1e:e5:d4:9f:76:f3:4b:6d:43:3c:cf: + c7:4c:bd:1a:ba:f1:f2:67:08:92:e4:aa:75:7b:71: + e8:58:9a:2f:9c:ea:21:af:0d:b9:15:cb:bb:d5:cd: + f5:a7 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - D1:43:15:54:E5:DE:B4:84:F3:72:A1:41:40:9C:C2:B6:16:C0:F2:5C + 41:E5:87:59:14:3F:3E:99:24:67:DF:F8:B7:59:F6:81:3D:9C:F7:14 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB X509v3 Extended Key Usage: TLS Web Server Authentication, TLS Web Client Authentication Signature Algorithm: sha256WithRSAEncryption - 47:8b:5b:f6:5e:a2:2d:fb:86:93:bf:ec:7c:53:5d:a0:8e:7d: - a2:93:1a:ae:fc:3e:e7:37:de:02:9e:fd:4e:ca:1e:06:3a:4c: - 76:2c:96:b6:a0:a8:f5:7a:0e:24:da:0d:38:d5:e9:75:f2:7d: - 5c:92:58:66:7a:65:b1:fb:15:2a:82:2c:a6:ae:19:d9:2f:15: - ac:c6:b8:04:25:a0:1d:4a:30:c1:96:b7:a2:4c:0b:58:7b:79: - ba:42:ca:41:ed:2d:70:8b:48:ae:e0:d4:4e:3d:37:29:68:fa: - af:fb:90:7b:91:eb:01:33:58:cd:c5:2c:c6:73:81:40:fe:f2: - 8b:e3:d3:13:2b:50:9c:af:a0:88:c7:18:81:cf:9d:af:45:55: - ff:fb:6c:1d:a4:db:c3:5c:d1:98:8b:91:d1:ac:05:e6:ae:a6: - ca:24:5f:85:58:3f:0a:eb:4d:b2:45:df:60:a9:0d:24:94:c5: - 8a:1a:07:11:ff:23:35:3f:bf:b8:d8:e6:36:2b:40:f8:3a:08: - 74:a7:95:77:e5:8b:18:11:25:b4:23:2a:e0:b0:73:ba:d9:1a: - 69:49:63:6e:08:5b:99:1d:a7:56:0a:9e:d1:7a:b9:45:be:35: - 2e:ea:7c:86:ef:0c:be:b7:dd:e4:88:31:f8:8c:8e:4f:18:81: - 40:26:1d:57 + 39:41:78:9d:38:e1:d2:7e:92:34:7a:da:32:6c:2d:51:d6:a4: + c1:d9:84:5f:24:2e:8f:ce:a8:60:29:ba:01:01:4b:a3:e0:fe: + 56:9c:5a:0b:8b:9f:b1:b6:55:89:0e:40:8f:09:0c:10:f1:dc: + 9a:3d:85:7c:ef:83:f9:0e:42:81:89:ac:a4:11:b9:e9:fd:db: + 58:54:63:51:66:5c:0e:0e:42:68:58:d9:0e:aa:54:70:6d:e7: + 51:e5:8b:fd:d0:da:dd:7b:b9:97:55:42:42:e7:39:b4:4b:4b: + c4:89:90:d1:6e:4b:0a:fd:cc:a8:a3:a7:70:ed:d6:e8:c4:09: + 80:d7:b0:09:ae:db:d2:4b:4f:0a:ec:73:28:bf:6f:cb:61:bd: + ab:5f:9a:2d:81:5e:e0:be:8c:32:d1:24:ea:a3:83:04:b8:81: + 97:e2:26:91:a2:fa:da:18:fa:54:58:46:d9:38:9b:66:b0:80: + 1d:a3:55:5b:86:7d:77:ca:0c:ba:e1:e6:c5:8c:e3:08:73:0f: + 73:b7:8b:42:75:6b:62:6e:bf:73:2d:4c:11:07:b4:b7:a0:72: + 0d:23:08:4b:65:8e:fd:1d:61:15:e6:d0:a5:ad:31:0b:d4:35: + 3a:f7:aa:e7:50:38:a2:dc:b0:24:52:9d:86:fc:ce:1a:d8:29: + 4b:de:82:af -----BEGIN CERTIFICATE----- -MIIDvDCCAqSgAwIBAgIQPiydvrBCyM/8mULVTUFqvTANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE3MTIyMDAwMDAwMFoXDTIwMTIyMDAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAJy8E6UP95pp2vk0HfcywbQoLlSWR5sxIm66 -txrWRQfOFtmqHEJZMR3e6oNu0nM1ppgt9xahaenWcHs+IG2/A1qeoC5SGU7Dk2FU -lV2LUp4UacrE79+6lTbS0dGH3Pyh1sqcoPVM2D2QpmhnQ94xowrwVh/2wkgyGkGh -qSRDOyWUEDEs7W2Cj1WaEGAJoJFyPoDqeuk47fHUcQLVDzrdaEypjDLLvTtNLKqI -nYim7b81TGEN4v+m0P7M/01X3DiKjBzfzvy9AiivGNXjQWHEB3CTiiEb649neCr+ -WfzGYaBL8FZJnmRb6qYm8NGDRreQ7lNHWLiVmHynu6UG+uTM4CUCAwEAAaNvMG0w -DAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQU0UMVVOXetITzcqFBQJzCthbA8lwwHwYD -VR0jBBgwFoAUmyYLipipux25HxzjGkAz7Y4XiKswHQYDVR0lBBYwFAYIKwYBBQUH -AwEGCCsGAQUFBwMCMA0GCSqGSIb3DQEBCwUAA4IBAQBHi1v2XqIt+4aTv+x8U12g -jn2ikxqu/D7nN94Cnv1Oyh4GOkx2LJa2oKj1eg4k2g041el18n1cklhmemWx+xUq -giymrhnZLxWsxrgEJaAdSjDBlreiTAtYe3m6QspB7S1wi0iu4NROPTcpaPqv+5B7 -kesBM1jNxSzGc4FA/vKL49MTK1Ccr6CIxxiBz52vRVX/+2wdpNvDXNGYi5HRrAXm -rqbKJF+FWD8K602yRd9gqQ0klMWKGgcR/yM1P7+42OY2K0D4Ogh0p5V35YsYESW0 -IyrgsHO62RppSWNuCFuZHadWCp7RerlFvjUu6nyG7wy+t93kiDH4jI5PGIFAJh1X +MIIDrTCCApWgAwIBAgIBGDANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE3MTIyMDAw +MDAwMFoXDTIwMTIyMDAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAKnUn0W68KZ+Cg+lSffD6JVEHAE4JeVnLNFx9GyI58QY2djyAQM2jJxw +oUeePmu0n+RBz0iBxkLaehupRJ0cESFSMplsNlc5NeUGalVjerDR50yDBL1JKZoz +lrE9cSomfspKHLMQL7eq7HVP6AfwMGDCI/aqMzUDqep/T9AMOazXmwqFkmb1n8wG +luk7/jM+NhJ2wAO/2xzu7JTFGc2nc9Ba7+FmOCD3DS1lY7MFoodMcktX7Afx+tGr +At0egH6BIhR+Y2cYcp7n2JqtaMZTiXlviQ5VLx7l1J9280ttQzzPx0y9Grrx8mcI +kuSqdXtx6FiaL5zqIa8NuRXLu9XN9acCAwEAAaNvMG0wDAYDVR0TAQH/BAIwADAd +BgNVHQ4EFgQUQeWHWRQ/PpkkZ9/4t1n2gT2c9xQwHwYDVR0jBBgwFoAUmyYLipip +ux25HxzjGkAz7Y4XiKswHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMA0G +CSqGSIb3DQEBCwUAA4IBAQA5QXidOOHSfpI0etoybC1R1qTB2YRfJC6PzqhgKboB +AUuj4P5WnFoLi5+xtlWJDkCPCQwQ8dyaPYV874P5DkKBiaykEbnp/dtYVGNRZlwO +DkJoWNkOqlRwbedR5Yv90Nrde7mXVUJC5zm0S0vEiZDRbksK/cyoo6dw7dboxAmA +17AJrtvSS08K7HMov2/LYb2rX5otgV7gvowy0STqo4MEuIGX4iaRovraGPpUWEbZ +OJtmsIAdo1Vbhn13ygy64ebFjOMIcw9zt4tCdWtibr9zLUwRB7S3oHINIwhLZY79 +HWEV5tClrTEL1DU696rnUDii3LAkUp2G/M4a2ClL3oKv -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/crlset_by_intermediate_serial.raw b/net/data/ssl/certificates/crlset_by_intermediate_serial.raw index 3179a08..370d488 100644 --- a/net/data/ssl/certificates/crlset_by_intermediate_serial.raw +++ b/net/data/ssl/certificates/crlset_by_intermediate_serial.raw Binary files differ
diff --git a/net/data/ssl/certificates/crlset_by_leaf_spki.raw b/net/data/ssl/certificates/crlset_by_leaf_spki.raw index f585687a..acc4c15 100644 --- a/net/data/ssl/certificates/crlset_by_leaf_spki.raw +++ b/net/data/ssl/certificates/crlset_by_leaf_spki.raw Binary files differ
diff --git a/net/data/ssl/certificates/crlset_by_leaf_subject_no_spki.raw b/net/data/ssl/certificates/crlset_by_leaf_subject_no_spki.raw index c25ff3bd..3a22aa7d 100644 --- a/net/data/ssl/certificates/crlset_by_leaf_subject_no_spki.raw +++ b/net/data/ssl/certificates/crlset_by_leaf_subject_no_spki.raw Binary files differ
diff --git a/net/data/ssl/certificates/crlset_by_root_serial.raw b/net/data/ssl/certificates/crlset_by_root_serial.raw index c231d2ae..31f6b462 100644 --- a/net/data/ssl/certificates/crlset_by_root_serial.raw +++ b/net/data/ssl/certificates/crlset_by_root_serial.raw Binary files differ
diff --git a/net/data/ssl/certificates/crlset_by_root_spki.raw b/net/data/ssl/certificates/crlset_by_root_spki.raw index fbdb334..ff6e2f45 100644 --- a/net/data/ssl/certificates/crlset_by_root_spki.raw +++ b/net/data/ssl/certificates/crlset_by_root_spki.raw Binary files differ
diff --git a/net/data/ssl/certificates/crlset_by_root_subject.raw b/net/data/ssl/certificates/crlset_by_root_subject.raw index f2734ad..95404126 100644 --- a/net/data/ssl/certificates/crlset_by_root_subject.raw +++ b/net/data/ssl/certificates/crlset_by_root_subject.raw Binary files differ
diff --git a/net/data/ssl/certificates/crlset_by_root_subject_no_spki.raw b/net/data/ssl/certificates/crlset_by_root_subject_no_spki.raw index 56d7bf88..bc10681c 100644 --- a/net/data/ssl/certificates/crlset_by_root_subject_no_spki.raw +++ b/net/data/ssl/certificates/crlset_by_root_subject_no_spki.raw Binary files differ
diff --git a/net/data/ssl/certificates/dec_2017.pem b/net/data/ssl/certificates/dec_2017.pem index 3e5eaaea..e0dff79 100644 --- a/net/data/ssl/certificates/dec_2017.pem +++ b/net/data/ssl/certificates/dec_2017.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:be - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 25 (0x19) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Dec 20 00:00:00 2017 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:d2:eb:f5:8f:40:9e:0a:5a:c9:42:20:d0:ec:6d: - 1b:6b:2f:e6:fc:67:0d:ef:ac:4f:23:94:70:28:2d: - ca:38:47:d9:c6:7e:6d:20:90:e6:89:8c:cb:60:02: - 5c:94:06:26:12:19:36:59:f3:ba:d6:3e:7e:39:da: - 4c:ea:69:ef:21:de:ce:6d:cc:c4:29:c6:b4:2e:c8: - 13:6b:f5:bd:b7:93:92:09:cd:de:11:b7:cf:fa:04: - 6d:b7:74:88:c3:60:ff:36:f2:df:5a:3a:ee:e7:96: - 7c:43:dd:9d:2d:dd:87:b1:d7:4e:8e:a8:31:72:47: - aa:46:0b:5b:bc:54:1e:ef:c4:fb:f7:d1:66:37:75: - 56:b3:e7:19:51:7c:c4:0d:6b:ab:f1:ae:89:e1:87: - 9c:26:e6:21:f5:6a:73:8e:23:4b:86:1b:80:c5:a3: - 27:52:1c:dd:35:68:d2:fc:35:2c:0c:f0:6f:67:fb: - b4:d5:84:e8:56:4e:3d:09:ad:b9:f2:fc:f7:84:d9: - 83:7f:c9:1b:f4:3d:f3:f4:f8:03:e6:fe:bd:17:09: - 57:cf:81:b1:ed:75:09:40:0e:36:7a:96:85:1d:a1: - ae:43:86:2b:c5:ee:30:66:ff:60:05:5e:f5:76:a7: - c7:eb:1e:65:8f:e6:88:b6:42:6b:78:86:a3:c6:7a: - be:73 + 00:d0:c1:27:76:2d:56:e6:b9:e3:23:b9:b6:c3:0e: + f4:8c:cb:73:85:0e:45:ed:b8:ea:e6:21:b6:60:56: + 1d:b7:24:72:b9:51:72:68:07:22:9f:8f:fd:47:c7: + da:9b:7b:5c:ad:e8:f5:6a:72:4d:8b:e4:55:fc:c6: + 41:d8:53:5e:0a:ba:35:4e:bc:98:21:d0:c2:ae:f7: + ff:ec:8f:26:eb:a1:71:74:11:b7:21:fd:38:04:5a: + e5:42:3d:02:28:05:3a:8d:2d:9b:5e:7b:39:35:e4: + fe:59:a8:98:39:c7:6c:d1:9e:1a:d7:c3:11:78:cb: + 44:72:e4:a0:89:83:e2:f8:de:c9:46:3a:c5:71:7f: + af:ee:e5:ba:1f:fa:97:19:f0:d0:5c:32:81:d3:7d: + 80:99:70:49:2a:ba:c8:40:b0:32:51:ec:16:3b:4d: + 61:05:e2:dc:b9:24:f0:a6:6b:ad:cd:53:1d:cd:9a: + ba:bb:df:96:f1:ac:e6:5e:03:cb:98:07:da:21:6e: + 8c:ac:56:37:39:15:d4:ab:b0:43:d1:64:7a:05:59: + f8:f8:bd:4e:31:c7:8c:d6:23:e8:3d:99:ea:75:78: + 25:8d:1a:83:32:39:ec:ec:69:ef:76:cc:b6:cf:06: + 0e:1d:ca:ac:8c:b7:10:a7:d2:ec:18:86:7c:6f:20: + 9c:bf Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - AF:5E:73:1B:EC:71:82:4F:A6:44:B2:11:27:57:AE:91:11:A0:50:1C + 4F:62:A1:56:D4:81:D5:18:65:C6:E0:DC:91:72:07:32:58:0C:79:EE X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - b1:92:16:b1:ec:a2:8a:d2:43:e6:5e:f5:a9:91:7b:1e:82:33: - 7f:bd:ef:5d:6c:d5:75:29:02:e9:7b:dc:cf:00:05:9e:cd:2c: - ff:d3:74:d0:1d:88:b6:c6:08:11:af:90:be:d6:96:e5:1a:35: - 18:1c:c7:ff:33:52:6e:07:65:2a:8d:8e:a4:66:d4:47:d5:74: - 79:9e:9f:59:10:53:23:11:40:be:9e:ae:67:c2:cb:bd:7d:f2: - e6:f9:00:45:23:22:2b:48:82:1d:53:19:b6:7c:c9:3b:67:8a: - 70:23:c6:43:c0:20:74:38:01:9f:35:95:c9:3c:09:b8:61:d8: - 78:d2:44:0c:ea:fe:47:ff:b8:77:f6:ca:c0:ef:4f:5f:27:22: - 34:8e:d0:a7:cd:7a:70:e4:4d:d1:d8:1a:b7:a3:90:06:17:46: - 90:4f:0e:92:28:5e:64:d4:54:84:69:6f:b8:4a:e9:06:82:f3: - 58:67:80:80:45:f7:26:a8:80:3c:35:e3:cb:b5:c1:9c:46:64: - a9:d5:b6:06:a3:30:81:d0:ea:45:75:da:36:1a:d6:c6:1c:38: - a2:d9:e3:37:71:84:e9:47:ed:5e:f4:1b:a3:cc:a2:ba:19:30: - f5:c7:18:31:b3:3e:86:3d:33:41:a9:2f:91:25:63:54:fe:3a: - aa:b3:24:61 + a5:16:f1:6f:8d:ab:b2:d7:c1:f6:98:98:d4:2d:8d:0f:85:09: + 65:73:f4:72:40:66:8b:28:f3:e4:d8:b8:8e:21:2b:9f:27:f2: + ab:0f:b6:e7:94:9a:1c:b1:58:9a:71:5e:79:d4:1b:9b:11:f3: + 52:ee:a2:00:85:75:d5:a0:6e:af:11:39:cd:72:f8:a8:57:09: + 09:4f:df:e7:42:26:63:08:a2:fb:19:ff:ab:97:e4:f1:01:7c: + df:e5:87:58:e7:90:e6:61:c0:f8:35:89:5f:4b:f2:f0:ae:cb: + 1a:69:3b:1f:0b:ac:38:18:28:5a:ca:92:75:fa:ee:56:69:dd: + dc:e8:c4:db:8f:84:20:d2:50:ee:34:32:e6:2f:90:aa:12:3d: + db:56:a3:38:0f:80:b7:f5:32:b6:12:b8:30:1c:14:84:83:4e: + 7b:42:49:16:ef:1e:b0:3a:f5:03:30:72:86:1f:0d:77:1a:7b: + 44:8b:60:e4:34:49:d8:b0:af:8d:a6:f1:08:70:b3:69:54:5f: + e0:2f:6d:42:2f:ff:68:07:fd:cf:c1:f7:fa:e7:5f:fe:1f:93: + ba:02:01:29:69:37:97:6a:16:03:7f:2d:0c:b2:2a:d8:43:13: + ed:cf:1b:2d:1f:b0:f3:b6:e1:98:cb:92:d3:26:5e:f4:a7:a3: + 90:de:6a:ab -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqvjANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE3MTIyMDAwMDAwMFoXDTIwMTIyMDAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBANLr9Y9AngpayUIg0OxtG2sv5vxnDe+sTyOU -cCgtyjhH2cZ+bSCQ5omMy2ACXJQGJhIZNlnzutY+fjnaTOpp7yHezm3MxCnGtC7I -E2v1vbeTkgnN3hG3z/oEbbd0iMNg/zby31o67ueWfEPdnS3dh7HXTo6oMXJHqkYL -W7xUHu/E+/fRZjd1VrPnGVF8xA1rq/GuieGHnCbmIfVqc44jS4YbgMWjJ1Ic3TVo -0vw1LAzwb2f7tNWE6FZOPQmtufL894TZg3/JG/Q98/T4A+b+vRcJV8+Bse11CUAO -NnqWhR2hrkOGK8XuMGb/YAVe9Xanx+seZY/miLZCa3iGo8Z6vnMCAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFK9ecxvscYJPpkSyESdXrpERoFAcMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQCxkhax7KKK0kPmXvWpkXsegjN/ve9dbNV1KQLpe9zPAAWezSz/03TQHYi2xggR -r5C+1pblGjUYHMf/M1JuB2UqjY6kZtRH1XR5np9ZEFMjEUC+nq5nwsu9ffLm+QBF -IyIrSIIdUxm2fMk7Z4pwI8ZDwCB0OAGfNZXJPAm4Ydh40kQM6v5H/7h39srA709f -JyI0jtCnzXpw5E3R2Bq3o5AGF0aQTw6SKF5k1FSEaW+4SukGgvNYZ4CARfcmqIA8 -NePLtcGcRmSp1bYGozCB0OpFddo2GtbGHDii2eM3cYTpR+1e9BujzKK6GTD1xxgx -sz6GPTNBqS+RJWNU/jqqsyRh +MIIDvzCCAqegAwIBAgIBGTANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE3MTIyMDAw +MDAwMFoXDTIwMTIyMDAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBANDBJ3YtVua54yO5tsMO9IzLc4UORe246uYhtmBWHbckcrlRcmgHIp+P +/UfH2pt7XK3o9WpyTYvkVfzGQdhTXgq6NU68mCHQwq73/+yPJuuhcXQRtyH9OARa +5UI9AigFOo0tm157OTXk/lmomDnHbNGeGtfDEXjLRHLkoImD4vjeyUY6xXF/r+7l +uh/6lxnw0FwygdN9gJlwSSq6yECwMlHsFjtNYQXi3Lkk8KZrrc1THc2aurvflvGs +5l4Dy5gH2iFujKxWNzkV1KuwQ9FkegVZ+Pi9TjHHjNYj6D2Z6nV4JY0agzI57Oxp +73bMts8GDh3KrIy3EKfS7BiGfG8gnL8CAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFE9ioVbUgdUYZcbg3JFyBzJYDHnuMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQClFvFvjauy18H2mJjU +LY0PhQllc/RyQGaLKPPk2LiOISufJ/KrD7bnlJocsViacV551BubEfNS7qIAhXXV +oG6vETnNcvioVwkJT9/nQiZjCKL7Gf+rl+TxAXzf5YdY55DmYcD4NYlfS/Lwrssa +aTsfC6w4GChaypJ1+u5Wad3c6MTbj4Qg0lDuNDLmL5CqEj3bVqM4D4C39TK2Ergw +HBSEg057QkkW7x6wOvUDMHKGHw13GntEi2DkNEnYsK+NpvEIcLNpVF/gL21CL/9o +B/3Pwff651/+H5O6AgEpaTeXahYDfy0MsirYQxPtzxstH7DztuGYy5LTJl70p6OQ +3mqr -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/expired_cert.pem b/net/data/ssl/certificates/expired_cert.pem index b853430d..c68dbc7c 100644 --- a/net/data/ssl/certificates/expired_cert.pem +++ b/net/data/ssl/certificates/expired_cert.pem
@@ -1,37 +1,36 @@ -----BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC3I3bZDnNngrCP -srB5V+Pbtr1g3LZ7kvqzsSGRSztLiIuoJaBQrV/5EJIkf0az7bJGlBXkbPd4inTZ -t5+MvaWe8qkMLtmVr9QntK5UzVnWEPcgPhp6/sfbTvMAwR5iitqNMkA4j6FVF4jr -CSmQDmdHuzTWEx9qLoaJh+Dpc2RPywAVx8voW+QJGJv8pCJuIJWkuV9+dSXezAf3 -2ba5hLn/+ztJqgYbDRSASovnaO59elnC9CYJ11Hh92ryoMNciJpSmpu0dfCk99OT -L1lbdDUKfX9GkVtlwfTUMXpiChvLW49zVlveaTHmKSiiFscbOR5bJ1sNhO2I01op -8cxl7qHJAgMBAAECggEAIJmNhGHQJTLcXxf91fvRMcE7wMxJJ4IoYmg7g3OS4IUz -5wCbowDZvqo2eYy2dzzuqSWfKARFoQ10c3T+T71KiBrGAMcuMDkWWOMOzUWoojRu -6Sxk5lQIG3/YPeAimoQBF3VEfU0D+POxibUd0ujddaVbaGgLBYm2pTCs1qGVz6YT -1JGXqjSeg8r+/gUENo9a00V/XXXUwvmnq9GSQklQz8JkFcPt/WV32CdyoATxUXvX -TDHnWDf0fUtATjYgRJLrBDbLZbrpPca0VUfPTBV2iiaj9Ibk6qH1X9/CczrOm8Mg -IwA+boWkAZhyjlPnY3jf5GR5YevvrrtIogwka6EdAQKBgQDpm8wFvnhFX9YN22Ih -64fosbylvOjtDha7Z7y8elY4B72xZBzkvymlYa+cifNU9Gf0Wc8i9+l+EeQgNl9V -wPyQZfOLCZwHBPS7wfQIYqIuN+LSUjwUvtcl8+Dtlwl98WSrK8FcWYxWJvJB9bCX -9WlqwGsl05gB77gG+kQNpJEh8QKBgQDIsUBdwgsadfcjU9xaDSk2hmaR7axMopKR -vglyEJTrMKd8/XhVKW3JUXF8yN0D0sdUg1HJv9RbT+1s2SsfVux4XcG2upmuzLxB -SsFLW0n1oIB41V+O28iIABvVRkz8VIzQ7BEVI5rWwqvymBGeJ5rfxaZbRMfjKClA -X3S5XLIlWQKBgC2i/QmGOzK6VTPhztr3i1Z/Gm56aDqfTPuReYKMl7lcccds2mQp -oDYpzkfTf1DyajiHLvsS2W+CiUFtvdQf3ndLI3ffCbcpVbI0YrscobhLvKj/3bLj -0V4dtaxUnEsZVGRIKP8kk1DlTOBr4fLdw5lSO9xo6MJAFYBvdcoAg0XRAoGAHBJn -DXZJ9U6Q3hkp1lLG9ACCsmDLXADVfZtWWOUm32rz0pDl1wuvdpx0wl6aQ6GlDhY8 -R3sUqh0Y+cO6u2x+MSv0H6okOwYaQwvA09iWFMx5i+1Uq3fkqdlSC1gFBrqQ49xR -W2KakvWx9YH93OBvUmOkLFoHl6eTdZSkkBT+OikCgYBxbC+jy0EwBtkFCo+22H7S -891Zq5vyztVn78PeK7/bC7MT26gZC5Pz3hsue+YDUizoutDXmzhzBZzmLKgS3yDd -ZkfyPXsvzh32VF/GCaBMf0Bv8NNDEIlvwvres6xUgEnxE5xRpTDuD6SJG5eqERwM -S1bbeuh3nNfChmUQE3+0Hg== +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDOyfwsFGz4KjJt +FmfGaisMwi3KJcI5RWUWvll6c94BNuVv643WZGaq/Yfx8bPCvKr9T5Q/1QnkXwRW +v8eRnocK5obwTQz8l1Md8PXsl81sT982C5Lk+HDBbXNrOlS56Q1W7ggNnC7Yxe09 +KHoFI/BibDgHM/qeneNFmzfUEPVm1XbUgsQmodoV3e6Ncv4UlwjJ1n+3Zy+y09OQ +MGEjsnpSWnzQkwnYJTpPi8QslnkX4AoUf4Qt+cI5QU90A9ODDTTqRdifLFOH8XD5 +OXPcqGwwdAx22SpUkpp4WHyLbbjthWOBarE4pvVlM6IG8bnOaW23EXgGiJOx0j+F +PZv8UQ25AgMBAAECggEAWZd1Y/utgo91rYGpkHNrF2oBwLU/QuTn+USbK8yLgOcx +3J2npB13xdl2TsKzaUmoo3sY9dbtJD5ueM86PcL7KyPZjr8zQzSk1DITul/Cpoys +XpQBHqbs40DyYqCxGKL6HpGed5cVTOHj+T1SMGvzuBC+7Y/9oz8wunWXaI+4YsaN +KTcahUeyw3B3nGu59iy8FtIgZE+XpXw6HmIM6fFq2qL9F1yCyOev5qpMQD+WbBVp +p6GDmt02mgatrIx4hDd//OfGAeLdnlpOHbs2Dzs2BL2j+V0UbatpzCX+9U3zb526 +EYm1n6AOkHIrFRGSiGs/6XcB+rKG1wFqNL2WGFfkCQKBgQD8o7krKl6bzTR0gssg +BDggFSab5f12o+lm5BB5f8ZcTASSV9+LvlFuTOqg00JWrj3W4ykapGiqy5DUb/TC +9SUnHMWN+gWAP1byoqrvlsPGRvaOkZZZ8BMFlgaTVdmSYm2jEL41DhiOco7uxeID +hbGl969Az1DYqk6l0B8eXhvmhwKBgQDRiiIw611fCaWuN9mPZC1WMzKOhddSVqFK +VX9avQ5RF0BDDze4QmCC3pBOVQ54iUyawk3anMysirD4WFbJSSZ/LyV+ChGbLNW+ +C3WnCOEoGnfXYRO8Anpba4uRODQD8aFSDhOwiX9cnGhn0LK+JWUsO73ubFp232id +GJp4lnQ5vwKBgQCPMNitr4kJ82fMtakdT2bkQDiu2c8sJEEQ0SjJRHOQMoHQ1D9e +vBL5Wl0NpE+QQ5fHKN9OO2sbit9emMn4ietx3KvYCaJ+iufkA/CwdRonUmdCbR/z +f8+4Nc0qStlTT7hmWQIFniSq8CE1EjFE38zNjbHmINrowrZq4qgQlTRpFwKBgH0o +Pd3sZ7wBfiW+lEOSuYW4VOVOSluTBQnqYYRoUinbcnXbnBOCCjWBDL7NDTSwBcKW +dnwylgolWSktUsEt4UGsfn93Mib2s8CtBZw8sIgMrzJFeM0eycjbRuT5phAI/quN +XvNeXWWKws3nmSv8GB9Am+TScYJ5VPoonPOUIl3vAoGBAIopah8JtNrmpWchIO5+ +z7JeELzUWelGbKOoclWOVnaC80RWYaUe9Zf+6FDifSpbEo6Muf2dGm8+uC+DmQX0 +sXscgfZafFYDLIFHjvFrL3kQH06jKhcbD6s48YHlBCHVZx5SJLGbbiVOnYtPubIS +uCQfr9VlJkIUbJCn5ekytz9K -----END PRIVATE KEY----- Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:a3 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 2 (0x2) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Jan 1 00:00:00 2006 GMT @@ -39,32 +38,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:b7:23:76:d9:0e:73:67:82:b0:8f:b2:b0:79:57: - e3:db:b6:bd:60:dc:b6:7b:92:fa:b3:b1:21:91:4b: - 3b:4b:88:8b:a8:25:a0:50:ad:5f:f9:10:92:24:7f: - 46:b3:ed:b2:46:94:15:e4:6c:f7:78:8a:74:d9:b7: - 9f:8c:bd:a5:9e:f2:a9:0c:2e:d9:95:af:d4:27:b4: - ae:54:cd:59:d6:10:f7:20:3e:1a:7a:fe:c7:db:4e: - f3:00:c1:1e:62:8a:da:8d:32:40:38:8f:a1:55:17: - 88:eb:09:29:90:0e:67:47:bb:34:d6:13:1f:6a:2e: - 86:89:87:e0:e9:73:64:4f:cb:00:15:c7:cb:e8:5b: - e4:09:18:9b:fc:a4:22:6e:20:95:a4:b9:5f:7e:75: - 25:de:cc:07:f7:d9:b6:b9:84:b9:ff:fb:3b:49:aa: - 06:1b:0d:14:80:4a:8b:e7:68:ee:7d:7a:59:c2:f4: - 26:09:d7:51:e1:f7:6a:f2:a0:c3:5c:88:9a:52:9a: - 9b:b4:75:f0:a4:f7:d3:93:2f:59:5b:74:35:0a:7d: - 7f:46:91:5b:65:c1:f4:d4:31:7a:62:0a:1b:cb:5b: - 8f:73:56:5b:de:69:31:e6:29:28:a2:16:c7:1b:39: - 1e:5b:27:5b:0d:84:ed:88:d3:5a:29:f1:cc:65:ee: - a1:c9 + 00:ce:c9:fc:2c:14:6c:f8:2a:32:6d:16:67:c6:6a: + 2b:0c:c2:2d:ca:25:c2:39:45:65:16:be:59:7a:73: + de:01:36:e5:6f:eb:8d:d6:64:66:aa:fd:87:f1:f1: + b3:c2:bc:aa:fd:4f:94:3f:d5:09:e4:5f:04:56:bf: + c7:91:9e:87:0a:e6:86:f0:4d:0c:fc:97:53:1d:f0: + f5:ec:97:cd:6c:4f:df:36:0b:92:e4:f8:70:c1:6d: + 73:6b:3a:54:b9:e9:0d:56:ee:08:0d:9c:2e:d8:c5: + ed:3d:28:7a:05:23:f0:62:6c:38:07:33:fa:9e:9d: + e3:45:9b:37:d4:10:f5:66:d5:76:d4:82:c4:26:a1: + da:15:dd:ee:8d:72:fe:14:97:08:c9:d6:7f:b7:67: + 2f:b2:d3:d3:90:30:61:23:b2:7a:52:5a:7c:d0:93: + 09:d8:25:3a:4f:8b:c4:2c:96:79:17:e0:0a:14:7f: + 84:2d:f9:c2:39:41:4f:74:03:d3:83:0d:34:ea:45: + d8:9f:2c:53:87:f1:70:f9:39:73:dc:a8:6c:30:74: + 0c:76:d9:2a:54:92:9a:78:58:7c:8b:6d:b8:ed:85: + 63:81:6a:b1:38:a6:f5:65:33:a2:06:f1:b9:ce:69: + 6d:b7:11:78:06:88:93:b1:d2:3f:85:3d:9b:fc:51: + 0d:b9 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 13:95:38:F8:17:3A:90:4F:19:29:53:12:1E:4D:7B:BB:AE:D9:27:A5 + AC:97:8A:09:35:95:6A:EB:AD:D3:05:F5:A8:58:AB:E6:58:95:3A:BD X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -73,41 +72,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 63:a5:49:11:ed:15:84:22:60:6d:f5:16:be:c8:1e:de:d7:99: - 55:4a:23:c3:c0:ba:be:ba:6e:95:03:5c:25:97:f8:29:ff:c0: - 95:a8:38:5e:b8:c1:b6:f9:4c:fe:e1:ef:78:5c:f3:d0:67:d4: - e4:47:57:44:9d:ce:a4:be:3f:42:ec:03:d7:3b:57:80:0b:92: - 02:b4:fd:50:06:ab:82:05:d3:62:5a:99:62:f0:ba:02:25:c7: - 88:61:20:12:ab:27:5c:ee:f8:7e:90:4a:ab:1e:6e:32:8c:49: - d8:47:e2:7e:0b:74:fe:c4:c7:2c:11:a1:c1:3c:48:89:95:aa: - 1e:55:50:69:1c:03:ea:90:50:ad:89:3e:13:7e:aa:d4:80:0a: - 3d:0c:cc:82:52:1b:c6:fd:2f:b3:25:e8:23:c2:03:01:e8:5b: - 12:5b:a3:e5:f1:1e:f9:70:49:5d:56:63:7f:8d:00:25:0a:92: - ca:73:25:db:29:52:e3:17:10:ec:95:b9:f7:03:77:ae:20:fa: - 47:e1:31:3f:af:23:eb:9d:6d:f8:14:fe:6a:be:cc:6f:25:84: - bb:92:07:8f:86:3c:ce:bf:61:d1:d0:3d:89:4a:d1:82:24:03: - 54:b8:f8:18:aa:64:7d:ef:08:fa:cb:30:8c:f4:72:60:20:c7: - fc:ae:26:38 + 97:9c:42:d2:b4:6f:c2:fd:d1:85:72:6f:92:9e:de:07:71:e8: + cc:6d:97:93:82:2c:0d:62:c0:4a:cd:bc:7a:55:82:08:5a:1f: + f9:aa:4a:16:35:de:19:86:25:12:93:0f:65:56:d7:bc:d3:6b: + f7:39:de:9e:fa:43:b1:39:b5:5b:d3:32:33:d9:6f:86:0c:f6: + 12:cc:0b:a7:27:54:36:55:ce:26:6c:e3:64:a2:b2:c6:a6:3e: + 94:16:ec:4e:c0:f3:cc:6f:54:ff:26:bf:ac:ae:0f:c3:69:a3: + 80:35:44:e3:28:9e:1b:7e:98:2c:a3:cc:ef:25:0e:25:3f:36: + c1:92:38:25:21:bf:d4:e5:0a:51:16:85:d6:36:ef:88:1a:56: + 2b:71:7c:88:50:c8:99:08:e2:a4:f0:50:12:c7:5f:6b:e8:01: + e8:26:06:a3:24:d0:3c:67:9e:88:96:fa:b2:26:47:08:93:94: + 74:f9:97:0f:c2:28:85:97:e1:dc:f3:1b:66:f1:71:d7:65:4e: + 34:d1:fa:56:84:be:a3:a9:8e:11:a1:03:fe:14:b8:a6:7f:ee: + 53:ce:e9:72:57:d8:3d:2d:54:0c:5a:80:1d:6a:4a:16:ab:fe: + 2b:07:05:cf:c5:a9:10:38:83:32:b5:bb:7c:81:39:a4:16:1a: + 0e:c5:1d:92 -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqozANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTA2MDEwMTAwMDAwMFoXDTA3MDEwMTAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBALcjdtkOc2eCsI+ysHlX49u2vWDctnuS+rOx -IZFLO0uIi6gloFCtX/kQkiR/RrPtskaUFeRs93iKdNm3n4y9pZ7yqQwu2ZWv1Ce0 -rlTNWdYQ9yA+Gnr+x9tO8wDBHmKK2o0yQDiPoVUXiOsJKZAOZ0e7NNYTH2ouhomH -4OlzZE/LABXHy+hb5AkYm/ykIm4glaS5X351Jd7MB/fZtrmEuf/7O0mqBhsNFIBK -i+do7n16WcL0JgnXUeH3avKgw1yImlKam7R18KT305MvWVt0NQp9f0aRW2XB9NQx -emIKG8tbj3NWW95pMeYpKKIWxxs5HlsnWw2E7YjTWinxzGXuockCAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFBOVOPgXOpBPGSlTEh5Ne7uu2SelMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQBjpUkR7RWEImBt9Ra+yB7e15lVSiPDwLq+um6VA1wll/gp/8CVqDheuMG2+Uz+ -4e94XPPQZ9TkR1dEnc6kvj9C7APXO1eAC5ICtP1QBquCBdNiWpli8LoCJceIYSAS -qydc7vh+kEqrHm4yjEnYR+J+C3T+xMcsEaHBPEiJlaoeVVBpHAPqkFCtiT4TfqrU -gAo9DMyCUhvG/S+zJegjwgMB6FsSW6Pl8R75cEldVmN/jQAlCpLKcyXbKVLjFxDs -lbn3A3euIPpH4TE/ryPrnW34FP5qvsxvJYS7kgePhjzOv2HR0D2JStGCJANUuPgY -qmR97wj6yzCM9HJgIMf8riY4 +MIIDvzCCAqegAwIBAgIBAjANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTA2MDEwMTAw +MDAwMFoXDTA3MDEwMTAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAM7J/CwUbPgqMm0WZ8ZqKwzCLcolwjlFZRa+WXpz3gE25W/rjdZkZqr9 +h/Hxs8K8qv1PlD/VCeRfBFa/x5GehwrmhvBNDPyXUx3w9eyXzWxP3zYLkuT4cMFt +c2s6VLnpDVbuCA2cLtjF7T0oegUj8GJsOAcz+p6d40WbN9QQ9WbVdtSCxCah2hXd +7o1y/hSXCMnWf7dnL7LT05AwYSOyelJafNCTCdglOk+LxCyWeRfgChR/hC35wjlB +T3QD04MNNOpF2J8sU4fxcPk5c9yobDB0DHbZKlSSmnhYfIttuO2FY4FqsTim9WUz +ogbxuc5pbbcReAaIk7HSP4U9m/xRDbkCAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFKyXigk1lWrrrdMF9ahYq+ZYlTq9MB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQCXnELStG/C/dGFcm+S +nt4HcejMbZeTgiwNYsBKzbx6VYIIWh/5qkoWNd4ZhiUSkw9lVte802v3Od6e+kOx +ObVb0zIz2W+GDPYSzAunJ1Q2Vc4mbONkorLGpj6UFuxOwPPMb1T/Jr+srg/DaaOA +NUTjKJ4bfpgso8zvJQ4lPzbBkjglIb/U5QpRFoXWNu+IGlYrcXyIUMiZCOKk8FAS +x19r6AHoJgajJNA8Z56IlvqyJkcIk5R0+ZcPwiiFl+Hc8xtm8XHXZU400fpWhL6j +qY4RoQP+FLimf+5TzulyV9g9LVQMWoAdakoWq/4rBwXPxakQOIMytbt8gTmkFhoO +xR2S -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/intermediate_ca_cert.pem b/net/data/ssl/certificates/intermediate_ca_cert.pem index 1f081e5..db82c408 100644 --- a/net/data/ssl/certificates/intermediate_ca_cert.pem +++ b/net/data/ssl/certificates/intermediate_ca_cert.pem
@@ -1,44 +1,44 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEAnem95D1KL/vC+eYiKkIVRhyMj0dM6cVXlR9mcJMi8JTDu7Vb -76RvyMeJlXW6DDa/TmupNUcIQ54pauLD+wO3H7bhUWvtexnH+c473GXpZseDlMTR -Tu7tZEuB8RrqWmQYG2pOk9ATbJBgytJOtyQW+LIIWJ2NpzNFFTSBrS0tnGDv+SuY -/nnTjSxI2xKR9C76v/UmwYIFgN1MqHC/p7wQNHc520cED+1EsmVGIiCIWSgPxwyi -tJGloqrKBZ+Km26jy9Sk6CR1nSCBIltfdz7J8R6u64ozjCdbHr5tIRtCcpXjnhMD -dadY1L5oEv5jjksRejTno2vdc64+GZrskYtzrwIDAQABAoIBAQCcLtoMiv38NWKj -bZUu/Isz+/qdn2SX9gHo0NSt1SkCj/CDkB1tCNMy3v/aHkUz3VYbRuplcmrfDehi -+gPiGcueB3AU6s1IKriZ/vs/wmA1snEWzA9EpZWP1AqiH//YBRW+z8cF9Q+xGZ9S -Gu2Vv5Ekyljs5G99Bn12OqdjU8K/3abGnEOb+vqPM90Q9jeOID76xgNndT/N2E9K -CGMCgB7abunOOggUJn+eJYY7NS3cRFIBfMPmPE/A2UOVnpHISFgXBmS4qgZJuPfr -gaBrZX63LM2ZAt6Z1/vh6GQGBPZrODgnVoRAR1MoXf6LOxo2l/ghlDOJzcdC5qKn -iQYQbdKpAoGBAM3LFqlWK7opqZxEvpcxSIhWVyOq2He4ZCfrHphbLeFBUDOdUxNI -F5K82XSLv64JkZW9ObaO9/VdYts9AU8RpGvlsy+o+GbSY8tlgZd+RnHqHi+SMG47 -PDoiRa/EwJKvb9009osprlAxkhwgs9U/Rn0uP86CzRoqijsaezumcGgtAoGBAMRw -RUbUNXnimC+RWcFr9iZJYr7rQ1lEStHc287LymlH+NGXWXvgOnBaJnJJu8bmx8DH -JGPvGNNdaYBefNSVliGkbPLvIyblgGo435hUgtC+brpOqmB2vXlkLvC71Bpil/Uj -LOzLdoewUvpfmQ24K+i54KCtQlhhCgy6NP36ezjLAoGAIvvkVVMdyd7tQ3B4SfGJ -2At9csXHWMrS0+pnYBUX/pQA01VqWvvFbh+GhAaBxk9AHYl2dy9kvaRresOrJkrk -faclx/NcjvYzGs+dsSg5R4I6MXITo5mUSnmrCQ9UgVsrlBo90zh5to5GvVtd1uGT -1RH4rN2Vil4y84sz6dcIgt0CgYBDFxEiCrIk6bYOcPcVr3jHRMMb75/16fQfzu2n -qER+Rp19f9KJE2ECJFgDKpmeag2JErqkAvIYpku1ExBRTrGS1eR76B66VyHPpZMA -JMT05EVPDjT0czltL0E06QGc7VV23MeoLClUWG1Oo73TSLZ+apWEawhAxQu4oxQc -NiNFlwKBgEVWA5ZiK0r58KmdO2Mz2kHi7ngQX5x6jfu1wBk3LZ9DDoRPejoFEcNJ -VlZ8qBrU5lAB7XYaORHgw1MUJv59ccIRjO9sqpRZbJaZ6HUFKgGM9RKnvkYD/VfC -l3VFc+udo6mcIbqiwY7QHPXvZJ8EfDE5sLLJMUqfQ1k7vrQoza8D ------END RSA PRIVATE KEY----- +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCd6b3kPUov+8L5 +5iIqQhVGHIyPR0zpxVeVH2ZwkyLwlMO7tVvvpG/Ix4mVdboMNr9Oa6k1RwhDnilq +4sP7A7cftuFRa+17Gcf5zjvcZelmx4OUxNFO7u1kS4HxGupaZBgbak6T0BNskGDK +0k63JBb4sghYnY2nM0UVNIGtLS2cYO/5K5j+edONLEjbEpH0Lvq/9SbBggWA3Uyo +cL+nvBA0dznbRwQP7USyZUYiIIhZKA/HDKK0kaWiqsoFn4qbbqPL1KToJHWdIIEi +W193PsnxHq7rijOMJ1sevm0hG0JyleOeEwN1p1jUvmgS/mOOSxF6NOeja91zrj4Z +muyRi3OvAgMBAAECggEBAJwu2gyK/fw1YqNtlS78izP7+p2fZJf2AejQ1K3VKQKP +8IOQHW0I0zLe/9oeRTPdVhtG6mVyat8N6GL6A+IZy54HcBTqzUgquJn++z/CYDWy +cRbMD0SllY/UCqIf/9gFFb7PxwX1D7EZn1Ia7ZW/kSTKWOzkb30GfXY6p2NTwr/d +psacQ5v6+o8z3RD2N44gPvrGA2d1P83YT0oIYwKAHtpu6c46CBQmf54lhjs1LdxE +UgF8w+Y8T8DZQ5WekchIWBcGZLiqBkm49+uBoGtlfrcszZkC3pnX++HoZAYE9ms4 +OCdWhEBHUyhd/os7GjaX+CGUM4nNx0LmoqeJBhBt0qkCgYEAzcsWqVYruimpnES+ +lzFIiFZXI6rYd7hkJ+semFst4UFQM51TE0gXkrzZdIu/rgmRlb05to739V1i2z0B +TxGka+WzL6j4ZtJjy2WBl35GceoeL5Iwbjs8OiJFr8TAkq9v3TT2iymuUDGSHCCz +1T9GfS4/zoLNGiqKOxp7O6ZwaC0CgYEAxHBFRtQ1eeKYL5FZwWv2JklivutDWURK +0dzbzsvKaUf40ZdZe+A6cFomckm7xubHwMckY+8Y011pgF581JWWIaRs8u8jJuWA +ajjfmFSC0L5uuk6qYHa9eWQu8LvUGmKX9SMs7Mt2h7BS+l+ZDbgr6LngoK1CWGEK +DLo0/fp7OMsCgYAi++RVUx3J3u1DcHhJ8YnYC31yxcdYytLT6mdgFRf+lADTVWpa ++8VuH4aEBoHGT0AdiXZ3L2S9pGt6w6smSuR9pyXH81yO9jMaz52xKDlHgjoxchOj +mZRKeasJD1SBWyuUGj3TOHm2jka9W13W4ZPVEfis3ZWKXjLzizPp1wiC3QKBgEMX +ESIKsiTptg5w9xWveMdEwxvvn/Xp9B/O7aeoRH5GnX1/0okTYQIkWAMqmZ5qDYkS +uqQC8himS7UTEFFOsZLV5HvoHrpXIc+lkwAkxPTkRU8ONPRzOW0vQTTpAZztVXbc +x6gsKVRYbU6jvdNItn5qlYRrCEDFC7ijFBw2I0WXAoGARVYDlmIrSvnwqZ07YzPa +QeLueBBfnHqN+7XAGTctn0MOhE96OgURw0lWVnyoGtTmUAHtdho5EeDDUxQm/n1x +whGM72yqlFlslpnodQUqAYz1Eqe+RgP9V8KXdUVz652jqZwhuqLBjtAc9e9knwR8 +MTmwsskxSp9DWTu+tCjNrwM= +-----END PRIVATE KEY----- Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:a2 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 1 (0x1) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity - Not Before: Mar 13 20:46:16 2020 GMT - Not After : Mar 11 20:46:16 2030 GMT + Not Before: Jun 5 17:10:45 2017 GMT + Not After : Jun 3 17:10:45 2027 GMT Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Intermediate CA Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: 00:9d:e9:bd:e4:3d:4a:2f:fb:c2:f9:e6:22:2a:42: 15:46:1c:8c:8f:47:4c:e9:c5:57:95:1f:66:70:93: @@ -67,40 +67,39 @@ X509v3 Key Usage: critical Certificate Sign, CRL Sign Signature Algorithm: sha256WithRSAEncryption - 00:25:9c:ba:83:ee:0f:a2:57:cc:9a:d4:50:15:d5:e0:e7:4a: - 8a:57:d1:3e:b1:de:a5:be:26:f0:22:98:35:c0:ee:f1:84:4f: - aa:8d:92:e5:5c:29:23:ad:68:fb:9a:68:d0:2c:6e:04:5e:25: - fb:a0:65:04:fc:82:0b:ec:5b:53:a9:f4:61:1e:15:0f:5e:93: - 94:ec:d3:31:82:06:a1:16:09:01:b9:cb:90:a9:f9:ac:e3:d3: - 15:4c:2c:75:1c:97:24:d3:33:33:e1:b3:53:28:4e:e3:8e:6f: - 59:06:83:20:06:bd:9b:e9:44:8a:bd:80:59:6d:c2:cd:ce:c5: - 9c:81:31:3c:72:f5:6c:bf:31:69:a9:7c:32:28:cb:0e:d3:fd: - 23:5b:30:e0:c1:e9:c8:f8:6e:21:d1:86:c6:ca:62:a6:d6:19: - e4:0b:25:88:95:74:ce:b3:c6:4c:3c:32:63:d6:6a:8b:a3:49: - 53:15:85:9d:1a:06:16:e5:62:35:f5:d2:8c:99:91:15:35:9e: - 9d:36:98:75:4d:f9:39:de:2e:74:8f:36:2b:3a:b4:51:74:26: - 7c:22:6b:c3:52:3e:03:9f:cc:31:e9:24:68:6b:49:63:b5:24: - 6f:08:79:ed:4a:c1:6b:b5:da:72:1f:d5:a4:7e:6c:9b:4d:d2: - 4d:5d:c1:2b + 3e:f5:d7:fd:82:3b:1e:34:8c:66:a2:f3:5e:18:e1:f1:a9:75: + 9f:b5:93:e7:0a:8e:cf:0a:33:ed:49:cd:ce:ce:ca:5f:a3:1d: + 64:76:d3:84:16:fe:9d:88:ac:f4:d1:f8:36:2b:20:80:52:0a: + ef:e0:0f:64:27:55:35:a3:7b:c6:8a:7c:a5:c4:29:17:b1:fa: + d2:89:5d:13:6b:b8:03:cb:d7:12:d6:ce:24:f0:af:48:17:03: + 54:99:af:e9:cb:fd:44:44:18:23:61:90:f6:bd:55:65:06:c3: + 36:98:8d:ea:7d:0f:79:ef:b6:bb:22:28:03:a6:ec:d9:d4:1b: + 47:ac:2c:25:de:ef:1a:02:69:4c:18:bb:29:48:f4:9d:e1:52: + 42:64:6c:88:46:68:86:83:fd:24:f5:7d:05:d7:1a:7e:22:bc: + 49:75:9c:8a:4d:e8:f3:a2:eb:9b:83:70:a7:d6:dd:2f:05:2d: + aa:be:d7:ee:7b:8e:75:44:3b:da:df:85:61:bf:e9:3b:13:40: + 4e:8b:52:08:d9:e4:8c:54:da:41:db:7b:2c:05:5e:99:06:0d: + 02:8c:8e:19:8e:55:b0:3a:33:18:30:03:a7:ed:4a:e4:f8:58: + cc:12:b8:af:d6:66:55:29:ec:01:1f:92:ed:3d:4d:c3:71:3b: + e0:2f:70:90 -----BEGIN CERTIFICATE----- -MIIDmjCCAoKgAwIBAgIQPiydvrBCyM/8mULVTUFqojANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTIwMDMxMzIwNDYxNloXDTMwMDMxMTIwNDYxNlowazELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExHTAbBgNVBAMMFFRlc3QgSW50ZXJtZWRpYXRlIENB -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnem95D1KL/vC+eYiKkIV -RhyMj0dM6cVXlR9mcJMi8JTDu7Vb76RvyMeJlXW6DDa/TmupNUcIQ54pauLD+wO3 -H7bhUWvtexnH+c473GXpZseDlMTRTu7tZEuB8RrqWmQYG2pOk9ATbJBgytJOtyQW -+LIIWJ2NpzNFFTSBrS0tnGDv+SuY/nnTjSxI2xKR9C76v/UmwYIFgN1MqHC/p7wQ -NHc520cED+1EsmVGIiCIWSgPxwyitJGloqrKBZ+Km26jy9Sk6CR1nSCBIltfdz7J -8R6u64ozjCdbHr5tIRtCcpXjnhMDdadY1L5oEv5jjksRejTno2vdc64+GZrskYtz -rwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQXXEXz0KwcEEyL -Q0QgxN2TxcUZOzAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggEBAAAl -nLqD7g+iV8ya1FAV1eDnSopX0T6x3qW+JvAimDXA7vGET6qNkuVcKSOtaPuaaNAs -bgReJfugZQT8ggvsW1Op9GEeFQ9ek5Ts0zGCBqEWCQG5y5Cp+azj0xVMLHUclyTT -MzPhs1MoTuOOb1kGgyAGvZvpRIq9gFltws3OxZyBMTxy9Wy/MWmpfDIoyw7T/SNb -MODB6cj4biHRhsbKYqbWGeQLJYiVdM6zxkw8MmPWaoujSVMVhZ0aBhblYjX10oyZ -kRU1np02mHVN+TneLnSPNis6tFF0Jnwia8NSPgOfzDHpJGhrSWO1JG8Iee1KwWu1 -2nIf1aR+bJtN0k1dwSs= +MIIDizCCAnOgAwIBAgIBATANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE3MDYwNTE3 +MTA0NVoXDTI3MDYwMzE3MTA0NVowazELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExHTAbBgNVBAMMFFRlc3QgSW50ZXJtZWRpYXRlIENBMIIBIjANBgkqhkiG9w0B +AQEFAAOCAQ8AMIIBCgKCAQEAnem95D1KL/vC+eYiKkIVRhyMj0dM6cVXlR9mcJMi +8JTDu7Vb76RvyMeJlXW6DDa/TmupNUcIQ54pauLD+wO3H7bhUWvtexnH+c473GXp +ZseDlMTRTu7tZEuB8RrqWmQYG2pOk9ATbJBgytJOtyQW+LIIWJ2NpzNFFTSBrS0t +nGDv+SuY/nnTjSxI2xKR9C76v/UmwYIFgN1MqHC/p7wQNHc520cED+1EsmVGIiCI +WSgPxwyitJGloqrKBZ+Km26jy9Sk6CR1nSCBIltfdz7J8R6u64ozjCdbHr5tIRtC +cpXjnhMDdadY1L5oEv5jjksRejTno2vdc64+GZrskYtzrwIDAQABo0IwQDAPBgNV +HRMBAf8EBTADAQH/MB0GA1UdDgQWBBQXXEXz0KwcEEyLQ0QgxN2TxcUZOzAOBgNV +HQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggEBAD711/2COx40jGai814Y4fGp +dZ+1k+cKjs8KM+1Jzc7Oyl+jHWR204QW/p2IrPTR+DYrIIBSCu/gD2QnVTWje8aK +fKXEKRex+tKJXRNruAPL1xLWziTwr0gXA1SZr+nL/UREGCNhkPa9VWUGwzaYjep9 +D3nvtrsiKAOm7NnUG0esLCXe7xoCaUwYuylI9J3hUkJkbIhGaIaD/ST1fQXXGn4i +vEl1nIpN6POi65uDcKfW3S8FLaq+1+57jnVEO9rfhWG/6TsTQE6LUgjZ5IxU2kHb +eywFXpkGDQKMjhmOVbA6MxgwA6ftSuT4WMwSuK/WZlUp7AEfku09TcNxO+AvcJA= -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/large_key.pem b/net/data/ssl/certificates/large_key.pem index c0eff466..94cb0c4 100644 --- a/net/data/ssl/certificates/large_key.pem +++ b/net/data/ssl/certificates/large_key.pem
@@ -1,195 +1,194 @@ Certificate: Data: Version: 1 (0x0) - Serial Number: - 50:c2:40:df:15:96:ce:8b:2a:9c:9b:0b:d3:3e:69:13:fc:18:50:a9 - Signature Algorithm: sha256WithRSAEncryption - Issuer: C = US, ST = California, L = Mountain View, O = Test CA, CN = 127.0.0.1 + Serial Number: 11333387438568092375 (0x9d4847d419b9b2d7) + Signature Algorithm: sha256WithRSAEncryption + Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Validity - Not Before: Mar 13 20:46:27 2020 GMT - Not After : Mar 11 20:46:27 2030 GMT - Subject: C = US, ST = California, L = Mountain View, O = Test CA, CN = 127.0.0.1 + Not Before: Jun 5 17:10:51 2017 GMT + Not After : Jun 3 17:10:51 2027 GMT + Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (8200 bit) + Public-Key: (8200 bit) Modulus: - 00:ae:d8:ad:c5:8e:6d:af:3f:98:10:b0:86:8f:44: - b8:b2:82:db:29:39:77:a2:c1:98:da:87:02:4e:49: - 4b:29:13:70:d5:70:42:14:17:34:00:b6:ba:c0:2c: - ab:93:9d:7e:a8:b3:3e:90:d8:6e:c3:33:b3:5f:95: - 7f:12:ea:5f:2d:eb:91:cd:fd:e3:e9:79:17:67:73: - 8a:00:d7:87:ad:02:be:9e:5f:3c:13:ee:05:bb:42: - e9:2f:8e:48:0c:66:d6:1b:13:dc:84:d6:d5:24:22: - 4e:a5:d0:41:de:0a:55:4e:91:16:8a:f3:93:f6:d3: - a8:30:62:81:0f:a6:58:a5:92:a8:d9:b7:f8:10:54: - c7:55:21:fd:2d:62:d3:3c:82:54:26:8e:75:2a:8f: - 19:ce:f8:e7:cc:75:86:18:14:82:32:25:b6:6f:70: - 39:cf:59:10:1d:78:d4:ef:d2:11:31:84:82:67:a7: - fb:6d:06:10:55:d5:da:69:7f:4f:aa:6b:09:66:f8: - 96:32:90:98:34:b2:44:73:0d:17:6e:03:ff:98:fb: - 7f:cd:a4:24:05:a9:26:d4:bd:48:f0:38:5d:a5:a5: - 0f:61:4e:a1:4d:0a:72:e2:19:e1:98:2d:b9:97:d0: - 28:5c:13:84:d5:02:1c:5e:25:22:64:78:5b:dc:e0: - 07:e4:e3:95:41:e8:e7:60:51:df:43:6b:ce:2c:c2: - af:4f:d8:1b:ce:cf:47:bc:f6:17:4c:1c:f3:06:14: - 3a:6f:96:d9:95:fc:26:a2:31:b4:ae:23:a1:a5:26: - a1:f6:4f:92:41:83:c4:59:99:76:6d:01:b6:82:cc: - ec:90:09:1a:ed:cb:4b:17:51:7e:ad:c3:ed:38:9e: - 84:f1:14:aa:19:14:59:c6:8f:31:3f:a2:90:89:3f: - 4b:f8:a4:38:5f:18:fc:30:3f:e6:37:7e:db:5c:cf: - 6b:e0:0e:60:03:cc:49:db:1a:44:3a:07:b6:99:73: - 1f:2d:14:5a:13:3b:a5:2d:71:9d:a0:d8:0e:b6:eb: - c6:2a:1c:35:aa:7f:58:91:ec:df:66:de:3c:df:78: - 86:85:03:f1:f3:2c:49:bd:e4:8a:0e:fc:cb:47:85: - 94:8b:e0:92:ac:17:2d:6a:62:9c:42:d5:ed:c1:7d: - 82:e1:ec:4c:58:f9:50:c5:bd:bd:68:6d:68:79:c6: - c3:93:85:22:4f:7b:ad:9b:a5:eb:e7:2a:fe:bc:b7: - 65:db:15:92:92:fa:85:5a:f0:6f:ee:02:b7:90:89: - ec:80:05:5d:df:71:44:ab:6e:42:c2:d8:ce:b3:42: - a3:dd:a5:26:3c:1d:8d:2e:d6:8f:ef:9b:d4:9c:30: - 58:53:60:6e:d1:62:5b:bd:42:e1:d7:28:43:cc:af: - 68:2e:4b:9b:90:dc:06:88:e8:a6:9b:66:72:6c:e6: - 22:dc:fe:93:5d:0d:02:0c:d7:ad:88:a8:dc:c7:d8: - 6a:e0:4b:e0:76:ee:9c:82:e9:b2:b9:b4:fc:7c:2a: - c5:97:74:fb:e8:01:ae:56:b3:a3:fb:cf:cd:82:44: - 05:ea:ed:fb:f7:6e:64:82:e2:0b:ac:3e:de:35:74: - 26:0b:f4:91:52:1c:25:83:81:02:77:4e:cc:ac:fa: - d7:37:e0:b3:d3:b3:b3:53:eb:06:40:8b:f1:6b:32: - e4:11:37:6f:6a:d4:09:3a:12:c0:1b:53:19:b1:14: - 4e:50:c9:a6:e9:20:8d:6b:2f:5f:ab:2e:62:7c:df: - dd:bd:79:72:2f:d3:51:f7:8d:20:7d:65:67:82:8c: - e2:a3:64:d1:57:55:df:4a:1c:17:8c:fe:fe:24:2e: - 68:8f:0b:ce:11:e9:ff:c7:0c:76:f6:03:7d:d2:49: - 2a:7d:9f:0c:5b:40:f4:a8:35:ef:71:ed:b8:66:9c: - ed:11:27:85:fe:9a:82:13:e3:cc:99:b4:9f:00:a7: - 3b:7b:d8:98:d4:6e:58:7c:71:9d:93:cb:97:41:c9: - f8:5f:9f:54:ba:c1:4c:df:83:3e:31:30:63:f0:ba: - 9f:71:f1:db:24:fe:7a:22:9c:0d:88:67:5a:98:27: - 0f:4c:31:69:91:d2:97:15:8d:53:5f:26:0b:17:fc: - f1:15:aa:df:6c:13:11:e2:00:bc:4a:00:89:77:18: - ff:50:69:6d:9a:70:79:4e:48:cb:cf:f5:a8:09:52: - a5:5b:1e:07:43:a5:14:33:3c:95:c8:0c:11:a1:4c: - b5:2b:89:9d:c0:fc:ae:92:1e:44:99:e8:0b:33:18: - df:54:46:d7:ae:81:b7:c6:7b:56:cc:4a:b9:3c:83: - fd:32:38:4c:55:90:3b:8b:fe:98:5b:6c:4c:ae:47: - a9:ad:31:39:92:aa:1a:12:c8:ac:23:a5:44:a5:f8: - ce:1b:0b:33:aa:ec:32:fe:ff:96:e5:52:ad:39:6e: - 49:71:83:5b:f8:cd:61:db:d8:15:16:08:d2:db:d8: - d6:e8:56:6d:d4:55:cf:d0:06:5c:ef:58:27:64:55: - 55:1f:da:f8:4d:38:d9:c8:d0:f5:3a:2d:6a:ff:00: - c3:0f:ad:07:2a:db:9e:cb:e3:03:d3:ac:20:59:40: - f5:56:78:d6:2c:4e:92:62:90:bb:b8:7d:c4:ef:3b: - 8a:79:15:fa:4d:86:34:a0:09:59:4d:99:b8:90:49: - 73:c4:e1:96:d3:29:40:7c:dd:f2:cb:56:d5:f6:d3: - fb:0c:83:c3:4a:9d + 00:ba:ab:d2:c8:6c:04:5e:23:61:04:38:ed:eb:c1: + ab:c7:5d:fd:21:15:49:2b:91:45:47:4e:b0:83:56: + ce:05:7f:3c:c3:6d:d5:02:2a:a3:f5:9b:0e:26:63: + a2:22:73:4c:89:a5:49:37:f4:0e:be:62:0a:fc:a7: + 31:02:a7:74:d1:c1:64:d2:d6:db:21:90:c3:a3:c9: + b6:1f:6a:f7:e9:24:8b:c5:a2:c2:cd:d4:91:16:1b: + 69:ba:c3:62:05:90:fc:2f:83:5c:6c:fe:63:c8:31: + 78:6e:27:f8:e2:25:a6:36:1d:83:4a:6d:f0:18:be: + 7c:56:12:24:d8:be:12:17:7a:f8:0e:58:5b:6d:e7: + 00:9e:2e:cc:08:94:3b:b2:71:df:df:c5:f7:b1:bb: + 45:41:40:82:c1:bd:90:63:f6:fa:98:ce:c9:83:95: + 17:30:5d:b6:4b:43:4d:ee:d9:e3:54:70:4c:87:92: + 71:39:3c:f6:53:43:96:a7:94:c7:a9:a8:62:ce:90: + 0e:d7:b3:e7:e4:0c:ef:2c:9a:48:30:d1:60:3f:b5: + 8f:6b:84:24:62:24:36:0d:3f:2e:82:15:3e:62:67: + 12:7f:d4:6e:2c:8b:a8:6d:70:da:55:5e:1f:0d:b9: + cd:55:b1:d4:88:eb:c6:24:3d:68:6e:31:75:20:70: + e2:2e:f9:cf:e8:38:93:47:f7:5a:91:50:9e:ed:c0: + 89:a6:2a:4b:04:83:e3:7f:e8:b3:89:c6:f9:3b:64: + 91:66:03:8f:3f:87:4a:0f:88:cb:1d:b4:57:cd:d1: + 35:6d:fd:33:a2:b3:f2:af:84:d6:76:81:98:c4:bb: + b1:8d:2a:fe:33:80:9a:87:3e:04:6d:aa:c8:19:04: + ea:82:86:5a:4c:d7:e6:a2:f6:cb:90:6f:d9:6b:44: + c0:aa:1f:f4:d1:8e:89:dc:00:80:16:63:18:a4:97: + 1e:1d:dd:1a:b6:26:2d:02:a5:ad:77:cd:00:d7:2f: + d2:5a:69:10:d6:7a:1d:d4:35:b4:22:67:fa:fa:d3: + c1:60:ba:6e:24:88:86:84:19:d7:db:84:f9:46:47: + f7:bd:e5:e4:80:09:5a:6c:b7:d9:b6:91:b9:78:5d: + 4a:d1:d8:a3:1a:5c:f7:22:d7:64:1d:71:cf:98:6b: + 02:20:b3:6d:a3:84:d5:52:31:e1:9c:a8:36:6c:b2: + 3b:12:f5:65:99:61:17:66:a8:fe:f7:7c:5a:db:35: + 16:66:94:2b:03:9e:c6:3b:c1:f7:f4:d8:0a:8e:af: + 64:0f:a4:d2:af:59:87:99:99:e7:4b:eb:6d:23:53: + 8b:be:a0:3c:91:85:e6:ae:5a:79:c8:5e:0a:21:1b: + 8e:a5:8b:24:fb:5d:f7:8d:78:68:f3:83:df:21:e3: + 4d:50:ab:78:f6:93:af:ae:1c:66:77:96:72:8d:6d: + 94:83:a4:f3:81:e4:a7:a2:b6:5d:5c:14:0f:bd:9b: + 26:1c:5a:4a:2f:6d:dd:b3:3b:e1:c6:79:63:04:1e: + 95:f0:41:29:1f:8d:97:7a:3c:f9:bd:11:ea:70:1b: + 3d:6e:e1:c2:1c:45:19:5f:20:e1:5d:50:21:b5:9a: + f3:ab:2f:37:59:bc:7a:33:68:28:47:ad:27:f2:dd: + e7:56:ae:53:84:06:0c:72:d2:25:76:b5:71:31:db: + c5:25:d0:46:1a:61:84:8e:3f:e4:df:0e:76:56:fc: + d1:64:08:80:b7:38:79:85:1a:ef:de:02:40:af:d8: + 2e:5b:3b:3d:e0:b2:05:05:6f:6c:53:a3:84:d4:8b: + 6c:18:61:b2:05:a3:8a:1b:82:51:7f:bd:40:28:c7: + b4:d9:84:a1:40:72:93:4a:7d:00:29:e4:f8:1a:8a: + 5e:cc:8f:f3:45:01:b3:51:31:63:03:6a:5c:cc:0c: + 21:8c:a3:33:ff:af:21:56:0f:c1:f1:09:55:ca:a4: + 50:a8:47:ee:24:ad:d5:05:4b:c0:38:11:d4:ac:84: + 06:35:f3:7c:44:3e:b2:24:a2:46:7b:31:c6:e9:7a: + 4b:36:b0:db:12:01:c3:23:b5:8c:c8:fa:f2:09:ef: + d8:6d:9f:64:cf:34:6c:c5:aa:85:d4:c3:17:90:7a: + 9d:2c:2a:23:31:1b:87:68:16:40:0f:a4:c0:3f:b2: + 4b:5e:a8:ec:28:79:55:f8:da:25:06:6c:65:7f:de: + 85:d1:f3:da:e4:14:58:fa:9f:71:35:79:4c:81:92: + fa:af:b4:f9:f3:0f:27:2c:22:8b:65:f2:38:1d:da: + c2:2e:a7:46:61:44:f3:74:8e:44:62:ab:7f:39:84: + a9:08:fa:77:f3:7b:de:79:af:ea:b9:5b:ba:4b:2e: + 2a:4b:54:d2:8b:53:33:31:c2:ab:2c:63:d6:2d:85: + 43:0d:90:aa:dc:23:b5:7a:39:e2:99:6b:03:1b:b4: + c5:86:37:76:6d:38:70:af:3c:0d:69:e5:68:91:dd: + 37:35:0f:a4:1a:fd:4c:a0:9d:f9:bd:8d:ec:12:35: + 73:60:5b:5b:62:3b:ee:fa:c5:ce:d9:86:7e:c1:00: + c5:d2:6b:86:85:af:f4:03:32:72:00:90:37:82:29: + 79:47:43:38:98:73:64:4e:bd:35:5c:a7:6e:d5:4c: + 0d:3b:e1:85:e4:0a:36:9b:00:4b:a9:ec:52:14:50: + 81:1f:a3:26:a3:b5:1d:a0:76:0a:1b:bb:d6:c5:3f: + c3:41:fa:3e:6f:85 Exponent: 65537 (0x10001) Signature Algorithm: sha256WithRSAEncryption - 91:bd:bb:3e:c4:ba:f8:4d:98:d0:da:bc:6c:30:da:0e:b0:e3: - 43:36:66:86:9f:ee:7b:34:83:38:e8:92:38:52:c3:9d:9b:eb: - f4:43:ab:29:5e:a1:24:04:94:c4:ff:5d:6e:35:89:b5:e0:67: - ed:b3:46:77:cf:77:c9:4c:b2:38:79:16:f0:99:86:06:30:9f: - 51:8d:98:eb:c9:30:db:80:31:31:7e:01:47:e4:95:a7:56:30: - ea:a0:54:29:9a:27:01:50:14:a1:b5:c8:ed:e1:a2:bf:73:e7: - 64:fc:08:d9:ab:07:6d:a3:94:2a:06:d5:25:59:c4:7f:be:47: - 8d:d5:0d:39:e6:1e:57:bd:40:8c:3a:b3:ef:14:58:b0:a7:c8: - 49:da:fd:66:bf:6f:f9:f0:37:9d:e5:21:a8:93:c2:d7:e4:33: - b1:87:31:04:2c:19:f5:41:78:2e:e7:c8:4b:94:73:f6:52:83: - 4a:e9:14:f9:dc:1d:7b:0a:60:16:c3:4c:1a:cf:20:1c:bb:f8: - 49:a1:27:ec:3a:a3:eb:cd:4b:52:4b:d5:71:d8:28:8f:64:b2: - 38:19:c6:a9:20:3a:cd:6f:f1:5c:5c:09:7c:57:5c:75:15:03: - 3f:c6:6b:16:91:14:1b:31:36:a3:21:93:07:1a:1d:56:0b:50: - 90:b6:de:fd:db:a4:3e:42:a5:bb:01:71:4f:9b:a1:5b:82:ba: - d6:9d:4b:21:38:c1:e9:fd:63:55:d2:ca:5c:23:22:e2:33:86: - 31:c3:70:81:68:ca:13:53:0b:11:05:97:8b:76:0f:eb:65:c9: - ac:da:c7:95:d8:51:a4:c3:70:a9:9c:6c:32:26:c2:5d:68:d4: - 8c:cf:0b:02:d2:76:3f:75:06:43:c7:47:ec:6c:33:45:73:5c: - 60:62:c7:0d:2a:8c:77:ff:bd:ca:ea:74:dc:74:20:7a:62:3d: - 61:d0:81:fc:0d:64:f2:b1:cd:37:20:f2:cf:b5:f4:37:fc:fc: - 8c:42:c6:c9:33:df:aa:b4:48:8c:82:ed:ab:23:2f:8b:97:34: - 30:75:42:4a:43:14:65:d3:20:1d:a9:ae:56:9b:1c:48:ec:67: - 43:1a:9d:5b:eb:80:a2:c7:ed:6b:96:50:0b:b0:90:38:ec:86: - 03:2a:0b:4f:33:73:07:47:81:74:01:0e:84:a7:77:17:fb:6d: - 4c:f5:4c:a3:d9:ca:36:3a:a3:93:0d:e9:6d:8e:0d:63:22:cf: - e9:43:9b:78:4b:cf:75:60:51:15:cf:8a:81:f1:93:c1:fb:3e: - d0:dd:bb:41:2d:69:99:cb:4c:43:47:6b:ab:54:24:64:4c:f3: - cf:07:39:ef:73:ae:07:41:f3:04:90:a8:3d:43:a5:7d:ec:a6: - 22:f3:c1:45:0f:0b:fc:9b:a4:7c:45:cf:be:67:e8:90:03:d0: - 05:b8:7d:31:d8:1b:b2:81:fe:4e:42:31:69:54:60:93:09:71: - 54:9f:6b:0c:e9:cb:c0:a3:42:f3:0c:b9:36:35:26:66:de:c7: - 0f:19:78:93:32:2e:3a:95:7e:3e:8e:71:82:9c:b4:6a:08:34: - ad:ee:bb:a5:a5:03:5a:c9:7a:fa:69:25:2a:bb:f3:d4:30:de: - 06:ec:d9:16:64:d2:32:dc:de:7f:21:6b:03:57:6f:1d:d5:4c: - b3:7a:c0:d1:1e:24:db:ae:cc:02:76:f3:d2:67:79:f2:b3:12: - 74:e0:2d:87:bc:1b:b2:70:9b:f5:11:65:6f:7c:0f:95:2f:67: - f8:7c:cc:52:cb:9d:74:b9:5a:22:0e:17:1d:26:4b:52:48:22: - f1:18:e2:05:15:b9:13:ed:46:42:41:0a:c7:4d:cf:f1:89:50: - fb:5b:94:03:17:bd:24:b0:5b:59:2c:9a:07:9d:c7:1e:d8:88: - f3:28:ee:fe:c3:c5:b7:c9:be:d2:63:52:76:0e:1d:94:d6:32: - c3:64:06:49:55:29:6e:30:34:20:fb:20:ec:32:bf:af:1b:0e: - ab:e1:8f:24:47:33:82:bc:7e:23:53:eb:44:28:3d:a1:47:a9: - 84:cd:6d:f1:a9:a1:e7:29:ca:1b:c6:83:43:8b:8f:90:96:2e: - b8:44:42:6e:71:ce:98:0d:7a:49:c5:e9:9b:1c:2b:97:24:00: - 1f:19:60:f0:14:2e:01:9d:b1:93:7d:13:d5:44:af:c4:0b:a6: - 64:12:4b:fa:9e:82:45:ee:79:f3:51:c5:04:71:0d:9c:82:4f: - 31:df:00:14:e4:c7:a8:f4:3e:d1:22:84:2d:c5:8f:fb:fe:11: - 33:4c:b9:a3:48:d3:fa:ac:ca:b8:66:98:c8:4a:00:c7:09:48: - 76:fd:ca:2a:d3:a8:d8:dd:58:0d:e3:30:93:cf:ae:54:8b:6a: - 0b:bc:3f:35:2a:07:98:aa:dc:b1:ed:d2:ca:db:dc:04:72:3d: - 08:ef:48:01:3d:7f:c2:b2:67:18:d3:9e:a6:b2:43:61:e5:48: - 08:75:be:f2:02:64:a4:d3:11:74:ad:04:ca:1a:26:ec:67:f2: - 1d:dc:16:22:5c:db:22:97:20:4c:cf:49:fc:1b:c2:bf:69:54: - 74:0c:6a:9d:52:a7:25:d8:4b:82:4b:35:d7:35:60:54:f6:90: - 6e:44:86:04:fc:f1:36:8c:59:1c:89:dd:9f:3d:c5:f6:59:78: - fc:5e:86:b7:4f:b3:cb:27:9e:c5:de:69:d5:66:7d:df:bb + 5a:d5:96:95:b5:3b:c2:47:95:f1:f1:b0:d7:a3:05:30:7b:80: + b1:2c:ef:aa:37:6c:de:df:78:69:76:ff:f0:11:90:a5:e9:86: + 49:29:73:df:2b:82:a9:7f:d4:64:3f:ce:16:7a:2d:39:8e:be: + 09:a6:95:c8:c3:e7:9a:75:e5:ff:9f:e0:0f:eb:b2:46:eb:2d: + 7f:da:67:95:37:45:c2:af:b8:50:1d:29:ef:f7:df:65:c8:36: + 98:77:d6:e0:e4:37:51:52:75:ff:ad:61:c0:aa:31:b0:bf:46: + ec:a4:a7:77:61:ad:b7:bf:6a:47:02:ed:e4:16:52:89:65:07: + 13:ca:aa:00:2a:5d:e4:dc:40:96:69:3c:41:f1:8f:9c:6d:e3: + 5c:0b:89:f1:ec:80:08:21:0f:dd:a3:53:1d:f2:f9:1b:82:20: + 7f:bf:10:04:92:65:a8:2c:9e:3b:c1:2d:37:7c:43:03:df:f1: + d0:7b:dc:33:55:52:55:da:6e:f6:bd:71:fe:79:f7:1b:c2:b2: + 65:c0:3f:5a:72:cc:b5:64:9d:7e:28:0c:29:b7:b4:fe:fc:85: + d5:60:a0:63:ee:e6:16:58:d1:d1:0e:0f:52:66:41:22:b8:5e: + e8:4f:a2:5c:16:ab:25:ed:93:5e:95:fc:d2:9e:f1:ba:76:6d: + ab:da:90:94:72:82:4a:0a:b8:ab:32:f0:6a:f7:57:41:fc:f3: + de:1d:79:97:b2:99:d5:d0:21:7b:e8:9a:21:1b:b2:2f:59:b5: + d9:45:d8:1a:50:29:24:88:00:97:9c:99:a6:3b:df:60:de:7b: + 3a:4b:4d:a4:05:38:1f:6f:bd:55:d7:b8:0f:3b:06:36:68:9e: + 9c:68:16:b5:0a:7d:f9:a6:5b:a0:1d:a9:6e:59:e3:69:12:0d: + fd:05:58:47:b3:71:65:13:45:dc:17:72:9d:2a:aa:9d:a9:03: + d2:9a:b1:11:0f:f9:9b:46:47:9d:d2:11:3e:94:9b:ea:17:a6: + 52:73:6c:c3:a0:6a:bf:84:94:fb:28:55:3d:eb:00:0d:0a:9d: + 68:d6:19:47:82:63:88:b4:1d:c4:30:fa:80:eb:59:08:96:8e: + b7:c0:96:ce:05:bc:e7:31:39:7f:9a:c9:63:a3:50:b2:40:33: + 18:50:e3:12:95:1a:87:39:62:eb:9c:3d:aa:d5:99:77:05:e3: + e3:6d:6b:b2:9e:86:30:fd:6f:ef:52:8d:95:7e:7c:e3:0e:2d: + e4:e3:f9:d2:66:7e:00:24:3d:9d:fc:b8:88:ca:b9:04:43:79: + 2c:50:30:85:3e:3a:f1:bb:d1:8a:e3:98:1c:ec:75:21:47:4e: + d8:f4:05:f8:c7:75:e0:89:37:2f:91:01:8c:dc:30:b9:16:4a: + c7:e4:ed:36:9d:5f:54:90:b8:e6:47:6d:c3:10:9f:16:56:2f: + dd:33:e7:2d:8e:0b:d4:97:50:da:e0:83:ee:54:30:b1:d9:cd: + 71:ff:00:b7:48:4d:e4:28:ac:cf:b1:01:77:bb:a9:dd:b5:3f: + 87:53:c9:f9:a6:86:3b:8c:fd:ba:aa:75:d7:1c:ca:48:70:6c: + c5:64:7c:94:ba:58:17:75:5f:ab:e7:4c:d2:5d:37:3a:9f:cb: + b4:37:e8:af:52:3f:5f:b4:bd:99:e9:79:6c:cc:e9:a4:99:2d: + d6:98:6d:bc:f4:2d:cf:4f:af:10:df:94:22:68:2a:2a:f4:f9: + 41:dc:a9:11:05:76:ae:f6:d8:af:1a:bc:27:8f:22:95:13:92: + 78:7f:60:43:a5:79:e4:4e:85:fc:32:0e:20:79:d9:90:81:ba: + 9f:f8:05:ba:98:bb:1f:36:52:1b:6a:c1:b9:6a:cc:e6:ea:21: + 7b:8e:1a:ac:b7:9c:c8:d5:f6:f7:1c:fd:a5:44:c5:7a:02:af: + b9:81:fb:d8:7e:89:dd:8b:05:96:a0:3d:b2:6f:af:bc:62:5d: + b5:0d:04:d7:09:24:77:d9:74:90:eb:9d:ae:bb:f2:60:83:22: + 09:86:0a:66:de:69:be:bd:c9:cf:31:e3:b9:32:3b:9d:6a:57: + 99:5f:6c:ba:c0:29:c0:d8:c6:b0:2b:11:9e:0c:11:0f:8d:67: + 2e:f3:b8:14:8e:dd:c4:e8:3c:c7:f9:81:8c:6a:77:7e:7d:86: + 7f:f2:7e:bd:38:03:10:2c:2f:13:e4:69:24:d4:2e:e3:7a:d0: + 1e:ed:79:49:06:22:6d:94:20:a0:73:22:18:09:01:4d:5b:5f: + 31:bd:37:13:a7:eb:9c:0a:9a:c1:c3:37:c4:62:07:c8:74:a1: + 5c:c8:d0:7f:4f:70:4a:53:a4:78:85:50:2a:a4:3e:0e:98:82: + 4d:2c:70:a0:71:3f:0b:ea:a0:11:e7:6b:00:02:a2:b6:83:99: + f3:18:68:ed:2d:2c:ef:02:ca:ab:d0:2c:0c:78:4b:ec:f1:03: + f4:d3:b9:df:36:a2:10:6d:3b:75:53:79:4c:6d:34:ae:cc:13: + 2f:d4:81:98:cd:94:9f:65:b7:20:a9:5e:64:51:01:09:b3:89: + 2f:bc:3b:38:0f:27:bb:59:72:0e:c0:47:18:65:50:77:48:b4: + d1:a8:b6:83:3f:55:86:3f:ac:ee:20:83:38:78:d3:ef:10:48: + 52:7d:92:ea:dc:5e:ad:24:0f:37:70:4c:a0:16:a2:59:3e:78: + 56:8f:d4:74:8b:c6:88:a6:3b:17:7c:34:bf:ab:19:21:f2 -----BEGIN CERTIFICATE----- -MIIJSTCCBTACFFDCQN8Vls6LKpybC9M+aRP8GFCpMA0GCSqGSIb3DQEBCwUAMGAx -CzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3Vu -dGFpbiBWaWV3MRAwDgYDVQQKDAdUZXN0IENBMRIwEAYDVQQDDAkxMjcuMC4wLjEw -HhcNMjAwMzEzMjA0NjI3WhcNMzAwMzExMjA0NjI3WjBgMQswCQYDVQQGEwJVUzET -MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G -A1UECgwHVGVzdCBDQTESMBAGA1UEAwwJMTI3LjAuMC4xMIIEIzANBgkqhkiG9w0B -AQEFAAOCBBAAMIIECwKCBAIArtitxY5trz+YELCGj0S4soLbKTl3osGY2ocCTklL -KRNw1XBCFBc0ALa6wCyrk51+qLM+kNhuwzOzX5V/EupfLeuRzf3j6XkXZ3OKANeH -rQK+nl88E+4Fu0LpL45IDGbWGxPchNbVJCJOpdBB3gpVTpEWivOT9tOoMGKBD6ZY -pZKo2bf4EFTHVSH9LWLTPIJUJo51Ko8ZzvjnzHWGGBSCMiW2b3A5z1kQHXjU79IR -MYSCZ6f7bQYQVdXaaX9PqmsJZviWMpCYNLJEcw0XbgP/mPt/zaQkBakm1L1I8Dhd -paUPYU6hTQpy4hnhmC25l9AoXBOE1QIcXiUiZHhb3OAH5OOVQejnYFHfQ2vOLMKv -T9gbzs9HvPYXTBzzBhQ6b5bZlfwmojG0riOhpSah9k+SQYPEWZl2bQG2gszskAka -7ctLF1F+rcPtOJ6E8RSqGRRZxo8xP6KQiT9L+KQ4Xxj8MD/mN37bXM9r4A5gA8xJ -2xpEOge2mXMfLRRaEzulLXGdoNgOtuvGKhw1qn9YkezfZt4833iGhQPx8yxJveSK -DvzLR4WUi+CSrBctamKcQtXtwX2C4exMWPlQxb29aG1oecbDk4UiT3utm6Xr5yr+ -vLdl2xWSkvqFWvBv7gK3kInsgAVd33FEq25CwtjOs0Kj3aUmPB2NLtaP75vUnDBY -U2Bu0WJbvULh1yhDzK9oLkubkNwGiOimm2ZybOYi3P6TXQ0CDNetiKjcx9hq4Evg -du6cgumyubT8fCrFl3T76AGuVrOj+8/NgkQF6u37925kguILrD7eNXQmC/SRUhwl -g4ECd07MrPrXN+Cz07OzU+sGQIvxazLkETdvatQJOhLAG1MZsRROUMmm6SCNay9f -qy5ifN/dvXlyL9NR940gfWVngozio2TRV1XfShwXjP7+JC5ojwvOEen/xwx29gN9 -0kkqfZ8MW0D0qDXvce24ZpztESeF/pqCE+PMmbSfAKc7e9iY1G5YfHGdk8uXQcn4 -X59UusFM34M+MTBj8LqfcfHbJP56IpwNiGdamCcPTDFpkdKXFY1TXyYLF/zxFarf -bBMR4gC8SgCJdxj/UGltmnB5TkjLz/WoCVKlWx4HQ6UUMzyVyAwRoUy1K4mdwPyu -kh5EmegLMxjfVEbXroG3xntWzEq5PIP9MjhMVZA7i/6YW2xMrkeprTE5kqoaEsis -I6VEpfjOGwszquwy/v+W5VKtOW5JcYNb+M1h29gVFgjS29jW6FZt1FXP0AZc71gn -ZFVVH9r4TTjZyND1Oi1q/wDDD60HKtuey+MD06wgWUD1VnjWLE6SYpC7uH3E7zuK -eRX6TYY0oAlZTZm4kElzxOGW0ylAfN3yy1bV9tP7DIPDSp0CAwEAATANBgkqhkiG -9w0BAQsFAAOCBAIAkb27PsS6+E2Y0Nq8bDDaDrDjQzZmhp/uezSDOOiSOFLDnZvr -9EOrKV6hJASUxP9dbjWJteBn7bNGd893yUyyOHkW8JmGBjCfUY2Y68kw24AxMX4B -R+SVp1Yw6qBUKZonAVAUobXI7eGiv3PnZPwI2asHbaOUKgbVJVnEf75HjdUNOeYe -V71AjDqz7xRYsKfISdr9Zr9v+fA3neUhqJPC1+QzsYcxBCwZ9UF4LufIS5Rz9lKD -SukU+dwdewpgFsNMGs8gHLv4SaEn7Dqj681LUkvVcdgoj2SyOBnGqSA6zW/xXFwJ -fFdcdRUDP8ZrFpEUGzE2oyGTBxodVgtQkLbe/dukPkKluwFxT5uhW4K61p1LITjB -6f1jVdLKXCMi4jOGMcNwgWjKE1MLEQWXi3YP62XJrNrHldhRpMNwqZxsMibCXWjU -jM8LAtJ2P3UGQ8dH7GwzRXNcYGLHDSqMd/+9yup03HQgemI9YdCB/A1k8rHNNyDy -z7X0N/z8jELGyTPfqrRIjILtqyMvi5c0MHVCSkMUZdMgHamuVpscSOxnQxqdW+uA -osfta5ZQC7CQOOyGAyoLTzNzB0eBdAEOhKd3F/ttTPVMo9nKNjqjkw3pbY4NYyLP -6UObeEvPdWBRFc+KgfGTwfs+0N27QS1pmctMQ0drq1QkZEzzzwc573OuB0HzBJCo -PUOlfeymIvPBRQ8L/JukfEXPvmfokAPQBbh9MdgbsoH+TkIxaVRgkwlxVJ9rDOnL -wKNC8wy5NjUmZt7HDxl4kzIuOpV+Po5xgpy0agg0re67paUDWsl6+mklKrvz1DDe -BuzZFmTSMtzefyFrA1dvHdVMs3rA0R4k267MAnbz0md58rMSdOAth7wbsnCb9RFl -b3wPlS9n+HzMUsuddLlaIg4XHSZLUkgi8RjiBRW5E+1GQkEKx03P8YlQ+1uUAxe9 -JLBbWSyaB53HHtiI8yju/sPFt8m+0mNSdg4dlNYyw2QGSVUpbjA0IPsg7DK/rxsO -q+GPJEczgrx+I1PrRCg9oUephM1t8amh5ynKG8aDQ4uPkJYuuERCbnHOmA16ScXp -mxwrlyQAHxlg8BQuAZ2xk30T1USvxAumZBJL+p6CRe5581HFBHENnIJPMd8AFOTH -qPQ+0SKELcWP+/4RM0y5o0jT+qzKuGaYyEoAxwlIdv3KKtOo2N1YDeMwk8+uVItq -C7w/NSoHmKrcse3SytvcBHI9CO9IAT1/wrJnGNOeprJDYeVICHW+8gJkpNMRdK0E -yhom7GfyHdwWIlzbIpcgTM9J/BvCv2lUdAxqnVKnJdhLgks11zVgVPaQbkSGBPzx -NoxZHIndnz3F9ll4/F6Gt0+zyyeexd5p1WZ937s= +MIIJPjCCBSUCCQCdSEfUGbmy1zANBgkqhkiG9w0BAQsFADBgMQswCQYDVQQGEwJV +UzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQ +MA4GA1UECgwHVGVzdCBDQTESMBAGA1UEAwwJMTI3LjAuMC4xMB4XDTE3MDYwNTE3 +MTA1MVoXDTI3MDYwMzE3MTA1MVowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCBCMwDQYJKoZIhvcNAQEBBQADggQQADCC +BAsCggQCALqr0shsBF4jYQQ47evBq8dd/SEVSSuRRUdOsINWzgV/PMNt1QIqo/Wb +DiZjoiJzTImlSTf0Dr5iCvynMQKndNHBZNLW2yGQw6PJth9q9+kki8Wiws3UkRYb +abrDYgWQ/C+DXGz+Y8gxeG4n+OIlpjYdg0pt8Bi+fFYSJNi+Ehd6+A5YW23nAJ4u +zAiUO7Jx39/F97G7RUFAgsG9kGP2+pjOyYOVFzBdtktDTe7Z41RwTIeScTk89lND +lqeUx6moYs6QDtez5+QM7yyaSDDRYD+1j2uEJGIkNg0/LoIVPmJnEn/UbiyLqG1w +2lVeHw25zVWx1IjrxiQ9aG4xdSBw4i75z+g4k0f3WpFQnu3AiaYqSwSD43/os4nG ++TtkkWYDjz+HSg+Iyx20V83RNW39M6Kz8q+E1naBmMS7sY0q/jOAmoc+BG2qyBkE +6oKGWkzX5qL2y5Bv2WtEwKof9NGOidwAgBZjGKSXHh3dGrYmLQKlrXfNANcv0lpp +ENZ6HdQ1tCJn+vrTwWC6biSIhoQZ19uE+UZH973l5IAJWmy32baRuXhdStHYoxpc +9yLXZB1xz5hrAiCzbaOE1VIx4ZyoNmyyOxL1ZZlhF2ao/vd8Wts1FmaUKwOexjvB +9/TYCo6vZA+k0q9Zh5mZ50vrbSNTi76gPJGF5q5aecheCiEbjqWLJPtd9414aPOD +3yHjTVCrePaTr64cZneWco1tlIOk84Hkp6K2XVwUD72bJhxaSi9t3bM74cZ5YwQe +lfBBKR+Nl3o8+b0R6nAbPW7hwhxFGV8g4V1QIbWa86svN1m8ejNoKEetJ/Ld51au +U4QGDHLSJXa1cTHbxSXQRhphhI4/5N8Odlb80WQIgLc4eYUa794CQK/YLls7PeCy +BQVvbFOjhNSLbBhhsgWjihuCUX+9QCjHtNmEoUByk0p9ACnk+BqKXsyP80UBs1Ex +YwNqXMwMIYyjM/+vIVYPwfEJVcqkUKhH7iSt1QVLwDgR1KyEBjXzfEQ+siSiRnsx +xul6Szaw2xIBwyO1jMj68gnv2G2fZM80bMWqhdTDF5B6nSwqIzEbh2gWQA+kwD+y +S16o7Ch5VfjaJQZsZX/ehdHz2uQUWPqfcTV5TIGS+q+0+fMPJywii2XyOB3awi6n +RmFE83SORGKrfzmEqQj6d/N73nmv6rlbuksuKktU0otTMzHCqyxj1i2FQw2Qqtwj +tXo54plrAxu0xYY3dm04cK88DWnlaJHdNzUPpBr9TKCd+b2N7BI1c2BbW2I77vrF +ztmGfsEAxdJrhoWv9AMycgCQN4IpeUdDOJhzZE69NVynbtVMDTvhheQKNpsAS6ns +UhRQgR+jJqO1HaB2Chu71sU/w0H6Pm+FAgMBAAEwDQYJKoZIhvcNAQELBQADggQC +AFrVlpW1O8JHlfHxsNejBTB7gLEs76o3bN7feGl2//ARkKXphkkpc98rgql/1GQ/ +zhZ6LTmOvgmmlcjD55p15f+f4A/rskbrLX/aZ5U3RcKvuFAdKe/332XINph31uDk +N1FSdf+tYcCqMbC/Ruykp3dhrbe/akcC7eQWUollBxPKqgAqXeTcQJZpPEHxj5xt +41wLifHsgAghD92jUx3y+RuCIH+/EASSZagsnjvBLTd8QwPf8dB73DNVUlXabva9 +cf559xvCsmXAP1pyzLVknX4oDCm3tP78hdVgoGPu5hZY0dEOD1JmQSK4XuhPolwW +qyXtk16V/NKe8bp2bavakJRygkoKuKsy8Gr3V0H8894deZeymdXQIXvomiEbsi9Z +tdlF2BpQKSSIAJecmaY732DeezpLTaQFOB9vvVXXuA87BjZonpxoFrUKffmmW6Ad +qW5Z42kSDf0FWEezcWUTRdwXcp0qqp2pA9KasREP+ZtGR53SET6Um+oXplJzbMOg +ar+ElPsoVT3rAA0KnWjWGUeCY4i0HcQw+oDrWQiWjrfAls4FvOcxOX+ayWOjULJA +MxhQ4xKVGoc5YuucParVmXcF4+Nta7KehjD9b+9SjZV+fOMOLeTj+dJmfgAkPZ38 +uIjKuQRDeSxQMIU+OvG70YrjmBzsdSFHTtj0BfjHdeCJNy+RAYzcMLkWSsfk7Tad +X1SQuOZHbcMQnxZWL90z5y2OC9SXUNrgg+5UMLHZzXH/ALdITeQorM+xAXe7qd21 +P4dTyfmmhjuM/bqqddccykhwbMVkfJS6WBd1X6vnTNJdNzqfy7Q36K9SP1+0vZnp +eWzM6aSZLdaYbbz0Lc9PrxDflCJoKir0+UHcqREFdq722K8avCePIpUTknh/YEOl +eeROhfwyDiB52ZCBup/4BbqYux82UhtqwblqzObqIXuOGqy3nMjV9vcc/aVExXoC +r7mB+9h+id2LBZagPbJvr7xiXbUNBNcJJHfZdJDrna678mCDIgmGCmbeab69yc8x +47kyO51qV5lfbLrAKcDYxrArEZ4MEQ+NZy7zuBSO3cToPMf5gYxqd359hn/yfr04 +AxAsLxPkaSTULuN60B7teUkGIm2UIKBzIhgJAU1bXzG9NxOn65wKmsHDN8RiB8h0 +oVzI0H9PcEpTpHiFUCqkPg6Ygk0scKBxPwvqoBHnawACoraDmfMYaO0tLO8CyqvQ +LAx4S+zxA/TTud82ohBtO3VTeUxtNK7MEy/UgZjNlJ9ltyCpXmRRAQmziS+8OzgP +J7tZcg7ARxhlUHdItNGotoM/VYY/rO4ggzh40+8QSFJ9kurcXq0kDzdwTKAWolk+ +eFaP1HSLxoimOxd8NL+rGSHy -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/localhost_cert.pem b/net/data/ssl/certificates/localhost_cert.pem index 4442639da..8a34ad36 100644 --- a/net/data/ssl/certificates/localhost_cert.pem +++ b/net/data/ssl/certificates/localhost_cert.pem
@@ -1,70 +1,69 @@ -----BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDlB6n9XNFWE704 -QoakrHZP/RhqyBF9/F9pNf8PTu+5jBNFdEiqaUds/Ve1DW7UepAzQ932GMhmJ8Q9 -eDfULwNzsDp/LzOLN27Ej7/kQlk/eNlTe8dwVYMP/I8/I3XVwzfyJs4P/7kw/iVI -/iK+tqMgEjvLrGjwYAxq95/a+pvkvmiwcAzwBkP76YvfsfmmiWt5waGDv5yazqQW -Wl0+i3W6Y+rFS8ckTXTcW0d5na8v5wAWyQwUjVp1+lTLo02C0nHm37AgT8jV1yly -4rXR8Nm5v07pPikOpQdBFQblg5dBTx80SKS66yaBmu83FLjXAmG1uhGT3OOBAxwk -aZUrt4xxAgMBAAECggEAe6/M5PB4eRUF7lk3H72n04Dq69gKYlCmMkqf6WOG4Vy9 -l5e6GpXqpfiXokaT4RojwBvZxisSJuE5AL1o4SVWpua4YLFcE8YnAu5jAmG2kymv -rH8/cPItarfJoJ6E56GbGCJOzKMdH1FRT383wmkd5ZcTReZhcdddPXNnmDoZcMlC -X60CQgJolD7mCvKAwTHYFX3vAlM1MgbbF6Mq1hePXGTSKPrlD5vRlMz9BNykCfr4 -GnRjdB9w78ry+UYMQppP+AdNJiRi/6enNrwBWQBAUmnqtRCQHDMlR+0DEbdLorRG -LpiZMuqCRU8p8qFEku0Oqj9iFp3oSLxLCy8mGoe/9QKBgQD4UEGEgknY2DR/mTf+ -RBStiwVXHpRwhgMpEgfUpB6Sc/aRgFrm6AkoCVttVSsHN6XW16d4u613Z/WGW81J -Af0F8lc2jsj8WQufZHYbZrto6DOsuE8WintBg7jc8RE3kXpf+esAuy23YUI3hE2I -BgMre+4lHzreAxguhnbEG1fMewKBgQDsHpjF0Mm+q2G02a4Rx8XDxkJWYsBQdj0G -Ph62ZNcD7O5ajQ3hVqOyFwW2U0b4F9sSrwBgXz2MKYbm7SnJgXHAy/BtYKYaPEV5 -rYkjFmsblElvhgz4+l8Rxe+yYxESbjEMiw86eNaPd3rtmcWVXn4tRN68BAdMsl/9 -YbIV+clFAwKBgAZGQOGQST1peSogPQH3xm38LU5eP3H4cOwAwKHm477fn0Nd8u4S -vuh8FAtXM5cjGNWs7VZnp6J0xgd3GmDV5AbacMm4Iev+dAS7DSD0H5gvBd8/aQAw -z5yAL5Olo8G7s1PphL6n/Ce+FWZBuZPOUxYuM35Mo7goa9wBGc8qwbUxAoGAOj1t -x1UxfeM97WLH6cDRyfFMCYzADNitQq3t22VSF7jILfOe2dcJ93JwSUGPPsB7m8co -m5zCTKEtkiYraXWRPlHPUttE/TGinVmtescb0iioWGbDKmJvMq4U6nY/DsG5PXPL -ZMvLeIWq/5IvRyGQk8/p9Iw11LgmrxP63irHd0sCgYB6lOmu3b219ILbif2BTod8 -0Afd6NdELAB5i6k/L+rqloJlzYdRgsx3Csy1qJCprLVdINNLHsIflEtHsbRLbutC -ZJBEltwfEnvXZiZKDOAAfXoem31ibIeqVfhMQTjyLKXrQZHqGegACVW9ETYbvLfr -dBmaTVqHfwZ+PD2lUog7RQ== +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCr/csPH2W5PnS4 +Ei02FKhBPWHuDhF4L4KkDARe+0iCU0lRMclBEgVCefaM20QfPnhNJtfrJ0MVD3nP +4/iIZHDQXlWgXRGIYpqyysmN3p4L2VBrl2zqrWKWYZqQPRZokFUGYIpujqpF1Th5 +Zz2dDWlqb58gUnPye+HswAmTHNOmEXYQjRjoASS4LKc11ZZmFmQaS6h88v+yGYK7 ++ss4kbH2oxRH0OSuiyXPWf9Pl9urA6IobaY2CPgJxl6Cn//+I98IC2heb7/Tciax +FkwrjO+SmOeb2NCQg4dxcPGIhQmPO2ZrOgw+/uttvfuQ3H80Fls4+VgPmo8EQ3VL ++a5zXo7tAgMBAAECggEAQPqJlRUPoYTvI/v6CMyVJNDEBuRZxUZt3PyNSjU1l8dP +k9Vza5obUpoxg9XzTrqTSNK8EKOsvHA0XU6LvzvzQ0Xgo82FqjlWqOXkcC0DGQbp +UzzKcX9AGACYHJZ3uNmOxfIDWvGbcvazd2qB5KwEf6ncPKHqHFqhaIjFFUd2zu56 +4+DcVFKUrMR44KvTk1qe4R00u0kDsxZTLk70fzMkRl0qcy4oyjtOSeSEEqIKgcFS +jiXv2TM1XpMZ28P2VqA98yPhpuEnZepvTFtBth2fh3Be+rs/WxUiND+1/U4b40rH +nJr9w6z7xbpQw5FD3fqBhYK5/rsS2ghALYYaRsPuIQKBgQDiP0YJpflCrY1lbFjg +pdp+oGSqfWB0Ejq1UNnN2vVqFHykyykn+y2Tg2VTC6xsH1gqruy0DRJeHgzLj57K +5/LA98+xobxBcu1QuU0sMylWlMqmppPrHqNf7+ZzTP0LafbJAzpKGqyOIGMfeb6Z +94RwVDz9ykp/VzFg/dTTRKutUwKBgQDCm/iP0x9dC0Weif8wV3QzmjOGY4Oq2RZn +d4OOTL2UIVQq/wGbMomR6X89b/Frs5TCK79VQqffTKkxMWTF+ZZlFG7IFBnUKT84 +KXhqez/jtmyq4flGJ6J6SdrJCXJkXZwt1NLnIPwZctgaugrgh5vEBIln50wTGOXN +8EgDABEKvwKBgQCzPCsxE5LPlwxQUDBs8BeTf1+gjSjva02lPML/yTno6wf/yY72 +RI/LsCmCS9ox4fcIAYI19bEabLX4QfQrjOuMogWhFJ8+PlzxOYuAu5tBIykUMx02 +BBSruTMZHuHMvAqtHmh8MnuHMPM2CU3NTgBWuPWEnVC9ZwcQbqa/JETZTwKBgQCf +Oy0yyQT1hX6OTM0vSa87daVJBW27Qerx97j9ms7XQDn1ADfZO42ShOHmbAy2GfbS +tSbVZTekHr6lEIwq7J/gzsoiDUhg7uraUhxDy9qnwCDD5Sen/lAUDQ/lxEQD2RAr +8+Io2TVMwUoO/EBgHLUXurqO+JKnYYzOZxcU1V4cUwKBgQCWUtlDJR/gg83Q/HbC ++fPPSifL7nLDuzgDgf6oUp555dsUnU/CSyVhAAGWh/bkYi2Kb0c/5L4pMXlGSHMv +N/6Ek8JA+teaRojEtHqEkEQw6l6T61BxzpImO+KYw05mk+f/I8VoaG/cQkDLr48B +k7jie9XxUXWGXk5vCuvZgtcwQg== -----END PRIVATE KEY----- Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:a8 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 7 (0x7) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity - Not Before: Mar 13 20:46:17 2020 GMT - Not After : Mar 13 20:46:17 2022 GMT + Not Before: Jun 5 17:10:46 2017 GMT + Not After : Jun 3 17:10:46 2027 GMT Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=localhost Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:e5:07:a9:fd:5c:d1:56:13:bd:38:42:86:a4:ac: - 76:4f:fd:18:6a:c8:11:7d:fc:5f:69:35:ff:0f:4e: - ef:b9:8c:13:45:74:48:aa:69:47:6c:fd:57:b5:0d: - 6e:d4:7a:90:33:43:dd:f6:18:c8:66:27:c4:3d:78: - 37:d4:2f:03:73:b0:3a:7f:2f:33:8b:37:6e:c4:8f: - bf:e4:42:59:3f:78:d9:53:7b:c7:70:55:83:0f:fc: - 8f:3f:23:75:d5:c3:37:f2:26:ce:0f:ff:b9:30:fe: - 25:48:fe:22:be:b6:a3:20:12:3b:cb:ac:68:f0:60: - 0c:6a:f7:9f:da:fa:9b:e4:be:68:b0:70:0c:f0:06: - 43:fb:e9:8b:df:b1:f9:a6:89:6b:79:c1:a1:83:bf: - 9c:9a:ce:a4:16:5a:5d:3e:8b:75:ba:63:ea:c5:4b: - c7:24:4d:74:dc:5b:47:79:9d:af:2f:e7:00:16:c9: - 0c:14:8d:5a:75:fa:54:cb:a3:4d:82:d2:71:e6:df: - b0:20:4f:c8:d5:d7:29:72:e2:b5:d1:f0:d9:b9:bf: - 4e:e9:3e:29:0e:a5:07:41:15:06:e5:83:97:41:4f: - 1f:34:48:a4:ba:eb:26:81:9a:ef:37:14:b8:d7:02: - 61:b5:ba:11:93:dc:e3:81:03:1c:24:69:95:2b:b7: - 8c:71 + 00:ab:fd:cb:0f:1f:65:b9:3e:74:b8:12:2d:36:14: + a8:41:3d:61:ee:0e:11:78:2f:82:a4:0c:04:5e:fb: + 48:82:53:49:51:31:c9:41:12:05:42:79:f6:8c:db: + 44:1f:3e:78:4d:26:d7:eb:27:43:15:0f:79:cf:e3: + f8:88:64:70:d0:5e:55:a0:5d:11:88:62:9a:b2:ca: + c9:8d:de:9e:0b:d9:50:6b:97:6c:ea:ad:62:96:61: + 9a:90:3d:16:68:90:55:06:60:8a:6e:8e:aa:45:d5: + 38:79:67:3d:9d:0d:69:6a:6f:9f:20:52:73:f2:7b: + e1:ec:c0:09:93:1c:d3:a6:11:76:10:8d:18:e8:01: + 24:b8:2c:a7:35:d5:96:66:16:64:1a:4b:a8:7c:f2: + ff:b2:19:82:bb:fa:cb:38:91:b1:f6:a3:14:47:d0: + e4:ae:8b:25:cf:59:ff:4f:97:db:ab:03:a2:28:6d: + a6:36:08:f8:09:c6:5e:82:9f:ff:fe:23:df:08:0b: + 68:5e:6f:bf:d3:72:26:b1:16:4c:2b:8c:ef:92:98: + e7:9b:d8:d0:90:83:87:71:70:f1:88:85:09:8f:3b: + 66:6b:3a:0c:3e:fe:eb:6d:bd:fb:90:dc:7f:34:16: + 5b:38:f9:58:0f:9a:8f:04:43:75:4b:f9:ae:73:5e: + 8e:ed Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - DE:5D:1D:65:FC:4D:F4:F9:7F:12:6B:EE:9C:B5:0D:9B:62:EA:4A:11 + FD:CB:18:66:1A:6B:34:2F:F7:F4:26:D0:37:12:5D:4B:70:93:87:CD X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -73,41 +72,41 @@ X509v3 Subject Alternative Name: DNS:localhost Signature Algorithm: sha256WithRSAEncryption - a1:c7:70:45:63:c1:6a:22:4c:f7:23:0b:71:dd:07:5f:a9:70: - 6d:7f:46:88:18:0b:ed:c4:5d:92:f9:3f:d4:27:e2:68:fd:0e: - 19:96:1e:30:1e:65:85:cf:9c:7d:90:37:88:de:cd:60:fa:95: - 98:ff:5f:66:12:53:65:28:8e:01:19:d6:ba:a9:e0:7a:a8:b4: - a6:d9:6f:73:00:01:da:4b:ab:18:48:6a:d0:b2:bc:6b:99:8f: - fd:36:52:ab:27:ef:dc:0b:6e:a2:71:78:02:8a:c2:d0:46:30: - b3:e1:3f:65:58:84:0c:04:f0:58:74:a3:e7:ca:c0:60:7a:a0: - eb:61:1b:86:fa:7e:81:c1:9d:93:57:ba:cc:32:80:6f:11:86: - 79:82:4c:27:5e:0a:2f:d3:44:5b:79:3f:33:33:80:87:d0:b2: - dc:74:db:f0:ec:d7:fd:cb:49:4a:b6:26:31:d2:1c:9a:22:7f: - 18:b1:a7:d1:63:8d:41:c9:d0:04:17:0c:e6:71:6c:d2:45:01: - b7:f8:ac:b3:b1:a2:d3:28:bb:ff:f4:4d:63:d0:ce:c6:4a:55: - 4d:da:20:16:23:19:53:aa:1a:63:cd:51:73:97:9c:f2:df:10: - 5a:48:a2:ce:b0:39:15:1d:d2:21:28:fe:98:09:66:17:26:c5: - a4:7d:a0:04 + 5f:9d:b6:22:48:7d:cd:6a:8e:f8:06:9f:64:98:f0:a2:66:1b: + 47:28:5d:97:8c:fd:36:38:bf:0e:ee:d9:3c:45:86:5b:af:6f: + 12:b2:be:55:10:e5:4d:b9:10:f3:1e:ed:66:ed:f3:7b:5b:c3: + e8:90:3a:57:26:db:51:89:1e:9e:cb:78:30:f9:f9:a2:40:da: + 65:ba:ed:65:c3:75:b3:45:43:be:88:e3:37:41:75:02:96:c0: + eb:49:d5:62:6a:5f:71:90:20:ad:8a:29:7e:84:56:aa:f3:24: + 7f:37:a6:81:89:56:54:e2:fb:e9:27:e7:de:ae:e1:0a:fe:b6: + 7e:cc:2e:69:9c:f8:8c:f3:64:09:a3:a2:62:99:4f:ff:1d:bb: + 5a:b3:8b:7e:8a:46:05:6c:32:1f:44:56:de:cf:b1:b7:33:0d: + b2:f9:08:76:3d:8e:4a:f4:77:1b:87:96:ae:49:a0:46:b0:97: + f8:0d:26:26:d3:70:39:9c:76:eb:6e:dc:0e:38:f6:d7:fe:c3: + fc:fe:4f:41:3f:81:3c:d2:da:8a:8a:39:70:da:04:ef:be:39: + 0f:5a:5f:d7:2e:28:dd:ae:e6:e2:52:8f:55:72:51:ad:51:c6: + 8b:48:17:bc:13:a5:19:19:f6:70:f3:12:6c:52:45:b1:6c:8c: + aa:b1:49:ee -----BEGIN CERTIFICATE----- -MIID1DCCArygAwIBAgIQPiydvrBCyM/8mULVTUFqqDANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTIwMDMxMzIwNDYxN1oXDTIyMDMxMzIwNDYxN1owYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAOUHqf1c0VYTvThChqSsdk/9GGrIEX38X2k1 -/w9O77mME0V0SKppR2z9V7UNbtR6kDND3fYYyGYnxD14N9QvA3OwOn8vM4s3bsSP -v+RCWT942VN7x3BVgw/8jz8jddXDN/Imzg//uTD+JUj+Ir62oyASO8usaPBgDGr3 -n9r6m+S+aLBwDPAGQ/vpi9+x+aaJa3nBoYO/nJrOpBZaXT6Ldbpj6sVLxyRNdNxb -R3mdry/nABbJDBSNWnX6VMujTYLScebfsCBPyNXXKXLitdHw2bm/Tuk+KQ6lB0EV -BuWDl0FPHzRIpLrrJoGa7zcUuNcCYbW6EZPc44EDHCRplSu3jHECAwEAAaOBhjCB -gzAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBTeXR1l/E30+X8Sa+6ctQ2bYupKETAf -BgNVHSMEGDAWgBSbJguKmKm7HbkfHOMaQDPtjheIqzAdBgNVHSUEFjAUBggrBgEF -BQcDAQYIKwYBBQUHAwIwFAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEB -CwUAA4IBAQChx3BFY8FqIkz3Iwtx3QdfqXBtf0aIGAvtxF2S+T/UJ+Jo/Q4Zlh4w -HmWFz5x9kDeI3s1g+pWY/19mElNlKI4BGda6qeB6qLSm2W9zAAHaS6sYSGrQsrxr -mY/9NlKrJ+/cC26icXgCisLQRjCz4T9lWIQMBPBYdKPnysBgeqDrYRuG+n6BwZ2T -V7rMMoBvEYZ5gkwnXgov00RbeT8zM4CH0LLcdNvw7Nf9y0lKtiYx0hyaIn8YsafR -Y41BydAEFwzmcWzSRQG3+KyzsaLTKLv/9E1j0M7GSlVN2iAWIxlTqhpjzVFzl5zy -3xBaSKLOsDkVHdIhKP6YCWYXJsWkfaAE +MIIDxTCCAq2gAwIBAgIBBzANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE3MDYwNTE3 +MTA0NloXDTI3MDYwMzE3MTA0NlowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAKv9yw8fZbk+dLgSLTYUqEE9Ye4OEXgvgqQMBF77SIJTSVExyUESBUJ5 +9ozbRB8+eE0m1+snQxUPec/j+IhkcNBeVaBdEYhimrLKyY3engvZUGuXbOqtYpZh +mpA9FmiQVQZgim6OqkXVOHlnPZ0NaWpvnyBSc/J74ezACZMc06YRdhCNGOgBJLgs +pzXVlmYWZBpLqHzy/7IZgrv6yziRsfajFEfQ5K6LJc9Z/0+X26sDoihtpjYI+AnG +XoKf//4j3wgLaF5vv9NyJrEWTCuM75KY55vY0JCDh3Fw8YiFCY87Zms6DD7+6229 ++5DcfzQWWzj5WA+ajwRDdUv5rnNeju0CAwEAAaOBhjCBgzAMBgNVHRMBAf8EAjAA +MB0GA1UdDgQWBBT9yxhmGms0L/f0JtA3El1LcJOHzTAfBgNVHSMEGDAWgBSbJguK +mKm7HbkfHOMaQDPtjheIqzAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIw +FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBCwUAA4IBAQBfnbYiSH3N +ao74Bp9kmPCiZhtHKF2XjP02OL8O7tk8RYZbr28Ssr5VEOVNuRDzHu1m7fN7W8Po +kDpXJttRiR6ey3gw+fmiQNpluu1lw3WzRUO+iOM3QXUClsDrSdVial9xkCCtiil+ +hFaq8yR/N6aBiVZU4vvpJ+feruEK/rZ+zC5pnPiM82QJo6JimU//Hbtas4t+ikYF +bDIfRFbez7G3Mw2y+Qh2PY5K9Hcbh5auSaBGsJf4DSYm03A5nHbrbtwOOPbX/sP8 +/k9BP4E80tqKijlw2gTvvjkPWl/XLijdrubiUo9VclGtUcaLSBe8E6UZGfZw8xJs +UkWxbIyqsUnu -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/may_2018.pem b/net/data/ssl/certificates/may_2018.pem index 2257526..3b275fc 100644 --- a/net/data/ssl/certificates/may_2018.pem +++ b/net/data/ssl/certificates/may_2018.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:bf - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 31 (0x1f) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: May 1 00:00:00 2018 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:a8:20:d7:b5:53:a5:b8:d6:5a:82:8b:5c:96:c6: - 88:55:d4:0d:4b:76:b8:31:9f:c7:55:1b:fb:6c:34: - e8:4e:92:f9:bb:91:54:c8:f6:90:6a:19:c2:d5:2c: - 6c:dd:1c:74:ae:0a:be:80:38:12:54:a9:22:6a:83: - d4:b2:a0:c8:e4:45:88:36:66:b8:6d:5f:b3:26:7c: - 4a:ee:64:77:02:37:fe:2f:4b:af:78:a2:36:d9:2e: - 2b:8a:f5:36:05:83:04:d0:75:0d:65:cc:4b:95:72: - 49:b1:b4:12:9a:a4:e6:b7:98:79:34:8e:75:bd:fa: - cb:f3:02:66:bf:2d:b4:54:cb:ce:e3:f2:53:9d:41: - 31:30:47:28:72:cc:55:de:73:ea:36:c6:45:c5:66: - d2:82:03:cc:de:0e:34:4a:27:dc:31:2d:3d:8c:5f: - dc:98:da:2c:74:c8:86:04:06:ba:dc:99:57:48:c0: - ed:bc:cd:94:34:bd:a2:be:46:b6:e7:8b:c7:04:3d: - 06:27:7e:a5:f2:69:d7:75:6f:8b:0b:29:2c:1c:bd: - 7e:0e:92:34:0c:0f:9b:5f:79:4f:a0:d5:5e:37:b1: - b8:24:ab:d8:b7:59:ea:e0:37:82:bd:b6:79:f1:51: - b3:16:98:6e:92:3c:a5:e6:03:0e:55:36:99:cd:71: - 89:2b + 00:dc:25:f0:b1:e7:f4:9a:33:24:c7:c7:55:bf:9f: + 06:3f:3d:61:ec:6e:38:21:04:87:7b:ea:c9:37:1d: + ad:61:46:3d:0f:43:54:ea:b0:01:45:a8:5f:fc:04: + 44:36:a5:0b:0e:53:49:ad:d4:de:70:b3:0e:9a:42: + 35:17:44:c8:7b:80:6e:a3:1b:3e:16:21:1d:b3:b5: + 08:89:97:ec:83:61:c6:a1:a5:6b:e7:f1:38:96:1b: + d1:db:2d:7e:93:90:3c:07:5b:77:6b:e0:18:63:f3: + ca:42:f1:97:7f:5b:44:9d:c1:65:34:cf:e8:4d:db: + b7:b2:8f:11:f9:0d:99:97:bd:56:24:22:aa:9a:02: + cb:93:e4:b2:55:bf:2d:82:2b:49:4f:2e:69:e2:e9: + a0:a5:18:95:f4:40:90:d7:90:34:cb:ad:a9:d8:a3: + 1b:3c:a9:d9:0b:00:60:6c:43:1f:42:82:07:f0:99: + 4b:d1:a6:66:7a:4e:69:3a:2f:c6:db:20:d0:58:80: + 90:c2:dc:70:ee:22:85:fb:59:bb:25:ba:12:1a:27: + 44:d6:f0:14:1a:71:f7:f9:fc:e5:3e:a5:7d:ad:e3: + 35:9b:c8:61:f5:13:e4:b6:58:e6:8f:46:1f:f4:18: + 69:76:78:eb:f9:ad:75:90:7c:69:dc:89:39:37:d7: + fc:2f Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - C5:B9:ED:68:6D:83:F9:9F:CA:5E:A1:DC:64:A5:0B:55:A3:C1:B4:D2 + FE:66:FC:2C:74:C7:2C:BB:9D:03:C1:68:2F:63:DC:AA:E7:7B:5F:F3 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 3c:43:c3:c6:fd:bf:4d:ed:7c:50:08:cb:ea:18:95:40:6c:32: - 9a:78:fd:90:72:64:6a:2b:95:23:2c:7e:29:6e:fd:ab:e7:22: - 5c:91:ae:cf:6a:89:d7:14:15:d9:da:b9:d1:c7:b9:ae:1b:b8: - 53:0f:aa:58:52:65:ba:24:b7:4b:b6:6e:db:12:3e:44:1f:60: - 06:49:0b:cb:5b:e1:87:4f:13:7e:3a:1f:63:70:0f:38:99:44: - 3a:49:a9:7a:ea:81:ef:94:22:88:21:3a:5b:af:5e:e4:4f:e4: - 57:3b:6c:79:87:1c:53:d6:60:e6:64:77:a5:6b:cf:8b:90:28: - 32:44:7b:6d:c3:01:ac:38:bf:2d:64:63:a5:03:c4:d0:46:8d: - 16:7c:a8:89:e6:10:5e:25:af:a4:1a:3d:8f:08:65:c6:75:f5: - e4:6e:a2:11:62:9a:03:d7:fe:f7:22:c6:c4:da:c7:83:f3:cf: - 93:c5:8c:47:30:79:16:c8:79:ea:02:96:bf:e9:26:03:a9:da: - 54:75:eb:13:85:f4:5e:53:8b:75:d1:cc:c3:22:a3:07:c1:68: - 17:de:a9:90:0c:b1:7e:72:c6:f8:02:9b:a8:d2:33:fa:c4:4e: - eb:8d:a3:49:62:2c:4c:0d:48:a0:7b:a6:98:42:dd:82:33:a8: - 1d:57:b7:32 + 2a:c8:c1:eb:97:c0:a7:01:7e:36:67:9b:8d:fe:ce:7d:30:25: + 7c:63:9b:be:fd:b0:b8:1d:25:ef:bf:f8:3a:58:78:24:08:de: + 37:b9:a9:48:66:8e:b7:db:e3:57:49:7f:f4:09:64:72:45:83: + c2:d2:d7:0b:01:85:cc:4a:d9:1c:bc:0f:88:f2:2e:fa:e6:ee: + 3c:76:b3:f7:5d:ec:57:f1:23:be:54:18:b3:6f:95:56:c6:fe: + 29:ca:85:3f:4d:d8:d5:23:63:8f:fd:68:c0:54:d0:e0:7f:b3: + 2f:36:fb:3b:60:ec:5a:25:2a:88:0b:00:94:a5:c4:13:c6:d0: + da:a6:f2:de:00:aa:ac:11:32:c3:30:ae:52:75:86:91:e5:5c: + 6a:b3:22:8d:2f:31:91:34:d1:2f:e3:59:53:4a:95:b9:17:34: + e7:ab:15:9f:96:a0:61:e7:ad:a2:dc:ac:3b:71:65:3b:e5:a5: + 36:56:69:a3:ce:c5:fc:44:f6:28:85:72:7b:90:0e:c1:df:a5: + 36:0a:3b:d6:76:9c:1d:2c:b7:3f:9a:c0:95:93:e8:31:e7:e4: + 8b:07:67:06:20:44:56:be:a1:1f:9a:aa:24:53:93:3e:f2:0d: + e4:f4:16:47:68:c5:6d:f4:c1:a6:c0:92:97:75:4e:f4:49:77: + 08:24:5e:8a -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqvzANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE4MDUwMTAwMDAwMFoXDTIwMDgwMzAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAKgg17VTpbjWWoKLXJbGiFXUDUt2uDGfx1Ub -+2w06E6S+buRVMj2kGoZwtUsbN0cdK4KvoA4ElSpImqD1LKgyORFiDZmuG1fsyZ8 -Su5kdwI3/i9Lr3iiNtkuK4r1NgWDBNB1DWXMS5VySbG0Epqk5reYeTSOdb36y/MC -Zr8ttFTLzuPyU51BMTBHKHLMVd5z6jbGRcVm0oIDzN4ONEon3DEtPYxf3JjaLHTI -hgQGutyZV0jA7bzNlDS9or5GtueLxwQ9Bid+pfJp13VviwspLBy9fg6SNAwPm195 -T6DVXjexuCSr2LdZ6uA3gr22efFRsxaYbpI8peYDDlU2mc1xiSsCAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFMW57Whtg/mfyl6h3GSlC1WjwbTSMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQA8Q8PG/b9N7XxQCMvqGJVAbDKaeP2QcmRqK5UjLH4pbv2r5yJcka7PaonXFBXZ -2rnRx7muG7hTD6pYUmW6JLdLtm7bEj5EH2AGSQvLW+GHTxN+Oh9jcA84mUQ6Sal6 -6oHvlCKIITpbr17kT+RXO2x5hxxT1mDmZHela8+LkCgyRHttwwGsOL8tZGOlA8TQ -Ro0WfKiJ5hBeJa+kGj2PCGXGdfXkbqIRYpoD1/73IsbE2seD88+TxYxHMHkWyHnq -Apa/6SYDqdpUdesThfReU4t10czDIqMHwWgX3qmQDLF+csb4Apuo0jP6xE7rjaNJ -YixMDUige6aYQt2CM6gdV7cy +MIIDvzCCAqegAwIBAgIBHzANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE4MDUwMTAw +MDAwMFoXDTIwMDgwMzAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBANwl8LHn9JozJMfHVb+fBj89YexuOCEEh3vqyTcdrWFGPQ9DVOqwAUWo +X/wERDalCw5TSa3U3nCzDppCNRdEyHuAbqMbPhYhHbO1CImX7INhxqGla+fxOJYb +0dstfpOQPAdbd2vgGGPzykLxl39bRJ3BZTTP6E3bt7KPEfkNmZe9ViQiqpoCy5Pk +slW/LYIrSU8uaeLpoKUYlfRAkNeQNMutqdijGzyp2QsAYGxDH0KCB/CZS9GmZnpO +aTovxtsg0FiAkMLccO4ihftZuyW6EhonRNbwFBpx9/n85T6lfa3jNZvIYfUT5LZY +5o9GH/QYaXZ46/mtdZB8adyJOTfX/C8CAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFP5m/Cx0xyy7nQPBaC9j3Krne1/zMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQAqyMHrl8CnAX42Z5uN +/s59MCV8Y5u+/bC4HSXvv/g6WHgkCN43ualIZo632+NXSX/0CWRyRYPC0tcLAYXM +StkcvA+I8i765u48drP3XexX8SO+VBizb5VWxv4pyoU/TdjVI2OP/WjAVNDgf7Mv +Nvs7YOxaJSqICwCUpcQTxtDapvLeAKqsETLDMK5SdYaR5VxqsyKNLzGRNNEv41lT +SpW5FzTnqxWflqBh562i3Kw7cWU75aU2VmmjzsX8RPYohXJ7kA7B36U2CjvWdpwd +LLc/msCVk+gx5+SLB2cGIERWvqEfmqokU5M+8g3k9BZHaMVt9MGmwJKXdU70SXcI +JF6K -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/name_constraint_bad.pem b/net/data/ssl/certificates/name_constraint_bad.pem index 96306bc..f311771 100644 --- a/net/data/ssl/certificates/name_constraint_bad.pem +++ b/net/data/ssl/certificates/name_constraint_bad.pem
@@ -1,70 +1,69 @@ -----BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmWNw2JdGmpJMI -zy07hge1zkTHW3/XEaZRmOyCTGwxRaMEVm/Bd9ZsONs82C3SJapHT/Sk844JmDfT -D3H2rClHewiOaKv8fhACZbaGTLAnBGoVI7M6GbgV8zsLHa3Yn0mxcvKvCN/IAqrL -8yotwP0osJfaSqkidMI6C2RlKsn0ZfdGfzypYZZfDCpmw/LH/mmHL3AMG2Y3ksU/ -hUDY5CZFGD/OUyegl34Rh9xK7Cbr/5UOs+ouZkUKqszFgVkuChsOG1lxytOQ72/K -t4yoyoJVuPtK5bopeM7rzY5PnK+FpO8LZF4+fqDg5bCG8xkI+j/6Hkqb/LUWF4gN -OA7Dpl/VAgMBAAECggEAeqgjGDoisMHBOUmqjK1zmfcSd/1b8nWtMZWVLy6yyFIU -teoWVY3Lqdjyr5anksD7IcIvHkIIhcKbxyEoYz7m4TIzSO6dgnxhyaK+R6Dccqiq -oBPG4Bx+xJCpBLVJruUlLZcYoz/j4lM1JVWT0FDxWsN79RYASMvXO32S9ZXrfC1S -YZjVeUrjyrc7Y2Z6z/n89P9mfWUwqOuuH6fHpNHvBugteFB3pS2oclooOh3hXWIu -ZSHWOyX0wj0Rk1iuOBADqxhec/zR4nQ9IZi3nRbfNyoUYzf2qgqPcS9yROS9PZQw -rESmMXpVJ1aF9sFo0LA5KW2sT7qbVWeLwfF8nZvPgQKBgQDdoAdvu5BPTk4E2jg9 -y/VfESKiVd1BStsw5DWBZtgDGDpLHtkoezcao0hJxGKAsnWJ1EqhqViNXEJcECi6 -Xdr5EF525y9KdKCld7q9ZeQbvvg0QLHXYY0bQhPhbymosFg+qdJCHfn8Wwim8Ibc -JnjpzDdzSKEWELanUrSTEla1TQKBgQDAJe6I4CtEXaBXi06KQHnKHI+9uu1w0TBp -YuM2/3v7CVBcN/lkmK/tnM+RZqgEi/Nhy08uIfIQjWetq7FQjbLEsesy3zlqIlth -Kw4jCcdrPW3XTp/Ru7rUQUjBTWpDh/f1T41OzY4qE5X6v2MQkJP5a614Qi2kqFZ3 -neZtpfNwqQKBgASoFR/q3/ham9cMQrxBqdEqigDBLxntGbfoQ5uJbqZ5/tePOV7Z -X+oGXkF2h99OYJvZwwushDjMJHTMvh5UVIKBLorvBpZY5vszDdBm8KkIlSx744C0 -AwP8mnBVJpntwpzmco2DFbqQqxje2uaLRGUdLlkUwJW3Gi9f1H12mC3NAoGBAJOr -00HwfnAhQHxnfKn12WPCRZo8EgV1T65+qD75ZJBO3SqyfgGY8wQ7Uq7dZV1xLVBI -TwcWYZHlCvxHCpPtAqn2TtsfAWIXG4F29HtrJY6+fC9PprYqf/BmaALfez6BPciT -JfedNJgTy10VP45YftDet0fIHIoCMcnmWVSFiK1ZAoGABYToKrxvwdgzqRt22k0D -OcMTSQqpcO/WZfcpFK9leOLuKBNniow1PSYkymdVgCkSjrY3Oksxh/0V20H62oqU -bJMTvYZFpTcCQgcwSiyQD2o2PgKNxrxIfII4/9H8hjV99uXaafEWFky8ea6GEJaN -4PkKpNDj9dus6J2Hzat2c3E= +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC0v9KXM+UTW3dl +vXMadSibR1nmtzDoRjNtWFvaHwr/5OQt8h34iehkLvbDzdejjtf3zefYDhDD51bS +/OXm007i/4JNGGOHsKPe2u8KN3ustbdDzvIHOd8U6cOkQT5+aEc0m3thxBjmE86z +tKbgugPu5OvnqvRtvpdbqgaXUAHQeLjWkrDk4rlDiLWuFGR9UnDUBRwJJdXiT8mo +gttBMcO+RG8L1P2/we7ZYr87j7UAyNHfXUoTrXHkS1/R2XJMg9iTQL9szS9mDgTW +uUMoJMkl/Vlw/j3yqQpOwpvE3p5XXl0WJeZ4tkRJKZ32v3T7hdYN8WVY8ivWjxBJ +yAAtiOItAgMBAAECggEAXuyGumXEnl/g2oueEX0J8FKOgj4e7z0+8OQAiRLYgf9B +XmfTGZ3DcCnB6p8F6p2wCjIW2j64y0mJLZEnZAwBV/F8CuUOEErSJM2x0BnHV7Kv +JmtebDEWWTNTTcX9/gDhtF0bdQK5WMt6OKJdKZRHUITk52u+pov7jWZDw99+tG5w +InCv1RekWbAGZWLs9hyzpOpvp0tGM2O9+XCWQh/LLeLb5rJkTcH8NKv9Xh+tLeSU +i/FER+rQHsMVA4uHdBmRgPsBnPrJopcKWQImRXDGidEd5AUWLIECQdnZI8pbtmjV +0HZj+UuUlDFdALmCHX+NxR4Z+hyi+E96ZWw/J9FHwQKBgQDYX0e873Sf4tDOn0cZ +Olof3cXPri8ezKoeAD8tfY0bxLIoOwDUtJXZeGEZD3sduDJDCdvS1M/eeW04ePlx +kTmcDecaYm4t3KYzbPauudbMQEQFvsoivp8ct/synPcRtGPTHg+GUHaqWT1d4DjT +WClxx67ugD/YQYs5UY/uLjm4tQKBgQDV2lh1Uk3xBj15FZrzg/7GM7bK3L/Xcxzz +VewAksKuVEyoqHfZAo6P/xOiQkwc9kBoet43MiNyph/kYssQowE+Pg+WffB1Ve4F +kVsq6z1mwAfnYD6m4GHxfrV6VxwM3ItiX+PiKQ4YWsbyjc/vC4ZRSarLwbk8Woya +lNucr2hGmQKBgF5sdioFdaewm98Psz9XL61oYsLXCMkwF60v/mIjwEi19emIljw8 +8ogM+JKvJtM5ZvXKf5vqMyyrYPacFH9zGOj5SDlDa0GoYP9gNebaQtqv0P+Q2zV+ +aoFl6MGVrlyTlFy1aaD7zE1a1GT7TNEuUCfPNI/wd+wv7kn9RgpzMc1hAoGBAJrh +5Zkq/+olc9ZDcJMXsSkJgUURdhvrcjdGroOHx1oNEexA/3P7ZxchTa4ByDBdpS5G +drSRKp05dfWqG5o0BI140z9SfRnuH1KHAPlnoHPPdqn7ycSA1E7cT0GI33btMEIS +YvCEfYHkFRzM2qEtvp0W9o1WA/uTNSwrzZaAb8xZAoGAZZLwniPa8zkd+4WAPSN6 +LVj+1dGasfL/zftFhVxu0/KCpdggghG26Ej0ieG71k8Xg9tpZDJvo9Kj0s8Hu4Zu +TnhwwRVyUHls+Gl0t8XXV/ryRLHB8zY45k6A+Yvc/iOYQVmY2rE4kB4PDsrJ+d5P +wA1o1OPvcx28oBjHViWoWJQ= -----END PRIVATE KEY----- Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:c3 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 5 (0x5) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity - Not Before: Mar 17 02:31:57 2020 GMT - Not After : Mar 17 02:31:57 2022 GMT + Not Before: Jun 5 17:10:46 2017 GMT + Not After : Jun 3 17:10:46 2027 GMT Subject: CN=Leaf certificate Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:a6:58:dc:36:25:d1:a6:a4:93:08:cf:2d:3b:86: - 07:b5:ce:44:c7:5b:7f:d7:11:a6:51:98:ec:82:4c: - 6c:31:45:a3:04:56:6f:c1:77:d6:6c:38:db:3c:d8: - 2d:d2:25:aa:47:4f:f4:a4:f3:8e:09:98:37:d3:0f: - 71:f6:ac:29:47:7b:08:8e:68:ab:fc:7e:10:02:65: - b6:86:4c:b0:27:04:6a:15:23:b3:3a:19:b8:15:f3: - 3b:0b:1d:ad:d8:9f:49:b1:72:f2:af:08:df:c8:02: - aa:cb:f3:2a:2d:c0:fd:28:b0:97:da:4a:a9:22:74: - c2:3a:0b:64:65:2a:c9:f4:65:f7:46:7f:3c:a9:61: - 96:5f:0c:2a:66:c3:f2:c7:fe:69:87:2f:70:0c:1b: - 66:37:92:c5:3f:85:40:d8:e4:26:45:18:3f:ce:53: - 27:a0:97:7e:11:87:dc:4a:ec:26:eb:ff:95:0e:b3: - ea:2e:66:45:0a:aa:cc:c5:81:59:2e:0a:1b:0e:1b: - 59:71:ca:d3:90:ef:6f:ca:b7:8c:a8:ca:82:55:b8: - fb:4a:e5:ba:29:78:ce:eb:cd:8e:4f:9c:af:85:a4: - ef:0b:64:5e:3e:7e:a0:e0:e5:b0:86:f3:19:08:fa: - 3f:fa:1e:4a:9b:fc:b5:16:17:88:0d:38:0e:c3:a6: - 5f:d5 + 00:b4:bf:d2:97:33:e5:13:5b:77:65:bd:73:1a:75: + 28:9b:47:59:e6:b7:30:e8:46:33:6d:58:5b:da:1f: + 0a:ff:e4:e4:2d:f2:1d:f8:89:e8:64:2e:f6:c3:cd: + d7:a3:8e:d7:f7:cd:e7:d8:0e:10:c3:e7:56:d2:fc: + e5:e6:d3:4e:e2:ff:82:4d:18:63:87:b0:a3:de:da: + ef:0a:37:7b:ac:b5:b7:43:ce:f2:07:39:df:14:e9: + c3:a4:41:3e:7e:68:47:34:9b:7b:61:c4:18:e6:13: + ce:b3:b4:a6:e0:ba:03:ee:e4:eb:e7:aa:f4:6d:be: + 97:5b:aa:06:97:50:01:d0:78:b8:d6:92:b0:e4:e2: + b9:43:88:b5:ae:14:64:7d:52:70:d4:05:1c:09:25: + d5:e2:4f:c9:a8:82:db:41:31:c3:be:44:6f:0b:d4: + fd:bf:c1:ee:d9:62:bf:3b:8f:b5:00:c8:d1:df:5d: + 4a:13:ad:71:e4:4b:5f:d1:d9:72:4c:83:d8:93:40: + bf:6c:cd:2f:66:0e:04:d6:b9:43:28:24:c9:25:fd: + 59:70:fe:3d:f2:a9:0a:4e:c2:9b:c4:de:9e:57:5e: + 5d:16:25:e6:78:b6:44:49:29:9d:f6:bf:74:fb:85: + d6:0d:f1:65:58:f2:2b:d6:8f:10:49:c8:00:2d:88: + e2:2d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 81:CD:A7:DD:52:43:7F:DF:7A:4B:BA:F5:B0:B6:10:A0:44:0C:EC:6C + E0:DC:E0:2F:07:88:74:3A:9F:D3:30:A3:71:8A:F9:D6:A5:E5:A6:53 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -73,40 +72,40 @@ X509v3 Subject Alternative Name: DNS:test.ExAmPlE.CoM, DNS:test.ExAmPlE.OrG Signature Algorithm: sha256WithRSAEncryption - 5b:ab:26:a5:3c:f7:6c:4a:6b:a1:ea:8d:e3:6a:79:a7:e7:49: - 3d:25:3c:2c:a0:e9:bc:d6:7f:d9:23:fd:a1:43:93:50:18:f3: - 2f:f7:4c:8b:97:e0:2f:cb:ed:7e:15:ce:c1:28:db:e1:a5:1d: - 8d:77:6d:b8:3a:37:2f:ca:9c:83:70:a9:40:ed:8b:81:db:69: - 2a:47:c4:c0:ed:83:aa:5d:fd:99:cf:56:73:a8:db:43:75:db: - ac:46:4a:a3:a7:36:03:43:47:2a:25:5e:22:7a:0d:46:a2:ea: - 77:cb:90:5d:4f:4c:a5:59:42:0d:78:cd:a8:24:f6:2a:ff:f9: - 2a:d6:a3:14:f5:4b:b2:d6:d0:98:4b:4a:47:5a:3a:97:c7:ba: - 02:b3:e1:bc:aa:09:ad:47:d2:38:59:5e:da:0d:af:41:95:f3: - 66:65:48:68:50:bc:b5:d5:9a:26:81:94:d7:5f:df:95:97:79: - e4:ea:e3:4f:82:84:1b:6b:62:8c:3a:1a:0e:ab:84:30:ff:f9: - 22:40:76:d2:31:e5:d7:6d:5d:0d:ba:35:34:ee:51:b9:0e:f5: - e0:9d:f1:c5:c8:2a:a0:8d:06:c5:a3:11:b8:69:a1:6f:c0:18: - eb:d7:28:4a:45:16:8f:d6:e2:cf:06:59:9f:97:60:86:11:a2: - 1b:0d:91:d2 + 92:fd:ff:16:24:68:99:2d:98:cd:7c:63:d8:89:31:a1:5b:51: + 19:85:21:d9:2c:a0:f9:a0:40:5d:e4:a7:c5:8c:9c:fe:cd:1c: + 8d:7e:9d:22:fb:0a:66:dc:6a:3d:e9:7a:3c:b6:51:15:f9:49: + 4b:0b:53:a3:f4:91:0b:f5:0d:78:b5:aa:3b:11:8d:9c:d2:b8: + 34:e2:53:07:49:d0:97:29:62:ca:6b:25:c0:ab:af:8e:a5:7c: + 1d:7f:12:52:12:cc:00:f3:78:f8:dd:0d:a0:96:3b:7f:fd:35: + 69:2c:23:a4:3a:fd:91:3b:c3:57:46:95:d8:a1:07:15:94:22: + 4a:e8:09:ca:ab:3a:e9:81:3a:3a:3d:6d:90:2c:db:4f:ec:a1: + a3:1f:66:20:78:a8:61:55:ac:a8:f2:a5:83:1e:7f:08:98:89: + f2:b6:bd:a4:12:71:bd:8e:89:bf:c1:d5:11:a8:3f:4c:13:7a: + 36:c9:6e:89:bb:d2:20:6d:7c:f2:db:3c:e5:9e:bb:12:7e:52: + 80:fd:d2:0a:71:7a:28:ab:70:76:1c:5d:e7:22:70:1d:cf:5b: + 15:0b:df:2f:46:18:79:01:cb:a4:86:b1:0c:e9:3a:1c:ce:58: + af:b7:ad:24:e4:b7:4e:7e:06:89:b6:47:49:56:9c:a6:c1:d8: + 3a:48:e1:a7 -----BEGIN CERTIFICATE----- -MIIDqDCCApCgAwIBAgIQPiydvrBCyM/8mULVTUFqwzANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTIwMDMxNzAyMzE1N1oXDTIyMDMxNzAyMzE1N1owGzEZMBcGA1UEAwwQ -TGVhZiBjZXJ0aWZpY2F0ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB -AKZY3DYl0aakkwjPLTuGB7XORMdbf9cRplGY7IJMbDFFowRWb8F31mw42zzYLdIl -qkdP9KTzjgmYN9MPcfasKUd7CI5oq/x+EAJltoZMsCcEahUjszoZuBXzOwsdrdif -SbFy8q8I38gCqsvzKi3A/Siwl9pKqSJ0wjoLZGUqyfRl90Z/PKlhll8MKmbD8sf+ -aYcvcAwbZjeSxT+FQNjkJkUYP85TJ6CXfhGH3ErsJuv/lQ6z6i5mRQqqzMWBWS4K -Gw4bWXHK05Dvb8q3jKjKglW4+0rluil4zuvNjk+cr4Wk7wtkXj5+oODlsIbzGQj6 -P/oeSpv8tRYXiA04DsOmX9UCAwEAAaOBnzCBnDAMBgNVHRMBAf8EAjAAMB0GA1Ud -DgQWBBSBzafdUkN/33pLuvWwthCgRAzsbDAfBgNVHSMEGDAWgBSbJguKmKm7Hbkf -HOMaQDPtjheIqzAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwLQYDVR0R -BCYwJIIQdGVzdC5FeEFtUGxFLkNvTYIQdGVzdC5FeEFtUGxFLk9yRzANBgkqhkiG -9w0BAQsFAAOCAQEAW6smpTz3bEproeqN42p5p+dJPSU8LKDpvNZ/2SP9oUOTUBjz -L/dMi5fgL8vtfhXOwSjb4aUdjXdtuDo3L8qcg3CpQO2LgdtpKkfEwO2Dql39mc9W -c6jbQ3XbrEZKo6c2A0NHKiVeInoNRqLqd8uQXU9MpVlCDXjNqCT2Kv/5KtajFPVL -stbQmEtKR1o6l8e6ArPhvKoJrUfSOFle2g2vQZXzZmVIaFC8tdWaJoGU11/flZd5 -5OrjT4KEG2tijDoaDquEMP/5IkB20jHl121dDbo1NO5RuQ714J3xxcgqoI0GxaMR -uGmhb8AY69coSkUWj9bizwZZn5dghhGiGw2R0g== +MIIDmTCCAoGgAwIBAgIBBTANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE3MDYwNTE3 +MTA0NloXDTI3MDYwMzE3MTA0NlowGzEZMBcGA1UEAxMQTGVhZiBjZXJ0aWZpY2F0 +ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALS/0pcz5RNbd2W9cxp1 +KJtHWea3MOhGM21YW9ofCv/k5C3yHfiJ6GQu9sPN16OO1/fN59gOEMPnVtL85ebT +TuL/gk0YY4ewo97a7wo3e6y1t0PO8gc53xTpw6RBPn5oRzSbe2HEGOYTzrO0puC6 +A+7k6+eq9G2+l1uqBpdQAdB4uNaSsOTiuUOIta4UZH1ScNQFHAkl1eJPyaiC20Ex +w75EbwvU/b/B7tlivzuPtQDI0d9dShOtceRLX9HZckyD2JNAv2zNL2YOBNa5Qygk +ySX9WXD+PfKpCk7Cm8TenldeXRYl5ni2REkpnfa/dPuF1g3xZVjyK9aPEEnIAC2I +4i0CAwEAAaOBnzCBnDAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBTg3OAvB4h0Op/T +MKNxivnWpeWmUzAfBgNVHSMEGDAWgBSbJguKmKm7HbkfHOMaQDPtjheIqzAdBgNV +HSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwLQYDVR0RBCYwJIIQdGVzdC5FeEFt +UGxFLkNvTYIQdGVzdC5FeEFtUGxFLk9yRzANBgkqhkiG9w0BAQsFAAOCAQEAkv3/ +FiRomS2YzXxj2IkxoVtRGYUh2Syg+aBAXeSnxYyc/s0cjX6dIvsKZtxqPel6PLZR +FflJSwtTo/SRC/UNeLWqOxGNnNK4NOJTB0nQlyliymslwKuvjqV8HX8SUhLMAPN4 ++N0NoJY7f/01aSwjpDr9kTvDV0aV2KEHFZQiSugJyqs66YE6Oj1tkCzbT+yhox9m +IHioYVWsqPKlgx5/CJiJ8ra9pBJxvY6Jv8HVEag/TBN6NsluibvSIG188ts85Z67 +En5SgP3SCnF6KKtwdhxd5yJwHc9bFQvfL0YYeQHLpIaxDOk6HM5Yr7etJOS3Tn4G +ibZHSVacpsHYOkjhpw== -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/name_constraint_good.pem b/net/data/ssl/certificates/name_constraint_good.pem index a062e800..3aae4c9 100644 --- a/net/data/ssl/certificates/name_constraint_good.pem +++ b/net/data/ssl/certificates/name_constraint_good.pem
@@ -1,70 +1,69 @@ -----BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmWNw2JdGmpJMI -zy07hge1zkTHW3/XEaZRmOyCTGwxRaMEVm/Bd9ZsONs82C3SJapHT/Sk844JmDfT -D3H2rClHewiOaKv8fhACZbaGTLAnBGoVI7M6GbgV8zsLHa3Yn0mxcvKvCN/IAqrL -8yotwP0osJfaSqkidMI6C2RlKsn0ZfdGfzypYZZfDCpmw/LH/mmHL3AMG2Y3ksU/ -hUDY5CZFGD/OUyegl34Rh9xK7Cbr/5UOs+ouZkUKqszFgVkuChsOG1lxytOQ72/K -t4yoyoJVuPtK5bopeM7rzY5PnK+FpO8LZF4+fqDg5bCG8xkI+j/6Hkqb/LUWF4gN -OA7Dpl/VAgMBAAECggEAeqgjGDoisMHBOUmqjK1zmfcSd/1b8nWtMZWVLy6yyFIU -teoWVY3Lqdjyr5anksD7IcIvHkIIhcKbxyEoYz7m4TIzSO6dgnxhyaK+R6Dccqiq -oBPG4Bx+xJCpBLVJruUlLZcYoz/j4lM1JVWT0FDxWsN79RYASMvXO32S9ZXrfC1S -YZjVeUrjyrc7Y2Z6z/n89P9mfWUwqOuuH6fHpNHvBugteFB3pS2oclooOh3hXWIu -ZSHWOyX0wj0Rk1iuOBADqxhec/zR4nQ9IZi3nRbfNyoUYzf2qgqPcS9yROS9PZQw -rESmMXpVJ1aF9sFo0LA5KW2sT7qbVWeLwfF8nZvPgQKBgQDdoAdvu5BPTk4E2jg9 -y/VfESKiVd1BStsw5DWBZtgDGDpLHtkoezcao0hJxGKAsnWJ1EqhqViNXEJcECi6 -Xdr5EF525y9KdKCld7q9ZeQbvvg0QLHXYY0bQhPhbymosFg+qdJCHfn8Wwim8Ibc -JnjpzDdzSKEWELanUrSTEla1TQKBgQDAJe6I4CtEXaBXi06KQHnKHI+9uu1w0TBp -YuM2/3v7CVBcN/lkmK/tnM+RZqgEi/Nhy08uIfIQjWetq7FQjbLEsesy3zlqIlth -Kw4jCcdrPW3XTp/Ru7rUQUjBTWpDh/f1T41OzY4qE5X6v2MQkJP5a614Qi2kqFZ3 -neZtpfNwqQKBgASoFR/q3/ham9cMQrxBqdEqigDBLxntGbfoQ5uJbqZ5/tePOV7Z -X+oGXkF2h99OYJvZwwushDjMJHTMvh5UVIKBLorvBpZY5vszDdBm8KkIlSx744C0 -AwP8mnBVJpntwpzmco2DFbqQqxje2uaLRGUdLlkUwJW3Gi9f1H12mC3NAoGBAJOr -00HwfnAhQHxnfKn12WPCRZo8EgV1T65+qD75ZJBO3SqyfgGY8wQ7Uq7dZV1xLVBI -TwcWYZHlCvxHCpPtAqn2TtsfAWIXG4F29HtrJY6+fC9PprYqf/BmaALfez6BPciT -JfedNJgTy10VP45YftDet0fIHIoCMcnmWVSFiK1ZAoGABYToKrxvwdgzqRt22k0D -OcMTSQqpcO/WZfcpFK9leOLuKBNniow1PSYkymdVgCkSjrY3Oksxh/0V20H62oqU -bJMTvYZFpTcCQgcwSiyQD2o2PgKNxrxIfII4/9H8hjV99uXaafEWFky8ea6GEJaN -4PkKpNDj9dus6J2Hzat2c3E= +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC0v9KXM+UTW3dl +vXMadSibR1nmtzDoRjNtWFvaHwr/5OQt8h34iehkLvbDzdejjtf3zefYDhDD51bS +/OXm007i/4JNGGOHsKPe2u8KN3ustbdDzvIHOd8U6cOkQT5+aEc0m3thxBjmE86z +tKbgugPu5OvnqvRtvpdbqgaXUAHQeLjWkrDk4rlDiLWuFGR9UnDUBRwJJdXiT8mo +gttBMcO+RG8L1P2/we7ZYr87j7UAyNHfXUoTrXHkS1/R2XJMg9iTQL9szS9mDgTW +uUMoJMkl/Vlw/j3yqQpOwpvE3p5XXl0WJeZ4tkRJKZ32v3T7hdYN8WVY8ivWjxBJ +yAAtiOItAgMBAAECggEAXuyGumXEnl/g2oueEX0J8FKOgj4e7z0+8OQAiRLYgf9B +XmfTGZ3DcCnB6p8F6p2wCjIW2j64y0mJLZEnZAwBV/F8CuUOEErSJM2x0BnHV7Kv +JmtebDEWWTNTTcX9/gDhtF0bdQK5WMt6OKJdKZRHUITk52u+pov7jWZDw99+tG5w +InCv1RekWbAGZWLs9hyzpOpvp0tGM2O9+XCWQh/LLeLb5rJkTcH8NKv9Xh+tLeSU +i/FER+rQHsMVA4uHdBmRgPsBnPrJopcKWQImRXDGidEd5AUWLIECQdnZI8pbtmjV +0HZj+UuUlDFdALmCHX+NxR4Z+hyi+E96ZWw/J9FHwQKBgQDYX0e873Sf4tDOn0cZ +Olof3cXPri8ezKoeAD8tfY0bxLIoOwDUtJXZeGEZD3sduDJDCdvS1M/eeW04ePlx +kTmcDecaYm4t3KYzbPauudbMQEQFvsoivp8ct/synPcRtGPTHg+GUHaqWT1d4DjT +WClxx67ugD/YQYs5UY/uLjm4tQKBgQDV2lh1Uk3xBj15FZrzg/7GM7bK3L/Xcxzz +VewAksKuVEyoqHfZAo6P/xOiQkwc9kBoet43MiNyph/kYssQowE+Pg+WffB1Ve4F +kVsq6z1mwAfnYD6m4GHxfrV6VxwM3ItiX+PiKQ4YWsbyjc/vC4ZRSarLwbk8Woya +lNucr2hGmQKBgF5sdioFdaewm98Psz9XL61oYsLXCMkwF60v/mIjwEi19emIljw8 +8ogM+JKvJtM5ZvXKf5vqMyyrYPacFH9zGOj5SDlDa0GoYP9gNebaQtqv0P+Q2zV+ +aoFl6MGVrlyTlFy1aaD7zE1a1GT7TNEuUCfPNI/wd+wv7kn9RgpzMc1hAoGBAJrh +5Zkq/+olc9ZDcJMXsSkJgUURdhvrcjdGroOHx1oNEexA/3P7ZxchTa4ByDBdpS5G +drSRKp05dfWqG5o0BI140z9SfRnuH1KHAPlnoHPPdqn7ycSA1E7cT0GI33btMEIS +YvCEfYHkFRzM2qEtvp0W9o1WA/uTNSwrzZaAb8xZAoGAZZLwniPa8zkd+4WAPSN6 +LVj+1dGasfL/zftFhVxu0/KCpdggghG26Ej0ieG71k8Xg9tpZDJvo9Kj0s8Hu4Zu +TnhwwRVyUHls+Gl0t8XXV/ryRLHB8zY45k6A+Yvc/iOYQVmY2rE4kB4PDsrJ+d5P +wA1o1OPvcx28oBjHViWoWJQ= -----END PRIVATE KEY----- Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:c4 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 6 (0x6) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity - Not Before: Mar 17 02:32:34 2020 GMT - Not After : Mar 17 02:32:34 2022 GMT + Not Before: Jun 5 17:10:46 2017 GMT + Not After : Jun 3 17:10:46 2027 GMT Subject: CN=Leaf Certificate Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:a6:58:dc:36:25:d1:a6:a4:93:08:cf:2d:3b:86: - 07:b5:ce:44:c7:5b:7f:d7:11:a6:51:98:ec:82:4c: - 6c:31:45:a3:04:56:6f:c1:77:d6:6c:38:db:3c:d8: - 2d:d2:25:aa:47:4f:f4:a4:f3:8e:09:98:37:d3:0f: - 71:f6:ac:29:47:7b:08:8e:68:ab:fc:7e:10:02:65: - b6:86:4c:b0:27:04:6a:15:23:b3:3a:19:b8:15:f3: - 3b:0b:1d:ad:d8:9f:49:b1:72:f2:af:08:df:c8:02: - aa:cb:f3:2a:2d:c0:fd:28:b0:97:da:4a:a9:22:74: - c2:3a:0b:64:65:2a:c9:f4:65:f7:46:7f:3c:a9:61: - 96:5f:0c:2a:66:c3:f2:c7:fe:69:87:2f:70:0c:1b: - 66:37:92:c5:3f:85:40:d8:e4:26:45:18:3f:ce:53: - 27:a0:97:7e:11:87:dc:4a:ec:26:eb:ff:95:0e:b3: - ea:2e:66:45:0a:aa:cc:c5:81:59:2e:0a:1b:0e:1b: - 59:71:ca:d3:90:ef:6f:ca:b7:8c:a8:ca:82:55:b8: - fb:4a:e5:ba:29:78:ce:eb:cd:8e:4f:9c:af:85:a4: - ef:0b:64:5e:3e:7e:a0:e0:e5:b0:86:f3:19:08:fa: - 3f:fa:1e:4a:9b:fc:b5:16:17:88:0d:38:0e:c3:a6: - 5f:d5 + 00:b4:bf:d2:97:33:e5:13:5b:77:65:bd:73:1a:75: + 28:9b:47:59:e6:b7:30:e8:46:33:6d:58:5b:da:1f: + 0a:ff:e4:e4:2d:f2:1d:f8:89:e8:64:2e:f6:c3:cd: + d7:a3:8e:d7:f7:cd:e7:d8:0e:10:c3:e7:56:d2:fc: + e5:e6:d3:4e:e2:ff:82:4d:18:63:87:b0:a3:de:da: + ef:0a:37:7b:ac:b5:b7:43:ce:f2:07:39:df:14:e9: + c3:a4:41:3e:7e:68:47:34:9b:7b:61:c4:18:e6:13: + ce:b3:b4:a6:e0:ba:03:ee:e4:eb:e7:aa:f4:6d:be: + 97:5b:aa:06:97:50:01:d0:78:b8:d6:92:b0:e4:e2: + b9:43:88:b5:ae:14:64:7d:52:70:d4:05:1c:09:25: + d5:e2:4f:c9:a8:82:db:41:31:c3:be:44:6f:0b:d4: + fd:bf:c1:ee:d9:62:bf:3b:8f:b5:00:c8:d1:df:5d: + 4a:13:ad:71:e4:4b:5f:d1:d9:72:4c:83:d8:93:40: + bf:6c:cd:2f:66:0e:04:d6:b9:43:28:24:c9:25:fd: + 59:70:fe:3d:f2:a9:0a:4e:c2:9b:c4:de:9e:57:5e: + 5d:16:25:e6:78:b6:44:49:29:9d:f6:bf:74:fb:85: + d6:0d:f1:65:58:f2:2b:d6:8f:10:49:c8:00:2d:88: + e2:2d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 81:CD:A7:DD:52:43:7F:DF:7A:4B:BA:F5:B0:B6:10:A0:44:0C:EC:6C + E0:DC:E0:2F:07:88:74:3A:9F:D3:30:A3:71:8A:F9:D6:A5:E5:A6:53 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -73,41 +72,41 @@ X509v3 Subject Alternative Name: DNS:test.ExAmPlE.CoM, DNS:example.notarealtld, DNS:*.test2.ExAmPlE.CoM, DNS:*.example2.notarealtld Signature Algorithm: sha256WithRSAEncryption - 25:98:e6:42:e1:a2:e1:f6:73:bc:b8:df:62:55:71:46:e1:5d: - 51:d0:87:3f:97:39:55:04:45:6a:d9:ba:54:f6:ab:1d:e4:1f: - 3f:70:bb:58:38:7c:5c:8b:3a:d2:9e:f0:21:a1:e3:a6:1b:8d: - 24:37:d3:d3:9e:e1:0f:70:2a:36:06:96:1b:95:13:25:64:46: - fb:e1:bf:b3:3d:0b:9f:55:8f:01:e1:7c:ba:2b:72:b3:55:48: - fb:50:0b:83:cd:21:2c:a0:9b:f1:de:66:68:e7:42:62:4a:ea: - d3:d0:d5:ff:b1:46:01:50:e1:94:69:ac:db:c4:7b:9d:6c:96: - 18:02:d3:35:14:2b:7e:8d:7d:7d:61:27:12:f0:0a:23:5a:6a: - 86:d7:9a:10:a6:8b:ca:92:24:d9:9b:d0:da:7b:e4:0e:b7:fa: - 84:db:0b:4b:a8:f4:45:5b:f4:84:0b:87:f6:33:3e:4b:1b:ef: - 1b:a7:39:69:b3:f2:c8:54:50:21:7a:5a:d4:82:a3:23:4b:b8: - 74:81:35:60:54:c2:37:f1:ea:79:17:9d:a7:6b:4b:21:73:16: - 5c:08:43:e7:25:94:f9:9a:cd:c5:7f:fa:5f:f0:93:53:59:2b: - ed:83:ef:69:42:51:9a:89:ea:bf:4c:16:f5:f7:b1:b5:d8:1c: - 70:35:9a:3d + 0e:29:bf:01:d0:62:9a:8d:ca:d5:3b:2a:9e:58:06:70:87:61: + 96:bc:0e:82:15:4d:98:82:b6:09:0a:22:91:29:ba:7a:17:78: + 9b:5d:fb:4b:d6:2d:75:4c:bb:75:ea:3f:23:0c:01:43:2c:26: + 75:22:05:cc:ac:36:8b:53:b3:ac:f1:4a:08:f5:da:d4:4a:4c: + 35:ae:10:f2:85:12:0f:60:b0:f3:25:8d:30:04:36:59:3e:66: + c9:dc:f9:36:4f:dc:71:c5:bb:f3:0b:7a:8b:1c:a8:38:45:fb: + cf:46:8c:df:f5:18:92:c0:4f:ac:f3:8c:30:81:a9:05:63:b1: + 2a:64:d9:25:01:61:53:24:09:0e:51:6b:6e:0c:85:03:b4:23: + 95:1e:5a:9c:a9:f3:83:c0:2a:8b:a2:97:03:be:ff:6d:4d:9b: + c4:8a:e2:d8:88:58:d4:73:32:3e:6a:33:69:2c:5d:d7:b5:97: + bb:71:df:5f:1d:d7:1a:8b:e6:00:c8:38:65:f0:ad:24:47:5a: + d3:b5:fd:23:e3:61:8a:89:05:7f:07:95:b3:41:61:41:b0:38: + c8:a8:ef:90:5b:34:00:81:86:13:e1:4d:1f:f7:29:f2:25:4d: + 4d:1b:2b:8e:58:75:c6:54:3b:5f:eb:13:09:56:f0:42:cc:16: + d2:12:d7:e5 -----BEGIN CERTIFICATE----- -MIID2DCCAsCgAwIBAgIQPiydvrBCyM/8mULVTUFqxDANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTIwMDMxNzAyMzIzNFoXDTIyMDMxNzAyMzIzNFowGzEZMBcGA1UEAwwQ -TGVhZiBDZXJ0aWZpY2F0ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB -AKZY3DYl0aakkwjPLTuGB7XORMdbf9cRplGY7IJMbDFFowRWb8F31mw42zzYLdIl -qkdP9KTzjgmYN9MPcfasKUd7CI5oq/x+EAJltoZMsCcEahUjszoZuBXzOwsdrdif -SbFy8q8I38gCqsvzKi3A/Siwl9pKqSJ0wjoLZGUqyfRl90Z/PKlhll8MKmbD8sf+ -aYcvcAwbZjeSxT+FQNjkJkUYP85TJ6CXfhGH3ErsJuv/lQ6z6i5mRQqqzMWBWS4K -Gw4bWXHK05Dvb8q3jKjKglW4+0rluil4zuvNjk+cr4Wk7wtkXj5+oODlsIbzGQj6 -P/oeSpv8tRYXiA04DsOmX9UCAwEAAaOBzzCBzDAMBgNVHRMBAf8EAjAAMB0GA1Ud -DgQWBBSBzafdUkN/33pLuvWwthCgRAzsbDAfBgNVHSMEGDAWgBSbJguKmKm7Hbkf -HOMaQDPtjheIqzAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwXQYDVR0R -BFYwVIIQdGVzdC5FeEFtUGxFLkNvTYITZXhhbXBsZS5ub3RhcmVhbHRsZIITKi50 -ZXN0Mi5FeEFtUGxFLkNvTYIWKi5leGFtcGxlMi5ub3RhcmVhbHRsZDANBgkqhkiG -9w0BAQsFAAOCAQEAJZjmQuGi4fZzvLjfYlVxRuFdUdCHP5c5VQRFatm6VParHeQf -P3C7WDh8XIs60p7wIaHjphuNJDfT057hD3AqNgaWG5UTJWRG++G/sz0Ln1WPAeF8 -uitys1VI+1ALg80hLKCb8d5maOdCYkrq09DV/7FGAVDhlGms28R7nWyWGALTNRQr -fo19fWEnEvAKI1pqhteaEKaLypIk2ZvQ2nvkDrf6hNsLS6j0RVv0hAuH9jM+Sxvv -G6c5abPyyFRQIXpa1IKjI0u4dIE1YFTCN/HqeRedp2tLIXMWXAhD5yWU+ZrNxX/6 -X/CTU1kr7YPvaUJRmonqv0wW9fextdgccDWaPQ== +MIIDyTCCArGgAwIBAgIBBjANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE3MDYwNTE3 +MTA0NloXDTI3MDYwMzE3MTA0NlowGzEZMBcGA1UEAxMQTGVhZiBDZXJ0aWZpY2F0 +ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALS/0pcz5RNbd2W9cxp1 +KJtHWea3MOhGM21YW9ofCv/k5C3yHfiJ6GQu9sPN16OO1/fN59gOEMPnVtL85ebT +TuL/gk0YY4ewo97a7wo3e6y1t0PO8gc53xTpw6RBPn5oRzSbe2HEGOYTzrO0puC6 +A+7k6+eq9G2+l1uqBpdQAdB4uNaSsOTiuUOIta4UZH1ScNQFHAkl1eJPyaiC20Ex +w75EbwvU/b/B7tlivzuPtQDI0d9dShOtceRLX9HZckyD2JNAv2zNL2YOBNa5Qygk +ySX9WXD+PfKpCk7Cm8TenldeXRYl5ni2REkpnfa/dPuF1g3xZVjyK9aPEEnIAC2I +4i0CAwEAAaOBzzCBzDAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBTg3OAvB4h0Op/T +MKNxivnWpeWmUzAfBgNVHSMEGDAWgBSbJguKmKm7HbkfHOMaQDPtjheIqzAdBgNV +HSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwXQYDVR0RBFYwVIIQdGVzdC5FeEFt +UGxFLkNvTYITZXhhbXBsZS5ub3RhcmVhbHRsZIITKi50ZXN0Mi5FeEFtUGxFLkNv +TYIWKi5leGFtcGxlMi5ub3RhcmVhbHRsZDANBgkqhkiG9w0BAQsFAAOCAQEADim/ +AdBimo3K1TsqnlgGcIdhlrwOghVNmIK2CQoikSm6ehd4m137S9YtdUy7deo/IwwB +QywmdSIFzKw2i1OzrPFKCPXa1EpMNa4Q8oUSD2Cw8yWNMAQ2WT5mydz5Nk/cccW7 +8wt6ixyoOEX7z0aM3/UYksBPrPOMMIGpBWOxKmTZJQFhUyQJDlFrbgyFA7QjlR5a +nKnzg8Aqi6KXA77/bU2bxIri2IhY1HMyPmozaSxd17WXu3HfXx3XGovmAMg4ZfCt +JEda07X9I+NhiokFfweVs0FhQbA4yKjvkFs0AIGGE+FNH/cp8iVNTRsrjlh1xlQ7 +X+sTCVbwQswW0hLX5Q== -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/ok_cert.pem b/net/data/ssl/certificates/ok_cert.pem index 23df9d3..a594b8e 100644 --- a/net/data/ssl/certificates/ok_cert.pem +++ b/net/data/ssl/certificates/ok_cert.pem
@@ -1,70 +1,69 @@ -----BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmWNw2JdGmpJMI -zy07hge1zkTHW3/XEaZRmOyCTGwxRaMEVm/Bd9ZsONs82C3SJapHT/Sk844JmDfT -D3H2rClHewiOaKv8fhACZbaGTLAnBGoVI7M6GbgV8zsLHa3Yn0mxcvKvCN/IAqrL -8yotwP0osJfaSqkidMI6C2RlKsn0ZfdGfzypYZZfDCpmw/LH/mmHL3AMG2Y3ksU/ -hUDY5CZFGD/OUyegl34Rh9xK7Cbr/5UOs+ouZkUKqszFgVkuChsOG1lxytOQ72/K -t4yoyoJVuPtK5bopeM7rzY5PnK+FpO8LZF4+fqDg5bCG8xkI+j/6Hkqb/LUWF4gN -OA7Dpl/VAgMBAAECggEAeqgjGDoisMHBOUmqjK1zmfcSd/1b8nWtMZWVLy6yyFIU -teoWVY3Lqdjyr5anksD7IcIvHkIIhcKbxyEoYz7m4TIzSO6dgnxhyaK+R6Dccqiq -oBPG4Bx+xJCpBLVJruUlLZcYoz/j4lM1JVWT0FDxWsN79RYASMvXO32S9ZXrfC1S -YZjVeUrjyrc7Y2Z6z/n89P9mfWUwqOuuH6fHpNHvBugteFB3pS2oclooOh3hXWIu -ZSHWOyX0wj0Rk1iuOBADqxhec/zR4nQ9IZi3nRbfNyoUYzf2qgqPcS9yROS9PZQw -rESmMXpVJ1aF9sFo0LA5KW2sT7qbVWeLwfF8nZvPgQKBgQDdoAdvu5BPTk4E2jg9 -y/VfESKiVd1BStsw5DWBZtgDGDpLHtkoezcao0hJxGKAsnWJ1EqhqViNXEJcECi6 -Xdr5EF525y9KdKCld7q9ZeQbvvg0QLHXYY0bQhPhbymosFg+qdJCHfn8Wwim8Ibc -JnjpzDdzSKEWELanUrSTEla1TQKBgQDAJe6I4CtEXaBXi06KQHnKHI+9uu1w0TBp -YuM2/3v7CVBcN/lkmK/tnM+RZqgEi/Nhy08uIfIQjWetq7FQjbLEsesy3zlqIlth -Kw4jCcdrPW3XTp/Ru7rUQUjBTWpDh/f1T41OzY4qE5X6v2MQkJP5a614Qi2kqFZ3 -neZtpfNwqQKBgASoFR/q3/ham9cMQrxBqdEqigDBLxntGbfoQ5uJbqZ5/tePOV7Z -X+oGXkF2h99OYJvZwwushDjMJHTMvh5UVIKBLorvBpZY5vszDdBm8KkIlSx744C0 -AwP8mnBVJpntwpzmco2DFbqQqxje2uaLRGUdLlkUwJW3Gi9f1H12mC3NAoGBAJOr -00HwfnAhQHxnfKn12WPCRZo8EgV1T65+qD75ZJBO3SqyfgGY8wQ7Uq7dZV1xLVBI -TwcWYZHlCvxHCpPtAqn2TtsfAWIXG4F29HtrJY6+fC9PprYqf/BmaALfez6BPciT -JfedNJgTy10VP45YftDet0fIHIoCMcnmWVSFiK1ZAoGABYToKrxvwdgzqRt22k0D -OcMTSQqpcO/WZfcpFK9leOLuKBNniow1PSYkymdVgCkSjrY3Oksxh/0V20H62oqU -bJMTvYZFpTcCQgcwSiyQD2o2PgKNxrxIfII4/9H8hjV99uXaafEWFky8ea6GEJaN -4PkKpNDj9dus6J2Hzat2c3E= +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC0v9KXM+UTW3dl +vXMadSibR1nmtzDoRjNtWFvaHwr/5OQt8h34iehkLvbDzdejjtf3zefYDhDD51bS +/OXm007i/4JNGGOHsKPe2u8KN3ustbdDzvIHOd8U6cOkQT5+aEc0m3thxBjmE86z +tKbgugPu5OvnqvRtvpdbqgaXUAHQeLjWkrDk4rlDiLWuFGR9UnDUBRwJJdXiT8mo +gttBMcO+RG8L1P2/we7ZYr87j7UAyNHfXUoTrXHkS1/R2XJMg9iTQL9szS9mDgTW +uUMoJMkl/Vlw/j3yqQpOwpvE3p5XXl0WJeZ4tkRJKZ32v3T7hdYN8WVY8ivWjxBJ +yAAtiOItAgMBAAECggEAXuyGumXEnl/g2oueEX0J8FKOgj4e7z0+8OQAiRLYgf9B +XmfTGZ3DcCnB6p8F6p2wCjIW2j64y0mJLZEnZAwBV/F8CuUOEErSJM2x0BnHV7Kv +JmtebDEWWTNTTcX9/gDhtF0bdQK5WMt6OKJdKZRHUITk52u+pov7jWZDw99+tG5w +InCv1RekWbAGZWLs9hyzpOpvp0tGM2O9+XCWQh/LLeLb5rJkTcH8NKv9Xh+tLeSU +i/FER+rQHsMVA4uHdBmRgPsBnPrJopcKWQImRXDGidEd5AUWLIECQdnZI8pbtmjV +0HZj+UuUlDFdALmCHX+NxR4Z+hyi+E96ZWw/J9FHwQKBgQDYX0e873Sf4tDOn0cZ +Olof3cXPri8ezKoeAD8tfY0bxLIoOwDUtJXZeGEZD3sduDJDCdvS1M/eeW04ePlx +kTmcDecaYm4t3KYzbPauudbMQEQFvsoivp8ct/synPcRtGPTHg+GUHaqWT1d4DjT +WClxx67ugD/YQYs5UY/uLjm4tQKBgQDV2lh1Uk3xBj15FZrzg/7GM7bK3L/Xcxzz +VewAksKuVEyoqHfZAo6P/xOiQkwc9kBoet43MiNyph/kYssQowE+Pg+WffB1Ve4F +kVsq6z1mwAfnYD6m4GHxfrV6VxwM3ItiX+PiKQ4YWsbyjc/vC4ZRSarLwbk8Woya +lNucr2hGmQKBgF5sdioFdaewm98Psz9XL61oYsLXCMkwF60v/mIjwEi19emIljw8 +8ogM+JKvJtM5ZvXKf5vqMyyrYPacFH9zGOj5SDlDa0GoYP9gNebaQtqv0P+Q2zV+ +aoFl6MGVrlyTlFy1aaD7zE1a1GT7TNEuUCfPNI/wd+wv7kn9RgpzMc1hAoGBAJrh +5Zkq/+olc9ZDcJMXsSkJgUURdhvrcjdGroOHx1oNEexA/3P7ZxchTa4ByDBdpS5G +drSRKp05dfWqG5o0BI140z9SfRnuH1KHAPlnoHPPdqn7ycSA1E7cT0GI33btMEIS +YvCEfYHkFRzM2qEtvp0W9o1WA/uTNSwrzZaAb8xZAoGAZZLwniPa8zkd+4WAPSN6 +LVj+1dGasfL/zftFhVxu0/KCpdggghG26Ej0ieG71k8Xg9tpZDJvo9Kj0s8Hu4Zu +TnhwwRVyUHls+Gl0t8XXV/ryRLHB8zY45k6A+Yvc/iOYQVmY2rE4kB4PDsrJ+d5P +wA1o1OPvcx28oBjHViWoWJQ= -----END PRIVATE KEY----- Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:a4 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 3 (0x3) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity - Not Before: Mar 13 20:46:17 2020 GMT - Not After : Mar 13 20:46:17 2022 GMT + Not Before: Jun 5 17:10:46 2017 GMT + Not After : Jun 3 17:10:46 2027 GMT Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:a6:58:dc:36:25:d1:a6:a4:93:08:cf:2d:3b:86: - 07:b5:ce:44:c7:5b:7f:d7:11:a6:51:98:ec:82:4c: - 6c:31:45:a3:04:56:6f:c1:77:d6:6c:38:db:3c:d8: - 2d:d2:25:aa:47:4f:f4:a4:f3:8e:09:98:37:d3:0f: - 71:f6:ac:29:47:7b:08:8e:68:ab:fc:7e:10:02:65: - b6:86:4c:b0:27:04:6a:15:23:b3:3a:19:b8:15:f3: - 3b:0b:1d:ad:d8:9f:49:b1:72:f2:af:08:df:c8:02: - aa:cb:f3:2a:2d:c0:fd:28:b0:97:da:4a:a9:22:74: - c2:3a:0b:64:65:2a:c9:f4:65:f7:46:7f:3c:a9:61: - 96:5f:0c:2a:66:c3:f2:c7:fe:69:87:2f:70:0c:1b: - 66:37:92:c5:3f:85:40:d8:e4:26:45:18:3f:ce:53: - 27:a0:97:7e:11:87:dc:4a:ec:26:eb:ff:95:0e:b3: - ea:2e:66:45:0a:aa:cc:c5:81:59:2e:0a:1b:0e:1b: - 59:71:ca:d3:90:ef:6f:ca:b7:8c:a8:ca:82:55:b8: - fb:4a:e5:ba:29:78:ce:eb:cd:8e:4f:9c:af:85:a4: - ef:0b:64:5e:3e:7e:a0:e0:e5:b0:86:f3:19:08:fa: - 3f:fa:1e:4a:9b:fc:b5:16:17:88:0d:38:0e:c3:a6: - 5f:d5 + 00:b4:bf:d2:97:33:e5:13:5b:77:65:bd:73:1a:75: + 28:9b:47:59:e6:b7:30:e8:46:33:6d:58:5b:da:1f: + 0a:ff:e4:e4:2d:f2:1d:f8:89:e8:64:2e:f6:c3:cd: + d7:a3:8e:d7:f7:cd:e7:d8:0e:10:c3:e7:56:d2:fc: + e5:e6:d3:4e:e2:ff:82:4d:18:63:87:b0:a3:de:da: + ef:0a:37:7b:ac:b5:b7:43:ce:f2:07:39:df:14:e9: + c3:a4:41:3e:7e:68:47:34:9b:7b:61:c4:18:e6:13: + ce:b3:b4:a6:e0:ba:03:ee:e4:eb:e7:aa:f4:6d:be: + 97:5b:aa:06:97:50:01:d0:78:b8:d6:92:b0:e4:e2: + b9:43:88:b5:ae:14:64:7d:52:70:d4:05:1c:09:25: + d5:e2:4f:c9:a8:82:db:41:31:c3:be:44:6f:0b:d4: + fd:bf:c1:ee:d9:62:bf:3b:8f:b5:00:c8:d1:df:5d: + 4a:13:ad:71:e4:4b:5f:d1:d9:72:4c:83:d8:93:40: + bf:6c:cd:2f:66:0e:04:d6:b9:43:28:24:c9:25:fd: + 59:70:fe:3d:f2:a9:0a:4e:c2:9b:c4:de:9e:57:5e: + 5d:16:25:e6:78:b6:44:49:29:9d:f6:bf:74:fb:85: + d6:0d:f1:65:58:f2:2b:d6:8f:10:49:c8:00:2d:88: + e2:2d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 81:CD:A7:DD:52:43:7F:DF:7A:4B:BA:F5:B0:B6:10:A0:44:0C:EC:6C + E0:DC:E0:2F:07:88:74:3A:9F:D3:30:A3:71:8A:F9:D6:A5:E5:A6:53 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -73,41 +72,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 4d:09:77:89:44:9c:ce:11:6a:a6:e3:4d:9f:1d:ea:0b:55:bb: - 39:19:90:ec:1e:f7:4e:5d:39:ac:b8:b8:3d:1a:7a:64:53:5a: - 0f:c6:c3:fc:16:2c:a1:f9:2a:51:55:65:07:87:98:ea:3d:c9: - 4f:9e:0c:d2:18:1f:08:26:78:f0:e0:dc:10:dd:66:f5:4a:83: - 66:5c:f9:7f:57:e3:d3:30:9b:91:f9:1b:ad:58:4e:88:e9:f6: - b9:11:f7:cf:9a:f6:6a:63:87:84:3c:7d:93:f9:06:51:83:d1: - be:d6:90:1b:b0:67:8c:c5:93:61:20:f7:91:c0:50:4a:e9:87: - a0:6b:8f:f7:99:f2:2e:81:cd:41:8a:24:f7:f7:a2:cf:20:79: - 44:7a:8b:7c:06:df:09:93:9b:29:0a:66:7d:72:cd:ad:3c:d7: - 31:66:c6:84:6c:01:20:ca:f4:b2:5a:f6:2f:e8:8f:9c:9c:92: - 58:1a:3f:4a:59:d4:e8:0f:c1:84:b4:a9:be:89:a3:7f:0b:2a: - b4:b2:00:8a:7a:49:44:92:5b:cb:1b:2d:f7:e6:2a:9a:a9:a5: - 0f:18:d8:71:1a:1d:2a:94:26:6c:40:db:2e:11:51:d9:c7:13: - a4:4a:31:65:1b:6a:5d:d2:8d:3a:de:58:3c:08:f9:be:be:95: - 34:70:a3:07 + 7a:14:44:2e:50:34:5c:0b:98:e4:5f:76:99:ba:e4:de:64:4a: + 8c:54:be:c9:5e:0b:e0:16:ac:d7:b0:f6:fc:cc:87:66:c6:bf: + ed:10:37:f0:5f:1d:aa:0d:fd:83:a7:1b:6c:ec:5a:b8:be:a5: + 30:8a:62:b8:a9:5d:ca:ee:17:8b:9d:65:76:f8:50:6f:57:57: + 9e:49:f6:7b:01:08:fe:49:44:64:76:5c:a8:e3:6a:f8:d7:eb: + 75:dd:05:1f:f9:9d:1f:b5:1f:76:eb:a2:d2:58:b2:ab:ba:47: + 88:33:19:3b:de:13:a4:9b:fb:bc:7a:78:53:77:4d:1d:cb:f1: + 4d:f5:d3:85:04:51:ec:79:53:2c:a5:63:71:22:47:51:20:b8: + 0e:9a:2c:9f:40:d4:60:c4:d6:1d:39:fd:1e:11:f1:0b:47:c1: + e7:e9:68:d9:f3:00:1b:bc:ee:29:ed:14:eb:ce:ed:5c:fd:16: + 74:33:e3:4b:90:80:f9:e8:1a:db:97:bd:06:0b:68:79:eb:cd: + 4b:3f:00:0e:69:9e:ff:99:64:39:91:e9:12:c8:98:e6:2d:f1: + 75:d9:bf:a1:f5:15:40:b7:93:2b:5d:98:24:da:f3:6e:8e:cb: + 20:19:fe:27:6d:68:78:29:9c:90:ea:aa:ec:ef:bf:19:74:32: + e6:c9:f5:27 -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqpDANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTIwMDMxMzIwNDYxN1oXDTIyMDMxMzIwNDYxN1owYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAKZY3DYl0aakkwjPLTuGB7XORMdbf9cRplGY -7IJMbDFFowRWb8F31mw42zzYLdIlqkdP9KTzjgmYN9MPcfasKUd7CI5oq/x+EAJl -toZMsCcEahUjszoZuBXzOwsdrdifSbFy8q8I38gCqsvzKi3A/Siwl9pKqSJ0wjoL -ZGUqyfRl90Z/PKlhll8MKmbD8sf+aYcvcAwbZjeSxT+FQNjkJkUYP85TJ6CXfhGH -3ErsJuv/lQ6z6i5mRQqqzMWBWS4KGw4bWXHK05Dvb8q3jKjKglW4+0rluil4zuvN -jk+cr4Wk7wtkXj5+oODlsIbzGQj6P/oeSpv8tRYXiA04DsOmX9UCAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFIHNp91SQ3/feku69bC2EKBEDOxsMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQBNCXeJRJzOEWqm402fHeoLVbs5GZDsHvdOXTmsuLg9GnpkU1oPxsP8Fiyh+SpR -VWUHh5jqPclPngzSGB8IJnjw4NwQ3Wb1SoNmXPl/V+PTMJuR+RutWE6I6fa5EffP -mvZqY4eEPH2T+QZRg9G+1pAbsGeMxZNhIPeRwFBK6Yega4/3mfIugc1BiiT396LP -IHlEeot8Bt8Jk5spCmZ9cs2tPNcxZsaEbAEgyvSyWvYv6I+cnJJYGj9KWdToD8GE -tKm+iaN/Cyq0sgCKeklEklvLGy335iqaqaUPGNhxGh0qlCZsQNsuEVHZxxOkSjFl -G2pd0o063lg8CPm+vpU0cKMH +MIIDvzCCAqegAwIBAgIBAzANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE3MDYwNTE3 +MTA0NloXDTI3MDYwMzE3MTA0NlowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBALS/0pcz5RNbd2W9cxp1KJtHWea3MOhGM21YW9ofCv/k5C3yHfiJ6GQu +9sPN16OO1/fN59gOEMPnVtL85ebTTuL/gk0YY4ewo97a7wo3e6y1t0PO8gc53xTp +w6RBPn5oRzSbe2HEGOYTzrO0puC6A+7k6+eq9G2+l1uqBpdQAdB4uNaSsOTiuUOI +ta4UZH1ScNQFHAkl1eJPyaiC20Exw75EbwvU/b/B7tlivzuPtQDI0d9dShOtceRL +X9HZckyD2JNAv2zNL2YOBNa5QygkySX9WXD+PfKpCk7Cm8TenldeXRYl5ni2REkp +nfa/dPuF1g3xZVjyK9aPEEnIAC2I4i0CAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFODc4C8HiHQ6n9Mwo3GK+dal5aZTMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQB6FEQuUDRcC5jkX3aZ +uuTeZEqMVL7JXgvgFqzXsPb8zIdmxr/tEDfwXx2qDf2Dpxts7Fq4vqUwimK4qV3K +7heLnWV2+FBvV1eeSfZ7AQj+SURkdlyo42r41+t13QUf+Z0ftR9266LSWLKrukeI +Mxk73hOkm/u8enhTd00dy/FN9dOFBFHseVMspWNxIkdRILgOmiyfQNRgxNYdOf0e +EfELR8Hn6WjZ8wAbvO4p7RTrzu1c/RZ0M+NLkID56Brbl70GC2h5681LPwAOaZ7/ +mWQ5kekSyJjmLfF12b+h9RVAt5MrXZgk2vNujssgGf4nbWh4KZyQ6qrs778ZdDLm +yfUn -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/ok_cert_by_intermediate.pem b/net/data/ssl/certificates/ok_cert_by_intermediate.pem index 2cdbda2..5cd3cc1 100644 --- a/net/data/ssl/certificates/ok_cert_by_intermediate.pem +++ b/net/data/ssl/certificates/ok_cert_by_intermediate.pem
@@ -1,70 +1,69 @@ -----BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmWNw2JdGmpJMI -zy07hge1zkTHW3/XEaZRmOyCTGwxRaMEVm/Bd9ZsONs82C3SJapHT/Sk844JmDfT -D3H2rClHewiOaKv8fhACZbaGTLAnBGoVI7M6GbgV8zsLHa3Yn0mxcvKvCN/IAqrL -8yotwP0osJfaSqkidMI6C2RlKsn0ZfdGfzypYZZfDCpmw/LH/mmHL3AMG2Y3ksU/ -hUDY5CZFGD/OUyegl34Rh9xK7Cbr/5UOs+ouZkUKqszFgVkuChsOG1lxytOQ72/K -t4yoyoJVuPtK5bopeM7rzY5PnK+FpO8LZF4+fqDg5bCG8xkI+j/6Hkqb/LUWF4gN -OA7Dpl/VAgMBAAECggEAeqgjGDoisMHBOUmqjK1zmfcSd/1b8nWtMZWVLy6yyFIU -teoWVY3Lqdjyr5anksD7IcIvHkIIhcKbxyEoYz7m4TIzSO6dgnxhyaK+R6Dccqiq -oBPG4Bx+xJCpBLVJruUlLZcYoz/j4lM1JVWT0FDxWsN79RYASMvXO32S9ZXrfC1S -YZjVeUrjyrc7Y2Z6z/n89P9mfWUwqOuuH6fHpNHvBugteFB3pS2oclooOh3hXWIu -ZSHWOyX0wj0Rk1iuOBADqxhec/zR4nQ9IZi3nRbfNyoUYzf2qgqPcS9yROS9PZQw -rESmMXpVJ1aF9sFo0LA5KW2sT7qbVWeLwfF8nZvPgQKBgQDdoAdvu5BPTk4E2jg9 -y/VfESKiVd1BStsw5DWBZtgDGDpLHtkoezcao0hJxGKAsnWJ1EqhqViNXEJcECi6 -Xdr5EF525y9KdKCld7q9ZeQbvvg0QLHXYY0bQhPhbymosFg+qdJCHfn8Wwim8Ibc -JnjpzDdzSKEWELanUrSTEla1TQKBgQDAJe6I4CtEXaBXi06KQHnKHI+9uu1w0TBp -YuM2/3v7CVBcN/lkmK/tnM+RZqgEi/Nhy08uIfIQjWetq7FQjbLEsesy3zlqIlth -Kw4jCcdrPW3XTp/Ru7rUQUjBTWpDh/f1T41OzY4qE5X6v2MQkJP5a614Qi2kqFZ3 -neZtpfNwqQKBgASoFR/q3/ham9cMQrxBqdEqigDBLxntGbfoQ5uJbqZ5/tePOV7Z -X+oGXkF2h99OYJvZwwushDjMJHTMvh5UVIKBLorvBpZY5vszDdBm8KkIlSx744C0 -AwP8mnBVJpntwpzmco2DFbqQqxje2uaLRGUdLlkUwJW3Gi9f1H12mC3NAoGBAJOr -00HwfnAhQHxnfKn12WPCRZo8EgV1T65+qD75ZJBO3SqyfgGY8wQ7Uq7dZV1xLVBI -TwcWYZHlCvxHCpPtAqn2TtsfAWIXG4F29HtrJY6+fC9PprYqf/BmaALfez6BPciT -JfedNJgTy10VP45YftDet0fIHIoCMcnmWVSFiK1ZAoGABYToKrxvwdgzqRt22k0D -OcMTSQqpcO/WZfcpFK9leOLuKBNniow1PSYkymdVgCkSjrY3Oksxh/0V20H62oqU -bJMTvYZFpTcCQgcwSiyQD2o2PgKNxrxIfII4/9H8hjV99uXaafEWFky8ea6GEJaN -4PkKpNDj9dus6J2Hzat2c3E= +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC0v9KXM+UTW3dl +vXMadSibR1nmtzDoRjNtWFvaHwr/5OQt8h34iehkLvbDzdejjtf3zefYDhDD51bS +/OXm007i/4JNGGOHsKPe2u8KN3ustbdDzvIHOd8U6cOkQT5+aEc0m3thxBjmE86z +tKbgugPu5OvnqvRtvpdbqgaXUAHQeLjWkrDk4rlDiLWuFGR9UnDUBRwJJdXiT8mo +gttBMcO+RG8L1P2/we7ZYr87j7UAyNHfXUoTrXHkS1/R2XJMg9iTQL9szS9mDgTW +uUMoJMkl/Vlw/j3yqQpOwpvE3p5XXl0WJeZ4tkRJKZ32v3T7hdYN8WVY8ivWjxBJ +yAAtiOItAgMBAAECggEAXuyGumXEnl/g2oueEX0J8FKOgj4e7z0+8OQAiRLYgf9B +XmfTGZ3DcCnB6p8F6p2wCjIW2j64y0mJLZEnZAwBV/F8CuUOEErSJM2x0BnHV7Kv +JmtebDEWWTNTTcX9/gDhtF0bdQK5WMt6OKJdKZRHUITk52u+pov7jWZDw99+tG5w +InCv1RekWbAGZWLs9hyzpOpvp0tGM2O9+XCWQh/LLeLb5rJkTcH8NKv9Xh+tLeSU +i/FER+rQHsMVA4uHdBmRgPsBnPrJopcKWQImRXDGidEd5AUWLIECQdnZI8pbtmjV +0HZj+UuUlDFdALmCHX+NxR4Z+hyi+E96ZWw/J9FHwQKBgQDYX0e873Sf4tDOn0cZ +Olof3cXPri8ezKoeAD8tfY0bxLIoOwDUtJXZeGEZD3sduDJDCdvS1M/eeW04ePlx +kTmcDecaYm4t3KYzbPauudbMQEQFvsoivp8ct/synPcRtGPTHg+GUHaqWT1d4DjT +WClxx67ugD/YQYs5UY/uLjm4tQKBgQDV2lh1Uk3xBj15FZrzg/7GM7bK3L/Xcxzz +VewAksKuVEyoqHfZAo6P/xOiQkwc9kBoet43MiNyph/kYssQowE+Pg+WffB1Ve4F +kVsq6z1mwAfnYD6m4GHxfrV6VxwM3ItiX+PiKQ4YWsbyjc/vC4ZRSarLwbk8Woya +lNucr2hGmQKBgF5sdioFdaewm98Psz9XL61oYsLXCMkwF60v/mIjwEi19emIljw8 +8ogM+JKvJtM5ZvXKf5vqMyyrYPacFH9zGOj5SDlDa0GoYP9gNebaQtqv0P+Q2zV+ +aoFl6MGVrlyTlFy1aaD7zE1a1GT7TNEuUCfPNI/wd+wv7kn9RgpzMc1hAoGBAJrh +5Zkq/+olc9ZDcJMXsSkJgUURdhvrcjdGroOHx1oNEexA/3P7ZxchTa4ByDBdpS5G +drSRKp05dfWqG5o0BI140z9SfRnuH1KHAPlnoHPPdqn7ycSA1E7cT0GI33btMEIS +YvCEfYHkFRzM2qEtvp0W9o1WA/uTNSwrzZaAb8xZAoGAZZLwniPa8zkd+4WAPSN6 +LVj+1dGasfL/zftFhVxu0/KCpdggghG26Ej0ieG71k8Xg9tpZDJvo9Kj0s8Hu4Zu +TnhwwRVyUHls+Gl0t8XXV/ryRLHB8zY45k6A+Yvc/iOYQVmY2rE4kB4PDsrJ+d5P +wA1o1OPvcx28oBjHViWoWJQ= -----END PRIVATE KEY----- Certificate: Data: Version: 3 (0x2) - Serial Number: - db:15:0b:57:64:f6:dc:4a:c0:6e:e7:ea:5d:c9:c5:cd - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 1 (0x1) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Intermediate CA Validity - Not Before: Mar 13 20:46:17 2020 GMT - Not After : Mar 13 20:46:17 2022 GMT + Not Before: Jun 5 17:10:46 2017 GMT + Not After : Jun 3 17:10:46 2027 GMT Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:a6:58:dc:36:25:d1:a6:a4:93:08:cf:2d:3b:86: - 07:b5:ce:44:c7:5b:7f:d7:11:a6:51:98:ec:82:4c: - 6c:31:45:a3:04:56:6f:c1:77:d6:6c:38:db:3c:d8: - 2d:d2:25:aa:47:4f:f4:a4:f3:8e:09:98:37:d3:0f: - 71:f6:ac:29:47:7b:08:8e:68:ab:fc:7e:10:02:65: - b6:86:4c:b0:27:04:6a:15:23:b3:3a:19:b8:15:f3: - 3b:0b:1d:ad:d8:9f:49:b1:72:f2:af:08:df:c8:02: - aa:cb:f3:2a:2d:c0:fd:28:b0:97:da:4a:a9:22:74: - c2:3a:0b:64:65:2a:c9:f4:65:f7:46:7f:3c:a9:61: - 96:5f:0c:2a:66:c3:f2:c7:fe:69:87:2f:70:0c:1b: - 66:37:92:c5:3f:85:40:d8:e4:26:45:18:3f:ce:53: - 27:a0:97:7e:11:87:dc:4a:ec:26:eb:ff:95:0e:b3: - ea:2e:66:45:0a:aa:cc:c5:81:59:2e:0a:1b:0e:1b: - 59:71:ca:d3:90:ef:6f:ca:b7:8c:a8:ca:82:55:b8: - fb:4a:e5:ba:29:78:ce:eb:cd:8e:4f:9c:af:85:a4: - ef:0b:64:5e:3e:7e:a0:e0:e5:b0:86:f3:19:08:fa: - 3f:fa:1e:4a:9b:fc:b5:16:17:88:0d:38:0e:c3:a6: - 5f:d5 + 00:b4:bf:d2:97:33:e5:13:5b:77:65:bd:73:1a:75: + 28:9b:47:59:e6:b7:30:e8:46:33:6d:58:5b:da:1f: + 0a:ff:e4:e4:2d:f2:1d:f8:89:e8:64:2e:f6:c3:cd: + d7:a3:8e:d7:f7:cd:e7:d8:0e:10:c3:e7:56:d2:fc: + e5:e6:d3:4e:e2:ff:82:4d:18:63:87:b0:a3:de:da: + ef:0a:37:7b:ac:b5:b7:43:ce:f2:07:39:df:14:e9: + c3:a4:41:3e:7e:68:47:34:9b:7b:61:c4:18:e6:13: + ce:b3:b4:a6:e0:ba:03:ee:e4:eb:e7:aa:f4:6d:be: + 97:5b:aa:06:97:50:01:d0:78:b8:d6:92:b0:e4:e2: + b9:43:88:b5:ae:14:64:7d:52:70:d4:05:1c:09:25: + d5:e2:4f:c9:a8:82:db:41:31:c3:be:44:6f:0b:d4: + fd:bf:c1:ee:d9:62:bf:3b:8f:b5:00:c8:d1:df:5d: + 4a:13:ad:71:e4:4b:5f:d1:d9:72:4c:83:d8:93:40: + bf:6c:cd:2f:66:0e:04:d6:b9:43:28:24:c9:25:fd: + 59:70:fe:3d:f2:a9:0a:4e:c2:9b:c4:de:9e:57:5e: + 5d:16:25:e6:78:b6:44:49:29:9d:f6:bf:74:fb:85: + d6:0d:f1:65:58:f2:2b:d6:8f:10:49:c8:00:2d:88: + e2:2d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 81:CD:A7:DD:52:43:7F:DF:7A:4B:BA:F5:B0:B6:10:A0:44:0C:EC:6C + E0:DC:E0:2F:07:88:74:3A:9F:D3:30:A3:71:8A:F9:D6:A5:E5:A6:53 X509v3 Authority Key Identifier: keyid:17:5C:45:F3:D0:AC:1C:10:4C:8B:43:44:20:C4:DD:93:C5:C5:19:3B @@ -73,58 +72,57 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 80:2c:94:86:a4:69:32:38:0e:41:73:db:0a:42:e9:1c:05:81: - fa:80:cc:c2:c3:2b:3d:7e:46:b1:19:32:ff:97:fe:fc:be:c2: - 32:7c:e2:db:fe:27:0a:75:26:6a:b8:6f:9f:0f:37:0c:bc:02: - 2d:6c:04:63:4a:45:50:75:b7:3e:90:49:85:50:3d:85:52:57: - 1d:2e:d5:b9:75:c1:84:56:9a:cb:92:e8:9b:28:38:bd:20:c5: - 6d:8c:53:70:37:9a:f5:64:5e:d5:11:e4:28:6b:08:9c:8b:0f: - 2a:f7:a1:59:00:15:58:6b:11:91:11:27:c3:6e:e2:54:52:f7: - fe:e6:3d:27:d5:0f:b6:91:ab:39:12:9d:c5:dc:f3:02:e4:87: - 48:c7:e8:93:c0:85:69:5c:97:8b:d8:5f:bf:d4:a1:f2:c4:5a: - 69:88:b0:3c:75:86:30:09:b4:84:0a:17:56:2c:6f:d4:c6:10: - f9:23:1c:5e:77:8c:29:5c:db:41:36:33:c7:3a:00:85:f9:a0: - f5:e3:71:9a:55:b7:0b:45:45:30:07:a7:78:6f:b2:2b:4e:e5: - 84:2f:bc:49:d7:80:07:ed:d1:44:c8:c3:5a:ec:3c:65:05:a0: - 78:e3:a3:8b:1c:b2:2e:b0:64:f5:9e:7b:08:8d:bd:4a:07:4f: - 29:50:74:e8 + 43:f7:63:38:a3:30:3f:ab:e6:6c:42:a1:dd:ff:8d:f6:ad:b2: + eb:b6:9e:4b:bd:90:fc:d8:f4:f0:5a:42:fc:be:5b:cc:c7:24: + 2f:91:48:a6:a1:bb:a2:b7:19:61:21:ac:d3:81:ee:6e:bb:04: + 2d:16:b5:7e:cb:e6:a3:17:8f:3e:65:4d:1d:8d:c1:da:3d:3b: + ad:a1:b3:e8:f5:e3:16:13:17:0a:a3:45:e0:cf:84:b2:3d:e8: + 38:69:31:46:e8:8c:10:63:0f:5e:6b:f4:10:25:23:98:b8:5c: + d9:06:78:83:18:70:09:a6:ef:8f:e9:f5:ff:b3:44:85:35:f6: + 69:61:0b:2a:8d:de:87:1c:ec:dc:50:c7:67:ef:88:2c:28:de: + c0:db:6e:21:20:00:c5:5b:5d:ef:36:c6:0a:e9:06:a3:25:3e: + 4d:13:fa:f0:3f:bc:fe:9c:68:48:ff:ec:1b:e7:2c:39:ac:88: + 2b:a0:88:96:11:3e:f0:20:e2:29:fc:bd:d3:d3:ca:24:63:58: + 17:15:c3:ac:19:21:cb:21:29:fc:53:e7:3b:cf:c2:0a:5e:f4: + ce:f1:9e:77:38:d4:c6:90:4e:94:fe:2e:97:cb:1a:94:2a:1e: + 8c:3b:db:36:65:c6:19:ba:d7:0b:03:22:e5:92:e2:f6:3e:df: + 99:ce:6b:49 -----BEGIN CERTIFICATE----- -MIID1zCCAr+gAwIBAgIRANsVC1dk9txKwG7n6l3Jxc0wDQYJKoZIhvcNAQELBQAw -azELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1v -dW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3QgQ0ExHTAbBgNVBAMMFFRlc3QgSW50 -ZXJtZWRpYXRlIENBMB4XDTIwMDMxMzIwNDYxN1oXDTIyMDMxMzIwNDYxN1owYDEL -MAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50 -YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCC -ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKZY3DYl0aakkwjPLTuGB7XO -RMdbf9cRplGY7IJMbDFFowRWb8F31mw42zzYLdIlqkdP9KTzjgmYN9MPcfasKUd7 -CI5oq/x+EAJltoZMsCcEahUjszoZuBXzOwsdrdifSbFy8q8I38gCqsvzKi3A/Siw -l9pKqSJ0wjoLZGUqyfRl90Z/PKlhll8MKmbD8sf+aYcvcAwbZjeSxT+FQNjkJkUY -P85TJ6CXfhGH3ErsJuv/lQ6z6i5mRQqqzMWBWS4KGw4bWXHK05Dvb8q3jKjKglW4 -+0rluil4zuvNjk+cr4Wk7wtkXj5+oODlsIbzGQj6P/oeSpv8tRYXiA04DsOmX9UC -AwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFIHNp91SQ3/feku69bC2 -EKBEDOxsMB8GA1UdIwQYMBaAFBdcRfPQrBwQTItDRCDE3ZPFxRk7MB0GA1UdJQQW -MBQGCCsGAQUFBwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3 -DQEBCwUAA4IBAQCALJSGpGkyOA5Bc9sKQukcBYH6gMzCwys9fkaxGTL/l/78vsIy -fOLb/icKdSZquG+fDzcMvAItbARjSkVQdbc+kEmFUD2FUlcdLtW5dcGEVprLkuib -KDi9IMVtjFNwN5r1ZF7VEeQoawiciw8q96FZABVYaxGRESfDbuJUUvf+5j0n1Q+2 -kas5Ep3F3PMC5IdIx+iTwIVpXJeL2F+/1KHyxFppiLA8dYYwCbSEChdWLG/UxhD5 -Ixxed4wpXNtBNjPHOgCF+aD143GaVbcLRUUwB6d4b7IrTuWEL7xJ14AH7dFEyMNa -7DxlBaB446OLHLIusGT1nnsIjb1KB08pUHTo +MIIDxzCCAq+gAwIBAgIBATANBgkqhkiG9w0BAQsFADBrMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEdMBsGA1UEAwwUVGVzdCBJbnRlcm1lZGlhdGUgQ0EwHhcN +MTcwNjA1MTcxMDQ2WhcNMjcwNjAzMTcxMDQ2WjBgMQswCQYDVQQGEwJVUzETMBEG +A1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4GA1UE +CgwHVGVzdCBDQTESMBAGA1UEAwwJMTI3LjAuMC4xMIIBIjANBgkqhkiG9w0BAQEF +AAOCAQ8AMIIBCgKCAQEAtL/SlzPlE1t3Zb1zGnUom0dZ5rcw6EYzbVhb2h8K/+Tk +LfId+InoZC72w83Xo47X983n2A4Qw+dW0vzl5tNO4v+CTRhjh7Cj3trvCjd7rLW3 +Q87yBznfFOnDpEE+fmhHNJt7YcQY5hPOs7Sm4LoD7uTr56r0bb6XW6oGl1AB0Hi4 +1pKw5OK5Q4i1rhRkfVJw1AUcCSXV4k/JqILbQTHDvkRvC9T9v8Hu2WK/O4+1AMjR +311KE61x5Etf0dlyTIPYk0C/bM0vZg4E1rlDKCTJJf1ZcP498qkKTsKbxN6eV15d +FiXmeLZESSmd9r90+4XWDfFlWPIr1o8QScgALYjiLQIDAQABo4GAMH4wDAYDVR0T +AQH/BAIwADAdBgNVHQ4EFgQU4NzgLweIdDqf0zCjcYr51qXlplMwHwYDVR0jBBgw +FoAUF1xF89CsHBBMi0NEIMTdk8XFGTswHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsG +AQUFBwMCMA8GA1UdEQQIMAaHBH8AAAEwDQYJKoZIhvcNAQELBQADggEBAEP3Yzij +MD+r5mxCod3/jfatsuu2nku9kPzY9PBaQvy+W8zHJC+RSKahu6K3GWEhrNOB7m67 +BC0WtX7L5qMXjz5lTR2Nwdo9O62hs+j14xYTFwqjReDPhLI96DhpMUbojBBjD15r +9BAlI5i4XNkGeIMYcAmm74/p9f+zRIU19mlhCyqN3occ7NxQx2fviCwo3sDbbiEg +AMVbXe82xgrpBqMlPk0T+vA/vP6caEj/7BvnLDmsiCugiJYRPvAg4in8vdPTyiRj +WBcVw6wZIcshKfxT5zvPwgpe9M7xnnc41MaQTpT+LpfLGpQqHow72zZlxhm61wsD +IuWS4vY+35nOa0k= -----END CERTIFICATE----- Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:a2 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 1 (0x1) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity - Not Before: Mar 13 20:46:16 2020 GMT - Not After : Mar 11 20:46:16 2030 GMT + Not Before: Jun 5 17:10:45 2017 GMT + Not After : Jun 3 17:10:45 2027 GMT Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Intermediate CA Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: 00:9d:e9:bd:e4:3d:4a:2f:fb:c2:f9:e6:22:2a:42: 15:46:1c:8c:8f:47:4c:e9:c5:57:95:1f:66:70:93: @@ -153,40 +151,39 @@ X509v3 Key Usage: critical Certificate Sign, CRL Sign Signature Algorithm: sha256WithRSAEncryption - 00:25:9c:ba:83:ee:0f:a2:57:cc:9a:d4:50:15:d5:e0:e7:4a: - 8a:57:d1:3e:b1:de:a5:be:26:f0:22:98:35:c0:ee:f1:84:4f: - aa:8d:92:e5:5c:29:23:ad:68:fb:9a:68:d0:2c:6e:04:5e:25: - fb:a0:65:04:fc:82:0b:ec:5b:53:a9:f4:61:1e:15:0f:5e:93: - 94:ec:d3:31:82:06:a1:16:09:01:b9:cb:90:a9:f9:ac:e3:d3: - 15:4c:2c:75:1c:97:24:d3:33:33:e1:b3:53:28:4e:e3:8e:6f: - 59:06:83:20:06:bd:9b:e9:44:8a:bd:80:59:6d:c2:cd:ce:c5: - 9c:81:31:3c:72:f5:6c:bf:31:69:a9:7c:32:28:cb:0e:d3:fd: - 23:5b:30:e0:c1:e9:c8:f8:6e:21:d1:86:c6:ca:62:a6:d6:19: - e4:0b:25:88:95:74:ce:b3:c6:4c:3c:32:63:d6:6a:8b:a3:49: - 53:15:85:9d:1a:06:16:e5:62:35:f5:d2:8c:99:91:15:35:9e: - 9d:36:98:75:4d:f9:39:de:2e:74:8f:36:2b:3a:b4:51:74:26: - 7c:22:6b:c3:52:3e:03:9f:cc:31:e9:24:68:6b:49:63:b5:24: - 6f:08:79:ed:4a:c1:6b:b5:da:72:1f:d5:a4:7e:6c:9b:4d:d2: - 4d:5d:c1:2b + 3e:f5:d7:fd:82:3b:1e:34:8c:66:a2:f3:5e:18:e1:f1:a9:75: + 9f:b5:93:e7:0a:8e:cf:0a:33:ed:49:cd:ce:ce:ca:5f:a3:1d: + 64:76:d3:84:16:fe:9d:88:ac:f4:d1:f8:36:2b:20:80:52:0a: + ef:e0:0f:64:27:55:35:a3:7b:c6:8a:7c:a5:c4:29:17:b1:fa: + d2:89:5d:13:6b:b8:03:cb:d7:12:d6:ce:24:f0:af:48:17:03: + 54:99:af:e9:cb:fd:44:44:18:23:61:90:f6:bd:55:65:06:c3: + 36:98:8d:ea:7d:0f:79:ef:b6:bb:22:28:03:a6:ec:d9:d4:1b: + 47:ac:2c:25:de:ef:1a:02:69:4c:18:bb:29:48:f4:9d:e1:52: + 42:64:6c:88:46:68:86:83:fd:24:f5:7d:05:d7:1a:7e:22:bc: + 49:75:9c:8a:4d:e8:f3:a2:eb:9b:83:70:a7:d6:dd:2f:05:2d: + aa:be:d7:ee:7b:8e:75:44:3b:da:df:85:61:bf:e9:3b:13:40: + 4e:8b:52:08:d9:e4:8c:54:da:41:db:7b:2c:05:5e:99:06:0d: + 02:8c:8e:19:8e:55:b0:3a:33:18:30:03:a7:ed:4a:e4:f8:58: + cc:12:b8:af:d6:66:55:29:ec:01:1f:92:ed:3d:4d:c3:71:3b: + e0:2f:70:90 -----BEGIN CERTIFICATE----- -MIIDmjCCAoKgAwIBAgIQPiydvrBCyM/8mULVTUFqojANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTIwMDMxMzIwNDYxNloXDTMwMDMxMTIwNDYxNlowazELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExHTAbBgNVBAMMFFRlc3QgSW50ZXJtZWRpYXRlIENB -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnem95D1KL/vC+eYiKkIV -RhyMj0dM6cVXlR9mcJMi8JTDu7Vb76RvyMeJlXW6DDa/TmupNUcIQ54pauLD+wO3 -H7bhUWvtexnH+c473GXpZseDlMTRTu7tZEuB8RrqWmQYG2pOk9ATbJBgytJOtyQW -+LIIWJ2NpzNFFTSBrS0tnGDv+SuY/nnTjSxI2xKR9C76v/UmwYIFgN1MqHC/p7wQ -NHc520cED+1EsmVGIiCIWSgPxwyitJGloqrKBZ+Km26jy9Sk6CR1nSCBIltfdz7J -8R6u64ozjCdbHr5tIRtCcpXjnhMDdadY1L5oEv5jjksRejTno2vdc64+GZrskYtz -rwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQXXEXz0KwcEEyL -Q0QgxN2TxcUZOzAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggEBAAAl -nLqD7g+iV8ya1FAV1eDnSopX0T6x3qW+JvAimDXA7vGET6qNkuVcKSOtaPuaaNAs -bgReJfugZQT8ggvsW1Op9GEeFQ9ek5Ts0zGCBqEWCQG5y5Cp+azj0xVMLHUclyTT -MzPhs1MoTuOOb1kGgyAGvZvpRIq9gFltws3OxZyBMTxy9Wy/MWmpfDIoyw7T/SNb -MODB6cj4biHRhsbKYqbWGeQLJYiVdM6zxkw8MmPWaoujSVMVhZ0aBhblYjX10oyZ -kRU1np02mHVN+TneLnSPNis6tFF0Jnwia8NSPgOfzDHpJGhrSWO1JG8Iee1KwWu1 -2nIf1aR+bJtN0k1dwSs= +MIIDizCCAnOgAwIBAgIBATANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE3MDYwNTE3 +MTA0NVoXDTI3MDYwMzE3MTA0NVowazELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExHTAbBgNVBAMMFFRlc3QgSW50ZXJtZWRpYXRlIENBMIIBIjANBgkqhkiG9w0B +AQEFAAOCAQ8AMIIBCgKCAQEAnem95D1KL/vC+eYiKkIVRhyMj0dM6cVXlR9mcJMi +8JTDu7Vb76RvyMeJlXW6DDa/TmupNUcIQ54pauLD+wO3H7bhUWvtexnH+c473GXp +ZseDlMTRTu7tZEuB8RrqWmQYG2pOk9ATbJBgytJOtyQW+LIIWJ2NpzNFFTSBrS0t +nGDv+SuY/nnTjSxI2xKR9C76v/UmwYIFgN1MqHC/p7wQNHc520cED+1EsmVGIiCI +WSgPxwyitJGloqrKBZ+Km26jy9Sk6CR1nSCBIltfdz7J8R6u64ozjCdbHr5tIRtC +cpXjnhMDdadY1L5oEv5jjksRejTno2vdc64+GZrskYtzrwIDAQABo0IwQDAPBgNV +HRMBAf8EBTADAQH/MB0GA1UdDgQWBBQXXEXz0KwcEEyLQ0QgxN2TxcUZOzAOBgNV +HQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggEBAD711/2COx40jGai814Y4fGp +dZ+1k+cKjs8KM+1Jzc7Oyl+jHWR204QW/p2IrPTR+DYrIIBSCu/gD2QnVTWje8aK +fKXEKRex+tKJXRNruAPL1xLWziTwr0gXA1SZr+nL/UREGCNhkPa9VWUGwzaYjep9 +D3nvtrsiKAOm7NnUG0esLCXe7xoCaUwYuylI9J3hUkJkbIhGaIaD/ST1fQXXGn4i +vEl1nIpN6POi65uDcKfW3S8FLaq+1+57jnVEO9rfhWG/6TsTQE6LUgjZ5IxU2kHb +eywFXpkGDQKMjhmOVbA6MxgwA6ftSuT4WMwSuK/WZlUp7AEfku09TcNxO+AvcJA= -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/post_june_2016.pem b/net/data/ssl/certificates/post_june_2016.pem index b614413d..0c10c1e 100644 --- a/net/data/ssl/certificates/post_june_2016.pem +++ b/net/data/ssl/certificates/post_june_2016.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:bb - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 23 (0x17) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Jun 1 00:00:00 2016 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:ea:28:87:52:f7:ef:f0:75:d4:d1:50:fb:fa:d4: - c4:c1:92:75:50:b9:c2:95:8c:14:07:10:aa:a0:d8: - fa:f7:7a:b3:f2:b3:5f:c8:f6:8e:db:73:1a:dc:3f: - b9:4e:99:fe:ac:48:6e:45:72:0b:ad:11:f6:56:62: - 6a:a4:2b:87:b2:57:bf:62:ec:5e:94:cd:d1:18:b3: - 88:62:ec:95:b5:b9:34:af:c8:d6:82:bb:f2:aa:e8: - ad:da:dd:9c:f0:5a:23:9c:1a:0b:80:c1:3e:43:78: - 00:f4:a1:c2:7c:0d:8f:d8:47:a7:db:02:69:b3:99: - 29:ad:f1:75:72:9d:27:7a:c6:24:ff:4a:f5:07:0f: - 64:21:1c:45:7f:7c:53:4f:76:52:79:b1:7b:96:14: - 0e:24:00:92:5c:17:89:d4:f3:bc:ad:1b:c2:0f:5a: - 48:b9:a1:fc:f9:98:c1:8b:86:c4:4d:cc:7c:c4:ca: - de:c9:cf:0d:48:f1:3b:a0:d2:27:3a:87:2e:d2:e0: - 3b:d1:a3:4d:a3:65:fd:90:d1:69:41:e1:bd:73:2b: - 09:e1:6c:c3:e0:66:ae:fb:87:c0:37:ef:6a:5f:2b: - 8b:6e:9a:39:12:78:63:1a:bc:68:08:b4:9a:b9:06: - a0:3c:0f:0f:94:15:84:7a:56:d2:fb:3e:5d:32:33: - f4:cb + 00:cc:24:fe:ba:05:d1:11:43:16:d3:95:5f:fa:79: + 1a:22:55:fc:43:d5:03:e2:c9:d3:32:53:bc:72:e3: + b6:b9:04:bd:3c:b4:04:55:64:a7:77:ef:ee:00:6e: + 5e:14:d5:a8:97:42:33:37:54:43:34:10:85:cd:10: + ad:b4:18:49:9c:a9:63:27:c4:bd:53:4a:39:45:ec: + 8b:88:8d:bf:b4:5f:fe:3e:1b:d5:ac:d1:23:fd:0c: + bd:09:3d:0c:8b:79:a0:89:b7:d6:16:73:07:b5:90: + 18:49:09:ed:80:26:19:e4:06:fb:71:16:97:f4:16: + 53:84:1b:33:92:22:08:c6:43:82:f5:02:d1:a1:4f: + a8:c8:97:46:e0:39:64:6d:b3:4c:e4:45:87:50:5f: + 37:aa:7a:de:00:58:bf:b3:68:31:5c:5d:5c:ab:e9: + 26:b7:06:4c:25:2f:42:63:d7:5a:ed:0f:45:59:8d: + fc:8a:ef:4f:16:b9:60:b4:bf:c6:a7:1a:50:53:3e: + 3b:0f:af:de:eb:12:da:80:c3:ca:bb:8f:03:74:d3: + fc:8a:e4:b2:7e:9a:d5:eb:74:9c:eb:c7:d5:79:6f: + 13:0e:ea:b9:5a:90:04:6b:e7:a0:39:fa:e0:ad:29: + 6d:2a:c7:3d:e6:06:70:a6:99:f7:4d:02:10:39:51: + 4a:13 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 5D:9D:AA:CB:E9:50:66:BA:68:B5:C4:63:09:40:F7:2A:EB:EF:A0:88 + E3:14:30:A9:76:2F:F9:DE:0D:D7:82:DF:8A:8B:5A:FE:84:EF:65:49 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,114 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - b0:38:e3:e3:17:c8:0d:35:cc:a7:fa:1a:ce:2f:08:70:b7:ff: - b4:e1:69:1e:76:67:56:24:93:dc:86:bb:32:a7:67:4b:65:67: - e4:0d:6e:32:16:1b:c9:73:53:39:9b:3e:1d:89:16:c5:f8:f0: - 1a:7c:9f:d3:6c:1a:2b:50:6f:4a:00:3e:69:74:72:94:47:8f: - 86:2d:85:ae:55:ae:f9:bd:97:d0:d9:08:95:67:e9:31:0e:0e: - 2f:ea:38:1a:1b:d1:c2:b1:e8:3d:ee:6b:9f:8f:40:a4:02:4b: - 9d:56:20:c3:7f:bd:00:da:61:98:68:33:75:65:a8:9d:21:bf: - 20:be:7d:f3:7e:82:51:88:a2:2d:4e:10:e9:59:44:63:88:0a: - 34:f3:4c:0d:d1:cb:79:0a:0b:52:4d:d2:b3:86:4c:99:e8:93: - e4:49:8b:92:a4:11:b0:f9:4a:1f:dd:2d:cf:e7:65:c3:84:9f: - 8a:9a:8d:bc:ec:37:d5:b2:5c:28:50:6b:67:38:8d:e5:21:78: - 75:18:5c:0d:5d:1a:87:1e:47:5b:74:0d:96:72:fa:85:9e:6c: - 8e:e9:a5:11:cc:6f:e0:52:b6:36:b2:8e:47:1d:4b:f8:55:88: - ab:9a:b9:47:40:ab:d1:19:78:d2:81:b5:57:25:a3:4e:6f:9f: - 41:f4:a3:56 + 6a:ca:b3:de:fd:7e:b9:3c:8a:ad:4e:e6:a3:40:f1:c4:10:5e: + d5:72:9f:ca:6b:ea:de:c3:d6:48:38:59:72:cc:77:b9:c1:9e: + 7f:a4:02:4f:57:ad:bd:4f:d5:66:a7:82:f3:85:ea:6a:b5:e8: + eb:21:a5:bc:cd:89:43:97:50:54:44:5e:b4:e8:98:98:0d:b1: + 12:69:d3:62:ae:77:0e:1b:3c:02:93:29:49:96:e2:7b:9f:c8: + 58:84:f3:a0:bb:26:99:71:80:c6:2e:99:4c:00:4f:90:08:e2: + e3:cf:9d:f1:71:40:a0:78:8f:dd:e1:ea:28:74:4e:83:3e:60: + 20:45:d4:68:28:cc:55:0d:d7:4e:7e:48:a7:aa:f4:fa:20:b8: + 74:76:f5:49:f6:e3:2c:e8:3f:f3:2e:84:a9:81:ce:4e:b9:87: + 5f:2e:fd:12:8a:ca:fb:53:46:b5:2d:16:57:fd:ca:64:5e:77: + 26:48:f6:52:29:70:a1:67:c2:5c:10:13:07:5a:1b:d5:9f:38: + 19:5c:d8:a1:e3:1b:09:3b:ff:56:fd:7d:57:74:5f:9c:14:92: + b3:3e:8f:f6:0b:f0:f5:25:4f:0b:05:de:ad:87:9a:4f:e4:b7: + b4:2d:de:31:2c:14:49:bf:ef:0a:0c:b6:4f:1e:53:d4:50:23: + c7:b4:78:66 -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFquzANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE2MDYwMTAwMDAwMFoXDTE3MDcwMzAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAOooh1L37/B11NFQ+/rUxMGSdVC5wpWMFAcQ -qqDY+vd6s/KzX8j2jttzGtw/uU6Z/qxIbkVyC60R9lZiaqQrh7JXv2LsXpTN0Riz -iGLslbW5NK/I1oK78qrordrdnPBaI5waC4DBPkN4APShwnwNj9hHp9sCabOZKa3x -dXKdJ3rGJP9K9QcPZCEcRX98U092Unmxe5YUDiQAklwXidTzvK0bwg9aSLmh/PmY -wYuGxE3MfMTK3snPDUjxO6DSJzqHLtLgO9GjTaNl/ZDRaUHhvXMrCeFsw+BmrvuH -wDfval8ri26aORJ4Yxq8aAi0mrkGoDwPD5QVhHpW0vs+XTIz9MsCAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFF2dqsvpUGa6aLXEYwlA9yrr76CIMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQCwOOPjF8gNNcyn+hrOLwhwt/+04WkedmdWJJPchrsyp2dLZWfkDW4yFhvJc1M5 -mz4diRbF+PAafJ/TbBorUG9KAD5pdHKUR4+GLYWuVa75vZfQ2QiVZ+kxDg4v6jga -G9HCseg97mufj0CkAkudViDDf70A2mGYaDN1ZaidIb8gvn3zfoJRiKItThDpWURj -iAo080wN0ct5CgtSTdKzhkyZ6JPkSYuSpBGw+Uof3S3P52XDhJ+Kmo287DfVslwo -UGtnOI3lIXh1GFwNXRqHHkdbdA2WcvqFnmyO6aURzG/gUrY2so5HHUv4VYirmrlH -QKvRGXjSgbVXJaNOb59B9KNW +MIIDvzCCAqegAwIBAgIBFzANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE2MDYwMTAw +MDAwMFoXDTE3MDcwMzAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAMwk/roF0RFDFtOVX/p5GiJV/EPVA+LJ0zJTvHLjtrkEvTy0BFVkp3fv +7gBuXhTVqJdCMzdUQzQQhc0QrbQYSZypYyfEvVNKOUXsi4iNv7Rf/j4b1azRI/0M +vQk9DIt5oIm31hZzB7WQGEkJ7YAmGeQG+3EWl/QWU4QbM5IiCMZDgvUC0aFPqMiX +RuA5ZG2zTORFh1BfN6p63gBYv7NoMVxdXKvpJrcGTCUvQmPXWu0PRVmN/IrvTxa5 +YLS/xqcaUFM+Ow+v3usS2oDDyruPA3TT/Irksn6a1et0nOvH1XlvEw7quVqQBGvn +oDn64K0pbSrHPeYGcKaZ900CEDlRShMCAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFOMUMKl2L/neDdeC34qLWv6E72VJMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQBqyrPe/X65PIqtTuaj +QPHEEF7Vcp/Ka+rew9ZIOFlyzHe5wZ5/pAJPV629T9Vmp4LzhepqtejrIaW8zYlD +l1BURF606JiYDbESadNirncOGzwCkylJluJ7n8hYhPOguyaZcYDGLplMAE+QCOLj +z53xcUCgeI/d4eoodE6DPmAgRdRoKMxVDddOfkinqvT6ILh0dvVJ9uMs6D/zLoSp +gc5OuYdfLv0Sisr7U0a1LRZX/cpkXncmSPZSKXChZ8JcEBMHWhvVnzgZXNih4xsJ +O/9W/X1XdF+cFJKzPo/2C/D1JU8LBd6th5pP5Le0Ld4xLBRJv+8KDLZPHlPUUCPH +tHhm -----END CERTIFICATE----- + +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 903804111 (0x35def4cf) + Signature Algorithm: sha1WithRSAEncryption + Issuer: C=US, O=Equifax, OU=Equifax Secure Certificate Authority + Validity + Not Before: Aug 22 16:41:51 1998 GMT + Not After : Aug 22 16:41:51 2018 GMT + Subject: C=US, O=Equifax, OU=Equifax Secure Certificate Authority + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + Public-Key: (1024 bit) + Modulus: + 00:c1:5d:b1:58:67:08:62:ee:a0:9a:2d:1f:08:6d: + 91:14:68:98:0a:1e:fe:da:04:6f:13:84:62:21:c3: + d1:7c:ce:9f:05:e0:b8:01:f0:4e:34:ec:e2:8a:95: + 04:64:ac:f1:6b:53:5f:05:b3:cb:67:80:bf:42:02: + 8e:fe:dd:01:09:ec:e1:00:14:4f:fc:fb:f0:0c:dd: + 43:ba:5b:2b:e1:1f:80:70:99:15:57:93:16:f1:0f: + 97:6a:b7:c2:68:23:1c:cc:4d:59:30:ac:51:1e:3b: + af:2b:d6:ee:63:45:7b:c5:d9:5f:50:d2:e3:50:0f: + 3a:88:e7:bf:14:fd:e0:c7:b9 + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 CRL Distribution Points: + + Full Name: + DirName: C = US, O = Equifax, OU = Equifax Secure Certificate Authority, CN = CRL1 + + X509v3 Private Key Usage Period: + Not After: Aug 22 16:41:51 2018 GMT + X509v3 Key Usage: + Certificate Sign, CRL Sign + X509v3 Authority Key Identifier: + keyid:48:E6:68:F9:2B:D2:B2:95:D7:47:D8:23:20:10:4F:33:98:90:9F:D4 + + X509v3 Subject Key Identifier: + 48:E6:68:F9:2B:D2:B2:95:D7:47:D8:23:20:10:4F:33:98:90:9F:D4 + X509v3 Basic Constraints: + CA:TRUE + 1.2.840.113533.7.65.0: + 0...V3.0c.... + Signature Algorithm: sha1WithRSAEncryption + 58:ce:29:ea:fc:f7:de:b5:ce:02:b9:17:b5:85:d1:b9:e3:e0: + 95:cc:25:31:0d:00:a6:92:6e:7f:b6:92:63:9e:50:95:d1:9a: + 6f:e4:11:de:63:85:6e:98:ee:a8:ff:5a:c8:d3:55:b2:66:71: + 57:de:c0:21:eb:3d:2a:a7:23:49:01:04:86:42:7b:fc:ee:7f: + a2:16:52:b5:67:67:d3:40:db:3b:26:58:b2:28:77:3d:ae:14: + 77:61:d6:fa:2a:66:27:a0:0d:fa:a7:73:5c:ea:70:f1:94:21: + 65:44:5f:fa:fc:ef:29:68:a9:a2:87:79:ef:79:ef:4f:ac:07: + 77:38 +-----BEGIN CERTIFICATE----- +MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJV +UzEQMA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2Vy +dGlmaWNhdGUgQXV0aG9yaXR5MB4XDTk4MDgyMjE2NDE1MVoXDTE4MDgyMjE2NDE1 +MVowTjELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0VxdWlmYXgxLTArBgNVBAsTJEVx +dWlmYXggU2VjdXJlIENlcnRpZmljYXRlIEF1dGhvcml0eTCBnzANBgkqhkiG9w0B +AQEFAAOBjQAwgYkCgYEAwV2xWGcIYu6gmi0fCG2RFGiYCh7+2gRvE4RiIcPRfM6f +BeC4AfBONOziipUEZKzxa1NfBbPLZ4C/QgKO/t0BCezhABRP/PvwDN1Dulsr4R+A +cJkVV5MW8Q+XarfCaCMczE1ZMKxRHjuvK9buY0V7xdlfUNLjUA86iOe/FP3gx7kC +AwEAAaOCAQkwggEFMHAGA1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQ +MA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlm +aWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTgw +ODIyMTY0MTUxWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvSspXXR9gj +IBBPM5iQn9QwHQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQF +MAMBAf8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUA +A4GBAFjOKer89961zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y +7qj/WsjTVbJmcVfewCHrPSqnI0kBBIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2uFHdh +1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4 +-----END CERTIFICATE----- +
diff --git a/net/data/ssl/certificates/pre_br_validity_bad_121.pem b/net/data/ssl/certificates/pre_br_validity_bad_121.pem index f420236..2bf5369b 100644 --- a/net/data/ssl/certificates/pre_br_validity_bad_121.pem +++ b/net/data/ssl/certificates/pre_br_validity_bad_121.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:b5 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 20 (0x14) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Jan 1 00:00:00 2008 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:f6:17:41:ab:0e:a4:ff:81:84:4e:7d:ff:d7:2a: - 5e:ac:67:30:a5:29:04:c6:0b:00:76:6d:ab:27:63: - 7d:31:39:a5:22:06:2e:df:c0:78:75:9c:29:e3:84: - 53:8b:3d:40:9b:82:cd:24:75:44:68:60:24:ed:be: - 9d:22:75:b4:01:54:97:c5:00:3d:95:9e:36:89:75: - ba:cf:70:8d:a0:cc:77:b7:4b:b5:04:55:b4:3f:75: - 2f:21:5a:d1:1d:35:77:08:c3:d0:14:89:5e:e5:41: - ce:7e:3d:9c:f6:4f:83:2c:39:d2:d9:3f:33:4c:36: - eb:4f:d8:37:ba:be:fb:08:12:f4:32:4d:2a:cc:43: - 1d:b4:8e:2a:d1:d0:6c:59:2a:de:ad:3e:34:e0:a6: - e3:94:72:e5:93:4e:08:c1:19:20:68:25:9d:da:75: - 03:99:b4:94:9f:ea:76:2d:93:b7:6d:45:36:3a:05: - 71:b2:68:1d:ab:58:c8:78:ef:b3:16:bc:d3:8d:68: - 0e:18:5e:0b:8f:49:e4:b9:a0:18:c2:9b:e7:85:95: - a8:65:2c:9c:48:29:99:31:36:07:7d:63:3d:3f:b5: - 2f:4e:9f:95:07:e5:c7:dd:86:56:8e:11:aa:cc:1b: - f6:aa:e1:d6:19:a2:53:69:06:c0:b2:45:a1:ad:6e: - 7e:35 + 00:9f:eb:e4:9c:a0:87:13:91:5c:dd:4b:ca:0d:15: + 66:ba:86:05:e4:f7:32:b3:ea:9b:57:9f:77:a6:52: + 39:7d:62:4f:c8:f4:24:c9:47:8d:1f:0a:a2:ce:13: + 90:a1:27:ab:4d:7d:ca:66:64:44:7b:5c:82:00:b0: + 3a:2f:da:ab:d3:f8:c1:22:09:49:3d:26:96:59:25: + ec:58:9f:2e:82:82:63:6e:dc:4a:87:ad:fd:c1:ef: + 44:34:a5:9d:d2:48:25:ca:f5:20:3f:e3:2b:6d:9a: + b7:d1:c5:e9:53:7f:f0:ab:b0:29:5a:1e:a1:8b:fb: + 6a:b8:99:5b:61:7f:ca:4d:5c:b9:50:5d:f2:52:de: + ec:06:62:e3:ff:95:2c:51:04:2c:95:6c:56:cf:a1: + 2d:78:be:7c:a2:a7:53:1f:52:96:e1:a2:cc:72:c2: + e6:a4:62:da:e8:94:2a:3b:e0:25:f0:6c:d2:a5:16: + ba:1f:75:52:8a:5e:7b:4d:0a:79:c9:14:bf:dc:ac: + 8c:d3:03:01:fe:05:8b:00:e8:17:f7:11:9b:ca:f8: + d4:80:58:7f:77:4b:f4:17:87:5f:f4:98:a4:1b:3c: + 8c:c8:a4:1d:26:02:4a:24:b5:e8:7c:e0:38:bc:e8: + 90:d5:fa:91:6a:3d:97:7c:ed:f5:22:f3:29:3d:3d: + c5:33 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - BC:BA:0C:C8:CE:15:C4:E4:E7:AC:E7:E8:E4:B9:39:22:FF:D3:64:F6 + 09:3A:F7:03:5A:79:7A:04:12:F8:DA:B6:8D:5F:90:7F:FD:9D:EE:67 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 91:a2:96:56:82:4d:e1:c6:c8:60:ed:c3:c9:30:c9:0b:64:ce: - ce:4a:5d:28:54:ed:52:a6:b2:c0:6a:8f:a3:ed:03:e2:26:9c: - 57:84:e2:27:27:54:7d:e3:64:b9:20:6a:75:4a:93:2b:00:ea: - 89:ad:12:eb:06:5a:ab:67:e2:c2:08:0f:a2:0c:1d:82:ab:37: - 2d:d4:d9:d3:df:69:1b:34:7d:1a:61:fe:26:eb:b8:d9:53:b0: - a7:d6:f6:32:83:ed:03:c5:9c:22:5c:1b:2b:8f:e1:af:15:ba: - 57:0f:bc:a0:f4:78:0a:10:39:93:b1:0c:79:47:8f:08:18:78: - 45:9b:b6:76:9b:c5:27:2c:de:80:4e:c6:5b:d0:c5:2c:f5:35: - 3c:a1:1b:5c:f7:d4:38:5b:ea:dd:3e:05:84:9f:71:c6:56:33: - 34:ad:df:2b:dd:e1:b7:a4:a5:9d:59:c9:06:33:2d:95:86:2e: - e4:8c:08:36:19:32:05:50:8d:40:27:e9:d0:b2:fe:e1:e5:45: - 70:e9:1a:b3:c7:81:ae:e0:0c:72:30:b6:2b:72:0e:73:32:96: - 75:63:e1:18:6c:0d:23:4b:ff:d6:d3:92:91:70:0d:0c:52:26: - 7d:3d:35:5f:26:3c:1d:7e:36:4e:b9:57:2e:0c:91:2f:8c:6c: - 11:dc:80:95 + 38:14:a7:3c:63:ee:dd:f9:f5:9e:55:09:97:55:fc:3e:2d:09: + f8:45:20:c0:05:9c:cd:96:87:f6:2d:d6:e0:9b:34:b8:16:03: + 40:39:1c:a5:02:c9:01:9d:2d:bb:52:f2:65:45:94:49:43:a0: + 1a:2f:26:c3:5d:cf:41:66:be:02:0b:37:0b:4e:66:3b:66:13: + 7f:10:8e:8b:6a:84:4e:50:ec:f0:0c:26:4d:dc:4d:2e:93:4b: + 19:98:18:12:2d:80:dd:55:12:d4:41:6c:53:50:2f:d7:4e:da: + fd:0c:5a:fc:f6:fc:02:30:3f:72:8c:2a:34:1e:9c:0c:96:3f: + 1f:54:79:97:d4:97:7b:81:bc:5b:22:42:0c:dd:6b:3a:04:30: + 7b:71:35:df:9b:32:95:86:07:2d:15:ef:a7:1e:8b:ec:fc:27: + 49:29:fd:a1:7f:01:88:13:6f:5d:8f:6b:be:21:57:2d:5a:c3: + cd:30:46:f6:5e:2b:ca:ce:48:f8:5b:ba:f6:40:97:31:c6:c3: + ea:31:55:64:9a:8b:93:6c:cb:e5:0e:f7:3d:f2:13:8e:bb:1e: + 39:09:3e:62:0a:d7:2c:c9:5c:35:db:8b:d7:e6:c8:27:f3:09: + e0:3f:e4:98:8d:e5:db:2c:d6:8b:9f:85:24:4f:15:98:af:86: + 85:b6:13:1f -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqtTANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTA4MDEwMTAwMDAwMFoXDTE4MDUwMTAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAPYXQasOpP+BhE59/9cqXqxnMKUpBMYLAHZt -qydjfTE5pSIGLt/AeHWcKeOEU4s9QJuCzSR1RGhgJO2+nSJ1tAFUl8UAPZWeNol1 -us9wjaDMd7dLtQRVtD91LyFa0R01dwjD0BSJXuVBzn49nPZPgyw50tk/M0w260/Y -N7q++wgS9DJNKsxDHbSOKtHQbFkq3q0+NOCm45Ry5ZNOCMEZIGglndp1A5m0lJ/q -di2Tt21FNjoFcbJoHatYyHjvsxa8041oDhheC49J5LmgGMKb54WVqGUsnEgpmTE2 -B31jPT+1L06flQflx92GVo4Rqswb9qrh1hmiU2kGwLJFoa1ufjUCAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFLy6DMjOFcTk56zn6OS5OSL/02T2MB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQCRopZWgk3hxshg7cPJMMkLZM7OSl0oVO1SprLAao+j7QPiJpxXhOInJ1R942S5 -IGp1SpMrAOqJrRLrBlqrZ+LCCA+iDB2Cqzct1NnT32kbNH0aYf4m67jZU7Cn1vYy -g+0DxZwiXBsrj+GvFbpXD7yg9HgKEDmTsQx5R48IGHhFm7Z2m8UnLN6ATsZb0MUs -9TU8oRtc99Q4W+rdPgWEn3HGVjM0rd8r3eG3pKWdWckGMy2Vhi7kjAg2GTIFUI1A -J+nQsv7h5UVw6Rqzx4Gu4AxyMLYrcg5zMpZ1Y+EYbA0jS//W05KRcA0MUiZ9PTVf -JjwdfjZOuVcuDJEvjGwR3ICV +MIIDvzCCAqegAwIBAgIBFDANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTA4MDEwMTAw +MDAwMFoXDTE4MDUwMTAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAJ/r5JyghxORXN1Lyg0VZrqGBeT3MrPqm1efd6ZSOX1iT8j0JMlHjR8K +os4TkKEnq019ymZkRHtcggCwOi/aq9P4wSIJST0mllkl7FifLoKCY27cSoet/cHv +RDSlndJIJcr1ID/jK22at9HF6VN/8KuwKVoeoYv7ariZW2F/yk1cuVBd8lLe7AZi +4/+VLFEELJVsVs+hLXi+fKKnUx9SluGizHLC5qRi2uiUKjvgJfBs0qUWuh91Uope +e00KeckUv9ysjNMDAf4FiwDoF/cRm8r41IBYf3dL9BeHX/SYpBs8jMikHSYCSiS1 +6HzgOLzokNX6kWo9l3zt9SLzKT09xTMCAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFAk69wNaeXoEEvjato1fkH/9ne5nMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQA4FKc8Y+7d+fWeVQmX +Vfw+LQn4RSDABZzNlof2LdbgmzS4FgNAORylAskBnS27UvJlRZRJQ6AaLybDXc9B +Zr4CCzcLTmY7ZhN/EI6LaoROUOzwDCZN3E0uk0sZmBgSLYDdVRLUQWxTUC/XTtr9 +DFr89vwCMD9yjCo0HpwMlj8fVHmX1Jd7gbxbIkIM3Ws6BDB7cTXfmzKVhgctFe+n +Hovs/CdJKf2hfwGIE29dj2u+IVctWsPNMEb2XivKzkj4W7r2QJcxxsPqMVVkmouT +bMvlDvc98hOOux45CT5iCtcsyVw124vX5sgn8wngP+SYjeXbLNaLn4UkTxWYr4aF +thMf -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/pre_br_validity_bad_2020.pem b/net/data/ssl/certificates/pre_br_validity_bad_2020.pem index cc65e31..10a08549 100644 --- a/net/data/ssl/certificates/pre_br_validity_bad_2020.pem +++ b/net/data/ssl/certificates/pre_br_validity_bad_2020.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:b6 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 21 (0x15) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: May 1 00:00:00 2012 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:ce:2b:2e:c2:3a:b0:fc:49:d7:4a:2c:e5:e1:50: - f1:71:bf:85:60:74:59:7d:f3:b8:3e:f1:a7:87:97: - 73:d3:a1:5a:bc:fc:f4:6d:33:2f:97:5c:2b:e6:9a: - 6a:5e:ff:33:c4:a7:ee:7c:74:55:05:77:63:a0:79: - d9:62:8c:fc:87:dc:5b:3d:44:6b:e7:42:03:4e:ca: - b6:0c:b6:8a:68:88:8f:57:09:17:0f:39:c1:35:5c: - e7:7c:db:0b:c8:c9:e4:0a:67:05:cd:99:ae:7a:ab: - ff:1f:55:ac:43:43:70:aa:d9:2a:6d:fe:53:03:d3: - c2:eb:f1:30:7a:25:d6:98:59:9c:7b:4a:a1:30:d8: - fe:79:42:dc:4d:c5:16:b6:3f:be:ea:5b:92:c2:f4: - ab:f6:d9:ee:f1:eb:19:ca:7b:01:7f:80:2f:b2:cc: - a4:73:9a:4a:8f:2f:35:07:3f:12:15:d3:14:77:8d: - 0e:b7:7d:ba:9b:b5:60:df:0a:a9:75:10:bf:af:66: - 3c:9b:4b:dc:d9:32:ac:94:2d:dc:e4:fb:cc:21:0d: - fb:cb:48:e7:f0:60:36:39:2d:12:cc:f4:f6:dd:28: - ef:36:a5:5d:8b:18:4b:d4:d2:d0:cd:95:1f:3b:b6: - 6d:d7:a0:6a:72:75:dc:7b:21:df:e7:71:ce:df:b3: - d8:ad + 00:e8:84:db:5e:7d:ea:ce:7c:36:6f:2c:8b:48:0a: + c4:c3:48:44:4a:75:7d:85:c0:86:c3:77:ed:55:4b: + 0d:0c:62:9f:90:5b:56:8f:db:80:a5:64:4c:b9:fa: + 64:9f:93:1e:bd:b5:bf:94:04:52:fa:9a:db:87:d1: + 9a:19:da:d4:5e:47:36:31:24:3e:62:60:34:34:d9: + 17:6e:89:14:04:f2:98:32:19:70:f4:5a:2a:a0:26: + 90:26:f6:5a:e4:a7:ad:23:d8:18:a3:bd:a0:a3:d5: + e0:de:fb:81:28:39:c4:b9:65:f7:5c:6e:ae:82:ef: + cd:14:75:53:45:31:de:1f:dd:61:de:ff:2d:11:7e: + 23:b6:bc:c1:d8:71:71:0c:14:af:d2:03:b2:38:35: + 83:39:48:d3:c4:a2:0c:76:c2:93:a7:de:78:56:db: + 27:67:92:a1:29:d7:aa:ed:25:27:9e:3e:17:aa:10: + 2a:10:d4:e2:db:43:cc:64:99:78:63:85:78:f6:e1: + 1e:c7:9a:a2:e2:98:8f:e9:10:93:3e:06:db:14:70: + fb:21:7f:6d:16:a6:13:e2:54:59:eb:66:75:26:e6: + 60:12:c1:51:6c:63:7a:1a:cf:18:52:dc:db:a0:7d: + 2d:92:ad:f1:4f:e5:2c:1c:14:81:1a:db:63:6a:2f: + 75:b1 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 34:90:01:F4:6C:53:72:1C:B4:D6:9B:53:1C:55:3A:E2:9F:BC:24:1B + A6:5C:B0:9B:17:D4:01:25:77:C5:1A:B6:E6:A2:D8:53:1D:18:93:6C X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 1e:93:77:b2:0d:68:43:76:30:8f:ca:33:5e:b8:d2:9d:89:69: - 2d:4e:8b:be:a9:14:b5:96:5c:95:e9:91:43:4f:11:19:f1:f0: - 48:c3:31:e8:91:b6:11:97:87:c7:fd:b6:8b:95:77:bd:6d:ed: - f0:03:dd:25:e8:33:27:c2:60:cd:0f:83:13:f8:58:7e:e7:d8: - c4:b5:d7:72:e0:7d:3a:ce:66:52:eb:56:f3:3a:2e:9f:f8:8d: - aa:b0:69:16:70:52:16:76:7c:35:ea:a6:2d:56:7e:29:39:1b: - f7:01:f5:41:a3:81:c1:d7:ce:c8:5a:04:30:93:30:d0:c7:04: - 7b:5a:63:86:ee:64:86:eb:9e:13:3a:f7:13:ad:46:48:c1:b3: - c5:5d:29:04:ed:cf:dd:68:fa:77:55:12:38:44:0c:55:cf:99: - b5:c1:31:48:4f:db:e6:ce:99:fb:4b:28:a4:76:24:2b:57:4b: - 79:91:28:77:18:d6:51:05:a9:54:35:8f:c3:dd:83:e6:91:37: - 35:3a:3d:d1:af:f4:61:c7:2a:9a:27:39:c9:05:2f:dc:d9:8e: - cf:08:9e:eb:f2:db:6d:ae:ea:4d:f0:25:5b:7e:a7:e4:13:3d: - 79:1c:b6:a3:83:24:b0:d9:e7:ff:cc:58:3c:f7:2c:00:87:0d: - ff:a5:bd:7d + 47:a5:c1:c8:64:68:17:77:f1:42:e1:2a:ae:0d:0a:6d:17:04: + a8:72:aa:7b:0a:46:ee:62:f1:61:28:f5:84:c5:f7:d0:fd:81: + 41:dc:77:b9:80:2d:24:35:c3:2f:86:ba:74:3b:48:3f:be:59: + 60:92:11:e8:57:0d:fa:7b:ef:a8:21:20:0d:77:27:c7:5d:51: + b3:03:06:a0:9b:5a:12:67:49:65:64:9c:b2:68:fe:1a:50:2e: + a9:f6:dd:d2:a5:07:a8:b1:24:65:71:1b:d6:1b:23:c6:7c:28: + 24:5e:df:1c:56:1d:0b:c5:dd:bb:07:5a:d2:86:55:df:76:95: + 19:b7:72:53:cb:1d:97:42:3b:7e:c5:98:24:46:73:4e:6d:81: + c8:b5:3e:8c:12:ec:6e:a5:51:a5:fa:0d:10:b8:39:4a:dd:26: + 51:b1:7d:4d:c6:c7:a7:6d:8d:aa:d8:19:da:c0:a0:d7:6d:5f: + 71:97:8e:16:1f:2a:6f:0b:3d:73:2d:60:1d:9f:07:4f:17:65: + 26:d9:c5:d6:9d:04:d9:b0:b9:b0:02:48:63:4e:fd:43:ac:7b: + 5c:87:80:e8:14:9d:59:fc:f8:a6:af:87:30:52:6d:c9:ab:23: + b7:88:9a:19:0f:38:a1:fe:78:90:34:1c:a4:19:48:c7:55:01: + 65:28:69:1b -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqtjANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTEyMDUwMTAwMDAwMFoXDTE5MDcwMzAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAM4rLsI6sPxJ10os5eFQ8XG/hWB0WX3zuD7x -p4eXc9OhWrz89G0zL5dcK+aaal7/M8Sn7nx0VQV3Y6B52WKM/IfcWz1Ea+dCA07K -tgy2imiIj1cJFw85wTVc53zbC8jJ5ApnBc2Zrnqr/x9VrENDcKrZKm3+UwPTwuvx -MHol1phZnHtKoTDY/nlC3E3FFrY/vupbksL0q/bZ7vHrGcp7AX+AL7LMpHOaSo8v -NQc/EhXTFHeNDrd9upu1YN8KqXUQv69mPJtL3NkyrJQt3OT7zCEN+8tI5/BgNjkt -Esz09t0o7zalXYsYS9TS0M2VHzu2bdeganJ13Hsh3+dxzt+z2K0CAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFDSQAfRsU3IctNabUxxVOuKfvCQbMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQAek3eyDWhDdjCPyjNeuNKdiWktTou+qRS1llyV6ZFDTxEZ8fBIwzHokbYRl4fH -/baLlXe9be3wA90l6DMnwmDND4MT+Fh+59jEtddy4H06zmZS61bzOi6f+I2qsGkW -cFIWdnw16qYtVn4pORv3AfVBo4HB187IWgQwkzDQxwR7WmOG7mSG654TOvcTrUZI -wbPFXSkE7c/daPp3VRI4RAxVz5m1wTFIT9vmzpn7SyikdiQrV0t5kSh3GNZRBalU -NY/D3YPmkTc1Oj3Rr/RhxyqaJznJBS/c2Y7PCJ7r8tttrupN8CVbfqfkEz15HLaj -gySw2ef/zFg89ywAhw3/pb19 +MIIDvzCCAqegAwIBAgIBFTANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTEyMDUwMTAw +MDAwMFoXDTE5MDcwMzAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAOiE21596s58Nm8si0gKxMNIREp1fYXAhsN37VVLDQxin5BbVo/bgKVk +TLn6ZJ+THr21v5QEUvqa24fRmhna1F5HNjEkPmJgNDTZF26JFATymDIZcPRaKqAm +kCb2WuSnrSPYGKO9oKPV4N77gSg5xLll91xuroLvzRR1U0Ux3h/dYd7/LRF+I7a8 +wdhxcQwUr9IDsjg1gzlI08SiDHbCk6feeFbbJ2eSoSnXqu0lJ54+F6oQKhDU4ttD +zGSZeGOFePbhHseaouKYj+kQkz4G2xRw+yF/bRamE+JUWetmdSbmYBLBUWxjehrP +GFLc26B9LZKt8U/lLBwUgRrbY2ovdbECAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFKZcsJsX1AEld8Uatuai2FMdGJNsMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQBHpcHIZGgXd/FC4Squ +DQptFwSocqp7CkbuYvFhKPWExffQ/YFB3He5gC0kNcMvhrp0O0g/vllgkhHoVw36 +e++oISANdyfHXVGzAwagm1oSZ0llZJyyaP4aUC6p9t3SpQeosSRlcRvWGyPGfCgk +Xt8cVh0Lxd27B1rShlXfdpUZt3JTyx2XQjt+xZgkRnNObYHItT6MEuxupVGl+g0Q +uDlK3SZRsX1NxsenbY2q2BnawKDXbV9xl44WHypvCz1zLWAdnwdPF2Um2cXWnQTZ +sLmwAkhjTv1DrHtch4DoFJ1Z/Pimr4cwUm3JqyO3iJoZDzih/niQNBykGUjHVQFl +KGkb -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/pre_br_validity_ok.pem b/net/data/ssl/certificates/pre_br_validity_ok.pem index 7583759b..cac2a9f0 100644 --- a/net/data/ssl/certificates/pre_br_validity_ok.pem +++ b/net/data/ssl/certificates/pre_br_validity_ok.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:b4 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 19 (0x13) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Jan 1 00:00:00 2008 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:c2:f2:38:19:75:99:d8:05:a9:04:32:c1:24:b8: - f1:fa:83:46:aa:71:7a:70:46:51:00:3b:9d:f7:94: - 08:81:8a:44:6b:30:b1:b8:7b:f8:43:0d:3b:b5:35: - 5c:fa:5d:55:01:ab:af:73:60:32:02:8a:90:59:5b: - 1c:a0:ee:c5:0f:7b:4a:67:66:a0:3a:b6:5f:53:e0: - 14:17:45:af:2f:c8:ae:63:af:d4:64:ed:c3:f7:a0: - ef:df:5e:87:11:3b:1a:ee:0d:54:a9:dd:2a:35:26: - c0:3d:21:3d:dc:81:56:80:10:dc:11:1e:b9:3b:58: - f4:e9:0f:fc:d8:0a:b5:dc:20:d2:9f:c4:a6:95:b4: - 22:02:75:7b:40:6f:ed:9d:a4:63:87:38:9c:62:b6: - ef:dd:af:1e:11:6a:61:18:a1:87:f5:dc:b1:02:a2: - 9a:fb:0d:d9:5a:f9:83:d3:a1:6d:d6:17:cc:36:12: - 74:e2:00:14:bd:3d:4e:e7:cc:b1:73:cb:92:90:5b: - 0d:66:c9:ea:65:64:9d:68:40:1f:4d:19:8b:5e:e1: - d4:17:3f:27:81:55:75:b8:47:46:4b:87:6c:b4:5c: - 0a:ea:06:ae:6c:30:e8:41:46:49:bb:fe:09:ab:a6: - 35:e1:0a:40:e6:e5:ee:27:ee:92:4b:1f:a9:1c:4a: - 0d:2d + 00:c9:a8:08:1a:b3:09:5d:20:f4:ee:7b:73:0d:56: + 82:3d:da:d7:f3:e4:94:34:04:1f:d1:bf:8f:7b:ac: + d8:ec:4b:b3:d2:da:ba:47:3d:19:12:cb:1d:12:ff: + dd:64:8b:d3:97:9f:56:80:b5:35:00:fa:fb:56:20: + 2c:96:d6:e5:73:87:30:72:98:11:ea:87:fa:35:cd: + 70:a9:f5:a2:16:b0:6d:64:d6:68:3e:4d:a5:fc:b8: + ec:d7:6e:9a:33:84:88:d7:50:ab:7f:2e:37:52:c4: + 21:80:6b:8e:4c:dc:95:c5:9e:a5:dd:46:c6:f0:6d: + bd:d6:03:d0:8b:5a:3c:4b:07:61:90:bb:4e:0b:58: + e5:be:1d:96:e7:66:03:12:96:6c:e7:e4:73:49:10: + 20:db:74:3d:ca:bd:c2:4d:47:46:4e:2f:1e:cc:09: + b7:0a:61:14:a0:b7:7a:0c:f1:5e:15:e8:87:4a:b8: + 3f:42:a3:73:8e:00:f5:81:e2:b9:1e:6a:b3:11:3e: + f9:84:0e:e8:59:17:fd:dd:8e:af:e2:88:09:88:43: + f6:89:15:af:91:36:b4:f8:b9:9f:a5:75:a1:39:21: + ad:03:fd:c0:60:c5:e7:aa:e3:4e:c3:bf:01:f8:e7: + 6b:dd:f7:7a:da:26:12:3c:d7:64:28:2e:da:36:d6: + fa:0b Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - D3:E2:DE:A9:CC:A9:BA:B8:09:17:9C:CB:DF:72:6A:D6:21:E8:31:22 + FB:DF:D4:89:A2:A9:E0:BE:B0:E3:FC:AD:C9:F9:80:85:3C:30:B5:81 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 4f:f3:66:42:14:a0:d3:74:04:f4:b2:09:ce:03:25:2d:e7:f9: - 21:40:0c:93:0c:ed:c3:f4:26:d7:0e:42:ee:d9:0e:ea:e4:fd: - d5:d4:c0:64:e1:ae:3e:8d:0d:ae:43:5e:29:35:cf:38:66:b2: - 1f:e7:33:92:4f:60:b5:7c:b6:39:26:66:da:27:ef:02:c3:d4: - a2:bd:75:51:c3:f3:2b:d7:5e:53:ff:71:66:31:ce:20:d5:49: - 78:fa:6d:47:75:f2:61:01:60:d7:2a:61:15:37:84:00:80:f3: - 65:ca:8b:2e:de:ad:54:04:94:8f:7d:c8:64:9f:b3:94:34:93: - c8:8c:23:f8:a1:10:1e:ba:e0:00:f1:8a:e3:49:98:cd:f4:2f: - 5e:e0:e0:e7:31:25:ca:bf:ae:68:e9:53:91:76:97:d0:d1:de: - 53:5f:73:df:c9:d0:94:20:e9:6e:d8:ef:cb:53:85:1d:93:59: - 91:57:6e:62:c4:cc:6a:90:27:c9:59:8b:c7:b3:fa:8d:90:84: - a0:a6:ef:e7:2e:94:95:83:3e:9d:f8:c1:a6:83:57:d1:ee:d9: - 29:aa:30:9f:f3:a2:71:82:96:1b:d7:c4:f4:e9:74:1b:27:48: - f6:87:96:77:f5:d8:95:21:e9:17:15:23:a3:21:76:f7:d9:f6: - 28:2e:91:24 + 4f:9f:49:7d:21:55:a4:d8:63:0c:79:2f:4a:62:cf:31:b9:94: + 18:e8:27:e3:de:73:53:19:0b:c0:cd:d0:35:89:40:a9:29:4c: + 64:2f:ae:77:4a:2d:b7:7a:1c:d7:8b:40:8b:5a:44:98:db:83: + 22:28:e7:4b:cc:4b:6d:49:a3:e4:23:ee:ae:73:c9:37:06:7b: + 12:c9:83:ef:50:64:bd:71:5b:01:9c:ff:5e:e9:86:91:51:a3: + f4:6e:15:07:4f:23:46:82:d7:11:95:79:e7:9c:9c:bb:10:90: + f5:da:9a:4e:6f:2a:b5:f5:68:ed:6c:a5:f1:69:6d:f6:aa:6d: + 02:df:10:c2:b1:7b:35:1d:20:9f:61:85:cb:81:9f:e7:aa:36: + 12:7a:f0:a3:31:29:a7:b4:a9:62:66:d6:2d:4d:3f:d8:9f:5c: + 1b:e2:06:31:37:92:51:a7:3f:5d:91:1b:45:c5:4b:be:b2:d8: + b9:59:f6:4d:45:52:af:d4:d0:db:f2:85:01:9b:fa:cf:1b:54: + 85:7c:79:3a:3f:f5:a8:b1:e9:d7:41:21:0b:d0:48:03:d0:ba: + ee:4d:cf:1e:df:f5:57:25:d9:1f:dc:34:4f:7b:f7:68:b3:65: + aa:e3:0f:50:e8:1f:0e:50:1a:c8:48:22:6b:bc:a1:ae:cc:b3: + 72:94:c2:24 -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqtDANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTA4MDEwMTAwMDAwMFoXDTE1MDEwMTAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAMLyOBl1mdgFqQQywSS48fqDRqpxenBGUQA7 -nfeUCIGKRGswsbh7+EMNO7U1XPpdVQGrr3NgMgKKkFlbHKDuxQ97SmdmoDq2X1Pg -FBdFry/IrmOv1GTtw/eg799ehxE7Gu4NVKndKjUmwD0hPdyBVoAQ3BEeuTtY9OkP -/NgKtdwg0p/EppW0IgJ1e0Bv7Z2kY4c4nGK2792vHhFqYRihh/XcsQKimvsN2Vr5 -g9OhbdYXzDYSdOIAFL09TufMsXPLkpBbDWbJ6mVknWhAH00Zi17h1Bc/J4FVdbhH -RkuHbLRcCuoGrmww6EFGSbv+CaumNeEKQObl7ifukksfqRxKDS0CAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFNPi3qnMqbq4CRecy99yatYh6DEiMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQBP82ZCFKDTdAT0sgnOAyUt5/khQAyTDO3D9CbXDkLu2Q7q5P3V1MBk4a4+jQ2u -Q14pNc84ZrIf5zOST2C1fLY5JmbaJ+8Cw9SivXVRw/Mr115T/3FmMc4g1Ul4+m1H -dfJhAWDXKmEVN4QAgPNlyosu3q1UBJSPfchkn7OUNJPIjCP4oRAeuuAA8YrjSZjN -9C9e4ODnMSXKv65o6VORdpfQ0d5TX3PfydCUIOlu2O/LU4Udk1mRV25ixMxqkCfJ -WYvHs/qNkISgpu/nLpSVgz6d+MGmg1fR7tkpqjCf86JxgpYb18T06XQbJ0j2h5Z3 -9diVIekXFSOjIXb32fYoLpEk +MIIDvzCCAqegAwIBAgIBEzANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTA4MDEwMTAw +MDAwMFoXDTE1MDEwMTAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAMmoCBqzCV0g9O57cw1Wgj3a1/PklDQEH9G/j3us2OxLs9Laukc9GRLL +HRL/3WSL05efVoC1NQD6+1YgLJbW5XOHMHKYEeqH+jXNcKn1ohawbWTWaD5Npfy4 +7NdumjOEiNdQq38uN1LEIYBrjkzclcWepd1GxvBtvdYD0ItaPEsHYZC7TgtY5b4d +ludmAxKWbOfkc0kQINt0Pcq9wk1HRk4vHswJtwphFKC3egzxXhXoh0q4P0Kjc44A +9YHiuR5qsxE++YQO6FkX/d2Or+KICYhD9okVr5E2tPi5n6V1oTkhrQP9wGDF56rj +TsO/Afjna933etomEjzXZCgu2jbW+gsCAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFPvf1ImiqeC+sOP8rcn5gIU8MLWBMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQBPn0l9IVWk2GMMeS9K +Ys8xuZQY6Cfj3nNTGQvAzdA1iUCpKUxkL653Si23ehzXi0CLWkSY24MiKOdLzEtt +SaPkI+6uc8k3BnsSyYPvUGS9cVsBnP9e6YaRUaP0bhUHTyNGgtcRlXnnnJy7EJD1 +2ppObyq19WjtbKXxaW32qm0C3xDCsXs1HSCfYYXLgZ/nqjYSevCjMSmntKliZtYt +TT/Yn1wb4gYxN5JRpz9dkRtFxUu+sti5WfZNRVKv1NDb8oUBm/rPG1SFfHk6P/Wo +senXQSEL0EgD0LruTc8e3/VXJdkf3DRPe/dos2Wq4w9Q6B8OUBrISCJrvKGuzLNy +lMIk -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/pre_june_2016.pem b/net/data/ssl/certificates/pre_june_2016.pem index 03eba7a9..766f3e9 100644 --- a/net/data/ssl/certificates/pre_june_2016.pem +++ b/net/data/ssl/certificates/pre_june_2016.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:ba - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 22 (0x16) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: May 1 00:00:00 2016 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:b3:61:e1:cd:72:d2:67:ac:82:e3:0a:2f:0e:71: - 84:8b:48:a0:3c:eb:3f:1f:5d:de:95:63:c0:8b:53: - 6a:b3:29:53:30:a8:d9:48:97:88:5f:6c:de:d3:1c: - 69:e5:99:54:e0:32:85:7e:be:37:07:9d:ee:e2:fb: - 01:3c:44:f4:2c:b1:e2:d7:73:61:e3:1f:69:25:00: - 0b:90:75:74:7d:b5:8c:be:02:ee:ee:f5:e9:4f:f5: - d3:1f:cf:17:aa:a9:d0:ef:85:f2:45:c4:6e:f5:d4: - 71:3f:f2:fc:40:e6:a8:b0:43:a3:d6:7f:d6:4a:a9: - c0:66:e1:1c:1c:ad:11:bf:bc:c8:c0:d7:a5:ee:e1: - 02:4c:0f:cc:da:3c:91:12:a5:13:c6:22:80:7e:73: - 9b:21:2e:71:81:cd:07:20:f8:60:31:9d:3f:5a:be: - 02:17:6b:7b:5d:b4:c1:af:3d:f3:5c:d8:e0:8d:a6: - db:6e:16:5e:87:06:ce:c3:c2:1e:1e:2d:3c:21:d6: - 65:f3:f4:94:6a:bc:b1:6b:3a:ea:72:13:40:03:b2: - 5c:dd:31:4a:78:41:c0:29:ee:3a:b6:32:64:42:07: - 06:ad:79:09:93:36:5c:d6:ec:2b:87:d2:09:f9:15: - 05:e1:45:48:2a:92:9f:8f:1f:b0:c2:d9:9d:28:11: - ec:05 + 00:b7:cf:66:d4:a6:c7:91:a5:b9:1e:8a:91:cf:51: + 54:07:f4:c2:a9:8e:ca:88:1f:51:cf:70:e2:93:07: + ff:17:9b:cf:ae:88:85:3d:ab:f6:66:be:ac:d5:ea: + 61:d7:54:86:36:12:dd:98:8c:bc:3a:86:54:f0:08: + d3:84:18:ab:ed:11:1a:41:1c:9f:cd:ec:97:8f:22: + 5a:f1:cb:d3:c0:bb:c2:ac:45:d4:bd:aa:ab:b3:ac: + ea:5b:da:20:24:e7:9e:03:97:3e:a4:c6:c1:ba:b4: + c4:69:6f:9d:7e:81:3d:58:96:80:0c:91:de:71:9f: + d8:24:73:8e:8b:f0:64:be:4e:9b:c4:3a:c1:9c:ef: + 3c:05:06:c7:a7:ba:34:1b:ff:d7:87:96:00:30:db: + 6d:74:f2:ae:f4:cb:a6:9e:b9:42:8a:58:6d:3e:e7: + 54:11:2e:b8:12:5a:c9:c1:21:d4:a1:c7:ce:5e:3e: + c5:75:03:38:7a:8d:20:13:ef:d8:f8:a4:9c:1e:04: + 7b:28:b0:d1:24:e1:14:d3:ff:18:2a:de:a0:c8:00: + 47:80:9a:86:c9:3d:0a:48:d8:0c:63:df:7b:1b:f3: + b6:d5:b8:14:1d:7a:40:eb:06:7c:23:b1:77:ab:1a: + 60:a2:36:7f:0a:e3:9b:75:01:11:7d:af:29:5b:7b: + f8:21 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 4E:EF:47:10:DD:E7:5D:A3:A5:CB:F7:26:3E:7F:2C:BD:63:3E:00:ED + D5:17:E7:68:DB:E1:51:CE:A3:7C:B7:76:EE:CD:89:C1:33:1E:98:86 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,114 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - bb:89:18:9e:99:ff:ac:70:9f:2f:f0:d4:67:34:a3:09:0e:00: - 0b:88:0a:1b:b8:24:0f:17:0e:5f:11:f9:9c:5d:d3:b1:20:c4: - 73:1b:cd:58:89:d6:4f:cd:1b:66:5f:c6:03:14:38:c3:ca:98: - d9:0b:83:7f:e4:99:63:80:31:08:95:66:9e:63:a0:7a:27:47: - fa:dd:b1:05:bc:e7:fc:8b:1a:2f:42:1d:62:46:e7:c9:c7:eb: - 5f:cb:5f:85:2d:10:6e:f1:45:a3:54:66:5a:bc:5b:26:10:f9: - c9:4e:55:0d:16:d1:7c:60:bd:70:76:f9:75:c8:5d:6e:26:df: - 3f:46:06:eb:5e:f6:c7:60:e8:60:4f:57:36:50:6a:f6:57:e7: - 7e:3d:6d:1b:90:59:dd:d4:11:f4:d0:fe:ed:18:7a:95:80:8b: - 9f:0a:3b:4d:9d:64:73:1d:6b:b0:1c:f4:df:af:68:39:1d:14: - 11:54:fd:79:6f:6c:56:fa:d6:72:93:0d:e9:7a:b6:7a:f8:11: - 1a:24:ad:6b:c4:fe:4f:42:c0:de:11:57:5e:be:6f:44:fd:d9: - e1:ba:f9:72:e0:27:ae:ca:15:74:40:71:1d:6e:68:f9:3a:b0: - f8:da:71:30:9c:ea:28:9c:48:08:81:55:59:27:20:98:c1:3e: - 4a:a1:1b:ba + 94:67:c8:ba:c7:18:21:a5:11:8c:39:e6:d2:17:47:a5:ac:04: + ce:88:a4:86:9d:a7:a9:3f:e2:fc:54:13:28:b3:4d:a4:04:96: + 21:cc:d1:3f:d2:94:fe:d3:bb:99:49:41:4d:2b:fc:61:be:a1: + 3c:01:88:03:1b:62:c6:5f:f8:ae:20:70:ba:82:65:50:10:ef: + f3:1e:7b:cd:76:c3:a2:77:b9:6f:28:13:3e:6e:76:57:2b:8a: + eb:4e:21:86:9d:f2:98:c9:89:f0:bd:c4:2c:62:e9:bd:3b:1f: + 50:ee:0f:94:65:9f:16:04:1f:27:18:a4:fc:7b:7c:b5:16:72: + 56:a2:dc:6c:6a:04:e8:45:03:82:d6:f5:54:9e:b2:59:f8:a2: + 8a:8b:77:ef:a3:ab:b2:b9:2b:a3:a6:40:45:b0:f3:48:3f:4b: + 18:d2:8d:49:45:ab:a8:34:46:c9:70:9d:02:75:3b:7e:27:9f: + 11:69:0a:fa:46:25:3e:e0:17:24:32:12:c2:2a:a9:4a:a2:d5: + 8e:62:b9:2d:3e:75:f9:d0:84:cd:e3:cb:45:16:81:3b:5a:80: + 7c:d9:96:78:76:9f:df:ae:93:61:8e:b8:31:28:d6:a2:6c:80: + 86:67:06:33:1b:71:7d:73:62:df:fc:e1:6c:01:b4:6d:73:19: + 50:fe:1e:47 -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqujANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE2MDUwMTAwMDAwMFoXDTE3MDcwMzAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBALNh4c1y0mesguMKLw5xhItIoDzrPx9d3pVj -wItTarMpUzCo2UiXiF9s3tMcaeWZVOAyhX6+Nwed7uL7ATxE9Cyx4tdzYeMfaSUA -C5B1dH21jL4C7u716U/10x/PF6qp0O+F8kXEbvXUcT/y/EDmqLBDo9Z/1kqpwGbh -HBytEb+8yMDXpe7hAkwPzNo8kRKlE8YigH5zmyEucYHNByD4YDGdP1q+Ahdre120 -wa8981zY4I2m224WXocGzsPCHh4tPCHWZfP0lGq8sWs66nITQAOyXN0xSnhBwCnu -OrYyZEIHBq15CZM2XNbsK4fSCfkVBeFFSCqSn48fsMLZnSgR7AUCAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFE7vRxDd512jpcv3Jj5/LL1jPgDtMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQC7iRiemf+scJ8v8NRnNKMJDgALiAobuCQPFw5fEfmcXdOxIMRzG81YidZPzRtm -X8YDFDjDypjZC4N/5JljgDEIlWaeY6B6J0f63bEFvOf8ixovQh1iRufJx+tfy1+F -LRBu8UWjVGZavFsmEPnJTlUNFtF8YL1wdvl1yF1uJt8/RgbrXvbHYOhgT1c2UGr2 -V+d+PW0bkFnd1BH00P7tGHqVgIufCjtNnWRzHWuwHPTfr2g5HRQRVP15b2xW+tZy -kw3perZ6+BEaJK1rxP5PQsDeEVdevm9E/dnhuvly4CeuyhV0QHEdbmj5OrD42nEw -nOoonEgIgVVZJyCYwT5KoRu6 +MIIDvzCCAqegAwIBAgIBFjANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE2MDUwMTAw +MDAwMFoXDTE3MDcwMzAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBALfPZtSmx5GluR6Kkc9RVAf0wqmOyogfUc9w4pMH/xebz66IhT2r9ma+ +rNXqYddUhjYS3ZiMvDqGVPAI04QYq+0RGkEcn83sl48iWvHL08C7wqxF1L2qq7Os +6lvaICTnngOXPqTGwbq0xGlvnX6BPViWgAyR3nGf2CRzjovwZL5Om8Q6wZzvPAUG +x6e6NBv/14eWADDbbXTyrvTLpp65QopYbT7nVBEuuBJaycEh1KHHzl4+xXUDOHqN +IBPv2PiknB4Eeyiw0SThFNP/GCreoMgAR4Cahsk9CkjYDGPfexvzttW4FB16QOsG +fCOxd6saYKI2fwrjm3UBEX2vKVt7+CECAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFNUX52jb4VHOo3y3du7NicEzHpiGMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQCUZ8i6xxghpRGMOebS +F0elrATOiKSGnaepP+L8VBMos02kBJYhzNE/0pT+07uZSUFNK/xhvqE8AYgDG2LG +X/iuIHC6gmVQEO/zHnvNdsOid7lvKBM+bnZXK4rrTiGGnfKYyYnwvcQsYum9Ox9Q +7g+UZZ8WBB8nGKT8e3y1FnJWotxsagToRQOC1vVUnrJZ+KKKi3fvo6uyuSujpkBF +sPNIP0sY0o1JRauoNEbJcJ0CdTt+J58RaQr6RiU+4BckMhLCKqlKotWOYrktPnX5 +0ITN48tFFoE7WoB82ZZ4dp/frpNhjrgxKNaibICGZwYzG3F9c2Lf/OFsAbRtcxlQ +/h5H -----END CERTIFICATE----- + +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 903804111 (0x35def4cf) + Signature Algorithm: sha1WithRSAEncryption + Issuer: C=US, O=Equifax, OU=Equifax Secure Certificate Authority + Validity + Not Before: Aug 22 16:41:51 1998 GMT + Not After : Aug 22 16:41:51 2018 GMT + Subject: C=US, O=Equifax, OU=Equifax Secure Certificate Authority + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + Public-Key: (1024 bit) + Modulus: + 00:c1:5d:b1:58:67:08:62:ee:a0:9a:2d:1f:08:6d: + 91:14:68:98:0a:1e:fe:da:04:6f:13:84:62:21:c3: + d1:7c:ce:9f:05:e0:b8:01:f0:4e:34:ec:e2:8a:95: + 04:64:ac:f1:6b:53:5f:05:b3:cb:67:80:bf:42:02: + 8e:fe:dd:01:09:ec:e1:00:14:4f:fc:fb:f0:0c:dd: + 43:ba:5b:2b:e1:1f:80:70:99:15:57:93:16:f1:0f: + 97:6a:b7:c2:68:23:1c:cc:4d:59:30:ac:51:1e:3b: + af:2b:d6:ee:63:45:7b:c5:d9:5f:50:d2:e3:50:0f: + 3a:88:e7:bf:14:fd:e0:c7:b9 + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 CRL Distribution Points: + + Full Name: + DirName: C = US, O = Equifax, OU = Equifax Secure Certificate Authority, CN = CRL1 + + X509v3 Private Key Usage Period: + Not After: Aug 22 16:41:51 2018 GMT + X509v3 Key Usage: + Certificate Sign, CRL Sign + X509v3 Authority Key Identifier: + keyid:48:E6:68:F9:2B:D2:B2:95:D7:47:D8:23:20:10:4F:33:98:90:9F:D4 + + X509v3 Subject Key Identifier: + 48:E6:68:F9:2B:D2:B2:95:D7:47:D8:23:20:10:4F:33:98:90:9F:D4 + X509v3 Basic Constraints: + CA:TRUE + 1.2.840.113533.7.65.0: + 0...V3.0c.... + Signature Algorithm: sha1WithRSAEncryption + 58:ce:29:ea:fc:f7:de:b5:ce:02:b9:17:b5:85:d1:b9:e3:e0: + 95:cc:25:31:0d:00:a6:92:6e:7f:b6:92:63:9e:50:95:d1:9a: + 6f:e4:11:de:63:85:6e:98:ee:a8:ff:5a:c8:d3:55:b2:66:71: + 57:de:c0:21:eb:3d:2a:a7:23:49:01:04:86:42:7b:fc:ee:7f: + a2:16:52:b5:67:67:d3:40:db:3b:26:58:b2:28:77:3d:ae:14: + 77:61:d6:fa:2a:66:27:a0:0d:fa:a7:73:5c:ea:70:f1:94:21: + 65:44:5f:fa:fc:ef:29:68:a9:a2:87:79:ef:79:ef:4f:ac:07: + 77:38 +-----BEGIN CERTIFICATE----- +MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJV +UzEQMA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2Vy +dGlmaWNhdGUgQXV0aG9yaXR5MB4XDTk4MDgyMjE2NDE1MVoXDTE4MDgyMjE2NDE1 +MVowTjELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0VxdWlmYXgxLTArBgNVBAsTJEVx +dWlmYXggU2VjdXJlIENlcnRpZmljYXRlIEF1dGhvcml0eTCBnzANBgkqhkiG9w0B +AQEFAAOBjQAwgYkCgYEAwV2xWGcIYu6gmi0fCG2RFGiYCh7+2gRvE4RiIcPRfM6f +BeC4AfBONOziipUEZKzxa1NfBbPLZ4C/QgKO/t0BCezhABRP/PvwDN1Dulsr4R+A +cJkVV5MW8Q+XarfCaCMczE1ZMKxRHjuvK9buY0V7xdlfUNLjUA86iOe/FP3gx7kC +AwEAAaOCAQkwggEFMHAGA1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQ +MA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlm +aWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTgw +ODIyMTY0MTUxWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvSspXXR9gj +IBBPM5iQn9QwHQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQF +MAMBAf8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUA +A4GBAFjOKer89961zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y +7qj/WsjTVbJmcVfewCHrPSqnI0kBBIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2uFHdh +1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4 +-----END CERTIFICATE----- +
diff --git a/net/data/ssl/certificates/punycodetest.pem b/net/data/ssl/certificates/punycodetest.pem index 395d3f7..8b7fe73 100644 --- a/net/data/ssl/certificates/punycodetest.pem +++ b/net/data/ssl/certificates/punycodetest.pem
@@ -1,36 +1,35 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 04:cd:5c:46:2c:7b:65:5b:b6:d2:f4:4b:44:90:ea:c1:c9:a1:3b:43 - Signature Algorithm: sha256WithRSAEncryption - Issuer: CN = xn--wgv71a119e.com + Serial Number: 10431067552074120060 (0x90c298ac257b3b7c) + Signature Algorithm: sha256WithRSAEncryption + Issuer: CN=xn--wgv71a119e.com Validity - Not Before: Mar 13 20:46:17 2020 GMT - Not After : Mar 11 20:46:17 2030 GMT - Subject: CN = xn--wgv71a119e.com + Not Before: Jun 5 17:10:47 2017 GMT + Not After : Jun 3 17:10:47 2027 GMT + Subject: CN=xn--wgv71a119e.com Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:bc:b7:6b:11:ab:e6:14:5a:73:0e:f1:c6:f1:8a: - 33:4e:5d:96:1a:d9:be:fa:47:a7:0a:8d:2a:30:c5: - fe:65:ab:24:a5:15:c1:b7:55:b2:3b:8a:bc:8c:d2: - 18:d8:82:e9:95:2d:84:36:a5:d5:53:9a:03:cb:fb: - 35:4c:22:f3:0f:fb:b6:23:ba:54:d0:ef:64:f8:85: - 8f:c3:8d:a8:a6:ec:5f:1a:ca:d7:d5:1f:3d:55:66: - 44:9a:35:54:1a:be:7a:40:03:7c:e4:98:cd:2a:e1: - 4d:49:0f:af:c0:6e:6a:e1:36:72:1a:a2:db:c7:db: - 94:bd:0e:b4:2e:ba:c6:f4:7b:39:bc:c3:2a:55:ca: - b3:80:dd:f9:e7:99:7c:69:05:28:eb:84:d6:48:cf: - ad:81:91:70:7e:54:ae:f4:79:31:03:3a:7d:7c:b7: - 7f:9b:31:83:65:2d:cf:dc:55:18:c0:09:96:a8:1e: - 1b:a5:2a:14:da:47:e7:a7:7a:77:9e:80:f0:b5:b1: - 02:08:a7:49:66:68:86:ef:1f:cb:14:a4:cb:33:df: - 36:35:fd:f6:0b:91:c4:11:4a:c3:d4:d0:c1:93:c6: - 74:d3:ae:dc:27:eb:cf:e3:f7:4c:d7:69:8b:28:99: - 7b:26:fb:84:14:cc:25:29:c1:aa:20:95:68:5b:7e: - a1:01 + 00:c7:8e:c3:54:a1:02:4a:e0:97:7a:13:a3:42:57: + 03:9e:f5:1e:61:69:35:f3:be:f8:92:2d:fe:47:5e: + 0d:dc:7d:b8:79:bb:ce:7d:dd:ce:45:82:ff:ce:23: + 56:0d:b3:08:ef:ab:67:02:50:6d:e6:dc:83:e1:9e: + a9:ac:5b:6a:6d:bd:b1:ef:78:d5:5c:4d:1f:d0:47: + d9:b3:d8:d0:5c:ad:fc:76:ac:7f:f7:33:b3:a0:bc: + 99:3f:b7:8b:e1:ca:d7:98:78:d4:aa:10:1a:9a:1a: + 84:f8:a9:fe:34:96:75:66:1c:36:5f:2d:8d:12:bf: + 7e:24:7c:87:b3:d5:f4:07:73:d6:b8:e2:a0:f1:11: + fe:6b:37:0a:cb:0f:e4:23:b3:67:77:3c:16:72:af: + c5:11:62:18:1d:9e:be:f9:ce:62:29:91:2e:7f:2f: + c5:ee:de:98:ef:f8:43:97:cc:65:92:87:4f:70:5d: + 62:23:f2:22:dc:48:e1:7c:9e:97:e5:d3:84:27:93: + 37:d6:45:ea:e3:1d:de:9f:06:b5:99:2d:2a:70:ab: + 76:34:95:7d:3d:43:9f:c8:35:5b:06:cf:94:d9:7c: + ed:cf:a3:b3:0b:f1:ad:b6:9d:cd:44:17:61:c8:97: + 7a:26:10:4b:fd:ae:6d:11:a9:87:cc:14:eb:24:32: + eb:9d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical @@ -38,37 +37,37 @@ X509v3 Subject Alternative Name: DNS:xn--wgv71a119e.com, DNS:*.xn--wgv71a119e.com, DNS:blahblahblahblah.com Signature Algorithm: sha256WithRSAEncryption - 83:3a:94:b3:f4:0d:82:b3:62:9f:a6:0e:34:5d:f6:d2:d7:4b: - 4e:23:4a:a6:10:9b:70:54:a3:b2:68:79:1b:4e:a7:05:75:bd: - 2d:14:b3:21:5a:3f:e6:9c:1b:f5:0b:5f:c0:36:cf:81:74:e3: - 4a:81:f6:54:e3:c2:6a:da:c8:7e:d8:59:7f:cb:6b:dd:40:88: - 47:bb:4a:22:7c:33:33:38:21:b1:60:33:67:84:b7:d2:2c:ad: - 26:ea:a2:22:2a:96:07:37:23:c1:94:9f:36:98:a9:9d:fd:72: - ba:f0:f1:ad:ae:3b:bc:cd:e7:25:c8:c1:11:df:23:f6:89:9a: - 0b:0d:c1:2f:e0:f4:35:8f:51:0d:b9:b9:06:37:d1:3b:7c:eb: - 5b:48:3b:0e:0f:90:01:56:d8:94:7e:38:1b:08:b5:f2:a9:2a: - e5:83:0d:84:3f:78:62:45:eb:25:24:69:c8:c4:20:7b:2f:bb: - 3d:0d:fb:27:84:7f:9f:cd:61:62:8b:dc:a0:93:8e:66:a9:61: - 28:4e:3a:5b:4d:8b:1e:34:4f:31:10:3d:fc:dd:68:ce:99:2f: - a9:36:57:f5:31:e9:d4:96:cd:d3:3d:ed:9a:ce:5a:df:95:64: - 0a:62:69:3e:59:6b:98:ca:ed:34:e0:6d:9e:0b:5e:70:50:a8: - 30:69:1b:ca + c4:81:b1:91:37:f7:df:1e:a4:56:f6:03:95:4c:67:2d:b9:a3: + ed:e0:2c:37:2d:bd:d1:6a:9e:a2:c4:66:3b:f8:7c:5a:cb:ec: + 57:64:e6:1d:20:85:cc:24:99:33:9c:cd:38:0e:03:c4:13:f6: + b4:c6:d1:ea:6c:bd:34:1b:71:24:15:35:20:be:87:a0:97:0e: + 32:42:24:18:b8:8b:0f:15:da:73:42:0e:d7:fa:b9:7a:1b:a9: + 3e:71:64:a0:12:36:91:1f:5f:ae:0d:c4:26:22:fb:19:11:b6: + 75:92:1e:f4:ef:79:68:ef:9b:fc:3a:a6:11:9d:aa:9e:11:64: + 74:54:ba:80:a0:b9:3b:28:f9:3d:54:95:25:da:54:8e:38:47: + 6a:b0:d5:ec:33:a6:3c:b7:60:86:c9:03:ee:7d:5e:3f:c5:f1: + e8:4c:1d:4a:20:be:02:43:bd:e2:cc:4c:c6:13:2a:4a:b8:80: + 67:98:7b:5f:ae:3b:48:16:ba:46:da:a1:0e:88:22:85:f9:48: + 1b:04:64:0f:09:a5:89:1e:4f:ca:ce:39:60:27:f3:ea:ee:29: + ff:27:58:88:ad:eb:1d:ac:6a:46:a5:66:a3:43:e9:7f:ce:01: + 8a:33:31:a2:fc:64:26:9b:e9:0e:a9:af:76:be:b7:d9:59:6a: + 71:15:b4:fb -----BEGIN CERTIFICATE----- -MIIDJjCCAg6gAwIBAgIUBM1cRix7ZVu20vRLRJDqwcmhO0MwDQYJKoZIhvcNAQEL -BQAwHTEbMBkGA1UEAwwSeG4tLXdndjcxYTExOWUuY29tMB4XDTIwMDMxMzIwNDYx -N1oXDTMwMDMxMTIwNDYxN1owHTEbMBkGA1UEAwwSeG4tLXdndjcxYTExOWUuY29t -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvLdrEavmFFpzDvHG8Yoz -Tl2WGtm++kenCo0qMMX+ZaskpRXBt1WyO4q8jNIY2ILplS2ENqXVU5oDy/s1TCLz -D/u2I7pU0O9k+IWPw42opuxfGsrX1R89VWZEmjVUGr56QAN85JjNKuFNSQ+vwG5q -4TZyGqLbx9uUvQ60LrrG9Hs5vMMqVcqzgN3555l8aQUo64TWSM+tgZFwflSu9Hkx -Azp9fLd/mzGDZS3P3FUYwAmWqB4bpSoU2kfnp3p3noDwtbECCKdJZmiG7x/LFKTL -M982Nf32C5HEEUrD1NDBk8Z0067cJ+vP4/dM12mLKJl7JvuEFMwlKcGqIJVoW36h -AQIDAQABo14wXDAPBgNVHRMBAf8EBTADAQH/MEkGA1UdEQRCMECCEnhuLS13Z3Y3 -MWExMTllLmNvbYIUKi54bi0td2d2NzFhMTE5ZS5jb22CFGJsYWhibGFoYmxhaGJs -YWguY29tMA0GCSqGSIb3DQEBCwUAA4IBAQCDOpSz9A2Cs2Kfpg40XfbS10tOI0qm -EJtwVKOyaHkbTqcFdb0tFLMhWj/mnBv1C1/ANs+BdONKgfZU48Jq2sh+2Fl/y2vd -QIhHu0oifDMzOCGxYDNnhLfSLK0m6qIiKpYHNyPBlJ82mKmd/XK68PGtrju8zecl -yMER3yP2iZoLDcEv4PQ1j1ENubkGN9E7fOtbSDsOD5ABVtiUfjgbCLXyqSrlgw2E -P3hiReslJGnIxCB7L7s9DfsnhH+fzWFii9ygk45mqWEoTjpbTYseNE8xED383WjO -mS+pNlf1MenUls3TPe2azlrflWQKYmk+WWuYyu004G2eC15wUKgwaRvK +MIIDGzCCAgOgAwIBAgIJAJDCmKwlezt8MA0GCSqGSIb3DQEBCwUAMB0xGzAZBgNV +BAMMEnhuLS13Z3Y3MWExMTllLmNvbTAeFw0xNzA2MDUxNzEwNDdaFw0yNzA2MDMx +NzEwNDdaMB0xGzAZBgNVBAMMEnhuLS13Z3Y3MWExMTllLmNvbTCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAMeOw1ShAkrgl3oTo0JXA571HmFpNfO++JIt +/kdeDdx9uHm7zn3dzkWC/84jVg2zCO+rZwJQbebcg+Geqaxbam29se941VxNH9BH +2bPY0Fyt/Hasf/czs6C8mT+3i+HK15h41KoQGpoahPip/jSWdWYcNl8tjRK/fiR8 +h7PV9Adz1rjioPER/ms3CssP5COzZ3c8FnKvxRFiGB2evvnOYimRLn8vxe7emO/4 +Q5fMZZKHT3BdYiPyItxI4Xyel+XThCeTN9ZF6uMd3p8GtZktKnCrdjSVfT1Dn8g1 +WwbPlNl87c+jswvxrbadzUQXYciXeiYQS/2ubRGph8wU6yQy650CAwEAAaNeMFww +DwYDVR0TAQH/BAUwAwEB/zBJBgNVHREEQjBAghJ4bi0td2d2NzFhMTE5ZS5jb22C +FCoueG4tLXdndjcxYTExOWUuY29tghRibGFoYmxhaGJsYWhibGFoLmNvbTANBgkq +hkiG9w0BAQsFAAOCAQEAxIGxkTf33x6kVvYDlUxnLbmj7eAsNy290WqeosRmO/h8 +WsvsV2TmHSCFzCSZM5zNOA4DxBP2tMbR6my9NBtxJBU1IL6HoJcOMkIkGLiLDxXa +c0IO1/q5ehupPnFkoBI2kR9frg3EJiL7GRG2dZIe9O95aO+b/DqmEZ2qnhFkdFS6 +gKC5Oyj5PVSVJdpUjjhHarDV7DOmPLdghskD7n1eP8Xx6EwdSiC+AkO94sxMxhMq +SriAZ5h7X647SBa6RtqhDogihflIGwRkDwmliR5Pys45YCfz6u4p/ydYiK3rHaxq +RqVmo0Ppf84BijMxovxkJpvpDqmvdr632VlqcRW0+w== -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/reject_intranet_hosts.pem b/net/data/ssl/certificates/reject_intranet_hosts.pem index 7b6dc4b..a6b3f64fae 100644 --- a/net/data/ssl/certificates/reject_intranet_hosts.pem +++ b/net/data/ssl/certificates/reject_intranet_hosts.pem
@@ -1,70 +1,69 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 6c:1d:7a:e2:b9:1c:2d:09:02:53:44:45:4e:95:06:dc:d5:64:0b:1d - Signature Algorithm: sha256WithRSAEncryption - Issuer: CN = webmail + Serial Number: 15572396188146182397 (0xd81c43d3b819a8fd) + Signature Algorithm: sha256WithRSAEncryption + Issuer: CN=webmail Validity - Not Before: Mar 13 20:46:17 2020 GMT - Not After : Mar 13 20:46:17 2022 GMT - Subject: CN = webmail + Not Before: Jun 5 17:10:47 2017 GMT + Not After : Jun 4 17:10:47 2020 GMT + Subject: CN=webmail Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:af:63:3b:72:45:a9:9e:9a:ea:4d:00:50:51:b0: - 94:52:a1:41:21:fa:cd:20:bd:2d:e8:05:16:5f:41: - 7c:58:4a:cb:af:f1:d3:23:af:d2:4f:2e:52:f3:f7: - df:4b:57:27:ab:43:01:5f:01:2f:c0:5d:a3:a2:15: - ff:78:f5:c2:df:50:41:f6:c4:7b:0f:b4:7f:a3:fe: - d1:7b:58:4f:92:28:8b:11:12:9d:d5:24:7d:ed:08: - 60:aa:1a:09:9d:e5:57:d2:ae:fe:01:02:a9:91:7b: - e5:42:a6:58:d6:f8:56:3d:9f:59:38:de:ed:d2:05: - 8f:26:2a:2d:b1:c9:bf:16:2b:55:20:cc:d9:66:50: - 45:f6:c0:ad:7a:19:19:aa:06:17:ad:41:79:1b:f1: - 9c:fc:ee:04:63:e4:0b:c7:b9:ad:89:4b:a2:b5:f7: - 75:1d:73:06:c8:cd:82:0d:1b:d0:be:fb:0d:e9:34: - 3f:4c:09:cc:31:eb:cd:a5:fa:a7:d9:01:0b:d4:c8: - 58:f0:1f:e4:cd:ed:77:f8:d3:08:14:3f:30:d7:6f: - ba:e8:ee:fd:27:09:8a:96:03:0e:3f:5d:59:d3:c8: - 97:19:e7:0e:0b:9d:34:9d:0c:06:7d:38:66:3e:52: - 59:58:4b:53:8f:ed:eb:36:5b:81:16:62:74:8e:71: - b8:3b + 00:ea:65:9e:eb:22:3a:b0:1c:eb:57:da:85:42:7e: + 2a:3d:f7:a7:54:b5:81:19:71:c3:b5:ae:ee:7e:85: + 1a:7a:23:61:76:3b:4e:bc:a6:a6:7f:e7:3d:b5:4b: + b8:d3:c9:df:d2:a2:36:11:9f:9f:bc:36:19:87:4c: + 43:89:c1:b3:0e:2c:bd:36:d7:d3:a4:00:52:06:01: + fb:a8:99:49:5c:46:bc:2b:9c:52:6e:b6:d0:e8:7d: + 4a:e6:a3:d3:e0:d9:f4:cf:e5:67:e7:37:51:fc:d5: + 5f:03:70:9c:b0:4b:c9:f4:db:91:42:86:40:60:73: + d8:7d:38:f1:e4:a8:16:93:e2:83:0f:03:52:9b:9c: + d0:d0:6d:3d:be:04:9c:14:21:b0:e5:97:c9:02:9e: + 92:34:2d:02:70:0a:74:21:91:1d:f7:cd:27:49:7f: + 93:48:5d:7a:02:d9:00:bd:3f:ab:ce:0c:96:3f:a5: + b0:04:93:b9:14:62:5b:c4:8d:ee:3e:bc:2d:aa:a7: + b5:ca:54:58:98:3f:a3:41:d4:e8:87:08:02:7d:89: + bf:2a:83:ae:ba:92:22:8e:19:3c:55:6b:f8:f4:53: + c3:03:e9:14:1d:5c:80:e1:71:5f:6a:2e:51:cf:d2: + 2d:2a:5d:50:58:03:06:70:be:1e:6e:d5:e0:2b:b2: + 7d:9d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Subject Alternative Name: DNS:webmail Signature Algorithm: sha256WithRSAEncryption - 5a:7a:bd:21:d7:17:c0:4c:2c:20:cf:88:a3:c9:10:46:33:0b: - 97:b4:41:c2:a2:3a:f8:1d:f5:f7:b6:9d:f3:60:21:60:61:d9: - ef:17:a4:89:f1:31:d0:f7:47:75:89:22:da:78:ae:78:c4:6f: - f2:f0:1c:ab:b7:1e:12:45:e6:3d:e6:75:27:40:33:03:12:71: - 96:23:a3:e6:2a:8f:5e:82:42:43:aa:41:cf:63:f7:d6:53:32: - 38:09:5b:38:b3:97:ea:ae:1e:e5:e4:03:1c:32:67:9f:d5:87: - 07:ec:8d:17:c0:c6:7e:c1:45:9a:4e:06:04:b8:34:66:06:cf: - 68:4e:00:a8:a9:d7:7d:15:d5:1f:53:6f:23:d5:b1:b4:d7:8a: - 2e:ea:39:88:b3:a8:44:a0:3b:29:52:78:55:b0:74:9c:cf:17: - 32:2d:20:ed:ae:51:5f:7d:3b:02:56:14:36:e0:21:db:5a:c7: - dc:1f:ec:94:45:84:e2:9b:4c:b5:45:5a:06:f1:d7:8b:63:fe: - f0:cf:3d:ae:0e:cf:f2:e0:73:75:ab:07:31:47:a5:02:9c:b0: - 4c:46:bd:13:b7:59:27:82:a0:9d:7c:a3:0a:6b:6b:82:ef:5f: - bd:5f:42:fd:b4:f5:67:67:b9:48:b8:7d:76:25:49:20:c1:0e: - f5:6b:56:d8 + 69:b0:cd:3e:65:2f:da:f6:0f:13:e8:ba:91:0d:c6:1a:4c:71: + 5a:4f:b6:2a:4d:87:29:53:7b:9d:53:c1:fb:bc:46:be:13:34: + 68:0f:57:6d:85:85:93:5f:69:74:ea:3d:34:8c:bc:c2:64:8e: + 59:e0:53:d8:ac:35:64:c3:77:19:d6:dd:4d:cc:b9:f3:9e:fb: + d7:d8:78:7b:5a:d2:aa:01:72:89:73:a1:a5:b2:75:01:ba:04: + 33:65:4f:eb:37:d4:41:3b:9c:3f:7a:d6:22:61:e6:fe:8d:92: + cf:f1:e0:70:ad:58:2f:5c:37:0c:69:1c:bf:05:f7:ec:9b:cb: + 87:eb:bd:8d:13:45:bf:ac:3c:80:d7:e4:f1:bd:40:50:dc:25: + 98:4f:50:13:8c:65:bc:c9:5f:62:33:c3:b6:13:34:22:d2:18: + c5:80:77:bb:46:44:68:33:b3:50:f2:dc:de:5a:03:b3:9c:e9: + f5:15:65:29:55:56:10:cd:bd:c7:54:59:9e:4a:1a:3b:9c:64: + d5:1e:fb:fa:26:d7:ba:5d:14:59:3a:3a:8e:61:98:4e:41:24: + 4c:c3:a0:25:26:f8:16:ba:d9:22:51:54:69:1e:a4:cf:d9:21: + 30:de:3a:09:31:55:d5:bd:3d:ab:2f:c0:37:c6:78:54:df:38: + 8c:02:bb:70 -----BEGIN CERTIFICATE----- -MIICyDCCAbCgAwIBAgIUbB164rkcLQkCU0RFTpUG3NVkCx0wDQYJKoZIhvcNAQEL -BQAwEjEQMA4GA1UEAwwHd2VibWFpbDAeFw0yMDAzMTMyMDQ2MTdaFw0yMjAzMTMy -MDQ2MTdaMBIxEDAOBgNVBAMMB3dlYm1haWwwggEiMA0GCSqGSIb3DQEBAQUAA4IB -DwAwggEKAoIBAQCvYztyRamemupNAFBRsJRSoUEh+s0gvS3oBRZfQXxYSsuv8dMj -r9JPLlLz999LVyerQwFfAS/AXaOiFf949cLfUEH2xHsPtH+j/tF7WE+SKIsREp3V -JH3tCGCqGgmd5VfSrv4BAqmRe+VCpljW+FY9n1k43u3SBY8mKi2xyb8WK1UgzNlm -UEX2wK16GRmqBhetQXkb8Zz87gRj5AvHua2JS6K193UdcwbIzYING9C++w3pND9M -Ccwx682l+qfZAQvUyFjwH+TN7Xf40wgUPzDXb7ro7v0nCYqWAw4/XVnTyJcZ5w4L -nTSdDAZ9OGY+UllYS1OP7es2W4EWYnSOcbg7AgMBAAGjFjAUMBIGA1UdEQQLMAmC -B3dlYm1haWwwDQYJKoZIhvcNAQELBQADggEBAFp6vSHXF8BMLCDPiKPJEEYzC5e0 -QcKiOvgd9fe2nfNgIWBh2e8XpInxMdD3R3WJItp4rnjEb/LwHKu3HhJF5j3mdSdA -MwMScZYjo+Yqj16CQkOqQc9j99ZTMjgJWzizl+quHuXkAxwyZ5/VhwfsjRfAxn7B -RZpOBgS4NGYGz2hOAKip130V1R9TbyPVsbTXii7qOYizqESgOylSeFWwdJzPFzIt -IO2uUV99OwJWFDbgIdtax9wf7JRFhOKbTLVFWgbx14tj/vDPPa4Oz/Lgc3WrBzFH -pQKcsExGvRO3WSeCoJ18owpra4LvX71fQv209WdnuUi4fXYlSSDBDvVrVtg= +MIICvTCCAaWgAwIBAgIJANgcQ9O4Gaj9MA0GCSqGSIb3DQEBCwUAMBIxEDAOBgNV +BAMMB3dlYm1haWwwHhcNMTcwNjA1MTcxMDQ3WhcNMjAwNjA0MTcxMDQ3WjASMRAw +DgYDVQQDDAd3ZWJtYWlsMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA +6mWe6yI6sBzrV9qFQn4qPfenVLWBGXHDta7ufoUaeiNhdjtOvKamf+c9tUu408nf +0qI2EZ+fvDYZh0xDicGzDiy9NtfTpABSBgH7qJlJXEa8K5xSbrbQ6H1K5qPT4Nn0 +z+Vn5zdR/NVfA3CcsEvJ9NuRQoZAYHPYfTjx5KgWk+KDDwNSm5zQ0G09vgScFCGw +5ZfJAp6SNC0CcAp0IZEd980nSX+TSF16AtkAvT+rzgyWP6WwBJO5FGJbxI3uPrwt +qqe1ylRYmD+jQdTohwgCfYm/KoOuupIijhk8VWv49FPDA+kUHVyA4XFfai5Rz9It +Kl1QWAMGcL4ebtXgK7J9nQIDAQABoxYwFDASBgNVHREECzAJggd3ZWJtYWlsMA0G +CSqGSIb3DQEBCwUAA4IBAQBpsM0+ZS/a9g8T6LqRDcYaTHFaT7YqTYcpU3udU8H7 +vEa+EzRoD1dthYWTX2l06j00jLzCZI5Z4FPYrDVkw3cZ1t1NzLnznvvX2Hh7WtKq +AXKJc6GlsnUBugQzZU/rN9RBO5w/etYiYeb+jZLP8eBwrVgvXDcMaRy/Bffsm8uH +672NE0W/rDyA1+TxvUBQ3CWYT1ATjGW8yV9iM8O2EzQi0hjFgHe7RkRoM7NQ8tze +WgOznOn1FWUpVVYQzb3HVFmeSho7nGTVHvv6Jte6XRRZOjqOYZhOQSRMw6AlJvgW +utkiUVRpHqTP2SEw3joJMVXVvT2rL8A3xnhU3ziMArtw -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/root_ca_cert.pem b/net/data/ssl/certificates/root_ca_cert.pem index e7e99ed..73172139 100644 --- a/net/data/ssl/certificates/root_ca_cert.pem +++ b/net/data/ssl/certificates/root_ca_cert.pem
@@ -28,17 +28,16 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 2f:25:f3:ce:3c:5e:72:d0:33:29:f6:09:1f:5d:5f:53:d9:ac:23:bb - Signature Algorithm: sha256WithRSAEncryption - Issuer: C = US, ST = California, L = Mountain View, O = Test CA, CN = Test Root CA + Serial Number: 10687961985666567129 (0x945344cc7888cbd9) + Signature Algorithm: sha256WithRSAEncryption + Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity - Not Before: Mar 13 20:46:16 2020 GMT - Not After : Mar 11 20:46:16 2030 GMT - Subject: C = US, ST = California, L = Mountain View, O = Test CA, CN = Test Root CA + Not Before: Jun 5 17:10:44 2017 GMT + Not After : Jun 3 17:10:44 2027 GMT + Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: 00:c6:81:1f:92:73:b6:58:85:d9:8d:ac:b7:20:fd: c7:bf:40:b2:ea:fa:e5:0b:52:01:8f:9a:c1:eb:7a: @@ -67,40 +66,39 @@ X509v3 Key Usage: critical Certificate Sign, CRL Sign Signature Algorithm: sha256WithRSAEncryption - b1:b1:83:61:af:db:ed:98:cf:3d:43:5f:a7:42:b8:6d:94:36: - 57:bb:ab:04:ee:dd:3b:b7:6d:ec:78:7d:46:59:b1:e6:2a:c3: - aa:a5:70:a7:e1:0c:fa:65:37:c6:cb:7d:a1:37:35:a1:ff:f0: - dd:ce:b6:a4:2c:12:d4:46:a9:9c:a2:91:3a:b0:95:55:97:55: - e6:0a:da:63:60:24:19:ac:20:c9:b1:94:40:e9:99:b1:f5:c3: - ed:61:5d:de:4c:e4:eb:d9:0e:ac:3a:0a:fc:44:7d:0f:77:a6: - b6:da:28:d4:ed:ea:3a:bc:57:23:9c:72:2b:2d:b0:5d:11:02: - 4d:c5:bc:b0:d6:7e:00:8e:f7:e7:f5:19:3a:23:df:33:02:aa: - 4b:bf:81:f4:5a:99:ee:74:20:f3:77:a1:f0:85:1e:a8:d6:cc: - a4:cb:31:fa:73:24:a2:0e:dd:9f:6f:82:38:5f:85:ac:8d:76: - bd:d8:f2:69:73:e3:46:44:42:e3:5e:f3:aa:5e:44:13:51:ea: - 0b:78:91:77:96:ee:73:fe:2a:b5:88:c1:38:8d:8d:a8:19:76: - 94:05:02:cf:d4:6f:eb:e6:07:f5:9d:52:24:b8:50:a3:0e:c4: - 45:a6:09:b4:06:2d:3e:14:a5:3f:1c:1a:bc:da:b8:40:3e:c1: - 1c:f6:3c:05 + 5b:53:ff:6d:d5:0a:43:a5:0f:d4:7d:c6:5d:88:e3:98:9d:67: + eb:32:82:b3:0f:f5:c1:78:f8:05:4a:bf:bc:21:05:ee:21:08: + 2c:b2:15:a1:b8:b2:f6:a3:15:61:e4:c1:ad:84:a4:a7:40:0c: + 87:09:5f:2b:1b:f9:4d:6c:92:7d:cb:7e:2b:b0:01:0a:ed:40: + e5:4e:af:1a:f1:0d:ec:1d:9e:96:c7:d4:61:64:39:23:fa:5f: + 29:c4:2a:3a:b8:ed:8a:72:50:6a:ac:45:04:76:09:a8:3d:57: + d7:f0:4b:ae:46:b4:83:c1:14:50:2a:19:59:53:b2:4d:ae:fc: + 2f:40:49:c8:ad:4d:9d:c8:22:8d:8c:01:db:31:33:5a:f4:bc: + 4c:9b:ed:d7:e3:43:d9:e8:1d:53:8b:30:d8:81:9e:72:ab:9e: + ce:b8:f5:83:93:f2:72:db:de:cd:b0:52:9a:45:4d:cf:e7:21: + d8:ce:16:64:8f:42:af:c1:87:a8:f9:d5:e2:03:dd:ba:6b:1b: + 7c:7d:a0:38:33:61:39:b4:dd:5c:69:17:79:02:3a:ec:1d:6f: + 5e:bb:13:fb:a6:82:5d:07:20:fc:86:fe:6e:8b:ac:e1:c2:18: + a2:fe:3f:95:66:d3:69:8a:00:06:2c:56:37:34:b9:b6:31:de: + 0f:f6:44:39 -----BEGIN CERTIFICATE----- -MIIDljCCAn6gAwIBAgIULyXzzjxectAzKfYJH11fU9msI7swDQYJKoZIhvcNAQEL -BQAwYzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcM -DU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3QgQ0ExFTATBgNVBAMMDFRlc3Qg -Um9vdCBDQTAeFw0yMDAzMTMyMDQ2MTZaFw0zMDAzMTEyMDQ2MTZaMGMxCzAJBgNV +MIIDizCCAnOgAwIBAgIJAJRTRMx4iMvZMA0GCSqGSIb3DQEBCwUAMGMxCzAJBgNV BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBW -aWV3MRAwDgYDVQQKDAdUZXN0IENBMRUwEwYDVQQDDAxUZXN0IFJvb3QgQ0EwggEi -MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGgR+Sc7ZYhdmNrLcg/ce/QLLq -+uULUgGPmsHreoDB84mkPtUbYcy1z4CxGtu7JeAYv5JpJlDN5z//DTy0HxQSq2c3 -3gcDbBJ0gjasw9TTZJ+R7Vv2qXqknJjoZWyU4ctVc674HVCweOV0/7E3LMsZPaSM -53ZOhlw/37PtRSNPVJszxoleEx3dfVmlBzQohicf+p5TTyq2Qq03EmL1cja2AhJA -RP7HnpWJQ1FetG7HZ4BYQ77MByi9Wf8cTI2QQvTP/VQAT0hyK+FnPIQXaJW/ygd7 -34adVuMy43CHt/g69+NuZRR8u3a3F/FCjG8qNGQQNRSMhfZXv/NcVZ2tAxDzAgMB -AAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFJsmC4qYqbsduR8c4xpA -M+2OF4irMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAQEAsbGDYa/b -7ZjPPUNfp0K4bZQ2V7urBO7dO7dt7Hh9Rlmx5irDqqVwp+EM+mU3xst9oTc1of/w -3c62pCwS1EapnKKROrCVVZdV5graY2AkGawgybGUQOmZsfXD7WFd3kzk69kOrDoK -/ER9D3emttoo1O3qOrxXI5xyKy2wXRECTcW8sNZ+AI735/UZOiPfMwKqS7+B9FqZ -7nQg83eh8IUeqNbMpMsx+nMkog7dn2+COF+FrI12vdjyaXPjRkRC417zql5EE1Hq -C3iRd5buc/4qtYjBOI2NqBl2lAUCz9Rv6+YH9Z1SJLhQow7ERaYJtAYtPhSlPxwa -vNq4QD7BHPY8BQ== +aWV3MRAwDgYDVQQKDAdUZXN0IENBMRUwEwYDVQQDDAxUZXN0IFJvb3QgQ0EwHhcN +MTcwNjA1MTcxMDQ0WhcNMjcwNjAzMTcxMDQ0WjBjMQswCQYDVQQGEwJVUzETMBEG +A1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4GA1UE +CgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMIIBIjANBgkqhkiG9w0B +AQEFAAOCAQ8AMIIBCgKCAQEAxoEfknO2WIXZjay3IP3Hv0Cy6vrlC1IBj5rB63qA +wfOJpD7VG2HMtc+AsRrbuyXgGL+SaSZQzec//w08tB8UEqtnN94HA2wSdII2rMPU +02Sfke1b9ql6pJyY6GVslOHLVXOu+B1QsHjldP+xNyzLGT2kjOd2ToZcP9+z7UUj +T1SbM8aJXhMd3X1ZpQc0KIYnH/qeU08qtkKtNxJi9XI2tgISQET+x56ViUNRXrRu +x2eAWEO+zAcovVn/HEyNkEL0z/1UAE9IcivhZzyEF2iVv8oHe9+GnVbjMuNwh7f4 +OvfjbmUUfLt2txfxQoxvKjRkEDUUjIX2V7/zXFWdrQMQ8wIDAQABo0IwQDAPBgNV +HRMBAf8EBTADAQH/MB0GA1UdDgQWBBSbJguKmKm7HbkfHOMaQDPtjheIqzAOBgNV +HQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggEBAFtT/23VCkOlD9R9xl2I45id +Z+sygrMP9cF4+AVKv7whBe4hCCyyFaG4svajFWHkwa2EpKdADIcJXysb+U1skn3L +fiuwAQrtQOVOrxrxDewdnpbH1GFkOSP6XynEKjq47YpyUGqsRQR2Cag9V9fwS65G +tIPBFFAqGVlTsk2u/C9AScitTZ3IIo2MAdsxM1r0vEyb7dfjQ9noHVOLMNiBnnKr +ns649YOT8nLb3s2wUppFTc/nIdjOFmSPQq/Bh6j51eID3bprG3x9oDgzYTm03Vxp +F3kCOuwdb167E/umgl0HIPyG/m6LrOHCGKL+P5Vm02mKAAYsVjc0ubYx3g/2RDk= -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/sha1_2016.pem b/net/data/ssl/certificates/sha1_2016.pem index 2c2f383..434febf 100644 --- a/net/data/ssl/certificates/sha1_2016.pem +++ b/net/data/ssl/certificates/sha1_2016.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:ab - Signature Algorithm: sha1WithRSAEncryption + Serial Number: 9 (0x9) + Signature Algorithm: sha1WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Oct 30 00:00:00 2008 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:a2:e9:0f:5b:9f:f4:5c:f2:e2:d1:92:95:72:25: - be:a0:ac:97:d1:7a:8d:7b:0f:a0:52:bb:b3:b3:c0: - 76:ec:02:f8:3a:32:8a:31:67:be:d7:86:f0:7b:4c: - 8c:c9:f3:d0:d1:f2:b0:0b:6c:20:1a:41:bd:ab:40: - 4f:c2:bd:ba:cb:31:83:76:79:2c:9d:58:b3:af:fd: - 90:d7:59:cd:33:93:c5:de:e1:2e:f6:29:00:54:99: - f4:fe:ac:51:a0:d1:17:5a:aa:1f:2c:ee:bb:81:22: - fa:58:61:81:d0:c5:d8:38:8f:6f:08:8a:53:9b:ea: - 0a:24:38:af:09:fe:57:7b:1d:3a:61:cb:fc:07:d8: - 54:16:c4:06:8a:83:f0:24:27:c4:ac:14:c9:2c:64: - de:97:b8:8c:6e:3b:85:64:4d:59:17:c1:a2:fb:28: - e8:ab:24:8f:cf:b0:46:ea:2b:64:7f:9d:04:fe:22: - 15:94:16:0b:4f:a4:8e:6e:d2:34:9b:f2:8f:61:ef: - 87:f8:a8:fa:ce:d7:f2:6b:ae:5c:9a:fd:f4:19:ad: - 79:47:9b:4e:d7:41:91:ab:55:bd:b1:2d:97:fc:82: - ae:6b:c1:3c:62:9a:f6:c9:cf:e7:3e:74:12:0c:ae: - 39:99:c6:e9:69:36:23:00:30:6e:e0:ea:11:9b:5f: - af:a1 + 00:b6:97:a0:79:d1:5c:5f:c1:13:33:6e:21:f8:2b: + e2:55:d6:bd:bb:2e:4e:78:cf:3d:fc:32:02:69:f7: + 1e:57:26:5d:38:18:bd:60:4e:c9:9b:7d:48:47:8e: + e0:b8:7f:de:9e:48:6a:e2:b7:fc:58:aa:38:a5:4d: + ab:b1:6d:ab:ed:f8:ae:7d:9b:2c:e0:cb:af:7b:2d: + 10:f8:97:8d:d7:8d:9f:8c:48:32:df:30:69:2a:de: + cc:1f:81:f1:6d:14:2f:56:ac:64:20:9e:90:6b:5a: + 63:da:0a:08:f2:c6:89:01:44:15:c7:bb:02:fe:4b: + c5:68:18:7f:47:4c:91:c0:59:bd:72:47:69:28:47: + b8:6d:2a:3b:57:74:59:68:9e:e7:35:1d:a4:a9:3b: + 51:9a:74:82:3b:9e:7c:49:d5:f8:d9:72:9b:20:b1: + 53:1f:30:9d:20:a0:26:b9:2f:57:18:a4:63:be:8b: + 3b:03:31:fd:11:8a:d5:2d:13:67:51:88:c1:9f:2b: + 65:da:ea:d3:29:25:3a:60:0f:7f:fc:a0:61:8d:dd: + 8e:4f:45:b3:0f:da:ba:a4:1a:13:87:0d:1f:27:31: + c2:37:1a:a6:fc:49:1c:02:82:ff:f8:a8:7f:4d:66: + 6e:46:38:4d:37:63:fd:bc:b3:d1:29:cc:de:4c:a5: + c8:5b Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - E0:52:8D:C0:78:60:88:97:8F:FA:E5:1D:19:1F:30:23:3A:FB:47:90 + 3C:CC:C9:4A:92:DF:8A:05:12:74:8D:AA:B3:40:EE:69:E4:52:77:62 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha1WithRSAEncryption - 25:c9:57:a0:28:e2:eb:e6:5a:eb:c6:c4:3a:85:77:55:8c:78: - 89:14:56:d5:53:36:75:a4:8c:90:49:eb:56:16:81:c9:45:65: - 98:17:cd:27:bf:82:81:30:ac:31:26:7c:13:8a:87:45:47:3d: - ab:4a:b3:6e:e6:a2:de:24:52:46:89:ef:44:a5:95:62:60:9e: - 62:f4:bf:df:54:ef:91:58:98:f1:44:9e:a4:45:3a:ca:d6:23: - 03:43:b8:4a:29:ff:87:97:64:58:50:cd:29:1a:64:cf:73:56: - 64:9a:2e:87:45:19:4a:99:ef:3e:f5:81:bc:21:08:8a:ac:2b: - f5:be:a6:8a:bf:f3:43:85:8f:2a:1d:3f:58:01:ef:e0:d4:53: - 20:4d:f7:a2:bc:67:cb:cb:48:a5:8b:7a:73:20:cd:c6:91:10: - 78:fc:d4:67:33:1b:d0:00:69:db:39:f6:ab:62:da:51:e2:e1: - 83:4c:10:80:09:f8:15:60:f0:61:7a:3a:7f:19:a1:91:2e:52: - 3c:9a:98:53:06:25:90:5f:0b:f1:a1:b5:ee:de:9d:0d:13:01: - 52:9a:31:07:2d:86:7f:5b:c1:5a:0a:22:8a:46:2f:6a:64:cf: - 59:af:2d:e7:e7:91:89:ff:bb:6a:c7:17:6f:cb:8e:c7:df:d8: - 2c:39:a4:98 + 61:42:bd:ce:3e:8a:ca:a0:bc:61:5f:0a:30:cb:86:02:e3:d3: + 22:a2:c2:d7:b9:b8:79:9b:53:b5:60:14:0a:7f:98:3f:bd:a6: + 09:03:fc:05:bd:b8:24:00:aa:85:ca:ea:36:c0:58:a7:6e:25: + 8f:64:a6:9a:77:35:53:f2:c1:be:04:95:c3:2b:dc:1a:9f:42: + 31:af:5f:1d:06:4d:bb:08:bb:18:b5:48:eb:4a:03:85:be:12: + 7f:bc:62:d5:44:25:0e:75:a8:7a:63:86:0b:c9:af:0f:03:4c: + 14:ac:de:50:c1:0b:d9:cd:17:1e:56:e4:43:18:a7:0f:cc:fc: + 58:e9:d9:7a:62:f7:8b:64:ae:0d:e0:a3:78:75:87:aa:e9:d0: + ce:f4:a2:60:46:41:48:eb:04:89:74:55:d6:f1:1f:f0:ed:32: + df:fc:cc:86:68:c9:b0:36:4f:9f:db:f0:cf:51:a2:9a:89:43: + 65:b1:6c:a1:1a:4f:ef:35:ca:d7:c1:d6:c7:96:f5:4e:0a:f6: + 1d:d1:8f:59:4c:77:20:73:4a:fe:0f:fc:a9:c8:e4:11:d9:3e: + 71:7e:84:b8:ed:e0:fb:00:5d:1e:7b:7b:c9:5b:2d:51:44:7c: + 0b:60:f1:13:7a:ff:7b:fa:0b:74:47:bb:99:89:ef:fe:cc:9f: + f7:a3:e3:20 -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqqzANBgkqhkiG9w0BAQUFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTA4MTAzMDAwMDAwMFoXDTE2MTIzMDAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAKLpD1uf9Fzy4tGSlXIlvqCsl9F6jXsPoFK7 -s7PAduwC+DoyijFnvteG8HtMjMnz0NHysAtsIBpBvatAT8K9ussxg3Z5LJ1Ys6/9 -kNdZzTOTxd7hLvYpAFSZ9P6sUaDRF1qqHyzuu4Ei+lhhgdDF2DiPbwiKU5vqCiQ4 -rwn+V3sdOmHL/AfYVBbEBoqD8CQnxKwUySxk3pe4jG47hWRNWRfBovso6Kskj8+w -RuorZH+dBP4iFZQWC0+kjm7SNJvyj2Hvh/io+s7X8muuXJr99BmteUebTtdBkatV -vbEtl/yCrmvBPGKa9snP5z50EgyuOZnG6Wk2IwAwbuDqEZtfr6ECAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFOBSjcB4YIiXj/rlHRkfMCM6+0eQMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBBQUAA4IB -AQAlyVegKOLr5lrrxsQ6hXdVjHiJFFbVUzZ1pIyQSetWFoHJRWWYF80nv4KBMKwx -JnwTiodFRz2rSrNu5qLeJFJGie9EpZViYJ5i9L/fVO+RWJjxRJ6kRTrK1iMDQ7hK -Kf+Hl2RYUM0pGmTPc1Zkmi6HRRlKme8+9YG8IQiKrCv1vqaKv/NDhY8qHT9YAe/g -1FMgTfeivGfLy0ili3pzIM3GkRB4/NRnMxvQAGnbOfarYtpR4uGDTBCACfgVYPBh -ejp/GaGRLlI8mphTBiWQXwvxobXu3p0NEwFSmjEHLYZ/W8FaCiKKRi9qZM9Zry3n -55GJ/7tqxxdvy47H39gsOaSY +MIIDvzCCAqegAwIBAgIBCTANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTA4MTAzMDAw +MDAwMFoXDTE2MTIzMDAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBALaXoHnRXF/BEzNuIfgr4lXWvbsuTnjPPfwyAmn3HlcmXTgYvWBOyZt9 +SEeO4Lh/3p5IauK3/FiqOKVNq7Ftq+34rn2bLODLr3stEPiXjdeNn4xIMt8waSre +zB+B8W0UL1asZCCekGtaY9oKCPLGiQFEFce7Av5LxWgYf0dMkcBZvXJHaShHuG0q +O1d0WWie5zUdpKk7UZp0gjuefEnV+NlymyCxUx8wnSCgJrkvVxikY76LOwMx/RGK +1S0TZ1GIwZ8rZdrq0yklOmAPf/ygYY3djk9Fsw/auqQaE4cNHycxwjcapvxJHAKC +//iof01mbkY4TTdj/byz0SnM3kylyFsCAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFDzMyUqS34oFEnSNqrNA7mnkUndiMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBBQUAA4IBAQBhQr3OPorKoLxhXwow +y4YC49MiosLXubh5m1O1YBQKf5g/vaYJA/wFvbgkAKqFyuo2wFinbiWPZKaadzVT +8sG+BJXDK9wan0Ixr18dBk27CLsYtUjrSgOFvhJ/vGLVRCUOdah6Y4YLya8PA0wU +rN5QwQvZzRceVuRDGKcPzPxY6dl6YveLZK4N4KN4dYeq6dDO9KJgRkFI6wSJdFXW +8R/w7TLf/MyGaMmwNk+f2/DPUaKaiUNlsWyhGk/vNcrXwdbHlvVOCvYd0Y9ZTHcg +c0r+D/ypyOQR2T5xfoS47eD7AF0ee3vJWy1RRHwLYPETev97+gt0R7uZie/+zJ/3 +o+Mg -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/sha1_leaf.pem b/net/data/ssl/certificates/sha1_leaf.pem index ea8df85..598b48d 100644 --- a/net/data/ssl/certificates/sha1_leaf.pem +++ b/net/data/ssl/certificates/sha1_leaf.pem
@@ -1,70 +1,69 @@ -----BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC3FUBTWsYvyZ6x -lkfEONK6U2oqeuFWPuE8cLh9H7u6t19m4uhRGHnMnOtiqUeuUlI9HPOk76+H2PhK -M4BS2yIzd2JIItxrgqm8cOoVM6R4Na9nUfWM9jpymJlwBy2HsktvHyblVfgpXVTe -W0Sz+oy5yJgvxcnQHEZWE8U87zJ6wzqNp0D/mvZAye91wEsBWH0iIrPok3x7SAvT -wnZJN1qYooPQBS3W8ji0Y6ZS7Z/KAPHnVe653VDRvjlRJl/O012Z02cuSn53BoAJ -u8EhCuybSDn3FXvgbCan5Vwtl4gwTMTYq9rn5aZ0lmmKceMs/XuL1bFMc1oPHtZX -s/JjmPP/AgMBAAECggEBAJn+UgDKlXCUkdqloO+3K+h1SRM6EFdOxHzmAwebrXe7 -zY7oxKeRgsFMK+DsqdJCg9HLjFPrFyWYph8jeog2sWnAvPYX/HahjMtn3jy/F1PV -NBgfo/5RDZBeMpE8OFuu6Cwrc7fqu7VvP3dYJU2NLNkHlJp6LunRHohAUOKT/02p -gzm5djM+9mTYAmvUQ5jx9SgltQL/eUOf+WKUQKVLaLsdgVFn8//kWfIiUxsGFe4q -Dx7SKcCkLFI7V3l6dJiiRpmd9ZonV03w/EGrxhn/afUrGwdsnXxHuQEBNSb5HXh7 -yjHmE/N3NsKmHp3FH8SBENOdAMABPz1cWb5eXQvm48ECgYEA6mioSARwtIDtJ+21 -ZBGh+YAL+k/nAs3V/dmAPxRu9vr+0rDLoUMJSlVyQIsGig8/rC82K6cohfmIBRtK -oqwBgzfpDpioZ3ssRF+VSJi2aqidFt/GXMJ/YkiajivTMft8469FmOM+PnAY0OEV -ScOuC984crfHV1dGvLnaTiO8mkcCgYEAx/JV0S/42tZwpnKhVeyVvF+9T9aWFvLc -AlZCbHBNDTlo7tsnw9yPZ0XAksQzUU1zupjkL2Wj9S/3vhRy/vmC44XD3Axn2KeD -xM0Xl578dMZNqQOxs6YaJJzYAwEWcSJvKKwxpCZMq1kVP1QihcmIGzknbo8D9E80 -q4CSy1eQfIkCgYAxRQQx9vT1i6/NV7JrsSUZeyeJWmgU98zFyYSiPZpBQWp0QILc -h2mZfTJBjLc4J5Jbj6TUMhNbbaKAaEccwAilWwgacE3dSk94o5qOIsMc0goKt8hK -0PrTXq1VurJubAzJEpsPUpxPpWIh7V17Hq0jg6yquCQnIIoWuv2+tNY8mwKBgHnx -wIkeeuXs1zOMwf0Hl6MVuP4SX+OLJsd+GHDOZQ/lravPmYcI46UWk4ZvhuTVGfn5 -+WE22jJVmQEis6fyQPPGx1dTcZpfQCws8XCVlF8b+o1UJXLtoRAnYE8kwK0rVSQ3 -MOduPGBcqmq/Q3bZHNuNlhEFxGGiVPssJVtDAmoRAoGALtnaRmr0YvIcxQ921pM/ -Suup3Hm6CcQ4ygl9cBZVcaJxdg5uOxgO0jNx3l+tSSV1eHVuZgW54aZyxg5t8kdv -laV1oKHmzCeRJkipB7LvWu6Aqa6nB+ARdsaKPaRamwRkZ+zlVZfp9Xjc72PTwndZ -pyfGQC1mOGLErTWa2HQQYlI= +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCt5Mpt4Jw+UG9v +qfdbenxHoJJ8YcG9PZssBRhmA4GIwNGoYqG5D50gMxppUybpdZtQus+FF/lS8v2R +0+my4D3cgLo+eIebg2oqhz/x5QLQlWsGvcjcn6bTg0INuK9vn9HNqeMQkDotxK9X +zvcbKazzxzV1K81PGgocpjhj10qdOZoboDu+eTN8bFe13uRNFG13l1nQmU0B6R6n +BreDtxggA/C9H0x9YjRVyDamxwXe5c1yrye2HZXdxJneEEm+CMUSjKXlpK1it/+U +1mafGMtrSdl++aspmO3lZ61TUNdSqdSUBGL8azw7AzewvRj48KN8V4EPG7WUvu4a +CrZpy3O1AgMBAAECggEAcz5ibcliouWZxK4m0YhuXuXqzuXWiP0QHm9OCSWfrirj +h62+MjBH2LQld9H0wtn/UdRMfY8y3CdPp1qC0dpNBRqG06n7bTP9oyu5VC2K3QN5 +R6F1QcnIvPqLRx6znc2UNLG3Wx3KgNSNxCrUlzradUD7i6i4ywid1PjP/FMNDv6q +k07xSxc0VpWwkUC0j3uau0qewfnjP3+Toe7au4vHhy+Opyudsu4WETlbhkZq2mlD +bgUS8/06FOjlf/2tfnElysL2NPvj0sFpm1yUckxZVjiepJ8QfqU46zsxUTqKrtca +b6kYiJmB30wSxwnsweBhJ6w7UOOV6kmB6scc5OD2IQKBgQDgZESH7yLkqBdY1qFE +AfWvyMfIe/buB8UNLcicGuSPkjdtCzsXoDgzXxt37RSLFMsPTDBM51KPAzJkWaeM +Jksbivw/+bEFTyY/AaYreiRHrpIXvLM/mNJFZ514ImZ+mY8YU7nuTZRMn7Ysfs9c +kHc7r3ET65KOcnXtPVGk6h2rHQKBgQDGY4dc0vWHktGLLqmgIJZHVcojj4NLuX67 +KCj1/DhNFpJhq24MKucxmaOlXXXPgEGTA/JwWnolo1fcT2Vv4LrlgL75SYVHOF71 +2PTIrlM3w6lOJNyzyD3Sjh2wZ87u993P2z6Z/qDWOMTdfD/jvyoU/k1uq6rTxJzy +SktzfqRveQKBgBwI6vcAzZ870Q7sYeGZTRTVRQCrXEKI/fmTisjWI1A8uGgLSyq8 +fckNTOVC3Zoy0tvqbO5uyEXN5HHdMa206xVZ3AIyNAexx9l/Xz93VykNinskvFBp +y3uYYngr9BpFHTew3j4Du0+HdL9CaK3r7rmqRbpzaDAb5NfrHVQ5W9ORAoGASfSq +bnkaHKsnwFnp1A6x1u/tRepnCKCi1MQ42NJobpxef1h30sNfokbjEW9QzsTCLTsI +csfXxxYoV7GlX9qH8axYBPhaXd1u0PlK71DFJwGiqMXnHIImQcrG2I8qPj1ai/Tw +VlnsvU82XFbIPm9yEZdnaD1Ill8yHsSBchGg3QkCgYEAxZcgtHjspR9TTzuyl8qm +gciF8YDwYIIHqOPnVKoC6+EQJf/BJnTU5naf56sa4aMg9eqqNA5eG0aohM1uZJAJ +TaxkXZ8wTCwFoIh6O05+SD4bHDWvr7Sur1z0HeasYH2OPf/H/N0Xuq10rphCr7dx +HYbEecCcSPrbEtOR7++xRvA= -----END PRIVATE KEY----- Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:bc - Signature Algorithm: sha1WithRSAEncryption + Serial Number: 23 (0x17) + Signature Algorithm: sha1WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity - Not Before: Mar 13 20:46:30 2020 GMT - Not After : Mar 13 20:46:30 2022 GMT + Not Before: Dec 20 00:00:00 2017 GMT + Not After : Dec 20 00:00:00 2020 GMT Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:b7:15:40:53:5a:c6:2f:c9:9e:b1:96:47:c4:38: - d2:ba:53:6a:2a:7a:e1:56:3e:e1:3c:70:b8:7d:1f: - bb:ba:b7:5f:66:e2:e8:51:18:79:cc:9c:eb:62:a9: - 47:ae:52:52:3d:1c:f3:a4:ef:af:87:d8:f8:4a:33: - 80:52:db:22:33:77:62:48:22:dc:6b:82:a9:bc:70: - ea:15:33:a4:78:35:af:67:51:f5:8c:f6:3a:72:98: - 99:70:07:2d:87:b2:4b:6f:1f:26:e5:55:f8:29:5d: - 54:de:5b:44:b3:fa:8c:b9:c8:98:2f:c5:c9:d0:1c: - 46:56:13:c5:3c:ef:32:7a:c3:3a:8d:a7:40:ff:9a: - f6:40:c9:ef:75:c0:4b:01:58:7d:22:22:b3:e8:93: - 7c:7b:48:0b:d3:c2:76:49:37:5a:98:a2:83:d0:05: - 2d:d6:f2:38:b4:63:a6:52:ed:9f:ca:00:f1:e7:55: - ee:b9:dd:50:d1:be:39:51:26:5f:ce:d3:5d:99:d3: - 67:2e:4a:7e:77:06:80:09:bb:c1:21:0a:ec:9b:48: - 39:f7:15:7b:e0:6c:26:a7:e5:5c:2d:97:88:30:4c: - c4:d8:ab:da:e7:e5:a6:74:96:69:8a:71:e3:2c:fd: - 7b:8b:d5:b1:4c:73:5a:0f:1e:d6:57:b3:f2:63:98: - f3:ff + 00:ad:e4:ca:6d:e0:9c:3e:50:6f:6f:a9:f7:5b:7a: + 7c:47:a0:92:7c:61:c1:bd:3d:9b:2c:05:18:66:03: + 81:88:c0:d1:a8:62:a1:b9:0f:9d:20:33:1a:69:53: + 26:e9:75:9b:50:ba:cf:85:17:f9:52:f2:fd:91:d3: + e9:b2:e0:3d:dc:80:ba:3e:78:87:9b:83:6a:2a:87: + 3f:f1:e5:02:d0:95:6b:06:bd:c8:dc:9f:a6:d3:83: + 42:0d:b8:af:6f:9f:d1:cd:a9:e3:10:90:3a:2d:c4: + af:57:ce:f7:1b:29:ac:f3:c7:35:75:2b:cd:4f:1a: + 0a:1c:a6:38:63:d7:4a:9d:39:9a:1b:a0:3b:be:79: + 33:7c:6c:57:b5:de:e4:4d:14:6d:77:97:59:d0:99: + 4d:01:e9:1e:a7:06:b7:83:b7:18:20:03:f0:bd:1f: + 4c:7d:62:34:55:c8:36:a6:c7:05:de:e5:cd:72:af: + 27:b6:1d:95:dd:c4:99:de:10:49:be:08:c5:12:8c: + a5:e5:a4:ad:62:b7:ff:94:d6:66:9f:18:cb:6b:49: + d9:7e:f9:ab:29:98:ed:e5:67:ad:53:50:d7:52:a9: + d4:94:04:62:fc:6b:3c:3b:03:37:b0:bd:18:f8:f0: + a3:7c:57:81:0f:1b:b5:94:be:ee:1a:0a:b6:69:cb: + 73:b5 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 65:7D:5B:06:08:D8:9C:CE:3E:A7:E8:60:32:66:25:AE:B7:AD:EB:D4 + 18:9A:76:1E:86:4C:EF:67:5D:20:7F:24:4C:DC:3F:AE:B5:B5:5C:A1 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -73,41 +72,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha1WithRSAEncryption - a8:f5:cd:7e:9f:43:7f:03:6b:1e:ad:83:ef:1d:9a:f2:f4:79: - 54:36:36:f7:50:76:75:5a:e3:ba:3e:94:a1:a0:9b:34:fa:5d: - dd:fd:89:f5:c6:9d:47:6c:27:38:71:0e:43:0d:29:70:00:f8: - 26:33:99:a2:5f:69:31:97:22:14:b2:a9:07:e7:c5:90:21:8b: - de:a2:65:71:d3:5c:d8:79:cf:38:bb:30:57:c6:2f:1a:8b:aa: - 87:85:d0:4c:27:20:4f:96:88:58:5c:2d:28:16:8b:86:e0:78: - 0b:7e:1b:37:0e:ff:e6:47:4e:11:8f:54:2a:29:55:ea:91:bc: - d8:f0:be:2f:2d:d9:da:a4:eb:46:84:34:cd:43:3e:c2:f0:78: - db:0c:44:a9:0c:9d:ed:da:8f:ce:48:f6:2a:e9:f6:6b:97:b3: - 08:73:40:2f:20:e9:de:39:c2:4b:f2:f4:95:6f:b8:60:10:2e: - a7:f6:03:c6:5a:f3:8d:08:48:72:0e:70:7a:70:e8:a9:61:59: - 00:c4:4f:d7:43:d8:b5:16:a3:f7:ae:42:47:fe:09:95:58:2f: - 03:14:a1:59:39:63:8c:98:bc:a3:2a:f8:be:c1:0f:30:f6:82: - 99:b2:bf:37:91:45:be:ed:04:7c:37:17:e0:10:62:1a:e3:7e: - 07:46:99:4a + a0:b6:c2:65:a0:9b:25:b7:c9:81:9a:dc:63:aa:ae:6e:f3:8a: + 62:92:66:6e:ad:3d:a7:fd:26:d4:ea:7b:7c:00:80:2b:73:db: + 36:86:fe:b1:b5:8a:05:40:d3:3c:6f:1d:11:1b:b2:a0:0d:f6: + 26:aa:ac:63:62:61:c0:7e:b0:7d:da:73:2c:14:71:41:fd:93: + f5:76:cd:21:13:42:df:e5:b0:26:e8:d0:ec:a2:e4:26:b8:ba: + e8:bd:49:f9:38:7f:92:1c:a2:7e:8f:b3:d3:e6:0a:51:60:88: + c4:ab:08:65:14:53:fd:c3:70:8a:6f:49:99:d7:09:38:00:20: + b5:3d:3c:f1:7c:2c:ab:67:4d:df:1d:c2:1e:24:d3:31:60:71: + be:b3:85:7e:a7:1e:ce:41:1f:21:58:63:83:3c:e5:91:4a:18: + 4d:6c:97:13:d5:df:34:c7:22:0a:92:3a:fb:03:3a:b8:62:2b: + 7e:be:03:fb:39:74:03:1d:f3:c7:55:28:e7:ed:cd:28:75:2b: + 75:c5:38:b7:fd:da:98:60:61:0a:aa:eb:17:1a:26:e1:74:7e: + 84:e8:76:bf:15:18:e3:b2:4e:25:41:cb:2b:19:c9:63:6f:aa: + 8a:58:c7:01:2a:cd:fc:04:ea:63:7f:b3:ed:5d:96:a2:b0:26: + 63:8d:0d:3f -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqvDANBgkqhkiG9w0BAQUFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTIwMDMxMzIwNDYzMFoXDTIyMDMxMzIwNDYzMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBALcVQFNaxi/JnrGWR8Q40rpTaip64VY+4Txw -uH0fu7q3X2bi6FEYecyc62KpR65SUj0c86Tvr4fY+EozgFLbIjN3Ykgi3GuCqbxw -6hUzpHg1r2dR9Yz2OnKYmXAHLYeyS28fJuVV+CldVN5bRLP6jLnImC/FydAcRlYT -xTzvMnrDOo2nQP+a9kDJ73XASwFYfSIis+iTfHtIC9PCdkk3Wpiig9AFLdbyOLRj -plLtn8oA8edV7rndUNG+OVEmX87TXZnTZy5KfncGgAm7wSEK7JtIOfcVe+BsJqfl -XC2XiDBMxNir2uflpnSWaYpx4yz9e4vVsUxzWg8e1lez8mOY8/8CAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFGV9WwYI2JzOPqfoYDJmJa63revUMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBBQUAA4IB -AQCo9c1+n0N/A2serYPvHZry9HlUNjb3UHZ1WuO6PpShoJs0+l3d/Yn1xp1HbCc4 -cQ5DDSlwAPgmM5miX2kxlyIUsqkH58WQIYveomVx01zYec84uzBXxi8ai6qHhdBM -JyBPlohYXC0oFouG4HgLfhs3Dv/mR04Rj1QqKVXqkbzY8L4vLdnapOtGhDTNQz7C -8HjbDESpDJ3t2o/OSPYq6fZrl7MIc0AvIOneOcJL8vSVb7hgEC6n9gPGWvONCEhy -DnB6cOipYVkAxE/XQ9i1FqP3rkJH/gmVWC8DFKFZOWOMmLyjKvi+wQ8w9oKZsr83 -kUW+7QR8NxfgEGIa434HRplK +MIIDvzCCAqegAwIBAgIBFzANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE3MTIyMDAw +MDAwMFoXDTIwMTIyMDAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAK3kym3gnD5Qb2+p91t6fEegknxhwb09mywFGGYDgYjA0ahiobkPnSAz +GmlTJul1m1C6z4UX+VLy/ZHT6bLgPdyAuj54h5uDaiqHP/HlAtCVawa9yNyfptOD +Qg24r2+f0c2p4xCQOi3Er1fO9xsprPPHNXUrzU8aChymOGPXSp05mhugO755M3xs +V7Xe5E0UbXeXWdCZTQHpHqcGt4O3GCAD8L0fTH1iNFXINqbHBd7lzXKvJ7Ydld3E +md4QSb4IxRKMpeWkrWK3/5TWZp8Yy2tJ2X75qymY7eVnrVNQ11Kp1JQEYvxrPDsD +N7C9GPjwo3xXgQ8btZS+7hoKtmnLc7UCAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFBiadh6GTO9nXSB/JEzcP661tVyhMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBBQUAA4IBAQCgtsJloJslt8mBmtxj +qq5u84pikmZurT2n/SbU6nt8AIArc9s2hv6xtYoFQNM8bx0RG7KgDfYmqqxjYmHA +frB92nMsFHFB/ZP1ds0hE0Lf5bAm6NDsouQmuLrovUn5OH+SHKJ+j7PT5gpRYIjE +qwhlFFP9w3CKb0mZ1wk4ACC1PTzxfCyrZ03fHcIeJNMxYHG+s4V+px7OQR8hWGOD +POWRShhNbJcT1d80xyIKkjr7Azq4Yit+vgP7OXQDHfPHVSjn7c0odSt1xTi3/dqY +YGEKqusXGibhdH6E6Ha/FRjjsk4lQcsrGcljb6qKWMcBKs38BOpjf7PtXZaisCZj +jQ0/ -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/spdy_pooling.pem b/net/data/ssl/certificates/spdy_pooling.pem index 5f67d6eb..baed434 100644 --- a/net/data/ssl/certificates/spdy_pooling.pem +++ b/net/data/ssl/certificates/spdy_pooling.pem
@@ -2,74 +2,74 @@ Data: Version: 3 (0x2) Serial Number: - 11:48:7c:ad:94:b7:50:ec:24:70:a5:6e:36:47:98:71:bc:1b:56:82 - Signature Algorithm: sha256WithRSAEncryption + c0:31:6d:a9:8d:46:62:c5 + Signature Algorithm: sha256WithRSAEncryption Issuer: C = US, ST = California, L = Mountain View, O = Test CA, CN = 127.0.0.1 Validity - Not Before: Mar 13 20:46:17 2020 GMT - Not After : Mar 11 20:46:17 2030 GMT + Not Before: Jun 19 18:00:00 2018 GMT + Not After : Jun 16 18:00:00 2028 GMT Subject: C = US, ST = California, L = Mountain View, O = Test CA, CN = 127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:b4:7d:d7:03:66:20:ad:5d:37:5a:43:fe:a2:a4: - 3d:eb:ea:26:ab:43:ee:42:9c:d7:5d:ab:f5:89:37: - aa:ca:c7:ec:b6:02:21:27:84:4c:d3:ab:bb:56:16: - 21:e0:6e:df:f5:dd:02:f7:f0:08:b7:59:e0:1e:d3: - c3:74:5c:67:91:1e:9c:f4:9f:b4:6b:29:58:bd:67: - 66:5c:d5:bc:6f:85:22:c4:34:5d:88:0a:b4:69:50: - 24:06:b9:fc:d2:bf:b7:20:0b:e3:a5:ea:b0:42:b6: - df:fa:a6:e2:66:13:ac:27:ee:c4:6b:6e:cb:1a:5b: - 15:47:d9:cd:06:f1:e5:68:11:03:c2:9e:11:67:e5: - 8a:d8:d9:77:fd:8d:ab:0f:d6:f1:28:41:ea:63:ca: - 98:30:87:da:a3:5b:a6:44:a6:e9:69:67:1d:b1:31: - 15:75:eb:7c:b8:72:52:8c:ea:78:12:65:b3:c4:73: - ee:85:74:35:0d:3d:4a:89:07:20:57:3e:3c:e7:53: - 5e:af:29:f8:2c:36:7f:df:ee:c2:b3:ea:18:33:34: - 54:0b:de:18:fe:75:c4:cc:9a:0c:13:49:de:8b:6e: - bf:96:85:9f:62:52:21:42:33:34:bc:37:39:a9:a2: - cd:09:0a:17:1b:77:69:d7:29:da:38:76:30:68:4e: - 29:a5 + 00:bc:75:b7:7b:11:4b:73:c5:b8:f8:2f:4e:46:fd: + e8:f1:cf:af:a5:e1:37:03:04:0f:af:17:43:03:57: + 6b:ea:84:e1:91:53:26:d7:9a:d8:14:c6:fe:1f:17: + 1a:ac:95:a6:06:be:1b:fd:9a:ea:e1:db:10:d1:06: + 10:63:85:7c:04:69:e2:df:fe:44:ac:31:cd:6e:ec: + bf:ff:5c:2e:af:c6:d1:5f:08:d5:84:b1:0a:b0:3c: + 70:80:8e:09:23:ca:49:d2:6b:b8:5c:c3:07:de:13: + 41:6f:84:1b:48:d8:8d:06:57:29:89:23:2a:fc:3d: + 97:3d:31:d4:38:0c:a5:64:7e:59:7c:22:92:a2:02: + fc:68:a8:23:db:d7:da:f6:9e:a7:34:9a:ce:92:ad: + 78:b4:71:08:31:25:ea:d9:a6:fa:52:9f:49:ab:76: + 74:78:f2:11:8f:7c:34:37:5c:5b:19:d1:83:f7:b3: + f3:55:ed:88:f2:05:65:2f:a2:ce:a8:91:bb:cd:dd: + 1f:5c:9a:e0:0a:35:ec:45:b6:9f:b0:ce:fa:f3:05: + 38:ab:34:38:88:6a:d0:f7:b2:0d:11:79:cd:b2:00: + 9c:c0:9b:15:f6:86:df:fe:53:89:8f:86:5a:ed:ac: + 3a:8d:bd:ff:9e:d9:a7:e2:65:6f:ae:85:6c:68:82: + 80:09 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Subject Alternative Name: DNS:www.example.org, DNS:mail.example.org, DNS:mail.example.com, DNS:example.test Signature Algorithm: sha256WithRSAEncryption - 17:5f:6d:ae:7b:82:7b:dc:5f:18:d2:27:bf:07:a0:8a:b4:5b: - 32:a9:38:f3:d1:18:fd:bd:68:b8:58:58:c7:d4:53:25:82:14: - f4:79:f3:31:83:e9:91:8b:33:87:0a:fe:95:ad:74:52:b3:91: - 4b:dd:82:10:d4:0a:a0:7a:ab:d6:32:b9:07:73:b5:4a:85:35: - 35:66:4b:f1:75:b8:93:07:3c:6a:7f:67:11:e6:9c:bc:bc:e8: - 83:dc:c1:85:11:28:c4:a2:08:25:57:30:6e:96:f6:fd:c5:76: - c9:ea:8a:c6:30:d7:46:49:6a:ca:84:4c:52:22:71:c7:ce:6a: - 43:bc:19:1d:70:d9:4c:4b:48:79:a0:ca:98:dc:53:84:c0:0e: - d5:68:57:5f:a6:d0:13:e4:81:2e:31:1b:d0:f3:32:a0:e3:4f: - de:2c:6c:e0:55:01:77:5b:6d:5b:b0:8a:6d:3e:d4:d1:ca:cc: - 93:1a:0c:73:80:fe:3e:8e:e3:d0:53:cd:d5:29:62:57:f0:97: - 1d:e4:93:ff:2e:ba:92:29:19:12:d1:82:28:8b:9a:8a:e7:ca: - c0:e4:a0:96:99:4a:cd:ad:45:9f:03:17:ca:35:1d:34:83:a1: - 3a:c3:77:ad:91:a3:e6:4b:d7:14:60:a0:5f:aa:35:72:64:c6: - 1f:0f:9f:ca + 64:42:12:b1:84:3b:d6:93:d7:43:61:e6:b6:7a:ec:c1:43:14: + f0:94:24:60:d0:53:ee:90:1e:4a:c4:d8:79:3f:10:eb:a5:e3: + 34:e2:bf:9c:ea:c2:a7:dc:8a:1e:f4:71:bc:34:4f:99:a6:58: + 6c:74:fd:85:2b:6a:ee:32:bf:50:22:72:23:e7:1f:12:60:c5: + 21:c1:c6:b6:62:a0:75:77:50:35:aa:b7:f3:2b:e7:27:ea:d2: + 2e:c7:91:2b:ae:fb:31:3f:c0:d8:d1:a4:7d:d1:80:39:a8:46: + df:89:70:84:2b:6a:39:5b:44:2d:cb:73:76:de:8e:dc:97:35: + 2c:75:6a:42:a7:07:a0:4c:64:07:e1:1f:9a:a0:fa:89:18:5a: + 37:90:72:8c:21:ae:0e:fc:28:c7:a4:2a:c6:50:8c:5d:68:ae: + 4b:86:64:ca:56:49:05:55:8a:86:36:9f:99:34:5d:29:f7:1b: + 5d:7f:39:44:03:3e:94:c9:d7:7d:1a:2d:5f:fd:ca:b5:70:2e: + 44:35:fc:56:3d:9f:80:b7:f0:c0:dc:09:63:c6:11:b0:9c:99: + c0:88:46:d8:14:92:1d:3d:3f:48:de:ed:a9:a2:19:af:e4:d2: + 52:d1:9c:b7:05:1f:d3:82:73:0a:3e:c4:21:88:90:9d:77:a9: + 97:d5:c2:d3 -----BEGIN CERTIFICATE----- -MIIDnjCCAoagAwIBAgIUEUh8rZS3UOwkcKVuNkeYcbwbVoIwDQYJKoZIhvcNAQEL -BQAwYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcM -DU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4w -LjAuMTAeFw0yMDAzMTMyMDQ2MTdaFw0zMDAzMTEyMDQ2MTdaMGAxCzAJBgNVBAYT -AlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3 -MRAwDgYDVQQKDAdUZXN0IENBMRIwEAYDVQQDDAkxMjcuMC4wLjEwggEiMA0GCSqG -SIb3DQEBAQUAA4IBDwAwggEKAoIBAQC0fdcDZiCtXTdaQ/6ipD3r6iarQ+5CnNdd -q/WJN6rKx+y2AiEnhEzTq7tWFiHgbt/13QL38Ai3WeAe08N0XGeRHpz0n7RrKVi9 -Z2Zc1bxvhSLENF2ICrRpUCQGufzSv7cgC+Ol6rBCtt/6puJmE6wn7sRrbssaWxVH -2c0G8eVoEQPCnhFn5YrY2Xf9jasP1vEoQepjypgwh9qjW6ZEpulpZx2xMRV163y4 -clKM6ngSZbPEc+6FdDUNPUqJByBXPjznU16vKfgsNn/f7sKz6hgzNFQL3hj+dcTM -mgwTSd6Lbr+WhZ9iUiFCMzS8Nzmpos0JChcbd2nXKdo4djBoTimlAgMBAAGjUDBO -MEwGA1UdEQRFMEOCD3d3dy5leGFtcGxlLm9yZ4IQbWFpbC5leGFtcGxlLm9yZ4IQ -bWFpbC5leGFtcGxlLmNvbYIMZXhhbXBsZS50ZXN0MA0GCSqGSIb3DQEBCwUAA4IB -AQAXX22ue4J73F8Y0ie/B6CKtFsyqTjz0Rj9vWi4WFjH1FMlghT0efMxg+mRizOH -Cv6VrXRSs5FL3YIQ1AqgeqvWMrkHc7VKhTU1ZkvxdbiTBzxqf2cR5py8vOiD3MGF -ESjEogglVzBulvb9xXbJ6orGMNdGSWrKhExSInHHzmpDvBkdcNlMS0h5oMqY3FOE -wA7VaFdfptAT5IEuMRvQ8zKg40/eLGzgVQF3W21bsIptPtTRysyTGgxzgP4+juPQ -U83VKWJX8Jcd5JP/LrqSKRkS0YIoi5qK58rA5KCWmUrNrUWfAxfKNR00g6E6w3et -kaPmS9cUYKBfqjVyZMYfD5/K +MIIDkzCCAnugAwIBAgIJAMAxbamNRmLFMA0GCSqGSIb3DQEBCwUAMGAxCzAJBgNV +BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBW +aWV3MRAwDgYDVQQKDAdUZXN0IENBMRIwEAYDVQQDDAkxMjcuMC4wLjEwHhcNMTgw +NjE5MTgwMDAwWhcNMjgwNjE2MTgwMDAwWjBgMQswCQYDVQQGEwJVUzETMBEGA1UE +CAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4GA1UECgwH +VGVzdCBDQTESMBAGA1UEAwwJMTI3LjAuMC4xMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEAvHW3exFLc8W4+C9ORv3o8c+vpeE3AwQPrxdDA1dr6oThkVMm +15rYFMb+HxcarJWmBr4b/Zrq4dsQ0QYQY4V8BGni3/5ErDHNbuy//1wur8bRXwjV +hLEKsDxwgI4JI8pJ0mu4XMMH3hNBb4QbSNiNBlcpiSMq/D2XPTHUOAylZH5ZfCKS +ogL8aKgj29fa9p6nNJrOkq14tHEIMSXq2ab6Up9Jq3Z0ePIRj3w0N1xbGdGD97Pz +Ve2I8gVlL6LOqJG7zd0fXJrgCjXsRbafsM768wU4qzQ4iGrQ97INEXnNsgCcwJsV +9obf/lOJj4Za7aw6jb3/ntmn4mVvroVsaIKACQIDAQABo1AwTjBMBgNVHREERTBD +gg93d3cuZXhhbXBsZS5vcmeCEG1haWwuZXhhbXBsZS5vcmeCEG1haWwuZXhhbXBs +ZS5jb22CDGV4YW1wbGUudGVzdDANBgkqhkiG9w0BAQsFAAOCAQEAZEISsYQ71pPX +Q2HmtnrswUMU8JQkYNBT7pAeSsTYeT8Q66XjNOK/nOrCp9yKHvRxvDRPmaZYbHT9 +hStq7jK/UCJyI+cfEmDFIcHGtmKgdXdQNaq38yvnJ+rSLseRK677MT/A2NGkfdGA +OahG34lwhCtqOVtELctzdt6O3Jc1LHVqQqcHoExkB+EfmqD6iRhaN5ByjCGuDvwo +x6QqxlCMXWiuS4ZkylZJBVWKhjafmTRdKfcbXX85RAM+lMnXfRotX/3KtXAuRDX8 +Vj2fgLfwwNwJY8YRsJyZwIhG2BSSHT0/SN7tqaIZr+TSUtGctwUf04JzCj7EIYiQ +nXepl9XC0w== -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/start_after_expiry.pem b/net/data/ssl/certificates/start_after_expiry.pem index 26a1328..06164e85 100644 --- a/net/data/ssl/certificates/start_after_expiry.pem +++ b/net/data/ssl/certificates/start_after_expiry.pem
@@ -1,9 +1,8 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:b3 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 18 (0x12) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity Not Before: Sep 1 00:00:00 2018 GMT @@ -11,32 +10,32 @@ Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:9e:37:74:a3:d3:a1:6d:c2:c9:55:30:78:ec:e8: - fa:e6:9e:20:e5:be:f0:3e:02:86:84:b4:8f:4c:94: - 94:66:04:19:68:26:ce:23:93:ac:aa:19:dc:87:6d: - bc:8e:10:bb:6f:ac:09:23:e8:1a:16:ae:3e:41:a0: - 67:e7:ad:8c:ef:42:f8:2f:ad:6d:d4:ed:37:8c:9f: - e3:d7:a3:3e:0d:62:2d:65:68:b8:d8:05:7a:4f:e3: - 3f:f1:c7:9b:8a:85:57:48:47:26:8d:d4:c8:84:2c: - 87:cc:59:ec:dd:93:83:a5:88:78:a1:35:09:0e:32: - 66:d0:6e:e9:2e:bc:4a:37:09:db:22:19:e2:83:5d: - 68:89:71:53:b4:b7:6c:06:47:bb:6c:4b:a2:ec:20: - f5:f9:85:a0:f4:08:a5:af:25:4c:19:40:0a:29:f4: - 57:72:bd:4a:9a:3a:8e:a5:18:29:75:e6:25:69:c4: - 12:3a:18:f1:b2:04:08:a2:12:a6:59:44:97:71:03: - ef:c0:e1:22:32:34:b9:90:6a:ba:45:98:e9:8d:2b: - 46:a8:05:7c:be:29:24:ad:ab:be:a8:95:ab:90:c4: - 3d:2f:e5:56:c4:9a:7b:d4:41:b9:31:3d:32:1c:e4: - e9:da:e6:59:6e:10:1b:a1:b0:27:53:a9:07:84:53: - 26:ed + 00:9a:5a:33:cc:a1:02:df:a5:c4:bc:57:68:1b:03: + 11:b3:58:58:8e:78:63:8a:02:0e:8a:ec:5d:96:a6: + 3b:3f:98:db:3e:ba:d6:56:48:8b:2b:00:3c:ef:e2: + 93:08:67:46:68:93:05:2c:63:4c:07:d2:01:6f:36: + 72:cb:d1:40:a4:7f:a2:53:0f:ae:72:92:2f:c9:8a: + 37:96:7b:a6:a9:a0:32:68:39:5b:03:d1:7b:be:fd: + 7c:9d:19:87:87:83:08:f4:66:5b:d4:f5:89:f7:52: + 93:16:6a:6c:70:41:d8:0a:4d:fd:3f:08:e1:3a:d5: + 26:b5:12:09:d0:0d:3b:6c:34:ae:56:46:0f:12:ab: + 39:f9:df:d9:a7:b6:95:ba:d3:96:de:64:42:44:83: + 6a:21:9a:2d:a3:5c:eb:ea:d6:9b:63:80:77:0a:12: + b3:12:1e:31:f1:b3:ac:b2:69:ca:01:51:4a:92:0a: + e5:7f:b5:d5:3f:17:d8:b3:e0:d2:14:c7:b1:3d:0a: + be:e2:ef:4f:25:94:0d:d3:39:2b:1e:fd:ff:69:89: + a8:1e:18:38:1e:2f:6b:8b:9d:e5:2e:1c:ce:f0:9f: + c2:f5:d9:14:31:2a:c5:f2:5f:04:d9:dc:ec:80:48: + 50:5f:b0:be:b7:50:57:22:40:f1:53:40:8e:97:5f: + 66:1d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 51:9E:6E:30:68:EA:D4:89:70:13:8E:2F:AA:12:27:5F:55:FA:FC:1A + E8:35:95:5F:B1:76:85:86:C1:35:20:30:76:70:AC:2B:AE:6E:48:DA X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -45,41 +44,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 69:0c:89:81:df:db:3c:80:58:6f:8d:59:fc:d2:a0:c2:f2:3a: - 83:60:a6:d8:a0:96:40:61:32:ec:e2:4c:44:ef:fa:20:98:48: - d9:91:f9:40:43:ef:81:58:90:02:78:bc:0b:bf:bd:7e:67:08: - 85:3c:88:e2:d9:38:9c:a8:51:45:43:eb:f1:77:97:47:f1:38: - d8:f1:74:4e:d5:17:a1:a6:dc:1f:f7:62:15:e8:fd:36:1c:3a: - cb:4c:1b:55:1f:62:36:e2:31:89:e0:84:02:5a:04:79:58:66: - 68:f9:d7:44:0d:25:29:f8:68:21:7b:c9:c8:d8:c6:21:9e:cd: - 1a:0b:7d:d6:30:0f:86:f8:7c:e0:e2:e5:b6:e3:ef:9e:c3:21: - 81:1e:f1:92:23:d6:87:b9:0e:90:b1:95:10:f1:20:ba:cf:0f: - 99:6d:bb:69:91:85:3c:ba:73:89:07:2f:e8:b0:9e:ca:94:0e: - b7:0a:95:99:63:df:a9:52:9d:96:84:dd:f5:75:af:ca:72:b3: - 6e:4a:3d:50:23:54:1c:b7:0c:e0:53:55:f2:5d:79:89:72:80: - b0:90:b7:2c:c9:8d:de:cf:ee:0a:ae:12:db:ba:a7:32:57:d3: - d7:64:0d:2e:87:c3:2e:0c:51:f3:84:36:ba:a2:4d:f3:98:ff: - eb:d1:06:d0 + a2:76:a0:fc:72:5c:0c:48:59:8e:fb:06:02:1d:de:e6:cd:eb: + 58:97:0c:4e:b8:f3:d2:af:f5:4c:35:36:fc:17:57:58:cc:f0: + fe:67:57:b0:26:f1:07:8f:01:72:62:d9:a0:a4:1f:95:d7:dc: + ea:48:0c:47:a2:57:dd:0b:0d:21:81:24:8f:15:0e:c3:7b:6c: + 3a:46:13:47:4f:fb:bf:b8:f1:74:04:ca:dd:17:40:ed:f4:a9: + 86:82:9a:b3:a5:1b:0e:2b:e2:f2:1b:c1:30:c9:aa:51:c5:f9: + 33:58:33:25:21:d1:10:34:6a:4d:89:9d:9e:ef:ef:cf:ed:3b: + 08:67:47:17:62:3b:5f:f7:81:14:57:86:c7:3c:fc:30:6b:20: + 8d:26:bc:b6:95:83:8d:84:2a:3a:12:25:02:22:c5:0c:11:cc: + eb:61:46:d4:01:f6:65:e0:b9:8d:6c:3e:7b:66:56:d8:c4:2d: + b5:c1:46:9f:b6:19:ae:ba:45:47:86:34:77:2d:3f:4d:66:4f: + fc:84:83:7a:98:c1:cc:b8:79:4f:21:d6:14:45:27:f1:c9:df: + 2d:db:b1:45:28:45:c9:73:a6:e6:6c:50:a5:9a:5a:dc:4b:87: + 9f:7c:fe:29:ed:50:c3:dd:6b:ad:2f:2e:97:1a:02:33:28:6d: + 68:72:7d:31 -----BEGIN CERTIFICATE----- -MIIDzjCCAragAwIBAgIQPiydvrBCyM/8mULVTUFqszANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTE4MDkwMTAwMDAwMFoXDTE1MDQwMjAwMDAwMFowYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAJ43dKPToW3CyVUweOzo+uaeIOW+8D4ChoS0 -j0yUlGYEGWgmziOTrKoZ3IdtvI4Qu2+sCSPoGhauPkGgZ+etjO9C+C+tbdTtN4yf -49ejPg1iLWVouNgFek/jP/HHm4qFV0hHJo3UyIQsh8xZ7N2Tg6WIeKE1CQ4yZtBu -6S68SjcJ2yIZ4oNdaIlxU7S3bAZHu2xLouwg9fmFoPQIpa8lTBlACin0V3K9Spo6 -jqUYKXXmJWnEEjoY8bIECKISpllEl3ED78DhIjI0uZBqukWY6Y0rRqgFfL4pJK2r -vqiVq5DEPS/lVsSae9RBuTE9Mhzk6drmWW4QG6GwJ1OpB4RTJu0CAwEAAaOBgDB+ -MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFFGebjBo6tSJcBOOL6oSJ19V+vwaMB8G -A1UdIwQYMBaAFJsmC4qYqbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IB -AQBpDImB39s8gFhvjVn80qDC8jqDYKbYoJZAYTLs4kxE7/ogmEjZkflAQ++BWJAC -eLwLv71+ZwiFPIji2TicqFFFQ+vxd5dH8TjY8XRO1Rehptwf92IV6P02HDrLTBtV -H2I24jGJ4IQCWgR5WGZo+ddEDSUp+Gghe8nI2MYhns0aC33WMA+G+Hzg4uW24++e -wyGBHvGSI9aHuQ6QsZUQ8SC6zw+ZbbtpkYU8unOJBy/osJ7KlA63CpWZY9+pUp2W -hN31da/KcrNuSj1QI1QctwzgU1XyXXmJcoCwkLcsyY3ez+4KrhLbuqcyV9PXZA0u -h8MuDFHzhDa6ok3zmP/r0QbQ +MIIDvzCCAqegAwIBAgIBEjANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE4MDkwMTAw +MDAwMFoXDTE1MDQwMjAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAJpaM8yhAt+lxLxXaBsDEbNYWI54Y4oCDorsXZamOz+Y2z661lZIiysA +PO/ikwhnRmiTBSxjTAfSAW82csvRQKR/olMPrnKSL8mKN5Z7pqmgMmg5WwPRe779 +fJ0Zh4eDCPRmW9T1ifdSkxZqbHBB2ApN/T8I4TrVJrUSCdANO2w0rlZGDxKrOfnf +2ae2lbrTlt5kQkSDaiGaLaNc6+rWm2OAdwoSsxIeMfGzrLJpygFRSpIK5X+11T8X +2LPg0hTHsT0KvuLvTyWUDdM5Kx79/2mJqB4YOB4va4ud5S4czvCfwvXZFDEqxfJf +BNnc7IBIUF+wvrdQVyJA8VNAjpdfZh0CAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFOg1lV+xdoWGwTUgMHZwrCuubkjaMB8GA1UdIwQYMBaAFJsmC4qY +qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP +BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQCidqD8clwMSFmO+wYC +Hd7mzetYlwxOuPPSr/VMNTb8F1dYzPD+Z1ewJvEHjwFyYtmgpB+V19zqSAxHolfd +Cw0hgSSPFQ7De2w6RhNHT/u/uPF0BMrdF0Dt9KmGgpqzpRsOK+LyG8EwyapRxfkz +WDMlIdEQNGpNiZ2e7+/P7TsIZ0cXYjtf94EUV4bHPPwwayCNJry2lYONhCo6EiUC +IsUMEczrYUbUAfZl4LmNbD57ZlbYxC21wUafthmuukVHhjR3LT9NZk/8hIN6mMHM +uHlPIdYURSfxyd8t27FFKEXJc6bmbFClmlrcS4effP4p7VDD3WutLy6XGgIzKG1o +cn0x -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/subjectAltName_sanity_check.pem b/net/data/ssl/certificates/subjectAltName_sanity_check.pem index d25a217..5ed3a9b3 100644 --- a/net/data/ssl/certificates/subjectAltName_sanity_check.pem +++ b/net/data/ssl/certificates/subjectAltName_sanity_check.pem
@@ -1,36 +1,35 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 7f:9a:03:34:c6:e4:ba:e0:92:bb:a0:cb:9a:c4:a6:2a:89:38:57:b5 - Signature Algorithm: sha256WithRSAEncryption - Issuer: C = US, ST = California, L = Mountain View, O = Test CA, CN = 127.0.0.1 + Serial Number: 16251326626457629923 (0xe1884f76aadab4e3) + Signature Algorithm: sha256WithRSAEncryption + Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Validity - Not Before: Mar 13 20:46:17 2020 GMT - Not After : Mar 11 20:46:17 2030 GMT - Subject: C = US, ST = California, L = Mountain View, O = Test CA, CN = 127.0.0.1 + Not Before: Jun 5 17:10:46 2017 GMT + Not After : Jun 3 17:10:46 2027 GMT + Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:b5:46:69:81:43:dc:81:89:0a:bb:45:9a:68:5b: - 13:7c:e9:7c:b1:0f:ef:94:58:cd:ae:6d:fb:07:03: - 0d:10:a9:3e:3e:8b:a2:a4:18:00:aa:ed:47:be:b2: - 13:b9:be:f7:52:68:32:0a:17:06:8f:55:2f:b1:31: - 43:7b:08:db:18:3b:43:b4:55:c1:89:1f:46:58:71: - 55:8f:33:3d:e4:ef:77:1f:e6:f0:ba:10:b4:1a:d4: - 08:7d:34:35:a9:66:76:5c:ab:2c:86:5e:15:5c:53: - 6e:08:92:d5:94:48:49:83:41:c5:ff:18:e4:81:2b: - d9:65:22:8f:90:96:b8:b0:82:40:61:d5:e5:2f:c3: - 9d:c2:95:fa:a7:64:e2:a9:aa:02:19:67:07:b5:cf: - 7c:96:14:0c:37:99:df:10:2f:23:b5:5a:bf:2b:a0: - 8a:f9:fb:72:86:db:db:51:ae:4d:c0:35:da:bb:ce: - 98:f8:1c:28:a6:04:4e:eb:1d:87:83:ac:70:bb:0b: - 17:d2:1d:df:1c:f7:b1:a0:f8:85:5f:31:25:ce:37: - c5:65:09:d4:53:47:a0:fb:ab:cc:95:1a:8e:4c:e5: - bd:a0:dc:c4:32:24:aa:10:10:4e:01:68:b7:df:2a: - fc:64:e5:88:de:bb:dd:60:ac:ea:df:56:a2:11:1f: - f8:73 + 00:be:1b:08:be:be:01:88:90:32:54:37:9f:95:fc: + 22:04:22:e1:ef:a8:28:b5:20:a8:dd:f9:ff:4e:3b: + ca:ca:e2:05:43:a0:6e:bb:db:0c:6c:e8:59:05:83: + 2a:65:14:32:83:9b:af:04:61:ab:2b:35:c7:1f:3a: + 59:6b:24:3c:91:f1:0e:18:33:23:0a:13:63:80:59: + 1e:4d:65:e8:60:67:1e:07:8f:70:19:f5:59:5f:b6: + 8b:54:83:c6:a4:33:e8:91:56:9d:f6:90:ab:3d:eb: + 6f:e9:91:07:d2:60:5c:d7:4c:36:97:7e:b4:ff:ac: + f0:8a:41:8f:50:fb:c6:bd:ee:d9:00:ac:d9:f6:4f: + c8:49:fc:1c:b5:3e:f6:74:4d:8e:cc:74:cb:4f:af: + f9:a6:42:dc:9f:e1:4b:0e:bb:82:4f:46:06:3d:6a: + 68:d6:45:96:3e:9c:c6:60:ac:c6:7e:ed:d7:39:16: + 85:c6:91:97:12:6f:74:2a:60:bf:2e:d7:ff:91:d8: + 81:46:d4:e9:33:19:5a:04:35:34:96:c2:de:9d:a8: + 54:75:ed:91:da:94:ed:91:f5:1d:2a:5e:66:b3:4b: + 0f:2f:1f:97:81:83:c4:5e:34:d5:e6:cf:df:e0:a2: + d1:93:e5:64:64:6f:50:5c:7d:bc:4d:1c:2e:93:6a: + ad:65 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical @@ -38,41 +37,41 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.2, IP Address:FE80:0:0:0:0:0:0:1, DNS:test.example, email:test@test.example, othername:<unsupported>, DirName:/CN=127.0.0.3 Signature Algorithm: sha256WithRSAEncryption - 5c:86:b6:d7:42:d1:91:3e:27:16:38:23:1b:58:96:1a:56:26: - d3:c0:2a:62:5b:d2:bb:1b:cf:72:5e:9c:70:40:61:0f:05:0b: - d9:2d:f8:67:de:b2:d5:6b:55:e2:48:b2:08:8f:b5:a0:36:32: - 63:3a:4b:08:12:de:54:e8:a8:bb:e2:4a:0b:76:0c:89:5e:d2: - 22:3d:42:06:23:64:85:17:0e:cf:56:91:ce:cc:ce:68:0a:55: - 87:fa:e0:f9:ad:63:ad:1b:fa:ca:d0:93:91:e6:76:8e:29:8e: - db:9c:1b:39:a6:dc:ed:dd:46:f7:e4:3b:d7:87:d6:73:21:27: - c4:cf:02:18:88:3f:99:ac:ba:63:ab:68:5d:ab:52:d7:1c:9b: - 2f:b9:1f:e8:59:57:ef:c2:f2:6b:2e:58:4d:e1:aa:85:da:8e: - 60:c7:1d:c6:ad:35:8a:07:ab:c5:11:60:84:71:fe:f6:ca:78: - 7b:ce:be:ba:41:c4:5b:b6:3e:da:82:8f:4a:93:b8:7e:2c:9d: - 46:85:5d:4c:66:e1:71:6f:13:12:af:a6:26:5a:48:d0:09:1e: - dd:71:25:9d:06:bc:2b:81:b6:c2:6d:d1:c0:17:a6:98:09:dc: - 0d:e2:74:d6:a8:e9:de:e0:7f:06:86:ef:f8:48:f2:b7:b4:e9: - ba:46:c3:68 + 27:c1:5a:11:e6:f9:3b:69:a1:61:a9:af:83:21:3c:d0:60:43: + b2:e4:27:b7:46:67:d8:ae:dc:b7:51:85:53:25:b8:d8:48:d9: + ce:2d:f4:17:2c:75:a1:2d:ad:fe:73:a6:1e:0b:3f:4a:1a:df: + 85:99:db:57:b0:cc:8d:3d:01:74:11:2e:51:81:c4:4b:2d:ee: + bd:05:84:59:ce:a5:40:c5:3d:fa:19:d7:48:32:22:ca:49:d6: + e3:74:8f:fb:02:0e:d1:73:76:7a:3d:ca:e8:96:7e:0d:2e:df: + 79:44:ce:aa:f6:ea:c2:61:d6:54:11:c9:38:85:72:4f:9f:94: + b0:f9:d1:84:43:05:5a:8a:37:d4:ce:d7:e9:16:23:7e:10:67: + 8b:61:00:54:c6:13:da:03:e3:ed:4f:46:eb:44:af:5c:65:e7: + 93:1d:2e:ab:d3:8e:35:e5:4e:d1:56:ef:09:1b:74:b3:a4:ca: + 00:83:ea:e0:95:ed:ef:f3:cd:8a:1e:da:71:6d:40:e7:36:56: + 26:50:9f:5a:86:7f:45:4a:d4:0c:6b:40:68:78:fe:57:0a:e7: + 96:8c:ec:38:57:ac:89:58:54:e0:14:76:4c:93:40:7d:2e:d7: + 36:1d:71:5a:ac:73:f8:ad:80:d3:52:48:b4:68:f3:06:ab:b7: + 5a:b4:2c:1a -----BEGIN CERTIFICATE----- -MIID0zCCArugAwIBAgIUf5oDNMbkuuCSu6DLmsSmKok4V7UwDQYJKoZIhvcNAQEL -BQAwYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcM -DU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4w -LjAuMTAeFw0yMDAzMTMyMDQ2MTdaFw0zMDAzMTEyMDQ2MTdaMGAxCzAJBgNVBAYT -AlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3 -MRAwDgYDVQQKDAdUZXN0IENBMRIwEAYDVQQDDAkxMjcuMC4wLjEwggEiMA0GCSqG -SIb3DQEBAQUAA4IBDwAwggEKAoIBAQC1RmmBQ9yBiQq7RZpoWxN86XyxD++UWM2u -bfsHAw0QqT4+i6KkGACq7Ue+shO5vvdSaDIKFwaPVS+xMUN7CNsYO0O0VcGJH0ZY -cVWPMz3k73cf5vC6ELQa1Ah9NDWpZnZcqyyGXhVcU24IktWUSEmDQcX/GOSBK9ll -Io+QlriwgkBh1eUvw53ClfqnZOKpqgIZZwe1z3yWFAw3md8QLyO1Wr8roIr5+3KG -29tRrk3ANdq7zpj4HCimBE7rHYeDrHC7CxfSHd8c97Gg+IVfMSXON8VlCdRTR6D7 -q8yVGo5M5b2g3MQyJKoQEE4BaLffKvxk5Yjeu91grOrfVqIRH/hzAgMBAAGjgYQw -gYEwDwYDVR0TAQH/BAUwAwEB/zBuBgNVHREEZzBlhwR/AAAChxD+gAAAAAAAAAAA -AAAAAAABggx0ZXN0LmV4YW1wbGWBEXRlc3RAdGVzdC5leGFtcGxloBIGAyoDBKAL -DAlpZ25vcmUgbWWkFjAUMRIwEAYDVQQDDAkxMjcuMC4wLjMwDQYJKoZIhvcNAQEL -BQADggEBAFyGttdC0ZE+JxY4IxtYlhpWJtPAKmJb0rsbz3JenHBAYQ8FC9kt+Gfe -stVrVeJIsgiPtaA2MmM6SwgS3lToqLviSgt2DIle0iI9QgYjZIUXDs9Wkc7MzmgK -VYf64PmtY60b+srQk5Hmdo4pjtucGzmm3O3dRvfkO9eH1nMhJ8TPAhiIP5msumOr -aF2rUtccmy+5H+hZV+/C8msuWE3hqoXajmDHHcatNYoHq8URYIRx/vbKeHvOvrpB -xFu2PtqCj0qTuH4snUaFXUxm4XFvExKvpiZaSNAJHt1xJZ0GvCuBtsJt0cAXppgJ -3A3idNao6d7gfwaG7/hI8re06bpGw2g= +MIIDyDCCArCgAwIBAgIJAOGIT3aq2rTjMA0GCSqGSIb3DQEBCwUAMGAxCzAJBgNV +BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBW +aWV3MRAwDgYDVQQKDAdUZXN0IENBMRIwEAYDVQQDDAkxMjcuMC4wLjEwHhcNMTcw +NjA1MTcxMDQ2WhcNMjcwNjAzMTcxMDQ2WjBgMQswCQYDVQQGEwJVUzETMBEGA1UE +CAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4GA1UECgwH +VGVzdCBDQTESMBAGA1UEAwwJMTI3LjAuMC4xMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEAvhsIvr4BiJAyVDeflfwiBCLh76gotSCo3fn/TjvKyuIFQ6Bu +u9sMbOhZBYMqZRQyg5uvBGGrKzXHHzpZayQ8kfEOGDMjChNjgFkeTWXoYGceB49w +GfVZX7aLVIPGpDPokVad9pCrPetv6ZEH0mBc10w2l360/6zwikGPUPvGve7ZAKzZ +9k/ISfwctT72dE2OzHTLT6/5pkLcn+FLDruCT0YGPWpo1kWWPpzGYKzGfu3XORaF +xpGXEm90KmC/Ltf/kdiBRtTpMxlaBDU0lsLenahUde2R2pTtkfUdKl5ms0sPLx+X +gYPEXjTV5s/f4KLRk+VkZG9QXH28TRwuk2qtZQIDAQABo4GEMIGBMA8GA1UdEwEB +/wQFMAMBAf8wbgYDVR0RBGcwZYcEfwAAAocQ/oAAAAAAAAAAAAAAAAAAAYIMdGVz +dC5leGFtcGxlgRF0ZXN0QHRlc3QuZXhhbXBsZaASBgMqAwSgCwwJaWdub3JlIG1l +pBYwFDESMBAGA1UEAwwJMTI3LjAuMC4zMA0GCSqGSIb3DQEBCwUAA4IBAQAnwVoR +5vk7aaFhqa+DITzQYEOy5Ce3RmfYrty3UYVTJbjYSNnOLfQXLHWhLa3+c6YeCz9K +Gt+FmdtXsMyNPQF0ES5RgcRLLe69BYRZzqVAxT36GddIMiLKSdbjdI/7Ag7Rc3Z6 +Pcroln4NLt95RM6q9urCYdZUEck4hXJPn5Sw+dGEQwVaijfUztfpFiN+EGeLYQBU +xhPaA+PtT0brRK9cZeeTHS6r04415U7RVu8JG3SzpMoAg+rgle3v882KHtpxbUDn +NlYmUJ9ahn9FStQMa0BoeP5XCueWjOw4V6yJWFTgFHZMk0B9Ltc2HXFarHP4rYDT +Uki0aPMGq7datCwa -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/subjectAltName_www_example_com.pem b/net/data/ssl/certificates/subjectAltName_www_example_com.pem index fc97459c..f08f3fde 100644 --- a/net/data/ssl/certificates/subjectAltName_www_example_com.pem +++ b/net/data/ssl/certificates/subjectAltName_www_example_com.pem
@@ -1,36 +1,35 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - 64:b2:04:2e:6b:94:d9:cd:c7:69:39:a8:9c:54:ee:0f:0b:a8:1f:93 - Signature Algorithm: sha256WithRSAEncryption - Issuer: C = US, ST = California, L = Mountain View, O = Test CA, CN = 127.0.0.1 + Serial Number: 9226305053301513866 (0x800a6b901b6d9e8a) + Signature Algorithm: sha256WithRSAEncryption + Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Validity - Not Before: Mar 13 20:46:17 2020 GMT - Not After : Mar 11 20:46:17 2030 GMT - Subject: C = US, ST = California, L = Mountain View, O = Test CA, CN = 127.0.0.1 + Not Before: Jun 5 17:10:46 2017 GMT + Not After : Jun 3 17:10:46 2027 GMT + Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:b2:74:1b:cb:70:e0:fb:16:f6:9e:e2:fb:1f:53: - d8:40:2a:b7:c0:58:41:8c:cd:97:95:9a:4c:a4:b4: - e8:ce:ac:e0:f3:cb:9c:4c:87:7a:35:0a:32:82:65: - b4:14:8a:e7:8b:d6:ac:37:1c:4e:68:f6:aa:88:17: - f8:e7:bb:c6:2f:73:38:15:ca:32:93:88:54:d8:0a: - da:69:da:51:0f:0c:24:1d:5c:69:e9:3e:cf:20:29: - 7f:c5:e0:99:8f:9a:b0:f2:94:3d:36:49:2a:d3:5f: - 1d:31:57:9f:ac:32:c7:8f:37:cd:26:9f:39:ca:e8: - c7:38:13:87:b6:81:e6:d5:66:5f:6d:28:a2:c3:22: - 4f:e2:38:ac:4b:13:87:aa:7c:03:0e:1e:96:2f:ef: - c3:96:f9:d5:73:34:16:0b:d6:18:0b:7a:95:c4:4a: - b5:ab:79:06:2b:01:8a:36:15:4e:66:c6:2b:ac:bb: - 1e:ea:5e:f5:c1:87:07:c2:88:58:6b:87:a4:ec:c4: - f8:9b:30:a8:34:f7:0d:5f:0c:e5:3f:e2:89:68:32: - 94:29:a5:3c:c3:f0:c5:5c:81:f3:72:a2:a8:d0:26: - f8:0a:95:b0:9f:d8:b1:70:b6:f1:4d:c4:91:0b:1e: - d9:3d:70:38:5c:69:bb:d8:f7:0b:57:01:b4:60:12: - 18:c3 + 00:c2:db:bc:7e:99:b1:50:d8:bf:22:12:80:24:5b: + ab:6d:bb:75:86:e1:14:17:9b:e4:c8:f2:99:ef:aa: + be:8f:4a:74:29:a1:ce:24:55:aa:f1:b5:e9:9a:c7: + 01:04:e1:87:c9:38:32:ff:fe:f1:26:e4:36:74:62: + 84:a7:13:1b:44:b5:4c:9f:41:86:f2:28:7c:d1:24: + 3e:c0:f4:4e:0b:81:e8:f1:f7:54:bf:b0:87:2f:19: + 17:92:aa:f7:fd:86:b3:bf:2c:5b:23:da:9b:13:ae: + 0d:32:4d:b4:94:72:c6:08:05:95:c4:1d:b7:e2:34: + 35:6e:44:44:c1:5d:d5:61:78:b9:e9:70:55:e6:a0: + cf:08:1d:7e:85:48:3e:51:33:6b:15:c2:11:f9:37: + db:cf:8b:6a:f0:cc:f7:cc:41:3a:ef:e6:78:3d:03: + 9f:ab:79:3f:aa:6f:e5:68:07:21:f0:62:5b:cd:2d: + d6:fb:fc:9f:71:a4:14:34:d7:3d:a3:27:ee:89:4c: + 6c:06:62:ab:1a:6e:7b:a4:1a:57:0f:93:2d:e5:c0: + 83:43:6d:e8:e3:72:53:58:2d:0f:57:f4:2a:37:84: + bf:d7:7f:f9:4f:5d:9a:96:ce:92:54:86:b4:6c:20: + 0e:fe:9a:f1:74:e3:65:3c:03:09:61:ea:6d:00:9a: + 70:df Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical @@ -38,39 +37,39 @@ X509v3 Subject Alternative Name: DNS:www.example.com Signature Algorithm: sha256WithRSAEncryption - 1f:17:5c:2b:99:43:7c:47:03:e4:af:a7:03:2d:32:f0:5a:99: - 64:c2:b2:c2:4e:e5:43:f4:dd:11:f9:0a:7d:53:8d:0e:d1:a0: - 3b:c1:9e:43:5d:73:aa:60:a6:34:05:4d:cb:11:e1:5e:d7:c4: - 2b:f7:b9:a0:b3:5d:07:c8:36:f9:91:bc:f0:62:19:11:ff:86: - 21:40:be:25:ce:cd:90:c1:99:d8:46:4d:e8:e2:40:a6:db:4d: - 26:fc:7a:e1:e6:1f:78:52:39:b5:d7:b2:75:aa:8a:77:3b:20: - 42:6c:4b:8d:9f:34:4d:51:af:f9:46:2b:81:51:7e:21:2f:38: - b0:96:84:92:05:18:3b:ca:b2:64:23:cc:17:48:40:f1:38:d3: - 70:1e:ba:06:84:9c:32:2d:97:f7:ee:2b:43:00:89:f7:ae:8b: - 74:63:70:fc:14:c2:c1:de:9c:e0:49:4f:2e:3e:6f:4b:8b:d5: - aa:94:d1:50:35:99:56:cb:6a:3d:7c:a2:44:29:2f:df:f4:1b: - aa:41:75:9a:e6:fe:b9:13:a7:86:86:a1:2b:77:31:3a:fe:32: - 55:63:a0:81:da:3e:c4:3f:2d:aa:4b:c9:3c:48:f2:fb:a2:46: - ab:ef:22:07:41:29:67:1f:ab:68:e5:9f:bb:d1:17:61:a8:13: - 7e:a9:32:eb + c1:24:33:a1:13:e3:3d:7a:aa:1c:d7:7e:02:27:b3:af:3b:f7: + 88:de:6a:97:11:28:07:ea:39:3b:11:89:9d:07:e5:7c:0e:b1: + 0e:5f:0f:6a:5a:b6:e4:35:ed:45:55:2c:b2:ed:c8:5a:af:69: + 86:87:b6:4e:11:3e:4d:82:a1:f5:11:ce:3c:fb:18:4a:1a:be: + e0:31:4c:bb:0d:2b:90:49:58:a7:1a:33:f3:16:84:d1:f4:ec: + c9:7a:eb:65:04:ac:03:3e:17:97:ac:fb:db:3a:52:bf:af:22: + f7:10:00:a8:ad:d6:0f:a3:c1:f1:6a:9e:78:30:de:0d:03:ad: + f6:8e:f6:6f:4b:af:5f:f4:76:ec:23:fa:d1:a0:1f:40:7f:e4: + 7d:84:cd:5f:42:c3:4c:7d:0e:89:3a:3e:ae:34:18:18:31:45: + 44:2f:d0:1f:e9:46:f0:ee:f2:c4:c7:a8:4d:f3:2d:c6:66:a5: + 02:01:a5:0b:7c:3f:91:d0:38:41:ad:d6:3d:0c:0c:3e:43:81: + cb:7e:87:95:b2:ae:7e:ff:67:11:ea:98:66:b4:3e:87:95:e3: + 37:09:e8:de:22:bb:7b:02:00:40:1b:77:a6:09:65:75:45:a0: + 0a:49:23:32:4e:b1:b5:c3:fb:a2:5b:d5:88:7d:35:04:7d:5b: + 79:53:f5:a0 -----BEGIN CERTIFICATE----- -MIIDfTCCAmWgAwIBAgIUZLIELmuU2c3HaTmonFTuDwuoH5MwDQYJKoZIhvcNAQEL -BQAwYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcM -DU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4w -LjAuMTAeFw0yMDAzMTMyMDQ2MTdaFw0zMDAzMTEyMDQ2MTdaMGAxCzAJBgNVBAYT -AlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3 -MRAwDgYDVQQKDAdUZXN0IENBMRIwEAYDVQQDDAkxMjcuMC4wLjEwggEiMA0GCSqG -SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCydBvLcOD7Fvae4vsfU9hAKrfAWEGMzZeV -mkyktOjOrODzy5xMh3o1CjKCZbQUiueL1qw3HE5o9qqIF/jnu8YvczgVyjKTiFTY -Ctpp2lEPDCQdXGnpPs8gKX/F4JmPmrDylD02SSrTXx0xV5+sMsePN80mnznK6Mc4 -E4e2gebVZl9tKKLDIk/iOKxLE4eqfAMOHpYv78OW+dVzNBYL1hgLepXESrWreQYr -AYo2FU5mxiusux7qXvXBhwfCiFhrh6TsxPibMKg09w1fDOU/4oloMpQppTzD8MVc -gfNyoqjQJvgKlbCf2LFwtvFNxJELHtk9cDhcabvY9wtXAbRgEhjDAgMBAAGjLzAt -MA8GA1UdEwEB/wQFMAMBAf8wGgYDVR0RBBMwEYIPd3d3LmV4YW1wbGUuY29tMA0G -CSqGSIb3DQEBCwUAA4IBAQAfF1wrmUN8RwPkr6cDLTLwWplkwrLCTuVD9N0R+Qp9 -U40O0aA7wZ5DXXOqYKY0BU3LEeFe18Qr97mgs10HyDb5kbzwYhkR/4YhQL4lzs2Q -wZnYRk3o4kCm200m/Hrh5h94Ujm117J1qop3OyBCbEuNnzRNUa/5RiuBUX4hLziw -loSSBRg7yrJkI8wXSEDxONNwHroGhJwyLZf37itDAIn3rot0Y3D8FMLB3pzgSU8u -Pm9Li9WqlNFQNZlWy2o9fKJEKS/f9BuqQXWa5v65E6eGhqErdzE6/jJVY6CB2j7E -Py2qS8k8SPL7okar7yIHQSlnH6to5Z+70RdhqBN+qTLr +MIIDcjCCAlqgAwIBAgIJAIAKa5AbbZ6KMA0GCSqGSIb3DQEBCwUAMGAxCzAJBgNV +BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBW +aWV3MRAwDgYDVQQKDAdUZXN0IENBMRIwEAYDVQQDDAkxMjcuMC4wLjEwHhcNMTcw +NjA1MTcxMDQ2WhcNMjcwNjAzMTcxMDQ2WjBgMQswCQYDVQQGEwJVUzETMBEGA1UE +CAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4GA1UECgwH +VGVzdCBDQTESMBAGA1UEAwwJMTI3LjAuMC4xMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEAwtu8fpmxUNi/IhKAJFurbbt1huEUF5vkyPKZ76q+j0p0KaHO +JFWq8bXpmscBBOGHyTgy//7xJuQ2dGKEpxMbRLVMn0GG8ih80SQ+wPROC4Ho8fdU +v7CHLxkXkqr3/YazvyxbI9qbE64NMk20lHLGCAWVxB234jQ1bkREwV3VYXi56XBV +5qDPCB1+hUg+UTNrFcIR+Tfbz4tq8Mz3zEE67+Z4PQOfq3k/qm/laAch8GJbzS3W ++/yfcaQUNNc9oyfuiUxsBmKrGm57pBpXD5Mt5cCDQ23o43JTWC0PV/QqN4S/13/5 +T12als6SVIa0bCAO/prxdONlPAMJYeptAJpw3wIDAQABoy8wLTAPBgNVHRMBAf8E +BTADAQH/MBoGA1UdEQQTMBGCD3d3dy5leGFtcGxlLmNvbTANBgkqhkiG9w0BAQsF +AAOCAQEAwSQzoRPjPXqqHNd+Aiezrzv3iN5qlxEoB+o5OxGJnQflfA6xDl8Palq2 +5DXtRVUssu3IWq9phoe2ThE+TYKh9RHOPPsYShq+4DFMuw0rkElYpxoz8xaE0fTs +yXrrZQSsAz4Xl6z72zpSv68i9xAAqK3WD6PB8WqeeDDeDQOt9o72b0uvX/R27CP6 +0aAfQH/kfYTNX0LDTH0OiTo+rjQYGDFFRC/QH+lG8O7yxMeoTfMtxmalAgGlC3w/ +kdA4Qa3WPQwMPkOBy36HlbKufv9nEeqYZrQ+h5XjNwno3iK7ewIAQBt3pglldUWg +CkkjMk6xtcP7olvViH01BH1beVP1oA== -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/test_names.pem b/net/data/ssl/certificates/test_names.pem index 82067fdb..95ff8975a 100644 --- a/net/data/ssl/certificates/test_names.pem +++ b/net/data/ssl/certificates/test_names.pem
@@ -1,70 +1,70 @@ -----BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC0qJb6OLzVG3DP -5EHtczqgmUFVcglIs0kjL+tQHR7rmMFCxp6/MHAcubCms7tlMkSW8qUEQsmRJVF3 -1jXgV063zgrXMTFbuTHmSnLK/9Ff25wyCOkWCYzhz7N+MIgALsSpLUCnmnfZxckU -u2HZnjBoRmU6Zh2lGbhGjFOr4hNINodwVmwh+BzgBqaf1m2ItXIU3oE9+lfyW0GU -aWDTOUZUCPfvSf/UPpLzrWDNdWGlqNjRWqgupyUwKxTg5ewfUhGNV6Mjrc3uKIJn -n4lwYeXHzTvEujsmzt4tlWZvihZijrXF+rBNIFxRZza8RNw2A7zVpecPWZ+ZSwCD -nrCfLkRtAgMBAAECggEAe3N5OCPtZfMKdAWWx5wmQ/h2HN2AWp2pLNJiCqzbpEMO -TYNMl3mSIw8BF+lZ9R0UodHN0cuR0g2eTjWjO1puAExcPBDxmaxD3QqixvVpLgf0 -BHzySozcKLK2BVVEmltbKAA0XlO/8qCld/VUOFFQ4vC32+BMAbZBpnPd+WbTplP2 -uj3KE6yU2Gn6z+cv8NhhhYgHBdgLtojsPu/Ezs/uKqsIomvzSIabzaYd7hk+RxY3 -a2kfVMt5o4mxhax21hwoZUq5bRRHLzNLJlFjHI6/ALJMn0MfJzt0J2/KeWue36z5 -QPW0nGt9DghvARPQtwrCTADSb9lpQoH0CSdLqf6AAQKBgQDfQ6bUcQazMGurrx0e -kUunwtMzxmMs9YOJpasGThFMmt2INP6zF4DePRTAP25wdQH8+quT1Uvws1g6MCa8 -Da8hhxphsDD8gA6bMw4p+mE3PxranAZyjd2P1HcgxfJlJBEG+Hjm5Hw2SqgzbW9G -pAShBTMBUPwJFu2ycynbwF7GAQKBgQDPJbWDSXZZSSzvFdh/ZR6BEmyLrEcJ+nAr -IPqDgL0qgMbm0yU4IgYG6Z7fLoAmJOtHwOm8d3oJUtLqsyLmhPO01zXayXlo3ri2 -T2LD5aqM+IvjwbfojLe2O0eCnU1JdmXCqWK/4neNgYwWAM1ARDBaVcgOiA+zzNde -R+iYCo/2bQKBgQDNZyonLM0jMhr82qCJrNbTwtQYQB6iEEYx7u7HYC9eMOQ7GbZy -Ad+Xls5uiG0MnTl1CxGrcoLpMbar4fzg6h4DVI6a7UREKXRGqNQRHr8t2qrUENOF -tKrwVmI7DqIRFvtrVFG26uKz+D+DAN1tOhzgHy5ruZwGqMeKc5VBDVykAQKBgBFK -5Zc7J70WZcDjwvoHl/9QaW1TiW6k0H5ZN3CI68HDlFcqoz3HYVdsY03gVORaSqXn -zdtk4fQrTN447B3wVWPwX1ePYCpIBYV6pRUTdCRmj08JGfA45xE4a6TUuuH6F06j -01GPd0mB2g7wLDJEPwEbjiLgaucon4YIXLtsjk4VAoGAeH9+EOKh6zvb/nhQ4X9f -+hldkbHhra9WPxRT8wB8mfOXaNVkJruJ6HDyXDb+bqlSaTgakw+VnAa0dSoyYIVB -wy8PWm+0pNjR3QZ01GbL2GVikr0dE805XwabFWHCMigbWvYxla+Kz5iQ9+bUrMAx -jo90xzuvy7tuwUDzXJU97Uc= +MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCr56DO++8VlWy3 +9XXdRKtmLymKfGU8mfUnv4ByKKnZu05BCLrkskcHn0KjferLmUvsuTr88H+icNbP +px1ZvJ58G4lesVcFx+rotsVaBFKPBt+BXlUxDhReet2Vb56/1F8clTeYz+IWQYzt +OpABrO/dxQRq0xmVG0pHXUI6Dk11Vo4Zd62c526kDFCyozvdxYyi62ZuRGI8nMVD +vymk5BvR88zSaRNFeA71GGTxInxi+3/UwVR3hcdhZ1CGRx/52pF3XDrTtKYuhwJL +OZOoUDY+CR9skbEBLvrCemL5PFwl/6upBuLWWxzYqGNrMd6WgEd0XcgAvJplqmeW +wzSgm/27AgMBAAECggEAf5zMsLsvihtKAOoUHDVc89dxBCBCWxGDf4VXCegL5tl4 +Ryj+7MU3m33rz0irY4ciaNI86wZyCZmwrahGTpaKJGGgwY3upxj41tbPfHqW+xxE +EVqA7ZChKF4XXlblR0yVareO9T7lfFYfEwCVZNkHm98k31Rkul7u7jlZ75UshTyL +esQcX8mlEZQXbBVEQ2ojoknWhq+jjRmZzAEZpXLJGIjLe20JT/p+QaNDclFimt6R +thxJ42bnx8G2Pxhl7wXgLmy+Pu6kDrs7gUa9iKqFoMswxifZODMD+iqUct5vgRV2 +e1+1XskeJJn+AKnMymCNujHiSS4iLL/LamMXtWElEQKBgQDS+alLOCzhNSnhFre/ +d4TkPWVLJcafMQ0Embmj1I8JOnpGx7KWuI+f3I8ut1G8kbNichD4yHui0fDlfqRT +pKWZE44K0GZGq5rzA/c3NfFCndHV7lkofS1I8AYVaUnl3oKVg7lhkg0pAr9cC2vE ++k9+iV2Fwq1L3qoiuJF5O1AsWQKBgQDQl2hZSnHxflk9nTtS7njnGI9Q5QSlW8eJ +BrN+6D7lVPK+U/Tqd7QHXwnRsrnOuSuiS0HiFM/7OAmjLRDxCGjUxnkVDAqm0Htj +oVp06FKofRElNb/up8wbFjhjEMrSWF0qGD3WDjmFSHp3ZznO7mw752CnzabD7tid +LF+4mrdoMwKBgDaESynjxz0exsaiXzL7yHxOHSmxBkVGoI2Kx7y9BYUl9kjp+40U +/hAaJ2mz90wZ/le3EAmpjMFDLNOwyPfQOPZ4ZiEHPxaN64lWggBjUQeczodQgvuC +dTw+weOwhGcA+491LWc4HWx2iEpZrSyGXhpdlqwk5TEQxbgZJ4ZDPHFpAoGAVHZK +eYVsd/XKWumUwPLxH9pRBdeGNxLfy/tbqTKPbTslg63pSRupWSbBihjNpghSw8en +aM02ninFtT4lUwQttqKbGsuicIOQwvnt79K2zaS+0YtfKVrmib1IncyJ4/yF1Oq1 +9zwRTIfZlwnEXacrSmJZP/lE4qePLK1wIQb85wMCgYBR6l2B8Cf/MlOlsqfP24ZU +AOm63+CWFarTh0m/pi/SVByLrS8LD3l1jZjaH6Gjw8Xfm6c7iVDJYCe7QWOxvb3c +QbafGkVB+EPmqL6wtnqpxLjtuhe19/L6qlTuM9oqODqqESzhU+bworovVtV8ZH00 +q+99H/JlBoMr13sYXsZYFw== -----END PRIVATE KEY----- Certificate: Data: Version: 3 (0x2) Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:aa + f3:16:df:45:2e:03:f3:bc:17:7c:99:0e:a4:e5:25:5a Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity - Not Before: Mar 13 20:46:17 2020 GMT - Not After : Mar 13 20:46:17 2022 GMT + Not Before: Nov 27 22:36:24 2019 GMT + Not After : Nov 24 22:36:24 2029 GMT Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption RSA Public-Key: (2048 bit) Modulus: - 00:b4:a8:96:fa:38:bc:d5:1b:70:cf:e4:41:ed:73: - 3a:a0:99:41:55:72:09:48:b3:49:23:2f:eb:50:1d: - 1e:eb:98:c1:42:c6:9e:bf:30:70:1c:b9:b0:a6:b3: - bb:65:32:44:96:f2:a5:04:42:c9:91:25:51:77:d6: - 35:e0:57:4e:b7:ce:0a:d7:31:31:5b:b9:31:e6:4a: - 72:ca:ff:d1:5f:db:9c:32:08:e9:16:09:8c:e1:cf: - b3:7e:30:88:00:2e:c4:a9:2d:40:a7:9a:77:d9:c5: - c9:14:bb:61:d9:9e:30:68:46:65:3a:66:1d:a5:19: - b8:46:8c:53:ab:e2:13:48:36:87:70:56:6c:21:f8: - 1c:e0:06:a6:9f:d6:6d:88:b5:72:14:de:81:3d:fa: - 57:f2:5b:41:94:69:60:d3:39:46:54:08:f7:ef:49: - ff:d4:3e:92:f3:ad:60:cd:75:61:a5:a8:d8:d1:5a: - a8:2e:a7:25:30:2b:14:e0:e5:ec:1f:52:11:8d:57: - a3:23:ad:cd:ee:28:82:67:9f:89:70:61:e5:c7:cd: - 3b:c4:ba:3b:26:ce:de:2d:95:66:6f:8a:16:62:8e: - b5:c5:fa:b0:4d:20:5c:51:67:36:bc:44:dc:36:03: - bc:d5:a5:e7:0f:59:9f:99:4b:00:83:9e:b0:9f:2e: - 44:6d + 00:ab:e7:a0:ce:fb:ef:15:95:6c:b7:f5:75:dd:44: + ab:66:2f:29:8a:7c:65:3c:99:f5:27:bf:80:72:28: + a9:d9:bb:4e:41:08:ba:e4:b2:47:07:9f:42:a3:7d: + ea:cb:99:4b:ec:b9:3a:fc:f0:7f:a2:70:d6:cf:a7: + 1d:59:bc:9e:7c:1b:89:5e:b1:57:05:c7:ea:e8:b6: + c5:5a:04:52:8f:06:df:81:5e:55:31:0e:14:5e:7a: + dd:95:6f:9e:bf:d4:5f:1c:95:37:98:cf:e2:16:41: + 8c:ed:3a:90:01:ac:ef:dd:c5:04:6a:d3:19:95:1b: + 4a:47:5d:42:3a:0e:4d:75:56:8e:19:77:ad:9c:e7: + 6e:a4:0c:50:b2:a3:3b:dd:c5:8c:a2:eb:66:6e:44: + 62:3c:9c:c5:43:bf:29:a4:e4:1b:d1:f3:cc:d2:69: + 13:45:78:0e:f5:18:64:f1:22:7c:62:fb:7f:d4:c1: + 54:77:85:c7:61:67:50:86:47:1f:f9:da:91:77:5c: + 3a:d3:b4:a6:2e:87:02:4b:39:93:a8:50:36:3e:09: + 1f:6c:91:b1:01:2e:fa:c2:7a:62:f9:3c:5c:25:ff: + ab:a9:06:e2:d6:5b:1c:d8:a8:63:6b:31:de:96:80: + 47:74:5d:c8:00:bc:9a:65:aa:67:96:c3:34:a0:9b: + fd:bb Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 4B:85:5B:1B:4D:92:DC:E2:FB:DF:82:21:95:D4:9A:3C:7A:81:D7:EF + 72:93:A0:82:75:3D:83:80:E7:FA:7F:34:7B:30:F3:E8:7A:1B:D4:B1 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -73,42 +73,42 @@ X509v3 Subject Alternative Name: DNS:a.test, DNS:*.a.test, DNS:b.test, DNS:*.b.test, DNS:c.test, DNS:*.c.test, DNS:d.test, DNS:*.d.test Signature Algorithm: sha256WithRSAEncryption - 33:8f:42:7b:56:29:7a:dd:85:99:3b:24:21:28:80:8b:92:ab: - bf:9e:4c:d2:23:c6:8d:5a:be:25:8c:b1:ce:ca:4d:ba:a2:a5: - d8:b4:cd:e5:31:3e:6e:73:40:81:30:bf:7e:8f:c6:45:92:74: - 9d:d6:60:4f:7b:b5:4e:06:d4:ad:5f:e7:64:39:2f:7d:68:da: - b8:e6:bc:52:fe:31:39:c8:d0:be:d4:3b:27:64:a3:f4:c0:1b: - 63:c8:12:35:97:4f:be:0e:db:ba:0a:ba:8c:c2:32:ac:a8:5b: - aa:39:4b:1e:62:30:be:8b:f4:02:b7:2a:12:f4:01:76:35:6a: - c3:00:20:72:a1:c8:a8:f8:c2:96:da:af:91:47:87:31:1f:6b: - b7:c1:f8:2a:d9:ed:80:c0:fb:16:06:7a:68:69:77:59:f0:97: - 35:23:30:7e:08:db:79:f1:03:6b:ca:b8:24:27:cd:20:6f:31: - 52:90:d3:f5:0e:b0:3a:19:6a:d4:c8:0f:37:ff:64:88:e7:ce: - b2:f0:c1:7f:a1:9c:f2:97:99:14:a9:db:bc:93:85:de:55:ff: - 8b:1a:a6:e4:cf:7e:f0:0d:b2:f9:ad:ae:09:38:b5:bf:71:a6: - 0e:16:93:d0:0c:ef:2d:db:3d:26:97:79:71:7d:c4:9d:50:59: - ed:4b:5d:91 + 9a:cf:6b:2b:2e:00:74:2e:70:a1:eb:a2:4e:b3:46:b6:03:ed: + ea:94:51:66:a2:9b:53:f0:a3:2a:8f:62:24:b4:2b:9b:68:3c: + f1:0f:fd:79:23:94:4d:6d:e6:06:2a:dd:88:d0:47:e8:f6:10: + b6:15:29:32:83:73:a8:7e:65:d5:46:36:d6:50:41:dd:0a:c3: + b5:45:92:8b:59:c8:1c:43:4d:77:78:9b:39:23:16:f4:6c:a5: + a7:1d:82:32:38:6f:d2:8d:d2:2c:97:3b:d7:f1:ed:18:0b:6c: + c3:e1:45:d1:39:96:ca:fb:71:7e:71:2e:0c:0e:0b:c2:18:53: + 72:c0:cf:2f:ec:b2:f1:4c:84:ea:9e:b7:18:e5:f0:ac:57:0d: + 64:3f:ff:6c:c2:18:10:5f:0a:30:d9:3a:a2:04:90:c4:96:c4: + c5:75:d1:13:b6:e3:53:6e:38:f0:ba:a3:42:3d:8d:6c:e8:cf: + 84:79:24:60:b9:63:88:e2:f7:59:7b:5d:4a:cb:cd:aa:bd:b3: + 04:7f:1f:2d:d3:60:de:20:c2:9f:89:0d:96:4c:c6:66:08:1e: + 64:c5:0e:17:89:b7:f1:5a:a6:90:74:b0:c7:aa:5e:a7:03:15: + d5:f8:a4:ef:9e:b3:a5:19:f8:0c:82:b6:bc:89:10:cb:5d:8b: + 3d:f8:ec:88 -----BEGIN CERTIFICATE----- -MIIEETCCAvmgAwIBAgIQPiydvrBCyM/8mULVTUFqqjANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTIwMDMxMzIwNDYxN1oXDTIyMDMxMzIwNDYxN1owYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBALSolvo4vNUbcM/kQe1zOqCZQVVyCUizSSMv -61AdHuuYwULGnr8wcBy5sKazu2UyRJbypQRCyZElUXfWNeBXTrfOCtcxMVu5MeZK -csr/0V/bnDII6RYJjOHPs34wiAAuxKktQKead9nFyRS7YdmeMGhGZTpmHaUZuEaM -U6viE0g2h3BWbCH4HOAGpp/WbYi1chTegT36V/JbQZRpYNM5RlQI9+9J/9Q+kvOt -YM11YaWo2NFaqC6nJTArFODl7B9SEY1XoyOtze4ogmefiXBh5cfNO8S6OybO3i2V -Zm+KFmKOtcX6sE0gXFFnNrxE3DYDvNWl5w9Zn5lLAIOesJ8uRG0CAwEAAaOBwzCB -wDAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBRLhVsbTZLc4vvfgiGV1Jo8eoHX7zAf -BgNVHSMEGDAWgBSbJguKmKm7HbkfHOMaQDPtjheIqzAdBgNVHSUEFjAUBggrBgEF -BQcDAQYIKwYBBQUHAwIwUQYDVR0RBEowSIIGYS50ZXN0gggqLmEudGVzdIIGYi50 -ZXN0gggqLmIudGVzdIIGYy50ZXN0gggqLmMudGVzdIIGZC50ZXN0gggqLmQudGVz -dDANBgkqhkiG9w0BAQsFAAOCAQEAM49Ce1Ypet2FmTskISiAi5Krv55M0iPGjVq+ -JYyxzspNuqKl2LTN5TE+bnNAgTC/fo/GRZJ0ndZgT3u1TgbUrV/nZDkvfWjauOa8 -Uv4xOcjQvtQ7J2Sj9MAbY8gSNZdPvg7bugq6jMIyrKhbqjlLHmIwvov0ArcqEvQB -djVqwwAgcqHIqPjCltqvkUeHMR9rt8H4KtntgMD7FgZ6aGl3WfCXNSMwfgjbefED -a8q4JCfNIG8xUpDT9Q6wOhlq1MgPN/9kiOfOsvDBf6Gc8peZFKnbvJOF3lX/ixqm -5M9+8A2y+a2uCTi1v3GmDhaT0AzvLds9Jpd5cX3EnVBZ7UtdkQ== +MIIEEjCCAvqgAwIBAgIRAPMW30UuA/O8F3yZDqTlJVowDQYJKoZIhvcNAQELBQAw +YzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1v +dW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3QgQ0ExFTATBgNVBAMMDFRlc3QgUm9v +dCBDQTAeFw0xOTExMjcyMjM2MjRaFw0yOTExMjQyMjM2MjRaMGAxCzAJBgNVBAYT +AlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3 +MRAwDgYDVQQKDAdUZXN0IENBMRIwEAYDVQQDDAkxMjcuMC4wLjEwggEiMA0GCSqG +SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCr56DO++8VlWy39XXdRKtmLymKfGU8mfUn +v4ByKKnZu05BCLrkskcHn0KjferLmUvsuTr88H+icNbPpx1ZvJ58G4lesVcFx+ro +tsVaBFKPBt+BXlUxDhReet2Vb56/1F8clTeYz+IWQYztOpABrO/dxQRq0xmVG0pH +XUI6Dk11Vo4Zd62c526kDFCyozvdxYyi62ZuRGI8nMVDvymk5BvR88zSaRNFeA71 +GGTxInxi+3/UwVR3hcdhZ1CGRx/52pF3XDrTtKYuhwJLOZOoUDY+CR9skbEBLvrC +emL5PFwl/6upBuLWWxzYqGNrMd6WgEd0XcgAvJplqmeWwzSgm/27AgMBAAGjgcMw +gcAwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUcpOggnU9g4Dn+n80ezDz6Hob1LEw +HwYDVR0jBBgwFoAUmyYLipipux25HxzjGkAz7Y4XiKswHQYDVR0lBBYwFAYIKwYB +BQUHAwEGCCsGAQUFBwMCMFEGA1UdEQRKMEiCBmEudGVzdIIIKi5hLnRlc3SCBmIu +dGVzdIIIKi5iLnRlc3SCBmMudGVzdIIIKi5jLnRlc3SCBmQudGVzdIIIKi5kLnRl +c3QwDQYJKoZIhvcNAQELBQADggEBAJrPaysuAHQucKHrok6zRrYD7eqUUWaim1Pw +oyqPYiS0K5toPPEP/XkjlE1t5gYq3YjQR+j2ELYVKTKDc6h+ZdVGNtZQQd0Kw7VF +kotZyBxDTXd4mzkjFvRspacdgjI4b9KN0iyXO9fx7RgLbMPhRdE5lsr7cX5xLgwO +C8IYU3LAzy/ssvFMhOqetxjl8KxXDWQ//2zCGBBfCjDZOqIEkMSWxMV10RO241Nu +OPC6o0I9jWzoz4R5JGC5Y4ji91l7XUrLzaq9swR/Hy3TYN4gwp+JDZZMxmYIHmTF +DheJt/FappB0sMeqXqcDFdX4pO+es6UZ+AyCtryJEMtdiz347Ig= -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/tls_feature_extension.pem b/net/data/ssl/certificates/tls_feature_extension.pem index 1c4ca74..67841a93 100644 --- a/net/data/ssl/certificates/tls_feature_extension.pem +++ b/net/data/ssl/certificates/tls_feature_extension.pem
@@ -1,21 +1,21 @@ -----BEGIN CERTIFICATE----- -MIIDdDCCAlygAwIBAgIUJwmcYO+T9T2JBKctB7Hr9z8JYQkwDQYJKoZIhvcNAQEL -BQAwYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcM -DU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4w -LjAuMTAeFw0yMDAzMTMyMDQ2MzBaFw0yMTAzMTMyMDQ2MzBaMGAxCzAJBgNVBAYT -AlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3 -MRAwDgYDVQQKDAdUZXN0IENBMRIwEAYDVQQDDAkxMjcuMC4wLjEwggEiMA0GCSqG -SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCnwt5EwSjyWlEhaudw3LB+7RCxSZlWN3Qg -Zzies6ybXadr3ehNEUg4pYK2PBSpH+Sdr5fn0goKZem7SwuT4ps0Q7qp+HKnjIcQ -jpaNSXEf53UGiG50ghNK2n8AUKGquWcZiW8MSJbp741ufmptRcsBd+bQnX+3gJ45 -Kk9HE1XO5SLzvmpKJB04RekoVJU1tMaLYtHtKGRmnZENZ2uMmUz8RGRU5s0onNPH -7mlYpy/o5brHNh4PmMSyduSO+EMb239CSEDDZ3iCWFxJ1VgLPTfrlgcOKLlLBd2Y -hXELRivCh+Jff9JadNXhjNjh6MKMFsdHUlrx5kdF5+5PTc7qRwwpAgMBAAGjJjAk -MA8GA1UdEQQIMAaHBH8AAAEwEQYIKwYBBQUHARgEBTADAgEFMA0GCSqGSIb3DQEB -CwUAA4IBAQBsNox5WKzNjWyEO00++6vFlfUjtomdvl4elEkgIeZOqXr9ZBWFJhKY -154+20R4JwUVYeLPEoHu8WMuejMyWotzmtsppTekmvAIpUwQgaW2TIH43PDI4ONZ -s3AFtSMSQV+y4urRRye6LxlyxcpmxACLaoKpOHQom616UTPfUcO+bT81yW2mccM4 -zTADJGkAG1bZJIPk7FQAFPSyBz5R2WUdKBomx6RSXvx6ck0c3vIF3izIMr2pxZ8X -Xdlxq1b5PXULZPYj2oHxDy8FDDt12OQmBMPCxt2np1NiLU5EHt0zyokivUM+MGX5 -x16Y5fSKJl0C3YTSh5W/oOaIcElP8Cms +MIIDaTCCAlGgAwIBAgIJAIeI+/LexiCJMA0GCSqGSIb3DQEBCwUAMGAxCzAJBgNV +BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBW +aWV3MRAwDgYDVQQKDAdUZXN0IENBMRIwEAYDVQQDDAkxMjcuMC4wLjEwHhcNMTcw +NjA1MTcxMDU0WhcNMTgwNjA1MTcxMDU0WjBgMQswCQYDVQQGEwJVUzETMBEGA1UE +CAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4GA1UECgwH +VGVzdCBDQTESMBAGA1UEAwwJMTI3LjAuMC4xMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEA8bX3pOpg4m3dEhcMVi7zWkxAStqH6FDJB2K5VfACCP13MZV3 +VO6rGcQyBd2NXQUCO+Ui0Jbiw1D2NfOD8bO0sJzlHjLjeHhDG8odpd6MZxApdCNu +Gn8TDtpKGadGCwq7PnlbaYu/Oj3keQfS2ACtY/nLOU8O8+zl8cnVR4gR77fhxJqa +gz3Z/LC8kbMrOQAbDaA6ZAO6uLsnp8ixjrbEjCUJMqSC1L/0VbIZ8wsPKZYAjB0I +fIWuQlWPwZxCzqmjhE3r9sqw1CgukgXdnt/5yxN5MVfN0QcTLYlJQCq2SfkQQNLv +GNoAqiW7rK6C5b1LuAdpuiHpNwvg7loAvbZ+wwIDAQABoyYwJDAPBgNVHREECDAG +hwR/AAABMBEGCCsGAQUFBwEYBAUwAwIBBTANBgkqhkiG9w0BAQsFAAOCAQEA2tLO +/fXAqNgpstCZPTCt+Wu+jYXf8fqpJJNw4TQln9LswxKZZ2oQnF84GskypCBbMZx3 +g5QjF/t/9BBVBdl71uaOxW4FkvWA4YUXonJgtsa6O97jB/56orNG3bAMqraHkZQx +ZoRzbWkEC/y6IYTnlD1kMubISiS7uMQFf3ntvpGl6s8YDIlloeV2RsosTx5bfheY +dkclVi0jtDuctUYdGfBQGiTbt+dorSuQGgmtKNK0zRKYtePS5m6JHHDn5K9TVPjs +wE65POtysB8hydH6Req+i+VSYunmeztb6VNJkDkPRUNcKDXKnMPNwI8u6GBZsSfR +Q8XktPLV77UFTMTBoA== -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/wildcard.pem b/net/data/ssl/certificates/wildcard.pem index ee33b86..34500b2 100644 --- a/net/data/ssl/certificates/wildcard.pem +++ b/net/data/ssl/certificates/wildcard.pem
@@ -1,70 +1,69 @@ -----BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCdXn3erLvkrUMc -iNA7fuk/Y+9sTYdtHY5qStRE6O1CBB4hQWeaeUHxJm1tyP21xgfeplSEaA+nLLDc -76hGv+hb6hA6NtlNbi234h3FxtBqXgyUSqoR4uCydadAh7Q4BHBPALPue4ySPH/0 -iIb2f7UThbJTaGpqnSx2VfMSoPkE53w1itSwTJZGJKiAhD0ieZgY/ubr6OL1zWiR -U5o4Yykcbgzgds012CRoBBBY6HlbddJ+hczElnEFAbrcOgkRnKC7w0wpKvnuc+WL -4IVVAxWGm1FrCD22H/aO2a+s+CDw6NelX39BobIcKP9KDAbdNxhzGMbKKRLckkPj -K12fXTJjAgMBAAECggEALFzV6O8S7M03LRUYdp05TchzVzmn4sfBPQ+pNV/georE -n6Vben2SbFPj514Qv6x6zXZgPw9C0mLT3QSmkINLEpYySubpbV2Q/9R7hiSc3k9z -Bl7iALbPlx95rcRTtrLxoiPVlXY404TAoYPXYCfyOPWopsC5tyJlxVpHcsn0SUAz -ZVqTRxbxYMSRiMaa1uMQZF3zBShDjxfA1VWr2KLc9a/glz1GnRNbWX6lDvg6zMcc -OS0XsuKTfZbxn3Jb9gqOaoTpxN5feeTOeExl/JVn5xQ0OYNkCD8qxK3PD3mnwJj3 -zoL6TV5lqL7JeXcTgVBlhhsx2u4MVWM3hAg0sPz86QKBgQDKYOHkJwaHPKCj8FwZ -6jCydJyy/8g90h7I4o3tUQN5MYBrWb5rSa0TjcfloUOHtrXMPyTzdzikIQQ7mvNr -xuK67s5coMQqQeGPkf60YlD3Y2RYzhDI+b9bREJldthhZu0TtTozauJuv51SYEDF -baHEhyaf5OqzKmMFKlofLV4WFwKBgQDHEKxP1RuKUrFk1XALa9w3VZ5Adgm3Zbtm -iXonlea2DGv8MCj/MIz/hR0+xe0q4omqQ4RdbML2QAiJrv4KvUVtSf5sZbd3KyW8 -ptr7IK4l4/jOcAyJwuMfEcVk79HbeGdCTaOPUMWtpznuunrjURKQ0HVYri3TTyTh -swsECYXBlQKBgD3Obs6N+Jlus6S9sHMdqbemk4C7Sz1OIaa6QhwbJNNrgcvHQbdk -bd5N66G+qXAWJdl142QTohHGH5PQk8zzlaT/b7isRJyfODLvpHkUmaOkEC5q6Ido -dr95zklMjXLZy0e8jkTLvNGT5YkV6lIhVEk/+VTVxbPoGwulzpY89cILAoGAYbbz -fnSTgkC5R0/mIhUeEiN6/RV0C4xqgxi0172jdHWAhFh3p1yDueHzyx6JHuX4wZVG -4j1DLnGcP0mg9lCWReFufHMprduGOKaHE4KlOYBAX8VswiriJhwpEzUNhHgD5+4I -fY8emfFeZKsxK2hefqt1DsThRbqx1gB3RdIO0EkCgYEAgZppkUS5wU+zK0OeAy3d -pjP6Hphwgg8JwPSjfi0M4RD42+8qxrj7UYoKCMRMv4g4JVccqws2PMtt9ncT18QQ -ok2ctwQGFbd7/g3YBgyKbusmQc56UNs3a+dHRQr1TjBAXap1nVdGMDHyE+CbiZXX -KxK+iwca19IXy6RqYHFwLqI= +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDTlB8ztLsVMnd6 +2FAK6t96JVwtDdQGDTNMBU41KlKxJS4l+PPuYREZBoRsAvFRuWa/9icP8LWqy4g4 +4Njnz3cMjKd0uzAU4L11mffPTFB6cem9HFjNvfIjoP1XopzKYRSw3zwxxVme0Vwa +n5OjBi4SORoL6KKGMNo1Jj/npZ6IsyC/zgdPLCGK2gFa8GrKEXfsjpsr0J88N5mT +SqVo3l+zYWQoNpxvAfLu/GoMAGFVrqR5yUthsIS88tfQMVPx5miPZMsjBpkbW0Wd +K6AsjAzoBBHFlEmDUT99yi4t9bimKjkm5b85gu5AO5OcnGt1V5YKoOIJ46/bWzjM +zHKXqnmjAgMBAAECggEAT1Cfwcpmt7OLhsnAd9dEn42R2HHuobYhHMaAYv3SsgW2 +HxYMm7hXqIIA8lzIClLuadflHNynvbc/AdOIfJ4RiurPe7sQc0MswwFNHLEHGl/J +t9MAl2A1fZXEYy3aiSOLliKZdi79QcRKOtDHj72pV7uAQCadhqCZrIMCQdycabHO +c30AI3cPKdC4ProHhP9bh0cGrIE31wBJx/6aiLWV94FgiIkj46ZSRvtGd13c7cIx +soyGbl4ZuLM4K6A5t8cmfyVv5rqS07rCopNFF1Sam7voBTEpDqXoe4WbY0GCMQi7 +96Q6napbgjCZUCN3vYtljmtOL3DhN+P21am+qauPQQKBgQDuGtsvmDYYJo1Ss/CN +d0YrxB4gIAA1B712HTkW5tH5bpRasAwnHaUplaDl4lE6j4uoih7OyTdgekPBuVO/ +bNdKEPg0oZZuUrL7630JrWh3aq31l9669zLbfjgGqb9TV/oZmuxNTazBNTO1FTjs +48jL401diqZhNz+iw4gtMmPwBQKBgQDjeuYiUUUI90PobUpS3y9TF1LotjQ8RWXf +r6qp234zSE8UM/WlHefvzmvMU1G+M8PKyZa4VbzUVI4RBDBNKcUyRJ1HxRnfcZIh +isZEBqpbjPC0YiFxijZS+lbQJUwYllkASF30Rvss/uaSab7xLb4bKTwLmIHn7tP+ +Iu+IIbr7hwKBgCNdbczF6NLxdvAftcztOEjr2iWfWyiFO8i9UmtqYSmRGQvXNhbh +OlTQ2pMKaFIwW+fui+De1hDIWCP/6MZ33gosNxFqJrPAKMFuGqZDUU7bU3c01Woj +qTQcrSmgMMCqQoVnE03wCYaw5jsxKcFVm89ctXL9UvUBhbwhGqrL3zgZAoGBAMQz +5nbG/fJDwxCf4zEjSyAxx9LsBJXPjZSnYV3r8SeuQHa+ciseZkRSGGw9mQ2ifEdW +JGeNm7bPz1Eh+b80Pd+jiryyZiRxQocnuOZHkXwxThNnaE0T1tMvFN2mrcGvO8ig +oljlOBORL7Is/wHqYEPxBtdBjRpMxhA2db9GyI3VAoGAE3QAcl8LZPQJ32TwPLb5 +oCOS9DYz7PgwR6CYfTNINePN0lnt7J6XQyA10nIKYiv7j1LcJjjmEHcYDYqHamuY +cQDoHD4rZwu3/cpqtldKifopP3mYE5E5wcYVklCZfXl2JohaFt9lQxmgcsRTjLxc +RaOLpZHusNcyPfIqHZQjD/Q= -----END PRIVATE KEY----- Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:a5 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 4 (0x4) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity - Not Before: Mar 13 20:46:17 2020 GMT - Not After : Mar 11 20:46:17 2030 GMT + Not Before: Jun 5 17:10:46 2017 GMT + Not After : Jun 3 17:10:46 2027 GMT Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:9d:5e:7d:de:ac:bb:e4:ad:43:1c:88:d0:3b:7e: - e9:3f:63:ef:6c:4d:87:6d:1d:8e:6a:4a:d4:44:e8: - ed:42:04:1e:21:41:67:9a:79:41:f1:26:6d:6d:c8: - fd:b5:c6:07:de:a6:54:84:68:0f:a7:2c:b0:dc:ef: - a8:46:bf:e8:5b:ea:10:3a:36:d9:4d:6e:2d:b7:e2: - 1d:c5:c6:d0:6a:5e:0c:94:4a:aa:11:e2:e0:b2:75: - a7:40:87:b4:38:04:70:4f:00:b3:ee:7b:8c:92:3c: - 7f:f4:88:86:f6:7f:b5:13:85:b2:53:68:6a:6a:9d: - 2c:76:55:f3:12:a0:f9:04:e7:7c:35:8a:d4:b0:4c: - 96:46:24:a8:80:84:3d:22:79:98:18:fe:e6:eb:e8: - e2:f5:cd:68:91:53:9a:38:63:29:1c:6e:0c:e0:76: - cd:35:d8:24:68:04:10:58:e8:79:5b:75:d2:7e:85: - cc:c4:96:71:05:01:ba:dc:3a:09:11:9c:a0:bb:c3: - 4c:29:2a:f9:ee:73:e5:8b:e0:85:55:03:15:86:9b: - 51:6b:08:3d:b6:1f:f6:8e:d9:af:ac:f8:20:f0:e8: - d7:a5:5f:7f:41:a1:b2:1c:28:ff:4a:0c:06:dd:37: - 18:73:18:c6:ca:29:12:dc:92:43:e3:2b:5d:9f:5d: - 32:63 + 00:d3:94:1f:33:b4:bb:15:32:77:7a:d8:50:0a:ea: + df:7a:25:5c:2d:0d:d4:06:0d:33:4c:05:4e:35:2a: + 52:b1:25:2e:25:f8:f3:ee:61:11:19:06:84:6c:02: + f1:51:b9:66:bf:f6:27:0f:f0:b5:aa:cb:88:38:e0: + d8:e7:cf:77:0c:8c:a7:74:bb:30:14:e0:bd:75:99: + f7:cf:4c:50:7a:71:e9:bd:1c:58:cd:bd:f2:23:a0: + fd:57:a2:9c:ca:61:14:b0:df:3c:31:c5:59:9e:d1: + 5c:1a:9f:93:a3:06:2e:12:39:1a:0b:e8:a2:86:30: + da:35:26:3f:e7:a5:9e:88:b3:20:bf:ce:07:4f:2c: + 21:8a:da:01:5a:f0:6a:ca:11:77:ec:8e:9b:2b:d0: + 9f:3c:37:99:93:4a:a5:68:de:5f:b3:61:64:28:36: + 9c:6f:01:f2:ee:fc:6a:0c:00:61:55:ae:a4:79:c9: + 4b:61:b0:84:bc:f2:d7:d0:31:53:f1:e6:68:8f:64: + cb:23:06:99:1b:5b:45:9d:2b:a0:2c:8c:0c:e8:04: + 11:c5:94:49:83:51:3f:7d:ca:2e:2d:f5:b8:a6:2a: + 39:26:e5:bf:39:82:ee:40:3b:93:9c:9c:6b:75:57: + 96:0a:a0:e2:09:e3:af:db:5b:38:cc:cc:72:97:aa: + 79:a3 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 83:F7:3F:C1:5B:0E:56:28:9B:CF:2C:01:99:48:94:D3:A2:2D:C4:2A + 18:0C:EB:51:B9:D3:36:A9:C9:04:AF:F9:2F:14:F0:99:66:D2:76:D4 X509v3 Authority Key Identifier: keyid:9B:26:0B:8A:98:A9:BB:1D:B9:1F:1C:E3:1A:40:33:ED:8E:17:88:AB @@ -73,41 +72,41 @@ X509v3 Subject Alternative Name: DNS:*.example.org Signature Algorithm: sha256WithRSAEncryption - bd:bf:81:f6:36:d4:6f:66:db:0f:82:e4:de:46:bd:d5:bb:f9: - c1:34:22:f8:05:69:50:2d:0a:53:0e:0a:16:b4:66:8b:e8:82: - 78:cd:05:9f:7d:5b:60:33:67:8b:64:38:0b:cc:99:50:f3:e9: - 60:14:99:88:54:10:53:9b:0a:5f:1a:6b:b8:f2:00:17:21:fa: - 8a:0c:7b:d9:c3:77:1e:39:03:8c:2b:c2:f7:eb:3e:ec:59:12: - 79:51:69:43:a4:b2:df:8b:73:91:66:66:df:9f:f7:6f:dd:16: - 5b:23:e0:6f:ed:27:64:d8:19:1e:6e:8b:5b:c3:bc:d9:13:c6: - 20:79:42:8a:81:0f:89:d8:86:90:13:12:37:64:18:d3:c5:8f: - 64:31:bc:ef:fb:41:81:0b:43:3c:44:a6:8c:89:f6:7f:b4:3e: - 02:bb:a4:55:73:b7:a4:ee:c3:b9:b6:02:a7:4d:77:70:6a:b5: - 17:79:cd:12:28:90:e8:1a:da:44:f5:3b:cc:f7:43:1b:83:6b: - 3c:c2:b0:9f:9b:0d:fc:23:f5:fd:13:02:4c:de:23:95:76:0a: - 6b:0f:56:2a:06:16:7b:5e:a8:46:e2:8c:64:ec:a8:34:13:3c: - 73:5d:45:65:df:1e:8a:60:f4:37:9f:71:16:be:75:3e:18:0e: - 1e:53:d1:9e + bd:72:b4:50:5d:7d:8b:b2:64:49:27:68:99:0c:01:d7:c5:91: + 15:a2:86:f1:56:69:48:5b:0a:6c:41:02:3d:11:e8:c6:4b:4c: + 97:f3:dd:d3:8c:24:f9:6d:1f:64:5a:b8:df:78:f7:e0:3f:9c: + 8d:30:7a:3b:10:15:74:f2:0f:49:ec:7c:53:8d:1f:60:c9:7d: + 0b:5d:ca:d6:d7:a3:7f:8a:3f:fa:b7:0b:c4:40:dd:55:fb:fb: + 3d:49:28:82:b9:62:5f:34:84:30:26:1d:71:3c:2b:b9:5e:e1: + 8c:2d:bf:21:bd:2d:fe:47:71:6e:54:6d:e1:d0:f6:23:58:dd: + 9e:db:05:cb:f5:5f:11:3f:e6:d0:9d:aa:46:12:56:95:f6:04: + cc:21:5e:1e:7f:07:fc:f6:48:88:8b:2c:a3:9a:66:d9:1a:1d: + 4e:a8:bd:c3:8f:fe:d6:bf:18:c9:f9:a4:f1:31:7e:12:85:83: + 62:d6:d9:f9:27:20:b4:21:f9:7e:57:52:fa:89:c8:84:78:23: + cf:fb:67:8a:a8:db:63:43:11:16:bf:59:c6:ba:21:9a:d8:0e: + 04:eb:d1:38:42:87:d3:a7:3d:da:83:a6:8f:66:a1:c8:5a:4c: + ff:25:3d:3c:bf:c9:bc:d9:85:49:a3:16:d5:e3:b3:8c:77:a6: + 21:62:93:33 -----BEGIN CERTIFICATE----- -MIID2DCCAsCgAwIBAgIQPiydvrBCyM/8mULVTUFqpTANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTIwMDMxMzIwNDYxN1oXDTMwMDMxMTIwNDYxN1owYDELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAJ1efd6su+StQxyI0Dt+6T9j72xNh20djmpK -1ETo7UIEHiFBZ5p5QfEmbW3I/bXGB96mVIRoD6cssNzvqEa/6FvqEDo22U1uLbfi -HcXG0GpeDJRKqhHi4LJ1p0CHtDgEcE8As+57jJI8f/SIhvZ/tROFslNoamqdLHZV -8xKg+QTnfDWK1LBMlkYkqICEPSJ5mBj+5uvo4vXNaJFTmjhjKRxuDOB2zTXYJGgE -EFjoeVt10n6FzMSWcQUButw6CRGcoLvDTCkq+e5z5YvghVUDFYabUWsIPbYf9o7Z -r6z4IPDo16Vff0Ghshwo/0oMBt03GHMYxsopEtySQ+MrXZ9dMmMCAwEAAaOBijCB -hzAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBSD9z/BWw5WKJvPLAGZSJTToi3EKjAf -BgNVHSMEGDAWgBSbJguKmKm7HbkfHOMaQDPtjheIqzAdBgNVHSUEFjAUBggrBgEF -BQcDAQYIKwYBBQUHAwIwGAYDVR0RBBEwD4INKi5leGFtcGxlLm9yZzANBgkqhkiG -9w0BAQsFAAOCAQEAvb+B9jbUb2bbD4Lk3ka91bv5wTQi+AVpUC0KUw4KFrRmi+iC -eM0Fn31bYDNni2Q4C8yZUPPpYBSZiFQQU5sKXxpruPIAFyH6igx72cN3HjkDjCvC -9+s+7FkSeVFpQ6Sy34tzkWZm35/3b90WWyPgb+0nZNgZHm6LW8O82RPGIHlCioEP -idiGkBMSN2QY08WPZDG87/tBgQtDPESmjIn2f7Q+ArukVXO3pO7DubYCp013cGq1 -F3nNEiiQ6BraRPU7zPdDG4NrPMKwn5sN/CP1/RMCTN4jlXYKaw9WKgYWe16oRuKM -ZOyoNBM8c11FZd8eimD0N59xFr51PhgOHlPRng== +MIIDyTCCArGgAwIBAgIBBDANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE3MDYwNTE3 +MTA0NloXDTI3MDYwMzE3MTA0NlowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBANOUHzO0uxUyd3rYUArq33olXC0N1AYNM0wFTjUqUrElLiX48+5hERkG +hGwC8VG5Zr/2Jw/wtarLiDjg2OfPdwyMp3S7MBTgvXWZ989MUHpx6b0cWM298iOg +/VeinMphFLDfPDHFWZ7RXBqfk6MGLhI5GgvoooYw2jUmP+elnoizIL/OB08sIYra +AVrwasoRd+yOmyvQnzw3mZNKpWjeX7NhZCg2nG8B8u78agwAYVWupHnJS2GwhLzy +19AxU/HmaI9kyyMGmRtbRZ0roCyMDOgEEcWUSYNRP33KLi31uKYqOSblvzmC7kA7 +k5yca3VXlgqg4gnjr9tbOMzMcpeqeaMCAwEAAaOBijCBhzAMBgNVHRMBAf8EAjAA +MB0GA1UdDgQWBBQYDOtRudM2qckEr/kvFPCZZtJ21DAfBgNVHSMEGDAWgBSbJguK +mKm7HbkfHOMaQDPtjheIqzAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIw +GAYDVR0RBBEwD4INKi5leGFtcGxlLm9yZzANBgkqhkiG9w0BAQsFAAOCAQEAvXK0 +UF19i7JkSSdomQwB18WRFaKG8VZpSFsKbEECPRHoxktMl/Pd04wk+W0fZFq433j3 +4D+cjTB6OxAVdPIPSex8U40fYMl9C13K1tejf4o/+rcLxEDdVfv7PUkogrliXzSE +MCYdcTwruV7hjC2/Ib0t/kdxblRt4dD2I1jdntsFy/VfET/m0J2qRhJWlfYEzCFe +Hn8H/PZIiIsso5pm2RodTqi9w4/+1r8Yyfmk8TF+EoWDYtbZ+ScgtCH5fldS+onI +hHgjz/tniqjbY0MRFr9ZxrohmtgOBOvROEKH06c92oOmj2ahyFpM/yU9PL/JvNmF +SaMW1eOzjHemIWKTMw== -----END CERTIFICATE-----
diff --git a/net/data/ssl/certificates/x509_verify_results.chain.pem b/net/data/ssl/certificates/x509_verify_results.chain.pem index 16f3314..84acc63 100644 --- a/net/data/ssl/certificates/x509_verify_results.chain.pem +++ b/net/data/ssl/certificates/x509_verify_results.chain.pem
@@ -1,42 +1,41 @@ Certificate: Data: Version: 3 (0x2) - Serial Number: - db:15:0b:57:64:f6:dc:4a:c0:6e:e7:ea:5d:c9:c5:cd - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 1 (0x1) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Intermediate CA Validity - Not Before: Mar 13 20:46:17 2020 GMT - Not After : Mar 13 20:46:17 2022 GMT + Not Before: Jun 5 17:10:46 2017 GMT + Not After : Jun 3 17:10:46 2027 GMT Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1 Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: - 00:a6:58:dc:36:25:d1:a6:a4:93:08:cf:2d:3b:86: - 07:b5:ce:44:c7:5b:7f:d7:11:a6:51:98:ec:82:4c: - 6c:31:45:a3:04:56:6f:c1:77:d6:6c:38:db:3c:d8: - 2d:d2:25:aa:47:4f:f4:a4:f3:8e:09:98:37:d3:0f: - 71:f6:ac:29:47:7b:08:8e:68:ab:fc:7e:10:02:65: - b6:86:4c:b0:27:04:6a:15:23:b3:3a:19:b8:15:f3: - 3b:0b:1d:ad:d8:9f:49:b1:72:f2:af:08:df:c8:02: - aa:cb:f3:2a:2d:c0:fd:28:b0:97:da:4a:a9:22:74: - c2:3a:0b:64:65:2a:c9:f4:65:f7:46:7f:3c:a9:61: - 96:5f:0c:2a:66:c3:f2:c7:fe:69:87:2f:70:0c:1b: - 66:37:92:c5:3f:85:40:d8:e4:26:45:18:3f:ce:53: - 27:a0:97:7e:11:87:dc:4a:ec:26:eb:ff:95:0e:b3: - ea:2e:66:45:0a:aa:cc:c5:81:59:2e:0a:1b:0e:1b: - 59:71:ca:d3:90:ef:6f:ca:b7:8c:a8:ca:82:55:b8: - fb:4a:e5:ba:29:78:ce:eb:cd:8e:4f:9c:af:85:a4: - ef:0b:64:5e:3e:7e:a0:e0:e5:b0:86:f3:19:08:fa: - 3f:fa:1e:4a:9b:fc:b5:16:17:88:0d:38:0e:c3:a6: - 5f:d5 + 00:b4:bf:d2:97:33:e5:13:5b:77:65:bd:73:1a:75: + 28:9b:47:59:e6:b7:30:e8:46:33:6d:58:5b:da:1f: + 0a:ff:e4:e4:2d:f2:1d:f8:89:e8:64:2e:f6:c3:cd: + d7:a3:8e:d7:f7:cd:e7:d8:0e:10:c3:e7:56:d2:fc: + e5:e6:d3:4e:e2:ff:82:4d:18:63:87:b0:a3:de:da: + ef:0a:37:7b:ac:b5:b7:43:ce:f2:07:39:df:14:e9: + c3:a4:41:3e:7e:68:47:34:9b:7b:61:c4:18:e6:13: + ce:b3:b4:a6:e0:ba:03:ee:e4:eb:e7:aa:f4:6d:be: + 97:5b:aa:06:97:50:01:d0:78:b8:d6:92:b0:e4:e2: + b9:43:88:b5:ae:14:64:7d:52:70:d4:05:1c:09:25: + d5:e2:4f:c9:a8:82:db:41:31:c3:be:44:6f:0b:d4: + fd:bf:c1:ee:d9:62:bf:3b:8f:b5:00:c8:d1:df:5d: + 4a:13:ad:71:e4:4b:5f:d1:d9:72:4c:83:d8:93:40: + bf:6c:cd:2f:66:0e:04:d6:b9:43:28:24:c9:25:fd: + 59:70:fe:3d:f2:a9:0a:4e:c2:9b:c4:de:9e:57:5e: + 5d:16:25:e6:78:b6:44:49:29:9d:f6:bf:74:fb:85: + d6:0d:f1:65:58:f2:2b:d6:8f:10:49:c8:00:2d:88: + e2:2d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Subject Key Identifier: - 81:CD:A7:DD:52:43:7F:DF:7A:4B:BA:F5:B0:B6:10:A0:44:0C:EC:6C + E0:DC:E0:2F:07:88:74:3A:9F:D3:30:A3:71:8A:F9:D6:A5:E5:A6:53 X509v3 Authority Key Identifier: keyid:17:5C:45:F3:D0:AC:1C:10:4C:8B:43:44:20:C4:DD:93:C5:C5:19:3B @@ -45,58 +44,57 @@ X509v3 Subject Alternative Name: IP Address:127.0.0.1 Signature Algorithm: sha256WithRSAEncryption - 80:2c:94:86:a4:69:32:38:0e:41:73:db:0a:42:e9:1c:05:81: - fa:80:cc:c2:c3:2b:3d:7e:46:b1:19:32:ff:97:fe:fc:be:c2: - 32:7c:e2:db:fe:27:0a:75:26:6a:b8:6f:9f:0f:37:0c:bc:02: - 2d:6c:04:63:4a:45:50:75:b7:3e:90:49:85:50:3d:85:52:57: - 1d:2e:d5:b9:75:c1:84:56:9a:cb:92:e8:9b:28:38:bd:20:c5: - 6d:8c:53:70:37:9a:f5:64:5e:d5:11:e4:28:6b:08:9c:8b:0f: - 2a:f7:a1:59:00:15:58:6b:11:91:11:27:c3:6e:e2:54:52:f7: - fe:e6:3d:27:d5:0f:b6:91:ab:39:12:9d:c5:dc:f3:02:e4:87: - 48:c7:e8:93:c0:85:69:5c:97:8b:d8:5f:bf:d4:a1:f2:c4:5a: - 69:88:b0:3c:75:86:30:09:b4:84:0a:17:56:2c:6f:d4:c6:10: - f9:23:1c:5e:77:8c:29:5c:db:41:36:33:c7:3a:00:85:f9:a0: - f5:e3:71:9a:55:b7:0b:45:45:30:07:a7:78:6f:b2:2b:4e:e5: - 84:2f:bc:49:d7:80:07:ed:d1:44:c8:c3:5a:ec:3c:65:05:a0: - 78:e3:a3:8b:1c:b2:2e:b0:64:f5:9e:7b:08:8d:bd:4a:07:4f: - 29:50:74:e8 + 43:f7:63:38:a3:30:3f:ab:e6:6c:42:a1:dd:ff:8d:f6:ad:b2: + eb:b6:9e:4b:bd:90:fc:d8:f4:f0:5a:42:fc:be:5b:cc:c7:24: + 2f:91:48:a6:a1:bb:a2:b7:19:61:21:ac:d3:81:ee:6e:bb:04: + 2d:16:b5:7e:cb:e6:a3:17:8f:3e:65:4d:1d:8d:c1:da:3d:3b: + ad:a1:b3:e8:f5:e3:16:13:17:0a:a3:45:e0:cf:84:b2:3d:e8: + 38:69:31:46:e8:8c:10:63:0f:5e:6b:f4:10:25:23:98:b8:5c: + d9:06:78:83:18:70:09:a6:ef:8f:e9:f5:ff:b3:44:85:35:f6: + 69:61:0b:2a:8d:de:87:1c:ec:dc:50:c7:67:ef:88:2c:28:de: + c0:db:6e:21:20:00:c5:5b:5d:ef:36:c6:0a:e9:06:a3:25:3e: + 4d:13:fa:f0:3f:bc:fe:9c:68:48:ff:ec:1b:e7:2c:39:ac:88: + 2b:a0:88:96:11:3e:f0:20:e2:29:fc:bd:d3:d3:ca:24:63:58: + 17:15:c3:ac:19:21:cb:21:29:fc:53:e7:3b:cf:c2:0a:5e:f4: + ce:f1:9e:77:38:d4:c6:90:4e:94:fe:2e:97:cb:1a:94:2a:1e: + 8c:3b:db:36:65:c6:19:ba:d7:0b:03:22:e5:92:e2:f6:3e:df: + 99:ce:6b:49 -----BEGIN CERTIFICATE----- -MIID1zCCAr+gAwIBAgIRANsVC1dk9txKwG7n6l3Jxc0wDQYJKoZIhvcNAQELBQAw -azELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1v -dW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3QgQ0ExHTAbBgNVBAMMFFRlc3QgSW50 -ZXJtZWRpYXRlIENBMB4XDTIwMDMxMzIwNDYxN1oXDTIyMDMxMzIwNDYxN1owYDEL -MAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50 -YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3QgQ0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCC -ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKZY3DYl0aakkwjPLTuGB7XO -RMdbf9cRplGY7IJMbDFFowRWb8F31mw42zzYLdIlqkdP9KTzjgmYN9MPcfasKUd7 -CI5oq/x+EAJltoZMsCcEahUjszoZuBXzOwsdrdifSbFy8q8I38gCqsvzKi3A/Siw -l9pKqSJ0wjoLZGUqyfRl90Z/PKlhll8MKmbD8sf+aYcvcAwbZjeSxT+FQNjkJkUY -P85TJ6CXfhGH3ErsJuv/lQ6z6i5mRQqqzMWBWS4KGw4bWXHK05Dvb8q3jKjKglW4 -+0rluil4zuvNjk+cr4Wk7wtkXj5+oODlsIbzGQj6P/oeSpv8tRYXiA04DsOmX9UC -AwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFIHNp91SQ3/feku69bC2 -EKBEDOxsMB8GA1UdIwQYMBaAFBdcRfPQrBwQTItDRCDE3ZPFxRk7MB0GA1UdJQQW -MBQGCCsGAQUFBwMBBggrBgEFBQcDAjAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3 -DQEBCwUAA4IBAQCALJSGpGkyOA5Bc9sKQukcBYH6gMzCwys9fkaxGTL/l/78vsIy -fOLb/icKdSZquG+fDzcMvAItbARjSkVQdbc+kEmFUD2FUlcdLtW5dcGEVprLkuib -KDi9IMVtjFNwN5r1ZF7VEeQoawiciw8q96FZABVYaxGRESfDbuJUUvf+5j0n1Q+2 -kas5Ep3F3PMC5IdIx+iTwIVpXJeL2F+/1KHyxFppiLA8dYYwCbSEChdWLG/UxhD5 -Ixxed4wpXNtBNjPHOgCF+aD143GaVbcLRUUwB6d4b7IrTuWEL7xJ14AH7dFEyMNa -7DxlBaB446OLHLIusGT1nnsIjb1KB08pUHTo +MIIDxzCCAq+gAwIBAgIBATANBgkqhkiG9w0BAQsFADBrMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEdMBsGA1UEAwwUVGVzdCBJbnRlcm1lZGlhdGUgQ0EwHhcN +MTcwNjA1MTcxMDQ2WhcNMjcwNjAzMTcxMDQ2WjBgMQswCQYDVQQGEwJVUzETMBEG +A1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4GA1UE +CgwHVGVzdCBDQTESMBAGA1UEAwwJMTI3LjAuMC4xMIIBIjANBgkqhkiG9w0BAQEF +AAOCAQ8AMIIBCgKCAQEAtL/SlzPlE1t3Zb1zGnUom0dZ5rcw6EYzbVhb2h8K/+Tk +LfId+InoZC72w83Xo47X983n2A4Qw+dW0vzl5tNO4v+CTRhjh7Cj3trvCjd7rLW3 +Q87yBznfFOnDpEE+fmhHNJt7YcQY5hPOs7Sm4LoD7uTr56r0bb6XW6oGl1AB0Hi4 +1pKw5OK5Q4i1rhRkfVJw1AUcCSXV4k/JqILbQTHDvkRvC9T9v8Hu2WK/O4+1AMjR +311KE61x5Etf0dlyTIPYk0C/bM0vZg4E1rlDKCTJJf1ZcP498qkKTsKbxN6eV15d +FiXmeLZESSmd9r90+4XWDfFlWPIr1o8QScgALYjiLQIDAQABo4GAMH4wDAYDVR0T +AQH/BAIwADAdBgNVHQ4EFgQU4NzgLweIdDqf0zCjcYr51qXlplMwHwYDVR0jBBgw +FoAUF1xF89CsHBBMi0NEIMTdk8XFGTswHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsG +AQUFBwMCMA8GA1UdEQQIMAaHBH8AAAEwDQYJKoZIhvcNAQELBQADggEBAEP3Yzij +MD+r5mxCod3/jfatsuu2nku9kPzY9PBaQvy+W8zHJC+RSKahu6K3GWEhrNOB7m67 +BC0WtX7L5qMXjz5lTR2Nwdo9O62hs+j14xYTFwqjReDPhLI96DhpMUbojBBjD15r +9BAlI5i4XNkGeIMYcAmm74/p9f+zRIU19mlhCyqN3occ7NxQx2fviCwo3sDbbiEg +AMVbXe82xgrpBqMlPk0T+vA/vP6caEj/7BvnLDmsiCugiJYRPvAg4in8vdPTyiRj +WBcVw6wZIcshKfxT5zvPwgpe9M7xnnc41MaQTpT+LpfLGpQqHow72zZlxhm61wsD +IuWS4vY+35nOa0k= -----END CERTIFICATE----- Certificate: Data: Version: 3 (0x2) - Serial Number: - 3e:2c:9d:be:b0:42:c8:cf:fc:99:42:d5:4d:41:6a:a2 - Signature Algorithm: sha256WithRSAEncryption + Serial Number: 1 (0x1) + Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity - Not Before: Mar 13 20:46:16 2020 GMT - Not After : Mar 11 20:46:16 2030 GMT + Not Before: Jun 5 17:10:45 2017 GMT + Not After : Jun 3 17:10:45 2027 GMT Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Intermediate CA Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: 00:9d:e9:bd:e4:3d:4a:2f:fb:c2:f9:e6:22:2a:42: 15:46:1c:8c:8f:47:4c:e9:c5:57:95:1f:66:70:93: @@ -125,57 +123,55 @@ X509v3 Key Usage: critical Certificate Sign, CRL Sign Signature Algorithm: sha256WithRSAEncryption - 00:25:9c:ba:83:ee:0f:a2:57:cc:9a:d4:50:15:d5:e0:e7:4a: - 8a:57:d1:3e:b1:de:a5:be:26:f0:22:98:35:c0:ee:f1:84:4f: - aa:8d:92:e5:5c:29:23:ad:68:fb:9a:68:d0:2c:6e:04:5e:25: - fb:a0:65:04:fc:82:0b:ec:5b:53:a9:f4:61:1e:15:0f:5e:93: - 94:ec:d3:31:82:06:a1:16:09:01:b9:cb:90:a9:f9:ac:e3:d3: - 15:4c:2c:75:1c:97:24:d3:33:33:e1:b3:53:28:4e:e3:8e:6f: - 59:06:83:20:06:bd:9b:e9:44:8a:bd:80:59:6d:c2:cd:ce:c5: - 9c:81:31:3c:72:f5:6c:bf:31:69:a9:7c:32:28:cb:0e:d3:fd: - 23:5b:30:e0:c1:e9:c8:f8:6e:21:d1:86:c6:ca:62:a6:d6:19: - e4:0b:25:88:95:74:ce:b3:c6:4c:3c:32:63:d6:6a:8b:a3:49: - 53:15:85:9d:1a:06:16:e5:62:35:f5:d2:8c:99:91:15:35:9e: - 9d:36:98:75:4d:f9:39:de:2e:74:8f:36:2b:3a:b4:51:74:26: - 7c:22:6b:c3:52:3e:03:9f:cc:31:e9:24:68:6b:49:63:b5:24: - 6f:08:79:ed:4a:c1:6b:b5:da:72:1f:d5:a4:7e:6c:9b:4d:d2: - 4d:5d:c1:2b + 3e:f5:d7:fd:82:3b:1e:34:8c:66:a2:f3:5e:18:e1:f1:a9:75: + 9f:b5:93:e7:0a:8e:cf:0a:33:ed:49:cd:ce:ce:ca:5f:a3:1d: + 64:76:d3:84:16:fe:9d:88:ac:f4:d1:f8:36:2b:20:80:52:0a: + ef:e0:0f:64:27:55:35:a3:7b:c6:8a:7c:a5:c4:29:17:b1:fa: + d2:89:5d:13:6b:b8:03:cb:d7:12:d6:ce:24:f0:af:48:17:03: + 54:99:af:e9:cb:fd:44:44:18:23:61:90:f6:bd:55:65:06:c3: + 36:98:8d:ea:7d:0f:79:ef:b6:bb:22:28:03:a6:ec:d9:d4:1b: + 47:ac:2c:25:de:ef:1a:02:69:4c:18:bb:29:48:f4:9d:e1:52: + 42:64:6c:88:46:68:86:83:fd:24:f5:7d:05:d7:1a:7e:22:bc: + 49:75:9c:8a:4d:e8:f3:a2:eb:9b:83:70:a7:d6:dd:2f:05:2d: + aa:be:d7:ee:7b:8e:75:44:3b:da:df:85:61:bf:e9:3b:13:40: + 4e:8b:52:08:d9:e4:8c:54:da:41:db:7b:2c:05:5e:99:06:0d: + 02:8c:8e:19:8e:55:b0:3a:33:18:30:03:a7:ed:4a:e4:f8:58: + cc:12:b8:af:d6:66:55:29:ec:01:1f:92:ed:3d:4d:c3:71:3b: + e0:2f:70:90 -----BEGIN CERTIFICATE----- -MIIDmjCCAoKgAwIBAgIQPiydvrBCyM/8mULVTUFqojANBgkqhkiG9w0BAQsFADBj -MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91 -bnRhaW4gVmlldzEQMA4GA1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290 -IENBMB4XDTIwMDMxMzIwNDYxNloXDTMwMDMxMTIwNDYxNlowazELMAkGA1UEBhMC -VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx -EDAOBgNVBAoMB1Rlc3QgQ0ExHTAbBgNVBAMMFFRlc3QgSW50ZXJtZWRpYXRlIENB -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnem95D1KL/vC+eYiKkIV -RhyMj0dM6cVXlR9mcJMi8JTDu7Vb76RvyMeJlXW6DDa/TmupNUcIQ54pauLD+wO3 -H7bhUWvtexnH+c473GXpZseDlMTRTu7tZEuB8RrqWmQYG2pOk9ATbJBgytJOtyQW -+LIIWJ2NpzNFFTSBrS0tnGDv+SuY/nnTjSxI2xKR9C76v/UmwYIFgN1MqHC/p7wQ -NHc520cED+1EsmVGIiCIWSgPxwyitJGloqrKBZ+Km26jy9Sk6CR1nSCBIltfdz7J -8R6u64ozjCdbHr5tIRtCcpXjnhMDdadY1L5oEv5jjksRejTno2vdc64+GZrskYtz -rwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQXXEXz0KwcEEyL -Q0QgxN2TxcUZOzAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggEBAAAl -nLqD7g+iV8ya1FAV1eDnSopX0T6x3qW+JvAimDXA7vGET6qNkuVcKSOtaPuaaNAs -bgReJfugZQT8ggvsW1Op9GEeFQ9ek5Ts0zGCBqEWCQG5y5Cp+azj0xVMLHUclyTT -MzPhs1MoTuOOb1kGgyAGvZvpRIq9gFltws3OxZyBMTxy9Wy/MWmpfDIoyw7T/SNb -MODB6cj4biHRhsbKYqbWGeQLJYiVdM6zxkw8MmPWaoujSVMVhZ0aBhblYjX10oyZ -kRU1np02mHVN+TneLnSPNis6tFF0Jnwia8NSPgOfzDHpJGhrSWO1JG8Iee1KwWu1 -2nIf1aR+bJtN0k1dwSs= +MIIDizCCAnOgAwIBAgIBATANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET +MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G +A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE3MDYwNTE3 +MTA0NVoXDTI3MDYwMzE3MTA0NVowazELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh +bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg +Q0ExHTAbBgNVBAMMFFRlc3QgSW50ZXJtZWRpYXRlIENBMIIBIjANBgkqhkiG9w0B +AQEFAAOCAQ8AMIIBCgKCAQEAnem95D1KL/vC+eYiKkIVRhyMj0dM6cVXlR9mcJMi +8JTDu7Vb76RvyMeJlXW6DDa/TmupNUcIQ54pauLD+wO3H7bhUWvtexnH+c473GXp +ZseDlMTRTu7tZEuB8RrqWmQYG2pOk9ATbJBgytJOtyQW+LIIWJ2NpzNFFTSBrS0t +nGDv+SuY/nnTjSxI2xKR9C76v/UmwYIFgN1MqHC/p7wQNHc520cED+1EsmVGIiCI +WSgPxwyitJGloqrKBZ+Km26jy9Sk6CR1nSCBIltfdz7J8R6u64ozjCdbHr5tIRtC +cpXjnhMDdadY1L5oEv5jjksRejTno2vdc64+GZrskYtzrwIDAQABo0IwQDAPBgNV +HRMBAf8EBTADAQH/MB0GA1UdDgQWBBQXXEXz0KwcEEyLQ0QgxN2TxcUZOzAOBgNV +HQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggEBAD711/2COx40jGai814Y4fGp +dZ+1k+cKjs8KM+1Jzc7Oyl+jHWR204QW/p2IrPTR+DYrIIBSCu/gD2QnVTWje8aK +fKXEKRex+tKJXRNruAPL1xLWziTwr0gXA1SZr+nL/UREGCNhkPa9VWUGwzaYjep9 +D3nvtrsiKAOm7NnUG0esLCXe7xoCaUwYuylI9J3hUkJkbIhGaIaD/ST1fQXXGn4i +vEl1nIpN6POi65uDcKfW3S8FLaq+1+57jnVEO9rfhWG/6TsTQE6LUgjZ5IxU2kHb +eywFXpkGDQKMjhmOVbA6MxgwA6ftSuT4WMwSuK/WZlUp7AEfku09TcNxO+AvcJA= -----END CERTIFICATE----- Certificate: Data: Version: 3 (0x2) - Serial Number: - 2f:25:f3:ce:3c:5e:72:d0:33:29:f6:09:1f:5d:5f:53:d9:ac:23:bb - Signature Algorithm: sha256WithRSAEncryption - Issuer: C = US, ST = California, L = Mountain View, O = Test CA, CN = Test Root CA + Serial Number: 10687961985666567129 (0x945344cc7888cbd9) + Signature Algorithm: sha256WithRSAEncryption + Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Validity - Not Before: Mar 13 20:46:16 2020 GMT - Not After : Mar 11 20:46:16 2030 GMT - Subject: C = US, ST = California, L = Mountain View, O = Test CA, CN = Test Root CA + Not Before: Jun 5 17:10:44 2017 GMT + Not After : Jun 3 17:10:44 2027 GMT + Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) + Public-Key: (2048 bit) Modulus: 00:c6:81:1f:92:73:b6:58:85:d9:8d:ac:b7:20:fd: c7:bf:40:b2:ea:fa:e5:0b:52:01:8f:9a:c1:eb:7a: @@ -204,40 +200,39 @@ X509v3 Key Usage: critical Certificate Sign, CRL Sign Signature Algorithm: sha256WithRSAEncryption - b1:b1:83:61:af:db:ed:98:cf:3d:43:5f:a7:42:b8:6d:94:36: - 57:bb:ab:04:ee:dd:3b:b7:6d:ec:78:7d:46:59:b1:e6:2a:c3: - aa:a5:70:a7:e1:0c:fa:65:37:c6:cb:7d:a1:37:35:a1:ff:f0: - dd:ce:b6:a4:2c:12:d4:46:a9:9c:a2:91:3a:b0:95:55:97:55: - e6:0a:da:63:60:24:19:ac:20:c9:b1:94:40:e9:99:b1:f5:c3: - ed:61:5d:de:4c:e4:eb:d9:0e:ac:3a:0a:fc:44:7d:0f:77:a6: - b6:da:28:d4:ed:ea:3a:bc:57:23:9c:72:2b:2d:b0:5d:11:02: - 4d:c5:bc:b0:d6:7e:00:8e:f7:e7:f5:19:3a:23:df:33:02:aa: - 4b:bf:81:f4:5a:99:ee:74:20:f3:77:a1:f0:85:1e:a8:d6:cc: - a4:cb:31:fa:73:24:a2:0e:dd:9f:6f:82:38:5f:85:ac:8d:76: - bd:d8:f2:69:73:e3:46:44:42:e3:5e:f3:aa:5e:44:13:51:ea: - 0b:78:91:77:96:ee:73:fe:2a:b5:88:c1:38:8d:8d:a8:19:76: - 94:05:02:cf:d4:6f:eb:e6:07:f5:9d:52:24:b8:50:a3:0e:c4: - 45:a6:09:b4:06:2d:3e:14:a5:3f:1c:1a:bc:da:b8:40:3e:c1: - 1c:f6:3c:05 + 5b:53:ff:6d:d5:0a:43:a5:0f:d4:7d:c6:5d:88:e3:98:9d:67: + eb:32:82:b3:0f:f5:c1:78:f8:05:4a:bf:bc:21:05:ee:21:08: + 2c:b2:15:a1:b8:b2:f6:a3:15:61:e4:c1:ad:84:a4:a7:40:0c: + 87:09:5f:2b:1b:f9:4d:6c:92:7d:cb:7e:2b:b0:01:0a:ed:40: + e5:4e:af:1a:f1:0d:ec:1d:9e:96:c7:d4:61:64:39:23:fa:5f: + 29:c4:2a:3a:b8:ed:8a:72:50:6a:ac:45:04:76:09:a8:3d:57: + d7:f0:4b:ae:46:b4:83:c1:14:50:2a:19:59:53:b2:4d:ae:fc: + 2f:40:49:c8:ad:4d:9d:c8:22:8d:8c:01:db:31:33:5a:f4:bc: + 4c:9b:ed:d7:e3:43:d9:e8:1d:53:8b:30:d8:81:9e:72:ab:9e: + ce:b8:f5:83:93:f2:72:db:de:cd:b0:52:9a:45:4d:cf:e7:21: + d8:ce:16:64:8f:42:af:c1:87:a8:f9:d5:e2:03:dd:ba:6b:1b: + 7c:7d:a0:38:33:61:39:b4:dd:5c:69:17:79:02:3a:ec:1d:6f: + 5e:bb:13:fb:a6:82:5d:07:20:fc:86:fe:6e:8b:ac:e1:c2:18: + a2:fe:3f:95:66:d3:69:8a:00:06:2c:56:37:34:b9:b6:31:de: + 0f:f6:44:39 -----BEGIN CERTIFICATE----- -MIIDljCCAn6gAwIBAgIULyXzzjxectAzKfYJH11fU9msI7swDQYJKoZIhvcNAQEL -BQAwYzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcM -DU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3QgQ0ExFTATBgNVBAMMDFRlc3Qg -Um9vdCBDQTAeFw0yMDAzMTMyMDQ2MTZaFw0zMDAzMTEyMDQ2MTZaMGMxCzAJBgNV +MIIDizCCAnOgAwIBAgIJAJRTRMx4iMvZMA0GCSqGSIb3DQEBCwUAMGMxCzAJBgNV BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBW -aWV3MRAwDgYDVQQKDAdUZXN0IENBMRUwEwYDVQQDDAxUZXN0IFJvb3QgQ0EwggEi -MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGgR+Sc7ZYhdmNrLcg/ce/QLLq -+uULUgGPmsHreoDB84mkPtUbYcy1z4CxGtu7JeAYv5JpJlDN5z//DTy0HxQSq2c3 -3gcDbBJ0gjasw9TTZJ+R7Vv2qXqknJjoZWyU4ctVc674HVCweOV0/7E3LMsZPaSM -53ZOhlw/37PtRSNPVJszxoleEx3dfVmlBzQohicf+p5TTyq2Qq03EmL1cja2AhJA -RP7HnpWJQ1FetG7HZ4BYQ77MByi9Wf8cTI2QQvTP/VQAT0hyK+FnPIQXaJW/ygd7 -34adVuMy43CHt/g69+NuZRR8u3a3F/FCjG8qNGQQNRSMhfZXv/NcVZ2tAxDzAgMB -AAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFJsmC4qYqbsduR8c4xpA -M+2OF4irMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAQEAsbGDYa/b -7ZjPPUNfp0K4bZQ2V7urBO7dO7dt7Hh9Rlmx5irDqqVwp+EM+mU3xst9oTc1of/w -3c62pCwS1EapnKKROrCVVZdV5graY2AkGawgybGUQOmZsfXD7WFd3kzk69kOrDoK -/ER9D3emttoo1O3qOrxXI5xyKy2wXRECTcW8sNZ+AI735/UZOiPfMwKqS7+B9FqZ -7nQg83eh8IUeqNbMpMsx+nMkog7dn2+COF+FrI12vdjyaXPjRkRC417zql5EE1Hq -C3iRd5buc/4qtYjBOI2NqBl2lAUCz9Rv6+YH9Z1SJLhQow7ERaYJtAYtPhSlPxwa -vNq4QD7BHPY8BQ== +aWV3MRAwDgYDVQQKDAdUZXN0IENBMRUwEwYDVQQDDAxUZXN0IFJvb3QgQ0EwHhcN +MTcwNjA1MTcxMDQ0WhcNMjcwNjAzMTcxMDQ0WjBjMQswCQYDVQQGEwJVUzETMBEG +A1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4GA1UE +CgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMIIBIjANBgkqhkiG9w0B +AQEFAAOCAQ8AMIIBCgKCAQEAxoEfknO2WIXZjay3IP3Hv0Cy6vrlC1IBj5rB63qA +wfOJpD7VG2HMtc+AsRrbuyXgGL+SaSZQzec//w08tB8UEqtnN94HA2wSdII2rMPU +02Sfke1b9ql6pJyY6GVslOHLVXOu+B1QsHjldP+xNyzLGT2kjOd2ToZcP9+z7UUj +T1SbM8aJXhMd3X1ZpQc0KIYnH/qeU08qtkKtNxJi9XI2tgISQET+x56ViUNRXrRu +x2eAWEO+zAcovVn/HEyNkEL0z/1UAE9IcivhZzyEF2iVv8oHe9+GnVbjMuNwh7f4 +OvfjbmUUfLt2txfxQoxvKjRkEDUUjIX2V7/zXFWdrQMQ8wIDAQABo0IwQDAPBgNV +HRMBAf8EBTADAQH/MB0GA1UdDgQWBBSbJguKmKm7HbkfHOMaQDPtjheIqzAOBgNV +HQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggEBAFtT/23VCkOlD9R9xl2I45id +Z+sygrMP9cF4+AVKv7whBe4hCCyyFaG4svajFWHkwa2EpKdADIcJXysb+U1skn3L +fiuwAQrtQOVOrxrxDewdnpbH1GFkOSP6XynEKjq47YpyUGqsRQR2Cag9V9fwS65G +tIPBFFAqGVlTsk2u/C9AScitTZ3IIo2MAdsxM1r0vEyb7dfjQ9noHVOLMNiBnnKr +ns649YOT8nLb3s2wUppFTc/nIdjOFmSPQq/Bh6j51eID3bprG3x9oDgzYTm03Vxp +F3kCOuwdb167E/umgl0HIPyG/m6LrOHCGKL+P5Vm02mKAAYsVjc0ubYx3g/2RDk= -----END CERTIFICATE-----
diff --git a/net/data/ssl/scripts/crlsetutil.py b/net/data/ssl/scripts/crlsetutil.py index 815fa9c..5d65cd1 100755 --- a/net/data/ssl/scripts/crlsetutil.py +++ b/net/data/ssl/scripts/crlsetutil.py
@@ -10,10 +10,10 @@ The input is taken on stdin and is a dict with the following keys: - BlockedBySPKI: An array of strings, where each string is a filename containing a PEM certificate, from which an SPKI will be extracted. - - BlockedByHash: A dict of string to an array of strings. The dict key is - a filename containing a PEM certificate, representing the issuer cert, - while the array of strings contain the filenames of PEM format - certificates whose serials are blocked. + - BlockedByHash: A dict of string to an array of ints, where the string is + a filename containing a PEM format certificate, and the ints are the + serial numbers. The listed serial numbers will be blocked when issued by + the given certificate. - LimitedSubjects: A dict of string to an array of strings, where the key is a filename containing a PEM format certificate, and the strings are the filenames of PEM format certificates. Certificates that share a Subject @@ -130,10 +130,6 @@ """Returns the raw data of the current element""" return self._contents - def encoded_value(self): - """Returns the encoded value of the current element (i.e. without header)""" - return self._contents[self._header_length:] - def _der_cert_to_spki(der_bytes): """Returns the subjectPublicKeyInfo of a DER-encoded certificate @@ -213,38 +209,6 @@ return der_cert_to_subject_hash(_pem_cert_to_binary(pem_filename)) -def der_cert_to_serial(der_bytes): - """Gets the serial of a DER-encoded certificate, omitting leading 0x00 - - Args: - der_bytes: A DER-encoded certificates (RFC 5280) - - Returns: - The encoded serial number value (omitting tag and length), and omitting - any leading 0x00 used to indicate it is a positive INTEGER. - """ - iterator = ASN1Iterator(der_bytes) - iterator.step_into() # enter certificate structure - iterator.step_into() # enter TBSCertificate - iterator.step_over() # over version - raw_serial = iterator.encoded_value() - if raw_serial[0] == chr(0x00) and len(raw_serial) > 1: - raw_serial = raw_serial[1:] - return raw_serial - - -def pem_cert_file_to_serial(pem_filename): - """Gets the DER-encoded serial of a cert in a file, omitting leading 0x00 - - Args: - pem_filename: A file containing a PEM-encoded certificate. - - Returns: - The DER-encoded serial as a byte sequence - """ - return der_cert_to_serial(_pem_cert_to_binary(pem_filename)) - - def main(): parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) parser.add_option('-o', '--output', @@ -259,11 +223,8 @@ pem_cert_file_to_spki_hash(pem_file).encode('base64').strip() for pem_file in config.get('BlockedBySPKI', [])] parents = { - pem_cert_file_to_spki_hash(pem_file): [ - pem_cert_file_to_serial(issued_cert_file) - for issued_cert_file in issued_certs - ] - for pem_file, issued_certs in config.get('BlockedByHash', {}).iteritems() + pem_cert_file_to_spki_hash(pem_file): serials + for pem_file, serials in config.get('BlockedByHash', {}).iteritems() } limited_subjects = { pem_cert_file_to_subject_hash(pem_file).encode('base64').strip(): [ @@ -299,7 +260,9 @@ if not serial: raw_serial = ['\x00'] else: - raw_serial = serial + while serial: + raw_serial.insert(0, chr(serial & 0xff)) + serial >>= 8 outfile.write(struct.pack('<B', len(raw_serial))) outfile.write(''.join(raw_serial))
diff --git a/net/data/ssl/scripts/generate-multi-root-test-chains.sh b/net/data/ssl/scripts/generate-multi-root-test-chains.sh index d624160..c4d1792e 100755 --- a/net/data/ssl/scripts/generate-multi-root-test-chains.sh +++ b/net/data/ssl/scripts/generate-multi-root-test-chains.sh
@@ -49,9 +49,10 @@ mkdir out echo Create the serial and index number files. +serial=1000 for i in B C D E F do - openssl rand -hex -out "out/${i}-serial" 16 + /bin/sh -c "echo ${serial} > out/${i}-serial" touch "out/${i}-index.txt" done @@ -228,13 +229,14 @@ } CRLSETDOCBLOCK -# Block C-by-D and F-by-E by way of serial number. +# Block C-by-D (serial number 0x1001) and F-by-E (serial number 0x1002) by +# way of serial number. python crlsetutil.py -o ../certificates/multi-root-crlset-CD-and-FE.raw \ <<CRLSETDOCBLOCK { "BlockedByHash": { - "out/D.pem": ["out/C.pem"], - "out/E.pem": ["out/F.pem"] + "out/D.pem": [4097], + "out/E.pem": [4098] } } CRLSETDOCBLOCK @@ -247,12 +249,12 @@ } CRLSETDOCBLOCK -# Block an unrelated/unissued serial (D, not issued by E) to enable all paths. +# Block an unrelated/unissued serial (0x0FFF) to enable all paths. python crlsetutil.py -o ../certificates/multi-root-crlset-unrelated.raw \ <<CRLSETDOCBLOCK { "BlockedByHash": { - "out/E.pem": ["out/D.pem"] + "out/E.pem": [4095] } } CRLSETDOCBLOCK
diff --git a/net/data/ssl/scripts/generate-test-certs.sh b/net/data/ssl/scripts/generate-test-certs.sh index a26a595..0a41eec 100755 --- a/net/data/ssl/scripts/generate-test-certs.sh +++ b/net/data/ssl/scripts/generate-test-certs.sh
@@ -8,17 +8,6 @@ # certificates that can be used to test fetching of an intermediate via AIA. set -e -x -# The maximum lifetime for any certificates that may go through a "real" -# cert verifier. This is effectively: -# min(OS verifier max lifetime for local certs, built-in verifier max lifetime -# for local certs) -# -# The current built-in verifier max lifetime is 39 months -# The current OS verifier max lifetime is 825 days, which comes from -# iOS 13/macOS 10.15 - https://support.apple.com/en-us/HT210176 -# 731 is used here as just a short-hand for 2 years -CERT_LIFETIME=730 - rm -rf out mkdir out mkdir out/int @@ -128,7 +117,7 @@ openssl ca \ -batch \ -extensions user_cert \ - -days ${CERT_LIFETIME} \ + -days 3650 \ -in out/ok_cert.req \ -out out/ok_cert.pem \ -config ca.cnf @@ -139,7 +128,7 @@ openssl ca \ -batch \ -extensions user_cert \ - -days ${CERT_LIFETIME} \ + -days 3650 \ -in out/ok_cert.req \ -out out/int/ok_cert.pem \ -config ca.cnf @@ -148,6 +137,7 @@ openssl ca \ -batch \ -extensions user_cert \ + -days 3650 \ -in out/wildcard.req \ -out out/wildcard.pem \ -config ca.cnf @@ -157,7 +147,7 @@ -batch \ -extensions name_constraint_bad \ -subj "/CN=Leaf certificate/" \ - -days ${CERT_LIFETIME} \ + -days 3650 \ -in out/ok_cert.req \ -out out/name_constraint_bad.pem \ -config ca.cnf @@ -167,7 +157,7 @@ -batch \ -extensions name_constraint_good \ -subj "/CN=Leaf Certificate/" \ - -days ${CERT_LIFETIME} \ + -days 3650 \ -in out/ok_cert.req \ -out out/name_constraint_good.pem \ -config ca.cnf @@ -176,7 +166,7 @@ openssl ca \ -batch \ -extensions user_cert \ - -days ${CERT_LIFETIME} \ + -days 3650 \ -in out/localhost_cert.req \ -out out/localhost_cert.pem \ -config ca.cnf @@ -196,7 +186,7 @@ openssl ca \ -batch \ -extensions user_cert \ - -days ${CERT_LIFETIME} \ + -days 3650 \ -in out/test_names.req \ -out out/test_names.pem \ -config ca.cnf @@ -251,8 +241,9 @@ -out ../certificates/punycodetest.pem ## Reject intranet hostnames in "publicly" trusted certs +# 365 * 3 = 1095 SUBJECT_NAME="req_intranet_dn" \ - openssl req -x509 -days ${CERT_LIFETIME} -extensions req_intranet_san \ + openssl req -x509 -days 1095 -extensions req_intranet_san \ -config ../scripts/ee.cnf -newkey rsa:2048 -text \ -out ../certificates/reject_intranet_hosts.pem @@ -289,6 +280,7 @@ -in out/10_year_validity.req \ -out ../certificates/10_year_validity.pem \ -config ca.cnf +# 365 * 11 = 4015 openssl req -config ../scripts/ee.cnf \ -newkey rsa:2048 -text -out out/11_year_validity.req CA_NAME="req_ca_dn" \ @@ -296,7 +288,7 @@ -batch \ -extensions user_cert \ -startdate 141030000000Z \ - -enddate 251030000000Z \ + -days 4015 \ -in out/11_year_validity.req \ -out ../certificates/11_year_validity.pem \ -config ca.cnf @@ -335,12 +327,13 @@ -config ca.cnf openssl req -config ../scripts/ee.cnf \ -newkey rsa:2048 -text -out out/61_months_after_2012_07.req +# 30 * 61 = 1830 CA_NAME="req_ca_dn" \ openssl ca \ -batch \ -extensions user_cert \ -startdate 141030000000Z \ - -enddate 191103000000Z \ + -days 1830 \ -in out/61_months_after_2012_07.req \ -out ../certificates/61_months_after_2012_07.pem \ -config ca.cnf @@ -510,7 +503,8 @@ openssl ca \ -batch \ -extensions user_cert \ - -days ${CERT_LIFETIME} \ + -startdate 171220000000Z \ + -enddate 201220000000Z \ -in out/sha1_leaf.req \ -out out/sha1_leaf.pem \ -config ca.cnf \ @@ -606,14 +600,13 @@ } CRLBYROOTSPKI -## Block a leaf cert by issuer-hash-and-serial +## Block a leaf cert by issuer-hash-and-serial (ok_cert.pem == serial 3, by +## virtue of the serial file and ordering above. python crlsetutil.py -o ../certificates/crlset_by_root_serial.raw \ <<CRLBYROOTSERIAL { "BlockedByHash": { - "../certificates/root_ca_cert.pem": [ - "../certificates/ok_cert.pem" - ] + "../certificates/root_ca_cert.pem": [3] } } CRLBYROOTSERIAL @@ -624,9 +617,7 @@ <<CRLSETBYINTERMEDIATESERIAL { "BlockedByHash": { - "../certificates/intermediate_ca_cert.pem": [ - "../certificates/ok_cert_by_intermediate.pem" - ] + "../certificates/intermediate_ca_cert.pem": [1] } } CRLSETBYINTERMEDIATESERIAL
diff --git a/net/http/http_proxy_client_socket.cc b/net/http/http_proxy_client_socket.cc index f9ebee2..4ee4331 100644 --- a/net/http/http_proxy_client_socket.cc +++ b/net/http/http_proxy_client_socket.cc
@@ -15,6 +15,7 @@ #include "net/base/host_port_pair.h" #include "net/base/io_buffer.h" #include "net/base/proxy_delegate.h" +#include "net/base/proxy_server.h" #include "net/http/http_basic_stream.h" #include "net/http/http_log_util.h" #include "net/http/http_network_session.h" @@ -382,8 +383,8 @@ if (proxy_delegate_) { HttpRequestHeaders proxy_delegate_headers; - proxy_delegate_->OnBeforeHttp1TunnelRequest(proxy_server_, - &proxy_delegate_headers); + proxy_delegate_->OnBeforeTunnelRequest(proxy_server_, + &proxy_delegate_headers); extra_headers.MergeFrom(proxy_delegate_headers); } @@ -434,8 +435,8 @@ response_.headers.get()); if (proxy_delegate_) { - int rv = proxy_delegate_->OnHttp1TunnelHeadersReceived(proxy_server_, - *response_.headers); + int rv = proxy_delegate_->OnTunnelHeadersReceived(proxy_server_, + *response_.headers); if (rv != OK) { DCHECK_NE(ERR_IO_PENDING, rv); return rv;
diff --git a/net/http/http_proxy_connect_job.cc b/net/http/http_proxy_connect_job.cc index d7769615..463f50e 100644 --- a/net/http/http_proxy_connect_job.cc +++ b/net/http/http_proxy_connect_job.cc
@@ -641,8 +641,9 @@ DCHECK(stream.get()); // |transport_socket_| will set itself as |stream|'s delegate. transport_socket_ = std::make_unique<SpdyProxyClientSocket>( - stream, GetUserAgent(), params_->endpoint(), net_log(), - http_auth_controller_.get()); + stream, ProxyServer(GetProxyServerScheme(), GetDestination()), + GetUserAgent(), params_->endpoint(), net_log(), + http_auth_controller_.get(), common_connect_job_params()->proxy_delegate); return transport_socket_->Connect(base::BindOnce( &HttpProxyConnectJob::OnIOComplete, base::Unretained(this))); } @@ -710,8 +711,10 @@ quic_stream->SetPriority(precedence); transport_socket_ = std::make_unique<QuicProxyClientSocket>( - std::move(quic_stream), std::move(quic_session_), GetUserAgent(), - params_->endpoint(), net_log(), http_auth_controller_.get()); + std::move(quic_stream), std::move(quic_session_), + ProxyServer(GetProxyServerScheme(), GetDestination()), GetUserAgent(), + params_->endpoint(), net_log(), http_auth_controller_.get(), + common_connect_job_params()->proxy_delegate); return transport_socket_->Connect(base::BindOnce( &HttpProxyConnectJob::OnIOComplete, base::Unretained(this))); }
diff --git a/net/http/http_proxy_connect_job_unittest.cc b/net/http/http_proxy_connect_job_unittest.cc index a1b3525..1a049b1 100644 --- a/net/http/http_proxy_connect_job_unittest.cc +++ b/net/http/http_proxy_connect_job_unittest.cc
@@ -447,46 +447,62 @@ } TEST_P(HttpProxyConnectJobTest, ProxyDelegateExtraHeaders) { - // TODO(https://crbug.com/926427): The ProxyDelegate API is currently broken - // in the SPDY case. - if (GetParam() == SPDY) - return; - InitProxyDelegate(); ProxyServer proxy_server( GetParam() == HTTP ? ProxyServer::SCHEME_HTTP : ProxyServer::SCHEME_HTTPS, HostPortPair(GetParam() == HTTP ? kHttpProxyHost : kHttpsProxyHost, GetParam() == HTTP ? 80 : 443)); - std::string request = + std::string proxy_server_uri = proxy_server.ToURI(); + + std::string http1_request = "CONNECT www.endpoint.test:443 HTTP/1.1\r\n" "Host: www.endpoint.test:443\r\n" "Proxy-Connection: keep-alive\r\n" "Foo: " + - proxy_server.ToURI() + "\r\n\r\n"; + proxy_server_uri + "\r\n\r\n"; MockWrite writes[] = { - MockWrite(ASYNC, 0, request.c_str()), + MockWrite(ASYNC, 0, http1_request.c_str()), }; - const char kResponseHeaderName[] = "Foo"; + const char kResponseHeaderName[] = "foo"; const char kResponseHeaderValue[] = "Response"; - std::string response = base::StringPrintf( + std::string http1_response = base::StringPrintf( "HTTP/1.1 200 Connection Established\r\n" "%s: %s\r\n\r\n", kResponseHeaderName, kResponseHeaderValue); MockRead reads[] = { - MockRead(ASYNC, 1, response.c_str()), + MockRead(ASYNC, 1, http1_response.c_str()), }; - Initialize(reads, writes, base::span<MockRead>(), base::span<MockWrite>(), - ASYNC); + const char* const kExtraRequestHeaders[] = { + "foo", + proxy_server_uri.c_str(), + }; + const char* const kExtraResponseHeaders[] = { + kResponseHeaderName, + kResponseHeaderValue, + }; + spdy::SpdySerializedFrame req(spdy_util_.ConstructSpdyConnect( + kExtraRequestHeaders, base::size(kExtraRequestHeaders) / 2, 1, + HttpProxyConnectJob::kH2QuicTunnelPriority, + HostPortPair(kEndpointHost, 443))); + MockWrite spdy_writes[] = {CreateMockWrite(req, 0)}; + spdy::SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply( + kExtraResponseHeaders, base::size(kExtraResponseHeaders) / 2, 1)); + MockRead spdy_reads[] = { + CreateMockRead(resp, 1, ASYNC), + MockRead(SYNCHRONOUS, ERR_IO_PENDING, 2), + }; + + Initialize(reads, writes, spdy_reads, spdy_writes, ASYNC); TestConnectJobDelegate test_delegate; std::unique_ptr<ConnectJob> connect_job = CreateConnectJobForTunnel(&test_delegate); test_delegate.StartJobExpectingResult(connect_job.get(), OK, false /* expect_sync_result */); - proxy_delegate_->VerifyOnHttp1TunnelHeadersReceived( + proxy_delegate_->VerifyOnTunnelHeadersReceived( proxy_server, kResponseHeaderName, kResponseHeaderValue); }
diff --git a/net/http/http_server_properties_manager.cc b/net/http/http_server_properties_manager.cc index 7ec6752..fd304630 100644 --- a/net/http/http_server_properties_manager.cc +++ b/net/http/http_server_properties_manager.cc
@@ -529,6 +529,7 @@ } // Advertised versions list is optional. + // It is only used for PROTOCOL_QUIC_CRYPTO versions. if (dict.HasKey(kAdvertisedVersionsKey)) { const base::ListValue* versions_list = nullptr; if (!dict.GetListWithoutPathExpansion(kAdvertisedVersionsKey, @@ -545,8 +546,13 @@ << server_str; return false; } - // TODO(nharper): Support ParsedQuicVersions (instead of - // QuicTransportVersions) in AlternativeServiceMap. + if (!quic::ParsedQuicVersionIsValid( + quic::PROTOCOL_QUIC_CRYPTO, + quic::QuicTransportVersion(version))) { + // This version is not valid, this can happen if we've deprecated + // a version that used to be valid. + continue; + } advertised_versions.push_back(quic::ParsedQuicVersion( quic::PROTOCOL_QUIC_CRYPTO, quic::QuicTransportVersion(version))); }
diff --git a/net/http/http_server_properties_manager_unittest.cc b/net/http/http_server_properties_manager_unittest.cc index ca7b3a2..51419ece 100644 --- a/net/http/http_server_properties_manager_unittest.cc +++ b/net/http/http_server_properties_manager_unittest.cc
@@ -1567,7 +1567,9 @@ "{\"port\":443,\"protocol_str\":\"quic\"}," "{\"port\":123,\"protocol_str\":\"quic\"," "\"expiration\":\"9223372036854775807\"," - "\"advertised_versions\":[46,43]}]}"); + // Add 33 which we know is not supported, as regression test for + // https://crbug.com/1061509 + "\"advertised_versions\":[33,46,43]}]}"); ASSERT_TRUE(server_value); base::DictionaryValue* server_dict; ASSERT_TRUE(server_value->GetAsDictionary(&server_dict));
diff --git a/net/proxy_resolution/configured_proxy_resolution_service_unittest.cc b/net/proxy_resolution/configured_proxy_resolution_service_unittest.cc index c5c0743..e82c863a 100644 --- a/net/proxy_resolution/configured_proxy_resolution_service_unittest.cc +++ b/net/proxy_resolution/configured_proxy_resolution_service_unittest.cc
@@ -221,10 +221,10 @@ void OnFallback(const ProxyServer& bad_proxy, int net_error) override {} - void OnBeforeHttp1TunnelRequest(const ProxyServer& proxy_server, - HttpRequestHeaders* extra_headers) override {} + void OnBeforeTunnelRequest(const ProxyServer& proxy_server, + HttpRequestHeaders* extra_headers) override {} - Error OnHttp1TunnelHeadersReceived( + Error OnTunnelHeadersReceived( const ProxyServer& proxy_server, const HttpResponseHeaders& response_headers) override { return OK; @@ -253,10 +253,10 @@ num_proxy_fallback_called_++; } - void OnBeforeHttp1TunnelRequest(const ProxyServer& proxy_server, - HttpRequestHeaders* extra_headers) override {} + void OnBeforeTunnelRequest(const ProxyServer& proxy_server, + HttpRequestHeaders* extra_headers) override {} - Error OnHttp1TunnelHeadersReceived( + Error OnTunnelHeadersReceived( const ProxyServer& proxy_server, const HttpResponseHeaders& response_headers) override { return OK;
diff --git a/net/quic/quic_flags_list.h b/net/quic/quic_flags_list.h index 11f37d3a..05ca1d5 100644 --- a/net/quic/quic_flags_list.h +++ b/net/quic/quic_flags_list.h
@@ -273,34 +273,15 @@ FLAGS_quic_reloadable_flag_quic_ack_delay_alarm_granularity, false) -// If true, QuicSentPacketManager::SetSendAlgorithm(CongestionControlType) will -// become a no-op if the current and the requested cc_type are the same. -QUIC_FLAG( - bool, - FLAGS_quic_reloadable_flag_quic_set_send_algorithm_noop_if_cc_type_unchanged, - true) - // If true, use predictable grease settings identifiers and values. QUIC_FLAG(bool, FLAGS_quic_enable_http3_grease_randomness, true) -// If true, QuicConnection will check handshake timeout before idle timeout. -QUIC_FLAG( - bool, - FLAGS_quic_reloadable_flag_quic_check_handshake_timeout_before_idle_timeout, - true) - // If true and batch writer is used, QuicConnection will flush after a mtu probe // is sent. QUIC_FLAG(bool, FLAGS_quic_reloadable_flag_quic_batch_writer_flush_after_mtu_probe, true) -// If true, neuter unencrypted control frames in -// QuicUnackedPacketMap::NeuterUnencryptedPackets. -QUIC_FLAG(bool, - FLAGS_quic_reloadable_flag_quic_neuter_unencrypted_control_frames, - true) - // When the EACK connection option is sent by the client, an ack-eliciting frame // is bundled with ACKs sent after the PTO fires. QUIC_FLAG(bool, @@ -342,11 +323,6 @@ FLAGS_quic_reloadable_flag_quic_minimum_validation_of_coalesced_packets, true) -// If true, do not send WINDOW_UPDATE if connection has been disconnected. -QUIC_FLAG(bool, - FLAGS_quic_reloadable_flag_quic_no_window_update_if_disconnected, - true) - // If true, arm the 1st PTO with earliest in flight sent time. QUIC_FLAG(bool, FLAGS_quic_reloadable_flag_quic_arm_pto_with_earliest_sent_time, @@ -399,3 +375,9 @@ QUIC_FLAG(bool, FLAGS_quic_reloadable_flag_quic_bbr_fix_zero_bw_on_loss_only_event, false) + +// If true, trigger QUIC_BUG in two ShouldCreateIncomingStream() overrides when +// called with locally initiated stream ID. +QUIC_FLAG(bool, + FLAGS_quic_reloadable_flag_quic_create_incoming_stream_bug, + false)
diff --git a/net/quic/quic_proxy_client_socket.cc b/net/quic/quic_proxy_client_socket.cc index 925205b2..2d879025 100644 --- a/net/quic/quic_proxy_client_socket.cc +++ b/net/quic/quic_proxy_client_socket.cc
@@ -11,6 +11,7 @@ #include "base/bind_helpers.h" #include "base/callback_helpers.h" #include "base/values.h" +#include "net/base/proxy_delegate.h" #include "net/http/http_auth_controller.h" #include "net/http/http_log_util.h" #include "net/http/http_response_headers.h" @@ -25,10 +26,12 @@ QuicProxyClientSocket::QuicProxyClientSocket( std::unique_ptr<QuicChromiumClientStream::Handle> stream, std::unique_ptr<QuicChromiumClientSession::Handle> session, + const ProxyServer& proxy_server, const std::string& user_agent, const HostPortPair& endpoint, const NetLogWithSource& net_log, - HttpAuthController* auth_controller) + HttpAuthController* auth_controller, + ProxyDelegate* proxy_delegate) : next_state_(STATE_DISCONNECTED), stream_(std::move(stream)), session_(std::move(session)), @@ -36,6 +39,8 @@ write_buf_len_(0), endpoint_(endpoint), auth_(auth_controller), + proxy_server_(proxy_server), + proxy_delegate_(proxy_delegate), user_agent_(user_agent), net_log_(net_log) { DCHECK(stream_->IsOpen()); @@ -348,6 +353,13 @@ auth_->AddAuthorizationHeader(&authorization_headers); } + if (proxy_delegate_) { + HttpRequestHeaders proxy_delegate_headers; + proxy_delegate_->OnBeforeTunnelRequest(proxy_server_, + &proxy_delegate_headers); + request_.extra_headers.MergeFrom(proxy_delegate_headers); + } + std::string request_line; BuildTunnelRequest(endpoint_, authorization_headers, user_agent_, &request_line, &request_.extra_headers); @@ -404,6 +416,15 @@ net_log_, NetLogEventType::HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, response_.headers.get()); + if (proxy_delegate_) { + int rv = proxy_delegate_->OnTunnelHeadersReceived(proxy_server_, + *response_.headers); + if (rv != OK) { + DCHECK_NE(ERR_IO_PENDING, rv); + return rv; + } + } + switch (response_.headers->response_code()) { case 200: // OK next_state_ = STATE_CONNECT_COMPLETE;
diff --git a/net/quic/quic_proxy_client_socket.h b/net/quic/quic_proxy_client_socket.h index 299526c8..723b6670 100644 --- a/net/quic/quic_proxy_client_socket.h +++ b/net/quic/quic_proxy_client_socket.h
@@ -11,6 +11,7 @@ #include "net/base/completion_once_callback.h" #include "net/base/load_timing_info.h" +#include "net/base/proxy_server.h" #include "net/http/proxy_client_socket.h" #include "net/quic/quic_chromium_client_session.h" #include "net/quic/quic_chromium_client_stream.h" @@ -20,6 +21,7 @@ namespace net { class HttpAuthController; +class ProxyDelegate; // QuicProxyClientSocket provides a socket interface to an underlying // QuicChromiumClientStream. Bytes written to/read from a QuicProxyClientSocket @@ -32,10 +34,12 @@ QuicProxyClientSocket( std::unique_ptr<QuicChromiumClientStream::Handle> stream, std::unique_ptr<QuicChromiumClientSession::Handle> session, + const ProxyServer& proxy_server, const std::string& user_agent, const HostPortPair& endpoint, const NetLogWithSource& net_log, - HttpAuthController* auth_controller); + HttpAuthController* auth_controller, + ProxyDelegate* proxy_delegate); // On destruction Disconnect() is called. ~QuicProxyClientSocket() override; @@ -137,6 +141,11 @@ const HostPortPair endpoint_; scoped_refptr<HttpAuthController> auth_; + const ProxyServer proxy_server_; + + // This delegate must outlive this proxy client socket. + ProxyDelegate* const proxy_delegate_; + std::string user_agent_; // Session connect timing info.
diff --git a/net/quic/quic_proxy_client_socket_unittest.cc b/net/quic/quic_proxy_client_socket_unittest.cc index f62240f..8fc4d25 100644 --- a/net/quic/quic_proxy_client_socket_unittest.cc +++ b/net/quic/quic_proxy_client_socket_unittest.cc
@@ -15,6 +15,7 @@ #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/default_tick_clock.h" +#include "net/base/test_proxy_delegate.h" #include "net/dns/mock_host_resolver.h" #include "net/http/http_auth_cache.h" #include "net/http/http_auth_handler_factory.h" @@ -305,13 +306,15 @@ EXPECT_TRUE(stream_handle->IsOpen()); sock_.reset(new QuicProxyClientSocket( - std::move(stream_handle), std::move(session_handle_), user_agent_, + std::move(stream_handle), std::move(session_handle_), + ProxyServer(ProxyServer::SCHEME_HTTPS, proxy_host_port_), user_agent_, endpoint_host_port_, net_log_.bound(), new HttpAuthController(HttpAuth::AUTH_PROXY, GURL("https://" + proxy_host_port_.ToString()), NetworkIsolationKey(), &http_auth_cache_, http_auth_handler_factory_.get(), - host_resolver_.get()))); + host_resolver_.get()), + proxy_delegate_.get())); session_->StartReading(); } @@ -375,6 +378,26 @@ std::move(block), 0, nullptr); } + std::unique_ptr<quic::QuicReceivedPacket> + ConstructConnectRequestPacketWithExtraHeaders( + uint64_t packet_number, + std::vector<std::pair<std::string, std::string>> extra_headers, + RequestPriority request_priority = LOWEST) { + spdy::SpdyHeaderBlock block; + block[":method"] = "CONNECT"; + block[":authority"] = endpoint_host_port_.ToString(); + for (const auto& header : extra_headers) { + block[header.first] = header.second; + } + if (VersionUsesHttp3(version_.transport_version)) { + request_priority = MEDIUM; + } + return client_maker_.MakeRequestHeadersPacket( + packet_number, client_data_stream_id1_, kIncludeVersion, !kFin, + ConvertRequestPriorityToQuicPriority(request_priority), + std::move(block), 0, nullptr); + } + std::unique_ptr<quic::QuicReceivedPacket> ConstructConnectAuthRequestPacket( uint64_t packet_number) { RequestPriority request_priority = LOWEST; @@ -455,6 +478,22 @@ } std::unique_ptr<quic::QuicReceivedPacket> + ConstructServerConnectReplyPacketWithExtraHeaders( + uint64_t packet_number, + bool fin, + std::vector<std::pair<std::string, std::string>> extra_headers) { + spdy::SpdyHeaderBlock block; + block[":status"] = "200"; + for (const auto& header : extra_headers) { + block[header.first] = header.second; + } + + return server_maker_.MakeResponseHeadersPacket( + packet_number, client_data_stream_id1_, !kIncludeVersion, fin, + std::move(block), nullptr); + } + + std::unique_ptr<quic::QuicReceivedPacket> ConstructServerConnectAuthReplyPacket(uint64_t packet_number, bool fin) { spdy::SpdyHeaderBlock block; block[":status"] = "407"; @@ -582,6 +621,7 @@ std::unique_ptr<QuicChromiumClientSession> session_; std::unique_ptr<QuicChromiumClientSession::Handle> session_handle_; std::unique_ptr<QuicProxyClientSocket> sock_; + std::unique_ptr<TestProxyDelegate> proxy_delegate_; quic::test::MockSendAlgorithm* send_algorithm_; scoped_refptr<TestTaskRunner> runner_; @@ -642,6 +682,45 @@ ASSERT_EQ(200, response->headers->response_code()); } +TEST_P(QuicProxyClientSocketTest, ProxyDelegateExtraHeaders) { + proxy_delegate_ = std::make_unique<TestProxyDelegate>(); + ProxyServer proxy_server(ProxyServer::SCHEME_HTTPS, proxy_host_port_); + + const char kResponseHeaderName[] = "foo"; + const char kResponseHeaderValue[] = "testing"; + + int packet_number = 1; + if (VersionUsesHttp3(version_.transport_version)) { + mock_quic_data_.AddWrite(SYNCHRONOUS, + ConstructSettingsPacket(packet_number++)); + } + mock_quic_data_.AddWrite( + SYNCHRONOUS, + ConstructConnectRequestPacketWithExtraHeaders( + packet_number++, + // Order matters! Keep these alphabetical. + {{"foo", proxy_server.ToURI()}, {"user-agent", kUserAgent}})); + mock_quic_data_.AddRead( + ASYNC, ConstructServerConnectReplyPacketWithExtraHeaders( + 1, !kFin, {{kResponseHeaderName, kResponseHeaderValue}})); + mock_quic_data_.AddRead(SYNCHRONOUS, ERR_IO_PENDING); + mock_quic_data_.AddWrite( + SYNCHRONOUS, ConstructAckAndRstPacket( + packet_number++, quic::QUIC_STREAM_CANCELLED, 1, 1, 1)); + + Initialize(); + + ASSERT_FALSE(sock_->IsConnected()); + + AssertConnectSucceeds(); + + const HttpResponseInfo* response = sock_->GetConnectResponseInfo(); + ASSERT_TRUE(response != nullptr); + ASSERT_EQ(200, response->headers->response_code()); + proxy_delegate_->VerifyOnTunnelHeadersReceived( + proxy_server, kResponseHeaderName, kResponseHeaderValue); +} + TEST_P(QuicProxyClientSocketTest, ConnectWithAuthRequested) { int packet_number = 1; if (VersionUsesHttp3(version_.transport_version)) {
diff --git a/net/spdy/spdy_proxy_client_socket.cc b/net/spdy/spdy_proxy_client_socket.cc index 2156b4b2..c7621eb 100644 --- a/net/spdy/spdy_proxy_client_socket.cc +++ b/net/spdy/spdy_proxy_client_socket.cc
@@ -18,6 +18,7 @@ #include "base/values.h" #include "net/base/auth.h" #include "net/base/io_buffer.h" +#include "net/base/proxy_delegate.h" #include "net/http/http_auth_cache.h" #include "net/http/http_auth_handler_factory.h" #include "net/http/http_log_util.h" @@ -33,14 +34,18 @@ SpdyProxyClientSocket::SpdyProxyClientSocket( const base::WeakPtr<SpdyStream>& spdy_stream, + const ProxyServer& proxy_server, const std::string& user_agent, const HostPortPair& endpoint, const NetLogWithSource& source_net_log, - HttpAuthController* auth_controller) + HttpAuthController* auth_controller, + ProxyDelegate* proxy_delegate) : next_state_(STATE_DISCONNECTED), spdy_stream_(spdy_stream), endpoint_(endpoint), auth_(auth_controller), + proxy_server_(proxy_server), + proxy_delegate_(proxy_delegate), user_agent_(user_agent), user_buffer_len_(0), write_buffer_len_(0), @@ -363,6 +368,13 @@ auth_->AddAuthorizationHeader(&authorization_headers); } + if (proxy_delegate_) { + HttpRequestHeaders proxy_delegate_headers; + proxy_delegate_->OnBeforeTunnelRequest(proxy_server_, + &proxy_delegate_headers); + request_.extra_headers.MergeFrom(proxy_delegate_headers); + } + std::string request_line; BuildTunnelRequest(endpoint_, authorization_headers, user_agent_, &request_line, &request_.extra_headers); @@ -402,6 +414,15 @@ net_log_, NetLogEventType::HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, response_.headers.get()); + if (proxy_delegate_) { + int rv = proxy_delegate_->OnTunnelHeadersReceived(proxy_server_, + *response_.headers); + if (rv != OK) { + DCHECK_NE(ERR_IO_PENDING, rv); + return rv; + } + } + switch (response_.headers->response_code()) { case 200: // OK next_state_ = STATE_OPEN;
diff --git a/net/spdy/spdy_proxy_client_socket.h b/net/spdy/spdy_proxy_client_socket.h index 744a2b8..4ad7a96 100644 --- a/net/spdy/spdy_proxy_client_socket.h +++ b/net/spdy/spdy_proxy_client_socket.h
@@ -18,6 +18,7 @@ #include "net/base/completion_once_callback.h" #include "net/base/host_port_pair.h" #include "net/base/net_export.h" +#include "net/base/proxy_server.h" #include "net/http/http_auth_controller.h" #include "net/http/http_request_headers.h" #include "net/http/http_request_info.h" @@ -35,6 +36,7 @@ namespace net { class IOBuffer; +class ProxyDelegate; class SpdyStream; class NET_EXPORT_PRIVATE SpdyProxyClientSocket : public ProxyClientSocket, @@ -45,10 +47,12 @@ // data read/written to the socket will be transferred in data frames. This // object will set itself as |spdy_stream|'s delegate. SpdyProxyClientSocket(const base::WeakPtr<SpdyStream>& spdy_stream, + const ProxyServer& proxy_server, const std::string& user_agent, const HostPortPair& endpoint, const NetLogWithSource& source_net_log, - HttpAuthController* auth_controller); + HttpAuthController* auth_controller, + ProxyDelegate* proxy_delegate); // On destruction Disconnect() is called. ~SpdyProxyClientSocket() override; @@ -155,6 +159,11 @@ const HostPortPair endpoint_; scoped_refptr<HttpAuthController> auth_; + const ProxyServer proxy_server_; + + // This delegate must outlive this proxy client socket. + ProxyDelegate* const proxy_delegate_; + std::string user_agent_; // We buffer the response body as it arrives asynchronously from the stream.
diff --git a/net/spdy/spdy_proxy_client_socket_unittest.cc b/net/spdy/spdy_proxy_client_socket_unittest.cc index 6c107dc..adad830 100644 --- a/net/spdy/spdy_proxy_client_socket_unittest.cc +++ b/net/spdy/spdy_proxy_client_socket_unittest.cc
@@ -14,6 +14,7 @@ #include "base/strings/utf_string_conversions.h" #include "net/base/address_list.h" #include "net/base/load_timing_info.h" +#include "net/base/proxy_server.h" #include "net/base/test_completion_callback.h" #include "net/base/winsock_init.h" #include "net/dns/mock_host_resolver.h" @@ -265,11 +266,14 @@ // Create the SpdyProxyClientSocket. sock_ = std::make_unique<SpdyProxyClientSocket>( - spdy_stream, user_agent_, endpoint_host_port_pair_, net_log_.bound(), + spdy_stream, ProxyServer(ProxyServer::SCHEME_HTTPS, proxy_host_port_), + user_agent_, endpoint_host_port_pair_, net_log_.bound(), new HttpAuthController( HttpAuth::AUTH_PROXY, GURL("https://" + proxy_host_port_.ToString()), NetworkIsolationKey(), session_->http_auth_cache(), - session_->http_auth_handler_factory(), session_->host_resolver())); + session_->http_auth_handler_factory(), session_->host_resolver()), + // Testing with the proxy delegate is in HttpProxyConnectJobTest. + nullptr); } scoped_refptr<IOBufferWithSize> SpdyProxyClientSocketTest::CreateBuffer(
diff --git a/net/websockets/websocket_end_to_end_test.cc b/net/websockets/websocket_end_to_end_test.cc index ce32134..170e1bf 100644 --- a/net/websockets/websocket_end_to_end_test.cc +++ b/net/websockets/websocket_end_to_end_test.cc
@@ -250,10 +250,10 @@ void OnFallback(const ProxyServer& bad_proxy, int net_error) override {} - void OnBeforeHttp1TunnelRequest(const ProxyServer& proxy_server, - HttpRequestHeaders* extra_headers) override {} + void OnBeforeTunnelRequest(const ProxyServer& proxy_server, + HttpRequestHeaders* extra_headers) override {} - Error OnHttp1TunnelHeadersReceived( + Error OnTunnelHeadersReceived( const ProxyServer& proxy_server, const HttpResponseHeaders& response_headers) override { return OK;
diff --git a/services/device/hid/hid_connection_impl_unittest.cc b/services/device/hid/hid_connection_impl_unittest.cc index 6cad1da8..cde9f8e 100644 --- a/services/device/hid/hid_connection_impl_unittest.cc +++ b/services/device/hid/hid_connection_impl_unittest.cc
@@ -20,6 +20,8 @@ #if defined(OS_MACOSX) const uint64_t kTestDeviceId = 123; +#elif defined(OS_WIN) +const wchar_t* kTestDeviceId = L"123"; #else const char* kTestDeviceId = "123"; #endif
diff --git a/services/device/hid/hid_device_info.h b/services/device/hid/hid_device_info.h index 03dc04f..eca93d9 100644 --- a/services/device/hid/hid_device_info.h +++ b/services/device/hid/hid_device_info.h
@@ -13,6 +13,7 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" +#include "base/strings/string16.h" #include "build/build_config.h" #include "services/device/public/mojom/hid.mojom.h" @@ -20,6 +21,8 @@ #if defined(OS_MACOSX) typedef uint64_t HidPlatformDeviceId; +#elif defined(OS_WIN) +typedef base::string16 HidPlatformDeviceId; #else typedef std::string HidPlatformDeviceId; #endif
diff --git a/services/device/hid/hid_manager_unittest.cc b/services/device/hid/hid_manager_unittest.cc index 4d8ec85..7334f83 100644 --- a/services/device/hid/hid_manager_unittest.cc +++ b/services/device/hid/hid_manager_unittest.cc
@@ -24,6 +24,8 @@ #if defined(OS_MACOSX) const uint64_t kTestDeviceIds[] = {0, 1, 2}; +#elif defined(OS_WIN) +const wchar_t* const kTestDeviceIds[] = {L"0", L"1", L"2"}; #else const char* const kTestDeviceIds[] = {"0", "1", "2"}; #endif
diff --git a/services/device/hid/hid_service_win.cc b/services/device/hid/hid_service_win.cc index 0a321482..b9a5e7a 100644 --- a/services/device/hid/hid_service_win.cc +++ b/services/device/hid/hid_service_win.cc
@@ -113,8 +113,7 @@ continue; } - std::string device_path( - base::SysWideToUTF8(device_interface_detail_data->DevicePath)); + base::string16 device_path(device_interface_detail_data->DevicePath); DCHECK(base::IsStringASCII(device_path)); AddDeviceBlocking(service, task_runner, base::ToLowerASCII(device_path)); } @@ -171,7 +170,7 @@ void HidServiceWin::AddDeviceBlocking( base::WeakPtr<HidServiceWin> service, scoped_refptr<base::SequencedTaskRunner> task_runner, - const std::string& device_path) { + const base::string16& device_path) { base::win::ScopedHandle device_handle(OpenDevice(device_path)); if (!device_handle.IsValid()) { return; @@ -267,7 +266,7 @@ } void HidServiceWin::OnDeviceAdded(const GUID& class_guid, - const std::string& device_path) { + const base::string16& device_path) { blocking_task_runner_->PostTask( FROM_HERE, base::BindOnce(&HidServiceWin::AddDeviceBlocking, @@ -275,7 +274,7 @@ } void HidServiceWin::OnDeviceRemoved(const GUID& class_guid, - const std::string& device_path) { + const base::string16& device_path) { // Execute a no-op closure on the file task runner to synchronize with any // devices that are still being enumerated. blocking_task_runner_->PostTaskAndReply( @@ -286,14 +285,14 @@ // static base::win::ScopedHandle HidServiceWin::OpenDevice( - const std::string& device_path) { + const base::string16& device_path) { base::win::ScopedHandle file( - CreateFileA(device_path.c_str(), GENERIC_WRITE | GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, NULL)); + CreateFile(device_path.c_str(), GENERIC_WRITE | GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, + FILE_FLAG_OVERLAPPED, nullptr)); if (!file.IsValid() && GetLastError() == ERROR_ACCESS_DENIED) { - file.Set(CreateFileA(device_path.c_str(), GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL)); + file.Set(CreateFile(device_path.c_str(), GENERIC_READ, FILE_SHARE_READ, + nullptr, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr)); } return file; }
diff --git a/services/device/hid/hid_service_win.h b/services/device/hid/hid_service_win.h index 9c11639..4965888 100644 --- a/services/device/hid/hid_service_win.h +++ b/services/device/hid/hid_service_win.h
@@ -22,6 +22,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/scoped_observer.h" +#include "base/strings/string16.h" #include "base/win/scoped_handle.h" #include "device/base/device_monitor_win.h" #include "services/device/hid/hid_device_info.h" @@ -58,16 +59,16 @@ static void AddDeviceBlocking( base::WeakPtr<HidServiceWin> service, scoped_refptr<base::SequencedTaskRunner> task_runner, - const std::string& device_path); + const base::string16& device_path); // DeviceMonitorWin::Observer implementation: void OnDeviceAdded(const GUID& class_guid, - const std::string& device_path) override; + const base::string16& device_path) override; void OnDeviceRemoved(const GUID& class_guid, - const std::string& device_path) override; + const base::string16& device_path) override; // Tries to open the device read-write and falls back to read-only. - static base::win::ScopedHandle OpenDevice(const std::string& device_path); + static base::win::ScopedHandle OpenDevice(const base::string16& device_path); const scoped_refptr<base::SequencedTaskRunner> task_runner_; const scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
diff --git a/services/device/public/cpp/hid/hid_device_filter_unittest.cc b/services/device/public/cpp/hid/hid_device_filter_unittest.cc index 7192ef9..8fb23c7 100644 --- a/services/device/public/cpp/hid/hid_device_filter_unittest.cc +++ b/services/device/public/cpp/hid/hid_device_filter_unittest.cc
@@ -17,6 +17,8 @@ #if defined(OS_MACOSX) const uint64_t kTestDeviceId = 42; +#elif defined(OS_WIN) +const wchar_t* kTestDeviceId = L"device1"; #else const char* kTestDeviceId = "device1"; #endif
diff --git a/services/device/serial/serial_device_enumerator.cc b/services/device/serial/serial_device_enumerator.cc index 66d5f20..dc13a1a 100644 --- a/services/device/serial/serial_device_enumerator.cc +++ b/services/device/serial/serial_device_enumerator.cc
@@ -7,9 +7,32 @@ #include <utility> #include "base/unguessable_token.h" +#include "build/build_config.h" + +#if defined(OS_LINUX) +#include "services/device/serial/serial_device_enumerator_linux.h" +#elif defined(OS_MACOSX) +#include "services/device/serial/serial_device_enumerator_mac.h" +#elif defined(OS_WIN) +#include "services/device/serial/serial_device_enumerator_win.h" +#endif namespace device { +// static +std::unique_ptr<SerialDeviceEnumerator> SerialDeviceEnumerator::Create( + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { +#if defined(OS_LINUX) + return std::make_unique<SerialDeviceEnumeratorLinux>(); +#elif defined(OS_MACOSX) + return std::make_unique<SerialDeviceEnumeratorMac>(); +#elif defined(OS_WIN) + return std::make_unique<SerialDeviceEnumeratorWin>(std::move(ui_task_runner)); +#else +#error "No implementation of SerialDeviceEnumerator on this platform." +#endif +} + SerialDeviceEnumerator::SerialDeviceEnumerator() = default; SerialDeviceEnumerator::~SerialDeviceEnumerator() = default;
diff --git a/services/device/serial/serial_device_enumerator.h b/services/device/serial/serial_device_enumerator.h index 08fb4872..95bc547 100644 --- a/services/device/serial/serial_device_enumerator.h +++ b/services/device/serial/serial_device_enumerator.h
@@ -24,7 +24,8 @@ public: using TokenPathMap = std::map<base::UnguessableToken, base::FilePath>; - static std::unique_ptr<SerialDeviceEnumerator> Create(); + static std::unique_ptr<SerialDeviceEnumerator> Create( + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); SerialDeviceEnumerator(); virtual ~SerialDeviceEnumerator();
diff --git a/services/device/serial/serial_device_enumerator_linux.cc b/services/device/serial/serial_device_enumerator_linux.cc index 7243bdc..c8f4dbc 100644 --- a/services/device/serial/serial_device_enumerator_linux.cc +++ b/services/device/serial/serial_device_enumerator_linux.cc
@@ -33,11 +33,6 @@ } // namespace -// static -std::unique_ptr<SerialDeviceEnumerator> SerialDeviceEnumerator::Create() { - return std::make_unique<SerialDeviceEnumeratorLinux>(); -} - SerialDeviceEnumeratorLinux::SerialDeviceEnumeratorLinux() { DETACH_FROM_SEQUENCE(sequence_checker_);
diff --git a/services/device/serial/serial_device_enumerator_mac.cc b/services/device/serial/serial_device_enumerator_mac.cc index a1c0c44..ffcdb2b 100644 --- a/services/device/serial/serial_device_enumerator_mac.cc +++ b/services/device/serial/serial_device_enumerator_mac.cc
@@ -104,11 +104,6 @@ } // namespace -// static -std::unique_ptr<SerialDeviceEnumerator> SerialDeviceEnumerator::Create() { - return std::make_unique<SerialDeviceEnumeratorMac>(); -} - SerialDeviceEnumeratorMac::SerialDeviceEnumeratorMac() { notify_port_.reset(IONotificationPortCreate(kIOMasterPortDefault)); CFRunLoopAddSource(CFRunLoopGetMain(),
diff --git a/services/device/serial/serial_device_enumerator_unittest.cc b/services/device/serial/serial_device_enumerator_unittest.cc index b92b128..9905e48a 100644 --- a/services/device/serial/serial_device_enumerator_unittest.cc +++ b/services/device/serial/serial_device_enumerator_unittest.cc
@@ -19,7 +19,7 @@ : task_environment_(base::test::TaskEnvironment::MainThreadType::IO) {} ~SerialDeviceEnumeratorTest() override = default; - private: + protected: base::test::TaskEnvironment task_environment_; }; @@ -27,7 +27,8 @@ // There is no guarantee that a test machine will have a serial device // available. The purpose of this test is to ensure that the process of // attempting to enumerate devices does not cause a crash. - auto enumerator = SerialDeviceEnumerator::Create(); + auto enumerator = SerialDeviceEnumerator::Create( + task_environment_.GetMainThreadTaskRunner()); ASSERT_TRUE(enumerator); std::vector<mojom::SerialPortInfoPtr> devices = enumerator->GetDevices(); }
diff --git a/services/device/serial/serial_device_enumerator_win.cc b/services/device/serial/serial_device_enumerator_win.cc index ee8b9ff..83c6253 100644 --- a/services/device/serial/serial_device_enumerator_win.cc +++ b/services/device/serial/serial_device_enumerator_win.cc
@@ -7,17 +7,19 @@ #include <windows.h> // Must be in front of other Windows header files. #include <devguid.h> +#include <ntddser.h> #include <setupapi.h> #include <stdint.h> #include <algorithm> #include <memory> #include <string> -#include <unordered_set> #include <utility> #include "base/metrics/histogram_functions.h" #include "base/numerics/ranges.h" +#include "base/scoped_generic.h" +#include "base/sequence_checker.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -30,29 +32,38 @@ namespace { +struct DevInfoScopedTraits { + static HDEVINFO InvalidValue() { return INVALID_HANDLE_VALUE; } + static void Free(HDEVINFO h) { SetupDiDestroyDeviceInfoList(h); } +}; + +using ScopedDevInfo = base::ScopedGeneric<HDEVINFO, DevInfoScopedTraits>; + // Searches the specified device info for a property with the specified key, // assigns the result to value, and returns whether the operation was // successful. bool GetProperty(HDEVINFO dev_info, - SP_DEVINFO_DATA dev_info_data, + SP_DEVINFO_DATA* dev_info_data, const int key, std::string* value) { // We don't know how much space the property's value will take up, so we call // the property retrieval function once to fetch the size of the required // value buffer, then again once we've allocated a sufficiently large buffer. DWORD buffer_size = 0; - SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data, key, nullptr, + SetupDiGetDeviceRegistryProperty(dev_info, dev_info_data, key, nullptr, nullptr, buffer_size, &buffer_size); if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return false; - std::unique_ptr<wchar_t[]> buffer(new wchar_t[buffer_size]); - if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data, key, nullptr, - reinterpret_cast<PBYTE>(buffer.get()), - buffer_size, nullptr)) + base::string16 buffer; + if (!SetupDiGetDeviceRegistryProperty( + dev_info, dev_info_data, key, nullptr, + reinterpret_cast<PBYTE>(base::WriteInto(&buffer, buffer_size)), + buffer_size, nullptr)) { return false; + } - *value = base::WideToUTF8(buffer.get()); + *value = base::UTF16ToUTF8(buffer); return true; } @@ -92,39 +103,70 @@ } // namespace -// static -std::unique_ptr<SerialDeviceEnumerator> SerialDeviceEnumerator::Create() { - return std::make_unique<SerialDeviceEnumeratorWin>(); +class SerialDeviceEnumeratorWin::UiThreadHelper + : public DeviceMonitorWin::Observer { + public: + UiThreadHelper() : task_runner_(base::SequencedTaskRunnerHandle::Get()) { + DETACH_FROM_SEQUENCE(sequence_checker_); + } + + // Disallow copy and assignment. + UiThreadHelper(UiThreadHelper&) = delete; + UiThreadHelper& operator=(UiThreadHelper&) = delete; + + virtual ~UiThreadHelper() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + } + + void Initialize(base::WeakPtr<SerialDeviceEnumeratorWin> enumerator) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + enumerator_ = std::move(enumerator); + device_observer_.Add( + DeviceMonitorWin::GetForDeviceInterface(GUID_DEVINTERFACE_COMPORT)); + } + + void OnDeviceAdded(const GUID& class_guid, + const base::string16& device_path) override { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + task_runner_->PostTask( + FROM_HERE, base::BindOnce(&SerialDeviceEnumeratorWin::OnPathAdded, + enumerator_, device_path)); + } + + void OnDeviceRemoved(const GUID& class_guid, + const base::string16& device_path) override { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + task_runner_->PostTask( + FROM_HERE, base::BindOnce(&SerialDeviceEnumeratorWin::OnPathRemoved, + enumerator_, device_path)); + } + + private: + SEQUENCE_CHECKER(sequence_checker_); + + // Weak reference to the SerialDeviceEnumeratorWin that owns this object. + // Calls on |enumerator_| must be posted to |task_runner_|. + base::WeakPtr<SerialDeviceEnumeratorWin> enumerator_; + scoped_refptr<base::SequencedTaskRunner> task_runner_; + + ScopedObserver<DeviceMonitorWin, DeviceMonitorWin::Observer> device_observer_{ + this}; +}; + +SerialDeviceEnumeratorWin::SerialDeviceEnumeratorWin( + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) + : helper_(new UiThreadHelper(), base::OnTaskRunnerDeleter(ui_task_runner)) { + // Passing a raw pointer to |helper_| is safe here because this task will + // reach the UI thread before any task to delete |helper_|. + ui_task_runner->PostTask(FROM_HERE, + base::BindOnce(&UiThreadHelper::Initialize, + base::Unretained(helper_.get()), + weak_factory_.GetWeakPtr())); + + DoInitialEnumeration(); } -SerialDeviceEnumeratorWin::SerialDeviceEnumeratorWin() {} - -SerialDeviceEnumeratorWin::~SerialDeviceEnumeratorWin() {} - -std::vector<mojom::SerialPortInfoPtr> SerialDeviceEnumeratorWin::GetDevices() { - std::vector<mojom::SerialPortInfoPtr> devices = GetDevicesNew(); - std::vector<mojom::SerialPortInfoPtr> old_devices = GetDevicesOld(); - - base::UmaHistogramSparse( - "Hardware.Serial.NewMinusOldDeviceListSize", - base::ClampToRange<int>(devices.size() - old_devices.size(), -10, 10)); - - // Add devices found from both the new and old methods of enumeration. If a - // device is found using both the new and the old enumeration method, then we - // take the device from the new enumeration method because it's able to - // collect more information. We do this by inserting the new devices first, - // because insertions are ignored if the key already exists. - std::unordered_set<base::FilePath> devices_seen; - for (const auto& device : devices) { - bool inserted = devices_seen.insert(device->path).second; - DCHECK(inserted); - } - for (auto& device : old_devices) { - if (devices_seen.insert(device->path).second) - devices.push_back(std::move(device)); - } - return devices; -} +SerialDeviceEnumeratorWin::~SerialDeviceEnumeratorWin() = default; // static base::Optional<base::FilePath> SerialDeviceEnumeratorWin::GetPath( @@ -136,83 +178,135 @@ return FixUpPortName(com_port); } -// Returns an array of devices as retrieved through the new method of -// enumerating serial devices (SetupDi). This new method gives more information -// about the devices than the old method. -std::vector<mojom::SerialPortInfoPtr> -SerialDeviceEnumeratorWin::GetDevicesNew() { - std::vector<mojom::SerialPortInfoPtr> devices; +std::vector<mojom::SerialPortInfoPtr> SerialDeviceEnumeratorWin::GetDevices() { + std::vector<mojom::SerialPortInfoPtr> ports; + ports.reserve(ports_.size()); + for (const auto& map_entry : ports_) + ports.push_back(map_entry.second->Clone()); + return ports; +} +base::Optional<base::FilePath> SerialDeviceEnumeratorWin::GetPathFromToken( + const base::UnguessableToken& token) { + auto it = ports_.find(token); + if (it == ports_.end()) + return base::nullopt; + return it->second->path; +} + +void SerialDeviceEnumeratorWin::OnPathAdded(const base::string16& device_path) { + ScopedDevInfo dev_info(SetupDiCreateDeviceInfoList(nullptr, nullptr)); + if (!dev_info.is_valid()) + return; + + if (!SetupDiOpenDeviceInterface(dev_info.get(), device_path.c_str(), 0, + nullptr)) { + return; + } + + SP_DEVINFO_DATA dev_info_data = {}; + dev_info_data.cbSize = sizeof(dev_info_data); + if (!SetupDiEnumDeviceInfo(dev_info.get(), 0, &dev_info_data)) + return; + + EnumeratePort(dev_info.get(), &dev_info_data); +} + +void SerialDeviceEnumeratorWin::OnPathRemoved( + const base::string16& device_path) { + ScopedDevInfo dev_info(SetupDiCreateDeviceInfoList(nullptr, nullptr)); + if (!dev_info.is_valid()) + return; + + if (!SetupDiOpenDeviceInterface(dev_info.get(), device_path.c_str(), 0, + nullptr)) { + return; + } + + SP_DEVINFO_DATA dev_info_data = {}; + dev_info_data.cbSize = sizeof(dev_info_data); + if (!SetupDiEnumDeviceInfo(dev_info.get(), 0, &dev_info_data)) + return; + + std::string friendly_name; + // SPDRP_FRIENDLYNAME looks like "USB_SERIAL_PORT (COM3)". + // In Windows, the COM port is the path used to uniquely identify the + // serial device. If the COM can't be found, ignore the device. + if (!GetProperty(dev_info.get(), &dev_info_data, SPDRP_FRIENDLYNAME, + &friendly_name)) { + return; + } + + base::Optional<base::FilePath> path = GetPath(friendly_name); + if (!path) + return; + + auto it = paths_.find(*path); + if (it == paths_.end()) + return; + + ports_.erase(it->second); + paths_.erase(it); +} + +void SerialDeviceEnumeratorWin::DoInitialEnumeration() { base::ScopedBlockingCall scoped_blocking_call(FROM_HERE, base::BlockingType::MAY_BLOCK); // Make a device interface query to find all serial devices. - HDEVINFO dev_info = - SetupDiGetClassDevs(&GUID_DEVCLASS_PORTS, 0, 0, DIGCF_PRESENT); - if (dev_info == INVALID_HANDLE_VALUE) - return devices; + ScopedDevInfo dev_info( + SetupDiGetClassDevs(&GUID_DEVINTERFACE_COMPORT, nullptr, 0, + DIGCF_DEVICEINTERFACE | DIGCF_PRESENT)); + if (!dev_info.is_valid()) + return; - SP_DEVINFO_DATA dev_info_data; - dev_info_data.cbSize = sizeof(SP_DEVINFO_DATA); - for (DWORD i = 0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++) { - std::string friendly_name; - // SPDRP_FRIENDLYNAME looks like "USB_SERIAL_PORT (COM3)". - // In Windows, the COM port is the path used to uniquely identify the - // serial device. If the COM can't be found, ignore the device. - if (!GetProperty(dev_info, dev_info_data, SPDRP_FRIENDLYNAME, - &friendly_name)) { - continue; - } - - base::Optional<base::FilePath> path = GetPath(friendly_name); - if (!path) - continue; - - auto info = mojom::SerialPortInfo::New(); - info->path = *path; - info->token = GetTokenFromPath(info->path); - - std::string display_name; - if (GetDisplayName(friendly_name, &display_name)) - info->display_name = std::move(display_name); - - std::string hardware_id; - // SPDRP_HARDWAREID looks like "FTDIBUS\COMPORT&VID_0403&PID_6001". - if (GetProperty(dev_info, dev_info_data, SPDRP_HARDWAREID, &hardware_id)) { - uint32_t vendor_id, product_id; - if (GetVendorID(hardware_id, &vendor_id)) { - info->has_vendor_id = true; - info->vendor_id = vendor_id; - } - if (GetProductID(hardware_id, &product_id)) { - info->has_product_id = true; - info->product_id = product_id; - } - } - - devices.push_back(std::move(info)); + SP_DEVINFO_DATA dev_info_data = {}; + dev_info_data.cbSize = sizeof(dev_info_data); + for (DWORD i = 0; SetupDiEnumDeviceInfo(dev_info.get(), i, &dev_info_data); + i++) { + EnumeratePort(dev_info.get(), &dev_info_data); } - - SetupDiDestroyDeviceInfoList(dev_info); - return devices; } -// Returns an array of devices as retrieved through the old method of -// enumerating serial devices (searching the registry). This old method gives -// less information about the devices than the new method. -std::vector<mojom::SerialPortInfoPtr> -SerialDeviceEnumeratorWin::GetDevicesOld() { - base::ScopedBlockingCall scoped_blocking_call(FROM_HERE, - base::BlockingType::MAY_BLOCK); - base::win::RegistryValueIterator iter_key( - HKEY_LOCAL_MACHINE, L"HARDWARE\\DEVICEMAP\\SERIALCOMM\\"); - std::vector<mojom::SerialPortInfoPtr> devices; - for (; iter_key.Valid(); ++iter_key) { - auto info = mojom::SerialPortInfo::New(); - info->path = FixUpPortName(base::UTF16ToASCII(iter_key.Value())); - info->token = GetTokenFromPath(info->path); - devices.push_back(std::move(info)); +void SerialDeviceEnumeratorWin::EnumeratePort(HDEVINFO dev_info, + SP_DEVINFO_DATA* dev_info_data) { + std::string friendly_name; + // SPDRP_FRIENDLYNAME looks like "USB_SERIAL_PORT (COM3)". + // In Windows, the COM port is the path used to uniquely identify the + // serial device. If the COM can't be found, ignore the device. + if (!GetProperty(dev_info, dev_info_data, SPDRP_FRIENDLYNAME, + &friendly_name)) { + return; } - return devices; + + base::Optional<base::FilePath> path = GetPath(friendly_name); + if (!path) + return; + + auto info = mojom::SerialPortInfo::New(); + info->path = *path; + base::UnguessableToken token = base::UnguessableToken::Create(); + info->token = token; + + std::string display_name; + if (GetDisplayName(friendly_name, &display_name)) + info->display_name = std::move(display_name); + + std::string hardware_id; + // SPDRP_HARDWAREID looks like "FTDIBUS\COMPORT&VID_0403&PID_6001". + if (GetProperty(dev_info, dev_info_data, SPDRP_HARDWAREID, &hardware_id)) { + uint32_t vendor_id, product_id; + if (GetVendorID(hardware_id, &vendor_id)) { + info->has_vendor_id = true; + info->vendor_id = vendor_id; + } + if (GetProductID(hardware_id, &product_id)) { + info->has_product_id = true; + info->product_id = product_id; + } + } + + ports_[token] = std::move(info); + paths_.insert(std::make_pair(*path, token)); } } // namespace device
diff --git a/services/device/serial/serial_device_enumerator_win.h b/services/device/serial/serial_device_enumerator_win.h index dbc875a..e38e35df 100644 --- a/services/device/serial/serial_device_enumerator_win.h +++ b/services/device/serial/serial_device_enumerator_win.h
@@ -5,10 +5,10 @@ #ifndef SERVICES_DEVICE_SERIAL_SERIAL_DEVICE_ENUMERATOR_WIN_H_ #define SERVICES_DEVICE_SERIAL_SERIAL_DEVICE_ENUMERATOR_WIN_H_ -#include <vector> - #include "base/macros.h" -#include "base/optional.h" +#include "base/scoped_observer.h" +#include "base/win/windows_types.h" +#include "device/base/device_monitor_win.h" #include "services/device/serial/serial_device_enumerator.h" namespace device { @@ -16,21 +16,35 @@ // Discovers and enumerates serial devices available to the host. class SerialDeviceEnumeratorWin : public SerialDeviceEnumerator { public: - SerialDeviceEnumeratorWin(); + SerialDeviceEnumeratorWin( + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); ~SerialDeviceEnumeratorWin() override; - // Implementation for SerialDeviceEnumerator. - std::vector<mojom::SerialPortInfoPtr> GetDevices() override; - // Searches for the COM port in the device's friendly name and returns the // appropriate device path or nullopt if the input did not contain a valid // name. static base::Optional<base::FilePath> GetPath( const std::string& friendly_name); + // SerialDeviceEnumerator + std::vector<mojom::SerialPortInfoPtr> GetDevices() override; + base::Optional<base::FilePath> GetPathFromToken( + const base::UnguessableToken& token) override; + + void OnPathAdded(const base::string16& device_path); + void OnPathRemoved(const base::string16& device_path); + private: - std::vector<mojom::SerialPortInfoPtr> GetDevicesNew(); - std::vector<mojom::SerialPortInfoPtr> GetDevicesOld(); + class UiThreadHelper; + + void DoInitialEnumeration(); + void EnumeratePort(HDEVINFO dev_info, SP_DEVINFO_DATA* dev_info_data); + + std::map<base::UnguessableToken, mojom::SerialPortInfoPtr> ports_; + std::map<base::FilePath, base::UnguessableToken> paths_; + + std::unique_ptr<UiThreadHelper, base::OnTaskRunnerDeleter> helper_; + base::WeakPtrFactory<SerialDeviceEnumeratorWin> weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(SerialDeviceEnumeratorWin); };
diff --git a/services/device/serial/serial_io_handler_win.cc b/services/device/serial/serial_io_handler_win.cc index 43d5cb5..1501ce90 100644 --- a/services/device/serial/serial_io_handler_win.cc +++ b/services/device/serial/serial_io_handler_win.cc
@@ -175,7 +175,7 @@ private: // DeviceMonitorWin::Observer void OnDeviceRemoved(const GUID& class_guid, - const std::string& device_path) override { + const base::string16& device_path) override { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); io_thread_task_runner_->PostTask( FROM_HERE, base::BindOnce(&SerialIoHandlerWin::OnDeviceRemoved, @@ -192,7 +192,7 @@ DISALLOW_COPY_AND_ASSIGN(UiThreadHelper); }; -void SerialIoHandlerWin::OnDeviceRemoved(const std::string& device_path) { +void SerialIoHandlerWin::OnDeviceRemoved(const base::string16& device_path) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DeviceInfoQueryWin device_info_query;
diff --git a/services/device/serial/serial_io_handler_win.h b/services/device/serial/serial_io_handler_win.h index 2b8bccf..13bb3ab 100644 --- a/services/device/serial/serial_io_handler_win.h +++ b/services/device/serial/serial_io_handler_win.h
@@ -11,6 +11,7 @@ #include "base/macros.h" #include "base/message_loop/message_pump_for_io.h" #include "base/single_thread_task_runner.h" +#include "base/strings/string16.h" #include "base/threading/thread_task_runner_handle.h" #include "services/device/serial/serial_io_handler.h" @@ -46,7 +47,7 @@ DWORD bytes_transfered, DWORD error) override; - void OnDeviceRemoved(const std::string& device_path); + void OnDeviceRemoved(const base::string16& device_path); // Context used for asynchronous WaitCommEvent calls. std::unique_ptr<base::MessagePumpForIO::IOContext> comm_context_;
diff --git a/services/device/serial/serial_port_manager_impl.cc b/services/device/serial/serial_port_manager_impl.cc index 0621f153..54be83a0b 100644 --- a/services/device/serial/serial_port_manager_impl.cc +++ b/services/device/serial/serial_port_manager_impl.cc
@@ -36,7 +36,7 @@ void SerialPortManagerImpl::GetDevices(GetDevicesCallback callback) { if (!enumerator_) - enumerator_ = SerialDeviceEnumerator::Create(); + enumerator_ = SerialDeviceEnumerator::Create(ui_task_runner_); std::move(callback).Run(enumerator_->GetDevices()); } @@ -45,7 +45,7 @@ mojo::PendingReceiver<mojom::SerialPort> receiver, mojo::PendingRemote<mojom::SerialPortConnectionWatcher> watcher) { if (!enumerator_) - enumerator_ = SerialDeviceEnumerator::Create(); + enumerator_ = SerialDeviceEnumerator::Create(ui_task_runner_); base::Optional<base::FilePath> path = enumerator_->GetPathFromToken(token); if (path) { io_task_runner_->PostTask(
diff --git a/services/device/usb/usb_device_handle_win.cc b/services/device/usb/usb_device_handle_win.cc index 874d124a..35efed0 100644 --- a/services/device/usb/usb_device_handle_win.cc +++ b/services/device/usb/usb_device_handle_win.cc
@@ -523,7 +523,7 @@ WINUSB_INTERFACE_HANDLE handle; if (interface->first_interface == interface->interface_number) { if (!function_handle_.IsValid()) { - function_handle_.Set(CreateFileA( + function_handle_.Set(CreateFile( device_->device_path().c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr));
diff --git a/services/device/usb/usb_device_win.cc b/services/device/usb/usb_device_win.cc index 708b511..09a5dd9 100644 --- a/services/device/usb/usb_device_win.cc +++ b/services/device/usb/usb_device_win.cc
@@ -24,11 +24,11 @@ const uint16_t kUsbVersion2_1 = 0x0210; } // namespace -UsbDeviceWin::UsbDeviceWin(const std::string& device_path, - const std::string& hub_path, +UsbDeviceWin::UsbDeviceWin(const base::string16& device_path, + const base::string16& hub_path, uint32_t bus_number, uint32_t port_number, - const std::string& driver_name) + const base::string16& driver_name) : UsbDevice(bus_number, port_number), device_path_(device_path), hub_path_(hub_path), @@ -40,7 +40,7 @@ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); scoped_refptr<UsbDeviceHandle> device_handle; - if (base::EqualsCaseInsensitiveASCII(driver_name_, "winusb")) + if (base::EqualsCaseInsensitiveASCII(driver_name_, L"winusb")) device_handle = new UsbDeviceHandleWin(this, false); // TODO: Support composite devices. // else if (base::EqualsCaseInsensitiveASCII(driver_name_, "usbccgp")) @@ -55,8 +55,8 @@ scoped_refptr<UsbDeviceHandle> device_handle; base::win::ScopedHandle handle( - CreateFileA(hub_path_.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, - OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr)); + CreateFile(hub_path_.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, + OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr)); if (handle.IsValid()) { device_handle = new UsbDeviceHandleWin(this, std::move(handle)); } else {
diff --git a/services/device/usb/usb_device_win.h b/services/device/usb/usb_device_win.h index 7d35c4e..6cb5b2b 100644 --- a/services/device/usb/usb_device_win.h +++ b/services/device/usb/usb_device_win.h
@@ -11,6 +11,7 @@ #include "base/macros.h" #include "base/sequence_checker.h" +#include "base/strings/string16.h" #include "services/device/usb/usb_device.h" namespace device { @@ -27,16 +28,16 @@ friend class UsbDeviceHandleWin; // Called by UsbServiceWin only. - UsbDeviceWin(const std::string& device_path, - const std::string& hub_path, + UsbDeviceWin(const base::string16& device_path, + const base::string16& hub_path, uint32_t bus_number, uint32_t port_number, - const std::string& driver_name); + const base::string16& driver_name); ~UsbDeviceWin() override; - const std::string& device_path() const { return device_path_; } - const std::string& driver_name() const { return driver_name_; } + const base::string16& device_path() const { return device_path_; } + const base::string16& driver_name() const { return driver_name_; } // Opens the device's parent hub in order to read the device, configuration // and string descriptors. @@ -63,9 +64,9 @@ private: SEQUENCE_CHECKER(sequence_checker_); - const std::string device_path_; - const std::string hub_path_; - const std::string driver_name_; + const base::string16 device_path_; + const base::string16 hub_path_; + const base::string16 driver_name_; DISALLOW_COPY_AND_ASSIGN(UsbDeviceWin); };
diff --git a/services/device/usb/usb_service_impl.cc b/services/device/usb/usb_service_impl.cc index af44d61..3cb6bee 100644 --- a/services/device/usb/usb_service_impl.cc +++ b/services/device/usb/usb_service_impl.cc
@@ -50,7 +50,7 @@ #if defined(OS_WIN) -bool IsWinUsbInterface(const std::string& device_path) { +bool IsWinUsbInterface(const base::string16& device_path) { DeviceInfoQueryWin device_info_query; if (!device_info_query.device_info_list_valid()) { USB_PLOG(ERROR) << "Failed to create a device information set"; @@ -97,7 +97,7 @@ } base::Optional<std::vector<ScopedLibusbDeviceRef>> GetDeviceListBlocking( - const std::string& new_device_path, + const base::string16& new_device_path, scoped_refptr<UsbContext> usb_context) { base::ScopedBlockingCall scoped_blocking_call(FROM_HERE, base::BlockingType::MAY_BLOCK); @@ -267,20 +267,20 @@ #if defined(OS_WIN) void UsbServiceImpl::OnDeviceAdded(const GUID& class_guid, - const std::string& device_path) { + const base::string16& device_path) { // Only the root node of a composite USB device has the class GUID // GUID_DEVINTERFACE_USB_DEVICE but we want to wait until WinUSB is loaded. // This first pass filter will catch anything that's sitting on the USB bus // (including devices on 3rd party USB controllers) to avoid the more // expensive driver check that needs to be done on the FILE thread. - if (device_path.find("usb") != std::string::npos) { + if (device_path.find(L"usb") != base::string16::npos) { pending_path_enumerations_.push(device_path); RefreshDevices(); } } void UsbServiceImpl::OnDeviceRemoved(const GUID& class_guid, - const std::string& device_path) { + const base::string16& device_path) { // The root USB device node is removed last. if (class_guid == GUID_DEVINTERFACE_USB_DEVICE) { RefreshDevices(); @@ -326,7 +326,7 @@ enumeration_in_progress_ = true; DCHECK(devices_being_enumerated_.empty()); - std::string device_path; + base::string16 device_path; if (!pending_path_enumerations_.empty()) { device_path = pending_path_enumerations_.front(); pending_path_enumerations_.pop();
diff --git a/services/device/usb/usb_service_impl.h b/services/device/usb/usb_service_impl.h index c6c8c29..669f857 100644 --- a/services/device/usb/usb_service_impl.h +++ b/services/device/usb/usb_service_impl.h
@@ -17,6 +17,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/optional.h" +#include "base/strings/string16.h" #include "build/build_config.h" #include "services/device/usb/scoped_libusb_device_ref.h" #include "services/device/usb/usb_context.h" @@ -52,9 +53,9 @@ #if defined(OS_WIN) // device::DeviceMonitorWin::Observer implementation void OnDeviceAdded(const GUID& class_guid, - const std::string& device_path) override; + const base::string16& device_path) override; void OnDeviceRemoved(const GUID& class_guid, - const std::string& device_path) override; + const base::string16& device_path) override; #endif // OS_WIN void OnUsbContext(scoped_refptr<UsbContext> context); @@ -100,7 +101,7 @@ // Enumeration callbacks are queued until an enumeration completes. bool enumeration_ready_ = false; bool enumeration_in_progress_ = false; - base::queue<std::string> pending_path_enumerations_; + base::queue<base::string16> pending_path_enumerations_; std::vector<GetDevicesCallback> pending_enumeration_callbacks_; // The map from libusb_device to UsbDeviceImpl. The key is a weak pointer to
diff --git a/services/device/usb/usb_service_win.cc b/services/device/usb/usb_service_win.cc index bb14c14..d5543ea7 100644 --- a/services/device/usb/usb_service_win.cc +++ b/services/device/usb/usb_service_win.cc
@@ -58,7 +58,7 @@ bool GetDeviceStringProperty(HDEVINFO dev_info, SP_DEVINFO_DATA* dev_info_data, const DEVPROPKEY& property, - std::string* property_buffer) { + base::string16* buffer) { DEVPROPTYPE property_type; DWORD required_size; if (SetupDiGetDeviceProperty(dev_info, dev_info_data, &property, @@ -68,25 +68,23 @@ return false; } - base::string16 buffer16; if (!SetupDiGetDeviceProperty( dev_info, dev_info_data, &property, &property_type, - reinterpret_cast<PBYTE>(base::WriteInto(&buffer16, required_size)), + reinterpret_cast<PBYTE>(base::WriteInto(buffer, required_size)), required_size, nullptr, 0)) { return false; } - *property_buffer = base::UTF16ToUTF8(buffer16); return true; } bool GetDeviceInterfaceDetails(HDEVINFO dev_info, SP_DEVICE_INTERFACE_DATA* device_interface_data, - std::string* device_path, + base::string16* device_path, uint32_t* bus_number, uint32_t* port_number, - std::string* parent_instance_id, - std::string* service_name) { + base::string16* parent_instance_id, + base::string16* service_name) { DWORD required_size = 0; if (SetupDiGetDeviceInterfaceDetail(dev_info, device_interface_data, nullptr, 0, &required_size, nullptr) || @@ -110,8 +108,7 @@ } if (device_path) { - *device_path = - base::SysWideToUTF8(device_interface_detail_data->DevicePath); + *device_path = base::string16(device_interface_detail_data->DevicePath); } if (bus_number) { @@ -147,7 +144,7 @@ // Windows pads this string with a variable number of NUL bytes for no // discernible reason. - size_t end = service_name->find_last_not_of('\0'); + size_t end = service_name->find_last_not_of(L'\0'); if (end != std::string::npos) service_name->erase(end + 1); } @@ -155,11 +152,11 @@ return true; } -bool GetHubDevicePath(const std::string& instance_id, - std::string* device_path) { +bool GetHubDevicePath(const base::string16& instance_id, + base::string16* device_path) { ScopedDevInfo dev_info( - SetupDiGetClassDevsA(&GUID_DEVINTERFACE_USB_HUB, instance_id.c_str(), 0, - DIGCF_DEVICEINTERFACE | DIGCF_PRESENT)); + SetupDiGetClassDevs(&GUID_DEVINTERFACE_USB_HUB, instance_id.c_str(), 0, + DIGCF_DEVICEINTERFACE | DIGCF_PRESENT)); if (!dev_info.is_valid()) { USB_PLOG(ERROR) << "SetupDiGetClassDevs"; return false; @@ -205,20 +202,20 @@ &GUID_DEVINTERFACE_USB_DEVICE, i, &device_interface_data); ++i) { - std::string device_path; + base::string16 device_path; uint32_t bus_number; uint32_t port_number; - std::string parent_instance_id; - std::string service_name; + base::string16 parent_instance_id; + base::string16 service_name; if (!GetDeviceInterfaceDetails(dev_info.get(), &device_interface_data, &device_path, &bus_number, &port_number, &parent_instance_id, &service_name)) { continue; } - std::string& hub_path = hub_paths_[parent_instance_id]; + base::string16& hub_path = hub_paths_[parent_instance_id]; if (hub_path.empty()) { - std::string parent_path; + base::string16 parent_path; if (!GetHubDevicePath(parent_instance_id, &parent_path)) continue; @@ -238,7 +235,7 @@ FROM_HERE, base::BindOnce(&UsbServiceWin::HelperStarted, service_)); } - void EnumerateDevicePath(const std::string& device_path) { + void EnumerateDevicePath(const base::string16& device_path) { ScopedDevInfo dev_info( SetupDiGetClassDevs(&GUID_DEVINTERFACE_USB_DEVICE, nullptr, 0, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT)); @@ -249,25 +246,25 @@ SP_DEVICE_INTERFACE_DATA device_interface_data; device_interface_data.cbSize = sizeof(device_interface_data); - if (!SetupDiOpenDeviceInterfaceA(dev_info.get(), device_path.c_str(), 0, - &device_interface_data)) { + if (!SetupDiOpenDeviceInterface(dev_info.get(), device_path.c_str(), 0, + &device_interface_data)) { USB_PLOG(ERROR) << "Failed to add device interface: " << device_path; return; } uint32_t bus_number; uint32_t port_number; - std::string parent_instance_id; - std::string service_name; + base::string16 parent_instance_id; + base::string16 service_name; if (!GetDeviceInterfaceDetails(dev_info.get(), &device_interface_data, nullptr, &bus_number, &port_number, &parent_instance_id, &service_name)) { return; } - std::string& hub_path = hub_paths_[parent_instance_id]; + base::string16& hub_path = hub_paths_[parent_instance_id]; if (hub_path.empty()) { - std::string parent_path; + base::string16 parent_path; if (!GetHubDevicePath(parent_instance_id, &parent_path)) return; @@ -281,7 +278,7 @@ } private: - std::unordered_map<std::string, std::string> hub_paths_; + std::unordered_map<base::string16, base::string16> hub_paths_; // Calls back to |service_| must be posted to |service_task_runner_|, which // runs tasks on the thread where that object lives. @@ -318,14 +315,14 @@ } void UsbServiceWin::OnDeviceAdded(const GUID& class_guid, - const std::string& device_path) { + const base::string16& device_path) { blocking_task_runner_->PostTask( FROM_HERE, base::BindOnce(&BlockingTaskRunnerHelper::EnumerateDevicePath, base::Unretained(helper_.get()), device_path)); } void UsbServiceWin::OnDeviceRemoved(const GUID& class_guid, - const std::string& device_path) { + const base::string16& device_path) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); auto by_path_it = devices_by_path_.find(device_path); if (by_path_it == devices_by_path_.end()) @@ -359,11 +356,11 @@ } } -void UsbServiceWin::CreateDeviceObject(const std::string& device_path, - const std::string& hub_path, +void UsbServiceWin::CreateDeviceObject(const base::string16& device_path, + const base::string16& hub_path, uint32_t bus_number, uint32_t port_number, - const std::string& driver_name) { + const base::string16& driver_name) { // Devices that appear during initial enumeration are gathered into the first // result returned by GetDevices() and prevent device add/remove notifications // from being sent.
diff --git a/services/device/usb/usb_service_win.h b/services/device/usb/usb_service_win.h index 3b53158..3d154a3 100644 --- a/services/device/usb/usb_service_win.h +++ b/services/device/usb/usb_service_win.h
@@ -14,6 +14,7 @@ #include "base/memory/weak_ptr.h" #include "base/scoped_observer.h" #include "base/sequenced_task_runner.h" +#include "base/strings/string16.h" #include "device/base/device_monitor_win.h" #include "services/device/usb/usb_device_win.h" @@ -33,17 +34,17 @@ // device::DeviceMonitorWin::Observer implementation void OnDeviceAdded(const GUID& class_guid, - const std::string& device_path) override; + const base::string16& device_path) override; void OnDeviceRemoved(const GUID& class_guid, - const std::string& device_path) override; + const base::string16& device_path) override; // Methods called by BlockingThreadHelper void HelperStarted(); - void CreateDeviceObject(const std::string& device_path, - const std::string& hub_path, + void CreateDeviceObject(const base::string16& device_path, + const base::string16& hub_path, uint32_t bus_number, uint32_t port_number, - const std::string& driver_name); + const base::string16& driver_name); void DeviceReady(scoped_refptr<UsbDeviceWin> device, bool success); @@ -58,7 +59,8 @@ scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; std::unique_ptr<BlockingTaskRunnerHelper, base::OnTaskRunnerDeleter> helper_; - std::unordered_map<std::string, scoped_refptr<UsbDeviceWin>> devices_by_path_; + std::unordered_map<base::string16, scoped_refptr<UsbDeviceWin>> + devices_by_path_; ScopedObserver<DeviceMonitorWin, DeviceMonitorWin::Observer> device_observer_;
diff --git a/services/media_session/audio_focus_manager.cc b/services/media_session/audio_focus_manager.cc index 3ce95ac2..4aa0146d 100644 --- a/services/media_session/audio_focus_manager.cc +++ b/services/media_session/audio_focus_manager.cc
@@ -91,7 +91,7 @@ void AudioFocusManager::RequestAudioFocus( mojo::PendingReceiver<mojom::AudioFocusRequestClient> receiver, - mojo::PendingRemote<mojom::MediaSession> media_session, + mojo::PendingRemote<mojom::MediaSession> session, mojom::MediaSessionInfoPtr session_info, mojom::AudioFocusType type, RequestAudioFocusCallback callback) { @@ -100,7 +100,7 @@ RequestAudioFocusInternal( std::make_unique<AudioFocusRequest>( weak_ptr_factory_.GetWeakPtr(), std::move(receiver), - std::move(media_session), std::move(session_info), type, request_id, + std::move(session), std::move(session_info), type, request_id, GetBindingSourceName(), base::UnguessableToken::Create(), GetBindingIdentity()), type); @@ -111,7 +111,7 @@ void AudioFocusManager::RequestGroupedAudioFocus( const base::UnguessableToken& request_id, mojo::PendingReceiver<mojom::AudioFocusRequestClient> receiver, - mojo::PendingRemote<mojom::MediaSession> media_session, + mojo::PendingRemote<mojom::MediaSession> session, mojom::MediaSessionInfoPtr session_info, mojom::AudioFocusType type, const base::UnguessableToken& group_id, @@ -124,7 +124,7 @@ RequestAudioFocusInternal( std::make_unique<AudioFocusRequest>( weak_ptr_factory_.GetWeakPtr(), std::move(receiver), - std::move(media_session), std::move(session_info), type, request_id, + std::move(session), std::move(session_info), type, request_id, GetBindingSourceName(), group_id, GetBindingIdentity()), type);
diff --git a/services/media_session/audio_focus_manager.h b/services/media_session/audio_focus_manager.h index ea393a5..1c0614d 100644 --- a/services/media_session/audio_focus_manager.h +++ b/services/media_session/audio_focus_manager.h
@@ -52,14 +52,14 @@ // mojom::AudioFocusManager. void RequestAudioFocus( mojo::PendingReceiver<mojom::AudioFocusRequestClient> receiver, - mojo::PendingRemote<mojom::MediaSession> media_session, + mojo::PendingRemote<mojom::MediaSession> session, mojom::MediaSessionInfoPtr session_info, mojom::AudioFocusType type, RequestAudioFocusCallback callback) override; void RequestGroupedAudioFocus( const base::UnguessableToken& request_id, mojo::PendingReceiver<mojom::AudioFocusRequestClient> receiver, - mojo::PendingRemote<mojom::MediaSession> media_session, + mojo::PendingRemote<mojom::MediaSession> session, mojom::MediaSessionInfoPtr session_info, mojom::AudioFocusType type, const base::UnguessableToken& group_id,
diff --git a/services/media_session/public/mojom/audio_focus.mojom b/services/media_session/public/mojom/audio_focus.mojom index 45e04a4..391cf084 100644 --- a/services/media_session/public/mojom/audio_focus.mojom +++ b/services/media_session/public/mojom/audio_focus.mojom
@@ -93,28 +93,28 @@ // Next Method ID: 9 // Deprecated method IDs: 3 interface AudioFocusManager { - // Requests audio focus with |type| for the |media_session| with - // |session_info|. Media sessions should provide a |request| that will - // provide an AudioFocusRequestClient that can be used to control this - // request. The callback will resolve with the id of the request when - // audio focus has been granted. + // Requests audio focus with |type| for the |session| with |session_info|. + // Media sessions should provide a |request| that will provide an + // AudioFocusRequestClient that can be used to control this request. The + // callback will resolve with the id of the request when audio focus has been + // granted. RequestAudioFocus@0(pending_receiver<AudioFocusRequestClient> client, - pending_remote<MediaSession> media_session, + pending_remote<MediaSession> session, MediaSessionInfo session_info, AudioFocusType type) => (mojo_base.mojom.UnguessableToken request_id); - // Requests audio focus with |type| for the |media_session| with - // |session_info|. Media sessions should provide a |request| that will - // provide an AudioFocusRequestClient that can be used to control this - // request. |request_id| should be generated by the client and should be - // unique. If it is not valid then the request will fail. |group_id| is - // used for grouping sessions together. This is when a group of sessions - // will share audio focus. Returns whether the request succeeded. + // Requests audio focus with |type| for the |session| with |session_info|. + // Media sessions should provide a |request| that will provide an + // AudioFocusRequestClient that can be used to control this request. + // |request_id| should be generated by the client and should be unique. If it + // is not valid then the request will fail. |group_id| is used for grouping + // sessions together. This is when a group of sessions will share audio focus. + // Returns whether the request succeeded. [MinVersion=4] RequestGroupedAudioFocus@4( mojo_base.mojom.UnguessableToken request_id, pending_receiver<AudioFocusRequestClient> client, - pending_remote<MediaSession> media_session, + pending_remote<MediaSession> session, MediaSessionInfo session_info, AudioFocusType type, mojo_base.mojom.UnguessableToken group_id) => (bool success);
diff --git a/services/network/network_service_proxy_delegate.cc b/services/network/network_service_proxy_delegate.cc index 035dd012..c1664fe4c 100644 --- a/services/network/network_service_proxy_delegate.cc +++ b/services/network/network_service_proxy_delegate.cc
@@ -218,14 +218,14 @@ void NetworkServiceProxyDelegate::OnFallback(const net::ProxyServer& bad_proxy, int net_error) {} -void NetworkServiceProxyDelegate::OnBeforeHttp1TunnelRequest( +void NetworkServiceProxyDelegate::OnBeforeTunnelRequest( const net::ProxyServer& proxy_server, net::HttpRequestHeaders* extra_headers) { if (IsInProxyConfig(proxy_server)) MergeRequestHeaders(extra_headers, proxy_config_->connect_tunnel_headers); } -net::Error NetworkServiceProxyDelegate::OnHttp1TunnelHeadersReceived( +net::Error NetworkServiceProxyDelegate::OnTunnelHeadersReceived( const net::ProxyServer& proxy_server, const net::HttpResponseHeaders& response_headers) { return net::OK; @@ -280,8 +280,9 @@ return true; for (const auto& config : previous_proxy_configs_) { - if (RulesContainsProxy(config->rules, proxy_server)) + if (RulesContainsProxy(config->rules, proxy_server)) { return true; + } } return false;
diff --git a/services/network/network_service_proxy_delegate.h b/services/network/network_service_proxy_delegate.h index 75bb881..f1a11b0 100644 --- a/services/network/network_service_proxy_delegate.h +++ b/services/network/network_service_proxy_delegate.h
@@ -52,10 +52,9 @@ const net::ProxyRetryInfoMap& proxy_retry_info, net::ProxyInfo* result) override; void OnFallback(const net::ProxyServer& bad_proxy, int net_error) override; - void OnBeforeHttp1TunnelRequest( - const net::ProxyServer& proxy_server, - net::HttpRequestHeaders* extra_headers) override; - net::Error OnHttp1TunnelHeadersReceived( + void OnBeforeTunnelRequest(const net::ProxyServer& proxy_server, + net::HttpRequestHeaders* extra_headers) override; + net::Error OnTunnelHeadersReceived( const net::ProxyServer& proxy_server, const net::HttpResponseHeaders& response_headers) override;
diff --git a/services/network/network_service_proxy_delegate_unittest.cc b/services/network/network_service_proxy_delegate_unittest.cc index fd4b18e1..7b27f4e 100644 --- a/services/network/network_service_proxy_delegate_unittest.cc +++ b/services/network/network_service_proxy_delegate_unittest.cc
@@ -312,7 +312,7 @@ net::HttpRequestHeaders headers; auto proxy_server = net::ProxyServer::FromPacString("HTTPS proxy"); - delegate->OnBeforeHttp1TunnelRequest(proxy_server, &headers); + delegate->OnBeforeTunnelRequest(proxy_server, &headers); EXPECT_FALSE(headers.HasHeader("pre_cache")); EXPECT_FALSE(headers.HasHeader("post_cache"));
diff --git a/skia/ext/benchmarking_canvas.cc b/skia/ext/benchmarking_canvas.cc index 252d8883..efff1c2 100644 --- a/skia/ext/benchmarking_canvas.cc +++ b/skia/ext/benchmarking_canvas.cc
@@ -241,13 +241,6 @@ return std::move(val); } -std::unique_ptr<base::Value> AsValue(const SkBitmap& bitmap) { - std::unique_ptr<base::DictionaryValue> val(new base::DictionaryValue()); - val->Set("size", AsValue(SkSize::Make(bitmap.width(), bitmap.height()))); - - return std::move(val); -} - std::unique_ptr<base::Value> AsValue(const SkImage& image) { std::unique_ptr<base::DictionaryValue> val(new base::DictionaryValue()); val->Set("size", AsValue(SkSize::Make(image.width(), image.height()))); @@ -578,32 +571,6 @@ INHERITED::onDrawPicture(picture, matrix, op.paint()); } -void BenchmarkingCanvas::onDrawBitmap(const SkBitmap& bitmap, - SkScalar left, - SkScalar top, - const SkPaint* paint) { - AutoOp op(this, "DrawBitmap", paint); - op.addParam("bitmap", AsValue(bitmap)); - op.addParam("left", AsValue(left)); - op.addParam("top", AsValue(top)); - - INHERITED::onDrawBitmap(bitmap, left, top, op.paint()); -} - -void BenchmarkingCanvas::onDrawBitmapRect(const SkBitmap& bitmap, - const SkRect* src, - const SkRect& dst, - const SkPaint* paint, - SrcRectConstraint constraint) { - AutoOp op(this, "DrawBitmapRect", paint); - op.addParam("bitmap", AsValue(bitmap)); - if (src) - op.addParam("src", AsValue(*src)); - op.addParam("dst", AsValue(dst)); - - INHERITED::onDrawBitmapRect(bitmap, src, dst, op.paint(), constraint); -} - void BenchmarkingCanvas::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
diff --git a/skia/ext/benchmarking_canvas.h b/skia/ext/benchmarking_canvas.h index c06f275..cb52c42 100644 --- a/skia/ext/benchmarking_canvas.h +++ b/skia/ext/benchmarking_canvas.h
@@ -54,9 +54,6 @@ void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override; - void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override; - void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, - const SkPaint*, SrcRectConstraint) override; void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override; void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, const SkPaint*, SrcRectConstraint) override;
diff --git a/testing/buildbot/chrome.ci.json b/testing/buildbot/chrome.ci.json index fa43420..afa2027 100644 --- a/testing/buildbot/chrome.ci.json +++ b/testing/buildbot/chrome.ci.json
@@ -3659,6 +3659,144 @@ } ] }, + "linux-rel-swarming-staging": { + "gtest_tests": [ + { + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "2", + "os": "Ubuntu-16.04", + "pool": "chromium.tests.template" + } + ], + "service_account": "chromium-tester-dev@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "base_unittests", + "test_target": "//base:base_unittests" + }, + { + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "8", + "os": "Ubuntu-16.04", + "pool": "chromium.tests.template" + } + ], + "service_account": "chromium-tester-dev@chops-service-accounts.iam.gserviceaccount.com", + "shards": 2 + }, + "test": "browser_tests", + "test_target": "//chrome/test:browser_tests" + }, + { + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "8", + "os": "Ubuntu-16.04", + "pool": "chromium.tests.template" + } + ], + "service_account": "chromium-tester-dev@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "content_browsertests", + "test_target": "//content/test:content_browsertests" + }, + { + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "2", + "os": "Ubuntu-16.04", + "pool": "chromium.tests.template" + } + ], + "service_account": "chromium-tester-dev@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "content_unittests", + "test_target": "//content/test:content_unittests" + }, + { + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "8", + "os": "Ubuntu-16.04", + "pool": "chromium.tests.template" + } + ], + "service_account": "chromium-tester-dev@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "interactive_ui_tests", + "test_target": "//chrome/test:interactive_ui_tests" + }, + { + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "8", + "os": "Ubuntu-16.04", + "pool": "chromium.tests.template" + } + ], + "service_account": "chromium-tester-dev@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "net_unittests", + "test_target": "//net:net_unittests" + }, + { + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "2", + "os": "Ubuntu-16.04", + "pool": "chromium.tests.template" + } + ], + "service_account": "chromium-tester-dev@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "unit_tests", + "test_target": "//chrome/test:unit_tests" + } + ] + }, "mac-chrome": { "additional_compile_targets": [ "chrome"
diff --git a/testing/buildbot/chromium.android.json b/testing/buildbot/chromium.android.json index c3db684f..823f99a 100644 --- a/testing/buildbot/chromium.android.json +++ b/testing/buildbot/chromium.android.json
@@ -1758,6 +1758,12 @@ "test_target": "//components/background_task_scheduler:components_background_task_scheduler_junit_tests" }, { + "name": "components_embedder_support_junit_tests", + "swarming": {}, + "test": "components_embedder_support_junit_tests", + "test_target": "//components/embedder_support/android:components_embedder_support_junit_tests" + }, + { "name": "components_gcm_driver_junit_tests", "swarming": {}, "test": "components_gcm_driver_junit_tests", @@ -25903,6 +25909,12 @@ "test_target": "//components/background_task_scheduler:components_background_task_scheduler_junit_tests" }, { + "name": "components_embedder_support_junit_tests", + "swarming": {}, + "test": "components_embedder_support_junit_tests", + "test_target": "//components/embedder_support/android:components_embedder_support_junit_tests" + }, + { "name": "components_gcm_driver_junit_tests", "swarming": {}, "test": "components_gcm_driver_junit_tests", @@ -37387,6 +37399,13 @@ }, { "isolate_coverage_data": true, + "name": "components_embedder_support_junit_tests", + "swarming": {}, + "test": "components_embedder_support_junit_tests", + "test_target": "//components/embedder_support/android:components_embedder_support_junit_tests" + }, + { + "isolate_coverage_data": true, "name": "components_gcm_driver_junit_tests", "swarming": {}, "test": "components_gcm_driver_junit_tests",
diff --git a/testing/buildbot/chromium.ci.json b/testing/buildbot/chromium.ci.json index 4347c18..75f5735 100644 --- a/testing/buildbot/chromium.ci.json +++ b/testing/buildbot/chromium.ci.json
@@ -1147,36 +1147,6 @@ "--browser=release", "--passthrough", "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:0a2e", - "os": "mac-intel-stable" - } - ], - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu", "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" ], @@ -1461,38 +1431,6 @@ "--browser=release", "--passthrough", "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "1002:6821", - "hidpi": "1", - "os": "mac-amd-stable", - "pool": "chromium.tests.gpu.template" - } - ], - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu", "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" ], @@ -13104,6 +13042,12 @@ "test_target": "//components/background_task_scheduler:components_background_task_scheduler_junit_tests" }, { + "name": "components_embedder_support_junit_tests", + "swarming": {}, + "test": "components_embedder_support_junit_tests", + "test_target": "//components/embedder_support/android:components_embedder_support_junit_tests" + }, + { "name": "components_gcm_driver_junit_tests", "swarming": {}, "test": "components_gcm_driver_junit_tests", @@ -57532,6 +57476,11 @@ }, "swarming": { "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "8" + } + ], "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", "shards": 20 }, @@ -60891,36 +60840,6 @@ "--browser=release", "--passthrough", "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:0a2e", - "os": "mac-intel-stable" - } - ], - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=validating --force_high_performance_gpu", "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" ], @@ -62663,38 +62582,6 @@ "--browser=release", "--passthrough", "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "1002:6821", - "hidpi": "1", - "os": "mac-amd-stable", - "pool": "chromium.tests.gpu.template" - } - ], - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=validating --force_high_performance_gpu", "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" ], @@ -63330,38 +63217,6 @@ "--browser=release", "--passthrough", "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:0fe9", - "hidpi": "1", - "os": "mac-nvidia-stable", - "pool": "chromium.tests.gpu.template" - } - ], - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=validating --force_high_performance_gpu", "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" ], @@ -64121,38 +63976,6 @@ "--browser=release", "--passthrough", "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "1002:679e", - "os": "Mac-10.12.6", - "pool": "chromium.tests.gpu.template" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=validating --force_high_performance_gpu", "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" ], @@ -73579,7 +73402,7 @@ } ], "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 10 + "shards": 20 }, "test": "browser_tests", "test_target": "//chrome/test:browser_tests" @@ -74813,7 +74636,6 @@ }, "name": "blink_web_tests", "results_handler": "layout tests", - "shards": 25, "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -74823,7 +74645,7 @@ } ], "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 12 + "shards": 25 }, "test_target": "//:blink_web_tests" }, @@ -86922,36 +86744,6 @@ "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", "shards": 2 } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:0a2e", - "os": "mac-intel-stable" - } - ], - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } } ] }, @@ -87208,38 +87000,6 @@ "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", "shards": 2 } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "1002:6821", - "hidpi": "1", - "os": "mac-amd-stable", - "pool": "chromium.tests.gpu.template" - } - ], - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } } ] }, @@ -92373,6 +92133,12 @@ "test_target": "//components/background_task_scheduler:components_background_task_scheduler_junit_tests" }, { + "name": "components_embedder_support_junit_tests", + "swarming": {}, + "test": "components_embedder_support_junit_tests", + "test_target": "//components/embedder_support/android:components_embedder_support_junit_tests" + }, + { "name": "components_gcm_driver_junit_tests", "swarming": {}, "test": "components_gcm_driver_junit_tests", @@ -156834,6 +156600,12 @@ "test_target": "//components/background_task_scheduler:components_background_task_scheduler_junit_tests" }, { + "name": "components_embedder_support_junit_tests", + "swarming": {}, + "test": "components_embedder_support_junit_tests", + "test_target": "//components/embedder_support/android:components_embedder_support_junit_tests" + }, + { "name": "components_gcm_driver_junit_tests", "swarming": {}, "test": "components_gcm_driver_junit_tests", @@ -163584,6 +163356,13 @@ }, { "isolate_coverage_data": true, + "name": "components_embedder_support_junit_tests", + "swarming": {}, + "test": "components_embedder_support_junit_tests", + "test_target": "//components/embedder_support/android:components_embedder_support_junit_tests" + }, + { + "isolate_coverage_data": true, "name": "components_gcm_driver_junit_tests", "swarming": {}, "test": "components_gcm_driver_junit_tests", @@ -177445,6 +177224,13 @@ }, { "isolate_coverage_data": true, + "name": "components_embedder_support_junit_tests", + "swarming": {}, + "test": "components_embedder_support_junit_tests", + "test_target": "//components/embedder_support/android:components_embedder_support_junit_tests" + }, + { + "isolate_coverage_data": true, "name": "components_gcm_driver_junit_tests", "swarming": {}, "test": "components_gcm_driver_junit_tests", @@ -193903,6 +193689,39 @@ "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" }, "test_target": "//content/test:fuchsia_telemetry_gpu_integration_test" + }, + { + "args": [ + "info_collection", + "--show-stdout", + "--browser=web-engine-shell", + "--passthrough", + "-v", + "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc", + "--expected-vendor-id", + "0", + "--expected-device-id", + "0" + ], + "isolate_name": "fuchsia_telemetry_gpu_integration_test", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_isolated_script_merge.py" + }, + "name": "info_collection_tests", + "should_retry_with_patch": false, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "kvm": "1", + "os": "Ubuntu-16.04" + } + ], + "idempotent": false, + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test_target": "//content/test:fuchsia_telemetry_gpu_integration_test" } ] }, @@ -201035,7 +200854,7 @@ ], "scripts": [] }, - "linux-bfcache-debug": { + "linux-bfcache-rel": { "gtest_tests": [ { "args": [ @@ -201134,7 +200953,6 @@ { "args": [ "--num-retries=3", - "--debug", "--additional-driver-flag=--enable-features=BackForwardCache", "--additional-expectations=../../third_party/blink/web_tests/FlagExpectations/enable-features=BackForwardCache" ],
diff --git a/testing/buildbot/chromium.clang.json b/testing/buildbot/chromium.clang.json index e30c9dc..6fdc08f 100644 --- a/testing/buildbot/chromium.clang.json +++ b/testing/buildbot/chromium.clang.json
@@ -8061,6 +8061,12 @@ "test_target": "//components/background_task_scheduler:components_background_task_scheduler_junit_tests" }, { + "name": "components_embedder_support_junit_tests", + "swarming": {}, + "test": "components_embedder_support_junit_tests", + "test_target": "//components/embedder_support/android:components_embedder_support_junit_tests" + }, + { "name": "components_gcm_driver_junit_tests", "swarming": {}, "test": "components_gcm_driver_junit_tests",
diff --git a/testing/buildbot/chromium.dev.json b/testing/buildbot/chromium.dev.json index dce8a943..b40da38 100644 --- a/testing/buildbot/chromium.dev.json +++ b/testing/buildbot/chromium.dev.json
@@ -880,6 +880,144 @@ } ] }, + "linux-rel-swarming-staging": { + "gtest_tests": [ + { + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "2", + "os": "Ubuntu-16.04", + "pool": "chromium.tests.template" + } + ], + "service_account": "chromium-tester-dev@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "base_unittests", + "test_target": "//base:base_unittests" + }, + { + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "8", + "os": "Ubuntu-16.04", + "pool": "chromium.tests.template" + } + ], + "service_account": "chromium-tester-dev@chops-service-accounts.iam.gserviceaccount.com", + "shards": 2 + }, + "test": "browser_tests", + "test_target": "//chrome/test:browser_tests" + }, + { + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "8", + "os": "Ubuntu-16.04", + "pool": "chromium.tests.template" + } + ], + "service_account": "chromium-tester-dev@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "content_browsertests", + "test_target": "//content/test:content_browsertests" + }, + { + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "2", + "os": "Ubuntu-16.04", + "pool": "chromium.tests.template" + } + ], + "service_account": "chromium-tester-dev@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "content_unittests", + "test_target": "//content/test:content_unittests" + }, + { + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "8", + "os": "Ubuntu-16.04", + "pool": "chromium.tests.template" + } + ], + "service_account": "chromium-tester-dev@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "interactive_ui_tests", + "test_target": "//chrome/test:interactive_ui_tests" + }, + { + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "8", + "os": "Ubuntu-16.04", + "pool": "chromium.tests.template" + } + ], + "service_account": "chromium-tester-dev@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "net_unittests", + "test_target": "//net:net_unittests" + }, + { + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "2", + "os": "Ubuntu-16.04", + "pool": "chromium.tests.template" + } + ], + "service_account": "chromium-tester-dev@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "unit_tests", + "test_target": "//chrome/test:unit_tests" + } + ] + }, "mac-rel-swarming": { "gtest_tests": [ {
diff --git a/testing/buildbot/chromium.fyi.json b/testing/buildbot/chromium.fyi.json index 97a2b4a..45ba1fe 100644 --- a/testing/buildbot/chromium.fyi.json +++ b/testing/buildbot/chromium.fyi.json
@@ -7644,6 +7644,13 @@ }, { "isolate_coverage_data": true, + "name": "components_embedder_support_junit_tests", + "swarming": {}, + "test": "components_embedder_support_junit_tests", + "test_target": "//components/embedder_support/android:components_embedder_support_junit_tests" + }, + { + "isolate_coverage_data": true, "name": "components_gcm_driver_junit_tests", "swarming": {}, "test": "components_gcm_driver_junit_tests", @@ -12677,6 +12684,39 @@ "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" }, "test_target": "//content/test:fuchsia_telemetry_gpu_integration_test" + }, + { + "args": [ + "info_collection", + "--show-stdout", + "--browser=web-engine-shell", + "--passthrough", + "-v", + "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc", + "--expected-vendor-id", + "0", + "--expected-device-id", + "0" + ], + "isolate_name": "fuchsia_telemetry_gpu_integration_test", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_isolated_script_merge.py" + }, + "name": "info_collection_tests", + "should_retry_with_patch": false, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "kvm": "1", + "os": "Ubuntu-16.04" + } + ], + "idempotent": false, + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test_target": "//content/test:fuchsia_telemetry_gpu_integration_test" } ] }, @@ -19788,7 +19828,7 @@ } ] }, - "linux-bfcache-debug": { + "linux-bfcache-rel": { "gtest_tests": [ { "args": [ @@ -19887,7 +19927,6 @@ { "args": [ "--num-retries=3", - "--debug", "--additional-driver-flag=--enable-features=BackForwardCache", "--additional-expectations=../../third_party/blink/web_tests/FlagExpectations/enable-features=BackForwardCache" ],
diff --git a/testing/buildbot/chromium.gpu.fyi.json b/testing/buildbot/chromium.gpu.fyi.json index f725c2c..17de2b3 100644 --- a/testing/buildbot/chromium.gpu.fyi.json +++ b/testing/buildbot/chromium.gpu.fyi.json
@@ -1147,36 +1147,6 @@ "--browser=release", "--passthrough", "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:0a2e", - "os": "mac-intel-stable" - } - ], - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu", "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" ], @@ -1461,38 +1431,6 @@ "--browser=release", "--passthrough", "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "1002:6821", - "hidpi": "1", - "os": "mac-amd-stable", - "pool": "chromium.tests.gpu.template" - } - ], - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu", "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" ], @@ -13654,36 +13592,6 @@ "--browser=release", "--passthrough", "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:0a2e", - "os": "mac-intel-stable" - } - ], - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=validating --force_high_performance_gpu", "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" ], @@ -15426,38 +15334,6 @@ "--browser=release", "--passthrough", "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "1002:6821", - "hidpi": "1", - "os": "mac-amd-stable", - "pool": "chromium.tests.gpu.template" - } - ], - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=validating --force_high_performance_gpu", "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" ], @@ -16093,38 +15969,6 @@ "--browser=release", "--passthrough", "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:0fe9", - "hidpi": "1", - "os": "mac-nvidia-stable", - "pool": "chromium.tests.gpu.template" - } - ], - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=validating --force_high_performance_gpu", "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" ], @@ -16884,38 +16728,6 @@ "--browser=release", "--passthrough", "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "1002:679e", - "os": "Mac-10.12.6", - "pool": "chromium.tests.gpu.template" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=validating --force_high_performance_gpu", "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" ], @@ -17687,36 +17499,6 @@ "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", "shards": 2 } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:0a2e", - "os": "mac-intel-stable" - } - ], - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } } ] }, @@ -17973,38 +17755,6 @@ "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", "shards": 2 } - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--test-filter=conformance/rendering/gl-drawelements.html" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_swangle_passthrough_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "1002:6821", - "hidpi": "1", - "os": "mac-amd-stable", - "pool": "chromium.tests.gpu.template" - } - ], - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - } } ] },
diff --git a/testing/buildbot/chromium.mac.json b/testing/buildbot/chromium.mac.json index 98cc438..d002554 100644 --- a/testing/buildbot/chromium.mac.json +++ b/testing/buildbot/chromium.mac.json
@@ -7113,7 +7113,7 @@ } ], "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 10 + "shards": 20 }, "test": "browser_tests", "test_target": "//chrome/test:browser_tests" @@ -8347,7 +8347,6 @@ }, "name": "blink_web_tests", "results_handler": "layout tests", - "shards": 25, "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -8357,7 +8356,7 @@ } ], "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 12 + "shards": 25 }, "test_target": "//:blink_web_tests" },
diff --git a/testing/buildbot/chromium.memory.json b/testing/buildbot/chromium.memory.json index 20c9c59..61c4583f 100644 --- a/testing/buildbot/chromium.memory.json +++ b/testing/buildbot/chromium.memory.json
@@ -13869,6 +13869,11 @@ }, "swarming": { "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "cores": "8" + } + ], "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", "shards": 20 },
diff --git a/testing/buildbot/gn_isolate_map.pyl b/testing/buildbot/gn_isolate_map.pyl index 1ad39085..c8cf95b7 100644 --- a/testing/buildbot/gn_isolate_map.pyl +++ b/testing/buildbot/gn_isolate_map.pyl
@@ -580,6 +580,10 @@ "label": "//components:components_browsertests", "type": "windowed_test_launcher", }, + "components_embedder_support_junit_tests": { + "label": "//components/embedder_support/android:components_embedder_support_junit_tests", + "type": "junit_test", + }, "components_gcm_driver_junit_tests": { "label": "//components/gcm_driver/android:components_gcm_driver_junit_tests", "type": "junit_test",
diff --git a/testing/buildbot/manage.py b/testing/buildbot/manage.py index 7ad64f0..e7dd81a3 100755 --- a/testing/buildbot/manage.py +++ b/testing/buildbot/manage.py
@@ -124,6 +124,7 @@ # These are listed in Builders that are skipped for other reasons. 'chrome_junit_tests', 'components_background_task_scheduler_junit_tests', + 'components_embedder_support_junit_tests', 'components_gcm_driver_junit_tests', 'components_permissions_junit_tests', 'components_policy_junit_tests',
diff --git a/testing/buildbot/test_suite_exceptions.pyl b/testing/buildbot/test_suite_exceptions.pyl index 5e84bd5..5ccd7d79 100644 --- a/testing/buildbot/test_suite_exceptions.pyl +++ b/testing/buildbot/test_suite_exceptions.pyl
@@ -155,7 +155,9 @@ 'args': [ '--debug', ], - 'shards': 25, + 'swarming': { + 'shards': 25, + }, }, 'V8 Blink Linux Debug': { 'args': [ @@ -292,9 +294,8 @@ 'shards': 1, }, }, - 'linux-bfcache-debug': { + 'linux-bfcache-rel': { 'args': [ - '--debug', '--additional-driver-flag=--enable-features=BackForwardCache', '--additional-expectations=../../third_party/blink/web_tests/FlagExpectations/enable-features=BackForwardCache', ], @@ -444,6 +445,17 @@ }, 'Mac ASan 64 Tests (1)': { 'swarming': { + 'dimension_sets': [ + { + # These shards are liable to time out when running on minis. + 'cores': '8', + } + ], + 'shards': 20, + }, + }, + 'Mac10.13 Tests (dbg)': { + 'swarming': { 'shards': 20, }, }, @@ -2287,13 +2299,6 @@ 'Win10 FYI x64 Release (AMD RX 550)', ], }, - 'webgl_conformance_swangle_passthrough_tests': { - 'remove_from': [ - # Disable tests on ASAN builds until libvulkan is statically linked: - # anglebug.com/4477 - 'Mac FYI GPU ASAN Release', - ], - }, 'webgl_conformance_tests': { 'modifications': { # On desktop platforms these don't take very long (~7 minutes),
diff --git a/testing/buildbot/test_suites.pyl b/testing/buildbot/test_suites.pyl index 8f56316e..897dd15 100644 --- a/testing/buildbot/test_suites.pyl +++ b/testing/buildbot/test_suites.pyl
@@ -744,6 +744,7 @@ 'chrome_java_test_pagecontroller_junit_tests': {}, 'chrome_junit_tests': {}, 'components_background_task_scheduler_junit_tests': {}, + 'components_embedder_support_junit_tests': {}, 'components_gcm_driver_junit_tests': {}, 'components_permissions_junit_tests': {}, 'components_policy_junit_tests': {}, @@ -1223,7 +1224,16 @@ 'fuchsia_gpu_telemetry_tests': { 'hardware_accelerated_feature': { 'isolate_name': 'fuchsia_telemetry_gpu_integration_test', - } + }, + 'info_collection': { + 'args': [ + '--expected-vendor-id', + '${gpu_vendor_id}', + '--expected-device-id', + '${gpu_device_id}', + ], + 'isolate_name': 'fuchsia_telemetry_gpu_integration_test', + }, }, 'fuchsia_gtests': { @@ -2534,22 +2544,6 @@ }, }, - 'gpu_webgl_conformance_swangle_passthrough_telemetry_tests': { - 'webgl_conformance_swangle_passthrough': { - 'telemetry_test_name': 'webgl_conformance', - 'args': [ - # On dual-GPU devices we want the high-performance GPU to be active - '--extra-browser-args=--use-gl=angle --use-angle=swiftshader --use-cmd-decoder=passthrough --force_high_performance_gpu', - # We are only interested in running a 'smoketest' to test swangle - # integration, not the full conformance suite. - '--test-filter=conformance/rendering/gl-drawelements.html', - ], - 'swarming': { - 'shards': 1, - }, - }, - }, - 'gpu_webgl_conformance_telemetry_tests': { 'webgl_conformance': { 'chromeos_args': [ @@ -4140,7 +4134,6 @@ 'gpu_webgl2_conformance_telemetry_tests', 'gpu_webgl_conformance_telemetry_tests', 'gpu_webgl_conformance_gl_passthrough_telemetry_tests', - 'gpu_webgl_conformance_swangle_passthrough_telemetry_tests', ], 'gpu_angle_perf_smoke_isolated_scripts_and_test_buildbucket_api_gpu_use_cases': [ @@ -4302,7 +4295,6 @@ 'gpu_webgl2_conformance_validating_telemetry_tests', 'gpu_webgl_conformance_gl_passthrough_telemetry_tests', 'gpu_webgl_conformance_validating_telemetry_tests', - 'gpu_webgl_conformance_swangle_passthrough_telemetry_tests', ], 'gpu_fyi_optional_linux_telemetry_tests': [ @@ -4315,7 +4307,6 @@ 'gpu_common_and_optional_telemetry_tests', 'gpu_webgl2_conformance_validating_telemetry_tests', 'gpu_webgl_conformance_gl_passthrough_telemetry_tests', - 'gpu_webgl_conformance_swangle_passthrough_telemetry_tests', # Not currently running # gpu_webgl2_conformance_gl_passthrough_telemetry_tests here due # to concerns about machine capacity.
diff --git a/testing/buildbot/waterfalls.pyl b/testing/buildbot/waterfalls.pyl index 4a9e601..a0dea8d3 100644 --- a/testing/buildbot/waterfalls.pyl +++ b/testing/buildbot/waterfalls.pyl
@@ -1448,6 +1448,15 @@ 'gtest_tests': 'chromium_swarm_linux_gtests', }, }, + 'linux-rel-swarming-staging': { + 'mixins': [ + 'linux-xenial', + 'chromium-template-pool', + ], + 'test_suites': { + 'gtest_tests': 'chromium_swarm_linux_gtests', + }, + }, 'mac-rel-swarming': { 'mixins': [ 'chromium-template-pool', @@ -1864,7 +1873,7 @@ 'scripts': 'test_traffic_annotation_auditor_script', }, }, - 'linux-bfcache-debug': { + 'linux-bfcache-rel': { 'mixins': [ 'linux-xenial', ],
diff --git a/third_party/.gitignore b/third_party/.gitignore index 46a44b5..07fb2dc 100644 --- a/third_party/.gitignore +++ b/third_party/.gitignore
@@ -36,7 +36,6 @@ /apache-mac/bin/openssl /apache-mac/lib/*.dylib /apache-mac/libexec/apache2/*.so -/apk-patch-size-estimator/lib/ /arcore-android-sdk/src/ /arcore-android-sdk/test-apks/arcore/*.apk /asan
diff --git a/third_party/abseil-cpp/CMake/AbseilDll.cmake b/third_party/abseil-cpp/CMake/AbseilDll.cmake new file mode 100644 index 0000000..90c9f1f --- /dev/null +++ b/third_party/abseil-cpp/CMake/AbseilDll.cmake
@@ -0,0 +1,504 @@ +include(CMakeParseArguments) + +set(ABSL_INTERNAL_DLL_FILES + "algorithm/algorithm.h" + "algorithm/container.h" + "base/attributes.h" + "base/call_once.h" + "base/casts.h" + "base/config.h" + "base/const_init.h" + "base/dynamic_annotations.cc" + "base/dynamic_annotations.h" + "base/internal/atomic_hook.h" + "base/internal/bits.h" + "base/internal/cycleclock.cc" + "base/internal/cycleclock.h" + "base/internal/direct_mmap.h" + "base/internal/endian.h" + "base/internal/errno_saver.h" + "base/internal/exponential_biased.cc" + "base/internal/exponential_biased.h" + "base/internal/hide_ptr.h" + "base/internal/identity.h" + "base/internal/invoke.h" + "base/internal/inline_variable.h" + "base/internal/low_level_alloc.cc" + "base/internal/low_level_alloc.h" + "base/internal/low_level_scheduling.h" + "base/internal/per_thread_tls.h" + "base/internal/periodic_sampler.cc" + "base/internal/periodic_sampler.h" + "base/internal/pretty_function.h" + "base/internal/raw_logging.cc" + "base/internal/raw_logging.h" + "base/internal/scheduling_mode.h" + "base/internal/scoped_set_env.cc" + "base/internal/scoped_set_env.h" + "base/internal/spinlock.cc" + "base/internal/spinlock.h" + "base/internal/spinlock_wait.cc" + "base/internal/spinlock_wait.h" + "base/internal/sysinfo.cc" + "base/internal/sysinfo.h" + "base/internal/thread_annotations.h" + "base/internal/thread_identity.cc" + "base/internal/thread_identity.h" + "base/internal/throw_delegate.cc" + "base/internal/throw_delegate.h" + "base/internal/tsan_mutex_interface.h" + "base/internal/unaligned_access.h" + "base/internal/unscaledcycleclock.cc" + "base/internal/unscaledcycleclock.h" + "base/log_severity.cc" + "base/log_severity.h" + "base/macros.h" + "base/optimization.h" + "base/options.h" + "base/policy_checks.h" + "base/port.h" + "base/thread_annotations.h" + "container/btree_map.h" + "container/btree_set.h" + "container/fixed_array.h" + "container/flat_hash_map.h" + "container/flat_hash_set.h" + "container/inlined_vector.h" + "container/internal/btree.h" + "container/internal/btree_container.h" + "container/internal/common.h" + "container/internal/compressed_tuple.h" + "container/internal/container_memory.h" + "container/internal/counting_allocator.h" + "container/internal/hash_function_defaults.h" + "container/internal/hash_policy_traits.h" + "container/internal/hashtable_debug.h" + "container/internal/hashtable_debug_hooks.h" + "container/internal/hashtablez_sampler.cc" + "container/internal/hashtablez_sampler.h" + "container/internal/hashtablez_sampler_force_weak_definition.cc" + "container/internal/have_sse.h" + "container/internal/inlined_vector.h" + "container/internal/layout.h" + "container/internal/node_hash_policy.h" + "container/internal/raw_hash_map.h" + "container/internal/raw_hash_set.cc" + "container/internal/raw_hash_set.h" + "container/internal/tracked.h" + "container/node_hash_map.h" + "container/node_hash_set.h" + "debugging/failure_signal_handler.cc" + "debugging/failure_signal_handler.h" + "debugging/leak_check.h" + "debugging/leak_check_disable.cc" + "debugging/stacktrace.cc" + "debugging/stacktrace.h" + "debugging/symbolize.cc" + "debugging/symbolize.h" + "debugging/internal/address_is_readable.cc" + "debugging/internal/address_is_readable.h" + "debugging/internal/demangle.cc" + "debugging/internal/demangle.h" + "debugging/internal/elf_mem_image.cc" + "debugging/internal/elf_mem_image.h" + "debugging/internal/examine_stack.cc" + "debugging/internal/examine_stack.h" + "debugging/internal/stack_consumption.cc" + "debugging/internal/stack_consumption.h" + "debugging/internal/stacktrace_config.h" + "debugging/internal/symbolize.h" + "debugging/internal/vdso_support.cc" + "debugging/internal/vdso_support.h" + "functional/internal/front_binder.h" + "functional/bind_front.h" + "functional/function_ref.h" + "functional/internal/function_ref.h" + "hash/hash.h" + "hash/internal/city.h" + "hash/internal/city.cc" + "hash/internal/hash.h" + "hash/internal/hash.cc" + "hash/internal/spy_hash_state.h" + "memory/memory.h" + "meta/type_traits.h" + "numeric/int128.cc" + "numeric/int128.h" + "random/bernoulli_distribution.h" + "random/beta_distribution.h" + "random/bit_gen_ref.h" + "random/discrete_distribution.cc" + "random/discrete_distribution.h" + "random/distribution_format_traits.h" + "random/distributions.h" + "random/exponential_distribution.h" + "random/gaussian_distribution.cc" + "random/gaussian_distribution.h" + "random/internal/distributions.h" + "random/internal/distribution_caller.h" + "random/internal/fast_uniform_bits.h" + "random/internal/fastmath.h" + "random/internal/gaussian_distribution_gentables.cc" + "random/internal/generate_real.h" + "random/internal/iostream_state_saver.h" + "random/internal/nonsecure_base.h" + "random/internal/pcg_engine.h" + "random/internal/platform.h" + "random/internal/pool_urbg.cc" + "random/internal/pool_urbg.h" + "random/internal/randen.cc" + "random/internal/randen.h" + "random/internal/randen_detect.cc" + "random/internal/randen_detect.h" + "random/internal/randen_engine.h" + "random/internal/randen_hwaes.cc" + "random/internal/randen_hwaes.h" + "random/internal/randen_slow.cc" + "random/internal/randen_slow.h" + "random/internal/randen_traits.h" + "random/internal/salted_seed_seq.h" + "random/internal/seed_material.cc" + "random/internal/seed_material.h" + "random/internal/sequence_urbg.h" + "random/internal/traits.h" + "random/internal/uniform_helper.h" + "random/internal/wide_multiply.h" + "random/log_uniform_int_distribution.h" + "random/poisson_distribution.h" + "random/random.h" + "random/seed_gen_exception.cc" + "random/seed_gen_exception.h" + "random/seed_sequences.cc" + "random/seed_sequences.h" + "random/uniform_int_distribution.h" + "random/uniform_real_distribution.h" + "random/zipf_distribution.h" + "status/status.h" + "status/status.cc" + "status/status_payload_printer.h" + "status/status_payload_printer.cc" + "strings/ascii.cc" + "strings/ascii.h" + "strings/charconv.cc" + "strings/charconv.h" + "strings/cord.cc" + "strings/cord.h" + "strings/escaping.cc" + "strings/escaping.h" + "strings/internal/cord_internal.h" + "strings/internal/charconv_bigint.cc" + "strings/internal/charconv_bigint.h" + "strings/internal/charconv_parse.cc" + "strings/internal/charconv_parse.h" + "strings/internal/stl_type_traits.h" + "strings/match.cc" + "strings/match.h" + "strings/numbers.cc" + "strings/numbers.h" + "strings/str_format.h" + "strings/str_cat.cc" + "strings/str_cat.h" + "strings/str_join.h" + "strings/str_replace.cc" + "strings/str_replace.h" + "strings/str_split.cc" + "strings/str_split.h" + "strings/string_view.cc" + "strings/string_view.h" + "strings/strip.h" + "strings/substitute.cc" + "strings/substitute.h" + "strings/internal/char_map.h" + "strings/internal/escaping.h" + "strings/internal/escaping.cc" + "strings/internal/memutil.cc" + "strings/internal/memutil.h" + "strings/internal/ostringstream.cc" + "strings/internal/ostringstream.h" + "strings/internal/pow10_helper.cc" + "strings/internal/pow10_helper.h" + "strings/internal/resize_uninitialized.h" + "strings/internal/str_format/arg.cc" + "strings/internal/str_format/arg.h" + "strings/internal/str_format/bind.cc" + "strings/internal/str_format/bind.h" + "strings/internal/str_format/checker.h" + "strings/internal/str_format/extension.cc" + "strings/internal/str_format/extension.h" + "strings/internal/str_format/float_conversion.cc" + "strings/internal/str_format/float_conversion.h" + "strings/internal/str_format/output.cc" + "strings/internal/str_format/output.h" + "strings/internal/str_format/parser.cc" + "strings/internal/str_format/parser.h" + "strings/internal/str_join_internal.h" + "strings/internal/str_split_internal.h" + "strings/internal/utf8.cc" + "strings/internal/utf8.h" + "synchronization/barrier.cc" + "synchronization/barrier.h" + "synchronization/blocking_counter.cc" + "synchronization/blocking_counter.h" + "synchronization/mutex.cc" + "synchronization/mutex.h" + "synchronization/notification.cc" + "synchronization/notification.h" + "synchronization/internal/create_thread_identity.cc" + "synchronization/internal/create_thread_identity.h" + "synchronization/internal/graphcycles.cc" + "synchronization/internal/graphcycles.h" + "synchronization/internal/kernel_timeout.h" + "synchronization/internal/per_thread_sem.cc" + "synchronization/internal/per_thread_sem.h" + "synchronization/internal/thread_pool.h" + "synchronization/internal/waiter.cc" + "synchronization/internal/waiter.h" + "time/civil_time.cc" + "time/civil_time.h" + "time/clock.cc" + "time/clock.h" + "time/duration.cc" + "time/format.cc" + "time/time.cc" + "time/time.h" + "time/internal/cctz/include/cctz/civil_time.h" + "time/internal/cctz/include/cctz/civil_time_detail.h" + "time/internal/cctz/include/cctz/time_zone.h" + "time/internal/cctz/include/cctz/zone_info_source.h" + "time/internal/cctz/src/civil_time_detail.cc" + "time/internal/cctz/src/time_zone_fixed.cc" + "time/internal/cctz/src/time_zone_fixed.h" + "time/internal/cctz/src/time_zone_format.cc" + "time/internal/cctz/src/time_zone_if.cc" + "time/internal/cctz/src/time_zone_if.h" + "time/internal/cctz/src/time_zone_impl.cc" + "time/internal/cctz/src/time_zone_impl.h" + "time/internal/cctz/src/time_zone_info.cc" + "time/internal/cctz/src/time_zone_info.h" + "time/internal/cctz/src/time_zone_libc.cc" + "time/internal/cctz/src/time_zone_libc.h" + "time/internal/cctz/src/time_zone_lookup.cc" + "time/internal/cctz/src/time_zone_posix.cc" + "time/internal/cctz/src/time_zone_posix.h" + "time/internal/cctz/src/tzfile.h" + "time/internal/cctz/src/zone_info_source.cc" + "types/any.h" + "types/bad_any_cast.cc" + "types/bad_any_cast.h" + "types/bad_optional_access.cc" + "types/bad_optional_access.h" + "types/bad_variant_access.cc" + "types/bad_variant_access.h" + "types/compare.h" + "types/internal/conformance_aliases.h" + "types/internal/conformance_archetype.h" + "types/internal/conformance_profile.h" + "types/internal/variant.h" + "types/optional.h" + "types/internal/optional.h" + "types/span.h" + "types/internal/span.h" + "types/variant.h" + "utility/utility.h" +) + +set(ABSL_INTERNAL_DLL_TARGETS + "stacktrace" + "symbolize" + "examine_stack" + "failure_signal_handler" + "debugging_internal" + "demangle_internal" + "leak_check" + "leak_check_disable" + "stack_consumption" + "debugging" + "hash" + "spy_hash_state" + "city" + "memory" + "strings" + "strings_internal" + "cord" + "str_format" + "str_format_internal" + "pow10_helper" + "int128" + "numeric" + "utility" + "any" + "bad_any_cast" + "bad_any_cast_impl" + "span" + "optional" + "bad_optional_access" + "bad_variant_access" + "variant" + "compare" + "algorithm" + "algorithm_container" + "graphcycles_internal" + "kernel_timeout_internal" + "synchronization" + "thread_pool" + "bind_front" + "function_ref" + "atomic_hook" + "log_severity" + "raw_logging_internal" + "spinlock_wait" + "config" + "dynamic_annotations" + "core_headers" + "malloc_internal" + "base_internal" + "base" + "throw_delegate" + "pretty_function" + "endian" + "bits" + "exponential_biased" + "periodic_sampler" + "scoped_set_env" + "type_traits" + "meta" + "random_random" + "random_bit_gen_ref" + "random_distributions" + "random_seed_gen_exception" + "random_seed_sequences" + "random_internal_traits" + "random_internal_distribution_caller" + "random_internal_distributions" + "random_internal_fast_uniform_bits" + "random_internal_seed_material" + "random_internal_pool_urbg" + "random_internal_explicit_seed_seq" + "random_internal_sequence_urbg" + "random_internal_salted_seed_seq" + "random_internal_iostream_state_saver" + "random_internal_generate_real" + "random_internal_wide_multiply" + "random_internal_fastmath" + "random_internal_nonsecure_base" + "random_internal_pcg_engine" + "random_internal_randen_engine" + "random_internal_platform" + "random_internal_randen" + "random_internal_randen_slow" + "random_internal_randen_hwaes" + "random_internal_randen_hwaes_impl" + "random_internal_uniform_helper" + "status" + "time" + "civil_time" + "time_zone" + "container" + "btree" + "compressed_tuple" + "fixed_array" + "inlined_vector_internal" + "inlined_vector" + "counting_allocator" + "flat_hash_map" + "flat_hash_set" + "node_hash_map" + "node_hash_set" + "container_memory" + "hash_function_defaults" + "hash_policy_traits" + "hashtablez_sampler" + "hashtable_debug" + "hashtable_debug_hooks" + "have_sse" + "node_hash_policy" + "raw_hash_map" + "container_common" + "raw_hash_set" + "layout" + "tracked" +) + +function(absl_internal_dll_contains) + cmake_parse_arguments(ABSL_INTERNAL_DLL + "" + "OUTPUT;TARGET" + "" + ${ARGN} + ) + + STRING(REGEX REPLACE "^absl::" "" _target ${ABSL_INTERNAL_DLL_TARGET}) + + list(FIND + ABSL_INTERNAL_DLL_TARGETS + "${_target}" + _index) + + if (${_index} GREATER -1) + set(${ABSL_INTERNAL_DLL_OUTPUT} 1 PARENT_SCOPE) + else() + set(${ABSL_INTERNAL_DLL_OUTPUT} 0 PARENT_SCOPE) + endif() +endfunction() + +function(absl_internal_dll_targets) + cmake_parse_arguments(ABSL_INTERNAL_DLL + "" + "OUTPUT" + "DEPS" + ${ARGN} + ) + + set(_deps "") + foreach(dep IN LISTS ABSL_INTERNAL_DLL_DEPS) + absl_internal_dll_contains(TARGET ${dep} OUTPUT _contains) + if (_contains) + list(APPEND _deps abseil_dll) + else() + list(APPEND _deps ${dep}) + endif() + endforeach() + + # Because we may have added the DLL multiple times + list(REMOVE_DUPLICATES _deps) + set(${ABSL_INTERNAL_DLL_OUTPUT} "${_deps}" PARENT_SCOPE) +endfunction() + +function(absl_make_dll) + add_library( + abseil_dll + SHARED + "${ABSL_INTERNAL_DLL_FILES}" + ) + target_link_libraries( + abseil_dll + PRIVATE + ${ABSL_DEFAULT_LINKOPTS} + ) + set_property(TARGET abseil_dll PROPERTY LINKER_LANGUAGE "CXX") + target_include_directories( + abseil_dll + PUBLIC + "$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>" + $<INSTALL_INTERFACE:${ABSL_INSTALL_INCLUDEDIR}> + ) + + target_compile_options( + abseil_dll + PRIVATE + ${ABSL_DEFAULT_COPTS} + ) + + target_compile_definitions( + abseil_dll + PRIVATE + ABSL_BUILD_DLL + NOMINMAX + INTERFACE + ${ABSL_CC_LIB_DEFINES} + ) + install(TARGETS abseil_dll EXPORT ${PROJECT_NAME}Targets + RUNTIME DESTINATION ${ABSL_INSTALL_BINDIR} + LIBRARY DESTINATION ${ABSL_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${ABSL_INSTALL_LIBDIR} + ) +endfunction()
diff --git a/third_party/abseil-cpp/CMake/AbseilHelpers.cmake b/third_party/abseil-cpp/CMake/AbseilHelpers.cmake index 58f98c8..86ff9eb 100644 --- a/third_party/abseil-cpp/CMake/AbseilHelpers.cmake +++ b/third_party/abseil-cpp/CMake/AbseilHelpers.cmake
@@ -16,6 +16,7 @@ include(CMakeParseArguments) include(AbseilConfigureCopts) +include(AbseilDll) include(AbseilInstallDirs) # The IDE folder for Abseil that will be used if Abseil is included in a CMake @@ -80,95 +81,173 @@ ${ARGN} ) - if(NOT ABSL_CC_LIB_TESTONLY OR ABSL_RUN_TESTS) - if(ABSL_ENABLE_INSTALL) - set(_NAME "${ABSL_CC_LIB_NAME}") - else() - set(_NAME "absl_${ABSL_CC_LIB_NAME}") - endif() + if(ABSL_CC_LIB_TESTONLY AND NOT ABSL_RUN_TESTS) + return() + endif() - # Check if this is a header-only library - # Note that as of February 2019, many popular OS's (for example, Ubuntu - # 16.04 LTS) only come with cmake 3.5 by default. For this reason, we can't - # use list(FILTER...) - set(ABSL_CC_SRCS "${ABSL_CC_LIB_SRCS}") - foreach(src_file IN LISTS ABSL_CC_SRCS) - if(${src_file} MATCHES ".*\\.(h|inc)") - list(REMOVE_ITEM ABSL_CC_SRCS "${src_file}") - endif() - endforeach() - if("${ABSL_CC_SRCS}" STREQUAL "") + if(ABSL_ENABLE_INSTALL) + set(_NAME "${ABSL_CC_LIB_NAME}") + else() + set(_NAME "absl_${ABSL_CC_LIB_NAME}") + endif() + + # Check if this is a header-only library + # Note that as of February 2019, many popular OS's (for example, Ubuntu + # 16.04 LTS) only come with cmake 3.5 by default. For this reason, we can't + # use list(FILTER...) + set(ABSL_CC_SRCS "${ABSL_CC_LIB_SRCS}") + foreach(src_file IN LISTS ABSL_CC_SRCS) + if(${src_file} MATCHES ".*\\.(h|inc)") + list(REMOVE_ITEM ABSL_CC_SRCS "${src_file}") + endif() + endforeach() + + if("${ABSL_CC_SRCS}" STREQUAL "") + set(ABSL_CC_LIB_IS_INTERFACE 1) + else() + set(ABSL_CC_LIB_IS_INTERFACE 0) + endif() + + # Determine this build target's relationship to the DLL. It's one of four things: + # 1. "dll" -- This target is part of the DLL + # 2. "dll_dep" -- This target is not part of the DLL, but depends on the DLL. + # Note that we assume any target not in the DLL depends on the + # DLL. This is not a technical necessity but a convenience + # which happens to be true, because nearly every target is + # part of the DLL. + # 3. "shared" -- This is a shared library, perhaps on a non-windows platform + # where DLL doesn't make sense. + # 4. "static" -- This target does not depend on the DLL and should be built + # statically. + if (${ABSL_BUILD_DLL}) + absl_internal_dll_contains(TARGET ${_NAME} OUTPUT _in_dll) + if (${_in_dll}) + # This target should be replaced by the DLL + set(_build_type "dll") set(ABSL_CC_LIB_IS_INTERFACE 1) else() - set(ABSL_CC_LIB_IS_INTERFACE 0) + # Building a DLL, but this target is not part of the DLL + set(_build_type "dll_dep") endif() + elseif(BUILD_SHARED_LIBS) + set(_build_type "shared") + else() + set(_build_type "static") + endif() - if(NOT ABSL_CC_LIB_IS_INTERFACE) + if(NOT ABSL_CC_LIB_IS_INTERFACE) + if(${_build_type} STREQUAL "dll_dep") + # This target depends on the DLL. When adding dependencies to this target, + # any depended-on-target which is contained inside the DLL is replaced + # with a dependency on the DLL. add_library(${_NAME} STATIC "") target_sources(${_NAME} PRIVATE ${ABSL_CC_LIB_SRCS} ${ABSL_CC_LIB_HDRS}) - target_include_directories(${_NAME} - PUBLIC - $<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}> - $<INSTALL_INTERFACE:${ABSL_INSTALL_INCLUDEDIR}> + absl_internal_dll_targets( + DEPS ${ABSL_CC_LIB_DEPS} + OUTPUT _dll_deps ) - target_compile_options(${_NAME} - PRIVATE ${ABSL_CC_LIB_COPTS}) target_link_libraries(${_NAME} - PUBLIC ${ABSL_CC_LIB_DEPS} + PUBLIC ${_dll_deps} PRIVATE ${ABSL_CC_LIB_LINKOPTS} ${ABSL_DEFAULT_LINKOPTS} ) - target_compile_definitions(${_NAME} PUBLIC ${ABSL_CC_LIB_DEFINES}) - # Add all Abseil targets to a a folder in the IDE for organization. - if(ABSL_CC_LIB_PUBLIC) - set_property(TARGET ${_NAME} PROPERTY FOLDER ${ABSL_IDE_FOLDER}) - elseif(ABSL_CC_LIB_TESTONLY) - set_property(TARGET ${_NAME} PROPERTY FOLDER ${ABSL_IDE_FOLDER}/test) + if (ABSL_CC_LIB_TESTONLY) + set(_gtest_link_define "GTEST_LINKED_AS_SHARED_LIBRARY=1") else() - set_property(TARGET ${_NAME} PROPERTY FOLDER ${ABSL_IDE_FOLDER}/internal) + set(_gtest_link_define) endif() - # INTERFACE libraries can't have the CXX_STANDARD property set - set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD}) - set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) + target_compile_definitions(${_NAME} + PUBLIC + ABSL_CONSUME_DLL + "${_gtest_link_define}" + ) - # When being installed, we lose the absl_ prefix. We want to put it back - # to have properly named lib files. This is a no-op when we are not being - # installed. + elseif(${_build_type} STREQUAL "static" OR ${_build_type} STREQUAL "shared") + add_library(${_NAME} "") + target_sources(${_NAME} PRIVATE ${ABSL_CC_LIB_SRCS} ${ABSL_CC_LIB_HDRS}) + target_link_libraries(${_NAME} + PUBLIC ${ABSL_CC_LIB_DEPS} + PRIVATE + ${ABSL_CC_LIB_LINKOPTS} + ${ABSL_DEFAULT_LINKOPTS} + ) + else() + message(FATAL_ERROR "Invalid build type: ${_build_type}") + endif() + + # Linker language can be inferred from sources, but in the case of DLLs we + # don't have any .cc files so it would be ambiguous. We could set it + # explicitly only in the case of DLLs but, because "CXX" is always the + # correct linker language for static or for shared libraries, we set it + # unconditionally. + set_property(TARGET ${_NAME} PROPERTY LINKER_LANGUAGE "CXX") + + target_include_directories(${_NAME} + PUBLIC + "$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>" + $<INSTALL_INTERFACE:${ABSL_INSTALL_INCLUDEDIR}> + ) + target_compile_options(${_NAME} + PRIVATE ${ABSL_CC_LIB_COPTS}) + target_compile_definitions(${_NAME} PUBLIC ${ABSL_CC_LIB_DEFINES}) + + # Add all Abseil targets to a a folder in the IDE for organization. + if(ABSL_CC_LIB_PUBLIC) + set_property(TARGET ${_NAME} PROPERTY FOLDER ${ABSL_IDE_FOLDER}) + elseif(ABSL_CC_LIB_TESTONLY) + set_property(TARGET ${_NAME} PROPERTY FOLDER ${ABSL_IDE_FOLDER}/test) + else() + set_property(TARGET ${_NAME} PROPERTY FOLDER ${ABSL_IDE_FOLDER}/internal) + endif() + + # INTERFACE libraries can't have the CXX_STANDARD property set + set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD}) + set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) + + # When being installed, we lose the absl_ prefix. We want to put it back + # to have properly named lib files. This is a no-op when we are not being + # installed. + if(ABSL_ENABLE_INSTALL) set_target_properties(${_NAME} PROPERTIES OUTPUT_NAME "absl_${_NAME}" ) - else() - # Generating header-only library - add_library(${_NAME} INTERFACE) - target_include_directories(${_NAME} - INTERFACE - $<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}> - $<INSTALL_INTERFACE:${ABSL_INSTALL_INCLUDEDIR}> - ) - target_link_libraries(${_NAME} - INTERFACE - ${ABSL_CC_LIB_DEPS} - ${ABSL_CC_LIB_LINKOPTS} - ${ABSL_DEFAULT_LINKOPTS} + endif() + else() + # Generating header-only library + add_library(${_NAME} INTERFACE) + target_include_directories(${_NAME} + INTERFACE + "$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>" + $<INSTALL_INTERFACE:${ABSL_INSTALL_INCLUDEDIR}> ) - target_compile_definitions(${_NAME} INTERFACE ${ABSL_CC_LIB_DEFINES}) + + if (${_build_type} STREQUAL "dll") + set(ABSL_CC_LIB_DEPS abseil_dll) endif() - # TODO currently we don't install googletest alongside abseil sources, so - # installed abseil can't be tested. - if(NOT ABSL_CC_LIB_TESTONLY AND ABSL_ENABLE_INSTALL) - install(TARGETS ${_NAME} EXPORT ${PROJECT_NAME}Targets - RUNTIME DESTINATION ${ABSL_INSTALL_BINDIR} - LIBRARY DESTINATION ${ABSL_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${ABSL_INSTALL_LIBDIR} - ) - endif() + target_link_libraries(${_NAME} + INTERFACE + ${ABSL_CC_LIB_DEPS} + ${ABSL_CC_LIB_LINKOPTS} + ${ABSL_DEFAULT_LINKOPTS} + ) + target_compile_definitions(${_NAME} INTERFACE ${ABSL_CC_LIB_DEFINES}) + endif() + + # TODO currently we don't install googletest alongside abseil sources, so + # installed abseil can't be tested. + if(NOT ABSL_CC_LIB_TESTONLY AND ABSL_ENABLE_INSTALL) + install(TARGETS ${_NAME} EXPORT ${PROJECT_NAME}Targets + RUNTIME DESTINATION ${ABSL_INSTALL_BINDIR} + LIBRARY DESTINATION ${ABSL_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${ABSL_INSTALL_LIBDIR} + ) + endif() add_library(absl::${ABSL_CC_LIB_NAME} ALIAS ${_NAME}) - endif() endfunction() # absl_cc_test() @@ -221,23 +300,42 @@ ) set(_NAME "absl_${ABSL_CC_TEST_NAME}") + add_executable(${_NAME} "") target_sources(${_NAME} PRIVATE ${ABSL_CC_TEST_SRCS}) target_include_directories(${_NAME} PUBLIC ${ABSL_COMMON_INCLUDE_DIRS} PRIVATE ${GMOCK_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS} ) - target_compile_definitions(${_NAME} - PUBLIC ${ABSL_CC_TEST_DEFINES} - ) + + if (${ABSL_BUILD_DLL}) + target_compile_definitions(${_NAME} + PUBLIC + ${ABSL_CC_TEST_DEFINES} + ABSL_CONSUME_DLL + GTEST_LINKED_AS_SHARED_LIBRARY=1 + ) + + # Replace dependencies on targets inside the DLL with abseil_dll itself. + absl_internal_dll_targets( + DEPS ${ABSL_CC_TEST_DEPS} + OUTPUT ABSL_CC_TEST_DEPS + ) + else() + target_compile_definitions(${_NAME} + PUBLIC + ${ABSL_CC_TEST_DEFINES} + ) + endif() target_compile_options(${_NAME} PRIVATE ${ABSL_CC_TEST_COPTS} ) + target_link_libraries(${_NAME} PUBLIC ${ABSL_CC_TEST_DEPS} PRIVATE ${ABSL_CC_TEST_LINKOPTS} ) - # Add all Abseil targets to a a folder in the IDE for organization. + # Add all Abseil targets to a folder in the IDE for organization. set_property(TARGET ${_NAME} PROPERTY FOLDER ${ABSL_IDE_FOLDER}/test) set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD})
diff --git a/third_party/abseil-cpp/CMake/Googletest/CMakeLists.txt.in b/third_party/abseil-cpp/CMake/Googletest/CMakeLists.txt.in index d60a33e..994dac0 100644 --- a/third_party/abseil-cpp/CMake/Googletest/CMakeLists.txt.in +++ b/third_party/abseil-cpp/CMake/Googletest/CMakeLists.txt.in
@@ -1,15 +1,26 @@ cmake_minimum_required(VERSION 2.8.2) -project(googletest-download NONE) +project(googletest-external NONE) include(ExternalProject) -ExternalProject_Add(googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG master - SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" - BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) \ No newline at end of file +if(${ABSL_USE_GOOGLETEST_HEAD}) + ExternalProject_Add(googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG master + SOURCE_DIR "${absl_gtest_src_dir}" + BINARY_DIR "${absl_gtest_build_dir}" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + ) +else() + ExternalProject_Add(googletest + SOURCE_DIR "${absl_gtest_src_dir}" + BINARY_DIR "${absl_gtest_build_dir}" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + ) +endif() \ No newline at end of file
diff --git a/third_party/abseil-cpp/CMake/Googletest/DownloadGTest.cmake b/third_party/abseil-cpp/CMake/Googletest/DownloadGTest.cmake index 3c682ae..6552e1d 100644 --- a/third_party/abseil-cpp/CMake/Googletest/DownloadGTest.cmake +++ b/third_party/abseil-cpp/CMake/Googletest/DownloadGTest.cmake
@@ -1,27 +1,38 @@ -# Downloads and unpacks googletest at configure time. Based on the instructions -# at https://github.com/google/googletest/tree/master/googletest#incorporating-into-an-existing-cmake-project +# Integrates googletest at configure time. Based on the instructions at +# https://github.com/google/googletest/tree/master/googletest#incorporating-into-an-existing-cmake-project -# Download the latest googletest from Github master +# Set up the external googletest project, downloading the latest from Github +# master if requested. configure_file( ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in - ${CMAKE_BINARY_DIR}/googletest-download/CMakeLists.txt + ${CMAKE_BINARY_DIR}/googletest-external/CMakeLists.txt ) -# Configure and build the downloaded googletest source +set(ABSL_SAVE_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) +set(ABSL_SAVE_CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +if (BUILD_SHARED_LIBS) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_CREATE_SHARED_LIBRARY=1") +endif() + +# Configure and build the googletest source. execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-external ) if(result) message(FATAL_ERROR "CMake step for googletest failed: ${result}") endif() execute_process(COMMAND ${CMAKE_COMMAND} --build . RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download) + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-external) if(result) message(FATAL_ERROR "Build step for googletest failed: ${result}") endif() +set(CMAKE_CXX_FLAGS ${ABSL_SAVE_CMAKE_CXX_FLAGS}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ABSL_SAVE_CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + # Prevent overriding the parent project's compiler/linker settings on Windows set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
diff --git a/third_party/abseil-cpp/CMake/README.md b/third_party/abseil-cpp/CMake/README.md index 469dfef..04d5df3a 100644 --- a/third_party/abseil-cpp/CMake/README.md +++ b/third_party/abseil-cpp/CMake/README.md
@@ -85,13 +85,15 @@ Here's a non-exhaustive list of Abseil CMake public targets: ```cmake -absl::base absl::algorithm +absl::base absl::debugging absl::flat_hash_map +absl::flags absl::memory absl::meta absl::numeric +absl::random absl::strings absl::synchronization absl::time
diff --git a/third_party/abseil-cpp/CMakeLists.txt b/third_party/abseil-cpp/CMakeLists.txt index 86f5634..e94dcd3 100644 --- a/third_party/abseil-cpp/CMakeLists.txt +++ b/third_party/abseil-cpp/CMakeLists.txt
@@ -27,11 +27,17 @@ # if command can use IN_LIST cmake_policy(SET CMP0057 NEW) -# Project version variables are the empty std::string if version is unspecified +# Project version variables are the empty string if version is unspecified cmake_policy(SET CMP0048 NEW) project(absl CXX) +# Output directory is correct by default for most build setups. However, when +# building Abseil as a DLL, it is important to have the DLL in the same +# directory as the executable using it. Thus, we put all executables in a single +# /bin directory. +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + # when absl is included as subproject (i.e. using add_subdirectory(abseil-cpp)) # in the source tree of a project that uses it, install rules are disabled. if(NOT "^${CMAKE_SOURCE_DIR}$" STREQUAL "^${PROJECT_SOURCE_DIR}$") @@ -47,6 +53,7 @@ include(AbseilInstallDirs) include(CMakePackageConfigHelpers) +include(AbseilDll) include(AbseilHelpers) @@ -77,6 +84,10 @@ option(ABSL_USE_GOOGLETEST_HEAD "If ON, abseil will download HEAD from googletest at config time." OFF) +set(ABSL_LOCAL_GOOGLETEST_DIR "/usr/src/googletest" CACHE PATH + "If ABSL_USE_GOOGLETEST_HEAD is OFF, specifies the directory of a local googletest checkout." + ) + option(ABSL_RUN_TESTS "If ON, Abseil tests will be run." OFF) if(${ABSL_RUN_TESTS}) @@ -89,11 +100,13 @@ ## check targets if(BUILD_TESTING) + set(absl_gtest_build_dir ${CMAKE_BINARY_DIR}/googletest-build) if(${ABSL_USE_GOOGLETEST_HEAD}) - include(CMake/Googletest/DownloadGTest.cmake) set(absl_gtest_src_dir ${CMAKE_BINARY_DIR}/googletest-src) - set(absl_gtest_build_dir ${CMAKE_BINARY_DIR}/googletest-build) + else() + set(absl_gtest_src_dir ${ABSL_LOCAL_GOOGLETEST_DIR}) endif() + include(CMake/Googletest/DownloadGTest.cmake) check_target(gtest) check_target(gtest_main)
diff --git a/third_party/abseil-cpp/CONTRIBUTING.md b/third_party/abseil-cpp/CONTRIBUTING.md index f4cb4a29..9dadae9 100644 --- a/third_party/abseil-cpp/CONTRIBUTING.md +++ b/third_party/abseil-cpp/CONTRIBUTING.md
@@ -123,10 +123,13 @@ ## Running Tests -Use "bazel test <>" functionality to run the unit tests. +If you have [Bazel](https://bazel.build/) installed, use `bazel test +--test_tag_filters="-benchmark" ...` to run the unit tests. -Prerequisites for building and running tests are listed in -[README.md](README.md) +If you are running the Linux operating system and have +[Docker](https://www.docker.com/) installed, you can also run the `linux_*.sh` +scripts under the `ci/`(https://github.com/abseil/abseil-cpp/tree/master/ci) +directory to test Abseil under a variety of conditions. ## Abseil Committers
diff --git a/third_party/abseil-cpp/FAQ.md b/third_party/abseil-cpp/FAQ.md new file mode 100644 index 0000000..78028fc0 --- /dev/null +++ b/third_party/abseil-cpp/FAQ.md
@@ -0,0 +1,164 @@ +# Abseil FAQ + +## Is Abseil the right home for my utility library? + +Most often the answer to the question is "no." As both the [About +Abseil](https://abseil.io/about/) page and our [contributing +guidelines](https://github.com/abseil/abseil-cpp/blob/master/CONTRIBUTING.md#contribution-guidelines) +explain, Abseil contains a variety of core C++ library code that is widely used +at [Google](https://www.google.com/). As such, Abseil's primary purpose is to be +used as a dependency by Google's open source C++ projects. While we do hope that +Abseil is also useful to the C++ community at large, this added constraint also +means that we are unlikely to accept a contribution of utility code that isn't +already widely used by Google. + +## How to I set the C++ dialect used to build Abseil? + +The short answer is that whatever mechanism you choose, you need to make sure +that you set this option consistently at the global level for your entire +project. If, for example, you want to set the C++ dialect to C++17, with +[Bazel](https://bazel/build/) as the build system and `gcc` or `clang` as the +compiler, there several ways to do this: +* Pass `--cxxopt=-std=c++17` on the command line (for example, `bazel build + --cxxopt=-std=c++17 ...`) +* Set the environment variable `BAZEL_CXXOPTS` (for example, + `BAZEL_CXXOPTS=-std=c++17`) +* Add `build --cxxopt=-std=c++17` to your [`.bazelrc` + file](https://docs.bazel.build/versions/master/guide.html#bazelrc) + +If you are using CMake as the build system, you'll need to add a line like +`set(CMAKE_CXX_STANDARD 17)` to your top level `CMakeLists.txt` file. See the +[CMake build +instructions](https://github.com/abseil/abseil-cpp/blob/master/CMake/README.md) +for more information. + +For a longer answer to this question and to understand why some other approaches +don't work, see the answer to ["What is ABI and why don't you recommend using a +pre-compiled version of +Abseil?"](#what-is-abi-and-why-dont-you-recommend-using-a-pre-compiled-version-of-abseil) + +## What is ABI and why don't you recommend using a pre-compiled version of Abseil? + +For the purposes of this discussion, you can think of +[ABI](https://en.wikipedia.org/wiki/Application_binary_interface) as the +compiled representation of the interfaces in code. This is in contrast to +[API](https://en.wikipedia.org/wiki/Application_programming_interface), which +you can think of as the interfaces as defined by the code itself. [Abseil has a +strong promise of API compatibility, but does not make any promise of ABI +compatibility](https://abseil.io/about/compatibility). Let's take a look at what +this means in practice. + +You might be tempted to do something like this in a +[Bazel](https://bazel.build/) `BUILD` file: + +``` +# DON'T DO THIS!!! +cc_library( + name = "my_library", + srcs = ["my_library.cc"], + copts = ["-std=c++17"], # May create a mixed-mode compile! + deps = ["@com_google_absl//absl/strings"], +) +``` + +Applying `-std=c++17` to an individual target in your `BUILD` file is going to +compile that specific target in C++17 mode, but it isn't going to ensure the +Abseil library is built in C++17 mode, since the Abseil library itself is a +different build target. If your code includes an Abseil header, then your +program may contain conflicting definitions of the same +class/function/variable/enum, etc. As a rule, all compile options that affect +the ABI of a program need to be applied to the entire build on a global basis. + +C++ has something called the [One Definition +Rule](https://en.wikipedia.org/wiki/One_Definition_Rule) (ODR). C++ doesn't +allow multiple definitions of the same class/function/variable/enum, etc. ODR +violations sometimes result in linker errors, but linkers do not always catch +violations. Uncaught ODR violations can result in strange runtime behaviors or +crashes that can be hard to debug. + +If you build the Abseil library and your code using different compile options +that affect ABI, there is a good chance you will run afoul of the One Definition +Rule. Examples of GCC compile options that affect ABI include (but aren't +limited to) language dialect (e.g. `-std=`), optimization level (e.g. `-O2`), +code generation flags (e.g. `-fexceptions`), and preprocessor defines +(e.g. `-DNDEBUG`). + +If you use a pre-compiled version of Abseil, (for example, from your Linux +distribution package manager or from something like +[vcpkg](https://github.com/microsoft/vcpkg)) you have to be very careful to +ensure ABI compatibility across the components of your program. The only way you +can be sure your program is going to be correct regarding ABI is to ensure +you've used the exact same compile options as were used to build the +pre-compiled library. This does not mean that Abseil cannot work as part of a +Linux distribution since a knowledgeable binary packager will have ensured that +all packages have been built with consistent compile options. This is one of the +reasons we warn against - though do not outright reject - using Abseil as a +pre-compiled library. + +Another possible way that you might afoul of ABI issues is if you accidentally +include two versions of Abseil in your program. Multiple versions of Abseil can +end up within the same binary if your program uses the Abseil library and +another library also transitively depends on Abseil (resulting in what is +sometimes called the diamond dependency problem). In cases such as this you must +structure your build so that all libraries use the same version of Abseil. +[Abseil's strong promise of API compatibility between +releases](https://abseil.io/about/compatibility) means the latest "HEAD" release +of Abseil is almost certainly the right choice if you are doing as we recommend +and building all of your code from source. + +For these reasons we recommend you avoid pre-compiled code and build the Abseil +library yourself in a consistent manner with the rest of your code. + +## What is "live at head" and how do I do it? + +From Abseil's point-of-view, "live at head" means that every Abseil source +release (which happens on an almost daily basis) is either API compatible with +the previous release, or comes with an automated tool that you can run over code +to make it compatible. In practice, the need to use an automated tool is +extremely rare. This means that upgrading from one source release to another +should be a routine practice that can and should be performed often. + +We recommend you update to the [latest commit in the `master` branch of +Abseil](https://github.com/abseil/abseil-cpp/commits/master) as often as +possible. Not only will you pick up bug fixes more quickly, but if you have good +automated testing, you will catch and be able to fix any [Hyrum's +Law](https://www.hyrumslaw.com/) dependency problems on an incremental basis +instead of being overwhelmed by them and having difficulty isolating them if you +wait longer between updates. + +If you are using the [Bazel](https://bazel.build/) build system and its +[external dependencies](https://docs.bazel.build/versions/master/external.html) +feature, updating the +[`http_archive`](https://docs.bazel.build/versions/master/repo/http.html#http_archive) +rule in your +[`WORKSPACE`](https://docs.bazel.build/versions/master/be/workspace.html) for +`com_google_abseil` to point to the [latest commit in the `master` branch of +Abseil](https://github.com/abseil/abseil-cpp/commits/master) is all you need to +do. For example, on February 11, 2020, the latest commit to the master branch +was `98eb410c93ad059f9bba1bf43f5bb916fc92a5ea`. To update to this commit, you +would add the following snippet to your `WORKSPACE` file: + +``` +http_archive( + name = "com_google_absl", + urls = ["https://github.com/abseil/abseil-cpp/archive/98eb410c93ad059f9bba1bf43f5bb916fc92a5ea.zip"], # 2020-02-11T18:50:53Z + strip_prefix = "abseil-cpp-98eb410c93ad059f9bba1bf43f5bb916fc92a5ea", + sha256 = "aabf6c57e3834f8dc3873a927f37eaf69975d4b28117fc7427dfb1c661542a87", +) +``` + +To get the `sha256` of this URL, run `curl -sL --output - +https://github.com/abseil/abseil-cpp/archive/98eb410c93ad059f9bba1bf43f5bb916fc92a5ea.zip +| sha256sum -`. + +You can commit the updated `WORKSPACE` file to your source control every time +you update, and if you have good automated testing, you might even consider +automating this. + +One thing we don't recommend is using GitHub's `master.zip` files (for example +[https://github.com/abseil/abseil-cpp/archive/master.zip](https://github.com/abseil/abseil-cpp/archive/master.zip)), +which are always the latest commit in the `master` branch, to implement live at +head. Since these `master.zip` URLs are not versioned, you will lose build +reproducibility. In addition, some build systems, including Bazel, will simply +cache this file, which means you won't actually be updating to the latest +release until your cache is cleared or invalidated.
diff --git a/third_party/abseil-cpp/LTS.md b/third_party/abseil-cpp/LTS.md index 08606f15..ade8b17 100644 --- a/third_party/abseil-cpp/LTS.md +++ b/third_party/abseil-cpp/LTS.md
@@ -12,3 +12,5 @@ * [LTS Branch December 18, 2018](https://github.com/abseil/abseil-cpp/tree/lts_2018_12_18/) * [LTS Branch June 20, 2018](https://github.com/abseil/abseil-cpp/tree/lts_2018_06_20/) +* [LTS Branch August 8, 2019](https://github.com/abseil/abseil-cpp/tree/lts_2019_08_08/) +* [LTS Branch February 25, 2020](https://github.com/abseil/abseil-cpp/tree/lts_2020_02_25/)
diff --git a/third_party/abseil-cpp/README.chromium b/third_party/abseil-cpp/README.chromium index 5d7acba4..0257977 100644 --- a/third_party/abseil-cpp/README.chromium +++ b/third_party/abseil-cpp/README.chromium
@@ -4,7 +4,7 @@ License: Apache 2.0 License File: LICENSE Version: 0 -Revision: 4ef574064e75b86f115549e9eb4c7e806781b3ab +Revision: c6954897f7ece5011f0126db9117361dc1a6ff36 Security Critical: yes Description:
diff --git a/third_party/abseil-cpp/WORKSPACE b/third_party/abseil-cpp/WORKSPACE index 49e2d3cb6..f2b1046 100644 --- a/third_party/abseil-cpp/WORKSPACE +++ b/third_party/abseil-cpp/WORKSPACE
@@ -1,17 +1,22 @@ +# +# Copyright 2019 The Abseil Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + workspace(name = "com_google_absl") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -# Bazel toolchains -http_archive( - name = "bazel_toolchains", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/bc09b995c137df042bb80a395b73d7ce6f26afbe.tar.gz", - "https://github.com/bazelbuild/bazel-toolchains/archive/bc09b995c137df042bb80a395b73d7ce6f26afbe.tar.gz", - ], - strip_prefix = "bazel-toolchains-bc09b995c137df042bb80a395b73d7ce6f26afbe", - sha256 = "4329663fe6c523425ad4d3c989a8ac026b04e1acedeceb56aa4b190fa7f3973c", -) - # GoogleTest/GoogleMock framework. Used by most unit-tests. http_archive( name = "com_google_googletest", @@ -27,3 +32,14 @@ strip_prefix = "benchmark-16703ff83c1ae6d53e5155df3bb3ab0bc96083be", sha256 = "59f918c8ccd4d74b6ac43484467b500f1d64b40cc1010daa055375b322a43ba3", ) + +# C++ rules for Bazel. +http_archive( + name = "rules_cc", + sha256 = "9a446e9dd9c1bb180c86977a8dc1e9e659550ae732ae58bd2e8fd51e15b2c91d", + strip_prefix = "rules_cc-262ebec3c2296296526740db4aefce68c80de7fa", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_cc/archive/262ebec3c2296296526740db4aefce68c80de7fa.zip", + "https://github.com/bazelbuild/rules_cc/archive/262ebec3c2296296526740db4aefce68c80de7fa.zip", + ], +)
diff --git a/third_party/abseil-cpp/absl/BUILD.bazel b/third_party/abseil-cpp/absl/BUILD.bazel index 853330d4..5a03acf 100644 --- a/third_party/abseil-cpp/absl/BUILD.bazel +++ b/third_party/abseil-cpp/absl/BUILD.bazel
@@ -14,12 +14,15 @@ # limitations under the License. # +load( + ":compiler_config_setting.bzl", + "create_llvm_config", +) + package(default_visibility = ["//visibility:public"]) licenses(["notice"]) # Apache 2.0 -load(":compiler_config_setting.bzl", "create_llvm_config") - create_llvm_config( name = "llvm_compiler", visibility = [":__subpackages__"],
diff --git a/third_party/abseil-cpp/absl/CMakeLists.txt b/third_party/abseil-cpp/absl/CMakeLists.txt index 3e78397..fbfa7822 100644 --- a/third_party/abseil-cpp/absl/CMakeLists.txt +++ b/third_party/abseil-cpp/absl/CMakeLists.txt
@@ -14,20 +14,24 @@ # limitations under the License. # - - add_subdirectory(base) add_subdirectory(algorithm) add_subdirectory(container) add_subdirectory(debugging) add_subdirectory(flags) +add_subdirectory(functional) add_subdirectory(hash) add_subdirectory(memory) add_subdirectory(meta) add_subdirectory(numeric) add_subdirectory(random) +add_subdirectory(status) add_subdirectory(strings) add_subdirectory(synchronization) add_subdirectory(time) add_subdirectory(types) add_subdirectory(utility) + +if (${ABSL_BUILD_DLL}) + absl_make_dll() +endif()
diff --git a/third_party/abseil-cpp/absl/abseil.podspec.gen.py b/third_party/abseil-cpp/absl/abseil.podspec.gen.py new file mode 100755 index 0000000..6aefb79 --- /dev/null +++ b/third_party/abseil-cpp/absl/abseil.podspec.gen.py
@@ -0,0 +1,229 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""This script generates abseil.podspec from all BUILD.bazel files. + +This is expected to run on abseil git repository with Bazel 1.0 on Linux. +It recursively analyzes BUILD.bazel files using query command of Bazel to +dump its build rules in XML format. From these rules, it constructs podspec +structure. +""" + +import argparse +import collections +import os +import re +import subprocess +import xml.etree.ElementTree + +# Template of root podspec. +SPEC_TEMPLATE = """ +# This file has been automatically generated from a script. +# Please make modifications to `abseil.podspec.gen.py` instead. +Pod::Spec.new do |s| + s.name = 'abseil' + s.version = '${version}' + s.summary = 'Abseil Common Libraries (C++) from Google' + s.homepage = 'https://abseil.io' + s.license = 'Apache License, Version 2.0' + s.authors = { 'Abseil Team' => 'abseil-io@googlegroups.com' } + s.source = { + :git => 'https://github.com/abseil/abseil-cpp.git', + :tag => '${tag}', + } + s.module_name = 'absl' + s.header_mappings_dir = 'absl' + s.header_dir = 'absl' + s.libraries = 'c++' + s.compiler_flags = '-Wno-everything' + s.pod_target_xcconfig = { + 'USER_HEADER_SEARCH_PATHS' => '$(inherited) "$(PODS_TARGET_SRCROOT)"', + 'USE_HEADERMAP' => 'NO', + 'ALWAYS_SEARCH_USER_PATHS' => 'NO', + } + s.ios.deployment_target = '7.0' + s.osx.deployment_target = '10.9' + s.tvos.deployment_target = '9.0' + s.watchos.deployment_target = '2.0' +""" + +# Rule object representing the rule of Bazel BUILD. +Rule = collections.namedtuple( + "Rule", "type name package srcs hdrs textual_hdrs deps visibility testonly") + + +def get_elem_value(elem, name): + """Returns the value of XML element with the given name.""" + for child in elem: + if child.attrib.get("name") != name: + continue + if child.tag == "string": + return child.attrib.get("value") + if child.tag == "boolean": + return child.attrib.get("value") == "true" + if child.tag == "list": + return [nested_child.attrib.get("value") for nested_child in child] + raise "Cannot recognize tag: " + child.tag + return None + + +def normalize_paths(paths): + """Returns the list of normalized path.""" + # e.g. ["//absl/strings:dir/header.h"] -> ["absl/strings/dir/header.h"] + return [path.lstrip("/").replace(":", "/") for path in paths] + + +def parse_rule(elem, package): + """Returns a rule from bazel XML rule.""" + return Rule( + type=elem.attrib["class"], + name=get_elem_value(elem, "name"), + package=package, + srcs=normalize_paths(get_elem_value(elem, "srcs") or []), + hdrs=normalize_paths(get_elem_value(elem, "hdrs") or []), + textual_hdrs=normalize_paths(get_elem_value(elem, "textual_hdrs") or []), + deps=get_elem_value(elem, "deps") or [], + visibility=get_elem_value(elem, "visibility") or [], + testonly=get_elem_value(elem, "testonly") or False) + + +def read_build(package): + """Runs bazel query on given package file and returns all cc rules.""" + result = subprocess.check_output( + ["bazel", "query", package + ":all", "--output", "xml"]) + root = xml.etree.ElementTree.fromstring(result) + return [ + parse_rule(elem, package) + for elem in root + if elem.tag == "rule" and elem.attrib["class"].startswith("cc_") + ] + + +def collect_rules(root_path): + """Collects and returns all rules from root path recursively.""" + rules = [] + for cur, _, _ in os.walk(root_path): + build_path = os.path.join(cur, "BUILD.bazel") + if os.path.exists(build_path): + rules.extend(read_build("//" + cur)) + return rules + + +def relevant_rule(rule): + """Returns true if a given rule is relevant when generating a podspec.""" + return ( + # cc_library only (ignore cc_test, cc_binary) + rule.type == "cc_library" and + # ignore empty rule + (rule.hdrs + rule.textual_hdrs + rule.srcs) and + # ignore test-only rule + not rule.testonly) + + +def get_spec_var(depth): + """Returns the name of variable for spec with given depth.""" + return "s" if depth == 0 else "s{}".format(depth) + + +def get_spec_name(label): + """Converts the label of bazel rule to the name of podspec.""" + assert label.startswith("//absl/"), "{} doesn't start with //absl/".format( + label) + # e.g. //absl/apple/banana -> abseil/apple/banana + return "abseil/" + label[7:] + + +def write_podspec(f, rules, args): + """Writes a podspec from given rules and args.""" + rule_dir = build_rule_directory(rules)["abseil"] + # Write root part with given arguments + spec = re.sub(r"\$\{(\w+)\}", lambda x: args[x.group(1)], + SPEC_TEMPLATE).lstrip() + f.write(spec) + # Write all target rules + write_podspec_map(f, rule_dir, 0) + f.write("end\n") + + +def build_rule_directory(rules): + """Builds a tree-style rule directory from given rules.""" + rule_dir = {} + for rule in rules: + cur = rule_dir + for frag in get_spec_name(rule.package).split("/"): + cur = cur.setdefault(frag, {}) + cur[rule.name] = rule + return rule_dir + + +def write_podspec_map(f, cur_map, depth): + """Writes podspec from rule map recursively.""" + for key, value in sorted(cur_map.items()): + indent = " " * (depth + 1) + f.write("{indent}{var0}.subspec '{key}' do |{var1}|\n".format( + indent=indent, + key=key, + var0=get_spec_var(depth), + var1=get_spec_var(depth + 1))) + if isinstance(value, dict): + write_podspec_map(f, value, depth + 1) + else: + write_podspec_rule(f, value, depth + 1) + f.write("{indent}end\n".format(indent=indent)) + + +def write_podspec_rule(f, rule, depth): + """Writes podspec from given rule.""" + indent = " " * (depth + 1) + spec_var = get_spec_var(depth) + # Puts all files in hdrs, textual_hdrs, and srcs into source_files. + # Since CocoaPods treats header_files a bit differently from bazel, + # this won't generate a header_files field so that all source_files + # are considered as header files. + srcs = sorted(set(rule.hdrs + rule.textual_hdrs + rule.srcs)) + write_indented_list( + f, "{indent}{var}.source_files = ".format(indent=indent, var=spec_var), + srcs) + # Writes dependencies of this rule. + for dep in sorted(rule.deps): + name = get_spec_name(dep.replace(":", "/")) + f.write("{indent}{var}.dependency '{dep}'\n".format( + indent=indent, var=spec_var, dep=name)) + + +def write_indented_list(f, leading, values): + """Writes leading values in an indented style.""" + f.write(leading) + f.write((",\n" + " " * len(leading)).join("'{}'".format(v) for v in values)) + f.write("\n") + + +def generate(args): + """Generates a podspec file from all BUILD files under absl directory.""" + rules = filter(relevant_rule, collect_rules("absl")) + with open(args.output, "wt") as f: + write_podspec(f, rules, vars(args)) + + +def main(): + parser = argparse.ArgumentParser( + description="Generates abseil.podspec from BUILD.bazel") + parser.add_argument( + "-v", "--version", help="The version of podspec", required=True) + parser.add_argument( + "-t", + "--tag", + default=None, + help="The name of git tag (default: version)") + parser.add_argument( + "-o", + "--output", + default="abseil.podspec", + help="The name of output file (default: abseil.podspec)") + args = parser.parse_args() + if args.tag is None: + args.tag = args.version + generate(args) + + +if __name__ == "__main__": + main()
diff --git a/third_party/abseil-cpp/absl/algorithm/BUILD.bazel b/third_party/abseil-cpp/absl/algorithm/BUILD.bazel index c506f3b..6a96420 100644 --- a/third_party/abseil-cpp/absl/algorithm/BUILD.bazel +++ b/third_party/abseil-cpp/absl/algorithm/BUILD.bazel
@@ -14,6 +14,7 @@ # limitations under the License. # +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", @@ -30,6 +31,7 @@ hdrs = ["algorithm.h"], copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, + deps = ["//absl/base:config"], ) cc_test(
diff --git a/third_party/abseil-cpp/absl/algorithm/BUILD.gn b/third_party/abseil-cpp/absl/algorithm/BUILD.gn index 350ed5f..21f4aa1 100644 --- a/third_party/abseil-cpp/absl/algorithm/BUILD.gn +++ b/third_party/abseil-cpp/absl/algorithm/BUILD.gn
@@ -25,6 +25,7 @@ ] public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] public = [ "algorithm.h" ] + deps = [ "../base:config" ] } source_set("container") {
diff --git a/third_party/abseil-cpp/absl/algorithm/CMakeLists.txt b/third_party/abseil-cpp/absl/algorithm/CMakeLists.txt index 9fbe36f..56cd0fb 100644 --- a/third_party/abseil-cpp/absl/algorithm/CMakeLists.txt +++ b/third_party/abseil-cpp/absl/algorithm/CMakeLists.txt
@@ -21,6 +21,8 @@ "algorithm.h" COPTS ${ABSL_DEFAULT_COPTS} + DEPS + absl::config PUBLIC )
diff --git a/third_party/abseil-cpp/absl/algorithm/algorithm.h b/third_party/abseil-cpp/absl/algorithm/algorithm.h index bb90215d..e9b4733 100644 --- a/third_party/abseil-cpp/absl/algorithm/algorithm.h +++ b/third_party/abseil-cpp/absl/algorithm/algorithm.h
@@ -26,7 +26,10 @@ #include <iterator> #include <type_traits> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace algorithm_internal { @@ -84,6 +87,8 @@ } // namespace algorithm_internal +// equal() +// // Compares the equality of two ranges specified by pairs of iterators, using // the given predicate, returning true iff for each corresponding iterator i1 // and i2 in the first and second range respectively, pred(*i1, *i2) == true @@ -104,8 +109,8 @@ typename std::iterator_traits<InputIter2>::iterator_category{}); } -// Performs comparison of two ranges specified by pairs of iterators using -// operator==. +// Overload of equal() that performs comparison of two ranges specified by pairs +// of iterators using operator==. template <typename InputIter1, typename InputIter2> bool equal(InputIter1 first1, InputIter1 last1, InputIter2 first2, InputIter2 last2) { @@ -113,6 +118,8 @@ algorithm_internal::EqualTo{}); } +// linear_search() +// // Performs a linear search for `value` using the iterator `first` up to // but not including `last`, returning true if [`first`, `last`) contains an // element equal to `value`. @@ -126,6 +133,8 @@ return std::find(first, last, value) != last; } +// rotate() +// // Performs a left rotation on a range of elements (`first`, `last`) such that // `middle` is now the first element. `rotate()` returns an iterator pointing to // the first element before rotation. This function is exactly the same as @@ -135,7 +144,6 @@ // The complexity of this algorithm is the same as that of `std::rotate`, but if // `ForwardIterator` is not a random-access iterator, then `absl::rotate` // performs an additional pass over the range to construct the return value. - template <typename ForwardIterator> ForwardIterator rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last) { @@ -145,6 +153,7 @@ ForwardIterator>()); } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_ALGORITHM_ALGORITHM_H_
diff --git a/third_party/abseil-cpp/absl/algorithm/container.h b/third_party/abseil-cpp/absl/algorithm/container.h index c84de46..d72532d 100644 --- a/third_party/abseil-cpp/absl/algorithm/container.h +++ b/third_party/abseil-cpp/absl/algorithm/container.h
@@ -55,6 +55,7 @@ #include "absl/meta/type_traits.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_algorithm_internal { // NOTE: it is important to defer to ADL lookup for building with C++ modules, @@ -112,6 +113,18 @@ struct IsUnorderedContainer<std::unordered_set<Key, Hash, KeyEqual, Allocator>> : std::true_type {}; +// container_algorithm_internal::c_size. It is meant for internal use only. + +template <class C> +auto c_size(C& c) -> decltype(c.size()) { + return c.size(); +} + +template <class T, std::size_t N> +constexpr std::size_t c_size(T (&)[N]) { + return N; +} + } // namespace container_algorithm_internal // PUBLIC API @@ -256,7 +269,8 @@ // c_find_first_of() // // Container-based version of the <algorithm> `std::find_first_of()` function to -// find the first elements in an ordered set within a container. +// find the first element within the container that is also within the options +// container. template <typename C1, typename C2> container_algorithm_internal::ContainerIter<C1> c_find_first_of(C1& container, C2& options) { @@ -365,7 +379,8 @@ template <typename C1, typename C2> bool c_equal(const C1& c1, const C2& c2) { - return ((c1.size() == c2.size()) && + return ((container_algorithm_internal::c_size(c1) == + container_algorithm_internal::c_size(c2)) && std::equal(container_algorithm_internal::c_begin(c1), container_algorithm_internal::c_end(c1), container_algorithm_internal::c_begin(c2))); @@ -375,7 +390,8 @@ // the function's test condition. template <typename C1, typename C2, typename BinaryPredicate> bool c_equal(const C1& c1, const C2& c2, BinaryPredicate&& pred) { - return ((c1.size() == c2.size()) && + return ((container_algorithm_internal::c_size(c1) == + container_algorithm_internal::c_size(c2)) && std::equal(container_algorithm_internal::c_begin(c1), container_algorithm_internal::c_end(c1), container_algorithm_internal::c_begin(c2), @@ -1705,6 +1721,7 @@ output_first, std::forward<BinaryOp>(op)); } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_ALGORITHM_CONTAINER_H_
diff --git a/third_party/abseil-cpp/absl/algorithm/container_test.cc b/third_party/abseil-cpp/absl/algorithm/container_test.cc index 86bf9d3..0a4abe9 100644 --- a/third_party/abseil-cpp/absl/algorithm/container_test.cc +++ b/third_party/abseil-cpp/absl/algorithm/container_test.cc
@@ -163,23 +163,29 @@ TEST_F(NonMutatingTest, Equal) { EXPECT_TRUE(absl::c_equal(vector_, sequence_)); EXPECT_TRUE(absl::c_equal(sequence_, vector_)); + EXPECT_TRUE(absl::c_equal(sequence_, array_)); + EXPECT_TRUE(absl::c_equal(array_, vector_)); // Test that behavior appropriately differs from that of equal(). std::vector<int> vector_plus = {1, 2, 3}; vector_plus.push_back(4); EXPECT_FALSE(absl::c_equal(vector_plus, sequence_)); EXPECT_FALSE(absl::c_equal(sequence_, vector_plus)); + EXPECT_FALSE(absl::c_equal(array_, vector_plus)); } TEST_F(NonMutatingTest, EqualWithPredicate) { EXPECT_TRUE(absl::c_equal(vector_, sequence_, Equals)); EXPECT_TRUE(absl::c_equal(sequence_, vector_, Equals)); + EXPECT_TRUE(absl::c_equal(array_, sequence_, Equals)); + EXPECT_TRUE(absl::c_equal(vector_, array_, Equals)); // Test that behavior appropriately differs from that of equal(). std::vector<int> vector_plus = {1, 2, 3}; vector_plus.push_back(4); EXPECT_FALSE(absl::c_equal(vector_plus, sequence_, Equals)); EXPECT_FALSE(absl::c_equal(sequence_, vector_plus, Equals)); + EXPECT_FALSE(absl::c_equal(vector_plus, array_, Equals)); } TEST_F(NonMutatingTest, IsPermutation) {
diff --git a/third_party/abseil-cpp/absl/base/BUILD.bazel b/third_party/abseil-cpp/absl/base/BUILD.bazel index a512272..bae7942 100644 --- a/third_party/abseil-cpp/absl/base/BUILD.bazel +++ b/third_party/abseil-cpp/absl/base/BUILD.bazel
@@ -14,12 +14,11 @@ # limitations under the License. # +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", "ABSL_DEFAULT_LINKOPTS", - "ABSL_EXCEPTIONS_FLAG", - "ABSL_EXCEPTIONS_FLAG_LINKOPTS", "ABSL_TEST_COPTS", ) @@ -35,6 +34,21 @@ visibility = [ "//absl:__subpackages__", ], + deps = [ + ":config", + ":core_headers", + ], +) + +cc_library( + name = "errno_saver", + hdrs = ["internal/errno_saver.h"], + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + visibility = [ + "//absl:__subpackages__", + ], + deps = [":config"], ) cc_library( @@ -43,16 +57,27 @@ hdrs = ["log_severity.h"], copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, - deps = [":core_headers"], + deps = [ + ":config", + ":core_headers", + ], ) cc_library( name = "raw_logging_internal", + srcs = ["internal/raw_logging.cc"], + hdrs = ["internal/raw_logging.h"], copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, visibility = [ "//absl:__subpackages__", ], + deps = [ + ":atomic_hook", + ":config", + ":core_headers", + ":log_severity", + ], ) cc_library( @@ -64,22 +89,24 @@ "internal/spinlock_wait.cc", "internal/spinlock_win32.inc", ], - hdrs = [ - "internal/scheduling_mode.h", - "internal/spinlock_wait.h", - ], + hdrs = ["internal/spinlock_wait.h"], copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, visibility = [ "//absl/base:__pkg__", ], - deps = [":core_headers"], + deps = [ + ":base_internal", + ":core_headers", + ":errno_saver", + ], ) cc_library( name = "config", hdrs = [ "config.h", + "options.h", "policy_checks.h", ], copts = ABSL_DEFAULT_COPTS, @@ -130,14 +157,15 @@ "//conditions:default": ["-pthread"], }) + ABSL_DEFAULT_LINKOPTS, visibility = [ - "//absl:__subpackages__", + "//visibility:public", ], deps = [ ":base", + ":base_internal", ":config", ":core_headers", ":dynamic_annotations", - ":spinlock_wait", + ":raw_logging_internal", ], ) @@ -156,6 +184,7 @@ "//absl:__subpackages__", ], deps = [ + ":config", "//absl/meta:type_traits", ], ) @@ -164,7 +193,6 @@ name = "base", srcs = [ "internal/cycleclock.cc", - "internal/raw_logging.cc", "internal/spinlock.cc", "internal/sysinfo.cc", "internal/thread_identity.cc", @@ -176,7 +204,6 @@ "internal/cycleclock.h", "internal/low_level_scheduling.h", "internal/per_thread_tls.h", - "internal/raw_logging.h", "internal/spinlock.h", "internal/sysinfo.h", "internal/thread_identity.h", @@ -185,7 +212,9 @@ ], copts = ABSL_DEFAULT_COPTS, linkopts = select({ - "//absl:windows": [], + "//absl:windows": [ + "-DEFAULTLIB:advapi32.lib", + ], "//conditions:default": ["-pthread"], }) + ABSL_DEFAULT_LINKOPTS, deps = [ @@ -195,11 +224,25 @@ ":core_headers", ":dynamic_annotations", ":log_severity", + ":raw_logging_internal", ":spinlock_wait", "//absl/meta:type_traits", ], ) +cc_library( + name = "atomic_hook_test_helper", + testonly = 1, + srcs = ["internal/atomic_hook_test_helper.cc"], + hdrs = ["internal/atomic_hook_test_helper.h"], + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + ":atomic_hook", + ":core_headers", + ], +) + cc_test( name = "atomic_hook_test", size = "small", @@ -208,6 +251,7 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":atomic_hook", + ":atomic_hook_test_helper", ":core_headers", "@com_google_googletest//:gtest_main", ], @@ -232,28 +276,41 @@ name = "throw_delegate", srcs = ["internal/throw_delegate.cc"], hdrs = ["internal/throw_delegate.h"], - copts = ABSL_DEFAULT_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, visibility = [ "//absl:__subpackages__", ], deps = [ - ":base", ":config", + ":raw_logging_internal", ], ) cc_test( name = "throw_delegate_test", srcs = ["throw_delegate_test.cc"], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ + ":config", ":throw_delegate", "@com_google_googletest//:gtest_main", ], ) +cc_test( + name = "errno_saver_test", + size = "small", + srcs = ["internal/errno_saver_test.cc"], + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + ":errno_saver", + "@com_google_googletest//:gtest_main", + ], +) + cc_library( name = "exception_testing", testonly = 1, @@ -281,8 +338,8 @@ testonly = 1, srcs = ["internal/exception_safety_testing.cc"], hdrs = ["internal/exception_safety_testing.h"], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":config", ":pretty_function", @@ -297,8 +354,8 @@ cc_test( name = "exception_safety_testing_test", srcs = ["exception_safety_testing_test.cc"], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":exception_safety_testing", "//absl/memory", @@ -347,8 +404,8 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":base", + ":base_internal", ":core_headers", - ":spinlock_wait", "//absl/synchronization", "@com_google_googletest//:gtest", ], @@ -363,8 +420,8 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":base", + ":base_internal", ":core_headers", - ":spinlock_wait", "//absl/synchronization", "@com_google_googletest//:gtest_main", ], @@ -382,6 +439,7 @@ deps = [ ":base", ":base_internal", + ":raw_logging_internal", "//absl/synchronization", "@com_github_google_benchmark//:benchmark_main", ], @@ -455,7 +513,7 @@ copts = ABSL_TEST_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ - ":base", + ":raw_logging_internal", "//absl/strings", "@com_google_googletest//:gtest_main", ], @@ -519,7 +577,10 @@ visibility = [ "//absl:__subpackages__", ], - deps = [":core_headers"], + deps = [ + ":config", + ":core_headers", + ], ) cc_test( @@ -535,6 +596,75 @@ ) cc_library( + name = "exponential_biased", + srcs = ["internal/exponential_biased.cc"], + hdrs = ["internal/exponential_biased.h"], + linkopts = ABSL_DEFAULT_LINKOPTS, + visibility = [ + "//absl:__subpackages__", + ], + deps = [ + ":config", + ":core_headers", + ], +) + +cc_test( + name = "exponential_biased_test", + size = "small", + srcs = ["internal/exponential_biased_test.cc"], + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + visibility = ["//visibility:private"], + deps = [ + ":exponential_biased", + "//absl/strings", + "@com_google_googletest//:gtest_main", + ], +) + +cc_library( + name = "periodic_sampler", + srcs = ["internal/periodic_sampler.cc"], + hdrs = ["internal/periodic_sampler.h"], + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + ":core_headers", + ":exponential_biased", + ], +) + +cc_test( + name = "periodic_sampler_test", + size = "small", + srcs = ["internal/periodic_sampler_test.cc"], + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + visibility = ["//visibility:private"], + deps = [ + ":core_headers", + ":periodic_sampler", + "@com_google_googletest//:gtest_main", + ], +) + +cc_binary( + name = "periodic_sampler_benchmark", + testonly = 1, + srcs = ["internal/periodic_sampler_benchmark.cc"], + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + tags = ["benchmark"], + visibility = ["//visibility:private"], + deps = [ + ":core_headers", + ":periodic_sampler", + "@com_github_google_benchmark//:benchmark_main", + ], +) + +cc_library( name = "scoped_set_env", testonly = 1, srcs = ["internal/scoped_set_env.cc"], @@ -543,7 +673,10 @@ visibility = [ "//absl:__subpackages__", ], - deps = [":base"], + deps = [ + ":config", + ":raw_logging_internal", + ], ) cc_test( @@ -565,8 +698,10 @@ copts = ABSL_TEST_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ - ":base", ":log_severity", + "//absl/flags:flag_internal", + "//absl/flags:marshalling", + "//absl/strings", "@com_google_googletest//:gtest_main", ], )
diff --git a/third_party/abseil-cpp/absl/base/BUILD.gn b/third_party/abseil-cpp/absl/base/BUILD.gn index 3d555b5..eba7617 100644 --- a/third_party/abseil-cpp/absl/base/BUILD.gn +++ b/third_party/abseil-cpp/absl/base/BUILD.gn
@@ -25,7 +25,25 @@ ] public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] public = [ "internal/atomic_hook.h" ] - deps = [ ":core_headers" ] + deps = [ + ":config", + ":core_headers", + ] + visibility = [] + visibility += [ "../*" ] +} + +source_set("errno_saver") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] + public = [ "internal/errno_saver.h" ] + deps = [ + ":config", + ] visibility = [] visibility += [ "../*" ] } @@ -39,7 +57,10 @@ public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] sources = [ "log_severity.cc" ] public = [ "log_severity.h" ] - deps = [ ":core_headers" ] + deps = [ + ":config", + ":core_headers", + ] } source_set("raw_logging_internal") { @@ -49,6 +70,14 @@ "//third_party/abseil-cpp:absl_default_cflags_cc", ] public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] + sources = [ "internal/raw_logging.cc" ] + public = [ "internal/raw_logging.h" ] + deps = [ + ":atomic_hook", + ":config", + ":core_headers", + ":log_severity", + ] visibility = [] visibility += [ "../*" ] } @@ -68,10 +97,13 @@ "internal/spinlock_win32.inc", ] public = [ - "internal/scheduling_mode.h", "internal/spinlock_wait.h", ] - deps = [ ":core_headers" ] + deps = [ + ":base_internal", + ":core_headers", + ":errno_saver", + ] visibility = [] visibility += [ "../base:*" ] } @@ -85,6 +117,7 @@ public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] public = [ "config.h", + "options.h", "policy_checks.h", ] } @@ -144,13 +177,12 @@ ] deps = [ ":base", + ":base_internal", ":config", ":core_headers", ":dynamic_annotations", - ":spinlock_wait", + ":raw_logging_internal", ] - visibility = [] - visibility += [ "../*" ] } source_set("base_internal") { @@ -167,7 +199,10 @@ "internal/invoke.h", "internal/scheduling_mode.h", ] - deps = [ "../meta:type_traits" ] + deps = [ + ":config", + "../meta:type_traits", + ] visibility = [] visibility += [ "../*" ] } @@ -181,7 +216,6 @@ public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] sources = [ "internal/cycleclock.cc", - "internal/raw_logging.cc", "internal/spinlock.cc", "internal/sysinfo.cc", "internal/thread_identity.cc", @@ -193,13 +227,15 @@ "internal/cycleclock.h", "internal/low_level_scheduling.h", "internal/per_thread_tls.h", - "internal/raw_logging.h", "internal/spinlock.h", "internal/sysinfo.h", "internal/thread_identity.h", "internal/tsan_mutex_interface.h", "internal/unscaledcycleclock.h", ] + # TODO(mbonadei): The bazel file has: + # "-DEFAULTLIB:advapi32.lib" + # understand if this is needed here as well. deps = [ ":atomic_hook", ":base_internal", @@ -207,6 +243,7 @@ ":core_headers", ":dynamic_annotations", ":log_severity", + ":raw_logging_internal", ":spinlock_wait", "../meta:type_traits", ] @@ -222,8 +259,8 @@ sources = [ "internal/throw_delegate.cc" ] public = [ "internal/throw_delegate.h" ] deps = [ - ":base", ":config", + ":raw_logging_internal", ] visibility = [] visibility += [ "../*" ] @@ -293,8 +330,8 @@ sources = [ "spinlock_test_common.cc" ] deps = [ ":base", + ":base_internal", ":core_headers", - ":spinlock_wait", "../synchronization", "//testing/gtest", ] @@ -324,11 +361,44 @@ "//third_party/abseil-cpp:absl_default_cflags_cc", ] public = [ "internal/bits.h" ] - deps = [ ":core_headers" ] + deps = [ + ":config", + ":core_headers", + ] visibility = [] visibility += [ "../*" ] } +source_set("exponential_biased") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + sources = [ "internal/exponential_biased.cc" ] + public = [ "internal/exponential_biased.h" ] + deps = [ + ":config", + ":core_headers", + ] + visibility = [] + visibility += [ "../*" ] +} + +source_set("periodic_sampler") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + sources = [ "internal/periodic_sampler.cc" ] + public = [ "internal/periodic_sampler.h" ] + deps = [ + ":core_headers", + ":exponential_biased", + ] +} + source_set("scoped_set_env") { testonly = true configs -= [ "//build/config/compiler:chromium_code" ] @@ -338,7 +408,10 @@ ] public = [ "internal/scoped_set_env.h" ] sources = [ "internal/scoped_set_env.cc" ] - deps = [ ":base" ] + deps = [ + ":config", + ":raw_logging_internal", + ] visibility = [] visibility += [ "../*" ] }
diff --git a/third_party/abseil-cpp/absl/base/CMakeLists.txt b/third_party/abseil-cpp/absl/base/CMakeLists.txt index cc7960e3..14c52eab 100644 --- a/third_party/abseil-cpp/absl/base/CMakeLists.txt +++ b/third_party/abseil-cpp/absl/base/CMakeLists.txt
@@ -14,11 +14,27 @@ # limitations under the License. # +find_library(LIBRT rt) + absl_cc_library( NAME atomic_hook HDRS "internal/atomic_hook.h" + DEPS + absl::config + absl::core_headers + COPTS + ${ABSL_DEFAULT_COPTS} +) + +absl_cc_library( + NAME + errno_saver + HDRS + "internal/errno_saver.h" + DEPS + absl::config COPTS ${ABSL_DEFAULT_COPTS} ) @@ -39,6 +55,15 @@ absl_cc_library( NAME raw_logging_internal + HDRS + "internal/raw_logging.h" + SRCS + "internal/raw_logging.cc" + DEPS + absl::atomic_hook + absl::config + absl::core_headers + absl::log_severity COPTS ${ABSL_DEFAULT_COPTS} ) @@ -47,7 +72,6 @@ NAME spinlock_wait HDRS - "internal/scheduling_mode.h" "internal/spinlock_wait.h" SRCS "internal/spinlock_akaros.inc" @@ -58,7 +82,9 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS + absl::base_internal absl::core_headers + absl::errno_saver ) absl_cc_library( @@ -66,6 +92,7 @@ config HDRS "config.h" + "options.h" "policy_checks.h" COPTS ${ABSL_DEFAULT_COPTS} @@ -116,10 +143,11 @@ ${ABSL_DEFAULT_COPTS} DEPS absl::base + absl::base_internal absl::config absl::core_headers absl::dynamic_annotations - absl::spinlock_wait + absl::raw_logging_internal Threads::Threads ) @@ -131,9 +159,11 @@ "internal/identity.h" "internal/inline_variable.h" "internal/invoke.h" + "internal/scheduling_mode.h" COPTS ${ABSL_DEFAULT_COPTS} DEPS + absl::config absl::type_traits ) @@ -146,23 +176,23 @@ "internal/cycleclock.h" "internal/low_level_scheduling.h" "internal/per_thread_tls.h" - "internal/raw_logging.h" "internal/spinlock.h" "internal/sysinfo.h" "internal/thread_identity.h" "internal/tsan_mutex_interface.h" "internal/unscaledcycleclock.h" - "log_severity.h" SRCS "internal/cycleclock.cc" - "internal/raw_logging.cc" "internal/spinlock.cc" "internal/sysinfo.cc" "internal/thread_identity.cc" "internal/unscaledcycleclock.cc" - "log_severity.cc" COPTS ${ABSL_DEFAULT_COPTS} + LINKOPTS + ${ABSL_DEFAULT_LINKOPTS} + $<$<BOOL:${LIBRT}>:${LIBRT}> + $<$<BOOL:${MINGW}>:"advapi32"> DEPS absl::atomic_hook absl::base_internal @@ -170,6 +200,7 @@ absl::core_headers absl::dynamic_annotations absl::log_severity + absl::raw_logging_internal absl::spinlock_wait absl::type_traits Threads::Threads @@ -185,9 +216,9 @@ "internal/throw_delegate.cc" COPTS ${ABSL_DEFAULT_COPTS} - ${ABSL_EXCEPTIONS_FLAG} DEPS - absl::base + absl::config + absl::raw_logging_internal ) absl_cc_library( @@ -221,9 +252,6 @@ "internal/exception_safety_testing.cc" COPTS ${ABSL_TEST_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS absl::config absl::pretty_function @@ -242,15 +270,25 @@ "exception_safety_testing_test.cc" COPTS ${ABSL_TEST_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS absl::exception_safety_testing absl::memory gtest_main ) +absl_cc_library( + NAME + atomic_hook_test_helper + SRCS + "internal/atomic_hook_test_helper.cc" + COPTS + ${ABSL_TEST_COPTS} + DEPS + absl::atomic_hook + absl::core_headers + TESTONLY +) + absl_cc_test( NAME atomic_hook_test @@ -259,8 +297,10 @@ COPTS ${ABSL_TEST_COPTS} DEPS + absl::atomic_hook_test_helper absl::atomic_hook absl::core_headers + gmock gtest_main ) @@ -279,6 +319,19 @@ absl_cc_test( NAME + errno_saver_test + SRCS + "internal/errno_saver_test.cc" + COPTS + ${ABSL_TEST_COPTS} + DEPS + absl::errno_saver + gmock + gtest_main +) + +absl_cc_test( + NAME throw_delegate_test SRCS "throw_delegate_test.cc" @@ -286,6 +339,7 @@ ${ABSL_TEST_COPTS} DEPS absl::base + absl::config absl::throw_delegate gtest_main ) @@ -329,8 +383,8 @@ ${ABSL_TEST_COPTS} DEPS absl::base + absl::base_internal absl::core_headers - absl::spinlock_wait absl::synchronization gtest TESTONLY @@ -346,8 +400,8 @@ ${ABSL_TEST_COPTS} DEPS absl::base + absl::base_internal absl::core_headers - absl::spinlock_wait absl::synchronization gtest_main ) @@ -415,7 +469,7 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::base + absl::raw_logging_internal absl::strings gtest_main ) @@ -468,6 +522,7 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS + absl::config absl::core_headers ) @@ -485,6 +540,60 @@ absl_cc_library( NAME + exponential_biased + SRCS + "internal/exponential_biased.cc" + HDRS + "internal/exponential_biased.h" + COPTS + ${ABSL_DEFAULT_COPTS} + DEPS + absl::config + absl::core_headers +) + +absl_cc_test( + NAME + exponential_biased_test + SRCS + "internal/exponential_biased_test.cc" + COPTS + ${ABSL_TEST_COPTS} + DEPS + absl::exponential_biased + absl::strings + gmock_main +) + +absl_cc_library( + NAME + periodic_sampler + SRCS + "internal/periodic_sampler.cc" + HDRS + "internal/periodic_sampler.h" + COPTS + ${ABSL_DEFAULT_COPTS} + DEPS + absl::core_headers + absl::exponential_biased +) + +absl_cc_test( + NAME + periodic_sampler_test + SRCS + "internal/periodic_sampler_test.cc" + COPTS + ${ABSL_TEST_COPTS} + DEPS + absl::core_headers + absl::periodic_sampler + gmock_main +) + +absl_cc_library( + NAME scoped_set_env SRCS "internal/scoped_set_env.cc" @@ -493,7 +602,8 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::base + absl::config + absl::raw_logging_internal ) absl_cc_test( @@ -525,8 +635,10 @@ SRCS "log_severity_test.cc" DEPS - absl::base + absl::flags_internal + absl::flags_marshalling absl::log_severity + absl::strings gmock gtest_main )
diff --git a/third_party/abseil-cpp/absl/base/attributes.h b/third_party/abseil-cpp/absl/base/attributes.h index a7da62a..b4bb6cf 100644 --- a/third_party/abseil-cpp/absl/base/attributes.h +++ b/third_party/abseil-cpp/absl/base/attributes.h
@@ -157,10 +157,12 @@ // Tags a function as weak for the purposes of compilation and linking. // Weak attributes currently do not work properly in LLVM's Windows backend, // so disable them there. See https://bugs.llvm.org/show_bug.cgi?id=37598 -// for futher information. -#if (ABSL_HAVE_ATTRIBUTE(weak) || \ +// for further information. +// The MinGW compiler doesn't complain about the weak attribute until the link +// step, presumably because Windows doesn't use ELF binaries. +#if (ABSL_HAVE_ATTRIBUTE(weak) || \ (defined(__GNUC__) && !defined(__clang__))) && \ - !(defined(__llvm__) && defined(_WIN32)) + !(defined(__llvm__) && defined(_WIN32)) && !defined(__MINGW32__) #undef ABSL_ATTRIBUTE_WEAK #define ABSL_ATTRIBUTE_WEAK __attribute__((weak)) #define ABSL_HAVE_ATTRIBUTE_WEAK 1 @@ -505,8 +507,10 @@ // packages/targets, as this may lead to conflicting definitions of functions at // link-time. // +// XRay isn't currently supported on Android: +// https://github.com/android/ndk/issues/368 #if ABSL_HAVE_CPP_ATTRIBUTE(clang::xray_always_instrument) && \ - !defined(ABSL_NO_XRAY_ATTRIBUTES) + !defined(ABSL_NO_XRAY_ATTRIBUTES) && !defined(__ANDROID__) #define ABSL_XRAY_ALWAYS_INSTRUMENT [[clang::xray_always_instrument]] #define ABSL_XRAY_NEVER_INSTRUMENT [[clang::xray_never_instrument]] #if ABSL_HAVE_CPP_ATTRIBUTE(clang::xray_log_args) @@ -561,7 +565,19 @@ // ABSL_ATTRIBUTE_PACKED // -// Prevents the compiler from padding a structure to natural alignment +// Instructs the compiler not to use natural alignment for a tagged data +// structure, but instead to reduce its alignment to 1. This attribute can +// either be applied to members of a structure or to a structure in its +// entirety. Applying this attribute (judiciously) to a structure in its +// entirety to optimize the memory footprint of very commonly-used structs is +// fine. Do not apply this attribute to a structure in its entirety if the +// purpose is to control the offsets of the members in the structure. Instead, +// apply this attribute only to structure members that need it. +// +// When applying ABSL_ATTRIBUTE_PACKED only to specific structure members the +// natural alignment of structure members not annotated is preserved. Aligned +// member accesses are faster than non-aligned member accesses even if the +// targeted microprocessor supports non-aligned accesses. #if ABSL_HAVE_ATTRIBUTE(packed) || (defined(__GNUC__) && !defined(__clang__)) #define ABSL_ATTRIBUTE_PACKED __attribute__((__packed__)) #else @@ -599,7 +615,6 @@ // // Note that this attribute is redundant if the variable is declared constexpr. #if ABSL_HAVE_CPP_ATTRIBUTE(clang::require_constant_initialization) -// NOLINTNEXTLINE(whitespace/braces) #define ABSL_CONST_INIT [[clang::require_constant_initialization]] #else #define ABSL_CONST_INIT
diff --git a/third_party/abseil-cpp/absl/base/bit_cast_test.cc b/third_party/abseil-cpp/absl/base/bit_cast_test.cc index 4846add4..8a3a41e 100644 --- a/third_party/abseil-cpp/absl/base/bit_cast_test.cc +++ b/third_party/abseil-cpp/absl/base/bit_cast_test.cc
@@ -22,6 +22,7 @@ #include "absl/base/macros.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { template <int N> @@ -104,4 +105,5 @@ } } // namespace +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/call_once.h b/third_party/abseil-cpp/absl/base/call_once.h index e7fc2300..bc5ec93 100644 --- a/third_party/abseil-cpp/absl/base/call_once.h +++ b/third_party/abseil-cpp/absl/base/call_once.h
@@ -41,6 +41,7 @@ #include "absl/base/port.h" namespace absl { +ABSL_NAMESPACE_BEGIN class once_flag; @@ -142,12 +143,13 @@ }; template <typename Callable, typename... Args> +ABSL_ATTRIBUTE_NOINLINE void CallOnceImpl(std::atomic<uint32_t>* control, base_internal::SchedulingMode scheduling_mode, Callable&& fn, Args&&... args) { #ifndef NDEBUG { - uint32_t old_control = control->load(std::memory_order_acquire); + uint32_t old_control = control->load(std::memory_order_relaxed); if (old_control != kOnceInit && old_control != kOnceRunning && old_control != kOnceWaiter && @@ -165,14 +167,23 @@ // Must do this before potentially modifying control word's state. base_internal::SchedulingHelper maybe_disable_scheduling(scheduling_mode); // Short circuit the simplest case to avoid procedure call overhead. + // The base_internal::SpinLockWait() call returns either kOnceInit or + // kOnceDone. If it returns kOnceDone, it must have loaded the control word + // with std::memory_order_acquire and seen a value of kOnceDone. uint32_t old_control = kOnceInit; if (control->compare_exchange_strong(old_control, kOnceRunning, - std::memory_order_acquire, std::memory_order_relaxed) || base_internal::SpinLockWait(control, ABSL_ARRAYSIZE(trans), trans, scheduling_mode) == kOnceInit) { base_internal::Invoke(std::forward<Callable>(fn), std::forward<Args>(args)...); + // The call to SpinLockWake below is an optimization, because the waiter + // in SpinLockWait is waiting with a short timeout. The atomic load/store + // sequence is slightly faster than an atomic exchange: + // old_control = control->exchange(base_internal::kOnceDone, + // std::memory_order_release); + // We opt for a slightly faster case when there are no waiters, in spite + // of longer tail latency when there are waiters. old_control = control->load(std::memory_order_relaxed); control->store(base_internal::kOnceDone, std::memory_order_release); if (old_control == base_internal::kOnceWaiter) { @@ -209,6 +220,7 @@ } } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_CALL_ONCE_H_
diff --git a/third_party/abseil-cpp/absl/base/call_once_test.cc b/third_party/abseil-cpp/absl/base/call_once_test.cc index 9a5a5c1..11d26c4 100644 --- a/third_party/abseil-cpp/absl/base/call_once_test.cc +++ b/third_party/abseil-cpp/absl/base/call_once_test.cc
@@ -24,6 +24,7 @@ #include "absl/synchronization/mutex.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { absl::once_flag once; @@ -102,4 +103,5 @@ } } // namespace +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/casts.h b/third_party/abseil-cpp/absl/base/casts.h index aba0178..322cc1d 100644 --- a/third_party/abseil-cpp/absl/base/casts.h +++ b/third_party/abseil-cpp/absl/base/casts.h
@@ -34,6 +34,7 @@ #include "absl/meta/type_traits.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace internal_casts { @@ -177,6 +178,7 @@ return dest; } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_CASTS_H_
diff --git a/third_party/abseil-cpp/absl/base/config.h b/third_party/abseil-cpp/absl/base/config.h index 1c3cb08e..ee99f946 100644 --- a/third_party/abseil-cpp/absl/base/config.h +++ b/third_party/abseil-cpp/absl/base/config.h
@@ -63,8 +63,72 @@ #include <TargetConditionals.h> #endif +#include "absl/base/options.h" #include "absl/base/policy_checks.h" +// Helper macro to convert a CPP variable to a string literal. +#define ABSL_INTERNAL_DO_TOKEN_STR(x) #x +#define ABSL_INTERNAL_TOKEN_STR(x) ABSL_INTERNAL_DO_TOKEN_STR(x) + +// ----------------------------------------------------------------------------- +// Abseil namespace annotations +// ----------------------------------------------------------------------------- + +// ABSL_NAMESPACE_BEGIN/ABSL_NAMESPACE_END +// +// An annotation placed at the beginning/end of each `namespace absl` scope. +// This is used to inject an inline namespace. +// +// The proper way to write Abseil code in the `absl` namespace is: +// +// namespace absl { +// ABSL_NAMESPACE_BEGIN +// +// void Foo(); // absl::Foo(). +// +// ABSL_NAMESPACE_END +// } // namespace absl +// +// Users of Abseil should not use these macros, because users of Abseil should +// not write `namespace absl {` in their own code for any reason. (Abseil does +// not support forward declarations of its own types, nor does it support +// user-provided specialization of Abseil templates. Code that violates these +// rules may be broken without warning.) +#if !defined(ABSL_OPTION_USE_INLINE_NAMESPACE) || \ + !defined(ABSL_OPTION_INLINE_NAMESPACE_NAME) +#error options.h is misconfigured. +#endif + +// Check that ABSL_OPTION_INLINE_NAMESPACE_NAME is neither "head" nor "" +#if defined(__cplusplus) && ABSL_OPTION_USE_INLINE_NAMESPACE == 1 + +#define ABSL_INTERNAL_INLINE_NAMESPACE_STR \ + ABSL_INTERNAL_TOKEN_STR(ABSL_OPTION_INLINE_NAMESPACE_NAME) + +static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != '\0', + "options.h misconfigured: ABSL_OPTION_INLINE_NAMESPACE_NAME must " + "not be empty."); +static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || + ABSL_INTERNAL_INLINE_NAMESPACE_STR[1] != 'e' || + ABSL_INTERNAL_INLINE_NAMESPACE_STR[2] != 'a' || + ABSL_INTERNAL_INLINE_NAMESPACE_STR[3] != 'd' || + ABSL_INTERNAL_INLINE_NAMESPACE_STR[4] != '\0', + "options.h misconfigured: ABSL_OPTION_INLINE_NAMESPACE_NAME must " + "be changed to a new, unique identifier name."); + +#endif + +#if ABSL_OPTION_USE_INLINE_NAMESPACE == 0 +#define ABSL_NAMESPACE_BEGIN +#define ABSL_NAMESPACE_END +#elif ABSL_OPTION_USE_INLINE_NAMESPACE == 1 +#define ABSL_NAMESPACE_BEGIN \ + inline namespace ABSL_OPTION_INLINE_NAMESPACE_NAME { +#define ABSL_NAMESPACE_END } +#else +#error options.h is misconfigured. +#endif + // ----------------------------------------------------------------------------- // Compiler Feature Checks // ----------------------------------------------------------------------------- @@ -84,6 +148,12 @@ #define ABSL_HAVE_BUILTIN(x) 0 #endif +#if defined(__is_identifier) +#define ABSL_INTERNAL_HAS_KEYWORD(x) !(__is_identifier(x)) +#else +#define ABSL_INTERNAL_HAS_KEYWORD(x) 0 +#endif + // ABSL_HAVE_TLS is defined to 1 when __thread should be supported. // We assume __thread is supported on Linux when compiled with Clang or compiled // against libstdc++ with _GLIBCXX_HAVE_TLS defined. @@ -125,13 +195,24 @@ #error ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE cannot directly set #elif (defined(__clang__) && defined(_LIBCPP_VERSION)) || \ (!defined(__clang__) && defined(__GNUC__) && \ - (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)) && \ + (__GNUC__ > 7 || (__GNUC__ == 7 && __GNUC_MINOR__ >= 4)) && \ (defined(_LIBCPP_VERSION) || defined(__GLIBCXX__))) || \ (defined(_MSC_VER) && !defined(__NVCC__)) #define ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE 1 #define ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE 1 #endif +// ABSL_HAVE_SOURCE_LOCATION_CURRENT +// +// Indicates whether `absl::SourceLocation::current()` will return useful +// information in some contexts. +#ifndef ABSL_HAVE_SOURCE_LOCATION_CURRENT +#if ABSL_INTERNAL_HAS_KEYWORD(__builtin_LINE) && \ + ABSL_INTERNAL_HAS_KEYWORD(__builtin_FILE) +#define ABSL_HAVE_SOURCE_LOCATION_CURRENT 1 +#endif +#endif + // ABSL_HAVE_THREAD_LOCAL // // Checks whether C++11's `thread_local` storage duration specifier is @@ -235,13 +316,19 @@ #error ABSL_HAVE_EXCEPTIONS cannot be directly set. #elif defined(__clang__) -// TODO(calabrese) -// Switch to using __cpp_exceptions when we no longer support versions < 3.6. -// For details on this check, see: -// http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro + +#if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6) +// Clang >= 3.6 +#if __has_feature(cxx_exceptions) +#define ABSL_HAVE_EXCEPTIONS 1 +#endif // __has_feature(cxx_exceptions) +#else +// Clang < 3.6 +// http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro #if defined(__EXCEPTIONS) && __has_feature(cxx_exceptions) #define ABSL_HAVE_EXCEPTIONS 1 #endif // defined(__EXCEPTIONS) && __has_feature(cxx_exceptions) +#endif // __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6) // Handle remaining special cases and default to exceptions being supported. #elif !(defined(__GNUC__) && (__GNUC__ < 5) && !defined(__EXCEPTIONS)) && \ @@ -307,7 +394,7 @@ // ABSL_HAVE_SEMAPHORE_H // -// Checks whether the platform supports the <semaphore.h> header and sem_open(3) +// Checks whether the platform supports the <semaphore.h> header and sem_init(3) // family of functions as standardized in POSIX.1-2001. // // Note: While Apple provides <semaphore.h> for both iOS and macOS, it is @@ -334,8 +421,15 @@ #define ABSL_HAVE_ALARM 1 #elif defined(_MSC_VER) // feature tests for Microsoft's library +#elif defined(__MINGW32__) +// mingw32 doesn't provide alarm(2): +// https://osdn.net/projects/mingw/scm/git/mingw-org-wsl/blobs/5.2-trunk/mingwrt/include/unistd.h +// mingw-w64 provides a no-op implementation: +// https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/misc/alarm.c #elif defined(__EMSCRIPTEN__) // emscripten doesn't support signals +#elif defined(__Fuchsia__) +// Signals don't exist on fuchsia. #elif defined(__native_client__) #else // other standard libraries @@ -461,6 +555,68 @@ #define ABSL_HAVE_STD_STRING_VIEW 1 #endif +// ABSL_USES_STD_ANY +// +// Indicates whether absl::any is an alias for std::any. +#if !defined(ABSL_OPTION_USE_STD_ANY) +#error options.h is misconfigured. +#elif ABSL_OPTION_USE_STD_ANY == 0 || \ + (ABSL_OPTION_USE_STD_ANY == 2 && !defined(ABSL_HAVE_STD_ANY)) +#undef ABSL_USES_STD_ANY +#elif ABSL_OPTION_USE_STD_ANY == 1 || \ + (ABSL_OPTION_USE_STD_ANY == 2 && defined(ABSL_HAVE_STD_ANY)) +#define ABSL_USES_STD_ANY 1 +#else +#error options.h is misconfigured. +#endif + +// ABSL_USES_STD_OPTIONAL +// +// Indicates whether absl::optional is an alias for std::optional. +#if !defined(ABSL_OPTION_USE_STD_OPTIONAL) +#error options.h is misconfigured. +#elif ABSL_OPTION_USE_STD_OPTIONAL == 0 || \ + (ABSL_OPTION_USE_STD_OPTIONAL == 2 && !defined(ABSL_HAVE_STD_OPTIONAL)) +#undef ABSL_USES_STD_OPTIONAL +#elif ABSL_OPTION_USE_STD_OPTIONAL == 1 || \ + (ABSL_OPTION_USE_STD_OPTIONAL == 2 && defined(ABSL_HAVE_STD_OPTIONAL)) +#define ABSL_USES_STD_OPTIONAL 1 +#else +#error options.h is misconfigured. +#endif + +// ABSL_USES_STD_VARIANT +// +// Indicates whether absl::variant is an alias for std::variant. +#if !defined(ABSL_OPTION_USE_STD_VARIANT) +#error options.h is misconfigured. +#elif ABSL_OPTION_USE_STD_VARIANT == 0 || \ + (ABSL_OPTION_USE_STD_VARIANT == 2 && !defined(ABSL_HAVE_STD_VARIANT)) +#undef ABSL_USES_STD_VARIANT +#elif ABSL_OPTION_USE_STD_VARIANT == 1 || \ + (ABSL_OPTION_USE_STD_VARIANT == 2 && defined(ABSL_HAVE_STD_VARIANT)) +#define ABSL_USES_STD_VARIANT 1 +#else +#error options.h is misconfigured. +#endif + +// ABSL_USES_STD_STRING_VIEW +// +// Indicates whether absl::string_view is an alias for std::string_view. +#if !defined(ABSL_OPTION_USE_STD_STRING_VIEW) +#error options.h is misconfigured. +#elif ABSL_OPTION_USE_STD_STRING_VIEW == 0 || \ + (ABSL_OPTION_USE_STD_STRING_VIEW == 2 && \ + !defined(ABSL_HAVE_STD_STRING_VIEW)) +#undef ABSL_USES_STD_STRING_VIEW +#elif ABSL_OPTION_USE_STD_STRING_VIEW == 1 || \ + (ABSL_OPTION_USE_STD_STRING_VIEW == 2 && \ + defined(ABSL_HAVE_STD_STRING_VIEW)) +#define ABSL_USES_STD_STRING_VIEW 1 +#else +#error options.h is misconfigured. +#endif + // In debug mode, MSVC 2017's std::variant throws a EXCEPTION_ACCESS_VIOLATION // SEH exception from emplace for variant<SomeStruct> when constructing the // struct can throw. This defeats some of variant_test and @@ -469,4 +625,47 @@ #define ABSL_INTERNAL_MSVC_2017_DBG_MODE #endif +// ABSL_INTERNAL_MANGLED_NS +// ABSL_INTERNAL_MANGLED_BACKREFERENCE +// +// Internal macros for building up mangled names in our internal fork of CCTZ. +// This implementation detail is only needed and provided for the MSVC build. +// +// These macros both expand to string literals. ABSL_INTERNAL_MANGLED_NS is +// the mangled spelling of the `absl` namespace, and +// ABSL_INTERNAL_MANGLED_BACKREFERENCE is a back-reference integer representing +// the proper count to skip past the CCTZ fork namespace names. (This number +// is one larger when there is an inline namespace name to skip.) +#if defined(_MSC_VER) +#if ABSL_OPTION_USE_INLINE_NAMESPACE == 0 +#define ABSL_INTERNAL_MANGLED_NS "absl" +#define ABSL_INTERNAL_MANGLED_BACKREFERENCE "5" +#else +#define ABSL_INTERNAL_MANGLED_NS \ + ABSL_INTERNAL_TOKEN_STR(ABSL_OPTION_INLINE_NAMESPACE_NAME) "@absl" +#define ABSL_INTERNAL_MANGLED_BACKREFERENCE "6" +#endif +#endif + +#undef ABSL_INTERNAL_HAS_KEYWORD + +// ABSL_DLL +// +// When building Abseil as a DLL, this macro expands to `__declspec(dllexport)` +// so we can annotate symbols appropriately as being exported. When used in +// headers consuming a DLL, this macro expands to `__declspec(dllimport)` so +// that consumers know the symbol is defined inside the DLL. In all other cases, +// the macro expands to nothing. +#if defined(_MSC_VER) +#if defined(ABSL_BUILD_DLL) +#define ABSL_DLL __declspec(dllexport) +#elif defined(ABSL_CONSUME_DLL) +#define ABSL_DLL __declspec(dllimport) +#else +#define ABSL_DLL +#endif +#else +#define ABSL_DLL +#endif // defined(_MSC_VER) + #endif // ABSL_BASE_CONFIG_H_
diff --git a/third_party/abseil-cpp/absl/base/const_init.h b/third_party/abseil-cpp/absl/base/const_init.h index 17858a7..16520b6 100644 --- a/third_party/abseil-cpp/absl/base/const_init.h +++ b/third_party/abseil-cpp/absl/base/const_init.h
@@ -22,6 +22,8 @@ #ifndef ABSL_BASE_CONST_INIT_H_ #define ABSL_BASE_CONST_INIT_H_ +#include "absl/base/config.h" + // In general, objects with static storage duration (such as global variables) // can trigger tricky object lifetime situations. Attempting to access them // from the constructors or destructors of other global objects can result in @@ -62,11 +64,13 @@ // or thread_local storage duration. namespace absl { +ABSL_NAMESPACE_BEGIN enum ConstInitType { kConstInit, }; +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_CONST_INIT_H_
diff --git a/third_party/abseil-cpp/absl/base/exception_safety_testing_test.cc b/third_party/abseil-cpp/absl/base/exception_safety_testing_test.cc index 2ed38606..a59be29 100644 --- a/third_party/abseil-cpp/absl/base/exception_safety_testing_test.cc +++ b/third_party/abseil-cpp/absl/base/exception_safety_testing_test.cc
@@ -14,6 +14,8 @@ #include "absl/base/internal/exception_safety_testing.h" +#ifdef ABSL_HAVE_EXCEPTIONS + #include <cstddef> #include <exception> #include <iostream> @@ -326,17 +328,15 @@ UnsetCountdown(); } -using Storage = - absl::aligned_storage_t<sizeof(ThrowingValue<>), alignof(ThrowingValue<>)>; - TEST(ThrowingValueTest, NonThrowingPlacementDelete) { constexpr int kArrayLen = 2; // We intentionally create extra space to store the tag allocated by placement // new[]. constexpr int kStorageLen = 4; - Storage buf; - Storage array_buf[kStorageLen]; + alignas(ThrowingValue<>) unsigned char buf[sizeof(ThrowingValue<>)]; + alignas(ThrowingValue<>) unsigned char + array_buf[sizeof(ThrowingValue<>[kStorageLen])]; auto* placed = new (&buf) ThrowingValue<>(1); auto placed_array = new (&array_buf) ThrowingValue<>[kArrayLen]; @@ -900,12 +900,12 @@ } TEST(ConstructorTrackerTest, NotDestroyedAfter) { - absl::aligned_storage_t<sizeof(Tracked), alignof(Tracked)> storage; + alignas(Tracked) unsigned char storage[sizeof(Tracked)]; EXPECT_NONFATAL_FAILURE( { exceptions_internal::ConstructorTracker ct( exceptions_internal::countdown); - new (&storage) Tracked; + new (&storage) Tracked(); }, "not destroyed"); } @@ -922,11 +922,11 @@ TEST(ConstructorTrackerTest, ConstructedTwice) { exceptions_internal::ConstructorTracker ct(exceptions_internal::countdown); - absl::aligned_storage_t<sizeof(Tracked), alignof(Tracked)> storage; + alignas(Tracked) unsigned char storage[sizeof(Tracked)]; EXPECT_NONFATAL_FAILURE( { - new (&storage) Tracked; - new (&storage) Tracked; + new (&storage) Tracked(); + new (&storage) Tracked(); reinterpret_cast<Tracked*>(&storage)->~Tracked(); }, "re-constructed"); @@ -952,3 +952,5 @@ } // namespace } // namespace testing + +#endif // ABSL_HAVE_EXCEPTIONS
diff --git a/third_party/abseil-cpp/absl/base/inline_variable_test.cc b/third_party/abseil-cpp/absl/base/inline_variable_test.cc index 471f7063..37a40e1e 100644 --- a/third_party/abseil-cpp/absl/base/inline_variable_test.cc +++ b/third_party/abseil-cpp/absl/base/inline_variable_test.cc
@@ -20,6 +20,7 @@ #include "gtest/gtest.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace inline_variable_testing_internal { namespace { @@ -59,4 +60,5 @@ } // namespace } // namespace inline_variable_testing_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/inline_variable_test_a.cc b/third_party/abseil-cpp/absl/base/inline_variable_test_a.cc index d0b8e7d3..f96a58d 100644 --- a/third_party/abseil-cpp/absl/base/inline_variable_test_a.cc +++ b/third_party/abseil-cpp/absl/base/inline_variable_test_a.cc
@@ -15,6 +15,7 @@ #include "absl/base/internal/inline_variable_testing.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace inline_variable_testing_internal { const Foo& get_foo_a() { return inline_variable_foo; } @@ -22,4 +23,5 @@ const int& get_int_a() { return inline_variable_int; } } // namespace inline_variable_testing_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/inline_variable_test_b.cc b/third_party/abseil-cpp/absl/base/inline_variable_test_b.cc index 931d56d0..038adc3 100644 --- a/third_party/abseil-cpp/absl/base/inline_variable_test_b.cc +++ b/third_party/abseil-cpp/absl/base/inline_variable_test_b.cc
@@ -15,6 +15,7 @@ #include "absl/base/internal/inline_variable_testing.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace inline_variable_testing_internal { const Foo& get_foo_b() { return inline_variable_foo; } @@ -22,4 +23,5 @@ const int& get_int_b() { return inline_variable_int; } } // namespace inline_variable_testing_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/atomic_hook.h b/third_party/abseil-cpp/absl/base/internal/atomic_hook.h index 803e9059..ae21cd7 100644 --- a/third_party/abseil-cpp/absl/base/internal/atomic_hook.h +++ b/third_party/abseil-cpp/absl/base/internal/atomic_hook.h
@@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// #ifndef ABSL_BASE_INTERNAL_ATOMIC_HOOK_H_ #define ABSL_BASE_INTERNAL_ATOMIC_HOOK_H_ @@ -21,28 +20,51 @@ #include <cstdint> #include <utility> -#ifdef _MSC_FULL_VER +#include "absl/base/attributes.h" +#include "absl/base/config.h" + +#if defined(_MSC_VER) && !defined(__clang__) +#define ABSL_HAVE_WORKING_CONSTEXPR_STATIC_INIT 0 +#else +#define ABSL_HAVE_WORKING_CONSTEXPR_STATIC_INIT 1 +#endif + +#if defined(_MSC_VER) #define ABSL_HAVE_WORKING_ATOMIC_POINTER 0 #else #define ABSL_HAVE_WORKING_ATOMIC_POINTER 1 #endif namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { template <typename T> class AtomicHook; -// AtomicHook is a helper class, templatized on a raw function pointer type, for -// implementing Abseil customization hooks. It is a callable object that -// dispatches to the registered hook. +// To workaround AtomicHook not being constant-initializable on some platforms, +// prefer to annotate instances with `ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES` +// instead of `ABSL_CONST_INIT`. +#if ABSL_HAVE_WORKING_CONSTEXPR_STATIC_INIT +#define ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES ABSL_CONST_INIT +#else +#define ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES +#endif + +// `AtomicHook` is a helper class, templatized on a raw function pointer type, +// for implementing Abseil customization hooks. It is a callable object that +// dispatches to the registered hook. Objects of type `AtomicHook` must have +// static or thread storage duration. // // A default constructed object performs a no-op (and returns a default // constructed object) if no hook has been registered. // -// Hooks can be pre-registered via constant initialization, for example, -// ABSL_CONST_INIT static AtomicHook<void(*)()> my_hook(DefaultAction); -// and then changed at runtime via a call to Store(). +// Hooks can be pre-registered via constant initialization, for example: +// +// ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES static AtomicHook<void(*)()> +// my_hook(DefaultAction); +// +// and then changed at runtime via a call to `Store()`. // // Reads and writes guarantee memory_order_acquire/memory_order_release // semantics. @@ -57,12 +79,23 @@ // Constructs an object that by default dispatches to/returns the // pre-registered default_fn when no hook has been registered at runtime. -#if ABSL_HAVE_WORKING_ATOMIC_POINTER +#if ABSL_HAVE_WORKING_ATOMIC_POINTER && ABSL_HAVE_WORKING_CONSTEXPR_STATIC_INIT explicit constexpr AtomicHook(FnPtr default_fn) : hook_(default_fn), default_fn_(default_fn) {} -#else +#elif ABSL_HAVE_WORKING_CONSTEXPR_STATIC_INIT explicit constexpr AtomicHook(FnPtr default_fn) : hook_(kUninitialized), default_fn_(default_fn) {} +#else + // As of January 2020, on all known versions of MSVC this constructor runs in + // the global constructor sequence. If `Store()` is called by a dynamic + // initializer, we want to preserve the value, even if this constructor runs + // after the call to `Store()`. If not, `hook_` will be + // zero-initialized by the linker and we have no need to set it. + // https://developercommunity.visualstudio.com/content/problem/336946/class-with-constexpr-constructor-not-using-static.html + explicit constexpr AtomicHook(FnPtr default_fn) + : /* hook_(deliberately omitted), */ default_fn_(default_fn) { + static_assert(kUninitialized == 0, "here we rely on zero-initialization"); + } #endif // Stores the provided function pointer as the value for this hook. @@ -158,8 +191,10 @@ }; #undef ABSL_HAVE_WORKING_ATOMIC_POINTER +#undef ABSL_HAVE_WORKING_CONSTEXPR_STATIC_INIT } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_ATOMIC_HOOK_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/atomic_hook_test.cc b/third_party/abseil-cpp/absl/base/internal/atomic_hook_test.cc index ecc8040..e577a8fd 100644 --- a/third_party/abseil-cpp/absl/base/internal/atomic_hook_test.cc +++ b/third_party/abseil-cpp/absl/base/internal/atomic_hook_test.cc
@@ -14,16 +14,22 @@ #include "absl/base/internal/atomic_hook.h" +#include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/base/attributes.h" +#include "absl/base/internal/atomic_hook_test_helper.h" namespace { +using ::testing::Eq; + int value = 0; void TestHook(int x) { value = x; } TEST(AtomicHookTest, NoDefaultFunction) { - ABSL_CONST_INIT static absl::base_internal::AtomicHook<void(*)(int)> hook; + ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES static absl::base_internal::AtomicHook< + void (*)(int)> + hook; value = 0; // Test the default DummyFunction. @@ -49,8 +55,9 @@ TEST(AtomicHookTest, WithDefaultFunction) { // Set the default value to TestHook at compile-time. - ABSL_CONST_INIT static absl::base_internal::AtomicHook<void (*)(int)> hook( - TestHook); + ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES static absl::base_internal::AtomicHook< + void (*)(int)> + hook(TestHook); value = 0; // Test the default value is TestHook. @@ -67,4 +74,24 @@ EXPECT_EQ(value, 2); } +ABSL_CONST_INIT int override_func_calls = 0; +void OverrideFunc() { override_func_calls++; } +static struct OverrideInstaller { + OverrideInstaller() { absl::atomic_hook_internal::func.Store(OverrideFunc); } +} override_installer; + +TEST(AtomicHookTest, DynamicInitFromAnotherTU) { + // MSVC 14.2 doesn't do constexpr static init correctly; in particular it + // tends to sequence static init (i.e. defaults) of `AtomicHook` objects + // after their dynamic init (i.e. overrides), overwriting whatever value was + // written during dynamic init. This regression test validates the fix. + // https://developercommunity.visualstudio.com/content/problem/336946/class-with-constexpr-constructor-not-using-static.html + EXPECT_THAT(absl::atomic_hook_internal::default_func_calls, Eq(0)); + EXPECT_THAT(override_func_calls, Eq(0)); + absl::atomic_hook_internal::func(); + EXPECT_THAT(absl::atomic_hook_internal::default_func_calls, Eq(0)); + EXPECT_THAT(override_func_calls, Eq(1)); + EXPECT_THAT(absl::atomic_hook_internal::func.Load(), Eq(OverrideFunc)); +} + } // namespace
diff --git a/third_party/abseil-cpp/absl/base/internal/atomic_hook_test_helper.cc b/third_party/abseil-cpp/absl/base/internal/atomic_hook_test_helper.cc new file mode 100644 index 0000000..537d47c --- /dev/null +++ b/third_party/abseil-cpp/absl/base/internal/atomic_hook_test_helper.cc
@@ -0,0 +1,32 @@ +// Copyright 2017 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/base/internal/atomic_hook_test_helper.h" + +#include "absl/base/attributes.h" +#include "absl/base/internal/atomic_hook.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace atomic_hook_internal { + +ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES absl::base_internal::AtomicHook<VoidF> + func(DefaultFunc); +ABSL_CONST_INIT int default_func_calls = 0; +void DefaultFunc() { default_func_calls++; } +void RegisterFunc(VoidF f) { func.Store(f); } + +} // namespace atomic_hook_internal +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/atomic_hook_test_helper.h b/third_party/abseil-cpp/absl/base/internal/atomic_hook_test_helper.h new file mode 100644 index 0000000..3e72b49 --- /dev/null +++ b/third_party/abseil-cpp/absl/base/internal/atomic_hook_test_helper.h
@@ -0,0 +1,34 @@ +// Copyright 2017 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ABSL_BASE_ATOMIC_HOOK_TEST_HELPER_H_ +#define ABSL_BASE_ATOMIC_HOOK_TEST_HELPER_H_ + +#include "absl/base/internal/atomic_hook.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace atomic_hook_internal { + +using VoidF = void (*)(); +extern absl::base_internal::AtomicHook<VoidF> func; +extern int default_func_calls; +void DefaultFunc(); +void RegisterFunc(VoidF func); + +} // namespace atomic_hook_internal +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_BASE_ATOMIC_HOOK_TEST_HELPER_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/bits.h b/third_party/abseil-cpp/absl/base/internal/bits.h index b0780f2..8b03453 100644 --- a/third_party/abseil-cpp/absl/base/internal/bits.h +++ b/third_party/abseil-cpp/absl/base/internal/bits.h
@@ -20,6 +20,8 @@ #include <cstdint> +#include "absl/base/config.h" + // Clang on Windows has __builtin_clzll; otherwise we need to use the // windows intrinsic functions. #if defined(_MSC_VER) @@ -46,14 +48,27 @@ namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { ABSL_BASE_INTERNAL_FORCEINLINE int CountLeadingZeros64Slow(uint64_t n) { int zeroes = 60; - if (n >> 32) zeroes -= 32, n >>= 32; - if (n >> 16) zeroes -= 16, n >>= 16; - if (n >> 8) zeroes -= 8, n >>= 8; - if (n >> 4) zeroes -= 4, n >>= 4; + if (n >> 32) { + zeroes -= 32; + n >>= 32; + } + if (n >> 16) { + zeroes -= 16; + n >>= 16; + } + if (n >> 8) { + zeroes -= 8; + n >>= 8; + } + if (n >> 4) { + zeroes -= 4; + n >>= 4; + } return "\4\3\2\2\1\1\1\1\0\0\0\0\0\0\0"[n] + zeroes; } @@ -95,9 +110,18 @@ ABSL_BASE_INTERNAL_FORCEINLINE int CountLeadingZeros32Slow(uint64_t n) { int zeroes = 28; - if (n >> 16) zeroes -= 16, n >>= 16; - if (n >> 8) zeroes -= 8, n >>= 8; - if (n >> 4) zeroes -= 4, n >>= 4; + if (n >> 16) { + zeroes -= 16; + n >>= 16; + } + if (n >> 8) { + zeroes -= 8; + n >>= 8; + } + if (n >> 4) { + zeroes -= 4; + n >>= 4; + } return "\4\3\2\2\1\1\1\1\0\0\0\0\0\0\0"[n] + zeroes; } @@ -188,6 +212,7 @@ #undef ABSL_BASE_INTERNAL_FORCEINLINE } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_BITS_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/cycleclock.cc b/third_party/abseil-cpp/absl/base/internal/cycleclock.cc index e9844b7..0e65005 100644 --- a/third_party/abseil-cpp/absl/base/internal/cycleclock.cc +++ b/third_party/abseil-cpp/absl/base/internal/cycleclock.cc
@@ -28,6 +28,7 @@ #include "absl/base/internal/unscaledcycleclock.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { #if ABSL_USE_UNSCALED_CYCLECLOCK @@ -102,4 +103,5 @@ #endif } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/cycleclock.h b/third_party/abseil-cpp/absl/base/internal/cycleclock.h index 794564e1..a18b5844 100644 --- a/third_party/abseil-cpp/absl/base/internal/cycleclock.h +++ b/third_party/abseil-cpp/absl/base/internal/cycleclock.h
@@ -44,7 +44,10 @@ #include <cstdint> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { // ----------------------------------------------------------------------------- @@ -85,6 +88,7 @@ }; } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_CYCLECLOCK_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/direct_mmap.h b/third_party/abseil-cpp/absl/base/internal/direct_mmap.h index 0401ddf..5618867 100644 --- a/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +++ b/third_party/abseil-cpp/absl/base/internal/direct_mmap.h
@@ -62,6 +62,7 @@ #endif // __BIONIC__ namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { // Platform specific logic extracted from @@ -128,6 +129,7 @@ } } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #else // !__linux__ @@ -136,6 +138,7 @@ // actual mmap()/munmap() methods. namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { inline void* DirectMmap(void* start, size_t length, int prot, int flags, int fd, @@ -148,6 +151,7 @@ } } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // __linux__
diff --git a/third_party/abseil-cpp/absl/base/internal/endian.h b/third_party/abseil-cpp/absl/base/internal/endian.h index 296e92d..9677530 100644 --- a/third_party/abseil-cpp/absl/base/internal/endian.h +++ b/third_party/abseil-cpp/absl/base/internal/endian.h
@@ -19,9 +19,6 @@ // The following guarantees declaration of the byte swap functions #ifdef _MSC_VER #include <stdlib.h> // NOLINT(build/include) -#elif defined(__APPLE__) -// macOS / Darwin features -#include <libkern/OSByteOrder.h> #elif defined(__FreeBSD__) #include <sys/endian.h> #elif defined(__GLIBC__) @@ -34,6 +31,7 @@ #include "absl/base/port.h" namespace absl { +ABSL_NAMESPACE_BEGIN // Use compiler byte-swapping intrinsics if they are available. 32-bit // and 64-bit versions are available in Clang and GCC as of GCC 4.3.0. @@ -63,11 +61,6 @@ return _byteswap_ushort(host_int); } -#elif defined(__APPLE__) -inline uint64_t gbswap_64(uint64_t host_int) { return OSSwapInt16(host_int); } -inline uint32_t gbswap_32(uint32_t host_int) { return OSSwapInt32(host_int); } -inline uint16_t gbswap_16(uint16_t host_int) { return OSSwapInt64(host_int); } - #else inline uint64_t gbswap_64(uint64_t host_int) { #if defined(__GNUC__) && defined(__x86_64__) && !defined(__APPLE__) @@ -113,7 +106,7 @@ #endif } -#endif // intrinics available +#endif // intrinsics available #ifdef ABSL_IS_LITTLE_ENDIAN @@ -267,6 +260,7 @@ } // namespace big_endian +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_ENDIAN_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/endian_test.cc b/third_party/abseil-cpp/absl/base/internal/endian_test.cc index 98a099e..aa6b8496 100644 --- a/third_party/abseil-cpp/absl/base/internal/endian_test.cc +++ b/third_party/abseil-cpp/absl/base/internal/endian_test.cc
@@ -24,6 +24,7 @@ #include "absl/base/config.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { const uint64_t kInitialNumber{0x0123456789abcdef}; @@ -260,4 +261,5 @@ } } // namespace +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/errno_saver.h b/third_party/abseil-cpp/absl/base/internal/errno_saver.h new file mode 100644 index 0000000..251de51 --- /dev/null +++ b/third_party/abseil-cpp/absl/base/internal/errno_saver.h
@@ -0,0 +1,43 @@ +// Copyright 2017 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ABSL_BASE_INTERNAL_ERRNO_SAVER_H_ +#define ABSL_BASE_INTERNAL_ERRNO_SAVER_H_ + +#include <cerrno> + +#include "absl/base/config.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace base_internal { + +// `ErrnoSaver` captures the value of `errno` upon construction and restores it +// upon deletion. It is used in low-level code and must be super fast. Do not +// add instrumentation, even in debug modes. +class ErrnoSaver { + public: + ErrnoSaver() : saved_errno_(errno) {} + ~ErrnoSaver() { errno = saved_errno_; } + int operator()() const { return saved_errno_; } + + private: + const int saved_errno_; +}; + +} // namespace base_internal +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_BASE_INTERNAL_ERRNO_SAVER_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/errno_saver_test.cc b/third_party/abseil-cpp/absl/base/internal/errno_saver_test.cc new file mode 100644 index 0000000..b845e2dd1 --- /dev/null +++ b/third_party/abseil-cpp/absl/base/internal/errno_saver_test.cc
@@ -0,0 +1,44 @@ +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/base/internal/errno_saver.h" + +#include <cerrno> + +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +namespace { +using ::testing::Eq; + +struct ErrnoPrinter { + int no; +}; +std::ostream &operator<<(std::ostream &os, ErrnoPrinter ep) { + return os << strerror(ep.no) << " [" << ep.no << "]"; +} +bool operator==(ErrnoPrinter one, ErrnoPrinter two) { return one.no == two.no; } + +TEST(ErrnoSaverTest, Works) { + errno = EDOM; + { + absl::base_internal::ErrnoSaver errno_saver; + EXPECT_THAT(ErrnoPrinter{errno}, Eq(ErrnoPrinter{EDOM})); + errno = ERANGE; + EXPECT_THAT(ErrnoPrinter{errno}, Eq(ErrnoPrinter{ERANGE})); + EXPECT_THAT(ErrnoPrinter{errno_saver()}, Eq(ErrnoPrinter{EDOM})); + } + EXPECT_THAT(ErrnoPrinter{errno}, Eq(ErrnoPrinter{EDOM})); +} +} // namespace
diff --git a/third_party/abseil-cpp/absl/base/internal/exception_safety_testing.cc b/third_party/abseil-cpp/absl/base/internal/exception_safety_testing.cc index 6ef4325..6ccac4186 100644 --- a/third_party/abseil-cpp/absl/base/internal/exception_safety_testing.cc +++ b/third_party/abseil-cpp/absl/base/internal/exception_safety_testing.cc
@@ -14,6 +14,8 @@ #include "absl/base/internal/exception_safety_testing.h" +#ifdef ABSL_HAVE_EXCEPTIONS + #include "gtest/gtest.h" #include "absl/meta/type_traits.h" @@ -73,3 +75,5 @@ } // namespace exceptions_internal } // namespace testing + +#endif // ABSL_HAVE_EXCEPTIONS
diff --git a/third_party/abseil-cpp/absl/base/internal/exception_safety_testing.h b/third_party/abseil-cpp/absl/base/internal/exception_safety_testing.h index be38ba54..6ba89d05 100644 --- a/third_party/abseil-cpp/absl/base/internal/exception_safety_testing.h +++ b/third_party/abseil-cpp/absl/base/internal/exception_safety_testing.h
@@ -17,6 +17,10 @@ #ifndef ABSL_BASE_INTERNAL_EXCEPTION_SAFETY_TESTING_H_ #define ABSL_BASE_INTERNAL_EXCEPTION_SAFETY_TESTING_H_ +#include "absl/base/config.h" + +#ifdef ABSL_HAVE_EXCEPTIONS + #include <cstddef> #include <cstdint> #include <functional> @@ -27,7 +31,6 @@ #include <unordered_map> #include "gtest/gtest.h" -#include "absl/base/config.h" #include "absl/base/internal/pretty_function.h" #include "absl/memory/memory.h" #include "absl/meta/type_traits.h" @@ -1093,4 +1096,6 @@ } // namespace testing +#endif // ABSL_HAVE_EXCEPTIONS + #endif // ABSL_BASE_INTERNAL_EXCEPTION_SAFETY_TESTING_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/exponential_biased.cc b/third_party/abseil-cpp/absl/base/internal/exponential_biased.cc new file mode 100644 index 0000000..1b30c06 --- /dev/null +++ b/third_party/abseil-cpp/absl/base/internal/exponential_biased.cc
@@ -0,0 +1,93 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/base/internal/exponential_biased.h" + +#include <stdint.h> + +#include <algorithm> +#include <atomic> +#include <cmath> +#include <limits> + +#include "absl/base/attributes.h" +#include "absl/base/optimization.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace base_internal { + +// The algorithm generates a random number between 0 and 1 and applies the +// inverse cumulative distribution function for an exponential. Specifically: +// Let m be the inverse of the sample period, then the probability +// distribution function is m*exp(-mx) so the CDF is +// p = 1 - exp(-mx), so +// q = 1 - p = exp(-mx) +// log_e(q) = -mx +// -log_e(q)/m = x +// log_2(q) * (-log_e(2) * 1/m) = x +// In the code, q is actually in the range 1 to 2**26, hence the -26 below +int64_t ExponentialBiased::GetSkipCount(int64_t mean) { + if (ABSL_PREDICT_FALSE(!initialized_)) { + Initialize(); + } + + uint64_t rng = NextRandom(rng_); + rng_ = rng; + + // Take the top 26 bits as the random number + // (This plus the 1<<58 sampling bound give a max possible step of + // 5194297183973780480 bytes.) + // The uint32_t cast is to prevent a (hard-to-reproduce) NAN + // under piii debug for some binaries. + double q = static_cast<uint32_t>(rng >> (kPrngNumBits - 26)) + 1.0; + // Put the computed p-value through the CDF of a geometric. + double interval = bias_ + (std::log2(q) - 26) * (-std::log(2.0) * mean); + // Very large values of interval overflow int64_t. To avoid that, we will + // cheat and clamp any huge values to (int64_t max)/2. This is a potential + // source of bias, but the mean would need to be such a large value that it's + // not likely to come up. For example, with a mean of 1e18, the probability of + // hitting this condition is about 1/1000. For a mean of 1e17, standard + // calculators claim that this event won't happen. + if (interval > static_cast<double>(std::numeric_limits<int64_t>::max() / 2)) { + // Assume huge values are bias neutral, retain bias for next call. + return std::numeric_limits<int64_t>::max() / 2; + } + double value = std::round(interval); + bias_ = interval - value; + return value; +} + +int64_t ExponentialBiased::GetStride(int64_t mean) { + return GetSkipCount(mean - 1) + 1; +} + +void ExponentialBiased::Initialize() { + // We don't get well distributed numbers from `this` so we call NextRandom() a + // bunch to mush the bits around. We use a global_rand to handle the case + // where the same thread (by memory address) gets created and destroyed + // repeatedly. + ABSL_CONST_INIT static std::atomic<uint32_t> global_rand(0); + uint64_t r = reinterpret_cast<uint64_t>(this) + + global_rand.fetch_add(1, std::memory_order_relaxed); + for (int i = 0; i < 20; ++i) { + r = NextRandom(r); + } + rng_ = r; + initialized_ = true; +} + +} // namespace base_internal +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/exponential_biased.h b/third_party/abseil-cpp/absl/base/internal/exponential_biased.h new file mode 100644 index 0000000..94f79a3 --- /dev/null +++ b/third_party/abseil-cpp/absl/base/internal/exponential_biased.h
@@ -0,0 +1,130 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ABSL_BASE_INTERNAL_EXPONENTIAL_BIASED_H_ +#define ABSL_BASE_INTERNAL_EXPONENTIAL_BIASED_H_ + +#include <stdint.h> + +#include "absl/base/config.h" +#include "absl/base/macros.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace base_internal { + +// ExponentialBiased provides a small and fast random number generator for a +// rounded exponential distribution. This generator manages very little state, +// and imposes no synchronization overhead. This makes it useful in specialized +// scenarios requiring minimum overhead, such as stride based periodic sampling. +// +// ExponentialBiased provides two closely related functions, GetSkipCount() and +// GetStride(), both returning a rounded integer defining a number of events +// required before some event with a given mean probability occurs. +// +// The distribution is useful to generate a random wait time or some periodic +// event with a given mean probability. For example, if an action is supposed to +// happen on average once every 'N' events, then we can get a random 'stride' +// counting down how long before the event to happen. For example, if we'd want +// to sample one in every 1000 'Frobber' calls, our code could look like this: +// +// Frobber::Frobber() { +// stride_ = exponential_biased_.GetStride(1000); +// } +// +// void Frobber::Frob(int arg) { +// if (--stride == 0) { +// SampleFrob(arg); +// stride_ = exponential_biased_.GetStride(1000); +// } +// ... +// } +// +// The rounding of the return value creates a bias, especially for smaller means +// where the distribution of the fraction is not evenly distributed. We correct +// this bias by tracking the fraction we rounded up or down on each iteration, +// effectively tracking the distance between the cumulative value, and the +// rounded cumulative value. For example, given a mean of 2: +// +// raw = 1.63076, cumulative = 1.63076, rounded = 2, bias = -0.36923 +// raw = 0.14624, cumulative = 1.77701, rounded = 2, bias = 0.14624 +// raw = 4.93194, cumulative = 6.70895, rounded = 7, bias = -0.06805 +// raw = 0.24206, cumulative = 6.95101, rounded = 7, bias = 0.24206 +// etc... +// +// Adjusting with rounding bias is relatively trivial: +// +// double value = bias_ + exponential_distribution(mean)(); +// double rounded_value = std::round(value); +// bias_ = value - rounded_value; +// return rounded_value; +// +// This class is thread-compatible. +class ExponentialBiased { + public: + // The number of bits set by NextRandom. + static constexpr int kPrngNumBits = 48; + + // `GetSkipCount()` returns the number of events to skip before some chosen + // event happens. For example, randomly tossing a coin, we will on average + // throw heads once before we get tails. We can simulate random coin tosses + // using GetSkipCount() as: + // + // ExponentialBiased eb; + // for (...) { + // int number_of_heads_before_tail = eb.GetSkipCount(1); + // for (int flips = 0; flips < number_of_heads_before_tail; ++flips) { + // printf("head..."); + // } + // printf("tail\n"); + // } + // + int64_t GetSkipCount(int64_t mean); + + // GetStride() returns the number of events required for a specific event to + // happen. See the class comments for a usage example. `GetStride()` is + // equivalent to `GetSkipCount(mean - 1) + 1`. When to use `GetStride()` or + // `GetSkipCount()` depends mostly on what best fits the use case. + int64_t GetStride(int64_t mean); + + // Computes a random number in the range [0, 1<<(kPrngNumBits+1) - 1] + // + // This is public to enable testing. + static uint64_t NextRandom(uint64_t rnd); + + private: + void Initialize(); + + uint64_t rng_{0}; + double bias_{0}; + bool initialized_{false}; +}; + +// Returns the next prng value. +// pRNG is: aX+b mod c with a = 0x5DEECE66D, b = 0xB, c = 1<<48 +// This is the lrand64 generator. +inline uint64_t ExponentialBiased::NextRandom(uint64_t rnd) { + const uint64_t prng_mult = uint64_t{0x5DEECE66D}; + const uint64_t prng_add = 0xB; + const uint64_t prng_mod_power = 48; + const uint64_t prng_mod_mask = + ~((~static_cast<uint64_t>(0)) << prng_mod_power); + return (prng_mult * rnd + prng_add) & prng_mod_mask; +} + +} // namespace base_internal +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_BASE_INTERNAL_EXPONENTIAL_BIASED_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/exponential_biased_test.cc b/third_party/abseil-cpp/absl/base/internal/exponential_biased_test.cc new file mode 100644 index 0000000..90a482d --- /dev/null +++ b/third_party/abseil-cpp/absl/base/internal/exponential_biased_test.cc
@@ -0,0 +1,199 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/base/internal/exponential_biased.h" + +#include <stddef.h> + +#include <cmath> +#include <cstdint> +#include <vector> + +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "absl/strings/str_cat.h" + +using ::testing::Ge; + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace base_internal { + +MATCHER_P2(IsBetween, a, b, + absl::StrCat(std::string(negation ? "isn't" : "is"), " between ", a, + " and ", b)) { + return a <= arg && arg <= b; +} + +// Tests of the quality of the random numbers generated +// This uses the Anderson Darling test for uniformity. +// See "Evaluating the Anderson-Darling Distribution" by Marsaglia +// for details. + +// Short cut version of ADinf(z), z>0 (from Marsaglia) +// This returns the p-value for Anderson Darling statistic in +// the limit as n-> infinity. For finite n, apply the error fix below. +double AndersonDarlingInf(double z) { + if (z < 2) { + return exp(-1.2337141 / z) / sqrt(z) * + (2.00012 + + (0.247105 - + (0.0649821 - (0.0347962 - (0.011672 - 0.00168691 * z) * z) * z) * + z) * + z); + } + return exp( + -exp(1.0776 - + (2.30695 - + (0.43424 - (0.082433 - (0.008056 - 0.0003146 * z) * z) * z) * z) * + z)); +} + +// Corrects the approximation error in AndersonDarlingInf for small values of n +// Add this to AndersonDarlingInf to get a better approximation +// (from Marsaglia) +double AndersonDarlingErrFix(int n, double x) { + if (x > 0.8) { + return (-130.2137 + + (745.2337 - + (1705.091 - (1950.646 - (1116.360 - 255.7844 * x) * x) * x) * x) * + x) / + n; + } + double cutoff = 0.01265 + 0.1757 / n; + if (x < cutoff) { + double t = x / cutoff; + t = sqrt(t) * (1 - t) * (49 * t - 102); + return t * (0.0037 / (n * n) + 0.00078 / n + 0.00006) / n; + } else { + double t = (x - cutoff) / (0.8 - cutoff); + t = -0.00022633 + + (6.54034 - (14.6538 - (14.458 - (8.259 - 1.91864 * t) * t) * t) * t) * + t; + return t * (0.04213 + 0.01365 / n) / n; + } +} + +// Returns the AndersonDarling p-value given n and the value of the statistic +double AndersonDarlingPValue(int n, double z) { + double ad = AndersonDarlingInf(z); + double errfix = AndersonDarlingErrFix(n, ad); + return ad + errfix; +} + +double AndersonDarlingStatistic(const std::vector<double>& random_sample) { + int n = random_sample.size(); + double ad_sum = 0; + for (int i = 0; i < n; i++) { + ad_sum += (2 * i + 1) * + std::log(random_sample[i] * (1 - random_sample[n - 1 - i])); + } + double ad_statistic = -n - 1 / static_cast<double>(n) * ad_sum; + return ad_statistic; +} + +// Tests if the array of doubles is uniformly distributed. +// Returns the p-value of the Anderson Darling Statistic +// for the given set of sorted random doubles +// See "Evaluating the Anderson-Darling Distribution" by +// Marsaglia and Marsaglia for details. +double AndersonDarlingTest(const std::vector<double>& random_sample) { + double ad_statistic = AndersonDarlingStatistic(random_sample); + double p = AndersonDarlingPValue(random_sample.size(), ad_statistic); + return p; +} + +TEST(ExponentialBiasedTest, CoinTossDemoWithGetSkipCount) { + ExponentialBiased eb; + for (int runs = 0; runs < 10; ++runs) { + for (int flips = eb.GetSkipCount(1); flips > 0; --flips) { + printf("head..."); + } + printf("tail\n"); + } + int heads = 0; + for (int i = 0; i < 10000000; i += 1 + eb.GetSkipCount(1)) { + ++heads; + } + printf("Heads = %d (%f%%)\n", heads, 100.0 * heads / 10000000); +} + +TEST(ExponentialBiasedTest, SampleDemoWithStride) { + ExponentialBiased eb; + int stride = eb.GetStride(10); + int samples = 0; + for (int i = 0; i < 10000000; ++i) { + if (--stride == 0) { + ++samples; + stride = eb.GetStride(10); + } + } + printf("Samples = %d (%f%%)\n", samples, 100.0 * samples / 10000000); +} + + +// Testing that NextRandom generates uniform random numbers. Applies the +// Anderson-Darling test for uniformity +TEST(ExponentialBiasedTest, TestNextRandom) { + for (auto n : std::vector<int>({ + 10, // Check short-range correlation + 100, 1000, + 10000 // Make sure there's no systemic error + })) { + uint64_t x = 1; + // This assumes that the prng returns 48 bit numbers + uint64_t max_prng_value = static_cast<uint64_t>(1) << 48; + // Initialize. + for (int i = 1; i <= 20; i++) { + x = ExponentialBiased::NextRandom(x); + } + std::vector<uint64_t> int_random_sample(n); + // Collect samples + for (int i = 0; i < n; i++) { + int_random_sample[i] = x; + x = ExponentialBiased::NextRandom(x); + } + // First sort them... + std::sort(int_random_sample.begin(), int_random_sample.end()); + std::vector<double> random_sample(n); + // Convert them to uniform randoms (in the range [0,1]) + for (int i = 0; i < n; i++) { + random_sample[i] = + static_cast<double>(int_random_sample[i]) / max_prng_value; + } + // Now compute the Anderson-Darling statistic + double ad_pvalue = AndersonDarlingTest(random_sample); + EXPECT_GT(std::min(ad_pvalue, 1 - ad_pvalue), 0.0001) + << "prng is not uniform: n = " << n << " p = " << ad_pvalue; + } +} + +// The generator needs to be available as a thread_local and as a static +// variable. +TEST(ExponentialBiasedTest, InitializationModes) { + ABSL_CONST_INIT static ExponentialBiased eb_static; + EXPECT_THAT(eb_static.GetSkipCount(2), Ge(0)); + +#if ABSL_HAVE_THREAD_LOCAL + thread_local ExponentialBiased eb_thread; + EXPECT_THAT(eb_thread.GetSkipCount(2), Ge(0)); +#endif + + ExponentialBiased eb_stack; + EXPECT_THAT(eb_stack.GetSkipCount(2), Ge(0)); +} + +} // namespace base_internal +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/hide_ptr.h b/third_party/abseil-cpp/absl/base/internal/hide_ptr.h index cf8f4080..1dba809 100644 --- a/third_party/abseil-cpp/absl/base/internal/hide_ptr.h +++ b/third_party/abseil-cpp/absl/base/internal/hide_ptr.h
@@ -17,7 +17,10 @@ #include <cstdint> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { // Arbitrary value with high bits set. Xor'ing with it is unlikely @@ -42,6 +45,7 @@ } } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_HIDE_PTR_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/identity.h b/third_party/abseil-cpp/absl/base/internal/identity.h index 086447c6..a3154ed 100644 --- a/third_party/abseil-cpp/absl/base/internal/identity.h +++ b/third_party/abseil-cpp/absl/base/internal/identity.h
@@ -16,7 +16,10 @@ #ifndef ABSL_BASE_INTERNAL_IDENTITY_H_ #define ABSL_BASE_INTERNAL_IDENTITY_H_ +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace internal { template <typename T> @@ -28,6 +31,7 @@ using identity_t = typename identity<T>::type; } // namespace internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_IDENTITY_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/inline_variable_testing.h b/third_party/abseil-cpp/absl/base/internal/inline_variable_testing.h index 15dc481e..3856b9f80 100644 --- a/third_party/abseil-cpp/absl/base/internal/inline_variable_testing.h +++ b/third_party/abseil-cpp/absl/base/internal/inline_variable_testing.h
@@ -18,6 +18,7 @@ #include "absl/base/internal/inline_variable.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace inline_variable_testing_internal { struct Foo { @@ -39,6 +40,7 @@ const int& get_int_b(); } // namespace inline_variable_testing_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INLINE_VARIABLE_TESTING_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/invoke.h b/third_party/abseil-cpp/absl/base/internal/invoke.h index 44f1330..c4eceeb 100644 --- a/third_party/abseil-cpp/absl/base/internal/invoke.h +++ b/third_party/abseil-cpp/absl/base/internal/invoke.h
@@ -45,6 +45,7 @@ // top of this file for the API documentation. namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { // The five classes below each implement one of the clauses from the definition @@ -180,6 +181,7 @@ std::forward<Args>(args)...); } } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_INVOKE_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc b/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc index cd526b3..229ab91 100644 --- a/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +++ b/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc
@@ -63,6 +63,7 @@ #endif // __APPLE__ namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { // A first-fit allocator with amortized logarithmic free() time. @@ -211,7 +212,7 @@ // Result of sysconf(_SC_PAGESIZE) const size_t pagesize; // Lowest power of two >= max(16, sizeof(AllocList)) - const size_t roundup; + const size_t round_up; // Smallest allocation block size const size_t min_size; // PRNG state @@ -219,16 +220,17 @@ }; namespace { -using ArenaStorage = std::aligned_storage<sizeof(LowLevelAlloc::Arena), - alignof(LowLevelAlloc::Arena)>::type; - // Static storage space for the lazily-constructed, default global arena // instances. We require this space because the whole point of LowLevelAlloc // is to avoid relying on malloc/new. -ArenaStorage default_arena_storage; -ArenaStorage unhooked_arena_storage; +alignas(LowLevelAlloc::Arena) unsigned char default_arena_storage[sizeof( + LowLevelAlloc::Arena)]; +alignas(LowLevelAlloc::Arena) unsigned char unhooked_arena_storage[sizeof( + LowLevelAlloc::Arena)]; #ifndef ABSL_LOW_LEVEL_ALLOC_ASYNC_SIGNAL_SAFE_MISSING -ArenaStorage unhooked_async_sig_safe_arena_storage; +alignas( + LowLevelAlloc::Arena) unsigned char unhooked_async_sig_safe_arena_storage + [sizeof(LowLevelAlloc::Arena)]; #endif // We must use LowLevelCallOnce here to construct the global arenas, rather than @@ -336,11 +338,11 @@ size_t RoundedUpBlockSize() { // Round up block sizes to a power of two close to the header size. - size_t roundup = 16; - while (roundup < sizeof(AllocList::Header)) { - roundup += roundup; + size_t round_up = 16; + while (round_up < sizeof(AllocList::Header)) { + round_up += round_up; } - return roundup; + return round_up; } } // namespace @@ -350,8 +352,8 @@ allocation_count(0), flags(flags_value), pagesize(GetPageSize()), - roundup(RoundedUpBlockSize()), - min_size(2 * roundup), + round_up(RoundedUpBlockSize()), + min_size(2 * round_up), random(0) { freelist.header.size = 0; freelist.header.magic = @@ -447,7 +449,7 @@ // that the freelist is in the correct order, that it // consists of regions marked "unallocated", and that no two regions // are adjacent in memory (they should have been coalesced). -// L < arena->mu +// L >= arena->mu static AllocList *Next(int i, AllocList *prev, LowLevelAlloc::Arena *arena) { ABSL_RAW_CHECK(i < prev->levels, "too few levels in Next()"); AllocList *next = prev->next[i]; @@ -508,8 +510,6 @@ if (v != nullptr) { AllocList *f = reinterpret_cast<AllocList *>( reinterpret_cast<char *>(v) - sizeof (f->header)); - ABSL_RAW_CHECK(f->header.magic == Magic(kMagicAllocated, &f->header), - "bad magic number in Free()"); LowLevelAlloc::Arena *arena = f->header.arena; ArenaLock section(arena); AddToFreelist(v, arena); @@ -528,7 +528,7 @@ ArenaLock section(arena); // round up with header size_t req_rnd = RoundUp(CheckedAdd(request, sizeof (s->header)), - arena->roundup); + arena->round_up); for (;;) { // loop until we find a suitable region // find the minimum levels that a block of this size must have int i = LLA_SkiplistLevels(req_rnd, arena->min_size, nullptr) - 1; @@ -614,6 +614,7 @@ } } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_LOW_LEVEL_ALLOC_MISSING
diff --git a/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h b/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h index c98cdb3..db91951 100644 --- a/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +++ b/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h
@@ -55,6 +55,7 @@ #include "absl/base/port.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { class LowLevelAlloc { @@ -119,6 +120,7 @@ }; } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_LOW_LEVEL_ALLOC_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/low_level_alloc_test.cc b/third_party/abseil-cpp/absl/base/internal/low_level_alloc_test.cc index 34a080c..7abbbf9c 100644 --- a/third_party/abseil-cpp/absl/base/internal/low_level_alloc_test.cc +++ b/third_party/abseil-cpp/absl/base/internal/low_level_alloc_test.cc
@@ -22,6 +22,7 @@ #include <utility> namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { namespace { @@ -149,6 +150,7 @@ } // namespace } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl int main(int argc, char *argv[]) {
diff --git a/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h b/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h index 0fcc8d3..961cc98 100644 --- a/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +++ b/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h
@@ -28,6 +28,7 @@ extern "C" void __google_enable_rescheduling(bool disable_result); namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { class SchedulingHelper; // To allow use of SchedulingGuard. @@ -100,6 +101,7 @@ } } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_LOW_LEVEL_SCHEDULING_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/periodic_sampler.cc b/third_party/abseil-cpp/absl/base/internal/periodic_sampler.cc new file mode 100644 index 0000000..520dabb --- /dev/null +++ b/third_party/abseil-cpp/absl/base/internal/periodic_sampler.cc
@@ -0,0 +1,53 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/base/internal/periodic_sampler.h" + +#include <atomic> + +#include "absl/base/internal/exponential_biased.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace base_internal { + +int64_t PeriodicSamplerBase::GetExponentialBiased(int period) noexcept { + return rng_.GetStride(period); +} + +bool PeriodicSamplerBase::SubtleConfirmSample() noexcept { + int current_period = period(); + + // Deal with period case 0 (always off) and 1 (always on) + if (ABSL_PREDICT_FALSE(current_period < 2)) { + stride_ = 0; + return current_period == 1; + } + + // Check if this is the first call to Sample() + if (ABSL_PREDICT_FALSE(stride_ == 1)) { + stride_ = static_cast<uint64_t>(-GetExponentialBiased(current_period)); + if (static_cast<int64_t>(stride_) < -1) { + ++stride_; + return false; + } + } + + stride_ = static_cast<uint64_t>(-GetExponentialBiased(current_period)); + return true; +} + +} // namespace base_internal +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/periodic_sampler.h b/third_party/abseil-cpp/absl/base/internal/periodic_sampler.h new file mode 100644 index 0000000..f8a8679 --- /dev/null +++ b/third_party/abseil-cpp/absl/base/internal/periodic_sampler.h
@@ -0,0 +1,211 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ABSL_BASE_INTERNAL_PERIODIC_SAMPLER_H_ +#define ABSL_BASE_INTERNAL_PERIODIC_SAMPLER_H_ + +#include <stdint.h> + +#include <atomic> + +#include "absl/base/internal/exponential_biased.h" +#include "absl/base/optimization.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace base_internal { + +// PeriodicSamplerBase provides the basic period sampler implementation. +// +// This is the base class for the templated PeriodicSampler class, which holds +// a global std::atomic value identified by a user defined tag, such that +// each specific PeriodSampler implementation holds its own global period. +// +// PeriodicSamplerBase is thread-compatible except where stated otherwise. +class PeriodicSamplerBase { + public: + // PeriodicSamplerBase is trivial / copyable / movable / destructible. + PeriodicSamplerBase() = default; + PeriodicSamplerBase(PeriodicSamplerBase&&) = default; + PeriodicSamplerBase(const PeriodicSamplerBase&) = default; + + // Returns true roughly once every `period` calls. This is established by a + // randomly picked `stride` that is counted down on each call to `Sample`. + // This stride is picked such that the probability of `Sample()` returning + // true is 1 in `period`. + inline bool Sample() noexcept; + + // The below methods are intended for optimized use cases where the + // size of the inlined fast path code is highly important. Applications + // should use the `Sample()` method unless they have proof that their + // specific use case requires the optimizations offered by these methods. + // + // An example of such a use case is SwissTable sampling. All sampling checks + // are in inlined SwissTable methods, and the number of call sites is huge. + // In this case, the inlined code size added to each translation unit calling + // SwissTable methods is non-trivial. + // + // The `SubtleMaybeSample()` function spuriously returns true even if the + // function should not be sampled, applications MUST match each call to + // 'SubtleMaybeSample()' returning true with a `SubtleConfirmSample()` call, + // and use the result of the latter as the sampling decision. + // In other words: the code should logically be equivalent to: + // + // if (SubtleMaybeSample() && SubtleConfirmSample()) { + // // Sample this call + // } + // + // In the 'inline-size' optimized case, the `SubtleConfirmSample()` call can + // be placed out of line, for example, the typical use case looks as follows: + // + // // --- frobber.h ----------- + // void FrobberSampled(); + // + // inline void FrobberImpl() { + // // ... + // } + // + // inline void Frobber() { + // if (ABSL_PREDICT_FALSE(sampler.SubtleMaybeSample())) { + // FrobberSampled(); + // } else { + // FrobberImpl(); + // } + // } + // + // // --- frobber.cc ----------- + // void FrobberSampled() { + // if (!sampler.SubtleConfirmSample())) { + // // Spurious false positive + // FrobberImpl(); + // return; + // } + // + // // Sampled execution + // // ... + // } + inline bool SubtleMaybeSample() noexcept; + bool SubtleConfirmSample() noexcept; + + protected: + // We explicitly don't use a virtual destructor as this class is never + // virtually destroyed, and it keeps the class trivial, which avoids TLS + // prologue and epilogue code for our TLS instances. + ~PeriodicSamplerBase() = default; + + // Returns the next stride for our sampler. + // This function is virtual for testing purposes only. + virtual int64_t GetExponentialBiased(int period) noexcept; + + private: + // Returns the current period of this sampler. Thread-safe. + virtual int period() const noexcept = 0; + + // Keep and decrement stride_ as an unsigned integer, but compare the value + // to zero casted as a signed int. clang and msvc do not create optimum code + // if we use signed for the combined decrement and sign comparison. + // + // Below 3 alternative options, all compiles generate the best code + // using the unsigned increment <---> signed int comparison option. + // + // Option 1: + // int64_t stride_; + // if (ABSL_PREDICT_TRUE(++stride_ < 0)) { ... } + // + // GCC x64 (OK) : https://gcc.godbolt.org/z/R5MzzA + // GCC ppc (OK) : https://gcc.godbolt.org/z/z7NZAt + // Clang x64 (BAD): https://gcc.godbolt.org/z/t4gPsd + // ICC x64 (OK) : https://gcc.godbolt.org/z/rE6s8W + // MSVC x64 (OK) : https://gcc.godbolt.org/z/ARMXqS + // + // Option 2: + // int64_t stride_ = 0; + // if (ABSL_PREDICT_TRUE(--stride_ >= 0)) { ... } + // + // GCC x64 (OK) : https://gcc.godbolt.org/z/jSQxYK + // GCC ppc (OK) : https://gcc.godbolt.org/z/VJdYaA + // Clang x64 (BAD): https://gcc.godbolt.org/z/Xm4NjX + // ICC x64 (OK) : https://gcc.godbolt.org/z/4snaFd + // MSVC x64 (BAD): https://gcc.godbolt.org/z/BgnEKE + // + // Option 3: + // uint64_t stride_; + // if (ABSL_PREDICT_TRUE(static_cast<int64_t>(++stride_) < 0)) { ... } + // + // GCC x64 (OK) : https://gcc.godbolt.org/z/bFbfPy + // GCC ppc (OK) : https://gcc.godbolt.org/z/S9KkUE + // Clang x64 (OK) : https://gcc.godbolt.org/z/UYzRb4 + // ICC x64 (OK) : https://gcc.godbolt.org/z/ptTNfD + // MSVC x64 (OK) : https://gcc.godbolt.org/z/76j4-5 + uint64_t stride_ = 0; + ExponentialBiased rng_; +}; + +inline bool PeriodicSamplerBase::SubtleMaybeSample() noexcept { + // See comments on `stride_` for the unsigned increment / signed compare. + if (ABSL_PREDICT_TRUE(static_cast<int64_t>(++stride_) < 0)) { + return false; + } + return true; +} + +inline bool PeriodicSamplerBase::Sample() noexcept { + return ABSL_PREDICT_FALSE(SubtleMaybeSample()) ? SubtleConfirmSample() + : false; +} + +// PeriodicSampler is a concreted periodic sampler implementation. +// The user provided Tag identifies the implementation, and is required to +// isolate the global state of this instance from other instances. +// +// Typical use case: +// +// struct HashTablezTag {}; +// thread_local PeriodicSampler sampler; +// +// void HashTableSamplingLogic(...) { +// if (sampler.Sample()) { +// HashTableSlowSamplePath(...); +// } +// } +// +template <typename Tag, int default_period = 0> +class PeriodicSampler final : public PeriodicSamplerBase { + public: + ~PeriodicSampler() = default; + + int period() const noexcept final { + return period_.load(std::memory_order_relaxed); + } + + // Sets the global period for this sampler. Thread-safe. + // Setting a period of 0 disables the sampler, i.e., every call to Sample() + // will return false. Setting a period of 1 puts the sampler in 'always on' + // mode, i.e., every call to Sample() returns true. + static void SetGlobalPeriod(int period) { + period_.store(period, std::memory_order_relaxed); + } + + private: + static std::atomic<int> period_; +}; + +template <typename Tag, int default_period> +std::atomic<int> PeriodicSampler<Tag, default_period>::period_(default_period); + +} // namespace base_internal +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_BASE_INTERNAL_PERIODIC_SAMPLER_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/periodic_sampler_benchmark.cc b/third_party/abseil-cpp/absl/base/internal/periodic_sampler_benchmark.cc new file mode 100644 index 0000000..5ad469c --- /dev/null +++ b/third_party/abseil-cpp/absl/base/internal/periodic_sampler_benchmark.cc
@@ -0,0 +1,79 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "benchmark/benchmark.h" +#include "absl/base/internal/periodic_sampler.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace base_internal { +namespace { + +template <typename Sampler> +void BM_Sample(Sampler* sampler, benchmark::State& state) { + for (auto _ : state) { + benchmark::DoNotOptimize(sampler); + benchmark::DoNotOptimize(sampler->Sample()); + } +} + +template <typename Sampler> +void BM_SampleMinunumInlined(Sampler* sampler, benchmark::State& state) { + for (auto _ : state) { + benchmark::DoNotOptimize(sampler); + if (ABSL_PREDICT_FALSE(sampler->SubtleMaybeSample())) { + benchmark::DoNotOptimize(sampler->SubtleConfirmSample()); + } + } +} + +void BM_PeriodicSampler_TinySample(benchmark::State& state) { + struct Tag {}; + PeriodicSampler<Tag, 10> sampler; + BM_Sample(&sampler, state); +} +BENCHMARK(BM_PeriodicSampler_TinySample); + +void BM_PeriodicSampler_ShortSample(benchmark::State& state) { + struct Tag {}; + PeriodicSampler<Tag, 1024> sampler; + BM_Sample(&sampler, state); +} +BENCHMARK(BM_PeriodicSampler_ShortSample); + +void BM_PeriodicSampler_LongSample(benchmark::State& state) { + struct Tag {}; + PeriodicSampler<Tag, 1024 * 1024> sampler; + BM_Sample(&sampler, state); +} +BENCHMARK(BM_PeriodicSampler_LongSample); + +void BM_PeriodicSampler_LongSampleMinunumInlined(benchmark::State& state) { + struct Tag {}; + PeriodicSampler<Tag, 1024 * 1024> sampler; + BM_SampleMinunumInlined(&sampler, state); +} +BENCHMARK(BM_PeriodicSampler_LongSampleMinunumInlined); + +void BM_PeriodicSampler_Disabled(benchmark::State& state) { + struct Tag {}; + PeriodicSampler<Tag, 0> sampler; + BM_Sample(&sampler, state); +} +BENCHMARK(BM_PeriodicSampler_Disabled); + +} // namespace +} // namespace base_internal +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/periodic_sampler_test.cc b/third_party/abseil-cpp/absl/base/internal/periodic_sampler_test.cc new file mode 100644 index 0000000..3b301e3 --- /dev/null +++ b/third_party/abseil-cpp/absl/base/internal/periodic_sampler_test.cc
@@ -0,0 +1,177 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/base/internal/periodic_sampler.h" + +#include <thread> // NOLINT(build/c++11) + +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "absl/base/attributes.h" +#include "absl/base/macros.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace base_internal { +namespace { + +using testing::Eq; +using testing::Return; +using testing::StrictMock; + +class MockPeriodicSampler : public PeriodicSamplerBase { + public: + virtual ~MockPeriodicSampler() = default; + + MOCK_METHOD(int, period, (), (const, noexcept)); + MOCK_METHOD(int64_t, GetExponentialBiased, (int), (noexcept)); +}; + +TEST(PeriodicSamplerBaseTest, Sample) { + StrictMock<MockPeriodicSampler> sampler; + + EXPECT_CALL(sampler, period()).Times(3).WillRepeatedly(Return(16)); + EXPECT_CALL(sampler, GetExponentialBiased(16)) + .WillOnce(Return(2)) + .WillOnce(Return(3)) + .WillOnce(Return(4)); + + EXPECT_FALSE(sampler.Sample()); + EXPECT_TRUE(sampler.Sample()); + + EXPECT_FALSE(sampler.Sample()); + EXPECT_FALSE(sampler.Sample()); + EXPECT_TRUE(sampler.Sample()); + + EXPECT_FALSE(sampler.Sample()); + EXPECT_FALSE(sampler.Sample()); + EXPECT_FALSE(sampler.Sample()); +} + +TEST(PeriodicSamplerBaseTest, ImmediatelySample) { + StrictMock<MockPeriodicSampler> sampler; + + EXPECT_CALL(sampler, period()).Times(2).WillRepeatedly(Return(16)); + EXPECT_CALL(sampler, GetExponentialBiased(16)) + .WillOnce(Return(1)) + .WillOnce(Return(2)) + .WillOnce(Return(3)); + + EXPECT_TRUE(sampler.Sample()); + + EXPECT_FALSE(sampler.Sample()); + EXPECT_TRUE(sampler.Sample()); + + EXPECT_FALSE(sampler.Sample()); + EXPECT_FALSE(sampler.Sample()); +} + +TEST(PeriodicSamplerBaseTest, Disabled) { + StrictMock<MockPeriodicSampler> sampler; + + EXPECT_CALL(sampler, period()).Times(3).WillRepeatedly(Return(0)); + + EXPECT_FALSE(sampler.Sample()); + EXPECT_FALSE(sampler.Sample()); + EXPECT_FALSE(sampler.Sample()); +} + +TEST(PeriodicSamplerBaseTest, AlwaysOn) { + StrictMock<MockPeriodicSampler> sampler; + + EXPECT_CALL(sampler, period()).Times(3).WillRepeatedly(Return(1)); + + EXPECT_TRUE(sampler.Sample()); + EXPECT_TRUE(sampler.Sample()); + EXPECT_TRUE(sampler.Sample()); +} + +TEST(PeriodicSamplerBaseTest, Disable) { + StrictMock<MockPeriodicSampler> sampler; + + EXPECT_CALL(sampler, period()).WillOnce(Return(16)); + EXPECT_CALL(sampler, GetExponentialBiased(16)).WillOnce(Return(3)); + EXPECT_FALSE(sampler.Sample()); + EXPECT_FALSE(sampler.Sample()); + + EXPECT_CALL(sampler, period()).Times(2).WillRepeatedly(Return(0)); + + EXPECT_FALSE(sampler.Sample()); + EXPECT_FALSE(sampler.Sample()); +} + +TEST(PeriodicSamplerBaseTest, Enable) { + StrictMock<MockPeriodicSampler> sampler; + + EXPECT_CALL(sampler, period()).WillOnce(Return(0)); + EXPECT_FALSE(sampler.Sample()); + + EXPECT_CALL(sampler, period()).Times(2).WillRepeatedly(Return(16)); + EXPECT_CALL(sampler, GetExponentialBiased(16)) + .Times(2) + .WillRepeatedly(Return(3)); + + EXPECT_FALSE(sampler.Sample()); + EXPECT_FALSE(sampler.Sample()); + EXPECT_TRUE(sampler.Sample()); + + EXPECT_FALSE(sampler.Sample()); + EXPECT_FALSE(sampler.Sample()); +} + +TEST(PeriodicSamplerTest, ConstructConstInit) { + struct Tag {}; + ABSL_CONST_INIT static PeriodicSampler<Tag> sampler; + (void)sampler; +} + +TEST(PeriodicSamplerTest, DefaultPeriod0) { + struct Tag {}; + PeriodicSampler<Tag> sampler; + EXPECT_THAT(sampler.period(), Eq(0)); +} + +TEST(PeriodicSamplerTest, DefaultPeriod) { + struct Tag {}; + PeriodicSampler<Tag, 100> sampler; + EXPECT_THAT(sampler.period(), Eq(100)); +} + +TEST(PeriodicSamplerTest, SetGlobalPeriod) { + struct Tag1 {}; + struct Tag2 {}; + PeriodicSampler<Tag1, 25> sampler1; + PeriodicSampler<Tag2, 50> sampler2; + + EXPECT_THAT(sampler1.period(), Eq(25)); + EXPECT_THAT(sampler2.period(), Eq(50)); + + std::thread thread([] { + PeriodicSampler<Tag1, 25> sampler1; + PeriodicSampler<Tag2, 50> sampler2; + EXPECT_THAT(sampler1.period(), Eq(25)); + EXPECT_THAT(sampler2.period(), Eq(50)); + sampler1.SetGlobalPeriod(10); + sampler2.SetGlobalPeriod(20); + }); + thread.join(); + + EXPECT_THAT(sampler1.period(), Eq(10)); + EXPECT_THAT(sampler2.period(), Eq(20)); +} + +} // namespace +} // namespace base_internal +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/raw_logging.cc b/third_party/abseil-cpp/absl/base/internal/raw_logging.cc index 878fe6c..40cea55 100644 --- a/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +++ b/third_party/abseil-cpp/absl/base/internal/raw_logging.cc
@@ -37,9 +37,9 @@ // this, consider moving both to config.h instead. #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ defined(__Fuchsia__) || defined(__native_client__) || \ - defined(__EMSCRIPTEN__) -#include <unistd.h> + defined(__EMSCRIPTEN__) || defined(__ASYLO__) +#include <unistd.h> #define ABSL_HAVE_POSIX_WRITE 1 #define ABSL_LOW_LEVEL_WRITE_SUPPORTED 1 @@ -71,10 +71,12 @@ // Explicitly #error out when not ABSL_LOW_LEVEL_WRITE_SUPPORTED, except for a // whitelisted set of platforms for which we expect not to be able to raw log. -ABSL_CONST_INIT static absl::base_internal::AtomicHook< - absl::raw_logging_internal::LogPrefixHook> log_prefix_hook; -ABSL_CONST_INIT static absl::base_internal::AtomicHook< - absl::raw_logging_internal::AbortHook> abort_hook; +ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES static absl::base_internal::AtomicHook< + absl::raw_logging_internal::LogPrefixHook> + log_prefix_hook; +ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES static absl::base_internal::AtomicHook< + absl::raw_logging_internal::AbortHook> + abort_hook; #ifdef ABSL_LOW_LEVEL_WRITE_SUPPORTED static const char kTruncated[] = " ... (message truncated)\n"; @@ -182,6 +184,7 @@ } // namespace namespace absl { +ABSL_NAMESPACE_BEGIN namespace raw_logging_internal { void SafeWriteToStderr(const char *s, size_t len) { #if defined(ABSL_HAVE_SYSCALL_WRITE) @@ -224,12 +227,14 @@ #endif // !ABSL_LOW_LEVEL_WRITE_SUPPORTED } -ABSL_CONST_INIT absl::base_internal::AtomicHook<InternalLogFunction> - internal_log_function(DefaultInternalLog); +ABSL_DLL ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES + absl::base_internal::AtomicHook<InternalLogFunction> + internal_log_function(DefaultInternalLog); void RegisterInternalLogFunction(InternalLogFunction func) { internal_log_function.Store(func); } } // namespace raw_logging_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/raw_logging.h b/third_party/abseil-cpp/absl/base/internal/raw_logging.h index 6a4c093..418d6c85 100644 --- a/third_party/abseil-cpp/absl/base/internal/raw_logging.h +++ b/third_party/abseil-cpp/absl/base/internal/raw_logging.h
@@ -22,9 +22,11 @@ #include <string> #include "absl/base/attributes.h" +#include "absl/base/config.h" #include "absl/base/internal/atomic_hook.h" #include "absl/base/log_severity.h" #include "absl/base/macros.h" +#include "absl/base/optimization.h" #include "absl/base/port.h" // This is similar to LOG(severity) << format..., but @@ -70,14 +72,10 @@ // // The API is a subset of the above: each macro only takes two arguments. Use // StrCat if you need to build a richer message. -#define ABSL_INTERNAL_LOG(severity, message) \ - do { \ - constexpr const char* absl_raw_logging_internal_basename = \ - ::absl::raw_logging_internal::Basename(__FILE__, \ - sizeof(__FILE__) - 1); \ - ::absl::raw_logging_internal::internal_log_function( \ - ABSL_RAW_LOGGING_INTERNAL_##severity, \ - absl_raw_logging_internal_basename, __LINE__, message); \ +#define ABSL_INTERNAL_LOG(severity, message) \ + do { \ + ::absl::raw_logging_internal::internal_log_function( \ + ABSL_RAW_LOGGING_INTERNAL_##severity, __FILE__, __LINE__, message); \ } while (0) #define ABSL_INTERNAL_CHECK(condition, message) \ @@ -97,6 +95,7 @@ ::absl::NormalizeLogSeverity(severity) namespace absl { +ABSL_NAMESPACE_BEGIN namespace raw_logging_internal { // Helper function to implement ABSL_RAW_LOG @@ -157,7 +156,7 @@ // // 'file' and 'line' are the file and line number where the ABSL_RAW_LOG macro // was located. -// The null-terminated logged message lives in the buffer between 'buf_start' +// The NUL-terminated logged message lives in the buffer between 'buf_start' // and 'buf_end'. 'prefix_end' points to the first non-prefix character of the // buffer (as written by the LogPrefixHook.) using AbortHook = void (*)(const char* file, int line, const char* buf_start, @@ -171,11 +170,14 @@ const char* file, int line, const std::string& message); -extern base_internal::AtomicHook<InternalLogFunction> internal_log_function; +ABSL_DLL ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES extern base_internal::AtomicHook< + InternalLogFunction> + internal_log_function; void RegisterInternalLogFunction(InternalLogFunction func); } // namespace raw_logging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_RAW_LOGGING_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/scheduling_mode.h b/third_party/abseil-cpp/absl/base/internal/scheduling_mode.h index d5b4b7f..8be5ab6d 100644 --- a/third_party/abseil-cpp/absl/base/internal/scheduling_mode.h +++ b/third_party/abseil-cpp/absl/base/internal/scheduling_mode.h
@@ -18,7 +18,10 @@ #ifndef ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_ #define ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_ +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { // Used to describe how a thread may be scheduled. Typically associated with @@ -49,6 +52,7 @@ }; } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/scoped_set_env.cc b/third_party/abseil-cpp/absl/base/internal/scoped_set_env.cc index 3ac3f68d..8a934cb 100644 --- a/third_party/abseil-cpp/absl/base/internal/scoped_set_env.cc +++ b/third_party/abseil-cpp/absl/base/internal/scoped_set_env.cc
@@ -23,6 +23,7 @@ #include "absl/base/internal/raw_logging.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { namespace { @@ -76,4 +77,5 @@ } } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/scoped_set_env.h b/third_party/abseil-cpp/absl/base/internal/scoped_set_env.h index 855b22fd..19ec7b5 100644 --- a/third_party/abseil-cpp/absl/base/internal/scoped_set_env.h +++ b/third_party/abseil-cpp/absl/base/internal/scoped_set_env.h
@@ -19,7 +19,10 @@ #include <string> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { class ScopedSetEnv { @@ -36,6 +39,7 @@ }; } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_SCOPED_SET_ENV_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/spinlock.cc b/third_party/abseil-cpp/absl/base/internal/spinlock.cc index 7354438..830d472 100644 --- a/third_party/abseil-cpp/absl/base/internal/spinlock.cc +++ b/third_party/abseil-cpp/absl/base/internal/spinlock.cc
@@ -54,10 +54,11 @@ // holder to acquire the lock. There may be outstanding waiter(s). namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { -ABSL_CONST_INIT static base_internal::AtomicHook<void (*)(const void *lock, - int64_t wait_cycles)> +ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES static base_internal::AtomicHook<void (*)( + const void *lock, int64_t wait_cycles)> submit_profile_data; void RegisterSpinLockProfiler(void (*fn)(const void *contendedlock, @@ -228,4 +229,5 @@ } } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/spinlock.h b/third_party/abseil-cpp/absl/base/internal/spinlock.h index ecda792..24e2e9a6 100644 --- a/third_party/abseil-cpp/absl/base/internal/spinlock.h +++ b/third_party/abseil-cpp/absl/base/internal/spinlock.h
@@ -46,6 +46,7 @@ #include "absl/base/thread_annotations.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { class ABSL_LOCKABLE SpinLock { @@ -225,11 +226,10 @@ } } - if (lockword_.compare_exchange_strong( + if (!lockword_.compare_exchange_strong( lock_value, kSpinLockHeld | lock_value | wait_cycles | sched_disabled_bit, std::memory_order_acquire, std::memory_order_relaxed)) { - } else { base_internal::SchedulingGuard::EnableRescheduling(sched_disabled_bit != 0); } @@ -237,6 +237,7 @@ } } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_SPINLOCK_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc b/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc index 28e29d1..323edd6 100644 --- a/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +++ b/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc
@@ -19,12 +19,12 @@ #include <unistd.h> #include <atomic> -#include <cerrno> #include <climits> #include <cstdint> #include <ctime> #include "absl/base/attributes.h" +#include "absl/base/internal/errno_saver.h" // The SpinLock lockword is `std::atomic<uint32_t>`. Here we assert that // `std::atomic<uint32_t>` is bitwise equivalent of the `int` expected @@ -51,12 +51,11 @@ ABSL_ATTRIBUTE_WEAK void AbslInternalSpinLockDelay( std::atomic<uint32_t> *w, uint32_t value, int loop, absl::base_internal::SchedulingMode) { - int save_errno = errno; + absl::base_internal::ErrnoSaver errno_saver; struct timespec tm; tm.tv_sec = 0; tm.tv_nsec = absl::base_internal::SpinLockSuggestedDelayNS(loop); syscall(SYS_futex, w, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, value, &tm); - errno = save_errno; } ABSL_ATTRIBUTE_WEAK void AbslInternalSpinLockWake(std::atomic<uint32_t> *w,
diff --git a/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc b/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc index f025b5f..fcd21b15 100644 --- a/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +++ b/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc
@@ -15,10 +15,11 @@ // This file is a Posix-specific part of spinlock_wait.cc #include <sched.h> + #include <atomic> #include <ctime> -#include <cerrno> +#include "absl/base/internal/errno_saver.h" #include "absl/base/internal/scheduling_mode.h" #include "absl/base/port.h" @@ -27,7 +28,7 @@ ABSL_ATTRIBUTE_WEAK void AbslInternalSpinLockDelay( std::atomic<uint32_t>* /* lock_word */, uint32_t /* value */, int loop, absl::base_internal::SchedulingMode /* mode */) { - int save_errno = errno; + absl::base_internal::ErrnoSaver errno_saver; if (loop == 0) { } else if (loop == 1) { sched_yield(); @@ -37,7 +38,6 @@ tm.tv_nsec = absl::base_internal::SpinLockSuggestedDelayNS(loop); nanosleep(&tm, nullptr); } - errno = save_errno; } ABSL_ATTRIBUTE_WEAK void AbslInternalSpinLockWake(
diff --git a/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc b/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc index fac8a21..fa824be1 100644 --- a/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc +++ b/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc
@@ -32,6 +32,7 @@ #endif namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { // See spinlock_wait.h for spec. @@ -76,4 +77,5 @@ } } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h b/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h index 6642ce1a..169bc749 100644 --- a/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +++ b/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h
@@ -24,6 +24,7 @@ #include "absl/base/internal/scheduling_mode.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { // SpinLockWait() waits until it can perform one of several transitions from @@ -62,6 +63,7 @@ int SpinLockSuggestedDelayNS(int loop); } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl // In some build configurations we pass --detect-odr-violations to the
diff --git a/third_party/abseil-cpp/absl/base/internal/sysinfo.cc b/third_party/abseil-cpp/absl/base/internal/sysinfo.cc index e5e131f..0bed0d8 100644 --- a/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +++ b/third_party/abseil-cpp/absl/base/internal/sysinfo.cc
@@ -17,7 +17,6 @@ #include "absl/base/attributes.h" #ifdef _WIN32 -#include <shlwapi.h> #include <windows.h> #else #include <fcntl.h> @@ -56,12 +55,9 @@ #include "absl/base/internal/unscaledcycleclock.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { -static once_flag init_system_info_once; -static int num_cpus = 0; -static double nominal_cpu_frequency = 1.0; // 0.0 might be dangerous. - static int GetNumCPUs() { #if defined(__myriad2__) return 1; @@ -76,16 +72,32 @@ #if defined(_WIN32) static double GetNominalCPUFrequency() { - DWORD data; - DWORD data_size = sizeof(data); - #pragma comment(lib, "shlwapi.lib") // For SHGetValue(). - if (SUCCEEDED( - SHGetValueA(HKEY_LOCAL_MACHINE, - "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", - "~MHz", nullptr, &data, &data_size))) { - return data * 1e6; // Value is MHz. +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ + !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + // UWP apps don't have access to the registry and currently don't provide an + // API informing about CPU nominal frequency. + return 1.0; +#else +#pragma comment(lib, "advapi32.lib") // For Reg* functions. + HKEY key; + // Use the Reg* functions rather than the SH functions because shlwapi.dll + // pulls in gdi32.dll which makes process destruction much more costly. + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, + "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, + KEY_READ, &key) == ERROR_SUCCESS) { + DWORD type = 0; + DWORD data = 0; + DWORD data_size = sizeof(data); + auto result = RegQueryValueExA(key, "~MHz", 0, &type, + reinterpret_cast<LPBYTE>(&data), &data_size); + RegCloseKey(key); + if (result == ERROR_SUCCESS && type == REG_DWORD && + data_size == sizeof(data)) { + return data * 1e6; // Value is MHz. + } } return 1.0; +#endif // WINAPI_PARTITION_APP && !WINAPI_PARTITION_DESKTOP } #elif defined(CTL_HW) && defined(HW_CPU_FREQ) @@ -256,28 +268,34 @@ #endif -// InitializeSystemInfo() may be called before main() and before -// malloc is properly initialized, therefore this must not allocate -// memory. -static void InitializeSystemInfo() { - num_cpus = GetNumCPUs(); - nominal_cpu_frequency = GetNominalCPUFrequency(); -} +ABSL_CONST_INIT static once_flag init_num_cpus_once; +ABSL_CONST_INIT static int num_cpus = 0; +// NumCPUs() may be called before main() and before malloc is properly +// initialized, therefore this must not allocate memory. int NumCPUs() { - base_internal::LowLevelCallOnce(&init_system_info_once, InitializeSystemInfo); + base_internal::LowLevelCallOnce( + &init_num_cpus_once, []() { num_cpus = GetNumCPUs(); }); return num_cpus; } +// A default frequency of 0.0 might be dangerous if it is used in division. +ABSL_CONST_INIT static once_flag init_nominal_cpu_frequency_once; +ABSL_CONST_INIT static double nominal_cpu_frequency = 1.0; + +// NominalCPUFrequency() may be called before main() and before malloc is +// properly initialized, therefore this must not allocate memory. double NominalCPUFrequency() { - base_internal::LowLevelCallOnce(&init_system_info_once, InitializeSystemInfo); + base_internal::LowLevelCallOnce( + &init_nominal_cpu_frequency_once, + []() { nominal_cpu_frequency = GetNominalCPUFrequency(); }); return nominal_cpu_frequency; } #if defined(_WIN32) pid_t GetTID() { - return GetCurrentThreadId(); + return pid_t{GetCurrentThreadId()}; } #elif defined(__linux__) @@ -401,4 +419,5 @@ #endif } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/sysinfo.h b/third_party/abseil-cpp/absl/base/internal/sysinfo.h index b864a597..7246d5d 100644 --- a/third_party/abseil-cpp/absl/base/internal/sysinfo.h +++ b/third_party/abseil-cpp/absl/base/internal/sysinfo.h
@@ -26,13 +26,14 @@ #ifndef _WIN32 #include <sys/types.h> -#else -#include <intsafe.h> #endif +#include <cstdint> + #include "absl/base/port.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { // Nominal core processor cycles per second of each processor. This is _not_ @@ -51,13 +52,15 @@ // On Linux, you may send a signal to the resulting ID with kill(). However, // it is recommended for portability that you use pthread_kill() instead. #ifdef _WIN32 -// On Windows, process id and thread id are of the same type according to -// the return types of GetProcessId() and GetThreadId() are both DWORD. -using pid_t = DWORD; +// On Windows, process id and thread id are of the same type according to the +// return types of GetProcessId() and GetThreadId() are both DWORD, an unsigned +// 32-bit type. +using pid_t = uint32_t; #endif pid_t GetTID(); } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_SYSINFO_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/sysinfo_test.cc b/third_party/abseil-cpp/absl/base/internal/sysinfo_test.cc index 82bbcc2..fa8b88b 100644 --- a/third_party/abseil-cpp/absl/base/internal/sysinfo_test.cc +++ b/third_party/abseil-cpp/absl/base/internal/sysinfo_test.cc
@@ -28,6 +28,7 @@ #include "absl/synchronization/mutex.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { namespace { @@ -58,8 +59,8 @@ #endif // Test that TIDs are unique to each thread. // Uses a few loops to exercise implementations that reallocate IDs. - for (int i = 0; i < 32; ++i) { - constexpr int kNumThreads = 64; + for (int i = 0; i < 10; ++i) { + constexpr int kNumThreads = 10; Barrier all_threads_done(kNumThreads); std::vector<std::thread> threads; @@ -95,4 +96,5 @@ } // namespace } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/thread_identity.cc b/third_party/abseil-cpp/absl/base/internal/thread_identity.cc index 91273a6b..d63a04ae9 100644 --- a/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +++ b/third_party/abseil-cpp/absl/base/internal/thread_identity.cc
@@ -28,6 +28,7 @@ #include "absl/base/internal/spinlock.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { #if ABSL_THREAD_IDENTITY_MODE != ABSL_THREAD_IDENTITY_MODE_USE_CPP11 @@ -55,7 +56,12 @@ #ifdef __GNUC__ __attribute__((visibility("protected"))) #endif // __GNUC__ - ABSL_PER_THREAD_TLS_KEYWORD ThreadIdentity* thread_identity_ptr; +#if ABSL_PER_THREAD_TLS +// Prefer __thread to thread_local as benchmarks indicate it is a bit faster. +ABSL_PER_THREAD_TLS_KEYWORD ThreadIdentity* thread_identity_ptr = nullptr; +#elif defined(ABSL_HAVE_THREAD_LOCAL) +thread_local ThreadIdentity* thread_identity_ptr = nullptr; +#endif // ABSL_PER_THREAD_TLS #endif // TLS or CPP11 void SetCurrentThreadIdentity( @@ -69,8 +75,8 @@ absl::call_once(init_thread_identity_key_once, AllocateThreadIdentityKey, reclaimer); -#ifdef __EMSCRIPTEN__ - // Emscripten PThread implementation does not support signals. +#if defined(__EMSCRIPTEN__) || defined(__MINGW32__) + // Emscripten and MinGW pthread implementations does not support signals. // See https://kripken.github.io/emscripten-site/docs/porting/pthreads.html // for more information. pthread_setspecific(thread_identity_pthread_key, @@ -89,7 +95,7 @@ pthread_setspecific(thread_identity_pthread_key, reinterpret_cast<void*>(identity)); pthread_sigmask(SIG_SETMASK, &curr_signals, nullptr); -#endif // !__EMSCRIPTEN__ +#endif // !__EMSCRIPTEN__ && !__MINGW32__ #elif ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_TLS // NOTE: Not async-safe. But can be open-coded. @@ -107,6 +113,18 @@ #endif } +#if ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_TLS || \ + ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_CPP11 + +// Please see the comment on `CurrentThreadIdentityIfPresent` in +// thread_identity.h. Because DLLs cannot expose thread_local variables in +// headers, we opt for the correct-but-slower option of placing the definition +// of this function only in a translation unit inside DLL. +#if defined(ABSL_BUILD_DLL) || defined(ABSL_CONSUME_DLL) +ThreadIdentity* CurrentThreadIdentityIfPresent() { return thread_identity_ptr; } +#endif +#endif + void ClearCurrentThreadIdentity() { #if ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_TLS || \ ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_CPP11 @@ -130,4 +148,5 @@ #endif } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/thread_identity.h b/third_party/abseil-cpp/absl/base/internal/thread_identity.h index b34674a..ceb109b4 100644 --- a/third_party/abseil-cpp/absl/base/internal/thread_identity.h +++ b/third_party/abseil-cpp/absl/base/internal/thread_identity.h
@@ -30,9 +30,11 @@ #include <atomic> #include <cstdint> +#include "absl/base/config.h" #include "absl/base/internal/per_thread_tls.h" namespace absl { +ABSL_NAMESPACE_BEGIN struct SynchLocksHeld; struct SynchWaitParams; @@ -208,7 +210,7 @@ #error ABSL_THREAD_IDENTITY_MODE cannot be direcly set #elif defined(ABSL_FORCE_THREAD_IDENTITY_MODE) #define ABSL_THREAD_IDENTITY_MODE ABSL_FORCE_THREAD_IDENTITY_MODE -#elif defined(_WIN32) +#elif defined(_WIN32) && !defined(__MINGW32__) #define ABSL_THREAD_IDENTITY_MODE ABSL_THREAD_IDENTITY_MODE_USE_CPP11 #elif ABSL_PER_THREAD_TLS && defined(__GOOGLE_GRTE_VERSION__) && \ (__GOOGLE_GRTE_VERSION__ >= 20140228L) @@ -224,11 +226,26 @@ #if ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_TLS || \ ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_CPP11 -extern ABSL_PER_THREAD_TLS_KEYWORD ThreadIdentity* thread_identity_ptr; +#if ABSL_PER_THREAD_TLS +ABSL_CONST_INIT extern ABSL_PER_THREAD_TLS_KEYWORD ThreadIdentity* + thread_identity_ptr; +#elif defined(ABSL_HAVE_THREAD_LOCAL) +ABSL_CONST_INIT extern thread_local ThreadIdentity* thread_identity_ptr; +#else +#error Thread-local storage not detected on this platform +#endif +// thread_local variables cannot be in headers exposed by DLLs. However, it is +// important for performance reasons in general that +// `CurrentThreadIdentityIfPresent` be inlined. This is not possible across a +// DLL boundary so, with DLLs, we opt to have the function not be inlined. Note +// that `CurrentThreadIdentityIfPresent` is declared above so we can exclude +// this entire inline definition when compiling as a DLL. +#if !defined(ABSL_BUILD_DLL) && !defined(ABSL_CONSUME_DLL) inline ThreadIdentity* CurrentThreadIdentityIfPresent() { return thread_identity_ptr; } +#endif #elif ABSL_THREAD_IDENTITY_MODE != \ ABSL_THREAD_IDENTITY_MODE_USE_POSIX_SETSPECIFIC @@ -236,6 +253,7 @@ #endif } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_THREAD_IDENTITY_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/thread_identity_test.cc b/third_party/abseil-cpp/absl/base/internal/thread_identity_test.cc index 13bfbe3..3685779 100644 --- a/third_party/abseil-cpp/absl/base/internal/thread_identity_test.cc +++ b/third_party/abseil-cpp/absl/base/internal/thread_identity_test.cc
@@ -25,6 +25,7 @@ #include "absl/synchronization/mutex.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { namespace { @@ -123,4 +124,5 @@ } // namespace } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc b/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc index 8e928b8..c055f75d 100644 --- a/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +++ b/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc
@@ -22,6 +22,7 @@ #include "absl/base/internal/raw_logging.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { namespace { @@ -103,4 +104,5 @@ void ThrowStdBadAlloc() { Throw(std::bad_alloc()); } } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/internal/throw_delegate.h b/third_party/abseil-cpp/absl/base/internal/throw_delegate.h index 03c700b..075f527 100644 --- a/third_party/abseil-cpp/absl/base/internal/throw_delegate.h +++ b/third_party/abseil-cpp/absl/base/internal/throw_delegate.h
@@ -19,7 +19,10 @@ #include <string> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { // Helper functions that allow throwing exceptions consistently from anywhere. @@ -66,6 +69,7 @@ // [[noreturn]] void ThrowStdBadArrayNewLength(); } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_THROW_DELEGATE_H_
diff --git a/third_party/abseil-cpp/absl/base/internal/unaligned_access.h b/third_party/abseil-cpp/absl/base/internal/unaligned_access.h index 2cf7c1d..6be56c86 100644 --- a/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +++ b/third_party/abseil-cpp/absl/base/internal/unaligned_access.h
@@ -18,9 +18,11 @@ #define ABSL_BASE_INTERNAL_UNALIGNED_ACCESS_H_ #include <string.h> + #include <cstdint> #include "absl/base/attributes.h" +#include "absl/base/config.h" // unaligned APIs @@ -56,6 +58,7 @@ } // extern "C" namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { inline uint16_t UnalignedLoad16(const void *p) { @@ -83,6 +86,7 @@ } } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) \ @@ -102,6 +106,7 @@ #else namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { inline uint16_t UnalignedLoad16(const void *p) { @@ -129,6 +134,7 @@ inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); } } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) \
diff --git a/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc b/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc index 593762b..f1e7bbe 100644 --- a/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +++ b/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc
@@ -21,12 +21,18 @@ #endif #if defined(__powerpc__) || defined(__ppc__) +#ifdef __GLIBC__ #include <sys/platform/ppc.h> +#elif defined(__FreeBSD__) +#include <sys/sysctl.h> +#include <sys/types.h> +#endif #endif #include "absl/base/internal/sysinfo.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { #if defined(__i386__) @@ -56,11 +62,43 @@ #elif defined(__powerpc__) || defined(__ppc__) int64_t UnscaledCycleClock::Now() { +#ifdef __GLIBC__ return __ppc_get_timebase(); +#else +#ifdef __powerpc64__ + int64_t tbr; + asm volatile("mfspr %0, 268" : "=r"(tbr)); + return tbr; +#else + int32_t tbu, tbl, tmp; + asm volatile( + "0:\n" + "mftbu %[hi32]\n" + "mftb %[lo32]\n" + "mftbu %[tmp]\n" + "cmpw %[tmp],%[hi32]\n" + "bne 0b\n" + : [ hi32 ] "=r"(tbu), [ lo32 ] "=r"(tbl), [ tmp ] "=r"(tmp)); + return (static_cast<int64_t>(tbu) << 32) | tbl; +#endif +#endif } double UnscaledCycleClock::Frequency() { +#ifdef __GLIBC__ return __ppc_get_timebase_freq(); +#elif defined(__FreeBSD__) + static once_flag init_timebase_frequency_once; + static double timebase_frequency = 0.0; + base_internal::LowLevelCallOnce(&init_timebase_frequency_once, [&]() { + size_t length = sizeof(timebase_frequency); + sysctlbyname("kern.timecounter.tc.timebase.frequency", &timebase_frequency, + &length, nullptr, 0); + }); + return timebase_frequency; +#else +#error Must implement UnscaledCycleClock::Frequency() +#endif } #elif defined(__aarch64__) @@ -96,6 +134,7 @@ #endif } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_USE_UNSCALED_CYCLECLOCK
diff --git a/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h b/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h index 2d361e9..cdce9bf 100644 --- a/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +++ b/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h
@@ -86,6 +86,7 @@ #endif namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { class UnscaledCycleClockWrapperForGetCurrentTime; } // namespace time_internal @@ -115,6 +116,7 @@ }; } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_USE_UNSCALED_CYCLECLOCK
diff --git a/third_party/abseil-cpp/absl/base/invoke_test.cc b/third_party/abseil-cpp/absl/base/invoke_test.cc index 9074443..6aa613c 100644 --- a/third_party/abseil-cpp/absl/base/invoke_test.cc +++ b/third_party/abseil-cpp/absl/base/invoke_test.cc
@@ -25,6 +25,7 @@ #include "absl/strings/str_cat.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { namespace { @@ -218,4 +219,5 @@ } // namespace } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/log_severity.cc b/third_party/abseil-cpp/absl/base/log_severity.cc index 02a2a485..72312afd 100644 --- a/third_party/abseil-cpp/absl/base/log_severity.cc +++ b/third_party/abseil-cpp/absl/base/log_severity.cc
@@ -17,9 +17,11 @@ #include <ostream> namespace absl { +ABSL_NAMESPACE_BEGIN std::ostream& operator<<(std::ostream& os, absl::LogSeverity s) { if (s == absl::NormalizeLogSeverity(s)) return os << absl::LogSeverityName(s); return os << "absl::LogSeverity(" << static_cast<int>(s) << ")"; } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/log_severity.h b/third_party/abseil-cpp/absl/base/log_severity.h index 5a1d5576..65a3b16 100644 --- a/third_party/abseil-cpp/absl/base/log_severity.h +++ b/third_party/abseil-cpp/absl/base/log_severity.h
@@ -19,12 +19,53 @@ #include <ostream> #include "absl/base/attributes.h" +#include "absl/base/config.h" namespace absl { +ABSL_NAMESPACE_BEGIN -// Four severity levels are defined. Logging APIs should terminate the program +// absl::LogSeverity +// +// Four severity levels are defined. Logging APIs should terminate the program // when a message is logged at severity `kFatal`; the other levels have no // special semantics. +// +// Values other than the four defined levels (e.g. produced by `static_cast`) +// are valid, but their semantics when passed to a function, macro, or flag +// depend on the function, macro, or flag. The usual behavior is to normalize +// such values to a defined severity level, however in some cases values other +// than the defined levels are useful for comparison. +// +// Exmaple: +// +// // Effectively disables all logging: +// SetMinLogLevel(static_cast<absl::LogSeverity>(100)); +// +// Abseil flags may be defined with type `LogSeverity`. Dependency layering +// constraints require that the `AbslParseFlag()` overload be declared and +// defined in the flags library itself rather than here. The `AbslUnparseFlag()` +// overload is defined there as well for consistency. +// +// absl::LogSeverity Flag String Representation +// +// An `absl::LogSeverity` has a string representation used for parsing +// command-line flags based on the enumerator name (e.g. `kFatal`) or +// its unprefixed name (without the `k`) in any case-insensitive form. (E.g. +// "FATAL", "fatal" or "Fatal" are all valid.) Unparsing such flags produces an +// unprefixed string representation in all caps (e.g. "FATAL") or an integer. +// +// Additionally, the parser accepts arbitrary integers (as if the type were +// `int`). +// +// Examples: +// +// --my_log_level=kInfo +// --my_log_level=INFO +// --my_log_level=info +// --my_log_level=0 +// +// Unparsing a flag produces the same result as `absl::LogSeverityName()` for +// the standard levels and a base-ten integer otherwise. enum class LogSeverity : int { kInfo = 0, kWarning = 1, @@ -32,6 +73,8 @@ kFatal = 3, }; +// LogSeverities() +// // Returns an iterable of all standard `absl::LogSeverity` values, ordered from // least to most severe. constexpr std::array<absl::LogSeverity, 4> LogSeverities() { @@ -39,8 +82,10 @@ absl::LogSeverity::kError, absl::LogSeverity::kFatal}}; } +// LogSeverityName() +// // Returns the all-caps string representation (e.g. "INFO") of the specified -// severity level if it is one of the normal levels and "UNKNOWN" otherwise. +// severity level if it is one of the standard levels and "UNKNOWN" otherwise. constexpr const char* LogSeverityName(absl::LogSeverity s) { return s == absl::LogSeverity::kInfo ? "INFO" @@ -51,6 +96,8 @@ : s == absl::LogSeverity::kFatal ? "FATAL" : "UNKNOWN"; } +// NormalizeLogSeverity() +// // Values less than `kInfo` normalize to `kInfo`; values greater than `kFatal` // normalize to `kError` (**NOT** `kFatal`). constexpr absl::LogSeverity NormalizeLogSeverity(absl::LogSeverity s) { @@ -59,13 +106,16 @@ : s > absl::LogSeverity::kFatal ? absl::LogSeverity::kError : s; } constexpr absl::LogSeverity NormalizeLogSeverity(int s) { - return NormalizeLogSeverity(static_cast<absl::LogSeverity>(s)); + return absl::NormalizeLogSeverity(static_cast<absl::LogSeverity>(s)); } +// operator<< +// // The exact representation of a streamed `absl::LogSeverity` is deliberately // unspecified; do not rely on it. std::ostream& operator<<(std::ostream& os, absl::LogSeverity s); +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_INTERNAL_LOG_SEVERITY_H_
diff --git a/third_party/abseil-cpp/absl/base/log_severity_test.cc b/third_party/abseil-cpp/absl/base/log_severity_test.cc index 1de2d10..2c6872b0 100644 --- a/third_party/abseil-cpp/absl/base/log_severity_test.cc +++ b/third_party/abseil-cpp/absl/base/log_severity_test.cc
@@ -14,14 +14,26 @@ #include "absl/base/log_severity.h" +#include <cstdint> +#include <ios> +#include <limits> +#include <ostream> #include <sstream> #include <string> +#include <tuple> #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "absl/flags/internal/flag.h" +#include "absl/flags/marshalling.h" +#include "absl/strings/str_cat.h" namespace { -using testing::Eq; +using ::testing::Eq; +using ::testing::IsFalse; +using ::testing::IsTrue; +using ::testing::TestWithParam; +using ::testing::Values; std::string StreamHelper(absl::LogSeverity value) { std::ostringstream stream; @@ -40,4 +52,153 @@ Eq("absl::LogSeverity(4)")); } +static_assert( + absl::flags_internal::FlagUseOneWordStorage<absl::LogSeverity>::value, + "Flags of type absl::LogSeverity ought to be lock-free."); + +using ParseFlagFromOutOfRangeIntegerTest = TestWithParam<int64_t>; +INSTANTIATE_TEST_SUITE_P( + Instantiation, ParseFlagFromOutOfRangeIntegerTest, + Values(static_cast<int64_t>(std::numeric_limits<int>::min()) - 1, + static_cast<int64_t>(std::numeric_limits<int>::max()) + 1)); +TEST_P(ParseFlagFromOutOfRangeIntegerTest, ReturnsError) { + const std::string to_parse = absl::StrCat(GetParam()); + absl::LogSeverity value; + std::string error; + EXPECT_THAT(absl::ParseFlag(to_parse, &value, &error), IsFalse()) << value; +} + +using ParseFlagFromAlmostOutOfRangeIntegerTest = TestWithParam<int>; +INSTANTIATE_TEST_SUITE_P(Instantiation, + ParseFlagFromAlmostOutOfRangeIntegerTest, + Values(std::numeric_limits<int>::min(), + std::numeric_limits<int>::max())); +TEST_P(ParseFlagFromAlmostOutOfRangeIntegerTest, YieldsExpectedValue) { + const auto expected = static_cast<absl::LogSeverity>(GetParam()); + const std::string to_parse = absl::StrCat(GetParam()); + absl::LogSeverity value; + std::string error; + ASSERT_THAT(absl::ParseFlag(to_parse, &value, &error), IsTrue()) << error; + EXPECT_THAT(value, Eq(expected)); +} + +using ParseFlagFromIntegerMatchingEnumeratorTest = + TestWithParam<std::tuple<absl::string_view, absl::LogSeverity>>; +INSTANTIATE_TEST_SUITE_P( + Instantiation, ParseFlagFromIntegerMatchingEnumeratorTest, + Values(std::make_tuple("0", absl::LogSeverity::kInfo), + std::make_tuple(" 0", absl::LogSeverity::kInfo), + std::make_tuple("-0", absl::LogSeverity::kInfo), + std::make_tuple("+0", absl::LogSeverity::kInfo), + std::make_tuple("00", absl::LogSeverity::kInfo), + std::make_tuple("0 ", absl::LogSeverity::kInfo), + std::make_tuple("0x0", absl::LogSeverity::kInfo), + std::make_tuple("1", absl::LogSeverity::kWarning), + std::make_tuple("+1", absl::LogSeverity::kWarning), + std::make_tuple("2", absl::LogSeverity::kError), + std::make_tuple("3", absl::LogSeverity::kFatal))); +TEST_P(ParseFlagFromIntegerMatchingEnumeratorTest, YieldsExpectedValue) { + const absl::string_view to_parse = std::get<0>(GetParam()); + const absl::LogSeverity expected = std::get<1>(GetParam()); + absl::LogSeverity value; + std::string error; + ASSERT_THAT(absl::ParseFlag(to_parse, &value, &error), IsTrue()) << error; + EXPECT_THAT(value, Eq(expected)); +} + +using ParseFlagFromOtherIntegerTest = + TestWithParam<std::tuple<absl::string_view, int>>; +INSTANTIATE_TEST_SUITE_P(Instantiation, ParseFlagFromOtherIntegerTest, + Values(std::make_tuple("-1", -1), + std::make_tuple("4", 4), + std::make_tuple("010", 10), + std::make_tuple("0x10", 16))); +TEST_P(ParseFlagFromOtherIntegerTest, YieldsExpectedValue) { + const absl::string_view to_parse = std::get<0>(GetParam()); + const auto expected = static_cast<absl::LogSeverity>(std::get<1>(GetParam())); + absl::LogSeverity value; + std::string error; + ASSERT_THAT(absl::ParseFlag(to_parse, &value, &error), IsTrue()) << error; + EXPECT_THAT(value, Eq(expected)); +} + +using ParseFlagFromEnumeratorTest = + TestWithParam<std::tuple<absl::string_view, absl::LogSeverity>>; +INSTANTIATE_TEST_SUITE_P( + Instantiation, ParseFlagFromEnumeratorTest, + Values(std::make_tuple("INFO", absl::LogSeverity::kInfo), + std::make_tuple("info", absl::LogSeverity::kInfo), + std::make_tuple("kInfo", absl::LogSeverity::kInfo), + std::make_tuple("iNfO", absl::LogSeverity::kInfo), + std::make_tuple("kInFo", absl::LogSeverity::kInfo), + std::make_tuple("WARNING", absl::LogSeverity::kWarning), + std::make_tuple("warning", absl::LogSeverity::kWarning), + std::make_tuple("kWarning", absl::LogSeverity::kWarning), + std::make_tuple("WaRnInG", absl::LogSeverity::kWarning), + std::make_tuple("KwArNiNg", absl::LogSeverity::kWarning), + std::make_tuple("ERROR", absl::LogSeverity::kError), + std::make_tuple("error", absl::LogSeverity::kError), + std::make_tuple("kError", absl::LogSeverity::kError), + std::make_tuple("eRrOr", absl::LogSeverity::kError), + std::make_tuple("kErRoR", absl::LogSeverity::kError), + std::make_tuple("FATAL", absl::LogSeverity::kFatal), + std::make_tuple("fatal", absl::LogSeverity::kFatal), + std::make_tuple("kFatal", absl::LogSeverity::kFatal), + std::make_tuple("FaTaL", absl::LogSeverity::kFatal), + std::make_tuple("KfAtAl", absl::LogSeverity::kFatal))); +TEST_P(ParseFlagFromEnumeratorTest, YieldsExpectedValue) { + const absl::string_view to_parse = std::get<0>(GetParam()); + const absl::LogSeverity expected = std::get<1>(GetParam()); + absl::LogSeverity value; + std::string error; + ASSERT_THAT(absl::ParseFlag(to_parse, &value, &error), IsTrue()) << error; + EXPECT_THAT(value, Eq(expected)); +} + +using ParseFlagFromGarbageTest = TestWithParam<absl::string_view>; +INSTANTIATE_TEST_SUITE_P(Instantiation, ParseFlagFromGarbageTest, + Values("", "\0", " ", "garbage", "kkinfo", "I")); +TEST_P(ParseFlagFromGarbageTest, ReturnsError) { + const absl::string_view to_parse = GetParam(); + absl::LogSeverity value; + std::string error; + EXPECT_THAT(absl::ParseFlag(to_parse, &value, &error), IsFalse()) << value; +} + +using UnparseFlagToEnumeratorTest = + TestWithParam<std::tuple<absl::LogSeverity, absl::string_view>>; +INSTANTIATE_TEST_SUITE_P( + Instantiation, UnparseFlagToEnumeratorTest, + Values(std::make_tuple(absl::LogSeverity::kInfo, "INFO"), + std::make_tuple(absl::LogSeverity::kWarning, "WARNING"), + std::make_tuple(absl::LogSeverity::kError, "ERROR"), + std::make_tuple(absl::LogSeverity::kFatal, "FATAL"))); +TEST_P(UnparseFlagToEnumeratorTest, ReturnsExpectedValueAndRoundTrips) { + const absl::LogSeverity to_unparse = std::get<0>(GetParam()); + const absl::string_view expected = std::get<1>(GetParam()); + const std::string stringified_value = absl::UnparseFlag(to_unparse); + EXPECT_THAT(stringified_value, Eq(expected)); + absl::LogSeverity reparsed_value; + std::string error; + EXPECT_THAT(absl::ParseFlag(stringified_value, &reparsed_value, &error), + IsTrue()); + EXPECT_THAT(reparsed_value, Eq(to_unparse)); +} + +using UnparseFlagToOtherIntegerTest = TestWithParam<int>; +INSTANTIATE_TEST_SUITE_P(Instantiation, UnparseFlagToOtherIntegerTest, + Values(std::numeric_limits<int>::min(), -1, 4, + std::numeric_limits<int>::max())); +TEST_P(UnparseFlagToOtherIntegerTest, ReturnsExpectedValueAndRoundTrips) { + const absl::LogSeverity to_unparse = + static_cast<absl::LogSeverity>(GetParam()); + const std::string expected = absl::StrCat(GetParam()); + const std::string stringified_value = absl::UnparseFlag(to_unparse); + EXPECT_THAT(stringified_value, Eq(expected)); + absl::LogSeverity reparsed_value; + std::string error; + EXPECT_THAT(absl::ParseFlag(stringified_value, &reparsed_value, &error), + IsTrue()); + EXPECT_THAT(reparsed_value, Eq(to_unparse)); +} } // namespace
diff --git a/third_party/abseil-cpp/absl/base/macros.h b/third_party/abseil-cpp/absl/base/macros.h index 606a90a..547f93b 100644 --- a/third_party/abseil-cpp/absl/base/macros.h +++ b/third_party/abseil-cpp/absl/base/macros.h
@@ -31,6 +31,7 @@ #include <cassert> #include <cstddef> +#include "absl/base/attributes.h" #include "absl/base/optimization.h" #include "absl/base/port.h" @@ -43,12 +44,14 @@ (sizeof(::absl::macros_internal::ArraySizeHelper(array))) namespace absl { +ABSL_NAMESPACE_BEGIN namespace macros_internal { // Note: this internal template function declaration is used by ABSL_ARRAYSIZE. // The function doesn't need a definition, as we only use its type. template <typename T, size_t N> auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N]; } // namespace macros_internal +ABSL_NAMESPACE_END } // namespace absl // kLinkerInitialized @@ -72,11 +75,13 @@ // // Invocation // static MyClass my_global(absl::base_internal::kLinkerInitialized); namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { enum LinkerInitialized { kLinkerInitialized = 0, }; } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl // ABSL_FALLTHROUGH_INTENDED @@ -107,7 +112,7 @@ // when performing switch labels fall-through diagnostic // (`-Wimplicit-fallthrough`). See clang documentation on language extensions // for details: -// http://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough +// https://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough // // When used with unsupported compilers, the ABSL_FALLTHROUGH_INTENDED macro // has no effect on diagnostics. In any case this macro has no effect on runtime @@ -137,10 +142,15 @@ // declarations. The macro argument is used as a custom diagnostic message (e.g. // suggestion of a better alternative). // -// Example: +// Examples: // // class ABSL_DEPRECATED("Use Bar instead") Foo {...}; -// ABSL_DEPRECATED("Use Baz instead") void Bar() {...} +// +// ABSL_DEPRECATED("Use Baz() instead") void Bar() {...} +// +// template <typename T> +// ABSL_DEPRECATED("Use DoThat() instead") +// void DoThis(); // // Every usage of a deprecated entity will trigger a warning when compiled with // clang's `-Wdeprecated-declarations` option. This option is turned off by @@ -158,7 +168,7 @@ // Used on a function overload to trap bad calls: any call that matches the // overload will cause a compile-time error. This macro uses a clang-specific // "enable_if" attribute, as described at -// http://clang.llvm.org/docs/AttributeReference.html#enable-if +// https://clang.llvm.org/docs/AttributeReference.html#enable-if // // Overloads which use this macro should be bracketed by // `#ifdef ABSL_BAD_CALL_IF`. @@ -171,12 +181,9 @@ // ABSL_BAD_CALL_IF(c <= -1 || c > 255, // "'c' must have the value of an unsigned char or EOF"); // #endif // ABSL_BAD_CALL_IF - -#if defined(__clang__) -# if __has_attribute(enable_if) -# define ABSL_BAD_CALL_IF(expr, msg) \ - __attribute__((enable_if(expr, "Bad call trap"), unavailable(msg))) -# endif +#if ABSL_HAVE_ATTRIBUTE(enable_if) +#define ABSL_BAD_CALL_IF(expr, msg) \ + __attribute__((enable_if(expr, "Bad call trap"), unavailable(msg))) #endif // ABSL_ASSERT()
diff --git a/third_party/abseil-cpp/absl/base/optimization.h b/third_party/abseil-cpp/absl/base/optimization.h index 0dcbef3..646523b3 100644 --- a/third_party/abseil-cpp/absl/base/optimization.h +++ b/third_party/abseil-cpp/absl/base/optimization.h
@@ -172,7 +172,7 @@ #if ABSL_HAVE_BUILTIN(__builtin_expect) || \ (defined(__GNUC__) && !defined(__clang__)) #define ABSL_PREDICT_FALSE(x) (__builtin_expect(x, 0)) -#define ABSL_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1)) +#define ABSL_PREDICT_TRUE(x) (__builtin_expect(false || (x), true)) #else #define ABSL_PREDICT_FALSE(x) (x) #define ABSL_PREDICT_TRUE(x) (x)
diff --git a/third_party/abseil-cpp/absl/base/options.h b/third_party/abseil-cpp/absl/base/options.h new file mode 100644 index 0000000..234137c7 --- /dev/null +++ b/third_party/abseil-cpp/absl/base/options.h
@@ -0,0 +1,211 @@ +#ifndef ABSL_BASE_OPTIONS_H_ +#define ABSL_BASE_OPTIONS_H_ + +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------- +// File: options.h +// ----------------------------------------------------------------------------- +// +// This file contains Abseil configuration options for setting specific +// implementations instead of letting Abseil determine which implementation to +// use at compile-time. Setting these options may be useful for package or build +// managers who wish to guarantee ABI stability within binary builds (which are +// otherwise difficult to enforce). +// +// *** IMPORTANT NOTICE FOR PACKAGE MANAGERS: It is important that +// maintainers of package managers who wish to package Abseil read and +// understand this file! *** +// +// Abseil contains a number of possible configuration endpoints, based on +// parameters such as the detected platform, language version, or command-line +// flags used to invoke the underlying binary. As is the case with all +// libraries, binaries which contain Abseil code must ensure that separate +// packages use the same compiled copy of Abseil to avoid a diamond dependency +// problem, which can occur if two packages built with different Abseil +// configuration settings are linked together. Diamond dependency problems in +// C++ may manifest as violations to the One Definition Rule (ODR) (resulting in +// linker errors), or undefined behavior (resulting in crashes). +// +// Diamond dependency problems can be avoided if all packages utilize the same +// exact version of Abseil. Building from source code with the same compilation +// parameters is the easiest way to avoid such dependency problems. However, for +// package managers who cannot control such compilation parameters, we are +// providing the file to allow you to inject ABI (Application Binary Interface) +// stability across builds. Settings options in this file will neither change +// API nor ABI, providing a stable copy of Abseil between packages. +// +// Care must be taken to keep options within these configurations isolated +// from any other dynamic settings, such as command-line flags which could alter +// these options. This file is provided specifically to help build and package +// managers provide a stable copy of Abseil within their libraries and binaries; +// other developers should not have need to alter the contents of this file. +// +// ----------------------------------------------------------------------------- +// Usage +// ----------------------------------------------------------------------------- +// +// For any particular package release, set the appropriate definitions within +// this file to whatever value makes the most sense for your package(s). Note +// that, by default, most of these options, at the moment, affect the +// implementation of types; future options may affect other implementation +// details. +// +// NOTE: the defaults within this file all assume that Abseil can select the +// proper Abseil implementation at compile-time, which will not be sufficient +// to guarantee ABI stability to package managers. + +// Include a standard library header to allow configuration based on the +// standard library in use. +#ifdef __cplusplus +#include <ciso646> +#endif + +// ----------------------------------------------------------------------------- +// Type Compatibility Options +// ----------------------------------------------------------------------------- +// +// ABSL_OPTION_USE_STD_ANY +// +// This option controls whether absl::any is implemented as an alias to +// std::any, or as an independent implementation. +// +// A value of 0 means to use Abseil's implementation. This requires only C++11 +// support, and is expected to work on every toolchain we support. +// +// A value of 1 means to use an alias to std::any. This requires that all code +// using Abseil is built in C++17 mode or later. +// +// A value of 2 means to detect the C++ version being used to compile Abseil, +// and use an alias only if a working std::any is available. This option is +// useful when you are building your entire program, including all of its +// dependencies, from source. It should not be used otherwise -- for example, +// if you are distributing Abseil in a binary package manager -- since in +// mode 2, absl::any will name a different type, with a different mangled name +// and binary layout, depending on the compiler flags passed by the end user. +// For more info, see https://abseil.io/about/design/dropin-types. +// +// User code should not inspect this macro. To check in the preprocessor if +// absl::any is a typedef of std::any, use the feature macro ABSL_USES_STD_ANY. + +#define ABSL_OPTION_USE_STD_ANY 2 + + +// ABSL_OPTION_USE_STD_OPTIONAL +// +// This option controls whether absl::optional is implemented as an alias to +// std::optional, or as an independent implementation. +// +// A value of 0 means to use Abseil's implementation. This requires only C++11 +// support, and is expected to work on every toolchain we support. +// +// A value of 1 means to use an alias to std::optional. This requires that all +// code using Abseil is built in C++17 mode or later. +// +// A value of 2 means to detect the C++ version being used to compile Abseil, +// and use an alias only if a working std::optional is available. This option +// is useful when you are building your program from source. It should not be +// used otherwise -- for example, if you are distributing Abseil in a binary +// package manager -- since in mode 2, absl::optional will name a different +// type, with a different mangled name and binary layout, depending on the +// compiler flags passed by the end user. For more info, see +// https://abseil.io/about/design/dropin-types. + +// User code should not inspect this macro. To check in the preprocessor if +// absl::optional is a typedef of std::optional, use the feature macro +// ABSL_USES_STD_OPTIONAL. + +#define ABSL_OPTION_USE_STD_OPTIONAL 2 + + +// ABSL_OPTION_USE_STD_STRING_VIEW +// +// This option controls whether absl::string_view is implemented as an alias to +// std::string_view, or as an independent implementation. +// +// A value of 0 means to use Abseil's implementation. This requires only C++11 +// support, and is expected to work on every toolchain we support. +// +// A value of 1 means to use an alias to std::string_view. This requires that +// all code using Abseil is built in C++17 mode or later. +// +// A value of 2 means to detect the C++ version being used to compile Abseil, +// and use an alias only if a working std::string_view is available. This +// option is useful when you are building your program from source. It should +// not be used otherwise -- for example, if you are distributing Abseil in a +// binary package manager -- since in mode 2, absl::string_view will name a +// different type, with a different mangled name and binary layout, depending on +// the compiler flags passed by the end user. For more info, see +// https://abseil.io/about/design/dropin-types. +// +// User code should not inspect this macro. To check in the preprocessor if +// absl::string_view is a typedef of std::string_view, use the feature macro +// ABSL_USES_STD_STRING_VIEW. + +#define ABSL_OPTION_USE_STD_STRING_VIEW 2 + +// ABSL_OPTION_USE_STD_VARIANT +// +// This option controls whether absl::variant is implemented as an alias to +// std::variant, or as an independent implementation. +// +// A value of 0 means to use Abseil's implementation. This requires only C++11 +// support, and is expected to work on every toolchain we support. +// +// A value of 1 means to use an alias to std::variant. This requires that all +// code using Abseil is built in C++17 mode or later. +// +// A value of 2 means to detect the C++ version being used to compile Abseil, +// and use an alias only if a working std::variant is available. This option +// is useful when you are building your program from source. It should not be +// used otherwise -- for example, if you are distributing Abseil in a binary +// package manager -- since in mode 2, absl::variant will name a different +// type, with a different mangled name and binary layout, depending on the +// compiler flags passed by the end user. For more info, see +// https://abseil.io/about/design/dropin-types. +// +// User code should not inspect this macro. To check in the preprocessor if +// absl::variant is a typedef of std::variant, use the feature macro +// ABSL_USES_STD_VARIANT. + +#define ABSL_OPTION_USE_STD_VARIANT 2 + + +// ABSL_OPTION_USE_INLINE_NAMESPACE +// ABSL_OPTION_INLINE_NAMESPACE_NAME +// +// These options controls whether all entities in the absl namespace are +// contained within an inner inline namespace. This does not affect the +// user-visible API of Abseil, but it changes the mangled names of all symbols. +// +// This can be useful as a version tag if you are distributing Abseil in +// precompiled form. This will prevent a binary library build of Abseil with +// one inline namespace being used with headers configured with a different +// inline namespace name. Binary packagers are reminded that Abseil does not +// guarantee any ABI stability in Abseil, so any update of Abseil or +// configuration change in such a binary package should be combined with a +// new, unique value for the inline namespace name. +// +// A value of 0 means not to use inline namespaces. +// +// A value of 1 means to use an inline namespace with the given name inside +// namespace absl. If this is set, ABSL_OPTION_INLINE_NAMESPACE_NAME must also +// be changed to a new, unique identifier name. In particular "head" is not +// allowed. + +#define ABSL_OPTION_USE_INLINE_NAMESPACE 0 +#define ABSL_OPTION_INLINE_NAMESPACE_NAME head + +#endif // ABSL_BASE_OPTIONS_H_
diff --git a/third_party/abseil-cpp/absl/base/policy_checks.h b/third_party/abseil-cpp/absl/base/policy_checks.h index 699fb1a2..4dfa49e 100644 --- a/third_party/abseil-cpp/absl/base/policy_checks.h +++ b/third_party/abseil-cpp/absl/base/policy_checks.h
@@ -82,16 +82,6 @@ // Standard Library Check // ----------------------------------------------------------------------------- -// We have chosen glibc 2.12 as the minimum as it was tagged for release -// in May, 2010 and includes some functionality used in Google software -// (for instance pthread_setname_np): -// https://sourceware.org/ml/libc-alpha/2010-05/msg00000.html -#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) -#if !__GLIBC_PREREQ(2, 12) -#error "Minimum required version of glibc is 2.12." -#endif -#endif - #if defined(_STLPORT_VERSION) #error "STLPort is not supported." #endif
diff --git a/third_party/abseil-cpp/absl/base/spinlock_test_common.cc b/third_party/abseil-cpp/absl/base/spinlock_test_common.cc index 84fc4dac..08f61ba 100644 --- a/third_party/abseil-cpp/absl/base/spinlock_test_common.cc +++ b/third_party/abseil-cpp/absl/base/spinlock_test_common.cc
@@ -36,6 +36,7 @@ constexpr int32_t kIters = 1000; namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { // This is defined outside of anonymous namespace so that it can be @@ -266,4 +267,5 @@ } // namespace } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/base/thread_annotations.h b/third_party/abseil-cpp/absl/base/thread_annotations.h index 9321c3f8..bcd05e51 100644 --- a/third_party/abseil-cpp/absl/base/thread_annotations.h +++ b/third_party/abseil-cpp/absl/base/thread_annotations.h
@@ -34,6 +34,8 @@ #ifndef ABSL_BASE_THREAD_ANNOTATIONS_H_ #define ABSL_BASE_THREAD_ANNOTATIONS_H_ +#include "absl/base/config.h" + #if defined(__clang__) #define ABSL_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(x) __attribute__((x)) #else @@ -253,6 +255,7 @@ #define ABSL_TS_UNCHECKED_READ(x) absl::base_internal::absl_ts_unchecked_read(x) namespace absl { +ABSL_NAMESPACE_BEGIN namespace base_internal { // Takes a reference to a guarded data member, and returns an unguarded @@ -269,6 +272,7 @@ } } // namespace base_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_THREAD_ANNOTATIONS_H_
diff --git a/third_party/abseil-cpp/absl/base/throw_delegate_test.cc b/third_party/abseil-cpp/absl/base/throw_delegate_test.cc index a74dd3c..5ba4ce5 100644 --- a/third_party/abseil-cpp/absl/base/throw_delegate_test.cc +++ b/third_party/abseil-cpp/absl/base/throw_delegate_test.cc
@@ -18,6 +18,7 @@ #include <new> #include <stdexcept> +#include "absl/base/config.h" #include "gtest/gtest.h" namespace { @@ -38,31 +39,43 @@ template <typename E> void ExpectThrowChar(void (*f)(const char*)) { +#ifdef ABSL_HAVE_EXCEPTIONS try { f(what_arg); FAIL() << "Didn't throw"; } catch (const E& e) { EXPECT_STREQ(e.what(), what_arg); } +#else + EXPECT_DEATH_IF_SUPPORTED(f(what_arg), what_arg); +#endif } template <typename E> void ExpectThrowString(void (*f)(const std::string&)) { +#ifdef ABSL_HAVE_EXCEPTIONS try { f(what_arg); FAIL() << "Didn't throw"; } catch (const E& e) { EXPECT_STREQ(e.what(), what_arg); } +#else + EXPECT_DEATH_IF_SUPPORTED(f(what_arg), what_arg); +#endif } template <typename E> void ExpectThrowNoWhat(void (*f)()) { +#ifdef ABSL_HAVE_EXCEPTIONS try { f(); FAIL() << "Didn't throw"; } catch (const E& e) { } +#else + EXPECT_DEATH_IF_SUPPORTED(f(), ""); +#endif } TEST(ThrowHelper, Test) {
diff --git a/third_party/abseil-cpp/absl/container/BUILD.bazel b/third_party/abseil-cpp/absl/container/BUILD.bazel index 1859d9e..709856414 100644 --- a/third_party/abseil-cpp/absl/container/BUILD.bazel +++ b/third_party/abseil-cpp/absl/container/BUILD.bazel
@@ -14,12 +14,11 @@ # limitations under the License. # +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", "ABSL_DEFAULT_LINKOPTS", - "ABSL_EXCEPTIONS_FLAG", - "ABSL_EXCEPTIONS_FLAG_LINKOPTS", "ABSL_TEST_COPTS", ) @@ -71,20 +70,6 @@ cc_test( name = "fixed_array_test", srcs = ["fixed_array_test.cc"], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, - deps = [ - ":fixed_array", - "//absl/base:exception_testing", - "//absl/hash:hash_testing", - "//absl/memory", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "fixed_array_test_noexceptions", - srcs = ["fixed_array_test.cc"], copts = ABSL_TEST_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ @@ -99,10 +84,11 @@ cc_test( name = "fixed_array_exception_safety_test", srcs = ["fixed_array_exception_safety_test.cc"], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":fixed_array", + "//absl/base:config", "//absl/base:exception_safety_testing", "@com_google_googletest//:gtest_main", ], @@ -155,39 +141,21 @@ copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, visibility = ["//visibility:private"], + deps = ["//absl/base:config"], ) cc_test( name = "inlined_vector_test", srcs = ["inlined_vector_test.cc"], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, - deps = [ - ":counting_allocator", - ":inlined_vector", - ":test_instance_tracker", - "//absl/base", - "//absl/base:core_headers", - "//absl/base:exception_testing", - "//absl/hash:hash_testing", - "//absl/memory", - "//absl/strings", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "inlined_vector_test_noexceptions", - srcs = ["inlined_vector_test.cc"], copts = ABSL_TEST_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":counting_allocator", ":inlined_vector", ":test_instance_tracker", - "//absl/base", "//absl/base:core_headers", "//absl/base:exception_testing", + "//absl/base:raw_logging_internal", "//absl/hash:hash_testing", "//absl/memory", "//absl/strings", @@ -203,8 +171,8 @@ tags = ["benchmark"], deps = [ ":inlined_vector", - "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "//absl/strings", "@com_github_google_benchmark//:benchmark_main", ], @@ -213,9 +181,10 @@ cc_test( name = "inlined_vector_exception_safety_test", srcs = ["inlined_vector_exception_safety_test.cc"], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + copts = ABSL_TEST_COPTS, deps = [ ":inlined_vector", + "//absl/base:config", "//absl/base:exception_safety_testing", "@com_google_googletest//:gtest_main", ], @@ -421,6 +390,7 @@ "//absl/base:config", "//absl/hash", "//absl/strings", + "//absl/strings:cord", ], ) @@ -433,7 +403,10 @@ deps = [ ":hash_function_defaults", "//absl/hash", + "//absl/random", "//absl/strings", + "//absl/strings:cord", + "//absl/strings:cord_test_helpers", "@com_google_googletest//:gtest_main", ], ) @@ -447,6 +420,7 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":hash_policy_testing", + "//absl/memory", "//absl/meta:type_traits", "//absl/strings", ], @@ -509,6 +483,9 @@ hdrs = ["internal/hashtable_debug_hooks.h"], copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + "//absl/base:config", + ], ) cc_library( @@ -524,6 +501,7 @@ ":have_sse", "//absl/base", "//absl/base:core_headers", + "//absl/base:exponential_biased", "//absl/debugging:stacktrace", "//absl/memory", "//absl/synchronization", @@ -551,6 +529,7 @@ hdrs = ["internal/node_hash_policy.h"], copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, + deps = ["//absl/base:config"], ) cc_test( @@ -635,6 +614,7 @@ ":raw_hash_set", "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "//absl/strings", "@com_google_googletest//:gtest_main", ], @@ -678,8 +658,8 @@ visibility = ["//visibility:private"], deps = [ ":layout", - "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "//absl/types:span", "@com_google_googletest//:gtest_main", ], @@ -691,6 +671,9 @@ hdrs = ["internal/tracked.h"], copts = ABSL_TEST_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + "//absl/base:config", + ], ) cc_library( @@ -849,6 +832,7 @@ "//absl/memory", "//absl/meta:type_traits", "//absl/strings", + "//absl/strings:cord", "//absl/types:compare", "//absl/utility", ], @@ -865,6 +849,7 @@ ":btree", ":flat_hash_set", "//absl/strings", + "//absl/strings:cord", "//absl/time", ], ) @@ -875,7 +860,7 @@ srcs = [ "btree_test.cc", ], - copts = ABSL_TEST_COPTS + ["-fexceptions"], + copts = ABSL_TEST_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, shard_count = 10, visibility = ["//visibility:private"], @@ -884,7 +869,8 @@ ":btree_test_common", ":counting_allocator", ":test_instance_tracker", - "//absl/base", + "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "//absl/flags:flag", "//absl/hash:hash_testing", "//absl/memory", @@ -894,3 +880,30 @@ "@com_google_googletest//:gtest_main", ], ) + +cc_binary( + name = "btree_benchmark", + testonly = 1, + srcs = [ + "btree_benchmark.cc", + ], + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + tags = ["benchmark"], + visibility = ["//visibility:private"], + deps = [ + ":btree", + ":btree_test_common", + ":flat_hash_map", + ":flat_hash_set", + ":hashtable_debug", + "//absl/base:raw_logging_internal", + "//absl/flags:flag", + "//absl/hash", + "//absl/memory", + "//absl/strings:cord", + "//absl/strings:str_format", + "//absl/time", + "@com_github_google_benchmark//:benchmark_main", + ], +)
diff --git a/third_party/abseil-cpp/absl/container/BUILD.gn b/third_party/abseil-cpp/absl/container/BUILD.gn index 96e16ba3..850c95d 100644 --- a/third_party/abseil-cpp/absl/container/BUILD.gn +++ b/third_party/abseil-cpp/absl/container/BUILD.gn
@@ -89,6 +89,7 @@ ] public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] public = [ "internal/counting_allocator.h" ] + deps = [ "../base:config" ] visibility = [] visibility += [ ":*" ] } @@ -205,6 +206,7 @@ "../base:config", "../hash", "../strings", + "../strings:cord", ] } @@ -220,6 +222,7 @@ public = [ "internal/hash_generator_testing.h" ] deps = [ ":hash_policy_testing", + "../memory", "../meta:type_traits", "../strings", ] @@ -270,6 +273,7 @@ ] public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] public = [ "internal/hashtable_debug_hooks.h" ] + deps = [ "../base:config" ] } source_set("hashtablez_sampler") { @@ -288,6 +292,7 @@ ":have_sse", "../base", "../base:core_headers", + "../base:exponential_biased", "../debugging:stacktrace", "../memory", "../synchronization", @@ -303,6 +308,7 @@ ] public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] public = [ "internal/node_hash_policy.h" ] + deps = [ "../base:config" ] } source_set("raw_hash_map") { @@ -400,6 +406,7 @@ ] public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] public = [ "internal/tracked.h" ] + deps = [ "../base:config" ] } source_set("unordered_map_constructor_test") { @@ -554,6 +561,7 @@ "../memory", "../meta:type_traits", "../strings", + "../strings:cord", "../types:compare", "../utility", ]
diff --git a/third_party/abseil-cpp/absl/container/CMakeLists.txt b/third_party/abseil-cpp/absl/container/CMakeLists.txt index 6cabe0c9..99a8e9c 100644 --- a/third_party/abseil-cpp/absl/container/CMakeLists.txt +++ b/third_party/abseil-cpp/absl/container/CMakeLists.txt
@@ -40,6 +40,7 @@ absl::compare absl::compressed_tuple absl::container_memory + absl::cord absl::core_headers absl::layout absl::memory @@ -60,6 +61,7 @@ ${ABSL_DEFAULT_LINKOPTS} DEPS absl::btree + absl::cord absl::flat_hash_set absl::strings absl::time @@ -71,14 +73,19 @@ btree_test SRCS "btree_test.cc" + COPTS + ${ABSL_TEST_COPTS} + LINKOPTS + ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::base absl::btree absl::btree_test_common absl::compare + absl::core_headers absl::counting_allocator absl::flags absl::hash_testing + absl::raw_logging_internal absl::strings absl::test_instance_tracker absl::type_traits @@ -138,24 +145,6 @@ "fixed_array_test.cc" COPTS ${ABSL_TEST_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} - DEPS - absl::fixed_array - absl::exception_testing - absl::hash_testing - absl::memory - gmock_main -) - -absl_cc_test( - NAME - fixed_array_test_noexceptions - SRCS - "fixed_array_test.cc" - COPTS - ${ABSL_TEST_COPTS} DEPS absl::fixed_array absl::exception_testing @@ -171,11 +160,9 @@ "fixed_array_exception_safety_test.cc" COPTS ${ABSL_TEST_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS absl::fixed_array + absl::config absl::exception_safety_testing gmock_main ) @@ -219,6 +206,8 @@ "internal/counting_allocator.h" COPTS ${ABSL_DEFAULT_COPTS} + DEPS + absl::config ) absl_cc_test( @@ -228,37 +217,15 @@ "inlined_vector_test.cc" COPTS ${ABSL_TEST_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS absl::counting_allocator absl::inlined_vector absl::test_instance_tracker - absl::base absl::core_headers absl::exception_testing absl::hash_testing absl::memory - absl::strings - gmock_main -) - -absl_cc_test( - NAME - inlined_vector_test_noexceptions - SRCS - "inlined_vector_test.cc" - COPTS - ${ABSL_TEST_COPTS} - DEPS - absl::inlined_vector - absl::test_instance_tracker - absl::base - absl::core_headers - absl::exception_testing - absl::hash_testing - absl::memory + absl::raw_logging_internal absl::strings gmock_main ) @@ -270,11 +237,9 @@ "inlined_vector_exception_safety_test.cc" COPTS ${ABSL_TEST_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS absl::inlined_vector + absl::config absl::exception_safety_testing gmock_main ) @@ -480,6 +445,7 @@ ${ABSL_DEFAULT_COPTS} DEPS absl::config + absl::cord absl::hash absl::strings PUBLIC @@ -493,8 +459,11 @@ COPTS ${ABSL_TEST_COPTS} DEPS + absl::cord + absl::cord_test_helpers absl::hash_function_defaults absl::hash + absl::random_random absl::strings gmock_main ) @@ -510,6 +479,7 @@ ${ABSL_TEST_COPTS} DEPS absl::hash_policy_testing + absl::memory absl::meta absl::strings TESTONLY @@ -576,6 +546,7 @@ ${ABSL_DEFAULT_COPTS} DEPS absl::base + absl::exponential_biased absl::have_sse absl::synchronization ) @@ -611,6 +582,8 @@ "internal/hashtable_debug_hooks.h" COPTS ${ABSL_DEFAULT_COPTS} + DEPS + absl::config PUBLIC ) @@ -630,6 +603,8 @@ "internal/node_hash_policy.h" COPTS ${ABSL_DEFAULT_COPTS} + DEPS + absl::config PUBLIC ) @@ -664,7 +639,7 @@ NAME container_common HDRS - "internal/commom.h" + "internal/common.h" COPTS ${ABSL_DEFAULT_COPTS} DEPS @@ -715,6 +690,7 @@ absl::raw_hash_set absl::base absl::core_headers + absl::raw_logging_internal absl::strings gmock_main ) @@ -758,8 +734,8 @@ ${ABSL_TEST_COPTS} DEPS absl::layout - absl::base absl::core_headers + absl::raw_logging_internal absl::span gmock_main ) @@ -771,6 +747,8 @@ "internal/tracked.h" COPTS ${ABSL_TEST_COPTS} + DEPS + absl::config TESTONLY )
diff --git a/third_party/abseil-cpp/absl/container/btree_benchmark.cc b/third_party/abseil-cpp/absl/container/btree_benchmark.cc new file mode 100644 index 0000000..ca4d575c --- /dev/null +++ b/third_party/abseil-cpp/absl/container/btree_benchmark.cc
@@ -0,0 +1,713 @@ +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include <stdint.h> + +#include <algorithm> +#include <functional> +#include <map> +#include <numeric> +#include <random> +#include <set> +#include <string> +#include <type_traits> +#include <unordered_map> +#include <unordered_set> +#include <vector> + +#include "absl/base/internal/raw_logging.h" +#include "absl/container/btree_map.h" +#include "absl/container/btree_set.h" +#include "absl/container/btree_test.h" +#include "absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_set.h" +#include "absl/container/internal/hashtable_debug.h" +#include "absl/flags/flag.h" +#include "absl/hash/hash.h" +#include "absl/memory/memory.h" +#include "absl/strings/cord.h" +#include "absl/strings/str_format.h" +#include "absl/time/time.h" +#include "benchmark/benchmark.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace container_internal { +namespace { + +constexpr size_t kBenchmarkValues = 1 << 20; + +// How many times we add and remove sub-batches in one batch of *AddRem +// benchmarks. +constexpr size_t kAddRemBatchSize = 1 << 2; + +// Generates n values in the range [0, 4 * n]. +template <typename V> +std::vector<V> GenerateValues(int n) { + constexpr int kSeed = 23; + return GenerateValuesWithSeed<V>(n, 4 * n, kSeed); +} + +// Benchmark insertion of values into a container. +template <typename T> +void BM_InsertImpl(benchmark::State& state, bool sorted) { + using V = typename remove_pair_const<typename T::value_type>::type; + typename KeyOfValue<typename T::key_type, V>::type key_of_value; + + std::vector<V> values = GenerateValues<V>(kBenchmarkValues); + if (sorted) { + std::sort(values.begin(), values.end()); + } + T container(values.begin(), values.end()); + + // Remove and re-insert 10% of the keys per batch. + const int batch_size = (kBenchmarkValues + 9) / 10; + while (state.KeepRunningBatch(batch_size)) { + state.PauseTiming(); + const auto i = static_cast<int>(state.iterations()); + + for (int j = i; j < i + batch_size; j++) { + int x = j % kBenchmarkValues; + container.erase(key_of_value(values[x])); + } + + state.ResumeTiming(); + + for (int j = i; j < i + batch_size; j++) { + int x = j % kBenchmarkValues; + container.insert(values[x]); + } + } +} + +template <typename T> +void BM_Insert(benchmark::State& state) { + BM_InsertImpl<T>(state, false); +} + +template <typename T> +void BM_InsertSorted(benchmark::State& state) { + BM_InsertImpl<T>(state, true); +} + +// container::insert sometimes returns a pair<iterator, bool> and sometimes +// returns an iterator (for multi- containers). +template <typename Iter> +Iter GetIterFromInsert(const std::pair<Iter, bool>& pair) { + return pair.first; +} +template <typename Iter> +Iter GetIterFromInsert(const Iter iter) { + return iter; +} + +// Benchmark insertion of values into a container at the end. +template <typename T> +void BM_InsertEnd(benchmark::State& state) { + using V = typename remove_pair_const<typename T::value_type>::type; + typename KeyOfValue<typename T::key_type, V>::type key_of_value; + + T container; + const int kSize = 10000; + for (int i = 0; i < kSize; ++i) { + container.insert(Generator<V>(kSize)(i)); + } + V v = Generator<V>(kSize)(kSize - 1); + typename T::key_type k = key_of_value(v); + + auto it = container.find(k); + while (state.KeepRunning()) { + // Repeatedly removing then adding v. + container.erase(it); + it = GetIterFromInsert(container.insert(v)); + } +} + +template <typename T> +void BM_LookupImpl(benchmark::State& state, bool sorted) { + using V = typename remove_pair_const<typename T::value_type>::type; + typename KeyOfValue<typename T::key_type, V>::type key_of_value; + + std::vector<V> values = GenerateValues<V>(kBenchmarkValues); + if (sorted) { + std::sort(values.begin(), values.end()); + } + T container(values.begin(), values.end()); + + while (state.KeepRunning()) { + int idx = state.iterations() % kBenchmarkValues; + benchmark::DoNotOptimize(container.find(key_of_value(values[idx]))); + } +} + +// Benchmark lookup of values in a container. +template <typename T> +void BM_Lookup(benchmark::State& state) { + BM_LookupImpl<T>(state, false); +} + +// Benchmark lookup of values in a full container, meaning that values +// are inserted in-order to take advantage of biased insertion, which +// yields a full tree. +template <typename T> +void BM_FullLookup(benchmark::State& state) { + BM_LookupImpl<T>(state, true); +} + +// Benchmark deletion of values from a container. +template <typename T> +void BM_Delete(benchmark::State& state) { + using V = typename remove_pair_const<typename T::value_type>::type; + typename KeyOfValue<typename T::key_type, V>::type key_of_value; + std::vector<V> values = GenerateValues<V>(kBenchmarkValues); + T container(values.begin(), values.end()); + + // Remove and re-insert 10% of the keys per batch. + const int batch_size = (kBenchmarkValues + 9) / 10; + while (state.KeepRunningBatch(batch_size)) { + const int i = state.iterations(); + + for (int j = i; j < i + batch_size; j++) { + int x = j % kBenchmarkValues; + container.erase(key_of_value(values[x])); + } + + state.PauseTiming(); + for (int j = i; j < i + batch_size; j++) { + int x = j % kBenchmarkValues; + container.insert(values[x]); + } + state.ResumeTiming(); + } +} + +// Benchmark deletion of multiple values from a container. +template <typename T> +void BM_DeleteRange(benchmark::State& state) { + using V = typename remove_pair_const<typename T::value_type>::type; + typename KeyOfValue<typename T::key_type, V>::type key_of_value; + std::vector<V> values = GenerateValues<V>(kBenchmarkValues); + T container(values.begin(), values.end()); + + // Remove and re-insert 10% of the keys per batch. + const int batch_size = (kBenchmarkValues + 9) / 10; + while (state.KeepRunningBatch(batch_size)) { + const int i = state.iterations(); + + const int start_index = i % kBenchmarkValues; + + state.PauseTiming(); + { + std::vector<V> removed; + removed.reserve(batch_size); + auto itr = container.find(key_of_value(values[start_index])); + auto start = itr; + for (int j = 0; j < batch_size; j++) { + if (itr == container.end()) { + state.ResumeTiming(); + container.erase(start, itr); + state.PauseTiming(); + itr = container.begin(); + start = itr; + } + removed.push_back(*itr++); + } + + state.ResumeTiming(); + container.erase(start, itr); + state.PauseTiming(); + + container.insert(removed.begin(), removed.end()); + } + state.ResumeTiming(); + } +} + +// Benchmark steady-state insert (into first half of range) and remove (from +// second half of range), treating the container approximately like a queue with +// log-time access for all elements. This benchmark does not test the case where +// insertion and removal happen in the same region of the tree. This benchmark +// counts two value constructors. +template <typename T> +void BM_QueueAddRem(benchmark::State& state) { + using V = typename remove_pair_const<typename T::value_type>::type; + typename KeyOfValue<typename T::key_type, V>::type key_of_value; + + ABSL_RAW_CHECK(kBenchmarkValues % 2 == 0, "for performance"); + + T container; + + const size_t half = kBenchmarkValues / 2; + std::vector<int> remove_keys(half); + std::vector<int> add_keys(half); + + // We want to do the exact same work repeatedly, and the benchmark can end + // after a different number of iterations depending on the speed of the + // individual run so we use a large batch size here and ensure that we do + // deterministic work every batch. + while (state.KeepRunningBatch(half * kAddRemBatchSize)) { + state.PauseTiming(); + + container.clear(); + + for (size_t i = 0; i < half; ++i) { + remove_keys[i] = i; + add_keys[i] = i; + } + constexpr int kSeed = 5; + std::mt19937_64 rand(kSeed); + std::shuffle(remove_keys.begin(), remove_keys.end(), rand); + std::shuffle(add_keys.begin(), add_keys.end(), rand); + + // Note needs lazy generation of values. + Generator<V> g(kBenchmarkValues * kAddRemBatchSize); + + for (size_t i = 0; i < half; ++i) { + container.insert(g(add_keys[i])); + container.insert(g(half + remove_keys[i])); + } + + // There are three parts each of size "half": + // 1 is being deleted from [offset - half, offset) + // 2 is standing [offset, offset + half) + // 3 is being inserted into [offset + half, offset + 2 * half) + size_t offset = 0; + + for (size_t i = 0; i < kAddRemBatchSize; ++i) { + std::shuffle(remove_keys.begin(), remove_keys.end(), rand); + std::shuffle(add_keys.begin(), add_keys.end(), rand); + offset += half; + + state.ResumeTiming(); + for (size_t idx = 0; idx < half; ++idx) { + container.erase(key_of_value(g(offset - half + remove_keys[idx]))); + container.insert(g(offset + half + add_keys[idx])); + } + state.PauseTiming(); + } + state.ResumeTiming(); + } +} + +// Mixed insertion and deletion in the same range using pre-constructed values. +template <typename T> +void BM_MixedAddRem(benchmark::State& state) { + using V = typename remove_pair_const<typename T::value_type>::type; + typename KeyOfValue<typename T::key_type, V>::type key_of_value; + + ABSL_RAW_CHECK(kBenchmarkValues % 2 == 0, "for performance"); + + T container; + + // Create two random shuffles + std::vector<int> remove_keys(kBenchmarkValues); + std::vector<int> add_keys(kBenchmarkValues); + + // We want to do the exact same work repeatedly, and the benchmark can end + // after a different number of iterations depending on the speed of the + // individual run so we use a large batch size here and ensure that we do + // deterministic work every batch. + while (state.KeepRunningBatch(kBenchmarkValues * kAddRemBatchSize)) { + state.PauseTiming(); + + container.clear(); + + constexpr int kSeed = 7; + std::mt19937_64 rand(kSeed); + + std::vector<V> values = GenerateValues<V>(kBenchmarkValues * 2); + + // Insert the first half of the values (already in random order) + container.insert(values.begin(), values.begin() + kBenchmarkValues); + + // Insert the first half of the values (already in random order) + for (size_t i = 0; i < kBenchmarkValues; ++i) { + // remove_keys and add_keys will be swapped before each round, + // therefore fill add_keys here w/ the keys being inserted, so + // they'll be the first to be removed. + remove_keys[i] = i + kBenchmarkValues; + add_keys[i] = i; + } + + for (size_t i = 0; i < kAddRemBatchSize; ++i) { + remove_keys.swap(add_keys); + std::shuffle(remove_keys.begin(), remove_keys.end(), rand); + std::shuffle(add_keys.begin(), add_keys.end(), rand); + + state.ResumeTiming(); + for (size_t idx = 0; idx < kBenchmarkValues; ++idx) { + container.erase(key_of_value(values[remove_keys[idx]])); + container.insert(values[add_keys[idx]]); + } + state.PauseTiming(); + } + state.ResumeTiming(); + } +} + +// Insertion at end, removal from the beginning. This benchmark +// counts two value constructors. +// TODO(ezb): we could add a GenerateNext version of generator that could reduce +// noise for string-like types. +template <typename T> +void BM_Fifo(benchmark::State& state) { + using V = typename remove_pair_const<typename T::value_type>::type; + + T container; + // Need lazy generation of values as state.max_iterations is large. + Generator<V> g(kBenchmarkValues + state.max_iterations); + + for (int i = 0; i < kBenchmarkValues; i++) { + container.insert(g(i)); + } + + while (state.KeepRunning()) { + container.erase(container.begin()); + container.insert(container.end(), g(state.iterations() + kBenchmarkValues)); + } +} + +// Iteration (forward) through the tree +template <typename T> +void BM_FwdIter(benchmark::State& state) { + using V = typename remove_pair_const<typename T::value_type>::type; + using R = typename T::value_type const*; + + std::vector<V> values = GenerateValues<V>(kBenchmarkValues); + T container(values.begin(), values.end()); + + auto iter = container.end(); + + R r = nullptr; + + while (state.KeepRunning()) { + if (iter == container.end()) iter = container.begin(); + r = &(*iter); + ++iter; + } + + benchmark::DoNotOptimize(r); +} + +// Benchmark random range-construction of a container. +template <typename T> +void BM_RangeConstructionImpl(benchmark::State& state, bool sorted) { + using V = typename remove_pair_const<typename T::value_type>::type; + + std::vector<V> values = GenerateValues<V>(kBenchmarkValues); + if (sorted) { + std::sort(values.begin(), values.end()); + } + { + T container(values.begin(), values.end()); + } + + while (state.KeepRunning()) { + T container(values.begin(), values.end()); + benchmark::DoNotOptimize(container); + } +} + +template <typename T> +void BM_InsertRangeRandom(benchmark::State& state) { + BM_RangeConstructionImpl<T>(state, false); +} + +template <typename T> +void BM_InsertRangeSorted(benchmark::State& state) { + BM_RangeConstructionImpl<T>(state, true); +} + +#define STL_ORDERED_TYPES(value) \ + using stl_set_##value = std::set<value>; \ + using stl_map_##value = std::map<value, intptr_t>; \ + using stl_multiset_##value = std::multiset<value>; \ + using stl_multimap_##value = std::multimap<value, intptr_t> + +using StdString = std::string; +STL_ORDERED_TYPES(int32_t); +STL_ORDERED_TYPES(int64_t); +STL_ORDERED_TYPES(StdString); +STL_ORDERED_TYPES(Cord); +STL_ORDERED_TYPES(Time); + +#define STL_UNORDERED_TYPES(value) \ + using stl_unordered_set_##value = std::unordered_set<value>; \ + using stl_unordered_map_##value = std::unordered_map<value, intptr_t>; \ + using flat_hash_set_##value = flat_hash_set<value>; \ + using flat_hash_map_##value = flat_hash_map<value, intptr_t>; \ + using stl_unordered_multiset_##value = std::unordered_multiset<value>; \ + using stl_unordered_multimap_##value = \ + std::unordered_multimap<value, intptr_t> + +#define STL_UNORDERED_TYPES_CUSTOM_HASH(value, hash) \ + using stl_unordered_set_##value = std::unordered_set<value, hash>; \ + using stl_unordered_map_##value = std::unordered_map<value, intptr_t, hash>; \ + using flat_hash_set_##value = flat_hash_set<value, hash>; \ + using flat_hash_map_##value = flat_hash_map<value, intptr_t, hash>; \ + using stl_unordered_multiset_##value = std::unordered_multiset<value, hash>; \ + using stl_unordered_multimap_##value = \ + std::unordered_multimap<value, intptr_t, hash> + +STL_UNORDERED_TYPES_CUSTOM_HASH(Cord, absl::Hash<absl::Cord>); + +STL_UNORDERED_TYPES(int32_t); +STL_UNORDERED_TYPES(int64_t); +STL_UNORDERED_TYPES(StdString); +STL_UNORDERED_TYPES_CUSTOM_HASH(Time, absl::Hash<absl::Time>); + +#define BTREE_TYPES(value) \ + using btree_256_set_##value = \ + btree_set<value, std::less<value>, std::allocator<value>>; \ + using btree_256_map_##value = \ + btree_map<value, intptr_t, std::less<value>, \ + std::allocator<std::pair<const value, intptr_t>>>; \ + using btree_256_multiset_##value = \ + btree_multiset<value, std::less<value>, std::allocator<value>>; \ + using btree_256_multimap_##value = \ + btree_multimap<value, intptr_t, std::less<value>, \ + std::allocator<std::pair<const value, intptr_t>>> + +BTREE_TYPES(int32_t); +BTREE_TYPES(int64_t); +BTREE_TYPES(StdString); +BTREE_TYPES(Cord); +BTREE_TYPES(Time); + +#define MY_BENCHMARK4(type, func) \ + void BM_##type##_##func(benchmark::State& state) { BM_##func<type>(state); } \ + BENCHMARK(BM_##type##_##func) + +#define MY_BENCHMARK3(type) \ + MY_BENCHMARK4(type, Insert); \ + MY_BENCHMARK4(type, InsertSorted); \ + MY_BENCHMARK4(type, InsertEnd); \ + MY_BENCHMARK4(type, Lookup); \ + MY_BENCHMARK4(type, FullLookup); \ + MY_BENCHMARK4(type, Delete); \ + MY_BENCHMARK4(type, DeleteRange); \ + MY_BENCHMARK4(type, QueueAddRem); \ + MY_BENCHMARK4(type, MixedAddRem); \ + MY_BENCHMARK4(type, Fifo); \ + MY_BENCHMARK4(type, FwdIter); \ + MY_BENCHMARK4(type, InsertRangeRandom); \ + MY_BENCHMARK4(type, InsertRangeSorted) + +#define MY_BENCHMARK2_SUPPORTS_MULTI_ONLY(type) \ + MY_BENCHMARK3(stl_##type); \ + MY_BENCHMARK3(stl_unordered_##type); \ + MY_BENCHMARK3(btree_256_##type) + +#define MY_BENCHMARK2(type) \ + MY_BENCHMARK2_SUPPORTS_MULTI_ONLY(type); \ + MY_BENCHMARK3(flat_hash_##type) + +// Define MULTI_TESTING to see benchmarks for multi-containers also. +// +// You can use --copt=-DMULTI_TESTING. +#ifdef MULTI_TESTING +#define MY_BENCHMARK(type) \ + MY_BENCHMARK2(set_##type); \ + MY_BENCHMARK2(map_##type); \ + MY_BENCHMARK2_SUPPORTS_MULTI_ONLY(multiset_##type); \ + MY_BENCHMARK2_SUPPORTS_MULTI_ONLY(multimap_##type) +#else +#define MY_BENCHMARK(type) \ + MY_BENCHMARK2(set_##type); \ + MY_BENCHMARK2(map_##type) +#endif + +MY_BENCHMARK(int32_t); +MY_BENCHMARK(int64_t); +MY_BENCHMARK(StdString); +MY_BENCHMARK(Cord); +MY_BENCHMARK(Time); + +// Define a type whose size and cost of moving are independently customizable. +// When sizeof(value_type) increases, we expect btree to no longer have as much +// cache-locality advantage over STL. When cost of moving increases, we expect +// btree to actually do more work than STL because it has to move values around +// and STL doesn't have to. +template <int Size, int Copies> +struct BigType { + BigType() : BigType(0) {} + explicit BigType(int x) { std::iota(values.begin(), values.end(), x); } + + void Copy(const BigType& other) { + for (int i = 0; i < Size && i < Copies; ++i) values[i] = other.values[i]; + // If Copies > Size, do extra copies. + for (int i = Size, idx = 0; i < Copies; ++i) { + int64_t tmp = other.values[idx]; + benchmark::DoNotOptimize(tmp); + idx = idx + 1 == Size ? 0 : idx + 1; + } + } + + BigType(const BigType& other) { Copy(other); } + BigType& operator=(const BigType& other) { + Copy(other); + return *this; + } + + // Compare only the first Copies elements if Copies is less than Size. + bool operator<(const BigType& other) const { + return std::lexicographical_compare( + values.begin(), values.begin() + std::min(Size, Copies), + other.values.begin(), other.values.begin() + std::min(Size, Copies)); + } + bool operator==(const BigType& other) const { + return std::equal(values.begin(), values.begin() + std::min(Size, Copies), + other.values.begin()); + } + + // Support absl::Hash. + template <typename State> + friend State AbslHashValue(State h, const BigType& b) { + for (int i = 0; i < Size && i < Copies; ++i) + h = State::combine(std::move(h), b.values[i]); + return h; + } + + std::array<int64_t, Size> values; +}; + +#define BIG_TYPE_BENCHMARKS(SIZE, COPIES) \ + using stl_set_size##SIZE##copies##COPIES = std::set<BigType<SIZE, COPIES>>; \ + using stl_map_size##SIZE##copies##COPIES = \ + std::map<BigType<SIZE, COPIES>, intptr_t>; \ + using stl_multiset_size##SIZE##copies##COPIES = \ + std::multiset<BigType<SIZE, COPIES>>; \ + using stl_multimap_size##SIZE##copies##COPIES = \ + std::multimap<BigType<SIZE, COPIES>, intptr_t>; \ + using stl_unordered_set_size##SIZE##copies##COPIES = \ + std::unordered_set<BigType<SIZE, COPIES>, \ + absl::Hash<BigType<SIZE, COPIES>>>; \ + using stl_unordered_map_size##SIZE##copies##COPIES = \ + std::unordered_map<BigType<SIZE, COPIES>, intptr_t, \ + absl::Hash<BigType<SIZE, COPIES>>>; \ + using flat_hash_set_size##SIZE##copies##COPIES = \ + flat_hash_set<BigType<SIZE, COPIES>>; \ + using flat_hash_map_size##SIZE##copies##COPIES = \ + flat_hash_map<BigType<SIZE, COPIES>, intptr_t>; \ + using stl_unordered_multiset_size##SIZE##copies##COPIES = \ + std::unordered_multiset<BigType<SIZE, COPIES>, \ + absl::Hash<BigType<SIZE, COPIES>>>; \ + using stl_unordered_multimap_size##SIZE##copies##COPIES = \ + std::unordered_multimap<BigType<SIZE, COPIES>, intptr_t, \ + absl::Hash<BigType<SIZE, COPIES>>>; \ + using btree_256_set_size##SIZE##copies##COPIES = \ + btree_set<BigType<SIZE, COPIES>>; \ + using btree_256_map_size##SIZE##copies##COPIES = \ + btree_map<BigType<SIZE, COPIES>, intptr_t>; \ + using btree_256_multiset_size##SIZE##copies##COPIES = \ + btree_multiset<BigType<SIZE, COPIES>>; \ + using btree_256_multimap_size##SIZE##copies##COPIES = \ + btree_multimap<BigType<SIZE, COPIES>, intptr_t>; \ + MY_BENCHMARK(size##SIZE##copies##COPIES) + +// Define BIG_TYPE_TESTING to see benchmarks for more big types. +// +// You can use --copt=-DBIG_TYPE_TESTING. +#ifndef NODESIZE_TESTING +#ifdef BIG_TYPE_TESTING +BIG_TYPE_BENCHMARKS(1, 4); +BIG_TYPE_BENCHMARKS(4, 1); +BIG_TYPE_BENCHMARKS(4, 4); +BIG_TYPE_BENCHMARKS(1, 8); +BIG_TYPE_BENCHMARKS(8, 1); +BIG_TYPE_BENCHMARKS(8, 8); +BIG_TYPE_BENCHMARKS(1, 16); +BIG_TYPE_BENCHMARKS(16, 1); +BIG_TYPE_BENCHMARKS(16, 16); +BIG_TYPE_BENCHMARKS(1, 32); +BIG_TYPE_BENCHMARKS(32, 1); +BIG_TYPE_BENCHMARKS(32, 32); +#else +BIG_TYPE_BENCHMARKS(32, 32); +#endif +#endif + +// Benchmark using unique_ptrs to large value types. In order to be able to use +// the same benchmark code as the other types, use a type that holds a +// unique_ptr and has a copy constructor. +template <int Size> +struct BigTypePtr { + BigTypePtr() : BigTypePtr(0) {} + explicit BigTypePtr(int x) { + ptr = absl::make_unique<BigType<Size, Size>>(x); + } + BigTypePtr(const BigTypePtr& other) { + ptr = absl::make_unique<BigType<Size, Size>>(*other.ptr); + } + BigTypePtr(BigTypePtr&& other) noexcept = default; + BigTypePtr& operator=(const BigTypePtr& other) { + ptr = absl::make_unique<BigType<Size, Size>>(*other.ptr); + } + BigTypePtr& operator=(BigTypePtr&& other) noexcept = default; + + bool operator<(const BigTypePtr& other) const { return *ptr < *other.ptr; } + bool operator==(const BigTypePtr& other) const { return *ptr == *other.ptr; } + + std::unique_ptr<BigType<Size, Size>> ptr; +}; + +template <int Size> +double ContainerInfo(const btree_set<BigTypePtr<Size>>& b) { + const double bytes_used = + b.bytes_used() + b.size() * sizeof(BigType<Size, Size>); + const double bytes_per_value = bytes_used / b.size(); + BtreeContainerInfoLog(b, bytes_used, bytes_per_value); + return bytes_per_value; +} +template <int Size> +double ContainerInfo(const btree_map<int, BigTypePtr<Size>>& b) { + const double bytes_used = + b.bytes_used() + b.size() * sizeof(BigType<Size, Size>); + const double bytes_per_value = bytes_used / b.size(); + BtreeContainerInfoLog(b, bytes_used, bytes_per_value); + return bytes_per_value; +} + +#define BIG_TYPE_PTR_BENCHMARKS(SIZE) \ + using stl_set_size##SIZE##copies##SIZE##ptr = std::set<BigType<SIZE, SIZE>>; \ + using stl_map_size##SIZE##copies##SIZE##ptr = \ + std::map<int, BigType<SIZE, SIZE>>; \ + using stl_unordered_set_size##SIZE##copies##SIZE##ptr = \ + std::unordered_set<BigType<SIZE, SIZE>, \ + absl::Hash<BigType<SIZE, SIZE>>>; \ + using stl_unordered_map_size##SIZE##copies##SIZE##ptr = \ + std::unordered_map<int, BigType<SIZE, SIZE>>; \ + using flat_hash_set_size##SIZE##copies##SIZE##ptr = \ + flat_hash_set<BigType<SIZE, SIZE>>; \ + using flat_hash_map_size##SIZE##copies##SIZE##ptr = \ + flat_hash_map<int, BigTypePtr<SIZE>>; \ + using btree_256_set_size##SIZE##copies##SIZE##ptr = \ + btree_set<BigTypePtr<SIZE>>; \ + using btree_256_map_size##SIZE##copies##SIZE##ptr = \ + btree_map<int, BigTypePtr<SIZE>>; \ + MY_BENCHMARK3(stl_set_size##SIZE##copies##SIZE##ptr); \ + MY_BENCHMARK3(stl_unordered_set_size##SIZE##copies##SIZE##ptr); \ + MY_BENCHMARK3(flat_hash_set_size##SIZE##copies##SIZE##ptr); \ + MY_BENCHMARK3(btree_256_set_size##SIZE##copies##SIZE##ptr); \ + MY_BENCHMARK3(stl_map_size##SIZE##copies##SIZE##ptr); \ + MY_BENCHMARK3(stl_unordered_map_size##SIZE##copies##SIZE##ptr); \ + MY_BENCHMARK3(flat_hash_map_size##SIZE##copies##SIZE##ptr); \ + MY_BENCHMARK3(btree_256_map_size##SIZE##copies##SIZE##ptr) + +BIG_TYPE_PTR_BENCHMARKS(32); + +} // namespace +} // namespace container_internal +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/btree_map.h b/third_party/abseil-cpp/absl/container/btree_map.h index 9f35f639..bb450ea 100644 --- a/third_party/abseil-cpp/absl/container/btree_map.h +++ b/third_party/abseil-cpp/absl/container/btree_map.h
@@ -51,6 +51,7 @@ #include "absl/container/internal/btree_container.h" // IWYU pragma: export namespace absl { +ABSL_NAMESPACE_BEGIN // absl::btree_map<> // @@ -225,6 +226,30 @@ // Inserts the elements within the initializer list `ilist`. using Base::insert; + // btree_map::insert_or_assign() + // + // Inserts an element of the specified value into the `btree_map` provided + // that a value with the given key does not already exist, or replaces the + // corresponding mapped type with the forwarded `obj` argument if a key for + // that value already exists, returning an iterator pointing to the newly + // inserted element. Overloads are listed below. + // + // pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj): + // pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj): + // + // Inserts/Assigns (or moves) the element of the specified key into the + // `btree_map`. If the returned bool is true, insertion took place, and if + // it's false, assignment took place. + // + // iterator insert_or_assign(const_iterator hint, + // const key_type& k, M&& obj): + // iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj): + // + // Inserts/Assigns (or moves) the element of the specified key into the + // `btree_map` using the position of `hint` as a non-binding suggestion + // for where to begin the insertion search. + using Base::insert_or_assign; + // btree_map::emplace() // // Inserts an element of the specified value by constructing it in-place @@ -293,7 +318,7 @@ // Extracts the element at the indicated position and returns a node handle // owning that extracted data. // - // template <typename K> node_type extract(const K& x): + // template <typename K> node_type extract(const K& k): // // Extracts the element with the key matching the passed key value and // returns a node handle owning that extracted data. If the `btree_map` @@ -411,6 +436,20 @@ return x.swap(y); } +// absl::erase_if(absl::btree_map<>, Pred) +// +// Erases all elements that satisfy the predicate pred from the container. +template <typename K, typename V, typename C, typename A, typename Pred> +void erase_if(btree_map<K, V, C, A> &map, Pred pred) { + for (auto it = map.begin(); it != map.end();) { + if (pred(*it)) { + it = map.erase(it); + } else { + ++it; + } + } +} + // absl::btree_multimap // // An `absl::btree_multimap<K, V>` is an ordered associative container of @@ -606,7 +645,7 @@ // Extracts the element at the indicated position and returns a node handle // owning that extracted data. // - // template <typename K> node_type extract(const K& x): + // template <typename K> node_type extract(const K& k): // // Extracts the element with the key matching the passed key value and // returns a node handle owning that extracted data. If the `btree_multimap` @@ -700,6 +739,21 @@ return x.swap(y); } +// absl::erase_if(absl::btree_multimap<>, Pred) +// +// Erases all elements that satisfy the predicate pred from the container. +template <typename K, typename V, typename C, typename A, typename Pred> +void erase_if(btree_multimap<K, V, C, A> &map, Pred pred) { + for (auto it = map.begin(); it != map.end();) { + if (pred(*it)) { + it = map.erase(it); + } else { + ++it; + } + } +} + +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_BTREE_MAP_H_
diff --git a/third_party/abseil-cpp/absl/container/btree_set.h b/third_party/abseil-cpp/absl/container/btree_set.h index 6e47b4aa..d3e78866 100644 --- a/third_party/abseil-cpp/absl/container/btree_set.h +++ b/third_party/abseil-cpp/absl/container/btree_set.h
@@ -51,6 +51,7 @@ #include "absl/container/internal/btree_container.h" // IWYU pragma: export namespace absl { +ABSL_NAMESPACE_BEGIN // absl::btree_set<> // @@ -262,7 +263,7 @@ // Extracts the element at the indicated position and returns a node handle // owning that extracted data. // - // template <typename K> node_type extract(const K& x): + // template <typename K> node_type extract(const K& k): // // Extracts the element with the key matching the passed key value and // returns a node handle owning that extracted data. If the `btree_set` @@ -359,6 +360,20 @@ return x.swap(y); } +// absl::erase_if(absl::btree_set<>, Pred) +// +// Erases all elements that satisfy the predicate pred from the container. +template <typename K, typename C, typename A, typename Pred> +void erase_if(btree_set<K, C, A> &set, Pred pred) { + for (auto it = set.begin(); it != set.end();) { + if (pred(*it)) { + it = set.erase(it); + } else { + ++it; + } + } +} + // absl::btree_multiset<> // // An `absl::btree_multiset<K>` is an ordered associative container of @@ -552,7 +567,7 @@ // Extracts the element at the indicated position and returns a node handle // owning that extracted data. // - // template <typename K> node_type extract(const K& x): + // template <typename K> node_type extract(const K& k): // // Extracts the element with the key matching the passed key value and // returns a node handle owning that extracted data. If the `btree_multiset` @@ -648,6 +663,21 @@ return x.swap(y); } +// absl::erase_if(absl::btree_multiset<>, Pred) +// +// Erases all elements that satisfy the predicate pred from the container. +template <typename K, typename C, typename A, typename Pred> +void erase_if(btree_multiset<K, C, A> &set, Pred pred) { + for (auto it = set.begin(); it != set.end();) { + if (pred(*it)) { + it = set.erase(it); + } else { + ++it; + } + } +} + +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_BTREE_SET_H_
diff --git a/third_party/abseil-cpp/absl/container/btree_test.cc b/third_party/abseil-cpp/absl/container/btree_test.cc index a330cca3..7ccdf6a 100644 --- a/third_party/abseil-cpp/absl/container/btree_test.cc +++ b/third_party/abseil-cpp/absl/container/btree_test.cc
@@ -25,6 +25,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/base/internal/raw_logging.h" +#include "absl/base/macros.h" #include "absl/container/btree_map.h" #include "absl/container/btree_set.h" #include "absl/container/internal/counting_allocator.h" @@ -41,9 +42,11 @@ ABSL_FLAG(int, test_values, 10000, "The number of values to use for tests"); namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { +using ::absl::test_internal::CopyableMovableInstance; using ::absl::test_internal::InstanceTracker; using ::absl::test_internal::MovableOnlyInstance; using ::testing::ElementsAre; @@ -86,8 +89,8 @@ public: base_checker() : const_tree_(tree_) {} - base_checker(const base_checker &x) - : tree_(x.tree_), const_tree_(tree_), checker_(x.checker_) {} + base_checker(const base_checker &other) + : tree_(other.tree_), const_tree_(tree_), checker_(other.checker_) {} template <typename InputIterator> base_checker(InputIterator b, InputIterator e) : tree_(b, e), const_tree_(tree_), checker_(b, e) {} @@ -121,11 +124,11 @@ } return tree_iter; } - void value_check(const value_type &x) { + void value_check(const value_type &v) { typename KeyOfValue<typename TreeType::key_type, typename TreeType::value_type>::type key_of_value; - const key_type &key = key_of_value(x); - CheckPairEquals(*find(key), x); + const key_type &key = key_of_value(v); + CheckPairEquals(*find(key), v); lower_bound(key); upper_bound(key); equal_range(key); @@ -177,18 +180,16 @@ const_iterator find(const key_type &key) const { return iter_check(tree_.find(key), checker_.find(key)); } - bool contains(const key_type &key) const { - return find(key) != end(); - } + bool contains(const key_type &key) const { return find(key) != end(); } size_type count(const key_type &key) const { size_type res = checker_.count(key); EXPECT_EQ(res, tree_.count(key)); return res; } - base_checker &operator=(const base_checker &x) { - tree_ = x.tree_; - checker_ = x.checker_; + base_checker &operator=(const base_checker &other) { + tree_ = other.tree_; + checker_ = other.checker_; return *this; } @@ -237,8 +238,10 @@ ++checker_end; } } - checker_.erase(checker_begin, checker_end); - tree_.erase(begin, end); + const auto checker_ret = checker_.erase(checker_begin, checker_end); + const auto tree_ret = tree_.erase(begin, end); + EXPECT_EQ(std::distance(checker_.begin(), checker_ret), + std::distance(tree_.begin(), tree_ret)); EXPECT_EQ(tree_.size(), checker_.size()); EXPECT_EQ(tree_.size(), size - count); } @@ -247,9 +250,9 @@ tree_.clear(); checker_.clear(); } - void swap(base_checker &x) { - tree_.swap(x.tree_); - checker_.swap(x.checker_); + void swap(base_checker &other) { + tree_.swap(other.tree_); + checker_.swap(other.checker_); } void verify() const { @@ -320,27 +323,28 @@ public: unique_checker() : super_type() {} - unique_checker(const unique_checker &x) : super_type(x) {} + unique_checker(const unique_checker &other) : super_type(other) {} template <class InputIterator> unique_checker(InputIterator b, InputIterator e) : super_type(b, e) {} + unique_checker &operator=(const unique_checker &) = default; // Insertion routines. - std::pair<iterator, bool> insert(const value_type &x) { + std::pair<iterator, bool> insert(const value_type &v) { int size = this->tree_.size(); std::pair<typename CheckerType::iterator, bool> checker_res = - this->checker_.insert(x); - std::pair<iterator, bool> tree_res = this->tree_.insert(x); + this->checker_.insert(v); + std::pair<iterator, bool> tree_res = this->tree_.insert(v); CheckPairEquals(*tree_res.first, *checker_res.first); EXPECT_EQ(tree_res.second, checker_res.second); EXPECT_EQ(this->tree_.size(), this->checker_.size()); EXPECT_EQ(this->tree_.size(), size + tree_res.second); return tree_res; } - iterator insert(iterator position, const value_type &x) { + iterator insert(iterator position, const value_type &v) { int size = this->tree_.size(); std::pair<typename CheckerType::iterator, bool> checker_res = - this->checker_.insert(x); - iterator tree_res = this->tree_.insert(position, x); + this->checker_.insert(v); + iterator tree_res = this->tree_.insert(position, v); CheckPairEquals(*tree_res, *checker_res.first); EXPECT_EQ(this->tree_.size(), this->checker_.size()); EXPECT_EQ(this->tree_.size(), size + checker_res.second); @@ -367,24 +371,25 @@ public: multi_checker() : super_type() {} - multi_checker(const multi_checker &x) : super_type(x) {} + multi_checker(const multi_checker &other) : super_type(other) {} template <class InputIterator> multi_checker(InputIterator b, InputIterator e) : super_type(b, e) {} + multi_checker &operator=(const multi_checker &) = default; // Insertion routines. - iterator insert(const value_type &x) { + iterator insert(const value_type &v) { int size = this->tree_.size(); - auto checker_res = this->checker_.insert(x); - iterator tree_res = this->tree_.insert(x); + auto checker_res = this->checker_.insert(v); + iterator tree_res = this->tree_.insert(v); CheckPairEquals(*tree_res, *checker_res); EXPECT_EQ(this->tree_.size(), this->checker_.size()); EXPECT_EQ(this->tree_.size(), size + 1); return tree_res; } - iterator insert(iterator position, const value_type &x) { + iterator insert(iterator position, const value_type &v) { int size = this->tree_.size(); - auto checker_res = this->checker_.insert(x); - iterator tree_res = this->tree_.insert(position, x); + auto checker_res = this->checker_.insert(v); + iterator tree_res = this->tree_.insert(position, v); CheckPairEquals(*tree_res, *checker_res); EXPECT_EQ(this->tree_.size(), this->checker_.size()); EXPECT_EQ(this->tree_.size(), size + 1); @@ -807,10 +812,12 @@ TEST(Btree, set_int32) { SetTest<int32_t>(); } TEST(Btree, set_int64) { SetTest<int64_t>(); } TEST(Btree, set_string) { SetTest<std::string>(); } +TEST(Btree, set_cord) { SetTest<absl::Cord>(); } TEST(Btree, set_pair) { SetTest<std::pair<int, int>>(); } TEST(Btree, map_int32) { MapTest<int32_t>(); } TEST(Btree, map_int64) { MapTest<int64_t>(); } TEST(Btree, map_string) { MapTest<std::string>(); } +TEST(Btree, map_cord) { MapTest<absl::Cord>(); } TEST(Btree, map_pair) { MapTest<std::pair<int, int>>(); } template <typename K, int N = 256> @@ -842,10 +849,12 @@ TEST(Btree, multiset_int32) { MultiSetTest<int32_t>(); } TEST(Btree, multiset_int64) { MultiSetTest<int64_t>(); } TEST(Btree, multiset_string) { MultiSetTest<std::string>(); } +TEST(Btree, multiset_cord) { MultiSetTest<absl::Cord>(); } TEST(Btree, multiset_pair) { MultiSetTest<std::pair<int, int>>(); } TEST(Btree, multimap_int32) { MultiMapTest<int32_t>(); } TEST(Btree, multimap_int64) { MultiMapTest<int64_t>(); } TEST(Btree, multimap_string) { MultiMapTest<std::string>(); } +TEST(Btree, multimap_cord) { MultiMapTest<absl::Cord>(); } TEST(Btree, multimap_pair) { MultiMapTest<std::pair<int, int>>(); } struct CompareIntToString { @@ -863,7 +872,7 @@ struct NonTransparentCompare { template <typename T, typename U> - bool operator()(const T& t, const U& u) const { + bool operator()(const T &t, const U &u) const { // Treating all comparators as transparent can cause inefficiencies (see // N3657 C++ proposal). Test that for comparators without 'is_transparent' // alias (like this one), we do not attempt heterogeneous lookup. @@ -1000,21 +1009,15 @@ public: StringLike() = default; - StringLike(const char* s) : s_(s) { // NOLINT + StringLike(const char *s) : s_(s) { // NOLINT ++constructor_calls_; } - bool operator<(const StringLike& a) const { - return s_ < a.s_; - } + bool operator<(const StringLike &a) const { return s_ < a.s_; } - static void clear_constructor_call_count() { - constructor_calls_ = 0; - } + static void clear_constructor_call_count() { constructor_calls_ = 0; } - static int constructor_calls() { - return constructor_calls_; - } + static int constructor_calls() { return constructor_calls_; } private: static int constructor_calls_; @@ -1269,6 +1272,8 @@ AssertKeyCompareToAdapted<std::less<absl::string_view>, absl::string_view>(); AssertKeyCompareToAdapted<std::greater<absl::string_view>, absl::string_view>(); + AssertKeyCompareToAdapted<std::less<absl::Cord>, absl::Cord>(); + AssertKeyCompareToAdapted<std::greater<absl::Cord>, absl::Cord>(); AssertKeyCompareToNotAdapted<std::less<int>, int>(); AssertKeyCompareToNotAdapted<std::greater<int>, int>(); } @@ -1471,7 +1476,7 @@ int num; explicit NoDefaultCtor(int i) : num(i) {} - friend bool operator<(const NoDefaultCtor& a, const NoDefaultCtor& b) { + friend bool operator<(const NoDefaultCtor &a, const NoDefaultCtor &b) { return a.num < b.num; } }; @@ -1535,12 +1540,11 @@ const absl::btree_map<int, int> &const_map = map; EXPECT_EQ(const_map.at(1), 2); EXPECT_EQ(const_map.at(2), 8); - try { - map.at(3); - FAIL() << "Exception not thrown"; - } catch (const std::out_of_range& e) { - EXPECT_STREQ(e.what(), "absl::btree_map::at"); - } +#ifdef ABSL_HAVE_EXCEPTIONS + EXPECT_THROW(map.at(3), std::out_of_range); +#else + EXPECT_DEATH(map.at(3), "absl::btree_map::at"); +#endif } TEST(Btree, BtreeMultisetEmplace) { @@ -1822,25 +1826,80 @@ EXPECT_EQ(res.node.value(), 3); } -struct Deref { - bool operator()(const std::unique_ptr<int> &lhs, - const std::unique_ptr<int> &rhs) const { - return *lhs < *rhs; - } -}; +template <typename Set> +void TestExtractWithTrackingForSet() { + InstanceTracker tracker; + { + Set s; + // Add enough elements to make sure we test internal nodes too. + const size_t kSize = 1000; + while (s.size() < kSize) { + s.insert(MovableOnlyInstance(s.size())); + } + for (int i = 0; i < kSize; ++i) { + // Extract with key + auto nh = s.extract(MovableOnlyInstance(i)); + EXPECT_EQ(s.size(), kSize - 1); + EXPECT_EQ(nh.value().value(), i); + // Insert with node + s.insert(std::move(nh)); + EXPECT_EQ(s.size(), kSize); -TEST(Btree, ExtractWithUniquePtr) { - absl::btree_set<std::unique_ptr<int>, Deref> s; - s.insert(absl::make_unique<int>(1)); - s.insert(absl::make_unique<int>(2)); - s.insert(absl::make_unique<int>(3)); - s.insert(absl::make_unique<int>(4)); - s.insert(absl::make_unique<int>(5)); - auto nh = s.extract(s.find(absl::make_unique<int>(3))); - EXPECT_EQ(s.size(), 4); - EXPECT_EQ(*nh.value(), 3); - s.insert(std::move(nh)); - EXPECT_EQ(s.size(), 5); + // Extract with iterator + auto it = s.find(MovableOnlyInstance(i)); + nh = s.extract(it); + EXPECT_EQ(s.size(), kSize - 1); + EXPECT_EQ(nh.value().value(), i); + // Insert with node and hint + s.insert(s.begin(), std::move(nh)); + EXPECT_EQ(s.size(), kSize); + } + } + EXPECT_EQ(0, tracker.instances()); +} + +template <typename Map> +void TestExtractWithTrackingForMap() { + InstanceTracker tracker; + { + Map m; + // Add enough elements to make sure we test internal nodes too. + const size_t kSize = 1000; + while (m.size() < kSize) { + m.insert( + {CopyableMovableInstance(m.size()), MovableOnlyInstance(m.size())}); + } + for (int i = 0; i < kSize; ++i) { + // Extract with key + auto nh = m.extract(CopyableMovableInstance(i)); + EXPECT_EQ(m.size(), kSize - 1); + EXPECT_EQ(nh.key().value(), i); + EXPECT_EQ(nh.mapped().value(), i); + // Insert with node + m.insert(std::move(nh)); + EXPECT_EQ(m.size(), kSize); + + // Extract with iterator + auto it = m.find(CopyableMovableInstance(i)); + nh = m.extract(it); + EXPECT_EQ(m.size(), kSize - 1); + EXPECT_EQ(nh.key().value(), i); + EXPECT_EQ(nh.mapped().value(), i); + // Insert with node and hint + m.insert(m.begin(), std::move(nh)); + EXPECT_EQ(m.size(), kSize); + } + } + EXPECT_EQ(0, tracker.instances()); +} + +TEST(Btree, ExtractTracking) { + TestExtractWithTrackingForSet<absl::btree_set<MovableOnlyInstance>>(); + TestExtractWithTrackingForSet<absl::btree_multiset<MovableOnlyInstance>>(); + TestExtractWithTrackingForMap< + absl::btree_map<CopyableMovableInstance, MovableOnlyInstance>>(); + TestExtractWithTrackingForMap< + absl::btree_multimap<CopyableMovableInstance, MovableOnlyInstance>>(); } TEST(Btree, ExtractAndInsertNodeHandleMultiSet) { @@ -2073,11 +2132,11 @@ TEST(Btree, TryEmplaceBasicTest) { absl::btree_map<int, std::string> m; - // Should construct a std::string from the literal. + // Should construct a string from the literal. m.try_emplace(1, "one"); EXPECT_EQ(1, m.size()); - // Try other std::string constructors and const lvalue key. + // Try other string constructors and const lvalue key. const int key(42); m.try_emplace(key, 3, 'a'); m.try_emplace(2, std::string("two")); @@ -2238,6 +2297,114 @@ } } +TEST(Btree, EmptyTree) { + absl::btree_set<int> s; + EXPECT_TRUE(s.empty()); + EXPECT_EQ(s.size(), 0); + EXPECT_GT(s.max_size(), 0); +} + +bool IsEven(int k) { return k % 2 == 0; } + +TEST(Btree, EraseIf) { + // Test that erase_if works with all the container types and supports lambdas. + { + absl::btree_set<int> s = {1, 3, 5, 6, 100}; + erase_if(s, [](int k) { return k > 3; }); + EXPECT_THAT(s, ElementsAre(1, 3)); + } + { + absl::btree_multiset<int> s = {1, 3, 3, 5, 6, 6, 100}; + erase_if(s, [](int k) { return k <= 3; }); + EXPECT_THAT(s, ElementsAre(5, 6, 6, 100)); + } + { + absl::btree_map<int, int> m = {{1, 1}, {3, 3}, {6, 6}, {100, 100}}; + erase_if(m, [](std::pair<const int, int> kv) { return kv.first > 3; }); + EXPECT_THAT(m, ElementsAre(Pair(1, 1), Pair(3, 3))); + } + { + absl::btree_multimap<int, int> m = {{1, 1}, {3, 3}, {3, 6}, + {6, 6}, {6, 7}, {100, 6}}; + erase_if(m, [](std::pair<const int, int> kv) { return kv.second == 6; }); + EXPECT_THAT(m, ElementsAre(Pair(1, 1), Pair(3, 3), Pair(6, 7))); + } + // Test that erasing all elements from a large set works and test support for + // function pointers. + { + absl::btree_set<int> s; + for (int i = 0; i < 1000; ++i) s.insert(2 * i); + erase_if(s, IsEven); + EXPECT_THAT(s, IsEmpty()); + } + // Test that erase_if supports other format of function pointers. + { + absl::btree_set<int> s = {1, 3, 5, 6, 100}; + erase_if(s, &IsEven); + EXPECT_THAT(s, ElementsAre(1, 3, 5)); + } +} + +TEST(Btree, InsertOrAssign) { + absl::btree_map<int, int> m = {{1, 1}, {3, 3}}; + using value_type = typename decltype(m)::value_type; + + auto ret = m.insert_or_assign(4, 4); + EXPECT_EQ(*ret.first, value_type(4, 4)); + EXPECT_TRUE(ret.second); + ret = m.insert_or_assign(3, 100); + EXPECT_EQ(*ret.first, value_type(3, 100)); + EXPECT_FALSE(ret.second); + + auto hint_ret = m.insert_or_assign(ret.first, 3, 200); + EXPECT_EQ(*hint_ret, value_type(3, 200)); + hint_ret = m.insert_or_assign(m.find(1), 0, 1); + EXPECT_EQ(*hint_ret, value_type(0, 1)); + // Test with bad hint. + hint_ret = m.insert_or_assign(m.end(), -1, 1); + EXPECT_EQ(*hint_ret, value_type(-1, 1)); + + EXPECT_THAT(m, ElementsAre(Pair(-1, 1), Pair(0, 1), Pair(1, 1), Pair(3, 200), + Pair(4, 4))); +} + +TEST(Btree, InsertOrAssignMovableOnly) { + absl::btree_map<int, MovableOnlyInstance> m; + using value_type = typename decltype(m)::value_type; + + auto ret = m.insert_or_assign(4, MovableOnlyInstance(4)); + EXPECT_EQ(*ret.first, value_type(4, MovableOnlyInstance(4))); + EXPECT_TRUE(ret.second); + ret = m.insert_or_assign(4, MovableOnlyInstance(100)); + EXPECT_EQ(*ret.first, value_type(4, MovableOnlyInstance(100))); + EXPECT_FALSE(ret.second); + + auto hint_ret = m.insert_or_assign(ret.first, 3, MovableOnlyInstance(200)); + EXPECT_EQ(*hint_ret, value_type(3, MovableOnlyInstance(200))); + + EXPECT_EQ(m.size(), 2); +} + +TEST(Btree, BitfieldArgument) { + union { + int n : 1; + }; + n = 0; + absl::btree_map<int, int> m; + m.erase(n); + m.count(n); + m.find(n); + m.contains(n); + m.equal_range(n); + m.insert_or_assign(n, n); + m.insert_or_assign(m.end(), n, n); + m.try_emplace(n); + m.try_emplace(m.end(), n); + m.at(n); + m[n]; +} + } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/btree_test.h b/third_party/abseil-cpp/absl/container/btree_test.h index 5ecf43c..6249080 100644 --- a/third_party/abseil-cpp/absl/container/btree_test.h +++ b/third_party/abseil-cpp/absl/container/btree_test.h
@@ -25,9 +25,11 @@ #include "absl/container/btree_map.h" #include "absl/container/btree_set.h" #include "absl/container/flat_hash_set.h" +#include "absl/strings/cord.h" #include "absl/time/time.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { // Like remove_const but propagates the removal through std::pair. @@ -99,6 +101,16 @@ } }; +template <> +struct Generator<Cord> { + int maxval; + explicit Generator(int m) : maxval(m) {} + Cord operator()(int i) const { + char buf[16]; + return Cord(GenerateDigits(buf, i, maxval)); + } +}; + template <typename T, typename U> struct Generator<std::pair<T, U> > { Generator<typename remove_pair_const<T>::type> tgen; @@ -148,6 +160,7 @@ } } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_BTREE_TEST_H_
diff --git a/third_party/abseil-cpp/absl/container/fixed_array.h b/third_party/abseil-cpp/absl/container/fixed_array.h index 60da048..75aa1994 100644 --- a/third_party/abseil-cpp/absl/container/fixed_array.h +++ b/third_party/abseil-cpp/absl/container/fixed_array.h
@@ -31,7 +31,6 @@ #define ABSL_CONTAINER_FIXED_ARRAY_H_ #include <algorithm> -#include <array> #include <cassert> #include <cstddef> #include <initializer_list> @@ -51,6 +50,7 @@ #include "absl/memory/memory.h" namespace absl { +ABSL_NAMESPACE_BEGIN constexpr static auto kFixedArrayUseDefault = static_cast<size_t>(-1); @@ -386,8 +386,7 @@ // error: call to int __builtin___sprintf_chk(etc...) // will always overflow destination buffer [-Werror] // - template <typename OuterT = value_type, - typename InnerT = absl::remove_extent_t<OuterT>, + template <typename OuterT, typename InnerT = absl::remove_extent_t<OuterT>, size_t InnerN = std::extent<OuterT>::value> struct StorageElementWrapper { InnerT array[InnerN]; @@ -396,8 +395,6 @@ using StorageElement = absl::conditional_t<std::is_array<value_type>::value, StorageElementWrapper<value_type>, value_type>; - using StorageElementBuffer = - absl::aligned_storage_t<sizeof(StorageElement), alignof(StorageElement)>; static pointer AsValueType(pointer ptr) { return ptr; } static pointer AsValueType(StorageElementWrapper<value_type>* ptr) { @@ -407,25 +404,25 @@ static_assert(sizeof(StorageElement) == sizeof(value_type), ""); static_assert(alignof(StorageElement) == alignof(value_type), ""); - struct NonEmptyInlinedStorage { - StorageElement* data() { - return reinterpret_cast<StorageElement*>(inlined_storage_.data()); - } + class NonEmptyInlinedStorage { + public: + StorageElement* data() { return reinterpret_cast<StorageElement*>(buff_); } + void AnnotateConstruct(size_type n); + void AnnotateDestruct(size_type n); #ifdef ADDRESS_SANITIZER void* RedzoneBegin() { return &redzone_begin_; } void* RedzoneEnd() { return &redzone_end_ + 1; } #endif // ADDRESS_SANITIZER - void AnnotateConstruct(size_type); - void AnnotateDestruct(size_type); - + private: ABSL_ADDRESS_SANITIZER_REDZONE(redzone_begin_); - std::array<StorageElementBuffer, inline_elements> inlined_storage_; + alignas(StorageElement) char buff_[sizeof(StorageElement[inline_elements])]; ABSL_ADDRESS_SANITIZER_REDZONE(redzone_end_); }; - struct EmptyInlinedStorage { + class EmptyInlinedStorage { + public: StorageElement* data() { return nullptr; } void AnnotateConstruct(size_type) {} void AnnotateDestruct(size_type) {} @@ -459,9 +456,7 @@ size_type size() const { return size_alloc_.template get<0>(); } StorageElement* begin() const { return data_; } StorageElement* end() const { return begin() + size(); } - allocator_type& alloc() { - return size_alloc_.template get<1>(); - } + allocator_type& alloc() { return size_alloc_.template get<1>(); } private: static bool UsingInlinedStorage(size_type n) { @@ -514,6 +509,7 @@ #endif // ADDRESS_SANITIZER static_cast<void>(n); // Mark used when not in asan mode } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_FIXED_ARRAY_H_
diff --git a/third_party/abseil-cpp/absl/container/fixed_array_exception_safety_test.cc b/third_party/abseil-cpp/absl/container/fixed_array_exception_safety_test.cc index 9984a5e2a..a5bb009 100644 --- a/third_party/abseil-cpp/absl/container/fixed_array_exception_safety_test.cc +++ b/third_party/abseil-cpp/absl/container/fixed_array_exception_safety_test.cc
@@ -12,13 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "absl/base/config.h" +#include "absl/container/fixed_array.h" + +#ifdef ABSL_HAVE_EXCEPTIONS + #include <initializer_list> #include "gtest/gtest.h" #include "absl/base/internal/exception_safety_testing.h" -#include "absl/container/fixed_array.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { @@ -32,10 +37,19 @@ using ::testing::TestThrowingCtor; using Thrower = testing::ThrowingValue<testing::TypeSpec::kEverythingThrows>; -using FixedArr = absl::FixedArray<Thrower, kInlined>; - +using ThrowAlloc = + testing::ThrowingAllocator<Thrower, testing::AllocSpec::kEverythingThrows>; using MoveThrower = testing::ThrowingValue<testing::TypeSpec::kNoThrowMove>; +using MoveThrowAlloc = + testing::ThrowingAllocator<MoveThrower, + testing::AllocSpec::kEverythingThrows>; + +using FixedArr = absl::FixedArray<Thrower, kInlined>; +using FixedArrWithAlloc = absl::FixedArray<Thrower, kInlined, ThrowAlloc>; + using MoveFixedArr = absl::FixedArray<MoveThrower, kInlined>; +using MoveFixedArrWithAlloc = + absl::FixedArray<MoveThrower, kInlined, MoveThrowAlloc>; TEST(FixedArrayExceptionSafety, CopyConstructor) { auto small = FixedArr(kSmallSize); @@ -45,6 +59,14 @@ TestThrowingCtor<FixedArr>(large); } +TEST(FixedArrayExceptionSafety, CopyConstructorWithAlloc) { + auto small = FixedArrWithAlloc(kSmallSize); + TestThrowingCtor<FixedArrWithAlloc>(small); + + auto large = FixedArrWithAlloc(kLargeSize); + TestThrowingCtor<FixedArrWithAlloc>(large); +} + TEST(FixedArrayExceptionSafety, MoveConstructor) { TestThrowingCtor<FixedArr>(FixedArr(kSmallSize)); TestThrowingCtor<FixedArr>(FixedArr(kLargeSize)); @@ -54,16 +76,35 @@ TestThrowingCtor<MoveFixedArr>(MoveFixedArr(kLargeSize)); } +TEST(FixedArrayExceptionSafety, MoveConstructorWithAlloc) { + TestThrowingCtor<FixedArrWithAlloc>(FixedArrWithAlloc(kSmallSize)); + TestThrowingCtor<FixedArrWithAlloc>(FixedArrWithAlloc(kLargeSize)); + + // TypeSpec::kNoThrowMove + TestThrowingCtor<MoveFixedArrWithAlloc>(MoveFixedArrWithAlloc(kSmallSize)); + TestThrowingCtor<MoveFixedArrWithAlloc>(MoveFixedArrWithAlloc(kLargeSize)); +} + TEST(FixedArrayExceptionSafety, SizeConstructor) { TestThrowingCtor<FixedArr>(kSmallSize); TestThrowingCtor<FixedArr>(kLargeSize); } +TEST(FixedArrayExceptionSafety, SizeConstructorWithAlloc) { + TestThrowingCtor<FixedArrWithAlloc>(kSmallSize); + TestThrowingCtor<FixedArrWithAlloc>(kLargeSize); +} + TEST(FixedArrayExceptionSafety, SizeValueConstructor) { TestThrowingCtor<FixedArr>(kSmallSize, Thrower()); TestThrowingCtor<FixedArr>(kLargeSize, Thrower()); } +TEST(FixedArrayExceptionSafety, SizeValueConstructorWithAlloc) { + TestThrowingCtor<FixedArrWithAlloc>(kSmallSize, Thrower()); + TestThrowingCtor<FixedArrWithAlloc>(kLargeSize, Thrower()); +} + TEST(FixedArrayExceptionSafety, IteratorConstructor) { auto small = FixedArr(kSmallSize); TestThrowingCtor<FixedArr>(small.begin(), small.end()); @@ -72,6 +113,14 @@ TestThrowingCtor<FixedArr>(large.begin(), large.end()); } +TEST(FixedArrayExceptionSafety, IteratorConstructorWithAlloc) { + auto small = FixedArrWithAlloc(kSmallSize); + TestThrowingCtor<FixedArrWithAlloc>(small.begin(), small.end()); + + auto large = FixedArrWithAlloc(kLargeSize); + TestThrowingCtor<FixedArrWithAlloc>(large.begin(), large.end()); +} + TEST(FixedArrayExceptionSafety, InitListConstructor) { constexpr int small_inlined = 3; using SmallFixedArr = absl::FixedArray<Thrower, small_inlined>; @@ -85,7 +134,22 @@ Thrower{}, Thrower{}, Thrower{}, Thrower{}, Thrower{}}); } -testing::AssertionResult ReadMemory(FixedArr* fixed_arr) { +TEST(FixedArrayExceptionSafety, InitListConstructorWithAlloc) { + constexpr int small_inlined = 3; + using SmallFixedArrWithAlloc = + absl::FixedArray<Thrower, small_inlined, ThrowAlloc>; + + TestThrowingCtor<SmallFixedArrWithAlloc>(std::initializer_list<Thrower>{}); + // Test inlined allocation + TestThrowingCtor<SmallFixedArrWithAlloc>( + std::initializer_list<Thrower>{Thrower{}, Thrower{}}); + // Test out of line allocation + TestThrowingCtor<SmallFixedArrWithAlloc>(std::initializer_list<Thrower>{ + Thrower{}, Thrower{}, Thrower{}, Thrower{}, Thrower{}}); +} + +template <typename FixedArrT> +testing::AssertionResult ReadMemory(FixedArrT* fixed_arr) { // Marked volatile to prevent optimization. Used for running asan tests. volatile int sum = 0; for (const auto& thrower : *fixed_arr) { @@ -96,7 +160,7 @@ TEST(FixedArrayExceptionSafety, Fill) { auto test_fill = testing::MakeExceptionSafetyTester() - .WithContracts(ReadMemory) + .WithContracts(ReadMemory<FixedArr>) .WithOperation([&](FixedArr* fixed_arr_ptr) { auto thrower = Thrower(kUpdatedValue, testing::nothrow_ctor); @@ -111,6 +175,28 @@ .Test()); } +TEST(FixedArrayExceptionSafety, FillWithAlloc) { + auto test_fill = testing::MakeExceptionSafetyTester() + .WithContracts(ReadMemory<FixedArrWithAlloc>) + .WithOperation([&](FixedArrWithAlloc* fixed_arr_ptr) { + auto thrower = + Thrower(kUpdatedValue, testing::nothrow_ctor); + fixed_arr_ptr->fill(thrower); + }); + + EXPECT_TRUE(test_fill + .WithInitialValue( + FixedArrWithAlloc(kSmallSize, Thrower(kInitialValue))) + .Test()); + EXPECT_TRUE(test_fill + .WithInitialValue( + FixedArrWithAlloc(kLargeSize, Thrower(kInitialValue))) + .Test()); +} + } // namespace +ABSL_NAMESPACE_END } // namespace absl + +#endif // ABSL_HAVE_EXCEPTIONS
diff --git a/third_party/abseil-cpp/absl/container/fixed_array_test.cc b/third_party/abseil-cpp/absl/container/fixed_array_test.cc index 2b1cf47..c960fe51 100644 --- a/third_party/abseil-cpp/absl/container/fixed_array_test.cc +++ b/third_party/abseil-cpp/absl/container/fixed_array_test.cc
@@ -604,19 +604,16 @@ empty.fill(fill_val); } -// TODO(johnsoncj): Investigate InlinedStorage default initialization in GCC 4.x #ifndef __GNUC__ TEST(FixedArrayTest, DefaultCtorDoesNotValueInit) { using T = char; constexpr auto capacity = 10; using FixedArrType = absl::FixedArray<T, capacity>; - using FixedArrBuffType = - absl::aligned_storage_t<sizeof(FixedArrType), alignof(FixedArrType)>; constexpr auto scrubbed_bits = 0x95; constexpr auto length = capacity / 2; - FixedArrBuffType buff; - std::memset(std::addressof(buff), scrubbed_bits, sizeof(FixedArrBuffType)); + alignas(FixedArrType) unsigned char buff[sizeof(FixedArrType)]; + std::memset(std::addressof(buff), scrubbed_bits, sizeof(FixedArrType)); FixedArrType* arr = ::new (static_cast<void*>(std::addressof(buff))) FixedArrType(length);
diff --git a/third_party/abseil-cpp/absl/container/flat_hash_map.h b/third_party/abseil-cpp/absl/container/flat_hash_map.h index 0bc501b1..fcb70d8 100644 --- a/third_party/abseil-cpp/absl/container/flat_hash_map.h +++ b/third_party/abseil-cpp/absl/container/flat_hash_map.h
@@ -42,6 +42,7 @@ #include "absl/memory/memory.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class K, class V> struct FlatHashMapPolicy; @@ -360,6 +361,10 @@ // Inserts (via copy or move) the element of the specified key into the // `flat_hash_map` using the position of `hint` as a non-binding suggestion // for where to begin the insertion search. + // + // All `try_emplace()` overloads make the same guarantees regarding rvalue + // arguments as `std::unordered_map::try_emplace()`, namely that these + // functions will not move from rvalue arguments if insertions do not happen. using Base::try_emplace; // flat_hash_map::extract() @@ -397,7 +402,7 @@ // for the past-the-end iterator, which is invalidated. // // `swap()` requires that the flat hash map's hashing and key equivalence - // functions be Swappable, and are exchaged using unqualified calls to + // functions be Swappable, and are exchanged using unqualified calls to // non-member `swap()`. If the map's allocator has // `std::allocator_traits<allocator_type>::propagate_on_container_swap::value` // set to `true`, the allocators are also exchanged using an unqualified call @@ -527,6 +532,15 @@ using Base::key_eq; }; +// erase_if(flat_hash_map<>, Pred) +// +// Erases all elements that satisfy the predicate `pred` from the container `c`. +template <typename K, typename V, typename H, typename E, typename A, + typename Predicate> +void erase_if(flat_hash_map<K, V, H, E, A>& c, Predicate pred) { + container_internal::EraseIf(pred, &c); +} + namespace container_internal { template <class K, class V> @@ -580,6 +594,7 @@ } // namespace container_algorithm_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_FLAT_HASH_MAP_H_
diff --git a/third_party/abseil-cpp/absl/container/flat_hash_map_test.cc b/third_party/abseil-cpp/absl/container/flat_hash_map_test.cc index ebcb560..728b693 100644 --- a/third_party/abseil-cpp/absl/container/flat_hash_map_test.cc +++ b/third_party/abseil-cpp/absl/container/flat_hash_map_test.cc
@@ -14,6 +14,8 @@ #include "absl/container/flat_hash_map.h" +#include <memory> + #include "absl/container/internal/hash_generator_testing.h" #include "absl/container/internal/unordered_map_constructor_test.h" #include "absl/container/internal/unordered_map_lookup_test.h" @@ -22,11 +24,13 @@ #include "absl/types/any.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { using ::absl::container_internal::hash_internal::Enum; using ::absl::container_internal::hash_internal::EnumClass; using ::testing::_; +using ::testing::IsEmpty; using ::testing::Pair; using ::testing::UnorderedElementsAre; @@ -46,6 +50,11 @@ INSTANTIATE_TYPED_TEST_SUITE_P(FlatHashMap, MembersTest, MapTypes); INSTANTIATE_TYPED_TEST_SUITE_P(FlatHashMap, ModifiersTest, MapTypes); +using UniquePtrMapTypes = ::testing::Types<Map<int, std::unique_ptr<int>>>; + +INSTANTIATE_TYPED_TEST_SUITE_P(FlatHashMap, UniquePtrModifiersTest, + UniquePtrMapTypes); + TEST(FlatHashMap, StandardLayout) { struct Int { explicit Int(size_t value) : value(value) {} @@ -207,41 +216,44 @@ EXPECT_THAT(m, UnorderedElementsAre(Pair(1, 17), Pair(2, 9))); } -#if (defined(ABSL_HAVE_STD_ANY) || !defined(_LIBCPP_VERSION)) && \ - !defined(__EMSCRIPTEN__) -TEST(FlatHashMap, Any) { - absl::flat_hash_map<int, absl::any> m; - m.emplace(1, 7); - auto it = m.find(1); - ASSERT_NE(it, m.end()); - EXPECT_EQ(7, absl::any_cast<int>(it->second)); +bool FirstIsEven(std::pair<const int, int> p) { return p.first % 2 == 0; } - m.emplace(std::piecewise_construct, std::make_tuple(2), std::make_tuple(8)); - it = m.find(2); - ASSERT_NE(it, m.end()); - EXPECT_EQ(8, absl::any_cast<int>(it->second)); - - m.emplace(std::piecewise_construct, std::make_tuple(3), - std::make_tuple(absl::any(9))); - it = m.find(3); - ASSERT_NE(it, m.end()); - EXPECT_EQ(9, absl::any_cast<int>(it->second)); - - struct H { - size_t operator()(const absl::any&) const { return 0; } - }; - struct E { - bool operator()(const absl::any&, const absl::any&) const { return true; } - }; - absl::flat_hash_map<absl::any, int, H, E> m2; - m2.emplace(1, 7); - auto it2 = m2.find(1); - ASSERT_NE(it2, m2.end()); - EXPECT_EQ(7, it2->second); +TEST(FlatHashMap, EraseIf) { + // Erase all elements. + { + flat_hash_map<int, int> s = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}; + erase_if(s, [](std::pair<const int, int>) { return true; }); + EXPECT_THAT(s, IsEmpty()); + } + // Erase no elements. + { + flat_hash_map<int, int> s = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}; + erase_if(s, [](std::pair<const int, int>) { return false; }); + EXPECT_THAT(s, UnorderedElementsAre(Pair(1, 1), Pair(2, 2), Pair(3, 3), + Pair(4, 4), Pair(5, 5))); + } + // Erase specific elements. + { + flat_hash_map<int, int> s = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}; + erase_if(s, + [](std::pair<const int, int> kvp) { return kvp.first % 2 == 1; }); + EXPECT_THAT(s, UnorderedElementsAre(Pair(2, 2), Pair(4, 4))); + } + // Predicate is function reference. + { + flat_hash_map<int, int> s = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}; + erase_if(s, FirstIsEven); + EXPECT_THAT(s, UnorderedElementsAre(Pair(1, 1), Pair(3, 3), Pair(5, 5))); + } + // Predicate is function pointer. + { + flat_hash_map<int, int> s = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}; + erase_if(s, &FirstIsEven); + EXPECT_THAT(s, UnorderedElementsAre(Pair(1, 1), Pair(3, 3), Pair(5, 5))); + } } -#endif // (defined(ABSL_HAVE_STD_ANY) || !defined(_LIBCPP_VERSION)) && - // !defined(__EMSCRIPTEN__) } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/flat_hash_set.h b/third_party/abseil-cpp/absl/container/flat_hash_set.h index 2a51c34..94be6e3 100644 --- a/third_party/abseil-cpp/absl/container/flat_hash_set.h +++ b/third_party/abseil-cpp/absl/container/flat_hash_set.h
@@ -40,6 +40,7 @@ #include "absl/memory/memory.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <typename T> struct FlatHashSetPolicy; @@ -438,6 +439,14 @@ using Base::key_eq; }; +// erase_if(flat_hash_set<>, Pred) +// +// Erases all elements that satisfy the predicate `pred` from the container `c`. +template <typename T, typename H, typename E, typename A, typename Predicate> +void erase_if(flat_hash_set<T, H, E, A>& c, Predicate pred) { + container_internal::EraseIf(pred, &c); +} + namespace container_internal { template <class T> @@ -488,6 +497,7 @@ } // namespace container_algorithm_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_FLAT_HASH_SET_H_
diff --git a/third_party/abseil-cpp/absl/container/flat_hash_set_test.cc b/third_party/abseil-cpp/absl/container/flat_hash_set_test.cc index b55be59..40d7f85c 100644 --- a/third_party/abseil-cpp/absl/container/flat_hash_set_test.cc +++ b/third_party/abseil-cpp/absl/container/flat_hash_set_test.cc
@@ -25,11 +25,13 @@ #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { using ::absl::container_internal::hash_internal::Enum; using ::absl::container_internal::hash_internal::EnumClass; +using ::testing::IsEmpty; using ::testing::Pointee; using ::testing::UnorderedElementsAre; using ::testing::UnorderedElementsAreArray; @@ -123,6 +125,42 @@ EXPECT_THAT(set2, UnorderedElementsAre(Pointee(7), Pointee(23))); } +bool IsEven(int k) { return k % 2 == 0; } + +TEST(FlatHashSet, EraseIf) { + // Erase all elements. + { + flat_hash_set<int> s = {1, 2, 3, 4, 5}; + erase_if(s, [](int) { return true; }); + EXPECT_THAT(s, IsEmpty()); + } + // Erase no elements. + { + flat_hash_set<int> s = {1, 2, 3, 4, 5}; + erase_if(s, [](int) { return false; }); + EXPECT_THAT(s, UnorderedElementsAre(1, 2, 3, 4, 5)); + } + // Erase specific elements. + { + flat_hash_set<int> s = {1, 2, 3, 4, 5}; + erase_if(s, [](int k) { return k % 2 == 1; }); + EXPECT_THAT(s, UnorderedElementsAre(2, 4)); + } + // Predicate is function reference. + { + flat_hash_set<int> s = {1, 2, 3, 4, 5}; + erase_if(s, IsEven); + EXPECT_THAT(s, UnorderedElementsAre(1, 3, 5)); + } + // Predicate is function pointer. + { + flat_hash_set<int> s = {1, 2, 3, 4, 5}; + erase_if(s, &IsEven); + EXPECT_THAT(s, UnorderedElementsAre(1, 3, 5)); + } +} + } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/inlined_vector.h b/third_party/abseil-cpp/absl/container/inlined_vector.h index 25af165..2388d471 100644 --- a/third_party/abseil-cpp/absl/container/inlined_vector.h +++ b/third_party/abseil-cpp/absl/container/inlined_vector.h
@@ -54,6 +54,7 @@ #include "absl/memory/memory.h" namespace absl { +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // InlinedVector // ----------------------------------------------------------------------------- @@ -69,9 +70,10 @@ static_assert(N > 0, "`absl::InlinedVector` requires an inlined capacity."); using Storage = inlined_vector_internal::Storage<T, N, A>; - using rvalue_reference = typename Storage::rvalue_reference; - using MoveIterator = typename Storage::MoveIterator; + using AllocatorTraits = typename Storage::AllocatorTraits; + using RValueReference = typename Storage::RValueReference; + using MoveIterator = typename Storage::MoveIterator; using IsMemcpyOk = typename Storage::IsMemcpyOk; template <typename Iterator> @@ -92,10 +94,10 @@ using value_type = typename Storage::value_type; using pointer = typename Storage::pointer; using const_pointer = typename Storage::const_pointer; - using reference = typename Storage::reference; - using const_reference = typename Storage::const_reference; using size_type = typename Storage::size_type; using difference_type = typename Storage::difference_type; + using reference = typename Storage::reference; + using const_reference = typename Storage::const_reference; using iterator = typename Storage::iterator; using const_iterator = typename Storage::const_iterator; using reverse_iterator = typename Storage::reverse_iterator; @@ -533,7 +535,6 @@ } erase(data() + i, data() + size()); - std::copy(first, last, std::back_inserter(*this)); } @@ -564,7 +565,7 @@ // Overload of `InlinedVector::insert(...)` that inserts `v` at `pos` using // move semantics, returning an `iterator` to the newly inserted element. - iterator insert(const_iterator pos, rvalue_reference v) { + iterator insert(const_iterator pos, RValueReference v) { return emplace(pos, std::move(v)); } @@ -661,7 +662,7 @@ // Overload of `InlinedVector::push_back(...)` for inserting `v` at `end()` // using move semantics. - void push_back(rvalue_reference v) { + void push_back(RValueReference v) { static_cast<void>(emplace_back(std::move(v))); } @@ -713,6 +714,7 @@ inlined_vector_internal::DestroyElements(storage_.GetAllocPtr(), data(), size()); storage_.DeallocateIfAllocated(); + storage_.SetInlinedSize(0); } @@ -840,6 +842,7 @@ return H::combine(H::combine_contiguous(std::move(h), a.data(), size), size); } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INLINED_VECTOR_H_
diff --git a/third_party/abseil-cpp/absl/container/inlined_vector_benchmark.cc b/third_party/abseil-cpp/absl/container/inlined_vector_benchmark.cc index b99bbd6..b8dafe9 100644 --- a/third_party/abseil-cpp/absl/container/inlined_vector_benchmark.cc +++ b/third_party/abseil-cpp/absl/container/inlined_vector_benchmark.cc
@@ -25,42 +25,45 @@ namespace { void BM_InlinedVectorFill(benchmark::State& state) { + const int len = state.range(0); absl::InlinedVector<int, 8> v; - int val = 10; + v.reserve(len); for (auto _ : state) { + v.resize(0); // Use resize(0) as InlinedVector releases storage on clear(). + for (int i = 0; i < len; ++i) { + v.push_back(i); + } benchmark::DoNotOptimize(v); - v.push_back(val); } } -BENCHMARK(BM_InlinedVectorFill)->Range(0, 1024); +BENCHMARK(BM_InlinedVectorFill)->Range(1, 256); void BM_InlinedVectorFillRange(benchmark::State& state) { const int len = state.range(0); - std::unique_ptr<int[]> ia(new int[len]); - for (int i = 0; i < len; i++) { - ia[i] = i; - } - auto* from = ia.get(); - auto* to = from + len; + const std::vector<int> src(len, len); + absl::InlinedVector<int, 8> v; + v.reserve(len); for (auto _ : state) { - benchmark::DoNotOptimize(from); - benchmark::DoNotOptimize(to); - absl::InlinedVector<int, 8> v(from, to); + benchmark::DoNotOptimize(src); + v.assign(src.begin(), src.end()); benchmark::DoNotOptimize(v); } } -BENCHMARK(BM_InlinedVectorFillRange)->Range(0, 1024); +BENCHMARK(BM_InlinedVectorFillRange)->Range(1, 256); void BM_StdVectorFill(benchmark::State& state) { + const int len = state.range(0); std::vector<int> v; - int val = 10; + v.reserve(len); for (auto _ : state) { + v.clear(); + for (int i = 0; i < len; ++i) { + v.push_back(i); + } benchmark::DoNotOptimize(v); - benchmark::DoNotOptimize(val); - v.push_back(val); } } -BENCHMARK(BM_StdVectorFill)->Range(0, 1024); +BENCHMARK(BM_StdVectorFill)->Range(1, 256); // The purpose of the next two benchmarks is to verify that // absl::InlinedVector is efficient when moving is more efficent than @@ -80,7 +83,7 @@ } ABSL_RAW_LOG( FATAL, - "Failed to find a std::string larger than the short std::string optimization"); + "Failed to find a string larger than the short string optimization"); return -1; }
diff --git a/third_party/abseil-cpp/absl/container/inlined_vector_exception_safety_test.cc b/third_party/abseil-cpp/absl/container/inlined_vector_exception_safety_test.cc index ff0da75..0e6a05b 100644 --- a/third_party/abseil-cpp/absl/container/inlined_vector_exception_safety_test.cc +++ b/third_party/abseil-cpp/absl/container/inlined_vector_exception_safety_test.cc
@@ -12,6 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "absl/container/inlined_vector.h" + +#include "absl/base/config.h" + +#if defined(ABSL_HAVE_EXCEPTIONS) + #include <array> #include <initializer_list> #include <iterator> @@ -20,7 +26,6 @@ #include "gtest/gtest.h" #include "absl/base/internal/exception_safety_testing.h" -#include "absl/container/inlined_vector.h" namespace { @@ -57,8 +62,8 @@ \ : std::initializer_list<T>{T(0, testing::nothrow_ctor), \ T(1, testing::nothrow_ctor)}) -static_assert((kLargeSize == 8 || kSmallSize == 2), - "Must update ABSL_INTERNAL_MAKE_INIT_LIST(...)."); +static_assert(kLargeSize == 8, "Must update ABSL_INTERNAL_MAKE_INIT_LIST(...)"); +static_assert(kSmallSize == 2, "Must update ABSL_INTERNAL_MAKE_INIT_LIST(...)"); template <typename TheVecT, size_t... TheSizes> class TestParams { @@ -359,9 +364,11 @@ using VecT = typename TypeParam::VecT; constexpr static auto size = TypeParam::GetSizeAt(0); + // For testing calls to `emplace_back(...)` that reallocate. VecT full_vec{size}; full_vec.resize(full_vec.capacity()); + // For testing calls to `emplace_back(...)` that don't reallocate. VecT nonfull_vec{size}; nonfull_vec.reserve(size + 1); @@ -369,12 +376,11 @@ InlinedVectorInvariants<VecT>); EXPECT_TRUE(tester.WithInitialValue(nonfull_vec).Test([](VecT* vec) { - vec->emplace_back(); // + vec->emplace_back(); })); - EXPECT_TRUE(tester.WithInitialValue(full_vec).Test([](VecT* vec) { - vec->emplace_back(); // - })); + EXPECT_TRUE(tester.WithInitialValue(full_vec).Test( + [](VecT* vec) { vec->emplace_back(); })); } TYPED_TEST(OneSizeTest, PopBack) { @@ -413,6 +419,19 @@ EXPECT_TRUE(tester.Test([](VecT* vec) { auto it = vec->begin(); + vec->erase(it, it); + })); + EXPECT_TRUE(tester.Test([](VecT* vec) { + auto it = vec->begin() + (vec->size() / 2); + vec->erase(it, it); + })); + EXPECT_TRUE(tester.Test([](VecT* vec) { + auto it = vec->begin() + (vec->size() - 1); + vec->erase(it, it); + })); + + EXPECT_TRUE(tester.Test([](VecT* vec) { + auto it = vec->begin(); vec->erase(it, it + 1); })); EXPECT_TRUE(tester.Test([](VecT* vec) { @@ -447,9 +466,7 @@ .WithInitialValue(VecT{from_size}) .WithContracts(InlinedVectorInvariants<VecT>); - EXPECT_TRUE(tester.Test([](VecT* vec) { - vec->reserve(to_capacity); // - })); + EXPECT_TRUE(tester.Test([](VecT* vec) { vec->reserve(to_capacity); })); } TYPED_TEST(OneSizeTest, ShrinkToFit) { @@ -487,3 +504,5 @@ } } // namespace + +#endif // defined(ABSL_HAVE_EXCEPTIONS)
diff --git a/third_party/abseil-cpp/absl/container/inlined_vector_test.cc b/third_party/abseil-cpp/absl/container/inlined_vector_test.cc index bada4fe..5965eac 100644 --- a/third_party/abseil-cpp/absl/container/inlined_vector_test.cc +++ b/third_party/abseil-cpp/absl/container/inlined_vector_test.cc
@@ -780,7 +780,7 @@ TEST(StringVec, SelfRefPushBack) { std::vector<std::string> std_v; absl::InlinedVector<std::string, 4> v; - const std::string s = "A quite long std::string to ensure heap."; + const std::string s = "A quite long string to ensure heap."; std_v.push_back(s); v.push_back(s); for (int i = 0; i < 20; ++i) { @@ -795,7 +795,7 @@ TEST(StringVec, SelfRefPushBackWithMove) { std::vector<std::string> std_v; absl::InlinedVector<std::string, 4> v; - const std::string s = "A quite long std::string to ensure heap."; + const std::string s = "A quite long string to ensure heap."; std_v.push_back(s); v.push_back(s); for (int i = 0; i < 20; ++i) { @@ -808,7 +808,7 @@ } TEST(StringVec, SelfMove) { - const std::string s = "A quite long std::string to ensure heap."; + const std::string s = "A quite long string to ensure heap."; for (int len = 0; len < 20; len++) { SCOPED_TRACE(len); absl::InlinedVector<std::string, 8> v; @@ -1689,7 +1689,11 @@ inlined_case.emplace_back(); int64_t absl_responsible_for_count = total_allocated_byte_count; + + // MSVC's allocator preemptively allocates in debug mode +#if !defined(_MSC_VER) EXPECT_EQ(absl_responsible_for_count, 0); +#endif // !defined(_MSC_VER) inlined_case[0].emplace_back(); EXPECT_GT(total_allocated_byte_count, absl_responsible_for_count); @@ -1750,6 +1754,30 @@ } } +TEST(InlinedVectorTest, MinimumAllocatorCompilesUsingTraits) { + using T = int; + using A = std::allocator<T>; + using ATraits = absl::allocator_traits<A>; + + struct MinimumAllocator { + using value_type = T; + + value_type* allocate(size_t n) { + A a; + return ATraits::allocate(a, n); + } + + void deallocate(value_type* p, size_t n) { + A a; + ATraits::deallocate(a, p, n); + } + }; + + absl::InlinedVector<T, 1, MinimumAllocator> vec; + vec.emplace_back(); + vec.resize(0); +} + TEST(InlinedVectorTest, AbslHashValueWorks) { using V = absl::InlinedVector<int, 4>; std::vector<V> cases;
diff --git a/third_party/abseil-cpp/absl/container/internal/btree.h b/third_party/abseil-cpp/absl/container/internal/btree.h index 9561a4d..d986f81e8 100644 --- a/third_party/abseil-cpp/absl/container/internal/btree.h +++ b/third_party/abseil-cpp/absl/container/internal/btree.h
@@ -65,11 +65,13 @@ #include "absl/container/internal/layout.h" #include "absl/memory/memory.h" #include "absl/meta/type_traits.h" +#include "absl/strings/cord.h" #include "absl/strings/string_view.h" #include "absl/types/compare.h" #include "absl/utility/utility.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { // A helper class that indicates if the Compare parameter is a key-compare-to @@ -92,6 +94,19 @@ absl::string_view rhs) const { return compare_internal::compare_result_as_ordering(lhs.compare(rhs)); } + StringBtreeDefaultLess(std::less<absl::Cord>) {} // NOLINT + absl::weak_ordering operator()(const absl::Cord &lhs, + const absl::Cord &rhs) const { + return compare_internal::compare_result_as_ordering(lhs.Compare(rhs)); + } + absl::weak_ordering operator()(const absl::Cord &lhs, + absl::string_view rhs) const { + return compare_internal::compare_result_as_ordering(lhs.Compare(rhs)); + } + absl::weak_ordering operator()(absl::string_view lhs, + const absl::Cord &rhs) const { + return compare_internal::compare_result_as_ordering(-rhs.Compare(lhs)); + } }; struct StringBtreeDefaultGreater { @@ -106,13 +121,27 @@ absl::string_view rhs) const { return compare_internal::compare_result_as_ordering(rhs.compare(lhs)); } + StringBtreeDefaultGreater(std::greater<absl::Cord>) {} // NOLINT + absl::weak_ordering operator()(const absl::Cord &lhs, + const absl::Cord &rhs) const { + return compare_internal::compare_result_as_ordering(rhs.Compare(lhs)); + } + absl::weak_ordering operator()(const absl::Cord &lhs, + absl::string_view rhs) const { + return compare_internal::compare_result_as_ordering(-lhs.Compare(rhs)); + } + absl::weak_ordering operator()(absl::string_view lhs, + const absl::Cord &rhs) const { + return compare_internal::compare_result_as_ordering(rhs.Compare(lhs)); + } }; // A helper class to convert a boolean comparison into a three-way "compare-to" // comparison that returns a negative value to indicate less-than, zero to // indicate equality and a positive value to indicate greater-than. This helper // class is specialized for less<std::string>, greater<std::string>, -// less<string_view>, and greater<string_view>. +// less<string_view>, greater<string_view>, less<absl::Cord>, and +// greater<absl::Cord>. // // key_compare_to_adapter is provided so that btree users // automatically get the more efficient compare-to code when using common @@ -144,10 +173,20 @@ using type = StringBtreeDefaultGreater; }; +template <> +struct key_compare_to_adapter<std::less<absl::Cord>> { + using type = StringBtreeDefaultLess; +}; + +template <> +struct key_compare_to_adapter<std::greater<absl::Cord>> { + using type = StringBtreeDefaultGreater; +}; + template <typename Key, typename Compare, typename Alloc, int TargetNodeSize, bool Multi, typename SlotPolicy> struct common_params { - // If Compare is a common comparator for a std::string-like type, then we adapt it + // If Compare is a common comparator for a string-like type, then we adapt it // to use heterogeneous lookup and to be a key-compare-to comparator. using key_compare = typename key_compare_to_adapter<Compare>::type; // A type which indicates if we have a key-compare-to functor or a plain old @@ -251,9 +290,9 @@ }; using is_map_container = std::true_type; - static const Key &key(const value_type &x) { return x.first; } - static const Key &key(const init_type &x) { return x.first; } - static const Key &key(const slot_type *x) { return slot_policy::key(x); } + static const Key &key(const value_type &value) { return value.first; } + static const Key &key(const init_type &init) { return init.first; } + static const Key &key(const slot_type *s) { return slot_policy::key(s); } static mapped_type &value(value_type *value) { return value->second; } }; @@ -314,8 +353,8 @@ using value_compare = typename set_params::common_params::key_compare; using is_map_container = std::false_type; - static const Key &key(const value_type &x) { return x; } - static const Key &key(const slot_type *x) { return *x; } + static const Key &key(const value_type &value) { return value; } + static const Key &key(const slot_type *slot) { return *slot; } }; // An adapter class that converts a lower-bound compare into an upper-bound @@ -325,8 +364,8 @@ template <typename Compare> struct upper_bound_adapter { explicit upper_bound_adapter(const Compare &c) : comp(c) {} - template <typename K, typename LK> - bool operator()(const K &a, const LK &b) const { + template <typename K1, typename K2> + bool operator()(const K1 &a, const K2 &b) const { // Returns true when a is not greater than b. return !compare_internal::compare_result_as_less_than(comp(b, a)); } @@ -402,8 +441,9 @@ // // TODO(ezb): right now, `start` is always 0. Update insertion/merge // // logic to allow for floating storage within nodes. // field_type start; - // // The count of the number of populated values in the node. - // field_type count; + // // The index after the last populated value in `values`. Currently, this + // // is the same as the count of values. + // field_type finish; // // The maximum number of values the node can hold. This is an integer in // // [1, kNodeValues] for root leaf nodes, kNodeValues for non-root leaf // // nodes, and kInternalNodeMaxCount (as a sentinel value) for internal @@ -414,7 +454,7 @@ // // // The array of values. The capacity is `max_count` for leaf nodes and // // kNodeValues for internal nodes. Only the values in - // // [start, start + count) have been initialized and are valid. + // // [start, finish) have been initialized and are valid. // slot_type values[max_count]; // // // The array of child pointers. The keys in children[i] are all less @@ -445,7 +485,7 @@ slot_type, btree_node *>; constexpr static size_type SizeWithNValues(size_type n) { return layout_type(/*parent*/ 1, - /*position, start, count, max_count*/ 4, + /*position, start, finish, max_count*/ 4, /*values*/ n, /*children*/ 0) .AllocSize(); @@ -482,13 +522,13 @@ // Leaves can have less than kNodeValues values. constexpr static layout_type LeafLayout(const int max_values = kNodeValues) { return layout_type(/*parent*/ 1, - /*position, start, count, max_count*/ 4, + /*position, start, finish, max_count*/ 4, /*values*/ max_values, /*children*/ 0); } constexpr static layout_type InternalLayout() { return layout_type(/*parent*/ 1, - /*position, start, count, max_count*/ 4, + /*position, start, finish, max_count*/ 4, /*values*/ kNodeValues, /*children*/ kNodeValues + 1); } @@ -514,12 +554,14 @@ reinterpret_cast<const char *>(this)); } void set_parent(btree_node *p) { *GetField<0>() = p; } - field_type &mutable_count() { return GetField<1>()[2]; } + field_type &mutable_finish() { return GetField<1>()[2]; } slot_type *slot(int i) { return &GetField<2>()[i]; } + slot_type *start_slot() { return slot(start()); } + slot_type *finish_slot() { return slot(finish()); } const slot_type *slot(int i) const { return &GetField<2>()[i]; } void set_position(field_type v) { GetField<1>()[0] = v; } void set_start(field_type v) { GetField<1>()[1] = v; } - void set_count(field_type v) { GetField<1>()[2] = v; } + void set_finish(field_type v) { GetField<1>()[2] = v; } // This method is only called by the node init methods. void set_max_count(field_type v) { GetField<1>()[3] = v; } @@ -532,10 +574,20 @@ field_type position() const { return GetField<1>()[0]; } // Getter for the offset of the first value in the `values` array. - field_type start() const { return GetField<1>()[1]; } + field_type start() const { + // TODO(ezb): when floating storage is implemented, return GetField<1>()[1]; + assert(GetField<1>()[1] == 0); + return 0; + } + + // Getter for the offset after the last value in the `values` array. + field_type finish() const { return GetField<1>()[2]; } // Getters for the number of values stored in this node. - field_type count() const { return GetField<1>()[2]; } + field_type count() const { + assert(finish() >= start()); + return finish() - start(); + } field_type max_count() const { // Internal nodes have max_count==kInternalNodeMaxCount. // Leaf nodes have max_count in [1, kNodeValues]. @@ -563,6 +615,7 @@ // Getters/setter for the child at position i in the node. btree_node *child(int i) const { return GetField<3>()[i]; } + btree_node *start_child() const { return child(start()); } btree_node *&mutable_child(int i) { return GetField<3>()[i]; } void clear_child(int i) { absl::container_internal::SanitizerPoisonObject(&mutable_child(i)); @@ -595,14 +648,14 @@ template <typename K, typename Compare> SearchResult<int, btree_is_key_compare_to<Compare, key_type>::value> linear_search(const K &k, const Compare &comp) const { - return linear_search_impl(k, 0, count(), comp, + return linear_search_impl(k, start(), finish(), comp, btree_is_key_compare_to<Compare, key_type>()); } template <typename K, typename Compare> SearchResult<int, btree_is_key_compare_to<Compare, key_type>::value> binary_search(const K &k, const Compare &comp) const { - return binary_search_impl(k, 0, count(), comp, + return binary_search_impl(k, start(), finish(), comp, btree_is_key_compare_to<Compare, key_type>()); } @@ -721,34 +774,31 @@ // Merges a node with its right sibling, moving all of the values and the // delimiting key in the parent node onto itself. - void merge(btree_node *sibling, allocator_type *alloc); + void merge(btree_node *src, allocator_type *alloc); - // Swap the contents of "this" and "src". - void swap(btree_node *src, allocator_type *alloc); + // Swaps the contents of `this` and `other`. + void swap(btree_node *other, allocator_type *alloc); // Node allocation/deletion routines. - static btree_node *init_leaf(btree_node *n, btree_node *parent, - int max_count) { - n->set_parent(parent); - n->set_position(0); - n->set_start(0); - n->set_count(0); - n->set_max_count(max_count); + void init_leaf(btree_node *parent, int max_count) { + set_parent(parent); + set_position(0); + set_start(0); + set_finish(0); + set_max_count(max_count); absl::container_internal::SanitizerPoisonMemoryRegion( - n->slot(0), max_count * sizeof(slot_type)); - return n; + start_slot(), max_count * sizeof(slot_type)); } - static btree_node *init_internal(btree_node *n, btree_node *parent) { - init_leaf(n, parent, kNodeValues); + void init_internal(btree_node *parent) { + init_leaf(parent, kNodeValues); // Set `max_count` to a sentinel value to indicate that this node is // internal. - n->set_max_count(kInternalNodeMaxCount); + set_max_count(kInternalNodeMaxCount); absl::container_internal::SanitizerPoisonMemoryRegion( - &n->mutable_child(0), (kNodeValues + 1) * sizeof(btree_node *)); - return n; + &mutable_child(start()), (kNodeValues + 1) * sizeof(btree_node *)); } void destroy(allocator_type *alloc) { - for (int i = 0; i < count(); ++i) { + for (int i = start(); i < finish(); ++i) { value_destroy(i, alloc); } } @@ -771,13 +821,13 @@ } // Move n values starting at value i in this node into the values starting at - // value j in node x. + // value j in dest_node. void uninitialized_move_n(const size_type n, const size_type i, - const size_type j, btree_node *x, + const size_type j, btree_node *dest_node, allocator_type *alloc) { absl::container_internal::SanitizerUnpoisonMemoryRegion( - x->slot(j), n * sizeof(slot_type)); - for (slot_type *src = slot(i), *end = src + n, *dest = x->slot(j); + dest_node->slot(j), n * sizeof(slot_type)); + for (slot_type *src = slot(i), *end = src + n, *dest = dest_node->slot(j); src != end; ++src, ++dest) { params_type::construct(alloc, dest, src); } @@ -828,6 +878,7 @@ using iterator_category = std::bidirectional_iterator_tag; btree_iterator() : node(nullptr), position(-1) {} + explicit btree_iterator(Node *n) : node(n), position(n->start()) {} btree_iterator(Node *n, int p) : node(n), position(p) {} // NOTE: this SFINAE allows for implicit conversions from iterator to @@ -839,8 +890,8 @@ std::is_same<btree_iterator<N, R, P>, iterator>::value && std::is_same<btree_iterator, const_iterator>::value, int> = 0> - btree_iterator(const btree_iterator<N, R, P> &x) // NOLINT - : node(x.node), position(x.position) {} + btree_iterator(const btree_iterator<N, R, P> &other) // NOLINT + : node(other.node), position(other.position) {} private: // This SFINAE allows explicit conversions from const_iterator to @@ -852,12 +903,12 @@ std::is_same<btree_iterator<N, R, P>, const_iterator>::value && std::is_same<btree_iterator, iterator>::value, int> = 0> - explicit btree_iterator(const btree_iterator<N, R, P> &x) - : node(const_cast<node_type *>(x.node)), position(x.position) {} + explicit btree_iterator(const btree_iterator<N, R, P> &other) + : node(const_cast<node_type *>(other.node)), position(other.position) {} // Increment/decrement the iterator. void increment() { - if (node->leaf() && ++position < node->count()) { + if (node->leaf() && ++position < node->finish()) { return; } increment_slow(); @@ -865,7 +916,7 @@ void increment_slow(); void decrement() { - if (node->leaf() && --position >= 0) { + if (node->leaf() && --position >= node->start()) { return; } decrement_slow(); @@ -873,26 +924,22 @@ void decrement_slow(); public: - bool operator==(const const_iterator &x) const { - return node == x.node && position == x.position; + bool operator==(const const_iterator &other) const { + return node == other.node && position == other.position; } - bool operator!=(const const_iterator &x) const { - return node != x.node || position != x.position; + bool operator!=(const const_iterator &other) const { + return node != other.node || position != other.position; } // Accessors for the key/value the iterator is pointing at. - reference operator*() const { - return node->value(position); - } - pointer operator->() const { - return &node->value(position); - } + reference operator*() const { return node->value(position); } + pointer operator->() const { return &node->value(position); } - btree_iterator& operator++() { + btree_iterator &operator++() { increment(); return *this; } - btree_iterator& operator--() { + btree_iterator &operator--() { decrement(); return *this; } @@ -929,7 +976,8 @@ // The node in the tree the iterator is pointing at. Node *node; // The position within the node of the tree the iterator is pointing at. - // TODO(ezb): make this a field_type + // NOTE: this is an int rather than a field_type because iterators can point + // to invalid positions (such as -1) in certain circumstances. int position; }; @@ -945,7 +993,7 @@ node_type *parent; field_type position = 0; field_type start = 0; - field_type count = 0; + field_type finish = 0; // max_count must be != kInternalNodeMaxCount (so that this node is regarded // as a leaf node). max_count() is never called when the tree is empty. field_type max_count = node_type::kInternalNodeMaxCount + 1; @@ -960,7 +1008,7 @@ static node_type *EmptyNode() { #ifdef _MSC_VER - static EmptyNodeType* empty_node = new EmptyNodeType; + static EmptyNodeType *empty_node = new EmptyNodeType; // This assert fails on some other construction methods. assert(empty_node->parent == empty_node); return empty_node; @@ -979,14 +1027,11 @@ struct node_stats { using size_type = typename Params::size_type; - node_stats(size_type l, size_type i) - : leaf_nodes(l), - internal_nodes(i) { - } + node_stats(size_type l, size_type i) : leaf_nodes(l), internal_nodes(i) {} - node_stats& operator+=(const node_stats &x) { - leaf_nodes += x.leaf_nodes; - internal_nodes += x.internal_nodes; + node_stats &operator+=(const node_stats &other) { + leaf_nodes += other.leaf_nodes; + internal_nodes += other.internal_nodes; return *this; } @@ -1018,15 +1063,15 @@ private: // For use in copy_or_move_values_in_order. - const value_type &maybe_move_from_iterator(const_iterator x) { return *x; } - value_type &&maybe_move_from_iterator(iterator x) { return std::move(*x); } + const value_type &maybe_move_from_iterator(const_iterator it) { return *it; } + value_type &&maybe_move_from_iterator(iterator it) { return std::move(*it); } // Copies or moves (depending on the template parameter) the values in - // x into this btree in their order in x. This btree must be empty before this - // method is called. This method is used in copy construction, copy - // assignment, and move assignment. + // other into this btree in their order in other. This btree must be empty + // before this method is called. This method is used in copy construction, + // copy assignment, and move assignment. template <typename Btree> - void copy_or_move_values_in_order(Btree *x); + void copy_or_move_values_in_order(Btree *other); // Validates that various assumptions/requirements are true at compile time. constexpr static bool static_assert_validation(); @@ -1034,12 +1079,12 @@ public: btree(const key_compare &comp, const allocator_type &alloc); - btree(const btree &x); - btree(btree &&x) noexcept - : root_(std::move(x.root_)), - rightmost_(absl::exchange(x.rightmost_, EmptyNode())), - size_(absl::exchange(x.size_, 0)) { - x.mutable_root() = EmptyNode(); + btree(const btree &other); + btree(btree &&other) noexcept + : root_(std::move(other.root_)), + rightmost_(absl::exchange(other.rightmost_, EmptyNode())), + size_(absl::exchange(other.size_, 0)) { + other.mutable_root() = EmptyNode(); } ~btree() { @@ -1049,29 +1094,21 @@ clear(); } - // Assign the contents of x to *this. - btree &operator=(const btree &x); - btree &operator=(btree &&x) noexcept; + // Assign the contents of other to *this. + btree &operator=(const btree &other); + btree &operator=(btree &&other) noexcept; - iterator begin() { - return iterator(leftmost(), 0); - } - const_iterator begin() const { - return const_iterator(leftmost(), 0); - } - iterator end() { return iterator(rightmost_, rightmost_->count()); } + iterator begin() { return iterator(leftmost()); } + const_iterator begin() const { return const_iterator(leftmost()); } + iterator end() { return iterator(rightmost_, rightmost_->finish()); } const_iterator end() const { - return const_iterator(rightmost_, rightmost_->count()); + return const_iterator(rightmost_, rightmost_->finish()); } - reverse_iterator rbegin() { - return reverse_iterator(end()); - } + reverse_iterator rbegin() { return reverse_iterator(end()); } const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } - reverse_iterator rend() { - return reverse_iterator(begin()); - } + reverse_iterator rend() { return reverse_iterator(begin()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } @@ -1159,7 +1196,7 @@ // Erases range. Returns the number of keys erased and an iterator pointing // to the element after the last erased element. - std::pair<size_type, iterator> erase(iterator begin, iterator end); + std::pair<size_type, iterator> erase_range(iterator begin, iterator end); // Erases the specified key from the btree. Returns 1 if an element was // erased and 0 otherwise. @@ -1202,15 +1239,15 @@ // Clear the btree, deleting all of the values it contains. void clear(); - // Swap the contents of *this and x. - void swap(btree &x); + // Swaps the contents of `this` and `other`. + void swap(btree &other); const key_compare &key_comp() const noexcept { return root_.template get<0>(); } - template <typename K, typename LK> - bool compare_keys(const K &x, const LK &y) const { - return compare_internal::compare_result_as_less_than(key_comp()(x, y)); + template <typename K1, typename K2> + bool compare_keys(const K1 &a, const K2 &b) const { + return compare_internal::compare_result_as_less_than(key_comp()(a, b)); } value_compare value_comp() const { return value_compare(key_comp()); } @@ -1226,7 +1263,7 @@ // The height of the btree. An empty tree will have height 0. size_type height() const { size_type h = 0; - if (root()) { + if (!empty()) { // Count the length of the chain from the leftmost node up to the // root. We actually count from the root back around to the level below // the root, but the calculation is the same because of the circularity @@ -1241,9 +1278,7 @@ } // The number of internal, leaf and total nodes used by the btree. - size_type leaf_nodes() const { - return internal_stats(root()).leaf_nodes; - } + size_type leaf_nodes() const { return internal_stats(root()).leaf_nodes; } size_type internal_nodes() const { return internal_stats(root()).internal_nodes; } @@ -1256,11 +1291,9 @@ size_type bytes_used() const { node_stats stats = internal_stats(root()); if (stats.leaf_nodes == 1 && stats.internal_nodes == 0) { - return sizeof(*this) + - node_type::LeafSize(root()->max_count()); + return sizeof(*this) + node_type::LeafSize(root()->max_count()); } else { - return sizeof(*this) + - stats.leaf_nodes * node_type::LeafSize() + + return sizeof(*this) + stats.leaf_nodes * node_type::LeafSize() + stats.internal_nodes * node_type::InternalSize(); } } @@ -1277,24 +1310,23 @@ // divided by the maximum number of elements a tree with the current number // of nodes could hold. A value of 1 indicates perfect space // utilization. Smaller values indicate space wastage. + // Returns 0 for empty trees. double fullness() const { + if (empty()) return 0.0; return static_cast<double>(size()) / (nodes() * kNodeValues); } // The overhead of the btree structure in bytes per node. Computed as the // total number of bytes used by the btree minus the number of bytes used for // storing elements divided by the number of elements. + // Returns 0 for empty trees. double overhead() const { - if (empty()) { - return 0.0; - } + if (empty()) return 0.0; return (bytes_used() - size() * sizeof(value_type)) / static_cast<double>(size()); } // The allocator used by the btree. - allocator_type get_allocator() const { - return allocator(); - } + allocator_type get_allocator() const { return allocator(); } private: // Internal accessor routines. @@ -1324,17 +1356,20 @@ } // Node creation/deletion routines. - node_type* new_internal_node(node_type *parent) { - node_type *p = allocate(node_type::InternalSize()); - return node_type::init_internal(p, parent); + node_type *new_internal_node(node_type *parent) { + node_type *n = allocate(node_type::InternalSize()); + n->init_internal(parent); + return n; } - node_type* new_leaf_node(node_type *parent) { - node_type *p = allocate(node_type::LeafSize()); - return node_type::init_leaf(p, parent, kNodeValues); + node_type *new_leaf_node(node_type *parent) { + node_type *n = allocate(node_type::LeafSize()); + n->init_leaf(parent, kNodeValues); + return n; } node_type *new_leaf_root_node(const int max_count) { - node_type *p = allocate(node_type::LeafSize(max_count)); - return node_type::init_leaf(p, p, max_count); + node_type *n = allocate(node_type::LeafSize(max_count)); + n->init_leaf(/*parent=*/n, max_count); + return n; } // Deletion helper routines. @@ -1386,9 +1421,9 @@ iterator internal_emplace(iterator iter, Args &&... args); // Returns an iterator pointing to the first value >= the value "iter" is - // pointing at. Note that "iter" might be pointing to an invalid location as - // iter.position == iter.node->count(). This routine simply moves iter up in - // the tree to a valid location. + // pointing at. Note that "iter" might be pointing to an invalid location such + // as iter.position == iter.node->finish(). This routine simply moves iter up + // in the tree to a valid location. // Requires: iter.node is non-null. template <typename IterType> static IterType internal_last(IterType iter); @@ -1429,8 +1464,8 @@ void internal_clear(node_type *node); // Verifies the tree structure of node. - int internal_verify(const node_type *node, - const key_type *lo, const key_type *hi) const; + int internal_verify(const node_type *node, const key_type *lo, + const key_type *hi) const; node_stats internal_stats(const node_type *node) const { // The root can be a static empty node. @@ -1441,7 +1476,7 @@ return node_stats(1, 0); } node_stats res(0, 1); - for (int i = 0; i <= node->count(); ++i) { + for (int i = node->start(); i <= node->finish(); ++i) { res += internal_stats(node->child(i)); } return res; @@ -1475,20 +1510,21 @@ inline void btree_node<P>::emplace_value(const size_type i, allocator_type *alloc, Args &&... args) { - assert(i <= count()); + assert(i >= start()); + assert(i <= finish()); // Shift old values to create space for new value and then construct it in // place. - if (i < count()) { - value_init(count(), alloc, slot(count() - 1)); - for (size_type j = count() - 1; j > i; --j) + if (i < finish()) { + value_init(finish(), alloc, slot(finish() - 1)); + for (size_type j = finish() - 1; j > i; --j) params_type::move(alloc, slot(j - 1), slot(j)); value_destroy(i, alloc); } value_init(i, alloc, std::forward<Args>(args)...); - set_count(count() + 1); + set_finish(finish() + 1); - if (!leaf() && count() > i + 1) { - for (int j = count(); j > i + 1; --j) { + if (!leaf() && finish() > i + 1) { + for (int j = finish(); j > i + 1; --j) { set_child(j, child(j - 1)); } clear_child(i + 1); @@ -1497,12 +1533,12 @@ template <typename P> inline void btree_node<P>::remove_value(const int i, allocator_type *alloc) { - if (!leaf() && count() > i + 1) { + if (!leaf() && finish() > i + 1) { assert(child(i + 1)->count() == 0); - for (size_type j = i + 1; j < count(); ++j) { + for (size_type j = i + 1; j < finish(); ++j) { set_child(j, child(j + 1)); } - clear_child(count()); + clear_child(finish()); } remove_values_ignore_children(i, /*to_erase=*/1, alloc); @@ -1511,9 +1547,9 @@ template <typename P> inline void btree_node<P>::remove_values_ignore_children( const int i, const int to_erase, allocator_type *alloc) { - params_type::move(alloc, slot(i + to_erase), slot(count()), slot(i)); - value_destroy_n(count() - to_erase, to_erase, alloc); - set_count(count() - to_erase); + params_type::move(alloc, slot(i + to_erase), finish_slot(), slot(i)); + value_destroy_n(finish() - to_erase, to_erase, alloc); + set_finish(finish() - to_erase); } template <typename P> @@ -1527,37 +1563,38 @@ assert(to_move <= right->count()); // 1) Move the delimiting value in the parent to the left node. - value_init(count(), alloc, parent()->slot(position())); + value_init(finish(), alloc, parent()->slot(position())); // 2) Move the (to_move - 1) values from the right node to the left node. - right->uninitialized_move_n(to_move - 1, 0, count() + 1, this, alloc); + right->uninitialized_move_n(to_move - 1, right->start(), finish() + 1, this, + alloc); // 3) Move the new delimiting value to the parent from the right node. params_type::move(alloc, right->slot(to_move - 1), parent()->slot(position())); // 4) Shift the values in the right node to their correct position. - params_type::move(alloc, right->slot(to_move), right->slot(right->count()), - right->slot(0)); + params_type::move(alloc, right->slot(to_move), right->finish_slot(), + right->start_slot()); // 5) Destroy the now-empty to_move entries in the right node. - right->value_destroy_n(right->count() - to_move, to_move, alloc); + right->value_destroy_n(right->finish() - to_move, to_move, alloc); if (!leaf()) { // Move the child pointers from the right to the left node. for (int i = 0; i < to_move; ++i) { - init_child(count() + i + 1, right->child(i)); + init_child(finish() + i + 1, right->child(i)); } - for (int i = 0; i <= right->count() - to_move; ++i) { + for (int i = right->start(); i <= right->finish() - to_move; ++i) { assert(i + to_move <= right->max_count()); right->init_child(i, right->child(i + to_move)); right->clear_child(i + to_move); } } - // Fixup the counts on the left and right nodes. - set_count(count() + to_move); - right->set_count(right->count() - to_move); + // Fixup `finish` on the left and right nodes. + set_finish(finish() + to_move); + right->set_finish(right->finish() - to_move); } template <typename P> @@ -1581,11 +1618,11 @@ // the new to_move entries from the parent and left node. // 1) Shift existing values in the right node to their correct positions. - right->uninitialized_move_n(to_move, right->count() - to_move, - right->count(), right, alloc); - for (slot_type *src = right->slot(right->count() - to_move - 1), - *dest = right->slot(right->count() - 1), - *end = right->slot(0); + right->uninitialized_move_n(to_move, right->finish() - to_move, + right->finish(), right, alloc); + for (slot_type *src = right->slot(right->finish() - to_move - 1), + *dest = right->slot(right->finish() - 1), + *end = right->start_slot(); src >= end; --src, --dest) { params_type::move(alloc, src, dest); } @@ -1595,14 +1632,15 @@ right->slot(to_move - 1)); // 3) Move the (to_move - 1) values from the left node to the right node. - params_type::move(alloc, slot(count() - (to_move - 1)), slot(count()), - right->slot(0)); + params_type::move(alloc, slot(finish() - (to_move - 1)), finish_slot(), + right->start_slot()); } else { // The right node does not have enough initialized space to hold the new // to_move entries, so part of them will move to uninitialized space. // 1) Shift existing values in the right node to their correct positions. - right->uninitialized_move_n(right->count(), 0, to_move, right, alloc); + right->uninitialized_move_n(right->count(), right->start(), + right->start() + to_move, right, alloc); // 2) Move the delimiting value in the parent to the right node. right->value_init(to_move - 1, alloc, parent()->slot(position())); @@ -1610,33 +1648,35 @@ // 3) Move the (to_move - 1) values from the left node to the right node. const size_type uninitialized_remaining = to_move - right->count() - 1; uninitialized_move_n(uninitialized_remaining, - count() - uninitialized_remaining, right->count(), + finish() - uninitialized_remaining, right->finish(), right, alloc); - params_type::move(alloc, slot(count() - (to_move - 1)), - slot(count() - uninitialized_remaining), right->slot(0)); + params_type::move(alloc, slot(finish() - (to_move - 1)), + slot(finish() - uninitialized_remaining), + right->start_slot()); } // 4) Move the new delimiting value to the parent from the left node. - params_type::move(alloc, slot(count() - to_move), parent()->slot(position())); + params_type::move(alloc, slot(finish() - to_move), + parent()->slot(position())); // 5) Destroy the now-empty to_move entries in the left node. - value_destroy_n(count() - to_move, to_move, alloc); + value_destroy_n(finish() - to_move, to_move, alloc); if (!leaf()) { // Move the child pointers from the left to the right node. - for (int i = right->count(); i >= 0; --i) { + for (int i = right->finish(); i >= right->start(); --i) { right->init_child(i + to_move, right->child(i)); right->clear_child(i); } for (int i = 1; i <= to_move; ++i) { - right->init_child(i - 1, child(count() - to_move + i)); - clear_child(count() - to_move + i); + right->init_child(i - 1, child(finish() - to_move + i)); + clear_child(finish() - to_move + i); } } // Fixup the counts on the left and right nodes. - set_count(count() - to_move); - right->set_count(right->count() + to_move); + set_finish(finish() - to_move); + right->set_finish(right->finish() + to_move); } template <typename P> @@ -1649,33 +1689,34 @@ // inserting at the beginning of the left node then bias the split to put // more values on the right node. If we're inserting at the end of the // right node then bias the split to put more values on the left node. - if (insert_position == 0) { - dest->set_count(count() - 1); + if (insert_position == start()) { + dest->set_finish(dest->start() + finish() - 1); } else if (insert_position == kNodeValues) { - dest->set_count(0); + dest->set_finish(dest->start()); } else { - dest->set_count(count() / 2); + dest->set_finish(dest->start() + count() / 2); } - set_count(count() - dest->count()); + set_finish(finish() - dest->count()); assert(count() >= 1); // Move values from the left sibling to the right sibling. - uninitialized_move_n(dest->count(), count(), 0, dest, alloc); + uninitialized_move_n(dest->count(), finish(), dest->start(), dest, alloc); // Destroy the now-empty entries in the left node. - value_destroy_n(count(), dest->count(), alloc); + value_destroy_n(finish(), dest->count(), alloc); // The split key is the largest value in the left sibling. - set_count(count() - 1); - parent()->emplace_value(position(), alloc, slot(count())); - value_destroy(count(), alloc); + --mutable_finish(); + parent()->emplace_value(position(), alloc, finish_slot()); + value_destroy(finish(), alloc); parent()->init_child(position() + 1, dest); if (!leaf()) { - for (int i = 0; i <= dest->count(); ++i) { - assert(child(count() + i + 1) != nullptr); - dest->init_child(i, child(count() + i + 1)); - clear_child(count() + i + 1); + for (int i = dest->start(), j = finish() + 1; i <= dest->finish(); + ++i, ++j) { + assert(child(j) != nullptr); + dest->init_child(i, child(j)); + clear_child(j); } } } @@ -1686,74 +1727,77 @@ assert(position() + 1 == src->position()); // Move the delimiting value to the left node. - value_init(count(), alloc, parent()->slot(position())); + value_init(finish(), alloc, parent()->slot(position())); // Move the values from the right to the left node. - src->uninitialized_move_n(src->count(), 0, count() + 1, this, alloc); + src->uninitialized_move_n(src->count(), src->start(), finish() + 1, this, + alloc); // Destroy the now-empty entries in the right node. - src->value_destroy_n(0, src->count(), alloc); + src->value_destroy_n(src->start(), src->count(), alloc); if (!leaf()) { // Move the child pointers from the right to the left node. - for (int i = 0; i <= src->count(); ++i) { - init_child(count() + i + 1, src->child(i)); + for (int i = src->start(), j = finish() + 1; i <= src->finish(); ++i, ++j) { + init_child(j, src->child(i)); src->clear_child(i); } } - // Fixup the counts on the src and dest nodes. - set_count(1 + count() + src->count()); - src->set_count(0); + // Fixup `finish` on the src and dest nodes. + set_finish(start() + 1 + count() + src->count()); + src->set_finish(src->start()); // Remove the value on the parent node. parent()->remove_value(position(), alloc); } template <typename P> -void btree_node<P>::swap(btree_node *x, allocator_type *alloc) { +void btree_node<P>::swap(btree_node *other, allocator_type *alloc) { using std::swap; - assert(leaf() == x->leaf()); + assert(leaf() == other->leaf()); // Determine which is the smaller/larger node. - btree_node *smaller = this, *larger = x; + btree_node *smaller = this, *larger = other; if (smaller->count() > larger->count()) { swap(smaller, larger); } // Swap the values. - for (slot_type *a = smaller->slot(0), *b = larger->slot(0), - *end = a + smaller->count(); + for (slot_type *a = smaller->start_slot(), *b = larger->start_slot(), + *end = smaller->finish_slot(); a != end; ++a, ++b) { params_type::swap(alloc, a, b); } // Move values that can't be swapped. const size_type to_move = larger->count() - smaller->count(); - larger->uninitialized_move_n(to_move, smaller->count(), smaller->count(), + larger->uninitialized_move_n(to_move, smaller->finish(), smaller->finish(), smaller, alloc); - larger->value_destroy_n(smaller->count(), to_move, alloc); + larger->value_destroy_n(smaller->finish(), to_move, alloc); if (!leaf()) { // Swap the child pointers. - std::swap_ranges(&smaller->mutable_child(0), - &smaller->mutable_child(smaller->count() + 1), - &larger->mutable_child(0)); + std::swap_ranges(&smaller->mutable_child(smaller->start()), + &smaller->mutable_child(smaller->finish() + 1), + &larger->mutable_child(larger->start())); // Update swapped children's parent pointers. - int i = 0; - for (; i <= smaller->count(); ++i) { + int i = smaller->start(); + int j = larger->start(); + for (; i <= smaller->finish(); ++i, ++j) { smaller->child(i)->set_parent(smaller); - larger->child(i)->set_parent(larger); + larger->child(j)->set_parent(larger); } // Move the child pointers that couldn't be swapped. - for (; i <= larger->count(); ++i) { - smaller->init_child(i, larger->child(i)); - larger->clear_child(i); + for (; j <= larger->finish(); ++i, ++j) { + smaller->init_child(i, larger->child(j)); + larger->clear_child(j); } } - // Swap the counts. - swap(mutable_count(), x->mutable_count()); + // Swap the `finish`s. + // TODO(ezb): with floating storage, will also need to swap starts. + swap(mutable_finish(), other->mutable_finish()); } //// @@ -1761,23 +1805,23 @@ template <typename N, typename R, typename P> void btree_iterator<N, R, P>::increment_slow() { if (node->leaf()) { - assert(position >= node->count()); + assert(position >= node->finish()); btree_iterator save(*this); - while (position == node->count() && !node->is_root()) { + while (position == node->finish() && !node->is_root()) { assert(node->parent()->child(node->position()) == node); position = node->position(); node = node->parent(); } - if (position == node->count()) { + if (position == node->finish()) { *this = save; } } else { - assert(position < node->count()); + assert(position < node->finish()); node = node->child(position + 1); while (!node->leaf()) { - node = node->child(0); + node = node->start_child(); } - position = 0; + position = node->start(); } } @@ -1786,21 +1830,21 @@ if (node->leaf()) { assert(position <= -1); btree_iterator save(*this); - while (position < 0 && !node->is_root()) { + while (position < node->start() && !node->is_root()) { assert(node->parent()->child(node->position()) == node); position = node->position() - 1; node = node->parent(); } - if (position < 0) { + if (position < node->start()) { *this = save; } } else { - assert(position >= 0); + assert(position >= node->start()); node = node->child(position); while (!node->leaf()) { - node = node->child(node->count()); + node = node->child(node->finish()); } - position = node->count() - 1; + position = node->finish() - 1; } } @@ -1808,7 +1852,7 @@ // btree methods template <typename P> template <typename Btree> -void btree<P>::copy_or_move_values_in_order(Btree *x) { +void btree<P>::copy_or_move_values_in_order(Btree *other) { static_assert(std::is_same<btree, Btree>::value || std::is_same<const btree, Btree>::value, "Btree type must be same or const."); @@ -1816,11 +1860,11 @@ // We can avoid key comparisons because we know the order of the // values is the same order we'll store them in. - auto iter = x->begin(); - if (iter == x->end()) return; + auto iter = other->begin(); + if (iter == other->end()) return; insert_multi(maybe_move_from_iterator(iter)); ++iter; - for (; iter != x->end(); ++iter) { + for (; iter != other->end(); ++iter) { // If the btree is not empty, we can just insert the new value at the end // of the tree. internal_emplace(end(), maybe_move_from_iterator(iter)); @@ -1863,8 +1907,9 @@ : root_(comp, alloc, EmptyNode()), rightmost_(EmptyNode()), size_(0) {} template <typename P> -btree<P>::btree(const btree &x) : btree(x.key_comp(), x.allocator()) { - copy_or_move_values_in_order(&x); +btree<P>::btree(const btree &other) + : btree(other.key_comp(), other.allocator()) { + copy_or_move_values_in_order(&other); } template <typename P> @@ -1900,8 +1945,7 @@ -> std::pair<iterator, bool> { if (!empty()) { if (position == end() || compare_keys(key, position.key())) { - iterator prev = position; - if (position == begin() || compare_keys((--prev).key(), key)) { + if (position == begin() || compare_keys(std::prev(position).key(), key)) { // prev.key() < key < position.key() return {internal_emplace(position, std::forward<Args>(args)...), true}; } @@ -1947,17 +1991,16 @@ if (!empty()) { const key_type &key = params_type::key(v); if (position == end() || !compare_keys(position.key(), key)) { - iterator prev = position; - if (position == begin() || !compare_keys(key, (--prev).key())) { + if (position == begin() || + !compare_keys(key, std::prev(position).key())) { // prev.key() <= key <= position.key() return internal_emplace(position, std::forward<ValueType>(v)); } } else { - iterator next = position; - ++next; - if (next == end() || !compare_keys(next.key(), key)) { - // position.key() < key <= next.key() - return internal_emplace(next, std::forward<ValueType>(v)); + ++position; + if (position == end() || !compare_keys(position.key(), key)) { + // {original `position`}.key() < key < {current `position`}.key() + return internal_emplace(position, std::forward<ValueType>(v)); } } } @@ -1973,46 +2016,47 @@ } template <typename P> -auto btree<P>::operator=(const btree &x) -> btree & { - if (this != &x) { +auto btree<P>::operator=(const btree &other) -> btree & { + if (this != &other) { clear(); - *mutable_key_comp() = x.key_comp(); + *mutable_key_comp() = other.key_comp(); if (absl::allocator_traits< allocator_type>::propagate_on_container_copy_assignment::value) { - *mutable_allocator() = x.allocator(); + *mutable_allocator() = other.allocator(); } - copy_or_move_values_in_order(&x); + copy_or_move_values_in_order(&other); } return *this; } template <typename P> -auto btree<P>::operator=(btree &&x) noexcept -> btree & { - if (this != &x) { +auto btree<P>::operator=(btree &&other) noexcept -> btree & { + if (this != &other) { clear(); using std::swap; if (absl::allocator_traits< allocator_type>::propagate_on_container_copy_assignment::value) { // Note: `root_` also contains the allocator and the key comparator. - swap(root_, x.root_); - swap(rightmost_, x.rightmost_); - swap(size_, x.size_); + swap(root_, other.root_); + swap(rightmost_, other.rightmost_); + swap(size_, other.size_); } else { - if (allocator() == x.allocator()) { - swap(mutable_root(), x.mutable_root()); - swap(*mutable_key_comp(), *x.mutable_key_comp()); - swap(rightmost_, x.rightmost_); - swap(size_, x.size_); + if (allocator() == other.allocator()) { + swap(mutable_root(), other.mutable_root()); + swap(*mutable_key_comp(), *other.mutable_key_comp()); + swap(rightmost_, other.rightmost_); + swap(size_, other.size_); } else { // We aren't allowed to propagate the allocator and the allocator is // different so we can't take over its memory. We must move each element - // individually. We need both `x` and `this` to have `x`s key comparator - // while moving the values so we can't swap the key comparators. - *mutable_key_comp() = x.key_comp(); - copy_or_move_values_in_order(&x); + // individually. We need both `other` and `this` to have `other`s key + // comparator while moving the values so we can't swap the key + // comparators. + *mutable_key_comp() = other.key_comp(); + copy_or_move_values_in_order(&other); } } } @@ -2030,7 +2074,6 @@ iterator internal_iter(iter); --iter; assert(iter.node->leaf()); - assert(!compare_keys(internal_iter.key(), iter.key())); params_type::move(mutable_allocator(), iter.node->slot(iter.position), internal_iter.node->slot(internal_iter.position)); internal_delete = true; @@ -2082,13 +2125,14 @@ if (!merged) { break; } + iter.position = iter.node->position(); iter.node = iter.node->parent(); } // Adjust our return value. If we're pointing at the end of a node, advance // the iterator. - if (res.position == res.node->count()) { - res.position = res.node->count() - 1; + if (res.position == res.node->finish()) { + res.position = res.node->finish() - 1; ++res; } @@ -2096,7 +2140,7 @@ } template <typename P> -auto btree<P>::erase(iterator begin, iterator end) +auto btree<P>::erase_range(iterator begin, iterator end) -> std::pair<size_type, iterator> { difference_type count = std::distance(begin, end); assert(count >= 0); @@ -2120,7 +2164,7 @@ while (size_ > target_size) { if (begin.node->leaf()) { const size_type remaining_to_erase = size_ - target_size; - const size_type remaining_in_node = begin.node->count() - begin.position; + const size_type remaining_in_node = begin.node->finish() - begin.position; begin = erase_from_leaf_node( begin, (std::min)(remaining_to_erase, remaining_in_node)); } else { @@ -2143,7 +2187,8 @@ internal_clear(node->child(begin.position + i + 1)); } // Rotate children after end into new positions. - for (size_type i = begin.position + to_erase + 1; i <= node->count(); ++i) { + for (size_type i = begin.position + to_erase + 1; i <= node->finish(); + ++i) { node->set_child(i - to_erase, node->child(i)); node->clear_child(i); } @@ -2163,8 +2208,8 @@ -> iterator { node_type *node = begin.node; assert(node->leaf()); - assert(node->count() > begin.position); - assert(begin.position + to_erase <= node->count()); + assert(node->finish() > begin.position); + assert(begin.position + to_erase <= node->finish()); node->remove_values_ignore_children(begin.position, to_erase, mutable_allocator()); @@ -2196,7 +2241,7 @@ } // Delete all of the keys between begin and upper_bound(key). const iterator end = internal_end(internal_upper_bound(key)); - return erase(begin, end).first; + return erase_range(begin, end).first; } template <typename P> @@ -2210,20 +2255,20 @@ } template <typename P> -void btree<P>::swap(btree &x) { +void btree<P>::swap(btree &other) { using std::swap; if (absl::allocator_traits< allocator_type>::propagate_on_container_swap::value) { // Note: `root_` also contains the allocator and the key comparator. - swap(root_, x.root_); + swap(root_, other.root_); } else { // It's undefined behavior if the allocators are unequal here. - assert(allocator() == x.allocator()); - swap(mutable_root(), x.mutable_root()); - swap(*mutable_key_comp(), *x.mutable_key_comp()); + assert(allocator() == other.allocator()); + swap(mutable_root(), other.mutable_root()); + swap(*mutable_key_comp(), *other.mutable_key_comp()); } - swap(rightmost_, x.rightmost_); - swap(size_, x.size_); + swap(rightmost_, other.rightmost_); + swap(size_, other.size_); } template <typename P> @@ -2233,7 +2278,7 @@ assert(rightmost_ != nullptr); assert(empty() || size() == internal_verify(root(), nullptr, nullptr)); assert(leftmost() == (++const_iterator(root(), -1)).node); - assert(rightmost_ == (--const_iterator(root(), root()->count())).node); + assert(rightmost_ == (--const_iterator(root(), root()->finish())).node); assert(leftmost()->leaf()); assert(rightmost_->leaf()); } @@ -2248,7 +2293,7 @@ // First try to make room on the node by rebalancing. node_type *parent = node->parent(); if (node != root()) { - if (node->position() > 0) { + if (node->position() > parent->start()) { // Try rebalancing with our left sibling. node_type *left = parent->child(node->position() - 1); assert(left->max_count() == kNodeValues); @@ -2260,13 +2305,13 @@ (1 + (insert_position < kNodeValues)); to_move = (std::max)(1, to_move); - if (((insert_position - to_move) >= 0) || - ((left->count() + to_move) < kNodeValues)) { + if (insert_position - to_move >= node->start() || + left->count() + to_move < kNodeValues) { left->rebalance_right_to_left(to_move, node, mutable_allocator()); assert(node->max_count() - node->count() == to_move); insert_position = insert_position - to_move; - if (insert_position < 0) { + if (insert_position < node->start()) { insert_position = insert_position + left->count() + 1; node = left; } @@ -2277,7 +2322,7 @@ } } - if (node->position() < parent->count()) { + if (node->position() < parent->finish()) { // Try rebalancing with our right sibling. node_type *right = parent->child(node->position() + 1); assert(right->max_count() == kNodeValues); @@ -2285,15 +2330,15 @@ // We bias rebalancing based on the position being inserted. If we're // inserting at the beginning of the left node then we bias rebalancing // to fill up the right node. - int to_move = - (kNodeValues - right->count()) / (1 + (insert_position > 0)); + int to_move = (kNodeValues - right->count()) / + (1 + (insert_position > node->start())); to_move = (std::max)(1, to_move); - if ((insert_position <= (node->count() - to_move)) || - ((right->count() + to_move) < kNodeValues)) { + if (insert_position <= node->finish() - to_move || + right->count() + to_move < kNodeValues) { node->rebalance_left_to_right(to_move, right, mutable_allocator()); - if (insert_position > node->count()) { + if (insert_position > node->finish()) { insert_position = insert_position - node->count() - 1; node = right; } @@ -2316,10 +2361,11 @@ // Create a new root node and set the current root node as the child of the // new root. parent = new_internal_node(parent); - parent->init_child(0, root()); + parent->init_child(parent->start(), root()); mutable_root() = parent; // If the former root was a leaf node, then it's now the rightmost node. - assert(!parent->child(0)->leaf() || parent->child(0) == rightmost_); + assert(!parent->start_child()->leaf() || + parent->start_child() == rightmost_); } // Split the node. @@ -2333,7 +2379,7 @@ node->split(insert_position, split_node, mutable_allocator()); } - if (insert_position > node->count()) { + if (insert_position > node->finish()) { insert_position = insert_position - node->count() - 1; node = split_node; } @@ -2353,22 +2399,22 @@ template <typename P> bool btree<P>::try_merge_or_rebalance(iterator *iter) { node_type *parent = iter->node->parent(); - if (iter->node->position() > 0) { + if (iter->node->position() > parent->start()) { // Try merging with our left sibling. node_type *left = parent->child(iter->node->position() - 1); assert(left->max_count() == kNodeValues); - if ((1 + left->count() + iter->node->count()) <= kNodeValues) { + if (1 + left->count() + iter->node->count() <= kNodeValues) { iter->position += 1 + left->count(); merge_nodes(left, iter->node); iter->node = left; return true; } } - if (iter->node->position() < parent->count()) { + if (iter->node->position() < parent->finish()) { // Try merging with our right sibling. node_type *right = parent->child(iter->node->position() + 1); assert(right->max_count() == kNodeValues); - if ((1 + iter->node->count() + right->count()) <= kNodeValues) { + if (1 + iter->node->count() + right->count() <= kNodeValues) { merge_nodes(iter->node, right); return true; } @@ -2376,24 +2422,22 @@ // we deleted the first element from iter->node and the node is not // empty. This is a small optimization for the common pattern of deleting // from the front of the tree. - if ((right->count() > kMinNodeValues) && - ((iter->node->count() == 0) || - (iter->position > 0))) { + if (right->count() > kMinNodeValues && + (iter->node->count() == 0 || iter->position > iter->node->start())) { int to_move = (right->count() - iter->node->count()) / 2; to_move = (std::min)(to_move, right->count() - 1); iter->node->rebalance_right_to_left(to_move, right, mutable_allocator()); return false; } } - if (iter->node->position() > 0) { + if (iter->node->position() > parent->start()) { // Try rebalancing with our left sibling. We don't perform rebalancing if // we deleted the last element from iter->node and the node is not // empty. This is a small optimization for the common pattern of deleting // from the back of the tree. node_type *left = parent->child(iter->node->position() - 1); - if ((left->count() > kMinNodeValues) && - ((iter->node->count() == 0) || - (iter->position < iter->node->count()))) { + if (left->count() > kMinNodeValues && + (iter->node->count() == 0 || iter->position < iter->node->finish())) { int to_move = (left->count() - iter->node->count()) / 2; to_move = (std::min)(to_move, left->count() - 1); left->rebalance_left_to_right(to_move, iter->node, mutable_allocator()); @@ -2413,10 +2457,9 @@ if (root()->leaf()) { assert(size() == 0); delete_leaf_node(root()); - mutable_root() = EmptyNode(); - rightmost_ = EmptyNode(); + mutable_root() = rightmost_ = EmptyNode(); } else { - node_type *child = root()->child(0); + node_type *child = root()->start_child(); child->make_root(); delete_internal_node(root()); mutable_root() = child; @@ -2427,7 +2470,7 @@ template <typename IterType> inline IterType btree<P>::internal_last(IterType iter) { assert(iter.node != nullptr); - while (iter.position == iter.node->count()) { + while (iter.position == iter.node->finish()) { iter.position = iter.node->position(); iter.node = iter.node->parent(); if (iter.node->leaf()) { @@ -2459,8 +2502,7 @@ new_leaf_root_node((std::min<int>)(kNodeValues, 2 * max_count)); iter.node->swap(root(), mutable_allocator()); delete_leaf_node(root()); - mutable_root() = iter.node; - rightmost_ = iter.node; + mutable_root() = rightmost_ = iter.node; } else { rebalance_or_split(&iter); } @@ -2483,7 +2525,7 @@ inline auto btree<P>::internal_locate_impl( const K &key, std::false_type /* IsCompareTo */) const -> SearchResult<iterator, false> { - iterator iter(const_cast<node_type *>(root()), 0); + iterator iter(const_cast<node_type *>(root())); for (;;) { iter.position = iter.node->lower_bound(key, key_comp()).value; // NOTE: we don't need to walk all the way down the tree if the keys are @@ -2503,7 +2545,7 @@ inline auto btree<P>::internal_locate_impl( const K &key, std::true_type /* IsCompareTo */) const -> SearchResult<iterator, true> { - iterator iter(const_cast<node_type *>(root()), 0); + iterator iter(const_cast<node_type *>(root())); for (;;) { SearchResult<int, true> res = iter.node->lower_bound(key, key_comp()); iter.position = res.value; @@ -2521,7 +2563,7 @@ template <typename P> template <typename K> auto btree<P>::internal_lower_bound(const K &key) const -> iterator { - iterator iter(const_cast<node_type *>(root()), 0); + iterator iter(const_cast<node_type *>(root())); for (;;) { iter.position = iter.node->lower_bound(key, key_comp()).value; if (iter.node->leaf()) { @@ -2535,7 +2577,7 @@ template <typename P> template <typename K> auto btree<P>::internal_upper_bound(const K &key) const -> iterator { - iterator iter(const_cast<node_type *>(root()), 0); + iterator iter(const_cast<node_type *>(root())); for (;;) { iter.position = iter.node->upper_bound(key, key_comp()); if (iter.node->leaf()) { @@ -2566,7 +2608,7 @@ template <typename P> void btree<P>::internal_clear(node_type *node) { if (!node->leaf()) { - for (int i = 0; i <= node->count(); ++i) { + for (int i = node->start(); i <= node->finish(); ++i) { internal_clear(node->child(i)); } delete_internal_node(node); @@ -2576,35 +2618,35 @@ } template <typename P> -int btree<P>::internal_verify( - const node_type *node, const key_type *lo, const key_type *hi) const { +int btree<P>::internal_verify(const node_type *node, const key_type *lo, + const key_type *hi) const { assert(node->count() > 0); assert(node->count() <= node->max_count()); if (lo) { - assert(!compare_keys(node->key(0), *lo)); + assert(!compare_keys(node->key(node->start()), *lo)); } if (hi) { - assert(!compare_keys(*hi, node->key(node->count() - 1))); + assert(!compare_keys(*hi, node->key(node->finish() - 1))); } - for (int i = 1; i < node->count(); ++i) { + for (int i = node->start() + 1; i < node->finish(); ++i) { assert(!compare_keys(node->key(i), node->key(i - 1))); } int count = node->count(); if (!node->leaf()) { - for (int i = 0; i <= node->count(); ++i) { + for (int i = node->start(); i <= node->finish(); ++i) { assert(node->child(i) != nullptr); assert(node->child(i)->parent() == node); assert(node->child(i)->position() == i); - count += internal_verify( - node->child(i), - (i == 0) ? lo : &node->key(i - 1), - (i == node->count()) ? hi : &node->key(i)); + count += internal_verify(node->child(i), + i == node->start() ? lo : &node->key(i - 1), + i == node->finish() ? hi : &node->key(i)); } } return count; } } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_BTREE_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/btree_container.h b/third_party/abseil-cpp/absl/container/internal/btree_container.h index 726861d5..734c90ef 100644 --- a/third_party/abseil-cpp/absl/container/internal/btree_container.h +++ b/third_party/abseil-cpp/absl/container/internal/btree_container.h
@@ -26,6 +26,7 @@ #include "absl/meta/type_traits.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { // A common base class for btree_set, btree_map, btree_multiset, and @@ -67,10 +68,10 @@ explicit btree_container(const key_compare &comp, const allocator_type &alloc = allocator_type()) : tree_(comp, alloc) {} - btree_container(const btree_container &x) = default; - btree_container(btree_container &&x) noexcept = default; - btree_container &operator=(const btree_container &x) = default; - btree_container &operator=(btree_container &&x) noexcept( + btree_container(const btree_container &other) = default; + btree_container(btree_container &&other) noexcept = default; + btree_container &operator=(const btree_container &other) = default; + btree_container &operator=(btree_container &&other) noexcept( std::is_nothrow_move_assignable<Tree>::value) = default; // Iterator routines. @@ -135,7 +136,7 @@ iterator erase(const_iterator iter) { return tree_.erase(iterator(iter)); } iterator erase(iterator iter) { return tree_.erase(iter); } iterator erase(const_iterator first, const_iterator last) { - return tree_.erase(iterator(first), iterator(last)).second; + return tree_.erase_range(iterator(first), iterator(last)).second; } // Extract routines. @@ -153,7 +154,7 @@ public: // Utility routines. void clear() { tree_.clear(); } - void swap(btree_container &x) { tree_.swap(x.tree_); } + void swap(btree_container &other) { tree_.swap(other.tree_); } void verify() const { tree_.verify(); } // Size routines. @@ -256,26 +257,26 @@ } // Insertion routines. - std::pair<iterator, bool> insert(const value_type &x) { - return this->tree_.insert_unique(params_type::key(x), x); + std::pair<iterator, bool> insert(const value_type &v) { + return this->tree_.insert_unique(params_type::key(v), v); } - std::pair<iterator, bool> insert(value_type &&x) { - return this->tree_.insert_unique(params_type::key(x), std::move(x)); + std::pair<iterator, bool> insert(value_type &&v) { + return this->tree_.insert_unique(params_type::key(v), std::move(v)); } template <typename... Args> std::pair<iterator, bool> emplace(Args &&... args) { init_type v(std::forward<Args>(args)...); return this->tree_.insert_unique(params_type::key(v), std::move(v)); } - iterator insert(const_iterator position, const value_type &x) { + iterator insert(const_iterator position, const value_type &v) { return this->tree_ - .insert_hint_unique(iterator(position), params_type::key(x), x) + .insert_hint_unique(iterator(position), params_type::key(v), v) .first; } - iterator insert(const_iterator position, value_type &&x) { + iterator insert(const_iterator position, value_type &&v) { return this->tree_ - .insert_hint_unique(iterator(position), params_type::key(x), - std::move(x)) + .insert_hint_unique(iterator(position), params_type::key(v), + std::move(v)) .first; } template <typename... Args> @@ -296,9 +297,10 @@ insert_return_type insert(node_type &&node) { if (!node) return {this->end(), false, node_type()}; std::pair<iterator, bool> res = - insert(std::move(params_type::element(CommonAccess::GetSlot(node)))); + this->tree_.insert_unique(params_type::key(CommonAccess::GetSlot(node)), + CommonAccess::GetSlot(node)); if (res.second) { - CommonAccess::Reset(&node); + CommonAccess::Destroy(&node); return {res.first, true, node_type()}; } else { return {res.first, false, std::move(node)}; @@ -308,8 +310,8 @@ if (!node) return this->end(); std::pair<iterator, bool> res = this->tree_.insert_hint_unique( iterator(hint), params_type::key(CommonAccess::GetSlot(node)), - std::move(params_type::element(CommonAccess::GetSlot(node)))); - if (res.second) CommonAccess::Reset(&node); + CommonAccess::GetSlot(node)); + if (res.second) CommonAccess::Destroy(&node); return res.first; } @@ -323,7 +325,7 @@ // Node extraction routines. template <typename K = key_type> node_type extract(const key_arg<K> &key) { - auto it = find(key); + auto it = this->find(key); return it == this->end() ? node_type() : extract(it); } using super_type::extract; @@ -370,7 +372,7 @@ using super_type = btree_set_container<Tree>; using params_type = typename Tree::params_type; - protected: + private: template <class K> using key_arg = typename super_type::template key_arg<K>; @@ -388,6 +390,69 @@ btree_map_container() {} // Insertion routines. + // Note: the nullptr template arguments and extra `const M&` overloads allow + // for supporting bitfield arguments. + // Note: when we call `std::forward<M>(obj)` twice, it's safe because + // insert_unique/insert_hint_unique are guaranteed to not consume `obj` when + // `ret.second` is false. + template <class M> + std::pair<iterator, bool> insert_or_assign(const key_type &k, const M &obj) { + const std::pair<iterator, bool> ret = this->tree_.insert_unique(k, k, obj); + if (!ret.second) ret.first->second = obj; + return ret; + } + template <class M, key_type * = nullptr> + std::pair<iterator, bool> insert_or_assign(key_type &&k, const M &obj) { + const std::pair<iterator, bool> ret = + this->tree_.insert_unique(k, std::move(k), obj); + if (!ret.second) ret.first->second = obj; + return ret; + } + template <class M, M * = nullptr> + std::pair<iterator, bool> insert_or_assign(const key_type &k, M &&obj) { + const std::pair<iterator, bool> ret = + this->tree_.insert_unique(k, k, std::forward<M>(obj)); + if (!ret.second) ret.first->second = std::forward<M>(obj); + return ret; + } + template <class M, key_type * = nullptr, M * = nullptr> + std::pair<iterator, bool> insert_or_assign(key_type &&k, M &&obj) { + const std::pair<iterator, bool> ret = + this->tree_.insert_unique(k, std::move(k), std::forward<M>(obj)); + if (!ret.second) ret.first->second = std::forward<M>(obj); + return ret; + } + template <class M> + iterator insert_or_assign(const_iterator position, const key_type &k, + const M &obj) { + const std::pair<iterator, bool> ret = + this->tree_.insert_hint_unique(iterator(position), k, k, obj); + if (!ret.second) ret.first->second = obj; + return ret.first; + } + template <class M, key_type * = nullptr> + iterator insert_or_assign(const_iterator position, key_type &&k, + const M &obj) { + const std::pair<iterator, bool> ret = this->tree_.insert_hint_unique( + iterator(position), k, std::move(k), obj); + if (!ret.second) ret.first->second = obj; + return ret.first; + } + template <class M, M * = nullptr> + iterator insert_or_assign(const_iterator position, const key_type &k, + M &&obj) { + const std::pair<iterator, bool> ret = this->tree_.insert_hint_unique( + iterator(position), k, k, std::forward<M>(obj)); + if (!ret.second) ret.first->second = std::forward<M>(obj); + return ret.first; + } + template <class M, key_type * = nullptr, M * = nullptr> + iterator insert_or_assign(const_iterator position, key_type &&k, M &&obj) { + const std::pair<iterator, bool> ret = this->tree_.insert_hint_unique( + iterator(position), k, std::move(k), std::forward<M>(obj)); + if (!ret.second) ret.first->second = std::forward<M>(obj); + return ret.first; + } template <typename... Args> std::pair<iterator, bool> try_emplace(const key_type &k, Args &&... args) { return this->tree_.insert_unique( @@ -400,7 +465,7 @@ // and then using `k` unsequenced. This is safe because the move is into a // forwarding reference and insert_unique guarantees that `key` is never // referenced after consuming `args`. - const key_type& key_ref = k; + const key_type &key_ref = k; return this->tree_.insert_unique( key_ref, std::piecewise_construct, std::forward_as_tuple(std::move(k)), std::forward_as_tuple(std::forward<Args>(args)...)); @@ -420,7 +485,7 @@ // and then using `k` unsequenced. This is safe because the move is into a // forwarding reference and insert_hint_unique guarantees that `key` is // never referenced after consuming `args`. - const key_type& key_ref = k; + const key_type &key_ref = k; return this->tree_ .insert_hint_unique(iterator(hint), key_ref, std::piecewise_construct, std::forward_as_tuple(std::move(k)), @@ -497,15 +562,15 @@ } // Insertion routines. - iterator insert(const value_type &x) { return this->tree_.insert_multi(x); } - iterator insert(value_type &&x) { - return this->tree_.insert_multi(std::move(x)); + iterator insert(const value_type &v) { return this->tree_.insert_multi(v); } + iterator insert(value_type &&v) { + return this->tree_.insert_multi(std::move(v)); } - iterator insert(const_iterator position, const value_type &x) { - return this->tree_.insert_hint_multi(iterator(position), x); + iterator insert(const_iterator position, const value_type &v) { + return this->tree_.insert_hint_multi(iterator(position), v); } - iterator insert(const_iterator position, value_type &&x) { - return this->tree_.insert_hint_multi(iterator(position), std::move(x)); + iterator insert(const_iterator position, value_type &&v) { + return this->tree_.insert_hint_multi(iterator(position), std::move(v)); } template <typename InputIterator> void insert(InputIterator b, InputIterator e) { @@ -523,24 +588,21 @@ return this->tree_.insert_hint_multi( iterator(position), init_type(std::forward<Args>(args)...)); } - - private: - template <typename... Args> - iterator insert_node_helper(node_type &&node, Args &&... args) { + iterator insert(node_type &&node) { if (!node) return this->end(); iterator res = - insert(std::forward<Args>(args)..., - std::move(params_type::element(CommonAccess::GetSlot(node)))); - CommonAccess::Reset(&node); + this->tree_.insert_multi(params_type::key(CommonAccess::GetSlot(node)), + CommonAccess::GetSlot(node)); + CommonAccess::Destroy(&node); return res; } - - public: - iterator insert(node_type &&node) { - return insert_node_helper(std::move(node)); - } iterator insert(const_iterator hint, node_type &&node) { - return insert_node_helper(std::move(node), hint); + if (!node) return this->end(); + iterator res = this->tree_.insert_hint_multi( + iterator(hint), + std::move(params_type::element(CommonAccess::GetSlot(node)))); + CommonAccess::Destroy(&node); + return res; } // Deletion routines. @@ -553,7 +615,7 @@ // Node extraction routines. template <typename K = key_type> node_type extract(const key_arg<K> &key) { - auto it = find(key); + auto it = this->find(key); return it == this->end() ? node_type() : extract(it); } using super_type::extract; @@ -604,6 +666,7 @@ }; } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_BTREE_CONTAINER_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/common.h b/third_party/abseil-cpp/absl/container/internal/common.h index 591d3ea..5037d80 100644 --- a/third_party/abseil-cpp/absl/container/internal/common.h +++ b/third_party/abseil-cpp/absl/container/internal/common.h
@@ -22,6 +22,7 @@ #include "absl/types/optional.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class, class = void> @@ -55,7 +56,7 @@ public: using allocator_type = Alloc; - constexpr node_handle_base() {} + constexpr node_handle_base() = default; node_handle_base(node_handle_base&& other) noexcept { *this = std::move(other); } @@ -108,16 +109,15 @@ allocator_type* alloc() { return std::addressof(*alloc_); } private: - absl::optional<allocator_type> alloc_; - mutable absl::aligned_storage_t<sizeof(slot_type), alignof(slot_type)> - slot_space_; + absl::optional<allocator_type> alloc_ = {}; + alignas(slot_type) mutable unsigned char slot_space_[sizeof(slot_type)] = {}; }; // For sets. template <typename Policy, typename PolicyTraits, typename Alloc, typename = void> class node_handle : public node_handle_base<PolicyTraits, Alloc> { - using Base = typename node_handle::node_handle_base; + using Base = node_handle_base<PolicyTraits, Alloc>; public: using value_type = typename PolicyTraits::value_type; @@ -137,7 +137,7 @@ class node_handle<Policy, PolicyTraits, Alloc, absl::void_t<typename Policy::mapped_type>> : public node_handle_base<PolicyTraits, Alloc> { - using Base = typename node_handle::node_handle_base; + using Base = node_handle_base<PolicyTraits, Alloc>; public: using key_type = typename Policy::key_type; @@ -167,6 +167,11 @@ } template <typename Node> + static void Destroy(Node* node) { + node->destroy(); + } + + template <typename Node> static void Reset(Node* node) { node->reset(); } @@ -191,6 +196,7 @@ }; } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_CONTAINER_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h b/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h index 7d08e370..02bfd03f 100644 --- a/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +++ b/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h
@@ -48,6 +48,7 @@ #endif namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <typename... Ts> @@ -168,9 +169,33 @@ } template <typename T, typename V> -using TupleMoveConstructible = typename std::conditional< - std::is_reference<T>::value, std::is_convertible<V, T>, - std::is_constructible<T, V&&>>::type; +using TupleElementMoveConstructible = + typename std::conditional<std::is_reference<T>::value, + std::is_convertible<V, T>, + std::is_constructible<T, V&&>>::type; + +template <bool SizeMatches, class T, class... Vs> +struct TupleMoveConstructible : std::false_type {}; + +template <class... Ts, class... Vs> +struct TupleMoveConstructible<true, CompressedTuple<Ts...>, Vs...> + : std::integral_constant< + bool, absl::conjunction< + TupleElementMoveConstructible<Ts, Vs&&>...>::value> {}; + +template <typename T> +struct compressed_tuple_size; + +template <typename... Es> +struct compressed_tuple_size<CompressedTuple<Es...>> + : public std::integral_constant<std::size_t, sizeof...(Es)> {}; + +template <class T, class... Vs> +struct TupleItemsMoveConstructible + : std::integral_constant< + bool, TupleMoveConstructible<compressed_tuple_size<T>::value == + sizeof...(Vs), + T, Vs...>::value> {}; } // namespace internal_compressed_tuple @@ -216,17 +241,18 @@ explicit constexpr CompressedTuple(const Ts&... base) : CompressedTuple::CompressedTupleImpl(absl::in_place, base...) {} - template <typename... Vs, + template <typename First, typename... Vs, absl::enable_if_t< absl::conjunction< // Ensure we are not hiding default copy/move constructors. absl::negation<std::is_same<void(CompressedTuple), - void(absl::decay_t<Vs>...)>>, - internal_compressed_tuple::TupleMoveConstructible< - Ts, Vs&&>...>::value, + void(absl::decay_t<First>)>>, + internal_compressed_tuple::TupleItemsMoveConstructible< + CompressedTuple<Ts...>, First, Vs...>>::value, bool> = true> - explicit constexpr CompressedTuple(Vs&&... base) + explicit constexpr CompressedTuple(First&& first, Vs&&... base) : CompressedTuple::CompressedTupleImpl(absl::in_place, + absl::forward<First>(first), absl::forward<Vs>(base)...) {} template <int I> @@ -256,6 +282,7 @@ class ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC CompressedTuple<> {}; } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #undef ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC
diff --git a/third_party/abseil-cpp/absl/container/internal/compressed_tuple_test.cc b/third_party/abseil-cpp/absl/container/internal/compressed_tuple_test.cc index 19af8f1..62a7483 100644 --- a/third_party/abseil-cpp/absl/container/internal/compressed_tuple_test.cc +++ b/third_party/abseil-cpp/absl/container/internal/compressed_tuple_test.cc
@@ -48,6 +48,7 @@ namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { @@ -276,11 +277,11 @@ TEST(CompressedTupleTest, Reference) { int i = 7; - std::string s = "Very long std::string that goes in the heap"; + std::string s = "Very long string that goes in the heap"; CompressedTuple<int, int&, std::string, std::string&> x(i, i, s, s); // Sanity check. We should have not moved from `s` - EXPECT_EQ(s, "Very long std::string that goes in the heap"); + EXPECT_EQ(s, "Very long string that goes in the heap"); EXPECT_EQ(x.get<0>(), x.get<1>()); EXPECT_NE(&x.get<0>(), &x.get<1>()); @@ -332,10 +333,6 @@ a = 0.5f; EXPECT_EQ(absl::any_cast<float>(x.get<1>()), 0.5); - - // Ensure copy construction work in the face of a type with a universal - // implicit constructor; - CompressedTuple<absl::any> c{}, d(c); // NOLINT } TEST(CompressedTupleTest, Constexpr) { @@ -408,4 +405,5 @@ } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/container_memory.h b/third_party/abseil-cpp/absl/container/internal/container_memory.h index e5bb977..d24b0f8 100644 --- a/third_party/abseil-cpp/absl/container/internal/container_memory.h +++ b/third_party/abseil-cpp/absl/container/internal/container_memory.h
@@ -34,6 +34,7 @@ #include "absl/utility/utility.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { // Allocates at least n bytes aligned to the specified alignment. @@ -433,6 +434,7 @@ }; } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_CONTAINER_MEMORY_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/container_memory_test.cc b/third_party/abseil-cpp/absl/container/internal/container_memory_test.cc index d6b0495..7942c7b 100644 --- a/third_party/abseil-cpp/absl/container/internal/container_memory_test.cc +++ b/third_party/abseil-cpp/absl/container/internal/container_memory_test.cc
@@ -23,6 +23,7 @@ #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { @@ -185,4 +186,5 @@ } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/counting_allocator.h b/third_party/abseil-cpp/absl/container/internal/counting_allocator.h index 4e717be..9efdc66 100644 --- a/third_party/abseil-cpp/absl/container/internal/counting_allocator.h +++ b/third_party/abseil-cpp/absl/container/internal/counting_allocator.h
@@ -19,7 +19,10 @@ #include <cstdint> #include <memory> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { // This is a stateful allocator, but the state lives outside of the @@ -74,6 +77,7 @@ }; } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_COUNTING_ALLOCATOR_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h b/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h index cb8f03c8..0683422 100644 --- a/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +++ b/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h
@@ -53,9 +53,11 @@ #include "absl/base/config.h" #include "absl/hash/hash.h" +#include "absl/strings/cord.h" #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { // The hash of an object of type T is computed by using absl::Hash. @@ -71,6 +73,9 @@ size_t operator()(absl::string_view v) const { return absl::Hash<absl::string_view>{}(v); } + size_t operator()(const absl::Cord& v) const { + return absl::Hash<absl::Cord>{}(v); + } }; // Supports heterogeneous lookup for string-like elements. @@ -81,6 +86,15 @@ bool operator()(absl::string_view lhs, absl::string_view rhs) const { return lhs == rhs; } + bool operator()(const absl::Cord& lhs, const absl::Cord& rhs) const { + return lhs == rhs; + } + bool operator()(const absl::Cord& lhs, absl::string_view rhs) const { + return lhs == rhs; + } + bool operator()(absl::string_view lhs, const absl::Cord& rhs) const { + return lhs == rhs; + } }; }; @@ -88,6 +102,8 @@ struct HashEq<std::string> : StringHashEq {}; template <> struct HashEq<absl::string_view> : StringHashEq {}; +template <> +struct HashEq<absl::Cord> : StringHashEq {}; // Supports heterogeneous lookup for pointers and smart pointers. template <class T> @@ -139,6 +155,7 @@ using hash_default_eq = typename container_internal::HashEq<T>::Eq; } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_HASH_FUNCTION_DEFAULTS_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/hash_function_defaults_test.cc b/third_party/abseil-cpp/absl/container/internal/hash_function_defaults_test.cc index 82708dbe..2d05a0b7 100644 --- a/third_party/abseil-cpp/absl/container/internal/hash_function_defaults_test.cc +++ b/third_party/abseil-cpp/absl/container/internal/hash_function_defaults_test.cc
@@ -19,9 +19,13 @@ #include <utility> #include "gtest/gtest.h" +#include "absl/random/random.h" +#include "absl/strings/cord.h" +#include "absl/strings/cord_test_helpers.h" #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { @@ -202,10 +206,91 @@ EXPECT_NE(hash(&dummy), hash(cuptr)); } +TEST(EqCord, Works) { + hash_default_eq<absl::Cord> eq; + const absl::string_view a_string_view = "a"; + const absl::Cord a_cord(a_string_view); + const absl::string_view b_string_view = "b"; + const absl::Cord b_cord(b_string_view); + + EXPECT_TRUE(eq(a_cord, a_cord)); + EXPECT_TRUE(eq(a_cord, a_string_view)); + EXPECT_TRUE(eq(a_string_view, a_cord)); + EXPECT_FALSE(eq(a_cord, b_cord)); + EXPECT_FALSE(eq(a_cord, b_string_view)); + EXPECT_FALSE(eq(b_string_view, a_cord)); +} + +TEST(HashCord, Works) { + hash_default_hash<absl::Cord> hash; + const absl::string_view a_string_view = "a"; + const absl::Cord a_cord(a_string_view); + const absl::string_view b_string_view = "b"; + const absl::Cord b_cord(b_string_view); + + EXPECT_EQ(hash(a_cord), hash(a_cord)); + EXPECT_EQ(hash(b_cord), hash(b_cord)); + EXPECT_EQ(hash(a_string_view), hash(a_cord)); + EXPECT_EQ(hash(b_string_view), hash(b_cord)); + EXPECT_EQ(hash(absl::Cord("")), hash("")); + EXPECT_EQ(hash(absl::Cord()), hash(absl::string_view())); + + EXPECT_NE(hash(a_cord), hash(b_cord)); + EXPECT_NE(hash(a_cord), hash(b_string_view)); + EXPECT_NE(hash(a_string_view), hash(b_cord)); + EXPECT_NE(hash(a_string_view), hash(b_string_view)); +} + +void NoOpReleaser(absl::string_view data, void* arg) {} + +TEST(HashCord, FragmentedCordWorks) { + hash_default_hash<absl::Cord> hash; + absl::Cord c = absl::MakeFragmentedCord({"a", "b", "c"}); + EXPECT_FALSE(c.TryFlat().has_value()); + EXPECT_EQ(hash(c), hash("abc")); +} + +TEST(HashCord, FragmentedLongCordWorks) { + hash_default_hash<absl::Cord> hash; + // Crete some large strings which do not fit on the stack. + std::string a(65536, 'a'); + std::string b(65536, 'b'); + absl::Cord c = absl::MakeFragmentedCord({a, b}); + EXPECT_FALSE(c.TryFlat().has_value()); + EXPECT_EQ(hash(c), hash(a + b)); +} + +TEST(HashCord, RandomCord) { + hash_default_hash<absl::Cord> hash; + auto bitgen = absl::BitGen(); + for (int i = 0; i < 1000; ++i) { + const int number_of_segments = absl::Uniform(bitgen, 0, 10); + std::vector<std::string> pieces; + for (size_t s = 0; s < number_of_segments; ++s) { + std::string str; + str.resize(absl::Uniform(bitgen, 0, 4096)); + // MSVC needed the explicit return type in the lambda. + std::generate(str.begin(), str.end(), [&]() -> char { + return static_cast<char>(absl::Uniform<unsigned char>(bitgen)); + }); + pieces.push_back(str); + } + absl::Cord c = absl::MakeFragmentedCord(pieces); + EXPECT_EQ(hash(c), hash(std::string(c))); + } +} + // Cartesian product of (std::string, absl::string_view) -// with (std::string, absl::string_view, const char*). +// with (std::string, absl::string_view, const char*, absl::Cord). using StringTypesCartesianProduct = Types< // clang-format off + std::pair<absl::Cord, std::string>, + std::pair<absl::Cord, absl::string_view>, + std::pair<absl::Cord, absl::Cord>, + std::pair<absl::Cord, const char*>, + + std::pair<std::string, absl::Cord>, + std::pair<absl::string_view, absl::Cord>, std::pair<absl::string_view, std::string>, std::pair<absl::string_view, absl::string_view>, @@ -248,6 +333,7 @@ } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl enum Hash : size_t { @@ -278,6 +364,7 @@ } // namespace std namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { @@ -292,4 +379,5 @@ } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/hash_generator_testing.cc b/third_party/abseil-cpp/absl/container/internal/hash_generator_testing.cc index 37a23d6..75c4db6c 100644 --- a/third_party/abseil-cpp/absl/container/internal/hash_generator_testing.cc +++ b/third_party/abseil-cpp/absl/container/internal/hash_generator_testing.cc
@@ -17,6 +17,7 @@ #include <deque> namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace hash_internal { namespace { @@ -69,4 +70,5 @@ } // namespace hash_internal } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/hash_generator_testing.h b/third_party/abseil-cpp/absl/container/internal/hash_generator_testing.h index 27fb84f5d0..6869fe4 100644 --- a/third_party/abseil-cpp/absl/container/internal/hash_generator_testing.h +++ b/third_party/abseil-cpp/absl/container/internal/hash_generator_testing.h
@@ -19,6 +19,7 @@ #define ABSL_CONTAINER_INTERNAL_HASH_GENERATOR_TESTING_H_ #include <stdint.h> + #include <algorithm> #include <iosfwd> #include <random> @@ -27,10 +28,12 @@ #include <utility> #include "absl/container/internal/hash_policy_testing.h" +#include "absl/memory/memory.h" #include "absl/meta/type_traits.h" #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace hash_internal { namespace generator_internal { @@ -129,6 +132,13 @@ } }; +template <class T> +struct Generator<std::unique_ptr<T>> { + std::unique_ptr<T> operator()() const { + return absl::make_unique<T>(Generator<T>()()); + } +}; + template <class U> struct Generator<U, absl::void_t<decltype(std::declval<U&>().key()), decltype(std::declval<U&>().value())>> @@ -145,6 +155,7 @@ } // namespace hash_internal } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_HASH_GENERATOR_TESTING_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/hash_policy_testing.h b/third_party/abseil-cpp/absl/container/internal/hash_policy_testing.h index c57407a..01c40d2 100644 --- a/third_party/abseil-cpp/absl/container/internal/hash_policy_testing.h +++ b/third_party/abseil-cpp/absl/container/internal/hash_policy_testing.h
@@ -30,6 +30,7 @@ #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace hash_testing_internal { @@ -162,6 +163,7 @@ } } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl // ABSL_UNORDERED_SUPPORTS_ALLOC_CTORS is false for glibcxx versions
diff --git a/third_party/abseil-cpp/absl/container/internal/hash_policy_testing_test.cc b/third_party/abseil-cpp/absl/container/internal/hash_policy_testing_test.cc index 0c95eb5..f0b20fe3 100644 --- a/third_party/abseil-cpp/absl/container/internal/hash_policy_testing_test.cc +++ b/third_party/abseil-cpp/absl/container/internal/hash_policy_testing_test.cc
@@ -17,6 +17,7 @@ #include "gtest/gtest.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { @@ -40,4 +41,5 @@ } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h b/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h index fd007de..3e1209c 100644 --- a/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +++ b/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h
@@ -23,6 +23,7 @@ #include "absl/meta/type_traits.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { // Defines how slots are initialized/destroyed/moved. @@ -184,6 +185,7 @@ }; } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_HASH_POLICY_TRAITS_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/hash_policy_traits_test.cc b/third_party/abseil-cpp/absl/container/internal/hash_policy_traits_test.cc index e643d18..6ef8b9e0 100644 --- a/third_party/abseil-cpp/absl/container/internal/hash_policy_traits_test.cc +++ b/third_party/abseil-cpp/absl/container/internal/hash_policy_traits_test.cc
@@ -22,6 +22,7 @@ #include "gtest/gtest.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { @@ -139,4 +140,5 @@ } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/hashtable_debug.h b/third_party/abseil-cpp/absl/container/internal/hashtable_debug.h index 71930004..19d52121 100644 --- a/third_party/abseil-cpp/absl/container/internal/hashtable_debug.h +++ b/third_party/abseil-cpp/absl/container/internal/hashtable_debug.h
@@ -38,6 +38,7 @@ #include "absl/container/internal/hashtable_debug_hooks.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { // Returns the number of probes required to lookup `key`. Returns 0 for a @@ -103,6 +104,7 @@ } } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_HASHTABLE_DEBUG_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/hashtable_debug_hooks.h b/third_party/abseil-cpp/absl/container/internal/hashtable_debug_hooks.h index 371ce81..3e9ea59 100644 --- a/third_party/abseil-cpp/absl/container/internal/hashtable_debug_hooks.h +++ b/third_party/abseil-cpp/absl/container/internal/hashtable_debug_hooks.h
@@ -23,7 +23,10 @@ #include <type_traits> #include <vector> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace hashtable_debug_internal { @@ -76,6 +79,7 @@ } // namespace hashtable_debug_internal } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_HASHTABLE_DEBUG_HOOKS_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc b/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc index d03dd82..886524f 100644 --- a/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +++ b/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc
@@ -21,12 +21,14 @@ #include <limits> #include "absl/base/attributes.h" +#include "absl/base/internal/exponential_biased.h" #include "absl/container/internal/have_sse.h" #include "absl/debugging/stacktrace.h" #include "absl/memory/memory.h" #include "absl/synchronization/mutex.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { constexpr int HashtablezInfo::kMaxStackDepth; @@ -37,80 +39,17 @@ ABSL_CONST_INIT std::atomic<int32_t> g_hashtablez_sample_parameter{1 << 10}; ABSL_CONST_INIT std::atomic<int32_t> g_hashtablez_max_samples{1 << 20}; -// Returns the next pseudo-random value. -// pRNG is: aX+b mod c with a = 0x5DEECE66D, b = 0xB, c = 1<<48 -// This is the lrand64 generator. -uint64_t NextRandom(uint64_t rnd) { - const uint64_t prng_mult = uint64_t{0x5DEECE66D}; - const uint64_t prng_add = 0xB; - const uint64_t prng_mod_power = 48; - const uint64_t prng_mod_mask = ~(~uint64_t{0} << prng_mod_power); - return (prng_mult * rnd + prng_add) & prng_mod_mask; -} - -// Generates a geometric variable with the specified mean. -// This is done by generating a random number between 0 and 1 and applying -// the inverse cumulative distribution function for an exponential. -// Specifically: Let m be the inverse of the sample period, then -// the probability distribution function is m*exp(-mx) so the CDF is -// p = 1 - exp(-mx), so -// q = 1 - p = exp(-mx) -// log_e(q) = -mx -// -log_e(q)/m = x -// log_2(q) * (-log_e(2) * 1/m) = x -// In the code, q is actually in the range 1 to 2**26, hence the -26 below -// -int64_t GetGeometricVariable(int64_t mean) { -#if ABSL_HAVE_THREAD_LOCAL - thread_local -#else // ABSL_HAVE_THREAD_LOCAL - // SampleSlow and hence GetGeometricVariable is guarded by a single mutex when - // there are not thread locals. Thus, a single global rng is acceptable for - // that case. - static -#endif // ABSL_HAVE_THREAD_LOCAL - uint64_t rng = []() { - // We don't get well distributed numbers from this so we call - // NextRandom() a bunch to mush the bits around. We use a global_rand - // to handle the case where the same thread (by memory address) gets - // created and destroyed repeatedly. - ABSL_CONST_INIT static std::atomic<uint32_t> global_rand(0); - uint64_t r = reinterpret_cast<uint64_t>(&rng) + - global_rand.fetch_add(1, std::memory_order_relaxed); - for (int i = 0; i < 20; ++i) { - r = NextRandom(r); - } - return r; - }(); - - rng = NextRandom(rng); - - // Take the top 26 bits as the random number - // (This plus the 1<<58 sampling bound give a max possible step of - // 5194297183973780480 bytes.) - const uint64_t prng_mod_power = 48; // Number of bits in prng - // The uint32_t cast is to prevent a (hard-to-reproduce) NAN - // under piii debug for some binaries. - double q = static_cast<uint32_t>(rng >> (prng_mod_power - 26)) + 1.0; - // Put the computed p-value through the CDF of a geometric. - double interval = (log2(q) - 26) * (-std::log(2.0) * mean); - - // Very large values of interval overflow int64_t. If we happen to - // hit such improbable condition, we simply cheat and clamp interval - // to largest supported value. - if (interval > static_cast<double>(std::numeric_limits<int64_t>::max() / 2)) { - return std::numeric_limits<int64_t>::max() / 2; - } - - // Small values of interval are equivalent to just sampling next time. - if (interval < 1) { - return 1; - } - return static_cast<int64_t>(interval); -} +#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) +ABSL_PER_THREAD_TLS_KEYWORD absl::base_internal::ExponentialBiased + g_exponential_biased_generator; +#endif } // namespace +#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) +ABSL_PER_THREAD_TLS_KEYWORD int64_t global_next_sample = 0; +#endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) + HashtablezSampler& HashtablezSampler::Global() { static auto* sampler = new HashtablezSampler(); return *sampler; @@ -228,15 +167,39 @@ return dropped_samples_.load(std::memory_order_relaxed); } +static bool ShouldForceSampling() { + enum ForceState { + kDontForce, + kForce, + kUninitialized + }; + ABSL_CONST_INIT static std::atomic<ForceState> global_state{ + kUninitialized}; + ForceState state = global_state.load(std::memory_order_relaxed); + if (ABSL_PREDICT_TRUE(state == kDontForce)) return false; + + if (state == kUninitialized) { + state = AbslContainerInternalSampleEverything() ? kForce : kDontForce; + global_state.store(state, std::memory_order_relaxed); + } + return state == kForce; +} + HashtablezInfo* SampleSlow(int64_t* next_sample) { - if (kAbslContainerInternalSampleEverything) { + if (ABSL_PREDICT_FALSE(ShouldForceSampling())) { *next_sample = 1; return HashtablezSampler::Global().Register(); } +#if !defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) + *next_sample = std::numeric_limits<int64_t>::max(); + return nullptr; +#else bool first = *next_sample < 0; - *next_sample = GetGeometricVariable( + *next_sample = g_exponential_biased_generator.GetStride( g_hashtablez_sample_parameter.load(std::memory_order_relaxed)); + // Small values of interval are equivalent to just sampling next time. + ABSL_ASSERT(*next_sample >= 1); // g_hashtablez_enabled can be dynamically flipped, we need to set a threshold // low enough that we will start sampling in a reasonable time, so we just use @@ -251,12 +214,9 @@ } return HashtablezSampler::Global().Register(); +#endif } -#if ABSL_PER_THREAD_TLS == 1 -ABSL_PER_THREAD_TLS_KEYWORD int64_t global_next_sample = 0; -#endif // ABSL_PER_THREAD_TLS == 1 - void UnsampleSlow(HashtablezInfo* info) { HashtablezSampler::Global().Unregister(info); } @@ -266,7 +226,7 @@ // SwissTables probe in groups of 16, so scale this to count items probes and // not offset from desired. size_t probe_length = distance_from_desired; -#if SWISSTABLE_HAVE_SSE2 +#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 probe_length /= 16; #else probe_length /= 8; @@ -305,4 +265,5 @@ } } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h b/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h index 41121754..8aaffc35 100644 --- a/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +++ b/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h
@@ -51,6 +51,7 @@ #include "absl/utility/utility.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { // Stores information about a sampled hashtable. All mutations to this *must* @@ -97,7 +98,7 @@ }; inline void RecordRehashSlow(HashtablezInfo* info, size_t total_probe_length) { -#if SWISSTABLE_HAVE_SSE2 +#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 total_probe_length /= 16; #else total_probe_length /= 8; @@ -179,23 +180,30 @@ HashtablezInfo* info_; }; -#if ABSL_PER_THREAD_TLS == 1 +#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) +#error ABSL_INTERNAL_HASHTABLEZ_SAMPLE cannot be directly set +#endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) + +#if (ABSL_PER_THREAD_TLS == 1) && !defined(ABSL_BUILD_DLL) && \ + !defined(ABSL_CONSUME_DLL) +#define ABSL_INTERNAL_HASHTABLEZ_SAMPLE +#endif + +#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) extern ABSL_PER_THREAD_TLS_KEYWORD int64_t global_next_sample; #endif // ABSL_PER_THREAD_TLS // Returns an RAII sampling handle that manages registration and unregistation // with the global sampler. inline HashtablezInfoHandle Sample() { -#if ABSL_PER_THREAD_TLS == 0 - static auto* mu = new absl::Mutex; - static int64_t global_next_sample = 0; - absl::MutexLock l(mu); -#endif // !ABSL_HAVE_THREAD_LOCAL - +#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) if (ABSL_PREDICT_TRUE(--global_next_sample > 0)) { return HashtablezInfoHandle(nullptr); } return HashtablezInfoHandle(SampleSlow(&global_next_sample)); +#else + return HashtablezInfoHandle(nullptr); +#endif // !ABSL_PER_THREAD_TLS } // Holds samples and their associated stack traces with a soft limit of @@ -280,9 +288,10 @@ // initialization of static storage duration objects. // The definition of this constant is weak, which allows us to inject a // different value for it at link time. -extern "C" const bool kAbslContainerInternalSampleEverything; +extern "C" bool AbslContainerInternalSampleEverything(); } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_HASHTABLEZ_SAMPLER_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc b/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc index 4ca6ffda..78b9d36 100644 --- a/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc +++ b/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc
@@ -17,11 +17,14 @@ #include "absl/base/attributes.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { // See hashtablez_sampler.h for details. -extern "C" ABSL_ATTRIBUTE_WEAK const bool - kAbslContainerInternalSampleEverything = false; +extern "C" ABSL_ATTRIBUTE_WEAK bool AbslContainerInternalSampleEverything() { + return false; +} } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_test.cc b/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_test.cc index 7f9e8dd..b4c4ff9 100644 --- a/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_test.cc +++ b/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_test.cc
@@ -29,13 +29,14 @@ #include "absl/time/clock.h" #include "absl/time/time.h" -#if SWISSTABLE_HAVE_SSE2 +#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 constexpr int kProbeLength = 16; #else constexpr int kProbeLength = 8; #endif namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { class HashtablezInfoHandlePeer { public: @@ -168,6 +169,7 @@ EXPECT_EQ(info.num_erases.load(), 0); } +#if defined(ABSL_HASHTABLEZ_SAMPLE) TEST(HashtablezSamplerTest, SmallSampleParameter) { SetHashtablezEnabled(true); SetHashtablezSampleParameter(100); @@ -211,6 +213,7 @@ } EXPECT_NEAR(sample_rate, 0.01, 0.005); } +#endif TEST(HashtablezSamplerTest, Handle) { auto& sampler = HashtablezSampler::Global(); @@ -352,4 +355,5 @@ } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/have_sse.h b/third_party/abseil-cpp/absl/container/internal/have_sse.h index 43414418..e75e1a16 100644 --- a/third_party/abseil-cpp/absl/container/internal/have_sse.h +++ b/third_party/abseil-cpp/absl/container/internal/have_sse.h
@@ -16,33 +16,34 @@ #ifndef ABSL_CONTAINER_INTERNAL_HAVE_SSE_H_ #define ABSL_CONTAINER_INTERNAL_HAVE_SSE_H_ -#ifndef SWISSTABLE_HAVE_SSE2 +#ifndef ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 #if defined(__SSE2__) || \ (defined(_MSC_VER) && \ (defined(_M_X64) || (defined(_M_IX86) && _M_IX86_FP >= 2))) -#define SWISSTABLE_HAVE_SSE2 1 +#define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 1 #else -#define SWISSTABLE_HAVE_SSE2 0 +#define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 0 #endif #endif -#ifndef SWISSTABLE_HAVE_SSSE3 +#ifndef ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 #ifdef __SSSE3__ -#define SWISSTABLE_HAVE_SSSE3 1 +#define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 1 #else -#define SWISSTABLE_HAVE_SSSE3 0 +#define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 0 #endif #endif -#if SWISSTABLE_HAVE_SSSE3 && !SWISSTABLE_HAVE_SSE2 +#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 && \ + !ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 #error "Bad configuration!" #endif -#if SWISSTABLE_HAVE_SSE2 +#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 #include <emmintrin.h> #endif -#if SWISSTABLE_HAVE_SSSE3 +#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 #include <tmmintrin.h> #endif
diff --git a/third_party/abseil-cpp/absl/container/internal/inlined_vector.h b/third_party/abseil-cpp/absl/container/internal/inlined_vector.h index 61c4f6e..4d80b727 100644 --- a/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +++ b/third_party/abseil-cpp/absl/container/internal/inlined_vector.h
@@ -30,6 +30,7 @@ #include "absl/types/span.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace inlined_vector_internal { template <typename Iterator> @@ -37,16 +38,17 @@ typename std::iterator_traits<Iterator>::iterator_category, std::forward_iterator_tag>; -template <typename AllocatorType> -using IsMemcpyOk = absl::conjunction< - std::is_same<std::allocator<typename AllocatorType::value_type>, - AllocatorType>, - absl::is_trivially_copy_constructible<typename AllocatorType::value_type>, - absl::is_trivially_copy_assignable<typename AllocatorType::value_type>, - absl::is_trivially_destructible<typename AllocatorType::value_type>>; +template <typename AllocatorType, + typename ValueType = + typename absl::allocator_traits<AllocatorType>::value_type> +using IsMemcpyOk = + absl::conjunction<std::is_same<AllocatorType, std::allocator<ValueType>>, + absl::is_trivially_copy_constructible<ValueType>, + absl::is_trivially_copy_assignable<ValueType>, + absl::is_trivially_destructible<ValueType>>; -template <typename AllocatorType, typename ValueType, typename SizeType> -void DestroyElements(AllocatorType* alloc_ptr, ValueType* destroy_first, +template <typename AllocatorType, typename Pointer, typename SizeType> +void DestroyElements(AllocatorType* alloc_ptr, Pointer destroy_first, SizeType destroy_size) { using AllocatorTraits = absl::allocator_traits<AllocatorType>; @@ -56,21 +58,26 @@ AllocatorTraits::destroy(*alloc_ptr, destroy_first + i); } -#ifndef NDEBUG - // Overwrite unused memory with `0xab` so we can catch uninitialized usage. - // - // Cast to `void*` to tell the compiler that we don't care that we might be - // scribbling on a vtable pointer. - auto* memory_ptr = static_cast<void*>(destroy_first); - auto memory_size = sizeof(ValueType) * destroy_size; - std::memset(memory_ptr, 0xab, memory_size); -#endif // NDEBUG +#if !defined(NDEBUG) + { + using ValueType = typename AllocatorTraits::value_type; + + // Overwrite unused memory with `0xab` so we can catch uninitialized + // usage. + // + // Cast to `void*` to tell the compiler that we don't care that we might + // be scribbling on a vtable pointer. + void* memory_ptr = destroy_first; + auto memory_size = destroy_size * sizeof(ValueType); + std::memset(memory_ptr, 0xab, memory_size); + } +#endif // !defined(NDEBUG) } } -template <typename AllocatorType, typename ValueType, typename ValueAdapter, +template <typename AllocatorType, typename Pointer, typename ValueAdapter, typename SizeType> -void ConstructElements(AllocatorType* alloc_ptr, ValueType* construct_first, +void ConstructElements(AllocatorType* alloc_ptr, Pointer construct_first, ValueAdapter* values_ptr, SizeType construct_size) { for (SizeType i = 0; i < construct_size; ++i) { ABSL_INTERNAL_TRY { @@ -83,8 +90,8 @@ } } -template <typename ValueType, typename ValueAdapter, typename SizeType> -void AssignElements(ValueType* assign_first, ValueAdapter* values_ptr, +template <typename Pointer, typename ValueAdapter, typename SizeType> +void AssignElements(Pointer assign_first, ValueAdapter* values_ptr, SizeType assign_size) { for (SizeType i = 0; i < assign_size; ++i) { values_ptr->AssignNext(assign_first + i); @@ -93,28 +100,29 @@ template <typename AllocatorType> struct StorageView { - using pointer = typename AllocatorType::pointer; - using size_type = typename AllocatorType::size_type; + using AllocatorTraits = absl::allocator_traits<AllocatorType>; + using Pointer = typename AllocatorTraits::pointer; + using SizeType = typename AllocatorTraits::size_type; - pointer data; - size_type size; - size_type capacity; + Pointer data; + SizeType size; + SizeType capacity; }; template <typename AllocatorType, typename Iterator> class IteratorValueAdapter { - using pointer = typename AllocatorType::pointer; using AllocatorTraits = absl::allocator_traits<AllocatorType>; + using Pointer = typename AllocatorTraits::pointer; public: explicit IteratorValueAdapter(const Iterator& it) : it_(it) {} - void ConstructNext(AllocatorType* alloc_ptr, pointer construct_at) { + void ConstructNext(AllocatorType* alloc_ptr, Pointer construct_at) { AllocatorTraits::construct(*alloc_ptr, construct_at, *it_); ++it_; } - void AssignNext(pointer assign_at) { + void AssignNext(Pointer assign_at) { *assign_at = *it_; ++it_; } @@ -125,46 +133,45 @@ template <typename AllocatorType> class CopyValueAdapter { - using pointer = typename AllocatorType::pointer; - using const_pointer = typename AllocatorType::const_pointer; - using const_reference = typename AllocatorType::const_reference; using AllocatorTraits = absl::allocator_traits<AllocatorType>; + using ValueType = typename AllocatorTraits::value_type; + using Pointer = typename AllocatorTraits::pointer; + using ConstPointer = typename AllocatorTraits::const_pointer; public: - explicit CopyValueAdapter(const_reference v) : ptr_(std::addressof(v)) {} + explicit CopyValueAdapter(const ValueType& v) : ptr_(std::addressof(v)) {} - void ConstructNext(AllocatorType* alloc_ptr, pointer construct_at) { + void ConstructNext(AllocatorType* alloc_ptr, Pointer construct_at) { AllocatorTraits::construct(*alloc_ptr, construct_at, *ptr_); } - void AssignNext(pointer assign_at) { *assign_at = *ptr_; } + void AssignNext(Pointer assign_at) { *assign_at = *ptr_; } private: - const_pointer ptr_; + ConstPointer ptr_; }; template <typename AllocatorType> class DefaultValueAdapter { - using pointer = typename AllocatorType::pointer; - using value_type = typename AllocatorType::value_type; using AllocatorTraits = absl::allocator_traits<AllocatorType>; + using ValueType = typename AllocatorTraits::value_type; + using Pointer = typename AllocatorTraits::pointer; public: explicit DefaultValueAdapter() {} - void ConstructNext(AllocatorType* alloc_ptr, pointer construct_at) { + void ConstructNext(AllocatorType* alloc_ptr, Pointer construct_at) { AllocatorTraits::construct(*alloc_ptr, construct_at); } - void AssignNext(pointer assign_at) { *assign_at = value_type(); } + void AssignNext(Pointer assign_at) { *assign_at = ValueType(); } }; template <typename AllocatorType> class AllocationTransaction { - using value_type = typename AllocatorType::value_type; - using pointer = typename AllocatorType::pointer; - using size_type = typename AllocatorType::size_type; using AllocatorTraits = absl::allocator_traits<AllocatorType>; + using Pointer = typename AllocatorTraits::pointer; + using SizeType = typename AllocatorTraits::size_type; public: explicit AllocationTransaction(AllocatorType* alloc_ptr) @@ -180,25 +187,31 @@ void operator=(const AllocationTransaction&) = delete; AllocatorType& GetAllocator() { return alloc_data_.template get<0>(); } - pointer& GetData() { return alloc_data_.template get<1>(); } - size_type& GetCapacity() { return capacity_; } + Pointer& GetData() { return alloc_data_.template get<1>(); } + SizeType& GetCapacity() { return capacity_; } bool DidAllocate() { return GetData() != nullptr; } - pointer Allocate(size_type capacity) { + Pointer Allocate(SizeType capacity) { GetData() = AllocatorTraits::allocate(GetAllocator(), capacity); GetCapacity() = capacity; return GetData(); } + void Reset() { + GetData() = nullptr; + GetCapacity() = 0; + } + private: - container_internal::CompressedTuple<AllocatorType, pointer> alloc_data_; - size_type capacity_ = 0; + container_internal::CompressedTuple<AllocatorType, Pointer> alloc_data_; + SizeType capacity_ = 0; }; template <typename AllocatorType> class ConstructionTransaction { - using pointer = typename AllocatorType::pointer; - using size_type = typename AllocatorType::size_type; + using AllocatorTraits = absl::allocator_traits<AllocatorType>; + using Pointer = typename AllocatorTraits::pointer; + using SizeType = typename AllocatorTraits::size_type; public: explicit ConstructionTransaction(AllocatorType* alloc_ptr) @@ -215,12 +228,12 @@ void operator=(const ConstructionTransaction&) = delete; AllocatorType& GetAllocator() { return alloc_data_.template get<0>(); } - pointer& GetData() { return alloc_data_.template get<1>(); } - size_type& GetSize() { return size_; } + Pointer& GetData() { return alloc_data_.template get<1>(); } + SizeType& GetSize() { return size_; } bool DidConstruct() { return GetData() != nullptr; } template <typename ValueAdapter> - void Construct(pointer data, ValueAdapter* values_ptr, size_type size) { + void Construct(Pointer data, ValueAdapter* values_ptr, SizeType size) { inlined_vector_internal::ConstructElements(std::addressof(GetAllocator()), data, values_ptr, size); GetData() = data; @@ -232,28 +245,29 @@ } private: - container_internal::CompressedTuple<AllocatorType, pointer> alloc_data_; - size_type size_ = 0; + container_internal::CompressedTuple<AllocatorType, Pointer> alloc_data_; + SizeType size_ = 0; }; template <typename T, size_t N, typename A> class Storage { public: - using allocator_type = A; - using value_type = typename allocator_type::value_type; - using pointer = typename allocator_type::pointer; - using const_pointer = typename allocator_type::const_pointer; - using reference = typename allocator_type::reference; - using const_reference = typename allocator_type::const_reference; - using rvalue_reference = typename allocator_type::value_type&&; - using size_type = typename allocator_type::size_type; - using difference_type = typename allocator_type::difference_type; + using AllocatorTraits = absl::allocator_traits<A>; + using allocator_type = typename AllocatorTraits::allocator_type; + using value_type = typename AllocatorTraits::value_type; + using pointer = typename AllocatorTraits::pointer; + using const_pointer = typename AllocatorTraits::const_pointer; + using size_type = typename AllocatorTraits::size_type; + using difference_type = typename AllocatorTraits::difference_type; + + using reference = value_type&; + using const_reference = const value_type&; + using RValueReference = value_type&&; using iterator = pointer; using const_iterator = const_pointer; using reverse_iterator = std::reverse_iterator<iterator>; using const_reverse_iterator = std::reverse_iterator<const_iterator>; using MoveIterator = std::move_iterator<iterator>; - using AllocatorTraits = absl::allocator_traits<allocator_type>; using IsMemcpyOk = inlined_vector_internal::IsMemcpyOk<allocator_type>; using StorageView = inlined_vector_internal::StorageView<allocator_type>; @@ -286,8 +300,7 @@ Storage() : metadata_() {} - explicit Storage(const allocator_type& alloc) - : metadata_(alloc, /* empty and inlined */ 0) {} + explicit Storage(const allocator_type& alloc) : metadata_(alloc, {}) {} ~Storage() { pointer data = GetIsAllocated() ? GetAllocatedData() : GetInlinedData(); @@ -413,8 +426,8 @@ void AcquireAllocatedData(AllocationTransaction* allocation_tx_ptr) { SetAllocatedData(allocation_tx_ptr->GetData(), allocation_tx_ptr->GetCapacity()); - allocation_tx_ptr->GetData() = nullptr; - allocation_tx_ptr->GetCapacity() = 0; + + allocation_tx_ptr->Reset(); } void MemcpyFrom(const Storage& other_storage) { @@ -441,9 +454,7 @@ }; struct Inlined { - using InlinedDataElement = - absl::aligned_storage_t<sizeof(value_type), alignof(value_type)>; - InlinedDataElement inlined_data[N]; + alignas(value_type) char inlined_data[sizeof(value_type[N])]; }; union Data { @@ -464,18 +475,14 @@ assert(GetSize() == 0); pointer construct_data; - if (new_size > GetInlinedCapacity()) { // Because this is only called from the `InlinedVector` constructors, it's // safe to take on the allocation with size `0`. If `ConstructElements(...)` // throws, deallocation will be automatically handled by `~Storage()`. size_type new_capacity = ComputeCapacity(GetInlinedCapacity(), new_size); - pointer new_data = AllocatorTraits::allocate(*GetAllocPtr(), new_capacity); - - SetAllocatedData(new_data, new_capacity); + construct_data = AllocatorTraits::allocate(*GetAllocPtr(), new_capacity); + SetAllocatedData(construct_data, new_capacity); SetIsAllocated(); - - construct_data = new_data; } else { construct_data = GetInlinedData(); } @@ -502,9 +509,7 @@ if (new_size > storage_view.capacity) { size_type new_capacity = ComputeCapacity(storage_view.capacity, new_size); - pointer new_data = allocation_tx.Allocate(new_capacity); - - construct_loop = {new_data, new_size}; + construct_loop = {allocation_tx.Allocate(new_capacity), new_size}; destroy_loop = {storage_view.data, storage_view.size}; } else if (new_size > storage_view.size) { assign_loop = {storage_view.data, storage_view.size}; @@ -538,12 +543,12 @@ auto Storage<T, N, A>::Resize(ValueAdapter values, size_type new_size) -> void { StorageView storage_view = MakeStorageView(); - AllocationTransaction allocation_tx(GetAllocPtr()); - ConstructionTransaction construction_tx(GetAllocPtr()); - IteratorValueAdapter<MoveIterator> move_values( MoveIterator(storage_view.data)); + AllocationTransaction allocation_tx(GetAllocPtr()); + ConstructionTransaction construction_tx(GetAllocPtr()); + absl::Span<value_type> construct_loop; absl::Span<value_type> move_construct_loop; absl::Span<value_type> destroy_loop; @@ -686,19 +691,17 @@ MoveIterator(storage_view.data)); pointer construct_data; - if (storage_view.size == storage_view.capacity) { size_type new_capacity = NextCapacity(storage_view.capacity); - pointer new_data = allocation_tx.Allocate(new_capacity); - - construct_data = new_data; + construct_data = allocation_tx.Allocate(new_capacity); } else { construct_data = storage_view.data; } - pointer end = construct_data + storage_view.size; + pointer last_ptr = construct_data + storage_view.size; - AllocatorTraits::construct(*GetAllocPtr(), end, std::forward<Args>(args)...); + AllocatorTraits::construct(*GetAllocPtr(), last_ptr, + std::forward<Args>(args)...); if (allocation_tx.DidAllocate()) { ABSL_INTERNAL_TRY { @@ -707,7 +710,7 @@ storage_view.size); } ABSL_INTERNAL_CATCH_ANY { - AllocatorTraits::destroy(*GetAllocPtr(), end); + AllocatorTraits::destroy(*GetAllocPtr(), last_ptr); ABSL_INTERNAL_RETHROW; } @@ -720,14 +723,12 @@ } AddSize(1); - return *end; + return *last_ptr; } template <typename T, size_t N, typename A> auto Storage<T, N, A>::Erase(const_iterator from, const_iterator to) -> iterator { - assert(from != to); - StorageView storage_view = MakeStorageView(); size_type erase_size = std::distance(from, to); @@ -792,12 +793,9 @@ MoveIterator(storage_view.data)); pointer construct_data; - if (storage_view.size > GetInlinedCapacity()) { size_type new_capacity = storage_view.size; - pointer new_data = allocation_tx.Allocate(new_capacity); - - construct_data = new_data; + construct_data = allocation_tx.Allocate(new_capacity); } else { construct_data = GetInlinedData(); } @@ -888,6 +886,7 @@ } } // namespace inlined_vector_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_INLINED_VECTOR_INTERNAL_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/layout.h b/third_party/abseil-cpp/absl/container/internal/layout.h index bbdde507..69cc85d 100644 --- a/third_party/abseil-cpp/absl/container/internal/layout.h +++ b/third_party/abseil-cpp/absl/container/internal/layout.h
@@ -188,6 +188,7 @@ #endif namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { // A type wrapper that instructs `Layout` to use the specific alignment for the @@ -734,6 +735,7 @@ }; } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_LAYOUT_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/layout_test.cc b/third_party/abseil-cpp/absl/container/internal/layout_test.cc index 33b72bd..8f3628a1 100644 --- a/third_party/abseil-cpp/absl/container/internal/layout_test.cc +++ b/third_party/abseil-cpp/absl/container/internal/layout_test.cc
@@ -28,6 +28,7 @@ #include "absl/types/span.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { @@ -1562,4 +1563,5 @@ } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/node_hash_policy.h b/third_party/abseil-cpp/absl/container/internal/node_hash_policy.h index 19b4fc09..4617162 100644 --- a/third_party/abseil-cpp/absl/container/internal/node_hash_policy.h +++ b/third_party/abseil-cpp/absl/container/internal/node_hash_policy.h
@@ -39,7 +39,10 @@ #include <type_traits> #include <utility> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class Reference, class Policy> @@ -83,6 +86,7 @@ }; } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_NODE_HASH_POLICY_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/node_hash_policy_test.cc b/third_party/abseil-cpp/absl/container/internal/node_hash_policy_test.cc index f1d3ec3..84aabba 100644 --- a/third_party/abseil-cpp/absl/container/internal/node_hash_policy_test.cc +++ b/third_party/abseil-cpp/absl/container/internal/node_hash_policy_test.cc
@@ -21,6 +21,7 @@ #include "absl/container/internal/hash_policy_traits.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { @@ -64,4 +65,5 @@ } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h b/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h index 6a9c730..0a02757 100644 --- a/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +++ b/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h
@@ -24,6 +24,7 @@ #include "absl/container/internal/raw_hash_set.h" // IWYU pragma: export namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class Policy, class Hash, class Eq, class Alloc> @@ -109,6 +110,9 @@ return insert_or_assign(k, v).first; } + // All `try_emplace()` overloads make the same guarantees regarding rvalue + // arguments as `std::unordered_map::try_emplace()`, namely that these + // functions will not move from rvalue arguments if insertions do not happen. template <class K = key_type, class... Args, typename std::enable_if< !std::is_convertible<K, const_iterator>::value, int>::type = 0, @@ -187,6 +191,7 @@ }; } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_RAW_HASH_MAP_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc b/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc index ac2d10a7..919ac07 100644 --- a/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +++ b/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc
@@ -20,6 +20,7 @@ #include "absl/base/config.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { constexpr size_t Group::kWidth; @@ -43,4 +44,5 @@ } } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h b/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h index 656e9806..fb47f62f 100644 --- a/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +++ b/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h
@@ -118,6 +118,7 @@ #include "absl/utility/utility.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <size_t Width> @@ -311,7 +312,7 @@ inline bool IsDeleted(ctrl_t c) { return c == kDeleted; } inline bool IsEmptyOrDeleted(ctrl_t c) { return c < kSentinel; } -#if SWISSTABLE_HAVE_SSE2 +#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 // https://github.com/abseil/abseil-cpp/issues/209 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87853 @@ -345,7 +346,7 @@ // Returns a bitmask representing the positions of empty slots. BitMask<uint32_t, kWidth> MatchEmpty() const { -#if SWISSTABLE_HAVE_SSSE3 +#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 // This only works because kEmpty is -128. return BitMask<uint32_t, kWidth>( _mm_movemask_epi8(_mm_sign_epi8(ctrl, ctrl))); @@ -371,7 +372,7 @@ void ConvertSpecialToEmptyAndFullToDeleted(ctrl_t* dst) const { auto msbs = _mm_set1_epi8(static_cast<char>(-128)); auto x126 = _mm_set1_epi8(126); -#if SWISSTABLE_HAVE_SSSE3 +#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 auto res = _mm_or_si128(_mm_shuffle_epi8(x126, ctrl), msbs); #else auto zero = _mm_setzero_si128(); @@ -383,7 +384,7 @@ __m128i ctrl; }; -#endif // SWISSTABLE_HAVE_SSE2 +#endif // ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 struct GroupPortableImpl { static constexpr size_t kWidth = 8; @@ -437,7 +438,7 @@ uint64_t ctrl; }; -#if SWISSTABLE_HAVE_SSE2 +#if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 using Group = GroupSse2Impl; #else using Group = GroupPortableImpl; @@ -614,13 +615,17 @@ iterator() {} // PRECONDITION: not an end() iterator. - reference operator*() const { return PolicyTraits::element(slot_); } + reference operator*() const { + assert_is_full(); + return PolicyTraits::element(slot_); + } // PRECONDITION: not an end() iterator. pointer operator->() const { return &operator*(); } // PRECONDITION: not an end() iterator. iterator& operator++() { + assert_is_full(); ++ctrl_; ++slot_; skip_empty_or_deleted(); @@ -634,6 +639,8 @@ } friend bool operator==(const iterator& a, const iterator& b) { + a.assert_is_valid(); + b.assert_is_valid(); return a.ctrl_ == b.ctrl_; } friend bool operator!=(const iterator& a, const iterator& b) { @@ -644,6 +651,11 @@ iterator(ctrl_t* ctrl) : ctrl_(ctrl) {} // for end() iterator(ctrl_t* ctrl, slot_type* slot) : ctrl_(ctrl), slot_(slot) {} + void assert_is_full() const { assert(IsFull(*ctrl_)); } + void assert_is_valid() const { + assert(!ctrl_ || IsFull(*ctrl_) || *ctrl_ == kSentinel); + } + void skip_empty_or_deleted() { while (IsEmptyOrDeleted(*ctrl_)) { // ctrl is not necessarily aligned to Group::kWidth. It is also likely @@ -657,7 +669,7 @@ } ctrl_t* ctrl_ = nullptr; - // To avoid uninitialized member warnigs, put slot_ in an anonymous union. + // To avoid uninitialized member warnings, put slot_ in an anonymous union. // The member is not initialized on singleton and end iterators. union { slot_type* slot_; @@ -938,8 +950,11 @@ // // flat_hash_map<std::string, int> m; // m.insert(std::make_pair("abc", 42)); + // TODO(cheshire): A type alias T2 is introduced as a workaround for the nvcc + // bug. template <class T, RequiresInsertable<T> = 0, - typename std::enable_if<IsDecomposable<T>::value, int>::type = 0, + class T2 = T, + typename std::enable_if<IsDecomposable<T2>::value, int>::type = 0, T* = nullptr> std::pair<iterator, bool> insert(T&& value) { return emplace(std::forward<T>(value)); @@ -975,8 +990,10 @@ return emplace(std::move(value)); } - template <class T, RequiresInsertable<T> = 0, - typename std::enable_if<IsDecomposable<T>::value, int>::type = 0, + // TODO(cheshire): A type alias T2 is introduced as a workaround for the nvcc + // bug. + template <class T, RequiresInsertable<T> = 0, class T2 = T, + typename std::enable_if<IsDecomposable<T2>::value, int>::type = 0, T* = nullptr> iterator insert(const_iterator, T&& value) { return insert(std::forward<T>(value)).first; @@ -1050,8 +1067,7 @@ template <class... Args, typename std::enable_if< !IsDecomposable<Args...>::value, int>::type = 0> std::pair<iterator, bool> emplace(Args&&... args) { - typename std::aligned_storage<sizeof(slot_type), alignof(slot_type)>::type - raw; + alignas(slot_type) unsigned char raw[sizeof(slot_type)]; slot_type* slot = reinterpret_cast<slot_type*>(&raw); PolicyTraits::construct(&alloc_ref(), slot, std::forward<Args>(args)...); @@ -1067,10 +1083,15 @@ // Extension API: support for lazy emplace. // // Looks up key in the table. If found, returns the iterator to the element. - // Otherwise calls f with one argument of type raw_hash_set::constructor. f - // MUST call raw_hash_set::constructor with arguments as if a - // raw_hash_set::value_type is constructed, otherwise the behavior is - // undefined. + // Otherwise calls `f` with one argument of type `raw_hash_set::constructor`. + // + // `f` must abide by several restrictions: + // - it MUST call `raw_hash_set::constructor` with arguments as if a + // `raw_hash_set::value_type` is constructed, + // - it MUST NOT access the container before the call to + // `raw_hash_set::constructor`, and + // - it MUST NOT erase the lazily emplaced element. + // Doing any of these is undefined behavior. // // For example: // @@ -1133,15 +1154,16 @@ } // Erases the element pointed to by `it`. Unlike `std::unordered_set::erase`, - // this method returns void to reduce algorithmic complexity to O(1). In - // order to erase while iterating across a map, use the following idiom (which - // also works for standard containers): + // this method returns void to reduce algorithmic complexity to O(1). The + // iterator is invalidated, so any increment should be done before calling + // erase. In order to erase while iterating across a map, use the following + // idiom (which also works for standard containers): // // for (auto it = m.begin(), end = m.end(); it != end;) { + // // `erase()` will invalidate `it`, so advance `it` first. + // auto copy_it = it++; // if (<pred>) { - // m.erase(it++); - // } else { - // ++it; + // m.erase(copy_it); // } // } void erase(const_iterator cit) { erase(cit.inner_); } @@ -1149,7 +1171,7 @@ // This overload is necessary because otherwise erase<K>(const K&) would be // a better match if non-const iterator is passed as an argument. void erase(iterator it) { - assert(it != end()); + it.assert_is_full(); PolicyTraits::destroy(&alloc_ref(), it.slot_); erase_meta_only(it); } @@ -1166,12 +1188,14 @@ template <typename H, typename E> void merge(raw_hash_set<Policy, H, E, Alloc>& src) { // NOLINT assert(this != &src); - for (auto it = src.begin(), e = src.end(); it != e; ++it) { + for (auto it = src.begin(), e = src.end(); it != e;) { + auto next = std::next(it); if (PolicyTraits::apply(InsertSlot<false>{*this, std::move(*it.slot_)}, PolicyTraits::element(it.slot_)) .second) { src.erase_meta_only(it); } + it = next; } } @@ -1181,6 +1205,7 @@ } node_type extract(const_iterator position) { + position.inner_.assert_is_full(); auto node = CommonAccess::Transfer<node_type>(alloc_ref(), position.inner_.slot_); erase_meta_only(position); @@ -1530,8 +1555,7 @@ // mark target as FULL // repeat procedure for current slot with moved from element (target) ConvertDeletedToEmptyAndFullToDeleted(ctrl_, capacity_); - typename std::aligned_storage<sizeof(slot_type), alignof(slot_type)>::type - raw; + alignas(slot_type) unsigned char raw[sizeof(slot_type)]; size_t total_probe_length = 0; slot_type* slot = reinterpret_cast<slot_type*>(&raw); for (size_t i = 0; i != capacity_; ++i) { @@ -1780,6 +1804,17 @@ settings_{0, hasher{}, key_equal{}, allocator_type{}}; }; +// Erases all elements that satisfy the predicate `pred` from the container `c`. +template <typename P, typename H, typename E, typename A, typename Predicate> +void EraseIf(Predicate pred, raw_hash_set<P, H, E, A>* c) { + for (auto it = c->begin(), last = c->end(); it != last;) { + auto copy_it = it++; + if (pred(*copy_it)) { + c->erase(copy_it); + } + } +} + namespace hashtable_debug_internal { template <typename Set> struct HashtableDebugAccess<Set, absl::void_t<typename Set::raw_hash_set>> { @@ -1841,6 +1876,7 @@ } // namespace hashtable_debug_internal } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_RAW_HASH_SET_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/raw_hash_set_allocator_test.cc b/third_party/abseil-cpp/absl/container/internal/raw_hash_set_allocator_test.cc index a5eff0b3..7ac4b9f 100644 --- a/third_party/abseil-cpp/absl/container/internal/raw_hash_set_allocator_test.cc +++ b/third_party/abseil-cpp/absl/container/internal/raw_hash_set_allocator_test.cc
@@ -20,6 +20,7 @@ #include "absl/container/internal/tracked.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { @@ -425,4 +426,5 @@ } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/raw_hash_set_test.cc b/third_party/abseil-cpp/absl/container/internal/raw_hash_set_test.cc index ed4ca8c..2fc8559 100644 --- a/third_party/abseil-cpp/absl/container/internal/raw_hash_set_test.cc +++ b/third_party/abseil-cpp/absl/container/internal/raw_hash_set_test.cc
@@ -35,6 +35,7 @@ #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { struct RawHashSetTestOnlyAccess { @@ -417,53 +418,6 @@ EXPECT_TRUE(t.empty()); } -#ifdef __GNUC__ -template <class T> -ABSL_ATTRIBUTE_ALWAYS_INLINE inline void DoNotOptimize(const T& v) { - asm volatile("" : : "r,m"(v) : "memory"); -} -#endif - -TEST(Table, Prefetch) { - IntTable t; - t.emplace(1); - // Works for both present and absent keys. - t.prefetch(1); - t.prefetch(2); - - // Do not run in debug mode, when prefetch is not implemented, or when - // sanitizers are enabled, or on WebAssembly. -#if defined(NDEBUG) && defined(__GNUC__) && defined(__x86_64__) && \ - !defined(ADDRESS_SANITIZER) && !defined(MEMORY_SANITIZER) && \ - !defined(THREAD_SANITIZER) && !defined(UNDEFINED_BEHAVIOR_SANITIZER) && \ - !defined(__EMSCRIPTEN__) - const auto now = [] { return absl::base_internal::CycleClock::Now(); }; - - // Make size enough to not fit in L2 cache (16.7 Mb) - static constexpr int size = 1 << 22; - for (int i = 0; i < size; ++i) t.insert(i); - - int64_t no_prefetch = 0, prefetch = 0; - for (int iter = 0; iter < 10; ++iter) { - int64_t time = now(); - for (int i = 0; i < size; ++i) { - DoNotOptimize(t.find(i)); - } - no_prefetch += now() - time; - - time = now(); - for (int i = 0; i < size; ++i) { - t.prefetch(i + 20); - DoNotOptimize(t.find(i)); - } - prefetch += now() - time; - } - - // no_prefetch is at least 30% slower. - EXPECT_GE(1.0 * no_prefetch / prefetch, 1.3); -#endif -} - TEST(Table, LookupEmpty) { IntTable t; auto it = t.find(0); @@ -1712,9 +1666,9 @@ } TEST(Nodes, ExtractInsert) { - constexpr char k0[] = "Very long std::string zero."; - constexpr char k1[] = "Very long std::string one."; - constexpr char k2[] = "Very long std::string two."; + constexpr char k0[] = "Very long string zero."; + constexpr char k1[] = "Very long string one."; + constexpr char k2[] = "Very long string two."; StringTable t = {{k0, ""}, {k1, ""}, {k2, ""}}; EXPECT_THAT(t, UnorderedElementsAre(Pair(k0, ""), Pair(k1, ""), Pair(k2, ""))); @@ -1837,10 +1791,11 @@ IntTable t; // Extra simple "regexp" as regexp support is highly varied across platforms. - constexpr char kDeathMsg[] = "it != end"; + constexpr char kDeathMsg[] = "IsFull"; EXPECT_DEATH_IF_SUPPORTED(t.erase(t.end()), kDeathMsg); } +#if defined(ABSL_HASHTABLEZ_SAMPLE) TEST(RawHashSamplerTest, Sample) { // Enable the feature even if the prod default is off. SetHashtablezEnabled(true); @@ -1861,6 +1816,7 @@ EXPECT_NEAR((end_size - start_size) / static_cast<double>(tables.size()), 0.01, 0.005); } +#endif // ABSL_HASHTABLEZ_SAMPLER TEST(RawHashSamplerTest, DoNotSampleCustomAllocators) { // Enable the feature even if the prod default is off. @@ -1911,4 +1867,5 @@ } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.cc b/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.cc index 5a66cb4d..f9947f0 100644 --- a/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.cc +++ b/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.cc
@@ -15,6 +15,7 @@ #include "absl/container/internal/test_instance_tracker.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace test_internal { int BaseCountedInstance::num_instances_ = 0; int BaseCountedInstance::num_live_instances_ = 0; @@ -24,4 +25,5 @@ int BaseCountedInstance::num_comparisons_ = 0; } // namespace test_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.h b/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.h index c4731dbe..5ff6fd71 100644 --- a/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.h +++ b/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.h
@@ -21,6 +21,7 @@ #include "absl/types/compare.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace test_internal { // A type that counts number of occurrences of the type, the live occurrences of @@ -267,6 +268,7 @@ }; } // namespace test_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_TEST_INSTANCE_TRACKER_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/tracked.h b/third_party/abseil-cpp/absl/container/internal/tracked.h index 75173ab..29f5829f 100644 --- a/third_party/abseil-cpp/absl/container/internal/tracked.h +++ b/third_party/abseil-cpp/absl/container/internal/tracked.h
@@ -16,10 +16,14 @@ #define ABSL_CONTAINER_INTERNAL_TRACKED_H_ #include <stddef.h> + #include <memory> #include <utility> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { // A class that tracks its copies and moves so that it can be queried in tests. @@ -73,6 +77,7 @@ }; } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_TRACKED_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/unordered_map_constructor_test.h b/third_party/abseil-cpp/absl/container/internal/unordered_map_constructor_test.h index 68817e4..76ee95e6 100644 --- a/third_party/abseil-cpp/absl/container/internal/unordered_map_constructor_test.h +++ b/third_party/abseil-cpp/absl/container/internal/unordered_map_constructor_test.h
@@ -24,6 +24,7 @@ #include "absl/container/internal/hash_policy_testing.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordMap> @@ -482,6 +483,7 @@ AssignmentFromInitializerListOverwritesExisting, AssignmentOnSelf); } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_CONSTRUCTOR_TEST_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/unordered_map_lookup_test.h b/third_party/abseil-cpp/absl/container/internal/unordered_map_lookup_test.h index ebd3612b..e76421e 100644 --- a/third_party/abseil-cpp/absl/container/internal/unordered_map_lookup_test.h +++ b/third_party/abseil-cpp/absl/container/internal/unordered_map_lookup_test.h
@@ -21,6 +21,7 @@ #include "absl/container/internal/hash_policy_testing.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordMap> @@ -110,6 +111,7 @@ EqualRange); } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_LOOKUP_TEST_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/unordered_map_members_test.h b/third_party/abseil-cpp/absl/container/internal/unordered_map_members_test.h index 1bf31ab..7d48cdb 100644 --- a/third_party/abseil-cpp/absl/container/internal/unordered_map_members_test.h +++ b/third_party/abseil-cpp/absl/container/internal/unordered_map_members_test.h
@@ -21,6 +21,7 @@ #include "absl/meta/type_traits.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordMap> @@ -80,6 +81,7 @@ REGISTER_TYPED_TEST_SUITE_P(MembersTest, Typedefs, SimpleFunctions, BeginEnd); } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_MEMBERS_TEST_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/unordered_map_modifiers_test.h b/third_party/abseil-cpp/absl/container/internal/unordered_map_modifiers_test.h index 52a1092..b8c513f1 100644 --- a/third_party/abseil-cpp/absl/container/internal/unordered_map_modifiers_test.h +++ b/third_party/abseil-cpp/absl/container/internal/unordered_map_modifiers_test.h
@@ -15,12 +15,15 @@ #ifndef ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_MODIFIERS_TEST_H_ #define ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_MODIFIERS_TEST_H_ +#include <memory> + #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/container/internal/hash_generator_testing.h" #include "absl/container/internal/hash_policy_testing.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordMap> @@ -267,7 +270,47 @@ Emplace, EmplaceHint, TryEmplace, TryEmplaceHint, Erase, EraseRange, EraseKey, Swap); +template <typename Type> +struct is_unique_ptr : std::false_type {}; + +template <typename Type> +struct is_unique_ptr<std::unique_ptr<Type>> : std::true_type {}; + +template <class UnordMap> +class UniquePtrModifiersTest : public ::testing::Test { + protected: + UniquePtrModifiersTest() { + static_assert(is_unique_ptr<typename UnordMap::mapped_type>::value, + "UniquePtrModifiersTyest may only be called with a " + "std::unique_ptr value type."); + } +}; + +TYPED_TEST_SUITE_P(UniquePtrModifiersTest); + +// Test that we do not move from rvalue arguments if an insertion does not +// happen. +TYPED_TEST_P(UniquePtrModifiersTest, TryEmplace) { +#ifdef UNORDERED_MAP_CXX17 + using T = hash_internal::GeneratedType<TypeParam>; + using V = typename TypeParam::mapped_type; + T val = hash_internal::Generator<T>()(); + TypeParam m; + auto p = m.try_emplace(val.first, std::move(val.second)); + EXPECT_TRUE(p.second); + // A moved from std::unique_ptr is guaranteed to be nullptr. + EXPECT_EQ(val.second, nullptr); + T val2 = {val.first, hash_internal::Generator<V>()()}; + p = m.try_emplace(val2.first, std::move(val2.second)); + EXPECT_FALSE(p.second); + EXPECT_NE(val2.second, nullptr); +#endif +} + +REGISTER_TYPED_TEST_SUITE_P(UniquePtrModifiersTest, TryEmplace); + } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_MODIFIERS_TEST_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/unordered_map_test.cc b/third_party/abseil-cpp/absl/container/internal/unordered_map_test.cc index 72567ea..9cbf512f 100644 --- a/third_party/abseil-cpp/absl/container/internal/unordered_map_test.cc +++ b/third_party/abseil-cpp/absl/container/internal/unordered_map_test.cc
@@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include <memory> #include <unordered_map> #include "absl/container/internal/unordered_map_constructor_test.h" @@ -20,6 +21,7 @@ #include "absl/container/internal/unordered_map_modifiers_test.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { @@ -35,6 +37,14 @@ INSTANTIATE_TYPED_TEST_SUITE_P(UnorderedMap, MembersTest, MapTypes); INSTANTIATE_TYPED_TEST_SUITE_P(UnorderedMap, ModifiersTest, MapTypes); +using UniquePtrMapTypes = ::testing::Types<std::unordered_map< + int, std::unique_ptr<int>, StatefulTestingHash, StatefulTestingEqual, + Alloc<std::pair<const int, std::unique_ptr<int>>>>>; + +INSTANTIATE_TYPED_TEST_SUITE_P(UnorderedMap, UniquePtrModifiersTest, + UniquePtrMapTypes); + } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/internal/unordered_set_constructor_test.h b/third_party/abseil-cpp/absl/container/internal/unordered_set_constructor_test.h index f484468..41165b0 100644 --- a/third_party/abseil-cpp/absl/container/internal/unordered_set_constructor_test.h +++ b/third_party/abseil-cpp/absl/container/internal/unordered_set_constructor_test.h
@@ -26,6 +26,7 @@ #include "absl/meta/type_traits.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordMap> @@ -489,6 +490,7 @@ AssignmentFromInitializerListOverwritesExisting, AssignmentOnSelf); } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_SET_CONSTRUCTOR_TEST_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/unordered_set_lookup_test.h b/third_party/abseil-cpp/absl/container/internal/unordered_set_lookup_test.h index 05b32b5d..8f2f4b20 100644 --- a/third_party/abseil-cpp/absl/container/internal/unordered_set_lookup_test.h +++ b/third_party/abseil-cpp/absl/container/internal/unordered_set_lookup_test.h
@@ -21,6 +21,7 @@ #include "absl/container/internal/hash_policy_testing.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordSet> @@ -84,6 +85,7 @@ REGISTER_TYPED_TEST_CASE_P(LookupTest, Count, Find, EqualRange); } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_SET_LOOKUP_TEST_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/unordered_set_members_test.h b/third_party/abseil-cpp/absl/container/internal/unordered_set_members_test.h index b96c945a..4c5e104 100644 --- a/third_party/abseil-cpp/absl/container/internal/unordered_set_members_test.h +++ b/third_party/abseil-cpp/absl/container/internal/unordered_set_members_test.h
@@ -21,6 +21,7 @@ #include "absl/meta/type_traits.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordSet> @@ -79,6 +80,7 @@ REGISTER_TYPED_TEST_SUITE_P(MembersTest, Typedefs, SimpleFunctions, BeginEnd); } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_SET_MEMBERS_TEST_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/unordered_set_modifiers_test.h b/third_party/abseil-cpp/absl/container/internal/unordered_set_modifiers_test.h index 79a8d42..26be58d 100644 --- a/third_party/abseil-cpp/absl/container/internal/unordered_set_modifiers_test.h +++ b/third_party/abseil-cpp/absl/container/internal/unordered_set_modifiers_test.h
@@ -21,6 +21,7 @@ #include "absl/container/internal/hash_policy_testing.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordSet> @@ -183,6 +184,7 @@ EraseKey, Swap); } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_SET_MODIFIERS_TEST_H_
diff --git a/third_party/abseil-cpp/absl/container/internal/unordered_set_test.cc b/third_party/abseil-cpp/absl/container/internal/unordered_set_test.cc index 6478fac..a134b539 100644 --- a/third_party/abseil-cpp/absl/container/internal/unordered_set_test.cc +++ b/third_party/abseil-cpp/absl/container/internal/unordered_set_test.cc
@@ -20,6 +20,7 @@ #include "absl/container/internal/unordered_set_modifiers_test.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { @@ -36,4 +37,5 @@ } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/node_hash_map.h b/third_party/abseil-cpp/absl/container/node_hash_map.h index a841f5a..fccea18 100644 --- a/third_party/abseil-cpp/absl/container/node_hash_map.h +++ b/third_party/abseil-cpp/absl/container/node_hash_map.h
@@ -48,6 +48,7 @@ #include "absl/memory/memory.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class Key, class Value> class NodeHashMapPolicy; @@ -351,6 +352,10 @@ // Inserts (via copy or move) the element of the specified key into the // `node_hash_map` using the position of `hint` as a non-binding suggestion // for where to begin the insertion search. + // + // All `try_emplace()` overloads make the same guarantees regarding rvalue + // arguments as `std::unordered_map::try_emplace()`, namely that these + // functions will not move from rvalue arguments if insertions do not happen. using Base::try_emplace; // node_hash_map::extract() @@ -517,6 +522,15 @@ void resize(typename Base::size_type hint) { this->rehash(hint); } }; +// erase_if(node_hash_map<>, Pred) +// +// Erases all elements that satisfy the predicate `pred` from the container `c`. +template <typename K, typename V, typename H, typename E, typename A, + typename Predicate> +void erase_if(node_hash_map<K, V, H, E, A>& c, Predicate pred) { + container_internal::EraseIf(pred, &c); +} + namespace container_internal { template <class Key, class Value> @@ -577,6 +591,7 @@ } // namespace container_algorithm_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_NODE_HASH_MAP_H_
diff --git a/third_party/abseil-cpp/absl/container/node_hash_map_test.cc b/third_party/abseil-cpp/absl/container/node_hash_map_test.cc index 0f2714a7..5d74b814 100644 --- a/third_party/abseil-cpp/absl/container/node_hash_map_test.cc +++ b/third_party/abseil-cpp/absl/container/node_hash_map_test.cc
@@ -21,10 +21,12 @@ #include "absl/container/internal/unordered_map_modifiers_test.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { using ::testing::Field; +using ::testing::IsEmpty; using ::testing::Pair; using ::testing::UnorderedElementsAre; @@ -215,6 +217,44 @@ EXPECT_THAT(set2, UnorderedElementsAre(Elem(7, -70), Elem(17, 23))); } +bool FirstIsEven(std::pair<const int, int> p) { return p.first % 2 == 0; } + +TEST(NodeHashMap, EraseIf) { + // Erase all elements. + { + node_hash_map<int, int> s = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}; + erase_if(s, [](std::pair<const int, int>) { return true; }); + EXPECT_THAT(s, IsEmpty()); + } + // Erase no elements. + { + node_hash_map<int, int> s = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}; + erase_if(s, [](std::pair<const int, int>) { return false; }); + EXPECT_THAT(s, UnorderedElementsAre(Pair(1, 1), Pair(2, 2), Pair(3, 3), + Pair(4, 4), Pair(5, 5))); + } + // Erase specific elements. + { + node_hash_map<int, int> s = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}; + erase_if(s, + [](std::pair<const int, int> kvp) { return kvp.first % 2 == 1; }); + EXPECT_THAT(s, UnorderedElementsAre(Pair(2, 2), Pair(4, 4))); + } + // Predicate is function reference. + { + node_hash_map<int, int> s = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}; + erase_if(s, FirstIsEven); + EXPECT_THAT(s, UnorderedElementsAre(Pair(1, 1), Pair(3, 3), Pair(5, 5))); + } + // Predicate is function pointer. + { + node_hash_map<int, int> s = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}; + erase_if(s, &FirstIsEven); + EXPECT_THAT(s, UnorderedElementsAre(Pair(1, 1), Pair(3, 3), Pair(5, 5))); + } +} + } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/container/node_hash_set.h b/third_party/abseil-cpp/absl/container/node_hash_set.h index 0cd1fe5..ad54b6dc 100644 --- a/third_party/abseil-cpp/absl/container/node_hash_set.h +++ b/third_party/abseil-cpp/absl/container/node_hash_set.h
@@ -44,6 +44,7 @@ #include "absl/memory/memory.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { template <typename T> struct NodeHashSetPolicy; @@ -76,7 +77,7 @@ // // // Create a node hash set of three strings // absl::node_hash_map<std::string, std::string> ducks = -// {"huey", "dewey"}, "louie"}; +// {"huey", "dewey", "louie"}; // // // Insert a new element into the node hash map // ducks.insert("donald"}; @@ -110,7 +111,7 @@ // * Initializer List constructor // // absl::node_hash_set<std::string> set2 = - // {{"huey"}, {"dewey"}, {"louie"},}; + // {{"huey"}, {"dewey"}, {"louie"}}; // // * Copy constructor // @@ -434,6 +435,14 @@ void resize(typename Base::size_type hint) { this->rehash(hint); } }; +// erase_if(node_hash_set<>, Pred) +// +// Erases all elements that satisfy the predicate `pred` from the container `c`. +template <typename T, typename H, typename E, typename A, typename Predicate> +void erase_if(node_hash_set<T, H, E, A>& c, Predicate pred) { + container_internal::EraseIf(pred, &c); +} + namespace container_internal { template <class T> @@ -483,6 +492,7 @@ : std::true_type {}; } // namespace container_algorithm_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_CONTAINER_NODE_HASH_SET_H_
diff --git a/third_party/abseil-cpp/absl/container/node_hash_set_test.cc b/third_party/abseil-cpp/absl/container/node_hash_set_test.cc index 0ea76e7..7ddad20 100644 --- a/third_party/abseil-cpp/absl/container/node_hash_set_test.cc +++ b/third_party/abseil-cpp/absl/container/node_hash_set_test.cc
@@ -20,10 +20,12 @@ #include "absl/container/internal/unordered_set_modifiers_test.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace { using ::absl::container_internal::hash_internal::Enum; using ::absl::container_internal::hash_internal::EnumClass; +using ::testing::IsEmpty; using ::testing::Pointee; using ::testing::UnorderedElementsAre; @@ -100,6 +102,42 @@ EXPECT_THAT(set2, UnorderedElementsAre(Pointee(7), Pointee(23))); } +bool IsEven(int k) { return k % 2 == 0; } + +TEST(NodeHashSet, EraseIf) { + // Erase all elements. + { + node_hash_set<int> s = {1, 2, 3, 4, 5}; + erase_if(s, [](int) { return true; }); + EXPECT_THAT(s, IsEmpty()); + } + // Erase no elements. + { + node_hash_set<int> s = {1, 2, 3, 4, 5}; + erase_if(s, [](int) { return false; }); + EXPECT_THAT(s, UnorderedElementsAre(1, 2, 3, 4, 5)); + } + // Erase specific elements. + { + node_hash_set<int> s = {1, 2, 3, 4, 5}; + erase_if(s, [](int k) { return k % 2 == 1; }); + EXPECT_THAT(s, UnorderedElementsAre(2, 4)); + } + // Predicate is function reference. + { + node_hash_set<int> s = {1, 2, 3, 4, 5}; + erase_if(s, IsEven); + EXPECT_THAT(s, UnorderedElementsAre(1, 3, 5)); + } + // Predicate is function pointer. + { + node_hash_set<int> s = {1, 2, 3, 4, 5}; + erase_if(s, &IsEven); + EXPECT_THAT(s, UnorderedElementsAre(1, 3, 5)); + } +} + } // namespace } // namespace container_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake b/third_party/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake index 4ece4c6f..390a07a0 100644 --- a/third_party/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake +++ b/third_party/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake
@@ -5,25 +5,46 @@ set(ABSL_HAVE_LSAN OFF) set(ABSL_DEFAULT_LINKOPTS "") +if (BUILD_SHARED_LIBS AND MSVC) + set(ABSL_BUILD_DLL TRUE) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +else() + set(ABSL_BUILD_DLL FALSE) +endif() + +if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64") + if (MSVC) + set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_MSVC_X64_FLAGS}") + else() + set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_X64_FLAGS}") + endif() +elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm.*|aarch64") + if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8") + set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_ARM64_FLAGS}") + elseif("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") + set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_ARM32_FLAGS}") + else() + message(WARNING "Value of CMAKE_SIZEOF_VOID_P (${CMAKE_SIZEOF_VOID_P}) is not supported.") + endif() +else() + message(WARNING "Value of CMAKE_SYSTEM_PROCESSOR (${CMAKE_SYSTEM_PROCESSOR}) is unknown and cannot be used to set ABSL_RANDOM_RANDEN_COPTS") + set(ABSL_RANDOM_RANDEN_COPTS "") +endif() + + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(ABSL_DEFAULT_COPTS "${ABSL_GCC_FLAGS}") set(ABSL_TEST_COPTS "${ABSL_GCC_FLAGS};${ABSL_GCC_TEST_FLAGS}") - set(ABSL_EXCEPTIONS_FLAG "${ABSL_GCC_EXCEPTIONS_FLAGS}") - set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_X64_FLAGS}") elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # MATCHES so we get both Clang and AppleClang if(MSVC) # clang-cl is half MSVC, half LLVM set(ABSL_DEFAULT_COPTS "${ABSL_CLANG_CL_FLAGS}") set(ABSL_TEST_COPTS "${ABSL_CLANG_CL_FLAGS};${ABSL_CLANG_CL_TEST_FLAGS}") - set(ABSL_EXCEPTIONS_FLAG "${ABSL_CLANG_CL_EXCEPTIONS_FLAGS}") set(ABSL_DEFAULT_LINKOPTS "${ABSL_MSVC_LINKOPTS}") - set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_MSVC_X64_FLAGS}") else() set(ABSL_DEFAULT_COPTS "${ABSL_LLVM_FLAGS}") set(ABSL_TEST_COPTS "${ABSL_LLVM_FLAGS};${ABSL_LLVM_TEST_FLAGS}") - set(ABSL_EXCEPTIONS_FLAG "${ABSL_LLVM_EXCEPTIONS_FLAGS}") - set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_X64_FLAGS}") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # AppleClang doesn't have lsan # https://developer.apple.com/documentation/code_diagnostics @@ -36,25 +57,9 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(ABSL_DEFAULT_COPTS "${ABSL_MSVC_FLAGS}") set(ABSL_TEST_COPTS "${ABSL_MSVC_FLAGS};${ABSL_MSVC_TEST_FLAGS}") - set(ABSL_EXCEPTIONS_FLAG "${ABSL_MSVC_EXCEPTIONS_FLAGS}") set(ABSL_DEFAULT_LINKOPTS "${ABSL_MSVC_LINKOPTS}") - set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_MSVC_X64_FLAGS}") else() message(WARNING "Unknown compiler: ${CMAKE_CXX_COMPILER}. Building with no default flags") set(ABSL_DEFAULT_COPTS "") set(ABSL_TEST_COPTS "") - set(ABSL_EXCEPTIONS_FLAG "") - set(ABSL_RANDOM_RANDEN_COPTS "") -endif() - -# This flag is used internally for Bazel builds and is kept here for consistency -set(ABSL_EXCEPTIONS_FLAG_LINKOPTS "") - -if("${CMAKE_CXX_STANDARD}" EQUAL 98) - message(FATAL_ERROR "Abseil requires at least C++11") -elseif(NOT "${CMAKE_CXX_STANDARD}") - message(STATUS "No CMAKE_CXX_STANDARD set, assuming 11") - set(ABSL_CXX_STANDARD 11) -else() - set(ABSL_CXX_STANDARD "${CMAKE_CXX_STANDARD}") endif()
diff --git a/third_party/abseil-cpp/absl/copts/GENERATED_AbseilCopts.cmake b/third_party/abseil-cpp/absl/copts/GENERATED_AbseilCopts.cmake index 01bd40b..7ef6339b 100644 --- a/third_party/abseil-cpp/absl/copts/GENERATED_AbseilCopts.cmake +++ b/third_party/abseil-cpp/absl/copts/GENERATED_AbseilCopts.cmake
@@ -3,12 +3,6 @@ # (1) Edit absl/copts/copts.py. # (2) Run `python <path_to_absl>/copts/generate_copts.py`. -list(APPEND ABSL_CLANG_CL_EXCEPTIONS_FLAGS - "/U_HAS_EXCEPTIONS" - "/D_HAS_EXCEPTIONS=1" - "/EHsc" -) - list(APPEND ABSL_CLANG_CL_FLAGS "/W3" "-Wno-c++98-compat-pedantic" @@ -29,7 +23,6 @@ "-Wno-gcc-compat" "-Wno-global-constructors" "-Wno-exit-time-destructors" - "-Wno-nested-anon-types" "-Wno-non-modular-include-in-module" "-Wno-old-style-cast" "-Wno-range-loop-analysis" @@ -80,10 +73,6 @@ "-Wno-gnu-zero-variadic-macro-arguments" ) -list(APPEND ABSL_GCC_EXCEPTIONS_FLAGS - "-fexceptions" -) - list(APPEND ABSL_GCC_FLAGS "-Wall" "-Wextra" @@ -111,10 +100,6 @@ "-Wno-unused-private-field" ) -list(APPEND ABSL_LLVM_EXCEPTIONS_FLAGS - "-fexceptions" -) - list(APPEND ABSL_LLVM_FLAGS "-Wall" "-Wextra" @@ -137,7 +122,6 @@ "-Wno-gcc-compat" "-Wno-global-constructors" "-Wno-exit-time-destructors" - "-Wno-nested-anon-types" "-Wno-non-modular-include-in-module" "-Wno-old-style-cast" "-Wno-range-loop-analysis" @@ -183,12 +167,6 @@ "-Wno-gnu-zero-variadic-macro-arguments" ) -list(APPEND ABSL_MSVC_EXCEPTIONS_FLAGS - "/U_HAS_EXCEPTIONS" - "/D_HAS_EXCEPTIONS=1" - "/EHsc" -) - list(APPEND ABSL_MSVC_FLAGS "/W3" "/DNOMINMAX" @@ -196,6 +174,7 @@ "/D_CRT_SECURE_NO_WARNINGS" "/D_SCL_SECURE_NO_WARNINGS" "/D_ENABLE_EXTENDED_ALIGNED_STORAGE" + "/bigobj" "/wd4005" "/wd4068" "/wd4180" @@ -226,8 +205,6 @@ ) list(APPEND ABSL_RANDOM_HWAES_MSVC_X64_FLAGS - "/O2" - "/Ob2" ) list(APPEND ABSL_RANDOM_HWAES_X64_FLAGS
diff --git a/third_party/abseil-cpp/absl/copts/GENERATED_copts.bzl b/third_party/abseil-cpp/absl/copts/GENERATED_copts.bzl index 82f332f..3cc4878 100644 --- a/third_party/abseil-cpp/absl/copts/GENERATED_copts.bzl +++ b/third_party/abseil-cpp/absl/copts/GENERATED_copts.bzl
@@ -4,12 +4,6 @@ (2) Run `python <path_to_absl>/copts/generate_copts.py`. """ -ABSL_CLANG_CL_EXCEPTIONS_FLAGS = [ - "/U_HAS_EXCEPTIONS", - "/D_HAS_EXCEPTIONS=1", - "/EHsc", -] - ABSL_CLANG_CL_FLAGS = [ "/W3", "-Wno-c++98-compat-pedantic", @@ -30,7 +24,6 @@ "-Wno-gcc-compat", "-Wno-global-constructors", "-Wno-exit-time-destructors", - "-Wno-nested-anon-types", "-Wno-non-modular-include-in-module", "-Wno-old-style-cast", "-Wno-range-loop-analysis", @@ -81,10 +74,6 @@ "-Wno-gnu-zero-variadic-macro-arguments", ] -ABSL_GCC_EXCEPTIONS_FLAGS = [ - "-fexceptions", -] - ABSL_GCC_FLAGS = [ "-Wall", "-Wextra", @@ -112,10 +101,6 @@ "-Wno-unused-private-field", ] -ABSL_LLVM_EXCEPTIONS_FLAGS = [ - "-fexceptions", -] - ABSL_LLVM_FLAGS = [ "-Wall", "-Wextra", @@ -138,7 +123,6 @@ "-Wno-gcc-compat", "-Wno-global-constructors", "-Wno-exit-time-destructors", - "-Wno-nested-anon-types", "-Wno-non-modular-include-in-module", "-Wno-old-style-cast", "-Wno-range-loop-analysis", @@ -184,12 +168,6 @@ "-Wno-gnu-zero-variadic-macro-arguments", ] -ABSL_MSVC_EXCEPTIONS_FLAGS = [ - "/U_HAS_EXCEPTIONS", - "/D_HAS_EXCEPTIONS=1", - "/EHsc", -] - ABSL_MSVC_FLAGS = [ "/W3", "/DNOMINMAX", @@ -197,6 +175,7 @@ "/D_CRT_SECURE_NO_WARNINGS", "/D_SCL_SECURE_NO_WARNINGS", "/D_ENABLE_EXTENDED_ALIGNED_STORAGE", + "/bigobj", "/wd4005", "/wd4068", "/wd4180", @@ -227,8 +206,6 @@ ] ABSL_RANDOM_HWAES_MSVC_X64_FLAGS = [ - "/O2", - "/Ob2", ] ABSL_RANDOM_HWAES_X64_FLAGS = [
diff --git a/third_party/abseil-cpp/absl/copts/configure_copts.bzl b/third_party/abseil-cpp/absl/copts/configure_copts.bzl index 8c4efe77..9dd6bd0 100644 --- a/third_party/abseil-cpp/absl/copts/configure_copts.bzl +++ b/third_party/abseil-cpp/absl/copts/configure_copts.bzl
@@ -6,13 +6,12 @@ load( "//absl:copts/GENERATED_copts.bzl", - "ABSL_GCC_EXCEPTIONS_FLAGS", + "ABSL_CLANG_CL_FLAGS", + "ABSL_CLANG_CL_TEST_FLAGS", "ABSL_GCC_FLAGS", "ABSL_GCC_TEST_FLAGS", - "ABSL_LLVM_EXCEPTIONS_FLAGS", "ABSL_LLVM_FLAGS", "ABSL_LLVM_TEST_FLAGS", - "ABSL_MSVC_EXCEPTIONS_FLAGS", "ABSL_MSVC_FLAGS", "ABSL_MSVC_LINKOPTS", "ABSL_MSVC_TEST_FLAGS", @@ -36,16 +35,6 @@ "//conditions:default": ABSL_GCC_TEST_FLAGS, }) -ABSL_EXCEPTIONS_FLAG = select({ - "//absl:windows": ABSL_MSVC_EXCEPTIONS_FLAGS, - "//absl:llvm_compiler": ABSL_LLVM_EXCEPTIONS_FLAGS, - "//conditions:default": ABSL_GCC_EXCEPTIONS_FLAGS, -}) - -ABSL_EXCEPTIONS_FLAG_LINKOPTS = select({ - "//conditions:default": [], -}) - ABSL_DEFAULT_LINKOPTS = select({ "//absl:windows": ABSL_MSVC_LINKOPTS, "//conditions:default": [],
diff --git a/third_party/abseil-cpp/absl/copts/copts.py b/third_party/abseil-cpp/absl/copts/copts.py index 068abce..704ef23 100644 --- a/third_party/abseil-cpp/absl/copts/copts.py +++ b/third_party/abseil-cpp/absl/copts/copts.py
@@ -56,7 +56,6 @@ "-Wno-global-constructors", "-Wno-exit-time-destructors", ### - "-Wno-nested-anon-types", "-Wno-non-modular-include-in-module", "-Wno-old-style-cast", # Warns on preferred usage of non-POD types such as string_view @@ -109,12 +108,6 @@ "-Wno-gnu-zero-variadic-macro-arguments", ] -MSVC_STYLE_EXCEPTIONS_FLAGS = [ - "/U_HAS_EXCEPTIONS", - "/D_HAS_EXCEPTIONS=1", - "/EHsc" -] - MSVC_DEFINES = [ "/DNOMINMAX", # Don't define min and max macros (windows.h) # Don't bloat namespace with incompatible winsock versions. @@ -157,20 +150,18 @@ "-Wno-unused-parameter", "-Wno-unused-private-field", ], - "ABSL_GCC_EXCEPTIONS_FLAGS": ["-fexceptions"], "ABSL_LLVM_FLAGS": LLVM_BIG_WARNING_FLAGS + LLVM_DISABLE_WARNINGS_FLAGS, "ABSL_LLVM_TEST_FLAGS": LLVM_TEST_DISABLE_WARNINGS_FLAGS, - "ABSL_LLVM_EXCEPTIONS_FLAGS": ["-fexceptions"], "ABSL_CLANG_CL_FLAGS": (MSVC_BIG_WARNING_FLAGS + LLVM_DISABLE_WARNINGS_FLAGS + MSVC_DEFINES), "ABSL_CLANG_CL_TEST_FLAGS": LLVM_TEST_DISABLE_WARNINGS_FLAGS, - "ABSL_CLANG_CL_EXCEPTIONS_FLAGS": - MSVC_STYLE_EXCEPTIONS_FLAGS, "ABSL_MSVC_FLAGS": MSVC_BIG_WARNING_FLAGS + MSVC_DEFINES + [ + # Increase the number of sections available in object files + "/bigobj", "/wd4005", # macro-redefinition "/wd4068", # unknown pragma # qualifier applied to function type has no meaning; ignored @@ -191,8 +182,6 @@ "/wd4996", # use of deprecated symbol "/DNOMINMAX", # disable the min() and max() macros from <windows.h> ], - "ABSL_MSVC_EXCEPTIONS_FLAGS": - MSVC_STYLE_EXCEPTIONS_FLAGS, "ABSL_MSVC_LINKOPTS": [ # Object file doesn't export any previously undefined symbols "-ignore:4221", @@ -207,8 +196,5 @@ "-maes", "-msse4.1", ], - "ABSL_RANDOM_HWAES_MSVC_X64_FLAGS": [ - "/O2", # Maximize speed - "/Ob2", # Aggressive inlining - ], + "ABSL_RANDOM_HWAES_MSVC_X64_FLAGS": [], }
diff --git a/third_party/abseil-cpp/absl/debugging/BUILD.bazel b/third_party/abseil-cpp/absl/debugging/BUILD.bazel index 913cfaf..8f521bec 100644 --- a/third_party/abseil-cpp/absl/debugging/BUILD.bazel +++ b/third_party/abseil-cpp/absl/debugging/BUILD.bazel
@@ -14,6 +14,7 @@ # limitations under the License. # +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", @@ -30,6 +31,14 @@ cc_library( name = "stacktrace", srcs = [ + "internal/stacktrace_aarch64-inl.inc", + "internal/stacktrace_arm-inl.inc", + "internal/stacktrace_config.h", + "internal/stacktrace_generic-inl.inc", + "internal/stacktrace_powerpc-inl.inc", + "internal/stacktrace_unimplemented-inl.inc", + "internal/stacktrace_win32-inl.inc", + "internal/stacktrace_x86-inl.inc", "stacktrace.cc", ], hdrs = ["stacktrace.h"], @@ -37,7 +46,7 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":debugging_internal", - "//absl/base", + "//absl/base:config", "//absl/base:core_headers", ], ) @@ -55,27 +64,39 @@ "symbolize.h", ], copts = ABSL_DEFAULT_COPTS, - linkopts = ABSL_DEFAULT_LINKOPTS, + linkopts = ABSL_DEFAULT_LINKOPTS + select({ + "//absl:windows": ["-DEFAULTLIB:dbghelp.lib"], + "//conditions:default": [], + }), deps = [ ":debugging_internal", ":demangle_internal", "//absl/base", + "//absl/base:config", "//absl/base:core_headers", "//absl/base:dynamic_annotations", "//absl/base:malloc_internal", + "//absl/base:raw_logging_internal", ], ) cc_test( name = "symbolize_test", srcs = ["symbolize_test.cc"], - copts = ABSL_TEST_COPTS, - linkopts = ABSL_DEFAULT_LINKOPTS, + copts = ABSL_TEST_COPTS + select({ + "//absl:windows": ["/Z7"], + "//conditions:default": [], + }), + linkopts = ABSL_DEFAULT_LINKOPTS + select({ + "//absl:windows": ["/DEBUG"], + "//conditions:default": [], + }), deps = [ ":stack_consumption", ":symbolize", "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "//absl/memory", "@com_google_googletest//:gtest", ], @@ -95,8 +116,9 @@ deps = [ ":stacktrace", ":symbolize", - "//absl/base", + "//absl/base:config", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", ], ) @@ -112,6 +134,8 @@ "//absl/base", "//absl/base:config", "//absl/base:core_headers", + "//absl/base:errno_saver", + "//absl/base:raw_logging_internal", ], ) @@ -127,7 +151,7 @@ ":failure_signal_handler", ":stacktrace", ":symbolize", - "//absl/base", + "//absl/base:raw_logging_internal", "//absl/strings", "@com_google_googletest//:gtest", ], @@ -143,22 +167,16 @@ hdrs = [ "internal/address_is_readable.h", "internal/elf_mem_image.h", - "internal/stacktrace_aarch64-inl.inc", - "internal/stacktrace_arm-inl.inc", - "internal/stacktrace_config.h", - "internal/stacktrace_generic-inl.inc", - "internal/stacktrace_powerpc-inl.inc", - "internal/stacktrace_unimplemented-inl.inc", - "internal/stacktrace_win32-inl.inc", - "internal/stacktrace_x86-inl.inc", "internal/vdso_support.h", ], copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ - "//absl/base", + "//absl/base:config", "//absl/base:core_headers", "//absl/base:dynamic_annotations", + "//absl/base:errno_saver", + "//absl/base:raw_logging_internal", ], ) @@ -169,6 +187,7 @@ copts = ABSL_DEFAULT_COPTS, deps = [ "//absl/base", + "//absl/base:config", "//absl/base:core_headers", ], ) @@ -181,8 +200,8 @@ deps = [ ":demangle_internal", ":stack_consumption", - "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "//absl/memory", "@com_google_googletest//:gtest_main", ], @@ -193,7 +212,10 @@ srcs = ["leak_check.cc"], hdrs = ["leak_check.h"], linkopts = ABSL_DEFAULT_LINKOPTS, - deps = ["//absl/base:core_headers"], + deps = [ + "//absl/base:config", + "//absl/base:core_headers", + ], ) # Adding a dependency to leak_check_disable will disable @@ -204,6 +226,7 @@ srcs = ["leak_check_disable.cc"], linkopts = ABSL_DEFAULT_LINKOPTS, linkstatic = 1, + deps = ["//absl/base:config"], alwayslink = 1, ) @@ -225,6 +248,9 @@ }), linkopts = ABSL_DEFAULT_LINKOPTS, visibility = ["//visibility:private"], + deps = [ + "//absl/base:config", + ], ) cc_library( @@ -235,6 +261,9 @@ copts = ["-ULEAK_SANITIZER"], linkopts = ABSL_DEFAULT_LINKOPTS, visibility = ["//visibility:private"], + deps = [ + "//absl/base:config", + ], ) cc_test( @@ -292,8 +321,9 @@ linkopts = ABSL_DEFAULT_LINKOPTS, visibility = ["//visibility:private"], deps = [ - "//absl/base", + "//absl/base:config", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", ], ) @@ -304,8 +334,8 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":stack_consumption", - "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "@com_google_googletest//:gtest_main", ], )
diff --git a/third_party/abseil-cpp/absl/debugging/BUILD.gn b/third_party/abseil-cpp/absl/debugging/BUILD.gn index 7829314..428e534 100644 --- a/third_party/abseil-cpp/absl/debugging/BUILD.gn +++ b/third_party/abseil-cpp/absl/debugging/BUILD.gn
@@ -25,12 +25,23 @@ "//third_party/abseil-cpp:absl_default_cflags_cc", ] public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] - sources = [ "stacktrace.cc" ] + sources = [ + "internal/stacktrace_aarch64-inl.inc", + "internal/stacktrace_arm-inl.inc", + "internal/stacktrace_config.h", + "internal/stacktrace_generic-inl.inc", + "internal/stacktrace_powerpc-inl.inc", + "internal/stacktrace_unimplemented-inl.inc", + "internal/stacktrace_win32-inl.inc", + "internal/stacktrace_x86-inl.inc", + "stacktrace.cc", + ] public = [ "stacktrace.h" ] deps = [ ":debugging_internal", - "../base", + "../base:config", "../base:core_headers", + "../base:raw_logging_internal", ] } @@ -55,10 +66,15 @@ ":debugging_internal", ":demangle_internal", "../base", + "../base:config", "../base:core_headers", "../base:dynamic_annotations", "../base:malloc_internal", + "../base:raw_logging_internal", ] + # TODO(mbonadei): The bazel file has: + # -DEFAULTLIB:dbghelp.lib + # evaluate if this needs to be added here as well. } source_set("examine_stack") { @@ -75,8 +91,9 @@ deps = [ ":stacktrace", ":symbolize", - "../base", + "../base:config", "../base:core_headers", + "../base:raw_logging_internal", ] } @@ -95,6 +112,8 @@ "../base", "../base:config", "../base:core_headers", + "../base:errno_saver", + "../base:raw_logging_internal", ] } @@ -113,13 +132,14 @@ public = [ "internal/address_is_readable.h", "internal/elf_mem_image.h", - "internal/stacktrace_config.h", "internal/vdso_support.h", ] deps = [ - "../base", + "../base:config", "../base:core_headers", "../base:dynamic_annotations", + "../base:errno_saver", + "../base:raw_logging_internal", ] } @@ -134,6 +154,7 @@ public = [ "internal/demangle.h" ] deps = [ "../base", + "../base:config", "../base:core_headers", ] } @@ -152,7 +173,10 @@ sources = [ "leak_check.cc" ] public = [ "leak_check.h" ] } - deps = [ "../base:core_headers" ] + deps = [ + "../base:config", + "../base:core_headers", + ] } source_set("leak_check_disable") { @@ -163,6 +187,7 @@ ] public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] sources = [ "leak_check_disable.cc" ] + deps = [ "../base:config" ] } if (is_lsan) { @@ -178,6 +203,7 @@ public = [ "leak_check.h" ] visibility = [] visibility += [ ":*" ] + deps = [ "../base:config" ] } } else { source_set("leak_check_api_disabled_for_testing") { @@ -192,6 +218,7 @@ public = [ "leak_check.h" ] visibility = [] visibility += [ ":*" ] + deps = [ "../base:config" ] } } @@ -206,8 +233,9 @@ sources = [ "internal/stack_consumption.cc" ] public = [ "internal/stack_consumption.h" ] deps = [ - "../base", + "../base:config", "../base:core_headers", + "../base:raw_logging_internal", ] visibility = [] visibility += [ ":*" ]
diff --git a/third_party/abseil-cpp/absl/debugging/CMakeLists.txt b/third_party/abseil-cpp/absl/debugging/CMakeLists.txt index 001e2727..7733615 100644 --- a/third_party/abseil-cpp/absl/debugging/CMakeLists.txt +++ b/third_party/abseil-cpp/absl/debugging/CMakeLists.txt
@@ -19,13 +19,21 @@ stacktrace HDRS "stacktrace.h" + "internal/stacktrace_aarch64-inl.inc" + "internal/stacktrace_arm-inl.inc" + "internal/stacktrace_config.h" + "internal/stacktrace_generic-inl.inc" + "internal/stacktrace_powerpc-inl.inc" + "internal/stacktrace_unimplemented-inl.inc" + "internal/stacktrace_win32-inl.inc" + "internal/stacktrace_x86-inl.inc" SRCS "stacktrace.cc" COPTS ${ABSL_DEFAULT_COPTS} DEPS absl::debugging_internal - absl::base + absl::config absl::core_headers PUBLIC ) @@ -45,13 +53,16 @@ ${ABSL_DEFAULT_COPTS} LINKOPTS ${ABSL_DEFAULT_LINKOPTS} + $<$<BOOL:${MINGW}>:"dbghelp"> DEPS absl::debugging_internal absl::demangle_internal absl::base + absl::config absl::core_headers absl::dynamic_annotations absl::malloc_internal + absl::raw_logging_internal PUBLIC ) @@ -62,12 +73,16 @@ "symbolize_test.cc" COPTS ${ABSL_TEST_COPTS} + $<$<BOOL:${MSVC}>:-Z7> + LINKOPTS + $<$<BOOL:${MSVC}>:-DEBUG> DEPS absl::stack_consumption absl::symbolize absl::base absl::core_headers absl::memory + absl::raw_logging_internal gmock ) @@ -83,8 +98,9 @@ DEPS absl::stacktrace absl::symbolize - absl::base + absl::config absl::core_headers + absl::raw_logging_internal ) absl_cc_library( @@ -102,6 +118,8 @@ absl::base absl::config absl::core_headers + absl::errno_saver + absl::raw_logging_internal PUBLIC ) @@ -116,8 +134,8 @@ absl::failure_signal_handler absl::stacktrace absl::symbolize - absl::base absl::strings + absl::raw_logging_internal Threads::Threads gmock ) @@ -128,14 +146,6 @@ HDRS "internal/address_is_readable.h" "internal/elf_mem_image.h" - "internal/stacktrace_aarch64-inl.inc" - "internal/stacktrace_arm-inl.inc" - "internal/stacktrace_config.h" - "internal/stacktrace_generic-inl.inc" - "internal/stacktrace_powerpc-inl.inc" - "internal/stacktrace_unimplemented-inl.inc" - "internal/stacktrace_win32-inl.inc" - "internal/stacktrace_x86-inl.inc" "internal/vdso_support.h" SRCS "internal/address_is_readable.cc" @@ -144,9 +154,11 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::base absl::core_headers + absl::config absl::dynamic_annotations + absl::errno_saver + absl::raw_logging_internal ) absl_cc_library( @@ -174,9 +186,9 @@ DEPS absl::demangle_internal absl::stack_consumption - absl::base absl::core_headers absl::memory + absl::raw_logging_internal gmock_main ) @@ -190,6 +202,7 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS + absl::config absl::core_headers PUBLIC ) @@ -236,7 +249,7 @@ SRCS "leak_check_test.cc" COPTS - ${ABSL_DEFAULT_COPTS} + ${ABSL_TEST_COPTS} "$<$<BOOL:${ABSL_HAVE_LSAN}>:-DABSL_EXPECT_LEAK_SANITIZER>" LINKOPTS "${ABSL_LSAN_LINKOPTS}" @@ -273,6 +286,7 @@ absl::leak_check_api_enabled_for_testing absl::leak_check_disable absl::base + absl::raw_logging_internal gmock_main ) @@ -286,8 +300,9 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::base + absl::config absl::core_headers + absl::raw_logging_internal TESTONLY ) @@ -300,8 +315,8 @@ ${ABSL_TEST_COPTS} DEPS absl::stack_consumption - absl::base absl::core_headers + absl::raw_logging_internal gmock_main )
diff --git a/third_party/abseil-cpp/absl/debugging/failure_signal_handler.cc b/third_party/abseil-cpp/absl/debugging/failure_signal_handler.cc index c6a4d96..1f69bfa8 100644 --- a/third_party/abseil-cpp/absl/debugging/failure_signal_handler.cc +++ b/third_party/abseil-cpp/absl/debugging/failure_signal_handler.cc
@@ -24,6 +24,10 @@ #include <unistd.h> #endif +#ifdef __APPLE__ +#include <TargetConditionals.h> +#endif + #ifdef ABSL_HAVE_MMAP #include <sys/mman.h> #endif @@ -37,6 +41,7 @@ #include <ctime> #include "absl/base/attributes.h" +#include "absl/base/internal/errno_saver.h" #include "absl/base/internal/raw_logging.h" #include "absl/base/internal/sysinfo.h" #include "absl/debugging/internal/examine_stack.h" @@ -44,9 +49,15 @@ #ifndef _WIN32 #define ABSL_HAVE_SIGACTION +// Apple WatchOS and TVOS don't allow sigaltstack +#if !(defined(TARGET_OS_WATCH) && TARGET_OS_WATCH) && \ + !(defined(TARGET_OS_TV) && TARGET_OS_TV) +#define ABSL_HAVE_SIGALTSTACK +#endif #endif namespace absl { +ABSL_NAMESPACE_BEGIN ABSL_CONST_INIT static FailureSignalHandlerOptions fsh_options; @@ -116,7 +127,7 @@ } // namespace debugging_internal -#ifndef _WIN32 +#ifdef ABSL_HAVE_SIGALTSTACK static bool SetupAlternateStackOnce() { #if defined(__wasm__) || defined (__asjms__) @@ -168,7 +179,7 @@ // Returns the appropriate flag for sig_action.sa_flags // if the system supports using an alternate stack. static int MaybeSetupAlternateStack() { -#ifndef _WIN32 +#ifdef ABSL_HAVE_SIGALTSTACK ABSL_ATTRIBUTE_UNUSED static const bool kOnce = SetupAlternateStackOnce(); return SA_ONSTACK; #else @@ -204,9 +215,8 @@ #endif static void WriteToStderr(const char* data) { - int old_errno = errno; + absl::base_internal::ErrnoSaver errno_saver; absl::raw_logging_internal::SafeWriteToStderr(data, strlen(data)); - errno = old_errno; } static void WriteSignalMessage(int signo, void (*writerfn)(const char*)) { @@ -356,4 +366,5 @@ } } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/debugging/failure_signal_handler.h b/third_party/abseil-cpp/absl/debugging/failure_signal_handler.h index 1beb78b9..0c0f585 100644 --- a/third_party/abseil-cpp/absl/debugging/failure_signal_handler.h +++ b/third_party/abseil-cpp/absl/debugging/failure_signal_handler.h
@@ -44,7 +44,10 @@ #ifndef ABSL_DEBUGGING_FAILURE_SIGNAL_HANDLER_H_ #define ABSL_DEBUGGING_FAILURE_SIGNAL_HANDLER_H_ +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN // FailureSignalHandlerOptions // @@ -85,7 +88,7 @@ bool call_previous_handler = false; // If non-null, indicates a pointer to a callback function that will be called - // upon failure, with a std::string argument containing failure data. This function + // upon failure, with a string argument containing failure data. This function // may be used as a hook to write failure data to a secondary location, such // as a log file. This function may also be called with null data, as a hint // to flush any buffered data before the program may be terminated. Consider @@ -112,6 +115,7 @@ const char* FailureSignalToString(int signo); } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_FAILURE_SIGNAL_HANDLER_H_
diff --git a/third_party/abseil-cpp/absl/debugging/failure_signal_handler_test.cc b/third_party/abseil-cpp/absl/debugging/failure_signal_handler_test.cc index bb2cc48..863fb514 100644 --- a/third_party/abseil-cpp/absl/debugging/failure_signal_handler_test.cc +++ b/third_party/abseil-cpp/absl/debugging/failure_signal_handler_test.cc
@@ -23,6 +23,7 @@ #include <fstream> #include "gtest/gtest.h" +#include "gmock/gmock.h" #include "absl/base/internal/raw_logging.h" #include "absl/debugging/stacktrace.h" #include "absl/debugging/symbolize.h" @@ -31,6 +32,8 @@ namespace { +using testing::StartsWith; + #if GTEST_HAS_DEATH_TEST // For the parameterized death tests. GetParam() returns the signal number. @@ -113,15 +116,15 @@ ASSERT_TRUE(error_output.is_open()) << file; std::string error_line; std::getline(error_output, error_line); - EXPECT_TRUE(absl::StartsWith( + EXPECT_THAT( error_line, - absl::StrCat("*** ", - absl::debugging_internal::FailureSignalToString(signo), - " received at "))); + StartsWith(absl::StrCat( + "*** ", absl::debugging_internal::FailureSignalToString(signo), + " received at "))); if (absl::debugging_internal::StackTraceWorksForTest()) { std::getline(error_output, error_line); - EXPECT_TRUE(absl::StartsWith(error_line, "PC: ")); + EXPECT_THAT(error_line, StartsWith("PC: ")); } }
diff --git a/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc b/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc index 99c4c64..6537606 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc +++ b/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc
@@ -20,12 +20,14 @@ #if !defined(__linux__) || defined(__ANDROID__) namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // On platforms other than Linux, just return true. bool AddressIsReadable(const void* /* addr */) { return true; } } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #else @@ -33,13 +35,16 @@ #include <fcntl.h> #include <sys/syscall.h> #include <unistd.h> + #include <atomic> #include <cerrno> #include <cstdint> +#include "absl/base/internal/errno_saver.h" #include "absl/base/internal/raw_logging.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // Pack a pid and two file descriptors into a 64-bit word, @@ -64,7 +69,7 @@ // This is a namespace-scoped variable for correct zero-initialization. static std::atomic<uint64_t> pid_and_fds; // initially 0, an invalid pid. bool AddressIsReadable(const void *addr) { - int save_errno = errno; + absl::base_internal::ErrnoSaver errno_saver; // We test whether a byte is readable by using write(). Normally, this would // be done via a cached file descriptor to /dev/null, but linux fails to // check whether the byte is readable when the destination is /dev/null, so @@ -123,11 +128,11 @@ std::memory_order_relaxed); } } while (errno == EBADF); - errno = save_errno; return bytes_written == 1; } } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif
diff --git a/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.h b/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.h index ca8003e..4bbaf4d 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.h +++ b/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.h
@@ -15,7 +15,10 @@ #ifndef ABSL_DEBUGGING_INTERNAL_ADDRESS_IS_READABLE_H_ #define ABSL_DEBUGGING_INTERNAL_ADDRESS_IS_READABLE_H_ +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // Return whether the byte at *addr is readable, without faulting. @@ -23,6 +26,7 @@ bool AddressIsReadable(const void *addr); } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_INTERNAL_ADDRESS_IS_READABLE_H_
diff --git a/third_party/abseil-cpp/absl/debugging/internal/demangle.cc b/third_party/abseil-cpp/absl/debugging/internal/demangle.cc index 52a553f..fc262e50 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +++ b/third_party/abseil-cpp/absl/debugging/internal/demangle.cc
@@ -24,6 +24,7 @@ #include <limits> namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { typedef struct { @@ -93,6 +94,8 @@ }; // List of builtin types from Itanium C++ ABI. +// +// Invariant: only one- or two-character type abbreviations here. static const AbbrevPair kBuiltinTypeList[] = { {"v", "void", 0}, {"w", "wchar_t", 0}, @@ -115,6 +118,16 @@ {"e", "long double", 0}, {"g", "__float128", 0}, {"z", "ellipsis", 0}, + + {"De", "decimal128", 0}, // IEEE 754r decimal floating point (128 bits) + {"Dd", "decimal64", 0}, // IEEE 754r decimal floating point (64 bits) + {"Dc", "decltype(auto)", 0}, + {"Da", "auto", 0}, + {"Dn", "std::nullptr_t", 0}, // i.e., decltype(nullptr) + {"Df", "decimal32", 0}, // IEEE 754r decimal floating point (32 bits) + {"Di", "char32_t", 0}, + {"Ds", "char16_t", 0}, + {"Dh", "float16", 0}, // IEEE 754r half-precision float (16 bits) {nullptr, nullptr, 0}, }; @@ -138,7 +151,7 @@ // frame, so every byte counts. typedef struct { int mangled_idx; // Cursor of mangled name. - int out_cur_idx; // Cursor of output std::string. + int out_cur_idx; // Cursor of output string. int prev_name_idx; // For constructors/destructors. signed int prev_name_length : 16; // For constructors/destructors. signed int nest_level : 15; // For nested names. @@ -159,8 +172,8 @@ // Only one copy of this exists for each call to Demangle, so the size of this // struct is nearly inconsequential. typedef struct { - const char *mangled_begin; // Beginning of input std::string. - char *out; // Beginning of output std::string. + const char *mangled_begin; // Beginning of input string. + char *out; // Beginning of output string. int out_end_idx; // One past last allowed output character. int recursion_depth; // For stack exhaustion prevention. int steps; // Cap how much work we'll do, regardless of depth. @@ -1168,12 +1181,6 @@ } state->parse_state = copy; - // nullptr_t, i.e. decltype(nullptr). - if (ParseTwoCharToken(state, "Dn")) { - return true; - } - state->parse_state = copy; - if (ParseOneCharToken(state, 'U') && ParseSourceName(state) && ParseType(state)) { return true; @@ -1214,16 +1221,26 @@ return num_cv_qualifiers > 0; } -// <builtin-type> ::= v, etc. +// <builtin-type> ::= v, etc. # single-character builtin types // ::= u <source-name> +// ::= Dd, etc. # two-character builtin types +// +// Not supported: +// ::= DF <number> _ # _FloatN (N bits) +// static bool ParseBuiltinType(State *state) { ComplexityGuard guard(state); if (guard.IsTooComplex()) return false; const AbbrevPair *p; for (p = kBuiltinTypeList; p->abbrev != nullptr; ++p) { - if (RemainingInput(state)[0] == p->abbrev[0]) { + // Guaranteed only 1- or 2-character strings in kBuiltinTypeList. + if (p->abbrev[1] == '\0') { + if (ParseOneCharToken(state, p->abbrev[0])) { + MaybeAppend(state, p->real_name); + return true; + } + } else if (p->abbrev[2] == '\0' && ParseTwoCharToken(state, p->abbrev)) { MaybeAppend(state, p->real_name); - ++state->parse_state.mangled_idx; return true; } } @@ -1874,4 +1891,5 @@ } } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/debugging/internal/demangle.h b/third_party/abseil-cpp/absl/debugging/internal/demangle.h index 81bb0df..c314d9bc 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/demangle.h +++ b/third_party/abseil-cpp/absl/debugging/internal/demangle.h
@@ -53,7 +53,10 @@ #ifndef ABSL_DEBUGGING_INTERNAL_DEMANGLE_H_ #define ABSL_DEBUGGING_INTERNAL_DEMANGLE_H_ +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // Demangle `mangled`. On success, return true and write the @@ -62,6 +65,7 @@ bool Demangle(const char *mangled, char *out, int out_size); } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_INTERNAL_DEMANGLE_H_
diff --git a/third_party/abseil-cpp/absl/debugging/internal/demangle_test.cc b/third_party/abseil-cpp/absl/debugging/internal/demangle_test.cc index a68ce324..c6f1ce1 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/demangle_test.cc +++ b/third_party/abseil-cpp/absl/debugging/internal/demangle_test.cc
@@ -23,6 +23,7 @@ #include "absl/memory/memory.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { namespace { @@ -190,4 +191,5 @@ } // namespace } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc b/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc index e7408bca..24cc013 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc +++ b/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc
@@ -38,6 +38,7 @@ #define VERSYM_VERSION 0x7fff namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { namespace { @@ -375,6 +376,7 @@ } } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_HAVE_ELF_MEM_IMAGE
diff --git a/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h b/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h index d84200d..46bfade3 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +++ b/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h
@@ -23,6 +23,8 @@ // used. #include <climits> +#include "absl/base/config.h" + // Maybe one day we can rewrite this file not to require the elf // symbol extensions in glibc, but for right now we need them. #ifdef ABSL_HAVE_ELF_MEM_IMAGE @@ -39,6 +41,7 @@ #include <link.h> // for ElfW namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // An in-memory ELF image (may not exist on disk). @@ -123,6 +126,7 @@ }; } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_HAVE_ELF_MEM_IMAGE
diff --git a/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc b/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc index 1ebc788..a3dd893 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc +++ b/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc
@@ -30,6 +30,7 @@ #include "absl/debugging/symbolize.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // Returns the program counter from signal context, nullptr if @@ -52,6 +53,8 @@ return reinterpret_cast<void*>(context->uc_mcontext.gp_regs[32]); #elif defined(__powerpc__) return reinterpret_cast<void*>(context->uc_mcontext.regs->nip); +#elif defined(__riscv) + return reinterpret_cast<void*>(context->uc_mcontext.__gregs[REG_PC]); #elif defined(__s390__) && !defined(__s390x__) return reinterpret_cast<void*>(context->uc_mcontext.psw.addr & 0x7fffffff); #elif defined(__s390__) && defined(__s390x__) @@ -150,4 +153,5 @@ } } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/debugging/internal/examine_stack.h b/third_party/abseil-cpp/absl/debugging/internal/examine_stack.h index 56c9763..3933691 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/examine_stack.h +++ b/third_party/abseil-cpp/absl/debugging/internal/examine_stack.h
@@ -17,7 +17,10 @@ #ifndef ABSL_DEBUGGING_INTERNAL_EXAMINE_STACK_H_ #define ABSL_DEBUGGING_INTERNAL_EXAMINE_STACK_H_ +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // Returns the program counter from signal context, or nullptr if @@ -33,6 +36,7 @@ void (*writerfn)(const char*, void*), void* writerfn_arg); } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_INTERNAL_EXAMINE_STACK_H_
diff --git a/third_party/abseil-cpp/absl/debugging/internal/stack_consumption.cc b/third_party/abseil-cpp/absl/debugging/internal/stack_consumption.cc index 4b05f49..875ca6d9 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/stack_consumption.cc +++ b/third_party/abseil-cpp/absl/debugging/internal/stack_consumption.cc
@@ -27,6 +27,7 @@ #include "absl/base/internal/raw_logging.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { namespace { @@ -115,10 +116,11 @@ // Set up the alt-signal-stack (and save the older one). stack_t sigstk; memset(&sigstk, 0, sizeof(sigstk)); - stack_t old_sigstk; sigstk.ss_sp = altstack; sigstk.ss_size = kAlternateStackSize; sigstk.ss_flags = 0; + stack_t old_sigstk; + memset(&old_sigstk, 0, sizeof(old_sigstk)); ABSL_RAW_CHECK(sigaltstack(&sigstk, &old_sigstk) == 0, "sigaltstack() failed"); @@ -152,6 +154,15 @@ int signal_handler_stack_consumption = GetStackConsumption(altstack); // Now restore the old alt-signal-stack and signal handlers. + if (old_sigstk.ss_sp == nullptr && old_sigstk.ss_size == 0 && + (old_sigstk.ss_flags & SS_DISABLE)) { + // https://git.musl-libc.org/cgit/musl/commit/src/signal/sigaltstack.c?id=7829f42a2c8944555439380498ab8b924d0f2070 + // The original stack has ss_size==0 and ss_flags==SS_DISABLE, but some + // versions of musl have a bug that rejects ss_size==0. Work around this by + // setting ss_size to MINSIGSTKSZ, which should be ignored by the kernel + // when SS_DISABLE is set. + old_sigstk.ss_size = MINSIGSTKSZ; + } ABSL_RAW_CHECK(sigaltstack(&old_sigstk, nullptr) == 0, "sigaltstack() failed"); ABSL_RAW_CHECK(sigaction(SIGUSR1, &old_sa1, nullptr) == 0, @@ -167,6 +178,7 @@ } } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION
diff --git a/third_party/abseil-cpp/absl/debugging/internal/stack_consumption.h b/third_party/abseil-cpp/absl/debugging/internal/stack_consumption.h index b860a3c..5e60ec4 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/stack_consumption.h +++ b/third_party/abseil-cpp/absl/debugging/internal/stack_consumption.h
@@ -18,6 +18,8 @@ #ifndef ABSL_DEBUGGING_INTERNAL_STACK_CONSUMPTION_H_ #define ABSL_DEBUGGING_INTERNAL_STACK_CONSUMPTION_H_ +#include "absl/base/config.h" + // The code in this module is not portable. // Use this feature test macro to detect its availability. #ifdef ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION @@ -27,6 +29,7 @@ #define ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION 1 namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // Returns the stack consumption in bytes for the code exercised by @@ -38,6 +41,7 @@ int GetSignalHandlerStackConsumption(void (*signal_handler)(int)); } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION
diff --git a/third_party/abseil-cpp/absl/debugging/internal/stack_consumption_test.cc b/third_party/abseil-cpp/absl/debugging/internal/stack_consumption_test.cc index 68bfa12..80445bf 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/stack_consumption_test.cc +++ b/third_party/abseil-cpp/absl/debugging/internal/stack_consumption_test.cc
@@ -23,6 +23,7 @@ #include "absl/base/internal/raw_logging.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { namespace { @@ -43,6 +44,7 @@ } // namespace } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION
diff --git a/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc b/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc index 7ed6b3e..411ea308 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +++ b/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc
@@ -180,11 +180,13 @@ } namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { bool StackTraceWorksForTest() { return true; } } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_AARCH64_INL_H_
diff --git a/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc b/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc index c8408337..fffda968 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +++ b/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc
@@ -113,11 +113,13 @@ } namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { bool StackTraceWorksForTest() { return false; } } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_ARM_INL_H_
diff --git a/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc b/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc index 2e876fe..ac034c9 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +++ b/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc
@@ -16,6 +16,7 @@ #include <cstring> #include "absl/debugging/stacktrace.h" +#include "absl/base/attributes.h" // Sometimes, we can try to get a stack trace from within a stack // trace, because we don't block signals inside this code (which would be too @@ -35,7 +36,7 @@ static std::atomic<bool> disable_stacktraces(true); // Disabled until healthy. // Waiting until static initializers run seems to be late enough. // This file is included into stacktrace.cc so this will only run once. -static int stacktraces_enabler = []() { +ABSL_ATTRIBUTE_UNUSED static int stacktraces_enabler = []() { void* unused_stack[1]; // Force the first backtrace to happen early to get the one-time shared lib // loading (allocation) out of the way. After the first call it is much safer @@ -86,11 +87,13 @@ } namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { bool StackTraceWorksForTest() { return true; } } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_GENERIC_INL_H_
diff --git a/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc b/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc index 3a070ee..2e7c2f4 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +++ b/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc
@@ -236,11 +236,13 @@ } namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { bool StackTraceWorksForTest() { return true; } } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_POWERPC_INL_H_
diff --git a/third_party/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc b/third_party/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc index e256fdd4..5b8fb191b 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc +++ b/third_party/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc
@@ -12,11 +12,13 @@ } namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { bool StackTraceWorksForTest() { return false; } } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_UNIMPLEMENTED_INL_H_
diff --git a/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc b/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc index b46491f..1c666c8b 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +++ b/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc
@@ -46,15 +46,23 @@ OUT PVOID *backtrace, OUT PULONG backtrace_hash); +// It is not possible to load RtlCaptureStackBackTrace at static init time in +// UWP. CaptureStackBackTrace is the public version of RtlCaptureStackBackTrace +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ + !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +static RtlCaptureStackBackTrace_Function* const RtlCaptureStackBackTrace_fn = + &::CaptureStackBackTrace; +#else // Load the function we need at static init time, where we don't have // to worry about someone else holding the loader's lock. static RtlCaptureStackBackTrace_Function* const RtlCaptureStackBackTrace_fn = - (RtlCaptureStackBackTrace_Function*) - GetProcAddress(GetModuleHandleA("ntdll.dll"), "RtlCaptureStackBackTrace"); + (RtlCaptureStackBackTrace_Function*)GetProcAddress( + GetModuleHandleA("ntdll.dll"), "RtlCaptureStackBackTrace"); +#endif // WINAPI_PARTITION_APP && !WINAPI_PARTITION_DESKTOP template <bool IS_STACK_FRAMES, bool IS_WITH_CONTEXT> static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count, - const void *ucp, int *min_dropped_frames) { + const void*, int* min_dropped_frames) { int n = 0; if (!RtlCaptureStackBackTrace_fn) { // can't find a stacktrace with no function to call @@ -73,11 +81,13 @@ } namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { bool StackTraceWorksForTest() { return false; } } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_WIN32_INL_H_
diff --git a/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc b/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc index 25aa8bdf..bc320ff 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +++ b/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc
@@ -36,6 +36,8 @@ #include "absl/base/internal/raw_logging.h" +using absl::debugging_internal::AddressIsReadable; + #if defined(__linux__) && defined(__i386__) // Count "push %reg" instructions in VDSO __kernel_vsyscall(), // preceeding "syscall" or "sysenter". @@ -81,7 +83,7 @@ // "mov reg,reg" if (addr[i + 1] == 0xE5) { // Found "mov %esp,%ebp". - return 0; + return 0; } ++i; // Skip register encoding byte. } else if (addr[i] == 0x0F && @@ -171,6 +173,7 @@ static const unsigned char *kernel_rt_sigreturn_address = nullptr; static const unsigned char *kernel_vsyscall_address = nullptr; if (num_push_instructions == -1) { +#ifdef ABSL_HAVE_VDSO_SUPPORT absl::debugging_internal::VDSOSupport vdso; if (vdso.IsPresent()) { absl::debugging_internal::VDSOSupport::SymbolInfo @@ -199,6 +202,9 @@ } else { num_push_instructions = 0; } +#else // ABSL_HAVE_VDSO_SUPPORT + num_push_instructions = 0; +#endif // ABSL_HAVE_VDSO_SUPPORT } if (num_push_instructions != 0 && kernel_rt_sigreturn_address != nullptr && old_fp[1] == kernel_rt_sigreturn_address) { @@ -222,7 +228,7 @@ // "double fault" in case we hit the first fault due to e.g. stack // corruption. void *const reg_esp2 = reg_esp[num_push_instructions - 1]; - if (absl::debugging_internal::AddressIsReadable(reg_esp2)) { + if (AddressIsReadable(reg_esp2)) { // Alleged %esp is readable, use it for further unwinding. new_fp = reinterpret_cast<void **>(reg_esp2); } @@ -274,7 +280,7 @@ // Note: NextStackFrame<false>() is only called while the program // is already on its last leg, so it's ok to be slow here. - if (!absl::debugging_internal::AddressIsReadable(new_fp)) { + if (!AddressIsReadable(new_fp)) { return nullptr; } } @@ -328,11 +334,13 @@ } namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { bool StackTraceWorksForTest() { return true; } } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_X86_INL_INC_
diff --git a/third_party/abseil-cpp/absl/debugging/internal/symbolize.h b/third_party/abseil-cpp/absl/debugging/internal/symbolize.h index 3e537893..5d0858b 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +++ b/third_party/abseil-cpp/absl/debugging/internal/symbolize.h
@@ -21,6 +21,8 @@ #include <cstddef> #include <cstdint> +#include "absl/base/config.h" + #ifdef ABSL_INTERNAL_HAVE_ELF_SYMBOLIZE #error ABSL_INTERNAL_HAVE_ELF_SYMBOLIZE cannot be directly set #elif defined(__ELF__) && defined(__GLIBC__) && !defined(__native_client__) && \ @@ -33,6 +35,7 @@ #include <string> namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // Iterates over all sections, invoking callback on each with the section name @@ -51,11 +54,13 @@ ElfW(Shdr) *out); } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_INTERNAL_HAVE_ELF_SYMBOLIZE namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { struct SymbolDecoratorArgs { @@ -117,6 +122,7 @@ const char** filename); } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_INTERNAL_SYMBOLIZE_H_
diff --git a/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc b/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc index 23c3084..b960cc4 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +++ b/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc
@@ -38,6 +38,7 @@ #endif namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { ABSL_CONST_INIT @@ -187,6 +188,7 @@ } vdso_init_helper; } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_HAVE_VDSO_SUPPORT
diff --git a/third_party/abseil-cpp/absl/debugging/internal/vdso_support.h b/third_party/abseil-cpp/absl/debugging/internal/vdso_support.h index 9895b48..6562c6c23 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/vdso_support.h +++ b/third_party/abseil-cpp/absl/debugging/internal/vdso_support.h
@@ -53,6 +53,7 @@ #endif namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // NOTE: this class may be used from within tcmalloc, and can not @@ -149,6 +150,7 @@ int GetCPU(); } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_HAVE_ELF_MEM_IMAGE
diff --git a/third_party/abseil-cpp/absl/debugging/leak_check.cc b/third_party/abseil-cpp/absl/debugging/leak_check.cc index ffe3d1b..ff90495 100644 --- a/third_party/abseil-cpp/absl/debugging/leak_check.cc +++ b/third_party/abseil-cpp/absl/debugging/leak_check.cc
@@ -21,12 +21,14 @@ #ifndef LEAK_SANITIZER namespace absl { +ABSL_NAMESPACE_BEGIN bool HaveLeakSanitizer() { return false; } void DoIgnoreLeak(const void*) { } void RegisterLivePointers(const void*, size_t) { } void UnRegisterLivePointers(const void*, size_t) { } LeakCheckDisabler::LeakCheckDisabler() { } LeakCheckDisabler::~LeakCheckDisabler() { } +ABSL_NAMESPACE_END } // namespace absl #else @@ -34,6 +36,7 @@ #include <sanitizer/lsan_interface.h> namespace absl { +ABSL_NAMESPACE_BEGIN bool HaveLeakSanitizer() { return true; } void DoIgnoreLeak(const void* ptr) { __lsan_ignore_object(ptr); } void RegisterLivePointers(const void* ptr, size_t size) { @@ -44,6 +47,7 @@ } LeakCheckDisabler::LeakCheckDisabler() { __lsan_disable(); } LeakCheckDisabler::~LeakCheckDisabler() { __lsan_enable(); } +ABSL_NAMESPACE_END } // namespace absl #endif // LEAK_SANITIZER
diff --git a/third_party/abseil-cpp/absl/debugging/leak_check.h b/third_party/abseil-cpp/absl/debugging/leak_check.h index 4d489c5..7a5a22d 100644 --- a/third_party/abseil-cpp/absl/debugging/leak_check.h +++ b/third_party/abseil-cpp/absl/debugging/leak_check.h
@@ -32,7 +32,10 @@ #include <cstddef> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN // HaveLeakSanitizer() // @@ -104,6 +107,7 @@ // `RegisterLivePointers()`, enabling leak checking of those pointers. void UnRegisterLivePointers(const void* ptr, size_t size); +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_LEAK_CHECK_H_
diff --git a/third_party/abseil-cpp/absl/debugging/leak_check_fail_test.cc b/third_party/abseil-cpp/absl/debugging/leak_check_fail_test.cc index 2887cea..c49b81a9 100644 --- a/third_party/abseil-cpp/absl/debugging/leak_check_fail_test.cc +++ b/third_party/abseil-cpp/absl/debugging/leak_check_fail_test.cc
@@ -25,7 +25,7 @@ // failed exit code. char* foo = strdup("lsan should complain about this leaked string"); - ABSL_RAW_LOG(INFO, "Should detect leaked std::string %s", foo); + ABSL_RAW_LOG(INFO, "Should detect leaked string %s", foo); } TEST(LeakCheckTest, LeakMemoryAfterDisablerScope) { @@ -34,7 +34,7 @@ // failed exit code. { absl::LeakCheckDisabler disabler; } char* foo = strdup("lsan should also complain about this leaked string"); - ABSL_RAW_LOG(INFO, "Re-enabled leak detection.Should detect leaked std::string %s", + ABSL_RAW_LOG(INFO, "Re-enabled leak detection.Should detect leaked string %s", foo); }
diff --git a/third_party/abseil-cpp/absl/debugging/leak_check_test.cc b/third_party/abseil-cpp/absl/debugging/leak_check_test.cc index 93a7edd2d..b5cc487 100644 --- a/third_party/abseil-cpp/absl/debugging/leak_check_test.cc +++ b/third_party/abseil-cpp/absl/debugging/leak_check_test.cc
@@ -30,13 +30,13 @@ TEST(LeakCheckTest, IgnoreLeakSuppressesLeakedMemoryErrors) { auto foo = absl::IgnoreLeak(new std::string("some ignored leaked string")); - ABSL_RAW_LOG(INFO, "Ignoring leaked std::string %s", foo->c_str()); + ABSL_RAW_LOG(INFO, "Ignoring leaked string %s", foo->c_str()); } TEST(LeakCheckTest, LeakCheckDisablerIgnoresLeak) { absl::LeakCheckDisabler disabler; - auto foo = new std::string("some std::string leaked while checks are disabled"); - ABSL_RAW_LOG(INFO, "Ignoring leaked std::string %s", foo->c_str()); + auto foo = new std::string("some string leaked while checks are disabled"); + ABSL_RAW_LOG(INFO, "Ignoring leaked string %s", foo->c_str()); } } // namespace
diff --git a/third_party/abseil-cpp/absl/debugging/stacktrace.cc b/third_party/abseil-cpp/absl/debugging/stacktrace.cc index 9de8782..1f7c7d82 100644 --- a/third_party/abseil-cpp/absl/debugging/stacktrace.cc +++ b/third_party/abseil-cpp/absl/debugging/stacktrace.cc
@@ -57,6 +57,7 @@ #endif namespace absl { +ABSL_NAMESPACE_BEGIN namespace { typedef int (*Unwinder)(void**, int*, int, int, const void*, int*); @@ -135,4 +136,5 @@ return n; } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/debugging/stacktrace.h b/third_party/abseil-cpp/absl/debugging/stacktrace.h index 3fc1c03..0ec0ffd 100644 --- a/third_party/abseil-cpp/absl/debugging/stacktrace.h +++ b/third_party/abseil-cpp/absl/debugging/stacktrace.h
@@ -31,15 +31,18 @@ #ifndef ABSL_DEBUGGING_STACKTRACE_H_ #define ABSL_DEBUGGING_STACKTRACE_H_ +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN // GetStackFrames() // // Records program counter values for up to `max_depth` frames, skipping the -// most recent `skip_count` stack frames, and stores their corresponding values -// and sizes in `results` and `sizes` buffers. (Note that the frame generated -// for the `absl::GetStackFrames()` routine itself is also skipped.) -// routine itself. +// most recent `skip_count` stack frames, stores their corresponding values +// and sizes in `results` and `sizes` buffers, and returns the number of frames +// stored. (Note that the frame generated for the `absl::GetStackFrames()` +// routine itself is also skipped.) // // Example: // @@ -54,8 +57,8 @@ // The current stack frame would consist of three function calls: `bar()`, // `foo()`, and then `main()`; however, since the `GetStackFrames()` call sets // `skip_count` to `1`, it will skip the frame for `bar()`, the most recently -// invoked function call. It will therefore return two program counters and will -// produce values that map to the following function calls: +// invoked function call. It will therefore return 2 and fill `result` with +// program counters within the following functions: // // result[0] foo() // result[1] main() @@ -82,9 +85,10 @@ // // Records program counter values obtained from a signal handler. Records // program counter values for up to `max_depth` frames, skipping the most recent -// `skip_count` stack frames, and stores their corresponding values and sizes in -// `results` and `sizes` buffers. (Note that the frame generated for the -// `absl::GetStackFramesWithContext()` routine itself is also skipped.) +// `skip_count` stack frames, stores their corresponding values and sizes in +// `results` and `sizes` buffers, and returns the number of frames stored. (Note +// that the frame generated for the `absl::GetStackFramesWithContext()` routine +// itself is also skipped.) // // The `uc` parameter, if non-null, should be a pointer to a `ucontext_t` value // passed to a signal handler registered via the `sa_sigaction` field of a @@ -105,8 +109,9 @@ // GetStackTrace() // // Records program counter values for up to `max_depth` frames, skipping the -// most recent `skip_count` stack frames, and stores their corresponding values -// in `results`. Note that this function is similar to `absl::GetStackFrames()` +// most recent `skip_count` stack frames, stores their corresponding values +// in `results`, and returns the number of frames +// stored. Note that this function is similar to `absl::GetStackFrames()` // except that it returns the stack trace only, and not stack frame sizes. // // Example: @@ -131,9 +136,9 @@ // // Records program counter values obtained from a signal handler. Records // program counter values for up to `max_depth` frames, skipping the most recent -// `skip_count` stack frames, and stores their corresponding values in -// `results`. (Note that the frame generated for the -// `absl::GetStackFramesWithContext()` routine itself is also skipped.) +// `skip_count` stack frames, stores their corresponding values in `results`, +// and returns the number of frames stored. (Note that the frame generated for +// the `absl::GetStackFramesWithContext()` routine itself is also skipped.) // // The `uc` parameter, if non-null, should be a pointer to a `ucontext_t` value // passed to a signal handler registered via the `sa_sigaction` field of a @@ -220,6 +225,7 @@ // working. extern bool StackTraceWorksForTest(); } // namespace debugging_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_STACKTRACE_H_
diff --git a/third_party/abseil-cpp/absl/debugging/symbolize.cc b/third_party/abseil-cpp/absl/debugging/symbolize.cc index 24e3a7f0..54ed970 100644 --- a/third_party/abseil-cpp/absl/debugging/symbolize.cc +++ b/third_party/abseil-cpp/absl/debugging/symbolize.cc
@@ -16,12 +16,9 @@ #if defined(ABSL_INTERNAL_HAVE_ELF_SYMBOLIZE) #include "absl/debugging/symbolize_elf.inc" -#elif defined(_WIN32) && defined(_DEBUG) -// The Windows Symbolizer only works in debug mode. Note that _DEBUG -// is the macro that defines whether or not MS C-Runtime debug info is -// available. Note that the PDB files containing the debug info must -// also be available to the program at runtime for the symbolizer to -// work. +#elif defined(_WIN32) +// The Windows Symbolizer only works if PDB files containing the debug info +// are available to the program at runtime. #include "absl/debugging/symbolize_win32.inc" #else #include "absl/debugging/symbolize_unimplemented.inc"
diff --git a/third_party/abseil-cpp/absl/debugging/symbolize.h b/third_party/abseil-cpp/absl/debugging/symbolize.h index a73dbd9..43d93a8 100644 --- a/third_party/abseil-cpp/absl/debugging/symbolize.h +++ b/third_party/abseil-cpp/absl/debugging/symbolize.h
@@ -55,6 +55,7 @@ #include "absl/debugging/internal/symbolize.h" namespace absl { +ABSL_NAMESPACE_BEGIN // InitializeSymbolizer() // @@ -70,7 +71,7 @@ // // Now you can use the symbolizer // } void InitializeSymbolizer(const char* argv0); - +// // Symbolize() // // Symbolizes a program counter (instruction pointer value) `pc` and, on @@ -88,10 +89,11 @@ // if (absl::Symbolize(pc, tmp, sizeof(tmp))) { // symbol = tmp; // } -// absl::PrintF("%*p %s\n", pc, symbol); +// absl::PrintF("%p %s\n", pc, symbol); // } bool Symbolize(const void *pc, char *out, int out_size); +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_SYMBOLIZE_H_
diff --git a/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc b/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc index 460dd03..4a4f988 100644 --- a/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +++ b/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc
@@ -76,6 +76,7 @@ #include "absl/debugging/internal/vdso_support.h" namespace absl { +ABSL_NAMESPACE_BEGIN // Value of argv[0]. Used by MaybeInitializeObjFile(). static char *argv0_value = nullptr; @@ -624,6 +625,13 @@ return start <= address && address < (start + size); } +static const char *ComputeOffset(const char *base, ptrdiff_t offset) { + // Note: cast to uintptr_t to avoid undefined behavior when base evaluates to + // zero and offset is non-zero. + return reinterpret_cast<const char *>( + reinterpret_cast<uintptr_t>(base) + offset); +} + // Read a symbol table and look for the symbol containing the // pc. Iterate over symbols in a symbol table and look for the symbol // containing "pc". If the symbol is found, and its name fits in @@ -676,7 +684,8 @@ // We keep the original address for opd redirection below. const char *const original_start_address = reinterpret_cast<const char *>(symbol.st_value); - const char *start_address = original_start_address + relocation; + const char *start_address = + ComputeOffset(original_start_address, relocation); if (deref_function_descriptor_pointer && InSection(original_start_address, opd)) { @@ -688,8 +697,7 @@ // If pc is inside the .opd section, it points to a function descriptor. const size_t size = pc_in_opd ? kFunctionDescriptorSize : symbol.st_size; - const void *const end_address = - reinterpret_cast<const char *>(start_address) + size; + const void *const end_address = ComputeOffset(start_address, size); if (symbol.st_value != 0 && // Skip null value symbols. symbol.st_shndx != 0 && // Skip undefined symbols. #ifdef STT_TLS @@ -1394,7 +1402,7 @@ if (g_num_file_mapping_hints >= kMaxFileMappingHints) { ret = false; } else { - // TODO(ckennelly): Move this into a std::string copy routine. + // TODO(ckennelly): Move this into a string copy routine. int len = strlen(filename); char *dst = static_cast<char *>( base_internal::LowLevelAlloc::AllocWithArena(len + 1, SigSafeArena())); @@ -1468,4 +1476,5 @@ return ok; } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/debugging/symbolize_test.cc b/third_party/abseil-cpp/absl/debugging/symbolize_test.cc index 08068c30..a1d03aa 100644 --- a/third_party/abseil-cpp/absl/debugging/symbolize_test.cc +++ b/third_party/abseil-cpp/absl/debugging/symbolize_test.cc
@@ -35,10 +35,29 @@ using testing::Contains; +#ifdef _WIN32 +#define ABSL_SYMBOLIZE_TEST_NOINLINE __declspec(noinline) +#else +#define ABSL_SYMBOLIZE_TEST_NOINLINE ABSL_ATTRIBUTE_NOINLINE +#endif + // Functions to symbolize. Use C linkage to avoid mangled names. extern "C" { -void nonstatic_func() { ABSL_BLOCK_TAIL_CALL_OPTIMIZATION(); } -static void static_func() { ABSL_BLOCK_TAIL_CALL_OPTIMIZATION(); } +ABSL_SYMBOLIZE_TEST_NOINLINE void nonstatic_func() { + // The next line makes this a unique function to prevent the compiler from + // folding identical functions together. + volatile int x = __LINE__; + static_cast<void>(x); + ABSL_BLOCK_TAIL_CALL_OPTIMIZATION(); +} + +ABSL_SYMBOLIZE_TEST_NOINLINE static void static_func() { + // The next line makes this a unique function to prevent the compiler from + // folding identical functions together. + volatile int x = __LINE__; + static_cast<void>(x); + ABSL_BLOCK_TAIL_CALL_OPTIMIZATION(); +} } // extern "C" struct Foo { @@ -46,7 +65,11 @@ }; // A C++ method that should have a mangled name. -void ABSL_ATTRIBUTE_NOINLINE Foo::func(int) { +ABSL_SYMBOLIZE_TEST_NOINLINE void Foo::func(int) { + // The next line makes this a unique function to prevent the compiler from + // folding identical functions together. + volatile int x = __LINE__; + static_cast<void>(x); ABSL_BLOCK_TAIL_CALL_OPTIMIZATION(); } @@ -80,6 +103,7 @@ symbolize_test_thread_big[2 * 1024 * 1024]; #endif +#if !defined(__EMSCRIPTEN__) // Used below to hopefully inhibit some compiler/linker optimizations // that may remove kHpageTextPadding, kPadding0, and kPadding1 from // the binary. @@ -89,6 +113,7 @@ static constexpr size_t kHpageSize = 1 << 21; const char kHpageTextPadding[kHpageSize * 4] ABSL_ATTRIBUTE_SECTION_VARIABLE( .text) = ""; +#endif // !defined(__EMSCRIPTEN__) static char try_symbolize_buffer[4096]; @@ -447,14 +472,15 @@ #endif } -#elif defined(_WIN32) && defined(_DEBUG) +#elif defined(_WIN32) +#if !defined(ABSL_CONSUME_DLL) TEST(Symbolize, Basics) { EXPECT_STREQ("nonstatic_func", TrySymbolize((void *)(&nonstatic_func))); // The name of an internal linkage symbol is not specified; allow either a // mangled or an unmangled name here. - const char* static_func_symbol = TrySymbolize((void *)(&static_func)); + const char *static_func_symbol = TrySymbolize((void *)(&static_func)); ASSERT_TRUE(static_func_symbol != nullptr); EXPECT_TRUE(strstr(static_func_symbol, "static_func") != nullptr); @@ -481,11 +507,12 @@ } TEST(Symbolize, SymbolizeWithDemangling) { - const char* result = TrySymbolize((void *)(&Foo::func)); + const char *result = TrySymbolize((void *)(&Foo::func)); ASSERT_TRUE(result != nullptr); EXPECT_TRUE(strstr(result, "Foo::func") != nullptr) << result; } +#endif // !defined(ABSL_CONSUME_DLL) #else // Symbolizer unimplemented TEST(Symbolize, Unimplemented) { @@ -498,10 +525,12 @@ #endif int main(int argc, char **argv) { +#if !defined(__EMSCRIPTEN__) // Make sure kHpageTextPadding is linked into the binary. if (volatile_bool) { ABSL_RAW_LOG(INFO, "%s", kHpageTextPadding); } +#endif // !defined(__EMSCRIPTEN__) #if ABSL_PER_THREAD_TLS // Touch the per-thread variables.
diff --git a/third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc b/third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc index 7c580fe..db24456b 100644 --- a/third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc +++ b/third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc
@@ -17,6 +17,7 @@ #include "absl/base/internal/raw_logging.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace debugging_internal { @@ -35,4 +36,5 @@ void InitializeSymbolizer(const char*) {} bool Symbolize(const void *, char *, int) { return false; } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc b/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc index 5a55f29d..c3df46f 100644 --- a/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +++ b/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc
@@ -17,10 +17,10 @@ #include <windows.h> -// MSVC header DbgHelp.h has a warning for an ignored typedef. +// MSVC header dbghelp.h has a warning for an ignored typedef. #pragma warning(push) #pragma warning(disable:4091) -#include <DbgHelp.h> +#include <dbghelp.h> #pragma warning(pop) #pragma comment(lib, "dbghelp.lib") @@ -31,10 +31,11 @@ #include "absl/base/internal/raw_logging.h" namespace absl { +ABSL_NAMESPACE_BEGIN static HANDLE process = NULL; -void InitializeSymbolizer(const char *argv0) { +void InitializeSymbolizer(const char*) { if (process != nullptr) { return; } @@ -53,13 +54,12 @@ } } -bool Symbolize(const void *pc, char *out, int out_size) { +bool Symbolize(const void* pc, char* out, int out_size) { if (out_size <= 0) { return false; } - std::aligned_storage<sizeof(SYMBOL_INFO) + MAX_SYM_NAME, - alignof(SYMBOL_INFO)>::type buf; - SYMBOL_INFO *symbol = reinterpret_cast<SYMBOL_INFO *>(&buf); + alignas(SYMBOL_INFO) char buf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME]; + SYMBOL_INFO* symbol = reinterpret_cast<SYMBOL_INFO*>(buf); symbol->SizeOfStruct = sizeof(SYMBOL_INFO); symbol->MaxNameLen = MAX_SYM_NAME; if (!SymFromAddr(process, reinterpret_cast<DWORD64>(pc), nullptr, symbol)) { @@ -77,4 +77,5 @@ return true; } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/flags/BUILD.bazel b/third_party/abseil-cpp/absl/flags/BUILD.bazel index 2fe61ea..9166f74c 100644 --- a/third_party/abseil-cpp/absl/flags/BUILD.bazel +++ b/third_party/abseil-cpp/absl/flags/BUILD.bazel
@@ -1,5 +1,5 @@ # -# Copyright 2019 The Abseil Authors. +# Copyright 2019 The Abseil Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ # limitations under the License. # +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", @@ -26,12 +27,36 @@ licenses(["notice"]) # Apache 2.0 cc_library( - name = "internal", + name = "flag_internal", + srcs = [ + "internal/flag.cc", + ], + hdrs = [ + "internal/flag.h", + ], + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + visibility = ["//absl/base:__subpackages__"], + deps = [ + ":config", + ":handle", + ":registry", + "//absl/base", + "//absl/base:config", + "//absl/base:core_headers", + "//absl/memory", + "//absl/meta:type_traits", + "//absl/strings", + "//absl/synchronization", + ], +) + +cc_library( + name = "program_name", srcs = [ "internal/program_name.cc", ], hdrs = [ - "internal/path_util.h", "internal/program_name.h", ], copts = ABSL_DEFAULT_COPTS, @@ -40,12 +65,31 @@ "//absl/flags:__pkg__", ], deps = [ + ":path_util", + "//absl/base:config", + "//absl/base:core_headers", "//absl/strings", "//absl/synchronization", ], ) cc_library( + name = "path_util", + hdrs = [ + "internal/path_util.h", + ], + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + visibility = [ + "//absl/flags:__pkg__", + ], + deps = [ + "//absl/base:config", + "//absl/strings", + ], +) + +cc_library( name = "config", srcs = [ "usage_config.cc", @@ -57,7 +101,9 @@ copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ - ":internal", + ":path_util", + ":program_name", + "//absl/base:config", "//absl/base:core_headers", "//absl/strings", "//absl/synchronization", @@ -75,7 +121,9 @@ copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ + "//absl/base:config", "//absl/base:core_headers", + "//absl/base:log_severity", "//absl/strings", "//absl/strings:str_format", ], @@ -97,10 +145,9 @@ deps = [ ":config", ":marshalling", - "//absl/base", + "//absl/base:config", "//absl/base:core_headers", "//absl/strings", - "//absl/synchronization", "//absl/types:optional", ], ) @@ -123,9 +170,9 @@ deps = [ ":config", ":handle", - "//absl/base", + "//absl/base:config", "//absl/base:core_headers", - "//absl/base:dynamic_annotations", + "//absl/base:raw_logging_internal", "//absl/strings", "//absl/synchronization", ], @@ -139,16 +186,17 @@ hdrs = [ "declare.h", "flag.h", - "internal/flag.h", ], copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":config", + ":flag_internal", ":handle", ":marshalling", ":registry", "//absl/base", + "//absl/base:config", "//absl/base:core_headers", "//absl/strings", ], @@ -170,10 +218,14 @@ deps = [ ":config", ":flag", + ":flag_internal", ":handle", - ":internal", + ":path_util", + ":program_name", + ":registry", + "//absl/base:config", + "//absl/base:core_headers", "//absl/strings", - "//absl/synchronization", ], ) @@ -189,6 +241,8 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":usage_internal", + "//absl/base:config", + "//absl/base:core_headers", "//absl/strings", "//absl/synchronization", ], @@ -206,18 +260,21 @@ deps = [ ":config", ":flag", + ":flag_internal", ":handle", - ":internal", + ":program_name", ":registry", ":usage", ":usage_internal", + "//absl/base:config", + "//absl/base:core_headers", "//absl/strings", "//absl/synchronization", ], ) ############################################################################ -# Unit tests in alpahabetical order. +# Unit tests in alphabetical order. cc_test( name = "commandlineflag_test", @@ -228,6 +285,7 @@ copts = ABSL_TEST_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ + ":config", ":flag", ":handle", ":registry", @@ -261,12 +319,34 @@ copts = ABSL_TEST_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ + ":config", ":flag", + ":flag_internal", + ":handle", + ":registry", + "//absl/base:core_headers", "//absl/strings", "@com_google_googletest//:gtest_main", ], ) +cc_binary( + name = "flag_benchmark", + testonly = 1, + srcs = [ + "flag_benchmark.cc", + ], + copts = ABSL_TEST_COPTS, + tags = ["benchmark"], + visibility = ["//visibility:private"], + deps = [ + ":flag", + "//absl/time", + "//absl/types:optional", + "@com_github_google_benchmark//:benchmark_main", + ], +) + cc_test( name = "marshalling_test", size = "small", @@ -290,7 +370,7 @@ copts = ABSL_TEST_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ - ":internal", + ":path_util", "@com_google_googletest//:gtest_main", ], ) @@ -306,7 +386,8 @@ deps = [ ":flag", ":parse", - "//absl/base", + ":registry", + "//absl/base:raw_logging_internal", "//absl/base:scoped_set_env", "//absl/strings", "//absl/types:span", @@ -323,7 +404,7 @@ copts = ABSL_TEST_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ - ":internal", + ":program_name", "//absl/strings", "@com_google_googletest//:gtest_main", ], @@ -339,9 +420,10 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":flag", + ":handle", + ":marshalling", ":registry", "//absl/memory", - "//absl/strings", "@com_google_googletest//:gtest_main", ], ) @@ -356,7 +438,8 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":config", - ":internal", + ":path_util", + ":program_name", "//absl/strings", "@com_google_googletest//:gtest_main", ], @@ -373,8 +456,10 @@ deps = [ ":config", ":flag", - ":internal", ":parse", + ":path_util", + ":program_name", + ":registry", ":usage", ":usage_internal", "//absl/memory",
diff --git a/third_party/abseil-cpp/absl/flags/BUILD.gn b/third_party/abseil-cpp/absl/flags/BUILD.gn index 54529f82..59025442 100644 --- a/third_party/abseil-cpp/absl/flags/BUILD.gn +++ b/third_party/abseil-cpp/absl/flags/BUILD.gn
@@ -22,7 +22,7 @@ # If this is a problem, feel free to remove "testonly" and use "assert_no_deps" # on the main Chrome binary. -source_set("internal") { +source_set("flag_internal") { testonly = true configs -= [ "//build/config/compiler:chromium_code" ] configs += [ @@ -30,16 +30,64 @@ "//third_party/abseil-cpp:absl_default_cflags_cc", ] public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] - sources = [ "internal/program_name.cc" ] + sources = [ "internal/flag.cc", ] public = [ - "internal/path_util.h", - "internal/program_name.h", + "internal/flag.h", ] deps = [ + ":config", + ":handle", + ":registry", + "../base", + "../base:config", + "../base:core_headers", + "../memory", + "../meta:type_traits", "../strings", "../synchronization", ] visibility = [] + visibility += [ + ":*", + "../base/*", + ] +} + +source_set("program_name") { + testonly = true + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] + sources = [ "internal/program_name.cc", ] + public = [ "internal/program_name.h" ] + deps = [ + ":path_util", + "../base:config", + "../base:core_headers", + "../strings", + "../synchronization", + ] + visibility = [] + visibility += [ ":*" ] +} + +source_set("path_util") { + testonly = true + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] + public = [ "internal/path_util.h" ] + deps = [ + "../base:config", + "../strings", + ] + visibility = [] visibility += [ ":*" ] } @@ -57,7 +105,9 @@ "usage_config.h", ] deps = [ - ":internal", + ":path_util", + ":program_name", + "../base:config", "../base:core_headers", "../strings", "../synchronization", @@ -75,7 +125,9 @@ sources = [ "marshalling.cc" ] public = [ "marshalling.h" ] deps = [ + "../base:config", "../base:core_headers", + "../base:log_severity", "../strings", "../strings:str_format", ] @@ -94,10 +146,9 @@ deps = [ ":config", ":marshalling", - "../base", + "../base:config", "../base:core_headers", "../strings", - "../synchronization", "../types:optional", ] visibility = [] @@ -123,9 +174,9 @@ deps = [ ":config", ":handle", - "../base", + "../base:config", "../base:core_headers", - "../base:dynamic_annotations", + "../base:raw_logging_internal", "../strings", "../synchronization", ] @@ -145,14 +196,15 @@ public = [ "declare.h", "flag.h", - "internal/flag.h", ] deps = [ ":config", + ":flag_internal", ":handle", ":marshalling", ":registry", "../base", + "../base:config", "../base:core_headers", "../strings", ] @@ -171,10 +223,14 @@ deps = [ ":config", ":flag", + ":flag_internal", ":handle", - ":internal", + ":path_util", + ":program_name", + ":registry", + "../base:config", + "../base:core_headers", "../strings", - "../synchronization", ] visibility = [] visibility += [ ":*" ] @@ -192,6 +248,8 @@ public = [ "usage.h" ] deps = [ ":usage_internal", + "../base:config", + "../base:core_headers", "../strings", "../synchronization", ] @@ -213,11 +271,14 @@ deps = [ ":config", ":flag", + ":flag_internal", ":handle", - ":internal", + ":program_name", ":registry", ":usage", ":usage_internal", + "../base:config", + "../base:core_headers", "../strings", "../synchronization", ]
diff --git a/third_party/abseil-cpp/absl/flags/CMakeLists.txt b/third_party/abseil-cpp/absl/flags/CMakeLists.txt index fa1d4e1..01cf09b 100644 --- a/third_party/abseil-cpp/absl/flags/CMakeLists.txt +++ b/third_party/abseil-cpp/absl/flags/CMakeLists.txt
@@ -19,20 +19,61 @@ NAME flags_internal SRCS + "internal/flag.cc" + HDRS + "internal/flag.h" + COPTS + ${ABSL_DEFAULT_COPTS} + LINKOPTS + ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::base + absl::config + absl::flags_config + absl::flags_handle + absl::flags_registry + absl::synchronization + absl::meta + PUBLIC +) + +# Internal-only target, do not depend on directly. +absl_cc_library( + NAME + flags_program_name + SRCS "internal/program_name.cc" HDRS - "internal/path_util.h" "internal/program_name.h" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS + absl::config + absl::core_headers + absl::flags_path_util absl::strings absl::synchronization PUBLIC ) +# Internal-only target, do not depend on directly. +absl_cc_library( + NAME + flags_path_util + HDRS + "internal/path_util.h" + COPTS + ${ABSL_DEFAULT_COPTS} + LINKOPTS + ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::config + absl::strings + PUBLIC +) + absl_cc_library( NAME flags_config @@ -46,7 +87,9 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::flags_internal + absl::config + absl::flags_path_util + absl::flags_program_name absl::core_headers absl::strings absl::synchronization @@ -64,7 +107,9 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS + absl::config absl::core_headers + absl::log_severity absl::strings absl::str_format ) @@ -82,13 +127,14 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS + absl::config absl::flags_config absl::flags_marshalling - absl::base absl::core_headers + absl::optional + absl::raw_logging_internal absl::strings absl::synchronization - absl::optional ) # Internal-only target, do not depend on directly. @@ -106,11 +152,11 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS + absl::config absl::flags_config absl::flags_handle - absl::base absl::core_headers - absl::dynamic_annotations + absl::raw_logging_internal absl::strings absl::synchronization ) @@ -123,14 +169,15 @@ HDRS "declare.h" "flag.h" - "internal/flag.h" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS + absl::config absl::flags_config absl::flags_handle + absl::flags_internal absl::flags_marshalling absl::flags_registry absl::base @@ -151,10 +198,14 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS + absl::config absl::flags_config absl::flags absl::flags_handle absl::flags_internal + absl::flags_path_util + absl::flags_program_name + absl::flags_registry absl::strings absl::synchronization ) @@ -171,6 +222,8 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS + absl::config + absl::core_headers absl::flags_usage_internal absl::strings absl::synchronization @@ -189,10 +242,13 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS + absl::config + absl::core_headers absl::flags_config absl::flags absl::flags_handle absl::flags_internal + absl::flags_program_name absl::flags_registry absl::flags_usage absl::strings @@ -211,6 +267,7 @@ ${ABSL_TEST_COPTS} DEPS absl::flags + absl::flags_config absl::flags_handle absl::flags_registry absl::memory @@ -239,7 +296,12 @@ COPTS ${ABSL_TEST_COPTS} DEPS + absl::core_headers absl::flags + absl::flags_config + absl::flags_handle + absl::flags_internal + absl::flags_registry absl::strings gtest_main ) @@ -265,8 +327,9 @@ ${ABSL_TEST_COPTS} DEPS absl::flags - absl::base absl::flags_parse + absl::flags_registry + absl::raw_logging_internal absl::scoped_set_env absl::span absl::strings @@ -281,7 +344,7 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::flags_internal + absl::flags_path_util gtest_main ) @@ -293,7 +356,7 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::flags_internal + absl::flags_program_name absl::strings gtest_main ) @@ -307,6 +370,8 @@ ${ABSL_TEST_COPTS} DEPS absl::flags + absl::flags_handle + absl::flags_marshalling absl::flags_registry absl::memory absl::strings @@ -322,7 +387,8 @@ ${ABSL_TEST_COPTS} DEPS absl::flags_config - absl::flags_internal + absl::flags_path_util + absl::flags_program_name absl::strings gtest_main ) @@ -337,8 +403,10 @@ DEPS absl::flags_config absl::flags - absl::flags_internal + absl::flags_path_util + absl::flags_program_name absl::flags_parse + absl::flags_registry absl::flags_usage absl::memory absl::strings
diff --git a/third_party/abseil-cpp/absl/flags/config.h b/third_party/abseil-cpp/absl/flags/config.h index a9fd97a..001f8fe 100644 --- a/third_party/abseil-cpp/absl/flags/config.h +++ b/third_party/abseil-cpp/absl/flags/config.h
@@ -45,4 +45,23 @@ #define ABSL_FLAGS_STRIP_HELP ABSL_FLAGS_STRIP_NAMES #endif +// ABSL_FLAGS_INTERNAL_ATOMIC_DOUBLE_WORD macro is used for using atomics with +// double words, e.g. absl::Duration. +// For reasons in bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80878, modern +// versions of GCC do not support cmpxchg16b instruction in standard atomics. +#ifdef ABSL_FLAGS_INTERNAL_ATOMIC_DOUBLE_WORD +#error "ABSL_FLAGS_INTERNAL_ATOMIC_DOUBLE_WORD should not be defined." +#elif defined(__clang__) && defined(__x86_64__) && \ + defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16) +#define ABSL_FLAGS_INTERNAL_ATOMIC_DOUBLE_WORD 1 +#endif + +// ABSL_FLAGS_INTERNAL_HAS_RTTI macro is used for selecting if we can use RTTI +// for flag type identification. +#ifdef ABSL_FLAGS_INTERNAL_HAS_RTTI +#error ABSL_FLAGS_INTERNAL_HAS_RTTI cannot be directly set +#elif !defined(__GNUC__) || defined(__GXX_RTTI) +#define ABSL_FLAGS_INTERNAL_HAS_RTTI 1 +#endif // !defined(__GNUC__) || defined(__GXX_RTTI) + #endif // ABSL_FLAGS_CONFIG_H_
diff --git a/third_party/abseil-cpp/absl/flags/declare.h b/third_party/abseil-cpp/absl/flags/declare.h index 556ec5e..0f8cc6a5 100644 --- a/third_party/abseil-cpp/absl/flags/declare.h +++ b/third_party/abseil-cpp/absl/flags/declare.h
@@ -25,9 +25,11 @@ #ifndef ABSL_FLAGS_DECLARE_H_ #define ABSL_FLAGS_DECLARE_H_ +#include "absl/base/config.h" #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { // absl::Flag<T> represents a flag of type 'T' created by ABSL_FLAG. @@ -39,9 +41,15 @@ // Flag // // Forward declaration of the `absl::Flag` type for use in defining the macro. +#if defined(_MSC_VER) && !defined(__clang__) +template <typename T> +class Flag; +#else template <typename T> using Flag = flags_internal::Flag<T>; +#endif +ABSL_NAMESPACE_END } // namespace absl // ABSL_DECLARE_FLAG()
diff --git a/third_party/abseil-cpp/absl/flags/flag.cc b/third_party/abseil-cpp/absl/flags/flag.cc index f16cc75..f7a457b 100644 --- a/third_party/abseil-cpp/absl/flags/flag.cc +++ b/third_party/abseil-cpp/absl/flags/flag.cc
@@ -15,30 +15,26 @@ #include "absl/flags/flag.h" -#include <cstring> +#include "absl/base/config.h" +#include "absl/flags/internal/commandlineflag.h" +#include "absl/flags/internal/flag.h" namespace absl { +ABSL_NAMESPACE_BEGIN -// We want to validate the type mismatch between type definition and -// declaration. The lock-free implementation does not allow us to do it, -// so in debug builds we always use the slower implementation, which always -// validates the type. -#ifndef NDEBUG -#define ABSL_FLAGS_ATOMIC_GET(T) \ - T GetFlag(const absl::Flag<T>& flag) { return flag.Get(); } -#else -#define ABSL_FLAGS_ATOMIC_GET(T) \ - T GetFlag(const absl::Flag<T>& flag) { \ - T result; \ - if (flag.AtomicGet(&result)) { \ - return result; \ - } \ - return flag.Get(); \ - } +// This global mutex protects on-demand construction of flag objects in MSVC +// builds. +#if defined(_MSC_VER) && !defined(__clang__) + +namespace flags_internal { + +ABSL_CONST_INIT static absl::Mutex construction_guard(absl::kConstInit); + +absl::Mutex* GetGlobalConstructionGuard() { return &construction_guard; } + +} // namespace flags_internal + #endif -ABSL_FLAGS_INTERNAL_FOR_EACH_LOCK_FREE(ABSL_FLAGS_ATOMIC_GET) - -#undef ABSL_FLAGS_ATOMIC_GET - +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/flags/flag.h b/third_party/abseil-cpp/absl/flags/flag.h index 36c771c..bb91765 100644 --- a/third_party/abseil-cpp/absl/flags/flag.h +++ b/third_party/abseil-cpp/absl/flags/flag.h
@@ -29,15 +29,21 @@ #ifndef ABSL_FLAGS_FLAG_H_ #define ABSL_FLAGS_FLAG_H_ +#include <string> +#include <type_traits> + #include "absl/base/attributes.h" #include "absl/base/casts.h" +#include "absl/base/config.h" #include "absl/flags/config.h" #include "absl/flags/declare.h" #include "absl/flags/internal/commandlineflag.h" #include "absl/flags/internal/flag.h" +#include "absl/flags/internal/registry.h" #include "absl/flags/marshalling.h" namespace absl { +ABSL_NAMESPACE_BEGIN // Flag // @@ -63,8 +69,102 @@ // ABSL_FLAG(int, count, 0, "Count of items to process"); // // No public methods of `absl::Flag<T>` are part of the Abseil Flags API. +#if !defined(_MSC_VER) || defined(__clang__) template <typename T> using Flag = flags_internal::Flag<T>; +#else +// MSVC debug builds do not implement initialization with constexpr constructors +// correctly. To work around this we add a level of indirection, so that the +// class `absl::Flag` contains an `internal::Flag*` (instead of being an alias +// to that class) and dynamically allocates an instance when necessary. We also +// forward all calls to internal::Flag methods via trampoline methods. In this +// setup the `absl::Flag` class does not have constructor and virtual methods, +// all the data members are public and thus MSVC is able to initialize it at +// link time. To deal with multiple threads accessing the flag for the first +// time concurrently we use an atomic boolean indicating if flag object is +// initialized. We also employ the double-checked locking pattern where the +// second level of protection is a global Mutex, so if two threads attempt to +// construct the flag concurrently only one wins. +// This solution is based on a recomendation here: +// https://developercommunity.visualstudio.com/content/problem/336946/class-with-constexpr-constructor-not-using-static.html?childToView=648454#comment-648454 + +namespace flags_internal { +absl::Mutex* GetGlobalConstructionGuard(); +} // namespace flags_internal + +template <typename T> +class Flag { + public: + // No constructor and destructor to ensure this is an aggregate type. + // Visual Studio 2015 still requires the constructor for class to be + // constexpr initializable. +#if _MSC_VER <= 1900 + constexpr Flag(const char* name, const char* filename, + const flags_internal::HelpGenFunc help_gen, + const flags_internal::FlagDfltGenFunc default_value_gen) + : name_(name), + filename_(filename), + help_gen_(help_gen), + default_value_gen_(default_value_gen), + inited_(false), + impl_(nullptr) {} +#endif + + flags_internal::Flag<T>* GetImpl() const { + if (!inited_.load(std::memory_order_acquire)) { + absl::MutexLock l(flags_internal::GetGlobalConstructionGuard()); + + if (inited_.load(std::memory_order_acquire)) { + return impl_; + } + + impl_ = + new flags_internal::Flag<T>(name_, filename_, + {flags_internal::FlagHelpMsg(help_gen_), + flags_internal::FlagHelpKind::kGenFunc}, + default_value_gen_); + inited_.store(true, std::memory_order_release); + } + + return impl_; + } + + // Public methods of `absl::Flag<T>` are NOT part of the Abseil Flags API. + // See https://abseil.io/docs/cpp/guides/flags + bool IsRetired() const { return GetImpl()->IsRetired(); } + bool IsAbseilFlag() const { return GetImpl()->IsAbseilFlag(); } + absl::string_view Name() const { return GetImpl()->Name(); } + std::string Help() const { return GetImpl()->Help(); } + bool IsModified() const { return GetImpl()->IsModified(); } + bool IsSpecifiedOnCommandLine() const { + return GetImpl()->IsSpecifiedOnCommandLine(); + } + absl::string_view Typename() const { return GetImpl()->Typename(); } + std::string Filename() const { return GetImpl()->Filename(); } + std::string DefaultValue() const { return GetImpl()->DefaultValue(); } + std::string CurrentValue() const { return GetImpl()->CurrentValue(); } + template <typename U> + inline bool IsOfType() const { + return GetImpl()->template IsOfType<U>(); + } + T Get() const { return GetImpl()->Get(); } + void Set(const T& v) { GetImpl()->Set(v); } + void SetCallback(const flags_internal::FlagCallbackFunc mutation_callback) { + GetImpl()->SetCallback(mutation_callback); + } + void InvokeCallback() { GetImpl()->InvokeCallback(); } + + // The data members are logically private, but they need to be public for + // this to be an aggregate type. + const char* name_; + const char* filename_; + const flags_internal::HelpGenFunc help_gen_; + const flags_internal::FlagDfltGenFunc default_value_gen_; + + mutable std::atomic<bool> inited_; + mutable flags_internal::Flag<T>* impl_; +}; +#endif // GetFlag() // @@ -83,23 +183,10 @@ // // FLAGS_firstname is a Flag of type `std::string` // std::string first_name = absl::GetFlag(FLAGS_firstname); template <typename T> -T GetFlag(const absl::Flag<T>& flag) { -#define ABSL_FLAGS_INTERNAL_LOCK_FREE_VALIDATE(BIT) \ - static_assert( \ - !std::is_same<T, BIT>::value, \ - "Do not specify explicit template parameters to absl::GetFlag"); - ABSL_FLAGS_INTERNAL_FOR_EACH_LOCK_FREE(ABSL_FLAGS_INTERNAL_LOCK_FREE_VALIDATE) -#undef ABSL_FLAGS_INTERNAL_LOCK_FREE_VALIDATE - +ABSL_MUST_USE_RESULT T GetFlag(const absl::Flag<T>& flag) { return flag.Get(); } -// Overload for `GetFlag()` for types that support lock-free reads. -#define ABSL_FLAGS_INTERNAL_LOCK_FREE_EXPORT(T) \ - extern T GetFlag(const absl::Flag<T>& flag); -ABSL_FLAGS_INTERNAL_FOR_EACH_LOCK_FREE(ABSL_FLAGS_INTERNAL_LOCK_FREE_EXPORT) -#undef ABSL_FLAGS_INTERNAL_LOCK_FREE_EXPORT - // SetFlag() // // Sets the value of an `absl::Flag` to the value `v`. Do not construct an @@ -121,6 +208,7 @@ flag->Set(value); } +ABSL_NAMESPACE_END } // namespace absl @@ -184,13 +272,23 @@ #if ABSL_FLAGS_STRIP_NAMES #define ABSL_FLAG_IMPL_FLAGNAME(txt) "" #define ABSL_FLAG_IMPL_FILENAME() "" +#if !defined(_MSC_VER) || defined(__clang__) #define ABSL_FLAG_IMPL_REGISTRAR(T, flag) \ absl::flags_internal::FlagRegistrar<T, false>(&flag) #else +#define ABSL_FLAG_IMPL_REGISTRAR(T, flag) \ + absl::flags_internal::FlagRegistrar<T, false>(flag.GetImpl()) +#endif +#else #define ABSL_FLAG_IMPL_FLAGNAME(txt) txt #define ABSL_FLAG_IMPL_FILENAME() __FILE__ +#if !defined(_MSC_VER) || defined(__clang__) #define ABSL_FLAG_IMPL_REGISTRAR(T, flag) \ absl::flags_internal::FlagRegistrar<T, true>(&flag) +#else +#define ABSL_FLAG_IMPL_REGISTRAR(T, flag) \ + absl::flags_internal::FlagRegistrar<T, true>(flag.GetImpl()) +#endif #endif // ABSL_FLAG_IMPL macro definition conditional on ABSL_FLAGS_STRIP_HELP @@ -201,9 +299,19 @@ #define ABSL_FLAG_IMPL_FLAGHELP(txt) txt #endif -#define ABSL_FLAG_IMPL_DECLARE_HELP_WRAPPER(name, txt) \ - static std::string AbslFlagsWrapHelp##name() { \ - return ABSL_FLAG_IMPL_FLAGHELP(txt); \ +// AbslFlagHelpGenFor##name is used to encapsulate both immediate (method Const) +// and lazy (method NonConst) evaluation of help message expression. We choose +// between the two via the call to HelpArg in absl::Flag instantiation below. +// If help message expression is constexpr evaluable compiler will optimize +// away this whole struct. +#define ABSL_FLAG_IMPL_DECLARE_HELP_WRAPPER(name, txt) \ + struct AbslFlagHelpGenFor##name { \ + template <typename T = void> \ + static constexpr const char* Const() { \ + return absl::flags_internal::HelpConstexprWrap( \ + ABSL_FLAG_IMPL_FLAGHELP(txt)); \ + } \ + static std::string NonConst() { return ABSL_FLAG_IMPL_FLAGHELP(txt); } \ } #define ABSL_FLAG_IMPL_DECLARE_DEF_VAL_WRAPPER(name, Type, default_value) \ @@ -216,17 +324,30 @@ // Note: Name of registrar object is not arbitrary. It is used to "grab" // global name for FLAGS_no<flag_name> symbol, thus preventing the possibility // of defining two flags with names foo and nofoo. +#if !defined(_MSC_VER) || defined(__clang__) #define ABSL_FLAG_IMPL(Type, name, default_value, help) \ namespace absl /* block flags in namespaces */ {} \ ABSL_FLAG_IMPL_DECLARE_DEF_VAL_WRAPPER(name, Type, default_value) \ - ABSL_FLAG_IMPL_DECLARE_HELP_WRAPPER(name, help) \ - ABSL_CONST_INIT absl::Flag<Type> FLAGS_##name( \ - ABSL_FLAG_IMPL_FLAGNAME(#name), &AbslFlagsWrapHelp##name, \ - ABSL_FLAG_IMPL_FILENAME(), \ - &absl::flags_internal::FlagMarshallingOps<Type>, \ - &AbslFlagsInitFlag##name); \ + ABSL_FLAG_IMPL_DECLARE_HELP_WRAPPER(name, help); \ + ABSL_CONST_INIT absl::Flag<Type> FLAGS_##name{ \ + ABSL_FLAG_IMPL_FLAGNAME(#name), ABSL_FLAG_IMPL_FILENAME(), \ + absl::flags_internal::HelpArg<AbslFlagHelpGenFor##name>(0), \ + &AbslFlagsInitFlag##name}; \ extern bool FLAGS_no##name; \ bool FLAGS_no##name = ABSL_FLAG_IMPL_REGISTRAR(Type, FLAGS_##name) +#else +// MSVC version uses aggregate initialization. We also do not try to +// optimize away help wrapper. +#define ABSL_FLAG_IMPL(Type, name, default_value, help) \ + namespace absl /* block flags in namespaces */ {} \ + ABSL_FLAG_IMPL_DECLARE_DEF_VAL_WRAPPER(name, Type, default_value) \ + ABSL_FLAG_IMPL_DECLARE_HELP_WRAPPER(name, help); \ + ABSL_CONST_INIT absl::Flag<Type> FLAGS_##name{ \ + ABSL_FLAG_IMPL_FLAGNAME(#name), ABSL_FLAG_IMPL_FILENAME(), \ + &AbslFlagHelpGenFor##name::NonConst, &AbslFlagsInitFlag##name}; \ + extern bool FLAGS_no##name; \ + bool FLAGS_no##name = ABSL_FLAG_IMPL_REGISTRAR(Type, FLAGS_##name) +#endif // ABSL_RETIRED_FLAG //
diff --git a/third_party/abseil-cpp/absl/flags/flag_benchmark.cc b/third_party/abseil-cpp/absl/flags/flag_benchmark.cc new file mode 100644 index 0000000..ff95bb5 --- /dev/null +++ b/third_party/abseil-cpp/absl/flags/flag_benchmark.cc
@@ -0,0 +1,119 @@ +// +// Copyright 2020 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/flags/flag.h" +#include "absl/time/time.h" +#include "absl/types/optional.h" +#include "benchmark/benchmark.h" + +namespace { +using String = std::string; +using VectorOfStrings = std::vector<std::string>; +using AbslDuration = absl::Duration; + +// We do not want to take over marshalling for the types absl::optional<int>, +// absl::optional<std::string> which we do not own. Instead we introduce unique +// "aliases" to these types, which we do. +using AbslOptionalInt = absl::optional<int>; +struct OptionalInt : AbslOptionalInt { + using AbslOptionalInt::AbslOptionalInt; +}; +// Next two functions represent Abseil Flags marshalling for OptionalInt. +bool AbslParseFlag(absl::string_view src, OptionalInt* flag, + std::string* error) { + int val; + if (src.empty()) + flag->reset(); + else if (!absl::ParseFlag(src, &val, error)) + return false; + *flag = val; + return true; +} +std::string AbslUnparseFlag(const OptionalInt& flag) { + return !flag ? "" : absl::UnparseFlag(*flag); +} + +using AbslOptionalString = absl::optional<std::string>; +struct OptionalString : AbslOptionalString { + using AbslOptionalString::AbslOptionalString; +}; +// Next two functions represent Abseil Flags marshalling for OptionalString. +bool AbslParseFlag(absl::string_view src, OptionalString* flag, + std::string* error) { + std::string val; + if (src.empty()) + flag->reset(); + else if (!absl::ParseFlag(src, &val, error)) + return false; + *flag = val; + return true; +} +std::string AbslUnparseFlag(const OptionalString& flag) { + return !flag ? "" : absl::UnparseFlag(*flag); +} + +struct UDT { + UDT() = default; + UDT(const UDT&) {} + UDT& operator=(const UDT&) { return *this; } +}; +// Next two functions represent Abseil Flags marshalling for UDT. +bool AbslParseFlag(absl::string_view, UDT*, std::string*) { return true; } +std::string AbslUnparseFlag(const UDT&) { return ""; } + +} // namespace + +#define BENCHMARKED_TYPES(A) \ + A(bool) \ + A(int16_t) \ + A(uint16_t) \ + A(int32_t) \ + A(uint32_t) \ + A(int64_t) \ + A(uint64_t) \ + A(double) \ + A(float) \ + A(String) \ + A(VectorOfStrings) \ + A(OptionalInt) \ + A(OptionalString) \ + A(AbslDuration) \ + A(UDT) + +#define FLAG_DEF(T) ABSL_FLAG(T, T##_flag, {}, ""); + +BENCHMARKED_TYPES(FLAG_DEF) + +namespace { + +#define BM_GetFlag(T) \ + void BM_GetFlag_##T(benchmark::State& state) { \ + for (auto _ : state) { \ + benchmark::DoNotOptimize(absl::GetFlag(FLAGS_##T##_flag)); \ + } \ + } \ + BENCHMARK(BM_GetFlag_##T); + +BENCHMARKED_TYPES(BM_GetFlag) + +} // namespace + +#define InvokeGetFlag(T) \ + T AbslInvokeGetFlag##T() { return absl::GetFlag(FLAGS_##T##_flag); } \ + int odr##T = (benchmark::DoNotOptimize(AbslInvokeGetFlag##T), 1); + +BENCHMARKED_TYPES(InvokeGetFlag) + +// To veiw disassembly use: gdb ${BINARY} -batch -ex "disassemble /s $FUNC"
diff --git a/third_party/abseil-cpp/absl/flags/flag_test.cc b/third_party/abseil-cpp/absl/flags/flag_test.cc index 1bcd7e9..1e01b49 100644 --- a/third_party/abseil-cpp/absl/flags/flag_test.cc +++ b/third_party/abseil-cpp/absl/flags/flag_test.cc
@@ -15,11 +15,25 @@ #include "absl/flags/flag.h" +#include <stdint.h> + +#include <cmath> +#include <string> +#include <vector> + #include "gtest/gtest.h" +#include "absl/base/attributes.h" +#include "absl/flags/config.h" +#include "absl/flags/declare.h" +#include "absl/flags/internal/commandlineflag.h" +#include "absl/flags/internal/flag.h" +#include "absl/flags/internal/registry.h" +#include "absl/flags/usage_config.h" #include "absl/strings/match.h" #include "absl/strings/numbers.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" ABSL_DECLARE_FLAG(int64_t, mistyped_int_flag); ABSL_DECLARE_FLAG(std::vector<std::string>, mistyped_string_flag); @@ -28,34 +42,13 @@ namespace flags = absl::flags_internal; -std::string TestHelpMsg() { return "help"; } +std::string TestHelpMsg() { return "dynamic help"; } template <typename T> void* TestMakeDflt() { return new T{}; } void TestCallback() {} -template <typename T> -bool TestConstructionFor() { - constexpr flags::Flag<T> f1("f1", &TestHelpMsg, "file", - &absl::flags_internal::FlagMarshallingOps<T>, - &TestMakeDflt<T>); - EXPECT_EQ(f1.Name(), "f1"); - EXPECT_EQ(f1.Help(), "help"); - EXPECT_EQ(f1.Filename(), "file"); - - ABSL_CONST_INIT static flags::Flag<T> f2( - "f2", &TestHelpMsg, "file", &absl::flags_internal::FlagMarshallingOps<T>, - &TestMakeDflt<T>); - flags::FlagRegistrar<T, false>(&f2).OnUpdate(TestCallback); - - EXPECT_EQ(f2.Name(), "f2"); - EXPECT_EQ(f2.Help(), "help"); - EXPECT_EQ(f2.Filename(), "file"); - - return true; -} - struct UDT { UDT() = default; UDT(const UDT&) = default; @@ -63,19 +56,123 @@ bool AbslParseFlag(absl::string_view, UDT*, std::string*) { return true; } std::string AbslUnparseFlag(const UDT&) { return ""; } -TEST(FlagTest, TestConstruction) { - TestConstructionFor<bool>(); - TestConstructionFor<int16_t>(); - TestConstructionFor<uint16_t>(); - TestConstructionFor<int32_t>(); - TestConstructionFor<uint32_t>(); - TestConstructionFor<int64_t>(); - TestConstructionFor<uint64_t>(); - TestConstructionFor<double>(); - TestConstructionFor<float>(); - TestConstructionFor<std::string>(); +class FlagTest : public testing::Test { + protected: + static void SetUpTestSuite() { + // Install a function to normalize filenames before this test is run. + absl::FlagsUsageConfig default_config; + default_config.normalize_filename = &FlagTest::NormalizeFileName; + absl::SetFlagsUsageConfig(default_config); + } - TestConstructionFor<UDT>(); + private: + static std::string NormalizeFileName(absl::string_view fname) { +#ifdef _WIN32 + std::string normalized(fname); + std::replace(normalized.begin(), normalized.end(), '\\', '/'); + fname = normalized; +#endif + return std::string(fname); + } +}; + +struct S1 { + S1() = default; + S1(const S1&) = default; + int32_t f1; + int64_t f2; +}; + +struct S2 { + S2() = default; + S2(const S2&) = default; + int64_t f1; + double f2; +}; + +TEST_F(FlagTest, Traits) { + EXPECT_EQ(flags::FlagValue::Kind<int>(), + flags::FlagValueStorageKind::kOneWordAtomic); + EXPECT_EQ(flags::FlagValue::Kind<bool>(), + flags::FlagValueStorageKind::kOneWordAtomic); + EXPECT_EQ(flags::FlagValue::Kind<double>(), + flags::FlagValueStorageKind::kOneWordAtomic); + EXPECT_EQ(flags::FlagValue::Kind<int64_t>(), + flags::FlagValueStorageKind::kOneWordAtomic); + +#if defined(ABSL_FLAGS_INTERNAL_ATOMIC_DOUBLE_WORD) + EXPECT_EQ(flags::FlagValue::Kind<S1>(), + flags::FlagValueStorageKind::kTwoWordsAtomic); + EXPECT_EQ(flags::FlagValue::Kind<S2>(), + flags::FlagValueStorageKind::kTwoWordsAtomic); +#else + EXPECT_EQ(flags::FlagValue::Kind<S1>(), + flags::FlagValueStorageKind::kHeapAllocated); + EXPECT_EQ(flags::FlagValue::Kind<S2>(), + flags::FlagValueStorageKind::kHeapAllocated); +#endif + + EXPECT_EQ(flags::FlagValue::Kind<std::string>(), + flags::FlagValueStorageKind::kHeapAllocated); + EXPECT_EQ(flags::FlagValue::Kind<std::vector<std::string>>(), + flags::FlagValueStorageKind::kHeapAllocated); +} + +// -------------------------------------------------------------------- + +constexpr flags::FlagHelpArg help_arg{flags::FlagHelpMsg("literal help"), + flags::FlagHelpKind::kLiteral}; + +using String = std::string; + +#define DEFINE_CONSTRUCTED_FLAG(T) \ + constexpr flags::Flag<T> f1##T("f1", "file", help_arg, &TestMakeDflt<T>); \ + ABSL_CONST_INIT flags::Flag<T> f2##T( \ + "f2", "file", \ + {flags::FlagHelpMsg(&TestHelpMsg), flags::FlagHelpKind::kGenFunc}, \ + &TestMakeDflt<T>) + +#define TEST_CONSTRUCTED_FLAG(T) TestConstructionFor(f1##T, &f2##T); + +DEFINE_CONSTRUCTED_FLAG(bool); +DEFINE_CONSTRUCTED_FLAG(int16_t); +DEFINE_CONSTRUCTED_FLAG(uint16_t); +DEFINE_CONSTRUCTED_FLAG(int32_t); +DEFINE_CONSTRUCTED_FLAG(uint32_t); +DEFINE_CONSTRUCTED_FLAG(int64_t); +DEFINE_CONSTRUCTED_FLAG(uint64_t); +DEFINE_CONSTRUCTED_FLAG(float); +DEFINE_CONSTRUCTED_FLAG(double); +DEFINE_CONSTRUCTED_FLAG(String); +DEFINE_CONSTRUCTED_FLAG(UDT); + +template <typename T> +bool TestConstructionFor(const flags::Flag<T>& f1, flags::Flag<T>* f2) { + EXPECT_EQ(f1.Name(), "f1"); + EXPECT_EQ(f1.Help(), "literal help"); + EXPECT_EQ(f1.Filename(), "file"); + + flags::FlagRegistrar<T, false>(f2).OnUpdate(TestCallback); + + EXPECT_EQ(f2->Name(), "f2"); + EXPECT_EQ(f2->Help(), "dynamic help"); + EXPECT_EQ(f2->Filename(), "file"); + + return true; +} + +TEST_F(FlagTest, TestConstruction) { + TEST_CONSTRUCTED_FLAG(bool); + TEST_CONSTRUCTED_FLAG(int16_t); + TEST_CONSTRUCTED_FLAG(uint16_t); + TEST_CONSTRUCTED_FLAG(int32_t); + TEST_CONSTRUCTED_FLAG(uint32_t); + TEST_CONSTRUCTED_FLAG(int64_t); + TEST_CONSTRUCTED_FLAG(uint64_t); + TEST_CONSTRUCTED_FLAG(float); + TEST_CONSTRUCTED_FLAG(double); + TEST_CONSTRUCTED_FLAG(String); + TEST_CONSTRUCTED_FLAG(UDT); } // -------------------------------------------------------------------- @@ -98,7 +195,7 @@ #if !ABSL_FLAGS_STRIP_NAMES -TEST(FlagTest, TestFlagDeclaration) { +TEST_F(FlagTest, TestFlagDeclaration) { // test that we can access flag objects. EXPECT_EQ(FLAGS_test_flag_01.Name(), "test_flag_01"); EXPECT_EQ(FLAGS_test_flag_02.Name(), "test_flag_02"); @@ -133,69 +230,69 @@ namespace { #if !ABSL_FLAGS_STRIP_NAMES -TEST(FlagTest, TestFlagDefinition) { +TEST_F(FlagTest, TestFlagDefinition) { absl::string_view expected_file_name = "absl/flags/flag_test.cc"; EXPECT_EQ(FLAGS_test_flag_01.Name(), "test_flag_01"); EXPECT_EQ(FLAGS_test_flag_01.Help(), "test flag 01"); - EXPECT_TRUE( - absl::EndsWith(FLAGS_test_flag_01.Filename(), expected_file_name)); + EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_01.Filename(), expected_file_name)) + << FLAGS_test_flag_01.Filename(); EXPECT_EQ(FLAGS_test_flag_02.Name(), "test_flag_02"); EXPECT_EQ(FLAGS_test_flag_02.Help(), "test flag 02"); - EXPECT_TRUE( - absl::EndsWith(FLAGS_test_flag_02.Filename(), expected_file_name)); + EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_02.Filename(), expected_file_name)) + << FLAGS_test_flag_02.Filename(); EXPECT_EQ(FLAGS_test_flag_03.Name(), "test_flag_03"); EXPECT_EQ(FLAGS_test_flag_03.Help(), "test flag 03"); - EXPECT_TRUE( - absl::EndsWith(FLAGS_test_flag_03.Filename(), expected_file_name)); + EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_03.Filename(), expected_file_name)) + << FLAGS_test_flag_03.Filename(); EXPECT_EQ(FLAGS_test_flag_04.Name(), "test_flag_04"); EXPECT_EQ(FLAGS_test_flag_04.Help(), "test flag 04"); - EXPECT_TRUE( - absl::EndsWith(FLAGS_test_flag_04.Filename(), expected_file_name)); + EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_04.Filename(), expected_file_name)) + << FLAGS_test_flag_04.Filename(); EXPECT_EQ(FLAGS_test_flag_05.Name(), "test_flag_05"); EXPECT_EQ(FLAGS_test_flag_05.Help(), "test flag 05"); - EXPECT_TRUE( - absl::EndsWith(FLAGS_test_flag_05.Filename(), expected_file_name)); + EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_05.Filename(), expected_file_name)) + << FLAGS_test_flag_05.Filename(); EXPECT_EQ(FLAGS_test_flag_06.Name(), "test_flag_06"); EXPECT_EQ(FLAGS_test_flag_06.Help(), "test flag 06"); - EXPECT_TRUE( - absl::EndsWith(FLAGS_test_flag_06.Filename(), expected_file_name)); + EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_06.Filename(), expected_file_name)) + << FLAGS_test_flag_06.Filename(); EXPECT_EQ(FLAGS_test_flag_07.Name(), "test_flag_07"); EXPECT_EQ(FLAGS_test_flag_07.Help(), "test flag 07"); - EXPECT_TRUE( - absl::EndsWith(FLAGS_test_flag_07.Filename(), expected_file_name)); + EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_07.Filename(), expected_file_name)) + << FLAGS_test_flag_07.Filename(); EXPECT_EQ(FLAGS_test_flag_08.Name(), "test_flag_08"); EXPECT_EQ(FLAGS_test_flag_08.Help(), "test flag 08"); - EXPECT_TRUE( - absl::EndsWith(FLAGS_test_flag_08.Filename(), expected_file_name)); + EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_08.Filename(), expected_file_name)) + << FLAGS_test_flag_08.Filename(); EXPECT_EQ(FLAGS_test_flag_09.Name(), "test_flag_09"); EXPECT_EQ(FLAGS_test_flag_09.Help(), "test flag 09"); - EXPECT_TRUE( - absl::EndsWith(FLAGS_test_flag_09.Filename(), expected_file_name)); + EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_09.Filename(), expected_file_name)) + << FLAGS_test_flag_09.Filename(); EXPECT_EQ(FLAGS_test_flag_10.Name(), "test_flag_10"); EXPECT_EQ(FLAGS_test_flag_10.Help(), "test flag 10"); - EXPECT_TRUE( - absl::EndsWith(FLAGS_test_flag_10.Filename(), expected_file_name)); + EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_10.Filename(), expected_file_name)) + << FLAGS_test_flag_10.Filename(); EXPECT_EQ(FLAGS_test_flag_11.Name(), "test_flag_11"); EXPECT_EQ(FLAGS_test_flag_11.Help(), "test flag 11"); - EXPECT_TRUE( - absl::EndsWith(FLAGS_test_flag_11.Filename(), expected_file_name)); + EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_11.Filename(), expected_file_name)) + << FLAGS_test_flag_11.Filename(); } #endif // !ABSL_FLAGS_STRIP_NAMES // -------------------------------------------------------------------- -TEST(FlagTest, TestDefault) { +TEST_F(FlagTest, TestDefault) { EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_01), true); EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_02), 1234); EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_03), -34); @@ -211,7 +308,7 @@ // -------------------------------------------------------------------- -TEST(FlagTest, TestGetSet) { +TEST_F(FlagTest, TestGetSet) { absl::SetFlag(&FLAGS_test_flag_01, false); EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_01), false); @@ -258,7 +355,7 @@ namespace { -TEST(FlagTest, TestNonConstexprDefault) { +TEST_F(FlagTest, TestNonConstexprDefault) { EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_12), 1); EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_13), "AAABBB"); } @@ -272,7 +369,7 @@ namespace { #if !ABSL_FLAGS_STRIP_HELP -TEST(FlagTest, TestNonConstexprHelp) { +TEST_F(FlagTest, TestNonConstexprHelp) { EXPECT_EQ(FLAGS_test_flag_14.Help(), "test flag 14"); } #endif //! ABSL_FLAGS_STRIP_HELP @@ -296,7 +393,7 @@ void TestFlagCB() { cb_test_value = absl::GetFlag(FLAGS_test_flag_with_cb); } // Tests side-effects of callback invocation. -TEST(FlagTest, CallbackInvocation) { +TEST_F(FlagTest, CallbackInvocation) { EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_with_cb), 100); EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_with_lambda_cb), 200); EXPECT_EQ(cb_test_value, 300); @@ -343,7 +440,7 @@ namespace { -TEST(FlagTest, TestCustomUDT) { +TEST_F(FlagTest, TestCustomUDT) { EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_15), CustomUDT(1, 1)); absl::SetFlag(&FLAGS_test_flag_15, CustomUDT(2, 3)); EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_15), CustomUDT(2, 3)); @@ -351,21 +448,23 @@ // MSVC produces link error on the type mismatch. // Linux does not have build errors and validations work as expected. -#if 0 // !defined(_WIN32) && GTEST_HAS_DEATH_TEST +#if !defined(_WIN32) && GTEST_HAS_DEATH_TEST -TEST(Flagtest, TestTypeMismatchValidations) { - // For builtin types, GetFlag() only does validation in debug mode. - EXPECT_DEBUG_DEATH( - absl::GetFlag(FLAGS_mistyped_int_flag), - "Flag 'mistyped_int_flag' is defined as one type and declared " - "as another"); - EXPECT_DEATH(absl::SetFlag(&FLAGS_mistyped_int_flag, 0), +using FlagDeathTest = FlagTest; + +TEST_F(FlagDeathTest, TestTypeMismatchValidations) { +#if !defined(NDEBUG) + EXPECT_DEATH(static_cast<void>(absl::GetFlag(FLAGS_mistyped_int_flag)), "Flag 'mistyped_int_flag' is defined as one type and declared " "as another"); - - EXPECT_DEATH(absl::GetFlag(FLAGS_mistyped_string_flag), + EXPECT_DEATH(static_cast<void>(absl::GetFlag(FLAGS_mistyped_string_flag)), "Flag 'mistyped_string_flag' is defined as one type and " "declared as another"); +#endif + + EXPECT_DEATH(absl::SetFlag(&FLAGS_mistyped_int_flag, 1), + "Flag 'mistyped_int_flag' is defined as one type and declared " + "as another"); EXPECT_DEATH( absl::SetFlag(&FLAGS_mistyped_string_flag, std::vector<std::string>{}), "Flag 'mistyped_string_flag' is defined as one type and declared as " @@ -409,7 +508,7 @@ namespace { -TEST(FlagTest, CanSetViaImplicitConversion) { +TEST_F(FlagTest, CanSetViaImplicitConversion) { EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_16).a, 10); absl::SetFlag(&FLAGS_test_flag_16, ConversionTestVal::ViaImplicitConv::kEleven); @@ -447,7 +546,7 @@ namespace { -TEST(FlagTest, TestNonDefaultConstructibleType) { +TEST_F(FlagTest, TestNonDefaultConstructibleType) { EXPECT_EQ(absl::GetFlag(FLAGS_ndc_flag1).value, '1' + 100); EXPECT_EQ(absl::GetFlag(FLAGS_ndc_flag2).value, 0); @@ -468,7 +567,7 @@ namespace { -TEST(FlagTest, TestRetiredFlagRegistration) { +TEST_F(FlagTest, TestRetiredFlagRegistration) { bool is_bool = false; EXPECT_TRUE(flags::IsRetiredFlag("old_bool_flag", &is_bool)); EXPECT_TRUE(is_bool);
diff --git a/third_party/abseil-cpp/absl/flags/flag_test_defs.cc b/third_party/abseil-cpp/absl/flags/flag_test_defs.cc index 3366c5803..49f91de 100644 --- a/third_party/abseil-cpp/absl/flags/flag_test_defs.cc +++ b/third_party/abseil-cpp/absl/flags/flag_test_defs.cc
@@ -20,3 +20,5 @@ ABSL_FLAG(int, mistyped_int_flag, 0, ""); ABSL_FLAG(std::string, mistyped_string_flag, "", ""); +ABSL_RETIRED_FLAG(bool, old_bool_flag, true, + "repetition of retired flag definition");
diff --git a/third_party/abseil-cpp/absl/flags/internal/commandlineflag.cc b/third_party/abseil-cpp/absl/flags/internal/commandlineflag.cc index b0800fc0..90765a3 100644 --- a/third_party/abseil-cpp/absl/flags/internal/commandlineflag.cc +++ b/third_party/abseil-cpp/absl/flags/internal/commandlineflag.cc
@@ -1,5 +1,5 @@ // -// Copyright 2019 The Abseil Authors. +// Copyright 2020 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,480 +15,16 @@ #include "absl/flags/internal/commandlineflag.h" -#include <cassert> - -#include "absl/base/internal/raw_logging.h" -#include "absl/base/optimization.h" -#include "absl/flags/config.h" -#include "absl/flags/usage_config.h" -#include "absl/strings/str_cat.h" -#include "absl/synchronization/mutex.h" - namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { -// The help message indicating that the commandline flag has been -// 'stripped'. It will not show up when doing "-help" and its -// variants. The flag is stripped if ABSL_FLAGS_STRIP_HELP is set to 1 -// before including absl/flags/flag.h +FlagStateInterface::~FlagStateInterface() {} -// This is used by this file, and also in commandlineflags_reporting.cc -const char kStrippedFlagHelp[] = "\001\002\003\004 (unknown) \004\003\002\001"; - -namespace { - -// Currently we only validate flag values for user-defined flag types. -bool ShouldValidateFlagValue(const CommandLineFlag& flag) { -#define DONT_VALIDATE(T) \ - if (flag.IsOfType<T>()) return false; - ABSL_FLAGS_INTERNAL_FOR_EACH_LOCK_FREE(DONT_VALIDATE) - DONT_VALIDATE(std::string) - DONT_VALIDATE(std::vector<std::string>) -#undef DONT_VALIDATE - - return true; -} - -} // namespace - -absl::Mutex* InitFlag(CommandLineFlag* flag) { - ABSL_CONST_INIT static absl::Mutex init_lock(absl::kConstInit); - absl::Mutex* mu; - - { - absl::MutexLock lock(&init_lock); - - if (flag->locks == nullptr) { // Must initialize Mutexes for this flag. - flag->locks = new flags_internal::CommandLineFlagLocks; - } - - mu = &flag->locks->primary_mu; - } - - { - absl::MutexLock lock(mu); - - if (!flag->retired && flag->def == nullptr) { - // Need to initialize def and cur fields. - flag->def = (*flag->make_init_value)(); - flag->cur = Clone(flag->op, flag->def); - UpdateCopy(flag); - flag->inited.store(true, std::memory_order_release); - flag->InvokeCallback(); - } - } - - flag->inited.store(true, std::memory_order_release); - return mu; -} - -// Ensure that the lazily initialized fields of *flag have been initialized, -// and return &flag->locks->primary_mu. -absl::Mutex* CommandLineFlag::InitFlagIfNecessary() const - ABSL_LOCK_RETURNED(locks->primary_mu) { - if (!this->inited.load(std::memory_order_acquire)) { - return InitFlag(const_cast<CommandLineFlag*>(this)); - } - - // All fields initialized; this->locks is therefore safe to read. - return &this->locks->primary_mu; -} - -void CommandLineFlag::Destroy() const { - // Values are heap allocated for retired and Abseil Flags. - if (IsRetired() || IsAbseilFlag()) { - if (this->cur) Delete(this->op, this->cur); - if (this->def) Delete(this->op, this->def); - } - - delete this->locks; -} - -bool CommandLineFlag::IsModified() const { - absl::MutexLock l(InitFlagIfNecessary()); - return modified; -} - -void CommandLineFlag::SetModified(bool is_modified) { - absl::MutexLock l(InitFlagIfNecessary()); - modified = is_modified; -} - -bool CommandLineFlag::IsSpecifiedOnCommandLine() const { - absl::MutexLock l(InitFlagIfNecessary()); - return on_command_line; -} - -absl::string_view CommandLineFlag::Typename() const { - // We do not store/report type in Abseil Flags, so that user do not rely on in - // at runtime - if (IsAbseilFlag() || IsRetired()) return ""; - -#define HANDLE_V1_BUILTIN_TYPE(t) \ - if (IsOfType<t>()) { \ - return #t; \ - } - - HANDLE_V1_BUILTIN_TYPE(bool); - HANDLE_V1_BUILTIN_TYPE(int32_t); - HANDLE_V1_BUILTIN_TYPE(int64_t); - HANDLE_V1_BUILTIN_TYPE(uint64_t); - HANDLE_V1_BUILTIN_TYPE(double); -#undef HANDLE_V1_BUILTIN_TYPE - - if (IsOfType<std::string>()) { - return "string"; - } - - return ""; -} - -std::string CommandLineFlag::Filename() const { - return flags_internal::GetUsageConfig().normalize_filename(this->filename); -} - -std::string CommandLineFlag::DefaultValue() const { - absl::MutexLock l(InitFlagIfNecessary()); - - return Unparse(this->marshalling_op, this->def); -} - -std::string CommandLineFlag::CurrentValue() const { - absl::MutexLock l(InitFlagIfNecessary()); - - return Unparse(this->marshalling_op, this->cur); -} - -bool CommandLineFlag::HasValidatorFn() const { - absl::MutexLock l(InitFlagIfNecessary()); - - return this->validator != nullptr; -} - -bool CommandLineFlag::SetValidatorFn(FlagValidator fn) { - absl::MutexLock l(InitFlagIfNecessary()); - - // ok to register the same function over and over again - if (fn == this->validator) return true; - - // Can't set validator to a different function, unless reset first. - if (fn != nullptr && this->validator != nullptr) { - ABSL_INTERNAL_LOG( - WARNING, absl::StrCat("Ignoring SetValidatorFn() for flag '", Name(), - "': validate-fn already registered")); - - return false; - } - - this->validator = fn; - return true; -} - -bool CommandLineFlag::InvokeValidator(const void* value) const - ABSL_EXCLUSIVE_LOCKS_REQUIRED(this->locks->primary_mu) { - if (!this->validator) { - return true; - } - - (void)value; - - ABSL_INTERNAL_LOG( - FATAL, - absl::StrCat("Flag '", Name(), - "' of encapsulated type should not have a validator")); - - return false; -} - -void CommandLineFlag::SetCallback( - const flags_internal::FlagCallback mutation_callback) { - absl::MutexLock l(InitFlagIfNecessary()); - - callback = mutation_callback; - - InvokeCallback(); -} - -// If the flag has a mutation callback this function invokes it. While the -// callback is being invoked the primary flag's mutex is unlocked and it is -// re-locked back after call to callback is completed. Callback invocation is -// guarded by flag's secondary mutex instead which prevents concurrent callback -// invocation. Note that it is possible for other thread to grab the primary -// lock and update flag's value at any time during the callback invocation. -// This is by design. Callback can get a value of the flag if necessary, but it -// might be different from the value initiated the callback and it also can be -// different by the time the callback invocation is completed. -// Requires that *primary_lock be held in exclusive mode; it may be released -// and reacquired by the implementation. -void CommandLineFlag::InvokeCallback() - ABSL_EXCLUSIVE_LOCKS_REQUIRED(this->locks->primary_mu) { - if (!this->callback) return; - - // The callback lock is guaranteed initialized, because *locks->primary_mu - // exists. - absl::Mutex* callback_mu = &this->locks->callback_mu; - - // When executing the callback we need the primary flag's mutex to be unlocked - // so that callback can retrieve the flag's value. - this->locks->primary_mu.Unlock(); - - { - absl::MutexLock lock(callback_mu); - this->callback(); - } - - this->locks->primary_mu.Lock(); -} - -// Attempts to parse supplied `value` string using parsing routine in the `flag` -// argument. If parsing is successful, it will try to validate that the parsed -// value is valid for the specified 'flag'. Finally this function stores the -// parsed value in 'dst' assuming it is a pointer to the flag's value type. In -// case if any error is encountered in either step, the error message is stored -// in 'err' -bool TryParseLocked(CommandLineFlag* flag, void* dst, absl::string_view value, - std::string* err) - ABSL_EXCLUSIVE_LOCKS_REQUIRED(flag->locks->primary_mu) { - void* tentative_value = Clone(flag->op, flag->def); - std::string parse_err; - if (!Parse(flag->marshalling_op, value, tentative_value, &parse_err)) { - auto type_name = flag->Typename(); - absl::string_view err_sep = parse_err.empty() ? "" : "; "; - absl::string_view typename_sep = type_name.empty() ? "" : " "; - *err = absl::StrCat("Illegal value '", value, "' specified for", - typename_sep, type_name, " flag '", flag->Name(), "'", - err_sep, parse_err); - Delete(flag->op, tentative_value); - return false; - } - - if (!flag->InvokeValidator(tentative_value)) { - *err = absl::StrCat("Failed validation of new value '", - Unparse(flag->marshalling_op, tentative_value), - "' for flag '", flag->Name(), "'"); - Delete(flag->op, tentative_value); - return false; - } - - flag->counter++; - Copy(flag->op, tentative_value, dst); - Delete(flag->op, tentative_value); - return true; -} - -// Sets the value of the flag based on specified string `value`. If the flag -// was successfully set to new value, it returns true. Otherwise, sets `err` -// to indicate the error, leaves the flag unchanged, and returns false. There -// are three ways to set the flag's value: -// * Update the current flag value -// * Update the flag's default value -// * Update the current flag value if it was never set before -// The mode is selected based on 'set_mode' parameter. -bool CommandLineFlag::SetFromString(absl::string_view value, - FlagSettingMode set_mode, - ValueSource source, std::string* err) { - if (IsRetired()) return false; - - absl::MutexLock l(InitFlagIfNecessary()); - - // Direct-access flags can be modified without going through the - // flag API. Detect such changes and update the flag->modified bit. - if (!IsAbseilFlag()) { - if (!this->modified && ChangedDirectly(this, this->cur, this->def)) { - this->modified = true; - } - } - - switch (set_mode) { - case SET_FLAGS_VALUE: { - // set or modify the flag's value - if (!TryParseLocked(this, this->cur, value, err)) return false; - this->modified = true; - UpdateCopy(this); - InvokeCallback(); - - if (source == kCommandLine) { - this->on_command_line = true; - } - break; - } - case SET_FLAG_IF_DEFAULT: { - // set the flag's value, but only if it hasn't been set by someone else - if (!this->modified) { - if (!TryParseLocked(this, this->cur, value, err)) return false; - this->modified = true; - UpdateCopy(this); - InvokeCallback(); - } else { - // TODO(rogeeff): review and fix this semantic. Currently we do not fail - // in this case if flag is modified. This is misleading since the flag's - // value is not updated even though we return true. - // *err = absl::StrCat(this->Name(), " is already set to ", - // CurrentValue(), "\n"); - // return false; - return true; - } - break; - } - case SET_FLAGS_DEFAULT: { - // modify the flag's default-value - if (!TryParseLocked(this, this->def, value, err)) return false; - - if (!this->modified) { - // Need to set both defvalue *and* current, in this case - Copy(this->op, this->def, this->cur); - UpdateCopy(this); - InvokeCallback(); - } - break; - } - default: { - // unknown set_mode - assert(false); - return false; - } - } - - return true; -} - -void CommandLineFlag::StoreAtomic(size_t size) { - int64_t t = 0; - assert(size <= sizeof(int64_t)); - memcpy(&t, this->cur, size); - this->atomic.store(t, std::memory_order_release); -} - -void CommandLineFlag::CheckDefaultValueParsingRoundtrip() const { - std::string v = DefaultValue(); - - absl::MutexLock lock(InitFlagIfNecessary()); - - void* dst = Clone(this->op, this->def); - std::string error; - if (!flags_internal::Parse(this->marshalling_op, v, dst, &error)) { - ABSL_INTERNAL_LOG( - FATAL, - absl::StrCat("Flag ", Name(), " (from ", Filename(), - "): std::string form of default value '", v, - "' could not be parsed; error=", error)); - } - - // We do not compare dst to def since parsing/unparsing may make - // small changes, e.g., precision loss for floating point types. - Delete(this->op, dst); -} - -bool CommandLineFlag::ValidateDefaultValue() const { - absl::MutexLock lock(InitFlagIfNecessary()); - return InvokeValidator(this->def); -} - -bool CommandLineFlag::ValidateInputValue(absl::string_view value) const { - absl::MutexLock l(InitFlagIfNecessary()); // protect default value access - - void* obj = Clone(this->op, this->def); - std::string ignored_error; - const bool result = - flags_internal::Parse(this->marshalling_op, value, obj, &ignored_error) && - InvokeValidator(obj); - Delete(this->op, obj); - return result; -} - -const int64_t CommandLineFlag::kAtomicInit; - -void CommandLineFlag::Read(void* dst, - const flags_internal::FlagOpFn dst_op) const { - absl::ReaderMutexLock l(InitFlagIfNecessary()); - - // `dst_op` is the unmarshaling operation corresponding to the declaration - // visibile at the call site. `op` is the Flag's defined unmarshalling - // operation. They must match for this operation to be well-defined. - if (ABSL_PREDICT_FALSE(dst_op != op)) { - ABSL_INTERNAL_LOG( - ERROR, - absl::StrCat("Flag '", name, - "' is defined as one type and declared as another")); - } - CopyConstruct(op, cur, dst); -} - -void CommandLineFlag::Write(const void* src, - const flags_internal::FlagOpFn src_op) { - absl::MutexLock l(InitFlagIfNecessary()); - - // `src_op` is the marshalling operation corresponding to the declaration - // visible at the call site. `op` is the Flag's defined marshalling operation. - // They must match for this operation to be well-defined. - if (ABSL_PREDICT_FALSE(src_op != op)) { - ABSL_INTERNAL_LOG( - ERROR, - absl::StrCat("Flag '", name, - "' is defined as one type and declared as another")); - } - - if (ShouldValidateFlagValue(*this)) { - void* obj = Clone(op, src); - std::string ignored_error; - std::string src_as_str = Unparse(marshalling_op, src); - if (!Parse(marshalling_op, src_as_str, obj, &ignored_error) || - !InvokeValidator(obj)) { - ABSL_INTERNAL_LOG(ERROR, absl::StrCat("Attempt to set flag '", name, - "' to invalid value ", src_as_str)); - } - Delete(op, obj); - } - - modified = true; - counter++; - Copy(op, src, cur); - - UpdateCopy(this); - InvokeCallback(); -} - -std::string HelpText::GetHelpText() const { - if (help_function_) return help_function_(); - if (help_message_) return help_message_; - - return {}; -} - -// Update any copy of the flag value that is stored in an atomic word. -// In addition if flag has a mutation callback this function invokes it. -void UpdateCopy(CommandLineFlag* flag) { -#define STORE_ATOMIC(T) \ - else if (flag->IsOfType<T>()) { \ - flag->StoreAtomic(sizeof(T)); \ - } - - if (false) { - } - ABSL_FLAGS_INTERNAL_FOR_EACH_LOCK_FREE(STORE_ATOMIC) -#undef STORE_ATOMIC -} - -// Return true iff flag value was changed via direct-access. -bool ChangedDirectly(CommandLineFlag* flag, const void* a, const void* b) { - if (!flag->IsAbseilFlag()) { -// Need to compare values for direct-access flags. -#define CHANGED_FOR_TYPE(T) \ - if (flag->IsOfType<T>()) { \ - return *reinterpret_cast<const T*>(a) != *reinterpret_cast<const T*>(b); \ - } - - CHANGED_FOR_TYPE(bool); - CHANGED_FOR_TYPE(int32_t); - CHANGED_FOR_TYPE(int64_t); - CHANGED_FOR_TYPE(uint64_t); - CHANGED_FOR_TYPE(double); - CHANGED_FOR_TYPE(std::string); -#undef CHANGED_FOR_TYPE - } - - return false; -} +bool CommandLineFlag::IsRetired() const { return false; } +bool CommandLineFlag::IsAbseilFlag() const { return true; } } // namespace flags_internal +ABSL_NAMESPACE_END } // namespace absl +
diff --git a/third_party/abseil-cpp/absl/flags/internal/commandlineflag.h b/third_party/abseil-cpp/absl/flags/internal/commandlineflag.h index d82443a..9a740d57 100644 --- a/third_party/abseil-cpp/absl/flags/internal/commandlineflag.h +++ b/third_party/abseil-cpp/absl/flags/internal/commandlineflag.h
@@ -16,29 +16,41 @@ #ifndef ABSL_FLAGS_INTERNAL_COMMANDLINEFLAG_H_ #define ABSL_FLAGS_INTERNAL_COMMANDLINEFLAG_H_ -#include <atomic> +#include <stddef.h> +#include <stdint.h> +#include <memory> +#include <string> +#include <typeinfo> + +#include "absl/base/config.h" #include "absl/base/macros.h" +#include "absl/flags/config.h" #include "absl/flags/marshalling.h" -#include "absl/synchronization/mutex.h" +#include "absl/strings/string_view.h" #include "absl/types/optional.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { -// Type-specific operations, eg., parsing, copying, etc. are provided -// by function specific to that type with a signature matching FlagOpFn. -enum FlagOp { - kDelete, - kClone, - kCopy, - kCopyConstruct, - kSizeof, - kParse, - kUnparse -}; -using FlagOpFn = void* (*)(FlagOp, const void*, void*); -using FlagMarshallingOpFn = void* (*)(FlagOp, const void*, void*, void*); +// An alias for flag static type id. Values of type identify the flag value type +// simialarly to typeid(T), but without relying on RTTI being available. In most +// cases this id is enough to uniquely identify the flag's value type. In a few +// cases we'll have to resort to using actual RTTI implementation if it is +// available. +using FlagStaticTypeId = void* (*)(); + +// Address of this function template is used in current implementation as a flag +// static type id. +template <typename T> +void* FlagStaticTypeIdGen() { +#if defined(ABSL_FLAGS_INTERNAL_HAS_RTTI) + return const_cast<std::type_info*>(&typeid(T)); +#else + return nullptr; +#endif +} // Options that control SetCommandLineOptionWithMode. enum FlagSettingMode { @@ -61,217 +73,97 @@ kProgrammaticChange, }; -// Signature for the help generation function used as an argument for the -// absl::Flag constructor. -using HelpGenFunc = std::string (*)(); - -// Signature for the function generating the initial flag value based (usually -// based on default value supplied in flag's definition) -using InitialValGenFunc = void* (*)(); - -struct CommandLineFlagInfo; - -// Signature for the mutation callback used by watched Flags -// The callback is noexcept. -// TODO(rogeeff): add noexcept after C++17 support is added. -using FlagCallback = void (*)(); - -using FlagValidator = bool (*)(); - -extern const char kStrippedFlagHelp[]; - -// The per-type function -template <typename T> -void* FlagOps(FlagOp op, const void* v1, void* v2) { - switch (op) { - case kDelete: - delete static_cast<const T*>(v1); - return nullptr; - case kClone: - return new T(*static_cast<const T*>(v1)); - case kCopy: - *static_cast<T*>(v2) = *static_cast<const T*>(v1); - return nullptr; - case kCopyConstruct: - new (v2) T(*static_cast<const T*>(v1)); - return nullptr; - case kSizeof: - return reinterpret_cast<void*>(sizeof(T)); - default: - return nullptr; - } -} - -template <typename T> -void* FlagMarshallingOps(FlagOp op, const void* v1, void* v2, void* v3) { - switch (op) { - case kParse: { - // initialize the temporary instance of type T based on current value in - // destination (which is going to be flag's default value). - T temp(*static_cast<T*>(v2)); - if (!absl::ParseFlag<T>(*static_cast<const absl::string_view*>(v1), &temp, - static_cast<std::string*>(v3))) { - return nullptr; - } - *static_cast<T*>(v2) = std::move(temp); - return v2; - } - case kUnparse: - *static_cast<std::string*>(v2) = - absl::UnparseFlag<T>(*static_cast<const T*>(v1)); - return nullptr; - default: - return nullptr; - } -} - -// Functions that invoke flag-type-specific operations. -inline void Delete(FlagOpFn op, const void* obj) { - op(flags_internal::kDelete, obj, nullptr); -} - -inline void* Clone(FlagOpFn op, const void* obj) { - return op(flags_internal::kClone, obj, nullptr); -} - -inline void Copy(FlagOpFn op, const void* src, void* dst) { - op(flags_internal::kCopy, src, dst); -} - -inline void CopyConstruct(FlagOpFn op, const void* src, void* dst) { - op(flags_internal::kCopyConstruct, src, dst); -} - -inline bool Parse(FlagMarshallingOpFn op, absl::string_view text, void* dst, - std::string* error) { - return op(flags_internal::kParse, &text, dst, error) != nullptr; -} - -inline std::string Unparse(FlagMarshallingOpFn op, const void* val) { - std::string result; - op(flags_internal::kUnparse, val, &result, nullptr); - return result; -} - -inline size_t Sizeof(FlagOpFn op) { - // This sequence of casts reverses the sequence from base::internal::FlagOps() - return static_cast<size_t>(reinterpret_cast<intptr_t>( - op(flags_internal::kSizeof, nullptr, nullptr))); -} - -// The following struct contains the locks in a CommandLineFlag struct. -// They are in a separate struct that is lazily allocated to avoid problems -// with static initialization and to avoid multiple allocations. -struct CommandLineFlagLocks { - absl::Mutex primary_mu; // protects several fields in CommandLineFlag - absl::Mutex callback_mu; // used to serialize callbacks -}; - -// Holds either a pointer to help text or a function which produces it. This is -// needed for supporting both static initialization of Flags while supporting -// the legacy registration framework. We can't use absl::variant<const char*, -// const char*(*)()> since anybody passing 0 or nullptr in to a CommandLineFlag -// would find an ambiguity. -class HelpText { +// Handle to FlagState objects. Specific flag state objects will restore state +// of a flag produced this flag state from method CommandLineFlag::SaveState(). +class FlagStateInterface { public: - static constexpr HelpText FromFunctionPointer(const HelpGenFunc fn) { - return HelpText(fn, nullptr); - } - static constexpr HelpText FromStaticCString(const char* msg) { - return HelpText(nullptr, msg); - } + virtual ~FlagStateInterface(); - std::string GetHelpText() const; - - HelpText() = delete; - HelpText(const HelpText&) = default; - HelpText(HelpText&&) = default; - - private: - explicit constexpr HelpText(const HelpGenFunc fn, const char* msg) - : help_function_(fn), help_message_(msg) {} - - HelpGenFunc help_function_; - const char* help_message_; + // Restores the flag originated this object to the saved state. + virtual void Restore() const = 0; }; // Holds all information for a flag. -struct CommandLineFlag { - constexpr CommandLineFlag( - const char* name_arg, HelpText help_text, const char* filename_arg, - const flags_internal::FlagOpFn op_arg, - const flags_internal::FlagMarshallingOpFn marshalling_op_arg, - const flags_internal::InitialValGenFunc initial_value_gen, - const bool retired_arg, void* def_arg, void* cur_arg) - : name(name_arg), - help(help_text), - filename(filename_arg), - op(op_arg), - marshalling_op(marshalling_op_arg), - make_init_value(initial_value_gen), - retired(retired_arg), - inited(false), - modified(false), - on_command_line(false), - validator(nullptr), - callback(nullptr), - def(def_arg), - cur(cur_arg), - counter(0), - atomic(kAtomicInit), - locks(nullptr) {} - - // Revert the init routine. - void Destroy() const; +class CommandLineFlag { + public: + constexpr CommandLineFlag() = default; // Not copyable/assignable. CommandLineFlag(const CommandLineFlag&) = delete; CommandLineFlag& operator=(const CommandLineFlag&) = delete; - absl::string_view Name() const { return name; } - std::string Help() const { return help.GetHelpText(); } - bool IsRetired() const { return this->retired; } - bool IsModified() const; - void SetModified(bool is_modified); - bool IsSpecifiedOnCommandLine() const; - // Returns true iff this is a handle to an Abseil Flag. - bool IsAbseilFlag() const { - // Set to null for V1 flags - return this->make_init_value != nullptr; - } - - absl::string_view Typename() const; - std::string Filename() const; - std::string DefaultValue() const; - std::string CurrentValue() const; - - bool HasValidatorFn() const; - bool SetValidatorFn(FlagValidator fn); - bool InvokeValidator(const void* value) const; + // Non-polymorphic access methods. // Return true iff flag has type T. template <typename T> inline bool IsOfType() const { - return this->op == &flags_internal::FlagOps<T>; + return TypeId() == &flags_internal::FlagStaticTypeIdGen<T>; } // Attempts to retrieve the flag value. Returns value on success, // absl::nullopt otherwise. template <typename T> absl::optional<T> Get() const { - if (IsRetired() || flags_internal::FlagOps<T> != this->op) + if (IsRetired() || !IsOfType<T>()) { return absl::nullopt; + } - T res; - Read(&res, flags_internal::FlagOps<T>); + // Implementation notes: + // + // We are wrapping a union around the value of `T` to serve three purposes: + // + // 1. `U.value` has correct size and alignment for a value of type `T` + // 2. The `U.value` constructor is not invoked since U's constructor does + // not do it explicitly. + // 3. The `U.value` destructor is invoked since U's destructor does it + // explicitly. This makes `U` a kind of RAII wrapper around non default + // constructible value of T, which is destructed when we leave the + // scope. We do need to destroy U.value, which is constructed by + // CommandLineFlag::Read even though we left it in a moved-from state + // after std::move. + // + // All of this serves to avoid requiring `T` being default constructible. + union U { + T value; + U() {} + ~U() { value.~T(); } + }; + U u; - return res; + Read(&u.value); + return std::move(u.value); } - void SetCallback(const flags_internal::FlagCallback mutation_callback); - void InvokeCallback(); + // Polymorphic access methods - // Sets the value of the flag based on specified std::string `value`. If the flag + // Returns name of this flag. + virtual absl::string_view Name() const = 0; + // Returns name of the file where this flag is defined. + virtual std::string Filename() const = 0; + // Returns name of the flag's value type for some built-in types or empty + // string. + virtual absl::string_view Typename() const = 0; + // Returns help message associated with this flag. + virtual std::string Help() const = 0; + // Returns true iff this object corresponds to retired flag. + virtual bool IsRetired() const; + // Returns true iff this is a handle to an Abseil Flag. + virtual bool IsAbseilFlag() const; + // Returns id of the flag's value type. + virtual FlagStaticTypeId TypeId() const = 0; + virtual bool IsModified() const = 0; + virtual bool IsSpecifiedOnCommandLine() const = 0; + virtual std::string DefaultValue() const = 0; + virtual std::string CurrentValue() const = 0; + + // Interfaces to operate on validators. + virtual bool ValidateInputValue(absl::string_view value) const = 0; + + // Interface to save flag to some persistent state. Returns current flag state + // or nullptr if flag does not support saving and restoring a state. + virtual std::unique_ptr<FlagStateInterface> SaveState() = 0; + + // Sets the value of the flag based on specified string `value`. If the flag // was successfully set to new value, it returns true. Otherwise, sets `error` // to indicate the error, leaves the flag unchanged, and returns false. There // are three ways to set the flag's value: @@ -279,105 +171,43 @@ // * Update the flag's default value // * Update the current flag value if it was never set before // The mode is selected based on `set_mode` parameter. - bool SetFromString(absl::string_view value, - flags_internal::FlagSettingMode set_mode, - flags_internal::ValueSource source, std::string* error); + virtual bool SetFromString(absl::string_view value, + flags_internal::FlagSettingMode set_mode, + flags_internal::ValueSource source, + std::string* error) = 0; - void StoreAtomic(size_t size); - - void CheckDefaultValueParsingRoundtrip() const; - // Invoke the flag validators for old flags. - // TODO(rogeeff): implement proper validators for Abseil Flags - bool ValidateDefaultValue() const; - bool ValidateInputValue(absl::string_view value) const; - - // Constant configuration for a particular flag. - private: - const char* const name; - const HelpText help; - const char* const filename; + // Checks that flags default value can be converted to string and back to the + // flag's value type. + virtual void CheckDefaultValueParsingRoundtrip() const = 0; protected: - const FlagOpFn op; // Type-specific handler - const FlagMarshallingOpFn marshalling_op; // Marshalling ops handler - const InitialValGenFunc make_init_value; // Makes initial value for the flag - const bool retired; // Is the flag retired? - std::atomic<bool> inited; // fields have been lazily initialized + ~CommandLineFlag() = default; - // Mutable state (guarded by locks->primary_mu). - bool modified; // Has flag value been modified? - bool on_command_line; // Specified on command line. - FlagValidator validator; // Validator function, or nullptr - FlagCallback callback; // Mutation callback, or nullptr - void* def; // Lazily initialized pointer to default value - void* cur; // Lazily initialized pointer to current value - int64_t counter; // Mutation counter - - // For some types, a copy of the current value is kept in an atomically - // accessible field. - static const int64_t kAtomicInit = 0xababababababababll; - std::atomic<int64_t> atomic; - - // Lazily initialized mutexes for this flag value. We cannot inline a - // SpinLock or Mutex here because those have non-constexpr constructors and - // so would prevent constant initialization of this type. - // TODO(rogeeff): fix it once Mutex has constexpr constructor - struct CommandLineFlagLocks* locks; // locks, laziliy allocated. - - // Ensure that the lazily initialized fields of *flag have been initialized, - // and return the lock which should be locked when flag's state is mutated. - absl::Mutex* InitFlagIfNecessary() const; - - // copy construct new value of flag's type in a memory referenced by dst - // based on current flag's value - void Read(void* dst, const flags_internal::FlagOpFn dst_op) const; - // updates flag's value to *src (locked) - void Write(const void* src, const flags_internal::FlagOpFn src_op); - - friend class FlagRegistry; - friend class FlagPtrMap; - friend class FlagSaverImpl; - friend void FillCommandLineFlagInfo(CommandLineFlag* flag, - CommandLineFlagInfo* result); - friend bool TryParseLocked(CommandLineFlag* flag, void* dst, - absl::string_view value, std::string* err); - friend absl::Mutex* InitFlag(CommandLineFlag* flag); + private: + // Copy-construct a new value of the flag's type in a memory referenced by + // the dst based on the current flag's value. + virtual void Read(void* dst) const = 0; }; -// Update any copy of the flag value that is stored in an atomic word. -// In addition if flag has a mutation callback this function invokes it. While -// callback is being invoked the primary flag's mutex is unlocked and it is -// re-locked back after call to callback is completed. Callback invocation is -// guarded by flag's secondary mutex instead which prevents concurrent callback -// invocation. Note that it is possible for other thread to grab the primary -// lock and update flag's value at any time during the callback invocation. -// This is by design. Callback can get a value of the flag if necessary, but it -// might be different from the value initiated the callback and it also can be -// different by the time the callback invocation is completed. -// Requires that *primary_lock be held in exclusive mode; it may be released -// and reacquired by the implementation. -void UpdateCopy(CommandLineFlag* flag); -// Return true iff flag value was changed via direct-access. -bool ChangedDirectly(CommandLineFlag* flag, const void* a, const void* b); - -// This macro is the "source of truth" for the list of supported flag types we -// expect to perform lock free operations on. Specifically it generates code, -// a one argument macro operating on a type, supplied as a macro argument, for -// each type in the list. -#define ABSL_FLAGS_INTERNAL_FOR_EACH_LOCK_FREE(A) \ - A(bool) \ - A(short) \ - A(unsigned short) \ - A(int) \ - A(unsigned int) \ - A(long) \ - A(unsigned long) \ - A(long long) \ - A(unsigned long long) \ - A(double) \ - A(float) +// This macro is the "source of truth" for the list of supported flag built-in +// types. +#define ABSL_FLAGS_INTERNAL_BUILTIN_TYPES(A) \ + A(bool) \ + A(short) \ + A(unsigned short) \ + A(int) \ + A(unsigned int) \ + A(long) \ + A(unsigned long) \ + A(long long) \ + A(unsigned long long) \ + A(double) \ + A(float) \ + A(std::string) \ + A(std::vector<std::string>) } // namespace flags_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_FLAGS_INTERNAL_COMMANDLINEFLAG_H_
diff --git a/third_party/abseil-cpp/absl/flags/internal/commandlineflag_test.cc b/third_party/abseil-cpp/absl/flags/internal/commandlineflag_test.cc index f0d57adb..0e8bc31 100644 --- a/third_party/abseil-cpp/absl/flags/internal/commandlineflag_test.cc +++ b/third_party/abseil-cpp/absl/flags/internal/commandlineflag_test.cc
@@ -15,12 +15,17 @@ #include "absl/flags/internal/commandlineflag.h" +#include <memory> +#include <string> + #include "gtest/gtest.h" #include "absl/flags/flag.h" #include "absl/flags/internal/registry.h" +#include "absl/flags/usage_config.h" #include "absl/memory/memory.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" ABSL_FLAG(int, int_flag, 201, "int_flag help"); ABSL_FLAG(std::string, string_flag, "dflt", @@ -33,10 +38,26 @@ class CommandLineFlagTest : public testing::Test { protected: + static void SetUpTestSuite() { + // Install a function to normalize filenames before this test is run. + absl::FlagsUsageConfig default_config; + default_config.normalize_filename = &CommandLineFlagTest::NormalizeFileName; + absl::SetFlagsUsageConfig(default_config); + } + void SetUp() override { flag_saver_ = absl::make_unique<flags::FlagSaver>(); } void TearDown() override { flag_saver_.reset(); } private: + static std::string NormalizeFileName(absl::string_view fname) { +#ifdef _WIN32 + std::string normalized(fname); + std::replace(normalized.begin(), normalized.end(), '\\', '/'); + fname = normalized; +#endif + return std::string(fname); + } + std::unique_ptr<flags::FlagSaver> flag_saver_; }; @@ -49,9 +70,10 @@ EXPECT_EQ(flag_01->Typename(), ""); EXPECT_TRUE(!flag_01->IsRetired()); EXPECT_TRUE(flag_01->IsOfType<int>()); - EXPECT_TRUE(absl::EndsWith( - flag_01->Filename(), - "absl/flags/internal/commandlineflag_test.cc")); + EXPECT_TRUE( + absl::EndsWith(flag_01->Filename(), + "absl/flags/internal/commandlineflag_test.cc")) + << flag_01->Filename(); auto* flag_02 = flags::FindCommandLineFlag("string_flag"); @@ -61,9 +83,10 @@ EXPECT_EQ(flag_02->Typename(), ""); EXPECT_TRUE(!flag_02->IsRetired()); EXPECT_TRUE(flag_02->IsOfType<std::string>()); - EXPECT_TRUE(absl::EndsWith( - flag_02->Filename(), - "absl/flags/internal/commandlineflag_test.cc")); + EXPECT_TRUE( + absl::EndsWith(flag_02->Filename(), + "absl/flags/internal/commandlineflag_test.cc")) + << flag_02->Filename(); auto* flag_03 = flags::FindRetiredFlag("bool_retired_flag");
diff --git a/third_party/abseil-cpp/absl/flags/internal/flag.cc b/third_party/abseil-cpp/absl/flags/internal/flag.cc new file mode 100644 index 0000000..a12fe7c --- /dev/null +++ b/third_party/abseil-cpp/absl/flags/internal/flag.cc
@@ -0,0 +1,429 @@ +// +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/flags/internal/flag.h" + +#include <stddef.h> +#include <stdint.h> +#include <string.h> + +#include <atomic> +#include <memory> +#include <string> +#include <vector> + +#include "absl/base/attributes.h" +#include "absl/base/config.h" +#include "absl/base/const_init.h" +#include "absl/base/optimization.h" +#include "absl/flags/internal/commandlineflag.h" +#include "absl/flags/usage_config.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" +#include "absl/synchronization/mutex.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace flags_internal { + +// The help message indicating that the commandline flag has been +// 'stripped'. It will not show up when doing "-help" and its +// variants. The flag is stripped if ABSL_FLAGS_STRIP_HELP is set to 1 +// before including absl/flags/flag.h +const char kStrippedFlagHelp[] = "\001\002\003\004 (unknown) \004\003\002\001"; + +namespace { + +// Currently we only validate flag values for user-defined flag types. +bool ShouldValidateFlagValue(FlagStaticTypeId flag_type_id) { +#define DONT_VALIDATE(T) \ + if (flag_type_id == &FlagStaticTypeIdGen<T>) return false; + ABSL_FLAGS_INTERNAL_BUILTIN_TYPES(DONT_VALIDATE) +#undef DONT_VALIDATE + + return true; +} + +// RAII helper used to temporarily unlock and relock `absl::Mutex`. +// This is used when we need to ensure that locks are released while +// invoking user supplied callbacks and then reacquired, since callbacks may +// need to acquire these locks themselves. +class MutexRelock { + public: + explicit MutexRelock(absl::Mutex* mu) : mu_(mu) { mu_->Unlock(); } + ~MutexRelock() { mu_->Lock(); } + + MutexRelock(const MutexRelock&) = delete; + MutexRelock& operator=(const MutexRelock&) = delete; + + private: + absl::Mutex* mu_; +}; + +} // namespace + +void FlagImpl::Init() { + new (&data_guard_) absl::Mutex; + + // At this point the default_value_ always points to gen_func. + std::unique_ptr<void, DynValueDeleter> init_value( + (*default_value_.gen_func)(), DynValueDeleter{op_}); + switch (ValueStorageKind()) { + case FlagValueStorageKind::kHeapAllocated: + value_.dynamic = init_value.release(); + break; + case FlagValueStorageKind::kOneWordAtomic: { + int64_t atomic_value; + std::memcpy(&atomic_value, init_value.get(), Sizeof(op_)); + value_.one_word_atomic.store(atomic_value, std::memory_order_release); + break; + } + case FlagValueStorageKind::kTwoWordsAtomic: { + AlignedTwoWords atomic_value{0, 0}; + std::memcpy(&atomic_value, init_value.get(), Sizeof(op_)); + value_.two_words_atomic.store(atomic_value, std::memory_order_release); + break; + } + } +} + +absl::Mutex* FlagImpl::DataGuard() const { + absl::call_once(const_cast<FlagImpl*>(this)->init_control_, &FlagImpl::Init, + const_cast<FlagImpl*>(this)); + + // data_guard_ is initialized inside Init. + return reinterpret_cast<absl::Mutex*>(&data_guard_); +} + +void FlagImpl::AssertValidType(FlagStaticTypeId type_id) const { + FlagStaticTypeId this_type_id = flags_internal::StaticTypeId(op_); + + // `type_id` is the type id corresponding to the declaration visibile at the + // call site. `this_type_id` is the type id corresponding to the type stored + // during flag definition. They must match for this operation to be + // well-defined. + if (ABSL_PREDICT_TRUE(type_id == this_type_id)) return; + + void* lhs_runtime_type_id = type_id(); + void* rhs_runtime_type_id = this_type_id(); + + if (lhs_runtime_type_id == rhs_runtime_type_id) return; + +#if defined(ABSL_FLAGS_INTERNAL_HAS_RTTI) + if (*reinterpret_cast<std::type_info*>(lhs_runtime_type_id) == + *reinterpret_cast<std::type_info*>(rhs_runtime_type_id)) + return; +#endif + + ABSL_INTERNAL_LOG( + FATAL, absl::StrCat("Flag '", Name(), + "' is defined as one type and declared as another")); +} + +std::unique_ptr<void, DynValueDeleter> FlagImpl::MakeInitValue() const { + void* res = nullptr; + if (DefaultKind() == FlagDefaultKind::kDynamicValue) { + res = flags_internal::Clone(op_, default_value_.dynamic_value); + } else { + res = (*default_value_.gen_func)(); + } + return {res, DynValueDeleter{op_}}; +} + +void FlagImpl::StoreValue(const void* src) { + switch (ValueStorageKind()) { + case FlagValueStorageKind::kHeapAllocated: + Copy(op_, src, value_.dynamic); + break; + case FlagValueStorageKind::kOneWordAtomic: { + int64_t one_word_val; + std::memcpy(&one_word_val, src, Sizeof(op_)); + value_.one_word_atomic.store(one_word_val, std::memory_order_release); + break; + } + case FlagValueStorageKind::kTwoWordsAtomic: { + AlignedTwoWords two_words_val{0, 0}; + std::memcpy(&two_words_val, src, Sizeof(op_)); + value_.two_words_atomic.store(two_words_val, std::memory_order_release); + break; + } + } + + modified_ = true; + ++counter_; + InvokeCallback(); +} + +absl::string_view FlagImpl::Name() const { return name_; } + +std::string FlagImpl::Filename() const { + return flags_internal::GetUsageConfig().normalize_filename(filename_); +} + +std::string FlagImpl::Help() const { + return HelpSourceKind() == FlagHelpKind::kLiteral ? help_.literal + : help_.gen_func(); +} + +bool FlagImpl::IsModified() const { + absl::MutexLock l(DataGuard()); + return modified_; +} + +bool FlagImpl::IsSpecifiedOnCommandLine() const { + absl::MutexLock l(DataGuard()); + return on_command_line_; +} + +std::string FlagImpl::DefaultValue() const { + absl::MutexLock l(DataGuard()); + + auto obj = MakeInitValue(); + return flags_internal::Unparse(op_, obj.get()); +} + +std::string FlagImpl::CurrentValue() const { + DataGuard(); // Make sure flag initialized + switch (ValueStorageKind()) { + case FlagValueStorageKind::kHeapAllocated: { + absl::MutexLock l(DataGuard()); + return flags_internal::Unparse(op_, value_.dynamic); + } + case FlagValueStorageKind::kOneWordAtomic: { + const auto one_word_val = + value_.one_word_atomic.load(std::memory_order_acquire); + return flags_internal::Unparse(op_, &one_word_val); + } + case FlagValueStorageKind::kTwoWordsAtomic: { + const auto two_words_val = + value_.two_words_atomic.load(std::memory_order_acquire); + return flags_internal::Unparse(op_, &two_words_val); + } + } + + return ""; +} + +void FlagImpl::SetCallback(const FlagCallbackFunc mutation_callback) { + absl::MutexLock l(DataGuard()); + + if (callback_ == nullptr) { + callback_ = new FlagCallback; + } + callback_->func = mutation_callback; + + InvokeCallback(); +} + +void FlagImpl::InvokeCallback() const { + if (!callback_) return; + + // Make a copy of the C-style function pointer that we are about to invoke + // before we release the lock guarding it. + FlagCallbackFunc cb = callback_->func; + + // If the flag has a mutation callback this function invokes it. While the + // callback is being invoked the primary flag's mutex is unlocked and it is + // re-locked back after call to callback is completed. Callback invocation is + // guarded by flag's secondary mutex instead which prevents concurrent + // callback invocation. Note that it is possible for other thread to grab the + // primary lock and update flag's value at any time during the callback + // invocation. This is by design. Callback can get a value of the flag if + // necessary, but it might be different from the value initiated the callback + // and it also can be different by the time the callback invocation is + // completed. Requires that *primary_lock be held in exclusive mode; it may be + // released and reacquired by the implementation. + MutexRelock relock(DataGuard()); + absl::MutexLock lock(&callback_->guard); + cb(); +} + +bool FlagImpl::RestoreState(const void* value, bool modified, + bool on_command_line, int64_t counter) { + { + absl::MutexLock l(DataGuard()); + + if (counter_ == counter) return false; + } + + Write(value); + + { + absl::MutexLock l(DataGuard()); + + modified_ = modified; + on_command_line_ = on_command_line; + } + + return true; +} + +// Attempts to parse supplied `value` string using parsing routine in the `flag` +// argument. If parsing successful, this function replaces the dst with newly +// parsed value. In case if any error is encountered in either step, the error +// message is stored in 'err' +std::unique_ptr<void, DynValueDeleter> FlagImpl::TryParse( + absl::string_view value, std::string* err) const { + std::unique_ptr<void, DynValueDeleter> tentative_value = MakeInitValue(); + + std::string parse_err; + if (!flags_internal::Parse(op_, value, tentative_value.get(), &parse_err)) { + absl::string_view err_sep = parse_err.empty() ? "" : "; "; + *err = absl::StrCat("Illegal value '", value, "' specified for flag '", + Name(), "'", err_sep, parse_err); + return nullptr; + } + + return tentative_value; +} + +void FlagImpl::Read(void* dst) const { + DataGuard(); // Make sure flag initialized + switch (ValueStorageKind()) { + case FlagValueStorageKind::kHeapAllocated: { + absl::MutexLock l(DataGuard()); + + flags_internal::CopyConstruct(op_, value_.dynamic, dst); + break; + } + case FlagValueStorageKind::kOneWordAtomic: { + const auto one_word_val = + value_.one_word_atomic.load(std::memory_order_acquire); + std::memcpy(dst, &one_word_val, Sizeof(op_)); + break; + } + case FlagValueStorageKind::kTwoWordsAtomic: { + const auto two_words_val = + value_.two_words_atomic.load(std::memory_order_acquire); + std::memcpy(dst, &two_words_val, Sizeof(op_)); + break; + } + } +} + +void FlagImpl::Write(const void* src) { + absl::MutexLock l(DataGuard()); + + if (ShouldValidateFlagValue(flags_internal::StaticTypeId(op_))) { + std::unique_ptr<void, DynValueDeleter> obj{flags_internal::Clone(op_, src), + DynValueDeleter{op_}}; + std::string ignored_error; + std::string src_as_str = flags_internal::Unparse(op_, src); + if (!flags_internal::Parse(op_, src_as_str, obj.get(), &ignored_error)) { + ABSL_INTERNAL_LOG(ERROR, absl::StrCat("Attempt to set flag '", Name(), + "' to invalid value ", src_as_str)); + } + } + + StoreValue(src); +} + +// Sets the value of the flag based on specified string `value`. If the flag +// was successfully set to new value, it returns true. Otherwise, sets `err` +// to indicate the error, leaves the flag unchanged, and returns false. There +// are three ways to set the flag's value: +// * Update the current flag value +// * Update the flag's default value +// * Update the current flag value if it was never set before +// The mode is selected based on 'set_mode' parameter. +bool FlagImpl::SetFromString(absl::string_view value, FlagSettingMode set_mode, + ValueSource source, std::string* err) { + absl::MutexLock l(DataGuard()); + + switch (set_mode) { + case SET_FLAGS_VALUE: { + // set or modify the flag's value + auto tentative_value = TryParse(value, err); + if (!tentative_value) return false; + + StoreValue(tentative_value.get()); + + if (source == kCommandLine) { + on_command_line_ = true; + } + break; + } + case SET_FLAG_IF_DEFAULT: { + // set the flag's value, but only if it hasn't been set by someone else + if (modified_) { + // TODO(rogeeff): review and fix this semantic. Currently we do not fail + // in this case if flag is modified. This is misleading since the flag's + // value is not updated even though we return true. + // *err = absl::StrCat(Name(), " is already set to ", + // CurrentValue(), "\n"); + // return false; + return true; + } + auto tentative_value = TryParse(value, err); + if (!tentative_value) return false; + + StoreValue(tentative_value.get()); + break; + } + case SET_FLAGS_DEFAULT: { + auto tentative_value = TryParse(value, err); + if (!tentative_value) return false; + + if (DefaultKind() == FlagDefaultKind::kDynamicValue) { + void* old_value = default_value_.dynamic_value; + default_value_.dynamic_value = tentative_value.release(); + tentative_value.reset(old_value); + } else { + default_value_.dynamic_value = tentative_value.release(); + def_kind_ = static_cast<uint8_t>(FlagDefaultKind::kDynamicValue); + } + + if (!modified_) { + // Need to set both default value *and* current, in this case. + StoreValue(default_value_.dynamic_value); + modified_ = false; + } + break; + } + } + + return true; +} + +void FlagImpl::CheckDefaultValueParsingRoundtrip() const { + std::string v = DefaultValue(); + + absl::MutexLock lock(DataGuard()); + + auto dst = MakeInitValue(); + std::string error; + if (!flags_internal::Parse(op_, v, dst.get(), &error)) { + ABSL_INTERNAL_LOG( + FATAL, + absl::StrCat("Flag ", Name(), " (from ", Filename(), + "): string form of default value '", v, + "' could not be parsed; error=", error)); + } + + // We do not compare dst to def since parsing/unparsing may make + // small changes, e.g., precision loss for floating point types. +} + +bool FlagImpl::ValidateInputValue(absl::string_view value) const { + absl::MutexLock l(DataGuard()); + + auto obj = MakeInitValue(); + std::string ignored_error; + return flags_internal::Parse(op_, value, obj.get(), &ignored_error); +} + +} // namespace flags_internal +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/flags/internal/flag.h b/third_party/abseil-cpp/absl/flags/internal/flag.h index bc50de5..344e31f 100644 --- a/third_party/abseil-cpp/absl/flags/internal/flag.h +++ b/third_party/abseil-cpp/absl/flags/internal/flag.h
@@ -16,44 +16,526 @@ #ifndef ABSL_FLAGS_INTERNAL_FLAG_H_ #define ABSL_FLAGS_INTERNAL_FLAG_H_ +#include <stdint.h> + +#include <atomic> +#include <cstring> +#include <memory> +#include <string> +#include <type_traits> + +#include "absl/base/call_once.h" +#include "absl/base/config.h" +#include "absl/base/thread_annotations.h" +#include "absl/flags/config.h" #include "absl/flags/internal/commandlineflag.h" #include "absl/flags/internal/registry.h" +#include "absl/memory/memory.h" +#include "absl/meta/type_traits.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" +#include "absl/synchronization/mutex.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { -// This is "unspecified" implementation of absl::Flag<T> type. template <typename T> -class Flag : public flags_internal::CommandLineFlag { +class Flag; + +/////////////////////////////////////////////////////////////////////////////// +// Flag value type operations, eg., parsing, copying, etc. are provided +// by function specific to that type with a signature matching FlagOpFn. + +enum class FlagOp { + kDelete, + kClone, + kCopy, + kCopyConstruct, + kSizeof, + kStaticTypeId, + kParse, + kUnparse, +}; +using FlagOpFn = void* (*)(FlagOp, const void*, void*, void*); + +// Flag value specific operations routine. +template <typename T> +void* FlagOps(FlagOp op, const void* v1, void* v2, void* v3) { + switch (op) { + case FlagOp::kDelete: + delete static_cast<const T*>(v1); + return nullptr; + case FlagOp::kClone: + return new T(*static_cast<const T*>(v1)); + case FlagOp::kCopy: + *static_cast<T*>(v2) = *static_cast<const T*>(v1); + return nullptr; + case FlagOp::kCopyConstruct: + new (v2) T(*static_cast<const T*>(v1)); + return nullptr; + case FlagOp::kSizeof: + return reinterpret_cast<void*>(sizeof(T)); + case FlagOp::kStaticTypeId: + return reinterpret_cast<void*>(&FlagStaticTypeIdGen<T>); + case FlagOp::kParse: { + // Initialize the temporary instance of type T based on current value in + // destination (which is going to be flag's default value). + T temp(*static_cast<T*>(v2)); + if (!absl::ParseFlag<T>(*static_cast<const absl::string_view*>(v1), &temp, + static_cast<std::string*>(v3))) { + return nullptr; + } + *static_cast<T*>(v2) = std::move(temp); + return v2; + } + case FlagOp::kUnparse: + *static_cast<std::string*>(v2) = + absl::UnparseFlag<T>(*static_cast<const T*>(v1)); + return nullptr; + default: + return nullptr; + } +} + +// Deletes memory interpreting obj as flag value type pointer. +inline void Delete(FlagOpFn op, const void* obj) { + op(FlagOp::kDelete, obj, nullptr, nullptr); +} +// Makes a copy of flag value pointed by obj. +inline void* Clone(FlagOpFn op, const void* obj) { + return op(FlagOp::kClone, obj, nullptr, nullptr); +} +// Copies src to dst interpreting as flag value type pointers. +inline void Copy(FlagOpFn op, const void* src, void* dst) { + op(FlagOp::kCopy, src, dst, nullptr); +} +// Construct a copy of flag value in a location pointed by dst +// based on src - pointer to the flag's value. +inline void CopyConstruct(FlagOpFn op, const void* src, void* dst) { + op(FlagOp::kCopyConstruct, src, dst, nullptr); +} +// Returns true if parsing of input text is successfull. +inline bool Parse(FlagOpFn op, absl::string_view text, void* dst, + std::string* error) { + return op(FlagOp::kParse, &text, dst, error) != nullptr; +} +// Returns string representing supplied value. +inline std::string Unparse(FlagOpFn op, const void* val) { + std::string result; + op(FlagOp::kUnparse, val, &result, nullptr); + return result; +} +// Returns size of flag value type. +inline size_t Sizeof(FlagOpFn op) { + // This sequence of casts reverses the sequence from + // `flags_internal::FlagOps()` + return static_cast<size_t>(reinterpret_cast<intptr_t>( + op(FlagOp::kSizeof, nullptr, nullptr, nullptr))); +} +// Returns static type id coresponding to the value type. +inline FlagStaticTypeId StaticTypeId(FlagOpFn op) { + return reinterpret_cast<FlagStaticTypeId>( + op(FlagOp::kStaticTypeId, nullptr, nullptr, nullptr)); +} + +/////////////////////////////////////////////////////////////////////////////// +// Persistent state of the flag data. + +template <typename T> +class FlagState : public flags_internal::FlagStateInterface { public: - constexpr Flag(const char* name, const flags_internal::HelpGenFunc help_gen, - const char* filename, - const flags_internal::FlagMarshallingOpFn marshalling_op_arg, - const flags_internal::InitialValGenFunc initial_value_gen) - : flags_internal::CommandLineFlag( - name, flags_internal::HelpText::FromFunctionPointer(help_gen), - filename, &flags_internal::FlagOps<T>, marshalling_op_arg, - initial_value_gen, - /*retired_arg=*/false, /*def_arg=*/nullptr, - /*cur_arg=*/nullptr) {} + FlagState(Flag<T>* flag, T&& cur, bool modified, bool on_command_line, + int64_t counter) + : flag_(flag), + cur_value_(std::move(cur)), + modified_(modified), + on_command_line_(on_command_line), + counter_(counter) {} + + ~FlagState() override = default; + + private: + friend class Flag<T>; + + // Restores the flag to the saved state. + void Restore() const override; + + // Flag and saved flag data. + Flag<T>* flag_; + T cur_value_; + bool modified_; + bool on_command_line_; + int64_t counter_; +}; + +/////////////////////////////////////////////////////////////////////////////// +// Flag help auxiliary structs. + +// This is help argument for absl::Flag encapsulating the string literal pointer +// or pointer to function generating it as well as enum descriminating two +// cases. +using HelpGenFunc = std::string (*)(); + +union FlagHelpMsg { + constexpr explicit FlagHelpMsg(const char* help_msg) : literal(help_msg) {} + constexpr explicit FlagHelpMsg(HelpGenFunc help_gen) : gen_func(help_gen) {} + + const char* literal; + HelpGenFunc gen_func; +}; + +enum class FlagHelpKind : uint8_t { kLiteral = 0, kGenFunc = 1 }; + +struct FlagHelpArg { + FlagHelpMsg source; + FlagHelpKind kind; +}; + +extern const char kStrippedFlagHelp[]; + +// HelpConstexprWrap is used by struct AbslFlagHelpGenFor##name generated by +// ABSL_FLAG macro. It is only used to silence the compiler in the case where +// help message expression is not constexpr and does not have type const char*. +// If help message expression is indeed constexpr const char* HelpConstexprWrap +// is just a trivial identity function. +template <typename T> +const char* HelpConstexprWrap(const T&) { + return nullptr; +} +constexpr const char* HelpConstexprWrap(const char* p) { return p; } +constexpr const char* HelpConstexprWrap(char* p) { return p; } + +// These two HelpArg overloads allows us to select at compile time one of two +// way to pass Help argument to absl::Flag. We'll be passing +// AbslFlagHelpGenFor##name as T and integer 0 as a single argument to prefer +// first overload if possible. If T::Const is evaluatable on constexpr +// context (see non template int parameter below) we'll choose first overload. +// In this case the help message expression is immediately evaluated and is used +// to construct the absl::Flag. No additionl code is generated by ABSL_FLAG. +// Otherwise SFINAE kicks in and first overload is dropped from the +// consideration, in which case the second overload will be used. The second +// overload does not attempt to evaluate the help message expression +// immediately and instead delays the evaluation by returing the function +// pointer (&T::NonConst) genering the help message when necessary. This is +// evaluatable in constexpr context, but the cost is an extra function being +// generated in the ABSL_FLAG code. +template <typename T, int = (T::Const(), 1)> +constexpr FlagHelpArg HelpArg(int) { + return {FlagHelpMsg(T::Const()), FlagHelpKind::kLiteral}; +} + +template <typename T> +constexpr FlagHelpArg HelpArg(char) { + return {FlagHelpMsg(&T::NonConst), FlagHelpKind::kGenFunc}; +} + +/////////////////////////////////////////////////////////////////////////////// +// Flag default value auxiliary structs. + +// Signature for the function generating the initial flag value (usually +// based on default value supplied in flag's definition) +using FlagDfltGenFunc = void* (*)(); + +union FlagDefaultSrc { + constexpr explicit FlagDefaultSrc(FlagDfltGenFunc gen_func_arg) + : gen_func(gen_func_arg) {} + + void* dynamic_value; + FlagDfltGenFunc gen_func; +}; + +enum class FlagDefaultKind : uint8_t { kDynamicValue = 0, kGenFunc = 1 }; + +/////////////////////////////////////////////////////////////////////////////// +// Flag current value auxiliary structs. + +constexpr int64_t UninitializedFlagValue() { return 0xababababababababll; } + +template <typename T> +using FlagUseOneWordStorage = std::integral_constant< + bool, absl::type_traits_internal::is_trivially_copyable<T>::value && + (sizeof(T) <= 8)>; + +#if defined(ABSL_FLAGS_INTERNAL_ATOMIC_DOUBLE_WORD) +// Clang does not always produce cmpxchg16b instruction when alignment of a 16 +// bytes type is not 16. +struct alignas(16) AlignedTwoWords { + int64_t first; + int64_t second; +}; + +template <typename T> +using FlagUseTwoWordsStorage = std::integral_constant< + bool, absl::type_traits_internal::is_trivially_copyable<T>::value && + (sizeof(T) > 8) && (sizeof(T) <= 16)>; +#else +// This is actually unused and only here to avoid ifdefs in other palces. +struct AlignedTwoWords { + constexpr AlignedTwoWords() = default; + constexpr AlignedTwoWords(int64_t, int64_t) {} +}; + +// This trait should be type dependent, otherwise SFINAE below will fail +template <typename T> +using FlagUseTwoWordsStorage = + std::integral_constant<bool, sizeof(T) != sizeof(T)>; +#endif + +template <typename T> +using FlagUseHeapStorage = + std::integral_constant<bool, !FlagUseOneWordStorage<T>::value && + !FlagUseTwoWordsStorage<T>::value>; + +enum class FlagValueStorageKind : uint8_t { + kHeapAllocated = 0, + kOneWordAtomic = 1, + kTwoWordsAtomic = 2 +}; + +union FlagValue { + constexpr explicit FlagValue(int64_t v) : one_word_atomic(v) {} + + template <typename T> + static constexpr FlagValueStorageKind Kind() { + return FlagUseHeapStorage<T>::value + ? FlagValueStorageKind::kHeapAllocated + : FlagUseOneWordStorage<T>::value + ? FlagValueStorageKind::kOneWordAtomic + : FlagUseTwoWordsStorage<T>::value + ? FlagValueStorageKind::kTwoWordsAtomic + : FlagValueStorageKind::kHeapAllocated; + } + + void* dynamic; + std::atomic<int64_t> one_word_atomic; + std::atomic<flags_internal::AlignedTwoWords> two_words_atomic; +}; + +/////////////////////////////////////////////////////////////////////////////// +// Flag callback auxiliary structs. + +// Signature for the mutation callback used by watched Flags +// The callback is noexcept. +// TODO(rogeeff): add noexcept after C++17 support is added. +using FlagCallbackFunc = void (*)(); + +struct FlagCallback { + FlagCallbackFunc func; + absl::Mutex guard; // Guard for concurrent callback invocations. +}; + +/////////////////////////////////////////////////////////////////////////////// +// Flag implementation, which does not depend on flag value type. +// The class encapsulates the Flag's data and access to it. + +struct DynValueDeleter { + explicit DynValueDeleter(FlagOpFn op_arg = nullptr) : op(op_arg) {} + void operator()(void* ptr) const { + if (op != nullptr) Delete(op, ptr); + } + + FlagOpFn op; +}; + +class FlagImpl { + public: + constexpr FlagImpl(const char* name, const char* filename, FlagOpFn op, + FlagHelpArg help, FlagValueStorageKind value_kind, + FlagDfltGenFunc default_value_gen) + : name_(name), + filename_(filename), + op_(op), + help_(help.source), + help_source_kind_(static_cast<uint8_t>(help.kind)), + value_storage_kind_(static_cast<uint8_t>(value_kind)), + def_kind_(static_cast<uint8_t>(FlagDefaultKind::kGenFunc)), + modified_(false), + on_command_line_(false), + counter_(0), + callback_(nullptr), + default_value_(default_value_gen), + value_(flags_internal::UninitializedFlagValue()), + data_guard_{} {} + + // Constant access methods + absl::string_view Name() const; + std::string Filename() const; + std::string Help() const; + bool IsModified() const ABSL_LOCKS_EXCLUDED(*DataGuard()); + bool IsSpecifiedOnCommandLine() const ABSL_LOCKS_EXCLUDED(*DataGuard()); + std::string DefaultValue() const ABSL_LOCKS_EXCLUDED(*DataGuard()); + std::string CurrentValue() const ABSL_LOCKS_EXCLUDED(*DataGuard()); + void Read(void* dst) const ABSL_LOCKS_EXCLUDED(*DataGuard()); + + template <typename T, typename std::enable_if<FlagUseHeapStorage<T>::value, + int>::type = 0> + void Get(T* dst) const { + Read(dst); + } + template <typename T, typename std::enable_if<FlagUseOneWordStorage<T>::value, + int>::type = 0> + void Get(T* dst) const { + int64_t one_word_val = + value_.one_word_atomic.load(std::memory_order_acquire); + if (ABSL_PREDICT_FALSE(one_word_val == UninitializedFlagValue())) { + DataGuard(); // Make sure flag initialized + one_word_val = value_.one_word_atomic.load(std::memory_order_acquire); + } + std::memcpy(dst, static_cast<const void*>(&one_word_val), sizeof(T)); + } + template <typename T, typename std::enable_if< + FlagUseTwoWordsStorage<T>::value, int>::type = 0> + void Get(T* dst) const { + DataGuard(); // Make sure flag initialized + const auto two_words_val = + value_.two_words_atomic.load(std::memory_order_acquire); + std::memcpy(dst, &two_words_val, sizeof(T)); + } + + // Mutating access methods + void Write(const void* src) ABSL_LOCKS_EXCLUDED(*DataGuard()); + bool SetFromString(absl::string_view value, FlagSettingMode set_mode, + ValueSource source, std::string* err) + ABSL_LOCKS_EXCLUDED(*DataGuard()); + + // Interfaces to operate on callbacks. + void SetCallback(const FlagCallbackFunc mutation_callback) + ABSL_LOCKS_EXCLUDED(*DataGuard()); + void InvokeCallback() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(*DataGuard()); + + // Interfaces to save/restore mutable flag data + template <typename T> + std::unique_ptr<FlagStateInterface> SaveState(Flag<T>* flag) const + ABSL_LOCKS_EXCLUDED(*DataGuard()) { + T&& cur_value = flag->Get(); + absl::MutexLock l(DataGuard()); + + return absl::make_unique<FlagState<T>>( + flag, std::move(cur_value), modified_, on_command_line_, counter_); + } + bool RestoreState(const void* value, bool modified, bool on_command_line, + int64_t counter) ABSL_LOCKS_EXCLUDED(*DataGuard()); + + // Value validation interfaces. + void CheckDefaultValueParsingRoundtrip() const + ABSL_LOCKS_EXCLUDED(*DataGuard()); + bool ValidateInputValue(absl::string_view value) const + ABSL_LOCKS_EXCLUDED(*DataGuard()); + + // Used in read/write operations to validate source/target has correct type. + // For example if flag is declared as absl::Flag<int> FLAGS_foo, a call to + // absl::GetFlag(FLAGS_foo) validates that the type of FLAGS_foo is indeed + // int. To do that we pass the "assumed" type id (which is deduced from type + // int) as an argument `op`, which is in turn is validated against the type id + // stored in flag object by flag definition statement. + void AssertValidType(FlagStaticTypeId type_id) const; + + private: + // Ensures that `data_guard_` is initialized and returns it. + absl::Mutex* DataGuard() const ABSL_LOCK_RETURNED((absl::Mutex*)&data_guard_); + // Returns heap allocated value of type T initialized with default value. + std::unique_ptr<void, DynValueDeleter> MakeInitValue() const + ABSL_EXCLUSIVE_LOCKS_REQUIRED(*DataGuard()); + // Flag initialization called via absl::call_once. + void Init(); + // Attempts to parse supplied `value` string. If parsing is successful, + // returns new value. Otherwise returns nullptr. + std::unique_ptr<void, DynValueDeleter> TryParse(absl::string_view value, + std::string* err) const + ABSL_EXCLUSIVE_LOCKS_REQUIRED(*DataGuard()); + // Stores the flag value based on the pointer to the source. + void StoreValue(const void* src) ABSL_EXCLUSIVE_LOCKS_REQUIRED(*DataGuard()); + + FlagHelpKind HelpSourceKind() const { + return static_cast<FlagHelpKind>(help_source_kind_); + } + FlagValueStorageKind ValueStorageKind() const { + return static_cast<FlagValueStorageKind>(value_storage_kind_); + } + FlagDefaultKind DefaultKind() const + ABSL_EXCLUSIVE_LOCKS_REQUIRED(*DataGuard()) { + return static_cast<FlagDefaultKind>(def_kind_); + } + + // Immutable flag's state. + + // Flags name passed to ABSL_FLAG as second arg. + const char* const name_; + // The file name where ABSL_FLAG resides. + const char* const filename_; + // Type-specific operations "vtable". + const FlagOpFn op_; + // Help message literal or function to generate it. + const FlagHelpMsg help_; + // Indicates if help message was supplied as literal or generator func. + const uint8_t help_source_kind_ : 1; + // Kind of storage this flag is using for the flag's value. + const uint8_t value_storage_kind_ : 2; + + // ------------------------------------------------------------------------ + // The bytes containing the const bitfields must not be shared with bytes + // containing the mutable bitfields. + // ------------------------------------------------------------------------ + + // Unique tag for absl::call_once call to initialize this flag. + // + // The placement of this variable between the immutable and mutable bitfields + // is important as prevents them from occupying the same byte. If you remove + // this variable, make sure to maintain this property. + absl::once_flag init_control_; + + // Mutable flag's state (guarded by `data_guard_`). + + // If def_kind_ == kDynamicValue, default_value_ holds a dynamically allocated + // value. + uint8_t def_kind_ : 1 ABSL_GUARDED_BY(*DataGuard()); + // Has this flag's value been modified? + bool modified_ : 1 ABSL_GUARDED_BY(*DataGuard()); + // Has this flag been specified on command line. + bool on_command_line_ : 1 ABSL_GUARDED_BY(*DataGuard()); + + // Mutation counter + int64_t counter_ ABSL_GUARDED_BY(*DataGuard()); + // Optional flag's callback and absl::Mutex to guard the invocations. + FlagCallback* callback_ ABSL_GUARDED_BY(*DataGuard()); + // Either a pointer to the function generating the default value based on the + // value specified in ABSL_FLAG or pointer to the dynamically set default + // value via SetCommandLineOptionWithMode. def_kind_ is used to distinguish + // these two cases. + FlagDefaultSrc default_value_; + + // Atomically mutable flag's state + + // Flag's value. This can be either the atomically stored small value or + // pointer to the heap allocated dynamic value. value_storage_kind_ is used + // to distinguish these cases. + FlagValue value_; + + // This is reserved space for an absl::Mutex to guard flag data. It will be + // initialized in FlagImpl::Init via placement new. + // We can't use "absl::Mutex data_guard_", since this class is not literal. + // We do not want to use "absl::Mutex* data_guard_", since this would require + // heap allocation during initialization, which is both slows program startup + // and can fail. Using reserved space + placement new allows us to avoid both + // problems. + alignas(absl::Mutex) mutable char data_guard_[sizeof(absl::Mutex)]; +}; + +/////////////////////////////////////////////////////////////////////////////// +// The Flag object parameterized by the flag's value type. This class implements +// flag reflection handle interface. + +template <typename T> +class Flag final : public flags_internal::CommandLineFlag { + public: + constexpr Flag(const char* name, const char* filename, const FlagHelpArg help, + const FlagDfltGenFunc default_value_gen) + : impl_(name, filename, &FlagOps<T>, help, FlagValue::Kind<T>(), + default_value_gen) {} T Get() const { - // Implementation notes: - // - // We are wrapping a union around the value of `T` to serve three purposes: - // - // 1. `U.value` has correct size and alignment for a value of type `T` - // 2. The `U.value` constructor is not invoked since U's constructor does - // not - // do it explicitly. - // 3. The `U.value` destructor is invoked since U's destructor does it - // explicitly. This makes `U` a kind of RAII wrapper around non default - // constructible value of T, which is destructed when we leave the - // scope. We do need to destroy U.value, which is constructed by - // CommandLineFlag::Read even though we left it in a moved-from state - // after std::move. - // - // All of this serves to avoid requiring `T` being default constructible. + // See implementation notes in CommandLineFlag::Get(). union U { T value; U() {} @@ -61,23 +543,76 @@ }; U u; - this->Read(&u.value, &flags_internal::FlagOps<T>); +#if !defined(NDEBUG) + impl_.AssertValidType(&flags_internal::FlagStaticTypeIdGen<T>); +#endif + + impl_.Get(&u.value); return std::move(u.value); } - - bool AtomicGet(T* v) const { - const int64_t r = this->atomic.load(std::memory_order_acquire); - if (r != flags_internal::CommandLineFlag::kAtomicInit) { - memcpy(v, &r, sizeof(T)); - return true; - } - - return false; + void Set(const T& v) { + impl_.AssertValidType(&flags_internal::FlagStaticTypeIdGen<T>); + impl_.Write(&v); + } + void SetCallback(const FlagCallbackFunc mutation_callback) { + impl_.SetCallback(mutation_callback); } - void Set(const T& v) { this->Write(&v, &flags_internal::FlagOps<T>); } + // CommandLineFlag interface + absl::string_view Name() const override { return impl_.Name(); } + std::string Filename() const override { return impl_.Filename(); } + absl::string_view Typename() const override { return ""; } + std::string Help() const override { return impl_.Help(); } + bool IsModified() const override { return impl_.IsModified(); } + bool IsSpecifiedOnCommandLine() const override { + return impl_.IsSpecifiedOnCommandLine(); + } + std::string DefaultValue() const override { return impl_.DefaultValue(); } + std::string CurrentValue() const override { return impl_.CurrentValue(); } + bool ValidateInputValue(absl::string_view value) const override { + return impl_.ValidateInputValue(value); + } + + // Interfaces to save and restore flags to/from persistent state. + // Returns current flag state or nullptr if flag does not support + // saving and restoring a state. + std::unique_ptr<FlagStateInterface> SaveState() override { + return impl_.SaveState(this); + } + + // Restores the flag state to the supplied state object. If there is + // nothing to restore returns false. Otherwise returns true. + bool RestoreState(const FlagState<T>& flag_state) { + return impl_.RestoreState(&flag_state.cur_value_, flag_state.modified_, + flag_state.on_command_line_, flag_state.counter_); + } + bool SetFromString(absl::string_view value, FlagSettingMode set_mode, + ValueSource source, std::string* error) override { + return impl_.SetFromString(value, set_mode, source, error); + } + void CheckDefaultValueParsingRoundtrip() const override { + impl_.CheckDefaultValueParsingRoundtrip(); + } + + private: + friend class FlagState<T>; + + void Read(void* dst) const override { impl_.Read(dst); } + FlagStaticTypeId TypeId() const override { return &FlagStaticTypeIdGen<T>; } + + // Flag's data + FlagImpl impl_; }; +template <typename T> +void FlagState<T>::Restore() const { + if (flag_->RestoreState(*this)) { + ABSL_INTERNAL_LOG(INFO, + absl::StrCat("Restore saved value of ", flag_->Name(), + " to: ", flag_->CurrentValue())); + } +} + // This class facilitates Flag object registration and tail expression-based // flag definition, for example: // ABSL_FLAG(int, foo, 42, "Foo help").OnUpdate(NotifyFooWatcher); @@ -88,7 +623,7 @@ if (do_register) flags_internal::RegisterCommandLineFlag(flag_); } - FlagRegistrar& OnUpdate(flags_internal::FlagCallback cb) && { + FlagRegistrar& OnUpdate(FlagCallbackFunc cb) && { flag_->SetCallback(cb); return *this; } @@ -116,6 +651,7 @@ } } // namespace flags_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_FLAGS_INTERNAL_FLAG_H_
diff --git a/third_party/abseil-cpp/absl/flags/internal/parse.h b/third_party/abseil-cpp/absl/flags/internal/parse.h index fd3aca6..03e8a07 100644 --- a/third_party/abseil-cpp/absl/flags/internal/parse.h +++ b/third_party/abseil-cpp/absl/flags/internal/parse.h
@@ -19,6 +19,7 @@ #include <string> #include <vector> +#include "absl/base/config.h" #include "absl/flags/declare.h" ABSL_DECLARE_FLAG(std::vector<std::string>, flagfile); @@ -27,6 +28,7 @@ ABSL_DECLARE_FLAG(std::vector<std::string>, undefok); namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { enum class ArgvListAction { kRemoveParsedArgs, kKeepParsedArgs }; @@ -43,6 +45,7 @@ OnUndefinedFlag on_undef_flag); } // namespace flags_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_FLAGS_INTERNAL_PARSE_H_
diff --git a/third_party/abseil-cpp/absl/flags/internal/path_util.h b/third_party/abseil-cpp/absl/flags/internal/path_util.h index 5615c0e..365c830 100644 --- a/third_party/abseil-cpp/absl/flags/internal/path_util.h +++ b/third_party/abseil-cpp/absl/flags/internal/path_util.h
@@ -16,10 +16,12 @@ #ifndef ABSL_FLAGS_INTERNAL_PATH_UTIL_H_ #define ABSL_FLAGS_INTERNAL_PATH_UTIL_H_ +#include "absl/base/config.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { // A portable interface that returns the basename of the filename passed as an @@ -55,6 +57,7 @@ } } // namespace flags_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_FLAGS_INTERNAL_PATH_UTIL_H_
diff --git a/third_party/abseil-cpp/absl/flags/internal/program_name.cc b/third_party/abseil-cpp/absl/flags/internal/program_name.cc index f0811f1..51d698d 100644 --- a/third_party/abseil-cpp/absl/flags/internal/program_name.cc +++ b/third_party/abseil-cpp/absl/flags/internal/program_name.cc
@@ -17,10 +17,16 @@ #include <string> +#include "absl/base/attributes.h" +#include "absl/base/config.h" +#include "absl/base/const_init.h" +#include "absl/base/thread_annotations.h" #include "absl/flags/internal/path_util.h" +#include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { ABSL_CONST_INIT static absl::Mutex program_name_guard(absl::kConstInit); @@ -50,4 +56,5 @@ } } // namespace flags_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/flags/internal/program_name.h b/third_party/abseil-cpp/absl/flags/internal/program_name.h index 326f24b..b99b94fe1 100644 --- a/third_party/abseil-cpp/absl/flags/internal/program_name.h +++ b/third_party/abseil-cpp/absl/flags/internal/program_name.h
@@ -18,12 +18,14 @@ #include <string> +#include "absl/base/config.h" #include "absl/strings/string_view.h" // -------------------------------------------------------------------- // Program name namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { // Returns program invocation name or "UNKNOWN" if `SetProgramInvocationName()` @@ -42,6 +44,7 @@ void SetProgramInvocationName(absl::string_view prog_name_str); } // namespace flags_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_FLAGS_INTERNAL_PROGRAM_NAME_H_
diff --git a/third_party/abseil-cpp/absl/flags/internal/program_name_test.cc b/third_party/abseil-cpp/absl/flags/internal/program_name_test.cc index ed69218..269142f 100644 --- a/third_party/abseil-cpp/absl/flags/internal/program_name_test.cc +++ b/third_party/abseil-cpp/absl/flags/internal/program_name_test.cc
@@ -15,8 +15,11 @@ #include "absl/flags/internal/program_name.h" +#include <string> + #include "gtest/gtest.h" #include "absl/strings/match.h" +#include "absl/strings/string_view.h" namespace {
diff --git a/third_party/abseil-cpp/absl/flags/internal/registry.cc b/third_party/abseil-cpp/absl/flags/internal/registry.cc index 2475bd8..e434a85 100644 --- a/third_party/abseil-cpp/absl/flags/internal/registry.cc +++ b/third_party/abseil-cpp/absl/flags/internal/registry.cc
@@ -15,9 +15,20 @@ #include "absl/flags/internal/registry.h" -#include "absl/base/dynamic_annotations.h" +#include <assert.h> +#include <stdlib.h> + +#include <functional> +#include <map> +#include <memory> +#include <string> +#include <utility> +#include <vector> + +#include "absl/base/config.h" #include "absl/base/internal/raw_logging.h" -#include "absl/flags/config.h" +#include "absl/base/thread_annotations.h" +#include "absl/flags/internal/commandlineflag.h" #include "absl/flags/usage_config.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" @@ -30,19 +41,8 @@ // set it. namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { -namespace { - -void DestroyFlag(CommandLineFlag* flag) ABSL_NO_THREAD_SAFETY_ANALYSIS { - flag->Destroy(); - - // CommandLineFlag handle object is heap allocated for non Abseil Flags. - if (!flag->IsAbseilFlag()) { - delete flag; - } -} - -} // namespace // -------------------------------------------------------------------- // FlagRegistry @@ -57,11 +57,7 @@ class FlagRegistry { public: FlagRegistry() = default; - ~FlagRegistry() { - for (auto& p : flags_) { - DestroyFlag(p.second); - } - } + ~FlagRegistry() = default; // Store a flag in this registry. Takes ownership of *flag. void RegisterFlag(CommandLineFlag* flag); @@ -113,6 +109,7 @@ FlagRegistry* const fr_; }; +void DestroyRetiredFlag(CommandLineFlag* flag); } // namespace void FlagRegistry::RegisterFlag(CommandLineFlag* flag) { @@ -130,7 +127,7 @@ (flag->IsRetired() ? old_flag->Filename() : flag->Filename()), "'."), true); - } else if (flag->op != old_flag->op) { + } else if (flag->TypeId() != old_flag->TypeId()) { flags_internal::ReportUsageError( absl::StrCat("Flag '", flag->Name(), "' was defined more than once but with " @@ -140,8 +137,8 @@ flag->Typename(), "', respectively."), true); } else if (old_flag->IsRetired()) { - // Retired definitions are idempotent. Just keep the old one. - DestroyFlag(flag); + // Retired flag can just be deleted. + DestroyRetiredFlag(flag); return; } else if (old_flag->Filename() != flag->Filename()) { flags_internal::ReportUsageError( @@ -200,112 +197,34 @@ class FlagSaverImpl { public: - // Constructs an empty FlagSaverImpl object. - FlagSaverImpl() {} - ~FlagSaverImpl() { - // reclaim memory from each of our CommandLineFlags - for (const SavedFlag& src : backup_registry_) { - Delete(src.op, src.current); - Delete(src.op, src.default_value); - } - } + FlagSaverImpl() = default; + FlagSaverImpl(const FlagSaverImpl&) = delete; + void operator=(const FlagSaverImpl&) = delete; // Saves the flag states from the flag registry into this object. // It's an error to call this more than once. - // Must be called when the registry mutex is not held. void SaveFromRegistry() { assert(backup_registry_.empty()); // call only once! - SavedFlag saved; flags_internal::ForEachFlag([&](flags_internal::CommandLineFlag* flag) { - if (flag->IsRetired()) return; - - saved.name = flag->Name(); - saved.op = flag->op; - saved.marshalling_op = flag->marshalling_op; - { - absl::MutexLock l(flag->InitFlagIfNecessary()); - saved.validator = flag->validator; - saved.modified = flag->modified; - saved.on_command_line = flag->on_command_line; - saved.current = Clone(saved.op, flag->cur); - saved.default_value = Clone(saved.op, flag->def); - saved.counter = flag->counter; + if (auto flag_state = flag->SaveState()) { + backup_registry_.emplace_back(std::move(flag_state)); } - backup_registry_.push_back(saved); }); } - // Restores the saved flag states into the flag registry. We - // assume no flags were added or deleted from the registry since - // the SaveFromRegistry; if they were, that's trouble! Must be - // called when the registry mutex is not held. + // Restores the saved flag states into the flag registry. void RestoreToRegistry() { - FlagRegistry* const global_registry = FlagRegistry::GlobalRegistry(); - FlagRegistryLock frl(global_registry); - for (const SavedFlag& src : backup_registry_) { - CommandLineFlag* flag = global_registry->FindFlagLocked(src.name); - // If null, flag got deleted from registry. - if (!flag) continue; - - bool restored = false; - { - absl::MutexLock l(flag->InitFlagIfNecessary()); - flag->validator = src.validator; - flag->modified = src.modified; - flag->on_command_line = src.on_command_line; - if (flag->counter != src.counter || - ChangedDirectly(flag, src.default_value, flag->def)) { - restored = true; - Copy(src.op, src.default_value, flag->def); - } - if (flag->counter != src.counter || - ChangedDirectly(flag, src.current, flag->cur)) { - restored = true; - Copy(src.op, src.current, flag->cur); - UpdateCopy(flag); - flag->InvokeCallback(); - } - } - - if (restored) { - flag->counter++; - - // Revalidate the flag because the validator might store state based - // on the flag's value, which just changed due to the restore. - // Failing validation is ignored because it's assumed that the flag - // was valid previously and there's little that can be done about it - // here, anyway. - flag->ValidateInputValue(flag->CurrentValue()); - - ABSL_INTERNAL_LOG( - INFO, absl::StrCat("Restore saved value of ", flag->Name(), ": ", - Unparse(src.marshalling_op, src.current))); - } + for (const auto& flag_state : backup_registry_) { + flag_state->Restore(); } } private: - struct SavedFlag { - absl::string_view name; - FlagOpFn op; - FlagMarshallingOpFn marshalling_op; - int64_t counter; - bool modified; - bool on_command_line; - bool (*validator)(); - const void* current; // nullptr after restore - const void* default_value; // nullptr after restore - }; - - std::vector<SavedFlag> backup_registry_; - - FlagSaverImpl(const FlagSaverImpl&); // no copying! - void operator=(const FlagSaverImpl&); + std::vector<std::unique_ptr<flags_internal::FlagStateInterface>> + backup_registry_; }; -FlagSaver::FlagSaver() : impl_(new FlagSaverImpl()) { - impl_->SaveFromRegistry(); -} +FlagSaver::FlagSaver() : impl_(new FlagSaverImpl) { impl_->SaveFromRegistry(); } void FlagSaver::Ignore() { delete impl_; @@ -320,44 +239,6 @@ } // -------------------------------------------------------------------- -// GetAllFlags() -// The main way the FlagRegistry class exposes its data. This -// returns, as strings, all the info about all the flags in -// the main registry, sorted first by filename they are defined -// in, and then by flagname. -// -------------------------------------------------------------------- - -struct FilenameFlagnameLess { - bool operator()(const CommandLineFlagInfo& a, - const CommandLineFlagInfo& b) const { - int cmp = absl::string_view(a.filename).compare(b.filename); - if (cmp != 0) return cmp < 0; - return a.name < b.name; - } -}; - -void FillCommandLineFlagInfo(CommandLineFlag* flag, - CommandLineFlagInfo* result) { - result->name = std::string(flag->Name()); - result->type = std::string(flag->Typename()); - result->description = flag->Help(); - result->filename = flag->Filename(); - - if (!flag->IsAbseilFlag()) { - if (!flag->IsModified() && ChangedDirectly(flag, flag->cur, flag->def)) { - flag->modified = true; - } - } - - result->current_value = flag->CurrentValue(); - result->default_value = flag->DefaultValue(); - result->is_default = !flag->IsModified(); - result->has_validator_fn = flag->HasValidatorFn(); - absl::MutexLock l(flag->InitFlagIfNecessary()); - result->flag_ptr = flag->IsAbseilFlag() ? nullptr : flag->cur; -} - -// -------------------------------------------------------------------- CommandLineFlag* FindCommandLineFlag(absl::string_view name) { if (name.empty()) return nullptr; @@ -392,21 +273,6 @@ // -------------------------------------------------------------------- -void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT) { - flags_internal::ForEachFlag([&](CommandLineFlag* flag) { - if (flag->IsRetired()) return; - - CommandLineFlagInfo fi; - FillCommandLineFlagInfo(flag, &fi); - OUTPUT->push_back(fi); - }); - - // Now sort the flags, first by filename they occur in, then alphabetically - std::sort(OUTPUT->begin(), OUTPUT->end(), FilenameFlagnameLess()); -} - -// -------------------------------------------------------------------- - bool RegisterCommandLineFlag(CommandLineFlag* flag) { FlagRegistry::GlobalRegistry()->RegisterFlag(flag); return true; @@ -414,14 +280,55 @@ // -------------------------------------------------------------------- -bool Retire(FlagOpFn ops, FlagMarshallingOpFn marshalling_ops, - const char* name) { - auto* flag = new CommandLineFlag( - name, - /*help_text=*/absl::flags_internal::HelpText::FromStaticCString(nullptr), - /*filename_arg=*/"RETIRED", ops, marshalling_ops, - /*initial_value_gen=*/nullptr, - /*retired_arg=*/true, nullptr, nullptr); +namespace { + +class RetiredFlagObj final : public flags_internal::CommandLineFlag { + public: + constexpr RetiredFlagObj(const char* name, FlagStaticTypeId type_id) + : name_(name), type_id_(type_id) {} + + private: + absl::string_view Name() const override { return name_; } + std::string Filename() const override { return "RETIRED"; } + absl::string_view Typename() const override { return ""; } + FlagStaticTypeId TypeId() const override { return type_id_; } + std::string Help() const override { return ""; } + bool IsRetired() const override { return true; } + bool IsModified() const override { return false; } + bool IsSpecifiedOnCommandLine() const override { return false; } + std::string DefaultValue() const override { return ""; } + std::string CurrentValue() const override { return ""; } + + // Any input is valid + bool ValidateInputValue(absl::string_view) const override { return true; } + + std::unique_ptr<flags_internal::FlagStateInterface> SaveState() override { + return nullptr; + } + + bool SetFromString(absl::string_view, flags_internal::FlagSettingMode, + flags_internal::ValueSource, std::string*) override { + return false; + } + + void CheckDefaultValueParsingRoundtrip() const override {} + + void Read(void*) const override {} + + // Data members + const char* const name_; + const FlagStaticTypeId type_id_; +}; + +void DestroyRetiredFlag(flags_internal::CommandLineFlag* flag) { + assert(flag->IsRetired()); + delete static_cast<RetiredFlagObj*>(flag); +} + +} // namespace + +bool Retire(const char* name, FlagStaticTypeId type_id) { + auto* flag = new flags_internal::RetiredFlagObj(name, type_id); FlagRegistry::GlobalRegistry()->RegisterFlag(flag); return true; } @@ -440,4 +347,5 @@ } } // namespace flags_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/flags/internal/registry.h b/third_party/abseil-cpp/absl/flags/internal/registry.h index 27566fb..69ff889fb 100644 --- a/third_party/abseil-cpp/absl/flags/internal/registry.h +++ b/third_party/abseil-cpp/absl/flags/internal/registry.h
@@ -20,42 +20,18 @@ #include <map> #include <string> +#include "absl/base/config.h" #include "absl/base/macros.h" #include "absl/flags/internal/commandlineflag.h" +#include "absl/strings/string_view.h" // -------------------------------------------------------------------- // Global flags registry API. namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { -// CommandLineFlagInfo holds all information for a flag. -struct CommandLineFlagInfo { - std::string name; // the name of the flag - std::string type; // DO NOT use. Use flag->IsOfType<T>() instead. - std::string description; // the "help text" associated with the flag - std::string current_value; // the current value, as a std::string - std::string default_value; // the default value, as a std::string - std::string filename; // 'cleaned' version of filename holding the flag - bool has_validator_fn; // true if RegisterFlagValidator called on this flag - - bool is_default; // true if the flag has the default value and - // has not been set explicitly from the cmdline - // or via SetCommandLineOption. - - // nullptr for ABSL_FLAG. A pointer to the flag's current value - // otherwise. E.g., for DEFINE_int32(foo, ...), flag_ptr will be - // &FLAGS_foo. - const void* flag_ptr; -}; - -//----------------------------------------------------------------------------- - -void FillCommandLineFlagInfo(CommandLineFlag* flag, - CommandLineFlagInfo* result); - -//----------------------------------------------------------------------------- - CommandLineFlag* FindCommandLineFlag(absl::string_view name); CommandLineFlag* FindRetiredFlag(absl::string_view name); @@ -68,11 +44,6 @@ //----------------------------------------------------------------------------- -// Store the list of all flags in *OUTPUT, sorted by file. -void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT); - -//----------------------------------------------------------------------------- - bool RegisterCommandLineFlag(CommandLineFlag*); //----------------------------------------------------------------------------- @@ -106,29 +77,14 @@ // 4: Remove the old_lib 'retired' registration. // 5: Eventually delete the graveyard registration entirely. // -// Returns bool to enable use in namespace-scope initializers. -// For example: -// -// static const bool dummy = base::RetiredFlag<int32_t>("myflag"); -// -// Or to declare several at once: -// -// static bool dummies[] = { -// base::RetiredFlag<std::string>("some_string_flag"), -// base::RetiredFlag<double>("some_double_flag"), -// base::RetiredFlag<int32_t>("some_int32_flag") -// }; // Retire flag with name "name" and type indicated by ops. -bool Retire(FlagOpFn ops, FlagMarshallingOpFn marshalling_ops, - const char* name); +bool Retire(const char* name, FlagStaticTypeId type_id); // Registered a retired flag with name 'flag_name' and type 'T'. template <typename T> inline bool RetiredFlag(const char* flag_name) { - return flags_internal::Retire(flags_internal::FlagOps<T>, - flags_internal::FlagMarshallingOps<T>, - flag_name); + return flags_internal::Retire(flag_name, &FlagStaticTypeIdGen<T>); } // If the flag is retired, returns true and indicates in |*type_is_bool| @@ -162,6 +118,7 @@ }; } // namespace flags_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_FLAGS_INTERNAL_REGISTRY_H_
diff --git a/third_party/abseil-cpp/absl/flags/internal/type_erased.cc b/third_party/abseil-cpp/absl/flags/internal/type_erased.cc index 2984291..490bc4e 100644 --- a/third_party/abseil-cpp/absl/flags/internal/type_erased.cc +++ b/third_party/abseil-cpp/absl/flags/internal/type_erased.cc
@@ -15,12 +15,19 @@ #include "absl/flags/internal/type_erased.h" +#include <assert.h> + +#include <string> + +#include "absl/base/config.h" #include "absl/base/internal/raw_logging.h" -#include "absl/flags/config.h" +#include "absl/flags/internal/commandlineflag.h" +#include "absl/flags/internal/registry.h" #include "absl/flags/usage_config.h" -#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { bool GetCommandLineOption(absl::string_view name, std::string* value) { @@ -36,30 +43,6 @@ return true; } -bool GetCommandLineFlagInfo(absl::string_view name, - CommandLineFlagInfo* OUTPUT) { - if (name.empty()) return false; - - CommandLineFlag* flag = flags_internal::FindCommandLineFlag(name); - if (flag == nullptr || flag->IsRetired()) { - return false; - } - - assert(OUTPUT); - FillCommandLineFlagInfo(flag, OUTPUT); - return true; -} - -CommandLineFlagInfo GetCommandLineFlagInfoOrDie(absl::string_view name) { - CommandLineFlagInfo info; - if (!GetCommandLineFlagInfo(name, &info)) { - ABSL_INTERNAL_LOG(FATAL, absl::StrCat("Flag '", name, "' does not exist")); - } - return info; -} - -// -------------------------------------------------------------------- - bool SetCommandLineOption(absl::string_view name, absl::string_view value) { return SetCommandLineOptionWithMode(name, value, flags_internal::SET_FLAGS_VALUE); @@ -103,4 +86,5 @@ } } // namespace flags_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/flags/internal/type_erased.h b/third_party/abseil-cpp/absl/flags/internal/type_erased.h index 249d36b..188429c 100644 --- a/third_party/abseil-cpp/absl/flags/internal/type_erased.h +++ b/third_party/abseil-cpp/absl/flags/internal/type_erased.h
@@ -18,13 +18,16 @@ #include <string> +#include "absl/base/config.h" #include "absl/flags/internal/commandlineflag.h" #include "absl/flags/internal/registry.h" +#include "absl/strings/string_view.h" // -------------------------------------------------------------------- // Registry interfaces operating on type erased handles. namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { // If a flag named "name" exists, store its current value in *OUTPUT @@ -32,17 +35,6 @@ // Thread-safe. bool GetCommandLineOption(absl::string_view name, std::string* value); -// If a flag named "name" exists, store its information in *OUTPUT -// and return true. Else return false without changing *OUTPUT. -// Thread-safe. -bool GetCommandLineFlagInfo(absl::string_view name, - CommandLineFlagInfo* OUTPUT); - -// Returns the CommandLineFlagInfo of the flagname. exit() with an -// error code if name not found. -// Thread-safe. -CommandLineFlagInfo GetCommandLineFlagInfoOrDie(absl::string_view name); - // Set the value of the flag named "name" to value. If successful, // returns true. If not successful (e.g., the flag was not found or // the value is not a valid value), returns false. @@ -92,6 +84,7 @@ } } // namespace flags_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_FLAGS_INTERNAL_TYPE_ERASED_H_
diff --git a/third_party/abseil-cpp/absl/flags/internal/type_erased_test.cc b/third_party/abseil-cpp/absl/flags/internal/type_erased_test.cc index ac749a60..4ce59810 100644 --- a/third_party/abseil-cpp/absl/flags/internal/type_erased_test.cc +++ b/third_party/abseil-cpp/absl/flags/internal/type_erased_test.cc
@@ -15,12 +15,15 @@ #include "absl/flags/internal/type_erased.h" -#include <cmath> +#include <memory> +#include <string> #include "gtest/gtest.h" #include "absl/flags/flag.h" +#include "absl/flags/internal/commandlineflag.h" +#include "absl/flags/internal/registry.h" +#include "absl/flags/marshalling.h" #include "absl/memory/memory.h" -#include "absl/strings/str_cat.h" ABSL_FLAG(int, int_flag, 1, "int_flag help"); ABSL_FLAG(std::string, string_flag, "dflt", "string_flag help"); @@ -116,6 +119,13 @@ EXPECT_TRUE(flags::SetCommandLineOptionWithMode("int_flag", "101", flags::SET_FLAGS_DEFAULT)); + // Set it again to ensure that resetting logic is covered. + EXPECT_TRUE(flags::SetCommandLineOptionWithMode("int_flag", "102", + flags::SET_FLAGS_DEFAULT)); + + EXPECT_TRUE(flags::SetCommandLineOptionWithMode("int_flag", "103", + flags::SET_FLAGS_DEFAULT)); + EXPECT_TRUE(flags::SetCommandLineOptionWithMode("string_flag", "asdfgh", flags::SET_FLAGS_DEFAULT)); EXPECT_EQ(absl::GetFlag(FLAGS_string_flag), "asdfgh");
diff --git a/third_party/abseil-cpp/absl/flags/internal/usage.cc b/third_party/abseil-cpp/absl/flags/internal/usage.cc index 0304851..a9a5cba9 100644 --- a/third_party/abseil-cpp/absl/flags/internal/usage.cc +++ b/third_party/abseil-cpp/absl/flags/internal/usage.cc
@@ -15,18 +15,24 @@ #include "absl/flags/internal/usage.h" +#include <functional> #include <map> +#include <ostream> #include <string> +#include <utility> +#include <vector> +#include "absl/base/config.h" #include "absl/flags/flag.h" +#include "absl/flags/internal/commandlineflag.h" +#include "absl/flags/internal/flag.h" #include "absl/flags/internal/path_util.h" #include "absl/flags/internal/program_name.h" +#include "absl/flags/internal/registry.h" #include "absl/flags/usage_config.h" -#include "absl/strings/ascii.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" -#include "absl/synchronization/mutex.h" ABSL_FLAG(bool, help, false, "show help on important flags for this binary [tip: all flags can " @@ -44,9 +50,31 @@ "show help on modules whose name contains the specified substr"); namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { namespace { +absl::string_view TypenameForHelp(const flags_internal::CommandLineFlag& flag) { + // Only report names of v1 built-in types +#define HANDLE_V1_BUILTIN_TYPE(t) \ + if (flag.IsOfType<t>()) { \ + return #t; \ + } + + HANDLE_V1_BUILTIN_TYPE(bool); + HANDLE_V1_BUILTIN_TYPE(int32_t); + HANDLE_V1_BUILTIN_TYPE(int64_t); + HANDLE_V1_BUILTIN_TYPE(uint64_t); + HANDLE_V1_BUILTIN_TYPE(double); +#undef HANDLE_V1_BUILTIN_TYPE + + if (flag.IsOfType<std::string>()) { + return "string"; + } + + return ""; +} + // This class is used to emit an XML element with `tag` and `text`. // It adds opening and closing tags and escapes special characters in the text. // For example: @@ -106,14 +134,14 @@ first_line_(true) {} void Write(absl::string_view str, bool wrap_line = false) { - // Empty std::string - do nothing. + // Empty string - do nothing. if (str.empty()) return; std::vector<absl::string_view> tokens; if (wrap_line) { for (auto line : absl::StrSplit(str, absl::ByAnyChar("\n\r"))) { if (!tokens.empty()) { - // Keep line separators in the input std::string. + // Keep line separators in the input string. tokens.push_back("\n"); } for (auto token : @@ -128,13 +156,13 @@ for (auto token : tokens) { bool new_line = (line_len_ == 0); - // Respect line separators in the input std::string. + // Respect line separators in the input string. if (token == "\n") { EndLine(); continue; } - // Write the token, ending the std::string first if necessary/possible. + // Write the token, ending the string first if necessary/possible. if (!new_line && (line_len_ + token.size() >= max_line_len_)) { EndLine(); new_line = true; @@ -179,14 +207,14 @@ FlagHelpPrettyPrinter printer(80, out); // Max line length is 80. // Flag name. - printer.Write(absl::StrCat("-", flag.Name())); + printer.Write(absl::StrCat("--", flag.Name())); // Flag help. printer.Write(absl::StrCat("(", flag.Help(), ");"), /*wrap_line=*/true); // Flag data type (for V1 flags only). if (!flag.IsAbseilFlag() && !flag.IsRetired()) { - printer.Write(absl::StrCat("type: ", flag.Typename(), ";")); + printer.Write(absl::StrCat("type: ", TypenameForHelp(flag), ";")); } // The listed default value will be the actual default from the flag @@ -223,6 +251,9 @@ } else { // XML schema is not a part of our public API for now. out << "<?xml version=\"1.0\"?>\n" + << "<!-- This output should be used with care. We do not report type " + "names for flags with user defined types -->\n" + << "<!-- Prefer flag only_check_args for validating flag inputs -->\n" // The document. << "<AllFlags>\n" // The program name and usage. @@ -380,4 +411,5 @@ } } // namespace flags_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/flags/internal/usage.h b/third_party/abseil-cpp/absl/flags/internal/usage.h index 76075b0..6b080fd 100644 --- a/third_party/abseil-cpp/absl/flags/internal/usage.h +++ b/third_party/abseil-cpp/absl/flags/internal/usage.h
@@ -19,6 +19,7 @@ #include <iosfwd> #include <string> +#include "absl/base/config.h" #include "absl/flags/declare.h" #include "absl/flags/internal/commandlineflag.h" #include "absl/strings/string_view.h" @@ -27,6 +28,7 @@ // Usage reporting interfaces namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { // The format to report the help messages in. @@ -64,6 +66,7 @@ absl::string_view program_usage_message); } // namespace flags_internal +ABSL_NAMESPACE_END } // namespace absl ABSL_DECLARE_FLAG(bool, help);
diff --git a/third_party/abseil-cpp/absl/flags/internal/usage_test.cc b/third_party/abseil-cpp/absl/flags/internal/usage_test.cc index 781e1d2..e1e57e5 100644 --- a/third_party/abseil-cpp/absl/flags/internal/usage_test.cc +++ b/third_party/abseil-cpp/absl/flags/internal/usage_test.cc
@@ -15,17 +15,23 @@ #include "absl/flags/internal/usage.h" +#include <stdint.h> + #include <sstream> +#include <string> #include "gtest/gtest.h" +#include "absl/flags/declare.h" #include "absl/flags/flag.h" +#include "absl/flags/internal/parse.h" #include "absl/flags/internal/path_util.h" #include "absl/flags/internal/program_name.h" -#include "absl/flags/parse.h" +#include "absl/flags/internal/registry.h" #include "absl/flags/usage.h" #include "absl/flags/usage_config.h" #include "absl/memory/memory.h" #include "absl/strings/match.h" +#include "absl/strings/string_view.h" ABSL_FLAG(int, usage_reporting_test_flag_01, 101, "usage_reporting_test_flag_01 help message"); @@ -67,9 +73,9 @@ fname = normalized; #endif - auto absl_pos = fname.find("/absl/"); + auto absl_pos = fname.rfind("absl/"); if (absl_pos != absl::string_view::npos) { - fname = fname.substr(absl_pos + 1); + fname = fname.substr(absl_pos); } return std::string(fname); } @@ -111,7 +117,7 @@ flags::FlagHelp(test_buf, *flag, flags::HelpFormat::kHumanReadable); EXPECT_EQ( test_buf.str(), - R"( -usage_reporting_test_flag_01 (usage_reporting_test_flag_01 help message); + R"( --usage_reporting_test_flag_01 (usage_reporting_test_flag_01 help message); default: 101; )"); } @@ -123,7 +129,7 @@ flags::FlagHelp(test_buf, *flag, flags::HelpFormat::kHumanReadable); EXPECT_EQ( test_buf.str(), - R"( -usage_reporting_test_flag_02 (usage_reporting_test_flag_02 help message); + R"( --usage_reporting_test_flag_02 (usage_reporting_test_flag_02 help message); default: false; )"); } @@ -135,7 +141,7 @@ flags::FlagHelp(test_buf, *flag, flags::HelpFormat::kHumanReadable); EXPECT_EQ( test_buf.str(), - R"( -usage_reporting_test_flag_03 (usage_reporting_test_flag_03 help message); + R"( --usage_reporting_test_flag_03 (usage_reporting_test_flag_03 help message); default: 1.03; )"); } @@ -147,7 +153,7 @@ flags::FlagHelp(test_buf, *flag, flags::HelpFormat::kHumanReadable); EXPECT_EQ( test_buf.str(), - R"( -usage_reporting_test_flag_04 (usage_reporting_test_flag_04 help message); + R"( --usage_reporting_test_flag_04 (usage_reporting_test_flag_04 help message); default: 1000000000000004; )"); } @@ -159,7 +165,7 @@ flags::FlagHelp(test_buf, *flag, flags::HelpFormat::kHumanReadable); EXPECT_EQ( test_buf.str(), - R"( -usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message); + R"( --usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message); default: UDT{}; )"); } @@ -171,17 +177,17 @@ R"(usage_test: Custom usage message Flags from absl/flags/internal/usage_test.cc: - -usage_reporting_test_flag_01 (usage_reporting_test_flag_01 help message); + --usage_reporting_test_flag_01 (usage_reporting_test_flag_01 help message); default: 101; - -usage_reporting_test_flag_02 (usage_reporting_test_flag_02 help message); + --usage_reporting_test_flag_02 (usage_reporting_test_flag_02 help message); default: false; - -usage_reporting_test_flag_03 (usage_reporting_test_flag_03 help message); + --usage_reporting_test_flag_03 (usage_reporting_test_flag_03 help message); default: 1.03; - -usage_reporting_test_flag_04 (usage_reporting_test_flag_04 help message); + --usage_reporting_test_flag_04 (usage_reporting_test_flag_04 help message); default: 1000000000000004; - -usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message); + --usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message); default: UDT{}; - -usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message. + --usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message. Some more help. Even more long long long long long long long long long long long long help @@ -247,17 +253,17 @@ R"(usage_test: Custom usage message Flags from absl/flags/internal/usage_test.cc: - -usage_reporting_test_flag_01 (usage_reporting_test_flag_01 help message); + --usage_reporting_test_flag_01 (usage_reporting_test_flag_01 help message); default: 101; - -usage_reporting_test_flag_02 (usage_reporting_test_flag_02 help message); + --usage_reporting_test_flag_02 (usage_reporting_test_flag_02 help message); default: false; - -usage_reporting_test_flag_03 (usage_reporting_test_flag_03 help message); + --usage_reporting_test_flag_03 (usage_reporting_test_flag_03 help message); default: 1.03; - -usage_reporting_test_flag_04 (usage_reporting_test_flag_04 help message); + --usage_reporting_test_flag_04 (usage_reporting_test_flag_04 help message); default: 1000000000000004; - -usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message); + --usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message); default: UDT{}; - -usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message. + --usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message. Some more help. Even more long long long long long long long long long long long long help @@ -276,17 +282,17 @@ R"(usage_test: Custom usage message Flags from absl/flags/internal/usage_test.cc: - -usage_reporting_test_flag_01 (usage_reporting_test_flag_01 help message); + --usage_reporting_test_flag_01 (usage_reporting_test_flag_01 help message); default: 101; - -usage_reporting_test_flag_02 (usage_reporting_test_flag_02 help message); + --usage_reporting_test_flag_02 (usage_reporting_test_flag_02 help message); default: false; - -usage_reporting_test_flag_03 (usage_reporting_test_flag_03 help message); + --usage_reporting_test_flag_03 (usage_reporting_test_flag_03 help message); default: 1.03; - -usage_reporting_test_flag_04 (usage_reporting_test_flag_04 help message); + --usage_reporting_test_flag_04 (usage_reporting_test_flag_04 help message); default: 1000000000000004; - -usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message); + --usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message); default: UDT{}; - -usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message. + --usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message. Some more help. Even more long long long long long long long long long long long long help @@ -307,17 +313,17 @@ R"(usage_test: Custom usage message Flags from absl/flags/internal/usage_test.cc: - -usage_reporting_test_flag_01 (usage_reporting_test_flag_01 help message); + --usage_reporting_test_flag_01 (usage_reporting_test_flag_01 help message); default: 101; - -usage_reporting_test_flag_02 (usage_reporting_test_flag_02 help message); + --usage_reporting_test_flag_02 (usage_reporting_test_flag_02 help message); default: false; - -usage_reporting_test_flag_03 (usage_reporting_test_flag_03 help message); + --usage_reporting_test_flag_03 (usage_reporting_test_flag_03 help message); default: 1.03; - -usage_reporting_test_flag_04 (usage_reporting_test_flag_04 help message); + --usage_reporting_test_flag_04 (usage_reporting_test_flag_04 help message); default: 1000000000000004; - -usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message); + --usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message); default: UDT{}; - -usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message. + --usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message. Some more help. Even more long long long long long long long long long long long long help @@ -372,17 +378,17 @@ R"(usage_test: Custom usage message Flags from absl/flags/internal/usage_test.cc: - -usage_reporting_test_flag_01 (usage_reporting_test_flag_01 help message); + --usage_reporting_test_flag_01 (usage_reporting_test_flag_01 help message); default: 101; - -usage_reporting_test_flag_02 (usage_reporting_test_flag_02 help message); + --usage_reporting_test_flag_02 (usage_reporting_test_flag_02 help message); default: false; - -usage_reporting_test_flag_03 (usage_reporting_test_flag_03 help message); + --usage_reporting_test_flag_03 (usage_reporting_test_flag_03 help message); default: 1.03; - -usage_reporting_test_flag_04 (usage_reporting_test_flag_04 help message); + --usage_reporting_test_flag_04 (usage_reporting_test_flag_04 help message); default: 1000000000000004; - -usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message); + --usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message); default: UDT{}; - -usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message. + --usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message. Some more help. Even more long long long long long long long long long long long long help @@ -395,7 +401,7 @@ } // namespace int main(int argc, char* argv[]) { - absl::GetFlag(FLAGS_undefok); // Force linking of parse.cc + (void)absl::GetFlag(FLAGS_undefok); // Force linking of parse.cc flags::SetProgramInvocationName("usage_test"); absl::SetProgramUsageMessage(kTestUsageMessage); ::testing::InitGoogleTest(&argc, argv);
diff --git a/third_party/abseil-cpp/absl/flags/marshalling.cc b/third_party/abseil-cpp/absl/flags/marshalling.cc index f025ae7..09baae8 100644 --- a/third_party/abseil-cpp/absl/flags/marshalling.cc +++ b/third_party/abseil-cpp/absl/flags/marshalling.cc
@@ -15,17 +15,28 @@ #include "absl/flags/marshalling.h" -#include <limits> +#include <stddef.h> +#include <cmath> +#include <limits> +#include <string> +#include <type_traits> +#include <vector> + +#include "absl/base/config.h" +#include "absl/base/log_severity.h" #include "absl/base/macros.h" +#include "absl/strings/ascii.h" #include "absl/strings/match.h" #include "absl/strings/numbers.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" #include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { // -------------------------------------------------------------------- @@ -161,7 +172,7 @@ std::string Unparse(unsigned long long v) { return absl::StrCat(v); } template <typename T> std::string UnparseFloatingPointVal(T v) { - // digits10 is guaranteed to roundtrip correctly in std::string -> value -> std::string + // digits10 is guaranteed to roundtrip correctly in string -> value -> string // conversions, but may not be enough to represent all the values correctly. std::string digit10_str = absl::StrFormat("%.*g", std::numeric_limits<T>::digits10, v); @@ -186,4 +197,44 @@ } } // namespace flags_internal + +bool AbslParseFlag(absl::string_view text, absl::LogSeverity* dst, + std::string* err) { + text = absl::StripAsciiWhitespace(text); + if (text.empty()) { + *err = "no value provided"; + return false; + } + if (text.front() == 'k' || text.front() == 'K') text.remove_prefix(1); + if (absl::EqualsIgnoreCase(text, "info")) { + *dst = absl::LogSeverity::kInfo; + return true; + } + if (absl::EqualsIgnoreCase(text, "warning")) { + *dst = absl::LogSeverity::kWarning; + return true; + } + if (absl::EqualsIgnoreCase(text, "error")) { + *dst = absl::LogSeverity::kError; + return true; + } + if (absl::EqualsIgnoreCase(text, "fatal")) { + *dst = absl::LogSeverity::kFatal; + return true; + } + std::underlying_type<absl::LogSeverity>::type numeric_value; + if (absl::ParseFlag(text, &numeric_value, err)) { + *dst = static_cast<absl::LogSeverity>(numeric_value); + return true; + } + *err = "only integers and absl::LogSeverity enumerators are accepted"; + return false; +} + +std::string AbslUnparseFlag(absl::LogSeverity v) { + if (v == absl::NormalizeLogSeverity(v)) return absl::LogSeverityName(v); + return absl::UnparseFlag(static_cast<int>(v)); +} + +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/flags/marshalling.h b/third_party/abseil-cpp/absl/flags/marshalling.h index f9e2959..0b50335 100644 --- a/third_party/abseil-cpp/absl/flags/marshalling.h +++ b/third_party/abseil-cpp/absl/flags/marshalling.h
@@ -33,15 +33,16 @@ // * `double` // * `std::string` // * `std::vector<std::string>` +// * `absl::LogSeverity` (provided natively for layering reasons) // // Note that support for integral types is implemented using overloads for // variable-width fundamental types (`short`, `int`, `long`, etc.). However, // you should prefer the fixed-width integral types (`int32_t`, `uint64_t`, // etc.) we've noted above within flag definitions. - // // In addition, several Abseil libraries provide their own custom support for -// Abseil flags. +// Abseil flags. Documentation for these formats is provided in the type's +// `AbslParseFlag()` definition. // // The Abseil time library provides the following support for civil time values: // @@ -164,9 +165,11 @@ #include <string> #include <vector> +#include "absl/base/config.h" #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { // Overloads of `AbslParseFlag()` and `AbslUnparseFlag()` for fundamental types. @@ -178,8 +181,8 @@ bool AbslParseFlag(absl::string_view, long*, std::string*); // NOLINT bool AbslParseFlag(absl::string_view, unsigned long*, std::string*); // NOLINT bool AbslParseFlag(absl::string_view, long long*, std::string*); // NOLINT -bool AbslParseFlag(absl::string_view, unsigned long long*, - std::string*); // NOLINT +bool AbslParseFlag(absl::string_view, unsigned long long*, // NOLINT + std::string*); bool AbslParseFlag(absl::string_view, float*, std::string*); bool AbslParseFlag(absl::string_view, double*, std::string*); bool AbslParseFlag(absl::string_view, std::string*, std::string*); @@ -248,6 +251,14 @@ return flags_internal::Unparse(v); } +// Overloads for `absl::LogSeverity` can't (easily) appear alongside that type's +// definition because it is layered below flags. See proper documentation in +// base/log_severity.h. +enum class LogSeverity : int; +bool AbslParseFlag(absl::string_view, absl::LogSeverity*, std::string*); +std::string AbslUnparseFlag(absl::LogSeverity); + +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_FLAGS_MARSHALLING_H_
diff --git a/third_party/abseil-cpp/absl/flags/marshalling_test.cc b/third_party/abseil-cpp/absl/flags/marshalling_test.cc index 37cd1940..4a64ce1 100644 --- a/third_party/abseil-cpp/absl/flags/marshalling_test.cc +++ b/third_party/abseil-cpp/absl/flags/marshalling_test.cc
@@ -15,7 +15,12 @@ #include "absl/flags/marshalling.h" +#include <stdint.h> + #include <cmath> +#include <limits> +#include <string> +#include <vector> #include "gtest/gtest.h"
diff --git a/third_party/abseil-cpp/absl/flags/parse.cc b/third_party/abseil-cpp/absl/flags/parse.cc index 16c4d68..af5fb12 100644 --- a/third_party/abseil-cpp/absl/flags/parse.cc +++ b/third_party/abseil-cpp/absl/flags/parse.cc
@@ -17,27 +17,43 @@ #include <stdlib.h> +#include <algorithm> #include <fstream> #include <iostream> +#include <iterator> +#include <string> #include <tuple> +#include <utility> +#include <vector> #ifdef _WIN32 #include <windows.h> #endif +#include "absl/base/attributes.h" +#include "absl/base/config.h" +#include "absl/base/const_init.h" +#include "absl/base/thread_annotations.h" +#include "absl/flags/config.h" #include "absl/flags/flag.h" +#include "absl/flags/internal/commandlineflag.h" +#include "absl/flags/internal/flag.h" +#include "absl/flags/internal/parse.h" #include "absl/flags/internal/program_name.h" #include "absl/flags/internal/registry.h" #include "absl/flags/internal/usage.h" #include "absl/flags/usage.h" #include "absl/flags/usage_config.h" +#include "absl/strings/ascii.h" #include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" #include "absl/strings/strip.h" #include "absl/synchronization/mutex.h" // -------------------------------------------------------------------- namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { namespace { @@ -52,6 +68,7 @@ } // namespace } // namespace flags_internal +ABSL_NAMESPACE_END } // namespace absl ABSL_FLAG(std::vector<std::string>, flagfile, {}, @@ -109,6 +126,7 @@ "with that name"); namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { namespace { @@ -277,9 +295,7 @@ #define IGNORE_TYPE(T) \ if (flag->IsOfType<T>()) return; - ABSL_FLAGS_INTERNAL_FOR_EACH_LOCK_FREE(IGNORE_TYPE) - IGNORE_TYPE(std::string) - IGNORE_TYPE(std::vector<std::string>) + ABSL_FLAGS_INTERNAL_BUILTIN_TYPES(IGNORE_TYPE) #undef IGNORE_TYPE flag->CheckDefaultValueParsingRoundtrip(); @@ -517,12 +533,12 @@ curr_list->PopFront(); value = curr_list->Front(); - // Heuristic to detect the case where someone treats a std::string arg + // Heuristic to detect the case where someone treats a string arg // like a bool or just forgets to pass a value: // --my_string_var --foo=bar - // We look for a flag of std::string type, whose value begins with a + // We look for a flag of string type, whose value begins with a // dash and corresponds to known flag or standalone --. - if (value[0] == '-' && flag.IsOfType<std::string>()) { + if (!value.empty() && value[0] == '-' && flag.IsOfType<std::string>()) { auto maybe_flag_name = std::get<0>(SplitNameAndValue(value.substr(1))); if (maybe_flag_name.empty() || @@ -630,7 +646,7 @@ // 60. Split the current argument on '=' to figure out the argument // name and value. If flag name is empty it means we've got "--". value - // can be empty either if there were no '=' in argument std::string at all or + // can be empty either if there were no '=' in argument string at all or // an argument looked like "--foo=". In a latter case is_empty_value is // true. absl::string_view flag_name; @@ -748,4 +764,5 @@ flags_internal::OnUndefinedFlag::kAbortIfUndefined); } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/flags/parse.h b/third_party/abseil-cpp/absl/flags/parse.h index dbb7510..f37b060 100644 --- a/third_party/abseil-cpp/absl/flags/parse.h +++ b/third_party/abseil-cpp/absl/flags/parse.h
@@ -26,9 +26,11 @@ #include <string> #include <vector> +#include "absl/base/config.h" #include "absl/flags/internal/parse.h" namespace absl { +ABSL_NAMESPACE_BEGIN // ParseCommandLine() // @@ -53,6 +55,7 @@ // help messages and then exits the program. std::vector<char*> ParseCommandLine(int argc, char* argv[]); +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_FLAGS_PARSE_H_
diff --git a/third_party/abseil-cpp/absl/flags/parse_test.cc b/third_party/abseil-cpp/absl/flags/parse_test.cc index 447a3bc..6f49377 100644 --- a/third_party/abseil-cpp/absl/flags/parse_test.cc +++ b/third_party/abseil-cpp/absl/flags/parse_test.cc
@@ -15,14 +15,22 @@ #include "absl/flags/parse.h" +#include <stdlib.h> + #include <fstream> +#include <string> +#include <vector> #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/base/internal/raw_logging.h" #include "absl/base/internal/scoped_set_env.h" +#include "absl/flags/declare.h" #include "absl/flags/flag.h" +#include "absl/flags/internal/parse.h" +#include "absl/flags/internal/registry.h" #include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" #include "absl/strings/substitute.h" #include "absl/types/span.h" @@ -92,8 +100,11 @@ auto len = GetTempPathA(MAX_PATH, temp_path_buffer); if (len < MAX_PATH && len != 0) { - std::string temp_dir_name = absl::StrCat( - temp_path_buffer, "\\parse_test.", GetCurrentProcessId()); + std::string temp_dir_name = temp_path_buffer; + if (!absl::EndsWith(temp_dir_name, "\\")) { + temp_dir_name.push_back('\\'); + } + absl::StrAppend(&temp_dir_name, "parse_test.", GetCurrentProcessId()); if (CreateDirectoryA(temp_dir_name.c_str(), nullptr)) { *res = temp_dir_name; } @@ -104,11 +115,11 @@ *res = unique_name; } #endif + } - if (res->empty()) { - ABSL_INTERNAL_LOG(FATAL, - "Failed to make temporary directory for data files"); - } + if (res->empty()) { + ABSL_INTERNAL_LOG(FATAL, + "Failed to make temporary directory for data files"); } #ifdef _WIN32
diff --git a/third_party/abseil-cpp/absl/flags/usage.cc b/third_party/abseil-cpp/absl/flags/usage.cc index dff7a3da..452f667 100644 --- a/third_party/abseil-cpp/absl/flags/usage.cc +++ b/third_party/abseil-cpp/absl/flags/usage.cc
@@ -14,12 +14,20 @@ // limitations under the License. #include "absl/flags/usage.h" +#include <stdlib.h> + #include <string> +#include "absl/base/attributes.h" +#include "absl/base/config.h" +#include "absl/base/const_init.h" +#include "absl/base/thread_annotations.h" #include "absl/flags/internal/usage.h" +#include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { namespace { ABSL_CONST_INIT absl::Mutex usage_message_guard(absl::kConstInit); @@ -53,4 +61,5 @@ : "Warning: SetProgramUsageMessage() never called"; } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/flags/usage.h b/third_party/abseil-cpp/absl/flags/usage.h index 3a121071..ad12ab7a 100644 --- a/third_party/abseil-cpp/absl/flags/usage.h +++ b/third_party/abseil-cpp/absl/flags/usage.h
@@ -16,12 +16,14 @@ #ifndef ABSL_FLAGS_USAGE_H_ #define ABSL_FLAGS_USAGE_H_ +#include "absl/base/config.h" #include "absl/strings/string_view.h" // -------------------------------------------------------------------- // Usage reporting interfaces namespace absl { +ABSL_NAMESPACE_BEGIN // Sets the "usage" message to be used by help reporting routines. // For example: @@ -35,6 +37,7 @@ // Returns the usage message set by SetProgramUsageMessage(). absl::string_view ProgramUsageMessage(); +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_FLAGS_USAGE_H_
diff --git a/third_party/abseil-cpp/absl/flags/usage_config.cc b/third_party/abseil-cpp/absl/flags/usage_config.cc index f97bf300..0d21bce 100644 --- a/third_party/abseil-cpp/absl/flags/usage_config.cc +++ b/third_party/abseil-cpp/absl/flags/usage_config.cc
@@ -16,12 +16,16 @@ #include "absl/flags/usage_config.h" #include <iostream> -#include <memory> +#include <string> #include "absl/base/attributes.h" +#include "absl/base/config.h" +#include "absl/base/const_init.h" +#include "absl/base/thread_annotations.h" #include "absl/flags/internal/path_util.h" #include "absl/flags/internal/program_name.h" -#include "absl/strings/str_cat.h" +#include "absl/strings/match.h" +#include "absl/strings/string_view.h" #include "absl/strings/strip.h" #include "absl/synchronization/mutex.h" @@ -34,6 +38,7 @@ } // extern "C" namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { namespace { @@ -45,10 +50,15 @@ bool ContainsHelpshortFlags(absl::string_view filename) { // By default we only want flags in binary's main. We expect the main // routine to reside in <program>.cc or <program>-main.cc or - // <program>_main.cc, where the <program> is the name of the binary. + // <program>_main.cc, where the <program> is the name of the binary + // (without .exe on Windows). auto suffix = flags_internal::Basename(filename); - if (!absl::ConsumePrefix(&suffix, - flags_internal::ShortProgramInvocationName())) + auto program_name = flags_internal::ShortProgramInvocationName(); + absl::string_view program_name_ref = program_name; +#if defined(_WIN32) + absl::ConsumeSuffix(&program_name_ref, ".exe"); +#endif + if (!absl::ConsumePrefix(&suffix, program_name_ref)) return false; return absl::StartsWith(suffix, ".") || absl::StartsWith(suffix, "-main.") || absl::StartsWith(suffix, "_main."); @@ -149,4 +159,5 @@ flags_internal::custom_usage_config = new FlagsUsageConfig(usage_config); } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/flags/usage_config.h b/third_party/abseil-cpp/absl/flags/usage_config.h index ee5016a..96eecea 100644 --- a/third_party/abseil-cpp/absl/flags/usage_config.h +++ b/third_party/abseil-cpp/absl/flags/usage_config.h
@@ -27,6 +27,7 @@ #include <functional> #include <string> +#include "absl/base/config.h" #include "absl/strings/string_view.h" // ----------------------------------------------------------------------------- @@ -54,6 +55,7 @@ // Shows help on modules whose name contains the specified substring namespace absl { +ABSL_NAMESPACE_BEGIN namespace flags_internal { using FlagKindFilter = std::function<bool (absl::string_view)>; @@ -88,7 +90,7 @@ // program output. flags_internal::FlagKindFilter contains_helppackage_flags; - // Generates std::string containing program version. This is the std::string reported + // Generates string containing program version. This is the string reported // when user specifies --version in a command line. std::function<std::string()> version_string; @@ -101,7 +103,7 @@ // normalize_filename("/my_company/some_long_path/src/project/file.cc") // might produce // "project/file.cc". - std::function<std::string (absl::string_view)> normalize_filename; + std::function<std::string(absl::string_view)> normalize_filename; }; // SetFlagsUsageConfig() @@ -118,6 +120,7 @@ void ReportUsageError(absl::string_view msg, bool is_fatal); } // namespace flags_internal +ABSL_NAMESPACE_END } // namespace absl extern "C" {
diff --git a/third_party/abseil-cpp/absl/flags/usage_config_test.cc b/third_party/abseil-cpp/absl/flags/usage_config_test.cc index 3bde13a..e57a8832 100644 --- a/third_party/abseil-cpp/absl/flags/usage_config_test.cc +++ b/third_party/abseil-cpp/absl/flags/usage_config_test.cc
@@ -15,10 +15,13 @@ #include "absl/flags/usage_config.h" +#include <string> + #include "gtest/gtest.h" #include "absl/flags/internal/path_util.h" #include "absl/flags/internal/program_name.h" #include "absl/strings/match.h" +#include "absl/strings/string_view.h" namespace { @@ -81,7 +84,11 @@ // -------------------------------------------------------------------- TEST_F(FlagsUsageConfigTest, TestContainsHelpshortFlags) { +#if defined(_WIN32) + flags::SetProgramInvocationName("usage_config_test.exe"); +#else flags::SetProgramInvocationName("usage_config_test"); +#endif auto config = flags::GetUsageConfig(); EXPECT_TRUE(config.contains_helpshort_flags("adir/cd/usage_config_test.cc"));
diff --git a/third_party/abseil-cpp/absl/functional/BUILD.bazel b/third_party/abseil-cpp/absl/functional/BUILD.bazel new file mode 100644 index 0000000..432546c --- /dev/null +++ b/third_party/abseil-cpp/absl/functional/BUILD.bazel
@@ -0,0 +1,93 @@ +# +# Copyright 2019 The Abseil Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") +load( + "//absl:copts/configure_copts.bzl", + "ABSL_DEFAULT_COPTS", + "ABSL_DEFAULT_LINKOPTS", + "ABSL_TEST_COPTS", +) + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # Apache 2.0 + +cc_library( + name = "bind_front", + srcs = ["internal/front_binder.h"], + hdrs = ["bind_front.h"], + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + "//absl/base:base_internal", + "//absl/container:compressed_tuple", + "//absl/meta:type_traits", + "//absl/utility", + ], +) + +cc_test( + name = "bind_front_test", + srcs = ["bind_front_test.cc"], + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + ":bind_front", + "//absl/memory", + "@com_google_googletest//:gtest_main", + ], +) + +cc_library( + name = "function_ref", + srcs = ["internal/function_ref.h"], + hdrs = ["function_ref.h"], + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + "//absl/base:base_internal", + "//absl/meta:type_traits", + ], +) + +cc_test( + name = "function_ref_test", + size = "small", + srcs = ["function_ref_test.cc"], + copts = ABSL_TEST_COPTS, + deps = [ + ":function_ref", + "//absl/container:test_instance_tracker", + "//absl/memory", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "function_ref_benchmark", + srcs = [ + "function_ref_benchmark.cc", + ], + copts = ABSL_TEST_COPTS, + tags = ["benchmark"], + visibility = ["//visibility:private"], + deps = [ + ":function_ref", + "//absl/base:core_headers", + "@com_github_google_benchmark//:benchmark_main", + ], +)
diff --git a/third_party/abseil-cpp/absl/functional/BUILD.gn b/third_party/abseil-cpp/absl/functional/BUILD.gn new file mode 100644 index 0000000..011606ab --- /dev/null +++ b/third_party/abseil-cpp/absl/functional/BUILD.gn
@@ -0,0 +1,50 @@ +# Copyright 2020 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. + +import("//build_overrides/build.gni") +import("//third_party/abseil-cpp/abseil_clients.gni") + +# Usage of Abseil in Chromium is guarded by an explicit opt-in list, before +# adding projects to this list please reach out to cxx@chromium.org and CC: +# - https://cs.chromium.org/chromium/src/third_party/abseil-cpp/OWNERS +# +# More information can be found at: +# https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU +if (build_with_chromium) { + visibility = absl_visibility +} else { + visibility = [ "*" ] +} + +source_set("bind_front") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] + sources = [ "internal/front_binder.h" ] + public = [ "bind_front.h" ] + deps = [ + "../base:base_internal", + "../container:compressed_tuple", + "../meta:type_traits", + "../utility", + ] +} + +source_set("function_ref") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] + sources = [ "internal/function_ref.h" ] + public = [ "function_ref.h" ] + deps = [ + "../base:base_internal", + "../meta:type_traits", + ] +}
diff --git a/third_party/abseil-cpp/absl/functional/CMakeLists.txt b/third_party/abseil-cpp/absl/functional/CMakeLists.txt new file mode 100644 index 0000000..cda914f --- /dev/null +++ b/third_party/abseil-cpp/absl/functional/CMakeLists.txt
@@ -0,0 +1,72 @@ +# +# Copyright 2019 The Abseil Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +absl_cc_library( + NAME + bind_front + SRCS + "internal/front_binder.h" + HDRS + "bind_front.h" + COPTS + ${ABSL_DEFAULT_COPTS} + DEPS + absl::base_internal + absl::compressed_tuple + PUBLIC +) + +absl_cc_test( + NAME + bind_front_test + SRCS + "bind_front_test.cc" + COPTS + ${ABSL_DEFAULT_COPTS} + DEPS + absl::bind_front + absl::memory + gmock_main +) + +absl_cc_library( + NAME + function_ref + SRCS + "internal/function_ref.h" + HDRS + "function_ref.h" + COPTS + ${ABSL_DEFAULT_COPTS} + DEPS + absl::base_internal + absl::meta + PUBLIC +) + +absl_cc_test( + NAME + function_ref_test + SRCS + "function_ref_test.cc" + COPTS + ${ABSL_TEST_COPTS} + DEPS + absl::function_ref + absl::memory + absl::test_instance_tracker + gmock_main +)
diff --git a/third_party/abseil-cpp/absl/functional/bind_front.h b/third_party/abseil-cpp/absl/functional/bind_front.h new file mode 100644 index 0000000..5b47970 --- /dev/null +++ b/third_party/abseil-cpp/absl/functional/bind_front.h
@@ -0,0 +1,184 @@ +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------- +// File: bind_front.h +// ----------------------------------------------------------------------------- +// +// `absl::bind_front()` returns a functor by binding a number of arguments to +// the front of a provided (usually more generic) functor. Unlike `std::bind`, +// it does not require the use of argument placeholders. The simpler syntax of +// `absl::bind_front()` allows you to avoid known misuses with `std::bind()`. +// +// `absl::bind_front()` is meant as a drop-in replacement for C++20's upcoming +// `std::bind_front()`, which similarly resolves these issues with +// `std::bind()`. Both `bind_front()` alternatives, unlike `std::bind()`, allow +// partial function application. (See +// https://en.wikipedia.org/wiki/Partial_application). + +#ifndef ABSL_FUNCTIONAL_BIND_FRONT_H_ +#define ABSL_FUNCTIONAL_BIND_FRONT_H_ + +#include "absl/functional/internal/front_binder.h" +#include "absl/utility/utility.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN + +// bind_front() +// +// Binds the first N arguments of an invocable object and stores them by value. +// +// Like `std::bind()`, `absl::bind_front()` is implicitly convertible to +// `std::function`. In particular, it may be used as a simpler replacement for +// `std::bind()` in most cases, as it does not require placeholders to be +// specified. More importantly, it provides more reliable correctness guarantees +// than `std::bind()`; while `std::bind()` will silently ignore passing more +// parameters than expected, for example, `absl::bind_front()` will report such +// mis-uses as errors. +// +// absl::bind_front(a...) can be seen as storing the results of +// std::make_tuple(a...). +// +// Example: Binding a free function. +// +// int Minus(int a, int b) { return a - b; } +// +// assert(absl::bind_front(Minus)(3, 2) == 3 - 2); +// assert(absl::bind_front(Minus, 3)(2) == 3 - 2); +// assert(absl::bind_front(Minus, 3, 2)() == 3 - 2); +// +// Example: Binding a member function. +// +// struct Math { +// int Double(int a) const { return 2 * a; } +// }; +// +// Math math; +// +// assert(absl::bind_front(&Math::Double)(&math, 3) == 2 * 3); +// // Stores a pointer to math inside the functor. +// assert(absl::bind_front(&Math::Double, &math)(3) == 2 * 3); +// // Stores a copy of math inside the functor. +// assert(absl::bind_front(&Math::Double, math)(3) == 2 * 3); +// // Stores std::unique_ptr<Math> inside the functor. +// assert(absl::bind_front(&Math::Double, +// std::unique_ptr<Math>(new Math))(3) == 2 * 3); +// +// Example: Using `absl::bind_front()`, instead of `std::bind()`, with +// `std::function`. +// +// class FileReader { +// public: +// void ReadFileAsync(const std::string& filename, std::string* content, +// const std::function<void()>& done) { +// // Calls Executor::Schedule(std::function<void()>). +// Executor::DefaultExecutor()->Schedule( +// absl::bind_front(&FileReader::BlockingRead, this, +// filename, content, done)); +// } +// +// private: +// void BlockingRead(const std::string& filename, std::string* content, +// const std::function<void()>& done) { +// CHECK_OK(file::GetContents(filename, content, {})); +// done(); +// } +// }; +// +// `absl::bind_front()` stores bound arguments explicitly using the type passed +// rather than implicitly based on the type accepted by its functor. +// +// Example: Binding arguments explicitly. +// +// void LogStringView(absl::string_view sv) { +// LOG(INFO) << sv; +// } +// +// Executor* e = Executor::DefaultExecutor(); +// std::string s = "hello"; +// absl::string_view sv = s; +// +// // absl::bind_front(LogStringView, arg) makes a copy of arg and stores it. +// e->Schedule(absl::bind_front(LogStringView, sv)); // ERROR: dangling +// // string_view. +// +// e->Schedule(absl::bind_front(LogStringView, s)); // OK: stores a copy of +// // s. +// +// To store some of the arguments passed to `absl::bind_front()` by reference, +// use std::ref()` and `std::cref()`. +// +// Example: Storing some of the bound arguments by reference. +// +// class Service { +// public: +// void Serve(const Request& req, std::function<void()>* done) { +// // The request protocol buffer won't be deleted until done is called. +// // It's safe to store a reference to it inside the functor. +// Executor::DefaultExecutor()->Schedule( +// absl::bind_front(&Service::BlockingServe, this, std::cref(req), +// done)); +// } +// +// private: +// void BlockingServe(const Request& req, std::function<void()>* done); +// }; +// +// Example: Storing bound arguments by reference. +// +// void Print(const std::string& a, const std::string& b) { +// std::cerr << a << b; +// } +// +// std::string hi = "Hello, "; +// std::vector<std::string> names = {"Chuk", "Gek"}; +// // Doesn't copy hi. +// for_each(names.begin(), names.end(), +// absl::bind_front(Print, std::ref(hi))); +// +// // DO NOT DO THIS: the functor may outlive "hi", resulting in +// // dangling references. +// foo->DoInFuture(absl::bind_front(Print, std::ref(hi), "Guest")); // BAD! +// auto f = absl::bind_front(Print, std::ref(hi), "Guest"); // BAD! +// +// Example: Storing reference-like types. +// +// void Print(absl::string_view a, const std::string& b) { +// std::cerr << a << b; +// } +// +// std::string hi = "Hello, "; +// // Copies "hi". +// absl::bind_front(Print, hi)("Chuk"); +// +// // Compile error: std::reference_wrapper<const string> is not implicitly +// // convertible to string_view. +// // absl::bind_front(Print, std::cref(hi))("Chuk"); +// +// // Doesn't copy "hi". +// absl::bind_front(Print, absl::string_view(hi))("Chuk"); +// +template <class F, class... BoundArgs> +constexpr functional_internal::bind_front_t<F, BoundArgs...> bind_front( + F&& func, BoundArgs&&... args) { + return functional_internal::bind_front_t<F, BoundArgs...>( + absl::in_place, absl::forward<F>(func), + absl::forward<BoundArgs>(args)...); +} + +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_FUNCTIONAL_BIND_FRONT_H_
diff --git a/third_party/abseil-cpp/absl/functional/bind_front_test.cc b/third_party/abseil-cpp/absl/functional/bind_front_test.cc new file mode 100644 index 0000000..4801a81 --- /dev/null +++ b/third_party/abseil-cpp/absl/functional/bind_front_test.cc
@@ -0,0 +1,231 @@ +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/functional/bind_front.h" + +#include <stddef.h> + +#include <functional> +#include <memory> +#include <string> + +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "absl/memory/memory.h" + +namespace { + +char CharAt(const char* s, size_t index) { return s[index]; } + +TEST(BindTest, Basics) { + EXPECT_EQ('C', absl::bind_front(CharAt)("ABC", 2)); + EXPECT_EQ('C', absl::bind_front(CharAt, "ABC")(2)); + EXPECT_EQ('C', absl::bind_front(CharAt, "ABC", 2)()); +} + +TEST(BindTest, Lambda) { + auto lambda = [](int x, int y, int z) { return x + y + z; }; + EXPECT_EQ(6, absl::bind_front(lambda)(1, 2, 3)); + EXPECT_EQ(6, absl::bind_front(lambda, 1)(2, 3)); + EXPECT_EQ(6, absl::bind_front(lambda, 1, 2)(3)); + EXPECT_EQ(6, absl::bind_front(lambda, 1, 2, 3)()); +} + +struct Functor { + std::string operator()() & { return "&"; } + std::string operator()() const& { return "const&"; } + std::string operator()() && { return "&&"; } + std::string operator()() const&& { return "const&&"; } +}; + +TEST(BindTest, PerfectForwardingOfBoundArgs) { + auto f = absl::bind_front(Functor()); + const auto& cf = f; + EXPECT_EQ("&", f()); + EXPECT_EQ("const&", cf()); + EXPECT_EQ("&&", std::move(f)()); + EXPECT_EQ("const&&", std::move(cf)()); +} + +struct ArgDescribe { + std::string operator()(int&) const { return "&"; } // NOLINT + std::string operator()(const int&) const { return "const&"; } // NOLINT + std::string operator()(int&&) const { return "&&"; } + std::string operator()(const int&&) const { return "const&&"; } +}; + +TEST(BindTest, PerfectForwardingOfFreeArgs) { + ArgDescribe f; + int i; + EXPECT_EQ("&", absl::bind_front(f)(static_cast<int&>(i))); + EXPECT_EQ("const&", absl::bind_front(f)(static_cast<const int&>(i))); + EXPECT_EQ("&&", absl::bind_front(f)(static_cast<int&&>(i))); + EXPECT_EQ("const&&", absl::bind_front(f)(static_cast<const int&&>(i))); +} + +struct NonCopyableFunctor { + NonCopyableFunctor() = default; + NonCopyableFunctor(const NonCopyableFunctor&) = delete; + NonCopyableFunctor& operator=(const NonCopyableFunctor&) = delete; + const NonCopyableFunctor* operator()() const { return this; } +}; + +TEST(BindTest, RefToFunctor) { + // It won't copy/move the functor and use the original object. + NonCopyableFunctor ncf; + auto bound_ncf = absl::bind_front(std::ref(ncf)); + auto bound_ncf_copy = bound_ncf; + EXPECT_EQ(&ncf, bound_ncf_copy()); +} + +struct Struct { + std::string value; +}; + +TEST(BindTest, StoreByCopy) { + Struct s = {"hello"}; + auto f = absl::bind_front(&Struct::value, s); + auto g = f; + EXPECT_EQ("hello", f()); + EXPECT_EQ("hello", g()); + EXPECT_NE(&s.value, &f()); + EXPECT_NE(&s.value, &g()); + EXPECT_NE(&g(), &f()); +} + +struct NonCopyable { + explicit NonCopyable(const std::string& s) : value(s) {} + NonCopyable(const NonCopyable&) = delete; + NonCopyable& operator=(const NonCopyable&) = delete; + + std::string value; +}; + +const std::string& GetNonCopyableValue(const NonCopyable& n) { return n.value; } + +TEST(BindTest, StoreByRef) { + NonCopyable s("hello"); + auto f = absl::bind_front(&GetNonCopyableValue, std::ref(s)); + EXPECT_EQ("hello", f()); + EXPECT_EQ(&s.value, &f()); + auto g = std::move(f); // NOLINT + EXPECT_EQ("hello", g()); + EXPECT_EQ(&s.value, &g()); + s.value = "goodbye"; + EXPECT_EQ("goodbye", g()); +} + +TEST(BindTest, StoreByCRef) { + NonCopyable s("hello"); + auto f = absl::bind_front(&GetNonCopyableValue, std::cref(s)); + EXPECT_EQ("hello", f()); + EXPECT_EQ(&s.value, &f()); + auto g = std::move(f); // NOLINT + EXPECT_EQ("hello", g()); + EXPECT_EQ(&s.value, &g()); + s.value = "goodbye"; + EXPECT_EQ("goodbye", g()); +} + +const std::string& GetNonCopyableValueByWrapper( + std::reference_wrapper<NonCopyable> n) { + return n.get().value; +} + +TEST(BindTest, StoreByRefInvokeByWrapper) { + NonCopyable s("hello"); + auto f = absl::bind_front(GetNonCopyableValueByWrapper, std::ref(s)); + EXPECT_EQ("hello", f()); + EXPECT_EQ(&s.value, &f()); + auto g = std::move(f); + EXPECT_EQ("hello", g()); + EXPECT_EQ(&s.value, &g()); + s.value = "goodbye"; + EXPECT_EQ("goodbye", g()); +} + +TEST(BindTest, StoreByPointer) { + NonCopyable s("hello"); + auto f = absl::bind_front(&NonCopyable::value, &s); + EXPECT_EQ("hello", f()); + EXPECT_EQ(&s.value, &f()); + auto g = std::move(f); + EXPECT_EQ("hello", g()); + EXPECT_EQ(&s.value, &g()); +} + +int Sink(std::unique_ptr<int> p) { + return *p; +} + +std::unique_ptr<int> Factory(int n) { return absl::make_unique<int>(n); } + +TEST(BindTest, NonCopyableArg) { + EXPECT_EQ(42, absl::bind_front(Sink)(absl::make_unique<int>(42))); + EXPECT_EQ(42, absl::bind_front(Sink, absl::make_unique<int>(42))()); +} + +TEST(BindTest, NonCopyableResult) { + EXPECT_THAT(absl::bind_front(Factory)(42), ::testing::Pointee(42)); + EXPECT_THAT(absl::bind_front(Factory, 42)(), ::testing::Pointee(42)); +} + +// is_copy_constructible<FalseCopyable<unique_ptr<T>> is true but an attempt to +// instantiate the copy constructor leads to a compile error. This is similar +// to how standard containers behave. +template <class T> +struct FalseCopyable { + FalseCopyable() {} + FalseCopyable(const FalseCopyable& other) : m(other.m) {} + FalseCopyable(FalseCopyable&& other) : m(std::move(other.m)) {} + T m; +}; + +int GetMember(FalseCopyable<std::unique_ptr<int>> x) { return *x.m; } + +TEST(BindTest, WrappedMoveOnly) { + FalseCopyable<std::unique_ptr<int>> x; + x.m = absl::make_unique<int>(42); + auto f = absl::bind_front(&GetMember, std::move(x)); + EXPECT_EQ(42, std::move(f)()); +} + +int Plus(int a, int b) { return a + b; } + +TEST(BindTest, ConstExpr) { + constexpr auto f = absl::bind_front(CharAt); + EXPECT_EQ(f("ABC", 1), 'B'); + static constexpr int five = 5; + constexpr auto plus5 = absl::bind_front(Plus, five); + EXPECT_EQ(plus5(1), 6); + + // There seems to be a bug in MSVC dealing constexpr construction of + // char[]. Notice 'plus5' above; 'int' works just fine. +#if !(defined(_MSC_VER) && _MSC_VER < 1910) + static constexpr char data[] = "DEF"; + constexpr auto g = absl::bind_front(CharAt, data); + EXPECT_EQ(g(1), 'E'); +#endif +} + +struct ManglingCall { + int operator()(int, double, std::string) const { return 0; } +}; + +TEST(BindTest, Mangling) { + // We just want to generate a particular instantiation to see its mangling. + absl::bind_front(ManglingCall{}, 1, 3.3)("A"); +} + +} // namespace
diff --git a/third_party/abseil-cpp/absl/functional/function_ref.h b/third_party/abseil-cpp/absl/functional/function_ref.h new file mode 100644 index 0000000..370acc5 --- /dev/null +++ b/third_party/abseil-cpp/absl/functional/function_ref.h
@@ -0,0 +1,139 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------- +// File: function_ref.h +// ----------------------------------------------------------------------------- +// +// This header file defines the `absl::FunctionRef` type for holding a +// non-owning reference to an object of any invocable type. This function +// reference is typically most useful as a type-erased argument type for +// accepting function types that neither take ownership nor copy the type; using +// the reference type in this case avoids a copy and an allocation. Best +// practices of other non-owning reference-like objects (such as +// `absl::string_view`) apply here. +// +// An `absl::FunctionRef` is similar in usage to a `std::function` but has the +// following differences: +// +// * It doesn't own the underlying object. +// * It doesn't have a null or empty state. +// * It never performs deep copies or allocations. +// * It's much faster and cheaper to construct. +// * It's trivially copyable and destructable. +// +// Generally, `absl::FunctionRef` should not be used as a return value, data +// member, or to initialize a `std::function`. Such usages will often lead to +// problematic lifetime issues. Once you convert something to an +// `absl::FunctionRef` you cannot make a deep copy later. +// +// This class is suitable for use wherever a "const std::function<>&" +// would be used without making a copy. ForEach functions and other versions of +// the visitor pattern are a good example of when this class should be used. +// +// This class is trivial to copy and should be passed by value. +#ifndef ABSL_FUNCTIONAL_FUNCTION_REF_H_ +#define ABSL_FUNCTIONAL_FUNCTION_REF_H_ + +#include <cassert> +#include <functional> +#include <type_traits> + +#include "absl/functional/internal/function_ref.h" +#include "absl/meta/type_traits.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN + +// FunctionRef +// +// Dummy class declaration to allow the partial specialization based on function +// types below. +template <typename T> +class FunctionRef; + +// FunctionRef +// +// An `absl::FunctionRef` is a lightweight wrapper to any invokable object with +// a compatible signature. Generally, an `absl::FunctionRef` should only be used +// as an argument type and should be preferred as an argument over a const +// reference to a `std::function`. +// +// Example: +// +// // The following function takes a function callback by const reference +// bool Visitor(const std::function<void(my_proto&, +// absl::string_view)>& callback); +// +// // Assuming that the function is not stored or otherwise copied, it can be +// // replaced by an `absl::FunctionRef`: +// bool Visitor(absl::FunctionRef<void(my_proto&, absl::string_view)> +// callback); +// +// Note: the assignment operator within an `absl::FunctionRef` is intentionally +// deleted to prevent misuse; because the `absl::FunctionRef` does not own the +// underlying type, assignment likely indicates misuse. +template <typename R, typename... Args> +class FunctionRef<R(Args...)> { + private: + // Used to disable constructors for objects that are not compatible with the + // signature of this FunctionRef. + template <typename F, + typename FR = absl::base_internal::InvokeT<F, Args&&...>> + using EnableIfCompatible = + typename std::enable_if<std::is_void<R>::value || + std::is_convertible<FR, R>::value>::type; + + public: + // Constructs a FunctionRef from any invokable type. + template <typename F, typename = EnableIfCompatible<const F&>> + FunctionRef(const F& f) // NOLINT(runtime/explicit) + : invoker_(&absl::functional_internal::InvokeObject<F, R, Args...>) { + absl::functional_internal::AssertNonNull(f); + ptr_.obj = &f; + } + + // Overload for function pointers. This eliminates a level of indirection that + // would happen if the above overload was used (it lets us store the pointer + // instead of a pointer to a pointer). + // + // This overload is also used for references to functions, since references to + // functions can decay to function pointers implicitly. + template < + typename F, typename = EnableIfCompatible<F*>, + absl::functional_internal::EnableIf<absl::is_function<F>::value> = 0> + FunctionRef(F* f) // NOLINT(runtime/explicit) + : invoker_(&absl::functional_internal::InvokeFunction<F*, R, Args...>) { + assert(f != nullptr); + ptr_.fun = reinterpret_cast<decltype(ptr_.fun)>(f); + } + + // To help prevent subtle lifetime bugs, FunctionRef is not assignable. + // Typically, it should only be used as an argument type. + FunctionRef& operator=(const FunctionRef& rhs) = delete; + + // Call the underlying object. + R operator()(Args... args) const { + return invoker_(ptr_, std::forward<Args>(args)...); + } + + private: + absl::functional_internal::VoidPtr ptr_; + absl::functional_internal::Invoker<R, Args...> invoker_; +}; + +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_FUNCTIONAL_FUNCTION_REF_H_
diff --git a/third_party/abseil-cpp/absl/functional/function_ref_benchmark.cc b/third_party/abseil-cpp/absl/functional/function_ref_benchmark.cc new file mode 100644 index 0000000..045305b --- /dev/null +++ b/third_party/abseil-cpp/absl/functional/function_ref_benchmark.cc
@@ -0,0 +1,142 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/functional/function_ref.h" + +#include <memory> + +#include "benchmark/benchmark.h" +#include "absl/base/attributes.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace { + +int dummy = 0; + +void FreeFunction() { benchmark::DoNotOptimize(dummy); } + +struct TrivialFunctor { + void operator()() const { benchmark::DoNotOptimize(dummy); } +}; + +struct LargeFunctor { + void operator()() const { benchmark::DoNotOptimize(this); } + std::string a, b, c; +}; + +template <typename Function, typename... Args> +void ABSL_ATTRIBUTE_NOINLINE CallFunction(Function f, Args&&... args) { + f(std::forward<Args>(args)...); +} + +template <typename Function, typename Callable, typename... Args> +void ConstructAndCallFunctionBenchmark(benchmark::State& state, + const Callable& c, Args&&... args) { + for (auto _ : state) { + CallFunction<Function>(c, std::forward<Args>(args)...); + } +} + +void BM_TrivialStdFunction(benchmark::State& state) { + ConstructAndCallFunctionBenchmark<std::function<void()>>(state, + TrivialFunctor{}); +} +BENCHMARK(BM_TrivialStdFunction); + +void BM_TrivialFunctionRef(benchmark::State& state) { + ConstructAndCallFunctionBenchmark<FunctionRef<void()>>(state, + TrivialFunctor{}); +} +BENCHMARK(BM_TrivialFunctionRef); + +void BM_LargeStdFunction(benchmark::State& state) { + ConstructAndCallFunctionBenchmark<std::function<void()>>(state, + LargeFunctor{}); +} +BENCHMARK(BM_LargeStdFunction); + +void BM_LargeFunctionRef(benchmark::State& state) { + ConstructAndCallFunctionBenchmark<FunctionRef<void()>>(state, LargeFunctor{}); +} +BENCHMARK(BM_LargeFunctionRef); + +void BM_FunPtrStdFunction(benchmark::State& state) { + ConstructAndCallFunctionBenchmark<std::function<void()>>(state, FreeFunction); +} +BENCHMARK(BM_FunPtrStdFunction); + +void BM_FunPtrFunctionRef(benchmark::State& state) { + ConstructAndCallFunctionBenchmark<FunctionRef<void()>>(state, FreeFunction); +} +BENCHMARK(BM_FunPtrFunctionRef); + +// Doesn't include construction or copy overhead in the loop. +template <typename Function, typename Callable, typename... Args> +void CallFunctionBenchmark(benchmark::State& state, const Callable& c, + Args... args) { + Function f = c; + for (auto _ : state) { + benchmark::DoNotOptimize(&f); + f(args...); + } +} + +struct FunctorWithTrivialArgs { + void operator()(int a, int b, int c) const { + benchmark::DoNotOptimize(a); + benchmark::DoNotOptimize(b); + benchmark::DoNotOptimize(c); + } +}; + +void BM_TrivialArgsStdFunction(benchmark::State& state) { + CallFunctionBenchmark<std::function<void(int, int, int)>>( + state, FunctorWithTrivialArgs{}, 1, 2, 3); +} +BENCHMARK(BM_TrivialArgsStdFunction); + +void BM_TrivialArgsFunctionRef(benchmark::State& state) { + CallFunctionBenchmark<FunctionRef<void(int, int, int)>>( + state, FunctorWithTrivialArgs{}, 1, 2, 3); +} +BENCHMARK(BM_TrivialArgsFunctionRef); + +struct FunctorWithNonTrivialArgs { + void operator()(std::string a, std::string b, std::string c) const { + benchmark::DoNotOptimize(&a); + benchmark::DoNotOptimize(&b); + benchmark::DoNotOptimize(&c); + } +}; + +void BM_NonTrivialArgsStdFunction(benchmark::State& state) { + std::string a, b, c; + CallFunctionBenchmark< + std::function<void(std::string, std::string, std::string)>>( + state, FunctorWithNonTrivialArgs{}, a, b, c); +} +BENCHMARK(BM_NonTrivialArgsStdFunction); + +void BM_NonTrivialArgsFunctionRef(benchmark::State& state) { + std::string a, b, c; + CallFunctionBenchmark< + FunctionRef<void(std::string, std::string, std::string)>>( + state, FunctorWithNonTrivialArgs{}, a, b, c); +} +BENCHMARK(BM_NonTrivialArgsFunctionRef); + +} // namespace +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/functional/function_ref_test.cc b/third_party/abseil-cpp/absl/functional/function_ref_test.cc new file mode 100644 index 0000000..3aa59745 --- /dev/null +++ b/third_party/abseil-cpp/absl/functional/function_ref_test.cc
@@ -0,0 +1,257 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/functional/function_ref.h" + +#include <memory> + +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "absl/container/internal/test_instance_tracker.h" +#include "absl/memory/memory.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace { + +void RunFun(FunctionRef<void()> f) { f(); } + +TEST(FunctionRefTest, Lambda) { + bool ran = false; + RunFun([&] { ran = true; }); + EXPECT_TRUE(ran); +} + +int Function() { return 1337; } + +TEST(FunctionRefTest, Function1) { + FunctionRef<int()> ref(&Function); + EXPECT_EQ(1337, ref()); +} + +TEST(FunctionRefTest, Function2) { + FunctionRef<int()> ref(Function); + EXPECT_EQ(1337, ref()); +} + +int NoExceptFunction() noexcept { return 1337; } + +// TODO(jdennett): Add a test for noexcept member functions. +TEST(FunctionRefTest, NoExceptFunction) { + FunctionRef<int()> ref(NoExceptFunction); + EXPECT_EQ(1337, ref()); +} + +TEST(FunctionRefTest, ForwardsArgs) { + auto l = [](std::unique_ptr<int> i) { return *i; }; + FunctionRef<int(std::unique_ptr<int>)> ref(l); + EXPECT_EQ(42, ref(absl::make_unique<int>(42))); +} + +TEST(FunctionRef, ReturnMoveOnly) { + auto l = [] { return absl::make_unique<int>(29); }; + FunctionRef<std::unique_ptr<int>()> ref(l); + EXPECT_EQ(29, *ref()); +} + +TEST(FunctionRef, ManyArgs) { + auto l = [](int a, int b, int c) { return a + b + c; }; + FunctionRef<int(int, int, int)> ref(l); + EXPECT_EQ(6, ref(1, 2, 3)); +} + +TEST(FunctionRef, VoidResultFromNonVoidFunctor) { + bool ran = false; + auto l = [&]() -> int { + ran = true; + return 2; + }; + FunctionRef<void()> ref(l); + ref(); + EXPECT_TRUE(ran); +} + +TEST(FunctionRef, CastFromDerived) { + struct Base {}; + struct Derived : public Base {}; + + Derived d; + auto l1 = [&](Base* b) { EXPECT_EQ(&d, b); }; + FunctionRef<void(Derived*)> ref1(l1); + ref1(&d); + + auto l2 = [&]() -> Derived* { return &d; }; + FunctionRef<Base*()> ref2(l2); + EXPECT_EQ(&d, ref2()); +} + +TEST(FunctionRef, VoidResultFromNonVoidFuncton) { + FunctionRef<void()> ref(Function); + ref(); +} + +TEST(FunctionRef, MemberPtr) { + struct S { + int i; + }; + + S s{1100111}; + auto mem_ptr = &S::i; + FunctionRef<int(const S& s)> ref(mem_ptr); + EXPECT_EQ(1100111, ref(s)); +} + +TEST(FunctionRef, MemberFun) { + struct S { + int i; + int get_i() const { return i; } + }; + + S s{22}; + auto mem_fun_ptr = &S::get_i; + FunctionRef<int(const S& s)> ref(mem_fun_ptr); + EXPECT_EQ(22, ref(s)); +} + +TEST(FunctionRef, MemberFunRefqualified) { + struct S { + int i; + int get_i() && { return i; } + }; + auto mem_fun_ptr = &S::get_i; + S s{22}; + FunctionRef<int(S && s)> ref(mem_fun_ptr); + EXPECT_EQ(22, ref(std::move(s))); +} + +#if !defined(_WIN32) && defined(GTEST_HAS_DEATH_TEST) + +TEST(FunctionRef, MemberFunRefqualifiedNull) { + struct S { + int i; + int get_i() && { return i; } + }; + auto mem_fun_ptr = &S::get_i; + mem_fun_ptr = nullptr; + EXPECT_DEBUG_DEATH({ FunctionRef<int(S && s)> ref(mem_fun_ptr); }, ""); +} + +TEST(FunctionRef, NullMemberPtrAssertFails) { + struct S { + int i; + }; + using MemberPtr = int S::*; + MemberPtr mem_ptr = nullptr; + EXPECT_DEBUG_DEATH({ FunctionRef<int(const S& s)> ref(mem_ptr); }, ""); +} + +#endif // GTEST_HAS_DEATH_TEST + +TEST(FunctionRef, CopiesAndMovesPerPassByValue) { + absl::test_internal::InstanceTracker tracker; + absl::test_internal::CopyableMovableInstance instance(0); + auto l = [](absl::test_internal::CopyableMovableInstance) {}; + FunctionRef<void(absl::test_internal::CopyableMovableInstance)> ref(l); + ref(instance); + EXPECT_EQ(tracker.copies(), 1); + EXPECT_EQ(tracker.moves(), 1); +} + +TEST(FunctionRef, CopiesAndMovesPerPassByRef) { + absl::test_internal::InstanceTracker tracker; + absl::test_internal::CopyableMovableInstance instance(0); + auto l = [](const absl::test_internal::CopyableMovableInstance&) {}; + FunctionRef<void(const absl::test_internal::CopyableMovableInstance&)> ref(l); + ref(instance); + EXPECT_EQ(tracker.copies(), 0); + EXPECT_EQ(tracker.moves(), 0); +} + +TEST(FunctionRef, CopiesAndMovesPerPassByValueCallByMove) { + absl::test_internal::InstanceTracker tracker; + absl::test_internal::CopyableMovableInstance instance(0); + auto l = [](absl::test_internal::CopyableMovableInstance) {}; + FunctionRef<void(absl::test_internal::CopyableMovableInstance)> ref(l); + ref(std::move(instance)); + EXPECT_EQ(tracker.copies(), 0); + EXPECT_EQ(tracker.moves(), 2); +} + +TEST(FunctionRef, CopiesAndMovesPerPassByValueToRef) { + absl::test_internal::InstanceTracker tracker; + absl::test_internal::CopyableMovableInstance instance(0); + auto l = [](const absl::test_internal::CopyableMovableInstance&) {}; + FunctionRef<void(absl::test_internal::CopyableMovableInstance)> ref(l); + ref(std::move(instance)); + EXPECT_EQ(tracker.copies(), 0); + EXPECT_EQ(tracker.moves(), 1); +} + +TEST(FunctionRef, PassByValueTypes) { + using absl::functional_internal::Invoker; + using absl::functional_internal::VoidPtr; + using absl::test_internal::CopyableMovableInstance; + struct Trivial { + void* p[2]; + }; + struct LargeTrivial { + void* p[3]; + }; + + static_assert(std::is_same<Invoker<void, int>, void (*)(VoidPtr, int)>::value, + "Scalar types should be passed by value"); + static_assert( + std::is_same<Invoker<void, Trivial>, void (*)(VoidPtr, Trivial)>::value, + "Small trivial types should be passed by value"); + static_assert(std::is_same<Invoker<void, LargeTrivial>, + void (*)(VoidPtr, LargeTrivial &&)>::value, + "Large trivial types should be passed by rvalue reference"); + static_assert( + std::is_same<Invoker<void, CopyableMovableInstance>, + void (*)(VoidPtr, CopyableMovableInstance &&)>::value, + "Types with copy/move ctor should be passed by rvalue reference"); + + // References are passed as references. + static_assert( + std::is_same<Invoker<void, int&>, void (*)(VoidPtr, int&)>::value, + "Reference types should be preserved"); + static_assert( + std::is_same<Invoker<void, CopyableMovableInstance&>, + void (*)(VoidPtr, CopyableMovableInstance&)>::value, + "Reference types should be preserved"); + static_assert( + std::is_same<Invoker<void, CopyableMovableInstance&&>, + void (*)(VoidPtr, CopyableMovableInstance &&)>::value, + "Reference types should be preserved"); + + // Make sure the address of an object received by reference is the same as the + // addess of the object passed by the caller. + { + LargeTrivial obj; + auto test = [&obj](LargeTrivial& input) { ASSERT_EQ(&input, &obj); }; + absl::FunctionRef<void(LargeTrivial&)> ref(test); + ref(obj); + } + + { + Trivial obj; + auto test = [&obj](Trivial& input) { ASSERT_EQ(&input, &obj); }; + absl::FunctionRef<void(Trivial&)> ref(test); + ref(obj); + } +} + +} // namespace +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/functional/internal/front_binder.h b/third_party/abseil-cpp/absl/functional/internal/front_binder.h new file mode 100644 index 0000000..a4d95da4 --- /dev/null +++ b/third_party/abseil-cpp/absl/functional/internal/front_binder.h
@@ -0,0 +1,95 @@ +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Implementation details for `absl::bind_front()`. + +#ifndef ABSL_FUNCTIONAL_INTERNAL_FRONT_BINDER_H_ +#define ABSL_FUNCTIONAL_INTERNAL_FRONT_BINDER_H_ + +#include <cstddef> +#include <type_traits> +#include <utility> + +#include "absl/base/internal/invoke.h" +#include "absl/container/internal/compressed_tuple.h" +#include "absl/meta/type_traits.h" +#include "absl/utility/utility.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace functional_internal { + +// Invoke the method, expanding the tuple of bound arguments. +template <class R, class Tuple, size_t... Idx, class... Args> +R Apply(Tuple&& bound, absl::index_sequence<Idx...>, Args&&... free) { + return base_internal::Invoke( + absl::forward<Tuple>(bound).template get<Idx>()..., + absl::forward<Args>(free)...); +} + +template <class F, class... BoundArgs> +class FrontBinder { + using BoundArgsT = absl::container_internal::CompressedTuple<F, BoundArgs...>; + using Idx = absl::make_index_sequence<sizeof...(BoundArgs) + 1>; + + BoundArgsT bound_args_; + + public: + template <class... Ts> + constexpr explicit FrontBinder(absl::in_place_t, Ts&&... ts) + : bound_args_(absl::forward<Ts>(ts)...) {} + + template <class... FreeArgs, + class R = base_internal::InvokeT<F&, BoundArgs&..., FreeArgs&&...>> + R operator()(FreeArgs&&... free_args) & { + return functional_internal::Apply<R>(bound_args_, Idx(), + absl::forward<FreeArgs>(free_args)...); + } + + template <class... FreeArgs, + class R = base_internal::InvokeT<const F&, const BoundArgs&..., + FreeArgs&&...>> + R operator()(FreeArgs&&... free_args) const& { + return functional_internal::Apply<R>(bound_args_, Idx(), + absl::forward<FreeArgs>(free_args)...); + } + + template <class... FreeArgs, class R = base_internal::InvokeT< + F&&, BoundArgs&&..., FreeArgs&&...>> + R operator()(FreeArgs&&... free_args) && { + // This overload is called when *this is an rvalue. If some of the bound + // arguments are stored by value or rvalue reference, we move them. + return functional_internal::Apply<R>(absl::move(bound_args_), Idx(), + absl::forward<FreeArgs>(free_args)...); + } + + template <class... FreeArgs, + class R = base_internal::InvokeT<const F&&, const BoundArgs&&..., + FreeArgs&&...>> + R operator()(FreeArgs&&... free_args) const&& { + // This overload is called when *this is an rvalue. If some of the bound + // arguments are stored by value or rvalue reference, we move them. + return functional_internal::Apply<R>(absl::move(bound_args_), Idx(), + absl::forward<FreeArgs>(free_args)...); + } +}; + +template <class F, class... BoundArgs> +using bind_front_t = FrontBinder<decay_t<F>, absl::decay_t<BoundArgs>...>; + +} // namespace functional_internal +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_FUNCTIONAL_INTERNAL_FRONT_BINDER_H_
diff --git a/third_party/abseil-cpp/absl/functional/internal/function_ref.h b/third_party/abseil-cpp/absl/functional/internal/function_ref.h new file mode 100644 index 0000000..d157505 --- /dev/null +++ b/third_party/abseil-cpp/absl/functional/internal/function_ref.h
@@ -0,0 +1,106 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ABSL_FUNCTIONAL_INTERNAL_FUNCTION_REF_H_ +#define ABSL_FUNCTIONAL_INTERNAL_FUNCTION_REF_H_ + +#include <cassert> +#include <functional> +#include <type_traits> + +#include "absl/base/internal/invoke.h" +#include "absl/meta/type_traits.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace functional_internal { + +// Like a void* that can handle function pointers as well. The standard does not +// allow function pointers to round-trip through void*, but void(*)() is fine. +// +// Note: It's important that this class remains trivial and is the same size as +// a pointer, since this allows the compiler to perform tail-call optimizations +// when the underlying function is a callable object with a matching signature. +union VoidPtr { + const void* obj; + void (*fun)(); +}; + +// Chooses the best type for passing T as an argument. +// Attempt to be close to SystemV AMD64 ABI. Objects with trivial copy ctor are +// passed by value. +template <typename T> +constexpr bool PassByValue() { + return !std::is_lvalue_reference<T>::value && + absl::is_trivially_copy_constructible<T>::value && + absl::is_trivially_copy_assignable< + typename std::remove_cv<T>::type>::value && + std::is_trivially_destructible<T>::value && + sizeof(T) <= 2 * sizeof(void*); +} + +template <typename T> +struct ForwardT : std::conditional<PassByValue<T>(), T, T&&> {}; + +// An Invoker takes a pointer to the type-erased invokable object, followed by +// the arguments that the invokable object expects. +// +// Note: The order of arguments here is an optimization, since member functions +// have an implicit "this" pointer as their first argument, putting VoidPtr +// first allows the compiler to perform tail-call optimization in many cases. +template <typename R, typename... Args> +using Invoker = R (*)(VoidPtr, typename ForwardT<Args>::type...); + +// +// InvokeObject and InvokeFunction provide static "Invoke" functions that can be +// used as Invokers for objects or functions respectively. +// +// static_cast<R> handles the case the return type is void. +template <typename Obj, typename R, typename... Args> +R InvokeObject(VoidPtr ptr, typename ForwardT<Args>::type... args) { + auto o = static_cast<const Obj*>(ptr.obj); + return static_cast<R>( + absl::base_internal::Invoke(*o, std::forward<Args>(args)...)); +} + +template <typename Fun, typename R, typename... Args> +R InvokeFunction(VoidPtr ptr, typename ForwardT<Args>::type... args) { + auto f = reinterpret_cast<Fun>(ptr.fun); + return static_cast<R>( + absl::base_internal::Invoke(f, std::forward<Args>(args)...)); +} + +template <typename Sig> +void AssertNonNull(const std::function<Sig>& f) { + assert(f != nullptr); + (void)f; +} + +template <typename F> +void AssertNonNull(const F&) {} + +template <typename F, typename C> +void AssertNonNull(F C::*f) { + assert(f != nullptr); + (void)f; +} + +template <bool C> +using EnableIf = typename ::std::enable_if<C, int>::type; + +} // namespace functional_internal +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_FUNCTIONAL_INTERNAL_FUNCTION_REF_H_
diff --git a/third_party/abseil-cpp/absl/hash/BUILD.bazel b/third_party/abseil-cpp/absl/hash/BUILD.bazel index 8c2daf7..59eac784 100644 --- a/third_party/abseil-cpp/absl/hash/BUILD.bazel +++ b/third_party/abseil-cpp/absl/hash/BUILD.bazel
@@ -1,5 +1,5 @@ # -# Copyright 2018 The Abseil Authors. +# Copyright 2019 The Abseil Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ # limitations under the License. # +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", @@ -42,6 +43,7 @@ "//absl/meta:type_traits", "//absl/numeric:int128", "//absl/strings", + "//absl/strings:cord", "//absl/types:optional", "//absl/types:variant", "//absl/utility", @@ -70,11 +72,12 @@ deps = [ ":hash", ":hash_testing", + ":spy_hash_state", "//absl/base:core_headers", "//absl/container:flat_hash_set", - "//absl/hash:spy_hash_state", "//absl/meta:type_traits", "//absl/numeric:int128", + "//absl/strings:cord_test_helpers", "@com_google_googletest//:gtest_main", ], )
diff --git a/third_party/abseil-cpp/absl/hash/BUILD.gn b/third_party/abseil-cpp/absl/hash/BUILD.gn index 37acead6..f9c161a 100644 --- a/third_party/abseil-cpp/absl/hash/BUILD.gn +++ b/third_party/abseil-cpp/absl/hash/BUILD.gn
@@ -38,6 +38,7 @@ "../meta:type_traits", "../numeric:int128", "../strings", + "../strings:cord", "../types:optional", "../types:variant", "../utility",
diff --git a/third_party/abseil-cpp/absl/hash/CMakeLists.txt b/third_party/abseil-cpp/absl/hash/CMakeLists.txt index febc551f..4e55514 100644 --- a/third_party/abseil-cpp/absl/hash/CMakeLists.txt +++ b/third_party/abseil-cpp/absl/hash/CMakeLists.txt
@@ -25,6 +25,7 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS + absl::cord absl::core_headers absl::endian absl::fixed_array @@ -62,6 +63,7 @@ COPTS ${ABSL_TEST_COPTS} DEPS + absl::cord_test_helpers absl::hash absl::hash_testing absl::core_headers
diff --git a/third_party/abseil-cpp/absl/hash/hash.h b/third_party/abseil-cpp/absl/hash/hash.h index 297dc9c..3dbeab6 100644 --- a/third_party/abseil-cpp/absl/hash/hash.h +++ b/third_party/abseil-cpp/absl/hash/hash.h
@@ -73,6 +73,7 @@ #include "absl/hash/internal/hash.h" namespace absl { +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // `absl::Hash` @@ -97,6 +98,7 @@ // * std::tuple<Ts...>, if all the Ts... are hashable // * std::unique_ptr and std::shared_ptr // * All string-like types including: +// * absl::Cord // * std::string // * std::string_view (as well as any instance of std::basic_string that // uses char and std::char_traits) @@ -317,6 +319,7 @@ void (*combine_contiguous_)(void*, const unsigned char*, size_t); }; +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_HASH_HASH_H_
diff --git a/third_party/abseil-cpp/absl/hash/hash_test.cc b/third_party/abseil-cpp/absl/hash/hash_test.cc index 9a667ba..5e6a8b1 100644 --- a/third_party/abseil-cpp/absl/hash/hash_test.cc +++ b/third_party/abseil-cpp/absl/hash/hash_test.cc
@@ -42,6 +42,7 @@ #include "absl/hash/internal/spy_hash_state.h" #include "absl/meta/type_traits.h" #include "absl/numeric/int128.h" +#include "absl/strings/cord_test_helpers.h" namespace { @@ -269,37 +270,84 @@ } }; +absl::Cord FlatCord(absl::string_view sv) { + absl::Cord c(sv); + c.Flatten(); + return c; +} + +absl::Cord FragmentedCord(absl::string_view sv) { + if (sv.size() < 2) { + return absl::Cord(sv); + } + size_t halfway = sv.size() / 2; + std::vector<absl::string_view> parts = {sv.substr(0, halfway), + sv.substr(halfway)}; + return absl::MakeFragmentedCord(parts); +} + TEST(HashValueTest, Strings) { EXPECT_TRUE((is_hashable<std::string>::value)); const std::string small = "foo"; const std::string dup = "foofoo"; - const std::string large = "large"; - const std::string huge = std::string(5000, 'a'); + const std::string large = std::string(2048, 'x'); // multiple of chunk size + const std::string huge = std::string(5000, 'a'); // not a multiple - EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(std::make_tuple( - std::string(), absl::string_view(), - std::string(""), absl::string_view(""), - std::string(small), absl::string_view(small), - std::string(dup), absl::string_view(dup), - std::string(large), absl::string_view(large), - std::string(huge), absl::string_view(huge)))); + EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(std::make_tuple( // + std::string(), absl::string_view(), absl::Cord(), // + std::string(""), absl::string_view(""), absl::Cord(""), // + std::string(small), absl::string_view(small), absl::Cord(small), // + std::string(dup), absl::string_view(dup), absl::Cord(dup), // + std::string(large), absl::string_view(large), absl::Cord(large), // + std::string(huge), absl::string_view(huge), FlatCord(huge), // + FragmentedCord(huge)))); // Also check that nested types maintain the same hash. const WrapInTuple t{}; - EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(std::make_tuple( - t(std::string()), t(absl::string_view()), - t(std::string("")), t(absl::string_view("")), - t(std::string(small)), t(absl::string_view(small)), - t(std::string(dup)), t(absl::string_view(dup)), - t(std::string(large)), t(absl::string_view(large)), - t(std::string(huge)), t(absl::string_view(huge))))); + EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(std::make_tuple( // + t(std::string()), t(absl::string_view()), t(absl::Cord()), // + t(std::string("")), t(absl::string_view("")), t(absl::Cord("")), // + t(std::string(small)), t(absl::string_view(small)), // + t(absl::Cord(small)), // + t(std::string(dup)), t(absl::string_view(dup)), t(absl::Cord(dup)), // + t(std::string(large)), t(absl::string_view(large)), // + t(absl::Cord(large)), // + t(std::string(huge)), t(absl::string_view(huge)), // + t(FlatCord(huge)), t(FragmentedCord(huge))))); - // Make sure that hashing a `const char*` does not use its std::string-value. + // Make sure that hashing a `const char*` does not use its string-value. EXPECT_NE(SpyHash(static_cast<const char*>("ABC")), SpyHash(absl::string_view("ABC"))); } +TEST(HashValueTest, WString) { + EXPECT_TRUE((is_hashable<std::wstring>::value)); + + EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(std::make_tuple( + std::wstring(), std::wstring(L"ABC"), std::wstring(L"ABC"), + std::wstring(L"Some other different string"), + std::wstring(L"Iñtërnâtiônàlizætiøn")))); +} + +TEST(HashValueTest, U16String) { + EXPECT_TRUE((is_hashable<std::u16string>::value)); + + EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(std::make_tuple( + std::u16string(), std::u16string(u"ABC"), std::u16string(u"ABC"), + std::u16string(u"Some other different string"), + std::u16string(u"Iñtërnâtiônàlizætiøn")))); +} + +TEST(HashValueTest, U32String) { + EXPECT_TRUE((is_hashable<std::u32string>::value)); + + EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(std::make_tuple( + std::u32string(), std::u32string(U"ABC"), std::u32string(U"ABC"), + std::u32string(U"Some other different string"), + std::u32string(U"Iñtërnâtiônàlizætiøn")))); +} + TEST(HashValueTest, StdArray) { EXPECT_TRUE((is_hashable<std::array<int, 3>>::value)); @@ -378,6 +426,116 @@ } }; +// Test helper for combine_piecewise_buffer. It holds a string_view to the +// buffer-to-be-hashed. Its AbslHashValue specialization will split up its +// contents at the character offsets requested. +class PiecewiseHashTester { + public: + // Create a hash view of a buffer to be hashed contiguously. + explicit PiecewiseHashTester(absl::string_view buf) + : buf_(buf), piecewise_(false), split_locations_() {} + + // Create a hash view of a buffer to be hashed piecewise, with breaks at the + // given locations. + PiecewiseHashTester(absl::string_view buf, std::set<size_t> split_locations) + : buf_(buf), + piecewise_(true), + split_locations_(std::move(split_locations)) {} + + template <typename H> + friend H AbslHashValue(H h, const PiecewiseHashTester& p) { + if (!p.piecewise_) { + return H::combine_contiguous(std::move(h), p.buf_.data(), p.buf_.size()); + } + absl::hash_internal::PiecewiseCombiner combiner; + if (p.split_locations_.empty()) { + h = combiner.add_buffer(std::move(h), p.buf_.data(), p.buf_.size()); + return combiner.finalize(std::move(h)); + } + size_t begin = 0; + for (size_t next : p.split_locations_) { + absl::string_view chunk = p.buf_.substr(begin, next - begin); + h = combiner.add_buffer(std::move(h), chunk.data(), chunk.size()); + begin = next; + } + absl::string_view last_chunk = p.buf_.substr(begin); + if (!last_chunk.empty()) { + h = combiner.add_buffer(std::move(h), last_chunk.data(), + last_chunk.size()); + } + return combiner.finalize(std::move(h)); + } + + private: + absl::string_view buf_; + bool piecewise_; + std::set<size_t> split_locations_; +}; + +// Dummy object that hashes as two distinct contiguous buffers, "foo" followed +// by "bar" +struct DummyFooBar { + template <typename H> + friend H AbslHashValue(H h, const DummyFooBar&) { + const char* foo = "foo"; + const char* bar = "bar"; + h = H::combine_contiguous(std::move(h), foo, 3); + h = H::combine_contiguous(std::move(h), bar, 3); + return h; + } +}; + +TEST(HashValueTest, CombinePiecewiseBuffer) { + absl::Hash<PiecewiseHashTester> hash; + + // Check that hashing an empty buffer through the piecewise API works. + EXPECT_EQ(hash(PiecewiseHashTester("")), hash(PiecewiseHashTester("", {}))); + + // Similarly, small buffers should give consistent results + EXPECT_EQ(hash(PiecewiseHashTester("foobar")), + hash(PiecewiseHashTester("foobar", {}))); + EXPECT_EQ(hash(PiecewiseHashTester("foobar")), + hash(PiecewiseHashTester("foobar", {3}))); + + // But hashing "foobar" in pieces gives a different answer than hashing "foo" + // contiguously, then "bar" contiguously. + EXPECT_NE(hash(PiecewiseHashTester("foobar", {3})), + absl::Hash<DummyFooBar>()(DummyFooBar{})); + + // Test hashing a large buffer incrementally, broken up in several different + // ways. Arrange for breaks on and near the stride boundaries to look for + // off-by-one errors in the implementation. + // + // This test is run on a buffer that is a multiple of the stride size, and one + // that isn't. + for (size_t big_buffer_size : {1024 * 2 + 512, 1024 * 3}) { + SCOPED_TRACE(big_buffer_size); + std::string big_buffer; + for (int i = 0; i < big_buffer_size; ++i) { + // Arbitrary string + big_buffer.push_back(32 + (i * (i / 3)) % 64); + } + auto big_buffer_hash = hash(PiecewiseHashTester(big_buffer)); + + const int possible_breaks = 9; + size_t breaks[possible_breaks] = {1, 512, 1023, 1024, 1025, + 1536, 2047, 2048, 2049}; + for (unsigned test_mask = 0; test_mask < (1u << possible_breaks); + ++test_mask) { + SCOPED_TRACE(test_mask); + std::set<size_t> break_locations; + for (int j = 0; j < possible_breaks; ++j) { + if (test_mask & (1u << j)) { + break_locations.insert(breaks[j]); + } + } + EXPECT_EQ( + hash(PiecewiseHashTester(big_buffer, std::move(break_locations))), + big_buffer_hash); + } + } +} + TEST(HashValueTest, PrivateSanity) { // Sanity check that Private is working as the tests below expect it to work. EXPECT_TRUE(is_hashable<Private>::value); @@ -458,7 +616,10 @@ EXPECT_FALSE(absl::is_copy_assignable<absl::Hash<X>>::value); EXPECT_FALSE(absl::is_move_assignable<absl::Hash<X>>::value); EXPECT_FALSE(IsHashCallable<X>::value); +#if !defined(__GNUC__) || __GNUC__ < 9 + // This doesn't compile on GCC 9. EXPECT_FALSE(IsAggregateInitializable<absl::Hash<X>>::value); +#endif } #endif // ABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ @@ -544,6 +705,7 @@ } // namespace namespace absl { +ABSL_NAMESPACE_BEGIN namespace hash_internal { template <InvokeTag... Tags> struct is_uniquely_represented< @@ -551,6 +713,7 @@ typename EnableIfContained<InvokeTag::kUniquelyRepresented, Tags...>::type> : std::true_type {}; } // namespace hash_internal +ABSL_NAMESPACE_END } // namespace absl #if ABSL_HASH_INTERNAL_SUPPORT_LEGACY_HASH_
diff --git a/third_party/abseil-cpp/absl/hash/hash_testing.h b/third_party/abseil-cpp/absl/hash/hash_testing.h index c45bc15..1e1c574 100644 --- a/third_party/abseil-cpp/absl/hash/hash_testing.h +++ b/third_party/abseil-cpp/absl/hash/hash_testing.h
@@ -28,6 +28,7 @@ #include "absl/types/variant.h" namespace absl { +ABSL_NAMESPACE_BEGIN // Run the absl::Hash algorithm over all the elements passed in and verify that // their hash expansion is congruent with their `==` operator. @@ -371,6 +372,7 @@ equals); } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_HASH_HASH_TESTING_H_
diff --git a/third_party/abseil-cpp/absl/hash/internal/city.cc b/third_party/abseil-cpp/absl/hash/internal/city.cc index dc7650a..e122c18 100644 --- a/third_party/abseil-cpp/absl/hash/internal/city.cc +++ b/third_party/abseil-cpp/absl/hash/internal/city.cc
@@ -30,6 +30,7 @@ #include "absl/base/optimization.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace hash_internal { #ifdef ABSL_IS_BIG_ENDIAN @@ -341,4 +342,5 @@ } } // namespace hash_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/hash/internal/city.h b/third_party/abseil-cpp/absl/hash/internal/city.h index b43d340..161c7748e 100644 --- a/third_party/abseil-cpp/absl/hash/internal/city.h +++ b/third_party/abseil-cpp/absl/hash/internal/city.h
@@ -47,9 +47,13 @@ #include <stdint.h> #include <stdlib.h> // for size_t. + #include <utility> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace hash_internal { typedef std::pair<uint64_t, uint64_t> uint128; @@ -86,6 +90,7 @@ } } // namespace hash_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_HASH_INTERNAL_CITY_H_
diff --git a/third_party/abseil-cpp/absl/hash/internal/city_test.cc b/third_party/abseil-cpp/absl/hash/internal/city_test.cc index 71b4ecc..251d381d 100644 --- a/third_party/abseil-cpp/absl/hash/internal/city_test.cc +++ b/third_party/abseil-cpp/absl/hash/internal/city_test.cc
@@ -20,6 +20,7 @@ #include "gtest/gtest.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace hash_internal { static const uint64_t k0 = 0xc3a5c85c97cb3127ULL; @@ -590,4 +591,5 @@ } } // namespace hash_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/hash/internal/hash.cc b/third_party/abseil-cpp/absl/hash/internal/hash.cc index 4ab7a9f8..b44ecb3 100644 --- a/third_party/abseil-cpp/absl/hash/internal/hash.cc +++ b/third_party/abseil-cpp/absl/hash/internal/hash.cc
@@ -15,9 +15,41 @@ #include "absl/hash/internal/hash.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace hash_internal { +uint64_t CityHashState::CombineLargeContiguousImpl32(uint64_t state, + const unsigned char* first, + size_t len) { + while (len >= PiecewiseChunkSize()) { + state = + Mix(state, absl::hash_internal::CityHash32(reinterpret_cast<const char*>(first), + PiecewiseChunkSize())); + len -= PiecewiseChunkSize(); + first += PiecewiseChunkSize(); + } + // Handle the remainder. + return CombineContiguousImpl(state, first, len, + std::integral_constant<int, 4>{}); +} + +uint64_t CityHashState::CombineLargeContiguousImpl64(uint64_t state, + const unsigned char* first, + size_t len) { + while (len >= PiecewiseChunkSize()) { + state = + Mix(state, absl::hash_internal::CityHash64(reinterpret_cast<const char*>(first), + PiecewiseChunkSize())); + len -= PiecewiseChunkSize(); + first += PiecewiseChunkSize(); + } + // Handle the remainder. + return CombineContiguousImpl(state, first, len, + std::integral_constant<int, 8>{}); +} + ABSL_CONST_INIT const void* const CityHashState::kSeed = &kSeed; } // namespace hash_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/hash/internal/hash.h b/third_party/abseil-cpp/absl/hash/internal/hash.h index 4ff4a126..025d287 100644 --- a/third_party/abseil-cpp/absl/hash/internal/hash.h +++ b/third_party/abseil-cpp/absl/hash/internal/hash.h
@@ -43,6 +43,7 @@ #include "absl/container/fixed_array.h" #include "absl/meta/type_traits.h" #include "absl/numeric/int128.h" +#include "absl/strings/cord.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "absl/types/variant.h" @@ -50,8 +51,15 @@ #include "absl/hash/internal/city.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace hash_internal { +class PiecewiseCombiner; + +// Internal detail: Large buffers are hashed in smaller chunks. This function +// returns the size of these chunks. +constexpr size_t PiecewiseChunkSize() { return 1024; } + // HashStateBase // // A hash state object represents an intermediate state in the computation @@ -68,7 +76,7 @@ // // `static H combine_contiguous(H state, const unsigned char*, size_t)`. // -// `HashStateBase` will provide a complete implementations for a hash state +// `HashStateBase` will provide a complete implementation for a hash state // object in terms of this method. // // Example: @@ -117,6 +125,9 @@ // for-loop instead. template <typename T> static H combine_contiguous(H state, const T* data, size_t size); + + private: + friend class PiecewiseCombiner; }; // is_uniquely_represented @@ -187,6 +198,61 @@ return H::combine_contiguous(std::move(hash_state), start, sizeof(value)); } +// PiecewiseCombiner +// +// PiecewiseCombiner is an internal-only helper class for hashing a piecewise +// buffer of `char` or `unsigned char` as though it were contiguous. This class +// provides two methods: +// +// H add_buffer(state, data, size) +// H finalize(state) +// +// `add_buffer` can be called zero or more times, followed by a single call to +// `finalize`. This will produce the same hash expansion as concatenating each +// buffer piece into a single contiguous buffer, and passing this to +// `H::combine_contiguous`. +// +// Example usage: +// PiecewiseCombiner combiner; +// for (const auto& piece : pieces) { +// state = combiner.add_buffer(std::move(state), piece.data, piece.size); +// } +// return combiner.finalize(std::move(state)); +class PiecewiseCombiner { + public: + PiecewiseCombiner() : position_(0) {} + PiecewiseCombiner(const PiecewiseCombiner&) = delete; + PiecewiseCombiner& operator=(const PiecewiseCombiner&) = delete; + + // PiecewiseCombiner::add_buffer() + // + // Appends the given range of bytes to the sequence to be hashed, which may + // modify the provided hash state. + template <typename H> + H add_buffer(H state, const unsigned char* data, size_t size); + template <typename H> + H add_buffer(H state, const char* data, size_t size) { + return add_buffer(std::move(state), + reinterpret_cast<const unsigned char*>(data), size); + } + + // PiecewiseCombiner::finalize() + // + // Finishes combining the hash sequence, which may may modify the provided + // hash state. + // + // Once finalize() is called, add_buffer() may no longer be called. The + // resulting hash state will be the same as if the pieces passed to + // add_buffer() were concatenated into a single flat buffer, and then provided + // to H::combine_contiguous(). + template <typename H> + H finalize(H state); + + private: + unsigned char buf_[PiecewiseChunkSize()]; + size_t position_; +}; + // ----------------------------------------------------------------------------- // AbslHashValue for Basic Types // ----------------------------------------------------------------------------- @@ -348,6 +414,7 @@ // All the string-like types supported here provide the same hash expansion for // the same character sequence. These types are: // +// - `absl::Cord` // - `std::string` (and std::basic_string<char, std::char_traits<char>, A> for // any allocator A) // - `absl::string_view` and `std::string_view` @@ -363,6 +430,38 @@ str.size()); } +// Support std::wstring, std::u16string and std::u32string. +template <typename Char, typename Alloc, typename H, + typename = absl::enable_if_t<std::is_same<Char, wchar_t>::value || + std::is_same<Char, char16_t>::value || + std::is_same<Char, char32_t>::value>> +H AbslHashValue( + H hash_state, + const std::basic_string<Char, std::char_traits<Char>, Alloc>& str) { + return H::combine( + H::combine_contiguous(std::move(hash_state), str.data(), str.size()), + str.size()); +} + +template <typename H> +H HashFragmentedCord(H hash_state, const absl::Cord& c) { + PiecewiseCombiner combiner; + c.ForEachChunk([&combiner, &hash_state](absl::string_view chunk) { + hash_state = + combiner.add_buffer(std::move(hash_state), chunk.data(), chunk.size()); + }); + return H::combine(combiner.finalize(std::move(hash_state)), c.size()); +} + +template <typename H> +H AbslHashValue(H hash_state, const absl::Cord& c) { + absl::optional<absl::string_view> maybe_flat = c.TryFlat(); + if (maybe_flat.has_value()) { + return H::combine(std::move(hash_state), *maybe_flat); + } + return hash_internal::HashFragmentedCord(std::move(hash_state), c); +} + // ----------------------------------------------------------------------------- // AbslHashValue for Sequence Containers // ----------------------------------------------------------------------------- @@ -630,7 +729,8 @@ : std::integral_constant<bool, HashSelect::template Apply<T>::value> {}; // CityHashState -class CityHashState : public HashStateBase<CityHashState> { +class ABSL_DLL CityHashState + : public HashStateBase<CityHashState> { // absl::uint128 is not an alias or a thin wrapper around the intrinsic. // We use the intrinsic when available to improve performance. #ifdef ABSL_HAVE_INTRINSIC_INT128 @@ -709,6 +809,16 @@ std::integral_constant<int, 8> /* sizeof_size_t*/); + // Slow dispatch path for calls to CombineContiguousImpl with a size argument + // larger than PiecewiseChunkSize(). Has the same effect as calling + // CombineContiguousImpl() repeatedly with the chunk stride size. + static uint64_t CombineLargeContiguousImpl32(uint64_t state, + const unsigned char* first, + size_t len); + static uint64_t CombineLargeContiguousImpl64(uint64_t state, + const unsigned char* first, + size_t len); + // Reads 9 to 16 bytes from p. // The first 8 bytes are in .first, the rest (zero padded) bytes are in // .second. @@ -776,6 +886,9 @@ // multiplicative hash. uint64_t v; if (len > 8) { + if (ABSL_PREDICT_FALSE(len > PiecewiseChunkSize())) { + return CombineLargeContiguousImpl32(state, first, len); + } v = absl::hash_internal::CityHash32(reinterpret_cast<const char*>(first), len); } else if (len >= 4) { v = Read4To8(first, len); @@ -796,6 +909,9 @@ // multiplicative hash. uint64_t v; if (len > 16) { + if (ABSL_PREDICT_FALSE(len > PiecewiseChunkSize())) { + return CombineLargeContiguousImpl64(state, first, len); + } v = absl::hash_internal::CityHash64(reinterpret_cast<const char*>(first), len); } else if (len > 8) { auto p = Read9To16(first, len); @@ -812,7 +928,6 @@ return Mix(state, v); } - struct AggregateBarrier {}; // HashImpl @@ -849,7 +964,49 @@ H HashStateBase<H>::combine_contiguous(H state, const T* data, size_t size) { return hash_internal::hash_range_or_bytes(std::move(state), data, size); } + +// HashStateBase::PiecewiseCombiner::add_buffer() +template <typename H> +H PiecewiseCombiner::add_buffer(H state, const unsigned char* data, + size_t size) { + if (position_ + size < PiecewiseChunkSize()) { + // This partial chunk does not fill our existing buffer + memcpy(buf_ + position_, data, size); + position_ += size; + return state; + } + + // If the buffer is partially filled we need to complete the buffer + // and hash it. + if (position_ != 0) { + const size_t bytes_needed = PiecewiseChunkSize() - position_; + memcpy(buf_ + position_, data, bytes_needed); + state = H::combine_contiguous(std::move(state), buf_, PiecewiseChunkSize()); + data += bytes_needed; + size -= bytes_needed; + } + + // Hash whatever chunks we can without copying + while (size >= PiecewiseChunkSize()) { + state = H::combine_contiguous(std::move(state), data, PiecewiseChunkSize()); + data += PiecewiseChunkSize(); + size -= PiecewiseChunkSize(); + } + // Fill the buffer with the remainder + memcpy(buf_, data, size); + position_ = size; + return state; +} + +// HashStateBase::PiecewiseCombiner::finalize() +template <typename H> +H PiecewiseCombiner::finalize(H state) { + // Hash the remainder left in the buffer, which may be empty + return H::combine_contiguous(std::move(state), buf_, position_); +} + } // namespace hash_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_HASH_INTERNAL_HASH_H_
diff --git a/third_party/abseil-cpp/absl/hash/internal/spy_hash_state.h b/third_party/abseil-cpp/absl/hash/internal/spy_hash_state.h index c4cc8d07..c083120 100644 --- a/third_party/abseil-cpp/absl/hash/internal/spy_hash_state.h +++ b/third_party/abseil-cpp/absl/hash/internal/spy_hash_state.h
@@ -25,6 +25,7 @@ #include "absl/strings/str_join.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace hash_internal { // SpyHashState is an implementation of the HashState API that simply @@ -146,6 +147,19 @@ static SpyHashStateImpl combine_contiguous(SpyHashStateImpl hash_state, const unsigned char* begin, size_t size) { + const size_t large_chunk_stride = PiecewiseChunkSize(); + if (size > large_chunk_stride) { + // Combining a large contiguous buffer must have the same effect as + // doing it piecewise by the stride length, followed by the (possibly + // empty) remainder. + while (size >= large_chunk_stride) { + hash_state = SpyHashStateImpl::combine_contiguous( + std::move(hash_state), begin, large_chunk_stride); + begin += large_chunk_stride; + size -= large_chunk_stride; + } + } + hash_state.hash_representation_.emplace_back( reinterpret_cast<const char*>(begin), size); return hash_state; @@ -211,6 +225,7 @@ using SpyHashState = SpyHashStateImpl<void>; } // namespace hash_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_HASH_INTERNAL_SPY_HASH_STATE_H_
diff --git a/third_party/abseil-cpp/absl/memory/BUILD.bazel b/third_party/abseil-cpp/absl/memory/BUILD.bazel index f815ef9..2ba9d7cb 100644 --- a/third_party/abseil-cpp/absl/memory/BUILD.bazel +++ b/third_party/abseil-cpp/absl/memory/BUILD.bazel
@@ -1,5 +1,5 @@ # -# Copyright 2017 The Abseil Authors. +# Copyright 2019 The Abseil Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,13 +14,12 @@ # limitations under the License. # +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", "ABSL_DEFAULT_LINKOPTS", "ABSL_TEST_COPTS", - "ABSL_EXCEPTIONS_FLAG", - "ABSL_EXCEPTIONS_FLAG_LINKOPTS", ) package(default_visibility = ["//visibility:public"]) @@ -45,7 +44,6 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":memory", - "//absl/base", "//absl/base:core_headers", "@com_google_googletest//:gtest_main", ], @@ -56,10 +54,11 @@ srcs = [ "memory_exception_safety_test.cc", ], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":memory", + "//absl/base:config", "//absl/base:exception_safety_testing", "@com_google_googletest//:gtest_main", ],
diff --git a/third_party/abseil-cpp/absl/memory/CMakeLists.txt b/third_party/abseil-cpp/absl/memory/CMakeLists.txt index 0a81220..78fb7e1 100644 --- a/third_party/abseil-cpp/absl/memory/CMakeLists.txt +++ b/third_party/abseil-cpp/absl/memory/CMakeLists.txt
@@ -36,7 +36,6 @@ ${ABSL_TEST_COPTS} DEPS absl::memory - absl::base absl::core_headers gmock_main ) @@ -48,11 +47,9 @@ "memory_exception_safety_test.cc" COPTS ${ABSL_TEST_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS absl::memory + absl::config absl::exception_safety_testing gmock_main )
diff --git a/third_party/abseil-cpp/absl/memory/memory.h b/third_party/abseil-cpp/absl/memory/memory.h index 5a4a1a1..513f710 100644 --- a/third_party/abseil-cpp/absl/memory/memory.h +++ b/third_party/abseil-cpp/absl/memory/memory.h
@@ -34,6 +34,7 @@ #include "absl/meta/type_traits.h" namespace absl { +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // Function Template: WrapUnique() @@ -92,11 +93,12 @@ } // namespace memory_internal -// gcc 4.8 has __cplusplus at 201301 but doesn't define make_unique. Other -// supported compilers either just define __cplusplus as 201103 but have -// make_unique (msvc), or have make_unique whenever __cplusplus > 201103 (clang) +// gcc 4.8 has __cplusplus at 201301 but the libstdc++ shipped with it doesn't +// define make_unique. Other supported compilers either just define __cplusplus +// as 201103 but have make_unique (msvc), or have make_unique whenever +// __cplusplus > 201103 (clang). #if (__cplusplus > 201103L || defined(_MSC_VER)) && \ - !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 8) + !(defined(__GLIBCXX__) && !defined(__cpp_lib_make_unique)) using std::make_unique; #else // ----------------------------------------------------------------------------- @@ -687,6 +689,7 @@ } } } // namespace memory_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_MEMORY_MEMORY_H_
diff --git a/third_party/abseil-cpp/absl/memory/memory_exception_safety_test.cc b/third_party/abseil-cpp/absl/memory/memory_exception_safety_test.cc index a1c3970..1df7261 100644 --- a/third_party/abseil-cpp/absl/memory/memory_exception_safety_test.cc +++ b/third_party/abseil-cpp/absl/memory/memory_exception_safety_test.cc
@@ -14,17 +14,19 @@ #include "absl/memory/memory.h" +#include "absl/base/config.h" + +#ifdef ABSL_HAVE_EXCEPTIONS + #include "gtest/gtest.h" #include "absl/base/internal/exception_safety_testing.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { constexpr int kLength = 50; using Thrower = testing::ThrowingValue<testing::TypeSpec::kEverythingThrows>; -using ThrowerStorage = - absl::aligned_storage_t<sizeof(Thrower), alignof(Thrower)>; -using ThrowerList = std::array<ThrowerStorage, kLength>; TEST(MakeUnique, CheckForLeaks) { constexpr int kValue = 321; @@ -49,4 +51,7 @@ } } // namespace +ABSL_NAMESPACE_END } // namespace absl + +#endif // ABSL_HAVE_EXCEPTIONS
diff --git a/third_party/abseil-cpp/absl/meta/BUILD.bazel b/third_party/abseil-cpp/absl/meta/BUILD.bazel index e004b50..c06d2d9 100644 --- a/third_party/abseil-cpp/absl/meta/BUILD.bazel +++ b/third_party/abseil-cpp/absl/meta/BUILD.bazel
@@ -1,3 +1,20 @@ +# +# Copyright 2019 The Abseil Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS",
diff --git a/third_party/abseil-cpp/absl/meta/type_traits.h b/third_party/abseil-cpp/absl/meta/type_traits.h index 927244e..ba87d2f 100644 --- a/third_party/abseil-cpp/absl/meta/type_traits.h +++ b/third_party/abseil-cpp/absl/meta/type_traits.h
@@ -41,7 +41,18 @@ #include "absl/base/config.h" +// MSVC constructibility traits do not detect destructor properties and so our +// implementations should not use them as a source-of-truth. +#if defined(_MSC_VER) && !defined(__clang__) && !defined(__GNUC__) +#define ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION 1 +#endif + namespace absl { +ABSL_NAMESPACE_BEGIN + +// Defined and documented later on in this file. +template <typename T> +struct is_trivially_destructible; // Defined and documented later on in this file. template <typename T> @@ -66,6 +77,20 @@ #endif // defined(_MSC_VER) && !defined(__GNUC__) template <class T> +struct IsTriviallyMoveConstructibleObject + : std::integral_constant< + bool, std::is_move_constructible< + type_traits_internal::SingleMemberUnion<T>>::value && + absl::is_trivially_destructible<T>::value> {}; + +template <class T> +struct IsTriviallyCopyConstructibleObject + : std::integral_constant< + bool, std::is_copy_constructible< + type_traits_internal::SingleMemberUnion<T>>::value && + absl::is_trivially_destructible<T>::value> {}; + +template <class T> struct IsTriviallyMoveAssignableReference : std::false_type {}; template <class T> @@ -145,6 +170,18 @@ } // namespace type_traits_internal +// MSVC 19.20 has a regression that causes our workarounds to fail, but their +// std forms now appear to be compliant. +#if defined(_MSC_VER) && !defined(__clang__) && (_MSC_VER >= 1920) + +template <typename T> +using is_copy_assignable = std::is_copy_assignable<T>; + +template <typename T> +using is_move_assignable = std::is_move_assignable<T>; + +#else + template <typename T> struct is_copy_assignable : type_traits_internal::is_detected< type_traits_internal::IsCopyAssignableImpl, T> { @@ -155,6 +192,8 @@ type_traits_internal::IsMoveAssignableImpl, T> { }; +#endif + // void_t() // // Ignores the type of any its arguments and returns `void`. In general, this @@ -243,7 +282,7 @@ // is_trivially_destructible() // -// Determines whether the passed type `T` is trivially destructable. +// Determines whether the passed type `T` is trivially destructible. // // This metafunction is designed to be a drop-in replacement for the C++11 // `std::is_trivially_destructible()` metafunction for platforms that have @@ -309,7 +348,9 @@ : std::integral_constant<bool, __has_trivial_constructor(T) && std::is_default_constructible<T>::value && is_trivially_destructible<T>::value> { -#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE +#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \ + !defined( \ + ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION) private: static constexpr bool compliant = std::is_trivially_default_constructible<T>::value == @@ -340,10 +381,11 @@ struct is_trivially_move_constructible : std::conditional< std::is_object<T>::value && !std::is_array<T>::value, - std::is_move_constructible< - type_traits_internal::SingleMemberUnion<T>>, + type_traits_internal::IsTriviallyMoveConstructibleObject<T>, std::is_reference<T>>::type::type { -#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE +#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \ + !defined( \ + ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION) private: static constexpr bool compliant = std::is_trivially_move_constructible<T>::value == @@ -374,10 +416,11 @@ struct is_trivially_copy_constructible : std::conditional< std::is_object<T>::value && !std::is_array<T>::value, - std::is_copy_constructible< - type_traits_internal::SingleMemberUnion<T>>, + type_traits_internal::IsTriviallyCopyConstructibleObject<T>, std::is_lvalue_reference<T>>::type::type { -#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE +#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \ + !defined( \ + ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION) private: static constexpr bool compliant = std::is_trivially_copy_constructible<T>::value == @@ -409,7 +452,8 @@ template <typename T> struct is_trivially_move_assignable : std::conditional< - std::is_object<T>::value && !std::is_array<T>::value, + std::is_object<T>::value && !std::is_array<T>::value && + std::is_move_assignable<T>::value, std::is_move_assignable<type_traits_internal::SingleMemberUnion<T>>, type_traits_internal::IsTriviallyMoveAssignableReference<T>>::type:: type { @@ -709,6 +753,7 @@ using swap_internal::StdSwapIsUnconstrained; } // namespace type_traits_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_META_TYPE_TRAITS_H_
diff --git a/third_party/abseil-cpp/absl/meta/type_traits_test.cc b/third_party/abseil-cpp/absl/meta/type_traits_test.cc index a7a9c5c..1aafd0d4 100644 --- a/third_party/abseil-cpp/absl/meta/type_traits_test.cc +++ b/third_party/abseil-cpp/absl/meta/type_traits_test.cc
@@ -347,21 +347,6 @@ virtual ~Base() {} }; -// In GCC/Clang, std::is_trivially_constructible requires that the destructor is -// trivial. However, MSVC doesn't require that. This results in different -// behavior when checking is_trivially_constructible on any type with -// nontrivial destructor. Since absl::is_trivially_default_constructible and -// absl::is_trivially_copy_constructible both follows Clang/GCC's interpretation -// and check is_trivially_destructible, it results in inconsistency with -// std::is_trivially_xxx_constructible on MSVC. This macro is used to work -// around this issue in test. In practice, a trivially constructible type -// should also be trivially destructible. -// GCC bug 51452: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51452 -// LWG issue 2116: http://cplusplus.github.io/LWG/lwg-active.html#2116 -#ifndef _MSC_VER -#define ABSL_TRIVIALLY_CONSTRUCTIBLE_VERIFY_TRIVIALLY_DESTRUCTIBLE 1 -#endif - // Old versions of libc++, around Clang 3.5 to 3.6, consider deleted destructors // as also being trivial. With the resolution of CWG 1928 and CWG 1734, this // is no longer considered true and has thus been amended. @@ -499,11 +484,9 @@ EXPECT_FALSE( absl::is_trivially_default_constructible<DeletedDefaultCtor>::value); -#ifdef ABSL_TRIVIALLY_CONSTRUCTIBLE_VERIFY_TRIVIALLY_DESTRUCTIBLE // types with nontrivial destructor are nontrivial EXPECT_FALSE( absl::is_trivially_default_constructible<NontrivialDestructor>::value); -#endif // types with vtables EXPECT_FALSE(absl::is_trivially_default_constructible<Base>::value); @@ -546,6 +529,28 @@ #endif } +// GCC prior to 7.4 had a bug in its trivially-constructible traits +// (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80654). +// This test makes sure that we do not depend on the trait in these cases when +// implementing absl triviality traits. + +template <class T> +struct BadConstructors { + BadConstructors() { static_assert(T::value, ""); } + + BadConstructors(BadConstructors&&) { static_assert(T::value, ""); } + + BadConstructors(const BadConstructors&) { static_assert(T::value, ""); } +}; + +TEST(TypeTraitsTest, TestTrivialityBadConstructors) { + using BadType = BadConstructors<int>; + + EXPECT_FALSE(absl::is_trivially_default_constructible<BadType>::value); + EXPECT_FALSE(absl::is_trivially_move_constructible<BadType>::value); + EXPECT_FALSE(absl::is_trivially_copy_constructible<BadType>::value); +} + TEST(TypeTraitsTest, TestTrivialMoveCtor) { // Verify that arithmetic types and pointers have trivial move // constructors. @@ -585,11 +590,9 @@ EXPECT_FALSE( absl::is_trivially_move_constructible<NonCopyableOrMovable>::value); -#ifdef ABSL_TRIVIALLY_CONSTRUCTIBLE_VERIFY_TRIVIALLY_DESTRUCTIBLE // type with nontrivial destructor are nontrivial move construbtible EXPECT_FALSE( absl::is_trivially_move_constructible<NontrivialDestructor>::value); -#endif // types with vtables EXPECT_FALSE(absl::is_trivially_move_constructible<Base>::value); @@ -660,11 +663,9 @@ EXPECT_FALSE( absl::is_trivially_copy_constructible<NonCopyableOrMovable>::value); -#ifdef ABSL_TRIVIALLY_CONSTRUCTIBLE_VERIFY_TRIVIALLY_DESTRUCTIBLE // type with nontrivial destructor are nontrivial copy construbtible EXPECT_FALSE( absl::is_trivially_copy_constructible<NontrivialDestructor>::value); -#endif // types with vtables EXPECT_FALSE(absl::is_trivially_copy_constructible<Base>::value);
diff --git a/third_party/abseil-cpp/absl/numeric/BUILD.bazel b/third_party/abseil-cpp/absl/numeric/BUILD.bazel index d9b561d..e09e52d 100644 --- a/third_party/abseil-cpp/absl/numeric/BUILD.bazel +++ b/third_party/abseil-cpp/absl/numeric/BUILD.bazel
@@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS",
diff --git a/third_party/abseil-cpp/absl/numeric/int128.cc b/third_party/abseil-cpp/absl/numeric/int128.cc index 93b62c52..b605a87 100644 --- a/third_party/abseil-cpp/absl/numeric/int128.cc +++ b/third_party/abseil-cpp/absl/numeric/int128.cc
@@ -23,9 +23,10 @@ #include <type_traits> namespace absl { +ABSL_NAMESPACE_BEGIN -const uint128 kuint128max = MakeUint128(std::numeric_limits<uint64_t>::max(), - std::numeric_limits<uint64_t>::max()); +ABSL_DLL const uint128 kuint128max = MakeUint128( + std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::max()); namespace { @@ -244,6 +245,112 @@ return os << rep; } +namespace { + +uint128 UnsignedAbsoluteValue(int128 v) { + // Cast to uint128 before possibly negating because -Int128Min() is undefined. + return Int128High64(v) < 0 ? -uint128(v) : uint128(v); +} + +} // namespace + +#if !defined(ABSL_HAVE_INTRINSIC_INT128) +namespace { + +template <typename T> +int128 MakeInt128FromFloat(T v) { + // Conversion when v is NaN or cannot fit into int128 would be undefined + // behavior if using an intrinsic 128-bit integer. + assert(std::isfinite(v) && (std::numeric_limits<T>::max_exponent <= 127 || + (v >= -std::ldexp(static_cast<T>(1), 127) && + v < std::ldexp(static_cast<T>(1), 127)))); + + // We must convert the absolute value and then negate as needed, because + // floating point types are typically sign-magnitude. Otherwise, the + // difference between the high and low 64 bits when interpreted as two's + // complement overwhelms the precision of the mantissa. + uint128 result = v < 0 ? -MakeUint128FromFloat(-v) : MakeUint128FromFloat(v); + return MakeInt128(int128_internal::BitCastToSigned(Uint128High64(result)), + Uint128Low64(result)); +} + +} // namespace + +int128::int128(float v) : int128(MakeInt128FromFloat(v)) {} +int128::int128(double v) : int128(MakeInt128FromFloat(v)) {} +int128::int128(long double v) : int128(MakeInt128FromFloat(v)) {} + +int128 operator/(int128 lhs, int128 rhs) { + assert(lhs != Int128Min() || rhs != -1); // UB on two's complement. + + uint128 quotient = 0; + uint128 remainder = 0; + DivModImpl(UnsignedAbsoluteValue(lhs), UnsignedAbsoluteValue(rhs), + "ient, &remainder); + if ((Int128High64(lhs) < 0) != (Int128High64(rhs) < 0)) quotient = -quotient; + return MakeInt128(int128_internal::BitCastToSigned(Uint128High64(quotient)), + Uint128Low64(quotient)); +} + +int128 operator%(int128 lhs, int128 rhs) { + assert(lhs != Int128Min() || rhs != -1); // UB on two's complement. + + uint128 quotient = 0; + uint128 remainder = 0; + DivModImpl(UnsignedAbsoluteValue(lhs), UnsignedAbsoluteValue(rhs), + "ient, &remainder); + if (Int128High64(lhs) < 0) remainder = -remainder; + return MakeInt128(int128_internal::BitCastToSigned(Uint128High64(remainder)), + Uint128Low64(remainder)); +} +#endif // ABSL_HAVE_INTRINSIC_INT128 + +std::ostream& operator<<(std::ostream& os, int128 v) { + std::ios_base::fmtflags flags = os.flags(); + std::string rep; + + // Add the sign if needed. + bool print_as_decimal = + (flags & std::ios::basefield) == std::ios::dec || + (flags & std::ios::basefield) == std::ios_base::fmtflags(); + if (print_as_decimal) { + if (Int128High64(v) < 0) { + rep = "-"; + } else if (flags & std::ios::showpos) { + rep = "+"; + } + } + + rep.append(Uint128ToFormattedString( + print_as_decimal ? UnsignedAbsoluteValue(v) : uint128(v), os.flags())); + + // Add the requisite padding. + std::streamsize width = os.width(0); + if (static_cast<size_t>(width) > rep.size()) { + switch (flags & std::ios::adjustfield) { + case std::ios::left: + rep.append(width - rep.size(), os.fill()); + break; + case std::ios::internal: + if (print_as_decimal && (rep[0] == '+' || rep[0] == '-')) { + rep.insert(1, width - rep.size(), os.fill()); + } else if ((flags & std::ios::basefield) == std::ios::hex && + (flags & std::ios::showbase) && v != 0) { + rep.insert(2, width - rep.size(), os.fill()); + } else { + rep.insert(0, width - rep.size(), os.fill()); + } + break; + default: // std::ios::right + rep.insert(0, width - rep.size(), os.fill()); + break; + } + } + + return os << rep; +} + +ABSL_NAMESPACE_END } // namespace absl namespace std { @@ -270,4 +377,28 @@ constexpr int numeric_limits<absl::uint128>::max_exponent10; constexpr bool numeric_limits<absl::uint128>::traps; constexpr bool numeric_limits<absl::uint128>::tinyness_before; + +constexpr bool numeric_limits<absl::int128>::is_specialized; +constexpr bool numeric_limits<absl::int128>::is_signed; +constexpr bool numeric_limits<absl::int128>::is_integer; +constexpr bool numeric_limits<absl::int128>::is_exact; +constexpr bool numeric_limits<absl::int128>::has_infinity; +constexpr bool numeric_limits<absl::int128>::has_quiet_NaN; +constexpr bool numeric_limits<absl::int128>::has_signaling_NaN; +constexpr float_denorm_style numeric_limits<absl::int128>::has_denorm; +constexpr bool numeric_limits<absl::int128>::has_denorm_loss; +constexpr float_round_style numeric_limits<absl::int128>::round_style; +constexpr bool numeric_limits<absl::int128>::is_iec559; +constexpr bool numeric_limits<absl::int128>::is_bounded; +constexpr bool numeric_limits<absl::int128>::is_modulo; +constexpr int numeric_limits<absl::int128>::digits; +constexpr int numeric_limits<absl::int128>::digits10; +constexpr int numeric_limits<absl::int128>::max_digits10; +constexpr int numeric_limits<absl::int128>::radix; +constexpr int numeric_limits<absl::int128>::min_exponent; +constexpr int numeric_limits<absl::int128>::min_exponent10; +constexpr int numeric_limits<absl::int128>::max_exponent; +constexpr int numeric_limits<absl::int128>::max_exponent10; +constexpr bool numeric_limits<absl::int128>::traps; +constexpr bool numeric_limits<absl::int128>::tinyness_before; } // namespace std
diff --git a/third_party/abseil-cpp/absl/numeric/int128.h b/third_party/abseil-cpp/absl/numeric/int128.h index 10be8ec..0dd814a 100644 --- a/third_party/abseil-cpp/absl/numeric/int128.h +++ b/third_party/abseil-cpp/absl/numeric/int128.h
@@ -17,10 +17,7 @@ // File: int128.h // ----------------------------------------------------------------------------- // -// This header file defines 128-bit integer types. -// -// Currently, this file defines `uint128`, an unsigned 128-bit integer; -// a signed 128-bit integer is forthcoming. +// This header file defines 128-bit integer types, `uint128` and `int128`. #ifndef ABSL_NUMERIC_INT128_H_ #define ABSL_NUMERIC_INT128_H_ @@ -52,6 +49,9 @@ #endif // defined(_MSC_VER) namespace absl { +ABSL_NAMESPACE_BEGIN + +class int128; // uint128 // @@ -116,6 +116,7 @@ constexpr uint128(__int128 v); // NOLINT(runtime/explicit) constexpr uint128(unsigned __int128 v); // NOLINT(runtime/explicit) #endif // ABSL_HAVE_INTRINSIC_INT128 + constexpr uint128(int128 v); // NOLINT(runtime/explicit) explicit uint128(float v); explicit uint128(double v); explicit uint128(long double v); @@ -131,6 +132,7 @@ uint128& operator=(__int128 v); uint128& operator=(unsigned __int128 v); #endif // ABSL_HAVE_INTRINSIC_INT128 + uint128& operator=(int128 v); // Conversion operators to other arithmetic types constexpr explicit operator bool() const; @@ -232,7 +234,7 @@ // Prefer to use the constexpr `Uint128Max()`. // // TODO(absl-team) deprecate kuint128max once migration tool is released. -extern const uint128 kuint128max; +ABSL_DLL extern const uint128 kuint128max; // allow uint128 to be logged std::ostream& operator<<(std::ostream& os, uint128 v); @@ -244,6 +246,7 @@ (std::numeric_limits<uint64_t>::max)()); } +ABSL_NAMESPACE_END } // namespace absl // Specialized numeric_limits for uint128. @@ -291,12 +294,246 @@ }; } // namespace std -// TODO(absl-team): Implement signed 128-bit type +namespace absl { +ABSL_NAMESPACE_BEGIN + +// int128 +// +// A signed 128-bit integer type. The API is meant to mimic an intrinsic +// integral type as closely as is practical, including exhibiting undefined +// behavior in analogous cases (e.g. division by zero). +// +// An `int128` supports the following: +// +// * Implicit construction from integral types +// * Explicit conversion to integral types +// +// However, an `int128` differs from intrinsic integral types in the following +// ways: +// +// * It is not implicitly convertible to other integral types. +// * Requires explicit construction from and conversion to floating point +// types. + +// Additionally, if your compiler supports `__int128`, `int128` is +// interoperable with that type. (Abseil checks for this compatibility through +// the `ABSL_HAVE_INTRINSIC_INT128` macro.) +// +// The design goal for `int128` is that it will be compatible with a future +// `int128_t`, if that type becomes a part of the standard. +// +// Example: +// +// float y = absl::int128(17); // Error. int128 cannot be implicitly +// // converted to float. +// +// absl::int128 v; +// int64_t i = v; // Error +// int64_t i = static_cast<int64_t>(v); // OK +// +class int128 { + public: + int128() = default; + + // Constructors from arithmetic types + constexpr int128(int v); // NOLINT(runtime/explicit) + constexpr int128(unsigned int v); // NOLINT(runtime/explicit) + constexpr int128(long v); // NOLINT(runtime/int) + constexpr int128(unsigned long v); // NOLINT(runtime/int) + constexpr int128(long long v); // NOLINT(runtime/int) + constexpr int128(unsigned long long v); // NOLINT(runtime/int) +#ifdef ABSL_HAVE_INTRINSIC_INT128 + constexpr int128(__int128 v); // NOLINT(runtime/explicit) + constexpr explicit int128(unsigned __int128 v); +#endif // ABSL_HAVE_INTRINSIC_INT128 + constexpr explicit int128(uint128 v); + explicit int128(float v); + explicit int128(double v); + explicit int128(long double v); + + // Assignment operators from arithmetic types + int128& operator=(int v); + int128& operator=(unsigned int v); + int128& operator=(long v); // NOLINT(runtime/int) + int128& operator=(unsigned long v); // NOLINT(runtime/int) + int128& operator=(long long v); // NOLINT(runtime/int) + int128& operator=(unsigned long long v); // NOLINT(runtime/int) +#ifdef ABSL_HAVE_INTRINSIC_INT128 + int128& operator=(__int128 v); +#endif // ABSL_HAVE_INTRINSIC_INT128 + + // Conversion operators to other arithmetic types + constexpr explicit operator bool() const; + constexpr explicit operator char() const; + constexpr explicit operator signed char() const; + constexpr explicit operator unsigned char() const; + constexpr explicit operator char16_t() const; + constexpr explicit operator char32_t() const; + constexpr explicit operator ABSL_INTERNAL_WCHAR_T() const; + constexpr explicit operator short() const; // NOLINT(runtime/int) + // NOLINTNEXTLINE(runtime/int) + constexpr explicit operator unsigned short() const; + constexpr explicit operator int() const; + constexpr explicit operator unsigned int() const; + constexpr explicit operator long() const; // NOLINT(runtime/int) + // NOLINTNEXTLINE(runtime/int) + constexpr explicit operator unsigned long() const; + // NOLINTNEXTLINE(runtime/int) + constexpr explicit operator long long() const; + // NOLINTNEXTLINE(runtime/int) + constexpr explicit operator unsigned long long() const; +#ifdef ABSL_HAVE_INTRINSIC_INT128 + constexpr explicit operator __int128() const; + constexpr explicit operator unsigned __int128() const; +#endif // ABSL_HAVE_INTRINSIC_INT128 + explicit operator float() const; + explicit operator double() const; + explicit operator long double() const; + + // Trivial copy constructor, assignment operator and destructor. + + // Arithmetic operators + int128& operator+=(int128 other); + int128& operator-=(int128 other); + int128& operator*=(int128 other); + int128& operator/=(int128 other); + int128& operator%=(int128 other); + int128 operator++(int); // postfix increment: i++ + int128 operator--(int); // postfix decrement: i-- + int128& operator++(); // prefix increment: ++i + int128& operator--(); // prefix decrement: --i + int128& operator&=(int128 other); + int128& operator|=(int128 other); + int128& operator^=(int128 other); + int128& operator<<=(int amount); + int128& operator>>=(int amount); + + // Int128Low64() + // + // Returns the lower 64-bit value of a `int128` value. + friend constexpr uint64_t Int128Low64(int128 v); + + // Int128High64() + // + // Returns the higher 64-bit value of a `int128` value. + friend constexpr int64_t Int128High64(int128 v); + + // MakeInt128() + // + // Constructs a `int128` numeric value from two 64-bit integers. Note that + // signedness is conveyed in the upper `high` value. + // + // (absl::int128(1) << 64) * high + low + // + // Note that this factory function is the only way to construct a `int128` + // from integer values greater than 2^64 or less than -2^64. + // + // Example: + // + // absl::int128 big = absl::MakeInt128(1, 0); + // absl::int128 big_n = absl::MakeInt128(-1, 0); + friend constexpr int128 MakeInt128(int64_t high, uint64_t low); + + // Int128Max() + // + // Returns the maximum value for a 128-bit signed integer. + friend constexpr int128 Int128Max(); + + // Int128Min() + // + // Returns the minimum value for a 128-bit signed integer. + friend constexpr int128 Int128Min(); + + // Support for absl::Hash. + template <typename H> + friend H AbslHashValue(H h, int128 v) { + return H::combine(std::move(h), Int128High64(v), Int128Low64(v)); + } + + private: + constexpr int128(int64_t high, uint64_t low); + +#if defined(ABSL_HAVE_INTRINSIC_INT128) + __int128 v_; +#else // ABSL_HAVE_INTRINSIC_INT128 +#if defined(ABSL_IS_LITTLE_ENDIAN) + uint64_t lo_; + int64_t hi_; +#elif defined(ABSL_IS_BIG_ENDIAN) + int64_t hi_; + uint64_t lo_; +#else // byte order +#error "Unsupported byte order: must be little-endian or big-endian." +#endif // byte order +#endif // ABSL_HAVE_INTRINSIC_INT128 +}; + +std::ostream& operator<<(std::ostream& os, int128 v); + +// TODO(absl-team) add operator>>(std::istream&, int128) + +constexpr int128 Int128Max() { + return int128((std::numeric_limits<int64_t>::max)(), + (std::numeric_limits<uint64_t>::max)()); +} + +constexpr int128 Int128Min() { + return int128((std::numeric_limits<int64_t>::min)(), 0); +} + +ABSL_NAMESPACE_END +} // namespace absl + +// Specialized numeric_limits for int128. +namespace std { +template <> +class numeric_limits<absl::int128> { + public: + static constexpr bool is_specialized = true; + static constexpr bool is_signed = true; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_NaN = false; + static constexpr bool has_signaling_NaN = false; + static constexpr float_denorm_style has_denorm = denorm_absent; + static constexpr bool has_denorm_loss = false; + static constexpr float_round_style round_style = round_toward_zero; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = false; + static constexpr int digits = 127; + static constexpr int digits10 = 38; + static constexpr int max_digits10 = 0; + static constexpr int radix = 2; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; +#ifdef ABSL_HAVE_INTRINSIC_INT128 + static constexpr bool traps = numeric_limits<__int128>::traps; +#else // ABSL_HAVE_INTRINSIC_INT128 + static constexpr bool traps = numeric_limits<uint64_t>::traps; +#endif // ABSL_HAVE_INTRINSIC_INT128 + static constexpr bool tinyness_before = false; + + static constexpr absl::int128 (min)() { return absl::Int128Min(); } + static constexpr absl::int128 lowest() { return absl::Int128Min(); } + static constexpr absl::int128 (max)() { return absl::Int128Max(); } + static constexpr absl::int128 epsilon() { return 0; } + static constexpr absl::int128 round_error() { return 0; } + static constexpr absl::int128 infinity() { return 0; } + static constexpr absl::int128 quiet_NaN() { return 0; } + static constexpr absl::int128 signaling_NaN() { return 0; } + static constexpr absl::int128 denorm_min() { return 0; } +}; +} // namespace std // -------------------------------------------------------------------------- // Implementation details follow // -------------------------------------------------------------------------- namespace absl { +ABSL_NAMESPACE_BEGIN constexpr uint128 MakeUint128(uint64_t high, uint64_t low) { return uint128(high, low); @@ -339,6 +576,10 @@ } #endif // ABSL_HAVE_INTRINSIC_INT128 +inline uint128& uint128::operator=(int128 v) { + return *this = uint128(v); +} + // Arithmetic operators. uint128 operator<<(uint128 lhs, int amount); @@ -420,6 +661,9 @@ hi_{static_cast<uint64_t>(v >> 64)} {} #endif // ABSL_HAVE_INTRINSIC_INT128 +constexpr uint128::uint128(int128 v) + : lo_{Int128Low64(v)}, hi_{static_cast<uint64_t>(Int128High64(v))} {} + #elif defined(ABSL_IS_BIG_ENDIAN) constexpr uint128::uint128(uint64_t high, uint64_t low) @@ -450,6 +694,9 @@ lo_{static_cast<uint64_t>(v & ~uint64_t{0})} {} #endif // ABSL_HAVE_INTRINSIC_INT128 +constexpr uint128::uint128(int128 v) + : hi_{static_cast<uint64_t>(Int128High64(v))}, lo_{Int128Low64(v)} {} + #else // byte order #error "Unsupported byte order: must be little-endian or big-endian." #endif // byte order @@ -545,28 +792,21 @@ } inline bool operator<(uint128 lhs, uint128 rhs) { +#ifdef ABSL_HAVE_INTRINSIC_INT128 + return static_cast<unsigned __int128>(lhs) < + static_cast<unsigned __int128>(rhs); +#else return (Uint128High64(lhs) == Uint128High64(rhs)) ? (Uint128Low64(lhs) < Uint128Low64(rhs)) : (Uint128High64(lhs) < Uint128High64(rhs)); +#endif } -inline bool operator>(uint128 lhs, uint128 rhs) { - return (Uint128High64(lhs) == Uint128High64(rhs)) - ? (Uint128Low64(lhs) > Uint128Low64(rhs)) - : (Uint128High64(lhs) > Uint128High64(rhs)); -} +inline bool operator>(uint128 lhs, uint128 rhs) { return rhs < lhs; } -inline bool operator<=(uint128 lhs, uint128 rhs) { - return (Uint128High64(lhs) == Uint128High64(rhs)) - ? (Uint128Low64(lhs) <= Uint128Low64(rhs)) - : (Uint128High64(lhs) <= Uint128High64(rhs)); -} +inline bool operator<=(uint128 lhs, uint128 rhs) { return !(rhs < lhs); } -inline bool operator>=(uint128 lhs, uint128 rhs) { - return (Uint128High64(lhs) == Uint128High64(rhs)) - ? (Uint128Low64(lhs) >= Uint128Low64(rhs)) - : (Uint128High64(lhs) >= Uint128High64(rhs)); -} +inline bool operator>=(uint128 lhs, uint128 rhs) { return !(lhs < rhs); } // Unary operators. @@ -623,6 +863,9 @@ // Arithmetic operators. inline uint128 operator<<(uint128 lhs, int amount) { +#ifdef ABSL_HAVE_INTRINSIC_INT128 + return static_cast<unsigned __int128>(lhs) << amount; +#else // uint64_t shifts of >= 64 are undefined, so we will need some // special-casing. if (amount < 64) { @@ -634,9 +877,13 @@ return lhs; } return MakeUint128(Uint128Low64(lhs) << (amount - 64), 0); +#endif } inline uint128 operator>>(uint128 lhs, int amount) { +#ifdef ABSL_HAVE_INTRINSIC_INT128 + return static_cast<unsigned __int128>(lhs) >> amount; +#else // uint64_t shifts of >= 64 are undefined, so we will need some // special-casing. if (amount < 64) { @@ -648,6 +895,7 @@ return lhs; } return MakeUint128(0, Uint128High64(lhs) >> (amount - 64)); +#endif } inline uint128 operator+(uint128 lhs, uint128 rhs) { @@ -719,12 +967,124 @@ return *this; } +constexpr int128 MakeInt128(int64_t high, uint64_t low) { + return int128(high, low); +} + +// Assignment from integer types. +inline int128& int128::operator=(int v) { + return *this = int128(v); +} + +inline int128& int128::operator=(unsigned int v) { + return *this = int128(v); +} + +inline int128& int128::operator=(long v) { // NOLINT(runtime/int) + return *this = int128(v); +} + +// NOLINTNEXTLINE(runtime/int) +inline int128& int128::operator=(unsigned long v) { + return *this = int128(v); +} + +// NOLINTNEXTLINE(runtime/int) +inline int128& int128::operator=(long long v) { + return *this = int128(v); +} + +// NOLINTNEXTLINE(runtime/int) +inline int128& int128::operator=(unsigned long long v) { + return *this = int128(v); +} + +// Arithmetic operators. + +int128 operator+(int128 lhs, int128 rhs); +int128 operator-(int128 lhs, int128 rhs); +int128 operator*(int128 lhs, int128 rhs); +int128 operator/(int128 lhs, int128 rhs); +int128 operator%(int128 lhs, int128 rhs); +int128 operator|(int128 lhs, int128 rhs); +int128 operator&(int128 lhs, int128 rhs); +int128 operator^(int128 lhs, int128 rhs); +int128 operator<<(int128 lhs, int amount); +int128 operator>>(int128 lhs, int amount); + +inline int128& int128::operator+=(int128 other) { + *this = *this + other; + return *this; +} + +inline int128& int128::operator-=(int128 other) { + *this = *this - other; + return *this; +} + +inline int128& int128::operator*=(int128 other) { + *this = *this * other; + return *this; +} + +inline int128& int128::operator/=(int128 other) { + *this = *this / other; + return *this; +} + +inline int128& int128::operator%=(int128 other) { + *this = *this % other; + return *this; +} + +inline int128& int128::operator|=(int128 other) { + *this = *this | other; + return *this; +} + +inline int128& int128::operator&=(int128 other) { + *this = *this & other; + return *this; +} + +inline int128& int128::operator^=(int128 other) { + *this = *this ^ other; + return *this; +} + +inline int128& int128::operator<<=(int amount) { + *this = *this << amount; + return *this; +} + +inline int128& int128::operator>>=(int amount) { + *this = *this >> amount; + return *this; +} + +namespace int128_internal { + +// Casts from unsigned to signed while preserving the underlying binary +// representation. +constexpr int64_t BitCastToSigned(uint64_t v) { + // Casting an unsigned integer to a signed integer of the same + // width is implementation defined behavior if the source value would not fit + // in the destination type. We step around it with a roundtrip bitwise not + // operation to make sure this function remains constexpr. Clang, GCC, and + // MSVC optimize this to a no-op on x86-64. + return v & (uint64_t{1} << 63) ? ~static_cast<int64_t>(~v) + : static_cast<int64_t>(v); +} + +} // namespace int128_internal + #if defined(ABSL_HAVE_INTRINSIC_INT128) -#include "absl/numeric/int128_have_intrinsic.inc" +#include "absl/numeric/int128_have_intrinsic.inc" // IWYU pragma: export #else // ABSL_HAVE_INTRINSIC_INT128 -#include "absl/numeric/int128_no_intrinsic.inc" +#include "absl/numeric/int128_no_intrinsic.inc" // IWYU pragma: export #endif // ABSL_HAVE_INTRINSIC_INT128 +ABSL_NAMESPACE_END } // namespace absl #undef ABSL_INTERNAL_WCHAR_T
diff --git a/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc b/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc index c7ea683..d6c76dd 100644 --- a/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +++ b/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc
@@ -16,3 +16,287 @@ // This file contains :int128 implementation details that depend on internal // representation when ABSL_HAVE_INTRINSIC_INT128 is defined. This file is // included by int128.h and relies on ABSL_INTERNAL_WCHAR_T being defined. + +namespace int128_internal { + +// Casts from unsigned to signed while preserving the underlying binary +// representation. +constexpr __int128 BitCastToSigned(unsigned __int128 v) { + // Casting an unsigned integer to a signed integer of the same + // width is implementation defined behavior if the source value would not fit + // in the destination type. We step around it with a roundtrip bitwise not + // operation to make sure this function remains constexpr. Clang and GCC + // optimize this to a no-op on x86-64. + return v & (static_cast<unsigned __int128>(1) << 127) + ? ~static_cast<__int128>(~v) + : static_cast<__int128>(v); +} + +} // namespace int128_internal + +inline int128& int128::operator=(__int128 v) { + v_ = v; + return *this; +} + +constexpr uint64_t Int128Low64(int128 v) { + return static_cast<uint64_t>(v.v_ & ~uint64_t{0}); +} + +constexpr int64_t Int128High64(int128 v) { + // Initially cast to unsigned to prevent a right shift on a negative value. + return int128_internal::BitCastToSigned( + static_cast<uint64_t>(static_cast<unsigned __int128>(v.v_) >> 64)); +} + +constexpr int128::int128(int64_t high, uint64_t low) + // Initially cast to unsigned to prevent a left shift that overflows. + : v_(int128_internal::BitCastToSigned(static_cast<unsigned __int128>(high) + << 64) | + low) {} + + +constexpr int128::int128(int v) : v_{v} {} + +constexpr int128::int128(long v) : v_{v} {} // NOLINT(runtime/int) + +constexpr int128::int128(long long v) : v_{v} {} // NOLINT(runtime/int) + +constexpr int128::int128(__int128 v) : v_{v} {} + +constexpr int128::int128(unsigned int v) : v_{v} {} + +constexpr int128::int128(unsigned long v) : v_{v} {} // NOLINT(runtime/int) + +// NOLINTNEXTLINE(runtime/int) +constexpr int128::int128(unsigned long long v) : v_{v} {} + +constexpr int128::int128(unsigned __int128 v) : v_{static_cast<__int128>(v)} {} + +inline int128::int128(float v) { + v_ = static_cast<__int128>(v); +} + +inline int128::int128(double v) { + v_ = static_cast<__int128>(v); +} + +inline int128::int128(long double v) { + v_ = static_cast<__int128>(v); +} + +constexpr int128::int128(uint128 v) : v_{static_cast<__int128>(v)} {} + +constexpr int128::operator bool() const { return static_cast<bool>(v_); } + +constexpr int128::operator char() const { return static_cast<char>(v_); } + +constexpr int128::operator signed char() const { + return static_cast<signed char>(v_); +} + +constexpr int128::operator unsigned char() const { + return static_cast<unsigned char>(v_); +} + +constexpr int128::operator char16_t() const { + return static_cast<char16_t>(v_); +} + +constexpr int128::operator char32_t() const { + return static_cast<char32_t>(v_); +} + +constexpr int128::operator ABSL_INTERNAL_WCHAR_T() const { + return static_cast<ABSL_INTERNAL_WCHAR_T>(v_); +} + +constexpr int128::operator short() const { // NOLINT(runtime/int) + return static_cast<short>(v_); // NOLINT(runtime/int) +} + +constexpr int128::operator unsigned short() const { // NOLINT(runtime/int) + return static_cast<unsigned short>(v_); // NOLINT(runtime/int) +} + +constexpr int128::operator int() const { + return static_cast<int>(v_); +} + +constexpr int128::operator unsigned int() const { + return static_cast<unsigned int>(v_); +} + +constexpr int128::operator long() const { // NOLINT(runtime/int) + return static_cast<long>(v_); // NOLINT(runtime/int) +} + +constexpr int128::operator unsigned long() const { // NOLINT(runtime/int) + return static_cast<unsigned long>(v_); // NOLINT(runtime/int) +} + +constexpr int128::operator long long() const { // NOLINT(runtime/int) + return static_cast<long long>(v_); // NOLINT(runtime/int) +} + +constexpr int128::operator unsigned long long() const { // NOLINT(runtime/int) + return static_cast<unsigned long long>(v_); // NOLINT(runtime/int) +} + +constexpr int128::operator __int128() const { return v_; } + +constexpr int128::operator unsigned __int128() const { + return static_cast<unsigned __int128>(v_); +} + +// Clang on PowerPC sometimes produces incorrect __int128 to floating point +// conversions. In that case, we do the conversion with a similar implementation +// to the conversion operators in int128_no_intrinsic.inc. +#if defined(__clang__) && !defined(__ppc64__) +inline int128::operator float() const { return static_cast<float>(v_); } + +inline int128::operator double () const { return static_cast<double>(v_); } + +inline int128::operator long double() const { + return static_cast<long double>(v_); +} + +#else // Clang on PowerPC +// Forward declaration for conversion operators to floating point types. +int128 operator-(int128 v); +bool operator!=(int128 lhs, int128 rhs); + +inline int128::operator float() const { + // We must convert the absolute value and then negate as needed, because + // floating point types are typically sign-magnitude. Otherwise, the + // difference between the high and low 64 bits when interpreted as two's + // complement overwhelms the precision of the mantissa. + // + // Also check to make sure we don't negate Int128Min() + return v_ < 0 && *this != Int128Min() + ? -static_cast<float>(-*this) + : static_cast<float>(Int128Low64(*this)) + + std::ldexp(static_cast<float>(Int128High64(*this)), 64); +} + +inline int128::operator double() const { + // See comment in int128::operator float() above. + return v_ < 0 && *this != Int128Min() + ? -static_cast<double>(-*this) + : static_cast<double>(Int128Low64(*this)) + + std::ldexp(static_cast<double>(Int128High64(*this)), 64); +} + +inline int128::operator long double() const { + // See comment in int128::operator float() above. + return v_ < 0 && *this != Int128Min() + ? -static_cast<long double>(-*this) + : static_cast<long double>(Int128Low64(*this)) + + std::ldexp(static_cast<long double>(Int128High64(*this)), + 64); +} +#endif // Clang on PowerPC + +// Comparison operators. + +inline bool operator==(int128 lhs, int128 rhs) { + return static_cast<__int128>(lhs) == static_cast<__int128>(rhs); +} + +inline bool operator!=(int128 lhs, int128 rhs) { + return static_cast<__int128>(lhs) != static_cast<__int128>(rhs); +} + +inline bool operator<(int128 lhs, int128 rhs) { + return static_cast<__int128>(lhs) < static_cast<__int128>(rhs); +} + +inline bool operator>(int128 lhs, int128 rhs) { + return static_cast<__int128>(lhs) > static_cast<__int128>(rhs); +} + +inline bool operator<=(int128 lhs, int128 rhs) { + return static_cast<__int128>(lhs) <= static_cast<__int128>(rhs); +} + +inline bool operator>=(int128 lhs, int128 rhs) { + return static_cast<__int128>(lhs) >= static_cast<__int128>(rhs); +} + +// Unary operators. + +inline int128 operator-(int128 v) { + return -static_cast<__int128>(v); +} + +inline bool operator!(int128 v) { + return !static_cast<__int128>(v); +} + +inline int128 operator~(int128 val) { + return ~static_cast<__int128>(val); +} + +// Arithmetic operators. + +inline int128 operator+(int128 lhs, int128 rhs) { + return static_cast<__int128>(lhs) + static_cast<__int128>(rhs); +} + +inline int128 operator-(int128 lhs, int128 rhs) { + return static_cast<__int128>(lhs) - static_cast<__int128>(rhs); +} + +inline int128 operator*(int128 lhs, int128 rhs) { + return static_cast<__int128>(lhs) * static_cast<__int128>(rhs); +} + +inline int128 operator/(int128 lhs, int128 rhs) { + return static_cast<__int128>(lhs) / static_cast<__int128>(rhs); +} + +inline int128 operator%(int128 lhs, int128 rhs) { + return static_cast<__int128>(lhs) % static_cast<__int128>(rhs); +} + +inline int128 int128::operator++(int) { + int128 tmp(*this); + ++v_; + return tmp; +} + +inline int128 int128::operator--(int) { + int128 tmp(*this); + --v_; + return tmp; +} + +inline int128& int128::operator++() { + ++v_; + return *this; +} + +inline int128& int128::operator--() { + --v_; + return *this; +} + +inline int128 operator|(int128 lhs, int128 rhs) { + return static_cast<__int128>(lhs) | static_cast<__int128>(rhs); +} + +inline int128 operator&(int128 lhs, int128 rhs) { + return static_cast<__int128>(lhs) & static_cast<__int128>(rhs); +} + +inline int128 operator^(int128 lhs, int128 rhs) { + return static_cast<__int128>(lhs) ^ static_cast<__int128>(rhs); +} + +inline int128 operator<<(int128 lhs, int amount) { + return static_cast<__int128>(lhs) << amount; +} + +inline int128 operator>>(int128 lhs, int amount) { + return static_cast<__int128>(lhs) >> amount; +}
diff --git a/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc b/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc index 046cb9b..c753771a 100644 --- a/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +++ b/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc
@@ -16,3 +16,293 @@ // This file contains :int128 implementation details that depend on internal // representation when ABSL_HAVE_INTRINSIC_INT128 is *not* defined. This file // is included by int128.h and relies on ABSL_INTERNAL_WCHAR_T being defined. + +constexpr uint64_t Int128Low64(int128 v) { return v.lo_; } + +constexpr int64_t Int128High64(int128 v) { return v.hi_; } + +#if defined(ABSL_IS_LITTLE_ENDIAN) + +constexpr int128::int128(int64_t high, uint64_t low) : + lo_(low), hi_(high) {} + +constexpr int128::int128(int v) + : lo_{static_cast<uint64_t>(v)}, hi_{v < 0 ? ~int64_t{0} : 0} {} +constexpr int128::int128(long v) // NOLINT(runtime/int) + : lo_{static_cast<uint64_t>(v)}, hi_{v < 0 ? ~int64_t{0} : 0} {} +constexpr int128::int128(long long v) // NOLINT(runtime/int) + : lo_{static_cast<uint64_t>(v)}, hi_{v < 0 ? ~int64_t{0} : 0} {} + +constexpr int128::int128(unsigned int v) : lo_{v}, hi_{0} {} +// NOLINTNEXTLINE(runtime/int) +constexpr int128::int128(unsigned long v) : lo_{v}, hi_{0} {} +// NOLINTNEXTLINE(runtime/int) +constexpr int128::int128(unsigned long long v) : lo_{v}, hi_{0} {} + +constexpr int128::int128(uint128 v) + : lo_{Uint128Low64(v)}, hi_{static_cast<int64_t>(Uint128High64(v))} {} + +#elif defined(ABSL_IS_BIG_ENDIAN) + +constexpr int128::int128(int64_t high, uint64_t low) : + hi_{high}, lo_{low} {} + +constexpr int128::int128(int v) + : hi_{v < 0 ? ~int64_t{0} : 0}, lo_{static_cast<uint64_t>(v)} {} +constexpr int128::int128(long v) // NOLINT(runtime/int) + : hi_{v < 0 ? ~int64_t{0} : 0}, lo_{static_cast<uint64_t>(v)} {} +constexpr int128::int128(long long v) // NOLINT(runtime/int) + : hi_{v < 0 ? ~int64_t{0} : 0}, lo_{static_cast<uint64_t>(v)} {} + +constexpr int128::int128(unsigned int v) : hi_{0}, lo_{v} {} +// NOLINTNEXTLINE(runtime/int) +constexpr int128::int128(unsigned long v) : hi_{0}, lo_{v} {} +// NOLINTNEXTLINE(runtime/int) +constexpr int128::int128(unsigned long long v) : hi_{0}, lo_{v} {} + +constexpr int128::int128(uint128 v) + : hi_{static_cast<int64_t>(Uint128High64(v))}, lo_{Uint128Low64(v)} {} + +#else // byte order +#error "Unsupported byte order: must be little-endian or big-endian." +#endif // byte order + +constexpr int128::operator bool() const { return lo_ || hi_; } + +constexpr int128::operator char() const { + // NOLINTNEXTLINE(runtime/int) + return static_cast<char>(static_cast<long long>(*this)); +} + +constexpr int128::operator signed char() const { + // NOLINTNEXTLINE(runtime/int) + return static_cast<signed char>(static_cast<long long>(*this)); +} + +constexpr int128::operator unsigned char() const { + return static_cast<unsigned char>(lo_); +} + +constexpr int128::operator char16_t() const { + return static_cast<char16_t>(lo_); +} + +constexpr int128::operator char32_t() const { + return static_cast<char32_t>(lo_); +} + +constexpr int128::operator ABSL_INTERNAL_WCHAR_T() const { + // NOLINTNEXTLINE(runtime/int) + return static_cast<ABSL_INTERNAL_WCHAR_T>(static_cast<long long>(*this)); +} + +constexpr int128::operator short() const { // NOLINT(runtime/int) + // NOLINTNEXTLINE(runtime/int) + return static_cast<short>(static_cast<long long>(*this)); +} + +constexpr int128::operator unsigned short() const { // NOLINT(runtime/int) + return static_cast<unsigned short>(lo_); // NOLINT(runtime/int) +} + +constexpr int128::operator int() const { + // NOLINTNEXTLINE(runtime/int) + return static_cast<int>(static_cast<long long>(*this)); +} + +constexpr int128::operator unsigned int() const { + return static_cast<unsigned int>(lo_); +} + +constexpr int128::operator long() const { // NOLINT(runtime/int) + // NOLINTNEXTLINE(runtime/int) + return static_cast<long>(static_cast<long long>(*this)); +} + +constexpr int128::operator unsigned long() const { // NOLINT(runtime/int) + return static_cast<unsigned long>(lo_); // NOLINT(runtime/int) +} + +constexpr int128::operator long long() const { // NOLINT(runtime/int) + // We don't bother checking the value of hi_. If *this < 0, lo_'s high bit + // must be set in order for the value to fit into a long long. Conversely, if + // lo_'s high bit is set, *this must be < 0 for the value to fit. + return int128_internal::BitCastToSigned(lo_); +} + +constexpr int128::operator unsigned long long() const { // NOLINT(runtime/int) + return static_cast<unsigned long long>(lo_); // NOLINT(runtime/int) +} + +// Forward declaration for conversion operators to floating point types. +int128 operator-(int128 v); +bool operator!=(int128 lhs, int128 rhs); + +inline int128::operator float() const { + // We must convert the absolute value and then negate as needed, because + // floating point types are typically sign-magnitude. Otherwise, the + // difference between the high and low 64 bits when interpreted as two's + // complement overwhelms the precision of the mantissa. + // + // Also check to make sure we don't negate Int128Min() + return hi_ < 0 && *this != Int128Min() + ? -static_cast<float>(-*this) + : static_cast<float>(lo_) + + std::ldexp(static_cast<float>(hi_), 64); +} + +inline int128::operator double() const { + // See comment in int128::operator float() above. + return hi_ < 0 && *this != Int128Min() + ? -static_cast<double>(-*this) + : static_cast<double>(lo_) + + std::ldexp(static_cast<double>(hi_), 64); +} + +inline int128::operator long double() const { + // See comment in int128::operator float() above. + return hi_ < 0 && *this != Int128Min() + ? -static_cast<long double>(-*this) + : static_cast<long double>(lo_) + + std::ldexp(static_cast<long double>(hi_), 64); +} + +// Comparison operators. + +inline bool operator==(int128 lhs, int128 rhs) { + return (Int128Low64(lhs) == Int128Low64(rhs) && + Int128High64(lhs) == Int128High64(rhs)); +} + +inline bool operator!=(int128 lhs, int128 rhs) { + return !(lhs == rhs); +} + +inline bool operator<(int128 lhs, int128 rhs) { + return (Int128High64(lhs) == Int128High64(rhs)) + ? (Int128Low64(lhs) < Int128Low64(rhs)) + : (Int128High64(lhs) < Int128High64(rhs)); +} + +inline bool operator>(int128 lhs, int128 rhs) { + return (Int128High64(lhs) == Int128High64(rhs)) + ? (Int128Low64(lhs) > Int128Low64(rhs)) + : (Int128High64(lhs) > Int128High64(rhs)); +} + +inline bool operator<=(int128 lhs, int128 rhs) { + return !(lhs > rhs); +} + +inline bool operator>=(int128 lhs, int128 rhs) { + return !(lhs < rhs); +} + +// Unary operators. + +inline int128 operator-(int128 v) { + int64_t hi = ~Int128High64(v); + uint64_t lo = ~Int128Low64(v) + 1; + if (lo == 0) ++hi; // carry + return MakeInt128(hi, lo); +} + +inline bool operator!(int128 v) { + return !Int128Low64(v) && !Int128High64(v); +} + +inline int128 operator~(int128 val) { + return MakeInt128(~Int128High64(val), ~Int128Low64(val)); +} + +// Arithmetic operators. + +inline int128 operator+(int128 lhs, int128 rhs) { + int128 result = MakeInt128(Int128High64(lhs) + Int128High64(rhs), + Int128Low64(lhs) + Int128Low64(rhs)); + if (Int128Low64(result) < Int128Low64(lhs)) { // check for carry + return MakeInt128(Int128High64(result) + 1, Int128Low64(result)); + } + return result; +} + +inline int128 operator-(int128 lhs, int128 rhs) { + int128 result = MakeInt128(Int128High64(lhs) - Int128High64(rhs), + Int128Low64(lhs) - Int128Low64(rhs)); + if (Int128Low64(lhs) < Int128Low64(rhs)) { // check for carry + return MakeInt128(Int128High64(result) - 1, Int128Low64(result)); + } + return result; +} + +inline int128 operator*(int128 lhs, int128 rhs) { + uint128 result = uint128(lhs) * rhs; + return MakeInt128(int128_internal::BitCastToSigned(Uint128High64(result)), + Uint128Low64(result)); +} + +inline int128 int128::operator++(int) { + int128 tmp(*this); + *this += 1; + return tmp; +} + +inline int128 int128::operator--(int) { + int128 tmp(*this); + *this -= 1; + return tmp; +} + +inline int128& int128::operator++() { + *this += 1; + return *this; +} + +inline int128& int128::operator--() { + *this -= 1; + return *this; +} + +inline int128 operator|(int128 lhs, int128 rhs) { + return MakeInt128(Int128High64(lhs) | Int128High64(rhs), + Int128Low64(lhs) | Int128Low64(rhs)); +} + +inline int128 operator&(int128 lhs, int128 rhs) { + return MakeInt128(Int128High64(lhs) & Int128High64(rhs), + Int128Low64(lhs) & Int128Low64(rhs)); +} + +inline int128 operator^(int128 lhs, int128 rhs) { + return MakeInt128(Int128High64(lhs) ^ Int128High64(rhs), + Int128Low64(lhs) ^ Int128Low64(rhs)); +} + +inline int128 operator<<(int128 lhs, int amount) { + // uint64_t shifts of >= 64 are undefined, so we need some special-casing. + if (amount < 64) { + if (amount != 0) { + return MakeInt128( + (Int128High64(lhs) << amount) | + static_cast<int64_t>(Int128Low64(lhs) >> (64 - amount)), + Int128Low64(lhs) << amount); + } + return lhs; + } + return MakeInt128(static_cast<int64_t>(Int128Low64(lhs) << (amount - 64)), 0); +} + +inline int128 operator>>(int128 lhs, int amount) { + // uint64_t shifts of >= 64 are undefined, so we need some special-casing. + if (amount < 64) { + if (amount != 0) { + return MakeInt128( + Int128High64(lhs) >> amount, + (Int128Low64(lhs) >> amount) | + (static_cast<uint64_t>(Int128High64(lhs)) << (64 - amount))); + } + return lhs; + } + return MakeInt128(0, + static_cast<uint64_t>(Int128High64(lhs) >> (amount - 64))); +}
diff --git a/third_party/abseil-cpp/absl/numeric/int128_stream_test.cc b/third_party/abseil-cpp/absl/numeric/int128_stream_test.cc index 3cfa9dc..479ad66c 100644 --- a/third_party/abseil-cpp/absl/numeric/int128_stream_test.cc +++ b/third_party/abseil-cpp/absl/numeric/int128_stream_test.cc
@@ -147,6 +147,735 @@ } } +struct Int128TestCase { + absl::int128 value; + std::ios_base::fmtflags flags; + std::streamsize width; + const char* expected; +}; + +void CheckInt128Case(const Int128TestCase& test_case) { + std::ostringstream os; + os.flags(test_case.flags); + os.width(test_case.width); + os.fill(kFill); + os << test_case.value; + SCOPED_TRACE(StreamFormatToString(test_case.flags, test_case.width)); + EXPECT_EQ(test_case.expected, os.str()); +} + +TEST(Int128, OStreamValueTest) { + CheckInt128Case({1, kDec, /*width = */ 0, "1"}); + CheckInt128Case({1, kOct, /*width = */ 0, "1"}); + CheckInt128Case({1, kHex, /*width = */ 0, "1"}); + CheckInt128Case({9, kDec, /*width = */ 0, "9"}); + CheckInt128Case({9, kOct, /*width = */ 0, "11"}); + CheckInt128Case({9, kHex, /*width = */ 0, "9"}); + CheckInt128Case({12345, kDec, /*width = */ 0, "12345"}); + CheckInt128Case({12345, kOct, /*width = */ 0, "30071"}); + CheckInt128Case({12345, kHex, /*width = */ 0, "3039"}); + CheckInt128Case( + {0x8000000000000000, kDec, /*width = */ 0, "9223372036854775808"}); + CheckInt128Case( + {0x8000000000000000, kOct, /*width = */ 0, "1000000000000000000000"}); + CheckInt128Case( + {0x8000000000000000, kHex, /*width = */ 0, "8000000000000000"}); + CheckInt128Case({std::numeric_limits<uint64_t>::max(), kDec, + /*width = */ 0, "18446744073709551615"}); + CheckInt128Case({std::numeric_limits<uint64_t>::max(), kOct, + /*width = */ 0, "1777777777777777777777"}); + CheckInt128Case({std::numeric_limits<uint64_t>::max(), kHex, + /*width = */ 0, "ffffffffffffffff"}); + CheckInt128Case( + {absl::MakeInt128(1, 0), kDec, /*width = */ 0, "18446744073709551616"}); + CheckInt128Case( + {absl::MakeInt128(1, 0), kOct, /*width = */ 0, "2000000000000000000000"}); + CheckInt128Case( + {absl::MakeInt128(1, 0), kHex, /*width = */ 0, "10000000000000000"}); + CheckInt128Case({absl::MakeInt128(std::numeric_limits<int64_t>::max(), + std::numeric_limits<uint64_t>::max()), + std::ios::dec, /*width = */ 0, + "170141183460469231731687303715884105727"}); + CheckInt128Case({absl::MakeInt128(std::numeric_limits<int64_t>::max(), + std::numeric_limits<uint64_t>::max()), + std::ios::oct, /*width = */ 0, + "1777777777777777777777777777777777777777777"}); + CheckInt128Case({absl::MakeInt128(std::numeric_limits<int64_t>::max(), + std::numeric_limits<uint64_t>::max()), + std::ios::hex, /*width = */ 0, + "7fffffffffffffffffffffffffffffff"}); + CheckInt128Case({absl::MakeInt128(std::numeric_limits<int64_t>::min(), 0), + std::ios::dec, /*width = */ 0, + "-170141183460469231731687303715884105728"}); + CheckInt128Case({absl::MakeInt128(std::numeric_limits<int64_t>::min(), 0), + std::ios::oct, /*width = */ 0, + "2000000000000000000000000000000000000000000"}); + CheckInt128Case({absl::MakeInt128(std::numeric_limits<int64_t>::min(), 0), + std::ios::hex, /*width = */ 0, + "80000000000000000000000000000000"}); + CheckInt128Case({-1, std::ios::dec, /*width = */ 0, "-1"}); + CheckInt128Case({-1, std::ios::oct, /*width = */ 0, + "3777777777777777777777777777777777777777777"}); + CheckInt128Case( + {-1, std::ios::hex, /*width = */ 0, "ffffffffffffffffffffffffffffffff"}); + CheckInt128Case({-12345, std::ios::dec, /*width = */ 0, "-12345"}); + CheckInt128Case({-12345, std::ios::oct, /*width = */ 0, + "3777777777777777777777777777777777777747707"}); + CheckInt128Case({-12345, std::ios::hex, /*width = */ 0, + "ffffffffffffffffffffffffffffcfc7"}); +} + +std::vector<Int128TestCase> GetInt128FormatCases(); +TEST(Int128, OStreamFormatTest) { + for (const Int128TestCase& test_case : GetInt128FormatCases()) { + CheckInt128Case(test_case); + } +} + +std::vector<Int128TestCase> GetInt128FormatCases() { + return { + {0, std::ios_base::fmtflags(), /*width = */ 0, "0"}, + {0, std::ios_base::fmtflags(), /*width = */ 6, "_____0"}, + {0, kPos, /*width = */ 0, "+0"}, + {0, kPos, /*width = */ 6, "____+0"}, + {0, kBase, /*width = */ 0, "0"}, + {0, kBase, /*width = */ 6, "_____0"}, + {0, kBase | kPos, /*width = */ 0, "+0"}, + {0, kBase | kPos, /*width = */ 6, "____+0"}, + {0, kUpper, /*width = */ 0, "0"}, + {0, kUpper, /*width = */ 6, "_____0"}, + {0, kUpper | kPos, /*width = */ 0, "+0"}, + {0, kUpper | kPos, /*width = */ 6, "____+0"}, + {0, kUpper | kBase, /*width = */ 0, "0"}, + {0, kUpper | kBase, /*width = */ 6, "_____0"}, + {0, kUpper | kBase | kPos, /*width = */ 0, "+0"}, + {0, kUpper | kBase | kPos, /*width = */ 6, "____+0"}, + {0, kLeft, /*width = */ 0, "0"}, + {0, kLeft, /*width = */ 6, "0_____"}, + {0, kLeft | kPos, /*width = */ 0, "+0"}, + {0, kLeft | kPos, /*width = */ 6, "+0____"}, + {0, kLeft | kBase, /*width = */ 0, "0"}, + {0, kLeft | kBase, /*width = */ 6, "0_____"}, + {0, kLeft | kBase | kPos, /*width = */ 0, "+0"}, + {0, kLeft | kBase | kPos, /*width = */ 6, "+0____"}, + {0, kLeft | kUpper, /*width = */ 0, "0"}, + {0, kLeft | kUpper, /*width = */ 6, "0_____"}, + {0, kLeft | kUpper | kPos, /*width = */ 0, "+0"}, + {0, kLeft | kUpper | kPos, /*width = */ 6, "+0____"}, + {0, kLeft | kUpper | kBase, /*width = */ 0, "0"}, + {0, kLeft | kUpper | kBase, /*width = */ 6, "0_____"}, + {0, kLeft | kUpper | kBase | kPos, /*width = */ 0, "+0"}, + {0, kLeft | kUpper | kBase | kPos, /*width = */ 6, "+0____"}, + {0, kInt, /*width = */ 0, "0"}, + {0, kInt, /*width = */ 6, "_____0"}, + {0, kInt | kPos, /*width = */ 0, "+0"}, + {0, kInt | kPos, /*width = */ 6, "+____0"}, + {0, kInt | kBase, /*width = */ 0, "0"}, + {0, kInt | kBase, /*width = */ 6, "_____0"}, + {0, kInt | kBase | kPos, /*width = */ 0, "+0"}, + {0, kInt | kBase | kPos, /*width = */ 6, "+____0"}, + {0, kInt | kUpper, /*width = */ 0, "0"}, + {0, kInt | kUpper, /*width = */ 6, "_____0"}, + {0, kInt | kUpper | kPos, /*width = */ 0, "+0"}, + {0, kInt | kUpper | kPos, /*width = */ 6, "+____0"}, + {0, kInt | kUpper | kBase, /*width = */ 0, "0"}, + {0, kInt | kUpper | kBase, /*width = */ 6, "_____0"}, + {0, kInt | kUpper | kBase | kPos, /*width = */ 0, "+0"}, + {0, kInt | kUpper | kBase | kPos, /*width = */ 6, "+____0"}, + {0, kRight, /*width = */ 0, "0"}, + {0, kRight, /*width = */ 6, "_____0"}, + {0, kRight | kPos, /*width = */ 0, "+0"}, + {0, kRight | kPos, /*width = */ 6, "____+0"}, + {0, kRight | kBase, /*width = */ 0, "0"}, + {0, kRight | kBase, /*width = */ 6, "_____0"}, + {0, kRight | kBase | kPos, /*width = */ 0, "+0"}, + {0, kRight | kBase | kPos, /*width = */ 6, "____+0"}, + {0, kRight | kUpper, /*width = */ 0, "0"}, + {0, kRight | kUpper, /*width = */ 6, "_____0"}, + {0, kRight | kUpper | kPos, /*width = */ 0, "+0"}, + {0, kRight | kUpper | kPos, /*width = */ 6, "____+0"}, + {0, kRight | kUpper | kBase, /*width = */ 0, "0"}, + {0, kRight | kUpper | kBase, /*width = */ 6, "_____0"}, + {0, kRight | kUpper | kBase | kPos, /*width = */ 0, "+0"}, + {0, kRight | kUpper | kBase | kPos, /*width = */ 6, "____+0"}, + {0, kDec, /*width = */ 0, "0"}, + {0, kDec, /*width = */ 6, "_____0"}, + {0, kDec | kPos, /*width = */ 0, "+0"}, + {0, kDec | kPos, /*width = */ 6, "____+0"}, + {0, kDec | kBase, /*width = */ 0, "0"}, + {0, kDec | kBase, /*width = */ 6, "_____0"}, + {0, kDec | kBase | kPos, /*width = */ 0, "+0"}, + {0, kDec | kBase | kPos, /*width = */ 6, "____+0"}, + {0, kDec | kUpper, /*width = */ 0, "0"}, + {0, kDec | kUpper, /*width = */ 6, "_____0"}, + {0, kDec | kUpper | kPos, /*width = */ 0, "+0"}, + {0, kDec | kUpper | kPos, /*width = */ 6, "____+0"}, + {0, kDec | kUpper | kBase, /*width = */ 0, "0"}, + {0, kDec | kUpper | kBase, /*width = */ 6, "_____0"}, + {0, kDec | kUpper | kBase | kPos, /*width = */ 0, "+0"}, + {0, kDec | kUpper | kBase | kPos, /*width = */ 6, "____+0"}, + {0, kDec | kLeft, /*width = */ 0, "0"}, + {0, kDec | kLeft, /*width = */ 6, "0_____"}, + {0, kDec | kLeft | kPos, /*width = */ 0, "+0"}, + {0, kDec | kLeft | kPos, /*width = */ 6, "+0____"}, + {0, kDec | kLeft | kBase, /*width = */ 0, "0"}, + {0, kDec | kLeft | kBase, /*width = */ 6, "0_____"}, + {0, kDec | kLeft | kBase | kPos, /*width = */ 0, "+0"}, + {0, kDec | kLeft | kBase | kPos, /*width = */ 6, "+0____"}, + {0, kDec | kLeft | kUpper, /*width = */ 0, "0"}, + {0, kDec | kLeft | kUpper, /*width = */ 6, "0_____"}, + {0, kDec | kLeft | kUpper | kPos, /*width = */ 0, "+0"}, + {0, kDec | kLeft | kUpper | kPos, /*width = */ 6, "+0____"}, + {0, kDec | kLeft | kUpper | kBase, /*width = */ 0, "0"}, + {0, kDec | kLeft | kUpper | kBase, /*width = */ 6, "0_____"}, + {0, kDec | kLeft | kUpper | kBase | kPos, /*width = */ 0, "+0"}, + {0, kDec | kLeft | kUpper | kBase | kPos, /*width = */ 6, "+0____"}, + {0, kDec | kInt, /*width = */ 0, "0"}, + {0, kDec | kInt, /*width = */ 6, "_____0"}, + {0, kDec | kInt | kPos, /*width = */ 0, "+0"}, + {0, kDec | kInt | kPos, /*width = */ 6, "+____0"}, + {0, kDec | kInt | kBase, /*width = */ 0, "0"}, + {0, kDec | kInt | kBase, /*width = */ 6, "_____0"}, + {0, kDec | kInt | kBase | kPos, /*width = */ 0, "+0"}, + {0, kDec | kInt | kBase | kPos, /*width = */ 6, "+____0"}, + {0, kDec | kInt | kUpper, /*width = */ 0, "0"}, + {0, kDec | kInt | kUpper, /*width = */ 6, "_____0"}, + {0, kDec | kInt | kUpper | kPos, /*width = */ 0, "+0"}, + {0, kDec | kInt | kUpper | kPos, /*width = */ 6, "+____0"}, + {0, kDec | kInt | kUpper | kBase, /*width = */ 0, "0"}, + {0, kDec | kInt | kUpper | kBase, /*width = */ 6, "_____0"}, + {0, kDec | kInt | kUpper | kBase | kPos, /*width = */ 0, "+0"}, + {0, kDec | kInt | kUpper | kBase | kPos, /*width = */ 6, "+____0"}, + {0, kDec | kRight, /*width = */ 0, "0"}, + {0, kDec | kRight, /*width = */ 6, "_____0"}, + {0, kDec | kRight | kPos, /*width = */ 0, "+0"}, + {0, kDec | kRight | kPos, /*width = */ 6, "____+0"}, + {0, kDec | kRight | kBase, /*width = */ 0, "0"}, + {0, kDec | kRight | kBase, /*width = */ 6, "_____0"}, + {0, kDec | kRight | kBase | kPos, /*width = */ 0, "+0"}, + {0, kDec | kRight | kBase | kPos, /*width = */ 6, "____+0"}, + {0, kDec | kRight | kUpper, /*width = */ 0, "0"}, + {0, kDec | kRight | kUpper, /*width = */ 6, "_____0"}, + {0, kDec | kRight | kUpper | kPos, /*width = */ 0, "+0"}, + {0, kDec | kRight | kUpper | kPos, /*width = */ 6, "____+0"}, + {0, kDec | kRight | kUpper | kBase, /*width = */ 0, "0"}, + {0, kDec | kRight | kUpper | kBase, /*width = */ 6, "_____0"}, + {0, kDec | kRight | kUpper | kBase | kPos, /*width = */ 0, "+0"}, + {0, kDec | kRight | kUpper | kBase | kPos, /*width = */ 6, "____+0"}, + {0, kOct, /*width = */ 0, "0"}, + {0, kOct, /*width = */ 6, "_____0"}, + {0, kOct | kPos, /*width = */ 0, "0"}, + {0, kOct | kPos, /*width = */ 6, "_____0"}, + {0, kOct | kBase, /*width = */ 0, "0"}, + {0, kOct | kBase, /*width = */ 6, "_____0"}, + {0, kOct | kBase | kPos, /*width = */ 0, "0"}, + {0, kOct | kBase | kPos, /*width = */ 6, "_____0"}, + {0, kOct | kUpper, /*width = */ 0, "0"}, + {0, kOct | kUpper, /*width = */ 6, "_____0"}, + {0, kOct | kUpper | kPos, /*width = */ 0, "0"}, + {0, kOct | kUpper | kPos, /*width = */ 6, "_____0"}, + {0, kOct | kUpper | kBase, /*width = */ 0, "0"}, + {0, kOct | kUpper | kBase, /*width = */ 6, "_____0"}, + {0, kOct | kUpper | kBase | kPos, /*width = */ 0, "0"}, + {0, kOct | kUpper | kBase | kPos, /*width = */ 6, "_____0"}, + {0, kOct | kLeft, /*width = */ 0, "0"}, + {0, kOct | kLeft, /*width = */ 6, "0_____"}, + {0, kOct | kLeft | kPos, /*width = */ 0, "0"}, + {0, kOct | kLeft | kPos, /*width = */ 6, "0_____"}, + {0, kOct | kLeft | kBase, /*width = */ 0, "0"}, + {0, kOct | kLeft | kBase, /*width = */ 6, "0_____"}, + {0, kOct | kLeft | kBase | kPos, /*width = */ 0, "0"}, + {0, kOct | kLeft | kBase | kPos, /*width = */ 6, "0_____"}, + {0, kOct | kLeft | kUpper, /*width = */ 0, "0"}, + {0, kOct | kLeft | kUpper, /*width = */ 6, "0_____"}, + {0, kOct | kLeft | kUpper | kPos, /*width = */ 0, "0"}, + {0, kOct | kLeft | kUpper | kPos, /*width = */ 6, "0_____"}, + {0, kOct | kLeft | kUpper | kBase, /*width = */ 0, "0"}, + {0, kOct | kLeft | kUpper | kBase, /*width = */ 6, "0_____"}, + {0, kOct | kLeft | kUpper | kBase | kPos, /*width = */ 0, "0"}, + {0, kOct | kLeft | kUpper | kBase | kPos, /*width = */ 6, "0_____"}, + {0, kOct | kInt, /*width = */ 0, "0"}, + {0, kOct | kInt, /*width = */ 6, "_____0"}, + {0, kOct | kInt | kPos, /*width = */ 0, "0"}, + {0, kOct | kInt | kPos, /*width = */ 6, "_____0"}, + {0, kOct | kInt | kBase, /*width = */ 0, "0"}, + {0, kOct | kInt | kBase, /*width = */ 6, "_____0"}, + {0, kOct | kInt | kBase | kPos, /*width = */ 0, "0"}, + {0, kOct | kInt | kBase | kPos, /*width = */ 6, "_____0"}, + {0, kOct | kInt | kUpper, /*width = */ 0, "0"}, + {0, kOct | kInt | kUpper, /*width = */ 6, "_____0"}, + {0, kOct | kInt | kUpper | kPos, /*width = */ 0, "0"}, + {0, kOct | kInt | kUpper | kPos, /*width = */ 6, "_____0"}, + {0, kOct | kInt | kUpper | kBase, /*width = */ 0, "0"}, + {0, kOct | kInt | kUpper | kBase, /*width = */ 6, "_____0"}, + {0, kOct | kInt | kUpper | kBase | kPos, /*width = */ 0, "0"}, + {0, kOct | kInt | kUpper | kBase | kPos, /*width = */ 6, "_____0"}, + {0, kOct | kRight, /*width = */ 0, "0"}, + {0, kOct | kRight, /*width = */ 6, "_____0"}, + {0, kOct | kRight | kPos, /*width = */ 0, "0"}, + {0, kOct | kRight | kPos, /*width = */ 6, "_____0"}, + {0, kOct | kRight | kBase, /*width = */ 0, "0"}, + {0, kOct | kRight | kBase, /*width = */ 6, "_____0"}, + {0, kOct | kRight | kBase | kPos, /*width = */ 0, "0"}, + {0, kOct | kRight | kBase | kPos, /*width = */ 6, "_____0"}, + {0, kOct | kRight | kUpper, /*width = */ 0, "0"}, + {0, kOct | kRight | kUpper, /*width = */ 6, "_____0"}, + {0, kOct | kRight | kUpper | kPos, /*width = */ 0, "0"}, + {0, kOct | kRight | kUpper | kPos, /*width = */ 6, "_____0"}, + {0, kOct | kRight | kUpper | kBase, /*width = */ 0, "0"}, + {0, kOct | kRight | kUpper | kBase, /*width = */ 6, "_____0"}, + {0, kOct | kRight | kUpper | kBase | kPos, /*width = */ 0, "0"}, + {0, kOct | kRight | kUpper | kBase | kPos, /*width = */ 6, "_____0"}, + {0, kHex, /*width = */ 0, "0"}, + {0, kHex, /*width = */ 6, "_____0"}, + {0, kHex | kPos, /*width = */ 0, "0"}, + {0, kHex | kPos, /*width = */ 6, "_____0"}, + {0, kHex | kBase, /*width = */ 0, "0"}, + {0, kHex | kBase, /*width = */ 6, "_____0"}, + {0, kHex | kBase | kPos, /*width = */ 0, "0"}, + {0, kHex | kBase | kPos, /*width = */ 6, "_____0"}, + {0, kHex | kUpper, /*width = */ 0, "0"}, + {0, kHex | kUpper, /*width = */ 6, "_____0"}, + {0, kHex | kUpper | kPos, /*width = */ 0, "0"}, + {0, kHex | kUpper | kPos, /*width = */ 6, "_____0"}, + {0, kHex | kUpper | kBase, /*width = */ 0, "0"}, + {0, kHex | kUpper | kBase, /*width = */ 6, "_____0"}, + {0, kHex | kUpper | kBase | kPos, /*width = */ 0, "0"}, + {0, kHex | kUpper | kBase | kPos, /*width = */ 6, "_____0"}, + {0, kHex | kLeft, /*width = */ 0, "0"}, + {0, kHex | kLeft, /*width = */ 6, "0_____"}, + {0, kHex | kLeft | kPos, /*width = */ 0, "0"}, + {0, kHex | kLeft | kPos, /*width = */ 6, "0_____"}, + {0, kHex | kLeft | kBase, /*width = */ 0, "0"}, + {0, kHex | kLeft | kBase, /*width = */ 6, "0_____"}, + {0, kHex | kLeft | kBase | kPos, /*width = */ 0, "0"}, + {0, kHex | kLeft | kBase | kPos, /*width = */ 6, "0_____"}, + {0, kHex | kLeft | kUpper, /*width = */ 0, "0"}, + {0, kHex | kLeft | kUpper, /*width = */ 6, "0_____"}, + {0, kHex | kLeft | kUpper | kPos, /*width = */ 0, "0"}, + {0, kHex | kLeft | kUpper | kPos, /*width = */ 6, "0_____"}, + {0, kHex | kLeft | kUpper | kBase, /*width = */ 0, "0"}, + {0, kHex | kLeft | kUpper | kBase, /*width = */ 6, "0_____"}, + {0, kHex | kLeft | kUpper | kBase | kPos, /*width = */ 0, "0"}, + {0, kHex | kLeft | kUpper | kBase | kPos, /*width = */ 6, "0_____"}, + {0, kHex | kInt, /*width = */ 0, "0"}, + {0, kHex | kInt, /*width = */ 6, "_____0"}, + {0, kHex | kInt | kPos, /*width = */ 0, "0"}, + {0, kHex | kInt | kPos, /*width = */ 6, "_____0"}, + {0, kHex | kInt | kBase, /*width = */ 0, "0"}, + {0, kHex | kInt | kBase, /*width = */ 6, "_____0"}, + {0, kHex | kInt | kBase | kPos, /*width = */ 0, "0"}, + {0, kHex | kInt | kBase | kPos, /*width = */ 6, "_____0"}, + {0, kHex | kInt | kUpper, /*width = */ 0, "0"}, + {0, kHex | kInt | kUpper, /*width = */ 6, "_____0"}, + {0, kHex | kInt | kUpper | kPos, /*width = */ 0, "0"}, + {0, kHex | kInt | kUpper | kPos, /*width = */ 6, "_____0"}, + {0, kHex | kInt | kUpper | kBase, /*width = */ 0, "0"}, + {0, kHex | kInt | kUpper | kBase, /*width = */ 6, "_____0"}, + {0, kHex | kInt | kUpper | kBase | kPos, /*width = */ 0, "0"}, + {0, kHex | kInt | kUpper | kBase | kPos, /*width = */ 6, "_____0"}, + {0, kHex | kRight, /*width = */ 0, "0"}, + {0, kHex | kRight, /*width = */ 6, "_____0"}, + {0, kHex | kRight | kPos, /*width = */ 0, "0"}, + {0, kHex | kRight | kPos, /*width = */ 6, "_____0"}, + {0, kHex | kRight | kBase, /*width = */ 0, "0"}, + {0, kHex | kRight | kBase, /*width = */ 6, "_____0"}, + {0, kHex | kRight | kBase | kPos, /*width = */ 0, "0"}, + {0, kHex | kRight | kBase | kPos, /*width = */ 6, "_____0"}, + {0, kHex | kRight | kUpper, /*width = */ 0, "0"}, + {0, kHex | kRight | kUpper, /*width = */ 6, "_____0"}, + {0, kHex | kRight | kUpper | kPos, /*width = */ 0, "0"}, + {0, kHex | kRight | kUpper | kPos, /*width = */ 6, "_____0"}, + {0, kHex | kRight | kUpper | kBase, /*width = */ 0, "0"}, + {0, kHex | kRight | kUpper | kBase, /*width = */ 6, "_____0"}, + {0, kHex | kRight | kUpper | kBase | kPos, /*width = */ 0, "0"}, + {0, kHex | kRight | kUpper | kBase | kPos, /*width = */ 6, "_____0"}, + {42, std::ios_base::fmtflags(), /*width = */ 0, "42"}, + {42, std::ios_base::fmtflags(), /*width = */ 6, "____42"}, + {42, kPos, /*width = */ 0, "+42"}, + {42, kPos, /*width = */ 6, "___+42"}, + {42, kBase, /*width = */ 0, "42"}, + {42, kBase, /*width = */ 6, "____42"}, + {42, kBase | kPos, /*width = */ 0, "+42"}, + {42, kBase | kPos, /*width = */ 6, "___+42"}, + {42, kUpper, /*width = */ 0, "42"}, + {42, kUpper, /*width = */ 6, "____42"}, + {42, kUpper | kPos, /*width = */ 0, "+42"}, + {42, kUpper | kPos, /*width = */ 6, "___+42"}, + {42, kUpper | kBase, /*width = */ 0, "42"}, + {42, kUpper | kBase, /*width = */ 6, "____42"}, + {42, kUpper | kBase | kPos, /*width = */ 0, "+42"}, + {42, kUpper | kBase | kPos, /*width = */ 6, "___+42"}, + {42, kLeft, /*width = */ 0, "42"}, + {42, kLeft, /*width = */ 6, "42____"}, + {42, kLeft | kPos, /*width = */ 0, "+42"}, + {42, kLeft | kPos, /*width = */ 6, "+42___"}, + {42, kLeft | kBase, /*width = */ 0, "42"}, + {42, kLeft | kBase, /*width = */ 6, "42____"}, + {42, kLeft | kBase | kPos, /*width = */ 0, "+42"}, + {42, kLeft | kBase | kPos, /*width = */ 6, "+42___"}, + {42, kLeft | kUpper, /*width = */ 0, "42"}, + {42, kLeft | kUpper, /*width = */ 6, "42____"}, + {42, kLeft | kUpper | kPos, /*width = */ 0, "+42"}, + {42, kLeft | kUpper | kPos, /*width = */ 6, "+42___"}, + {42, kLeft | kUpper | kBase, /*width = */ 0, "42"}, + {42, kLeft | kUpper | kBase, /*width = */ 6, "42____"}, + {42, kLeft | kUpper | kBase | kPos, /*width = */ 0, "+42"}, + {42, kLeft | kUpper | kBase | kPos, /*width = */ 6, "+42___"}, + {42, kInt, /*width = */ 0, "42"}, + {42, kInt, /*width = */ 6, "____42"}, + {42, kInt | kPos, /*width = */ 0, "+42"}, + {42, kInt | kPos, /*width = */ 6, "+___42"}, + {42, kInt | kBase, /*width = */ 0, "42"}, + {42, kInt | kBase, /*width = */ 6, "____42"}, + {42, kInt | kBase | kPos, /*width = */ 0, "+42"}, + {42, kInt | kBase | kPos, /*width = */ 6, "+___42"}, + {42, kInt | kUpper, /*width = */ 0, "42"}, + {42, kInt | kUpper, /*width = */ 6, "____42"}, + {42, kInt | kUpper | kPos, /*width = */ 0, "+42"}, + {42, kInt | kUpper | kPos, /*width = */ 6, "+___42"}, + {42, kInt | kUpper | kBase, /*width = */ 0, "42"}, + {42, kInt | kUpper | kBase, /*width = */ 6, "____42"}, + {42, kInt | kUpper | kBase | kPos, /*width = */ 0, "+42"}, + {42, kInt | kUpper | kBase | kPos, /*width = */ 6, "+___42"}, + {42, kRight, /*width = */ 0, "42"}, + {42, kRight, /*width = */ 6, "____42"}, + {42, kRight | kPos, /*width = */ 0, "+42"}, + {42, kRight | kPos, /*width = */ 6, "___+42"}, + {42, kRight | kBase, /*width = */ 0, "42"}, + {42, kRight | kBase, /*width = */ 6, "____42"}, + {42, kRight | kBase | kPos, /*width = */ 0, "+42"}, + {42, kRight | kBase | kPos, /*width = */ 6, "___+42"}, + {42, kRight | kUpper, /*width = */ 0, "42"}, + {42, kRight | kUpper, /*width = */ 6, "____42"}, + {42, kRight | kUpper | kPos, /*width = */ 0, "+42"}, + {42, kRight | kUpper | kPos, /*width = */ 6, "___+42"}, + {42, kRight | kUpper | kBase, /*width = */ 0, "42"}, + {42, kRight | kUpper | kBase, /*width = */ 6, "____42"}, + {42, kRight | kUpper | kBase | kPos, /*width = */ 0, "+42"}, + {42, kRight | kUpper | kBase | kPos, /*width = */ 6, "___+42"}, + {42, kDec, /*width = */ 0, "42"}, + {42, kDec, /*width = */ 6, "____42"}, + {42, kDec | kPos, /*width = */ 0, "+42"}, + {42, kDec | kPos, /*width = */ 6, "___+42"}, + {42, kDec | kBase, /*width = */ 0, "42"}, + {42, kDec | kBase, /*width = */ 6, "____42"}, + {42, kDec | kBase | kPos, /*width = */ 0, "+42"}, + {42, kDec | kBase | kPos, /*width = */ 6, "___+42"}, + {42, kDec | kUpper, /*width = */ 0, "42"}, + {42, kDec | kUpper, /*width = */ 6, "____42"}, + {42, kDec | kUpper | kPos, /*width = */ 0, "+42"}, + {42, kDec | kUpper | kPos, /*width = */ 6, "___+42"}, + {42, kDec | kUpper | kBase, /*width = */ 0, "42"}, + {42, kDec | kUpper | kBase, /*width = */ 6, "____42"}, + {42, kDec | kUpper | kBase | kPos, /*width = */ 0, "+42"}, + {42, kDec | kUpper | kBase | kPos, /*width = */ 6, "___+42"}, + {42, kDec | kLeft, /*width = */ 0, "42"}, + {42, kDec | kLeft, /*width = */ 6, "42____"}, + {42, kDec | kLeft | kPos, /*width = */ 0, "+42"}, + {42, kDec | kLeft | kPos, /*width = */ 6, "+42___"}, + {42, kDec | kLeft | kBase, /*width = */ 0, "42"}, + {42, kDec | kLeft | kBase, /*width = */ 6, "42____"}, + {42, kDec | kLeft | kBase | kPos, /*width = */ 0, "+42"}, + {42, kDec | kLeft | kBase | kPos, /*width = */ 6, "+42___"}, + {42, kDec | kLeft | kUpper, /*width = */ 0, "42"}, + {42, kDec | kLeft | kUpper, /*width = */ 6, "42____"}, + {42, kDec | kLeft | kUpper | kPos, /*width = */ 0, "+42"}, + {42, kDec | kLeft | kUpper | kPos, /*width = */ 6, "+42___"}, + {42, kDec | kLeft | kUpper | kBase, /*width = */ 0, "42"}, + {42, kDec | kLeft | kUpper | kBase, /*width = */ 6, "42____"}, + {42, kDec | kLeft | kUpper | kBase | kPos, /*width = */ 0, "+42"}, + {42, kDec | kLeft | kUpper | kBase | kPos, /*width = */ 6, "+42___"}, + {42, kDec | kInt, /*width = */ 0, "42"}, + {42, kDec | kInt, /*width = */ 6, "____42"}, + {42, kDec | kInt | kPos, /*width = */ 0, "+42"}, + {42, kDec | kInt | kPos, /*width = */ 6, "+___42"}, + {42, kDec | kInt | kBase, /*width = */ 0, "42"}, + {42, kDec | kInt | kBase, /*width = */ 6, "____42"}, + {42, kDec | kInt | kBase | kPos, /*width = */ 0, "+42"}, + {42, kDec | kInt | kBase | kPos, /*width = */ 6, "+___42"}, + {42, kDec | kInt | kUpper, /*width = */ 0, "42"}, + {42, kDec | kInt | kUpper, /*width = */ 6, "____42"}, + {42, kDec | kInt | kUpper | kPos, /*width = */ 0, "+42"}, + {42, kDec | kInt | kUpper | kPos, /*width = */ 6, "+___42"}, + {42, kDec | kInt | kUpper | kBase, /*width = */ 0, "42"}, + {42, kDec | kInt | kUpper | kBase, /*width = */ 6, "____42"}, + {42, kDec | kInt | kUpper | kBase | kPos, /*width = */ 0, "+42"}, + {42, kDec | kInt | kUpper | kBase | kPos, /*width = */ 6, "+___42"}, + {42, kDec | kRight, /*width = */ 0, "42"}, + {42, kDec | kRight, /*width = */ 6, "____42"}, + {42, kDec | kRight | kPos, /*width = */ 0, "+42"}, + {42, kDec | kRight | kPos, /*width = */ 6, "___+42"}, + {42, kDec | kRight | kBase, /*width = */ 0, "42"}, + {42, kDec | kRight | kBase, /*width = */ 6, "____42"}, + {42, kDec | kRight | kBase | kPos, /*width = */ 0, "+42"}, + {42, kDec | kRight | kBase | kPos, /*width = */ 6, "___+42"}, + {42, kDec | kRight | kUpper, /*width = */ 0, "42"}, + {42, kDec | kRight | kUpper, /*width = */ 6, "____42"}, + {42, kDec | kRight | kUpper | kPos, /*width = */ 0, "+42"}, + {42, kDec | kRight | kUpper | kPos, /*width = */ 6, "___+42"}, + {42, kDec | kRight | kUpper | kBase, /*width = */ 0, "42"}, + {42, kDec | kRight | kUpper | kBase, /*width = */ 6, "____42"}, + {42, kDec | kRight | kUpper | kBase | kPos, /*width = */ 0, "+42"}, + {42, kDec | kRight | kUpper | kBase | kPos, /*width = */ 6, "___+42"}, + {42, kOct, /*width = */ 0, "52"}, + {42, kOct, /*width = */ 6, "____52"}, + {42, kOct | kPos, /*width = */ 0, "52"}, + {42, kOct | kPos, /*width = */ 6, "____52"}, + {42, kOct | kBase, /*width = */ 0, "052"}, + {42, kOct | kBase, /*width = */ 6, "___052"}, + {42, kOct | kBase | kPos, /*width = */ 0, "052"}, + {42, kOct | kBase | kPos, /*width = */ 6, "___052"}, + {42, kOct | kUpper, /*width = */ 0, "52"}, + {42, kOct | kUpper, /*width = */ 6, "____52"}, + {42, kOct | kUpper | kPos, /*width = */ 0, "52"}, + {42, kOct | kUpper | kPos, /*width = */ 6, "____52"}, + {42, kOct | kUpper | kBase, /*width = */ 0, "052"}, + {42, kOct | kUpper | kBase, /*width = */ 6, "___052"}, + {42, kOct | kUpper | kBase | kPos, /*width = */ 0, "052"}, + {42, kOct | kUpper | kBase | kPos, /*width = */ 6, "___052"}, + {42, kOct | kLeft, /*width = */ 0, "52"}, + {42, kOct | kLeft, /*width = */ 6, "52____"}, + {42, kOct | kLeft | kPos, /*width = */ 0, "52"}, + {42, kOct | kLeft | kPos, /*width = */ 6, "52____"}, + {42, kOct | kLeft | kBase, /*width = */ 0, "052"}, + {42, kOct | kLeft | kBase, /*width = */ 6, "052___"}, + {42, kOct | kLeft | kBase | kPos, /*width = */ 0, "052"}, + {42, kOct | kLeft | kBase | kPos, /*width = */ 6, "052___"}, + {42, kOct | kLeft | kUpper, /*width = */ 0, "52"}, + {42, kOct | kLeft | kUpper, /*width = */ 6, "52____"}, + {42, kOct | kLeft | kUpper | kPos, /*width = */ 0, "52"}, + {42, kOct | kLeft | kUpper | kPos, /*width = */ 6, "52____"}, + {42, kOct | kLeft | kUpper | kBase, /*width = */ 0, "052"}, + {42, kOct | kLeft | kUpper | kBase, /*width = */ 6, "052___"}, + {42, kOct | kLeft | kUpper | kBase | kPos, /*width = */ 0, "052"}, + {42, kOct | kLeft | kUpper | kBase | kPos, /*width = */ 6, "052___"}, + {42, kOct | kInt, /*width = */ 0, "52"}, + {42, kOct | kInt, /*width = */ 6, "____52"}, + {42, kOct | kInt | kPos, /*width = */ 0, "52"}, + {42, kOct | kInt | kPos, /*width = */ 6, "____52"}, + {42, kOct | kInt | kBase, /*width = */ 0, "052"}, + {42, kOct | kInt | kBase, /*width = */ 6, "___052"}, + {42, kOct | kInt | kBase | kPos, /*width = */ 0, "052"}, + {42, kOct | kInt | kBase | kPos, /*width = */ 6, "___052"}, + {42, kOct | kInt | kUpper, /*width = */ 0, "52"}, + {42, kOct | kInt | kUpper, /*width = */ 6, "____52"}, + {42, kOct | kInt | kUpper | kPos, /*width = */ 0, "52"}, + {42, kOct | kInt | kUpper | kPos, /*width = */ 6, "____52"}, + {42, kOct | kInt | kUpper | kBase, /*width = */ 0, "052"}, + {42, kOct | kInt | kUpper | kBase, /*width = */ 6, "___052"}, + {42, kOct | kInt | kUpper | kBase | kPos, /*width = */ 0, "052"}, + {42, kOct | kInt | kUpper | kBase | kPos, /*width = */ 6, "___052"}, + {42, kOct | kRight, /*width = */ 0, "52"}, + {42, kOct | kRight, /*width = */ 6, "____52"}, + {42, kOct | kRight | kPos, /*width = */ 0, "52"}, + {42, kOct | kRight | kPos, /*width = */ 6, "____52"}, + {42, kOct | kRight | kBase, /*width = */ 0, "052"}, + {42, kOct | kRight | kBase, /*width = */ 6, "___052"}, + {42, kOct | kRight | kBase | kPos, /*width = */ 0, "052"}, + {42, kOct | kRight | kBase | kPos, /*width = */ 6, "___052"}, + {42, kOct | kRight | kUpper, /*width = */ 0, "52"}, + {42, kOct | kRight | kUpper, /*width = */ 6, "____52"}, + {42, kOct | kRight | kUpper | kPos, /*width = */ 0, "52"}, + {42, kOct | kRight | kUpper | kPos, /*width = */ 6, "____52"}, + {42, kOct | kRight | kUpper | kBase, /*width = */ 0, "052"}, + {42, kOct | kRight | kUpper | kBase, /*width = */ 6, "___052"}, + {42, kOct | kRight | kUpper | kBase | kPos, /*width = */ 0, "052"}, + {42, kOct | kRight | kUpper | kBase | kPos, /*width = */ 6, "___052"}, + {42, kHex, /*width = */ 0, "2a"}, + {42, kHex, /*width = */ 6, "____2a"}, + {42, kHex | kPos, /*width = */ 0, "2a"}, + {42, kHex | kPos, /*width = */ 6, "____2a"}, + {42, kHex | kBase, /*width = */ 0, "0x2a"}, + {42, kHex | kBase, /*width = */ 6, "__0x2a"}, + {42, kHex | kBase | kPos, /*width = */ 0, "0x2a"}, + {42, kHex | kBase | kPos, /*width = */ 6, "__0x2a"}, + {42, kHex | kUpper, /*width = */ 0, "2A"}, + {42, kHex | kUpper, /*width = */ 6, "____2A"}, + {42, kHex | kUpper | kPos, /*width = */ 0, "2A"}, + {42, kHex | kUpper | kPos, /*width = */ 6, "____2A"}, + {42, kHex | kUpper | kBase, /*width = */ 0, "0X2A"}, + {42, kHex | kUpper | kBase, /*width = */ 6, "__0X2A"}, + {42, kHex | kUpper | kBase | kPos, /*width = */ 0, "0X2A"}, + {42, kHex | kUpper | kBase | kPos, /*width = */ 6, "__0X2A"}, + {42, kHex | kLeft, /*width = */ 0, "2a"}, + {42, kHex | kLeft, /*width = */ 6, "2a____"}, + {42, kHex | kLeft | kPos, /*width = */ 0, "2a"}, + {42, kHex | kLeft | kPos, /*width = */ 6, "2a____"}, + {42, kHex | kLeft | kBase, /*width = */ 0, "0x2a"}, + {42, kHex | kLeft | kBase, /*width = */ 6, "0x2a__"}, + {42, kHex | kLeft | kBase | kPos, /*width = */ 0, "0x2a"}, + {42, kHex | kLeft | kBase | kPos, /*width = */ 6, "0x2a__"}, + {42, kHex | kLeft | kUpper, /*width = */ 0, "2A"}, + {42, kHex | kLeft | kUpper, /*width = */ 6, "2A____"}, + {42, kHex | kLeft | kUpper | kPos, /*width = */ 0, "2A"}, + {42, kHex | kLeft | kUpper | kPos, /*width = */ 6, "2A____"}, + {42, kHex | kLeft | kUpper | kBase, /*width = */ 0, "0X2A"}, + {42, kHex | kLeft | kUpper | kBase, /*width = */ 6, "0X2A__"}, + {42, kHex | kLeft | kUpper | kBase | kPos, /*width = */ 0, "0X2A"}, + {42, kHex | kLeft | kUpper | kBase | kPos, /*width = */ 6, "0X2A__"}, + {42, kHex | kInt, /*width = */ 0, "2a"}, + {42, kHex | kInt, /*width = */ 6, "____2a"}, + {42, kHex | kInt | kPos, /*width = */ 0, "2a"}, + {42, kHex | kInt | kPos, /*width = */ 6, "____2a"}, + {42, kHex | kInt | kBase, /*width = */ 0, "0x2a"}, + {42, kHex | kInt | kBase, /*width = */ 6, "0x__2a"}, + {42, kHex | kInt | kBase | kPos, /*width = */ 0, "0x2a"}, + {42, kHex | kInt | kBase | kPos, /*width = */ 6, "0x__2a"}, + {42, kHex | kInt | kUpper, /*width = */ 0, "2A"}, + {42, kHex | kInt | kUpper, /*width = */ 6, "____2A"}, + {42, kHex | kInt | kUpper | kPos, /*width = */ 0, "2A"}, + {42, kHex | kInt | kUpper | kPos, /*width = */ 6, "____2A"}, + {42, kHex | kInt | kUpper | kBase, /*width = */ 0, "0X2A"}, + {42, kHex | kInt | kUpper | kBase, /*width = */ 6, "0X__2A"}, + {42, kHex | kInt | kUpper | kBase | kPos, /*width = */ 0, "0X2A"}, + {42, kHex | kInt | kUpper | kBase | kPos, /*width = */ 6, "0X__2A"}, + {42, kHex | kRight, /*width = */ 0, "2a"}, + {42, kHex | kRight, /*width = */ 6, "____2a"}, + {42, kHex | kRight | kPos, /*width = */ 0, "2a"}, + {42, kHex | kRight | kPos, /*width = */ 6, "____2a"}, + {42, kHex | kRight | kBase, /*width = */ 0, "0x2a"}, + {42, kHex | kRight | kBase, /*width = */ 6, "__0x2a"}, + {42, kHex | kRight | kBase | kPos, /*width = */ 0, "0x2a"}, + {42, kHex | kRight | kBase | kPos, /*width = */ 6, "__0x2a"}, + {42, kHex | kRight | kUpper, /*width = */ 0, "2A"}, + {42, kHex | kRight | kUpper, /*width = */ 6, "____2A"}, + {42, kHex | kRight | kUpper | kPos, /*width = */ 0, "2A"}, + {42, kHex | kRight | kUpper | kPos, /*width = */ 6, "____2A"}, + {42, kHex | kRight | kUpper | kBase, /*width = */ 0, "0X2A"}, + {42, kHex | kRight | kUpper | kBase, /*width = */ 6, "__0X2A"}, + {42, kHex | kRight | kUpper | kBase | kPos, /*width = */ 0, "0X2A"}, + {42, kHex | kRight | kUpper | kBase | kPos, /*width = */ 6, "__0X2A"}, + {-321, std::ios_base::fmtflags(), /*width = */ 0, "-321"}, + {-321, std::ios_base::fmtflags(), /*width = */ 6, "__-321"}, + {-321, kPos, /*width = */ 0, "-321"}, + {-321, kPos, /*width = */ 6, "__-321"}, + {-321, kBase, /*width = */ 0, "-321"}, + {-321, kBase, /*width = */ 6, "__-321"}, + {-321, kBase | kPos, /*width = */ 0, "-321"}, + {-321, kBase | kPos, /*width = */ 6, "__-321"}, + {-321, kUpper, /*width = */ 0, "-321"}, + {-321, kUpper, /*width = */ 6, "__-321"}, + {-321, kUpper | kPos, /*width = */ 0, "-321"}, + {-321, kUpper | kPos, /*width = */ 6, "__-321"}, + {-321, kUpper | kBase, /*width = */ 0, "-321"}, + {-321, kUpper | kBase, /*width = */ 6, "__-321"}, + {-321, kUpper | kBase | kPos, /*width = */ 0, "-321"}, + {-321, kUpper | kBase | kPos, /*width = */ 6, "__-321"}, + {-321, kLeft, /*width = */ 0, "-321"}, + {-321, kLeft, /*width = */ 6, "-321__"}, + {-321, kLeft | kPos, /*width = */ 0, "-321"}, + {-321, kLeft | kPos, /*width = */ 6, "-321__"}, + {-321, kLeft | kBase, /*width = */ 0, "-321"}, + {-321, kLeft | kBase, /*width = */ 6, "-321__"}, + {-321, kLeft | kBase | kPos, /*width = */ 0, "-321"}, + {-321, kLeft | kBase | kPos, /*width = */ 6, "-321__"}, + {-321, kLeft | kUpper, /*width = */ 0, "-321"}, + {-321, kLeft | kUpper, /*width = */ 6, "-321__"}, + {-321, kLeft | kUpper | kPos, /*width = */ 0, "-321"}, + {-321, kLeft | kUpper | kPos, /*width = */ 6, "-321__"}, + {-321, kLeft | kUpper | kBase, /*width = */ 0, "-321"}, + {-321, kLeft | kUpper | kBase, /*width = */ 6, "-321__"}, + {-321, kLeft | kUpper | kBase | kPos, /*width = */ 0, "-321"}, + {-321, kLeft | kUpper | kBase | kPos, /*width = */ 6, "-321__"}, + {-321, kInt, /*width = */ 0, "-321"}, + {-321, kInt, /*width = */ 6, "-__321"}, + {-321, kInt | kPos, /*width = */ 0, "-321"}, + {-321, kInt | kPos, /*width = */ 6, "-__321"}, + {-321, kInt | kBase, /*width = */ 0, "-321"}, + {-321, kInt | kBase, /*width = */ 6, "-__321"}, + {-321, kInt | kBase | kPos, /*width = */ 0, "-321"}, + {-321, kInt | kBase | kPos, /*width = */ 6, "-__321"}, + {-321, kInt | kUpper, /*width = */ 0, "-321"}, + {-321, kInt | kUpper, /*width = */ 6, "-__321"}, + {-321, kInt | kUpper | kPos, /*width = */ 0, "-321"}, + {-321, kInt | kUpper | kPos, /*width = */ 6, "-__321"}, + {-321, kInt | kUpper | kBase, /*width = */ 0, "-321"}, + {-321, kInt | kUpper | kBase, /*width = */ 6, "-__321"}, + {-321, kInt | kUpper | kBase | kPos, /*width = */ 0, "-321"}, + {-321, kInt | kUpper | kBase | kPos, /*width = */ 6, "-__321"}, + {-321, kRight, /*width = */ 0, "-321"}, + {-321, kRight, /*width = */ 6, "__-321"}, + {-321, kRight | kPos, /*width = */ 0, "-321"}, + {-321, kRight | kPos, /*width = */ 6, "__-321"}, + {-321, kRight | kBase, /*width = */ 0, "-321"}, + {-321, kRight | kBase, /*width = */ 6, "__-321"}, + {-321, kRight | kBase | kPos, /*width = */ 0, "-321"}, + {-321, kRight | kBase | kPos, /*width = */ 6, "__-321"}, + {-321, kRight | kUpper, /*width = */ 0, "-321"}, + {-321, kRight | kUpper, /*width = */ 6, "__-321"}, + {-321, kRight | kUpper | kPos, /*width = */ 0, "-321"}, + {-321, kRight | kUpper | kPos, /*width = */ 6, "__-321"}, + {-321, kRight | kUpper | kBase, /*width = */ 0, "-321"}, + {-321, kRight | kUpper | kBase, /*width = */ 6, "__-321"}, + {-321, kRight | kUpper | kBase | kPos, /*width = */ 0, "-321"}, + {-321, kRight | kUpper | kBase | kPos, /*width = */ 6, "__-321"}, + {-321, kDec, /*width = */ 0, "-321"}, + {-321, kDec, /*width = */ 6, "__-321"}, + {-321, kDec | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kPos, /*width = */ 6, "__-321"}, + {-321, kDec | kBase, /*width = */ 0, "-321"}, + {-321, kDec | kBase, /*width = */ 6, "__-321"}, + {-321, kDec | kBase | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kBase | kPos, /*width = */ 6, "__-321"}, + {-321, kDec | kUpper, /*width = */ 0, "-321"}, + {-321, kDec | kUpper, /*width = */ 6, "__-321"}, + {-321, kDec | kUpper | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kUpper | kPos, /*width = */ 6, "__-321"}, + {-321, kDec | kUpper | kBase, /*width = */ 0, "-321"}, + {-321, kDec | kUpper | kBase, /*width = */ 6, "__-321"}, + {-321, kDec | kUpper | kBase | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kUpper | kBase | kPos, /*width = */ 6, "__-321"}, + {-321, kDec | kLeft, /*width = */ 0, "-321"}, + {-321, kDec | kLeft, /*width = */ 6, "-321__"}, + {-321, kDec | kLeft | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kLeft | kPos, /*width = */ 6, "-321__"}, + {-321, kDec | kLeft | kBase, /*width = */ 0, "-321"}, + {-321, kDec | kLeft | kBase, /*width = */ 6, "-321__"}, + {-321, kDec | kLeft | kBase | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kLeft | kBase | kPos, /*width = */ 6, "-321__"}, + {-321, kDec | kLeft | kUpper, /*width = */ 0, "-321"}, + {-321, kDec | kLeft | kUpper, /*width = */ 6, "-321__"}, + {-321, kDec | kLeft | kUpper | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kLeft | kUpper | kPos, /*width = */ 6, "-321__"}, + {-321, kDec | kLeft | kUpper | kBase, /*width = */ 0, "-321"}, + {-321, kDec | kLeft | kUpper | kBase, /*width = */ 6, "-321__"}, + {-321, kDec | kLeft | kUpper | kBase | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kLeft | kUpper | kBase | kPos, /*width = */ 6, "-321__"}, + {-321, kDec | kInt, /*width = */ 0, "-321"}, + {-321, kDec | kInt, /*width = */ 6, "-__321"}, + {-321, kDec | kInt | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kInt | kPos, /*width = */ 6, "-__321"}, + {-321, kDec | kInt | kBase, /*width = */ 0, "-321"}, + {-321, kDec | kInt | kBase, /*width = */ 6, "-__321"}, + {-321, kDec | kInt | kBase | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kInt | kBase | kPos, /*width = */ 6, "-__321"}, + {-321, kDec | kInt | kUpper, /*width = */ 0, "-321"}, + {-321, kDec | kInt | kUpper, /*width = */ 6, "-__321"}, + {-321, kDec | kInt | kUpper | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kInt | kUpper | kPos, /*width = */ 6, "-__321"}, + {-321, kDec | kInt | kUpper | kBase, /*width = */ 0, "-321"}, + {-321, kDec | kInt | kUpper | kBase, /*width = */ 6, "-__321"}, + {-321, kDec | kInt | kUpper | kBase | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kInt | kUpper | kBase | kPos, /*width = */ 6, "-__321"}, + {-321, kDec | kRight, /*width = */ 0, "-321"}, + {-321, kDec | kRight, /*width = */ 6, "__-321"}, + {-321, kDec | kRight | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kRight | kPos, /*width = */ 6, "__-321"}, + {-321, kDec | kRight | kBase, /*width = */ 0, "-321"}, + {-321, kDec | kRight | kBase, /*width = */ 6, "__-321"}, + {-321, kDec | kRight | kBase | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kRight | kBase | kPos, /*width = */ 6, "__-321"}, + {-321, kDec | kRight | kUpper, /*width = */ 0, "-321"}, + {-321, kDec | kRight | kUpper, /*width = */ 6, "__-321"}, + {-321, kDec | kRight | kUpper | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kRight | kUpper | kPos, /*width = */ 6, "__-321"}, + {-321, kDec | kRight | kUpper | kBase, /*width = */ 0, "-321"}, + {-321, kDec | kRight | kUpper | kBase, /*width = */ 6, "__-321"}, + {-321, kDec | kRight | kUpper | kBase | kPos, /*width = */ 0, "-321"}, + {-321, kDec | kRight | kUpper | kBase | kPos, /*width = */ 6, "__-321"}}; +} + std::vector<Uint128TestCase> GetUint128FormatCases() { return { {0, std::ios_base::fmtflags(), /*width = */ 0, "0"},
diff --git a/third_party/abseil-cpp/absl/numeric/int128_test.cc b/third_party/abseil-cpp/absl/numeric/int128_test.cc index 5e1b5ec..bc86c71 100644 --- a/third_party/abseil-cpp/absl/numeric/int128_test.cc +++ b/third_party/abseil-cpp/absl/numeric/int128_test.cc
@@ -479,4 +479,747 @@ })); } + +TEST(Int128Uint128, ConversionTest) { + absl::int128 nonnegative_signed_values[] = { + 0, + 1, + 0xffeeddccbbaa9988, + absl::MakeInt128(0x7766554433221100, 0), + absl::MakeInt128(0x1234567890abcdef, 0xfedcba0987654321), + absl::Int128Max()}; + for (absl::int128 value : nonnegative_signed_values) { + EXPECT_EQ(value, absl::int128(absl::uint128(value))); + + absl::uint128 assigned_value; + assigned_value = value; + EXPECT_EQ(value, absl::int128(assigned_value)); + } + + absl::int128 negative_values[] = { + -1, -0x1234567890abcdef, + absl::MakeInt128(-0x5544332211ffeedd, 0), + -absl::MakeInt128(0x76543210fedcba98, 0xabcdef0123456789)}; + for (absl::int128 value : negative_values) { + EXPECT_EQ(absl::uint128(-value), -absl::uint128(value)); + + absl::uint128 assigned_value; + assigned_value = value; + EXPECT_EQ(absl::uint128(-value), -assigned_value); + } +} + +template <typename T> +class Int128IntegerTraitsTest : public ::testing::Test {}; + +TYPED_TEST_SUITE(Int128IntegerTraitsTest, IntegerTypes); + +TYPED_TEST(Int128IntegerTraitsTest, ConstructAssignTest) { + static_assert(std::is_constructible<absl::int128, TypeParam>::value, + "absl::int128 must be constructible from TypeParam"); + static_assert(std::is_assignable<absl::int128&, TypeParam>::value, + "absl::int128 must be assignable from TypeParam"); + static_assert(!std::is_assignable<TypeParam&, absl::int128>::value, + "TypeParam must not be assignable from absl::int128"); +} + +template <typename T> +class Int128FloatTraitsTest : public ::testing::Test {}; + +TYPED_TEST_SUITE(Int128FloatTraitsTest, FloatingPointTypes); + +TYPED_TEST(Int128FloatTraitsTest, ConstructAssignTest) { + static_assert(std::is_constructible<absl::int128, TypeParam>::value, + "absl::int128 must be constructible from TypeParam"); + static_assert(!std::is_assignable<absl::int128&, TypeParam>::value, + "absl::int128 must not be assignable from TypeParam"); + static_assert(!std::is_assignable<TypeParam&, absl::int128>::value, + "TypeParam must not be assignable from absl::int128"); +} + +#ifdef ABSL_HAVE_INTRINSIC_INT128 +// These type traits done separately as TYPED_TEST requires typeinfo, and not +// all platforms have this for __int128 even though they define the type. +TEST(Int128, IntrinsicTypeTraitsTest) { + static_assert(std::is_constructible<absl::int128, __int128>::value, + "absl::int128 must be constructible from __int128"); + static_assert(std::is_assignable<absl::int128&, __int128>::value, + "absl::int128 must be assignable from __int128"); + static_assert(!std::is_assignable<__int128&, absl::int128>::value, + "__int128 must not be assignable from absl::int128"); + + static_assert(std::is_constructible<absl::int128, unsigned __int128>::value, + "absl::int128 must be constructible from unsigned __int128"); + static_assert(!std::is_assignable<absl::int128&, unsigned __int128>::value, + "absl::int128 must be assignable from unsigned __int128"); + static_assert(!std::is_assignable<unsigned __int128&, absl::int128>::value, + "unsigned __int128 must not be assignable from absl::int128"); +} +#endif // ABSL_HAVE_INTRINSIC_INT128 + +TEST(Int128, TrivialTraitsTest) { + static_assert(absl::is_trivially_default_constructible<absl::int128>::value, + ""); + static_assert(absl::is_trivially_copy_constructible<absl::int128>::value, ""); + static_assert(absl::is_trivially_copy_assignable<absl::int128>::value, ""); + static_assert(std::is_trivially_destructible<absl::int128>::value, ""); +} + +TEST(Int128, BoolConversionTest) { + EXPECT_FALSE(absl::int128(0)); + for (int i = 0; i < 64; ++i) { + EXPECT_TRUE(absl::MakeInt128(0, uint64_t{1} << i)); + } + for (int i = 0; i < 63; ++i) { + EXPECT_TRUE(absl::MakeInt128(int64_t{1} << i, 0)); + } + EXPECT_TRUE(absl::Int128Min()); + + EXPECT_EQ(absl::int128(1), absl::int128(true)); + EXPECT_EQ(absl::int128(0), absl::int128(false)); +} + +template <typename T> +class Int128IntegerConversionTest : public ::testing::Test {}; + +TYPED_TEST_SUITE(Int128IntegerConversionTest, IntegerTypes); + +TYPED_TEST(Int128IntegerConversionTest, RoundTripTest) { + EXPECT_EQ(TypeParam{0}, static_cast<TypeParam>(absl::int128(0))); + EXPECT_EQ(std::numeric_limits<TypeParam>::min(), + static_cast<TypeParam>( + absl::int128(std::numeric_limits<TypeParam>::min()))); + EXPECT_EQ(std::numeric_limits<TypeParam>::max(), + static_cast<TypeParam>( + absl::int128(std::numeric_limits<TypeParam>::max()))); +} + +template <typename T> +class Int128FloatConversionTest : public ::testing::Test {}; + +TYPED_TEST_SUITE(Int128FloatConversionTest, FloatingPointTypes); + +TYPED_TEST(Int128FloatConversionTest, ConstructAndCastTest) { + // Conversions where the floating point values should be exactly the same. + // 0x9f5b is a randomly chosen small value. + for (int i = 0; i < 110; ++i) { // 110 = 126 - #bits in 0x9f5b + SCOPED_TRACE(::testing::Message() << "i = " << i); + + TypeParam float_value = std::ldexp(static_cast<TypeParam>(0x9f5b), i); + absl::int128 int_value = absl::int128(0x9f5b) << i; + + EXPECT_EQ(float_value, static_cast<TypeParam>(int_value)); + EXPECT_EQ(-float_value, static_cast<TypeParam>(-int_value)); + EXPECT_EQ(int_value, absl::int128(float_value)); + EXPECT_EQ(-int_value, absl::int128(-float_value)); + } + + // Round trip conversions with a small sample of randomly generated uint64_t + // values (less than int64_t max so that value * 2^64 fits into int128). + uint64_t values[] = {0x6d4492c24fb86199, 0x26ead65e4cb359b5, + 0x2c43407433ba3fd1, 0x3b574ec668df6b55, + 0x1c750e55a29f4f0f}; + for (uint64_t value : values) { + for (int i = 0; i <= 64; ++i) { + SCOPED_TRACE(::testing::Message() + << "value = " << value << "; i = " << i); + + TypeParam fvalue = std::ldexp(static_cast<TypeParam>(value), i); + EXPECT_DOUBLE_EQ(fvalue, static_cast<TypeParam>(absl::int128(fvalue))); + EXPECT_DOUBLE_EQ(-fvalue, static_cast<TypeParam>(-absl::int128(fvalue))); + EXPECT_DOUBLE_EQ(-fvalue, static_cast<TypeParam>(absl::int128(-fvalue))); + EXPECT_DOUBLE_EQ(fvalue, static_cast<TypeParam>(-absl::int128(-fvalue))); + } + } + + // Round trip conversions with a small sample of random large positive values. + absl::int128 large_values[] = { + absl::MakeInt128(0x5b0640d96c7b3d9f, 0xb7a7189e51d18622), + absl::MakeInt128(0x34bed042c6f65270, 0x73b236570669a089), + absl::MakeInt128(0x43deba9e6da12724, 0xf7f0f83da686797d), + absl::MakeInt128(0x71e8d383be4e5589, 0x75c3f96fb00752b6)}; + for (absl::int128 value : large_values) { + // Make value have as many significant bits as can be represented by + // the mantissa, also making sure the highest and lowest bit in the range + // are set. + value >>= (127 - std::numeric_limits<TypeParam>::digits); + value |= absl::int128(1) << (std::numeric_limits<TypeParam>::digits - 1); + value |= 1; + for (int i = 0; i < 127 - std::numeric_limits<TypeParam>::digits; ++i) { + absl::int128 int_value = value << i; + EXPECT_EQ(int_value, + static_cast<absl::int128>(static_cast<TypeParam>(int_value))); + EXPECT_EQ(-int_value, + static_cast<absl::int128>(static_cast<TypeParam>(-int_value))); + } + } + + // Small sample of checks that rounding is toward zero + EXPECT_EQ(0, absl::int128(TypeParam(0.1))); + EXPECT_EQ(17, absl::int128(TypeParam(17.8))); + EXPECT_EQ(0, absl::int128(TypeParam(-0.8))); + EXPECT_EQ(-53, absl::int128(TypeParam(-53.1))); + EXPECT_EQ(0, absl::int128(TypeParam(0.5))); + EXPECT_EQ(0, absl::int128(TypeParam(-0.5))); + TypeParam just_lt_one = std::nexttoward(TypeParam(1), TypeParam(0)); + EXPECT_EQ(0, absl::int128(just_lt_one)); + TypeParam just_gt_minus_one = std::nexttoward(TypeParam(-1), TypeParam(0)); + EXPECT_EQ(0, absl::int128(just_gt_minus_one)); + + // Check limits + EXPECT_DOUBLE_EQ(std::ldexp(static_cast<TypeParam>(1), 127), + static_cast<TypeParam>(absl::Int128Max())); + EXPECT_DOUBLE_EQ(-std::ldexp(static_cast<TypeParam>(1), 127), + static_cast<TypeParam>(absl::Int128Min())); +} + +TEST(Int128, FactoryTest) { + EXPECT_EQ(absl::int128(-1), absl::MakeInt128(-1, -1)); + EXPECT_EQ(absl::int128(-31), absl::MakeInt128(-1, -31)); + EXPECT_EQ(absl::int128(std::numeric_limits<int64_t>::min()), + absl::MakeInt128(-1, std::numeric_limits<int64_t>::min())); + EXPECT_EQ(absl::int128(0), absl::MakeInt128(0, 0)); + EXPECT_EQ(absl::int128(1), absl::MakeInt128(0, 1)); + EXPECT_EQ(absl::int128(std::numeric_limits<int64_t>::max()), + absl::MakeInt128(0, std::numeric_limits<int64_t>::max())); +} + +TEST(Int128, HighLowTest) { + struct HighLowPair { + int64_t high; + uint64_t low; + }; + HighLowPair values[]{{0, 0}, {0, 1}, {1, 0}, {123, 456}, {-654, 321}}; + for (const HighLowPair& pair : values) { + absl::int128 value = absl::MakeInt128(pair.high, pair.low); + EXPECT_EQ(pair.low, absl::Int128Low64(value)); + EXPECT_EQ(pair.high, absl::Int128High64(value)); + } +} + +TEST(Int128, LimitsTest) { + EXPECT_EQ(absl::MakeInt128(0x7fffffffffffffff, 0xffffffffffffffff), + absl::Int128Max()); + EXPECT_EQ(absl::Int128Max(), ~absl::Int128Min()); +} + +#if defined(ABSL_HAVE_INTRINSIC_INT128) +TEST(Int128, IntrinsicConversionTest) { + __int128 intrinsic = + (static_cast<__int128>(0x3a5b76c209de76f6) << 64) + 0x1f25e1d63a2b46c5; + absl::int128 custom = + absl::MakeInt128(0x3a5b76c209de76f6, 0x1f25e1d63a2b46c5); + + EXPECT_EQ(custom, absl::int128(intrinsic)); + EXPECT_EQ(intrinsic, static_cast<__int128>(custom)); +} +#endif // ABSL_HAVE_INTRINSIC_INT128 + +TEST(Int128, ConstexprTest) { + constexpr absl::int128 zero = absl::int128(); + constexpr absl::int128 one = 1; + constexpr absl::int128 minus_two = -2; + constexpr absl::int128 min = absl::Int128Min(); + constexpr absl::int128 max = absl::Int128Max(); + EXPECT_EQ(zero, absl::int128(0)); + EXPECT_EQ(one, absl::int128(1)); + EXPECT_EQ(minus_two, absl::MakeInt128(-1, -2)); + EXPECT_GT(max, one); + EXPECT_LT(min, minus_two); +} + +TEST(Int128, ComparisonTest) { + struct TestCase { + absl::int128 smaller; + absl::int128 larger; + }; + TestCase cases[] = { + {absl::int128(0), absl::int128(123)}, + {absl::MakeInt128(-12, 34), absl::MakeInt128(12, 34)}, + {absl::MakeInt128(1, 1000), absl::MakeInt128(1000, 1)}, + {absl::MakeInt128(-1000, 1000), absl::MakeInt128(-1, 1)}, + }; + for (const TestCase& pair : cases) { + SCOPED_TRACE(::testing::Message() << "pair.smaller = " << pair.smaller + << "; pair.larger = " << pair.larger); + + EXPECT_TRUE(pair.smaller == pair.smaller); // NOLINT(readability/check) + EXPECT_TRUE(pair.larger == pair.larger); // NOLINT(readability/check) + EXPECT_FALSE(pair.smaller == pair.larger); // NOLINT(readability/check) + + EXPECT_TRUE(pair.smaller != pair.larger); // NOLINT(readability/check) + EXPECT_FALSE(pair.smaller != pair.smaller); // NOLINT(readability/check) + EXPECT_FALSE(pair.larger != pair.larger); // NOLINT(readability/check) + + EXPECT_TRUE(pair.smaller < pair.larger); // NOLINT(readability/check) + EXPECT_FALSE(pair.larger < pair.smaller); // NOLINT(readability/check) + + EXPECT_TRUE(pair.larger > pair.smaller); // NOLINT(readability/check) + EXPECT_FALSE(pair.smaller > pair.larger); // NOLINT(readability/check) + + EXPECT_TRUE(pair.smaller <= pair.larger); // NOLINT(readability/check) + EXPECT_FALSE(pair.larger <= pair.smaller); // NOLINT(readability/check) + EXPECT_TRUE(pair.smaller <= pair.smaller); // NOLINT(readability/check) + EXPECT_TRUE(pair.larger <= pair.larger); // NOLINT(readability/check) + + EXPECT_TRUE(pair.larger >= pair.smaller); // NOLINT(readability/check) + EXPECT_FALSE(pair.smaller >= pair.larger); // NOLINT(readability/check) + EXPECT_TRUE(pair.smaller >= pair.smaller); // NOLINT(readability/check) + EXPECT_TRUE(pair.larger >= pair.larger); // NOLINT(readability/check) + } +} + +TEST(Int128, UnaryNegationTest) { + int64_t values64[] = {0, 1, 12345, 0x4000000000000000, + std::numeric_limits<int64_t>::max()}; + for (int64_t value : values64) { + SCOPED_TRACE(::testing::Message() << "value = " << value); + + EXPECT_EQ(absl::int128(-value), -absl::int128(value)); + EXPECT_EQ(absl::int128(value), -absl::int128(-value)); + EXPECT_EQ(absl::MakeInt128(-value, 0), -absl::MakeInt128(value, 0)); + EXPECT_EQ(absl::MakeInt128(value, 0), -absl::MakeInt128(-value, 0)); + } +} + +TEST(Int128, LogicalNotTest) { + EXPECT_TRUE(!absl::int128(0)); + for (int i = 0; i < 64; ++i) { + EXPECT_FALSE(!absl::MakeInt128(0, uint64_t{1} << i)); + } + for (int i = 0; i < 63; ++i) { + EXPECT_FALSE(!absl::MakeInt128(int64_t{1} << i, 0)); + } +} + +TEST(Int128, AdditionSubtractionTest) { + // 64 bit pairs that will not cause overflow / underflow. These test negative + // carry; positive carry must be checked separately. + std::pair<int64_t, int64_t> cases[]{ + {0, 0}, // 0, 0 + {0, 2945781290834}, // 0, + + {1908357619234, 0}, // +, 0 + {0, -1204895918245}, // 0, - + {-2957928523560, 0}, // -, 0 + {89023982312461, 98346012567134}, // +, + + {-63454234568239, -23456235230773}, // -, - + {98263457263502, -21428561935925}, // +, - + {-88235237438467, 15923659234573}, // -, + + }; + for (const auto& pair : cases) { + SCOPED_TRACE(::testing::Message() + << "pair = {" << pair.first << ", " << pair.second << '}'); + + EXPECT_EQ(absl::int128(pair.first + pair.second), + absl::int128(pair.first) + absl::int128(pair.second)); + EXPECT_EQ(absl::int128(pair.second + pair.first), + absl::int128(pair.second) += absl::int128(pair.first)); + + EXPECT_EQ(absl::int128(pair.first - pair.second), + absl::int128(pair.first) - absl::int128(pair.second)); + EXPECT_EQ(absl::int128(pair.second - pair.first), + absl::int128(pair.second) -= absl::int128(pair.first)); + + EXPECT_EQ( + absl::MakeInt128(pair.second + pair.first, 0), + absl::MakeInt128(pair.second, 0) + absl::MakeInt128(pair.first, 0)); + EXPECT_EQ( + absl::MakeInt128(pair.first + pair.second, 0), + absl::MakeInt128(pair.first, 0) += absl::MakeInt128(pair.second, 0)); + + EXPECT_EQ( + absl::MakeInt128(pair.second - pair.first, 0), + absl::MakeInt128(pair.second, 0) - absl::MakeInt128(pair.first, 0)); + EXPECT_EQ( + absl::MakeInt128(pair.first - pair.second, 0), + absl::MakeInt128(pair.first, 0) -= absl::MakeInt128(pair.second, 0)); + } + + // check positive carry + EXPECT_EQ(absl::MakeInt128(31, 0), + absl::MakeInt128(20, 1) + + absl::MakeInt128(10, std::numeric_limits<uint64_t>::max())); +} + +TEST(Int128, IncrementDecrementTest) { + absl::int128 value = 0; + EXPECT_EQ(0, value++); + EXPECT_EQ(1, value); + EXPECT_EQ(1, value--); + EXPECT_EQ(0, value); + EXPECT_EQ(-1, --value); + EXPECT_EQ(-1, value); + EXPECT_EQ(0, ++value); + EXPECT_EQ(0, value); +} + +TEST(Int128, MultiplicationTest) { + // 1 bit x 1 bit, and negative combinations + for (int i = 0; i < 64; ++i) { + for (int j = 0; j < 127 - i; ++j) { + SCOPED_TRACE(::testing::Message() << "i = " << i << "; j = " << j); + absl::int128 a = absl::int128(1) << i; + absl::int128 b = absl::int128(1) << j; + absl::int128 c = absl::int128(1) << (i + j); + + EXPECT_EQ(c, a * b); + EXPECT_EQ(-c, -a * b); + EXPECT_EQ(-c, a * -b); + EXPECT_EQ(c, -a * -b); + + EXPECT_EQ(c, absl::int128(a) *= b); + EXPECT_EQ(-c, absl::int128(-a) *= b); + EXPECT_EQ(-c, absl::int128(a) *= -b); + EXPECT_EQ(c, absl::int128(-a) *= -b); + } + } + + // Pairs of random values that will not overflow signed 64-bit multiplication + std::pair<int64_t, int64_t> small_values[] = { + {0x5e61, 0xf29f79ca14b4}, // +, + + {0x3e033b, -0x612c0ee549}, // +, - + {-0x052ce7e8, 0x7c728f0f}, // -, + + {-0x3af7054626, -0xfb1e1d}, // -, - + }; + for (const std::pair<int64_t, int64_t>& pair : small_values) { + SCOPED_TRACE(::testing::Message() + << "pair = {" << pair.first << ", " << pair.second << '}'); + + EXPECT_EQ(absl::int128(pair.first * pair.second), + absl::int128(pair.first) * absl::int128(pair.second)); + EXPECT_EQ(absl::int128(pair.first * pair.second), + absl::int128(pair.first) *= absl::int128(pair.second)); + + EXPECT_EQ(absl::MakeInt128(pair.first * pair.second, 0), + absl::MakeInt128(pair.first, 0) * absl::int128(pair.second)); + EXPECT_EQ(absl::MakeInt128(pair.first * pair.second, 0), + absl::MakeInt128(pair.first, 0) *= absl::int128(pair.second)); + } + + // Pairs of positive random values that will not overflow 64-bit + // multiplication and can be left shifted by 32 without overflow + std::pair<int64_t, int64_t> small_values2[] = { + {0x1bb0a110, 0x31487671}, + {0x4792784e, 0x28add7d7}, + {0x7b66553a, 0x11dff8ef}, + }; + for (const std::pair<int64_t, int64_t>& pair : small_values2) { + SCOPED_TRACE(::testing::Message() + << "pair = {" << pair.first << ", " << pair.second << '}'); + + absl::int128 a = absl::int128(pair.first << 32); + absl::int128 b = absl::int128(pair.second << 32); + absl::int128 c = absl::MakeInt128(pair.first * pair.second, 0); + + EXPECT_EQ(c, a * b); + EXPECT_EQ(-c, -a * b); + EXPECT_EQ(-c, a * -b); + EXPECT_EQ(c, -a * -b); + + EXPECT_EQ(c, absl::int128(a) *= b); + EXPECT_EQ(-c, absl::int128(-a) *= b); + EXPECT_EQ(-c, absl::int128(a) *= -b); + EXPECT_EQ(c, absl::int128(-a) *= -b); + } + + // check 0, 1, and -1 behavior with large values + absl::int128 large_values[] = { + {absl::MakeInt128(0xd66f061af02d0408, 0x727d2846cb475b53)}, + {absl::MakeInt128(0x27b8d5ed6104452d, 0x03f8a33b0ee1df4f)}, + {-absl::MakeInt128(0x621b6626b9e8d042, 0x27311ac99df00938)}, + {-absl::MakeInt128(0x34e0656f1e95fb60, 0x4281cfd731257a47)}, + }; + for (absl::int128 value : large_values) { + EXPECT_EQ(0, 0 * value); + EXPECT_EQ(0, value * 0); + EXPECT_EQ(0, absl::int128(0) *= value); + EXPECT_EQ(0, value *= 0); + + EXPECT_EQ(value, 1 * value); + EXPECT_EQ(value, value * 1); + EXPECT_EQ(value, absl::int128(1) *= value); + EXPECT_EQ(value, value *= 1); + + EXPECT_EQ(-value, -1 * value); + EXPECT_EQ(-value, value * -1); + EXPECT_EQ(-value, absl::int128(-1) *= value); + EXPECT_EQ(-value, value *= -1); + } + + // Manually calculated random large value cases + EXPECT_EQ(absl::MakeInt128(0xcd0efd3442219bb, 0xde47c05bcd9df6e1), + absl::MakeInt128(0x7c6448, 0x3bc4285c47a9d253) * 0x1a6037537b); + EXPECT_EQ(-absl::MakeInt128(0x1f8f149850b1e5e6, 0x1e50d6b52d272c3e), + -absl::MakeInt128(0x23, 0x2e68a513ca1b8859) * 0xe5a434cd14866e); + EXPECT_EQ(-absl::MakeInt128(0x55cae732029d1fce, 0xca6474b6423263e4), + 0xa9b98a8ddf66bc * -absl::MakeInt128(0x81, 0x672e58231e2469d7)); + EXPECT_EQ(absl::MakeInt128(0x19c8b7620b507dc4, 0xfec042b71a5f29a4), + -0x3e39341147 * -absl::MakeInt128(0x6a14b2, 0x5ed34cca42327b3c)); + + EXPECT_EQ(absl::MakeInt128(0xcd0efd3442219bb, 0xde47c05bcd9df6e1), + absl::MakeInt128(0x7c6448, 0x3bc4285c47a9d253) *= 0x1a6037537b); + EXPECT_EQ(-absl::MakeInt128(0x1f8f149850b1e5e6, 0x1e50d6b52d272c3e), + -absl::MakeInt128(0x23, 0x2e68a513ca1b8859) *= 0xe5a434cd14866e); + EXPECT_EQ(-absl::MakeInt128(0x55cae732029d1fce, 0xca6474b6423263e4), + absl::int128(0xa9b98a8ddf66bc) *= + -absl::MakeInt128(0x81, 0x672e58231e2469d7)); + EXPECT_EQ(absl::MakeInt128(0x19c8b7620b507dc4, 0xfec042b71a5f29a4), + absl::int128(-0x3e39341147) *= + -absl::MakeInt128(0x6a14b2, 0x5ed34cca42327b3c)); +} + +TEST(Int128, DivisionAndModuloTest) { + // Check against 64 bit division and modulo operators with a sample of + // randomly generated pairs. + std::pair<int64_t, int64_t> small_pairs[] = { + {0x15f2a64138, 0x67da05}, {0x5e56d194af43045f, 0xcf1543fb99}, + {0x15e61ed052036a, -0xc8e6}, {0x88125a341e85, -0xd23fb77683}, + {-0xc06e20, 0x5a}, {-0x4f100219aea3e85d, 0xdcc56cb4efe993}, + {-0x168d629105, -0xa7}, {-0x7b44e92f03ab2375, -0x6516}, + }; + for (const std::pair<int64_t, int64_t>& pair : small_pairs) { + SCOPED_TRACE(::testing::Message() + << "pair = {" << pair.first << ", " << pair.second << '}'); + + absl::int128 dividend = pair.first; + absl::int128 divisor = pair.second; + int64_t quotient = pair.first / pair.second; + int64_t remainder = pair.first % pair.second; + + EXPECT_EQ(quotient, dividend / divisor); + EXPECT_EQ(quotient, absl::int128(dividend) /= divisor); + EXPECT_EQ(remainder, dividend % divisor); + EXPECT_EQ(remainder, absl::int128(dividend) %= divisor); + } + + // Test behavior with 0, 1, and -1 with a sample of randomly generated large + // values. + absl::int128 values[] = { + absl::MakeInt128(0x63d26ee688a962b2, 0x9e1411abda5c1d70), + absl::MakeInt128(0x152f385159d6f986, 0xbf8d48ef63da395d), + -absl::MakeInt128(0x3098d7567030038c, 0x14e7a8a098dc2164), + -absl::MakeInt128(0x49a037aca35c809f, 0xa6a87525480ef330), + }; + for (absl::int128 value : values) { + SCOPED_TRACE(::testing::Message() << "value = " << value); + + EXPECT_EQ(0, 0 / value); + EXPECT_EQ(0, absl::int128(0) /= value); + EXPECT_EQ(0, 0 % value); + EXPECT_EQ(0, absl::int128(0) %= value); + + EXPECT_EQ(value, value / 1); + EXPECT_EQ(value, absl::int128(value) /= 1); + EXPECT_EQ(0, value % 1); + EXPECT_EQ(0, absl::int128(value) %= 1); + + EXPECT_EQ(-value, value / -1); + EXPECT_EQ(-value, absl::int128(value) /= -1); + EXPECT_EQ(0, value % -1); + EXPECT_EQ(0, absl::int128(value) %= -1); + } + + // Min and max values + EXPECT_EQ(0, absl::Int128Max() / absl::Int128Min()); + EXPECT_EQ(absl::Int128Max(), absl::Int128Max() % absl::Int128Min()); + EXPECT_EQ(-1, absl::Int128Min() / absl::Int128Max()); + EXPECT_EQ(-1, absl::Int128Min() % absl::Int128Max()); + + // Power of two division and modulo of random large dividends + absl::int128 positive_values[] = { + absl::MakeInt128(0x21e1a1cc69574620, 0xe7ac447fab2fc869), + absl::MakeInt128(0x32c2ff3ab89e66e8, 0x03379a613fd1ce74), + absl::MakeInt128(0x6f32ca786184dcaf, 0x046f9c9ecb3a9ce1), + absl::MakeInt128(0x1aeb469dd990e0ee, 0xda2740f243cd37eb), + }; + for (absl::int128 value : positive_values) { + for (int i = 0; i < 127; ++i) { + SCOPED_TRACE(::testing::Message() + << "value = " << value << "; i = " << i); + absl::int128 power_of_two = absl::int128(1) << i; + + EXPECT_EQ(value >> i, value / power_of_two); + EXPECT_EQ(value >> i, absl::int128(value) /= power_of_two); + EXPECT_EQ(value & (power_of_two - 1), value % power_of_two); + EXPECT_EQ(value & (power_of_two - 1), + absl::int128(value) %= power_of_two); + } + } + + // Manually calculated cases with random large dividends + struct DivisionModCase { + absl::int128 dividend; + absl::int128 divisor; + absl::int128 quotient; + absl::int128 remainder; + }; + DivisionModCase manual_cases[] = { + {absl::MakeInt128(0x6ada48d489007966, 0x3c9c5c98150d5d69), + absl::MakeInt128(0x8bc308fb, 0x8cb9cc9a3b803344), 0xc3b87e08, + absl::MakeInt128(0x1b7db5e1, 0xd9eca34b7af04b49)}, + {absl::MakeInt128(0xd6946511b5b, 0x4886c5c96546bf5f), + -absl::MakeInt128(0x263b, 0xfd516279efcfe2dc), -0x59cbabf0, + absl::MakeInt128(0x622, 0xf462909155651d1f)}, + {-absl::MakeInt128(0x33db734f9e8d1399, 0x8447ac92482bca4d), 0x37495078240, + -absl::MakeInt128(0xf01f1, 0xbc0368bf9a77eae8), -0x21a508f404d}, + {-absl::MakeInt128(0x13f837b409a07e7d, 0x7fc8e248a7d73560), -0x1b9f, + absl::MakeInt128(0xb9157556d724, 0xb14f635714d7563e), -0x1ade}, + }; + for (const DivisionModCase test_case : manual_cases) { + EXPECT_EQ(test_case.quotient, test_case.dividend / test_case.divisor); + EXPECT_EQ(test_case.quotient, + absl::int128(test_case.dividend) /= test_case.divisor); + EXPECT_EQ(test_case.remainder, test_case.dividend % test_case.divisor); + EXPECT_EQ(test_case.remainder, + absl::int128(test_case.dividend) %= test_case.divisor); + } +} + +TEST(Int128, BitwiseLogicTest) { + EXPECT_EQ(absl::int128(-1), ~absl::int128(0)); + + absl::int128 values[]{ + 0, -1, 0xde400bee05c3ff6b, absl::MakeInt128(0x7f32178dd81d634a, 0), + absl::MakeInt128(0xaf539057055613a9, 0x7d104d7d946c2e4d)}; + for (absl::int128 value : values) { + EXPECT_EQ(value, ~~value); + + EXPECT_EQ(value, value | value); + EXPECT_EQ(value, value & value); + EXPECT_EQ(0, value ^ value); + + EXPECT_EQ(value, absl::int128(value) |= value); + EXPECT_EQ(value, absl::int128(value) &= value); + EXPECT_EQ(0, absl::int128(value) ^= value); + + EXPECT_EQ(value, value | 0); + EXPECT_EQ(0, value & 0); + EXPECT_EQ(value, value ^ 0); + + EXPECT_EQ(absl::int128(-1), value | absl::int128(-1)); + EXPECT_EQ(value, value & absl::int128(-1)); + EXPECT_EQ(~value, value ^ absl::int128(-1)); + } + + // small sample of randomly generated int64_t's + std::pair<int64_t, int64_t> pairs64[]{ + {0x7f86797f5e991af4, 0x1ee30494fb007c97}, + {0x0b278282bacf01af, 0x58780e0a57a49e86}, + {0x059f266ccb93a666, 0x3d5b731bae9286f5}, + {0x63c0c4820f12108c, 0x58166713c12e1c3a}, + {0x381488bb2ed2a66e, 0x2220a3eb76a3698c}, + {0x2a0a0dfb81e06f21, 0x4b60585927f5523c}, + {0x555b1c3a03698537, 0x25478cd19d8e53cb}, + {0x4750f6f27d779225, 0x16397553c6ff05fc}, + }; + for (const std::pair<int64_t, int64_t>& pair : pairs64) { + SCOPED_TRACE(::testing::Message() + << "pair = {" << pair.first << ", " << pair.second << '}'); + + EXPECT_EQ(absl::MakeInt128(~pair.first, ~pair.second), + ~absl::MakeInt128(pair.first, pair.second)); + + EXPECT_EQ(absl::int128(pair.first & pair.second), + absl::int128(pair.first) & absl::int128(pair.second)); + EXPECT_EQ(absl::int128(pair.first | pair.second), + absl::int128(pair.first) | absl::int128(pair.second)); + EXPECT_EQ(absl::int128(pair.first ^ pair.second), + absl::int128(pair.first) ^ absl::int128(pair.second)); + + EXPECT_EQ(absl::int128(pair.first & pair.second), + absl::int128(pair.first) &= absl::int128(pair.second)); + EXPECT_EQ(absl::int128(pair.first | pair.second), + absl::int128(pair.first) |= absl::int128(pair.second)); + EXPECT_EQ(absl::int128(pair.first ^ pair.second), + absl::int128(pair.first) ^= absl::int128(pair.second)); + + EXPECT_EQ( + absl::MakeInt128(pair.first & pair.second, 0), + absl::MakeInt128(pair.first, 0) & absl::MakeInt128(pair.second, 0)); + EXPECT_EQ( + absl::MakeInt128(pair.first | pair.second, 0), + absl::MakeInt128(pair.first, 0) | absl::MakeInt128(pair.second, 0)); + EXPECT_EQ( + absl::MakeInt128(pair.first ^ pair.second, 0), + absl::MakeInt128(pair.first, 0) ^ absl::MakeInt128(pair.second, 0)); + + EXPECT_EQ( + absl::MakeInt128(pair.first & pair.second, 0), + absl::MakeInt128(pair.first, 0) &= absl::MakeInt128(pair.second, 0)); + EXPECT_EQ( + absl::MakeInt128(pair.first | pair.second, 0), + absl::MakeInt128(pair.first, 0) |= absl::MakeInt128(pair.second, 0)); + EXPECT_EQ( + absl::MakeInt128(pair.first ^ pair.second, 0), + absl::MakeInt128(pair.first, 0) ^= absl::MakeInt128(pair.second, 0)); + } +} + +TEST(Int128, BitwiseShiftTest) { + for (int i = 0; i < 64; ++i) { + for (int j = 0; j <= i; ++j) { + // Left shift from j-th bit to i-th bit. + SCOPED_TRACE(::testing::Message() << "i = " << i << "; j = " << j); + EXPECT_EQ(uint64_t{1} << i, absl::int128(uint64_t{1} << j) << (i - j)); + EXPECT_EQ(uint64_t{1} << i, absl::int128(uint64_t{1} << j) <<= (i - j)); + } + } + for (int i = 0; i < 63; ++i) { + for (int j = 0; j < 64; ++j) { + // Left shift from j-th bit to (i + 64)-th bit. + SCOPED_TRACE(::testing::Message() << "i = " << i << "; j = " << j); + EXPECT_EQ(absl::MakeInt128(uint64_t{1} << i, 0), + absl::int128(uint64_t{1} << j) << (i + 64 - j)); + EXPECT_EQ(absl::MakeInt128(uint64_t{1} << i, 0), + absl::int128(uint64_t{1} << j) <<= (i + 64 - j)); + } + for (int j = 0; j <= i; ++j) { + // Left shift from (j + 64)-th bit to (i + 64)-th bit. + SCOPED_TRACE(::testing::Message() << "i = " << i << "; j = " << j); + EXPECT_EQ(absl::MakeInt128(uint64_t{1} << i, 0), + absl::MakeInt128(uint64_t{1} << j, 0) << (i - j)); + EXPECT_EQ(absl::MakeInt128(uint64_t{1} << i, 0), + absl::MakeInt128(uint64_t{1} << j, 0) <<= (i - j)); + } + } + + for (int i = 0; i < 64; ++i) { + for (int j = i; j < 64; ++j) { + // Right shift from j-th bit to i-th bit. + SCOPED_TRACE(::testing::Message() << "i = " << i << "; j = " << j); + EXPECT_EQ(uint64_t{1} << i, absl::int128(uint64_t{1} << j) >> (j - i)); + EXPECT_EQ(uint64_t{1} << i, absl::int128(uint64_t{1} << j) >>= (j - i)); + } + for (int j = 0; j < 63; ++j) { + // Right shift from (j + 64)-th bit to i-th bit. + SCOPED_TRACE(::testing::Message() << "i = " << i << "; j = " << j); + EXPECT_EQ(uint64_t{1} << i, + absl::MakeInt128(uint64_t{1} << j, 0) >> (j + 64 - i)); + EXPECT_EQ(uint64_t{1} << i, + absl::MakeInt128(uint64_t{1} << j, 0) >>= (j + 64 - i)); + } + } + for (int i = 0; i < 63; ++i) { + for (int j = i; j < 63; ++j) { + // Right shift from (j + 64)-th bit to (i + 64)-th bit. + SCOPED_TRACE(::testing::Message() << "i = " << i << "; j = " << j); + EXPECT_EQ(absl::MakeInt128(uint64_t{1} << i, 0), + absl::MakeInt128(uint64_t{1} << j, 0) >> (j - i)); + EXPECT_EQ(absl::MakeInt128(uint64_t{1} << i, 0), + absl::MakeInt128(uint64_t{1} << j, 0) >>= (j - i)); + } + } +} + +TEST(Int128, NumericLimitsTest) { + static_assert(std::numeric_limits<absl::int128>::is_specialized, ""); + static_assert(std::numeric_limits<absl::int128>::is_signed, ""); + static_assert(std::numeric_limits<absl::int128>::is_integer, ""); + EXPECT_EQ(static_cast<int>(127 * std::log10(2)), + std::numeric_limits<absl::int128>::digits10); + EXPECT_EQ(absl::Int128Min(), std::numeric_limits<absl::int128>::min()); + EXPECT_EQ(absl::Int128Min(), std::numeric_limits<absl::int128>::lowest()); + EXPECT_EQ(absl::Int128Max(), std::numeric_limits<absl::int128>::max()); +} + } // namespace
diff --git a/third_party/abseil-cpp/absl/random/BUILD.bazel b/third_party/abseil-cpp/absl/random/BUILD.bazel index f7587bf..f78fbc7 100644 --- a/third_party/abseil-cpp/absl/random/BUILD.bazel +++ b/third_party/abseil-cpp/absl/random/BUILD.bazel
@@ -1,17 +1,32 @@ +# +# Copyright 2019 The Abseil Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # ABSL random-number generation libraries. +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", "ABSL_DEFAULT_LINKOPTS", - "ABSL_EXCEPTIONS_FLAG", - "ABSL_EXCEPTIONS_FLAG_LINKOPTS", "ABSL_TEST_COPTS", ) package(default_visibility = ["//visibility:public"]) -licenses(["notice"]) # Apache 2.0 +licenses(["notice"]) cc_library( name = "random", @@ -52,15 +67,17 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ "//absl/base:base_internal", + "//absl/base:config", "//absl/base:core_headers", "//absl/meta:type_traits", - "//absl/random/internal:distribution_impl", "//absl/random/internal:distributions", "//absl/random/internal:fast_uniform_bits", "//absl/random/internal:fastmath", + "//absl/random/internal:generate_real", "//absl/random/internal:iostream_state_saver", "//absl/random/internal:traits", "//absl/random/internal:uniform_helper", + "//absl/random/internal:wide_multiply", "//absl/strings", "//absl/types:span", ], @@ -70,8 +87,8 @@ name = "seed_gen_exception", srcs = ["seed_gen_exception.cc"], hdrs = ["seed_gen_exception.h"], - copts = ABSL_DEFAULT_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, deps = ["//absl/base:config"], ) @@ -94,6 +111,58 @@ ], ) +cc_library( + name = "bit_gen_ref", + hdrs = ["bit_gen_ref.h"], + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + "//absl/base:core_headers", + "//absl/meta:type_traits", + "//absl/random/internal:distribution_caller", + "//absl/random/internal:fast_uniform_bits", + "//absl/random/internal:mocking_bit_gen_base", + ], +) + +cc_library( + name = "mock_distributions", + testonly = 1, + hdrs = ["mock_distributions.h"], + deps = [ + ":distributions", + ":mocking_bit_gen", + "//absl/meta:type_traits", + "//absl/random/internal:mock_overload_set", + "@com_google_googletest//:gtest", + ], +) + +cc_library( + name = "mocking_bit_gen", + testonly = 1, + srcs = [ + "mocking_bit_gen.cc", + ], + hdrs = [ + "mocking_bit_gen.h", + ], + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + ":distributions", + "//absl/base:raw_logging_internal", + "//absl/container:flat_hash_map", + "//absl/meta:type_traits", + "//absl/random/internal:distribution_caller", + "//absl/random/internal:mocking_bit_gen_base", + "//absl/strings", + "//absl/types:span", + "//absl/types:variant", + "//absl/utility", + "@com_google_googletest//:gtest", + ], +) + cc_test( name = "bernoulli_distribution_test", size = "small", @@ -115,11 +184,12 @@ timeout = "eternal", # Android can take a very long time srcs = ["beta_distribution_test.cc"], copts = ABSL_TEST_COPTS, + flaky = 1, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":distributions", ":random", - "//absl/base", + "//absl/base:raw_logging_internal", "//absl/random/internal:distribution_test_util", "//absl/random/internal:sequence_urbg", "//absl/strings", @@ -168,8 +238,8 @@ deps = [ ":distributions", ":random", - "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "//absl/random/internal:distribution_test_util", "//absl/random/internal:sequence_urbg", "//absl/strings", @@ -189,7 +259,7 @@ deps = [ ":distributions", ":random", - "//absl/base", + "//absl/base:raw_logging_internal", "//absl/random/internal:distribution_test_util", "//absl/random/internal:sequence_urbg", "//absl/strings", @@ -214,8 +284,8 @@ deps = [ ":distributions", ":random", - "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "//absl/container:flat_hash_map", "//absl/random/internal:distribution_test_util", "//absl/random/internal:sequence_urbg", @@ -234,8 +304,8 @@ deps = [ ":distributions", ":random", - "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "//absl/random/internal:distribution_test_util", "//absl/random/internal:sequence_urbg", "//absl/strings", @@ -256,8 +326,8 @@ deps = [ ":distributions", ":random", - "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "//absl/random/internal:distribution_test_util", "//absl/random/internal:sequence_urbg", "//absl/strings", @@ -278,7 +348,7 @@ deps = [ ":distributions", ":random", - "//absl/base", + "//absl/base:raw_logging_internal", "//absl/random/internal:distribution_test_util", "//absl/random/internal:sequence_urbg", "//absl/strings", @@ -302,7 +372,7 @@ deps = [ ":distributions", ":random", - "//absl/base", + "//absl/base:raw_logging_internal", "//absl/random/internal:distribution_test_util", "//absl/random/internal:sequence_urbg", "//absl/strings", @@ -321,7 +391,7 @@ deps = [ ":distributions", ":random", - "//absl/base", + "//absl/base:raw_logging_internal", "//absl/random/internal:distribution_test_util", "//absl/random/internal:sequence_urbg", "//absl/strings", @@ -330,6 +400,46 @@ ) cc_test( + name = "bit_gen_ref_test", + size = "small", + srcs = ["bit_gen_ref_test.cc"], + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + ":bit_gen_ref", + ":random", + "//absl/random/internal:sequence_urbg", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "mocking_bit_gen_test", + size = "small", + srcs = ["mocking_bit_gen_test.cc"], + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + ":bit_gen_ref", + ":mock_distributions", + ":mocking_bit_gen", + ":random", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "mock_distributions_test", + size = "small", + srcs = ["mock_distributions_test.cc"], + deps = [ + ":mock_distributions", + ":mocking_bit_gen", + ":random", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( name = "examples_test", size = "small", srcs = ["examples_test.cc"],
diff --git a/third_party/abseil-cpp/absl/random/BUILD.gn b/third_party/abseil-cpp/absl/random/BUILD.gn index 5be2d89..0a2b404 100644 --- a/third_party/abseil-cpp/absl/random/BUILD.gn +++ b/third_party/abseil-cpp/absl/random/BUILD.gn
@@ -63,15 +63,17 @@ ] deps = [ "../base:base_internal", + "../base:config", "../base:core_headers", "../meta:type_traits", - "../random/internal:distribution_impl", "../random/internal:distributions", "../random/internal:fast_uniform_bits", "../random/internal:fastmath", + "../random/internal:generate_real", "../random/internal:iostream_state_saver", "../random/internal:traits", "../random/internal:uniform_helper", + "../random/internal:wide_multiply", "../strings", "../types:span", ] @@ -108,3 +110,20 @@ "../types:span", ] } + +source_set("bit_gen_ref") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] + public = [ "bit_gen_ref.h" ] + deps = [ + "../base:core_headers", + "../meta:type_traits", + "../random/internal:distribution_caller", + "../random/internal:fast_uniform_bits", + "../random/internal:mocking_bit_gen_base", + ] +}
diff --git a/third_party/abseil-cpp/absl/random/CMakeLists.txt b/third_party/abseil-cpp/absl/random/CMakeLists.txt index 2d5c065..efa55d8f 100644 --- a/third_party/abseil-cpp/absl/random/CMakeLists.txt +++ b/third_party/abseil-cpp/absl/random/CMakeLists.txt
@@ -34,6 +34,132 @@ absl_cc_library( NAME + random_bit_gen_ref + HDRS + "bit_gen_ref.h" + COPTS + ${ABSL_DEFAULT_COPTS} + LINKOPTS + ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::core_headers + absl::random_internal_distribution_caller + absl::random_internal_fast_uniform_bits + absl::random_internal_mocking_bit_gen_base + absl::type_traits +) + +absl_cc_test( + NAME + random_bit_gen_ref_test + SRCS + "bit_gen_ref_test.cc" + COPTS + ${ABSL_TEST_COPTS} + LINKOPTS + ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::random_bit_gen_ref + absl::random_random + absl::random_internal_sequence_urbg + gmock + gtest_main +) + +# Internal-only target, do not depend on directly. +absl_cc_library( + NAME + random_internal_mocking_bit_gen_base + HDRS + "internal/mocking_bit_gen_base.h" + COPTS + ${ABSL_DEFAULT_COPTS} + LINKOPTS + ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::random_random + absl::strings +) + +# Internal-only target, do not depend on directly. +absl_cc_library( + NAME + random_internal_mock_overload_set + HDRS + "internal/mock_overload_set.h" + COPTS + ${ABSL_DEFAULT_COPTS} + LINKOPTS + ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::random_mocking_bit_gen + TESTONLY +) + +absl_cc_library( + NAME + random_mocking_bit_gen + HDRS + "mock_distributions.h" + "mocking_bit_gen.h" + SRCS + "mocking_bit_gen.cc" + COPTS + ${ABSL_DEFAULT_COPTS} + LINKOPTS + ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::flat_hash_map + absl::raw_logging_internal + absl::random_distributions + absl::random_internal_distribution_caller + absl::random_internal_mocking_bit_gen_base + absl::random_internal_mock_overload_set + absl::strings + absl::span + absl::type_traits + absl::utility + absl::variant + gmock + gtest + TESTONLY +) + +absl_cc_test( + NAME + random_mock_distributions_test + SRCS + "mock_distributions_test.cc" + COPTS + ${ABSL_TEST_COPTS} + LINKOPTS + ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::random_mocking_bit_gen + absl::random_random + gmock + gtest_main +) + +absl_cc_test( + NAME + random_mocking_bit_gen_test + SRCS + "mocking_bit_gen_test.cc" + COPTS + ${ABSL_TEST_COPTS} + LINKOPTS + ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::random_bit_gen_ref + absl::random_mocking_bit_gen + absl::random_random + gmock + gtest_main +) + +absl_cc_library( + NAME random_distributions SRCS "discrete_distribution.cc" @@ -57,14 +183,16 @@ ${ABSL_DEFAULT_LINKOPTS} DEPS absl::base_internal + absl::config absl::core_headers - absl::random_internal_distribution_impl + absl::random_internal_generate_real absl::random_internal_distributions absl::random_internal_fast_uniform_bits absl::random_internal_fastmath absl::random_internal_iostream_state_saver absl::random_internal_traits absl::random_internal_uniform_helper + absl::random_internal_wide_multiply absl::strings absl::span absl::type_traits @@ -79,9 +207,7 @@ "seed_gen_exception.h" COPTS ${ABSL_DEFAULT_COPTS} - ${ABSL_EXCEPTIONS_FLAG} LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} ${ABSL_DEFAULT_LINKOPTS} DEPS absl::config @@ -137,9 +263,9 @@ DEPS absl::random_distributions absl::random_random - absl::base absl::random_internal_distribution_test_util absl::random_internal_sequence_urbg + absl::raw_logging_internal absl::strings absl::str_format gmock @@ -174,6 +300,7 @@ ${ABSL_DEFAULT_LINKOPTS} absl::random_distributions absl::random_random + absl::raw_logging_internal gmock gtest_main ) @@ -187,12 +314,12 @@ ${ABSL_TEST_COPTS} LINKOPTS ${ABSL_DEFAULT_LINKOPTS} - absl::base absl::core_headers absl::random_distributions absl::random_internal_distribution_test_util absl::random_internal_sequence_urbg absl::random_random + absl::raw_logging_internal absl::strings absl::str_format gmock @@ -209,11 +336,11 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::base absl::random_distributions absl::random_internal_distribution_test_util absl::random_internal_sequence_urbg absl::random_random + absl::raw_logging_internal absl::strings gmock gtest_main @@ -231,11 +358,11 @@ DEPS absl::random_distributions absl::random_random - absl::base absl::core_headers absl::flat_hash_map absl::random_internal_distribution_test_util absl::random_internal_sequence_urbg + absl::raw_logging_internal absl::strings absl::str_format gmock @@ -252,12 +379,12 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::base absl::core_headers absl::random_distributions absl::random_internal_distribution_test_util absl::random_internal_sequence_urbg absl::random_random + absl::raw_logging_internal absl::strings absl::str_format gmock @@ -274,12 +401,12 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::base absl::core_headers absl::random_distributions absl::random_internal_distribution_test_util absl::random_internal_sequence_urbg absl::random_random + absl::raw_logging_internal absl::strings absl::str_format gmock @@ -296,11 +423,11 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::base absl::random_distributions absl::random_internal_distribution_test_util absl::random_internal_sequence_urbg absl::random_random + absl::raw_logging_internal absl::strings gmock gtest_main @@ -316,7 +443,6 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::base absl::random_distributions absl::random_internal_distribution_test_util absl::random_internal_sequence_urbg @@ -336,11 +462,11 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::base absl::random_distributions absl::random_internal_distribution_test_util absl::random_internal_sequence_urbg absl::random_random + absl::raw_logging_internal absl::strings gmock gtest_main @@ -401,6 +527,8 @@ ${ABSL_DEFAULT_COPTS} LINKOPTS ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::config ) # Internal-only target, do not depend on directly. @@ -434,6 +562,8 @@ ${ABSL_DEFAULT_COPTS} LINKOPTS ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::config ) # Internal-only target, do not depend on directly. @@ -448,11 +578,12 @@ ${ABSL_DEFAULT_COPTS} LINKOPTS ${ABSL_DEFAULT_LINKOPTS} + $<$<BOOL:${MINGW}>:"bcrypt"> DEPS - absl::base absl::core_headers absl::optional absl::random_internal_fast_uniform_bits + absl::raw_logging_internal absl::span absl::strings ) @@ -478,6 +609,7 @@ absl::random_internal_seed_material absl::random_internal_traits absl::random_seed_gen_exception + absl::raw_logging_internal absl::span ) @@ -491,6 +623,8 @@ ${ABSL_DEFAULT_COPTS} LINKOPTS ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::config TESTONLY ) @@ -504,6 +638,8 @@ ${ABSL_DEFAULT_COPTS} LINKOPTS ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::config TESTONLY ) @@ -543,9 +679,26 @@ # Internal-only target, do not depend on directly. absl_cc_library( NAME - random_internal_distribution_impl + random_internal_generate_real HDRS - "internal/distribution_impl.h" + "internal/generate_real.h" + COPTS + ${ABSL_DEFAULT_COPTS} + LINKOPTS + ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::bits + absl::random_internal_fastmath + absl::random_internal_traits + absl::type_traits +) + +# Internal-only target, do not depend on directly. +absl_cc_library( + NAME + random_internal_wide_multiply + HDRS + "internal/wide_multiply.h" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -554,8 +707,6 @@ absl::bits absl::config absl::int128 - absl::random_internal_fastmath - absl::random_internal_traits ) # Internal-only target, do not depend on directly. @@ -624,6 +775,7 @@ DEPS absl::random_internal_iostream_state_saver absl::random_internal_randen + absl::raw_logging_internal absl::type_traits ) @@ -639,6 +791,8 @@ ${ABSL_DEFAULT_COPTS} LINKOPTS ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::config ) # Internal-only target, do not depend on directly. @@ -654,7 +808,6 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::base absl::random_internal_platform absl::random_internal_randen_hwaes absl::random_internal_randen_slow @@ -674,6 +827,7 @@ ${ABSL_DEFAULT_LINKOPTS} DEPS absl::random_internal_platform + absl::config ) # Internal-only target, do not depend on directly. @@ -693,6 +847,7 @@ DEPS absl::random_internal_platform absl::random_internal_randen_hwaes_impl + absl::config ) # Internal-only target, do not depend on directly. @@ -709,6 +864,7 @@ ${ABSL_DEFAULT_LINKOPTS} DEPS absl::random_internal_platform + absl::config ) # Internal-only target, do not depend on directly. @@ -726,8 +882,9 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::base + absl::config absl::core_headers + absl::raw_logging_internal absl::strings absl::str_format absl::span @@ -751,9 +908,9 @@ # Internal-only target, do not depend on directly. absl_cc_test( NAME - random_internal_distribution_impl_test + random_internal_generate_real_test SRCS - "internal/distribution_impl_test.cc" + "internal/generate_real_test.cc" COPTS ${ABSL_TEST_COPTS} LINKOPTS @@ -761,8 +918,7 @@ DEPS absl::bits absl::flags - absl::int128 - absl::random_internal_distribution_impl + absl::random_internal_generate_real gtest_main ) @@ -941,9 +1097,9 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::base absl::random_internal_explicit_seed_seq absl::random_internal_randen_engine + absl::raw_logging_internal absl::strings absl::time gmock @@ -995,7 +1151,7 @@ absl::random_internal_platform absl::random_internal_randen_hwaes absl::random_internal_randen_hwaes_impl - absl::base + absl::raw_logging_internal absl::str_format gmock gtest @@ -1013,7 +1169,6 @@ ${ABSL_DEFAULT_LINKOPTS} DEPS absl::core_headers - absl::random_internal_distribution_impl absl::random_internal_fast_uniform_bits absl::random_internal_iostream_state_saver absl::random_internal_traits @@ -1026,9 +1181,28 @@ random_internal_iostream_state_saver_test SRCS "internal/iostream_state_saver_test.cc" + COPTS + ${ABSL_TEST_COPTS} LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS absl::random_internal_iostream_state_saver gtest_main ) + +# Internal-only target, do not depend on directly. +absl_cc_test( + NAME + random_internal_wide_multiply_test + SRCS + internal/wide_multiply_test.cc + COPTS + ${ABSL_TEST_COPTS} + LINKOPTS + ${ABSL_DEFAULT_LINKOPTS} + DEPS + absl::random_internal_wide_multiply + absl::bits + absl::int128 + gtest_main +)
diff --git a/third_party/abseil-cpp/absl/random/bernoulli_distribution.h b/third_party/abseil-cpp/absl/random/bernoulli_distribution.h index 326fcb6..25bd0d5 100644 --- a/third_party/abseil-cpp/absl/random/bernoulli_distribution.h +++ b/third_party/abseil-cpp/absl/random/bernoulli_distribution.h
@@ -24,6 +24,7 @@ #include "absl/random/internal/iostream_state_saver.h" namespace absl { +ABSL_NAMESPACE_BEGIN // absl::bernoulli_distribution is a drop in replacement for // std::bernoulli_distribution. It guarantees that (given a perfect @@ -193,6 +194,7 @@ } } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_BERNOULLI_DISTRIBUTION_H_
diff --git a/third_party/abseil-cpp/absl/random/bernoulli_distribution_test.cc b/third_party/abseil-cpp/absl/random/bernoulli_distribution_test.cc index f2c3b99c..5581af50 100644 --- a/third_party/abseil-cpp/absl/random/bernoulli_distribution_test.cc +++ b/third_party/abseil-cpp/absl/random/bernoulli_distribution_test.cc
@@ -131,7 +131,7 @@ 0x275b0dc7e0a18acfull, 0x36cebe0d2653682eull, 0x0361e9b23861596bull, }); - // Generate a std::string of '0' and '1' for the distribution output. + // Generate a string of '0' and '1' for the distribution output. auto generate = [&urbg](absl::bernoulli_distribution& dist) { std::string output; output.reserve(36); @@ -176,7 +176,7 @@ 0xECDD4775619F1510ull, 0x13CCA830EB61BD96ull, 0x0334FE1EAA0363CFull, 0xB5735C904C70A239ull, 0xD59E9E0BCBAADE14ull, 0xEECC86BC60622CA7ull}); - // Generate a std::string of '0' and '1' for the distribution output. + // Generate a string of '0' and '1' for the distribution output. auto generate = [&urbg](absl::bernoulli_distribution& dist) { std::string output; output.reserve(13);
diff --git a/third_party/abseil-cpp/absl/random/beta_distribution.h b/third_party/abseil-cpp/absl/random/beta_distribution.h index d7afd61c..c154066f 100644 --- a/third_party/abseil-cpp/absl/random/beta_distribution.h +++ b/third_party/abseil-cpp/absl/random/beta_distribution.h
@@ -22,12 +22,14 @@ #include <ostream> #include <type_traits> -#include "absl/random/internal/distribution_impl.h" +#include "absl/meta/type_traits.h" #include "absl/random/internal/fast_uniform_bits.h" #include "absl/random/internal/fastmath.h" +#include "absl/random/internal/generate_real.h" #include "absl/random/internal/iostream_state_saver.h" namespace absl { +ABSL_NAMESPACE_BEGIN // absl::beta_distribution: // Generate a floating-point variate conforming to a Beta distribution: @@ -129,7 +131,7 @@ private: friend class beta_distribution; -#ifdef COMPILER_MSVC +#ifdef _MSC_VER // MSVC does not have constexpr implementations for std::log and std::exp // so they are computed at runtime. #define ABSL_RANDOM_INTERNAL_LOG_EXP_CONSTEXPR @@ -275,15 +277,21 @@ beta_distribution<RealType>::AlgorithmJoehnk( URBG& g, // NOLINT(runtime/references) const param_type& p) { + using random_internal::GeneratePositiveTag; + using random_internal::GenerateRealFromBits; + using real_type = + absl::conditional_t<std::is_same<RealType, float>::value, float, double>; + // Based on Joehnk, M. D. Erzeugung von betaverteilten und gammaverteilten // Zufallszahlen. Metrika 8.1 (1964): 5-15. // This method is described in Knuth, Vol 2 (Third Edition), pp 134. - using RandU64ToReal = typename random_internal::RandU64ToReal<result_type>; - using random_internal::PositiveValueT; + result_type u, v, x, y, z; for (;;) { - u = RandU64ToReal::template Value<PositiveValueT, false>(fast_u64_(g)); - v = RandU64ToReal::template Value<PositiveValueT, false>(fast_u64_(g)); + u = GenerateRealFromBits<real_type, GeneratePositiveTag, false>( + fast_u64_(g)); + v = GenerateRealFromBits<real_type, GeneratePositiveTag, false>( + fast_u64_(g)); // Direct method. std::pow is slow for float, so rely on the optimizer to // remove the std::pow() path for that case. @@ -327,12 +335,14 @@ beta_distribution<RealType>::AlgorithmCheng( URBG& g, // NOLINT(runtime/references) const param_type& p) { + using random_internal::GeneratePositiveTag; + using random_internal::GenerateRealFromBits; + using real_type = + absl::conditional_t<std::is_same<RealType, float>::value, float, double>; + // Based on Cheng, Russell CH. Generating beta variates with nonintegral // shape parameters. Communications of the ACM 21.4 (1978): 317-322. // (https://dl.acm.org/citation.cfm?id=359482). - using RandU64ToReal = typename random_internal::RandU64ToReal<result_type>; - using random_internal::PositiveValueT; - static constexpr result_type kLogFour = result_type(1.3862943611198906188344642429163531361); // log(4) static constexpr result_type kS = @@ -341,8 +351,10 @@ const bool use_algorithm_ba = (p.method_ == param_type::CHENG_BA); result_type u1, u2, v, w, z, r, s, t, bw_inv, lhs; for (;;) { - u1 = RandU64ToReal::template Value<PositiveValueT, false>(fast_u64_(g)); - u2 = RandU64ToReal::template Value<PositiveValueT, false>(fast_u64_(g)); + u1 = GenerateRealFromBits<real_type, GeneratePositiveTag, false>( + fast_u64_(g)); + u2 = GenerateRealFromBits<real_type, GeneratePositiveTag, false>( + fast_u64_(g)); v = p.y_ * std::log(u1 / (1 - u1)); w = p.a_ * std::exp(v); bw_inv = result_type(1) / (p.b_ + w); @@ -409,6 +421,7 @@ return is; } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_BETA_DISTRIBUTION_H_
diff --git a/third_party/abseil-cpp/absl/random/beta_distribution_test.cc b/third_party/abseil-cpp/absl/random/beta_distribution_test.cc index 966ad08..d0111b3 100644 --- a/third_party/abseil-cpp/absl/random/beta_distribution_test.cc +++ b/third_party/abseil-cpp/absl/random/beta_distribution_test.cc
@@ -92,7 +92,7 @@ for (TypeParam alpha : kValues) { for (TypeParam beta : kValues) { ABSL_INTERNAL_LOG( - INFO, absl::StrFormat("Smoke test for Beta(%f, %f)", alpha, beta)); + INFO, absl::StrFormat("Smoke test for Beta(%a, %a)", alpha, beta)); param_type param(alpha, beta); absl::beta_distribution<TypeParam> before(alpha, beta);
diff --git a/third_party/abseil-cpp/absl/random/bit_gen_ref.h b/third_party/abseil-cpp/absl/random/bit_gen_ref.h new file mode 100644 index 0000000..e8771162 --- /dev/null +++ b/third_party/abseil-cpp/absl/random/bit_gen_ref.h
@@ -0,0 +1,153 @@ +// +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------- +// File: bit_gen_ref.h +// ----------------------------------------------------------------------------- +// +// This header defines a bit generator "reference" class, for use in interfaces +// that take both Abseil (e.g. `absl::BitGen`) and standard library (e.g. +// `std::mt19937`) bit generators. + +#ifndef ABSL_RANDOM_BIT_GEN_REF_H_ +#define ABSL_RANDOM_BIT_GEN_REF_H_ + +#include "absl/base/macros.h" +#include "absl/meta/type_traits.h" +#include "absl/random/internal/distribution_caller.h" +#include "absl/random/internal/fast_uniform_bits.h" +#include "absl/random/internal/mocking_bit_gen_base.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace random_internal { + +template <typename URBG, typename = void, typename = void, typename = void> +struct is_urbg : std::false_type {}; + +template <typename URBG> +struct is_urbg< + URBG, + absl::enable_if_t<std::is_same< + typename URBG::result_type, + typename std::decay<decltype((URBG::min)())>::type>::value>, + absl::enable_if_t<std::is_same< + typename URBG::result_type, + typename std::decay<decltype((URBG::max)())>::type>::value>, + absl::enable_if_t<std::is_same< + typename URBG::result_type, + typename std::decay<decltype(std::declval<URBG>()())>::type>::value>> + : std::true_type {}; + +} // namespace random_internal + +// ----------------------------------------------------------------------------- +// absl::BitGenRef +// ----------------------------------------------------------------------------- +// +// `absl::BitGenRef` is a type-erasing class that provides a generator-agnostic +// non-owning "reference" interface for use in place of any specific uniform +// random bit generator (URBG). This class may be used for both Abseil +// (e.g. `absl::BitGen`, `absl::InsecureBitGen`) and Standard library (e.g +// `std::mt19937`, `std::minstd_rand`) bit generators. +// +// Like other reference classes, `absl::BitGenRef` does not own the +// underlying bit generator, and the underlying instance must outlive the +// `absl::BitGenRef`. +// +// `absl::BitGenRef` is particularly useful when used with an +// `absl::MockingBitGen` to test specific paths in functions which use random +// values. +// +// Example: +// void TakesBitGenRef(absl::BitGenRef gen) { +// int x = absl::Uniform<int>(gen, 0, 1000); +// } +// +class BitGenRef { + public: + using result_type = uint64_t; + + BitGenRef(const absl::BitGenRef&) = default; + BitGenRef(absl::BitGenRef&&) = default; + BitGenRef& operator=(const absl::BitGenRef&) = default; + BitGenRef& operator=(absl::BitGenRef&&) = default; + + template <typename URBG, + typename absl::enable_if_t< + (!std::is_same<URBG, BitGenRef>::value && + random_internal::is_urbg<URBG>::value)>* = nullptr> + BitGenRef(URBG& gen) // NOLINT + : mocked_gen_ptr_(MakeMockPointer(&gen)), + t_erased_gen_ptr_(reinterpret_cast<uintptr_t>(&gen)), + generate_impl_fn_(ImplFn<URBG>) { + } + + static constexpr result_type(min)() { + return (std::numeric_limits<result_type>::min)(); + } + + static constexpr result_type(max)() { + return (std::numeric_limits<result_type>::max)(); + } + + result_type operator()() { return generate_impl_fn_(t_erased_gen_ptr_); } + + private: + friend struct absl::random_internal::DistributionCaller<absl::BitGenRef>; + using impl_fn = result_type (*)(uintptr_t); + using mocker_base_t = absl::random_internal::MockingBitGenBase; + + // Convert an arbitrary URBG pointer into either a valid mocker_base_t + // pointer or a nullptr. + static inline mocker_base_t* MakeMockPointer(mocker_base_t* t) { return t; } + static inline mocker_base_t* MakeMockPointer(void*) { return nullptr; } + + template <typename URBG> + static result_type ImplFn(uintptr_t ptr) { + // Ensure that the return values from operator() fill the entire + // range promised by result_type, min() and max(). + absl::random_internal::FastUniformBits<result_type> fast_uniform_bits; + return fast_uniform_bits(*reinterpret_cast<URBG*>(ptr)); + } + + mocker_base_t* mocked_gen_ptr_; + uintptr_t t_erased_gen_ptr_; + impl_fn generate_impl_fn_; +}; + +namespace random_internal { + +template <> +struct DistributionCaller<absl::BitGenRef> { + template <typename DistrT, typename FormatT, typename... Args> + static typename DistrT::result_type Call(absl::BitGenRef* gen_ref, + Args&&... args) { + auto* mock_ptr = gen_ref->mocked_gen_ptr_; + if (mock_ptr == nullptr) { + DistrT dist(std::forward<Args>(args)...); + return dist(*gen_ref); + } else { + return mock_ptr->template Call<DistrT, FormatT>( + std::forward<Args>(args)...); + } + } +}; + +} // namespace random_internal +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_RANDOM_BIT_GEN_REF_H_
diff --git a/third_party/abseil-cpp/absl/random/bit_gen_ref_test.cc b/third_party/abseil-cpp/absl/random/bit_gen_ref_test.cc new file mode 100644 index 0000000..ca0e4d7 --- /dev/null +++ b/third_party/abseil-cpp/absl/random/bit_gen_ref_test.cc
@@ -0,0 +1,101 @@ +// +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "absl/random/bit_gen_ref.h" + +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "absl/random/internal/sequence_urbg.h" +#include "absl/random/random.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN + +class ConstBitGen : public absl::random_internal::MockingBitGenBase { + bool CallImpl(const std::type_info&, void*, void* result) override { + *static_cast<int*>(result) = 42; + return true; + } +}; + +namespace random_internal { +template <> +struct DistributionCaller<ConstBitGen> { + template <typename DistrT, typename FormatT, typename... Args> + static typename DistrT::result_type Call(ConstBitGen* gen, Args&&... args) { + return gen->template Call<DistrT, FormatT>(std::forward<Args>(args)...); + } +}; +} // namespace random_internal + +namespace { +int FnTest(absl::BitGenRef gen_ref) { return absl::Uniform(gen_ref, 1, 7); } + +template <typename T> +class BitGenRefTest : public testing::Test {}; + +using BitGenTypes = + ::testing::Types<absl::BitGen, absl::InsecureBitGen, std::mt19937, + std::mt19937_64, std::minstd_rand>; +TYPED_TEST_SUITE(BitGenRefTest, BitGenTypes); + +TYPED_TEST(BitGenRefTest, BasicTest) { + TypeParam gen; + auto x = FnTest(gen); + EXPECT_NEAR(x, 4, 3); +} + +TYPED_TEST(BitGenRefTest, Copyable) { + TypeParam gen; + absl::BitGenRef gen_ref(gen); + FnTest(gen_ref); // Copy +} + +TEST(BitGenRefTest, PassThroughEquivalence) { + // sequence_urbg returns 64-bit results. + absl::random_internal::sequence_urbg urbg( + {0x0003eb76f6f7f755ull, 0xFFCEA50FDB2F953Bull, 0xC332DDEFBE6C5AA5ull, + 0x6558218568AB9702ull, 0x2AEF7DAD5B6E2F84ull, 0x1521B62829076170ull, + 0xECDD4775619F1510ull, 0x13CCA830EB61BD96ull, 0x0334FE1EAA0363CFull, + 0xB5735C904C70A239ull, 0xD59E9E0BCBAADE14ull, 0xEECC86BC60622CA7ull}); + + std::vector<uint64_t> output(12); + + { + absl::BitGenRef view(urbg); + for (auto& v : output) { + v = view(); + } + } + + std::vector<uint64_t> expected( + {0x0003eb76f6f7f755ull, 0xFFCEA50FDB2F953Bull, 0xC332DDEFBE6C5AA5ull, + 0x6558218568AB9702ull, 0x2AEF7DAD5B6E2F84ull, 0x1521B62829076170ull, + 0xECDD4775619F1510ull, 0x13CCA830EB61BD96ull, 0x0334FE1EAA0363CFull, + 0xB5735C904C70A239ull, 0xD59E9E0BCBAADE14ull, 0xEECC86BC60622CA7ull}); + + EXPECT_THAT(output, testing::Eq(expected)); +} + +TEST(BitGenRefTest, MockingBitGenBaseOverrides) { + ConstBitGen const_gen; + EXPECT_EQ(FnTest(const_gen), 42); + + absl::BitGenRef gen_ref(const_gen); + EXPECT_EQ(FnTest(gen_ref), 42); // Copy +} +} // namespace +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/random/discrete_distribution.cc b/third_party/abseil-cpp/absl/random/discrete_distribution.cc index e6c09c51..081acce 100644 --- a/third_party/abseil-cpp/absl/random/discrete_distribution.cc +++ b/third_party/abseil-cpp/absl/random/discrete_distribution.cc
@@ -15,6 +15,7 @@ #include "absl/random/discrete_distribution.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // Initializes the distribution table for Walker's Aliasing algorithm, described @@ -93,4 +94,5 @@ } } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/random/discrete_distribution.h b/third_party/abseil-cpp/absl/random/discrete_distribution.h index 1560f03c..171aa11 100644 --- a/third_party/abseil-cpp/absl/random/discrete_distribution.h +++ b/third_party/abseil-cpp/absl/random/discrete_distribution.h
@@ -29,6 +29,7 @@ #include "absl/random/uniform_int_distribution.h" namespace absl { +ABSL_NAMESPACE_BEGIN // absl::discrete_distribution // @@ -240,6 +241,7 @@ return is; } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_DISCRETE_DISTRIBUTION_H_
diff --git a/third_party/abseil-cpp/absl/random/distribution_format_traits.h b/third_party/abseil-cpp/absl/random/distribution_format_traits.h index 3f28c90..22b358c 100644 --- a/third_party/abseil-cpp/absl/random/distribution_format_traits.h +++ b/third_party/abseil-cpp/absl/random/distribution_format_traits.h
@@ -36,6 +36,13 @@ #include "absl/types/span.h" namespace absl { +ABSL_NAMESPACE_BEGIN + +struct IntervalClosedClosedTag; +struct IntervalClosedOpenTag; +struct IntervalOpenClosedTag; +struct IntervalOpenOpenTag; + namespace random_internal { // ScalarTypeName defines a preferred hierarchy of preferred type names for @@ -243,7 +250,29 @@ } }; +template <typename NumType> +struct UniformDistributionWrapper; + +template <typename NumType> +struct DistributionFormatTraits<UniformDistributionWrapper<NumType>> { + using distribution_t = UniformDistributionWrapper<NumType>; + using result_t = NumType; + + static constexpr const char* Name() { return "Uniform"; } + + static std::string FunctionName() { + return absl::StrCat(Name(), "<", ScalarTypeName<NumType>(), ">"); + } + static std::string FormatArgs(const distribution_t& d) { + return absl::StrCat((d.min)(), ", ", (d.max)()); + } + static std::string FormatResults(absl::Span<const result_t> results) { + return absl::StrJoin(results, ", "); + } +}; + } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_DISTRIBUTION_FORMAT_TRAITS_H_
diff --git a/third_party/abseil-cpp/absl/random/distributions.h b/third_party/abseil-cpp/absl/random/distributions.h index d8ba3cd..d026d92 100644 --- a/third_party/abseil-cpp/absl/random/distributions.h +++ b/third_party/abseil-cpp/absl/random/distributions.h
@@ -67,19 +67,15 @@ #include "absl/random/zipf_distribution.h" namespace absl { +ABSL_NAMESPACE_BEGIN -ABSL_INTERNAL_INLINE_CONSTEXPR(random_internal::IntervalClosedClosedT, - IntervalClosedClosed, {}); -ABSL_INTERNAL_INLINE_CONSTEXPR(random_internal::IntervalClosedClosedT, - IntervalClosed, {}); -ABSL_INTERNAL_INLINE_CONSTEXPR(random_internal::IntervalClosedOpenT, - IntervalClosedOpen, {}); -ABSL_INTERNAL_INLINE_CONSTEXPR(random_internal::IntervalOpenOpenT, - IntervalOpenOpen, {}); -ABSL_INTERNAL_INLINE_CONSTEXPR(random_internal::IntervalOpenOpenT, - IntervalOpen, {}); -ABSL_INTERNAL_INLINE_CONSTEXPR(random_internal::IntervalOpenClosedT, - IntervalOpenClosed, {}); +ABSL_INTERNAL_INLINE_CONSTEXPR(IntervalClosedClosedTag, IntervalClosedClosed, + {}); +ABSL_INTERNAL_INLINE_CONSTEXPR(IntervalClosedClosedTag, IntervalClosed, {}); +ABSL_INTERNAL_INLINE_CONSTEXPR(IntervalClosedOpenTag, IntervalClosedOpen, {}); +ABSL_INTERNAL_INLINE_CONSTEXPR(IntervalOpenOpenTag, IntervalOpenOpen, {}); +ABSL_INTERNAL_INLINE_CONSTEXPR(IntervalOpenOpenTag, IntervalOpen, {}); +ABSL_INTERNAL_INLINE_CONSTEXPR(IntervalOpenClosedTag, IntervalOpenClosed, {}); // ----------------------------------------------------------------------------- // absl::Uniform<T>(tag, bitgen, lo, hi) @@ -101,7 +97,7 @@ // the return type based on the provided endpoint arguments {A lo, B hi}. // Given these endpoints, one of {A, B} will be chosen as the return type, if // a type can be implicitly converted into the other in a lossless way. The -// lack of any such implcit conversion between {A, B} will produce a +// lack of any such implicit conversion between {A, B} will produce a // compile-time error // // See https://en.wikipedia.org/wiki/Uniform_distribution_(continuous) @@ -129,7 +125,15 @@ URBG&& urbg, // NOLINT(runtime/references) R lo, R hi) { using gen_t = absl::decay_t<URBG>; - return random_internal::UniformImpl<R, TagType, gen_t>(tag, urbg, lo, hi); + using distribution_t = random_internal::UniformDistributionWrapper<R>; + using format_t = random_internal::DistributionFormatTraits<distribution_t>; + + auto a = random_internal::uniform_lower_bound(tag, lo, hi); + auto b = random_internal::uniform_upper_bound(tag, lo, hi); + if (a > b) return a; + + return random_internal::DistributionCaller<gen_t>::template Call< + distribution_t, format_t>(&urbg, tag, lo, hi); } // absl::Uniform<T>(bitgen, lo, hi) @@ -140,11 +144,17 @@ typename absl::enable_if_t<!std::is_same<R, void>::value, R> // Uniform(URBG&& urbg, // NOLINT(runtime/references) R lo, R hi) { - constexpr auto tag = absl::IntervalClosedOpen; - using tag_t = decltype(tag); using gen_t = absl::decay_t<URBG>; + using distribution_t = random_internal::UniformDistributionWrapper<R>; + using format_t = random_internal::DistributionFormatTraits<distribution_t>; - return random_internal::UniformImpl<R, tag_t, gen_t>(tag, urbg, lo, hi); + constexpr auto tag = absl::IntervalClosedOpen; + auto a = random_internal::uniform_lower_bound(tag, lo, hi); + auto b = random_internal::uniform_upper_bound(tag, lo, hi); + if (a > b) return a; + + return random_internal::DistributionCaller<gen_t>::template Call< + distribution_t, format_t>(&urbg, lo, hi); } // absl::Uniform(tag, bitgen, lo, hi) @@ -161,9 +171,16 @@ A lo, B hi) { using gen_t = absl::decay_t<URBG>; using return_t = typename random_internal::uniform_inferred_return_t<A, B>; + using distribution_t = random_internal::UniformDistributionWrapper<return_t>; + using format_t = random_internal::DistributionFormatTraits<distribution_t>; - return random_internal::UniformImpl<return_t, TagType, gen_t>(tag, urbg, lo, - hi); + auto a = random_internal::uniform_lower_bound<return_t>(tag, lo, hi); + auto b = random_internal::uniform_upper_bound<return_t>(tag, lo, hi); + if (a > b) return a; + + return random_internal::DistributionCaller<gen_t>::template Call< + distribution_t, format_t>(&urbg, tag, static_cast<return_t>(lo), + static_cast<return_t>(hi)); } // absl::Uniform(bitgen, lo, hi) @@ -176,13 +193,19 @@ random_internal::uniform_inferred_return_t<A, B>> Uniform(URBG&& urbg, // NOLINT(runtime/references) A lo, B hi) { - constexpr auto tag = absl::IntervalClosedOpen; - using tag_t = decltype(tag); using gen_t = absl::decay_t<URBG>; using return_t = typename random_internal::uniform_inferred_return_t<A, B>; + using distribution_t = random_internal::UniformDistributionWrapper<return_t>; + using format_t = random_internal::DistributionFormatTraits<distribution_t>; - return random_internal::UniformImpl<return_t, tag_t, gen_t>(tag, urbg, lo, - hi); + constexpr auto tag = absl::IntervalClosedOpen; + auto a = random_internal::uniform_lower_bound<return_t>(tag, lo, hi); + auto b = random_internal::uniform_upper_bound<return_t>(tag, lo, hi); + if (a > b) return a; + + return random_internal::DistributionCaller<gen_t>::template Call< + distribution_t, format_t>(&urbg, static_cast<return_t>(lo), + static_cast<return_t>(hi)); } // absl::Uniform<unsigned T>(bitgen) @@ -192,13 +215,12 @@ template <typename R, typename URBG> typename absl::enable_if_t<!std::is_signed<R>::value, R> // Uniform(URBG&& urbg) { // NOLINT(runtime/references) - constexpr auto tag = absl::IntervalClosedClosed; - constexpr auto lo = std::numeric_limits<R>::lowest(); - constexpr auto hi = (std::numeric_limits<R>::max)(); - using tag_t = decltype(tag); using gen_t = absl::decay_t<URBG>; + using distribution_t = random_internal::UniformDistributionWrapper<R>; + using format_t = random_internal::DistributionFormatTraits<distribution_t>; - return random_internal::UniformImpl<R, tag_t, gen_t>(tag, urbg, lo, hi); + return random_internal::DistributionCaller<gen_t>::template Call< + distribution_t, format_t>(&urbg); } // ----------------------------------------------------------------------------- @@ -269,10 +291,10 @@ // absl::Exponential<T>(bitgen, lambda = 1) // ----------------------------------------------------------------------------- // -// `absl::Exponential` produces a floating point number for discrete -// distributions of events occurring continuously and independently at a -// constant average rate. `T` must be a floating point type, but may be inferred -// from the type of `lambda`. +// `absl::Exponential` produces a floating point number representing the +// distance (time) between two consecutive events in a point process of events +// occurring continuously and independently at a constant average rate. `T` must +// be a floating point type, but may be inferred from the type of `lambda`. // // See https://en.wikipedia.org/wiki/Exponential_distribution. // @@ -437,6 +459,7 @@ distribution_t, format_t>(&urbg, hi, q, v); } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_DISTRIBUTIONS_H_
diff --git a/third_party/abseil-cpp/absl/random/distributions_test.cc b/third_party/abseil-cpp/absl/random/distributions_test.cc index eb82868..2d92723 100644 --- a/third_party/abseil-cpp/absl/random/distributions_test.cc +++ b/third_party/abseil-cpp/absl/random/distributions_test.cc
@@ -171,14 +171,11 @@ ""); static_assert( absl::conjunction< + std::is_same<Expect, decltype(InferredTaggedUniformReturnT< + absl::IntervalOpenOpenTag, A, B>(0))>, std::is_same<Expect, decltype(InferredTaggedUniformReturnT< - absl::random_internal::IntervalOpenOpenT, A, B>( - 0))>, - std::is_same<Expect, - decltype(InferredTaggedUniformReturnT< - absl::random_internal::IntervalOpenOpenT, B, A>( - 0))>>::value, + absl::IntervalOpenOpenTag, B, A>(0))>>::value, ""); } @@ -218,12 +215,10 @@ absl::conjunction< std::is_same<Expect, decltype(ExplicitTaggedUniformReturnT< - absl::random_internal::IntervalOpenOpenT, A, B, - Expect>(0))>, - std::is_same<Expect, - decltype(ExplicitTaggedUniformReturnT< - absl::random_internal::IntervalOpenOpenT, B, A, - Expect>(0))>>::value, + absl::IntervalOpenOpenTag, A, B, Expect>(0))>, + std::is_same<Expect, decltype(ExplicitTaggedUniformReturnT< + absl::IntervalOpenOpenTag, B, A, + Expect>(0))>>::value, ""); }
diff --git a/third_party/abseil-cpp/absl/random/exponential_distribution.h b/third_party/abseil-cpp/absl/random/exponential_distribution.h index c8af1975..b5caf8a 100644 --- a/third_party/abseil-cpp/absl/random/exponential_distribution.h +++ b/third_party/abseil-cpp/absl/random/exponential_distribution.h
@@ -21,11 +21,13 @@ #include <limits> #include <type_traits> -#include "absl/random/internal/distribution_impl.h" +#include "absl/meta/type_traits.h" #include "absl/random/internal/fast_uniform_bits.h" +#include "absl/random/internal/generate_real.h" #include "absl/random/internal/iostream_state_saver.h" namespace absl { +ABSL_NAMESPACE_BEGIN // absl::exponential_distribution: // Generates a number conforming to an exponential distribution and is @@ -118,9 +120,14 @@ exponential_distribution<RealType>::operator()( URBG& g, // NOLINT(runtime/references) const param_type& p) { - using random_internal::NegativeValueT; - const result_type u = random_internal::RandU64ToReal< - result_type>::template Value<NegativeValueT, false>(fast_u64_(g)); + using random_internal::GenerateNegativeTag; + using random_internal::GenerateRealFromBits; + using real_type = + absl::conditional_t<std::is_same<RealType, float>::value, float, double>; + + const result_type u = GenerateRealFromBits<real_type, GenerateNegativeTag, + false>(fast_u64_(g)); // U(-1, 0) + // log1p(-x) is mathematically equivalent to log(1 - x) but has more // accuracy for x near zero. return p.neg_inv_lambda_ * std::log1p(u); @@ -152,6 +159,7 @@ return is; } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_EXPONENTIAL_DISTRIBUTION_H_
diff --git a/third_party/abseil-cpp/absl/random/exponential_distribution_test.cc b/third_party/abseil-cpp/absl/random/exponential_distribution_test.cc index 6f8865c2..f3cfd76 100644 --- a/third_party/abseil-cpp/absl/random/exponential_distribution_test.cc +++ b/third_party/abseil-cpp/absl/random/exponential_distribution_test.cc
@@ -46,7 +46,11 @@ template <typename RealType> class ExponentialDistributionTypedTest : public ::testing::Test {}; +#if defined(__EMSCRIPTEN__) +using RealTypes = ::testing::Types<float, double>; +#else using RealTypes = ::testing::Types<float, double, long double>; +#endif // defined(__EMSCRIPTEN__) TYPED_TEST_CASE(ExponentialDistributionTypedTest, RealTypes); TYPED_TEST(ExponentialDistributionTypedTest, SerializeTest) { @@ -346,7 +350,7 @@ return absl::StrReplaceAll(name, {{"+", "_"}, {"-", "_"}, {".", "_"}}); } -INSTANTIATE_TEST_CASE_P(, ExponentialDistributionTests, +INSTANTIATE_TEST_CASE_P(All, ExponentialDistributionTests, ::testing::ValuesIn(GenParams()), ParamName); // NOTE: absl::exponential_distribution is not guaranteed to be stable.
diff --git a/third_party/abseil-cpp/absl/random/gaussian_distribution.cc b/third_party/abseil-cpp/absl/random/gaussian_distribution.cc index 5dd8461..c7a72cb 100644 --- a/third_party/abseil-cpp/absl/random/gaussian_distribution.cc +++ b/third_party/abseil-cpp/absl/random/gaussian_distribution.cc
@@ -4,6 +4,7 @@ #include "absl/random/gaussian_distribution.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { const gaussian_distribution_base::Tables @@ -96,6 +97,7 @@ 0.9362826816850632339, 0.9635996931270905952, 1}}; } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl // clang-format on
diff --git a/third_party/abseil-cpp/absl/random/gaussian_distribution.h b/third_party/abseil-cpp/absl/random/gaussian_distribution.h index 1d1347bc..4b07a5c 100644 --- a/third_party/abseil-cpp/absl/random/gaussian_distribution.h +++ b/third_party/abseil-cpp/absl/random/gaussian_distribution.h
@@ -28,11 +28,13 @@ #include <limits> #include <type_traits> -#include "absl/random/internal/distribution_impl.h" +#include "absl/base/config.h" #include "absl/random/internal/fast_uniform_bits.h" +#include "absl/random/internal/generate_real.h" #include "absl/random/internal/iostream_state_saver.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // absl::gaussian_distribution_base implements the underlying ziggurat algorithm @@ -42,7 +44,7 @@ // The specific algorithm has some of the improvements suggested by the // 2005 paper, "An Improved Ziggurat Method to Generate Normal Random Samples", // Jurgen A Doornik. (https://www.doornik.com/research/ziggurat.pdf) -class gaussian_distribution_base { +class ABSL_DLL gaussian_distribution_base { public: template <typename URBG> inline double zignor(URBG& g); // NOLINT(runtime/references) @@ -207,12 +209,18 @@ template <typename URBG> inline double gaussian_distribution_base::zignor_fallback(URBG& g, bool neg) { + using random_internal::GeneratePositiveTag; + using random_internal::GenerateRealFromBits; + // This fallback path happens approximately 0.05% of the time. double x, y; do { // kRInv = 1/r, U(0, 1) - x = kRInv * std::log(RandU64ToDouble<PositiveValueT, false>(fast_u64_(g))); - y = -std::log(RandU64ToDouble<PositiveValueT, false>(fast_u64_(g))); + x = kRInv * + std::log(GenerateRealFromBits<double, GeneratePositiveTag, false>( + fast_u64_(g))); + y = -std::log( + GenerateRealFromBits<double, GeneratePositiveTag, false>(fast_u64_(g))); } while ((y + y) < (x * x)); return neg ? (x - kR) : (kR - x); } @@ -220,6 +228,10 @@ template <typename URBG> inline double gaussian_distribution_base::zignor( URBG& g) { // NOLINT(runtime/references) + using random_internal::GeneratePositiveTag; + using random_internal::GenerateRealFromBits; + using random_internal::GenerateSignedTag; + while (true) { // We use a single uint64_t to generate both a double and a strip. // These bits are unused when the generated double is > 1/2^5. @@ -227,7 +239,8 @@ // values (those smaller than 1/2^5, which all end up on the left tail). uint64_t bits = fast_u64_(g); int i = static_cast<int>(bits & kMask); // pick a random strip - double j = RandU64ToDouble<SignedValueT, false>(bits); // U(-1, 1) + double j = GenerateRealFromBits<double, GenerateSignedTag, false>( + bits); // U(-1, 1) const double x = j * zg_.x[i]; // Retangular box. Handles >97% of all cases. @@ -244,7 +257,8 @@ } // i > 0: Wedge samples using precomputed values. - double v = RandU64ToDouble<PositiveValueT, false>(fast_u64_(g)); // U(0, 1) + double v = GenerateRealFromBits<double, GeneratePositiveTag, false>( + fast_u64_(g)); // U(0, 1) if ((zg_.f[i + 1] + v * (zg_.f[i] - zg_.f[i + 1])) < std::exp(-0.5 * x * x)) { return x; @@ -255,6 +269,7 @@ } } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_GAUSSIAN_DISTRIBUTION_H_
diff --git a/third_party/abseil-cpp/absl/random/gaussian_distribution_test.cc b/third_party/abseil-cpp/absl/random/gaussian_distribution_test.cc index 47c2989..49c0751 100644 --- a/third_party/abseil-cpp/absl/random/gaussian_distribution_test.cc +++ b/third_party/abseil-cpp/absl/random/gaussian_distribution_test.cc
@@ -394,7 +394,7 @@ return absl::StrReplaceAll(name, {{"+", "_"}, {"-", "_"}, {".", "_"}}); } -INSTANTIATE_TEST_SUITE_P(, GaussianDistributionTests, +INSTANTIATE_TEST_SUITE_P(All, GaussianDistributionTests, ::testing::ValuesIn(GenParams()), ParamName); // NOTE: absl::gaussian_distribution is not guaranteed to be stable.
diff --git a/third_party/abseil-cpp/absl/random/internal/BUILD.bazel b/third_party/abseil-cpp/absl/random/internal/BUILD.bazel index fd5471a..1c9dabb 100644 --- a/third_party/abseil-cpp/absl/random/internal/BUILD.bazel +++ b/third_party/abseil-cpp/absl/random/internal/BUILD.bazel
@@ -1,3 +1,21 @@ +# +# Copyright 2019 The Abseil Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") + # Internal-only implementation classes for Abseil Random load( "//absl:copts/configure_copts.bzl", @@ -33,24 +51,21 @@ visibility = [ "//absl/random:__pkg__", ], + deps = ["//absl/base:config"], ) cc_library( name = "distributions", - hdrs = [ - "distributions.h", - ], + hdrs = ["distributions.h"], copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":distribution_caller", - ":fast_uniform_bits", - ":fastmath", ":traits", ":uniform_helper", + "//absl/base", "//absl/meta:type_traits", "//absl/strings", - "//absl/types:span", ], ) @@ -64,6 +79,7 @@ visibility = [ "//absl/random:__pkg__", ], + deps = ["//absl/base:config"], ) cc_library( @@ -75,11 +91,14 @@ "seed_material.h", ], copts = ABSL_DEFAULT_COPTS, - linkopts = ABSL_DEFAULT_LINKOPTS, + linkopts = ABSL_DEFAULT_LINKOPTS + select({ + "//absl:windows": ["-DEFAULTLIB:bcrypt.lib"], + "//conditions:default": [], + }), deps = [ ":fast_uniform_bits", - "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "//absl/strings", "//absl/types:optional", "//absl/types:span", @@ -107,6 +126,7 @@ "//absl/base:config", "//absl/base:core_headers", "//absl/base:endian", + "//absl/base:raw_logging_internal", "//absl/random:seed_gen_exception", "//absl/types:span", ], @@ -120,6 +140,7 @@ ], copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, + deps = ["//absl/base:config"], ) cc_library( @@ -130,6 +151,7 @@ ], copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, + deps = ["//absl/base:config"], ) cc_library( @@ -160,9 +182,9 @@ ) cc_library( - name = "distribution_impl", + name = "generate_real", hdrs = [ - "distribution_impl.h", + "generate_real.h", ], copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, @@ -170,8 +192,7 @@ ":fastmath", ":traits", "//absl/base:bits", - "//absl/base:config", - "//absl/numeric:int128", + "//absl/meta:type_traits", ], ) @@ -186,6 +207,19 @@ ) cc_library( + name = "wide_multiply", + hdrs = ["wide_multiply.h"], + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + ":traits", + "//absl/base:bits", + "//absl/base:config", + "//absl/numeric:int128", + ], +) + +cc_library( name = "nonsecure_base", hdrs = ["nonsecure_base.h"], copts = ABSL_DEFAULT_COPTS, @@ -239,6 +273,7 @@ "randen-keys.inc", "platform.h", ], + deps = ["//absl/base:config"], ) cc_library( @@ -255,7 +290,7 @@ ":platform", ":randen_hwaes", ":randen_slow", - "//absl/base", + "//absl/base:raw_logging_internal", ], ) @@ -267,6 +302,8 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":platform", + "//absl/base:config", + "//absl/base:core_headers", ], ) @@ -286,6 +323,7 @@ deps = [ ":platform", ":randen_hwaes_impl", + "//absl/base:config", ], ) @@ -305,7 +343,11 @@ # anyway and thus there wouldn't be any gain from using it as a module. features = ["-header_modules"], linkopts = ABSL_DEFAULT_LINKOPTS, - deps = [":platform"], + deps = [ + ":platform", + "//absl/base:config", + "//absl/base:core_headers", + ], ) cc_binary( @@ -334,8 +376,9 @@ copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ - "//absl/base", + "//absl/base:config", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "//absl/strings", "//absl/strings:str_format", "//absl/types:span", @@ -367,16 +410,17 @@ ) cc_test( - name = "distribution_impl_test", + name = "generate_real_test", size = "small", - srcs = ["distribution_impl_test.cc"], + srcs = [ + "generate_real_test.cc", + ], copts = ABSL_TEST_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ - ":distribution_impl", + ":generate_real", "//absl/base:bits", "//absl/flags:flag", - "//absl/numeric:int128", "@com_google_googletest//:gtest_main", ], ) @@ -459,6 +503,29 @@ ], ) +cc_library( + name = "mocking_bit_gen_base", + hdrs = ["mocking_bit_gen_base.h"], + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + "//absl/random", + "//absl/strings", + ], +) + +cc_library( + name = "mock_overload_set", + testonly = 1, + hdrs = ["mock_overload_set.h"], + visibility = [ + "//absl/random:__pkg__", + ], + deps = [ + "//absl/random:mocking_bit_gen", + "@com_google_googletest//:gtest", + ], +) + cc_test( name = "nonsecure_base_test", size = "small", @@ -531,7 +598,7 @@ deps = [ ":explicit_seed_seq", ":randen_engine", - "//absl/base", + "//absl/base:raw_logging_internal", "//absl/strings", "//absl/time", "@com_google_googletest//:gtest_main", @@ -574,12 +641,26 @@ ":platform", ":randen_hwaes", ":randen_hwaes_impl", # build_cleaner: keep - "//absl/base", + "//absl/base:raw_logging_internal", "//absl/strings:str_format", "@com_google_googletest//:gtest", ], ) +cc_test( + name = "wide_multiply_test", + size = "small", + srcs = ["wide_multiply_test.cc"], + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + ":wide_multiply", + "//absl/base:bits", + "//absl/numeric:int128", + "@com_google_googletest//:gtest_main", + ], +) + cc_library( name = "nanobenchmark", srcs = ["nanobenchmark.cc"], @@ -588,7 +669,8 @@ deps = [ ":platform", ":randen_engine", - "//absl/base", + "//absl/base:core_headers", + "//absl/base:raw_logging_internal", ], ) @@ -598,11 +680,6 @@ copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ - ":distribution_impl", - ":fast_uniform_bits", - ":iostream_state_saver", - ":traits", - "//absl/base:core_headers", "//absl/meta:type_traits", ], ) @@ -620,7 +697,7 @@ ], deps = [ ":nanobenchmark", - "//absl/base", + "//absl/base:raw_logging_internal", "//absl/strings", ], ) @@ -628,6 +705,7 @@ cc_test( name = "randen_benchmarks", size = "medium", + timeout = "long", srcs = ["randen_benchmarks.cc"], copts = ABSL_TEST_COPTS + ABSL_RANDOM_RANDEN_COPTS, flaky = 1, @@ -641,7 +719,7 @@ ":randen_hwaes", ":randen_hwaes_impl", ":randen_slow", - "//absl/base", + "//absl/base:raw_logging_internal", "//absl/strings", ], )
diff --git a/third_party/abseil-cpp/absl/random/internal/BUILD.gn b/third_party/abseil-cpp/absl/random/internal/BUILD.gn index 6eb6b7d..abf4f8f 100644 --- a/third_party/abseil-cpp/absl/random/internal/BUILD.gn +++ b/third_party/abseil-cpp/absl/random/internal/BUILD.gn
@@ -41,6 +41,7 @@ public = [ "distribution_caller.h" ] visibility = [] visibility += [ "../../random/*" ] + deps = [ "../../base:config" ] } source_set("distributions") { @@ -53,13 +54,11 @@ public = [ "distributions.h" ] deps = [ ":distribution_caller", - ":fast_uniform_bits", - ":fastmath", ":traits", ":uniform_helper", + "../../base", "../../meta:type_traits", "../../strings", - "../../types:span", ] } @@ -73,6 +72,7 @@ public = [ "fast_uniform_bits.h" ] visibility = [] visibility += [ "../../random/*" ] + deps = [ "../../base:config" ] } source_set("seed_material") { @@ -84,10 +84,14 @@ public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] public = [ "seed_material.h" ] sources = [ "seed_material.cc" ] + if (is_win) { + # TODO(mbonadei): In the bazel file this is -DEFAULTLIB:bcrypt.lib. + libs = [ "bcrypt.lib" ] + } deps = [ ":fast_uniform_bits", - "../../base", "../../base:core_headers", + "../../base:raw_logging_internal", "../../strings", "../../types:optional", "../../types:span", @@ -111,6 +115,7 @@ "../../base:config", "../../base:core_headers", "../../base:endian", + "../../base:raw_logging_internal", "../../random:seed_gen_exception", "../../types:span", ] @@ -125,6 +130,7 @@ ] public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] public = [ "explicit_seed_seq.h" ] + deps = [ "../../base:config" ] } source_set("sequence_urbg") { @@ -136,6 +142,7 @@ ] public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] public = [ "sequence_urbg.h" ] + deps = [ "../../base:config" ] } source_set("salted_seed_seq") { @@ -169,20 +176,19 @@ ] } -source_set("distribution_impl") { +source_set("generate_real") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code", "//third_party/abseil-cpp:absl_default_cflags_cc", ] public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] - public = [ "distribution_impl.h" ] + public = [ "generate_real.h" ] deps = [ ":fastmath", ":traits", "../../base:bits", - "../../base:config", - "../../numeric:int128", + "../../meta:type_traits", ] } @@ -197,6 +203,22 @@ deps = [ "../../base:bits" ] } +source_set("wide_multiply") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] + public = [ "wide_multiply.h" ] + deps = [ + ":traits", + "../../base:bits", + "../../base:config", + "../../numeric:int128", + ] +} + source_set("nonsecure_base") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ @@ -261,6 +283,7 @@ "randen-keys.inc", "randen_traits.h", ] + deps = [ "../../base:config" ] } source_set("randen") { @@ -276,7 +299,7 @@ ":platform", ":randen_hwaes", ":randen_slow", - "../../base", + "../../base:raw_logging_internal", ] } @@ -289,7 +312,11 @@ public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] public = [ "randen_slow.h" ] sources = [ "randen_slow.cc" ] - deps = [ ":platform" ] + deps = [ + ":platform", + "../../base:config", + "../../base:core_headers", + ] } source_set("randen_hwaes") { @@ -307,6 +334,7 @@ deps = [ ":platform", ":randen_hwaes_impl", + "../../base:config", ] } @@ -321,7 +349,11 @@ "randen_hwaes.cc", "randen_hwaes.h", ] - deps = [ ":platform" ] + deps = [ + ":platform", + "../../base:config", + "../../base:core_headers", + ] } executable("gaussian_distribution_gentables") { @@ -355,14 +387,29 @@ "distribution_test_util.cc", ] deps = [ - "../../base", + "../../base:config", "../../base:core_headers", + "../../base:raw_logging_internal", "../../strings", "../../strings:str_format", "../../types:span", ] } +source_set("mocking_bit_gen_base") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] + public = [ "mocking_bit_gen_base.h" ] + deps = [ + "../../random", + "../../strings", + ] +} + source_set("nanobenchmark") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ @@ -374,7 +421,8 @@ deps = [ ":platform", ":randen_engine", - "../../base", + "../../base:core_headers", + "../../base:raw_logging_internal", ] } @@ -386,12 +434,5 @@ ] public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] public = [ "uniform_helper.h" ] - deps = [ - ":distribution_impl", - ":fast_uniform_bits", - ":iostream_state_saver", - ":traits", - "../../base:core_headers", - "../../meta:type_traits", - ] + deps = [ "../../meta:type_traits" ] }
diff --git a/third_party/abseil-cpp/absl/random/internal/chi_square.cc b/third_party/abseil-cpp/absl/random/internal/chi_square.cc index c0acc94..640d48c 100644 --- a/third_party/abseil-cpp/absl/random/internal/chi_square.cc +++ b/third_party/abseil-cpp/absl/random/internal/chi_square.cc
@@ -19,6 +19,7 @@ #include "absl/random/internal/distribution_test_util.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { namespace { @@ -227,4 +228,5 @@ } } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/random/internal/chi_square.h b/third_party/abseil-cpp/absl/random/internal/chi_square.h index fa8646f..07f4fbe5 100644 --- a/third_party/abseil-cpp/absl/random/internal/chi_square.h +++ b/third_party/abseil-cpp/absl/random/internal/chi_square.h
@@ -26,7 +26,10 @@ #include <cassert> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { constexpr const char kChiSquared[] = "chi-squared"; @@ -80,6 +83,7 @@ double ChiSquarePValue(double chi_square, int dof); } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_CHI_SQUARE_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/distribution_caller.h b/third_party/abseil-cpp/absl/random/internal/distribution_caller.h index 0318e1f8..02603cf8 100644 --- a/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +++ b/third_party/abseil-cpp/absl/random/internal/distribution_caller.h
@@ -19,7 +19,10 @@ #include <utility> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // DistributionCaller provides an opportunity to overload the general @@ -51,6 +54,7 @@ }; } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_DISTRIBUTION_CALLER_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/distribution_impl.h b/third_party/abseil-cpp/absl/random/internal/distribution_impl.h deleted file mode 100644 index 9b6ffb0..0000000 --- a/third_party/abseil-cpp/absl/random/internal/distribution_impl.h +++ /dev/null
@@ -1,260 +0,0 @@ -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef ABSL_RANDOM_INTERNAL_DISTRIBUTION_IMPL_H_ -#define ABSL_RANDOM_INTERNAL_DISTRIBUTION_IMPL_H_ - -// This file contains some implementation details which are used by one or more -// of the absl random number distributions. - -#include <cfloat> -#include <cstddef> -#include <cstdint> -#include <cstring> -#include <limits> -#include <type_traits> - -#if (defined(_WIN32) || defined(_WIN64)) && defined(_M_IA64) -#include <intrin.h> // NOLINT(build/include_order) -#pragma intrinsic(_umul128) -#define ABSL_INTERNAL_USE_UMUL128 1 -#endif - -#include "absl/base/config.h" -#include "absl/base/internal/bits.h" -#include "absl/numeric/int128.h" -#include "absl/random/internal/fastmath.h" -#include "absl/random/internal/traits.h" - -namespace absl { -namespace random_internal { - -// Creates a double from `bits`, with the template fields controlling the -// output. -// -// RandU64To is both more efficient and generates more unique values in the -// result interval than known implementations of std::generate_canonical(). -// -// The `Signed` parameter controls whether positive, negative, or both are -// returned (thus affecting the output interval). -// When Signed == SignedValueT, range is U(-1, 1) -// When Signed == NegativeValueT, range is U(-1, 0) -// When Signed == PositiveValueT, range is U(0, 1) -// -// When the `IncludeZero` parameter is true, the function may return 0 for some -// inputs, otherwise it never returns 0. -// -// The `ExponentBias` parameter determines the scale of the output range by -// adjusting the exponent. -// -// When a value in U(0,1) is required, use: -// RandU64ToDouble<PositiveValueT, true, 0>(); -// -// When a value in U(-1,1) is required, use: -// RandU64ToDouble<SignedValueT, false, 0>() => U(-1, 1) -// This generates more distinct values than the mathematically equivalent -// expression `U(0, 1) * 2.0 - 1.0`, and is preferable. -// -// Scaling the result by powers of 2 (and avoiding a multiply) is also possible: -// RandU64ToDouble<PositiveValueT, false, 1>(); => U(0, 2) -// RandU64ToDouble<PositiveValueT, false, -1>(); => U(0, 0.5) -// - -// Tristate types controlling the output. -struct PositiveValueT {}; -struct NegativeValueT {}; -struct SignedValueT {}; - -// RandU64ToDouble is the double-result variant of RandU64To, described above. -template <typename Signed, bool IncludeZero, int ExponentBias = 0> -inline double RandU64ToDouble(uint64_t bits) { - static_assert(std::is_same<Signed, PositiveValueT>::value || - std::is_same<Signed, NegativeValueT>::value || - std::is_same<Signed, SignedValueT>::value, - ""); - - // Maybe use the left-most bit for a sign bit. - uint64_t sign = std::is_same<Signed, NegativeValueT>::value - ? 0x8000000000000000ull - : 0; // Sign bits. - - if (std::is_same<Signed, SignedValueT>::value) { - sign = bits & 0x8000000000000000ull; - bits = bits & 0x7FFFFFFFFFFFFFFFull; - } - if (IncludeZero) { - if (bits == 0u) return 0; - } - - // Number of leading zeros is mapped to the exponent: 2^-clz - int clz = base_internal::CountLeadingZeros64(bits); - // Shift number left to erase leading zeros. - bits <<= IncludeZero ? clz : (clz & 63); - - // Shift number right to remove bits that overflow double mantissa. The - // direction of the shift depends on `clz`. - bits >>= (64 - DBL_MANT_DIG); - - // Compute IEEE 754 double exponent. - // In the Signed case, bits is a 63-bit number with a 0 msb. Adjust the - // exponent to account for that. - const uint64_t exp = - (std::is_same<Signed, SignedValueT>::value ? 1023U : 1022U) + - static_cast<uint64_t>(ExponentBias - clz); - constexpr int kExp = DBL_MANT_DIG - 1; - // Construct IEEE 754 double from exponent and mantissa. - const uint64_t val = sign | (exp << kExp) | (bits & ((1ULL << kExp) - 1U)); - - double res; - static_assert(sizeof(res) == sizeof(val), "double is not 64 bit"); - // Memcpy value from "val" to "res" to avoid aliasing problems. Assumes that - // endian-ness is same for double and uint64_t. - std::memcpy(&res, &val, sizeof(res)); - - return res; -} - -// RandU64ToFloat is the float-result variant of RandU64To, described above. -template <typename Signed, bool IncludeZero, int ExponentBias = 0> -inline float RandU64ToFloat(uint64_t bits) { - static_assert(std::is_same<Signed, PositiveValueT>::value || - std::is_same<Signed, NegativeValueT>::value || - std::is_same<Signed, SignedValueT>::value, - ""); - - // Maybe use the left-most bit for a sign bit. - uint64_t sign = std::is_same<Signed, NegativeValueT>::value - ? 0x80000000ul - : 0; // Sign bits. - - if (std::is_same<Signed, SignedValueT>::value) { - uint64_t a = bits & 0x8000000000000000ull; - sign = static_cast<uint32_t>(a >> 32); - bits = bits & 0x7FFFFFFFFFFFFFFFull; - } - if (IncludeZero) { - if (bits == 0u) return 0; - } - - // Number of leading zeros is mapped to the exponent: 2^-clz - int clz = base_internal::CountLeadingZeros64(bits); - // Shift number left to erase leading zeros. - bits <<= IncludeZero ? clz : (clz & 63); - // Shift number right to remove bits that overflow double mantissa. The - // direction of the shift depends on `clz`. - bits >>= (64 - FLT_MANT_DIG); - - // Construct IEEE 754 float exponent. - // In the Signed case, bits is a 63-bit number with a 0 msb. Adjust the - // exponent to account for that. - const uint32_t exp = - (std::is_same<Signed, SignedValueT>::value ? 127U : 126U) + - static_cast<uint32_t>(ExponentBias - clz); - constexpr int kExp = FLT_MANT_DIG - 1; - const uint32_t val = sign | (exp << kExp) | (bits & ((1U << kExp) - 1U)); - - float res; - static_assert(sizeof(res) == sizeof(val), "float is not 32 bit"); - // Assumes that endian-ness is same for float and uint32_t. - std::memcpy(&res, &val, sizeof(res)); - - return res; -} - -template <typename Result> -struct RandU64ToReal { - template <typename Signed, bool IncludeZero, int ExponentBias = 0> - static inline Result Value(uint64_t bits) { - return RandU64ToDouble<Signed, IncludeZero, ExponentBias>(bits); - } -}; - -template <> -struct RandU64ToReal<float> { - template <typename Signed, bool IncludeZero, int ExponentBias = 0> - static inline float Value(uint64_t bits) { - return RandU64ToFloat<Signed, IncludeZero, ExponentBias>(bits); - } -}; - -inline uint128 MultiplyU64ToU128(uint64_t a, uint64_t b) { -#if defined(ABSL_HAVE_INTRINSIC_INT128) - return uint128(static_cast<__uint128_t>(a) * b); -#elif defined(ABSL_INTERNAL_USE_UMUL128) - // uint64_t * uint64_t => uint128 multiply using imul intrinsic on MSVC. - uint64_t high = 0; - const uint64_t low = _umul128(a, b, &high); - return absl::MakeUint128(high, low); -#else - // uint128(a) * uint128(b) in emulated mode computes a full 128-bit x 128-bit - // multiply. However there are many cases where that is not necessary, and it - // is only necessary to support a 64-bit x 64-bit = 128-bit multiply. This is - // for those cases. - const uint64_t a00 = static_cast<uint32_t>(a); - const uint64_t a32 = a >> 32; - const uint64_t b00 = static_cast<uint32_t>(b); - const uint64_t b32 = b >> 32; - - const uint64_t c00 = a00 * b00; - const uint64_t c32a = a00 * b32; - const uint64_t c32b = a32 * b00; - const uint64_t c64 = a32 * b32; - - const uint32_t carry = - static_cast<uint32_t>(((c00 >> 32) + static_cast<uint32_t>(c32a) + - static_cast<uint32_t>(c32b)) >> - 32); - - return absl::MakeUint128(c64 + (c32a >> 32) + (c32b >> 32) + carry, - c00 + (c32a << 32) + (c32b << 32)); -#endif -} - -// wide_multiply<T> multiplies two N-bit values to a 2N-bit result. -template <typename UIntType> -struct wide_multiply { - static constexpr size_t kN = std::numeric_limits<UIntType>::digits; - using input_type = UIntType; - using result_type = typename random_internal::unsigned_bits<kN * 2>::type; - - static result_type multiply(input_type a, input_type b) { - return static_cast<result_type>(a) * b; - } - - static input_type hi(result_type r) { return r >> kN; } - static input_type lo(result_type r) { return r; } - - static_assert(std::is_unsigned<UIntType>::value, - "Class-template wide_multiply<> argument must be unsigned."); -}; - -#ifndef ABSL_HAVE_INTRINSIC_INT128 -template <> -struct wide_multiply<uint64_t> { - using input_type = uint64_t; - using result_type = uint128; - - static result_type multiply(uint64_t a, uint64_t b) { - return MultiplyU64ToU128(a, b); - } - - static uint64_t hi(result_type r) { return Uint128High64(r); } - static uint64_t lo(result_type r) { return Uint128Low64(r); } -}; -#endif - -} // namespace random_internal -} // namespace absl - -#endif // ABSL_RANDOM_INTERNAL_DISTRIBUTION_IMPL_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/distribution_test_util.cc b/third_party/abseil-cpp/absl/random/internal/distribution_test_util.cc index 85c8d596..e9005658 100644 --- a/third_party/abseil-cpp/absl/random/internal/distribution_test_util.cc +++ b/third_party/abseil-cpp/absl/random/internal/distribution_test_util.cc
@@ -25,6 +25,7 @@ #include "absl/strings/str_format.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { namespace { @@ -413,4 +414,5 @@ } } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/random/internal/distribution_test_util.h b/third_party/abseil-cpp/absl/random/internal/distribution_test_util.h index b5ba49f..6d94cf6c 100644 --- a/third_party/abseil-cpp/absl/random/internal/distribution_test_util.h +++ b/third_party/abseil-cpp/absl/random/internal/distribution_test_util.h
@@ -26,6 +26,7 @@ // non-test code. namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // http://webspace.ship.edu/pgmarr/Geo441/Lectures/Lec%205%20-%20Normality%20Testing.pdf @@ -106,6 +107,7 @@ double BetaIncompleteInv(double p, double q, double alpha); } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_DISTRIBUTION_TEST_UTIL_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/distributions.h b/third_party/abseil-cpp/absl/random/internal/distributions.h index 34db3b3..d7e3c016 100644 --- a/third_party/abseil-cpp/absl/random/internal/distributions.h +++ b/third_party/abseil-cpp/absl/random/internal/distributions.h
@@ -23,39 +23,8 @@ #include "absl/random/internal/uniform_helper.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { -template <typename D> -struct DistributionFormatTraits; - -// UniformImpl implements the core logic of the Uniform<T> call, which is to -// select the correct distribution type, compute the bounds based on the -// interval tag, and then generate a value. -template <typename NumType, typename TagType, typename URBG> -NumType UniformImpl(TagType tag, - URBG& urbg, // NOLINT(runtime/references) - NumType lo, NumType hi) { - static_assert( - std::is_arithmetic<NumType>::value, - "absl::Uniform<T>() must use an integer or real parameter type."); - - using distribution_t = - typename std::conditional<std::is_integral<NumType>::value, - absl::uniform_int_distribution<NumType>, - absl::uniform_real_distribution<NumType>>::type; - using format_t = random_internal::DistributionFormatTraits<distribution_t>; - - auto a = random_internal::uniform_lower_bound<NumType>(tag, lo, hi); - auto b = random_internal::uniform_upper_bound<NumType>(tag, lo, hi); - // TODO(lar): it doesn't make a lot of sense to ask for a random number in an - // empty range. Right now we just return a boundary--even though that - // boundary is not an acceptable value! Is there something better we can do - // here? - - using gen_t = absl::decay_t<URBG>; - if (a > b) return a; - return DistributionCaller<gen_t>::template Call<distribution_t, format_t>( - &urbg, a, b); -} // In the absence of an explicitly provided return-type, the template // "uniform_inferred_return_t<A, B>" is used to derive a suitable type, based on @@ -77,6 +46,7 @@ is_widening_convertible<A, B>::value, B, A>::type>; } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_DISTRIBUTIONS_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/explicit_seed_seq.h b/third_party/abseil-cpp/absl/random/internal/explicit_seed_seq.h index b660ece..6a743eaf 100644 --- a/third_party/abseil-cpp/absl/random/internal/explicit_seed_seq.h +++ b/third_party/abseil-cpp/absl/random/internal/explicit_seed_seq.h
@@ -22,7 +22,10 @@ #include <iterator> #include <vector> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // This class conforms to the C++ Standard "Seed Sequence" concept @@ -82,6 +85,7 @@ }; } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_EXPLICIT_SEED_SEQ_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h b/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h index e8df92f3..f13c872 100644 --- a/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +++ b/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h
@@ -20,7 +20,10 @@ #include <limits> #include <type_traits> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // Returns true if the input value is zero or a power of two. Useful for // determining if the range of output values in a URBG @@ -255,6 +258,7 @@ } } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_FAST_UNIFORM_BITS_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits_test.cc b/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits_test.cc index 9f2e826..f5b837e5 100644 --- a/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits_test.cc +++ b/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits_test.cc
@@ -19,6 +19,7 @@ #include "gtest/gtest.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { namespace { @@ -269,4 +270,5 @@ } // namespace } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/random/internal/fastmath.h b/third_party/abseil-cpp/absl/random/internal/fastmath.h index 4bd18410..6baeb5a 100644 --- a/third_party/abseil-cpp/absl/random/internal/fastmath.h +++ b/third_party/abseil-cpp/absl/random/internal/fastmath.h
@@ -25,6 +25,7 @@ #include "absl/base/internal/bits.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // Returns the position of the first bit set. @@ -67,6 +68,7 @@ } } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_FASTMATH_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/gaussian_distribution_gentables.cc b/third_party/abseil-cpp/absl/random/internal/gaussian_distribution_gentables.cc index 16a23cb..a2bf0394 100644 --- a/third_party/abseil-cpp/absl/random/internal/gaussian_distribution_gentables.cc +++ b/third_party/abseil-cpp/absl/random/internal/gaussian_distribution_gentables.cc
@@ -27,6 +27,7 @@ #include "absl/base/macros.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { namespace { @@ -135,6 +136,7 @@ } } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl int main(int, char**) {
diff --git a/third_party/abseil-cpp/absl/random/internal/generate_real.h b/third_party/abseil-cpp/absl/random/internal/generate_real.h new file mode 100644 index 0000000..20f6d208 --- /dev/null +++ b/third_party/abseil-cpp/absl/random/internal/generate_real.h
@@ -0,0 +1,146 @@ +// Copyright 2017 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ABSL_RANDOM_INTERNAL_GENERATE_REAL_H_ +#define ABSL_RANDOM_INTERNAL_GENERATE_REAL_H_ + +// This file contains some implementation details which are used by one or more +// of the absl random number distributions. + +#include <cstdint> +#include <cstring> +#include <limits> +#include <type_traits> + +#include "absl/base/internal/bits.h" +#include "absl/meta/type_traits.h" +#include "absl/random/internal/fastmath.h" +#include "absl/random/internal/traits.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace random_internal { + +// Tristate tag types controlling the output of GenerateRealFromBits. +struct GeneratePositiveTag {}; +struct GenerateNegativeTag {}; +struct GenerateSignedTag {}; + +// GenerateRealFromBits generates a single real value from a single 64-bit +// `bits` with template fields controlling the output. +// +// The `SignedTag` parameter controls whether positive, negative, +// or either signed/unsigned may be returned. +// When SignedTag == GeneratePositiveTag, range is U(0, 1) +// When SignedTag == GenerateNegativeTag, range is U(-1, 0) +// When SignedTag == GenerateSignedTag, range is U(-1, 1) +// +// When the `IncludeZero` parameter is true, the function may return 0 for some +// inputs, otherwise it never returns 0. +// +// When a value in U(0,1) is required, use: +// Uniform64ToReal<double, PositiveValueT, true>; +// +// When a value in U(-1,1) is required, use: +// Uniform64ToReal<double, SignedValueT, false>; +// +// This generates more distinct values than the mathematical equivalent +// `U(0, 1) * 2.0 - 1.0`. +// +// Scaling the result by powers of 2 (and avoiding a multiply) is also possible: +// GenerateRealFromBits<double>(..., -1); => U(0, 0.5) +// GenerateRealFromBits<double>(..., 1); => U(0, 2) +// +template <typename RealType, // Real type, either float or double. + typename SignedTag = GeneratePositiveTag, // Whether a positive, + // negative, or signed + // value is generated. + bool IncludeZero = true> +inline RealType GenerateRealFromBits(uint64_t bits, int exp_bias = 0) { + using real_type = RealType; + using uint_type = absl::conditional_t<std::is_same<real_type, float>::value, + uint32_t, uint64_t>; + + static_assert( + (std::is_same<double, real_type>::value || + std::is_same<float, real_type>::value), + "GenerateRealFromBits must be parameterized by either float or double."); + + static_assert(sizeof(uint_type) == sizeof(real_type), + "Mismatched unsinged and real types."); + + static_assert((std::numeric_limits<real_type>::is_iec559 && + std::numeric_limits<real_type>::radix == 2), + "RealType representation is not IEEE 754 binary."); + + static_assert((std::is_same<SignedTag, GeneratePositiveTag>::value || + std::is_same<SignedTag, GenerateNegativeTag>::value || + std::is_same<SignedTag, GenerateSignedTag>::value), + ""); + + static constexpr int kExp = std::numeric_limits<real_type>::digits - 1; + static constexpr uint_type kMask = (static_cast<uint_type>(1) << kExp) - 1u; + static constexpr int kUintBits = sizeof(uint_type) * 8; + + int exp = exp_bias + int{std::numeric_limits<real_type>::max_exponent - 2}; + + // Determine the sign bit. + // Depending on the SignedTag, this may use the left-most bit + // or it may be a constant value. + uint_type sign = std::is_same<SignedTag, GenerateNegativeTag>::value + ? (static_cast<uint_type>(1) << (kUintBits - 1)) + : 0; + if (std::is_same<SignedTag, GenerateSignedTag>::value) { + if (std::is_same<uint_type, uint64_t>::value) { + sign = bits & uint64_t{0x8000000000000000}; + } + if (std::is_same<uint_type, uint32_t>::value) { + const uint64_t tmp = bits & uint64_t{0x8000000000000000}; + sign = static_cast<uint32_t>(tmp >> 32); + } + // adjust the bits and the exponent to account for removing + // the leading bit. + bits = bits & uint64_t{0x7FFFFFFFFFFFFFFF}; + exp++; + } + if (IncludeZero) { + if (bits == 0u) return 0; + } + + // Number of leading zeros is mapped to the exponent: 2^-clz + // bits is 0..01xxxxxx. After shifting, we're left with 1xxx...0..0 + int clz = base_internal::CountLeadingZeros64(bits); + bits <<= (IncludeZero ? clz : (clz & 63)); // remove 0-bits. + exp -= clz; // set the exponent. + bits >>= (63 - kExp); + + // Construct the 32-bit or 64-bit IEEE 754 floating-point value from + // the individual fields: sign, exp, mantissa(bits). + uint_type val = + (std::is_same<SignedTag, GeneratePositiveTag>::value ? 0u : sign) | + (static_cast<uint_type>(exp) << kExp) | + (static_cast<uint_type>(bits) & kMask); + + // bit_cast to the output-type + real_type result; + memcpy(static_cast<void*>(&result), static_cast<const void*>(&val), + sizeof(result)); + return result; +} + +} // namespace random_internal +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_RANDOM_INTERNAL_GENERATE_REAL_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/distribution_impl_test.cc b/third_party/abseil-cpp/absl/random/internal/generate_real_test.cc similarity index 80% rename from third_party/abseil-cpp/absl/random/internal/distribution_impl_test.cc rename to third_party/abseil-cpp/absl/random/internal/generate_real_test.cc index 09e7a31..aa02f0c 100644 --- a/third_party/abseil-cpp/absl/random/internal/distribution_impl_test.cc +++ b/third_party/abseil-cpp/absl/random/internal/generate_real_test.cc
@@ -12,57 +12,74 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "absl/random/internal/distribution_impl.h" +#include "absl/random/internal/generate_real.h" + +#include <cfloat> +#include <cstddef> +#include <cstdint> +#include <string> #include "gtest/gtest.h" #include "absl/base/internal/bits.h" #include "absl/flags/flag.h" -#include "absl/numeric/int128.h" ABSL_FLAG(int64_t, absl_random_test_trials, 50000, "Number of trials for the probability tests."); -using absl::random_internal::NegativeValueT; -using absl::random_internal::PositiveValueT; -using absl::random_internal::RandU64ToDouble; -using absl::random_internal::RandU64ToFloat; -using absl::random_internal::SignedValueT; +using absl::random_internal::GenerateNegativeTag; +using absl::random_internal::GeneratePositiveTag; +using absl::random_internal::GenerateRealFromBits; +using absl::random_internal::GenerateSignedTag; namespace { -TEST(DistributionImplTest, U64ToFloat_Positive_NoZero_Test) { +TEST(GenerateRealTest, U64ToFloat_Positive_NoZero_Test) { auto ToFloat = [](uint64_t a) { - return RandU64ToFloat<PositiveValueT, false>(a); + return GenerateRealFromBits<float, GeneratePositiveTag, false>(a); }; EXPECT_EQ(ToFloat(0x0000000000000000), 2.710505431e-20f); EXPECT_EQ(ToFloat(0x0000000000000001), 5.421010862e-20f); EXPECT_EQ(ToFloat(0x8000000000000000), 0.5); + EXPECT_EQ(ToFloat(0x8000000000000001), 0.5); EXPECT_EQ(ToFloat(0xFFFFFFFFFFFFFFFF), 0.9999999404f); } -TEST(DistributionImplTest, U64ToFloat_Positive_Zero_Test) { +TEST(GenerateRealTest, U64ToFloat_Positive_Zero_Test) { auto ToFloat = [](uint64_t a) { - return RandU64ToFloat<PositiveValueT, true>(a); + return GenerateRealFromBits<float, GeneratePositiveTag, true>(a); }; EXPECT_EQ(ToFloat(0x0000000000000000), 0.0); EXPECT_EQ(ToFloat(0x0000000000000001), 5.421010862e-20f); EXPECT_EQ(ToFloat(0x8000000000000000), 0.5); + EXPECT_EQ(ToFloat(0x8000000000000001), 0.5); EXPECT_EQ(ToFloat(0xFFFFFFFFFFFFFFFF), 0.9999999404f); } -TEST(DistributionImplTest, U64ToFloat_Negative_NoZero_Test) { +TEST(GenerateRealTest, U64ToFloat_Negative_NoZero_Test) { auto ToFloat = [](uint64_t a) { - return RandU64ToFloat<NegativeValueT, false>(a); + return GenerateRealFromBits<float, GenerateNegativeTag, false>(a); }; EXPECT_EQ(ToFloat(0x0000000000000000), -2.710505431e-20f); EXPECT_EQ(ToFloat(0x0000000000000001), -5.421010862e-20f); EXPECT_EQ(ToFloat(0x8000000000000000), -0.5); + EXPECT_EQ(ToFloat(0x8000000000000001), -0.5); EXPECT_EQ(ToFloat(0xFFFFFFFFFFFFFFFF), -0.9999999404f); } -TEST(DistributionImplTest, U64ToFloat_Signed_NoZero_Test) { +TEST(GenerateRealTest, U64ToFloat_Negative_Zero_Test) { auto ToFloat = [](uint64_t a) { - return RandU64ToFloat<SignedValueT, false>(a); + return GenerateRealFromBits<float, GenerateNegativeTag, true>(a); + }; + EXPECT_EQ(ToFloat(0x0000000000000000), 0.0); + EXPECT_EQ(ToFloat(0x0000000000000001), -5.421010862e-20f); + EXPECT_EQ(ToFloat(0x8000000000000000), -0.5); + EXPECT_EQ(ToFloat(0x8000000000000001), -0.5); + EXPECT_EQ(ToFloat(0xFFFFFFFFFFFFFFFF), -0.9999999404f); +} + +TEST(GenerateRealTest, U64ToFloat_Signed_NoZero_Test) { + auto ToFloat = [](uint64_t a) { + return GenerateRealFromBits<float, GenerateSignedTag, false>(a); }; EXPECT_EQ(ToFloat(0x0000000000000000), 5.421010862e-20f); EXPECT_EQ(ToFloat(0x0000000000000001), 1.084202172e-19f); @@ -72,9 +89,9 @@ EXPECT_EQ(ToFloat(0xFFFFFFFFFFFFFFFF), -0.9999999404f); } -TEST(DistributionImplTest, U64ToFloat_Signed_Zero_Test) { +TEST(GenerateRealTest, U64ToFloat_Signed_Zero_Test) { auto ToFloat = [](uint64_t a) { - return RandU64ToFloat<SignedValueT, true>(a); + return GenerateRealFromBits<float, GenerateSignedTag, true>(a); }; EXPECT_EQ(ToFloat(0x0000000000000000), 0); EXPECT_EQ(ToFloat(0x0000000000000001), 1.084202172e-19f); @@ -84,9 +101,9 @@ EXPECT_EQ(ToFloat(0xFFFFFFFFFFFFFFFF), -0.9999999404f); } -TEST(DistributionImplTest, U64ToFloat_Signed_Bias_Test) { +TEST(GenerateRealTest, U64ToFloat_Signed_Bias_Test) { auto ToFloat = [](uint64_t a) { - return RandU64ToFloat<SignedValueT, true, 1>(a); + return GenerateRealFromBits<float, GenerateSignedTag, true>(a, 1); }; EXPECT_EQ(ToFloat(0x0000000000000000), 0); EXPECT_EQ(ToFloat(0x0000000000000001), 2 * 1.084202172e-19f); @@ -96,9 +113,9 @@ EXPECT_EQ(ToFloat(0xFFFFFFFFFFFFFFFF), 2 * -0.9999999404f); } -TEST(DistributionImplTest, U64ToFloatTest) { +TEST(GenerateRealTest, U64ToFloatTest) { auto ToFloat = [](uint64_t a) -> float { - return RandU64ToFloat<PositiveValueT, true>(a); + return GenerateRealFromBits<float, GeneratePositiveTag, true>(a); }; EXPECT_EQ(ToFloat(0x0000000000000000), 0.0f); @@ -150,44 +167,60 @@ } } -TEST(DistributionImplTest, U64ToDouble_Positive_NoZero_Test) { +TEST(GenerateRealTest, U64ToDouble_Positive_NoZero_Test) { auto ToDouble = [](uint64_t a) { - return RandU64ToDouble<PositiveValueT, false>(a); + return GenerateRealFromBits<double, GeneratePositiveTag, false>(a); }; EXPECT_EQ(ToDouble(0x0000000000000000), 2.710505431213761085e-20); EXPECT_EQ(ToDouble(0x0000000000000001), 5.42101086242752217004e-20); EXPECT_EQ(ToDouble(0x0000000000000002), 1.084202172485504434e-19); EXPECT_EQ(ToDouble(0x8000000000000000), 0.5); + EXPECT_EQ(ToDouble(0x8000000000000001), 0.5); EXPECT_EQ(ToDouble(0xFFFFFFFFFFFFFFFF), 0.999999999999999888978); } -TEST(DistributionImplTest, U64ToDouble_Positive_Zero_Test) { +TEST(GenerateRealTest, U64ToDouble_Positive_Zero_Test) { auto ToDouble = [](uint64_t a) { - return RandU64ToDouble<PositiveValueT, true>(a); + return GenerateRealFromBits<double, GeneratePositiveTag, true>(a); }; EXPECT_EQ(ToDouble(0x0000000000000000), 0.0); EXPECT_EQ(ToDouble(0x0000000000000001), 5.42101086242752217004e-20); EXPECT_EQ(ToDouble(0x8000000000000000), 0.5); + EXPECT_EQ(ToDouble(0x8000000000000001), 0.5); EXPECT_EQ(ToDouble(0xFFFFFFFFFFFFFFFF), 0.999999999999999888978); } -TEST(DistributionImplTest, U64ToDouble_Negative_NoZero_Test) { +TEST(GenerateRealTest, U64ToDouble_Negative_NoZero_Test) { auto ToDouble = [](uint64_t a) { - return RandU64ToDouble<NegativeValueT, false>(a); + return GenerateRealFromBits<double, GenerateNegativeTag, false>(a); }; EXPECT_EQ(ToDouble(0x0000000000000000), -2.710505431213761085e-20); EXPECT_EQ(ToDouble(0x0000000000000001), -5.42101086242752217004e-20); EXPECT_EQ(ToDouble(0x0000000000000002), -1.084202172485504434e-19); EXPECT_EQ(ToDouble(0x8000000000000000), -0.5); + EXPECT_EQ(ToDouble(0x8000000000000001), -0.5); EXPECT_EQ(ToDouble(0xFFFFFFFFFFFFFFFF), -0.999999999999999888978); } -TEST(DistributionImplTest, U64ToDouble_Signed_NoZero_Test) { +TEST(GenerateRealTest, U64ToDouble_Negative_Zero_Test) { auto ToDouble = [](uint64_t a) { - return RandU64ToDouble<SignedValueT, false>(a); + return GenerateRealFromBits<double, GenerateNegativeTag, true>(a); + }; + + EXPECT_EQ(ToDouble(0x0000000000000000), 0.0); + EXPECT_EQ(ToDouble(0x0000000000000001), -5.42101086242752217004e-20); + EXPECT_EQ(ToDouble(0x0000000000000002), -1.084202172485504434e-19); + EXPECT_EQ(ToDouble(0x8000000000000000), -0.5); + EXPECT_EQ(ToDouble(0x8000000000000001), -0.5); + EXPECT_EQ(ToDouble(0xFFFFFFFFFFFFFFFF), -0.999999999999999888978); +} + +TEST(GenerateRealTest, U64ToDouble_Signed_NoZero_Test) { + auto ToDouble = [](uint64_t a) { + return GenerateRealFromBits<double, GenerateSignedTag, false>(a); }; EXPECT_EQ(ToDouble(0x0000000000000000), 5.42101086242752217004e-20); @@ -198,9 +231,9 @@ EXPECT_EQ(ToDouble(0xFFFFFFFFFFFFFFFF), -0.999999999999999888978); } -TEST(DistributionImplTest, U64ToDouble_Signed_Zero_Test) { +TEST(GenerateRealTest, U64ToDouble_Signed_Zero_Test) { auto ToDouble = [](uint64_t a) { - return RandU64ToDouble<SignedValueT, true>(a); + return GenerateRealFromBits<double, GenerateSignedTag, true>(a); }; EXPECT_EQ(ToDouble(0x0000000000000000), 0); EXPECT_EQ(ToDouble(0x0000000000000001), 1.084202172485504434e-19); @@ -210,9 +243,9 @@ EXPECT_EQ(ToDouble(0xFFFFFFFFFFFFFFFF), -0.999999999999999888978); } -TEST(DistributionImplTest, U64ToDouble_Signed_Bias_Test) { +TEST(GenerateRealTest, U64ToDouble_GenerateSignedTag_Bias_Test) { auto ToDouble = [](uint64_t a) { - return RandU64ToDouble<SignedValueT, true, -1>(a); + return GenerateRealFromBits<double, GenerateSignedTag, true>(a, -1); }; EXPECT_EQ(ToDouble(0x0000000000000000), 0); EXPECT_EQ(ToDouble(0x0000000000000001), 1.084202172485504434e-19 / 2); @@ -222,9 +255,9 @@ EXPECT_EQ(ToDouble(0xFFFFFFFFFFFFFFFF), -0.999999999999999888978 / 2); } -TEST(DistributionImplTest, U64ToDoubleTest) { +TEST(GenerateRealTest, U64ToDoubleTest) { auto ToDouble = [](uint64_t a) { - return RandU64ToDouble<PositiveValueT, true>(a); + return GenerateRealFromBits<double, GeneratePositiveTag, true>(a); }; EXPECT_EQ(ToDouble(0x0000000000000000), 0.0); @@ -296,9 +329,9 @@ } } -TEST(DistributionImplTest, U64ToDoubleSignedTest) { +TEST(GenerateRealTest, U64ToDoubleSignedTest) { auto ToDouble = [](uint64_t a) { - return RandU64ToDouble<SignedValueT, false>(a); + return GenerateRealFromBits<double, GenerateSignedTag, false>(a); }; EXPECT_EQ(ToDouble(0x0000000000000000), 5.42101086242752217004e-20); @@ -379,10 +412,10 @@ } } -TEST(DistributionImplTest, ExhaustiveFloat) { +TEST(GenerateRealTest, ExhaustiveFloat) { using absl::base_internal::CountLeadingZeros64; auto ToFloat = [](uint64_t a) { - return RandU64ToFloat<PositiveValueT, true>(a); + return GenerateRealFromBits<float, GeneratePositiveTag, true>(a); }; // Rely on RandU64ToFloat generating values from greatest to least when @@ -461,46 +494,4 @@ } } -TEST(DistributionImplTest, MultiplyU64ToU128Test) { - using absl::random_internal::MultiplyU64ToU128; - constexpr uint64_t k1 = 1; - constexpr uint64_t kMax = ~static_cast<uint64_t>(0); - - EXPECT_EQ(absl::uint128(0), MultiplyU64ToU128(0, 0)); - - // Max uint64 - EXPECT_EQ(MultiplyU64ToU128(kMax, kMax), - absl::MakeUint128(0xfffffffffffffffe, 0x0000000000000001)); - EXPECT_EQ(absl::MakeUint128(0, kMax), MultiplyU64ToU128(kMax, 1)); - EXPECT_EQ(absl::MakeUint128(0, kMax), MultiplyU64ToU128(1, kMax)); - for (int i = 0; i < 64; ++i) { - EXPECT_EQ(absl::MakeUint128(0, kMax) << i, - MultiplyU64ToU128(kMax, k1 << i)); - EXPECT_EQ(absl::MakeUint128(0, kMax) << i, - MultiplyU64ToU128(k1 << i, kMax)); - } - - // 1-bit x 1-bit. - for (int i = 0; i < 64; ++i) { - for (int j = 0; j < 64; ++j) { - EXPECT_EQ(absl::MakeUint128(0, 1) << (i + j), - MultiplyU64ToU128(k1 << i, k1 << j)); - EXPECT_EQ(absl::MakeUint128(0, 1) << (i + j), - MultiplyU64ToU128(k1 << i, k1 << j)); - } - } - - // Verified multiplies - EXPECT_EQ(MultiplyU64ToU128(0xffffeeeeddddcccc, 0xbbbbaaaa99998888), - absl::MakeUint128(0xbbbb9e2692c5dddc, 0xc28f7531048d2c60)); - EXPECT_EQ(MultiplyU64ToU128(0x0123456789abcdef, 0xfedcba9876543210), - absl::MakeUint128(0x0121fa00ad77d742, 0x2236d88fe5618cf0)); - EXPECT_EQ(MultiplyU64ToU128(0x0123456789abcdef, 0xfdb97531eca86420), - absl::MakeUint128(0x0120ae99d26725fc, 0xce197f0ecac319e0)); - EXPECT_EQ(MultiplyU64ToU128(0x97a87f4f261ba3f2, 0xfedcba9876543210), - absl::MakeUint128(0x96fbf1a8ae78d0ba, 0x5a6dd4b71f278320)); - EXPECT_EQ(MultiplyU64ToU128(0xfedcba9876543210, 0xfdb97531eca86420), - absl::MakeUint128(0xfc98c6981a413e22, 0x342d0bbf48948200)); -} - } // namespace
diff --git a/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h b/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h index df88fa7..7378829 100644 --- a/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h +++ b/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h
@@ -24,6 +24,7 @@ #include "absl/numeric/int128.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // The null_state_saver does nothing. @@ -238,6 +239,7 @@ } } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_IOSTREAM_STATE_SAVER_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/iostream_state_saver_test.cc b/third_party/abseil-cpp/absl/random/internal/iostream_state_saver_test.cc index 2ecbaac..7bb8ad95 100644 --- a/third_party/abseil-cpp/absl/random/internal/iostream_state_saver_test.cc +++ b/third_party/abseil-cpp/absl/random/internal/iostream_state_saver_test.cc
@@ -196,8 +196,8 @@ EXPECT_EQ(-d, StreamRoundTrip<double>(-d)); // Avoid undefined behavior (overflow/underflow). - if (d <= std::numeric_limits<int64_t>::max() && - d >= std::numeric_limits<int64_t>::lowest()) { + if (f <= static_cast<float>(std::numeric_limits<int64_t>::max()) && + f >= static_cast<float>(std::numeric_limits<int64_t>::lowest())) { int64_t x = static_cast<int64_t>(f); EXPECT_EQ(x, StreamRoundTrip<int64_t>(x)); } @@ -264,14 +264,15 @@ } // Avoid undefined behavior (overflow/underflow). - if (d <= std::numeric_limits<int64_t>::max() && - d >= std::numeric_limits<int64_t>::lowest()) { + if (d <= static_cast<double>(std::numeric_limits<int64_t>::max()) && + d >= static_cast<double>(std::numeric_limits<int64_t>::lowest())) { int64_t x = static_cast<int64_t>(d); EXPECT_EQ(x, StreamRoundTrip<int64_t>(x)); } } } +#if !defined(__EMSCRIPTEN__) TEST(IOStreamStateSaver, RoundTripLongDoubles) { // Technically, C++ only guarantees that long double is at least as large as a // double. Practically it varies from 64-bits to 128-bits. @@ -349,6 +350,7 @@ } } } +#endif // !defined(__EMSCRIPTEN__) TEST(StrToDTest, DoubleMin) { const char kV[] = "2.22507385850720138e-308";
diff --git a/third_party/abseil-cpp/absl/random/internal/mock_overload_set.h b/third_party/abseil-cpp/absl/random/internal/mock_overload_set.h new file mode 100644 index 0000000..c2a30d8 --- /dev/null +++ b/third_party/abseil-cpp/absl/random/internal/mock_overload_set.h
@@ -0,0 +1,91 @@ +// +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ABSL_RANDOM_INTERNAL_MOCK_OVERLOAD_SET_H_ +#define ABSL_RANDOM_INTERNAL_MOCK_OVERLOAD_SET_H_ + +#include <type_traits> + +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "absl/random/mocking_bit_gen.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace random_internal { + +template <typename DistrT, typename Fn> +struct MockSingleOverload; + +// MockSingleOverload +// +// MockSingleOverload hooks in to gMock's `ON_CALL` and `EXPECT_CALL` macros. +// EXPECT_CALL(mock_single_overload, Call(...))` will expand to a call to +// `mock_single_overload.gmock_Call(...)`. Because expectations are stored on +// the MockingBitGen (an argument passed inside `Call(...)`), this forwards to +// arguments to Mocking::Register. +template <typename DistrT, typename Ret, typename... Args> +struct MockSingleOverload<DistrT, Ret(MockingBitGen&, Args...)> { + static_assert(std::is_same<typename DistrT::result_type, Ret>::value, + "Overload signature must have return type matching the " + "distributions result type."); + auto gmock_Call( + absl::MockingBitGen& gen, // NOLINT(google-runtime-references) + const ::testing::Matcher<Args>&... args) + -> decltype(gen.Register<DistrT, Args...>(args...)) { + return gen.Register<DistrT, Args...>(args...); + } +}; + +template <typename DistrT, typename Ret, typename Arg, typename... Args> +struct MockSingleOverload<DistrT, Ret(Arg, MockingBitGen&, Args...)> { + static_assert(std::is_same<typename DistrT::result_type, Ret>::value, + "Overload signature must have return type matching the " + "distributions result type."); + auto gmock_Call( + const ::testing::Matcher<Arg>& arg, + absl::MockingBitGen& gen, // NOLINT(google-runtime-references) + const ::testing::Matcher<Args>&... args) + -> decltype(gen.Register<DistrT, Arg, Args...>(arg, args...)) { + return gen.Register<DistrT, Arg, Args...>(arg, args...); + } +}; + +// MockOverloadSet +// +// MockOverloadSet takes a distribution and a collection of signatures and +// performs overload resolution amongst all the overloads. This makes +// `EXPECT_CALL(mock_overload_set, Call(...))` expand and do overload resolution +// correctly. +template <typename DistrT, typename... Signatures> +struct MockOverloadSet; + +template <typename DistrT, typename Sig> +struct MockOverloadSet<DistrT, Sig> : public MockSingleOverload<DistrT, Sig> { + using MockSingleOverload<DistrT, Sig>::gmock_Call; +}; + +template <typename DistrT, typename FirstSig, typename... Rest> +struct MockOverloadSet<DistrT, FirstSig, Rest...> + : public MockSingleOverload<DistrT, FirstSig>, + public MockOverloadSet<DistrT, Rest...> { + using MockSingleOverload<DistrT, FirstSig>::gmock_Call; + using MockOverloadSet<DistrT, Rest...>::gmock_Call; +}; + +} // namespace random_internal +ABSL_NAMESPACE_END +} // namespace absl +#endif // ABSL_RANDOM_INTERNAL_MOCK_OVERLOAD_SET_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/mocking_bit_gen_base.h b/third_party/abseil-cpp/absl/random/internal/mocking_bit_gen_base.h new file mode 100644 index 0000000..eeeae9d --- /dev/null +++ b/third_party/abseil-cpp/absl/random/internal/mocking_bit_gen_base.h
@@ -0,0 +1,120 @@ +// +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#ifndef ABSL_RANDOM_INTERNAL_MOCKING_BIT_GEN_BASE_H_ +#define ABSL_RANDOM_INTERNAL_MOCKING_BIT_GEN_BASE_H_ + +#include <atomic> +#include <deque> +#include <string> +#include <typeinfo> + +#include "absl/random/random.h" +#include "absl/strings/str_cat.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace random_internal { + +// MockingBitGenExpectationFormatter is invoked to format unsatisfied mocks +// and remaining results into a description string. +template <typename DistrT, typename FormatT> +struct MockingBitGenExpectationFormatter { + std::string operator()(absl::string_view args) { + return absl::StrCat(FormatT::FunctionName(), "(", args, ")"); + } +}; + +// MockingBitGenCallFormatter is invoked to format each distribution call +// into a description string for the mock log. +template <typename DistrT, typename FormatT> +struct MockingBitGenCallFormatter { + std::string operator()(const DistrT& dist, + const typename DistrT::result_type& result) { + return absl::StrCat( + FormatT::FunctionName(), "(", FormatT::FormatArgs(dist), ") => {", + FormatT::FormatResults(absl::MakeSpan(&result, 1)), "}"); + } +}; + +class MockingBitGenBase { + template <typename> + friend struct DistributionCaller; + using generator_type = absl::BitGen; + + public: + // URBG interface + using result_type = generator_type::result_type; + static constexpr result_type(min)() { return (generator_type::min)(); } + static constexpr result_type(max)() { return (generator_type::max)(); } + result_type operator()() { return gen_(); } + + MockingBitGenBase() : gen_(), observed_call_log_() {} + virtual ~MockingBitGenBase() = default; + + protected: + const std::deque<std::string>& observed_call_log() { + return observed_call_log_; + } + + // CallImpl is the type-erased virtual dispatch. + // The type of dist is always distribution<T>, + // The type of result is always distribution<T>::result_type. + virtual bool CallImpl(const std::type_info& distr_type, void* dist_args, + void* result) = 0; + + template <typename DistrT, typename ArgTupleT> + static const std::type_info& GetTypeId() { + return typeid(std::pair<absl::decay_t<DistrT>, absl::decay_t<ArgTupleT>>); + } + + // Call the generating distribution function. + // Invoked by DistributionCaller<>::Call<DistT, FormatT>. + // DistT is the distribution type. + // FormatT is the distribution formatter traits type. + template <typename DistrT, typename FormatT, typename... Args> + typename DistrT::result_type Call(Args&&... args) { + using distr_result_type = typename DistrT::result_type; + using ArgTupleT = std::tuple<absl::decay_t<Args>...>; + + ArgTupleT arg_tuple(std::forward<Args>(args)...); + auto dist = absl::make_from_tuple<DistrT>(arg_tuple); + + distr_result_type result{}; + bool found_match = + CallImpl(GetTypeId<DistrT, ArgTupleT>(), &arg_tuple, &result); + + if (!found_match) { + result = dist(gen_); + } + + // TODO(asoffer): Forwarding the args through means we no longer need to + // extract them from the from the distribution in formatter traits. We can + // just StrJoin them. + observed_call_log_.push_back( + MockingBitGenCallFormatter<DistrT, FormatT>{}(dist, result)); + return result; + } + + private: + generator_type gen_; + std::deque<std::string> observed_call_log_; +}; // namespace random_internal + +} // namespace random_internal +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_RANDOM_INTERNAL_MOCKING_BIT_GEN_BASE_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/nanobenchmark.cc b/third_party/abseil-cpp/absl/random/internal/nanobenchmark.cc index 7f37800c..c918181 100644 --- a/third_party/abseil-cpp/absl/random/internal/nanobenchmark.cc +++ b/third_party/abseil-cpp/absl/random/internal/nanobenchmark.cc
@@ -27,6 +27,7 @@ #include <utility> #include <vector> +#include "absl/base/attributes.h" #include "absl/base/internal/raw_logging.h" #include "absl/random/internal/platform.h" #include "absl/random/internal/randen_engine.h" @@ -59,15 +60,6 @@ #include <time.h> // NOLINT #endif -// ABSL_HAVE_ATTRIBUTE -#if !defined(ABSL_HAVE_ATTRIBUTE) -#ifdef __has_attribute -#define ABSL_HAVE_ATTRIBUTE(x) __has_attribute(x) -#else -#define ABSL_HAVE_ATTRIBUTE(x) 0 -#endif -#endif - // ABSL_RANDOM_INTERNAL_ATTRIBUTE_NEVER_INLINE prevents inlining of the method. #if ABSL_HAVE_ATTRIBUTE(noinline) || (defined(__GNUC__) && !defined(__clang__)) #define ABSL_RANDOM_INTERNAL_ATTRIBUTE_NEVER_INLINE __attribute__((noinline)) @@ -78,6 +70,7 @@ #endif namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal_nanobenchmark { namespace { @@ -108,7 +101,7 @@ char brand_string[49]; uint32_t abcd[4]; - // Check if brand std::string is supported (it is on all reasonable Intel/AMD) + // Check if brand string is supported (it is on all reasonable Intel/AMD) Cpuid(0x80000000U, 0, abcd); if (abcd[0] < 0x80000004U) { return std::string(); @@ -807,4 +800,5 @@ } } // namespace random_internal_nanobenchmark +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/random/internal/nanobenchmark.h b/third_party/abseil-cpp/absl/random/internal/nanobenchmark.h index c2b650d..a5097ba 100644 --- a/third_party/abseil-cpp/absl/random/internal/nanobenchmark.h +++ b/third_party/abseil-cpp/absl/random/internal/nanobenchmark.h
@@ -50,7 +50,10 @@ #include <stddef.h> #include <stdint.h> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal_nanobenchmark { // Input influencing the function being measured (e.g. number of bytes to copy). @@ -163,6 +166,7 @@ } } // namespace random_internal_nanobenchmark +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_NANOBENCHMARK_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/nanobenchmark_test.cc b/third_party/abseil-cpp/absl/random/internal/nanobenchmark_test.cc index 383345a..ab824ef 100644 --- a/third_party/abseil-cpp/absl/random/internal/nanobenchmark_test.cc +++ b/third_party/abseil-cpp/absl/random/internal/nanobenchmark_test.cc
@@ -18,6 +18,7 @@ #include "absl/strings/numbers.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal_nanobenchmark { namespace { @@ -67,6 +68,7 @@ } // namespace } // namespace random_internal_nanobenchmark +ABSL_NAMESPACE_END } // namespace absl int main(int argc, char* argv[]) {
diff --git a/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h b/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h index 8847e74..730fa2e 100644 --- a/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +++ b/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h
@@ -33,6 +33,7 @@ #include "absl/types/span.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // Each instance of NonsecureURBGBase<URBG> will be seeded by variates produced @@ -143,6 +144,7 @@ }; } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_NONSECURE_BASE_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/nonsecure_base_test.cc b/third_party/abseil-cpp/absl/random/internal/nonsecure_base_test.cc index d9de990..698027f 100644 --- a/third_party/abseil-cpp/absl/random/internal/nonsecure_base_test.cc +++ b/third_party/abseil-cpp/absl/random/internal/nonsecure_base_test.cc
@@ -154,9 +154,10 @@ TEST(NonsecureURBGBase, CompatibleWithStdDistributions) { ExampleNonsecureURBG rbg; - std::uniform_int_distribution<uint32_t>(0, 100)(rbg); - std::uniform_real_distribution<float>()(rbg); - std::bernoulli_distribution(0.2)(rbg); + // Cast to void to suppress [[nodiscard]] warnings + static_cast<void>(std::uniform_int_distribution<uint32_t>(0, 100)(rbg)); + static_cast<void>(std::uniform_real_distribution<float>()(rbg)); + static_cast<void>(std::bernoulli_distribution(0.2)(rbg)); } TEST(NonsecureURBGBase, ConsecutiveDefaultInstancesYieldUniqueVariates) {
diff --git a/third_party/abseil-cpp/absl/random/internal/pcg_engine.h b/third_party/abseil-cpp/absl/random/internal/pcg_engine.h index b5df4eaff..53c23fe 100644 --- a/third_party/abseil-cpp/absl/random/internal/pcg_engine.h +++ b/third_party/abseil-cpp/absl/random/internal/pcg_engine.h
@@ -24,6 +24,7 @@ #include "absl/random/internal/iostream_state_saver.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // pcg_engine is a simplified implementation of Melissa O'Neil's PCG engine in @@ -300,6 +301,7 @@ random_internal::pcg_xsh_rr_64_32>; } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_PCG_ENGINE_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/platform.h b/third_party/abseil-cpp/absl/random/internal/platform.h index a5a42cb..bbdb4e62 100644 --- a/third_party/abseil-cpp/absl/random/internal/platform.h +++ b/third_party/abseil-cpp/absl/random/internal/platform.h
@@ -162,7 +162,8 @@ // iOS does not support dispatch, even on x86, since applications // should be bundled as fat binaries, with a different build tailored for // each specific supported platform/architecture. -#if defined(__APPLE__) && (TARGET_OS_IPHONE || TARGET_OS_IPHONE_SIMULATOR) +#if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || \ + (defined(TARGET_OS_IPHONE_SIMULATOR) && TARGET_OS_IPHONE_SIMULATOR) #undef ABSL_RANDOM_INTERNAL_AES_DISPATCH #define ABSL_RANDOM_INTERNAL_AES_DISPATCH 0 #endif
diff --git a/third_party/abseil-cpp/absl/random/internal/pool_urbg.cc b/third_party/abseil-cpp/absl/random/internal/pool_urbg.cc index f2e1c1f..5bee530 100644 --- a/third_party/abseil-cpp/absl/random/internal/pool_urbg.cc +++ b/third_party/abseil-cpp/absl/random/internal/pool_urbg.cc
@@ -37,6 +37,7 @@ using absl::base_internal::SpinLockHolder; namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { namespace { @@ -249,4 +250,5 @@ template class RandenPool<uint64_t>; } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/random/internal/pool_urbg.h b/third_party/abseil-cpp/absl/random/internal/pool_urbg.h index 9b2dd4b..05721929 100644 --- a/third_party/abseil-cpp/absl/random/internal/pool_urbg.h +++ b/third_party/abseil-cpp/absl/random/internal/pool_urbg.h
@@ -22,6 +22,7 @@ #include "absl/types/span.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // RandenPool is a thread-safe random number generator [random.req.urbg] that @@ -124,6 +125,7 @@ }; } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_POOL_URBG_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/randen.cc b/third_party/abseil-cpp/absl/random/internal/randen.cc index bab8075..78a1e00 100644 --- a/third_party/abseil-cpp/absl/random/internal/randen.cc +++ b/third_party/abseil-cpp/absl/random/internal/randen.cc
@@ -41,6 +41,7 @@ // structured/low-entropy counters to digits of Pi. namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { namespace { @@ -86,4 +87,5 @@ } } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/random/internal/randen.h b/third_party/abseil-cpp/absl/random/internal/randen.h index a4ff2545..c2834aa 100644 --- a/third_party/abseil-cpp/absl/random/internal/randen.h +++ b/third_party/abseil-cpp/absl/random/internal/randen.h
@@ -23,6 +23,7 @@ #include "absl/random/internal/randen_traits.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // RANDen = RANDom generator or beetroots in Swiss German. @@ -95,6 +96,7 @@ }; } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_RANDEN_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/randen_detect.cc b/third_party/abseil-cpp/absl/random/internal/randen_detect.cc index d5946b21..d63230c2 100644 --- a/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +++ b/third_party/abseil-cpp/absl/random/internal/randen_detect.cc
@@ -95,6 +95,7 @@ #endif namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // The default return at the end of the function might be unreachable depending @@ -216,4 +217,5 @@ #endif } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/random/internal/randen_detect.h b/third_party/abseil-cpp/absl/random/internal/randen_detect.h index 44c5c66..f283f43 100644 --- a/third_party/abseil-cpp/absl/random/internal/randen_detect.h +++ b/third_party/abseil-cpp/absl/random/internal/randen_detect.h
@@ -15,7 +15,10 @@ #ifndef ABSL_RANDOM_INTERNAL_RANDEN_DETECT_H_ #define ABSL_RANDOM_INTERNAL_RANDEN_DETECT_H_ +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // Returns whether the current CPU supports RandenHwAes implementation. @@ -24,6 +27,7 @@ bool CPUSupportsRandenHwAes(); } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_RANDEN_DETECT_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/randen_engine.h b/third_party/abseil-cpp/absl/random/internal/randen_engine.h index 02212a13..6b33731 100644 --- a/third_party/abseil-cpp/absl/random/internal/randen_engine.h +++ b/third_party/abseil-cpp/absl/random/internal/randen_engine.h
@@ -28,6 +28,7 @@ #include "absl/random/internal/randen.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // Deterministic pseudorandom byte generator with backtracking resistance @@ -223,6 +224,7 @@ }; } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_RANDEN_ENGINE_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc b/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc index 6b82d1d..e23844f1 100644 --- a/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc +++ b/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc
@@ -22,39 +22,9 @@ #include <cstdint> #include <cstring> +#include "absl/base/attributes.h" #include "absl/random/internal/platform.h" -// ABSL_HAVE_ATTRIBUTE -#if !defined(ABSL_HAVE_ATTRIBUTE) -#ifdef __has_attribute -#define ABSL_HAVE_ATTRIBUTE(x) __has_attribute(x) -#else -#define ABSL_HAVE_ATTRIBUTE(x) 0 -#endif -#endif - -#if ABSL_HAVE_ATTRIBUTE(always_inline) || \ - (defined(__GNUC__) && !defined(__clang__)) -#define ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE \ - __attribute__((always_inline)) -#elif defined(_MSC_VER) -// We can achieve something similar to attribute((always_inline)) with MSVC by -// using the __forceinline keyword, however this is not perfect. MSVC is -// much less aggressive about inlining, and even with the __forceinline keyword. -#define ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE __forceinline -#else -#define ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE -#endif - -// ABSL_ATTRIBUTE_FLATTEN enables much more aggressive inlining within -// the indicated function. -#undef ABSL_ATTRIBUTE_FLATTEN -#if ABSL_HAVE_ATTRIBUTE(flatten) || (defined(__GNUC__) && !defined(__clang__)) -#define ABSL_ATTRIBUTE_FLATTEN __attribute__((flatten)) -#else -#define ABSL_ATTRIBUTE_FLATTEN -#endif - // ABSL_RANDEN_HWAES_IMPL indicates whether this file will contain // a hardware accelerated implementation of randen, or whether it // will contain stubs that exit the process. @@ -105,6 +75,7 @@ #include <cstdlib> namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // No accelerated implementation. @@ -136,6 +107,7 @@ } } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #else // defined(ABSL_RANDEN_HWAES_IMPL) @@ -146,18 +118,6 @@ #include "absl/random/internal/randen_traits.h" -// ABSL_FUNCTION_ALIGN32 defines a 32-byte alignment attribute -// for the functions in this file. -// -// NOTE: Determine whether we actually have any wins from ALIGN32 -// using microbenchmarks. If not, remove. -#undef ABSL_FUNCTION_ALIGN32 -#if ABSL_HAVE_ATTRIBUTE(aligned) || (defined(__GNUC__) && !defined(__clang__)) -#define ABSL_FUNCTION_ALIGN32 __attribute__((aligned(32))) -#else -#define ABSL_FUNCTION_ALIGN32 -#endif - // TARGET_CRYPTO defines a crypto attribute for each architecture. // // NOTE: Evaluate whether we should eliminate ABSL_TARGET_CRYPTO. @@ -191,8 +151,7 @@ namespace { -inline ABSL_TARGET_CRYPTO ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE Vector128 -ReverseBytes(const Vector128& v) { +inline ABSL_TARGET_CRYPTO Vector128 ReverseBytes(const Vector128& v) { // Reverses the bytes of the vector. const __vector unsigned char perm = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; @@ -202,26 +161,23 @@ // WARNING: these load/store in native byte order. It is OK to load and then // store an unchanged vector, but interpreting the bits as a number or input // to AES will have undefined results. -inline ABSL_TARGET_CRYPTO ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE Vector128 -Vector128Load(const void* ABSL_RANDOM_INTERNAL_RESTRICT from) { +inline ABSL_TARGET_CRYPTO Vector128 Vector128Load(const void* from) { return vec_vsx_ld(0, reinterpret_cast<const Vector128*>(from)); } -inline ABSL_TARGET_CRYPTO ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE void -Vector128Store(const Vector128& v, void* ABSL_RANDOM_INTERNAL_RESTRICT to) { +inline ABSL_TARGET_CRYPTO void Vector128Store(const Vector128& v, void* to) { vec_vsx_st(v, 0, reinterpret_cast<Vector128*>(to)); } // One round of AES. "round_key" is a public constant for breaking the // symmetry of AES (ensures previously equal columns differ afterwards). -inline ABSL_TARGET_CRYPTO ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE Vector128 -AesRound(const Vector128& state, const Vector128& round_key) { +inline ABSL_TARGET_CRYPTO Vector128 AesRound(const Vector128& state, + const Vector128& round_key) { return Vector128(__builtin_crypto_vcipher(state, round_key)); } // Enables native loads in the round loop by pre-swapping. -inline ABSL_TARGET_CRYPTO ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE void -SwapEndian(uint64_t* ABSL_RANDOM_INTERNAL_RESTRICT state) { +inline ABSL_TARGET_CRYPTO void SwapEndian(uint64_t* state) { using absl::random_internal::RandenTraits; constexpr size_t kLanes = 2; constexpr size_t kFeistelBlocks = RandenTraits::kFeistelBlocks; @@ -273,20 +229,18 @@ namespace { -inline ABSL_TARGET_CRYPTO ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE Vector128 -Vector128Load(const void* ABSL_RANDOM_INTERNAL_RESTRICT from) { +inline ABSL_TARGET_CRYPTO Vector128 Vector128Load(const void* from) { return vld1q_u8(reinterpret_cast<const uint8_t*>(from)); } -inline ABSL_TARGET_CRYPTO ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE void -Vector128Store(const Vector128& v, void* ABSL_RANDOM_INTERNAL_RESTRICT to) { +inline ABSL_TARGET_CRYPTO void Vector128Store(const Vector128& v, void* to) { vst1q_u8(reinterpret_cast<uint8_t*>(to), v); } // One round of AES. "round_key" is a public constant for breaking the // symmetry of AES (ensures previously equal columns differ afterwards). -inline ABSL_TARGET_CRYPTO ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE Vector128 -AesRound(const Vector128& state, const Vector128& round_key) { +inline ABSL_TARGET_CRYPTO Vector128 AesRound(const Vector128& state, + const Vector128& round_key) { // It is important to always use the full round function - omitting the // final MixColumns reduces security [https://eprint.iacr.org/2010/041.pdf] // and does not help because we never decrypt. @@ -297,8 +251,7 @@ return vaesmcq_u8(vaeseq_u8(state, uint8x16_t{})) ^ round_key; } -inline ABSL_TARGET_CRYPTO ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE void -SwapEndian(uint64_t* ABSL_RANDOM_INTERNAL_RESTRICT) {} +inline ABSL_TARGET_CRYPTO void SwapEndian(uint64_t*) {} } // namespace @@ -313,16 +266,11 @@ class Vector128 { public: // Convert from/to intrinsics. - inline ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE explicit Vector128( - const __m128i& Vector128) - : data_(Vector128) {} + inline explicit Vector128(const __m128i& Vector128) : data_(Vector128) {} - inline ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE __m128i data() const { - return data_; - } + inline __m128i data() const { return data_; } - inline ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE Vector128& operator^=( - const Vector128& other) { + inline Vector128& operator^=(const Vector128& other) { data_ = _mm_xor_si128(data_, other.data()); return *this; } @@ -331,29 +279,25 @@ __m128i data_; }; -inline ABSL_TARGET_CRYPTO ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE Vector128 -Vector128Load(const void* ABSL_RANDOM_INTERNAL_RESTRICT from) { +inline ABSL_TARGET_CRYPTO Vector128 Vector128Load(const void* from) { return Vector128(_mm_load_si128(reinterpret_cast<const __m128i*>(from))); } -inline ABSL_TARGET_CRYPTO ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE void -Vector128Store(const Vector128& v, void* ABSL_RANDOM_INTERNAL_RESTRICT to) { - _mm_store_si128(reinterpret_cast<__m128i * ABSL_RANDOM_INTERNAL_RESTRICT>(to), - v.data()); +inline ABSL_TARGET_CRYPTO void Vector128Store(const Vector128& v, void* to) { + _mm_store_si128(reinterpret_cast<__m128i*>(to), v.data()); } // One round of AES. "round_key" is a public constant for breaking the // symmetry of AES (ensures previously equal columns differ afterwards). -inline ABSL_TARGET_CRYPTO ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE Vector128 -AesRound(const Vector128& state, const Vector128& round_key) { +inline ABSL_TARGET_CRYPTO Vector128 AesRound(const Vector128& state, + const Vector128& round_key) { // It is important to always use the full round function - omitting the // final MixColumns reduces security [https://eprint.iacr.org/2010/041.pdf] // and does not help because we never decrypt. return Vector128(_mm_aesenc_si128(state.data(), round_key.data())); } -inline ABSL_TARGET_CRYPTO ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE void -SwapEndian(uint64_t* ABSL_RANDOM_INTERNAL_RESTRICT) {} +inline ABSL_TARGET_CRYPTO void SwapEndian(uint64_t*) {} } // namespace @@ -450,8 +394,7 @@ // Block shuffles applies a shuffle to the entire state between AES rounds. // Improved odd-even shuffle from "New criterion for diffusion property". -inline ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE ABSL_TARGET_CRYPTO void -BlockShuffle(uint64_t* ABSL_RANDOM_INTERNAL_RESTRICT state) { +inline ABSL_TARGET_CRYPTO void BlockShuffle(uint64_t* state) { static_assert(kFeistelBlocks == 16, "Expecting 16 FeistelBlocks."); constexpr size_t shuffle[kFeistelBlocks] = {7, 2, 13, 4, 11, 8, 3, 6, @@ -499,10 +442,8 @@ // per 16 bytes (vs. 10 for AES-CTR). Computing eight round functions in // parallel hides the 7-cycle AESNI latency on HSW. Note that the Feistel // XORs are 'free' (included in the second AES instruction). -inline ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE ABSL_TARGET_CRYPTO const - u64x2* - FeistelRound(uint64_t* ABSL_RANDOM_INTERNAL_RESTRICT state, - const u64x2* ABSL_RANDOM_INTERNAL_RESTRICT keys) { +inline ABSL_TARGET_CRYPTO const u64x2* FeistelRound( + uint64_t* state, const u64x2* ABSL_RANDOM_INTERNAL_RESTRICT keys) { static_assert(kFeistelBlocks == 16, "Expecting 16 FeistelBlocks."); // MSVC does a horrible job at unrolling loops. @@ -561,9 +502,8 @@ // Indistinguishable from ideal by chosen-ciphertext adversaries using less than // 2^64 queries if the round function is a PRF. This is similar to the b=8 case // of Simpira v2, but more efficient than its generic construction for b=16. -inline ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE ABSL_TARGET_CRYPTO void -Permute(const void* ABSL_RANDOM_INTERNAL_RESTRICT keys, - uint64_t* ABSL_RANDOM_INTERNAL_RESTRICT state) { +inline ABSL_TARGET_CRYPTO void Permute( + const void* ABSL_RANDOM_INTERNAL_RESTRICT keys, uint64_t* state) { const u64x2* ABSL_RANDOM_INTERNAL_RESTRICT keys128 = static_cast<const u64x2*>(keys); @@ -580,24 +520,22 @@ } // namespace namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { bool HasRandenHwAesImplementation() { return true; } -const void* ABSL_TARGET_CRYPTO ABSL_FUNCTION_ALIGN32 ABSL_ATTRIBUTE_FLATTEN -RandenHwAes::GetKeys() { +const void* ABSL_TARGET_CRYPTO RandenHwAes::GetKeys() { // Round keys for one AES per Feistel round and branch. // The canonical implementation uses first digits of Pi. return round_keys; } // NOLINTNEXTLINE -void ABSL_TARGET_CRYPTO ABSL_FUNCTION_ALIGN32 ABSL_ATTRIBUTE_FLATTEN -RandenHwAes::Absorb(const void* seed_void, void* state_void) { - uint64_t* ABSL_RANDOM_INTERNAL_RESTRICT state = - reinterpret_cast<uint64_t*>(state_void); - const uint64_t* ABSL_RANDOM_INTERNAL_RESTRICT seed = - reinterpret_cast<const uint64_t*>(seed_void); +void ABSL_TARGET_CRYPTO RandenHwAes::Absorb(const void* seed_void, + void* state_void) { + auto* state = static_cast<uint64_t*>(state_void); + const auto* seed = static_cast<const uint64_t*>(seed_void); constexpr size_t kCapacityBlocks = kCapacityBytes / sizeof(Vector128); constexpr size_t kStateBlocks = kStateBytes / sizeof(Vector128); @@ -669,12 +607,11 @@ } // NOLINTNEXTLINE -void ABSL_TARGET_CRYPTO ABSL_FUNCTION_ALIGN32 ABSL_ATTRIBUTE_FLATTEN -RandenHwAes::Generate(const void* keys, void* state_void) { +void ABSL_TARGET_CRYPTO RandenHwAes::Generate(const void* keys, + void* state_void) { static_assert(kCapacityBytes == sizeof(Vector128), "Capacity mismatch"); - uint64_t* ABSL_RANDOM_INTERNAL_RESTRICT state = - reinterpret_cast<uint64_t*>(state_void); + auto* state = static_cast<uint64_t*>(state_void); const Vector128 prev_inner = Vector128Load(state); @@ -695,6 +632,7 @@ #endif } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // (ABSL_RANDEN_HWAES_IMPL)
diff --git a/third_party/abseil-cpp/absl/random/internal/randen_hwaes.h b/third_party/abseil-cpp/absl/random/internal/randen_hwaes.h index d8e6055f..bce36b5 100644 --- a/third_party/abseil-cpp/absl/random/internal/randen_hwaes.h +++ b/third_party/abseil-cpp/absl/random/internal/randen_hwaes.h
@@ -15,12 +15,15 @@ #ifndef ABSL_RANDOM_INTERNAL_RANDEN_HWAES_H_ #define ABSL_RANDOM_INTERNAL_RANDEN_HWAES_H_ +#include "absl/base/config.h" + // HERMETIC NOTE: The randen_hwaes target must not introduce duplicate // symbols from arbitrary system and other headers, since it may be built // with different flags from other targets, using different levels of // optimization, potentially introducing ODR violations. namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // RANDen = RANDom generator or beetroots in Swiss German. @@ -41,6 +44,7 @@ bool HasRandenHwAesImplementation(); } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_RANDEN_HWAES_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/randen_slow.cc b/third_party/abseil-cpp/absl/random/internal/randen_slow.cc index 7a2e2da..8d07458 100644 --- a/third_party/abseil-cpp/absl/random/internal/randen_slow.cc +++ b/third_party/abseil-cpp/absl/random/internal/randen_slow.cc
@@ -18,17 +18,9 @@ #include <cstdint> #include <cstring> +#include "absl/base/attributes.h" #include "absl/random/internal/platform.h" -// ABSL_HAVE_ATTRIBUTE -#if !defined(ABSL_HAVE_ATTRIBUTE) -#ifdef __has_attribute -#define ABSL_HAVE_ATTRIBUTE(x) __has_attribute(x) -#else -#define ABSL_HAVE_ATTRIBUTE(x) 0 -#endif -#endif - #if ABSL_HAVE_ATTRIBUTE(always_inline) || \ (defined(__GNUC__) && !defined(__clang__)) #define ABSL_RANDOM_INTERNAL_ATTRIBUTE_ALWAYS_INLINE \ @@ -470,6 +462,7 @@ } // namespace namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { const void* RandenSlow::GetKeys() { @@ -509,4 +502,5 @@ } } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/random/internal/randen_slow.h b/third_party/abseil-cpp/absl/random/internal/randen_slow.h index 3058613..72f92b54 100644 --- a/third_party/abseil-cpp/absl/random/internal/randen_slow.h +++ b/third_party/abseil-cpp/absl/random/internal/randen_slow.h
@@ -17,7 +17,10 @@ #include <cstddef> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // RANDen = RANDom generator or beetroots in Swiss German. @@ -38,6 +41,7 @@ }; } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_RANDEN_SLOW_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/randen_traits.h b/third_party/abseil-cpp/absl/random/internal/randen_traits.h index 4f1f408..2b8bbe7 100644 --- a/third_party/abseil-cpp/absl/random/internal/randen_traits.h +++ b/third_party/abseil-cpp/absl/random/internal/randen_traits.h
@@ -22,7 +22,10 @@ #include <cstddef> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // RANDen = RANDom generator or beetroots in Swiss German. @@ -54,6 +57,7 @@ }; } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_RANDEN_TRAITS_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h b/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h index 8648700..5953a090 100644 --- a/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h +++ b/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h
@@ -30,6 +30,7 @@ #include "absl/types/span.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // This class conforms to the C++ Standard "Seed Sequence" concept @@ -160,6 +161,7 @@ } } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_SALTED_SEED_SEQ_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/seed_material.cc b/third_party/abseil-cpp/absl/random/internal/seed_material.cc index 85dd535..4d38a57 100644 --- a/third_party/abseil-cpp/absl/random/internal/seed_material.cc +++ b/third_party/abseil-cpp/absl/random/internal/seed_material.cc
@@ -45,6 +45,9 @@ #define ABSL_RANDOM_USE_BCRYPT 1 #pragma comment(lib, "bcrypt.lib") +#elif defined(__Fuchsia__) +#include <zircon/syscalls.h> + #endif #if defined(ABSL_RANDOM_USE_BCRYPT) @@ -58,6 +61,7 @@ #endif namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { namespace { @@ -107,6 +111,15 @@ return true; } +#elif defined(__Fuchsia__) + +bool ReadSeedMaterialFromOSEntropyImpl(absl::Span<uint32_t> values) { + auto buffer = reinterpret_cast<uint8_t*>(values.data()); + size_t buffer_size = sizeof(uint32_t) * values.size(); + zx_cprng_draw(buffer, buffer_size); + return true; +} + #else // On *nix, read entropy from /dev/urandom. @@ -202,4 +215,5 @@ } } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/random/internal/seed_material.h b/third_party/abseil-cpp/absl/random/internal/seed_material.h index 57de8a2..4be10e9 100644 --- a/third_party/abseil-cpp/absl/random/internal/seed_material.h +++ b/third_party/abseil-cpp/absl/random/internal/seed_material.h
@@ -27,6 +27,7 @@ #include "absl/types/span.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // Returns the number of 32-bit blocks needed to contain the given number of @@ -97,6 +98,7 @@ absl::optional<uint32_t> GetSaltMaterial(); } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_SEED_MATERIAL_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/seed_salting_sequence_generator.cc b/third_party/abseil-cpp/absl/random/internal/seed_salting_sequence_generator.cc deleted file mode 100644 index 31fdcfe..0000000 --- a/third_party/abseil-cpp/absl/random/internal/seed_salting_sequence_generator.cc +++ /dev/null
@@ -1,30 +0,0 @@ -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include <iostream> -#include <random> - -#include "absl/random/random.h" - -// This program is used in integration tests. - -int main() { - std::seed_seq seed_seq{1234}; - absl::BitGen rng(seed_seq); - constexpr size_t kSequenceLength = 8; - for (size_t i = 0; i < kSequenceLength; i++) { - std::cout << rng() << "\n"; - } - return 0; -}
diff --git a/third_party/abseil-cpp/absl/random/internal/seed_salting_sequence_generator_empty_sequence.cc b/third_party/abseil-cpp/absl/random/internal/seed_salting_sequence_generator_empty_sequence.cc deleted file mode 100644 index 8797e2e..0000000 --- a/third_party/abseil-cpp/absl/random/internal/seed_salting_sequence_generator_empty_sequence.cc +++ /dev/null
@@ -1,30 +0,0 @@ -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include <iostream> -#include <random> - -#include "absl/random/random.h" - -// This program is used in integration tests. - -int main() { - std::seed_seq seed_seq{}; - absl::BitGen rng(seed_seq); - constexpr size_t kSequenceLength = 8; - for (size_t i = 0; i < kSequenceLength; i++) { - std::cout << rng() << "\n"; - } - return 0; -}
diff --git a/third_party/abseil-cpp/absl/random/internal/sequence_urbg.h b/third_party/abseil-cpp/absl/random/internal/sequence_urbg.h index 9a9b577..bc96a12c 100644 --- a/third_party/abseil-cpp/absl/random/internal/sequence_urbg.h +++ b/third_party/abseil-cpp/absl/random/internal/sequence_urbg.h
@@ -21,7 +21,10 @@ #include <type_traits> #include <vector> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // `sequence_urbg` is a simple random number generator which meets the @@ -51,6 +54,7 @@ }; } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_SEQUENCE_URBG_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/traits.h b/third_party/abseil-cpp/absl/random/internal/traits.h index 40eb011f1..75772bd 100644 --- a/third_party/abseil-cpp/absl/random/internal/traits.h +++ b/third_party/abseil-cpp/absl/random/internal/traits.h
@@ -22,6 +22,7 @@ #include "absl/base/config.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace random_internal { // random_internal::is_widening_convertible<A, B> @@ -94,6 +95,7 @@ }; } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_TRAITS_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/uniform_helper.h b/third_party/abseil-cpp/absl/random/internal/uniform_helper.h index 21646489..663107c 100644 --- a/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +++ b/third_party/abseil-cpp/absl/random/internal/uniform_helper.h
@@ -22,6 +22,7 @@ #include "absl/meta/type_traits.h" namespace absl { +ABSL_NAMESPACE_BEGIN template <typename IntType> class uniform_int_distribution; @@ -30,15 +31,33 @@ // Interval tag types which specify whether the interval is open or closed // on either boundary. + namespace random_internal { -struct IntervalClosedClosedT {}; -struct IntervalClosedOpenT {}; -struct IntervalOpenClosedT {}; -struct IntervalOpenOpenT {}; +template <typename T> +struct TagTypeCompare {}; + +template <typename T> +constexpr bool operator==(TagTypeCompare<T>, TagTypeCompare<T>) { + // Tags are mono-states. They always compare equal. + return true; +} +template <typename T> +constexpr bool operator!=(TagTypeCompare<T>, TagTypeCompare<T>) { + return false; +} + } // namespace random_internal -namespace random_internal { +struct IntervalClosedClosedTag + : public random_internal::TagTypeCompare<IntervalClosedClosedTag> {}; +struct IntervalClosedOpenTag + : public random_internal::TagTypeCompare<IntervalClosedOpenTag> {}; +struct IntervalOpenClosedTag + : public random_internal::TagTypeCompare<IntervalOpenClosedTag> {}; +struct IntervalOpenOpenTag + : public random_internal::TagTypeCompare<IntervalOpenOpenTag> {}; +namespace random_internal { // The functions // uniform_lower_bound(tag, a, b) // and @@ -59,8 +78,8 @@ typename absl::enable_if_t< absl::conjunction< std::is_integral<IntType>, - absl::disjunction<std::is_same<Tag, IntervalOpenClosedT>, - std::is_same<Tag, IntervalOpenOpenT>>>::value, + absl::disjunction<std::is_same<Tag, IntervalOpenClosedTag>, + std::is_same<Tag, IntervalOpenOpenTag>>>::value, IntType> uniform_lower_bound(Tag, IntType a, IntType) { return a + 1; @@ -70,8 +89,8 @@ typename absl::enable_if_t< absl::conjunction< std::is_floating_point<FloatType>, - absl::disjunction<std::is_same<Tag, IntervalOpenClosedT>, - std::is_same<Tag, IntervalOpenOpenT>>>::value, + absl::disjunction<std::is_same<Tag, IntervalOpenClosedTag>, + std::is_same<Tag, IntervalOpenOpenTag>>>::value, FloatType> uniform_lower_bound(Tag, FloatType a, FloatType b) { return std::nextafter(a, b); @@ -79,8 +98,8 @@ template <typename NumType, typename Tag> typename absl::enable_if_t< - absl::disjunction<std::is_same<Tag, IntervalClosedClosedT>, - std::is_same<Tag, IntervalClosedOpenT>>::value, + absl::disjunction<std::is_same<Tag, IntervalClosedClosedTag>, + std::is_same<Tag, IntervalClosedOpenTag>>::value, NumType> uniform_lower_bound(Tag, NumType a, NumType) { return a; @@ -90,8 +109,8 @@ typename absl::enable_if_t< absl::conjunction< std::is_integral<IntType>, - absl::disjunction<std::is_same<Tag, IntervalClosedOpenT>, - std::is_same<Tag, IntervalOpenOpenT>>>::value, + absl::disjunction<std::is_same<Tag, IntervalClosedOpenTag>, + std::is_same<Tag, IntervalOpenOpenTag>>>::value, IntType> uniform_upper_bound(Tag, IntType, IntType b) { return b - 1; @@ -101,8 +120,8 @@ typename absl::enable_if_t< absl::conjunction< std::is_floating_point<FloatType>, - absl::disjunction<std::is_same<Tag, IntervalClosedOpenT>, - std::is_same<Tag, IntervalOpenOpenT>>>::value, + absl::disjunction<std::is_same<Tag, IntervalClosedOpenTag>, + std::is_same<Tag, IntervalOpenOpenTag>>>::value, FloatType> uniform_upper_bound(Tag, FloatType, FloatType b) { return b; @@ -112,8 +131,8 @@ typename absl::enable_if_t< absl::conjunction< std::is_integral<IntType>, - absl::disjunction<std::is_same<Tag, IntervalClosedClosedT>, - std::is_same<Tag, IntervalOpenClosedT>>>::value, + absl::disjunction<std::is_same<Tag, IntervalClosedClosedTag>, + std::is_same<Tag, IntervalOpenClosedTag>>>::value, IntType> uniform_upper_bound(Tag, IntType, IntType b) { return b; @@ -123,8 +142,8 @@ typename absl::enable_if_t< absl::conjunction< std::is_floating_point<FloatType>, - absl::disjunction<std::is_same<Tag, IntervalClosedClosedT>, - std::is_same<Tag, IntervalOpenClosedT>>>::value, + absl::disjunction<std::is_same<Tag, IntervalClosedClosedTag>, + std::is_same<Tag, IntervalOpenClosedTag>>>::value, FloatType> uniform_upper_bound(Tag, FloatType, FloatType b) { return std::nextafter(b, (std::numeric_limits<FloatType>::max)()); @@ -136,15 +155,26 @@ absl::uniform_int_distribution<NumType>, absl::uniform_real_distribution<NumType>>::type; -template <typename TagType, typename NumType> +template <typename NumType> struct UniformDistributionWrapper : public UniformDistribution<NumType> { - explicit UniformDistributionWrapper(NumType lo, NumType hi) + template <typename TagType> + explicit UniformDistributionWrapper(TagType, NumType lo, NumType hi) : UniformDistribution<NumType>( uniform_lower_bound<NumType>(TagType{}, lo, hi), uniform_upper_bound<NumType>(TagType{}, lo, hi)) {} + + explicit UniformDistributionWrapper(NumType lo, NumType hi) + : UniformDistribution<NumType>( + uniform_lower_bound<NumType>(IntervalClosedOpenTag(), lo, hi), + uniform_upper_bound<NumType>(IntervalClosedOpenTag(), lo, hi)) {} + + explicit UniformDistributionWrapper() + : UniformDistribution<NumType>(std::numeric_limits<NumType>::lowest(), + (std::numeric_limits<NumType>::max)()) {} }; } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_INTERNAL_UNIFORM_HELPER_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/wide_multiply.h b/third_party/abseil-cpp/absl/random/internal/wide_multiply.h new file mode 100644 index 0000000..6e4cf1b --- /dev/null +++ b/third_party/abseil-cpp/absl/random/internal/wide_multiply.h
@@ -0,0 +1,111 @@ +// Copyright 2017 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ABSL_RANDOM_INTERNAL_WIDE_MULTIPLY_H_ +#define ABSL_RANDOM_INTERNAL_WIDE_MULTIPLY_H_ + +#include <cstdint> +#include <limits> +#include <type_traits> + +#if (defined(_WIN32) || defined(_WIN64)) && defined(_M_IA64) +#include <intrin.h> // NOLINT(build/include_order) +#pragma intrinsic(_umul128) +#define ABSL_INTERNAL_USE_UMUL128 1 +#endif + +#include "absl/base/config.h" +#include "absl/base/internal/bits.h" +#include "absl/numeric/int128.h" +#include "absl/random/internal/traits.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace random_internal { + +// Helper object to multiply two 64-bit values to a 128-bit value. +// MultiplyU64ToU128 multiplies two 64-bit values to a 128-bit value. +// If an intrinsic is available, it is used, otherwise use native 32-bit +// multiplies to construct the result. +inline uint128 MultiplyU64ToU128(uint64_t a, uint64_t b) { +#if defined(ABSL_HAVE_INTRINSIC_INT128) + return uint128(static_cast<__uint128_t>(a) * b); +#elif defined(ABSL_INTERNAL_USE_UMUL128) + // uint64_t * uint64_t => uint128 multiply using imul intrinsic on MSVC. + uint64_t high = 0; + const uint64_t low = _umul128(a, b, &high); + return absl::MakeUint128(high, low); +#else + // uint128(a) * uint128(b) in emulated mode computes a full 128-bit x 128-bit + // multiply. However there are many cases where that is not necessary, and it + // is only necessary to support a 64-bit x 64-bit = 128-bit multiply. This is + // for those cases. + const uint64_t a00 = static_cast<uint32_t>(a); + const uint64_t a32 = a >> 32; + const uint64_t b00 = static_cast<uint32_t>(b); + const uint64_t b32 = b >> 32; + + const uint64_t c00 = a00 * b00; + const uint64_t c32a = a00 * b32; + const uint64_t c32b = a32 * b00; + const uint64_t c64 = a32 * b32; + + const uint32_t carry = + static_cast<uint32_t>(((c00 >> 32) + static_cast<uint32_t>(c32a) + + static_cast<uint32_t>(c32b)) >> + 32); + + return absl::MakeUint128(c64 + (c32a >> 32) + (c32b >> 32) + carry, + c00 + (c32a << 32) + (c32b << 32)); +#endif +} + +// wide_multiply<T> multiplies two N-bit values to a 2N-bit result. +template <typename UIntType> +struct wide_multiply { + static constexpr size_t kN = std::numeric_limits<UIntType>::digits; + using input_type = UIntType; + using result_type = typename random_internal::unsigned_bits<kN * 2>::type; + + static result_type multiply(input_type a, input_type b) { + return static_cast<result_type>(a) * b; + } + + static input_type hi(result_type r) { return r >> kN; } + static input_type lo(result_type r) { return r; } + + static_assert(std::is_unsigned<UIntType>::value, + "Class-template wide_multiply<> argument must be unsigned."); +}; + +#ifndef ABSL_HAVE_INTRINSIC_INT128 +template <> +struct wide_multiply<uint64_t> { + using input_type = uint64_t; + using result_type = uint128; + + static result_type multiply(uint64_t a, uint64_t b) { + return MultiplyU64ToU128(a, b); + } + + static uint64_t hi(result_type r) { return Uint128High64(r); } + static uint64_t lo(result_type r) { return Uint128Low64(r); } +}; +#endif + +} // namespace random_internal +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_RANDOM_INTERNAL_WIDE_MULTIPLY_H_
diff --git a/third_party/abseil-cpp/absl/random/internal/wide_multiply_test.cc b/third_party/abseil-cpp/absl/random/internal/wide_multiply_test.cc new file mode 100644 index 0000000..922603f --- /dev/null +++ b/third_party/abseil-cpp/absl/random/internal/wide_multiply_test.cc
@@ -0,0 +1,66 @@ +// Copyright 2017 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/random/internal/wide_multiply.h" + +#include "gtest/gtest.h" +#include "absl/base/internal/bits.h" +#include "absl/numeric/int128.h" + +using absl::random_internal::MultiplyU64ToU128; + +namespace { + +TEST(WideMultiplyTest, MultiplyU64ToU128Test) { + constexpr uint64_t k1 = 1; + constexpr uint64_t kMax = ~static_cast<uint64_t>(0); + + EXPECT_EQ(absl::uint128(0), MultiplyU64ToU128(0, 0)); + + // Max uint64 + EXPECT_EQ(MultiplyU64ToU128(kMax, kMax), + absl::MakeUint128(0xfffffffffffffffe, 0x0000000000000001)); + EXPECT_EQ(absl::MakeUint128(0, kMax), MultiplyU64ToU128(kMax, 1)); + EXPECT_EQ(absl::MakeUint128(0, kMax), MultiplyU64ToU128(1, kMax)); + for (int i = 0; i < 64; ++i) { + EXPECT_EQ(absl::MakeUint128(0, kMax) << i, + MultiplyU64ToU128(kMax, k1 << i)); + EXPECT_EQ(absl::MakeUint128(0, kMax) << i, + MultiplyU64ToU128(k1 << i, kMax)); + } + + // 1-bit x 1-bit. + for (int i = 0; i < 64; ++i) { + for (int j = 0; j < 64; ++j) { + EXPECT_EQ(absl::MakeUint128(0, 1) << (i + j), + MultiplyU64ToU128(k1 << i, k1 << j)); + EXPECT_EQ(absl::MakeUint128(0, 1) << (i + j), + MultiplyU64ToU128(k1 << i, k1 << j)); + } + } + + // Verified multiplies + EXPECT_EQ(MultiplyU64ToU128(0xffffeeeeddddcccc, 0xbbbbaaaa99998888), + absl::MakeUint128(0xbbbb9e2692c5dddc, 0xc28f7531048d2c60)); + EXPECT_EQ(MultiplyU64ToU128(0x0123456789abcdef, 0xfedcba9876543210), + absl::MakeUint128(0x0121fa00ad77d742, 0x2236d88fe5618cf0)); + EXPECT_EQ(MultiplyU64ToU128(0x0123456789abcdef, 0xfdb97531eca86420), + absl::MakeUint128(0x0120ae99d26725fc, 0xce197f0ecac319e0)); + EXPECT_EQ(MultiplyU64ToU128(0x97a87f4f261ba3f2, 0xfedcba9876543210), + absl::MakeUint128(0x96fbf1a8ae78d0ba, 0x5a6dd4b71f278320)); + EXPECT_EQ(MultiplyU64ToU128(0xfedcba9876543210, 0xfdb97531eca86420), + absl::MakeUint128(0xfc98c6981a413e22, 0x342d0bbf48948200)); +} + +} // namespace
diff --git a/third_party/abseil-cpp/absl/random/log_uniform_int_distribution.h b/third_party/abseil-cpp/absl/random/log_uniform_int_distribution.h index ac43416e..960816e 100644 --- a/third_party/abseil-cpp/absl/random/log_uniform_int_distribution.h +++ b/third_party/abseil-cpp/absl/random/log_uniform_int_distribution.h
@@ -23,13 +23,14 @@ #include <ostream> #include <type_traits> -#include "absl/random/internal/distribution_impl.h" #include "absl/random/internal/fastmath.h" +#include "absl/random/internal/generate_real.h" #include "absl/random/internal/iostream_state_saver.h" #include "absl/random/internal/traits.h" #include "absl/random/uniform_int_distribution.h" namespace absl { +ABSL_NAMESPACE_BEGIN // log_uniform_int_distribution: // @@ -192,13 +193,15 @@ const double r = std::pow(p.base(), d); const double s = (r * p.base()) - 1.0; - base_e = (r > (std::numeric_limits<unsigned_type>::max)()) - ? (std::numeric_limits<unsigned_type>::max)() - : static_cast<unsigned_type>(r); + base_e = + (r > static_cast<double>((std::numeric_limits<unsigned_type>::max)())) + ? (std::numeric_limits<unsigned_type>::max)() + : static_cast<unsigned_type>(r); - top_e = (s > (std::numeric_limits<unsigned_type>::max)()) - ? (std::numeric_limits<unsigned_type>::max)() - : static_cast<unsigned_type>(s); + top_e = + (s > static_cast<double>((std::numeric_limits<unsigned_type>::max)())) + ? (std::numeric_limits<unsigned_type>::max)() + : static_cast<unsigned_type>(s); } const unsigned_type lo = (base_e >= p.range()) ? p.range() : base_e; @@ -245,6 +248,7 @@ return is; } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_LOG_UNIFORM_INT_DISTRIBUTION_H_
diff --git a/third_party/abseil-cpp/absl/random/log_uniform_int_distribution_test.cc b/third_party/abseil-cpp/absl/random/log_uniform_int_distribution_test.cc index 0ff4c32d..5270531 100644 --- a/third_party/abseil-cpp/absl/random/log_uniform_int_distribution_test.cc +++ b/third_party/abseil-cpp/absl/random/log_uniform_int_distribution_test.cc
@@ -243,7 +243,7 @@ return absl::StrReplaceAll(name, {{"+", "_"}, {"-", "_"}, {".", "_"}}); } -INSTANTIATE_TEST_SUITE_P(, LogUniformIntChiSquaredTest, +INSTANTIATE_TEST_SUITE_P(All, LogUniformIntChiSquaredTest, ::testing::ValuesIn(GenParams()), ParamName); // NOTE: absl::log_uniform_int_distribution is not guaranteed to be stable.
diff --git a/third_party/abseil-cpp/absl/random/mock_distributions.h b/third_party/abseil-cpp/absl/random/mock_distributions.h new file mode 100644 index 0000000..d36d5ba --- /dev/null +++ b/third_party/abseil-cpp/absl/random/mock_distributions.h
@@ -0,0 +1,261 @@ +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------- +// File: mock_distributions.h +// ----------------------------------------------------------------------------- +// +// This file contains mock distribution functions for use alongside an +// `absl::MockingBitGen` object within the Googletest testing framework. Such +// mocks are useful to provide deterministic values as return values within +// (otherwise random) Abseil distribution functions. +// +// The return type of each function is a mock expectation object which +// is used to set the match result. +// +// More information about the Googletest testing framework is available at +// https://github.com/google/googletest +// +// Example: +// +// absl::MockingBitGen mock; +// EXPECT_CALL(absl::MockUniform<int>(), Call(mock, 1, 1000)) +// .WillRepeatedly(testing::ReturnRoundRobin({20, 40})); +// +// EXPECT_EQ(absl::Uniform<int>(gen, 1, 1000), 20); +// EXPECT_EQ(absl::Uniform<int>(gen, 1, 1000), 40); +// EXPECT_EQ(absl::Uniform<int>(gen, 1, 1000), 20); +// EXPECT_EQ(absl::Uniform<int>(gen, 1, 1000), 40); + +#ifndef ABSL_RANDOM_MOCK_DISTRIBUTIONS_H_ +#define ABSL_RANDOM_MOCK_DISTRIBUTIONS_H_ + +#include <limits> +#include <type_traits> +#include <utility> + +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "absl/meta/type_traits.h" +#include "absl/random/distributions.h" +#include "absl/random/internal/mock_overload_set.h" +#include "absl/random/mocking_bit_gen.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN + +// ----------------------------------------------------------------------------- +// absl::MockUniform +// ----------------------------------------------------------------------------- +// +// Matches calls to absl::Uniform. +// +// `absl::MockUniform` is a class template used in conjunction with Googletest's +// `ON_CALL()` and `EXPECT_CALL()` macros. To use it, default-construct an +// instance of it inside `ON_CALL()` or `EXPECT_CALL()`, and use `Call(...)` the +// same way one would define mocks on a Googletest `MockFunction()`. +// +// Example: +// +// absl::MockingBitGen mock; +// EXPECT_CALL(absl::MockUniform<uint32_t>(), Call(mock)) +// .WillOnce(Return(123456)); +// auto x = absl::Uniform<uint32_t>(mock); +// assert(x == 123456) +// +template <typename R> +using MockUniform = random_internal::MockOverloadSet< + random_internal::UniformDistributionWrapper<R>, + R(IntervalClosedOpenTag, MockingBitGen&, R, R), + R(IntervalClosedClosedTag, MockingBitGen&, R, R), + R(IntervalOpenOpenTag, MockingBitGen&, R, R), + R(IntervalOpenClosedTag, MockingBitGen&, R, R), R(MockingBitGen&, R, R), + R(MockingBitGen&)>; + +// ----------------------------------------------------------------------------- +// absl::MockBernoulli +// ----------------------------------------------------------------------------- +// +// Matches calls to absl::Bernoulli. +// +// `absl::MockBernoulli` is a class used in conjunction with Googletest's +// `ON_CALL()` and `EXPECT_CALL()` macros. To use it, default-construct an +// instance of it inside `ON_CALL()` or `EXPECT_CALL()`, and use `Call(...)` the +// same way one would define mocks on a Googletest `MockFunction()`. +// +// Example: +// +// absl::MockingBitGen mock; +// EXPECT_CALL(absl::MockBernoulli(), Call(mock, testing::_)) +// .WillOnce(Return(false)); +// assert(absl::Bernoulli(mock, 0.5) == false); +// +using MockBernoulli = + random_internal::MockOverloadSet<absl::bernoulli_distribution, + bool(MockingBitGen&, double)>; + +// ----------------------------------------------------------------------------- +// absl::MockBeta +// ----------------------------------------------------------------------------- +// +// Matches calls to absl::Beta. +// +// `absl::MockBeta` is a class used in conjunction with Googletest's `ON_CALL()` +// and `EXPECT_CALL()` macros. To use it, default-construct an instance of it +// inside `ON_CALL()` or `EXPECT_CALL()`, and use `Call(...)` the same way one +// would define mocks on a Googletest `MockFunction()`. +// +// Example: +// +// absl::MockingBitGen mock; +// EXPECT_CALL(absl::MockBeta(), Call(mock, 3.0, 2.0)) +// .WillOnce(Return(0.567)); +// auto x = absl::Beta<double>(mock, 3.0, 2.0); +// assert(x == 0.567); +// +template <typename RealType> +using MockBeta = + random_internal::MockOverloadSet<absl::beta_distribution<RealType>, + RealType(MockingBitGen&, RealType, + RealType)>; + +// ----------------------------------------------------------------------------- +// absl::MockExponential +// ----------------------------------------------------------------------------- +// +// Matches calls to absl::Exponential. +// +// `absl::MockExponential` is a class template used in conjunction with +// Googletest's `ON_CALL()` and `EXPECT_CALL()` macros. To use it, +// default-construct an instance of it inside `ON_CALL()` or `EXPECT_CALL()`, +// and use `Call(...)` the same way one would define mocks on a +// Googletest `MockFunction()`. +// +// Example: +// +// absl::MockingBitGen mock; +// EXPECT_CALL(absl::MockExponential<double>(), Call(mock, 0.5)) +// .WillOnce(Return(12.3456789)); +// auto x = absl::Exponential<double>(mock, 0.5); +// assert(x == 12.3456789) +// +template <typename RealType> +using MockExponential = + random_internal::MockOverloadSet<absl::exponential_distribution<RealType>, + RealType(MockingBitGen&, RealType)>; + +// ----------------------------------------------------------------------------- +// absl::MockGaussian +// ----------------------------------------------------------------------------- +// +// Matches calls to absl::Gaussian. +// +// `absl::MockGaussian` is a class template used in conjunction with +// Googletest's `ON_CALL()` and `EXPECT_CALL()` macros. To use it, +// default-construct an instance of it inside `ON_CALL()` or `EXPECT_CALL()`, +// and use `Call(...)` the same way one would define mocks on a +// Googletest `MockFunction()`. +// +// Example: +// +// absl::MockingBitGen mock; +// EXPECT_CALL(absl::MockGaussian<double>(), Call(mock, 16.3, 3.3)) +// .WillOnce(Return(12.3456789)); +// auto x = absl::Gaussian<double>(mock, 16.3, 3.3); +// assert(x == 12.3456789) +// +template <typename RealType> +using MockGaussian = + random_internal::MockOverloadSet<absl::gaussian_distribution<RealType>, + RealType(MockingBitGen&, RealType, + RealType)>; + +// ----------------------------------------------------------------------------- +// absl::MockLogUniform +// ----------------------------------------------------------------------------- +// +// Matches calls to absl::LogUniform. +// +// `absl::MockLogUniform` is a class template used in conjunction with +// Googletest's `ON_CALL()` and `EXPECT_CALL()` macros. To use it, +// default-construct an instance of it inside `ON_CALL()` or `EXPECT_CALL()`, +// and use `Call(...)` the same way one would define mocks on a +// Googletest `MockFunction()`. +// +// Example: +// +// absl::MockingBitGen mock; +// EXPECT_CALL(absl::MockLogUniform<int>(), Call(mock, 10, 10000, 10)) +// .WillOnce(Return(1221)); +// auto x = absl::LogUniform<int>(mock, 10, 10000, 10); +// assert(x == 1221) +// +template <typename IntType> +using MockLogUniform = random_internal::MockOverloadSet< + absl::log_uniform_int_distribution<IntType>, + IntType(MockingBitGen&, IntType, IntType, IntType)>; + +// ----------------------------------------------------------------------------- +// absl::MockPoisson +// ----------------------------------------------------------------------------- +// +// Matches calls to absl::Poisson. +// +// `absl::MockPoisson` is a class template used in conjunction with Googletest's +// `ON_CALL()` and `EXPECT_CALL()` macros. To use it, default-construct an +// instance of it inside `ON_CALL()` or `EXPECT_CALL()`, and use `Call(...)` the +// same way one would define mocks on a Googletest `MockFunction()`. +// +// Example: +// +// absl::MockingBitGen mock; +// EXPECT_CALL(absl::MockPoisson<int>(), Call(mock, 2.0)) +// .WillOnce(Return(1221)); +// auto x = absl::Poisson<int>(mock, 2.0); +// assert(x == 1221) +// +template <typename IntType> +using MockPoisson = + random_internal::MockOverloadSet<absl::poisson_distribution<IntType>, + IntType(MockingBitGen&, double)>; + +// ----------------------------------------------------------------------------- +// absl::MockZipf +// ----------------------------------------------------------------------------- +// +// Matches calls to absl::Zipf. +// +// `absl::MockZipf` is a class template used in conjunction with Googletest's +// `ON_CALL()` and `EXPECT_CALL()` macros. To use it, default-construct an +// instance of it inside `ON_CALL()` or `EXPECT_CALL()`, and use `Call(...)` the +// same way one would define mocks on a Googletest `MockFunction()`. +// +// Example: +// +// absl::MockingBitGen mock; +// EXPECT_CALL(absl::MockZipf<int>(), Call(mock, 1000000, 2.0, 1.0)) +// .WillOnce(Return(1221)); +// auto x = absl::Zipf<int>(mock, 1000000, 2.0, 1.0); +// assert(x == 1221) +// +template <typename IntType> +using MockZipf = + random_internal::MockOverloadSet<absl::zipf_distribution<IntType>, + IntType(MockingBitGen&, IntType, double, + double)>; + +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_RANDOM_MOCK_DISTRIBUTIONS_H_
diff --git a/third_party/abseil-cpp/absl/random/mock_distributions_test.cc b/third_party/abseil-cpp/absl/random/mock_distributions_test.cc new file mode 100644 index 0000000..de23baf --- /dev/null +++ b/third_party/abseil-cpp/absl/random/mock_distributions_test.cc
@@ -0,0 +1,72 @@ +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/random/mock_distributions.h" + +#include "gtest/gtest.h" +#include "absl/random/mocking_bit_gen.h" +#include "absl/random/random.h" + +namespace { +using ::testing::Return; + +TEST(MockDistributions, Examples) { + absl::MockingBitGen gen; + + EXPECT_NE(absl::Uniform<int>(gen, 1, 1000000), 20); + EXPECT_CALL(absl::MockUniform<int>(), Call(gen, 1, 1000000)) + .WillOnce(Return(20)); + EXPECT_EQ(absl::Uniform<int>(gen, 1, 1000000), 20); + + EXPECT_NE(absl::Uniform<double>(gen, 0.0, 100.0), 5.0); + EXPECT_CALL(absl::MockUniform<double>(), Call(gen, 0.0, 100.0)) + .WillOnce(Return(5.0)); + EXPECT_EQ(absl::Uniform<double>(gen, 0.0, 100.0), 5.0); + + EXPECT_NE(absl::Exponential<double>(gen, 1.0), 42); + EXPECT_CALL(absl::MockExponential<double>(), Call(gen, 1.0)) + .WillOnce(Return(42)); + EXPECT_EQ(absl::Exponential<double>(gen, 1.0), 42); + + EXPECT_NE(absl::Poisson<int>(gen, 1.0), 500); + EXPECT_CALL(absl::MockPoisson<int>(), Call(gen, 1.0)).WillOnce(Return(500)); + EXPECT_EQ(absl::Poisson<int>(gen, 1.0), 500); + + EXPECT_NE(absl::Bernoulli(gen, 0.000001), true); + EXPECT_CALL(absl::MockBernoulli(), Call(gen, 0.000001)) + .WillOnce(Return(true)); + EXPECT_EQ(absl::Bernoulli(gen, 0.000001), true); + + EXPECT_NE(absl::Beta<double>(gen, 3.0, 2.0), 0.567); + EXPECT_CALL(absl::MockBeta<double>(), Call(gen, 3.0, 2.0)) + .WillOnce(Return(0.567)); + EXPECT_EQ(absl::Beta<double>(gen, 3.0, 2.0), 0.567); + + EXPECT_NE(absl::Zipf<int>(gen, 1000000, 2.0, 1.0), 1221); + EXPECT_CALL(absl::MockZipf<int>(), Call(gen, 1000000, 2.0, 1.0)) + .WillOnce(Return(1221)); + EXPECT_EQ(absl::Zipf<int>(gen, 1000000, 2.0, 1.0), 1221); + + EXPECT_NE(absl::Gaussian<double>(gen, 0.0, 1.0), 0.001); + EXPECT_CALL(absl::MockGaussian<double>(), Call(gen, 0.0, 1.0)) + .WillOnce(Return(0.001)); + EXPECT_EQ(absl::Gaussian<double>(gen, 0.0, 1.0), 0.001); + + EXPECT_NE(absl::LogUniform<int>(gen, 0, 1000000, 2), 2040); + EXPECT_CALL(absl::MockLogUniform<int>(), Call(gen, 0, 1000000, 2)) + .WillOnce(Return(2040)); + EXPECT_EQ(absl::LogUniform<int>(gen, 0, 1000000, 2), 2040); +} + +} // namespace
diff --git a/third_party/abseil-cpp/absl/random/internal/named_generator.cc b/third_party/abseil-cpp/absl/random/mocking_bit_gen.cc similarity index 62% rename from third_party/abseil-cpp/absl/random/internal/named_generator.cc rename to third_party/abseil-cpp/absl/random/mocking_bit_gen.cc index b168a25..6bb1e414 100644 --- a/third_party/abseil-cpp/absl/random/internal/named_generator.cc +++ b/third_party/abseil-cpp/absl/random/mocking_bit_gen.cc
@@ -1,3 +1,4 @@ +// // Copyright 2018 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,20 +12,19 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +#include "absl/random/mocking_bit_gen.h" -#include <cstddef> -#include <iostream> +#include <string> -#include "absl/random/random.h" +namespace absl { +ABSL_NAMESPACE_BEGIN +MockingBitGen::~MockingBitGen() { -// This program is used in integration tests. - -int main() { - auto seed_seq = absl::MakeTaggedSeedSeq("TEST_GENERATOR", std::cerr); - absl::BitGen rng(seed_seq); - constexpr size_t kSequenceLength = 8; - for (size_t i = 0; i < kSequenceLength; i++) { - std::cout << rng() << "\n"; + for (const auto& del : deleters_) { + del(); } - return 0; } + +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/random/mocking_bit_gen.h b/third_party/abseil-cpp/absl/random/mocking_bit_gen.h new file mode 100644 index 0000000..36cef91 --- /dev/null +++ b/third_party/abseil-cpp/absl/random/mocking_bit_gen.h
@@ -0,0 +1,196 @@ +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------- +// mocking_bit_gen.h +// ----------------------------------------------------------------------------- +// +// This file includes an `absl::MockingBitGen` class to use as a mock within the +// Googletest testing framework. Such a mock is useful to provide deterministic +// values as return values within (otherwise random) Abseil distribution +// functions. Such determinism within a mock is useful within testing frameworks +// to test otherwise indeterminate APIs. +// +// More information about the Googletest testing framework is available at +// https://github.com/google/googletest + +#ifndef ABSL_RANDOM_MOCKING_BIT_GEN_H_ +#define ABSL_RANDOM_MOCKING_BIT_GEN_H_ + +#include <iterator> +#include <limits> +#include <memory> +#include <tuple> +#include <type_traits> +#include <typeindex> +#include <typeinfo> +#include <utility> + +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "absl/container/flat_hash_map.h" +#include "absl/meta/type_traits.h" +#include "absl/random/distributions.h" +#include "absl/random/internal/distribution_caller.h" +#include "absl/random/internal/mocking_bit_gen_base.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include "absl/types/span.h" +#include "absl/types/variant.h" +#include "absl/utility/utility.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN + +namespace random_internal { + +template <typename, typename> +struct MockSingleOverload; + +} // namespace random_internal + +// MockingBitGen +// +// `absl::MockingBitGen` is a mock Uniform Random Bit Generator (URBG) class +// which can act in place of an `absl::BitGen` URBG within tests using the +// Googletest testing framework. +// +// Usage: +// +// Use an `absl::MockingBitGen` along with a mock distribution object (within +// mock_distributions.h) inside Googletest constructs such as ON_CALL(), +// EXPECT_TRUE(), etc. to produce deterministic results conforming to the +// distribution's API contract. +// +// Example: +// +// // Mock a call to an `absl::Bernoulli` distribution using Googletest +// absl::MockingBitGen bitgen; +// +// ON_CALL(absl::MockBernoulli(), Call(bitgen, 0.5)) +// .WillByDefault(testing::Return(true)); +// EXPECT_TRUE(absl::Bernoulli(bitgen, 0.5)); +// +// // Mock a call to an `absl::Uniform` distribution within Googletest +// absl::MockingBitGen bitgen; +// +// ON_CALL(absl::MockUniform<int>(), Call(bitgen, testing::_, testing::_)) +// .WillByDefault([] (int low, int high) { +// return (low + high) / 2; +// }); +// +// EXPECT_EQ(absl::Uniform<int>(gen, 0, 10), 5); +// EXPECT_EQ(absl::Uniform<int>(gen, 30, 40), 35); +// +// At this time, only mock distributions supplied within the Abseil random +// library are officially supported. +// +class MockingBitGen : public absl::random_internal::MockingBitGenBase { + public: + MockingBitGen() {} + + ~MockingBitGen() override; + + private: + template <typename DistrT, typename... Args> + using MockFnType = + ::testing::MockFunction<typename DistrT::result_type(Args...)>; + + // MockingBitGen::Register + // + // Register<DistrT, FormatT, ArgTupleT> is the main extension point for + // extending the MockingBitGen framework. It provides a mechanism to install a + // mock expectation for the distribution `distr_t` onto the MockingBitGen + // context. + // + // The returned MockFunction<...> type can be used to setup additional + // distribution parameters of the expectation. + template <typename DistrT, typename... Args, typename... Ms> + decltype(std::declval<MockFnType<DistrT, Args...>>().gmock_Call( + std::declval<Ms>()...)) + Register(Ms&&... matchers) { + auto& mock = + mocks_[std::type_index(GetTypeId<DistrT, std::tuple<Args...>>())]; + + if (!mock.mock_fn) { + auto* mock_fn = new MockFnType<DistrT, Args...>; + mock.mock_fn = mock_fn; + mock.match_impl = &MatchImpl<DistrT, Args...>; + deleters_.emplace_back([mock_fn] { delete mock_fn; }); + } + + return static_cast<MockFnType<DistrT, Args...>*>(mock.mock_fn) + ->gmock_Call(std::forward<Ms>(matchers)...); + } + + mutable std::vector<std::function<void()>> deleters_; + + using match_impl_fn = void (*)(void* mock_fn, void* t_erased_dist_args, + void* t_erased_result); + struct MockData { + void* mock_fn = nullptr; + match_impl_fn match_impl = nullptr; + }; + + mutable absl::flat_hash_map<std::type_index, MockData> mocks_; + + template <typename DistrT, typename... Args> + static void MatchImpl(void* mock_fn, void* dist_args, void* result) { + using result_type = typename DistrT::result_type; + *static_cast<result_type*>(result) = absl::apply( + [mock_fn](Args... args) -> result_type { + return (*static_cast<MockFnType<DistrT, Args...>*>(mock_fn)) + .Call(std::move(args)...); + }, + *static_cast<std::tuple<Args...>*>(dist_args)); + } + + // Looks for an appropriate mock - Returns the mocked result if one is found. + // Otherwise, returns a random value generated by the underlying URBG. + bool CallImpl(const std::type_info& key_type, void* dist_args, + void* result) override { + // Trigger a mock, if there exists one that matches `param`. + auto it = mocks_.find(std::type_index(key_type)); + if (it == mocks_.end()) return false; + auto* mock_data = static_cast<MockData*>(&it->second); + mock_data->match_impl(mock_data->mock_fn, dist_args, result); + return true; + } + + template <typename, typename> + friend struct ::absl::random_internal::MockSingleOverload; + friend struct ::absl::random_internal::DistributionCaller< + absl::MockingBitGen>; +}; + +// ----------------------------------------------------------------------------- +// Implementation Details Only Below +// ----------------------------------------------------------------------------- + +namespace random_internal { + +template <> +struct DistributionCaller<absl::MockingBitGen> { + template <typename DistrT, typename FormatT, typename... Args> + static typename DistrT::result_type Call(absl::MockingBitGen* gen, + Args&&... args) { + return gen->template Call<DistrT, FormatT>(std::forward<Args>(args)...); + } +}; + +} // namespace random_internal +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_RANDOM_MOCKING_BIT_GEN_H_
diff --git a/third_party/abseil-cpp/absl/random/mocking_bit_gen_test.cc b/third_party/abseil-cpp/absl/random/mocking_bit_gen_test.cc new file mode 100644 index 0000000..f0ffc9a --- /dev/null +++ b/third_party/abseil-cpp/absl/random/mocking_bit_gen_test.cc
@@ -0,0 +1,347 @@ +// +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "absl/random/mocking_bit_gen.h" + +#include <numeric> +#include <random> + +#include "gmock/gmock.h" +#include "gtest/gtest-spi.h" +#include "gtest/gtest.h" +#include "absl/random/bit_gen_ref.h" +#include "absl/random/mock_distributions.h" +#include "absl/random/random.h" + +namespace { +using ::testing::Ne; +using ::testing::Return; + +TEST(BasicMocking, AllDistributionsAreOverridable) { + absl::MockingBitGen gen; + + EXPECT_NE(absl::Uniform<int>(gen, 1, 1000000), 20); + EXPECT_CALL(absl::MockUniform<int>(), Call(gen, 1, 1000000)) + .WillOnce(Return(20)); + EXPECT_EQ(absl::Uniform<int>(gen, 1, 1000000), 20); + + EXPECT_NE(absl::Uniform<double>(gen, 0.0, 100.0), 5.0); + EXPECT_CALL(absl::MockUniform<double>(), Call(gen, 0.0, 100.0)) + .WillOnce(Return(5.0)); + EXPECT_EQ(absl::Uniform<double>(gen, 0.0, 100.0), 5.0); + + EXPECT_NE(absl::Exponential<double>(gen, 1.0), 42); + EXPECT_CALL(absl::MockExponential<double>(), Call(gen, 1.0)) + .WillOnce(Return(42)); + EXPECT_EQ(absl::Exponential<double>(gen, 1.0), 42); + + EXPECT_NE(absl::Poisson<int>(gen, 1.0), 500); + EXPECT_CALL(absl::MockPoisson<int>(), Call(gen, 1.0)).WillOnce(Return(500)); + EXPECT_EQ(absl::Poisson<int>(gen, 1.0), 500); + + EXPECT_NE(absl::Bernoulli(gen, 0.000001), true); + EXPECT_CALL(absl::MockBernoulli(), Call(gen, 0.000001)) + .WillOnce(Return(true)); + EXPECT_EQ(absl::Bernoulli(gen, 0.000001), true); + + EXPECT_NE(absl::Zipf<int>(gen, 1000000, 2.0, 1.0), 1221); + EXPECT_CALL(absl::MockZipf<int>(), Call(gen, 1000000, 2.0, 1.0)) + .WillOnce(Return(1221)); + EXPECT_EQ(absl::Zipf<int>(gen, 1000000, 2.0, 1.0), 1221); + + EXPECT_NE(absl::Gaussian<double>(gen, 0.0, 1.0), 0.001); + EXPECT_CALL(absl::MockGaussian<double>(), Call(gen, 0.0, 1.0)) + .WillOnce(Return(0.001)); + EXPECT_EQ(absl::Gaussian<double>(gen, 0.0, 1.0), 0.001); + + EXPECT_NE(absl::LogUniform<int>(gen, 0, 1000000, 2), 500000); + EXPECT_CALL(absl::MockLogUniform<int>(), Call(gen, 0, 1000000, 2)) + .WillOnce(Return(500000)); + EXPECT_EQ(absl::LogUniform<int>(gen, 0, 1000000, 2), 500000); +} + +TEST(BasicMocking, OnDistribution) { + absl::MockingBitGen gen; + + EXPECT_NE(absl::Uniform<int>(gen, 1, 1000000), 20); + ON_CALL(absl::MockUniform<int>(), Call(gen, 1, 1000000)) + .WillByDefault(Return(20)); + EXPECT_EQ(absl::Uniform<int>(gen, 1, 1000000), 20); + + EXPECT_NE(absl::Uniform<double>(gen, 0.0, 100.0), 5.0); + ON_CALL(absl::MockUniform<double>(), Call(gen, 0.0, 100.0)) + .WillByDefault(Return(5.0)); + EXPECT_EQ(absl::Uniform<double>(gen, 0.0, 100.0), 5.0); + + EXPECT_NE(absl::Exponential<double>(gen, 1.0), 42); + ON_CALL(absl::MockExponential<double>(), Call(gen, 1.0)) + .WillByDefault(Return(42)); + EXPECT_EQ(absl::Exponential<double>(gen, 1.0), 42); + + EXPECT_NE(absl::Poisson<int>(gen, 1.0), 500); + ON_CALL(absl::MockPoisson<int>(), Call(gen, 1.0)).WillByDefault(Return(500)); + EXPECT_EQ(absl::Poisson<int>(gen, 1.0), 500); + + EXPECT_NE(absl::Bernoulli(gen, 0.000001), true); + ON_CALL(absl::MockBernoulli(), Call(gen, 0.000001)) + .WillByDefault(Return(true)); + EXPECT_EQ(absl::Bernoulli(gen, 0.000001), true); + + EXPECT_NE(absl::Zipf<int>(gen, 1000000, 2.0, 1.0), 1221); + ON_CALL(absl::MockZipf<int>(), Call(gen, 1000000, 2.0, 1.0)) + .WillByDefault(Return(1221)); + EXPECT_EQ(absl::Zipf<int>(gen, 1000000, 2.0, 1.0), 1221); + + EXPECT_NE(absl::Gaussian<double>(gen, 0.0, 1.0), 0.001); + ON_CALL(absl::MockGaussian<double>(), Call(gen, 0.0, 1.0)) + .WillByDefault(Return(0.001)); + EXPECT_EQ(absl::Gaussian<double>(gen, 0.0, 1.0), 0.001); + + EXPECT_NE(absl::LogUniform<int>(gen, 0, 1000000, 2), 2040); + ON_CALL(absl::MockLogUniform<int>(), Call(gen, 0, 1000000, 2)) + .WillByDefault(Return(2040)); + EXPECT_EQ(absl::LogUniform<int>(gen, 0, 1000000, 2), 2040); +} + +TEST(BasicMocking, GMockMatchers) { + absl::MockingBitGen gen; + + EXPECT_NE(absl::Zipf<int>(gen, 1000000, 2.0, 1.0), 1221); + ON_CALL(absl::MockZipf<int>(), Call(gen, 1000000, 2.0, 1.0)) + .WillByDefault(Return(1221)); + EXPECT_EQ(absl::Zipf<int>(gen, 1000000, 2.0, 1.0), 1221); +} + +TEST(BasicMocking, OverridesWithMultipleGMockExpectations) { + absl::MockingBitGen gen; + + EXPECT_CALL(absl::MockUniform<int>(), Call(gen, 1, 10000)) + .WillOnce(Return(20)) + .WillOnce(Return(40)) + .WillOnce(Return(60)); + EXPECT_EQ(absl::Uniform(gen, 1, 10000), 20); + EXPECT_EQ(absl::Uniform(gen, 1, 10000), 40); + EXPECT_EQ(absl::Uniform(gen, 1, 10000), 60); +} + +TEST(BasicMocking, DefaultArgument) { + absl::MockingBitGen gen; + + ON_CALL(absl::MockExponential<double>(), Call(gen, 1.0)) + .WillByDefault(Return(200)); + + EXPECT_EQ(absl::Exponential<double>(gen), 200); + EXPECT_EQ(absl::Exponential<double>(gen, 1.0), 200); +} + +TEST(BasicMocking, MultipleGenerators) { + auto get_value = [](absl::BitGenRef gen_ref) { + return absl::Uniform(gen_ref, 1, 1000000); + }; + absl::MockingBitGen unmocked_generator; + absl::MockingBitGen mocked_with_3; + absl::MockingBitGen mocked_with_11; + + EXPECT_CALL(absl::MockUniform<int>(), Call(mocked_with_3, 1, 1000000)) + .WillOnce(Return(3)) + .WillRepeatedly(Return(17)); + EXPECT_CALL(absl::MockUniform<int>(), Call(mocked_with_11, 1, 1000000)) + .WillOnce(Return(11)) + .WillRepeatedly(Return(17)); + + // Ensure that unmocked generator generates neither value. + int unmocked_value = get_value(unmocked_generator); + EXPECT_NE(unmocked_value, 3); + EXPECT_NE(unmocked_value, 11); + // Mocked generators should generate their mocked values. + EXPECT_EQ(get_value(mocked_with_3), 3); + EXPECT_EQ(get_value(mocked_with_11), 11); + // Ensure that the mocks have expired. + EXPECT_NE(get_value(mocked_with_3), 3); + EXPECT_NE(get_value(mocked_with_11), 11); +} + +TEST(BasicMocking, MocksNotTrigeredForIncorrectTypes) { + absl::MockingBitGen gen; + EXPECT_CALL(absl::MockUniform<uint32_t>(), Call(gen)).WillOnce(Return(42)); + + EXPECT_NE(absl::Uniform<uint16_t>(gen), 42); // Not mocked + EXPECT_EQ(absl::Uniform<uint32_t>(gen), 42); // Mock triggered +} + +TEST(BasicMocking, FailsOnUnsatisfiedMocks) { + EXPECT_NONFATAL_FAILURE( + []() { + absl::MockingBitGen gen; + EXPECT_CALL(absl::MockExponential<double>(), Call(gen, 1.0)) + .WillOnce(Return(3.0)); + // Does not call absl::Exponential(). + }(), + "unsatisfied and active"); +} + +TEST(OnUniform, RespectsUniformIntervalSemantics) { + absl::MockingBitGen gen; + + EXPECT_CALL(absl::MockUniform<int>(), + Call(absl::IntervalClosed, gen, 1, 1000000)) + .WillOnce(Return(301)); + EXPECT_NE(absl::Uniform(gen, 1, 1000000), 301); // Not mocked + EXPECT_EQ(absl::Uniform(absl::IntervalClosed, gen, 1, 1000000), 301); +} + +TEST(OnUniform, RespectsNoArgUnsignedShorthand) { + absl::MockingBitGen gen; + EXPECT_CALL(absl::MockUniform<uint32_t>(), Call(gen)).WillOnce(Return(42)); + EXPECT_EQ(absl::Uniform<uint32_t>(gen), 42); +} + +TEST(RepeatedlyModifier, ForceSnakeEyesForManyDice) { + auto roll_some_dice = [](absl::BitGenRef gen_ref) { + std::vector<int> results(16); + for (auto& r : results) { + r = absl::Uniform(absl::IntervalClosed, gen_ref, 1, 6); + } + return results; + }; + std::vector<int> results; + absl::MockingBitGen gen; + + // Without any mocked calls, not all dice roll a "6". + results = roll_some_dice(gen); + EXPECT_LT(std::accumulate(std::begin(results), std::end(results), 0), + results.size() * 6); + + // Verify that we can force all "6"-rolls, with mocking. + ON_CALL(absl::MockUniform<int>(), Call(absl::IntervalClosed, gen, 1, 6)) + .WillByDefault(Return(6)); + results = roll_some_dice(gen); + EXPECT_EQ(std::accumulate(std::begin(results), std::end(results), 0), + results.size() * 6); +} + +TEST(WillOnce, DistinctCounters) { + absl::MockingBitGen gen; + EXPECT_CALL(absl::MockUniform<int>(), Call(gen, 1, 1000000)) + .Times(3) + .WillRepeatedly(Return(0)); + EXPECT_CALL(absl::MockUniform<int>(), Call(gen, 1000001, 2000000)) + .Times(3) + .WillRepeatedly(Return(1)); + EXPECT_EQ(absl::Uniform(gen, 1000001, 2000000), 1); + EXPECT_EQ(absl::Uniform(gen, 1, 1000000), 0); + EXPECT_EQ(absl::Uniform(gen, 1000001, 2000000), 1); + EXPECT_EQ(absl::Uniform(gen, 1, 1000000), 0); + EXPECT_EQ(absl::Uniform(gen, 1000001, 2000000), 1); + EXPECT_EQ(absl::Uniform(gen, 1, 1000000), 0); +} + +TEST(TimesModifier, ModifierSaturatesAndExpires) { + EXPECT_NONFATAL_FAILURE( + []() { + absl::MockingBitGen gen; + EXPECT_CALL(absl::MockUniform<int>(), Call(gen, 1, 1000000)) + .Times(3) + .WillRepeatedly(Return(15)) + .RetiresOnSaturation(); + + EXPECT_EQ(absl::Uniform(gen, 1, 1000000), 15); + EXPECT_EQ(absl::Uniform(gen, 1, 1000000), 15); + EXPECT_EQ(absl::Uniform(gen, 1, 1000000), 15); + // Times(3) has expired - Should get a different value now. + + EXPECT_NE(absl::Uniform(gen, 1, 1000000), 15); + }(), + ""); +} + +TEST(TimesModifier, Times0) { + absl::MockingBitGen gen; + EXPECT_CALL(absl::MockBernoulli(), Call(gen, 0.0)).Times(0); + EXPECT_CALL(absl::MockPoisson<int>(), Call(gen, 1.0)).Times(0); +} + +TEST(AnythingMatcher, MatchesAnyArgument) { + using testing::_; + + { + absl::MockingBitGen gen; + ON_CALL(absl::MockUniform<int>(), Call(absl::IntervalClosed, gen, _, 1000)) + .WillByDefault(Return(11)); + ON_CALL(absl::MockUniform<int>(), + Call(absl::IntervalClosed, gen, _, Ne(1000))) + .WillByDefault(Return(99)); + + EXPECT_EQ(absl::Uniform(absl::IntervalClosed, gen, 10, 1000000), 99); + EXPECT_EQ(absl::Uniform(absl::IntervalClosed, gen, 10, 1000), 11); + } + + { + absl::MockingBitGen gen; + ON_CALL(absl::MockUniform<int>(), Call(gen, 1, _)) + .WillByDefault(Return(25)); + ON_CALL(absl::MockUniform<int>(), Call(gen, Ne(1), _)) + .WillByDefault(Return(99)); + EXPECT_EQ(absl::Uniform(gen, 3, 1000000), 99); + EXPECT_EQ(absl::Uniform(gen, 1, 1000000), 25); + } + + { + absl::MockingBitGen gen; + ON_CALL(absl::MockUniform<int>(), Call(gen, _, _)) + .WillByDefault(Return(145)); + EXPECT_EQ(absl::Uniform(gen, 1, 1000), 145); + EXPECT_EQ(absl::Uniform(gen, 10, 1000), 145); + EXPECT_EQ(absl::Uniform(gen, 100, 1000), 145); + } +} + +TEST(AnythingMatcher, WithWillByDefault) { + using testing::_; + absl::MockingBitGen gen; + std::vector<int> values = {11, 22, 33, 44, 55, 66, 77, 88, 99, 1010}; + + ON_CALL(absl::MockUniform<size_t>(), Call(gen, 0, _)) + .WillByDefault(Return(0)); + for (int i = 0; i < 100; i++) { + auto& elem = values[absl::Uniform(gen, 0u, values.size())]; + EXPECT_EQ(elem, 11); + } +} + +TEST(BasicMocking, WillByDefaultWithArgs) { + using testing::_; + + absl::MockingBitGen gen; + ON_CALL(absl::MockPoisson<int>(), Call(gen, _)) + .WillByDefault( + [](double lambda) { return static_cast<int>(lambda * 10); }); + EXPECT_EQ(absl::Poisson<int>(gen, 1.7), 17); + EXPECT_EQ(absl::Poisson<int>(gen, 0.03), 0); +} + +TEST(MockingBitGen, InSequenceSucceedsInOrder) { + absl::MockingBitGen gen; + + testing::InSequence seq; + + EXPECT_CALL(absl::MockPoisson<int>(), Call(gen, 1.0)).WillOnce(Return(3)); + EXPECT_CALL(absl::MockPoisson<int>(), Call(gen, 2.0)).WillOnce(Return(4)); + + EXPECT_EQ(absl::Poisson<int>(gen, 1.0), 3); + EXPECT_EQ(absl::Poisson<int>(gen, 2.0), 4); +} + +} // namespace
diff --git a/third_party/abseil-cpp/absl/random/poisson_distribution.h b/third_party/abseil-cpp/absl/random/poisson_distribution.h index 7750b1c..cb5f5d5d 100644 --- a/third_party/abseil-cpp/absl/random/poisson_distribution.h +++ b/third_party/abseil-cpp/absl/random/poisson_distribution.h
@@ -22,12 +22,13 @@ #include <ostream> #include <type_traits> -#include "absl/random/internal/distribution_impl.h" #include "absl/random/internal/fast_uniform_bits.h" #include "absl/random/internal/fastmath.h" +#include "absl/random/internal/generate_real.h" #include "absl/random/internal/iostream_state_saver.h" namespace absl { +ABSL_NAMESPACE_BEGIN // absl::poisson_distribution: // Generates discrete variates conforming to a Poisson distribution. @@ -164,9 +165,9 @@ poisson_distribution<IntType>::operator()( URBG& g, // NOLINT(runtime/references) const param_type& p) { - using random_internal::PositiveValueT; - using random_internal::RandU64ToDouble; - using random_internal::SignedValueT; + using random_internal::GeneratePositiveTag; + using random_internal::GenerateRealFromBits; + using random_internal::GenerateSignedTag; if (p.split_ != 0) { // Use Knuth's algorithm with range splitting to avoid floating-point @@ -186,7 +187,8 @@ for (int split = p.split_; split > 0; --split) { double r = 1.0; do { - r *= RandU64ToDouble<PositiveValueT, true>(fast_u64_(g)); + r *= GenerateRealFromBits<double, GeneratePositiveTag, true>( + fast_u64_(g)); // U(-1, 0) ++n; } while (r > p.emu_); --n; @@ -205,10 +207,11 @@ // and k = max(f). const double a = p.mean_ + 0.5; for (;;) { - const double u = - RandU64ToDouble<PositiveValueT, false>(fast_u64_(g)); // (0, 1) - const double v = - RandU64ToDouble<SignedValueT, false>(fast_u64_(g)); // (-1, 1) + const double u = GenerateRealFromBits<double, GeneratePositiveTag, false>( + fast_u64_(g)); // U(0, 1) + const double v = GenerateRealFromBits<double, GenerateSignedTag, false>( + fast_u64_(g)); // U(-1, 1) + const double x = std::floor(p.s_ * v / u + a); if (x < 0) continue; // f(negative) = 0 const double rhs = x * p.lmu_; @@ -249,6 +252,7 @@ return is; } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_POISSON_DISTRIBUTION_H_
diff --git a/third_party/abseil-cpp/absl/random/poisson_distribution_test.cc b/third_party/abseil-cpp/absl/random/poisson_distribution_test.cc index 6d68999..9d215fb 100644 --- a/third_party/abseil-cpp/absl/random/poisson_distribution_test.cc +++ b/third_party/abseil-cpp/absl/random/poisson_distribution_test.cc
@@ -339,7 +339,7 @@ return absl::StrReplaceAll(name, {{"+", "_"}, {"-", "_"}, {".", "_"}}); } -INSTANTIATE_TEST_SUITE_P(, PoissonDistributionZTest, +INSTANTIATE_TEST_SUITE_P(All, PoissonDistributionZTest, ::testing::ValuesIn(GetZParams()), ZParamName); // The PoissonDistributionChiSquaredTest class provides a basic test framework @@ -468,7 +468,7 @@ EXPECT_LE(failures, 4); } -INSTANTIATE_TEST_SUITE_P(, PoissonDistributionChiSquaredTest, +INSTANTIATE_TEST_SUITE_P(All, PoissonDistributionChiSquaredTest, ::testing::Values(0.5, 1.0, 2.0, 10.0, 50.0, 51.0, 200.0));
diff --git a/third_party/abseil-cpp/absl/random/random.h b/third_party/abseil-cpp/absl/random/random.h index dc6852f..c8f326e 100644 --- a/third_party/abseil-cpp/absl/random/random.h +++ b/third_party/abseil-cpp/absl/random/random.h
@@ -41,6 +41,7 @@ #include "absl/random/seed_sequences.h" // IWYU pragma: export namespace absl { +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // absl::BitGen @@ -182,6 +183,7 @@ // discards the intermediate results. // --------------------------------------------------------------------------- +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_RANDOM_H_
diff --git a/third_party/abseil-cpp/absl/random/seed_gen_exception.cc b/third_party/abseil-cpp/absl/random/seed_gen_exception.cc index e4271ba..fdcb54a 100644 --- a/third_party/abseil-cpp/absl/random/seed_gen_exception.cc +++ b/third_party/abseil-cpp/absl/random/seed_gen_exception.cc
@@ -19,6 +19,7 @@ #include "absl/base/config.h" namespace absl { +ABSL_NAMESPACE_BEGIN static constexpr const char kExceptionMessage[] = "Failed generating seed-material for URBG."; @@ -41,4 +42,5 @@ } } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/random/seed_gen_exception.h b/third_party/abseil-cpp/absl/random/seed_gen_exception.h index b464d52..5353900 100644 --- a/third_party/abseil-cpp/absl/random/seed_gen_exception.h +++ b/third_party/abseil-cpp/absl/random/seed_gen_exception.h
@@ -28,7 +28,10 @@ #include <exception> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN //------------------------------------------------------------------------------ // SeedGenException @@ -46,6 +49,7 @@ [[noreturn]] void ThrowSeedGenException(); } // namespace random_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_SEED_GEN_EXCEPTION_H_
diff --git a/third_party/abseil-cpp/absl/random/seed_sequences.cc b/third_party/abseil-cpp/absl/random/seed_sequences.cc index 9f31961..426eafd 100644 --- a/third_party/abseil-cpp/absl/random/seed_sequences.cc +++ b/third_party/abseil-cpp/absl/random/seed_sequences.cc
@@ -17,6 +17,7 @@ #include "absl/random/internal/pool_urbg.h" namespace absl { +ABSL_NAMESPACE_BEGIN SeedSeq MakeSeedSeq() { SeedSeq::result_type seed_material[8]; @@ -24,4 +25,5 @@ return SeedSeq(std::begin(seed_material), std::end(seed_material)); } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/random/seed_sequences.h b/third_party/abseil-cpp/absl/random/seed_sequences.h index 631d1ecd..ff1340cc8 100644 --- a/third_party/abseil-cpp/absl/random/seed_sequences.h +++ b/third_party/abseil-cpp/absl/random/seed_sequences.h
@@ -34,6 +34,7 @@ #include "absl/types/span.h" namespace absl { +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // absl::SeedSeq @@ -103,6 +104,7 @@ // SeedSeq MakeSeedSeq(); +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_SEED_SEQUENCES_H_
diff --git a/third_party/abseil-cpp/absl/random/uniform_int_distribution.h b/third_party/abseil-cpp/absl/random/uniform_int_distribution.h index 4970486..da66564a 100644 --- a/third_party/abseil-cpp/absl/random/uniform_int_distribution.h +++ b/third_party/abseil-cpp/absl/random/uniform_int_distribution.h
@@ -34,12 +34,13 @@ #include <type_traits> #include "absl/base/optimization.h" -#include "absl/random/internal/distribution_impl.h" #include "absl/random/internal/fast_uniform_bits.h" #include "absl/random/internal/iostream_state_saver.h" #include "absl/random/internal/traits.h" +#include "absl/random/internal/wide_multiply.h" namespace absl { +ABSL_NAMESPACE_BEGIN // absl::uniform_int_distribution<T> // @@ -268,6 +269,7 @@ return helper::hi(product); } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_UNIFORM_INT_DISTRIBUTION_H_
diff --git a/third_party/abseil-cpp/absl/random/uniform_int_distribution_test.cc b/third_party/abseil-cpp/absl/random/uniform_int_distribution_test.cc index aacff88d..6953760 100644 --- a/third_party/abseil-cpp/absl/random/uniform_int_distribution_test.cc +++ b/third_party/abseil-cpp/absl/random/uniform_int_distribution_test.cc
@@ -123,7 +123,7 @@ absl::uniform_int_distribution<TypeParam> dist(10, 1); auto x = dist(gen); - // Any value will generate a non-empty std::string. + // Any value will generate a non-empty string. EXPECT_FALSE(absl::StrCat(+x).empty()) << x; #endif // NDEBUG }
diff --git a/third_party/abseil-cpp/absl/random/uniform_real_distribution.h b/third_party/abseil-cpp/absl/random/uniform_real_distribution.h index 600f915..5ba17b2 100644 --- a/third_party/abseil-cpp/absl/random/uniform_real_distribution.h +++ b/third_party/abseil-cpp/absl/random/uniform_real_distribution.h
@@ -39,11 +39,13 @@ #include <limits> #include <type_traits> -#include "absl/random/internal/distribution_impl.h" +#include "absl/meta/type_traits.h" #include "absl/random/internal/fast_uniform_bits.h" +#include "absl/random/internal/generate_real.h" #include "absl/random/internal/iostream_state_saver.h" namespace absl { +ABSL_NAMESPACE_BEGIN // absl::uniform_real_distribution<T> // @@ -56,7 +58,7 @@ // // // Use the distribution to produce a value between 0.0 (inclusive) // // and 1.0 (exclusive). -// int value = absl::uniform_real_distribution<double>(0, 1)(gen); +// double value = absl::uniform_real_distribution<double>(0, 1)(gen); // template <typename RealType = double> class uniform_real_distribution { @@ -76,6 +78,7 @@ // is not possible, so value generation cannot use the full range of the // real type. assert(range_ <= (std::numeric_limits<result_type>::max)()); + assert(std::isfinite(range_)); } result_type a() const { return lo_; } @@ -151,10 +154,15 @@ typename uniform_real_distribution<RealType>::result_type uniform_real_distribution<RealType>::operator()( URBG& gen, const param_type& p) { // NOLINT(runtime/references) - using random_internal::PositiveValueT; + using random_internal::GeneratePositiveTag; + using random_internal::GenerateRealFromBits; + using real_type = + absl::conditional_t<std::is_same<RealType, float>::value, float, double>; + while (true) { - const result_type sample = random_internal::RandU64ToReal< - result_type>::template Value<PositiveValueT, true>(fast_u64_(gen)); + const result_type sample = + GenerateRealFromBits<real_type, GeneratePositiveTag, true>( + fast_u64_(gen)); const result_type res = p.a() + (sample * p.range_); if (res < p.b() || p.range_ <= 0 || !std::isfinite(p.range_)) { return res; @@ -188,6 +196,7 @@ } return is; } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_UNIFORM_REAL_DISTRIBUTION_H_
diff --git a/third_party/abseil-cpp/absl/random/uniform_real_distribution_test.cc b/third_party/abseil-cpp/absl/random/uniform_real_distribution_test.cc index 597f0ee..a56374a6 100644 --- a/third_party/abseil-cpp/absl/random/uniform_real_distribution_test.cc +++ b/third_party/abseil-cpp/absl/random/uniform_real_distribution_test.cc
@@ -54,7 +54,12 @@ template <typename RealType> class UniformRealDistributionTest : public ::testing::Test {}; +#if defined(__EMSCRIPTEN__) +using RealTypes = ::testing::Types<float, double>; +#else using RealTypes = ::testing::Types<float, double, long double>; +#endif // defined(__EMSCRIPTEN__) + TYPED_TEST_SUITE(UniformRealDistributionTest, RealTypes); TYPED_TEST(UniformRealDistributionTest, ParamSerializeTest) { @@ -156,6 +161,10 @@ } } +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4756) // Constant arithmetic overflow. +#endif TYPED_TEST(UniformRealDistributionTest, ViolatesPreconditionsDeathTest) { #if GTEST_HAS_DEATH_TEST // Hi < Lo @@ -190,6 +199,9 @@ } #endif // NDEBUG } +#ifdef _MSC_VER +#pragma warning(pop) // warning(disable:4756) +#endif TYPED_TEST(UniformRealDistributionTest, TestMoments) { constexpr int kSize = 1000000;
diff --git a/third_party/abseil-cpp/absl/random/zipf_distribution.h b/third_party/abseil-cpp/absl/random/zipf_distribution.h index d7b4ac3..22ebc75 100644 --- a/third_party/abseil-cpp/absl/random/zipf_distribution.h +++ b/third_party/abseil-cpp/absl/random/zipf_distribution.h
@@ -26,6 +26,7 @@ #include "absl/random/uniform_real_distribution.h" namespace absl { +ABSL_NAMESPACE_BEGIN // absl::zipf_distribution produces random integer-values in the range [0, k], // distributed according to the discrete probability function: @@ -264,6 +265,7 @@ return is; } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_RANDOM_ZIPF_DISTRIBUTION_H_
diff --git a/third_party/abseil-cpp/absl/status/BUILD.bazel b/third_party/abseil-cpp/absl/status/BUILD.bazel new file mode 100644 index 0000000..2b83077 --- /dev/null +++ b/third_party/abseil-cpp/absl/status/BUILD.bazel
@@ -0,0 +1,65 @@ +# +# Copyright 2017 The Abseil Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This package contains `absl::Status`. +# It will expand later to have utilities around `Status` like `StatusOr`, +# `StatusBuilder` and macros. + +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") +load( + "//absl:copts/configure_copts.bzl", + "ABSL_DEFAULT_COPTS", + "ABSL_TEST_COPTS", +) + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # Apache 2.0 + +cc_library( + name = "status", + srcs = [ + "status.cc", + "status_payload_printer.cc", + ], + hdrs = [ + "status.h", + "status_payload_printer.h", + ], + copts = ABSL_DEFAULT_COPTS, + deps = [ + "//absl/base:config", + "//absl/base:core_headers", + "//absl/base:raw_logging_internal", + "//absl/container:inlined_vector", + "//absl/debugging:stacktrace", + "//absl/debugging:symbolize", + "//absl/strings", + "//absl/strings:cord", + "//absl/strings:str_format", + "//absl/types:optional", + ], +) + +cc_test( + name = "status_test", + srcs = ["status_test.cc"], + copts = ABSL_TEST_COPTS, + deps = [ + ":status", + "//absl/strings", + "@com_google_googletest//:gtest_main", + ], +)
diff --git a/third_party/abseil-cpp/absl/status/BUILD.gn b/third_party/abseil-cpp/absl/status/BUILD.gn new file mode 100644 index 0000000..3b85d36 --- /dev/null +++ b/third_party/abseil-cpp/absl/status/BUILD.gn
@@ -0,0 +1,47 @@ +# Copyright 2018 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. + +import("//build_overrides/build.gni") +import("//third_party/abseil-cpp/abseil_clients.gni") + +# Usage of Abseil in Chromium is guarded by an explicit opt-in list, before +# adding projects to this list please reach out to cxx@chromium.org and CC: +# - https://cs.chromium.org/chromium/src/third_party/abseil-cpp/OWNERS +# +# More information can be found at: +# https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU +if (build_with_chromium) { + visibility = absl_visibility +} else { + visibility = [ "*" ] +} + +source_set("status") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] + public = [ + "status.h", + "status_payload_printer.h", + ] + sources = [ + "status.cc", + "status_payload_printer.cc", + ] + deps = [ + "../base:config", + "../base:core_headers", + "../base:raw_logging_internal", + "../container:inlined_vector", + "../debugging:stacktrace", + "../debugging:symbolize", + "../strings", + "../strings:cord", + "../strings:str_format", + "../types:optional", + ] +}
diff --git a/third_party/abseil-cpp/absl/status/CMakeLists.txt b/third_party/abseil-cpp/absl/status/CMakeLists.txt new file mode 100644 index 0000000..f05cee5e --- /dev/null +++ b/third_party/abseil-cpp/absl/status/CMakeLists.txt
@@ -0,0 +1,52 @@ +# +# Copyright 2020 The Abseil Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +absl_cc_library( + NAME + status + HDRS + "status.h" + SRCS + "status.cc" + "status_payload_printer.h" + "status_payload_printer.cc" + COPTS + ${ABSL_DEFAULT_COPTS} + DEPS + absl::config + absl::core_headers + absl::raw_logging_internal + absl::inlined_vector + absl::stacktrace + absl::symbolize + absl::strings + absl::cord + absl::str_format + absl::optional + PUBLIC +) + +absl_cc_test( + NAME + status_test + SRCS + "status_test.cc" + COPTS + ${ABSL_TEST_COPTS} + DEPS + absl::status + absl::strings + gmock_main +)
diff --git a/third_party/abseil-cpp/absl/status/status.cc b/third_party/abseil-cpp/absl/status/status.cc new file mode 100644 index 0000000..6d57a6b --- /dev/null +++ b/third_party/abseil-cpp/absl/status/status.cc
@@ -0,0 +1,447 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#include "absl/status/status.h" + +#include <cassert> + +#include "absl/base/internal/raw_logging.h" +#include "absl/debugging/stacktrace.h" +#include "absl/debugging/symbolize.h" +#include "absl/status/status_payload_printer.h" +#include "absl/strings/escaping.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_split.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN + +// The implementation was intentionally kept same as util::error::Code_Name() +// to ease the migration. +std::string StatusCodeToString(StatusCode code) { + switch (code) { + case StatusCode::kOk: + return "OK"; + case StatusCode::kCancelled: + return "CANCELLED"; + case StatusCode::kUnknown: + return "UNKNOWN"; + case StatusCode::kInvalidArgument: + return "INVALID_ARGUMENT"; + case StatusCode::kDeadlineExceeded: + return "DEADLINE_EXCEEDED"; + case StatusCode::kNotFound: + return "NOT_FOUND"; + case StatusCode::kAlreadyExists: + return "ALREADY_EXISTS"; + case StatusCode::kPermissionDenied: + return "PERMISSION_DENIED"; + case StatusCode::kUnauthenticated: + return "UNAUTHENTICATED"; + case StatusCode::kResourceExhausted: + return "RESOURCE_EXHAUSTED"; + case StatusCode::kFailedPrecondition: + return "FAILED_PRECONDITION"; + case StatusCode::kAborted: + return "ABORTED"; + case StatusCode::kOutOfRange: + return "OUT_OF_RANGE"; + case StatusCode::kUnimplemented: + return "UNIMPLEMENTED"; + case StatusCode::kInternal: + return "INTERNAL"; + case StatusCode::kUnavailable: + return "UNAVAILABLE"; + case StatusCode::kDataLoss: + return "DATA_LOSS"; + default: + return ""; + } +} + +std::ostream& operator<<(std::ostream& os, StatusCode code) { + return os << StatusCodeToString(code); +} + +namespace status_internal { + +static int FindPayloadIndexByUrl(const Payloads* payloads, + absl::string_view type_url) { + if (payloads == nullptr) return -1; + + for (int i = 0; i < payloads->size(); ++i) { + if ((*payloads)[i].type_url == type_url) return i; + } + + return -1; +} + +// Convert canonical code to a value known to this binary. +absl::StatusCode MapToLocalCode(int value) { + absl::StatusCode code = static_cast<absl::StatusCode>(value); + switch (code) { + case absl::StatusCode::kOk: + case absl::StatusCode::kCancelled: + case absl::StatusCode::kUnknown: + case absl::StatusCode::kInvalidArgument: + case absl::StatusCode::kDeadlineExceeded: + case absl::StatusCode::kNotFound: + case absl::StatusCode::kAlreadyExists: + case absl::StatusCode::kPermissionDenied: + case absl::StatusCode::kResourceExhausted: + case absl::StatusCode::kFailedPrecondition: + case absl::StatusCode::kAborted: + case absl::StatusCode::kOutOfRange: + case absl::StatusCode::kUnimplemented: + case absl::StatusCode::kInternal: + case absl::StatusCode::kUnavailable: + case absl::StatusCode::kDataLoss: + case absl::StatusCode::kUnauthenticated: + return code; + default: + return absl::StatusCode::kUnknown; + } +} +} // namespace status_internal + +absl::optional<absl::Cord> Status::GetPayload( + absl::string_view type_url) const { + const auto* payloads = GetPayloads(); + int index = status_internal::FindPayloadIndexByUrl(payloads, type_url); + if (index != -1) return (*payloads)[index].payload; + + return absl::nullopt; +} + +void Status::SetPayload(absl::string_view type_url, absl::Cord payload) { + if (ok()) return; + + PrepareToModify(); + + status_internal::StatusRep* rep = RepToPointer(rep_); + if (!rep->payloads) { + rep->payloads = absl::make_unique<status_internal::Payloads>(); + } + + int index = + status_internal::FindPayloadIndexByUrl(rep->payloads.get(), type_url); + if (index != -1) { + (*rep->payloads)[index].payload = std::move(payload); + return; + } + + rep->payloads->push_back({std::string(type_url), std::move(payload)}); +} + +bool Status::ErasePayload(absl::string_view type_url) { + int index = status_internal::FindPayloadIndexByUrl(GetPayloads(), type_url); + if (index != -1) { + PrepareToModify(); + GetPayloads()->erase(GetPayloads()->begin() + index); + if (GetPayloads()->empty() && message().empty()) { + // Special case: If this can be represented inlined, it MUST be + // inlined (EqualsSlow depends on this behavior). + StatusCode c = static_cast<StatusCode>(raw_code()); + Unref(rep_); + rep_ = CodeToInlinedRep(c); + } + return true; + } + + return false; +} + +void Status::ForEachPayload( + const std::function<void(absl::string_view, const absl::Cord&)>& visitor) + const { + if (auto* payloads = GetPayloads()) { + bool in_reverse = + payloads->size() > 1 && reinterpret_cast<uintptr_t>(payloads) % 13 > 6; + + for (int index = 0; index < payloads->size(); ++index) { + const auto& elem = + (*payloads)[in_reverse ? payloads->size() - 1 - index : index]; + +#ifdef NDEBUG + visitor(elem.type_url, elem.payload); +#else + // In debug mode invalidate the type url to prevent users from relying on + // this string lifetime. + + // NOLINTNEXTLINE intentional extra conversion to force temporary. + visitor(std::string(elem.type_url), elem.payload); +#endif // NDEBUG + } + } +} + +const std::string* Status::EmptyString() { + static std::string* empty_string = new std::string(); + return empty_string; +} + +constexpr const char Status::kMovedFromString[]; + +const std::string* Status::MovedFromString() { + static std::string* moved_from_string = new std::string(kMovedFromString); + return moved_from_string; +} + +void Status::UnrefNonInlined(uintptr_t rep) { + status_internal::StatusRep* r = RepToPointer(rep); + // Fast path: if ref==1, there is no need for a RefCountDec (since + // this is the only reference and therefore no other thread is + // allowed to be mucking with r). + if (r->ref.load(std::memory_order_acquire) == 1 || + r->ref.fetch_sub(1, std::memory_order_acq_rel) - 1 == 0) { + delete r; + } +} + +uintptr_t Status::NewRep(absl::StatusCode code, absl::string_view msg, + std::unique_ptr<status_internal::Payloads> payloads) { + status_internal::StatusRep* rep = new status_internal::StatusRep; + rep->ref.store(1, std::memory_order_relaxed); + rep->code = code; + rep->message.assign(msg.data(), msg.size()); + rep->payloads = std::move(payloads); + return PointerToRep(rep); +} + +Status::Status(absl::StatusCode code, absl::string_view msg) + : rep_(CodeToInlinedRep(code)) { + if (code != absl::StatusCode::kOk && !msg.empty()) { + rep_ = NewRep(code, msg, nullptr); + } +} + +int Status::raw_code() const { + if (IsInlined(rep_)) { + return static_cast<int>(InlinedRepToCode(rep_)); + } + status_internal::StatusRep* rep = RepToPointer(rep_); + return static_cast<int>(rep->code); +} + +absl::StatusCode Status::code() const { + return status_internal::MapToLocalCode(raw_code()); +} + +void Status::PrepareToModify() { + ABSL_RAW_CHECK(!ok(), "PrepareToModify shouldn't be called on OK status."); + if (IsInlined(rep_)) { + rep_ = NewRep(static_cast<absl::StatusCode>(raw_code()), + absl::string_view(), nullptr); + return; + } + + uintptr_t rep_i = rep_; + status_internal::StatusRep* rep = RepToPointer(rep_); + if (rep->ref.load(std::memory_order_acquire) != 1) { + std::unique_ptr<status_internal::Payloads> payloads; + if (rep->payloads) { + payloads = absl::make_unique<status_internal::Payloads>(*rep->payloads); + } + rep_ = NewRep(rep->code, message(), std::move(payloads)); + UnrefNonInlined(rep_i); + } +} + +bool Status::EqualsSlow(const absl::Status& a, const absl::Status& b) { + if (IsInlined(a.rep_) != IsInlined(b.rep_)) return false; + if (a.message() != b.message()) return false; + if (a.raw_code() != b.raw_code()) return false; + if (a.GetPayloads() == b.GetPayloads()) return true; + + const status_internal::Payloads no_payloads; + const status_internal::Payloads* larger_payloads = + a.GetPayloads() ? a.GetPayloads() : &no_payloads; + const status_internal::Payloads* smaller_payloads = + b.GetPayloads() ? b.GetPayloads() : &no_payloads; + if (larger_payloads->size() < smaller_payloads->size()) { + std::swap(larger_payloads, smaller_payloads); + } + if ((larger_payloads->size() - smaller_payloads->size()) > 1) return false; + // Payloads can be ordered differently, so we can't just compare payload + // vectors. + for (const auto& payload : *larger_payloads) { + + bool found = false; + for (const auto& other_payload : *smaller_payloads) { + if (payload.type_url == other_payload.type_url) { + if (payload.payload != other_payload.payload) { + return false; + } + found = true; + break; + } + } + if (!found) return false; + } + return true; +} + +std::string Status::ToStringSlow() const { + std::string text; + absl::StrAppend(&text, absl::StatusCodeToString(code()), ": ", message()); + status_internal::StatusPayloadPrinter printer = + status_internal::GetStatusPayloadPrinter(); + this->ForEachPayload([&](absl::string_view type_url, + const absl::Cord& payload) { + absl::optional<std::string> result; + if (printer) result = printer(type_url, payload); + absl::StrAppend( + &text, " [", type_url, "='", + result.has_value() ? *result : absl::CHexEscape(std::string(payload)), + "']"); + }); + + return text; +} + +std::ostream& operator<<(std::ostream& os, const Status& x) { + os << x.ToString(); + return os; +} + +Status AbortedError(absl::string_view message) { + return Status(absl::StatusCode::kAborted, message); +} + +Status AlreadyExistsError(absl::string_view message) { + return Status(absl::StatusCode::kAlreadyExists, message); +} + +Status CancelledError(absl::string_view message) { + return Status(absl::StatusCode::kCancelled, message); +} + +Status DataLossError(absl::string_view message) { + return Status(absl::StatusCode::kDataLoss, message); +} + +Status DeadlineExceededError(absl::string_view message) { + return Status(absl::StatusCode::kDeadlineExceeded, message); +} + +Status FailedPreconditionError(absl::string_view message) { + return Status(absl::StatusCode::kFailedPrecondition, message); +} + +Status InternalError(absl::string_view message) { + return Status(absl::StatusCode::kInternal, message); +} + +Status InvalidArgumentError(absl::string_view message) { + return Status(absl::StatusCode::kInvalidArgument, message); +} + +Status NotFoundError(absl::string_view message) { + return Status(absl::StatusCode::kNotFound, message); +} + +Status OutOfRangeError(absl::string_view message) { + return Status(absl::StatusCode::kOutOfRange, message); +} + +Status PermissionDeniedError(absl::string_view message) { + return Status(absl::StatusCode::kPermissionDenied, message); +} + +Status ResourceExhaustedError(absl::string_view message) { + return Status(absl::StatusCode::kResourceExhausted, message); +} + +Status UnauthenticatedError(absl::string_view message) { + return Status(absl::StatusCode::kUnauthenticated, message); +} + +Status UnavailableError(absl::string_view message) { + return Status(absl::StatusCode::kUnavailable, message); +} + +Status UnimplementedError(absl::string_view message) { + return Status(absl::StatusCode::kUnimplemented, message); +} + +Status UnknownError(absl::string_view message) { + return Status(absl::StatusCode::kUnknown, message); +} + +bool IsAborted(const Status& status) { + return status.code() == absl::StatusCode::kAborted; +} + +bool IsAlreadyExists(const Status& status) { + return status.code() == absl::StatusCode::kAlreadyExists; +} + +bool IsCancelled(const Status& status) { + return status.code() == absl::StatusCode::kCancelled; +} + +bool IsDataLoss(const Status& status) { + return status.code() == absl::StatusCode::kDataLoss; +} + +bool IsDeadlineExceeded(const Status& status) { + return status.code() == absl::StatusCode::kDeadlineExceeded; +} + +bool IsFailedPrecondition(const Status& status) { + return status.code() == absl::StatusCode::kFailedPrecondition; +} + +bool IsInternal(const Status& status) { + return status.code() == absl::StatusCode::kInternal; +} + +bool IsInvalidArgument(const Status& status) { + return status.code() == absl::StatusCode::kInvalidArgument; +} + +bool IsNotFound(const Status& status) { + return status.code() == absl::StatusCode::kNotFound; +} + +bool IsOutOfRange(const Status& status) { + return status.code() == absl::StatusCode::kOutOfRange; +} + +bool IsPermissionDenied(const Status& status) { + return status.code() == absl::StatusCode::kPermissionDenied; +} + +bool IsResourceExhausted(const Status& status) { + return status.code() == absl::StatusCode::kResourceExhausted; +} + +bool IsUnauthenticated(const Status& status) { + return status.code() == absl::StatusCode::kUnauthenticated; +} + +bool IsUnavailable(const Status& status) { + return status.code() == absl::StatusCode::kUnavailable; +} + +bool IsUnimplemented(const Status& status) { + return status.code() == absl::StatusCode::kUnimplemented; +} + +bool IsUnknown(const Status& status) { + return status.code() == absl::StatusCode::kUnknown; +} + +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/status/status.h b/third_party/abseil-cpp/absl/status/status.h new file mode 100644 index 0000000..67ff988 --- /dev/null +++ b/third_party/abseil-cpp/absl/status/status.h
@@ -0,0 +1,428 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef ABSL_STATUS_STATUS_H_ +#define ABSL_STATUS_STATUS_H_ + +#include <iostream> +#include <string> + +#include "absl/container/inlined_vector.h" +#include "absl/strings/cord.h" +#include "absl/types/optional.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN + +enum class StatusCode : int { + kOk = 0, + kCancelled = 1, + kUnknown = 2, + kInvalidArgument = 3, + kDeadlineExceeded = 4, + kNotFound = 5, + kAlreadyExists = 6, + kPermissionDenied = 7, + kResourceExhausted = 8, + kFailedPrecondition = 9, + kAborted = 10, + kOutOfRange = 11, + kUnimplemented = 12, + kInternal = 13, + kUnavailable = 14, + kDataLoss = 15, + kUnauthenticated = 16, + kDoNotUseReservedForFutureExpansionUseDefaultInSwitchInstead_ = 20 +}; + +// Returns the name for the status code, or "" if it is an unknown value. +std::string StatusCodeToString(StatusCode code); + +// Streams StatusCodeToString(code) to `os`. +std::ostream& operator<<(std::ostream& os, StatusCode code); + +namespace status_internal { + +// Container for status payloads. +struct Payload { + std::string type_url; + absl::Cord payload; +}; + +using Payloads = absl::InlinedVector<Payload, 1>; + +// Reference-counted representation of Status data. +struct StatusRep { + std::atomic<int32_t> ref; + absl::StatusCode code; + std::string message; + std::unique_ptr<status_internal::Payloads> payloads; +}; + +absl::StatusCode MapToLocalCode(int value); +} // namespace status_internal + +class ABSL_MUST_USE_RESULT Status final { + public: + // Creates an OK status with no message or payload. + Status(); + + // Create a status in the canonical error space with the specified code and + // error message. If `code == util::error::OK`, `msg` is ignored and an + // object identical to an OK status is constructed. + // + // `msg` must be in UTF-8. The implementation may complain (e.g., + // by printing a warning) if it is not. + Status(absl::StatusCode code, absl::string_view msg); + + Status(const Status&); + Status& operator=(const Status& x); + + // Move operations. + // The moved-from state is valid but unspecified. + Status(Status&&) noexcept; + Status& operator=(Status&&); + + ~Status(); + + // If `this->ok()`, stores `new_status` into *this. If `!this->ok()`, + // preserves the current data. May, in the future, augment the current status + // with additional information about `new_status`. + // + // Convenient way of keeping track of the first error encountered. + // Instead of: + // if (overall_status.ok()) overall_status = new_status + // Use: + // overall_status.Update(new_status); + // + // Style guide exception for rvalue reference granted in CL 153567220. + void Update(const Status& new_status); + void Update(Status&& new_status); + + // Returns true if the Status is OK. + ABSL_MUST_USE_RESULT bool ok() const; + + // Returns the (canonical) error code. + absl::StatusCode code() const; + + // Returns the raw (canonical) error code which could be out of the range of + // the local `absl::StatusCode` enum. NOTE: This should only be called when + // converting to wire format. Use `code` for error handling. + int raw_code() const; + + // Returns the error message. Note: prefer ToString() for debug logging. + // This message rarely describes the error code. It is not unusual for the + // error message to be the empty string. + absl::string_view message() const; + + friend bool operator==(const Status&, const Status&); + friend bool operator!=(const Status&, const Status&); + + // Returns a combination of the error code name, the message and the payloads. + // You can expect the code name and the message to be substrings of the + // result, and the payloads to be printed by the registered printer extensions + // if they are recognized. + // WARNING: Do not depend on the exact format of the result of `ToString()` + // which is subject to change. + std::string ToString() const; + + // Ignores any errors. This method does nothing except potentially suppress + // complaints from any tools that are checking that errors are not dropped on + // the floor. + void IgnoreError() const; + + // Swap the contents of `a` with `b` + friend void swap(Status& a, Status& b); + + // Payload management APIs + + // Type URL should be unique and follow the naming convention below: + // The idea of type URL comes from `google.protobuf.Any` + // (https://developers.google.com/protocol-buffers/docs/proto3#any). The + // type URL should be globally unique and follow the format of URL + // (https://en.wikipedia.org/wiki/URL). The default type URL for a given + // protobuf message type is "type.googleapis.com/packagename.messagename". For + // other custom wire formats, users should define the format of type URL in a + // similar practice so as to minimize the chance of conflict between type + // URLs. Users should make sure that the type URL can be mapped to a concrete + // C++ type if they want to deserialize the payload and read it effectively. + + // Gets the payload based for `type_url` key, if it is present. + absl::optional<absl::Cord> GetPayload(absl::string_view type_url) const; + + // Sets the payload for `type_url` key for a non-ok status, overwriting any + // existing payload for `type_url`. + // + // NOTE: Does nothing if the Status is ok. + void SetPayload(absl::string_view type_url, absl::Cord payload); + + // Erases the payload corresponding to the `type_url` key. Returns true if + // the payload was present. + bool ErasePayload(absl::string_view type_url); + + // Iterates over the stored payloads and calls `visitor(type_key, payload)` + // for each one. + // + // NOTE: The order of calls to `visitor` is not specified and may change at + // any time. + // + // NOTE: Any mutation on the same 'Status' object during visitation is + // forbidden and could result in undefined behavior. + void ForEachPayload( + const std::function<void(absl::string_view, const absl::Cord&)>& visitor) + const; + + private: + friend Status CancelledError(); + + // Creates a status in the canonical error space with the specified + // code, and an empty error message. + explicit Status(absl::StatusCode code); + + static void UnrefNonInlined(uintptr_t rep); + static void Ref(uintptr_t rep); + static void Unref(uintptr_t rep); + + // REQUIRES: !ok() + // Ensures rep_ is not shared with any other Status. + void PrepareToModify(); + + const status_internal::Payloads* GetPayloads() const; + status_internal::Payloads* GetPayloads(); + + // Takes ownership of payload. + static uintptr_t NewRep(absl::StatusCode code, absl::string_view msg, + std::unique_ptr<status_internal::Payloads> payload); + static bool EqualsSlow(const absl::Status& a, const absl::Status& b); + + // MSVC 14.0 limitation requires the const. + static constexpr const char kMovedFromString[] = + "Status accessed after move."; + + static const std::string* EmptyString(); + static const std::string* MovedFromString(); + + // Returns whether rep contains an inlined representation. + // See rep_ for details. + static bool IsInlined(uintptr_t rep); + + // Indicates whether this Status was the rhs of a move operation. See rep_ + // for details. + static bool IsMovedFrom(uintptr_t rep); + static uintptr_t MovedFromRep(); + + // Convert between error::Code and the inlined uintptr_t representation used + // by rep_. See rep_ for details. + static uintptr_t CodeToInlinedRep(absl::StatusCode code); + static absl::StatusCode InlinedRepToCode(uintptr_t rep); + + // Converts between StatusRep* and the external uintptr_t representation used + // by rep_. See rep_ for details. + static uintptr_t PointerToRep(status_internal::StatusRep* r); + static status_internal::StatusRep* RepToPointer(uintptr_t r); + + // Returns string for non-ok Status. + std::string ToStringSlow() const; + + // Status supports two different representations. + // - When the low bit is off it is an inlined representation. + // It uses the canonical error space, no message or payload. + // The error code is (rep_ >> 2). + // The (rep_ & 2) bit is the "moved from" indicator, used in IsMovedFrom(). + // - When the low bit is on it is an external representation. + // In this case all the data comes from a heap allocated Rep object. + // (rep_ - 1) is a status_internal::StatusRep* pointer to that structure. + uintptr_t rep_; +}; + +// Returns an OK status, equivalent to a default constructed instance. +Status OkStatus(); + +// Prints a human-readable representation of `x` to `os`. +std::ostream& operator<<(std::ostream& os, const Status& x); + +// ----------------------------------------------------------------- +// Implementation details follow + +inline Status::Status() : rep_(CodeToInlinedRep(absl::StatusCode::kOk)) {} + +inline Status::Status(absl::StatusCode code) : rep_(CodeToInlinedRep(code)) {} + +inline Status::Status(const Status& x) : rep_(x.rep_) { Ref(rep_); } + +inline Status& Status::operator=(const Status& x) { + uintptr_t old_rep = rep_; + if (x.rep_ != old_rep) { + Ref(x.rep_); + rep_ = x.rep_; + Unref(old_rep); + } + return *this; +} + +inline Status::Status(Status&& x) noexcept : rep_(x.rep_) { + x.rep_ = MovedFromRep(); +} + +inline Status& Status::operator=(Status&& x) { + uintptr_t old_rep = rep_; + rep_ = x.rep_; + x.rep_ = MovedFromRep(); + Unref(old_rep); + return *this; +} + +inline void Status::Update(const Status& new_status) { + if (ok()) { + *this = new_status; + } +} + +inline void Status::Update(Status&& new_status) { + if (ok()) { + *this = std::move(new_status); + } +} + +inline Status::~Status() { Unref(rep_); } + +inline bool Status::ok() const { + return rep_ == CodeToInlinedRep(absl::StatusCode::kOk); +} + +inline absl::string_view Status::message() const { + return !IsInlined(rep_) + ? RepToPointer(rep_)->message + : (IsMovedFrom(rep_) ? absl::string_view(kMovedFromString) + : absl::string_view()); +} + +inline bool operator==(const Status& lhs, const Status& rhs) { + return lhs.rep_ == rhs.rep_ || Status::EqualsSlow(lhs, rhs); +} + +inline bool operator!=(const Status& lhs, const Status& rhs) { + return !(lhs == rhs); +} + +inline std::string Status::ToString() const { + return ok() ? "OK" : ToStringSlow(); +} + +inline void Status::IgnoreError() const { + // no-op +} + +inline void swap(absl::Status& a, absl::Status& b) { + using std::swap; + swap(a.rep_, b.rep_); +} + +inline const status_internal::Payloads* Status::GetPayloads() const { + return IsInlined(rep_) ? nullptr : RepToPointer(rep_)->payloads.get(); +} + +inline status_internal::Payloads* Status::GetPayloads() { + return IsInlined(rep_) ? nullptr : RepToPointer(rep_)->payloads.get(); +} + +inline bool Status::IsInlined(uintptr_t rep) { return (rep & 1) == 0; } + +inline bool Status::IsMovedFrom(uintptr_t rep) { + return IsInlined(rep) && (rep & 2) != 0; +} + +inline uintptr_t Status::MovedFromRep() { + return CodeToInlinedRep(absl::StatusCode::kInternal) | 2; +} + +inline uintptr_t Status::CodeToInlinedRep(absl::StatusCode code) { + return static_cast<uintptr_t>(code) << 2; +} + +inline absl::StatusCode Status::InlinedRepToCode(uintptr_t rep) { + assert(IsInlined(rep)); + return static_cast<absl::StatusCode>(rep >> 2); +} + +inline status_internal::StatusRep* Status::RepToPointer(uintptr_t rep) { + assert(!IsInlined(rep)); + return reinterpret_cast<status_internal::StatusRep*>(rep - 1); +} + +inline uintptr_t Status::PointerToRep(status_internal::StatusRep* rep) { + return reinterpret_cast<uintptr_t>(rep) + 1; +} + +inline void Status::Ref(uintptr_t rep) { + if (!IsInlined(rep)) { + RepToPointer(rep)->ref.fetch_add(1, std::memory_order_relaxed); + } +} + +inline void Status::Unref(uintptr_t rep) { + if (!IsInlined(rep)) { + UnrefNonInlined(rep); + } +} + +inline Status OkStatus() { return Status(); } + +// Each of the functions below creates a Status object with a particular error +// code and the given message. The error code of the returned status object +// matches the name of the function. +Status AbortedError(absl::string_view message); +Status AlreadyExistsError(absl::string_view message); +Status CancelledError(absl::string_view message); +Status DataLossError(absl::string_view message); +Status DeadlineExceededError(absl::string_view message); +Status FailedPreconditionError(absl::string_view message); +Status InternalError(absl::string_view message); +Status InvalidArgumentError(absl::string_view message); +Status NotFoundError(absl::string_view message); +Status OutOfRangeError(absl::string_view message); +Status PermissionDeniedError(absl::string_view message); +Status ResourceExhaustedError(absl::string_view message); +Status UnauthenticatedError(absl::string_view message); +Status UnavailableError(absl::string_view message); +Status UnimplementedError(absl::string_view message); +Status UnknownError(absl::string_view message); + +// Creates a `Status` object with the `absl::StatusCode::kCancelled` error code +// and an empty message. It is provided only for efficiency, given that +// message-less kCancelled errors are common in the infrastructure. +inline Status CancelledError() { return Status(absl::StatusCode::kCancelled); } + +// Each of the functions below returns true if the given status matches the +// error code implied by the function's name. +ABSL_MUST_USE_RESULT bool IsAborted(const Status& status); +ABSL_MUST_USE_RESULT bool IsAlreadyExists(const Status& status); +ABSL_MUST_USE_RESULT bool IsCancelled(const Status& status); +ABSL_MUST_USE_RESULT bool IsDataLoss(const Status& status); +ABSL_MUST_USE_RESULT bool IsDeadlineExceeded(const Status& status); +ABSL_MUST_USE_RESULT bool IsFailedPrecondition(const Status& status); +ABSL_MUST_USE_RESULT bool IsInternal(const Status& status); +ABSL_MUST_USE_RESULT bool IsInvalidArgument(const Status& status); +ABSL_MUST_USE_RESULT bool IsNotFound(const Status& status); +ABSL_MUST_USE_RESULT bool IsOutOfRange(const Status& status); +ABSL_MUST_USE_RESULT bool IsPermissionDenied(const Status& status); +ABSL_MUST_USE_RESULT bool IsResourceExhausted(const Status& status); +ABSL_MUST_USE_RESULT bool IsUnauthenticated(const Status& status); +ABSL_MUST_USE_RESULT bool IsUnavailable(const Status& status); +ABSL_MUST_USE_RESULT bool IsUnimplemented(const Status& status); +ABSL_MUST_USE_RESULT bool IsUnknown(const Status& status); + +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_STATUS_STATUS_H_
diff --git a/third_party/abseil-cpp/absl/status/status_payload_printer.cc b/third_party/abseil-cpp/absl/status/status_payload_printer.cc new file mode 100644 index 0000000..ad96d76 --- /dev/null +++ b/third_party/abseil-cpp/absl/status/status_payload_printer.cc
@@ -0,0 +1,43 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#include "absl/status/status_payload_printer.h" + +#include <atomic> + +#include "absl/base/attributes.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace status_internal { + +namespace { +// Tried constant initialized global variable but it doesn't work with Lexan +// (MSVC's `std::atomic` has trouble constant initializing). +std::atomic<StatusPayloadPrinter>& GetStatusPayloadPrinterStorage() { + ABSL_CONST_INIT static std::atomic<StatusPayloadPrinter> instance{nullptr}; + return instance; +} +} // namespace + +void SetStatusPayloadPrinter(StatusPayloadPrinter printer) { + GetStatusPayloadPrinterStorage().store(printer, std::memory_order_relaxed); +} + +StatusPayloadPrinter GetStatusPayloadPrinter() { + return GetStatusPayloadPrinterStorage().load(std::memory_order_relaxed); +} + +} // namespace status_internal +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/status/status_payload_printer.h b/third_party/abseil-cpp/absl/status/status_payload_printer.h new file mode 100644 index 0000000..5e0937f6 --- /dev/null +++ b/third_party/abseil-cpp/absl/status/status_payload_printer.h
@@ -0,0 +1,51 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef ABSL_STATUS_STATUS_PAYLOAD_PRINTER_H_ +#define ABSL_STATUS_STATUS_PAYLOAD_PRINTER_H_ + +#include <string> + +#include "absl/strings/cord.h" +#include "absl/strings/string_view.h" +#include "absl/types/optional.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace status_internal { + +// By default, `Status::ToString` and `operator<<(Status)` print a payload by +// dumping the type URL and the raw bytes. To help debugging, we provide an +// extension point, which is a global printer function that can be set by users +// to specify how to print payloads. The function takes the type URL and the +// payload as input, and should return a valid human-readable string on success +// or `absl::nullopt` on failure (in which case it falls back to the default +// approach of printing the raw bytes). +// NOTE: This is an internal API and the design is subject to change in the +// future in a non-backward-compatible way. Since it's only meant for debugging +// purpose, you should not rely on it in any critical logic. +using StatusPayloadPrinter = absl::optional<std::string> (*)(absl::string_view, + const absl::Cord&); + +// Sets the global payload printer. Only one printer should be set per process. +// If multiple printers are set, it's undefined which one will be used. +void SetStatusPayloadPrinter(StatusPayloadPrinter); + +// Returns the global payload printer if previously set, otherwise `nullptr`. +StatusPayloadPrinter GetStatusPayloadPrinter(); + +} // namespace status_internal +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_STATUS_STATUS_PAYLOAD_PRINTER_H_
diff --git a/third_party/abseil-cpp/absl/status/status_test.cc b/third_party/abseil-cpp/absl/status/status_test.cc new file mode 100644 index 0000000..ca9488a --- /dev/null +++ b/third_party/abseil-cpp/absl/status/status_test.cc
@@ -0,0 +1,458 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/status/status.h" + +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "absl/strings/str_cat.h" + +namespace { + +using ::testing::Eq; +using ::testing::HasSubstr; +using ::testing::Optional; +using ::testing::UnorderedElementsAreArray; + +TEST(StatusCode, InsertionOperator) { + const absl::StatusCode code = absl::StatusCode::kUnknown; + std::ostringstream oss; + oss << code; + EXPECT_EQ(oss.str(), absl::StatusCodeToString(code)); +} + +// This structure holds the details for testing a single error code, +// its creator, and its classifier. +struct ErrorTest { + absl::StatusCode code; + using Creator = absl::Status (*)(absl::string_view); + using Classifier = bool (*)(const absl::Status&); + Creator creator; + Classifier classifier; +}; + +constexpr ErrorTest kErrorTests[]{ + {absl::StatusCode::kCancelled, absl::CancelledError, absl::IsCancelled}, + {absl::StatusCode::kUnknown, absl::UnknownError, absl::IsUnknown}, + {absl::StatusCode::kInvalidArgument, absl::InvalidArgumentError, + absl::IsInvalidArgument}, + {absl::StatusCode::kDeadlineExceeded, absl::DeadlineExceededError, + absl::IsDeadlineExceeded}, + {absl::StatusCode::kNotFound, absl::NotFoundError, absl::IsNotFound}, + {absl::StatusCode::kAlreadyExists, absl::AlreadyExistsError, + absl::IsAlreadyExists}, + {absl::StatusCode::kPermissionDenied, absl::PermissionDeniedError, + absl::IsPermissionDenied}, + {absl::StatusCode::kResourceExhausted, absl::ResourceExhaustedError, + absl::IsResourceExhausted}, + {absl::StatusCode::kFailedPrecondition, absl::FailedPreconditionError, + absl::IsFailedPrecondition}, + {absl::StatusCode::kAborted, absl::AbortedError, absl::IsAborted}, + {absl::StatusCode::kOutOfRange, absl::OutOfRangeError, absl::IsOutOfRange}, + {absl::StatusCode::kUnimplemented, absl::UnimplementedError, + absl::IsUnimplemented}, + {absl::StatusCode::kInternal, absl::InternalError, absl::IsInternal}, + {absl::StatusCode::kUnavailable, absl::UnavailableError, + absl::IsUnavailable}, + {absl::StatusCode::kDataLoss, absl::DataLossError, absl::IsDataLoss}, + {absl::StatusCode::kUnauthenticated, absl::UnauthenticatedError, + absl::IsUnauthenticated}, +}; + +TEST(Status, CreateAndClassify) { + for (const auto& test : kErrorTests) { + SCOPED_TRACE(absl::StatusCodeToString(test.code)); + + // Ensure that the creator does, in fact, create status objects with the + // expected error code and message. + std::string message = + absl::StrCat("error code ", test.code, " test message"); + absl::Status status = test.creator(message); + EXPECT_EQ(test.code, status.code()); + EXPECT_EQ(message, status.message()); + + // Ensure that the classifier returns true for a status produced by the + // creator. + EXPECT_TRUE(test.classifier(status)); + + // Ensure that the classifier returns false for status with a different + // code. + for (const auto& other : kErrorTests) { + if (other.code != test.code) { + EXPECT_FALSE(test.classifier(absl::Status(other.code, ""))) + << " other.code = " << other.code; + } + } + } +} + +TEST(Status, DefaultConstructor) { + absl::Status status; + EXPECT_TRUE(status.ok()); + EXPECT_EQ(absl::StatusCode::kOk, status.code()); + EXPECT_EQ("", status.message()); +} + +TEST(Status, OkStatus) { + absl::Status status = absl::OkStatus(); + EXPECT_TRUE(status.ok()); + EXPECT_EQ(absl::StatusCode::kOk, status.code()); + EXPECT_EQ("", status.message()); +} + +TEST(Status, ConstructorWithCodeMessage) { + { + absl::Status status(absl::StatusCode::kCancelled, ""); + EXPECT_FALSE(status.ok()); + EXPECT_EQ(absl::StatusCode::kCancelled, status.code()); + EXPECT_EQ("", status.message()); + } + { + absl::Status status(absl::StatusCode::kInternal, "message"); + EXPECT_FALSE(status.ok()); + EXPECT_EQ(absl::StatusCode::kInternal, status.code()); + EXPECT_EQ("message", status.message()); + } +} + +TEST(Status, ConstructOutOfRangeCode) { + const int kRawCode = 9999; + absl::Status status(static_cast<absl::StatusCode>(kRawCode), ""); + EXPECT_EQ(absl::StatusCode::kUnknown, status.code()); + EXPECT_EQ(kRawCode, status.raw_code()); +} + +constexpr char kUrl1[] = "url.payload.1"; +constexpr char kUrl2[] = "url.payload.2"; +constexpr char kUrl3[] = "url.payload.3"; +constexpr char kUrl4[] = "url.payload.xx"; + +constexpr char kPayload1[] = "aaaaa"; +constexpr char kPayload2[] = "bbbbb"; +constexpr char kPayload3[] = "ccccc"; + +using PayloadsVec = std::vector<std::pair<std::string, absl::Cord>>; + +TEST(Status, TestGetSetPayload) { + absl::Status ok_status = absl::OkStatus(); + ok_status.SetPayload(kUrl1, absl::Cord(kPayload1)); + ok_status.SetPayload(kUrl2, absl::Cord(kPayload2)); + + EXPECT_FALSE(ok_status.GetPayload(kUrl1)); + EXPECT_FALSE(ok_status.GetPayload(kUrl2)); + + absl::Status bad_status(absl::StatusCode::kInternal, "fail"); + bad_status.SetPayload(kUrl1, absl::Cord(kPayload1)); + bad_status.SetPayload(kUrl2, absl::Cord(kPayload2)); + + EXPECT_THAT(bad_status.GetPayload(kUrl1), Optional(Eq(kPayload1))); + EXPECT_THAT(bad_status.GetPayload(kUrl2), Optional(Eq(kPayload2))); + + EXPECT_FALSE(bad_status.GetPayload(kUrl3)); + + bad_status.SetPayload(kUrl1, absl::Cord(kPayload3)); + EXPECT_THAT(bad_status.GetPayload(kUrl1), Optional(Eq(kPayload3))); + + // Testing dynamically generated type_url + bad_status.SetPayload(absl::StrCat(kUrl1, ".1"), absl::Cord(kPayload1)); + EXPECT_THAT(bad_status.GetPayload(absl::StrCat(kUrl1, ".1")), + Optional(Eq(kPayload1))); +} + +TEST(Status, TestErasePayload) { + absl::Status bad_status(absl::StatusCode::kInternal, "fail"); + bad_status.SetPayload(kUrl1, absl::Cord(kPayload1)); + bad_status.SetPayload(kUrl2, absl::Cord(kPayload2)); + bad_status.SetPayload(kUrl3, absl::Cord(kPayload3)); + + EXPECT_FALSE(bad_status.ErasePayload(kUrl4)); + + EXPECT_TRUE(bad_status.GetPayload(kUrl2)); + EXPECT_TRUE(bad_status.ErasePayload(kUrl2)); + EXPECT_FALSE(bad_status.GetPayload(kUrl2)); + EXPECT_FALSE(bad_status.ErasePayload(kUrl2)); + + EXPECT_TRUE(bad_status.ErasePayload(kUrl1)); + EXPECT_TRUE(bad_status.ErasePayload(kUrl3)); + + bad_status.SetPayload(kUrl1, absl::Cord(kPayload1)); + EXPECT_TRUE(bad_status.ErasePayload(kUrl1)); +} + +TEST(Status, TestComparePayloads) { + absl::Status bad_status1(absl::StatusCode::kInternal, "fail"); + bad_status1.SetPayload(kUrl1, absl::Cord(kPayload1)); + bad_status1.SetPayload(kUrl2, absl::Cord(kPayload2)); + bad_status1.SetPayload(kUrl3, absl::Cord(kPayload3)); + + absl::Status bad_status2(absl::StatusCode::kInternal, "fail"); + bad_status2.SetPayload(kUrl2, absl::Cord(kPayload2)); + bad_status2.SetPayload(kUrl3, absl::Cord(kPayload3)); + bad_status2.SetPayload(kUrl1, absl::Cord(kPayload1)); + + EXPECT_EQ(bad_status1, bad_status2); +} + +TEST(Status, TestComparePayloadsAfterErase) { + absl::Status payload_status(absl::StatusCode::kInternal, ""); + payload_status.SetPayload(kUrl1, absl::Cord(kPayload1)); + payload_status.SetPayload(kUrl2, absl::Cord(kPayload2)); + + absl::Status empty_status(absl::StatusCode::kInternal, ""); + + // Different payloads, not equal + EXPECT_NE(payload_status, empty_status); + EXPECT_TRUE(payload_status.ErasePayload(kUrl1)); + + // Still Different payloads, still not equal. + EXPECT_NE(payload_status, empty_status); + EXPECT_TRUE(payload_status.ErasePayload(kUrl2)); + + // Both empty payloads, should be equal + EXPECT_EQ(payload_status, empty_status); +} + +PayloadsVec AllVisitedPayloads(const absl::Status& s) { + PayloadsVec result; + + s.ForEachPayload([&](absl::string_view type_url, const absl::Cord& payload) { + result.push_back(std::make_pair(std::string(type_url), payload)); + }); + + return result; +} + +TEST(Status, TestForEachPayload) { + absl::Status bad_status(absl::StatusCode::kInternal, "fail"); + bad_status.SetPayload(kUrl1, absl::Cord(kPayload1)); + bad_status.SetPayload(kUrl2, absl::Cord(kPayload2)); + bad_status.SetPayload(kUrl3, absl::Cord(kPayload3)); + + int count = 0; + + bad_status.ForEachPayload( + [&count](absl::string_view, const absl::Cord&) { ++count; }); + + EXPECT_EQ(count, 3); + + PayloadsVec expected_payloads = {{kUrl1, absl::Cord(kPayload1)}, + {kUrl2, absl::Cord(kPayload2)}, + {kUrl3, absl::Cord(kPayload3)}}; + + // Test that we visit all the payloads in the status. + PayloadsVec visited_payloads = AllVisitedPayloads(bad_status); + EXPECT_THAT(visited_payloads, UnorderedElementsAreArray(expected_payloads)); + + // Test that visitation order is not consistent between run. + std::vector<absl::Status> scratch; + while (true) { + scratch.emplace_back(absl::StatusCode::kInternal, "fail"); + + scratch.back().SetPayload(kUrl1, absl::Cord(kPayload1)); + scratch.back().SetPayload(kUrl2, absl::Cord(kPayload2)); + scratch.back().SetPayload(kUrl3, absl::Cord(kPayload3)); + + if (AllVisitedPayloads(scratch.back()) != visited_payloads) { + break; + } + } +} + +TEST(Status, ToString) { + absl::Status s(absl::StatusCode::kInternal, "fail"); + EXPECT_EQ("INTERNAL: fail", s.ToString()); + s.SetPayload("foo", absl::Cord("bar")); + EXPECT_EQ("INTERNAL: fail [foo='bar']", s.ToString()); + s.SetPayload("bar", absl::Cord("\377")); + EXPECT_THAT(s.ToString(), + AllOf(HasSubstr("INTERNAL: fail"), HasSubstr("[foo='bar']"), + HasSubstr("[bar='\\xff']"))); +} + +absl::Status EraseAndReturn(const absl::Status& base) { + absl::Status copy = base; + EXPECT_TRUE(copy.ErasePayload(kUrl1)); + return copy; +} + +TEST(Status, CopyOnWriteForErasePayload) { + { + absl::Status base(absl::StatusCode::kInvalidArgument, "fail"); + base.SetPayload(kUrl1, absl::Cord(kPayload1)); + EXPECT_TRUE(base.GetPayload(kUrl1).has_value()); + absl::Status copy = EraseAndReturn(base); + EXPECT_TRUE(base.GetPayload(kUrl1).has_value()); + EXPECT_FALSE(copy.GetPayload(kUrl1).has_value()); + } + { + absl::Status base(absl::StatusCode::kInvalidArgument, "fail"); + base.SetPayload(kUrl1, absl::Cord(kPayload1)); + absl::Status copy = base; + + EXPECT_TRUE(base.GetPayload(kUrl1).has_value()); + EXPECT_TRUE(copy.GetPayload(kUrl1).has_value()); + + EXPECT_TRUE(base.ErasePayload(kUrl1)); + + EXPECT_FALSE(base.GetPayload(kUrl1).has_value()); + EXPECT_TRUE(copy.GetPayload(kUrl1).has_value()); + } +} + +TEST(Status, CopyConstructor) { + { + absl::Status status; + absl::Status copy(status); + EXPECT_EQ(copy, status); + } + { + absl::Status status(absl::StatusCode::kInvalidArgument, "message"); + absl::Status copy(status); + EXPECT_EQ(copy, status); + } + { + absl::Status status(absl::StatusCode::kInvalidArgument, "message"); + status.SetPayload(kUrl1, absl::Cord(kPayload1)); + absl::Status copy(status); + EXPECT_EQ(copy, status); + } +} + +TEST(Status, CopyAssignment) { + absl::Status assignee; + { + absl::Status status; + assignee = status; + EXPECT_EQ(assignee, status); + } + { + absl::Status status(absl::StatusCode::kInvalidArgument, "message"); + assignee = status; + EXPECT_EQ(assignee, status); + } + { + absl::Status status(absl::StatusCode::kInvalidArgument, "message"); + status.SetPayload(kUrl1, absl::Cord(kPayload1)); + assignee = status; + EXPECT_EQ(assignee, status); + } +} + +TEST(Status, CopyAssignmentIsNotRef) { + const absl::Status status_orig(absl::StatusCode::kInvalidArgument, "message"); + absl::Status status_copy = status_orig; + EXPECT_EQ(status_orig, status_copy); + status_copy.SetPayload(kUrl1, absl::Cord(kPayload1)); + EXPECT_NE(status_orig, status_copy); +} + +TEST(Status, MoveConstructor) { + { + absl::Status status; + absl::Status copy(absl::Status{}); + EXPECT_EQ(copy, status); + } + { + absl::Status status(absl::StatusCode::kInvalidArgument, "message"); + absl::Status copy( + absl::Status(absl::StatusCode::kInvalidArgument, "message")); + EXPECT_EQ(copy, status); + } + { + absl::Status status(absl::StatusCode::kInvalidArgument, "message"); + status.SetPayload(kUrl1, absl::Cord(kPayload1)); + absl::Status copy1(status); + absl::Status copy2(std::move(status)); + EXPECT_EQ(copy1, copy2); + } +} + +TEST(Status, MoveAssignment) { + absl::Status assignee; + { + absl::Status status; + assignee = absl::Status(); + EXPECT_EQ(assignee, status); + } + { + absl::Status status(absl::StatusCode::kInvalidArgument, "message"); + assignee = absl::Status(absl::StatusCode::kInvalidArgument, "message"); + EXPECT_EQ(assignee, status); + } + { + absl::Status status(absl::StatusCode::kInvalidArgument, "message"); + status.SetPayload(kUrl1, absl::Cord(kPayload1)); + absl::Status copy(status); + assignee = std::move(status); + EXPECT_EQ(assignee, copy); + } +} + +TEST(Status, Update) { + absl::Status s; + s.Update(absl::OkStatus()); + EXPECT_TRUE(s.ok()); + const absl::Status a(absl::StatusCode::kCancelled, "message"); + s.Update(a); + EXPECT_EQ(s, a); + const absl::Status b(absl::StatusCode::kInternal, "other message"); + s.Update(b); + EXPECT_EQ(s, a); + s.Update(absl::OkStatus()); + EXPECT_EQ(s, a); + EXPECT_FALSE(s.ok()); +} + +TEST(Status, Equality) { + absl::Status ok; + absl::Status no_payload = absl::CancelledError("no payload"); + absl::Status one_payload = absl::InvalidArgumentError("one payload"); + one_payload.SetPayload(kUrl1, absl::Cord(kPayload1)); + absl::Status two_payloads = one_payload; + two_payloads.SetPayload(kUrl2, absl::Cord(kPayload2)); + const std::array<absl::Status, 4> status_arr = {ok, no_payload, one_payload, + two_payloads}; + for (int i = 0; i < status_arr.size(); i++) { + for (int j = 0; j < status_arr.size(); j++) { + if (i == j) { + EXPECT_TRUE(status_arr[i] == status_arr[j]); + EXPECT_FALSE(status_arr[i] != status_arr[j]); + } else { + EXPECT_TRUE(status_arr[i] != status_arr[j]); + EXPECT_FALSE(status_arr[i] == status_arr[j]); + } + } + } +} + +TEST(Status, Swap) { + auto test_swap = [](const absl::Status& s1, const absl::Status& s2) { + absl::Status copy1 = s1, copy2 = s2; + swap(copy1, copy2); + EXPECT_EQ(copy1, s2); + EXPECT_EQ(copy2, s1); + }; + const absl::Status ok; + const absl::Status no_payload(absl::StatusCode::kAlreadyExists, "no payload"); + absl::Status with_payload(absl::StatusCode::kInternal, "with payload"); + with_payload.SetPayload(kUrl1, absl::Cord(kPayload1)); + test_swap(ok, no_payload); + test_swap(no_payload, ok); + test_swap(ok, with_payload); + test_swap(with_payload, ok); + test_swap(no_payload, with_payload); + test_swap(with_payload, no_payload); +} + +} // namespace
diff --git a/third_party/abseil-cpp/absl/strings/BUILD.bazel b/third_party/abseil-cpp/absl/strings/BUILD.bazel index 20511a3..e72db82 100644 --- a/third_party/abseil-cpp/absl/strings/BUILD.bazel +++ b/third_party/abseil-cpp/absl/strings/BUILD.bazel
@@ -13,11 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", - "ABSL_EXCEPTIONS_FLAG", - "ABSL_EXCEPTIONS_FLAG_LINKOPTS", "ABSL_TEST_COPTS", ) @@ -26,7 +25,7 @@ features = ["parse_headers"], ) -licenses(["notice"]) # Apache 2.0 +licenses(["notice"]) cc_library( name = "strings", @@ -73,6 +72,7 @@ "//absl/base:config", "//absl/base:core_headers", "//absl/base:endian", + "//absl/base:raw_logging_internal", "//absl/base:throw_delegate", "//absl/memory", "//absl/meta:type_traits", @@ -83,19 +83,23 @@ cc_library( name = "internal", srcs = [ + "internal/escaping.cc", "internal/ostringstream.cc", "internal/utf8.cc", ], hdrs = [ "internal/char_map.h", + "internal/escaping.h", "internal/ostringstream.h", "internal/resize_uninitialized.h", "internal/utf8.h", ], copts = ABSL_DEFAULT_COPTS, deps = [ + "//absl/base:config", "//absl/base:core_headers", "//absl/base:endian", + "//absl/base:raw_logging_internal", "//absl/meta:type_traits", ], ) @@ -122,6 +126,7 @@ copts = ABSL_TEST_COPTS, visibility = ["//visibility:private"], deps = [ + ":cord", ":strings", "//absl/base:core_headers", "//absl/container:fixed_array", @@ -140,7 +145,7 @@ visibility = ["//visibility:private"], deps = [ ":strings", - "//absl/base", + "//absl/base:raw_logging_internal", "@com_github_google_benchmark//:benchmark_main", ], ) @@ -225,8 +230,8 @@ visibility = ["//visibility:private"], deps = [ ":strings", - "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "@com_github_google_benchmark//:benchmark_main", ], ) @@ -235,8 +240,7 @@ name = "string_view_test", size = "small", srcs = ["string_view_test.cc"], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, + copts = ABSL_TEST_COPTS, visibility = ["//visibility:private"], deps = [ ":strings", @@ -247,6 +251,75 @@ ], ) +cc_library( + name = "cord_internal", + hdrs = ["internal/cord_internal.h"], + copts = ABSL_DEFAULT_COPTS, + visibility = ["//visibility:private"], + deps = [ + ":strings", + "//absl/meta:type_traits", + ], +) + +cc_library( + name = "cord", + srcs = [ + "cord.cc", + ], + hdrs = [ + "cord.h", + ], + copts = ABSL_DEFAULT_COPTS, + deps = [ + ":cord_internal", + ":internal", + ":str_format", + ":strings", + "//absl/base", + "//absl/base:base_internal", + "//absl/base:core_headers", + "//absl/base:endian", + "//absl/base:raw_logging_internal", + "//absl/container:fixed_array", + "//absl/container:inlined_vector", + "//absl/functional:function_ref", + "//absl/meta:type_traits", + "//absl/types:optional", + ], +) + +cc_library( + name = "cord_test_helpers", + testonly = 1, + hdrs = [ + "cord_test_helpers.h", + ], + copts = ABSL_DEFAULT_COPTS, + deps = [ + ":cord", + ], +) + +cc_test( + name = "cord_test", + size = "medium", + srcs = ["cord_test.cc"], + copts = ABSL_TEST_COPTS, + visibility = ["//visibility:private"], + deps = [ + ":cord", + ":cord_test_helpers", + ":strings", + "//absl/base", + "//absl/base:config", + "//absl/base:endian", + "//absl/base:raw_logging_internal", + "//absl/container:fixed_array", + "@com_google_googletest//:gtest_main", + ], +) + cc_test( name = "substitute_test", size = "small", @@ -268,7 +341,7 @@ visibility = ["//visibility:private"], deps = [ ":strings", - "//absl/base", + "//absl/base:raw_logging_internal", "@com_github_google_benchmark//:benchmark_main", ], ) @@ -306,7 +379,7 @@ visibility = ["//visibility:private"], deps = [ ":strings", - "//absl/base", + "//absl/base:raw_logging_internal", "@com_github_google_benchmark//:benchmark_main", ], ) @@ -414,8 +487,10 @@ deps = [ ":pow10_helper", ":strings", - "//absl/base", - "//absl/base:core_headers", + "//absl/base:config", + "//absl/base:raw_logging_internal", + "//absl/random", + "//absl/random:distributions", "@com_google_googletest//:gtest_main", ], ) @@ -428,7 +503,9 @@ visibility = ["//visibility:private"], deps = [ ":strings", - "//absl/base", + "//absl/base:raw_logging_internal", + "//absl/random", + "//absl/random:distributions", "@com_github_google_benchmark//:benchmark_main", ], ) @@ -474,7 +551,6 @@ ":pow10_helper", ":str_format", ":strings", - "//absl/base", "@com_google_googletest//:gtest_main", ], ) @@ -488,7 +564,8 @@ copts = ABSL_TEST_COPTS, deps = [ ":strings", - "//absl/base", + "//absl/base:config", + "//absl/base:raw_logging_internal", "@com_google_googletest//:gtest_main", ], ) @@ -503,7 +580,7 @@ copts = ABSL_TEST_COPTS, deps = [ ":strings", - "//absl/base", + "//absl/base:config", "@com_google_googletest//:gtest_main", ], ) @@ -518,7 +595,6 @@ ], deps = [ ":strings", - "//absl/base", "@com_github_google_benchmark//:benchmark_main", ], ) @@ -634,6 +710,7 @@ visibility = ["//visibility:private"], deps = [ ":str_format_internal", + "//absl/base:raw_logging_internal", "//absl/numeric:int128", "@com_google_googletest//:gtest_main", ], @@ -668,6 +745,7 @@ srcs = ["internal/pow10_helper.cc"], hdrs = ["internal/pow10_helper.h"], visibility = ["//visibility:private"], + deps = ["//absl/base:config"], ) cc_test(
diff --git a/third_party/abseil-cpp/absl/strings/BUILD.gn b/third_party/abseil-cpp/absl/strings/BUILD.gn index fa0a46cf..930a1f4 100644 --- a/third_party/abseil-cpp/absl/strings/BUILD.gn +++ b/third_party/abseil-cpp/absl/strings/BUILD.gn
@@ -67,6 +67,7 @@ "../base:config", "../base:core_headers", "../base:endian", + "../base:raw_logging_internal", "../base:throw_delegate", "../memory", "../meta:type_traits", @@ -82,18 +83,22 @@ ] public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] sources = [ + "internal/escaping.cc", "internal/ostringstream.cc", "internal/utf8.cc", ] public = [ "internal/char_map.h", + "internal/escaping.h", "internal/ostringstream.h", "internal/resize_uninitialized.h", "internal/utf8.h", ] deps = [ + "../base:config", "../base:core_headers", "../base:endian", + "../base:raw_logging_internal", "../meta:type_traits", ] } @@ -145,6 +150,61 @@ ] } +source_set("cord_internal") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] + public = [ "internal/cord_internal.h" ] + visibility = [] + visibility += [ ":*" ] + deps = [ + ":strings", + "../meta:type_traits", + ] +} + +source_set("cord") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] + sources = [ "cord.cc" ] + public = [ "cord.h" ] + deps = [ + ":cord_internal", + ":internal", + ":str_format", + ":strings", + "../base", + "../base:base_internal", + "../base:core_headers", + "../base:endian", + "../base:raw_logging_internal", + "../container:fixed_array", + "../container:inlined_vector", + "../functional:function_ref", + "../meta:type_traits", + "../types:optional", + ] +} + +source_set("cord_test_helpers") { + testonly = true + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] + public = [ "cord_test_helpers.h" ] + deps = [ ":cord" ] +} + source_set("pow10_helper") { testonly = true configs -= [ "//build/config/compiler:chromium_code" ] @@ -157,4 +217,5 @@ public = [ "internal/pow10_helper.h" ] visibility = [] visibility += [ ":*" ] + deps = [ "../base:config" ] }
diff --git a/third_party/abseil-cpp/absl/strings/CMakeLists.txt b/third_party/abseil-cpp/absl/strings/CMakeLists.txt index e63eec1..668d722 100644 --- a/third_party/abseil-cpp/absl/strings/CMakeLists.txt +++ b/third_party/abseil-cpp/absl/strings/CMakeLists.txt
@@ -59,10 +59,11 @@ absl::config absl::core_headers absl::endian - absl::throw_delegate - absl::memory - absl::type_traits absl::int128 + absl::memory + absl::raw_logging_internal + absl::throw_delegate + absl::type_traits PUBLIC ) @@ -71,6 +72,8 @@ strings_internal HDRS "internal/char_map.h" + "internal/escaping.cc" + "internal/escaping.h" "internal/ostringstream.h" "internal/resize_uninitialized.h" "internal/utf8.h" @@ -80,8 +83,10 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS + absl::config absl::core_headers absl::endian + absl::raw_logging_internal absl::type_traits ) @@ -160,9 +165,6 @@ "string_view_test.cc" COPTS ${ABSL_TEST_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS absl::strings absl::config @@ -276,9 +278,12 @@ ${ABSL_TEST_COPTS} DEPS absl::strings - absl::base absl::core_headers absl::pow10_helper + absl::config + absl::raw_logging_internal + absl::random_random + absl::random_distributions gmock_main ) @@ -317,7 +322,6 @@ DEPS absl::strings absl::str_format - absl::base absl::pow10_helper gmock_main ) @@ -332,7 +336,8 @@ ${ABSL_TEST_COPTS} DEPS absl::strings - absl::base + absl::config + absl::raw_logging_internal gmock_main ) @@ -347,7 +352,7 @@ ${ABSL_TEST_COPTS} DEPS absl::strings - absl::base + absl::config gmock_main ) @@ -465,6 +470,7 @@ ${ABSL_TEST_COPTS} DEPS absl::str_format_internal + absl::raw_logging_internal absl::int128 gmock_main ) @@ -503,6 +509,8 @@ "internal/pow10_helper.cc" COPTS ${ABSL_TEST_COPTS} + DEPS + absl::config TESTONLY ) @@ -518,3 +526,59 @@ absl::str_format gmock_main ) + +absl_cc_library( + NAME + cord + HDRS + "cord.h" + SRCS + "cord.cc" + "internal/cord_internal.h" + COPTS + ${ABSL_DEFAULT_COPTS} + DEPS + absl::strings_internal + absl::base + absl::base_internal + absl::core_headers + absl::endian + absl::fixed_array + absl::function_ref + absl::inlined_vector + absl::optional + absl::raw_logging_internal + absl::strings + absl::type_traits + PUBLIC +) + +absl_cc_library( + NAME + cord_test_helpers + HDRS + "cord_test_helpers.h" + COPTS + ${ABSL_TEST_COPTS} + DEPS + absl::cord + TESTONLY +) + +absl_cc_test( + NAME + cord_test + SRCS + "cord_test.cc" + COPTS + ${ABSL_TEST_COPTS} + DEPS + absl::cord + absl::strings + absl::base + absl::config + absl::endian + absl::raw_logging_internal + absl::fixed_array + gmock_main +)
diff --git a/third_party/abseil-cpp/absl/strings/ascii.cc b/third_party/abseil-cpp/absl/strings/ascii.cc index 3f7c581f..93bb03e9 100644 --- a/third_party/abseil-cpp/absl/strings/ascii.cc +++ b/third_party/abseil-cpp/absl/strings/ascii.cc
@@ -15,6 +15,7 @@ #include "absl/strings/ascii.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace ascii_internal { // # Table generated by this Python code (bit 0x02 is currently unused): @@ -56,7 +57,7 @@ // of these bits is tightly coupled to this implementation, the individual bits // are not named. Note that bitfields for all characters above ASCII 127 are // zero-initialized. -const unsigned char kPropertyBits[256] = { +ABSL_DLL const unsigned char kPropertyBits[256] = { 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x00 0x40, 0x68, 0x48, 0x48, 0x48, 0x48, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x10 @@ -78,7 +79,7 @@ // Array of characters for the ascii_tolower() function. For values 'A' // through 'Z', return the lower-case character; otherwise, return the // identity of the passed character. -const char kToLower[256] = { +ABSL_DLL const char kToLower[256] = { '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', @@ -116,7 +117,7 @@ // Array of characters for the ascii_toupper() function. For values 'a' // through 'z', return the upper-case character; otherwise, return the // identity of the passed character. -const char kToUpper[256] = { +ABSL_DLL const char kToUpper[256] = { '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', @@ -195,4 +196,5 @@ str->erase(output_it - &(*str)[0]); } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/ascii.h b/third_party/abseil-cpp/absl/strings/ascii.h index f9e4fd1d..b46bc71 100644 --- a/third_party/abseil-cpp/absl/strings/ascii.h +++ b/third_party/abseil-cpp/absl/strings/ascii.h
@@ -56,19 +56,21 @@ #include <string> #include "absl/base/attributes.h" +#include "absl/base/config.h" #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace ascii_internal { // Declaration for an array of bitfields holding character information. -extern const unsigned char kPropertyBits[256]; +ABSL_DLL extern const unsigned char kPropertyBits[256]; // Declaration for the array of characters to upper-case characters. -extern const char kToUpper[256]; +ABSL_DLL extern const char kToUpper[256]; // Declaration for the array of characters to lower-case characters. -extern const char kToLower[256]; +ABSL_DLL extern const char kToLower[256]; } // namespace ascii_internal @@ -234,6 +236,7 @@ // Removes leading, trailing, and consecutive internal whitespace. void RemoveExtraAsciiWhitespace(std::string*); +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_ASCII_H_
diff --git a/third_party/abseil-cpp/absl/strings/charconv.cc b/third_party/abseil-cpp/absl/strings/charconv.cc index bc07e7a..3613a65 100644 --- a/third_party/abseil-cpp/absl/strings/charconv.cc +++ b/third_party/abseil-cpp/absl/strings/charconv.cc
@@ -57,6 +57,7 @@ // narrower mantissas. namespace absl { +ABSL_NAMESPACE_BEGIN namespace { template <typename FloatType> @@ -618,10 +619,10 @@ // Either we failed to parse a hex float after the "0x", or we read // "0xinf" or "0xnan" which we don't want to match. // - // However, a std::string that begins with "0x" also begins with "0", which + // However, a string that begins with "0x" also begins with "0", which // is normally a valid match for the number zero. So we want these // strings to match zero unless fmt_flags is `scientific`. (This flag - // means an exponent is required, which the std::string "0" does not have.) + // means an exponent is required, which the string "0" does not have.) if (fmt_flags == chars_format::scientific) { result.ec = std::errc::invalid_argument; } else { @@ -672,7 +673,6 @@ EncodeResult(calculated, negative, &result, &value); return result; } - return result; } } // namespace @@ -980,4 +980,5 @@ }; } // namespace +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/charconv.h b/third_party/abseil-cpp/absl/strings/charconv.h index 3f5891b..e04be32 100644 --- a/third_party/abseil-cpp/absl/strings/charconv.h +++ b/third_party/abseil-cpp/absl/strings/charconv.h
@@ -17,7 +17,10 @@ #include <system_error> // NOLINT(build/c++11) +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN // Workalike compatibilty version of std::chars_format from C++17. // @@ -110,6 +113,7 @@ return lhs; } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_CHARCONV_H_
diff --git a/third_party/abseil-cpp/absl/strings/charconv_benchmark.cc b/third_party/abseil-cpp/absl/strings/charconv_benchmark.cc index 644b2ab..e8c7371 100644 --- a/third_party/abseil-cpp/absl/strings/charconv_benchmark.cc +++ b/third_party/abseil-cpp/absl/strings/charconv_benchmark.cc
@@ -132,7 +132,7 @@ std::string MakeHardCase(int length) { // The number 1.1521...e-297 is exactly halfway between 12345 * 2**-1000 and // the next larger representable number. The digits of this number are in - // the std::string below. + // the string below. const std::string digits = "1." "152113937042223790993097181572444900347587985074226836242307364987727724"
diff --git a/third_party/abseil-cpp/absl/strings/charconv_test.cc b/third_party/abseil-cpp/absl/strings/charconv_test.cc index b58fad2..9090e9c 100644 --- a/third_party/abseil-cpp/absl/strings/charconv_test.cc +++ b/third_party/abseil-cpp/absl/strings/charconv_test.cc
@@ -511,6 +511,13 @@ EXPECT_EQ(f, std::numeric_limits<float>::max()); } +TEST(FromChars, RegressionTestsFromFuzzer) { + absl::string_view src = "0x21900000p00000000099"; + float f; + auto result = absl::from_chars(src.data(), src.data() + src.size(), f); + EXPECT_EQ(result.ec, std::errc::result_out_of_range); +} + TEST(FromChars, ReturnValuePtr) { // Check that `ptr` points one past the number scanned, even if that number // is not representable.
diff --git a/third_party/abseil-cpp/absl/strings/cord.cc b/third_party/abseil-cpp/absl/strings/cord.cc new file mode 100644 index 0000000..415b239 --- /dev/null +++ b/third_party/abseil-cpp/absl/strings/cord.cc
@@ -0,0 +1,2012 @@ +// Copyright 2020 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/strings/cord.h" + +#include <algorithm> +#include <cstddef> +#include <cstdio> +#include <cstdlib> +#include <iomanip> +#include <limits> +#include <ostream> +#include <sstream> +#include <type_traits> +#include <unordered_set> +#include <vector> + +#include "absl/base/casts.h" +#include "absl/base/internal/raw_logging.h" +#include "absl/base/port.h" +#include "absl/container/fixed_array.h" +#include "absl/strings/escaping.h" +#include "absl/strings/internal/cord_internal.h" +#include "absl/strings/internal/resize_uninitialized.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN + +using ::absl::cord_internal::CordRep; +using ::absl::cord_internal::CordRepConcat; +using ::absl::cord_internal::CordRepExternal; +using ::absl::cord_internal::CordRepSubstring; + +// Various representations that we allow +enum CordRepKind { + CONCAT = 0, + EXTERNAL = 1, + SUBSTRING = 2, + + // We have different tags for different sized flat arrays, + // starting with FLAT + FLAT = 3, +}; + +namespace { + +// Type used with std::allocator for allocating and deallocating +// `CordRepExternal`. std::allocator is used because it opaquely handles the +// different new / delete overloads available on a given platform. +struct alignas(absl::cord_internal::ExternalRepAlignment()) ExternalAllocType { + unsigned char value[absl::cord_internal::ExternalRepAlignment()]; +}; + +// Returns the number of objects to pass in to std::allocator<ExternalAllocType> +// allocate() and deallocate() to create enough room for `CordRepExternal` with +// `releaser_size` bytes on the end. +constexpr size_t GetExternalAllocNumObjects(size_t releaser_size) { + // Be sure to round up since `releaser_size` could be smaller than + // `sizeof(ExternalAllocType)`. + return (sizeof(CordRepExternal) + releaser_size + sizeof(ExternalAllocType) - + 1) / + sizeof(ExternalAllocType); +} + +// Allocates enough memory for `CordRepExternal` and a releaser with size +// `releaser_size` bytes. +void* AllocateExternal(size_t releaser_size) { + return std::allocator<ExternalAllocType>().allocate( + GetExternalAllocNumObjects(releaser_size)); +} + +// Deallocates the memory for a `CordRepExternal` assuming it was allocated with +// a releaser of given size and alignment. +void DeallocateExternal(CordRepExternal* p, size_t releaser_size) { + std::allocator<ExternalAllocType>().deallocate( + reinterpret_cast<ExternalAllocType*>(p), + GetExternalAllocNumObjects(releaser_size)); +} + +// Returns a pointer to the type erased releaser for the given CordRepExternal. +void* GetExternalReleaser(CordRepExternal* rep) { + return rep + 1; +} + +} // namespace + +namespace cord_internal { + +inline CordRepConcat* CordRep::concat() { + assert(tag == CONCAT); + return static_cast<CordRepConcat*>(this); +} + +inline const CordRepConcat* CordRep::concat() const { + assert(tag == CONCAT); + return static_cast<const CordRepConcat*>(this); +} + +inline CordRepSubstring* CordRep::substring() { + assert(tag == SUBSTRING); + return static_cast<CordRepSubstring*>(this); +} + +inline const CordRepSubstring* CordRep::substring() const { + assert(tag == SUBSTRING); + return static_cast<const CordRepSubstring*>(this); +} + +inline CordRepExternal* CordRep::external() { + assert(tag == EXTERNAL); + return static_cast<CordRepExternal*>(this); +} + +inline const CordRepExternal* CordRep::external() const { + assert(tag == EXTERNAL); + return static_cast<const CordRepExternal*>(this); +} + +using CordTreeConstPath = CordTreePath<const CordRep*, MaxCordDepth()>; + +// This type is used to store the list of pending nodes during re-balancing. +// Its maximum size is 2 * MaxCordDepth() because the tree has a maximum +// possible depth of MaxCordDepth() and every concat node along a tree path +// could theoretically be split during rebalancing. +using RebalancingStack = CordTreePath<CordRep*, 2 * MaxCordDepth()>; + +} // namespace cord_internal + +static const size_t kFlatOverhead = offsetof(CordRep, data); + +// Largest and smallest flat node lengths we are willing to allocate +// Flat allocation size is stored in tag, which currently can encode sizes up +// to 4K, encoded as multiple of either 8 or 32 bytes. +// If we allow for larger sizes, we need to change this to 8/64, 16/128, etc. +static constexpr size_t kMaxFlatSize = 4096; +static constexpr size_t kMaxFlatLength = kMaxFlatSize - kFlatOverhead; +static constexpr size_t kMinFlatLength = 32 - kFlatOverhead; + +// Prefer copying blocks of at most this size, otherwise reference count. +static const size_t kMaxBytesToCopy = 511; + +// Helper functions for rounded div, and rounding to exact sizes. +static size_t DivUp(size_t n, size_t m) { return (n + m - 1) / m; } +static size_t RoundUp(size_t n, size_t m) { return DivUp(n, m) * m; } + +// Returns the size to the nearest equal or larger value that can be +// expressed exactly as a tag value. +static size_t RoundUpForTag(size_t size) { + return RoundUp(size, (size <= 1024) ? 8 : 32); +} + +// Converts the allocated size to a tag, rounding down if the size +// does not exactly match a 'tag expressible' size value. The result is +// undefined if the size exceeds the maximum size that can be encoded in +// a tag, i.e., if size is larger than TagToAllocatedSize(<max tag>). +static uint8_t AllocatedSizeToTag(size_t size) { + const size_t tag = (size <= 1024) ? size / 8 : 128 + size / 32 - 1024 / 32; + assert(tag <= std::numeric_limits<uint8_t>::max()); + return tag; +} + +// Converts the provided tag to the corresponding allocated size +static constexpr size_t TagToAllocatedSize(uint8_t tag) { + return (tag <= 128) ? (tag * 8) : (1024 + (tag - 128) * 32); +} + +// Converts the provided tag to the corresponding available data length +static constexpr size_t TagToLength(uint8_t tag) { + return TagToAllocatedSize(tag) - kFlatOverhead; +} + +// Enforce that kMaxFlatSize maps to a well-known exact tag value. +static_assert(TagToAllocatedSize(224) == kMaxFlatSize, "Bad tag logic"); + +constexpr size_t Fibonacci(uint8_t n, const size_t a = 0, const size_t b = 1) { + return n == 0 + ? a + : n == 1 ? b + : Fibonacci(n - 1, b, + (a > (size_t(-1) - b)) ? size_t(-1) : a + b); +} + +// Minimum length required for a given depth tree -- a tree is considered +// balanced if +// length(t) >= kMinLength[depth(t)] +// The node depth is allowed to become larger to reduce rebalancing +// for larger strings (see ShouldRebalance). +constexpr size_t kMinLength[] = { + Fibonacci(2), Fibonacci(3), Fibonacci(4), Fibonacci(5), Fibonacci(6), + Fibonacci(7), Fibonacci(8), Fibonacci(9), Fibonacci(10), Fibonacci(11), + Fibonacci(12), Fibonacci(13), Fibonacci(14), Fibonacci(15), Fibonacci(16), + Fibonacci(17), Fibonacci(18), Fibonacci(19), Fibonacci(20), Fibonacci(21), + Fibonacci(22), Fibonacci(23), Fibonacci(24), Fibonacci(25), Fibonacci(26), + Fibonacci(27), Fibonacci(28), Fibonacci(29), Fibonacci(30), Fibonacci(31), + Fibonacci(32), Fibonacci(33), Fibonacci(34), Fibonacci(35), Fibonacci(36), + Fibonacci(37), Fibonacci(38), Fibonacci(39), Fibonacci(40), Fibonacci(41), + Fibonacci(42), Fibonacci(43), Fibonacci(44), Fibonacci(45), Fibonacci(46), + Fibonacci(47), Fibonacci(48), Fibonacci(49), Fibonacci(50), Fibonacci(51), + Fibonacci(52), Fibonacci(53), Fibonacci(54), Fibonacci(55), Fibonacci(56), + Fibonacci(57), Fibonacci(58), Fibonacci(59), Fibonacci(60), Fibonacci(61), + Fibonacci(62), Fibonacci(63), Fibonacci(64), Fibonacci(65), Fibonacci(66), + Fibonacci(67), Fibonacci(68), Fibonacci(69), Fibonacci(70), Fibonacci(71), + Fibonacci(72), Fibonacci(73), Fibonacci(74), Fibonacci(75), Fibonacci(76), + Fibonacci(77), Fibonacci(78), Fibonacci(79), Fibonacci(80), Fibonacci(81), + Fibonacci(82), Fibonacci(83), Fibonacci(84), Fibonacci(85), Fibonacci(86), + Fibonacci(87), Fibonacci(88), Fibonacci(89), Fibonacci(90), Fibonacci(91), + Fibonacci(92), Fibonacci(93), Fibonacci(94), Fibonacci(95)}; + +static_assert(sizeof(kMinLength) / sizeof(size_t) >= + (cord_internal::MaxCordDepth() + 1), + "Not enough elements in kMinLength array to cover all the " + "supported Cord depth(s)"); + +inline bool ShouldRebalance(const CordRep* node) { + if (node->tag != CONCAT) return false; + + size_t node_depth = node->concat()->depth(); + + if (node_depth <= 15) return false; + + // Rebalancing Cords is expensive, so we reduce how often rebalancing occurs + // by allowing shallow Cords to have twice the depth that the Fibonacci rule + // would otherwise imply. Deep Cords need to follow the rule more closely, + // however to ensure algorithm correctness. We implement this with linear + // interpolation. Cords of depth 16 are treated as though they have a depth + // of 16 * 1/2, and Cords of depth MaxCordDepth() interpolate to + // MaxCordDepth() * 1. + return node->length < + kMinLength[(node_depth * (cord_internal::MaxCordDepth() - 16)) / + (2 * cord_internal::MaxCordDepth() - 16 - node_depth)]; +} + +// Unlike root balancing condition this one is part of the re-balancing +// algorithm and has to be always matching against right depth for +// algorithm to be correct. +inline bool IsNodeBalanced(const CordRep* node) { + if (node->tag != CONCAT) return true; + + size_t node_depth = node->concat()->depth(); + + return node->length >= kMinLength[node_depth]; +} + +static CordRep* Rebalance(CordRep* node); +static void DumpNode(const CordRep* rep, bool include_data, std::ostream* os); +static bool VerifyNode(const CordRep* root, const CordRep* start_node, + bool full_validation); + +static inline CordRep* VerifyTree(CordRep* node) { + // Verification is expensive, so only do it in debug mode. + // Even in debug mode we normally do only light validation. + // If you are debugging Cord itself, you should define the + // macro EXTRA_CORD_VALIDATION, e.g. by adding + // --copt=-DEXTRA_CORD_VALIDATION to the blaze line. +#ifdef EXTRA_CORD_VALIDATION + assert(node == nullptr || VerifyNode(node, node, /*full_validation=*/true)); +#else // EXTRA_CORD_VALIDATION + assert(node == nullptr || VerifyNode(node, node, /*full_validation=*/false)); +#endif // EXTRA_CORD_VALIDATION + static_cast<void>(&VerifyNode); + + return node; +} + +// -------------------------------------------------------------------- +// Memory management + +inline CordRep* Ref(CordRep* rep) { + if (rep != nullptr) { + rep->refcount.Increment(); + } + return rep; +} + +// This internal routine is called from the cold path of Unref below. Keeping it +// in a separate routine allows good inlining of Unref into many profitable call +// sites. However, the call to this function can be highly disruptive to the +// register pressure in those callers. To minimize the cost to callers, we use +// a special LLVM calling convention that preserves most registers. This allows +// the call to this routine in cold paths to not disrupt the caller's register +// pressure. This calling convention is not available on all platforms; we +// intentionally allow LLVM to ignore the attribute rather than attempting to +// hardcode the list of supported platforms. +#if defined(__clang__) && !defined(__i386__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wattributes" +__attribute__((preserve_most)) +#pragma clang diagnostic pop +#endif +static void UnrefInternal(CordRep* rep) { + assert(rep != nullptr); + + cord_internal::RebalancingStack pending; + + while (true) { + if (rep->tag == CONCAT) { + CordRepConcat* rep_concat = rep->concat(); + CordRep* right = rep_concat->right; + if (!right->refcount.Decrement()) { + pending.push_back(right); + } + CordRep* left = rep_concat->left; + delete rep_concat; + rep = nullptr; + if (!left->refcount.Decrement()) { + rep = left; + continue; + } + } else if (rep->tag == EXTERNAL) { + CordRepExternal* rep_external = rep->external(); + absl::string_view data(rep_external->base, rep->length); + void* releaser = GetExternalReleaser(rep_external); + size_t releaser_size = rep_external->releaser_invoker(releaser, data); + rep_external->~CordRepExternal(); + DeallocateExternal(rep_external, releaser_size); + rep = nullptr; + } else if (rep->tag == SUBSTRING) { + CordRepSubstring* rep_substring = rep->substring(); + CordRep* child = rep_substring->child; + delete rep_substring; + rep = nullptr; + if (!child->refcount.Decrement()) { + rep = child; + continue; + } + } else { + // Flat CordReps are allocated and constructed with raw ::operator new + // and placement new, and must be destructed and deallocated + // accordingly. +#if defined(__cpp_sized_deallocation) + size_t size = TagToAllocatedSize(rep->tag); + rep->~CordRep(); + ::operator delete(rep, size); +#else + rep->~CordRep(); + ::operator delete(rep); +#endif + rep = nullptr; + } + + if (!pending.empty()) { + rep = pending.back(); + pending.pop_back(); + } else { + break; + } + } +} + +inline void Unref(CordRep* rep) { + // Fast-path for two common, hot cases: a null rep and a shared root. + if (ABSL_PREDICT_TRUE(rep == nullptr || + rep->refcount.DecrementExpectHighRefcount())) { + return; + } + + UnrefInternal(rep); +} + +// Return the depth of a node +static int Depth(const CordRep* rep) { + if (rep->tag == CONCAT) { + return rep->concat()->depth(); + } else { + return 0; + } +} + +static void SetConcatChildren(CordRepConcat* concat, CordRep* left, + CordRep* right) { + concat->left = left; + concat->right = right; + + concat->length = left->length + right->length; + concat->set_depth(1 + std::max(Depth(left), Depth(right))); + + ABSL_INTERNAL_CHECK(concat->depth() <= cord_internal::MaxCordDepth(), + "Cord depth exceeds max"); + ABSL_INTERNAL_CHECK(concat->length >= left->length, "Cord is too long"); + ABSL_INTERNAL_CHECK(concat->length >= right->length, "Cord is too long"); +} + +// Create a concatenation of the specified nodes. +// Does not change the refcounts of "left" and "right". +// The returned node has a refcount of 1. +static CordRep* RawConcat(CordRep* left, CordRep* right) { + // Avoid making degenerate concat nodes (one child is empty) + if (left == nullptr || left->length == 0) { + Unref(left); + return right; + } + if (right == nullptr || right->length == 0) { + Unref(right); + return left; + } + + CordRepConcat* rep = new CordRepConcat(); + rep->tag = CONCAT; + SetConcatChildren(rep, left, right); + + return rep; +} + +static CordRep* Concat(CordRep* left, CordRep* right) { + CordRep* rep = RawConcat(left, right); + if (rep != nullptr && ShouldRebalance(rep)) { + rep = Rebalance(rep); + } + return VerifyTree(rep); +} + +// Make a balanced tree out of an array of leaf nodes. +static CordRep* MakeBalancedTree(CordRep** reps, size_t n) { + // Make repeated passes over the array, merging adjacent pairs + // until we are left with just a single node. + while (n > 1) { + size_t dst = 0; + for (size_t src = 0; src < n; src += 2) { + if (src + 1 < n) { + reps[dst] = Concat(reps[src], reps[src + 1]); + } else { + reps[dst] = reps[src]; + } + dst++; + } + n = dst; + } + + return reps[0]; +} + +// Create a new flat node. +static CordRep* NewFlat(size_t length_hint) { + if (length_hint <= kMinFlatLength) { + length_hint = kMinFlatLength; + } else if (length_hint > kMaxFlatLength) { + length_hint = kMaxFlatLength; + } + + // Round size up so it matches a size we can exactly express in a tag. + const size_t size = RoundUpForTag(length_hint + kFlatOverhead); + void* const raw_rep = ::operator new(size); + CordRep* rep = new (raw_rep) CordRep(); + rep->tag = AllocatedSizeToTag(size); + return VerifyTree(rep); +} + +// Create a new tree out of the specified array. +// The returned node has a refcount of 1. +static CordRep* NewTree(const char* data, + size_t length, + size_t alloc_hint) { + if (length == 0) return nullptr; + absl::FixedArray<CordRep*> reps((length - 1) / kMaxFlatLength + 1); + size_t n = 0; + do { + const size_t len = std::min(length, kMaxFlatLength); + CordRep* rep = NewFlat(len + alloc_hint); + rep->length = len; + memcpy(rep->data, data, len); + reps[n++] = VerifyTree(rep); + data += len; + length -= len; + } while (length != 0); + return MakeBalancedTree(reps.data(), n); +} + +namespace cord_internal { + +ExternalRepReleaserPair NewExternalWithUninitializedReleaser( + absl::string_view data, ExternalReleaserInvoker invoker, + size_t releaser_size) { + assert(!data.empty()); + + void* raw_rep = AllocateExternal(releaser_size); + auto* rep = new (raw_rep) CordRepExternal(); + rep->length = data.size(); + rep->tag = EXTERNAL; + rep->base = data.data(); + rep->releaser_invoker = invoker; + return {VerifyTree(rep), GetExternalReleaser(rep)}; +} + +} // namespace cord_internal + +static CordRep* NewSubstring(CordRep* child, size_t offset, size_t length) { + // Never create empty substring nodes + if (length == 0) { + Unref(child); + return nullptr; + } else { + CordRepSubstring* rep = new CordRepSubstring(); + assert((offset + length) <= child->length); + rep->length = length; + rep->tag = SUBSTRING; + rep->start = offset; + rep->child = child; + return VerifyTree(rep); + } +} + +// -------------------------------------------------------------------- +// Cord::InlineRep functions + +// This will trigger LNK2005 in MSVC. +#ifndef COMPILER_MSVC +const unsigned char Cord::InlineRep::kMaxInline; +#endif // COMPILER_MSVC + +inline void Cord::InlineRep::set_data(const char* data, size_t n, + bool nullify_tail) { + static_assert(kMaxInline == 15, "set_data is hard-coded for a length of 15"); + + cord_internal::SmallMemmove(data_, data, n, nullify_tail); + data_[kMaxInline] = static_cast<char>(n); +} + +inline char* Cord::InlineRep::set_data(size_t n) { + assert(n <= kMaxInline); + memset(data_, 0, sizeof(data_)); + data_[kMaxInline] = static_cast<char>(n); + return data_; +} + +inline CordRep* Cord::InlineRep::force_tree(size_t extra_hint) { + size_t len = data_[kMaxInline]; + CordRep* result; + if (len > kMaxInline) { + memcpy(&result, data_, sizeof(result)); + } else { + result = NewFlat(len + extra_hint); + result->length = len; + memcpy(result->data, data_, len); + set_tree(result); + } + return result; +} + +inline void Cord::InlineRep::reduce_size(size_t n) { + size_t tag = data_[kMaxInline]; + assert(tag <= kMaxInline); + assert(tag >= n); + tag -= n; + memset(data_ + tag, 0, n); + data_[kMaxInline] = static_cast<char>(tag); +} + +inline void Cord::InlineRep::remove_prefix(size_t n) { + cord_internal::SmallMemmove(data_, data_ + n, data_[kMaxInline] - n); + reduce_size(n); +} + +void Cord::InlineRep::AppendTree(CordRep* tree) { + if (tree == nullptr) return; + size_t len = data_[kMaxInline]; + if (len == 0) { + set_tree(tree); + } else { + set_tree(Concat(force_tree(0), tree)); + } +} + +void Cord::InlineRep::PrependTree(CordRep* tree) { + if (tree == nullptr) return; + size_t len = data_[kMaxInline]; + if (len == 0) { + set_tree(tree); + } else { + set_tree(Concat(tree, force_tree(0))); + } +} + +// Searches for a non-full flat node at the rightmost leaf of the tree. If a +// suitable leaf is found, the function will update the length field for all +// nodes to account for the size increase. The append region address will be +// written to region and the actual size increase will be written to size. +static inline bool PrepareAppendRegion(CordRep* root, char** region, + size_t* size, size_t max_length) { + // Search down the right-hand path for a non-full FLAT node. + CordRep* dst = root; + while (dst->tag == CONCAT && dst->refcount.IsOne()) { + dst = dst->concat()->right; + } + + if (dst->tag < FLAT || !dst->refcount.IsOne()) { + *region = nullptr; + *size = 0; + return false; + } + + const size_t in_use = dst->length; + const size_t capacity = TagToLength(dst->tag); + if (in_use == capacity) { + *region = nullptr; + *size = 0; + return false; + } + + size_t size_increase = std::min(capacity - in_use, max_length); + + // We need to update the length fields for all nodes, including the leaf node. + for (CordRep* rep = root; rep != dst; rep = rep->concat()->right) { + rep->length += size_increase; + } + dst->length += size_increase; + + *region = dst->data + in_use; + *size = size_increase; + return true; +} + +void Cord::InlineRep::GetAppendRegion(char** region, size_t* size, + size_t max_length) { + if (max_length == 0) { + *region = nullptr; + *size = 0; + return; + } + + // Try to fit in the inline buffer if possible. + size_t inline_length = data_[kMaxInline]; + if (inline_length < kMaxInline && max_length <= kMaxInline - inline_length) { + *region = data_ + inline_length; + *size = max_length; + data_[kMaxInline] = static_cast<char>(inline_length + max_length); + return; + } + + CordRep* root = force_tree(max_length); + + if (PrepareAppendRegion(root, region, size, max_length)) { + return; + } + + // Allocate new node. + CordRep* new_node = + NewFlat(std::max(static_cast<size_t>(root->length), max_length)); + new_node->length = + std::min(static_cast<size_t>(TagToLength(new_node->tag)), max_length); + *region = new_node->data; + *size = new_node->length; + replace_tree(Concat(root, new_node)); +} + +void Cord::InlineRep::GetAppendRegion(char** region, size_t* size) { + const size_t max_length = std::numeric_limits<size_t>::max(); + + // Try to fit in the inline buffer if possible. + size_t inline_length = data_[kMaxInline]; + if (inline_length < kMaxInline) { + *region = data_ + inline_length; + *size = kMaxInline - inline_length; + data_[kMaxInline] = kMaxInline; + return; + } + + CordRep* root = force_tree(max_length); + + if (PrepareAppendRegion(root, region, size, max_length)) { + return; + } + + // Allocate new node. + CordRep* new_node = NewFlat(root->length); + new_node->length = TagToLength(new_node->tag); + *region = new_node->data; + *size = new_node->length; + replace_tree(Concat(root, new_node)); +} + +// If the rep is a leaf, this will increment the value at total_mem_usage and +// will return true. +static bool RepMemoryUsageLeaf(const CordRep* rep, size_t* total_mem_usage) { + if (rep->tag >= FLAT) { + *total_mem_usage += TagToAllocatedSize(rep->tag); + return true; + } + if (rep->tag == EXTERNAL) { + *total_mem_usage += sizeof(CordRepConcat) + rep->length; + return true; + } + return false; +} + +void Cord::InlineRep::AssignSlow(const Cord::InlineRep& src) { + ClearSlow(); + + memcpy(data_, src.data_, sizeof(data_)); + if (is_tree()) { + Ref(tree()); + } +} + +void Cord::InlineRep::ClearSlow() { + if (is_tree()) { + Unref(tree()); + } + memset(data_, 0, sizeof(data_)); +} + +// -------------------------------------------------------------------- +// Constructors and destructors + +Cord::Cord(const Cord& src) : contents_(src.contents_) { + Ref(contents_.tree()); // Does nothing if contents_ has embedded data +} + +Cord::Cord(absl::string_view src) { + const size_t n = src.size(); + if (n <= InlineRep::kMaxInline) { + contents_.set_data(src.data(), n, false); + } else { + contents_.set_tree(NewTree(src.data(), n, 0)); + } +} + +// The destruction code is separate so that the compiler can determine +// that it does not need to call the destructor on a moved-from Cord. +void Cord::DestroyCordSlow() { + Unref(VerifyTree(contents_.tree())); +} + +// -------------------------------------------------------------------- +// Mutators + +void Cord::Clear() { + Unref(contents_.clear()); +} + +Cord& Cord::operator=(absl::string_view src) { + + const char* data = src.data(); + size_t length = src.size(); + CordRep* tree = contents_.tree(); + if (length <= InlineRep::kMaxInline) { + // Embed into this->contents_ + contents_.set_data(data, length, true); + Unref(tree); + return *this; + } + if (tree != nullptr && tree->tag >= FLAT && + TagToLength(tree->tag) >= length && tree->refcount.IsOne()) { + // Copy in place if the existing FLAT node is reusable. + memmove(tree->data, data, length); + tree->length = length; + VerifyTree(tree); + return *this; + } + contents_.set_tree(NewTree(data, length, 0)); + Unref(tree); + return *this; +} + +// TODO(sanjay): Move to Cord::InlineRep section of file. For now, +// we keep it here to make diffs easier. +void Cord::InlineRep::AppendArray(const char* src_data, size_t src_size) { + if (src_size == 0) return; // memcpy(_, nullptr, 0) is undefined. + // Try to fit in the inline buffer if possible. + size_t inline_length = data_[kMaxInline]; + if (inline_length < kMaxInline && src_size <= kMaxInline - inline_length) { + // Append new data to embedded array + data_[kMaxInline] = static_cast<char>(inline_length + src_size); + memcpy(data_ + inline_length, src_data, src_size); + return; + } + + CordRep* root = tree(); + + size_t appended = 0; + if (root) { + char* region; + if (PrepareAppendRegion(root, ®ion, &appended, src_size)) { + memcpy(region, src_data, appended); + } + } else { + // It is possible that src_data == data_, but when we transition from an + // InlineRep to a tree we need to assign data_ = root via set_tree. To + // avoid corrupting the source data before we copy it, delay calling + // set_tree until after we've copied data. + // We are going from an inline size to beyond inline size. Make the new size + // either double the inlined size, or the added size + 10%. + const size_t size1 = inline_length * 2 + src_size; + const size_t size2 = inline_length + src_size / 10; + root = NewFlat(std::max<size_t>(size1, size2)); + appended = std::min(src_size, TagToLength(root->tag) - inline_length); + memcpy(root->data, data_, inline_length); + memcpy(root->data + inline_length, src_data, appended); + root->length = inline_length + appended; + set_tree(root); + } + + src_data += appended; + src_size -= appended; + if (src_size == 0) { + return; + } + + // Use new block(s) for any remaining bytes that were not handled above. + // Alloc extra memory only if the right child of the root of the new tree is + // going to be a FLAT node, which will permit further inplace appends. + size_t length = src_size; + if (src_size < kMaxFlatLength) { + // The new length is either + // - old size + 10% + // - old_size + src_size + // This will cause a reasonable conservative step-up in size that is still + // large enough to avoid excessive amounts of small fragments being added. + length = std::max<size_t>(root->length / 10, src_size); + } + set_tree(Concat(root, NewTree(src_data, src_size, length - src_size))); +} + +inline CordRep* Cord::TakeRep() const& { + return Ref(contents_.tree()); +} + +inline CordRep* Cord::TakeRep() && { + CordRep* rep = contents_.tree(); + contents_.clear(); + return rep; +} + +template <typename C> +inline void Cord::AppendImpl(C&& src) { + if (empty()) { + // In case of an empty destination avoid allocating a new node, do not copy + // data. + *this = std::forward<C>(src); + return; + } + + // For short cords, it is faster to copy data if there is room in dst. + const size_t src_size = src.contents_.size(); + if (src_size <= kMaxBytesToCopy) { + CordRep* src_tree = src.contents_.tree(); + if (src_tree == nullptr) { + // src has embedded data. + contents_.AppendArray(src.contents_.data(), src_size); + return; + } + if (src_tree->tag >= FLAT) { + // src tree just has one flat node. + contents_.AppendArray(src_tree->data, src_size); + return; + } + if (&src == this) { + // ChunkIterator below assumes that src is not modified during traversal. + Append(Cord(src)); + return; + } + // TODO(mec): Should we only do this if "dst" has space? + for (absl::string_view chunk : src.Chunks()) { + Append(chunk); + } + return; + } + + contents_.AppendTree(std::forward<C>(src).TakeRep()); +} + +void Cord::Append(const Cord& src) { AppendImpl(src); } + +void Cord::Append(Cord&& src) { AppendImpl(std::move(src)); } + +void Cord::Prepend(const Cord& src) { + CordRep* src_tree = src.contents_.tree(); + if (src_tree != nullptr) { + Ref(src_tree); + contents_.PrependTree(src_tree); + return; + } + + // `src` cord is inlined. + absl::string_view src_contents(src.contents_.data(), src.contents_.size()); + return Prepend(src_contents); +} + +void Cord::Prepend(absl::string_view src) { + if (src.empty()) return; // memcpy(_, nullptr, 0) is undefined. + size_t cur_size = contents_.size(); + if (!contents_.is_tree() && cur_size + src.size() <= InlineRep::kMaxInline) { + // Use embedded storage. + char data[InlineRep::kMaxInline + 1] = {0}; + data[InlineRep::kMaxInline] = cur_size + src.size(); // set size + memcpy(data, src.data(), src.size()); + memcpy(data + src.size(), contents_.data(), cur_size); + memcpy(reinterpret_cast<void*>(&contents_), data, + InlineRep::kMaxInline + 1); + } else { + contents_.PrependTree(NewTree(src.data(), src.size(), 0)); + } +} + +static CordRep* RemovePrefixFrom(CordRep* node, size_t n) { + if (n >= node->length) return nullptr; + if (n == 0) return Ref(node); + cord_internal::CordTreeMutablePath rhs_stack; + + while (node->tag == CONCAT) { + assert(n <= node->length); + if (n < node->concat()->left->length) { + // Push right to stack, descend left. + rhs_stack.push_back(node->concat()->right); + node = node->concat()->left; + } else { + // Drop left, descend right. + n -= node->concat()->left->length; + node = node->concat()->right; + } + } + assert(n <= node->length); + + if (n == 0) { + Ref(node); + } else { + size_t start = n; + size_t len = node->length - n; + if (node->tag == SUBSTRING) { + // Consider in-place update of node, similar to in RemoveSuffixFrom(). + start += node->substring()->start; + node = node->substring()->child; + } + node = NewSubstring(Ref(node), start, len); + } + while (!rhs_stack.empty()) { + node = Concat(node, Ref(rhs_stack.back())); + rhs_stack.pop_back(); + } + return node; +} + +// RemoveSuffixFrom() is very similar to RemovePrefixFrom(), with the +// exception that removing a suffix has an optimization where a node may be +// edited in place iff that node and all its ancestors have a refcount of 1. +static CordRep* RemoveSuffixFrom(CordRep* node, size_t n) { + if (n >= node->length) return nullptr; + if (n == 0) return Ref(node); + absl::cord_internal::CordTreeMutablePath lhs_stack; + bool inplace_ok = node->refcount.IsOne(); + + while (node->tag == CONCAT) { + assert(n <= node->length); + if (n < node->concat()->right->length) { + // Push left to stack, descend right. + lhs_stack.push_back(node->concat()->left); + node = node->concat()->right; + } else { + // Drop right, descend left. + n -= node->concat()->right->length; + node = node->concat()->left; + } + inplace_ok = inplace_ok && node->refcount.IsOne(); + } + assert(n <= node->length); + + if (n == 0) { + Ref(node); + } else if (inplace_ok && node->tag != EXTERNAL) { + // Consider making a new buffer if the current node capacity is much + // larger than the new length. + Ref(node); + node->length -= n; + } else { + size_t start = 0; + size_t len = node->length - n; + if (node->tag == SUBSTRING) { + start = node->substring()->start; + node = node->substring()->child; + } + node = NewSubstring(Ref(node), start, len); + } + while (!lhs_stack.empty()) { + node = Concat(Ref(lhs_stack.back()), node); + lhs_stack.pop_back(); + } + return node; +} + +void Cord::RemovePrefix(size_t n) { + ABSL_INTERNAL_CHECK(n <= size(), + absl::StrCat("Requested prefix size ", n, + " exceeds Cord's size ", size())); + CordRep* tree = contents_.tree(); + if (tree == nullptr) { + contents_.remove_prefix(n); + } else { + CordRep* newrep = RemovePrefixFrom(tree, n); + Unref(tree); + contents_.replace_tree(VerifyTree(newrep)); + } +} + +void Cord::RemoveSuffix(size_t n) { + ABSL_INTERNAL_CHECK(n <= size(), + absl::StrCat("Requested suffix size ", n, + " exceeds Cord's size ", size())); + CordRep* tree = contents_.tree(); + if (tree == nullptr) { + contents_.reduce_size(n); + } else { + CordRep* newrep = RemoveSuffixFrom(tree, n); + Unref(tree); + contents_.replace_tree(VerifyTree(newrep)); + } +} + +// Work item for NewSubRange(). +struct SubRange { + SubRange() = default; + SubRange(CordRep* a_node, size_t a_pos, size_t a_n) + : node(a_node), pos(a_pos), n(a_n) {} + CordRep* node; // nullptr means concat last 2 results. + size_t pos; + size_t n; +}; + +static CordRep* NewSubRange(CordRep* node, size_t pos, size_t n) { + cord_internal::CordTreeMutablePath results; + // The algorithm below in worst case scenario adds up to 3 nodes to the `todo` + // list, but we also pop one out on every cycle. If original tree has depth d + // todo list can grew up to 2*d in size. + cord_internal::CordTreePath<SubRange, 2 * cord_internal::MaxCordDepth()> todo; + todo.push_back(SubRange(node, pos, n)); + do { + const SubRange& sr = todo.back(); + node = sr.node; + pos = sr.pos; + n = sr.n; + todo.pop_back(); + + if (node == nullptr) { + assert(results.size() >= 2); + CordRep* right = results.back(); + results.pop_back(); + CordRep* left = results.back(); + results.pop_back(); + results.push_back(Concat(left, right)); + } else if (pos == 0 && n == node->length) { + results.push_back(Ref(node)); + } else if (node->tag != CONCAT) { + if (node->tag == SUBSTRING) { + pos += node->substring()->start; + node = node->substring()->child; + } + results.push_back(NewSubstring(Ref(node), pos, n)); + } else if (pos + n <= node->concat()->left->length) { + todo.push_back(SubRange(node->concat()->left, pos, n)); + } else if (pos >= node->concat()->left->length) { + pos -= node->concat()->left->length; + todo.push_back(SubRange(node->concat()->right, pos, n)); + } else { + size_t left_n = node->concat()->left->length - pos; + todo.push_back(SubRange(nullptr, 0, 0)); // Concat() + todo.push_back(SubRange(node->concat()->right, 0, n - left_n)); + todo.push_back(SubRange(node->concat()->left, pos, left_n)); + } + } while (!todo.empty()); + assert(results.size() == 1); + return results.back(); +} + +Cord Cord::Subcord(size_t pos, size_t new_size) const { + Cord sub_cord; + size_t length = size(); + if (pos > length) pos = length; + if (new_size > length - pos) new_size = length - pos; + CordRep* tree = contents_.tree(); + if (tree == nullptr) { + // sub_cord is newly constructed, no need to re-zero-out the tail of + // contents_ memory. + sub_cord.contents_.set_data(contents_.data() + pos, new_size, false); + } else if (new_size == 0) { + // We want to return empty subcord, so nothing to do. + } else if (new_size <= InlineRep::kMaxInline) { + Cord::ChunkIterator it = chunk_begin(); + it.AdvanceBytes(pos); + char* dest = sub_cord.contents_.data_; + size_t remaining_size = new_size; + while (remaining_size > it->size()) { + cord_internal::SmallMemmove(dest, it->data(), it->size()); + remaining_size -= it->size(); + dest += it->size(); + ++it; + } + cord_internal::SmallMemmove(dest, it->data(), remaining_size); + sub_cord.contents_.data_[InlineRep::kMaxInline] = new_size; + } else { + sub_cord.contents_.set_tree(NewSubRange(tree, pos, new_size)); + } + return sub_cord; +} + +// -------------------------------------------------------------------- +// Balancing + +class CordForest { + public: + explicit CordForest(size_t length) : root_length_(length), trees_({}) {} + + void Build(CordRep* cord_root) { + // We are adding up to two nodes to the `pending` list, but we also popping + // one, so the size of `pending` will never exceed `MaxCordDepth()`. + cord_internal::CordTreeMutablePath pending(cord_root); + + while (!pending.empty()) { + CordRep* node = pending.back(); + pending.pop_back(); + CheckNode(node); + if (ABSL_PREDICT_FALSE(node->tag != CONCAT)) { + AddNode(node); + continue; + } + + CordRepConcat* concat_node = node->concat(); + if (IsNodeBalanced(concat_node)) { + AddNode(node); + continue; + } + pending.push_back(concat_node->right); + pending.push_back(concat_node->left); + + if (concat_node->refcount.IsOne()) { + concat_node->left = concat_freelist_; + concat_freelist_ = concat_node; + } else { + Ref(concat_node->right); + Ref(concat_node->left); + Unref(concat_node); + } + } + } + + CordRep* ConcatNodes() { + CordRep* sum = nullptr; + for (auto* node : trees_) { + if (node == nullptr) continue; + + sum = PrependNode(node, sum); + root_length_ -= node->length; + if (root_length_ == 0) break; + } + ABSL_INTERNAL_CHECK(sum != nullptr, "Failed to locate sum node"); + return VerifyTree(sum); + } + + private: + CordRep* AppendNode(CordRep* node, CordRep* sum) { + return (sum == nullptr) ? node : MakeConcat(sum, node); + } + + CordRep* PrependNode(CordRep* node, CordRep* sum) { + return (sum == nullptr) ? node : MakeConcat(node, sum); + } + + void AddNode(CordRep* node) { + CordRep* sum = nullptr; + + // Collect together everything with which we will merge with node + int i = 0; + for (; node->length >= kMinLength[i + 1]; ++i) { + auto& tree_at_i = trees_[i]; + + if (tree_at_i == nullptr) continue; + sum = PrependNode(tree_at_i, sum); + tree_at_i = nullptr; + } + + sum = AppendNode(node, sum); + + // Insert sum into appropriate place in the forest + for (; sum->length >= kMinLength[i]; ++i) { + auto& tree_at_i = trees_[i]; + if (tree_at_i == nullptr) continue; + + sum = MakeConcat(tree_at_i, sum); + tree_at_i = nullptr; + } + + // kMinLength[0] == 1, which means sum->length >= kMinLength[0] + assert(i > 0); + trees_[i - 1] = sum; + } + + // Make concat node trying to resue existing CordRepConcat nodes we + // already collected in the concat_freelist_. + CordRep* MakeConcat(CordRep* left, CordRep* right) { + if (concat_freelist_ == nullptr) return RawConcat(left, right); + + CordRepConcat* rep = concat_freelist_; + if (concat_freelist_->left == nullptr) { + concat_freelist_ = nullptr; + } else { + concat_freelist_ = concat_freelist_->left->concat(); + } + SetConcatChildren(rep, left, right); + + return rep; + } + + static void CheckNode(CordRep* node) { + ABSL_INTERNAL_CHECK(node->length != 0u, ""); + if (node->tag == CONCAT) { + ABSL_INTERNAL_CHECK(node->concat()->left != nullptr, ""); + ABSL_INTERNAL_CHECK(node->concat()->right != nullptr, ""); + ABSL_INTERNAL_CHECK(node->length == (node->concat()->left->length + + node->concat()->right->length), + ""); + } + } + + size_t root_length_; + std::array<cord_internal::CordRep*, cord_internal::MaxCordDepth()> trees_; + + // List of concat nodes we can re-use for Cord balancing. + CordRepConcat* concat_freelist_ = nullptr; +}; + +static CordRep* Rebalance(CordRep* node) { + VerifyTree(node); + assert(node->tag == CONCAT); + + if (node->length == 0) { + return nullptr; + } + + CordForest forest(node->length); + forest.Build(node); + return forest.ConcatNodes(); +} + +// -------------------------------------------------------------------- +// Comparators + +namespace { + +int ClampResult(int memcmp_res) { + return static_cast<int>(memcmp_res > 0) - static_cast<int>(memcmp_res < 0); +} + +int CompareChunks(absl::string_view* lhs, absl::string_view* rhs, + size_t* size_to_compare) { + size_t compared_size = std::min(lhs->size(), rhs->size()); + assert(*size_to_compare >= compared_size); + *size_to_compare -= compared_size; + + int memcmp_res = ::memcmp(lhs->data(), rhs->data(), compared_size); + if (memcmp_res != 0) return memcmp_res; + + lhs->remove_prefix(compared_size); + rhs->remove_prefix(compared_size); + + return 0; +} + +// This overload set computes comparison results from memcmp result. This +// interface is used inside GenericCompare below. Differet implementations +// are specialized for int and bool. For int we clamp result to {-1, 0, 1} +// set. For bool we just interested in "value == 0". +template <typename ResultType> +ResultType ComputeCompareResult(int memcmp_res) { + return ClampResult(memcmp_res); +} +template <> +bool ComputeCompareResult<bool>(int memcmp_res) { + return memcmp_res == 0; +} + +} // namespace + +// Helper routine. Locates the first flat chunk of the Cord without +// initializing the iterator. +inline absl::string_view Cord::InlineRep::FindFlatStartPiece() const { + size_t n = data_[kMaxInline]; + if (n <= kMaxInline) { + return absl::string_view(data_, n); + } + + CordRep* node = tree(); + if (node->tag >= FLAT) { + return absl::string_view(node->data, node->length); + } + + if (node->tag == EXTERNAL) { + return absl::string_view(node->external()->base, node->length); + } + + // Walk down the left branches until we hit a non-CONCAT node. + while (node->tag == CONCAT) { + node = node->concat()->left; + } + + // Get the child node if we encounter a SUBSTRING. + size_t offset = 0; + size_t length = node->length; + assert(length != 0); + + if (node->tag == SUBSTRING) { + offset = node->substring()->start; + node = node->substring()->child; + } + + if (node->tag >= FLAT) { + return absl::string_view(node->data + offset, length); + } + + assert((node->tag == EXTERNAL) && "Expect FLAT or EXTERNAL node here"); + + return absl::string_view(node->external()->base + offset, length); +} + +inline int Cord::CompareSlowPath(absl::string_view rhs, size_t compared_size, + size_t size_to_compare) const { + auto advance = [](Cord::ChunkIterator* it, absl::string_view* chunk) { + if (!chunk->empty()) return true; + ++*it; + if (it->bytes_remaining_ == 0) return false; + *chunk = **it; + return true; + }; + + Cord::ChunkIterator lhs_it = chunk_begin(); + + // compared_size is inside first chunk. + absl::string_view lhs_chunk = + (lhs_it.bytes_remaining_ != 0) ? *lhs_it : absl::string_view(); + assert(compared_size <= lhs_chunk.size()); + assert(compared_size <= rhs.size()); + lhs_chunk.remove_prefix(compared_size); + rhs.remove_prefix(compared_size); + size_to_compare -= compared_size; // skip already compared size. + + while (advance(&lhs_it, &lhs_chunk) && !rhs.empty()) { + int comparison_result = CompareChunks(&lhs_chunk, &rhs, &size_to_compare); + if (comparison_result != 0) return comparison_result; + if (size_to_compare == 0) return 0; + } + + return static_cast<int>(rhs.empty()) - static_cast<int>(lhs_chunk.empty()); +} + +inline int Cord::CompareSlowPath(const Cord& rhs, size_t compared_size, + size_t size_to_compare) const { + auto advance = [](Cord::ChunkIterator* it, absl::string_view* chunk) { + if (!chunk->empty()) return true; + ++*it; + if (it->bytes_remaining_ == 0) return false; + *chunk = **it; + return true; + }; + + Cord::ChunkIterator lhs_it = chunk_begin(); + Cord::ChunkIterator rhs_it = rhs.chunk_begin(); + + // compared_size is inside both first chunks. + absl::string_view lhs_chunk = + (lhs_it.bytes_remaining_ != 0) ? *lhs_it : absl::string_view(); + absl::string_view rhs_chunk = + (rhs_it.bytes_remaining_ != 0) ? *rhs_it : absl::string_view(); + assert(compared_size <= lhs_chunk.size()); + assert(compared_size <= rhs_chunk.size()); + lhs_chunk.remove_prefix(compared_size); + rhs_chunk.remove_prefix(compared_size); + size_to_compare -= compared_size; // skip already compared size. + + while (advance(&lhs_it, &lhs_chunk) && advance(&rhs_it, &rhs_chunk)) { + int memcmp_res = CompareChunks(&lhs_chunk, &rhs_chunk, &size_to_compare); + if (memcmp_res != 0) return memcmp_res; + if (size_to_compare == 0) return 0; + } + + return static_cast<int>(rhs_chunk.empty()) - + static_cast<int>(lhs_chunk.empty()); +} + +inline absl::string_view Cord::GetFirstChunk(const Cord& c) { + return c.contents_.FindFlatStartPiece(); +} +inline absl::string_view Cord::GetFirstChunk(absl::string_view sv) { + return sv; +} + +// Compares up to 'size_to_compare' bytes of 'lhs' with 'rhs'. It is assumed +// that 'size_to_compare' is greater that size of smallest of first chunks. +template <typename ResultType, typename RHS> +ResultType GenericCompare(const Cord& lhs, const RHS& rhs, + size_t size_to_compare) { + absl::string_view lhs_chunk = Cord::GetFirstChunk(lhs); + absl::string_view rhs_chunk = Cord::GetFirstChunk(rhs); + + size_t compared_size = std::min(lhs_chunk.size(), rhs_chunk.size()); + assert(size_to_compare >= compared_size); + int memcmp_res = ::memcmp(lhs_chunk.data(), rhs_chunk.data(), compared_size); + if (compared_size == size_to_compare || memcmp_res != 0) { + return ComputeCompareResult<ResultType>(memcmp_res); + } + + return ComputeCompareResult<ResultType>( + lhs.CompareSlowPath(rhs, compared_size, size_to_compare)); +} + +bool Cord::EqualsImpl(absl::string_view rhs, size_t size_to_compare) const { + return GenericCompare<bool>(*this, rhs, size_to_compare); +} + +bool Cord::EqualsImpl(const Cord& rhs, size_t size_to_compare) const { + return GenericCompare<bool>(*this, rhs, size_to_compare); +} + +template <typename RHS> +inline int SharedCompareImpl(const Cord& lhs, const RHS& rhs) { + size_t lhs_size = lhs.size(); + size_t rhs_size = rhs.size(); + if (lhs_size == rhs_size) { + return GenericCompare<int>(lhs, rhs, lhs_size); + } + if (lhs_size < rhs_size) { + auto data_comp_res = GenericCompare<int>(lhs, rhs, lhs_size); + return data_comp_res == 0 ? -1 : data_comp_res; + } + + auto data_comp_res = GenericCompare<int>(lhs, rhs, rhs_size); + return data_comp_res == 0 ? +1 : data_comp_res; +} + +int Cord::Compare(absl::string_view rhs) const { + return SharedCompareImpl(*this, rhs); +} + +int Cord::CompareImpl(const Cord& rhs) const { + return SharedCompareImpl(*this, rhs); +} + +bool Cord::EndsWith(absl::string_view rhs) const { + size_t my_size = size(); + size_t rhs_size = rhs.size(); + + if (my_size < rhs_size) return false; + + Cord tmp(*this); + tmp.RemovePrefix(my_size - rhs_size); + return tmp.EqualsImpl(rhs, rhs_size); +} + +bool Cord::EndsWith(const Cord& rhs) const { + size_t my_size = size(); + size_t rhs_size = rhs.size(); + + if (my_size < rhs_size) return false; + + Cord tmp(*this); + tmp.RemovePrefix(my_size - rhs_size); + return tmp.EqualsImpl(rhs, rhs_size); +} + +// -------------------------------------------------------------------- +// Misc. + +Cord::operator std::string() const { + std::string s; + absl::CopyCordToString(*this, &s); + return s; +} + +void CopyCordToString(const Cord& src, std::string* dst) { + if (!src.contents_.is_tree()) { + src.contents_.CopyTo(dst); + } else { + absl::strings_internal::STLStringResizeUninitialized(dst, src.size()); + src.CopyToArraySlowPath(&(*dst)[0]); + } +} + +void Cord::CopyToArraySlowPath(char* dst) const { + assert(contents_.is_tree()); + absl::string_view fragment; + if (GetFlatAux(contents_.tree(), &fragment)) { + memcpy(dst, fragment.data(), fragment.size()); + return; + } + for (absl::string_view chunk : Chunks()) { + memcpy(dst, chunk.data(), chunk.size()); + dst += chunk.size(); + } +} + +Cord::ChunkIterator& Cord::ChunkIterator::operator++() { + assert(bytes_remaining_ > 0 && "Attempted to iterate past `end()`"); + assert(bytes_remaining_ >= current_chunk_.size()); + bytes_remaining_ -= current_chunk_.size(); + + if (stack_of_right_children_.empty()) { + assert(!current_chunk_.empty()); // Called on invalid iterator. + // We have reached the end of the Cord. + return *this; + } + + // Process the next node on the stack. + CordRep* node = stack_of_right_children_.back(); + stack_of_right_children_.pop_back(); + + // Walk down the left branches until we hit a non-CONCAT node. Save the + // right children to the stack for subsequent traversal. + while (node->tag == CONCAT) { + stack_of_right_children_.push_back(node->concat()->right); + node = node->concat()->left; + } + + // Get the child node if we encounter a SUBSTRING. + size_t offset = 0; + size_t length = node->length; + if (node->tag == SUBSTRING) { + offset = node->substring()->start; + node = node->substring()->child; + } + + assert(node->tag == EXTERNAL || node->tag >= FLAT); + assert(length != 0); + const char* data = + node->tag == EXTERNAL ? node->external()->base : node->data; + current_chunk_ = absl::string_view(data + offset, length); + current_leaf_ = node; + return *this; +} + +Cord Cord::ChunkIterator::AdvanceAndReadBytes(size_t n) { + assert(bytes_remaining_ >= n && "Attempted to iterate past `end()`"); + Cord subcord; + + if (n <= InlineRep::kMaxInline) { + // Range to read fits in inline data. Flatten it. + char* data = subcord.contents_.set_data(n); + while (n > current_chunk_.size()) { + memcpy(data, current_chunk_.data(), current_chunk_.size()); + data += current_chunk_.size(); + n -= current_chunk_.size(); + ++*this; + } + memcpy(data, current_chunk_.data(), n); + if (n < current_chunk_.size()) { + RemoveChunkPrefix(n); + } else if (n > 0) { + ++*this; + } + return subcord; + } + if (n < current_chunk_.size()) { + // Range to read is a proper subrange of the current chunk. + assert(current_leaf_ != nullptr); + CordRep* subnode = Ref(current_leaf_); + const char* data = + subnode->tag == EXTERNAL ? subnode->external()->base : subnode->data; + subnode = NewSubstring(subnode, current_chunk_.data() - data, n); + subcord.contents_.set_tree(VerifyTree(subnode)); + RemoveChunkPrefix(n); + return subcord; + } + + // Range to read begins with a proper subrange of the current chunk. + assert(!current_chunk_.empty()); + assert(current_leaf_ != nullptr); + CordRep* subnode = Ref(current_leaf_); + if (current_chunk_.size() < subnode->length) { + const char* data = + subnode->tag == EXTERNAL ? subnode->external()->base : subnode->data; + subnode = NewSubstring(subnode, current_chunk_.data() - data, + current_chunk_.size()); + } + n -= current_chunk_.size(); + bytes_remaining_ -= current_chunk_.size(); + + // Process the next node(s) on the stack, reading whole subtrees depending on + // their length and how many bytes we are advancing. + CordRep* node = nullptr; + while (!stack_of_right_children_.empty()) { + node = stack_of_right_children_.back(); + stack_of_right_children_.pop_back(); + if (node->length > n) break; + // TODO(qrczak): This might unnecessarily recreate existing concat nodes. + // Avoiding that would need pretty complicated logic (instead of + // current_leaf_, keep current_subtree_ which points to the highest node + // such that the current leaf can be found on the path of left children + // starting from current_subtree_; delay creating subnode while node is + // below current_subtree_; find the proper node along the path of left + // children starting from current_subtree_ if this loop exits while staying + // below current_subtree_; etc.; alternatively, push parents instead of + // right children on the stack). + subnode = Concat(subnode, Ref(node)); + n -= node->length; + bytes_remaining_ -= node->length; + node = nullptr; + } + + if (node == nullptr) { + // We have reached the end of the Cord. + assert(bytes_remaining_ == 0); + subcord.contents_.set_tree(VerifyTree(subnode)); + return subcord; + } + + // Walk down the appropriate branches until we hit a non-CONCAT node. Save the + // right children to the stack for subsequent traversal. + while (node->tag == CONCAT) { + if (node->concat()->left->length > n) { + // Push right, descend left. + stack_of_right_children_.push_back(node->concat()->right); + node = node->concat()->left; + } else { + // Read left, descend right. + subnode = Concat(subnode, Ref(node->concat()->left)); + n -= node->concat()->left->length; + bytes_remaining_ -= node->concat()->left->length; + node = node->concat()->right; + } + } + + // Get the child node if we encounter a SUBSTRING. + size_t offset = 0; + size_t length = node->length; + if (node->tag == SUBSTRING) { + offset = node->substring()->start; + node = node->substring()->child; + } + + // Range to read ends with a proper (possibly empty) subrange of the current + // chunk. + assert(node->tag == EXTERNAL || node->tag >= FLAT); + assert(length > n); + if (n > 0) subnode = Concat(subnode, NewSubstring(Ref(node), offset, n)); + const char* data = + node->tag == EXTERNAL ? node->external()->base : node->data; + current_chunk_ = absl::string_view(data + offset + n, length - n); + current_leaf_ = node; + bytes_remaining_ -= n; + subcord.contents_.set_tree(VerifyTree(subnode)); + return subcord; +} + +void Cord::ChunkIterator::AdvanceBytesSlowPath(size_t n) { + assert(bytes_remaining_ >= n && "Attempted to iterate past `end()`"); + assert(n >= current_chunk_.size()); // This should only be called when + // iterating to a new node. + + n -= current_chunk_.size(); + bytes_remaining_ -= current_chunk_.size(); + + // Process the next node(s) on the stack, skipping whole subtrees depending on + // their length and how many bytes we are advancing. + CordRep* node = nullptr; + while (!stack_of_right_children_.empty()) { + node = stack_of_right_children_.back(); + stack_of_right_children_.pop_back(); + if (node->length > n) break; + n -= node->length; + bytes_remaining_ -= node->length; + node = nullptr; + } + + if (node == nullptr) { + // We have reached the end of the Cord. + assert(bytes_remaining_ == 0); + return; + } + + // Walk down the appropriate branches until we hit a non-CONCAT node. Save the + // right children to the stack for subsequent traversal. + while (node->tag == CONCAT) { + if (node->concat()->left->length > n) { + // Push right, descend left. + stack_of_right_children_.push_back(node->concat()->right); + node = node->concat()->left; + } else { + // Skip left, descend right. + n -= node->concat()->left->length; + bytes_remaining_ -= node->concat()->left->length; + node = node->concat()->right; + } + } + + // Get the child node if we encounter a SUBSTRING. + size_t offset = 0; + size_t length = node->length; + if (node->tag == SUBSTRING) { + offset = node->substring()->start; + node = node->substring()->child; + } + + assert(node->tag == EXTERNAL || node->tag >= FLAT); + assert(length > n); + const char* data = + node->tag == EXTERNAL ? node->external()->base : node->data; + current_chunk_ = absl::string_view(data + offset + n, length - n); + current_leaf_ = node; + bytes_remaining_ -= n; +} + +char Cord::operator[](size_t i) const { + assert(i < size()); + size_t offset = i; + const CordRep* rep = contents_.tree(); + if (rep == nullptr) { + return contents_.data()[i]; + } + while (true) { + assert(rep != nullptr); + assert(offset < rep->length); + if (rep->tag >= FLAT) { + // Get the "i"th character directly from the flat array. + return rep->data[offset]; + } else if (rep->tag == EXTERNAL) { + // Get the "i"th character from the external array. + return rep->external()->base[offset]; + } else if (rep->tag == CONCAT) { + // Recursively branch to the side of the concatenation that the "i"th + // character is on. + size_t left_length = rep->concat()->left->length; + if (offset < left_length) { + rep = rep->concat()->left; + } else { + offset -= left_length; + rep = rep->concat()->right; + } + } else { + // This must be a substring a node, so bypass it to get to the child. + assert(rep->tag == SUBSTRING); + offset += rep->substring()->start; + rep = rep->substring()->child; + } + } +} + +absl::string_view Cord::FlattenSlowPath() { + size_t total_size = size(); + CordRep* new_rep; + char* new_buffer; + + // Try to put the contents into a new flat rep. If they won't fit in the + // biggest possible flat node, use an external rep instead. + if (total_size <= kMaxFlatLength) { + new_rep = NewFlat(total_size); + new_rep->length = total_size; + new_buffer = new_rep->data; + CopyToArraySlowPath(new_buffer); + } else { + new_buffer = std::allocator<char>().allocate(total_size); + CopyToArraySlowPath(new_buffer); + new_rep = absl::cord_internal::NewExternalRep( + absl::string_view(new_buffer, total_size), [](absl::string_view s) { + std::allocator<char>().deallocate(const_cast<char*>(s.data()), + s.size()); + }); + } + Unref(contents_.tree()); + contents_.set_tree(new_rep); + return absl::string_view(new_buffer, total_size); +} + +/* static */ bool Cord::GetFlatAux(CordRep* rep, absl::string_view* fragment) { + assert(rep != nullptr); + if (rep->tag >= FLAT) { + *fragment = absl::string_view(rep->data, rep->length); + return true; + } else if (rep->tag == EXTERNAL) { + *fragment = absl::string_view(rep->external()->base, rep->length); + return true; + } else if (rep->tag == SUBSTRING) { + CordRep* child = rep->substring()->child; + if (child->tag >= FLAT) { + *fragment = + absl::string_view(child->data + rep->substring()->start, rep->length); + return true; + } else if (child->tag == EXTERNAL) { + *fragment = absl::string_view( + child->external()->base + rep->substring()->start, rep->length); + return true; + } + } + return false; +} + +/* static */ void Cord::ForEachChunkAux( + absl::cord_internal::CordRep* rep, + absl::FunctionRef<void(absl::string_view)> callback) { + assert(rep != nullptr); + int stack_pos = 0; + constexpr int stack_max = 128; + // Stack of right branches for tree traversal + absl::cord_internal::CordRep* stack[stack_max]; + absl::cord_internal::CordRep* current_node = rep; + while (true) { + if (current_node->tag == CONCAT) { + if (stack_pos == stack_max) { + // There's no more room on our stack array to add another right branch, + // and the idea is to avoid allocations, so call this function + // recursively to navigate this subtree further. (This is not something + // we expect to happen in practice). + ForEachChunkAux(current_node, callback); + + // Pop the next right branch and iterate. + current_node = stack[--stack_pos]; + continue; + } else { + // Save the right branch for later traversal and continue down the left + // branch. + stack[stack_pos++] = current_node->concat()->right; + current_node = current_node->concat()->left; + continue; + } + } + // This is a leaf node, so invoke our callback. + absl::string_view chunk; + bool success = GetFlatAux(current_node, &chunk); + assert(success); + if (success) { + callback(chunk); + } + if (stack_pos == 0) { + // end of traversal + return; + } + current_node = stack[--stack_pos]; + } +} + +static void DumpNode(const CordRep* rep, bool include_data, std::ostream* os) { + const int kIndentStep = 1; + int indent = 0; + cord_internal::CordTreeConstPath stack; + cord_internal::CordTreePath<int, cord_internal::MaxCordDepth()> indents; + for (;;) { + *os << std::setw(3) << rep->refcount.Get(); + *os << " " << std::setw(7) << rep->length; + *os << " ["; + if (include_data) *os << static_cast<const void*>(rep); + *os << "]"; + *os << " " << (IsNodeBalanced(rep) ? 'b' : 'u'); + *os << " " << std::setw(indent) << ""; + if (rep->tag == CONCAT) { + *os << "CONCAT depth=" << Depth(rep) << "\n"; + indent += kIndentStep; + indents.push_back(indent); + stack.push_back(rep->concat()->right); + rep = rep->concat()->left; + } else if (rep->tag == SUBSTRING) { + *os << "SUBSTRING @ " << rep->substring()->start << "\n"; + indent += kIndentStep; + rep = rep->substring()->child; + } else { // Leaf + if (rep->tag == EXTERNAL) { + *os << "EXTERNAL ["; + if (include_data) + *os << absl::CEscape(std::string(rep->external()->base, rep->length)); + *os << "]\n"; + } else { + *os << "FLAT cap=" << TagToLength(rep->tag) << " ["; + if (include_data) + *os << absl::CEscape(absl::string_view(rep->data, rep->length)); + *os << "]\n"; + } + if (stack.empty()) break; + rep = stack.back(); + stack.pop_back(); + indent = indents.back(); + indents.pop_back(); + } + } + ABSL_INTERNAL_CHECK(indents.empty(), ""); +} + +static std::string ReportError(const CordRep* root, const CordRep* node) { + std::ostringstream buf; + buf << "Error at node " << node << " in:"; + DumpNode(root, true, &buf); + return buf.str(); +} + +static bool VerifyNode(const CordRep* root, const CordRep* start_node, + bool full_validation) { + cord_internal::CordTreeConstPath worklist; + worklist.push_back(start_node); + do { + const CordRep* node = worklist.back(); + worklist.pop_back(); + + ABSL_INTERNAL_CHECK(node != nullptr, ReportError(root, node)); + if (node != root) { + ABSL_INTERNAL_CHECK(node->length != 0, ReportError(root, node)); + } + + if (node->tag == CONCAT) { + ABSL_INTERNAL_CHECK(node->concat()->left != nullptr, + ReportError(root, node)); + ABSL_INTERNAL_CHECK(node->concat()->right != nullptr, + ReportError(root, node)); + ABSL_INTERNAL_CHECK((node->length == node->concat()->left->length + + node->concat()->right->length), + ReportError(root, node)); + if (full_validation) { + worklist.push_back(node->concat()->right); + worklist.push_back(node->concat()->left); + } + } else if (node->tag >= FLAT) { + ABSL_INTERNAL_CHECK(node->length <= TagToLength(node->tag), + ReportError(root, node)); + } else if (node->tag == EXTERNAL) { + ABSL_INTERNAL_CHECK(node->external()->base != nullptr, + ReportError(root, node)); + } else if (node->tag == SUBSTRING) { + ABSL_INTERNAL_CHECK( + node->substring()->start < node->substring()->child->length, + ReportError(root, node)); + ABSL_INTERNAL_CHECK(node->substring()->start + node->length <= + node->substring()->child->length, + ReportError(root, node)); + } + } while (!worklist.empty()); + return true; +} + +// Traverses the tree and computes the total memory allocated. +/* static */ size_t Cord::MemoryUsageAux(const CordRep* rep) { + size_t total_mem_usage = 0; + + // Allow a quick exit for the common case that the root is a leaf. + if (RepMemoryUsageLeaf(rep, &total_mem_usage)) { + return total_mem_usage; + } + + // Iterate over the tree. cur_node is never a leaf node and leaf nodes will + // never be appended to tree_stack. This reduces overhead from manipulating + // tree_stack. + cord_internal::CordTreeConstPath tree_stack; + const CordRep* cur_node = rep; + while (true) { + const CordRep* next_node = nullptr; + + if (cur_node->tag == CONCAT) { + total_mem_usage += sizeof(CordRepConcat); + const CordRep* left = cur_node->concat()->left; + if (!RepMemoryUsageLeaf(left, &total_mem_usage)) { + next_node = left; + } + + const CordRep* right = cur_node->concat()->right; + if (!RepMemoryUsageLeaf(right, &total_mem_usage)) { + if (next_node) { + tree_stack.push_back(next_node); + } + next_node = right; + } + } else { + // Since cur_node is not a leaf or a concat node it must be a substring. + assert(cur_node->tag == SUBSTRING); + total_mem_usage += sizeof(CordRepSubstring); + next_node = cur_node->substring()->child; + if (RepMemoryUsageLeaf(next_node, &total_mem_usage)) { + next_node = nullptr; + } + } + + if (!next_node) { + if (tree_stack.empty()) { + return total_mem_usage; + } + next_node = tree_stack.back(); + tree_stack.pop_back(); + } + cur_node = next_node; + } +} + +std::ostream& operator<<(std::ostream& out, const Cord& cord) { + for (absl::string_view chunk : cord.Chunks()) { + out.write(chunk.data(), chunk.size()); + } + return out; +} + +namespace strings_internal { +size_t CordTestAccess::FlatOverhead() { return kFlatOverhead; } +size_t CordTestAccess::MaxFlatLength() { return kMaxFlatLength; } +size_t CordTestAccess::FlatTagToLength(uint8_t tag) { + return TagToLength(tag); +} +uint8_t CordTestAccess::LengthToTag(size_t s) { + ABSL_INTERNAL_CHECK(s <= kMaxFlatLength, absl::StrCat("Invalid length ", s)); + return AllocatedSizeToTag(s + kFlatOverhead); +} +size_t CordTestAccess::SizeofCordRepConcat() { return sizeof(CordRepConcat); } +size_t CordTestAccess::SizeofCordRepExternal() { + return sizeof(CordRepExternal); +} +size_t CordTestAccess::SizeofCordRepSubstring() { + return sizeof(CordRepSubstring); +} +} // namespace strings_internal +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/cord.h b/third_party/abseil-cpp/absl/strings/cord.h new file mode 100644 index 0000000..eb236e5 --- /dev/null +++ b/third_party/abseil-cpp/absl/strings/cord.h
@@ -0,0 +1,1202 @@ +// Copyright 2020 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// A Cord is a sequence of characters with some unusual access propreties. +// A Cord supports efficient insertions and deletions at the start and end of +// the byte sequence, but random access reads are slower, and random access +// modifications are not supported by the API. Cord also provides cheap copies +// (using a copy-on-write strategy) and cheap substring operations. +// +// Thread safety +// ------------- +// Cord has the same thread-safety properties as many other types like +// std::string, std::vector<>, int, etc -- it is thread-compatible. In +// particular, if no thread may call a non-const method, then it is safe to +// concurrently call const methods. Copying a Cord produces a new instance that +// can be used concurrently with the original in arbitrary ways. +// +// Implementation is similar to the "Ropes" described in: +// Ropes: An alternative to strings +// Hans J. Boehm, Russ Atkinson, Michael Plass +// Software Practice and Experience, December 1995 + +#ifndef ABSL_STRINGS_CORD_H_ +#define ABSL_STRINGS_CORD_H_ + +#include <algorithm> +#include <cstddef> +#include <cstdint> +#include <cstring> +#include <iostream> +#include <iterator> +#include <string> +#include <type_traits> + +#include "absl/base/internal/endian.h" +#include "absl/base/internal/invoke.h" +#include "absl/base/internal/per_thread_tls.h" +#include "absl/base/macros.h" +#include "absl/base/port.h" +#include "absl/functional/function_ref.h" +#include "absl/meta/type_traits.h" +#include "absl/strings/internal/cord_internal.h" +#include "absl/strings/internal/resize_uninitialized.h" +#include "absl/strings/string_view.h" +#include "absl/types/optional.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +class Cord; +class CordTestPeer; +template <typename Releaser> +Cord MakeCordFromExternal(absl::string_view, Releaser&&); +void CopyCordToString(const Cord& src, std::string* dst); +namespace hash_internal { +template <typename H> +H HashFragmentedCord(H, const Cord&); +} + +namespace cord_internal { + +// It's expensive to keep a tree perfectly balanced, so instead we keep trees +// approximately balanced. A tree node N of depth D(N) that contains a string +// of L(N) characters is considered balanced if L >= Fibonacci(D + 2). +// The "+ 2" is used to ensure that every balanced leaf node contains at least +// one character. Here we presume that +// Fibonacci(0) = 0 +// Fibonacci(1) = 1 +// Fibonacci(2) = 1 +// Fibonacci(3) = 2 +// ... +// The algorithm is based on paper by Hans Boehm et al: +// https://www.cs.rit.edu/usr/local/pub/jeh/courses/QUARTERS/FP/Labs/CedarRope/rope-paper.pdf +// In this paper authors shows that rebalancing based on cord forest of already +// balanced subtrees can be proven to never produce tree of depth larger than +// largest Fibonacci number representable in the same integral type as cord size +// For 64 bit integers this is the 93rd Fibonacci number. For 32 bit integrals +// this is 47th Fibonacci number. +constexpr size_t MaxCordDepth() { return sizeof(size_t) == 8 ? 93 : 47; } + +// This class models fixed max size stack of CordRep pointers. +// The elements are being pushed back and popped from the back. +template <typename CordRepPtr, size_t N> +class CordTreePath { + public: + CordTreePath() {} + explicit CordTreePath(CordRepPtr root) { push_back(root); } + + bool empty() const { return size_ == 0; } + size_t size() const { return size_; } + void clear() { size_ = 0; } + + CordRepPtr back() { return data_[size_ - 1]; } + + void pop_back() { + --size_; + assert(size_ < N); + } + void push_back(CordRepPtr elem) { data_[size_++] = elem; } + + private: + CordRepPtr data_[N]; + size_t size_ = 0; +}; + +using CordTreeMutablePath = CordTreePath<CordRep*, MaxCordDepth()>; +} // namespace cord_internal + +// A Cord is a sequence of characters. +class Cord { + private: + template <typename T> + using EnableIfString = + absl::enable_if_t<std::is_same<T, std::string>::value, int>; + + public: + // -------------------------------------------------------------------- + // Constructors, destructors and helper factories + + // Create an empty cord + constexpr Cord() noexcept; + + // Cord is copyable and efficiently movable. + // The moved-from state is valid but unspecified. + Cord(const Cord& src); + Cord(Cord&& src) noexcept; + Cord& operator=(const Cord& x); + Cord& operator=(Cord&& x) noexcept; + + // Create a cord out of "src". This constructor is explicit on + // purpose so that people do not get automatic type conversions. + explicit Cord(absl::string_view src); + Cord& operator=(absl::string_view src); + + // These are templated to avoid ambiguities for types that are convertible to + // both `absl::string_view` and `std::string`, such as `const char*`. + // + // Note that these functions reserve the right to reuse the `string&&`'s + // memory and that they will do so in the future. + template <typename T, EnableIfString<T> = 0> + explicit Cord(T&& src) : Cord(absl::string_view(src)) {} + template <typename T, EnableIfString<T> = 0> + Cord& operator=(T&& src); + + // Destroy the cord + ~Cord() { + if (contents_.is_tree()) DestroyCordSlow(); + } + + // Creates a Cord that takes ownership of external memory. The contents of + // `data` are not copied. + // + // This function takes a callable that is invoked when all Cords are + // finished with `data`. The data must remain live and unchanging until the + // releaser is called. The requirements for the releaser are that it: + // * is move constructible, + // * supports `void operator()(absl::string_view) const` or + // `void operator()() const`, + // * does not have alignment requirement greater than what is guaranteed by + // ::operator new. This is dictated by alignof(std::max_align_t) before + // C++17 and __STDCPP_DEFAULT_NEW_ALIGNMENT__ if compiling with C++17 or + // it is supported by the implementation. + // + // Example: + // + // Cord MakeCord(BlockPool* pool) { + // Block* block = pool->NewBlock(); + // FillBlock(block); + // return absl::MakeCordFromExternal( + // block->ToStringView(), + // [pool, block](absl::string_view v) { + // pool->FreeBlock(block, v); + // }); + // } + // + // WARNING: It's likely a bug if your releaser doesn't do anything. + // For example, consider the following: + // + // void Foo(const char* buffer, int len) { + // auto c = absl::MakeCordFromExternal(absl::string_view(buffer, len), + // [](absl::string_view) {}); + // + // // BUG: If Bar() copies its cord for any reason, including keeping a + // // substring of it, the lifetime of buffer might be extended beyond + // // when Foo() returns. + // Bar(c); + // } + template <typename Releaser> + friend Cord MakeCordFromExternal(absl::string_view data, Releaser&& releaser); + + // -------------------------------------------------------------------- + // Mutations + + void Clear(); + + void Append(const Cord& src); + void Append(Cord&& src); + void Append(absl::string_view src); + template <typename T, EnableIfString<T> = 0> + void Append(T&& src); + + void Prepend(const Cord& src); + void Prepend(absl::string_view src); + template <typename T, EnableIfString<T> = 0> + void Prepend(T&& src); + + void RemovePrefix(size_t n); + void RemoveSuffix(size_t n); + + // Returns a new cord representing the subrange [pos, pos + new_size) of + // *this. If pos >= size(), the result is empty(). If + // (pos + new_size) >= size(), the result is the subrange [pos, size()). + Cord Subcord(size_t pos, size_t new_size) const; + + friend void swap(Cord& x, Cord& y) noexcept; + + // -------------------------------------------------------------------- + // Accessors + + size_t size() const; + bool empty() const; + + // Returns the approximate number of bytes pinned by this Cord. Note that + // Cords that share memory could each be "charged" independently for the same + // shared memory. + size_t EstimatedMemoryUsage() const; + + // -------------------------------------------------------------------- + // Comparators + + // Compares 'this' Cord with rhs. This function and its relatives + // treat Cords as sequences of unsigned bytes. The comparison is a + // straightforward lexicographic comparison. Return value: + // -1 'this' Cord is smaller + // 0 two Cords are equal + // 1 'this' Cord is larger + int Compare(absl::string_view rhs) const; + int Compare(const Cord& rhs) const; + + // Does 'this' cord start/end with rhs + bool StartsWith(const Cord& rhs) const; + bool StartsWith(absl::string_view rhs) const; + bool EndsWith(absl::string_view rhs) const; + bool EndsWith(const Cord& rhs) const; + + // -------------------------------------------------------------------- + // Conversion to other types + + explicit operator std::string() const; + + // Copies the contents from `src` to `*dst`. + // + // This function optimizes the case of reusing the destination string since it + // can reuse previously allocated capacity. However, this function does not + // guarantee that pointers previously returned by `dst->data()` remain valid + // even if `*dst` had enough capacity to hold `src`. If `*dst` is a new + // object, prefer to simply use the conversion operator to `std::string`. + friend void CopyCordToString(const Cord& src, std::string* dst); + + // -------------------------------------------------------------------- + // Iteration + + class CharIterator; + + // Type for iterating over the chunks of a `Cord`. See comments for + // `Cord::chunk_begin()`, `Cord::chunk_end()` and `Cord::Chunks()` below for + // preferred usage. + // + // Additional notes: + // * The `string_view` returned by dereferencing a valid, non-`end()` + // iterator is guaranteed to be non-empty. + // * A `ChunkIterator` object is invalidated after any non-const + // operation on the `Cord` object over which it iterates. + // * Two `ChunkIterator` objects can be equality compared if and only if + // they remain valid and iterate over the same `Cord`. + // * This is a proxy iterator. This means the `string_view` returned by the + // iterator does not live inside the Cord, and its lifetime is limited to + // the lifetime of the iterator itself. To help prevent issues, + // `ChunkIterator::reference` is not a true reference type and is + // equivalent to `value_type`. + // * The iterator keeps state that can grow for `Cord`s that contain many + // nodes and are imbalanced due to sharing. Prefer to pass this type by + // const reference instead of by value. + class ChunkIterator { + public: + using iterator_category = std::input_iterator_tag; + using value_type = absl::string_view; + using difference_type = ptrdiff_t; + using pointer = const value_type*; + using reference = value_type; + + ChunkIterator() = default; + + ChunkIterator& operator++(); + ChunkIterator operator++(int); + bool operator==(const ChunkIterator& other) const; + bool operator!=(const ChunkIterator& other) const; + reference operator*() const; + pointer operator->() const; + + friend class Cord; + friend class CharIterator; + + private: + // Constructs a `begin()` iterator from `cord`. + explicit ChunkIterator(const Cord* cord); + + // Removes `n` bytes from `current_chunk_`. Expects `n` to be smaller than + // `current_chunk_.size()`. + void RemoveChunkPrefix(size_t n); + Cord AdvanceAndReadBytes(size_t n); + void AdvanceBytes(size_t n); + // Iterates `n` bytes, where `n` is expected to be greater than or equal to + // `current_chunk_.size()`. + void AdvanceBytesSlowPath(size_t n); + + // A view into bytes of the current `CordRep`. It may only be a view to a + // suffix of bytes if this is being used by `CharIterator`. + absl::string_view current_chunk_; + // The current leaf, or `nullptr` if the iterator points to short data. + // If the current chunk is a substring node, current_leaf_ points to the + // underlying flat or external node. + absl::cord_internal::CordRep* current_leaf_ = nullptr; + // The number of bytes left in the `Cord` over which we are iterating. + size_t bytes_remaining_ = 0; + absl::cord_internal::CordTreeMutablePath stack_of_right_children_; + }; + + // Returns an iterator to the first chunk of the `Cord`. + // + // This is useful for getting a `ChunkIterator` outside the context of a + // range-based for-loop (in which case see `Cord::Chunks()` below). + // + // Example: + // + // absl::Cord::ChunkIterator FindAsChunk(const absl::Cord& c, + // absl::string_view s) { + // return std::find(c.chunk_begin(), c.chunk_end(), s); + // } + ChunkIterator chunk_begin() const; + // Returns an iterator one increment past the last chunk of the `Cord`. + ChunkIterator chunk_end() const; + + // Convenience wrapper over `Cord::chunk_begin()` and `Cord::chunk_end()` to + // enable range-based for-loop iteration over `Cord` chunks. + // + // Prefer to use `Cord::Chunks()` below instead of constructing this directly. + class ChunkRange { + public: + explicit ChunkRange(const Cord* cord) : cord_(cord) {} + + ChunkIterator begin() const; + ChunkIterator end() const; + + private: + const Cord* cord_; + }; + + // Returns a range for iterating over the chunks of a `Cord` with a + // range-based for-loop. + // + // Example: + // + // void ProcessChunks(const Cord& cord) { + // for (absl::string_view chunk : cord.Chunks()) { ... } + // } + // + // Note that the ordinary caveats of temporary lifetime extension apply: + // + // void Process() { + // for (absl::string_view chunk : CordFactory().Chunks()) { + // // The temporary Cord returned by CordFactory has been destroyed! + // } + // } + ChunkRange Chunks() const; + + // Type for iterating over the characters of a `Cord`. See comments for + // `Cord::char_begin()`, `Cord::char_end()` and `Cord::Chars()` below for + // preferred usage. + // + // Additional notes: + // * A `CharIterator` object is invalidated after any non-const + // operation on the `Cord` object over which it iterates. + // * Two `CharIterator` objects can be equality compared if and only if + // they remain valid and iterate over the same `Cord`. + // * The iterator keeps state that can grow for `Cord`s that contain many + // nodes and are imbalanced due to sharing. Prefer to pass this type by + // const reference instead of by value. + // * This type cannot be a forward iterator because a `Cord` can reuse + // sections of memory. This violates the requirement that if dereferencing + // two iterators returns the same object, the iterators must compare + // equal. + class CharIterator { + public: + using iterator_category = std::input_iterator_tag; + using value_type = char; + using difference_type = ptrdiff_t; + using pointer = const char*; + using reference = const char&; + + CharIterator() = default; + + CharIterator& operator++(); + CharIterator operator++(int); + bool operator==(const CharIterator& other) const; + bool operator!=(const CharIterator& other) const; + reference operator*() const; + pointer operator->() const; + + friend Cord; + + private: + explicit CharIterator(const Cord* cord) : chunk_iterator_(cord) {} + + ChunkIterator chunk_iterator_; + }; + + // Advances `*it` by `n_bytes` and returns the bytes passed as a `Cord`. + // + // `n_bytes` must be less than or equal to the number of bytes remaining for + // iteration. Otherwise the behavior is undefined. It is valid to pass + // `char_end()` and 0. + static Cord AdvanceAndRead(CharIterator* it, size_t n_bytes); + + // Advances `*it` by `n_bytes`. + // + // `n_bytes` must be less than or equal to the number of bytes remaining for + // iteration. Otherwise the behavior is undefined. It is valid to pass + // `char_end()` and 0. + static void Advance(CharIterator* it, size_t n_bytes); + + // Returns the longest contiguous view starting at the iterator's position. + // + // `it` must be dereferenceable. + static absl::string_view ChunkRemaining(const CharIterator& it); + + // Returns an iterator to the first character of the `Cord`. + CharIterator char_begin() const; + // Returns an iterator to one past the last character of the `Cord`. + CharIterator char_end() const; + + // Convenience wrapper over `Cord::char_begin()` and `Cord::char_end()` to + // enable range-based for-loop iterator over the characters of a `Cord`. + // + // Prefer to use `Cord::Chars()` below instead of constructing this directly. + class CharRange { + public: + explicit CharRange(const Cord* cord) : cord_(cord) {} + + CharIterator begin() const; + CharIterator end() const; + + private: + const Cord* cord_; + }; + + // Returns a range for iterating over the characters of a `Cord` with a + // range-based for-loop. + // + // Example: + // + // void ProcessCord(const Cord& cord) { + // for (char c : cord.Chars()) { ... } + // } + // + // Note that the ordinary caveats of temporary lifetime extension apply: + // + // void Process() { + // for (char c : CordFactory().Chars()) { + // // The temporary Cord returned by CordFactory has been destroyed! + // } + // } + CharRange Chars() const; + + // -------------------------------------------------------------------- + // Miscellaneous + + // Get the "i"th character of 'this' and return it. + // NOTE: This routine is reasonably efficient. It is roughly + // logarithmic in the number of nodes that make up the cord. Still, + // if you need to iterate over the contents of a cord, you should + // use a CharIterator/CordIterator rather than call operator[] or Get() + // repeatedly in a loop. + // + // REQUIRES: 0 <= i < size() + char operator[](size_t i) const; + + // If this cord's representation is a single flat array, return a + // string_view referencing that array. Otherwise return nullopt. + absl::optional<absl::string_view> TryFlat() const; + + // Flattens the cord into a single array and returns a view of the data. + // + // If the cord was already flat, the contents are not modified. + absl::string_view Flatten(); + + private: + friend class CordTestPeer; + template <typename H> + friend H absl::hash_internal::HashFragmentedCord(H, const Cord&); + friend bool operator==(const Cord& lhs, const Cord& rhs); + friend bool operator==(const Cord& lhs, absl::string_view rhs); + + // Call the provided function once for each cord chunk, in order. Unlike + // Chunks(), this API will not allocate memory. + void ForEachChunk(absl::FunctionRef<void(absl::string_view)>) const; + + // Allocates new contiguous storage for the contents of the cord. This is + // called by Flatten() when the cord was not already flat. + absl::string_view FlattenSlowPath(); + + // Actual cord contents are hidden inside the following simple + // class so that we can isolate the bulk of cord.cc from changes + // to the representation. + // + // InlineRep holds either either a tree pointer, or an array of kMaxInline + // bytes. + class InlineRep { + public: + static const unsigned char kMaxInline = 15; + static_assert(kMaxInline >= sizeof(absl::cord_internal::CordRep*), ""); + // Tag byte & kMaxInline means we are storing a pointer. + static const unsigned char kTreeFlag = 1 << 4; + // Tag byte & kProfiledFlag means we are profiling the Cord. + static const unsigned char kProfiledFlag = 1 << 5; + + constexpr InlineRep() : data_{} {} + InlineRep(const InlineRep& src); + InlineRep(InlineRep&& src); + InlineRep& operator=(const InlineRep& src); + InlineRep& operator=(InlineRep&& src) noexcept; + + void Swap(InlineRep* rhs); + bool empty() const; + size_t size() const; + const char* data() const; // Returns nullptr if holding pointer + void set_data(const char* data, size_t n, + bool nullify_tail); // Discards pointer, if any + char* set_data(size_t n); // Write data to the result + // Returns nullptr if holding bytes + absl::cord_internal::CordRep* tree() const; + // Discards old pointer, if any + void set_tree(absl::cord_internal::CordRep* rep); + // Replaces a tree with a new root. This is faster than set_tree, but it + // should only be used when it's clear that the old rep was a tree. + void replace_tree(absl::cord_internal::CordRep* rep); + // Returns non-null iff was holding a pointer + absl::cord_internal::CordRep* clear(); + // Convert to pointer if necessary + absl::cord_internal::CordRep* force_tree(size_t extra_hint); + void reduce_size(size_t n); // REQUIRES: holding data + void remove_prefix(size_t n); // REQUIRES: holding data + void AppendArray(const char* src_data, size_t src_size); + absl::string_view FindFlatStartPiece() const; + void AppendTree(absl::cord_internal::CordRep* tree); + void PrependTree(absl::cord_internal::CordRep* tree); + void GetAppendRegion(char** region, size_t* size, size_t max_length); + void GetAppendRegion(char** region, size_t* size); + bool IsSame(const InlineRep& other) const { + return memcmp(data_, other.data_, sizeof(data_)) == 0; + } + int BitwiseCompare(const InlineRep& other) const { + uint64_t x, y; + // Use memcpy to avoid anti-aliasing issues. + memcpy(&x, data_, sizeof(x)); + memcpy(&y, other.data_, sizeof(y)); + if (x == y) { + memcpy(&x, data_ + 8, sizeof(x)); + memcpy(&y, other.data_ + 8, sizeof(y)); + if (x == y) return 0; + } + return absl::big_endian::FromHost64(x) < absl::big_endian::FromHost64(y) + ? -1 + : 1; + } + void CopyTo(std::string* dst) const { + // memcpy is much faster when operating on a known size. On most supported + // platforms, the small string optimization is large enough that resizing + // to 15 bytes does not cause a memory allocation. + absl::strings_internal::STLStringResizeUninitialized(dst, + sizeof(data_) - 1); + memcpy(&(*dst)[0], data_, sizeof(data_) - 1); + // erase is faster than resize because the logic for memory allocation is + // not needed. + dst->erase(data_[kMaxInline]); + } + + // Copies the inline contents into `dst`. Assumes the cord is not empty. + void CopyToArray(char* dst) const; + + bool is_tree() const { return data_[kMaxInline] > kMaxInline; } + + private: + friend class Cord; + + void AssignSlow(const InlineRep& src); + // Unrefs the tree, stops profiling, and zeroes the contents + void ClearSlow(); + + // If the data has length <= kMaxInline, we store it in data_[0..len-1], + // and store the length in data_[kMaxInline]. Else we store it in a tree + // and store a pointer to that tree in data_[0..sizeof(CordRep*)-1]. + alignas(absl::cord_internal::CordRep*) char data_[kMaxInline + 1]; + }; + InlineRep contents_; + + // Helper for MemoryUsage() + static size_t MemoryUsageAux(const absl::cord_internal::CordRep* rep); + + // Helper for GetFlat() and TryFlat() + static bool GetFlatAux(absl::cord_internal::CordRep* rep, + absl::string_view* fragment); + + // Helper for ForEachChunk() + static void ForEachChunkAux( + absl::cord_internal::CordRep* rep, + absl::FunctionRef<void(absl::string_view)> callback); + + // The destructor for non-empty Cords. + void DestroyCordSlow(); + + // Out-of-line implementation of slower parts of logic. + void CopyToArraySlowPath(char* dst) const; + int CompareSlowPath(absl::string_view rhs, size_t compared_size, + size_t size_to_compare) const; + int CompareSlowPath(const Cord& rhs, size_t compared_size, + size_t size_to_compare) const; + bool EqualsImpl(absl::string_view rhs, size_t size_to_compare) const; + bool EqualsImpl(const Cord& rhs, size_t size_to_compare) const; + int CompareImpl(const Cord& rhs) const; + + template <typename ResultType, typename RHS> + friend ResultType GenericCompare(const Cord& lhs, const RHS& rhs, + size_t size_to_compare); + static absl::string_view GetFirstChunk(const Cord& c); + static absl::string_view GetFirstChunk(absl::string_view sv); + + // Returns a new reference to contents_.tree(), or steals an existing + // reference if called on an rvalue. + absl::cord_internal::CordRep* TakeRep() const&; + absl::cord_internal::CordRep* TakeRep() &&; + + // Helper for Append() + template <typename C> + void AppendImpl(C&& src); +}; + +ABSL_NAMESPACE_END +} // namespace absl + +namespace absl { +ABSL_NAMESPACE_BEGIN + +// allow a Cord to be logged +extern std::ostream& operator<<(std::ostream& out, const Cord& cord); + +// ------------------------------------------------------------------ +// Internal details follow. Clients should ignore. + +namespace cord_internal { + +// Fast implementation of memmove for up to 15 bytes. This implementation is +// safe for overlapping regions. If nullify_tail is true, the destination is +// padded with '\0' up to 16 bytes. +inline void SmallMemmove(char* dst, const char* src, size_t n, + bool nullify_tail = false) { + if (n >= 8) { + assert(n <= 16); + uint64_t buf1; + uint64_t buf2; + memcpy(&buf1, src, 8); + memcpy(&buf2, src + n - 8, 8); + if (nullify_tail) { + memset(dst + 8, 0, 8); + } + memcpy(dst, &buf1, 8); + memcpy(dst + n - 8, &buf2, 8); + } else if (n >= 4) { + uint32_t buf1; + uint32_t buf2; + memcpy(&buf1, src, 4); + memcpy(&buf2, src + n - 4, 4); + if (nullify_tail) { + memset(dst + 4, 0, 4); + memset(dst + 8, 0, 8); + } + memcpy(dst, &buf1, 4); + memcpy(dst + n - 4, &buf2, 4); + } else { + if (n != 0) { + dst[0] = src[0]; + dst[n / 2] = src[n / 2]; + dst[n - 1] = src[n - 1]; + } + if (nullify_tail) { + memset(dst + 8, 0, 8); + memset(dst + n, 0, 8); + } + } +} + +struct ExternalRepReleaserPair { + CordRep* rep; + void* releaser_address; +}; + +// Allocates a new external `CordRep` and returns a pointer to it and a pointer +// to `releaser_size` bytes where the desired releaser can be constructed. +// Expects `data` to be non-empty. +ExternalRepReleaserPair NewExternalWithUninitializedReleaser( + absl::string_view data, ExternalReleaserInvoker invoker, + size_t releaser_size); + +struct Rank1 {}; +struct Rank0 : Rank1 {}; + +template <typename Releaser, typename = ::absl::base_internal::InvokeT< + Releaser, absl::string_view>> +void InvokeReleaser(Rank0, Releaser&& releaser, absl::string_view data) { + ::absl::base_internal::Invoke(std::forward<Releaser>(releaser), data); +} + +template <typename Releaser, + typename = ::absl::base_internal::InvokeT<Releaser>> +void InvokeReleaser(Rank1, Releaser&& releaser, absl::string_view) { + ::absl::base_internal::Invoke(std::forward<Releaser>(releaser)); +} + +// Creates a new `CordRep` that owns `data` and `releaser` and returns a pointer +// to it, or `nullptr` if `data` was empty. +template <typename Releaser> +// NOLINTNEXTLINE - suppress clang-tidy raw pointer return. +CordRep* NewExternalRep(absl::string_view data, Releaser&& releaser) { + static_assert( +#if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__) + alignof(Releaser) <= __STDCPP_DEFAULT_NEW_ALIGNMENT__, +#else + alignof(Releaser) <= alignof(max_align_t), +#endif + "Releasers with alignment requirement greater than what is returned by " + "default `::operator new()` are not supported."); + + using ReleaserType = absl::decay_t<Releaser>; + if (data.empty()) { + // Never create empty external nodes. + InvokeReleaser(Rank0{}, ReleaserType(std::forward<Releaser>(releaser)), + data); + return nullptr; + } + + auto releaser_invoker = [](void* type_erased_releaser, absl::string_view d) { + auto* my_releaser = static_cast<ReleaserType*>(type_erased_releaser); + InvokeReleaser(Rank0{}, std::move(*my_releaser), d); + my_releaser->~ReleaserType(); + return sizeof(Releaser); + }; + + ExternalRepReleaserPair external = NewExternalWithUninitializedReleaser( + data, releaser_invoker, sizeof(releaser)); + ::new (external.releaser_address) + ReleaserType(std::forward<Releaser>(releaser)); + return external.rep; +} + +// Overload for function reference types that dispatches using a function +// pointer because there are no `alignof()` or `sizeof()` a function reference. +// NOLINTNEXTLINE - suppress clang-tidy raw pointer return. +inline CordRep* NewExternalRep(absl::string_view data, + void (&releaser)(absl::string_view)) { + return NewExternalRep(data, &releaser); +} + +} // namespace cord_internal + +template <typename Releaser> +Cord MakeCordFromExternal(absl::string_view data, Releaser&& releaser) { + Cord cord; + cord.contents_.set_tree(::absl::cord_internal::NewExternalRep( + data, std::forward<Releaser>(releaser))); + return cord; +} + +inline Cord::InlineRep::InlineRep(const Cord::InlineRep& src) { + cord_internal::SmallMemmove(data_, src.data_, sizeof(data_)); +} + +inline Cord::InlineRep::InlineRep(Cord::InlineRep&& src) { + memcpy(data_, src.data_, sizeof(data_)); + memset(src.data_, 0, sizeof(data_)); +} + +inline Cord::InlineRep& Cord::InlineRep::operator=(const Cord::InlineRep& src) { + if (this == &src) { + return *this; + } + if (!is_tree() && !src.is_tree()) { + cord_internal::SmallMemmove(data_, src.data_, sizeof(data_)); + return *this; + } + AssignSlow(src); + return *this; +} + +inline Cord::InlineRep& Cord::InlineRep::operator=( + Cord::InlineRep&& src) noexcept { + if (is_tree()) { + ClearSlow(); + } + memcpy(data_, src.data_, sizeof(data_)); + memset(src.data_, 0, sizeof(data_)); + return *this; +} + +inline void Cord::InlineRep::Swap(Cord::InlineRep* rhs) { + if (rhs == this) { + return; + } + + Cord::InlineRep tmp; + cord_internal::SmallMemmove(tmp.data_, data_, sizeof(data_)); + cord_internal::SmallMemmove(data_, rhs->data_, sizeof(data_)); + cord_internal::SmallMemmove(rhs->data_, tmp.data_, sizeof(data_)); +} + +inline const char* Cord::InlineRep::data() const { + return is_tree() ? nullptr : data_; +} + +inline absl::cord_internal::CordRep* Cord::InlineRep::tree() const { + if (is_tree()) { + absl::cord_internal::CordRep* rep; + memcpy(&rep, data_, sizeof(rep)); + return rep; + } else { + return nullptr; + } +} + +inline bool Cord::InlineRep::empty() const { return data_[kMaxInline] == 0; } + +inline size_t Cord::InlineRep::size() const { + const char tag = data_[kMaxInline]; + if (tag <= kMaxInline) return tag; + return static_cast<size_t>(tree()->length); +} + +inline void Cord::InlineRep::set_tree(absl::cord_internal::CordRep* rep) { + if (rep == nullptr) { + memset(data_, 0, sizeof(data_)); + } else { + bool was_tree = is_tree(); + memcpy(data_, &rep, sizeof(rep)); + memset(data_ + sizeof(rep), 0, sizeof(data_) - sizeof(rep) - 1); + if (!was_tree) { + data_[kMaxInline] = kTreeFlag; + } + } +} + +inline void Cord::InlineRep::replace_tree(absl::cord_internal::CordRep* rep) { + ABSL_ASSERT(is_tree()); + if (ABSL_PREDICT_FALSE(rep == nullptr)) { + set_tree(rep); + return; + } + memcpy(data_, &rep, sizeof(rep)); + memset(data_ + sizeof(rep), 0, sizeof(data_) - sizeof(rep) - 1); +} + +inline absl::cord_internal::CordRep* Cord::InlineRep::clear() { + const char tag = data_[kMaxInline]; + absl::cord_internal::CordRep* result = nullptr; + if (tag > kMaxInline) { + memcpy(&result, data_, sizeof(result)); + } + memset(data_, 0, sizeof(data_)); // Clear the cord + return result; +} + +inline void Cord::InlineRep::CopyToArray(char* dst) const { + assert(!is_tree()); + size_t n = data_[kMaxInline]; + assert(n != 0); + cord_internal::SmallMemmove(dst, data_, n); +} + +constexpr inline Cord::Cord() noexcept {} + +inline Cord& Cord::operator=(const Cord& x) { + contents_ = x.contents_; + return *this; +} + +inline Cord::Cord(Cord&& src) noexcept : contents_(std::move(src.contents_)) {} + +inline Cord& Cord::operator=(Cord&& x) noexcept { + contents_ = std::move(x.contents_); + return *this; +} + +template <typename T, Cord::EnableIfString<T>> +inline Cord& Cord::operator=(T&& src) { + *this = absl::string_view(src); + return *this; +} + +inline size_t Cord::size() const { + // Length is 1st field in str.rep_ + return contents_.size(); +} + +inline bool Cord::empty() const { return contents_.empty(); } + +inline size_t Cord::EstimatedMemoryUsage() const { + size_t result = sizeof(Cord); + if (const absl::cord_internal::CordRep* rep = contents_.tree()) { + result += MemoryUsageAux(rep); + } + return result; +} + +inline absl::optional<absl::string_view> Cord::TryFlat() const { + absl::cord_internal::CordRep* rep = contents_.tree(); + if (rep == nullptr) { + return absl::string_view(contents_.data(), contents_.size()); + } + absl::string_view fragment; + if (GetFlatAux(rep, &fragment)) { + return fragment; + } + return absl::nullopt; +} + +inline absl::string_view Cord::Flatten() { + absl::cord_internal::CordRep* rep = contents_.tree(); + if (rep == nullptr) { + return absl::string_view(contents_.data(), contents_.size()); + } else { + absl::string_view already_flat_contents; + if (GetFlatAux(rep, &already_flat_contents)) { + return already_flat_contents; + } + } + return FlattenSlowPath(); +} + +inline void Cord::Append(absl::string_view src) { + contents_.AppendArray(src.data(), src.size()); +} + +template <typename T, Cord::EnableIfString<T>> +inline void Cord::Append(T&& src) { + // Note that this function reserves the right to reuse the `string&&`'s + // memory and that it will do so in the future. + Append(absl::string_view(src)); +} + +template <typename T, Cord::EnableIfString<T>> +inline void Cord::Prepend(T&& src) { + // Note that this function reserves the right to reuse the `string&&`'s + // memory and that it will do so in the future. + Prepend(absl::string_view(src)); +} + +inline int Cord::Compare(const Cord& rhs) const { + if (!contents_.is_tree() && !rhs.contents_.is_tree()) { + return contents_.BitwiseCompare(rhs.contents_); + } + + return CompareImpl(rhs); +} + +// Does 'this' cord start/end with rhs +inline bool Cord::StartsWith(const Cord& rhs) const { + if (contents_.IsSame(rhs.contents_)) return true; + size_t rhs_size = rhs.size(); + if (size() < rhs_size) return false; + return EqualsImpl(rhs, rhs_size); +} + +inline bool Cord::StartsWith(absl::string_view rhs) const { + size_t rhs_size = rhs.size(); + if (size() < rhs_size) return false; + return EqualsImpl(rhs, rhs_size); +} + +inline Cord::ChunkIterator::ChunkIterator(const Cord* cord) + : bytes_remaining_(cord->size()) { + if (cord->empty()) return; + if (cord->contents_.is_tree()) { + stack_of_right_children_.push_back(cord->contents_.tree()); + operator++(); + } else { + current_chunk_ = absl::string_view(cord->contents_.data(), cord->size()); + } +} + +inline Cord::ChunkIterator Cord::ChunkIterator::operator++(int) { + ChunkIterator tmp(*this); + operator++(); + return tmp; +} + +inline bool Cord::ChunkIterator::operator==(const ChunkIterator& other) const { + return bytes_remaining_ == other.bytes_remaining_; +} + +inline bool Cord::ChunkIterator::operator!=(const ChunkIterator& other) const { + return !(*this == other); +} + +inline Cord::ChunkIterator::reference Cord::ChunkIterator::operator*() const { + assert(bytes_remaining_ != 0); + return current_chunk_; +} + +inline Cord::ChunkIterator::pointer Cord::ChunkIterator::operator->() const { + assert(bytes_remaining_ != 0); + return ¤t_chunk_; +} + +inline void Cord::ChunkIterator::RemoveChunkPrefix(size_t n) { + assert(n < current_chunk_.size()); + current_chunk_.remove_prefix(n); + bytes_remaining_ -= n; +} + +inline void Cord::ChunkIterator::AdvanceBytes(size_t n) { + if (ABSL_PREDICT_TRUE(n < current_chunk_.size())) { + RemoveChunkPrefix(n); + } else if (n != 0) { + AdvanceBytesSlowPath(n); + } +} + +inline Cord::ChunkIterator Cord::chunk_begin() const { + return ChunkIterator(this); +} + +inline Cord::ChunkIterator Cord::chunk_end() const { return ChunkIterator(); } + +inline Cord::ChunkIterator Cord::ChunkRange::begin() const { + return cord_->chunk_begin(); +} + +inline Cord::ChunkIterator Cord::ChunkRange::end() const { + return cord_->chunk_end(); +} + +inline Cord::ChunkRange Cord::Chunks() const { return ChunkRange(this); } + +inline Cord::CharIterator& Cord::CharIterator::operator++() { + if (ABSL_PREDICT_TRUE(chunk_iterator_->size() > 1)) { + chunk_iterator_.RemoveChunkPrefix(1); + } else { + ++chunk_iterator_; + } + return *this; +} + +inline Cord::CharIterator Cord::CharIterator::operator++(int) { + CharIterator tmp(*this); + operator++(); + return tmp; +} + +inline bool Cord::CharIterator::operator==(const CharIterator& other) const { + return chunk_iterator_ == other.chunk_iterator_; +} + +inline bool Cord::CharIterator::operator!=(const CharIterator& other) const { + return !(*this == other); +} + +inline Cord::CharIterator::reference Cord::CharIterator::operator*() const { + return *chunk_iterator_->data(); +} + +inline Cord::CharIterator::pointer Cord::CharIterator::operator->() const { + return chunk_iterator_->data(); +} + +inline Cord Cord::AdvanceAndRead(CharIterator* it, size_t n_bytes) { + assert(it != nullptr); + return it->chunk_iterator_.AdvanceAndReadBytes(n_bytes); +} + +inline void Cord::Advance(CharIterator* it, size_t n_bytes) { + assert(it != nullptr); + it->chunk_iterator_.AdvanceBytes(n_bytes); +} + +inline absl::string_view Cord::ChunkRemaining(const CharIterator& it) { + return *it.chunk_iterator_; +} + +inline Cord::CharIterator Cord::char_begin() const { + return CharIterator(this); +} + +inline Cord::CharIterator Cord::char_end() const { return CharIterator(); } + +inline Cord::CharIterator Cord::CharRange::begin() const { + return cord_->char_begin(); +} + +inline Cord::CharIterator Cord::CharRange::end() const { + return cord_->char_end(); +} + +inline Cord::CharRange Cord::Chars() const { return CharRange(this); } + +inline void Cord::ForEachChunk( + absl::FunctionRef<void(absl::string_view)> callback) const { + absl::cord_internal::CordRep* rep = contents_.tree(); + if (rep == nullptr) { + callback(absl::string_view(contents_.data(), contents_.size())); + } else { + return ForEachChunkAux(rep, callback); + } +} + +// Nonmember Cord-to-Cord relational operarators. +inline bool operator==(const Cord& lhs, const Cord& rhs) { + if (lhs.contents_.IsSame(rhs.contents_)) return true; + size_t rhs_size = rhs.size(); + if (lhs.size() != rhs_size) return false; + return lhs.EqualsImpl(rhs, rhs_size); +} + +inline bool operator!=(const Cord& x, const Cord& y) { return !(x == y); } +inline bool operator<(const Cord& x, const Cord& y) { + return x.Compare(y) < 0; +} +inline bool operator>(const Cord& x, const Cord& y) { + return x.Compare(y) > 0; +} +inline bool operator<=(const Cord& x, const Cord& y) { + return x.Compare(y) <= 0; +} +inline bool operator>=(const Cord& x, const Cord& y) { + return x.Compare(y) >= 0; +} + +// Nonmember Cord-to-absl::string_view relational operators. +// +// Due to implicit conversions, these also enable comparisons of Cord with +// with std::string, ::string, and const char*. +inline bool operator==(const Cord& lhs, absl::string_view rhs) { + size_t lhs_size = lhs.size(); + size_t rhs_size = rhs.size(); + if (lhs_size != rhs_size) return false; + return lhs.EqualsImpl(rhs, rhs_size); +} + +inline bool operator==(absl::string_view x, const Cord& y) { return y == x; } +inline bool operator!=(const Cord& x, absl::string_view y) { return !(x == y); } +inline bool operator!=(absl::string_view x, const Cord& y) { return !(x == y); } +inline bool operator<(const Cord& x, absl::string_view y) { + return x.Compare(y) < 0; +} +inline bool operator<(absl::string_view x, const Cord& y) { + return y.Compare(x) > 0; +} +inline bool operator>(const Cord& x, absl::string_view y) { return y < x; } +inline bool operator>(absl::string_view x, const Cord& y) { return y < x; } +inline bool operator<=(const Cord& x, absl::string_view y) { return !(y < x); } +inline bool operator<=(absl::string_view x, const Cord& y) { return !(y < x); } +inline bool operator>=(const Cord& x, absl::string_view y) { return !(x < y); } +inline bool operator>=(absl::string_view x, const Cord& y) { return !(x < y); } + +// Overload of swap for Cord. The use of non-const references is +// required. :( +inline void swap(Cord& x, Cord& y) noexcept { y.contents_.Swap(&x.contents_); } + +// Some internals exposed to test code. +namespace strings_internal { +class CordTestAccess { + public: + static size_t FlatOverhead(); + static size_t MaxFlatLength(); + static size_t SizeofCordRepConcat(); + static size_t SizeofCordRepExternal(); + static size_t SizeofCordRepSubstring(); + static size_t FlatTagToLength(uint8_t tag); + static uint8_t LengthToTag(size_t s); +}; +} // namespace strings_internal +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_STRINGS_CORD_H_
diff --git a/third_party/abseil-cpp/absl/strings/cord_test.cc b/third_party/abseil-cpp/absl/strings/cord_test.cc new file mode 100644 index 0000000..f2d81d4 --- /dev/null +++ b/third_party/abseil-cpp/absl/strings/cord_test.cc
@@ -0,0 +1,1629 @@ +#include "absl/strings/cord.h" + +#include <algorithm> +#include <climits> +#include <cstdio> +#include <iterator> +#include <map> +#include <numeric> +#include <random> +#include <sstream> +#include <type_traits> +#include <utility> +#include <vector> + +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "absl/base/casts.h" +#include "absl/base/config.h" +#include "absl/base/internal/endian.h" +#include "absl/base/internal/raw_logging.h" +#include "absl/container/fixed_array.h" +#include "absl/strings/cord_test_helpers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" + +typedef std::mt19937_64 RandomEngine; + +static std::string RandomLowercaseString(RandomEngine* rng); +static std::string RandomLowercaseString(RandomEngine* rng, size_t length); + +static int GetUniformRandomUpTo(RandomEngine* rng, int upper_bound) { + if (upper_bound > 0) { + std::uniform_int_distribution<int> uniform(0, upper_bound - 1); + return uniform(*rng); + } else { + return 0; + } +} + +static size_t GetUniformRandomUpTo(RandomEngine* rng, size_t upper_bound) { + if (upper_bound > 0) { + std::uniform_int_distribution<size_t> uniform(0, upper_bound - 1); + return uniform(*rng); + } else { + return 0; + } +} + +static int32_t GenerateSkewedRandom(RandomEngine* rng, int max_log) { + const uint32_t base = (*rng)() % (max_log + 1); + const uint32_t mask = ((base < 32) ? (1u << base) : 0u) - 1u; + return (*rng)() & mask; +} + +static std::string RandomLowercaseString(RandomEngine* rng) { + int length; + std::bernoulli_distribution one_in_1k(0.001); + std::bernoulli_distribution one_in_10k(0.0001); + // With low probability, make a large fragment + if (one_in_10k(*rng)) { + length = GetUniformRandomUpTo(rng, 1048576); + } else if (one_in_1k(*rng)) { + length = GetUniformRandomUpTo(rng, 10000); + } else { + length = GenerateSkewedRandom(rng, 10); + } + return RandomLowercaseString(rng, length); +} + +static std::string RandomLowercaseString(RandomEngine* rng, size_t length) { + std::string result(length, '\0'); + std::uniform_int_distribution<int> chars('a', 'z'); + std::generate(result.begin(), result.end(), + [&]() { return static_cast<char>(chars(*rng)); }); + return result; +} + +static void DoNothing(absl::string_view /* data */, void* /* arg */) {} + +static void DeleteExternalString(absl::string_view data, void* arg) { + std::string* s = reinterpret_cast<std::string*>(arg); + EXPECT_EQ(data, *s); + delete s; +} + +// Add "s" to *dst via `MakeCordFromExternal` +static void AddExternalMemory(absl::string_view s, absl::Cord* dst) { + std::string* str = new std::string(s.data(), s.size()); + dst->Append(absl::MakeCordFromExternal(*str, [str](absl::string_view data) { + DeleteExternalString(data, str); + })); +} + +static void DumpGrowth() { + absl::Cord str; + for (int i = 0; i < 1000; i++) { + char c = 'a' + i % 26; + str.Append(absl::string_view(&c, 1)); + } +} + +// Make a Cord with some number of fragments. Return the size (in bytes) +// of the smallest fragment. +static size_t AppendWithFragments(const std::string& s, RandomEngine* rng, + absl::Cord* cord) { + size_t j = 0; + const size_t max_size = s.size() / 5; // Make approx. 10 fragments + size_t min_size = max_size; // size of smallest fragment + while (j < s.size()) { + size_t N = 1 + GetUniformRandomUpTo(rng, max_size); + if (N > (s.size() - j)) { + N = s.size() - j; + } + if (N < min_size) { + min_size = N; + } + + std::bernoulli_distribution coin_flip(0.5); + if (coin_flip(*rng)) { + // Grow by adding an external-memory. + AddExternalMemory(absl::string_view(s.data() + j, N), cord); + } else { + cord->Append(absl::string_view(s.data() + j, N)); + } + j += N; + } + return min_size; +} + +// Add an external memory that contains the specified std::string to cord +static void AddNewStringBlock(const std::string& str, absl::Cord* dst) { + char* data = new char[str.size()]; + memcpy(data, str.data(), str.size()); + dst->Append(absl::MakeCordFromExternal( + absl::string_view(data, str.size()), + [](absl::string_view s) { delete[] s.data(); })); +} + +// Make a Cord out of many different types of nodes. +static absl::Cord MakeComposite() { + absl::Cord cord; + cord.Append("the"); + AddExternalMemory(" quick brown", &cord); + AddExternalMemory(" fox jumped", &cord); + + absl::Cord full(" over"); + AddExternalMemory(" the lazy", &full); + AddNewStringBlock(" dog slept the whole day away", &full); + absl::Cord substring = full.Subcord(0, 18); + + // Make substring long enough to defeat the copying fast path in Append. + substring.Append(std::string(1000, '.')); + cord.Append(substring); + cord = cord.Subcord(0, cord.size() - 998); // Remove most of extra junk + + return cord; +} + +namespace absl { +ABSL_NAMESPACE_BEGIN + +class CordTestPeer { + public: + static void ForEachChunk( + const Cord& c, absl::FunctionRef<void(absl::string_view)> callback) { + c.ForEachChunk(callback); + } +}; + +ABSL_NAMESPACE_END +} // namespace absl + +TEST(Cord, AllFlatSizes) { + using absl::strings_internal::CordTestAccess; + + for (size_t s = 0; s < CordTestAccess::MaxFlatLength(); s++) { + // Make a string of length s. + std::string src; + while (src.size() < s) { + src.push_back('a' + (src.size() % 26)); + } + + absl::Cord dst(src); + EXPECT_EQ(std::string(dst), src) << s; + } +} + +// We create a Cord at least 128GB in size using the fact that Cords can +// internally reference-count; thus the Cord is enormous without actually +// consuming very much memory. +TEST(GigabyteCord, FromExternal) { + const size_t one_gig = 1024U * 1024U * 1024U; + size_t max_size = 2 * one_gig; + if (sizeof(max_size) > 4) max_size = 128 * one_gig; + + size_t length = 128 * 1024; + char* data = new char[length]; + absl::Cord from = absl::MakeCordFromExternal( + absl::string_view(data, length), + [](absl::string_view sv) { delete[] sv.data(); }); + + // This loop may seem odd due to its combination of exponential doubling of + // size and incremental size increases. We do it incrementally to be sure the + // Cord will need rebalancing and will exercise code that, in the past, has + // caused crashes in production. We grow exponentially so that the code will + // execute in a reasonable amount of time. + absl::Cord c; + ABSL_RAW_LOG(INFO, "Made a Cord with %zu bytes!", c.size()); + c.Append(from); + while (c.size() < max_size) { + c.Append(c); + c.Append(from); + c.Append(from); + c.Append(from); + c.Append(from); + } + + for (int i = 0; i < 1024; ++i) { + c.Append(from); + } + ABSL_RAW_LOG(INFO, "Made a Cord with %zu bytes!", c.size()); + // Note: on a 32-bit build, this comes out to 2,818,048,000 bytes. + // Note: on a 64-bit build, this comes out to 171,932,385,280 bytes. +} + +static absl::Cord MakeExternalCord(int size) { + char* buffer = new char[size]; + memset(buffer, 'x', size); + absl::Cord cord; + cord.Append(absl::MakeCordFromExternal( + absl::string_view(buffer, size), + [](absl::string_view s) { delete[] s.data(); })); + return cord; +} + +// Extern to fool clang that this is not constant. Needed to suppress +// a warning of unsafe code we want to test. +extern bool my_unique_true_boolean; +bool my_unique_true_boolean = true; + +TEST(Cord, Assignment) { + absl::Cord x(absl::string_view("hi there")); + absl::Cord y(x); + ASSERT_EQ(std::string(x), "hi there"); + ASSERT_EQ(std::string(y), "hi there"); + ASSERT_TRUE(x == y); + ASSERT_TRUE(x <= y); + ASSERT_TRUE(y <= x); + + x = absl::string_view("foo"); + ASSERT_EQ(std::string(x), "foo"); + ASSERT_EQ(std::string(y), "hi there"); + ASSERT_TRUE(x < y); + ASSERT_TRUE(y > x); + ASSERT_TRUE(x != y); + ASSERT_TRUE(x <= y); + ASSERT_TRUE(y >= x); + + x = "foo"; + ASSERT_EQ(x, "foo"); + + // Test that going from inline rep to tree we don't leak memory. + std::vector<std::pair<absl::string_view, absl::string_view>> + test_string_pairs = {{"hi there", "foo"}, + {"loooooong coooooord", "short cord"}, + {"short cord", "loooooong coooooord"}, + {"loooooong coooooord1", "loooooong coooooord2"}}; + for (std::pair<absl::string_view, absl::string_view> test_strings : + test_string_pairs) { + absl::Cord tmp(test_strings.first); + absl::Cord z(std::move(tmp)); + ASSERT_EQ(std::string(z), test_strings.first); + tmp = test_strings.second; + z = std::move(tmp); + ASSERT_EQ(std::string(z), test_strings.second); + } + { + // Test that self-move assignment doesn't crash/leak. + // Do not write such code! + absl::Cord my_small_cord("foo"); + absl::Cord my_big_cord("loooooong coooooord"); + // Bypass clang's warning on self move-assignment. + absl::Cord* my_small_alias = + my_unique_true_boolean ? &my_small_cord : &my_big_cord; + absl::Cord* my_big_alias = + !my_unique_true_boolean ? &my_small_cord : &my_big_cord; + + *my_small_alias = std::move(my_small_cord); + *my_big_alias = std::move(my_big_cord); + // my_small_cord and my_big_cord are in an unspecified but valid + // state, and will be correctly destroyed here. + } +} + +TEST(Cord, StartsEndsWith) { + absl::Cord x(absl::string_view("abcde")); + absl::Cord empty(""); + + ASSERT_TRUE(x.StartsWith(absl::Cord("abcde"))); + ASSERT_TRUE(x.StartsWith(absl::Cord("abc"))); + ASSERT_TRUE(x.StartsWith(absl::Cord(""))); + ASSERT_TRUE(empty.StartsWith(absl::Cord(""))); + ASSERT_TRUE(x.EndsWith(absl::Cord("abcde"))); + ASSERT_TRUE(x.EndsWith(absl::Cord("cde"))); + ASSERT_TRUE(x.EndsWith(absl::Cord(""))); + ASSERT_TRUE(empty.EndsWith(absl::Cord(""))); + + ASSERT_TRUE(!x.StartsWith(absl::Cord("xyz"))); + ASSERT_TRUE(!empty.StartsWith(absl::Cord("xyz"))); + ASSERT_TRUE(!x.EndsWith(absl::Cord("xyz"))); + ASSERT_TRUE(!empty.EndsWith(absl::Cord("xyz"))); + + ASSERT_TRUE(x.StartsWith("abcde")); + ASSERT_TRUE(x.StartsWith("abc")); + ASSERT_TRUE(x.StartsWith("")); + ASSERT_TRUE(empty.StartsWith("")); + ASSERT_TRUE(x.EndsWith("abcde")); + ASSERT_TRUE(x.EndsWith("cde")); + ASSERT_TRUE(x.EndsWith("")); + ASSERT_TRUE(empty.EndsWith("")); + + ASSERT_TRUE(!x.StartsWith("xyz")); + ASSERT_TRUE(!empty.StartsWith("xyz")); + ASSERT_TRUE(!x.EndsWith("xyz")); + ASSERT_TRUE(!empty.EndsWith("xyz")); +} + +TEST(Cord, Subcord) { + RandomEngine rng(testing::GTEST_FLAG(random_seed)); + const std::string s = RandomLowercaseString(&rng, 1024); + + absl::Cord a; + AppendWithFragments(s, &rng, &a); + ASSERT_EQ(s.size(), a.size()); + + // Check subcords of a, from a variety of interesting points. + std::set<size_t> positions; + for (int i = 0; i <= 32; ++i) { + positions.insert(i); + positions.insert(i * 32 - 1); + positions.insert(i * 32); + positions.insert(i * 32 + 1); + positions.insert(a.size() - i); + } + positions.insert(237); + positions.insert(732); + for (size_t pos : positions) { + if (pos > a.size()) continue; + for (size_t end_pos : positions) { + if (end_pos < pos || end_pos > a.size()) continue; + absl::Cord sa = a.Subcord(pos, end_pos - pos); + EXPECT_EQ(absl::string_view(s).substr(pos, end_pos - pos), + std::string(sa)) + << a; + } + } + + // Do the same thing for an inline cord. + const std::string sh = "short"; + absl::Cord c(sh); + for (size_t pos = 0; pos <= sh.size(); ++pos) { + for (size_t n = 0; n <= sh.size() - pos; ++n) { + absl::Cord sc = c.Subcord(pos, n); + EXPECT_EQ(sh.substr(pos, n), std::string(sc)) << c; + } + } + + // Check subcords of subcords. + absl::Cord sa = a.Subcord(0, a.size()); + std::string ss = s.substr(0, s.size()); + while (sa.size() > 1) { + sa = sa.Subcord(1, sa.size() - 2); + ss = ss.substr(1, ss.size() - 2); + EXPECT_EQ(ss, std::string(sa)) << a; + if (HasFailure()) break; // halt cascade + } + + // It is OK to ask for too much. + sa = a.Subcord(0, a.size() + 1); + EXPECT_EQ(s, std::string(sa)); + + // It is OK to ask for something beyond the end. + sa = a.Subcord(a.size() + 1, 0); + EXPECT_TRUE(sa.empty()); + sa = a.Subcord(a.size() + 1, 1); + EXPECT_TRUE(sa.empty()); +} + +TEST(Cord, Swap) { + absl::string_view a("Dexter"); + absl::string_view b("Mandark"); + absl::Cord x(a); + absl::Cord y(b); + swap(x, y); + ASSERT_EQ(x, absl::Cord(b)); + ASSERT_EQ(y, absl::Cord(a)); +} + +static void VerifyCopyToString(const absl::Cord& cord) { + std::string initially_empty; + absl::CopyCordToString(cord, &initially_empty); + EXPECT_EQ(initially_empty, cord); + + constexpr size_t kInitialLength = 1024; + std::string has_initial_contents(kInitialLength, 'x'); + const char* address_before_copy = has_initial_contents.data(); + absl::CopyCordToString(cord, &has_initial_contents); + EXPECT_EQ(has_initial_contents, cord); + + if (cord.size() <= kInitialLength) { + EXPECT_EQ(has_initial_contents.data(), address_before_copy) + << "CopyCordToString allocated new string storage; " + "has_initial_contents = \"" + << has_initial_contents << "\""; + } +} + +TEST(Cord, CopyToString) { + VerifyCopyToString(absl::Cord()); + VerifyCopyToString(absl::Cord("small cord")); + VerifyCopyToString( + absl::MakeFragmentedCord({"fragmented ", "cord ", "to ", "test ", + "copying ", "to ", "a ", "string."})); +} + +TEST(TryFlat, Empty) { + absl::Cord c; + EXPECT_EQ(c.TryFlat(), ""); +} + +TEST(TryFlat, Flat) { + absl::Cord c("hello"); + EXPECT_EQ(c.TryFlat(), "hello"); +} + +TEST(TryFlat, SubstrInlined) { + absl::Cord c("hello"); + c.RemovePrefix(1); + EXPECT_EQ(c.TryFlat(), "ello"); +} + +TEST(TryFlat, SubstrFlat) { + absl::Cord c("longer than 15 bytes"); + c.RemovePrefix(1); + EXPECT_EQ(c.TryFlat(), "onger than 15 bytes"); +} + +TEST(TryFlat, Concat) { + absl::Cord c = absl::MakeFragmentedCord({"hel", "lo"}); + EXPECT_EQ(c.TryFlat(), absl::nullopt); +} + +TEST(TryFlat, External) { + absl::Cord c = absl::MakeCordFromExternal("hell", [](absl::string_view) {}); + EXPECT_EQ(c.TryFlat(), "hell"); +} + +TEST(TryFlat, SubstrExternal) { + absl::Cord c = absl::MakeCordFromExternal("hell", [](absl::string_view) {}); + c.RemovePrefix(1); + EXPECT_EQ(c.TryFlat(), "ell"); +} + +TEST(TryFlat, SubstrConcat) { + absl::Cord c = absl::MakeFragmentedCord({"hello", " world"}); + c.RemovePrefix(1); + EXPECT_EQ(c.TryFlat(), absl::nullopt); +} + +static bool IsFlat(const absl::Cord& c) { + return c.chunk_begin() == c.chunk_end() || ++c.chunk_begin() == c.chunk_end(); +} + +static void VerifyFlatten(absl::Cord c) { + std::string old_contents(c); + absl::string_view old_flat; + bool already_flat_and_non_empty = IsFlat(c) && !c.empty(); + if (already_flat_and_non_empty) { + old_flat = *c.chunk_begin(); + } + absl::string_view new_flat = c.Flatten(); + + // Verify that the contents of the flattened Cord are correct. + EXPECT_EQ(new_flat, old_contents); + EXPECT_EQ(std::string(c), old_contents); + + // If the Cord contained data and was already flat, verify that the data + // wasn't copied. + if (already_flat_and_non_empty) { + EXPECT_EQ(old_flat.data(), new_flat.data()) + << "Allocated new memory even though the Cord was already flat."; + } + + // Verify that the flattened Cord is in fact flat. + EXPECT_TRUE(IsFlat(c)); +} + +TEST(Cord, Flatten) { + VerifyFlatten(absl::Cord()); + VerifyFlatten(absl::Cord("small cord")); + VerifyFlatten(absl::Cord("larger than small buffer optimization")); + VerifyFlatten(absl::MakeFragmentedCord({"small ", "fragmented ", "cord"})); + + // Test with a cord that is longer than the largest flat buffer + RandomEngine rng(testing::GTEST_FLAG(random_seed)); + VerifyFlatten(absl::Cord(RandomLowercaseString(&rng, 8192))); +} + +// Test data +namespace { +class TestData { + private: + std::vector<std::string> data_; + + // Return a std::string of the specified length. + static std::string MakeString(int length) { + std::string result; + char buf[30]; + snprintf(buf, sizeof(buf), "(%d)", length); + while (result.size() < length) { + result += buf; + } + result.resize(length); + return result; + } + + public: + TestData() { + // short strings increasing in length by one + for (int i = 0; i < 30; i++) { + data_.push_back(MakeString(i)); + } + + // strings around half kMaxFlatLength + static const int kMaxFlatLength = 4096 - 9; + static const int kHalf = kMaxFlatLength / 2; + + for (int i = -10; i <= +10; i++) { + data_.push_back(MakeString(kHalf + i)); + } + + for (int i = -10; i <= +10; i++) { + data_.push_back(MakeString(kMaxFlatLength + i)); + } + } + + size_t size() const { return data_.size(); } + const std::string& data(size_t i) const { return data_[i]; } +}; +} // namespace + +TEST(Cord, MultipleLengths) { + TestData d; + for (size_t i = 0; i < d.size(); i++) { + std::string a = d.data(i); + + { // Construct from Cord + absl::Cord tmp(a); + absl::Cord x(tmp); + EXPECT_EQ(a, std::string(x)) << "'" << a << "'"; + } + + { // Construct from absl::string_view + absl::Cord x(a); + EXPECT_EQ(a, std::string(x)) << "'" << a << "'"; + } + + { // Append cord to self + absl::Cord self(a); + self.Append(self); + EXPECT_EQ(a + a, std::string(self)) << "'" << a << "' + '" << a << "'"; + } + + { // Prepend cord to self + absl::Cord self(a); + self.Prepend(self); + EXPECT_EQ(a + a, std::string(self)) << "'" << a << "' + '" << a << "'"; + } + + // Try to append/prepend others + for (size_t j = 0; j < d.size(); j++) { + std::string b = d.data(j); + + { // CopyFrom Cord + absl::Cord x(a); + absl::Cord y(b); + x = y; + EXPECT_EQ(b, std::string(x)) << "'" << a << "' + '" << b << "'"; + } + + { // CopyFrom absl::string_view + absl::Cord x(a); + x = b; + EXPECT_EQ(b, std::string(x)) << "'" << a << "' + '" << b << "'"; + } + + { // Cord::Append(Cord) + absl::Cord x(a); + absl::Cord y(b); + x.Append(y); + EXPECT_EQ(a + b, std::string(x)) << "'" << a << "' + '" << b << "'"; + } + + { // Cord::Append(absl::string_view) + absl::Cord x(a); + x.Append(b); + EXPECT_EQ(a + b, std::string(x)) << "'" << a << "' + '" << b << "'"; + } + + { // Cord::Prepend(Cord) + absl::Cord x(a); + absl::Cord y(b); + x.Prepend(y); + EXPECT_EQ(b + a, std::string(x)) << "'" << b << "' + '" << a << "'"; + } + + { // Cord::Prepend(absl::string_view) + absl::Cord x(a); + x.Prepend(b); + EXPECT_EQ(b + a, std::string(x)) << "'" << b << "' + '" << a << "'"; + } + } + } +} + +namespace { + +TEST(Cord, RemoveSuffixWithExternalOrSubstring) { + absl::Cord cord = absl::MakeCordFromExternal( + "foo bar baz", [](absl::string_view s) { DoNothing(s, nullptr); }); + + EXPECT_EQ("foo bar baz", std::string(cord)); + + // This RemoveSuffix() will wrap the EXTERNAL node in a SUBSTRING node. + cord.RemoveSuffix(4); + EXPECT_EQ("foo bar", std::string(cord)); + + // This RemoveSuffix() will adjust the SUBSTRING node in-place. + cord.RemoveSuffix(4); + EXPECT_EQ("foo", std::string(cord)); +} + +TEST(Cord, RemoveSuffixMakesZeroLengthNode) { + absl::Cord c; + c.Append(absl::Cord(std::string(100, 'x'))); + absl::Cord other_ref = c; // Prevent inplace appends + c.Append(absl::Cord(std::string(200, 'y'))); + c.RemoveSuffix(200); + EXPECT_EQ(std::string(100, 'x'), std::string(c)); +} + +} // namespace + +// CordSpliceTest contributed by hendrie. +namespace { + +// Create a cord with an external memory block filled with 'z' +absl::Cord CordWithZedBlock(size_t size) { + char* data = new char[size]; + if (size > 0) { + memset(data, 'z', size); + } + absl::Cord cord = absl::MakeCordFromExternal( + absl::string_view(data, size), + [](absl::string_view s) { delete[] s.data(); }); + return cord; +} + +// Establish that ZedBlock does what we think it does. +TEST(CordSpliceTest, ZedBlock) { + absl::Cord blob = CordWithZedBlock(10); + EXPECT_EQ(10, blob.size()); + std::string s; + absl::CopyCordToString(blob, &s); + EXPECT_EQ("zzzzzzzzzz", s); +} + +TEST(CordSpliceTest, ZedBlock0) { + absl::Cord blob = CordWithZedBlock(0); + EXPECT_EQ(0, blob.size()); + std::string s; + absl::CopyCordToString(blob, &s); + EXPECT_EQ("", s); +} + +TEST(CordSpliceTest, ZedBlockSuffix1) { + absl::Cord blob = CordWithZedBlock(10); + EXPECT_EQ(10, blob.size()); + absl::Cord suffix(blob); + suffix.RemovePrefix(9); + EXPECT_EQ(1, suffix.size()); + std::string s; + absl::CopyCordToString(suffix, &s); + EXPECT_EQ("z", s); +} + +// Remove all of a prefix block +TEST(CordSpliceTest, ZedBlockSuffix0) { + absl::Cord blob = CordWithZedBlock(10); + EXPECT_EQ(10, blob.size()); + absl::Cord suffix(blob); + suffix.RemovePrefix(10); + EXPECT_EQ(0, suffix.size()); + std::string s; + absl::CopyCordToString(suffix, &s); + EXPECT_EQ("", s); +} + +absl::Cord BigCord(size_t len, char v) { + std::string s(len, v); + return absl::Cord(s); +} + +// Splice block into cord. +absl::Cord SpliceCord(const absl::Cord& blob, int64_t offset, + const absl::Cord& block) { + ABSL_RAW_CHECK(offset >= 0, ""); + ABSL_RAW_CHECK(offset + block.size() <= blob.size(), ""); + absl::Cord result(blob); + result.RemoveSuffix(blob.size() - offset); + result.Append(block); + absl::Cord suffix(blob); + suffix.RemovePrefix(offset + block.size()); + result.Append(suffix); + ABSL_RAW_CHECK(blob.size() == result.size(), ""); + return result; +} + +// Taking an empty suffix of a block breaks appending. +TEST(CordSpliceTest, RemoveEntireBlock1) { + absl::Cord zero = CordWithZedBlock(10); + absl::Cord suffix(zero); + suffix.RemovePrefix(10); + absl::Cord result; + result.Append(suffix); +} + +TEST(CordSpliceTest, RemoveEntireBlock2) { + absl::Cord zero = CordWithZedBlock(10); + absl::Cord prefix(zero); + prefix.RemoveSuffix(10); + absl::Cord suffix(zero); + suffix.RemovePrefix(10); + absl::Cord result(prefix); + result.Append(suffix); +} + +TEST(CordSpliceTest, RemoveEntireBlock3) { + absl::Cord blob = CordWithZedBlock(10); + absl::Cord block = BigCord(10, 'b'); + blob = SpliceCord(blob, 0, block); +} + +struct CordCompareTestCase { + template <typename LHS, typename RHS> + CordCompareTestCase(const LHS& lhs, const RHS& rhs) + : lhs_cord(lhs), rhs_cord(rhs) {} + + absl::Cord lhs_cord; + absl::Cord rhs_cord; +}; + +const auto sign = [](int x) { return x == 0 ? 0 : (x > 0 ? 1 : -1); }; + +void VerifyComparison(const CordCompareTestCase& test_case) { + std::string lhs_string(test_case.lhs_cord); + std::string rhs_string(test_case.rhs_cord); + int expected = sign(lhs_string.compare(rhs_string)); + EXPECT_EQ(expected, test_case.lhs_cord.Compare(test_case.rhs_cord)) + << "LHS=" << lhs_string << "; RHS=" << rhs_string; + EXPECT_EQ(expected, test_case.lhs_cord.Compare(rhs_string)) + << "LHS=" << lhs_string << "; RHS=" << rhs_string; + EXPECT_EQ(-expected, test_case.rhs_cord.Compare(test_case.lhs_cord)) + << "LHS=" << rhs_string << "; RHS=" << lhs_string; + EXPECT_EQ(-expected, test_case.rhs_cord.Compare(lhs_string)) + << "LHS=" << rhs_string << "; RHS=" << lhs_string; +} + +TEST(Cord, Compare) { + absl::Cord subcord("aaaaaBBBBBcccccDDDDD"); + subcord = subcord.Subcord(3, 10); + + absl::Cord tmp("aaaaaaaaaaaaaaaa"); + tmp.Append("BBBBBBBBBBBBBBBB"); + absl::Cord concat = absl::Cord("cccccccccccccccc"); + concat.Append("DDDDDDDDDDDDDDDD"); + concat.Prepend(tmp); + + absl::Cord concat2("aaaaaaaaaaaaa"); + concat2.Append("aaaBBBBBBBBBBBBBBBBccccc"); + concat2.Append("cccccccccccDDDDDDDDDDDDDD"); + concat2.Append("DD"); + + std::vector<CordCompareTestCase> test_cases = {{ + // Inline cords + {"abcdef", "abcdef"}, + {"abcdef", "abcdee"}, + {"abcdef", "abcdeg"}, + {"bbcdef", "abcdef"}, + {"bbcdef", "abcdeg"}, + {"abcdefa", "abcdef"}, + {"abcdef", "abcdefa"}, + + // Small flat cords + {"aaaaaBBBBBcccccDDDDD", "aaaaaBBBBBcccccDDDDD"}, + {"aaaaaBBBBBcccccDDDDD", "aaaaaBBBBBxccccDDDDD"}, + {"aaaaaBBBBBcxcccDDDDD", "aaaaaBBBBBcccccDDDDD"}, + {"aaaaaBBBBBxccccDDDDD", "aaaaaBBBBBcccccDDDDX"}, + {"aaaaaBBBBBcccccDDDDDa", "aaaaaBBBBBcccccDDDDD"}, + {"aaaaaBBBBBcccccDDDDD", "aaaaaBBBBBcccccDDDDDa"}, + + // Subcords + {subcord, subcord}, + {subcord, "aaBBBBBccc"}, + {subcord, "aaBBBBBccd"}, + {subcord, "aaBBBBBccb"}, + {subcord, "aaBBBBBxcb"}, + {subcord, "aaBBBBBccca"}, + {subcord, "aaBBBBBcc"}, + + // Concats + {concat, concat}, + {concat, + "aaaaaaaaaaaaaaaaBBBBBBBBBBBBBBBBccccccccccccccccDDDDDDDDDDDDDDDD"}, + {concat, + "aaaaaaaaaaaaaaaaBBBBBBBBBBBBBBBBcccccccccccccccxDDDDDDDDDDDDDDDD"}, + {concat, + "aaaaaaaaaaaaaaaaBBBBBBBBBBBBBBBBacccccccccccccccDDDDDDDDDDDDDDDD"}, + {concat, + "aaaaaaaaaaaaaaaaBBBBBBBBBBBBBBBBccccccccccccccccDDDDDDDDDDDDDDD"}, + {concat, + "aaaaaaaaaaaaaaaaBBBBBBBBBBBBBBBBccccccccccccccccDDDDDDDDDDDDDDDDe"}, + + {concat, concat2}, + }}; + + for (const auto& tc : test_cases) { + VerifyComparison(tc); + } +} + +TEST(Cord, CompareAfterAssign) { + absl::Cord a("aaaaaa1111111"); + absl::Cord b("aaaaaa2222222"); + a = "cccccc"; + b = "cccccc"; + EXPECT_EQ(a, b); + EXPECT_FALSE(a < b); + + a = "aaaa"; + b = "bbbbb"; + a = ""; + b = ""; + EXPECT_EQ(a, b); + EXPECT_FALSE(a < b); +} + +// Test CompareTo() and ComparePrefix() against string and substring +// comparison methods from basic_string. +static void TestCompare(const absl::Cord& c, const absl::Cord& d, + RandomEngine* rng) { + typedef std::basic_string<uint8_t> ustring; + ustring cs(reinterpret_cast<const uint8_t*>(std::string(c).data()), c.size()); + ustring ds(reinterpret_cast<const uint8_t*>(std::string(d).data()), d.size()); + // ustring comparison is ideal because we expect Cord comparisons to be + // based on unsigned byte comparisons regardless of whether char is signed. + int expected = sign(cs.compare(ds)); + EXPECT_EQ(expected, sign(c.Compare(d))) << c << ", " << d; +} + +TEST(Compare, ComparisonIsUnsigned) { + RandomEngine rng(testing::GTEST_FLAG(random_seed)); + std::uniform_int_distribution<uint32_t> uniform_uint8(0, 255); + char x = static_cast<char>(uniform_uint8(rng)); + TestCompare( + absl::Cord(std::string(GetUniformRandomUpTo(&rng, 100), x)), + absl::Cord(std::string(GetUniformRandomUpTo(&rng, 100), x ^ 0x80)), &rng); +} + +TEST(Compare, RandomComparisons) { + const int kIters = 5000; + RandomEngine rng(testing::GTEST_FLAG(random_seed)); + + int n = GetUniformRandomUpTo(&rng, 5000); + absl::Cord a[] = {MakeExternalCord(n), + absl::Cord("ant"), + absl::Cord("elephant"), + absl::Cord("giraffe"), + absl::Cord(std::string(GetUniformRandomUpTo(&rng, 100), + GetUniformRandomUpTo(&rng, 100))), + absl::Cord(""), + absl::Cord("x"), + absl::Cord("A"), + absl::Cord("B"), + absl::Cord("C")}; + for (int i = 0; i < kIters; i++) { + absl::Cord c, d; + for (int j = 0; j < (i % 7) + 1; j++) { + c.Append(a[GetUniformRandomUpTo(&rng, ABSL_ARRAYSIZE(a))]); + d.Append(a[GetUniformRandomUpTo(&rng, ABSL_ARRAYSIZE(a))]); + } + std::bernoulli_distribution coin_flip(0.5); + TestCompare(coin_flip(rng) ? c : absl::Cord(std::string(c)), + coin_flip(rng) ? d : absl::Cord(std::string(d)), &rng); + } +} + +template <typename T1, typename T2> +void CompareOperators() { + const T1 a("a"); + const T2 b("b"); + + EXPECT_TRUE(a == a); + // For pointer type (i.e. `const char*`), operator== compares the address + // instead of the string, so `a == const char*("a")` isn't necessarily true. + EXPECT_TRUE(std::is_pointer<T1>::value || a == T1("a")); + EXPECT_TRUE(std::is_pointer<T2>::value || a == T2("a")); + EXPECT_FALSE(a == b); + + EXPECT_TRUE(a != b); + EXPECT_FALSE(a != a); + + EXPECT_TRUE(a < b); + EXPECT_FALSE(b < a); + + EXPECT_TRUE(b > a); + EXPECT_FALSE(a > b); + + EXPECT_TRUE(a >= a); + EXPECT_TRUE(b >= a); + EXPECT_FALSE(a >= b); + + EXPECT_TRUE(a <= a); + EXPECT_TRUE(a <= b); + EXPECT_FALSE(b <= a); +} + +TEST(ComparisonOperators, Cord_Cord) { + CompareOperators<absl::Cord, absl::Cord>(); +} + +TEST(ComparisonOperators, Cord_StringPiece) { + CompareOperators<absl::Cord, absl::string_view>(); +} + +TEST(ComparisonOperators, StringPiece_Cord) { + CompareOperators<absl::string_view, absl::Cord>(); +} + +TEST(ComparisonOperators, Cord_string) { + CompareOperators<absl::Cord, std::string>(); +} + +TEST(ComparisonOperators, string_Cord) { + CompareOperators<std::string, absl::Cord>(); +} + +TEST(ComparisonOperators, stdstring_Cord) { + CompareOperators<std::string, absl::Cord>(); +} + +TEST(ComparisonOperators, Cord_stdstring) { + CompareOperators<absl::Cord, std::string>(); +} + +TEST(ComparisonOperators, charstar_Cord) { + CompareOperators<const char*, absl::Cord>(); +} + +TEST(ComparisonOperators, Cord_charstar) { + CompareOperators<absl::Cord, const char*>(); +} + +TEST(ConstructFromExternal, ReleaserInvoked) { + // Empty external memory means the releaser should be called immediately. + { + bool invoked = false; + auto releaser = [&invoked](absl::string_view) { invoked = true; }; + { + auto c = absl::MakeCordFromExternal("", releaser); + EXPECT_TRUE(invoked); + } + } + + // If the size of the data is small enough, a future constructor + // implementation may copy the bytes and immediately invoke the releaser + // instead of creating an external node. We make a large dummy std::string to + // make this test independent of such an optimization. + std::string large_dummy(2048, 'c'); + { + bool invoked = false; + auto releaser = [&invoked](absl::string_view) { invoked = true; }; + { + auto c = absl::MakeCordFromExternal(large_dummy, releaser); + EXPECT_FALSE(invoked); + } + EXPECT_TRUE(invoked); + } + + { + bool invoked = false; + auto releaser = [&invoked](absl::string_view) { invoked = true; }; + { + absl::Cord copy; + { + auto c = absl::MakeCordFromExternal(large_dummy, releaser); + copy = c; + EXPECT_FALSE(invoked); + } + EXPECT_FALSE(invoked); + } + EXPECT_TRUE(invoked); + } +} + +TEST(ConstructFromExternal, CompareContents) { + RandomEngine rng(testing::GTEST_FLAG(random_seed)); + + for (int length = 1; length <= 2048; length *= 2) { + std::string data = RandomLowercaseString(&rng, length); + auto* external = new std::string(data); + auto cord = + absl::MakeCordFromExternal(*external, [external](absl::string_view sv) { + EXPECT_EQ(external->data(), sv.data()); + EXPECT_EQ(external->size(), sv.size()); + delete external; + }); + EXPECT_EQ(data, cord); + } +} + +TEST(ConstructFromExternal, LargeReleaser) { + RandomEngine rng(testing::GTEST_FLAG(random_seed)); + constexpr size_t kLength = 256; + std::string data = RandomLowercaseString(&rng, kLength); + std::array<char, kLength> data_array; + for (size_t i = 0; i < kLength; ++i) data_array[i] = data[i]; + bool invoked = false; + auto releaser = [data_array, &invoked](absl::string_view data) { + EXPECT_EQ(data, absl::string_view(data_array.data(), data_array.size())); + invoked = true; + }; + (void)absl::MakeCordFromExternal(data, releaser); + EXPECT_TRUE(invoked); +} + +TEST(ConstructFromExternal, FunctionPointerReleaser) { + static absl::string_view data("hello world"); + static bool invoked; + auto* releaser = + static_cast<void (*)(absl::string_view)>([](absl::string_view sv) { + EXPECT_EQ(data, sv); + invoked = true; + }); + invoked = false; + (void)absl::MakeCordFromExternal(data, releaser); + EXPECT_TRUE(invoked); + + invoked = false; + (void)absl::MakeCordFromExternal(data, *releaser); + EXPECT_TRUE(invoked); +} + +TEST(ConstructFromExternal, MoveOnlyReleaser) { + struct Releaser { + explicit Releaser(bool* invoked) : invoked(invoked) {} + Releaser(Releaser&& other) noexcept : invoked(other.invoked) {} + void operator()(absl::string_view) const { *invoked = true; } + + bool* invoked; + }; + + bool invoked = false; + (void)absl::MakeCordFromExternal("dummy", Releaser(&invoked)); + EXPECT_TRUE(invoked); +} + +TEST(ConstructFromExternal, NoArgLambda) { + bool invoked = false; + (void)absl::MakeCordFromExternal("dummy", [&invoked]() { invoked = true; }); + EXPECT_TRUE(invoked); +} + +TEST(ConstructFromExternal, StringViewArgLambda) { + bool invoked = false; + (void)absl::MakeCordFromExternal( + "dummy", [&invoked](absl::string_view) { invoked = true; }); + EXPECT_TRUE(invoked); +} + +TEST(ConstructFromExternal, NonTrivialReleaserDestructor) { + struct Releaser { + explicit Releaser(bool* destroyed) : destroyed(destroyed) {} + ~Releaser() { *destroyed = true; } + void operator()(absl::string_view) const {} + + bool* destroyed; + }; + + bool destroyed = false; + Releaser releaser(&destroyed); + (void)absl::MakeCordFromExternal("dummy", releaser); + EXPECT_TRUE(destroyed); +} + +TEST(ConstructFromExternal, ReferenceQualifierOverloads) { + struct Releaser { + void operator()(absl::string_view) & { *lvalue_invoked = true; } + void operator()(absl::string_view) && { *rvalue_invoked = true; } + + bool* lvalue_invoked; + bool* rvalue_invoked; + }; + + bool lvalue_invoked = false; + bool rvalue_invoked = false; + Releaser releaser = {&lvalue_invoked, &rvalue_invoked}; + (void)absl::MakeCordFromExternal("", releaser); + EXPECT_FALSE(lvalue_invoked); + EXPECT_TRUE(rvalue_invoked); + rvalue_invoked = false; + + (void)absl::MakeCordFromExternal("dummy", releaser); + EXPECT_FALSE(lvalue_invoked); + EXPECT_TRUE(rvalue_invoked); + rvalue_invoked = false; + + // NOLINTNEXTLINE: suppress clang-tidy std::move on trivially copyable type. + (void)absl::MakeCordFromExternal("dummy", std::move(releaser)); + EXPECT_FALSE(lvalue_invoked); + EXPECT_TRUE(rvalue_invoked); +} + +TEST(ExternalMemory, BasicUsage) { + static const char* strings[] = {"", "hello", "there"}; + for (const char* str : strings) { + absl::Cord dst("(prefix)"); + AddExternalMemory(str, &dst); + dst.Append("(suffix)"); + EXPECT_EQ((std::string("(prefix)") + str + std::string("(suffix)")), + std::string(dst)); + } +} + +TEST(ExternalMemory, RemovePrefixSuffix) { + // Exhaustively try all sub-strings. + absl::Cord cord = MakeComposite(); + std::string s = std::string(cord); + for (int offset = 0; offset <= s.size(); offset++) { + for (int length = 0; length <= s.size() - offset; length++) { + absl::Cord result(cord); + result.RemovePrefix(offset); + result.RemoveSuffix(result.size() - length); + EXPECT_EQ(s.substr(offset, length), std::string(result)) + << offset << " " << length; + } + } +} + +TEST(ExternalMemory, Get) { + absl::Cord cord("hello"); + AddExternalMemory(" world!", &cord); + AddExternalMemory(" how are ", &cord); + cord.Append(" you?"); + std::string s = std::string(cord); + for (int i = 0; i < s.size(); i++) { + EXPECT_EQ(s[i], cord[i]); + } +} + +// CordMemoryUsage tests verify the correctness of the EstimatedMemoryUsage() +// These tests take into account that the reported memory usage is approximate +// and non-deterministic. For all tests, We verify that the reported memory +// usage is larger than `size()`, and less than `size() * 1.5` as a cord should +// never reserve more 'extra' capacity than half of its size as it grows. +// Additionally we have some whiteboxed expectations based on our knowledge of +// the layout and size of empty and inlined cords, and flat nodes. + +TEST(CordMemoryUsage, Empty) { + EXPECT_EQ(sizeof(absl::Cord), absl::Cord().EstimatedMemoryUsage()); +} + +TEST(CordMemoryUsage, Embedded) { + absl::Cord a("hello"); + EXPECT_EQ(a.EstimatedMemoryUsage(), sizeof(absl::Cord)); +} + +TEST(CordMemoryUsage, EmbeddedAppend) { + absl::Cord a("a"); + absl::Cord b("bcd"); + EXPECT_EQ(b.EstimatedMemoryUsage(), sizeof(absl::Cord)); + a.Append(b); + EXPECT_EQ(a.EstimatedMemoryUsage(), sizeof(absl::Cord)); +} + +TEST(CordMemoryUsage, ExternalMemory) { + static const int kLength = 1000; + absl::Cord cord; + AddExternalMemory(std::string(kLength, 'x'), &cord); + EXPECT_GT(cord.EstimatedMemoryUsage(), kLength); + EXPECT_LE(cord.EstimatedMemoryUsage(), kLength * 1.5); +} + +TEST(CordMemoryUsage, Flat) { + static const int kLength = 125; + absl::Cord a(std::string(kLength, 'a')); + EXPECT_GT(a.EstimatedMemoryUsage(), kLength); + EXPECT_LE(a.EstimatedMemoryUsage(), kLength * 1.5); +} + +TEST(CordMemoryUsage, AppendFlat) { + using absl::strings_internal::CordTestAccess; + absl::Cord a(std::string(CordTestAccess::MaxFlatLength(), 'a')); + size_t length = a.EstimatedMemoryUsage(); + a.Append(std::string(CordTestAccess::MaxFlatLength(), 'b')); + size_t delta = a.EstimatedMemoryUsage() - length; + EXPECT_GT(delta, CordTestAccess::MaxFlatLength()); + EXPECT_LE(delta, CordTestAccess::MaxFlatLength() * 1.5); +} + +// Regtest for a change that had to be rolled back because it expanded out +// of the InlineRep too soon, which was observable through MemoryUsage(). +TEST(CordMemoryUsage, InlineRep) { + constexpr size_t kMaxInline = 15; // Cord::InlineRep::N + const std::string small_string(kMaxInline, 'x'); + absl::Cord c1(small_string); + + absl::Cord c2; + c2.Append(small_string); + EXPECT_EQ(c1, c2); + EXPECT_EQ(c1.EstimatedMemoryUsage(), c2.EstimatedMemoryUsage()); +} + +} // namespace + +// Regtest for 7510292 (fix a bug introduced by 7465150) +TEST(Cord, Concat_Append) { + // Create a rep of type CONCAT + absl::Cord s1("foobarbarbarbarbar"); + s1.Append("abcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefg"); + size_t size = s1.size(); + + // Create a copy of s1 and append to it. + absl::Cord s2 = s1; + s2.Append("x"); + + // 7465150 modifies s1 when it shouldn't. + EXPECT_EQ(s1.size(), size); + EXPECT_EQ(s2.size(), size + 1); +} + +TEST(MakeFragmentedCord, MakeFragmentedCordFromInitializerList) { + absl::Cord fragmented = + absl::MakeFragmentedCord({"A ", "fragmented ", "Cord"}); + + EXPECT_EQ("A fragmented Cord", fragmented); + + auto chunk_it = fragmented.chunk_begin(); + + ASSERT_TRUE(chunk_it != fragmented.chunk_end()); + EXPECT_EQ("A ", *chunk_it); + + ASSERT_TRUE(++chunk_it != fragmented.chunk_end()); + EXPECT_EQ("fragmented ", *chunk_it); + + ASSERT_TRUE(++chunk_it != fragmented.chunk_end()); + EXPECT_EQ("Cord", *chunk_it); + + ASSERT_TRUE(++chunk_it == fragmented.chunk_end()); +} + +TEST(MakeFragmentedCord, MakeFragmentedCordFromVector) { + std::vector<absl::string_view> chunks = {"A ", "fragmented ", "Cord"}; + absl::Cord fragmented = absl::MakeFragmentedCord(chunks); + + EXPECT_EQ("A fragmented Cord", fragmented); + + auto chunk_it = fragmented.chunk_begin(); + + ASSERT_TRUE(chunk_it != fragmented.chunk_end()); + EXPECT_EQ("A ", *chunk_it); + + ASSERT_TRUE(++chunk_it != fragmented.chunk_end()); + EXPECT_EQ("fragmented ", *chunk_it); + + ASSERT_TRUE(++chunk_it != fragmented.chunk_end()); + EXPECT_EQ("Cord", *chunk_it); + + ASSERT_TRUE(++chunk_it == fragmented.chunk_end()); +} + +TEST(CordChunkIterator, Traits) { + static_assert(std::is_copy_constructible<absl::Cord::ChunkIterator>::value, + ""); + static_assert(std::is_copy_assignable<absl::Cord::ChunkIterator>::value, ""); + + // Move semantics to satisfy swappable via std::swap + static_assert(std::is_move_constructible<absl::Cord::ChunkIterator>::value, + ""); + static_assert(std::is_move_assignable<absl::Cord::ChunkIterator>::value, ""); + + static_assert( + std::is_same< + std::iterator_traits<absl::Cord::ChunkIterator>::iterator_category, + std::input_iterator_tag>::value, + ""); + static_assert( + std::is_same<std::iterator_traits<absl::Cord::ChunkIterator>::value_type, + absl::string_view>::value, + ""); + static_assert( + std::is_same< + std::iterator_traits<absl::Cord::ChunkIterator>::difference_type, + ptrdiff_t>::value, + ""); + static_assert( + std::is_same<std::iterator_traits<absl::Cord::ChunkIterator>::pointer, + const absl::string_view*>::value, + ""); + static_assert( + std::is_same<std::iterator_traits<absl::Cord::ChunkIterator>::reference, + absl::string_view>::value, + ""); +} + +static void VerifyChunkIterator(const absl::Cord& cord, + size_t expected_chunks) { + EXPECT_EQ(cord.chunk_begin() == cord.chunk_end(), cord.empty()) << cord; + EXPECT_EQ(cord.chunk_begin() != cord.chunk_end(), !cord.empty()); + + absl::Cord::ChunkRange range = cord.Chunks(); + EXPECT_EQ(range.begin() == range.end(), cord.empty()); + EXPECT_EQ(range.begin() != range.end(), !cord.empty()); + + std::string content(cord); + size_t pos = 0; + auto pre_iter = cord.chunk_begin(), post_iter = cord.chunk_begin(); + size_t n_chunks = 0; + while (pre_iter != cord.chunk_end() && post_iter != cord.chunk_end()) { + EXPECT_FALSE(pre_iter == cord.chunk_end()); // NOLINT: explicitly test == + EXPECT_FALSE(post_iter == cord.chunk_end()); // NOLINT + + EXPECT_EQ(pre_iter, post_iter); + EXPECT_EQ(*pre_iter, *post_iter); + + EXPECT_EQ(pre_iter->data(), (*pre_iter).data()); + EXPECT_EQ(pre_iter->size(), (*pre_iter).size()); + + absl::string_view chunk = *pre_iter; + EXPECT_FALSE(chunk.empty()); + EXPECT_LE(pos + chunk.size(), content.size()); + EXPECT_EQ(absl::string_view(content.c_str() + pos, chunk.size()), chunk); + + int n_equal_iterators = 0; + for (absl::Cord::ChunkIterator it = range.begin(); it != range.end(); + ++it) { + n_equal_iterators += static_cast<int>(it == pre_iter); + } + EXPECT_EQ(n_equal_iterators, 1); + + ++pre_iter; + EXPECT_EQ(*post_iter++, chunk); + + pos += chunk.size(); + ++n_chunks; + } + EXPECT_EQ(expected_chunks, n_chunks); + EXPECT_EQ(pos, content.size()); + EXPECT_TRUE(pre_iter == cord.chunk_end()); // NOLINT: explicitly test == + EXPECT_TRUE(post_iter == cord.chunk_end()); // NOLINT +} + +TEST(CordChunkIterator, Operations) { + absl::Cord empty_cord; + VerifyChunkIterator(empty_cord, 0); + + absl::Cord small_buffer_cord("small cord"); + VerifyChunkIterator(small_buffer_cord, 1); + + absl::Cord flat_node_cord("larger than small buffer optimization"); + VerifyChunkIterator(flat_node_cord, 1); + + VerifyChunkIterator( + absl::MakeFragmentedCord({"a ", "small ", "fragmented ", "cord ", "for ", + "testing ", "chunk ", "iterations."}), + 8); + + absl::Cord reused_nodes_cord(std::string(40, 'c')); + reused_nodes_cord.Prepend(absl::Cord(std::string(40, 'b'))); + reused_nodes_cord.Prepend(absl::Cord(std::string(40, 'a'))); + size_t expected_chunks = 3; + for (int i = 0; i < 8; ++i) { + reused_nodes_cord.Prepend(reused_nodes_cord); + expected_chunks *= 2; + VerifyChunkIterator(reused_nodes_cord, expected_chunks); + } + + RandomEngine rng(testing::GTEST_FLAG(random_seed)); + absl::Cord flat_cord(RandomLowercaseString(&rng, 256)); + absl::Cord subcords; + for (int i = 0; i < 128; ++i) subcords.Prepend(flat_cord.Subcord(i, 128)); + VerifyChunkIterator(subcords, 128); +} + +TEST(CordChunkIterator, MaxLengthFullTree) { + // Start with a 1-byte cord, and then double its length in a loop. We should + // be able to do this until the point where we would overflow size_t. + + absl::Cord cord; + size_t size = 1; + AddExternalMemory("x", &cord); + EXPECT_EQ(cord.size(), size); + + const int kCordLengthDoublingLimit = std::numeric_limits<size_t>::digits - 1; + for (int i = 0; i < kCordLengthDoublingLimit; ++i) { + cord.Prepend(absl::Cord(cord)); + size <<= 1; + + EXPECT_EQ(cord.size(), size); + + auto chunk_it = cord.chunk_begin(); + EXPECT_EQ(*chunk_it, "x"); + } + + EXPECT_DEATH_IF_SUPPORTED( + (cord.Prepend(absl::Cord(cord)), *cord.chunk_begin()), + "Cord is too long"); +} + +TEST(CordChunkIterator, MaxDepth) { + // By reusing nodes, it's possible in pathological cases to build a Cord that + // exceeds both the maximum permissible length and depth. In this case, the + // violation of the maximum depth is reported. + absl::Cord left_child; + AddExternalMemory("x", &left_child); + absl::Cord root = left_child; + + for (int i = 0; i < absl::cord_internal::MaxCordDepth() - 2; ++i) { + size_t new_size = left_child.size() + root.size(); + root.Prepend(left_child); + EXPECT_EQ(root.size(), new_size); + + auto chunk_it = root.chunk_begin(); + EXPECT_EQ(*chunk_it, "x"); + + std::swap(left_child, root); + } + + EXPECT_DEATH_IF_SUPPORTED(root.Prepend(left_child), "Cord is too long"); +} + +TEST(CordCharIterator, Traits) { + static_assert(std::is_copy_constructible<absl::Cord::CharIterator>::value, + ""); + static_assert(std::is_copy_assignable<absl::Cord::CharIterator>::value, ""); + + // Move semantics to satisfy swappable via std::swap + static_assert(std::is_move_constructible<absl::Cord::CharIterator>::value, + ""); + static_assert(std::is_move_assignable<absl::Cord::CharIterator>::value, ""); + + static_assert( + std::is_same< + std::iterator_traits<absl::Cord::CharIterator>::iterator_category, + std::input_iterator_tag>::value, + ""); + static_assert( + std::is_same<std::iterator_traits<absl::Cord::CharIterator>::value_type, + char>::value, + ""); + static_assert( + std::is_same< + std::iterator_traits<absl::Cord::CharIterator>::difference_type, + ptrdiff_t>::value, + ""); + static_assert( + std::is_same<std::iterator_traits<absl::Cord::CharIterator>::pointer, + const char*>::value, + ""); + static_assert( + std::is_same<std::iterator_traits<absl::Cord::CharIterator>::reference, + const char&>::value, + ""); +} + +static void VerifyCharIterator(const absl::Cord& cord) { + EXPECT_EQ(cord.char_begin() == cord.char_end(), cord.empty()); + EXPECT_EQ(cord.char_begin() != cord.char_end(), !cord.empty()); + + absl::Cord::CharRange range = cord.Chars(); + EXPECT_EQ(range.begin() == range.end(), cord.empty()); + EXPECT_EQ(range.begin() != range.end(), !cord.empty()); + + size_t i = 0; + absl::Cord::CharIterator pre_iter = cord.char_begin(); + absl::Cord::CharIterator post_iter = cord.char_begin(); + std::string content(cord); + while (pre_iter != cord.char_end() && post_iter != cord.char_end()) { + EXPECT_FALSE(pre_iter == cord.char_end()); // NOLINT: explicitly test == + EXPECT_FALSE(post_iter == cord.char_end()); // NOLINT + + EXPECT_LT(i, cord.size()); + EXPECT_EQ(content[i], *pre_iter); + + EXPECT_EQ(pre_iter, post_iter); + EXPECT_EQ(*pre_iter, *post_iter); + EXPECT_EQ(&*pre_iter, &*post_iter); + + EXPECT_EQ(&*pre_iter, pre_iter.operator->()); + + const char* character_address = &*pre_iter; + absl::Cord::CharIterator copy = pre_iter; + ++copy; + EXPECT_EQ(character_address, &*pre_iter); + + int n_equal_iterators = 0; + for (absl::Cord::CharIterator it = range.begin(); it != range.end(); ++it) { + n_equal_iterators += static_cast<int>(it == pre_iter); + } + EXPECT_EQ(n_equal_iterators, 1); + + absl::Cord::CharIterator advance_iter = range.begin(); + absl::Cord::Advance(&advance_iter, i); + EXPECT_EQ(pre_iter, advance_iter); + + advance_iter = range.begin(); + EXPECT_EQ(absl::Cord::AdvanceAndRead(&advance_iter, i), cord.Subcord(0, i)); + EXPECT_EQ(pre_iter, advance_iter); + + advance_iter = pre_iter; + absl::Cord::Advance(&advance_iter, cord.size() - i); + EXPECT_EQ(range.end(), advance_iter); + + advance_iter = pre_iter; + EXPECT_EQ(absl::Cord::AdvanceAndRead(&advance_iter, cord.size() - i), + cord.Subcord(i, cord.size() - i)); + EXPECT_EQ(range.end(), advance_iter); + + ++i; + ++pre_iter; + post_iter++; + } + EXPECT_EQ(i, cord.size()); + EXPECT_TRUE(pre_iter == cord.char_end()); // NOLINT: explicitly test == + EXPECT_TRUE(post_iter == cord.char_end()); // NOLINT + + absl::Cord::CharIterator zero_advanced_end = cord.char_end(); + absl::Cord::Advance(&zero_advanced_end, 0); + EXPECT_EQ(zero_advanced_end, cord.char_end()); + + absl::Cord::CharIterator it = cord.char_begin(); + for (absl::string_view chunk : cord.Chunks()) { + while (!chunk.empty()) { + EXPECT_EQ(absl::Cord::ChunkRemaining(it), chunk); + chunk.remove_prefix(1); + ++it; + } + } +} + +TEST(CordCharIterator, Operations) { + absl::Cord empty_cord; + VerifyCharIterator(empty_cord); + + absl::Cord small_buffer_cord("small cord"); + VerifyCharIterator(small_buffer_cord); + + absl::Cord flat_node_cord("larger than small buffer optimization"); + VerifyCharIterator(flat_node_cord); + + VerifyCharIterator( + absl::MakeFragmentedCord({"a ", "small ", "fragmented ", "cord ", "for ", + "testing ", "character ", "iteration."})); + + absl::Cord reused_nodes_cord("ghi"); + reused_nodes_cord.Prepend(absl::Cord("def")); + reused_nodes_cord.Prepend(absl::Cord("abc")); + for (int i = 0; i < 4; ++i) { + reused_nodes_cord.Prepend(reused_nodes_cord); + VerifyCharIterator(reused_nodes_cord); + } + + RandomEngine rng(testing::GTEST_FLAG(random_seed)); + absl::Cord flat_cord(RandomLowercaseString(&rng, 256)); + absl::Cord subcords; + for (int i = 0; i < 4; ++i) subcords.Prepend(flat_cord.Subcord(16 * i, 128)); + VerifyCharIterator(subcords); +} + +TEST(Cord, StreamingOutput) { + absl::Cord c = + absl::MakeFragmentedCord({"A ", "small ", "fragmented ", "Cord", "."}); + std::stringstream output; + output << c; + EXPECT_EQ("A small fragmented Cord.", output.str()); +} + +TEST(Cord, ForEachChunk) { + for (int num_elements : {1, 10, 200}) { + SCOPED_TRACE(num_elements); + std::vector<std::string> cord_chunks; + for (int i = 0; i < num_elements; ++i) { + cord_chunks.push_back(absl::StrCat("[", i, "]")); + } + absl::Cord c = absl::MakeFragmentedCord(cord_chunks); + + std::vector<std::string> iterated_chunks; + absl::CordTestPeer::ForEachChunk(c, + [&iterated_chunks](absl::string_view sv) { + iterated_chunks.emplace_back(sv); + }); + EXPECT_EQ(iterated_chunks, cord_chunks); + } +} + +TEST(Cord, SmallBufferAssignFromOwnData) { + constexpr size_t kMaxInline = 15; + std::string contents = "small buff cord"; + EXPECT_EQ(contents.size(), kMaxInline); + for (size_t pos = 0; pos < contents.size(); ++pos) { + for (size_t count = contents.size() - pos; count > 0; --count) { + absl::Cord c(contents); + absl::string_view flat = c.Flatten(); + c = flat.substr(pos, count); + EXPECT_EQ(c, contents.substr(pos, count)) + << "pos = " << pos << "; count = " << count; + } + } +}
diff --git a/third_party/abseil-cpp/absl/strings/cord_test_helpers.h b/third_party/abseil-cpp/absl/strings/cord_test_helpers.h new file mode 100644 index 0000000..f1036e3b --- /dev/null +++ b/third_party/abseil-cpp/absl/strings/cord_test_helpers.h
@@ -0,0 +1,60 @@ +// +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef ABSL_STRINGS_CORD_TEST_HELPERS_H_ +#define ABSL_STRINGS_CORD_TEST_HELPERS_H_ + +#include "absl/strings/cord.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN + +// Creates a multi-segment Cord from an iterable container of strings. The +// resulting Cord is guaranteed to have one segment for every string in the +// container. This allows code to be unit tested with multi-segment Cord +// inputs. +// +// Example: +// +// absl::Cord c = absl::MakeFragmentedCord({"A ", "fragmented ", "Cord"}); +// EXPECT_FALSE(c.GetFlat(&unused)); +// +// The mechanism by which this Cord is created is an implementation detail. Any +// implementation that produces a multi-segment Cord may produce a flat Cord in +// the future as new optimizations are added to the Cord class. +// MakeFragmentedCord will, however, always be updated to return a multi-segment +// Cord. +template <typename Container> +Cord MakeFragmentedCord(const Container& c) { + Cord result; + for (const auto& s : c) { + auto* external = new std::string(s); + Cord tmp = absl::MakeCordFromExternal( + *external, [external](absl::string_view) { delete external; }); + tmp.Prepend(result); + result = tmp; + } + return result; +} + +inline Cord MakeFragmentedCord(std::initializer_list<absl::string_view> list) { + return MakeFragmentedCord<std::initializer_list<absl::string_view>>(list); +} + +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_STRINGS_CORD_TEST_HELPERS_H_
diff --git a/third_party/abseil-cpp/absl/strings/escaping.cc b/third_party/abseil-cpp/absl/strings/escaping.cc index 0d336e3..9fceeef 100644 --- a/third_party/abseil-cpp/absl/strings/escaping.cc +++ b/third_party/abseil-cpp/absl/strings/escaping.cc
@@ -26,6 +26,7 @@ #include "absl/base/internal/raw_logging.h" #include "absl/base/internal/unaligned_access.h" #include "absl/strings/internal/char_map.h" +#include "absl/strings/internal/escaping.h" #include "absl/strings/internal/resize_uninitialized.h" #include "absl/strings/internal/utf8.h" #include "absl/strings/str_cat.h" @@ -33,29 +34,9 @@ #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { -// Digit conversion. -constexpr char kHexChar[] = "0123456789abcdef"; - -constexpr char kHexTable[513] = - "000102030405060708090a0b0c0d0e0f" - "101112131415161718191a1b1c1d1e1f" - "202122232425262728292a2b2c2d2e2f" - "303132333435363738393a3b3c3d3e3f" - "404142434445464748494a4b4c4d4e4f" - "505152535455565758595a5b5c5d5e5f" - "606162636465666768696a6b6c6d6e6f" - "707172737475767778797a7b7c7d7e7f" - "808182838485868788898a8b8c8d8e8f" - "909192939495969798999a9b9c9d9e9f" - "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf" - "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" - "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf" - "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf" - "e0e1e2e3e4e5e6e7e8e9eaebecedeeef" - "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"; - // These are used for the leave_nulls_escaped argument to CUnescapeInternal(). constexpr bool kUnescapeNulls = false; @@ -348,14 +329,14 @@ (last_hex_escape && absl::ascii_isxdigit(c)))) { if (use_hex) { dest.append("\\" "x"); - dest.push_back(kHexChar[c / 16]); - dest.push_back(kHexChar[c % 16]); + dest.push_back(numbers_internal::kHexChar[c / 16]); + dest.push_back(numbers_internal::kHexChar[c % 16]); is_hex_escape = true; } else { dest.append("\\"); - dest.push_back(kHexChar[c / 64]); - dest.push_back(kHexChar[(c % 64) / 8]); - dest.push_back(kHexChar[c % 8]); + dest.push_back(numbers_internal::kHexChar[c / 64]); + dest.push_back(numbers_internal::kHexChar[(c % 64) / 8]); + dest.push_back(numbers_internal::kHexChar[c % 8]); } } else { dest.push_back(c); @@ -469,7 +450,7 @@ // The GET_INPUT macro gets the next input character, skipping // over any whitespace, and stopping when we reach the end of the - // std::string or when we read any non-data character. The arguments are + // string or when we read any non-data character. The arguments are // an arbitrary identifier (used as a label for goto) and the number // of data bytes that must remain in the input to avoid aborting the // loop. @@ -492,18 +473,18 @@ if (dest) { // This loop consumes 4 input bytes and produces 3 output bytes // per iteration. We can't know at the start that there is enough - // data left in the std::string for a full iteration, so the loop may + // data left in the string for a full iteration, so the loop may // break out in the middle; if so 'state' will be set to the // number of input bytes read. while (szsrc >= 4) { // We'll start by optimistically assuming that the next four - // bytes of the std::string (src[0..3]) are four good data bytes + // bytes of the string (src[0..3]) are four good data bytes // (that is, no nulls, whitespace, padding chars, or illegal // chars). We need to test src[0..2] for nulls individually // before constructing temp to preserve the property that we - // never read past a null in the std::string (no matter how long - // szsrc claims the std::string is). + // never read past a null in the string (no matter how long + // szsrc claims the string is). if (!src[0] || !src[1] || !src[2] || ((temp = ((unsigned(unbase64[src[0]]) << 18) | @@ -528,7 +509,7 @@ temp = (temp << 6) | decode; } else { // We really did have four good data bytes, so advance four - // characters in the std::string. + // characters in the string. szsrc -= 4; src += 4; @@ -663,7 +644,7 @@ state); } - // The remainder of the std::string should be all whitespace, mixed with + // The remainder of the string should be all whitespace, mixed with // exactly 0 equals signs, or exactly 'expected_equals' equals // signs. (Always accepting 0 equals signs is an Abseil extension // not covered in the RFC, as is accepting dot as the pad character.) @@ -784,180 +765,13 @@ }; /* clang-format on */ -size_t CalculateBase64EscapedLenInternal(size_t input_len, bool do_padding) { - // Base64 encodes three bytes of input at a time. If the input is not - // divisible by three, we pad as appropriate. - // - // (from https://tools.ietf.org/html/rfc3548) - // Special processing is performed if fewer than 24 bits are available - // at the end of the data being encoded. A full encoding quantum is - // always completed at the end of a quantity. When fewer than 24 input - // bits are available in an input group, zero bits are added (on the - // right) to form an integral number of 6-bit groups. Padding at the - // end of the data is performed using the '=' character. Since all base - // 64 input is an integral number of octets, only the following cases - // can arise: - - // Base64 encodes each three bytes of input into four bytes of output. - size_t len = (input_len / 3) * 4; - - if (input_len % 3 == 0) { - // (from https://tools.ietf.org/html/rfc3548) - // (1) the final quantum of encoding input is an integral multiple of 24 - // bits; here, the final unit of encoded output will be an integral - // multiple of 4 characters with no "=" padding, - } else if (input_len % 3 == 1) { - // (from https://tools.ietf.org/html/rfc3548) - // (2) the final quantum of encoding input is exactly 8 bits; here, the - // final unit of encoded output will be two characters followed by two - // "=" padding characters, or - len += 2; - if (do_padding) { - len += 2; - } - } else { // (input_len % 3 == 2) - // (from https://tools.ietf.org/html/rfc3548) - // (3) the final quantum of encoding input is exactly 16 bits; here, the - // final unit of encoded output will be three characters followed by one - // "=" padding character. - len += 3; - if (do_padding) { - len += 1; - } - } - - assert(len >= input_len); // make sure we didn't overflow - return len; -} - -size_t Base64EscapeInternal(const unsigned char* src, size_t szsrc, char* dest, - size_t szdest, const char* base64, - bool do_padding) { - static const char kPad64 = '='; - - if (szsrc * 4 > szdest * 3) return 0; - - char* cur_dest = dest; - const unsigned char* cur_src = src; - - char* const limit_dest = dest + szdest; - const unsigned char* const limit_src = src + szsrc; - - // Three bytes of data encodes to four characters of cyphertext. - // So we can pump through three-byte chunks atomically. - if (szsrc >= 3) { // "limit_src - 3" is UB if szsrc < 3. - while (cur_src < limit_src - 3) { // While we have >= 32 bits. - uint32_t in = absl::big_endian::Load32(cur_src) >> 8; - - cur_dest[0] = base64[in >> 18]; - in &= 0x3FFFF; - cur_dest[1] = base64[in >> 12]; - in &= 0xFFF; - cur_dest[2] = base64[in >> 6]; - in &= 0x3F; - cur_dest[3] = base64[in]; - - cur_dest += 4; - cur_src += 3; - } - } - // To save time, we didn't update szdest or szsrc in the loop. So do it now. - szdest = limit_dest - cur_dest; - szsrc = limit_src - cur_src; - - /* now deal with the tail (<=3 bytes) */ - switch (szsrc) { - case 0: - // Nothing left; nothing more to do. - break; - case 1: { - // One byte left: this encodes to two characters, and (optionally) - // two pad characters to round out the four-character cypherblock. - if (szdest < 2) return 0; - uint32_t in = cur_src[0]; - cur_dest[0] = base64[in >> 2]; - in &= 0x3; - cur_dest[1] = base64[in << 4]; - cur_dest += 2; - szdest -= 2; - if (do_padding) { - if (szdest < 2) return 0; - cur_dest[0] = kPad64; - cur_dest[1] = kPad64; - cur_dest += 2; - szdest -= 2; - } - break; - } - case 2: { - // Two bytes left: this encodes to three characters, and (optionally) - // one pad character to round out the four-character cypherblock. - if (szdest < 3) return 0; - uint32_t in = absl::big_endian::Load16(cur_src); - cur_dest[0] = base64[in >> 10]; - in &= 0x3FF; - cur_dest[1] = base64[in >> 4]; - in &= 0x00F; - cur_dest[2] = base64[in << 2]; - cur_dest += 3; - szdest -= 3; - if (do_padding) { - if (szdest < 1) return 0; - cur_dest[0] = kPad64; - cur_dest += 1; - szdest -= 1; - } - break; - } - case 3: { - // Three bytes left: same as in the big loop above. We can't do this in - // the loop because the loop above always reads 4 bytes, and the fourth - // byte is past the end of the input. - if (szdest < 4) return 0; - uint32_t in = (cur_src[0] << 16) + absl::big_endian::Load16(cur_src + 1); - cur_dest[0] = base64[in >> 18]; - in &= 0x3FFFF; - cur_dest[1] = base64[in >> 12]; - in &= 0xFFF; - cur_dest[2] = base64[in >> 6]; - in &= 0x3F; - cur_dest[3] = base64[in]; - cur_dest += 4; - szdest -= 4; - break; - } - default: - // Should not be reached: blocks of 4 bytes are handled - // in the while loop before this switch statement. - ABSL_RAW_LOG(FATAL, "Logic problem? szsrc = %zu", szsrc); - break; - } - return (cur_dest - dest); -} - -constexpr char kBase64Chars[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - constexpr char kWebSafeBase64Chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; template <typename String> -void Base64EscapeInternal(const unsigned char* src, size_t szsrc, String* dest, - bool do_padding, const char* base64_chars) { - const size_t calc_escaped_size = - CalculateBase64EscapedLenInternal(szsrc, do_padding); - strings_internal::STLStringResizeUninitialized(dest, calc_escaped_size); - - const size_t escaped_len = Base64EscapeInternal( - src, szsrc, &(*dest)[0], dest->size(), base64_chars, do_padding); - assert(calc_escaped_size == escaped_len); - dest->erase(escaped_len); -} - -template <typename String> bool Base64UnescapeInternal(const char* src, size_t slen, String* dest, const signed char* unbase64) { - // Determine the size of the output std::string. Base64 encodes every 3 bytes into + // Determine the size of the output string. Base64 encodes every 3 bytes into // 4 characters. any leftover chars are added directly for good measure. // This is documented in the base64 RFC: http://tools.ietf.org/html/rfc3548 const size_t dest_len = 3 * (slen / 4) + (slen % 4); @@ -965,7 +779,7 @@ strings_internal::STLStringResizeUninitialized(dest, dest_len); // We are getting the destination buffer by getting the beginning of the - // std::string and converting it into a char *. + // string and converting it into a char *. size_t len; const bool ok = Base64UnescapeInternal(src, slen, &(*dest)[0], dest_len, unbase64, &len); @@ -982,7 +796,7 @@ } /* clang-format off */ -constexpr char kHexValue[256] = { +constexpr char kHexValueLenient[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -998,8 +812,9 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; + /* clang-format on */ // This is a templated function so that T can be either a char* @@ -1008,8 +823,8 @@ template <typename T> void HexStringToBytesInternal(const char* from, T to, ptrdiff_t num) { for (int i = 0; i < num; i++) { - to[i] = (kHexValue[from[i * 2] & 0xFF] << 4) + - (kHexValue[from[i * 2 + 1] & 0xFF]); + to[i] = (kHexValueLenient[from[i * 2] & 0xFF] << 4) + + (kHexValueLenient[from[i * 2 + 1] & 0xFF]); } } @@ -1019,7 +834,7 @@ void BytesToHexStringInternal(const unsigned char* src, T dest, ptrdiff_t num) { auto dest_ptr = &dest[0]; for (auto src_ptr = src; src_ptr != (src + num); ++src_ptr, dest_ptr += 2) { - const char* hex_p = &kHexTable[*src_ptr * 2]; + const char* hex_p = &numbers_internal::kHexTable[*src_ptr * 2]; std::copy(hex_p, hex_p + 2, dest_ptr); } } @@ -1087,26 +902,30 @@ } void Base64Escape(absl::string_view src, std::string* dest) { - Base64EscapeInternal(reinterpret_cast<const unsigned char*>(src.data()), - src.size(), dest, true, kBase64Chars); + strings_internal::Base64EscapeInternal( + reinterpret_cast<const unsigned char*>(src.data()), src.size(), dest, + true, strings_internal::kBase64Chars); } void WebSafeBase64Escape(absl::string_view src, std::string* dest) { - Base64EscapeInternal(reinterpret_cast<const unsigned char*>(src.data()), - src.size(), dest, false, kWebSafeBase64Chars); + strings_internal::Base64EscapeInternal( + reinterpret_cast<const unsigned char*>(src.data()), src.size(), dest, + false, kWebSafeBase64Chars); } std::string Base64Escape(absl::string_view src) { std::string dest; - Base64EscapeInternal(reinterpret_cast<const unsigned char*>(src.data()), - src.size(), &dest, true, kBase64Chars); + strings_internal::Base64EscapeInternal( + reinterpret_cast<const unsigned char*>(src.data()), src.size(), &dest, + true, strings_internal::kBase64Chars); return dest; } std::string WebSafeBase64Escape(absl::string_view src) { std::string dest; - Base64EscapeInternal(reinterpret_cast<const unsigned char*>(src.data()), - src.size(), &dest, false, kWebSafeBase64Chars); + strings_internal::Base64EscapeInternal( + reinterpret_cast<const unsigned char*>(src.data()), src.size(), &dest, + false, kWebSafeBase64Chars); return dest; } @@ -1126,4 +945,5 @@ return result; } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/escaping.h b/third_party/abseil-cpp/absl/strings/escaping.h index 198b9348..f5ca26c5d 100644 --- a/third_party/abseil-cpp/absl/strings/escaping.h +++ b/third_party/abseil-cpp/absl/strings/escaping.h
@@ -33,6 +33,7 @@ #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN // CUnescape() // @@ -157,6 +158,7 @@ // `2*from.size()`. std::string BytesToHexString(absl::string_view from); +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_ESCAPING_H_
diff --git a/third_party/abseil-cpp/absl/strings/escaping_test.cc b/third_party/abseil-cpp/absl/strings/escaping_test.cc index 1967975..45671a0e 100644 --- a/third_party/abseil-cpp/absl/strings/escaping_test.cc +++ b/third_party/abseil-cpp/absl/strings/escaping_test.cc
@@ -300,7 +300,7 @@ absl::string_view plaintext; absl::string_view cyphertext; } const base64_tests[] = { - // Empty std::string. + // Empty string. {{"", 0}, {"", 0}}, {{nullptr, 0}, {"", 0}}, // if length is zero, plaintext ptr must be ignored! @@ -586,7 +586,7 @@ EXPECT_EQ(encoded, websafe); EXPECT_EQ(absl::WebSafeBase64Escape(tc.plaintext), websafe); - // Let's try the std::string version of the decoder + // Let's try the string version of the decoder decoded = "this junk should be ignored"; EXPECT_TRUE(absl::WebSafeBase64Unescape(websafe, &decoded)); EXPECT_EQ(decoded, tc.plaintext); @@ -625,7 +625,7 @@ std::string escaped; absl::Base64Escape(huge, &escaped); - // Generates the std::string that should match a base64 encoded "xxx..." std::string. + // Generates the string that should match a base64 encoded "xxx..." string. // "xxx" in base64 is "eHh4". std::string expected_encoding; expected_encoding.reserve(kSize / 3 * 4);
diff --git a/third_party/abseil-cpp/absl/strings/internal/char_map.h b/third_party/abseil-cpp/absl/strings/internal/char_map.h index b9108b8c..61484de 100644 --- a/third_party/abseil-cpp/absl/strings/internal/char_map.h +++ b/third_party/abseil-cpp/absl/strings/internal/char_map.h
@@ -28,6 +28,7 @@ #include "absl/base/port.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { class Charmap { @@ -71,7 +72,7 @@ CharMaskForWord(x, 2), CharMaskForWord(x, 3)); } - // Containing all the chars in the C-std::string 's'. + // Containing all the chars in the C-string 's'. // Note that this is expensively recursive because of the C++11 constexpr // formulation. Use only in constexpr initializers. static constexpr Charmap FromString(const char* s) { @@ -149,6 +150,7 @@ constexpr Charmap PunctCharmap() { return GraphCharmap() & ~AlnumCharmap(); } } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_CHAR_MAP_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc b/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc index 95d471d..ebf8c07 100644 --- a/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +++ b/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc
@@ -19,6 +19,7 @@ #include <string> namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { namespace { @@ -157,12 +158,12 @@ int LargePowerOfFiveSize(int i) { return 2 * i; } } // namespace -const uint32_t kFiveToNth[14] = { +ABSL_DLL const uint32_t kFiveToNth[14] = { 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125, 244140625, 1220703125, }; -const uint32_t kTenToNth[10] = { +ABSL_DLL const uint32_t kTenToNth[10] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, }; @@ -207,7 +208,7 @@ ++dropped_digits; } if (begin < end && *std::prev(end) == '.') { - // If the std::string ends in '.', either before or after dropping zeroes, then + // If the string ends in '.', either before or after dropping zeroes, then // drop the decimal point and look for more digits to drop. dropped_digits = 0; --end; @@ -354,4 +355,5 @@ template class BigUnsigned<84>; } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h b/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h index 7da9a7e7..8f70297 100644 --- a/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +++ b/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h
@@ -20,11 +20,13 @@ #include <iostream> #include <string> +#include "absl/base/config.h" #include "absl/strings/ascii.h" #include "absl/strings/internal/charconv_parse.h" #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { // The largest power that 5 that can be raised to, and still fit in a uint32_t. @@ -32,8 +34,9 @@ // The largest power that 10 that can be raised to, and still fit in a uint32_t. constexpr int kMaxSmallPowerOfTen = 9; -extern const uint32_t kFiveToNth[kMaxSmallPowerOfFive + 1]; -extern const uint32_t kTenToNth[kMaxSmallPowerOfTen + 1]; +ABSL_DLL extern const uint32_t + kFiveToNth[kMaxSmallPowerOfFive + 1]; +ABSL_DLL extern const uint32_t kTenToNth[kMaxSmallPowerOfTen + 1]; // Large, fixed-width unsigned integer. // @@ -63,7 +66,7 @@ static_cast<uint32_t>(v >> 32)} {} // Constructs a BigUnsigned from the given string_view containing a decimal - // value. If the input std::string is not a decimal integer, constructs a 0 + // value. If the input string is not a decimal integer, constructs a 0 // instead. explicit BigUnsigned(absl::string_view sv) : size_(0), words_{} { // Check for valid input, returning a 0 otherwise. This is reasonable @@ -207,7 +210,7 @@ return words_[index]; } - // Returns this integer as a decimal std::string. This is not used in the decimal- + // Returns this integer as a decimal string. This is not used in the decimal- // to-binary conversion; it is intended to aid in testing. std::string ToString() const; @@ -414,6 +417,7 @@ extern template class BigUnsigned<84>; } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_CHARCONV_BIGINT_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/charconv_bigint_test.cc b/third_party/abseil-cpp/absl/strings/internal/charconv_bigint_test.cc index 745714a..363bcb0 100644 --- a/third_party/abseil-cpp/absl/strings/internal/charconv_bigint_test.cc +++ b/third_party/abseil-cpp/absl/strings/internal/charconv_bigint_test.cc
@@ -19,6 +19,7 @@ #include "gtest/gtest.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { TEST(BigUnsigned, ShiftLeft) { @@ -200,4 +201,5 @@ } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc b/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc index f3c7232..fd6d948 100644 --- a/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +++ b/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc
@@ -22,6 +22,7 @@ #include "absl/strings/internal/memutil.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { // ParseFloat<10> will read the first 19 significant digits of the mantissa. @@ -253,6 +254,12 @@ assert(max_digits * 4 <= std::numeric_limits<T>::digits); } const char* const original_begin = begin; + + // Skip leading zeros, but only if *out is zero. + // They don't cause an overflow so we don't have to count them for + // `max_digits`. + while (!*out && end != begin && *begin == '0') ++begin; + T accumulator = *out; const char* significant_digits_end = (end - begin > max_digits) ? begin + max_digits : end; @@ -295,7 +302,7 @@ switch (*begin) { case 'i': case 'I': { - // An infinity std::string consists of the characters "inf" or "infinity", + // An infinity string consists of the characters "inf" or "infinity", // case insensitive. if (strings_internal::memcasecmp(begin + 1, "nf", 2) != 0) { return false; @@ -319,7 +326,7 @@ } out->type = strings_internal::FloatType::kNan; out->end = begin + 3; - // NaN is allowed to be followed by a parenthesized std::string, consisting of + // NaN is allowed to be followed by a parenthesized string, consisting of // only the characters [a-zA-Z0-9_]. Match that if it's present. begin += 3; if (begin < end && *begin == '(') { @@ -493,4 +500,5 @@ chars_format format_flags); } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/charconv_parse.h b/third_party/abseil-cpp/absl/strings/internal/charconv_parse.h index 44d06b2..505998b5 100644 --- a/third_party/abseil-cpp/absl/strings/internal/charconv_parse.h +++ b/third_party/abseil-cpp/absl/strings/internal/charconv_parse.h
@@ -17,9 +17,11 @@ #include <cstdint> +#include "absl/base/config.h" #include "absl/strings/charconv.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { // Enum indicating whether a parsed float is a number or special value. @@ -92,5 +94,6 @@ absl::chars_format format_flags); } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_CHARCONV_PARSE_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/charconv_parse_test.cc b/third_party/abseil-cpp/absl/strings/internal/charconv_parse_test.cc index 9511c987..bc2d111 100644 --- a/third_party/abseil-cpp/absl/strings/internal/charconv_parse_test.cc +++ b/third_party/abseil-cpp/absl/strings/internal/charconv_parse_test.cc
@@ -63,7 +63,7 @@ } const std::string::size_type expected_characters_matched = s.find('$'); ABSL_RAW_CHECK(expected_characters_matched != std::string::npos, - "Input std::string must contain $"); + "Input string must contain $"); s.replace(expected_characters_matched, 1, ""); ParsedFloat parsed =
diff --git a/third_party/abseil-cpp/absl/strings/internal/cord_internal.h b/third_party/abseil-cpp/absl/strings/internal/cord_internal.h new file mode 100644 index 0000000..830ceaf --- /dev/null +++ b/third_party/abseil-cpp/absl/strings/internal/cord_internal.h
@@ -0,0 +1,150 @@ +// Copyright 2020 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ABSL_STRINGS_INTERNAL_CORD_INTERNAL_H_ +#define ABSL_STRINGS_INTERNAL_CORD_INTERNAL_H_ + +#include <atomic> +#include <cassert> +#include <cstddef> +#include <cstdint> +#include <type_traits> + +#include "absl/meta/type_traits.h" +#include "absl/strings/string_view.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace cord_internal { + +// Wraps std::atomic for reference counting. +class Refcount { + public: + Refcount() : count_{1} {} + ~Refcount() {} + + // Increments the reference count by 1. Imposes no memory ordering. + inline void Increment() { count_.fetch_add(1, std::memory_order_relaxed); } + + // Asserts that the current refcount is greater than 0. If the refcount is + // greater than 1, decrements the reference count by 1. + // + // Returns false if there are no references outstanding; true otherwise. + // Inserts barriers to ensure that state written before this method returns + // false will be visible to a thread that just observed this method returning + // false. + inline bool Decrement() { + int32_t refcount = count_.load(std::memory_order_acquire); + assert(refcount > 0); + return refcount != 1 && count_.fetch_sub(1, std::memory_order_acq_rel) != 1; + } + + // Same as Decrement but expect that refcount is greater than 1. + inline bool DecrementExpectHighRefcount() { + int32_t refcount = count_.fetch_sub(1, std::memory_order_acq_rel); + assert(refcount > 0); + return refcount != 1; + } + + // Returns the current reference count using acquire semantics. + inline int32_t Get() const { return count_.load(std::memory_order_acquire); } + + // Returns whether the atomic integer is 1. + // If the reference count is used in the conventional way, a + // reference count of 1 implies that the current thread owns the + // reference and no other thread shares it. + // This call performs the test for a reference count of one, and + // performs the memory barrier needed for the owning thread + // to act on the object, knowing that it has exclusive access to the + // object. + inline bool IsOne() { return count_.load(std::memory_order_acquire) == 1; } + + private: + std::atomic<int32_t> count_; +}; + +// The overhead of a vtable is too much for Cord, so we roll our own subclasses +// using only a single byte to differentiate classes from each other - the "tag" +// byte. Define the subclasses first so we can provide downcasting helper +// functions in the base class. + +struct CordRepConcat; +struct CordRepSubstring; +struct CordRepExternal; + +struct CordRep { + // The following three fields have to be less than 32 bytes since + // that is the smallest supported flat node size. + size_t length; + Refcount refcount; + // If tag < FLAT, it represents CordRepKind and indicates the type of node. + // Otherwise, the node type is CordRepFlat and the tag is the encoded size. + uint8_t tag; + char data[1]; // Starting point for flat array: MUST BE LAST FIELD of CordRep + + inline CordRepConcat* concat(); + inline const CordRepConcat* concat() const; + inline CordRepSubstring* substring(); + inline const CordRepSubstring* substring() const; + inline CordRepExternal* external(); + inline const CordRepExternal* external() const; +}; + +struct CordRepConcat : public CordRep { + CordRep* left; + CordRep* right; + + uint8_t depth() const { return static_cast<uint8_t>(data[0]); } + void set_depth(uint8_t depth) { data[0] = static_cast<char>(depth); } +}; + +struct CordRepSubstring : public CordRep { + size_t start; // Starting offset of substring in child + CordRep* child; +}; + +// TODO(strel): replace the following logic (and related functions in cord.cc) +// with container_internal::Layout. + +// Alignment requirement for CordRepExternal so that the type erased releaser +// will be stored at a suitably aligned address. +constexpr size_t ExternalRepAlignment() { +#if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__) + return __STDCPP_DEFAULT_NEW_ALIGNMENT__; +#else + return alignof(max_align_t); +#endif +} + +// Type for function pointer that will invoke and destroy the type-erased +// releaser function object. Accepts a pointer to the releaser and the +// `string_view` that were passed in to `NewExternalRep` below. The return value +// is the size of the `Releaser` type. +using ExternalReleaserInvoker = size_t (*)(void*, absl::string_view); + +// External CordReps are allocated together with a type erased releaser. The +// releaser is stored in the memory directly following the CordRepExternal. +struct alignas(ExternalRepAlignment()) CordRepExternal : public CordRep { + const char* base; + // Pointer to function that knows how to call and destroy the releaser. + ExternalReleaserInvoker releaser_invoker; +}; + +// TODO(strel): look into removing, it doesn't seem like anything relies on this +static_assert(sizeof(CordRepConcat) == sizeof(CordRepSubstring), ""); + +} // namespace cord_internal +ABSL_NAMESPACE_END +} // namespace absl +#endif // ABSL_STRINGS_INTERNAL_CORD_INTERNAL_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/escaping.cc b/third_party/abseil-cpp/absl/strings/internal/escaping.cc new file mode 100644 index 0000000..c5271286a --- /dev/null +++ b/third_party/abseil-cpp/absl/strings/internal/escaping.cc
@@ -0,0 +1,180 @@ +// Copyright 2020 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/strings/internal/escaping.h" + +#include "absl/base/internal/endian.h" +#include "absl/base/internal/raw_logging.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace strings_internal { + +const char kBase64Chars[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +size_t CalculateBase64EscapedLenInternal(size_t input_len, bool do_padding) { + // Base64 encodes three bytes of input at a time. If the input is not + // divisible by three, we pad as appropriate. + // + // (from https://tools.ietf.org/html/rfc3548) + // Special processing is performed if fewer than 24 bits are available + // at the end of the data being encoded. A full encoding quantum is + // always completed at the end of a quantity. When fewer than 24 input + // bits are available in an input group, zero bits are added (on the + // right) to form an integral number of 6-bit groups. Padding at the + // end of the data is performed using the '=' character. Since all base + // 64 input is an integral number of octets, only the following cases + // can arise: + + // Base64 encodes each three bytes of input into four bytes of output. + size_t len = (input_len / 3) * 4; + + if (input_len % 3 == 0) { + // (from https://tools.ietf.org/html/rfc3548) + // (1) the final quantum of encoding input is an integral multiple of 24 + // bits; here, the final unit of encoded output will be an integral + // multiple of 4 characters with no "=" padding, + } else if (input_len % 3 == 1) { + // (from https://tools.ietf.org/html/rfc3548) + // (2) the final quantum of encoding input is exactly 8 bits; here, the + // final unit of encoded output will be two characters followed by two + // "=" padding characters, or + len += 2; + if (do_padding) { + len += 2; + } + } else { // (input_len % 3 == 2) + // (from https://tools.ietf.org/html/rfc3548) + // (3) the final quantum of encoding input is exactly 16 bits; here, the + // final unit of encoded output will be three characters followed by one + // "=" padding character. + len += 3; + if (do_padding) { + len += 1; + } + } + + assert(len >= input_len); // make sure we didn't overflow + return len; +} + +size_t Base64EscapeInternal(const unsigned char* src, size_t szsrc, char* dest, + size_t szdest, const char* base64, + bool do_padding) { + static const char kPad64 = '='; + + if (szsrc * 4 > szdest * 3) return 0; + + char* cur_dest = dest; + const unsigned char* cur_src = src; + + char* const limit_dest = dest + szdest; + const unsigned char* const limit_src = src + szsrc; + + // Three bytes of data encodes to four characters of cyphertext. + // So we can pump through three-byte chunks atomically. + if (szsrc >= 3) { // "limit_src - 3" is UB if szsrc < 3. + while (cur_src < limit_src - 3) { // While we have >= 32 bits. + uint32_t in = absl::big_endian::Load32(cur_src) >> 8; + + cur_dest[0] = base64[in >> 18]; + in &= 0x3FFFF; + cur_dest[1] = base64[in >> 12]; + in &= 0xFFF; + cur_dest[2] = base64[in >> 6]; + in &= 0x3F; + cur_dest[3] = base64[in]; + + cur_dest += 4; + cur_src += 3; + } + } + // To save time, we didn't update szdest or szsrc in the loop. So do it now. + szdest = limit_dest - cur_dest; + szsrc = limit_src - cur_src; + + /* now deal with the tail (<=3 bytes) */ + switch (szsrc) { + case 0: + // Nothing left; nothing more to do. + break; + case 1: { + // One byte left: this encodes to two characters, and (optionally) + // two pad characters to round out the four-character cypherblock. + if (szdest < 2) return 0; + uint32_t in = cur_src[0]; + cur_dest[0] = base64[in >> 2]; + in &= 0x3; + cur_dest[1] = base64[in << 4]; + cur_dest += 2; + szdest -= 2; + if (do_padding) { + if (szdest < 2) return 0; + cur_dest[0] = kPad64; + cur_dest[1] = kPad64; + cur_dest += 2; + szdest -= 2; + } + break; + } + case 2: { + // Two bytes left: this encodes to three characters, and (optionally) + // one pad character to round out the four-character cypherblock. + if (szdest < 3) return 0; + uint32_t in = absl::big_endian::Load16(cur_src); + cur_dest[0] = base64[in >> 10]; + in &= 0x3FF; + cur_dest[1] = base64[in >> 4]; + in &= 0x00F; + cur_dest[2] = base64[in << 2]; + cur_dest += 3; + szdest -= 3; + if (do_padding) { + if (szdest < 1) return 0; + cur_dest[0] = kPad64; + cur_dest += 1; + szdest -= 1; + } + break; + } + case 3: { + // Three bytes left: same as in the big loop above. We can't do this in + // the loop because the loop above always reads 4 bytes, and the fourth + // byte is past the end of the input. + if (szdest < 4) return 0; + uint32_t in = (cur_src[0] << 16) + absl::big_endian::Load16(cur_src + 1); + cur_dest[0] = base64[in >> 18]; + in &= 0x3FFFF; + cur_dest[1] = base64[in >> 12]; + in &= 0xFFF; + cur_dest[2] = base64[in >> 6]; + in &= 0x3F; + cur_dest[3] = base64[in]; + cur_dest += 4; + szdest -= 4; + break; + } + default: + // Should not be reached: blocks of 4 bytes are handled + // in the while loop before this switch statement. + ABSL_RAW_LOG(FATAL, "Logic problem? szsrc = %zu", szsrc); + break; + } + return (cur_dest - dest); +} + +} // namespace strings_internal +ABSL_NAMESPACE_END +} // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/escaping.h b/third_party/abseil-cpp/absl/strings/internal/escaping.h new file mode 100644 index 0000000..6a9ce60 --- /dev/null +++ b/third_party/abseil-cpp/absl/strings/internal/escaping.h
@@ -0,0 +1,58 @@ +// Copyright 2020 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ABSL_STRINGS_INTERNAL_ESCAPING_H_ +#define ABSL_STRINGS_INTERNAL_ESCAPING_H_ + +#include <cassert> + +#include "absl/strings/internal/resize_uninitialized.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace strings_internal { + +ABSL_CONST_INIT extern const char kBase64Chars[]; + +// Calculates how long a string will be when it is base64 encoded given its +// length and whether or not the result should be padded. +size_t CalculateBase64EscapedLenInternal(size_t input_len, bool do_padding); + +// Base64-encodes `src` using the alphabet provided in `base64` and writes the +// result to `dest`. If `do_padding` is true, `dest` is padded with '=' chars +// until its length is a multiple of 3. Returns the length of `dest`. +size_t Base64EscapeInternal(const unsigned char* src, size_t szsrc, char* dest, + size_t szdest, const char* base64, bool do_padding); + +// Base64-encodes `src` using the alphabet provided in `base64` and writes the +// result to `dest`. If `do_padding` is true, `dest` is padded with '=' chars +// until its length is a multiple of 3. +template <typename String> +void Base64EscapeInternal(const unsigned char* src, size_t szsrc, String* dest, + bool do_padding, const char* base64_chars) { + const size_t calc_escaped_size = + CalculateBase64EscapedLenInternal(szsrc, do_padding); + STLStringResizeUninitialized(dest, calc_escaped_size); + + const size_t escaped_len = Base64EscapeInternal( + src, szsrc, &(*dest)[0], dest->size(), base64_chars, do_padding); + assert(calc_escaped_size == escaped_len); + dest->erase(escaped_len); +} + +} // namespace strings_internal +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_STRINGS_INTERNAL_ESCAPING_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/escaping_test_common.h b/third_party/abseil-cpp/absl/strings/internal/escaping_test_common.h index bd80303..7b18017a 100644 --- a/third_party/abseil-cpp/absl/strings/internal/escaping_test_common.h +++ b/third_party/abseil-cpp/absl/strings/internal/escaping_test_common.h
@@ -22,6 +22,7 @@ #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { struct base64_testcase { @@ -126,6 +127,7 @@ } } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_ESCAPING_TEST_COMMON_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/memutil.cc b/third_party/abseil-cpp/absl/strings/internal/memutil.cc index 77aa63c2..2519c68 100644 --- a/third_party/abseil-cpp/absl/strings/internal/memutil.cc +++ b/third_party/abseil-cpp/absl/strings/internal/memutil.cc
@@ -17,6 +17,7 @@ #include <cstdlib> namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { int memcasecmp(const char* s1, const char* s2, size_t len) { @@ -107,4 +108,5 @@ } } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/memutil.h b/third_party/abseil-cpp/absl/strings/internal/memutil.h index 7c071a8..9ad05358 100644 --- a/third_party/abseil-cpp/absl/strings/internal/memutil.h +++ b/third_party/abseil-cpp/absl/strings/internal/memutil.h
@@ -69,6 +69,7 @@ #include "absl/strings/ascii.h" // for absl::ascii_tolower namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { inline char* memcat(char* dest, size_t destlen, const char* src, @@ -141,6 +142,7 @@ size_t neelen); } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_MEMUTIL_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/numbers_test_common.h b/third_party/abseil-cpp/absl/strings/internal/numbers_test_common.h index 28247205..eaa88a8 100644 --- a/third_party/abseil-cpp/absl/strings/internal/numbers_test_common.h +++ b/third_party/abseil-cpp/absl/strings/internal/numbers_test_common.h
@@ -23,7 +23,10 @@ #include <limits> #include <string> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { template <typename IntType> @@ -42,8 +45,9 @@ while (value != 0) { const IntType next_value = value / base; // Can't use std::abs here because of problems when IntType is unsigned. - int remainder = value > next_value * base ? value - next_value * base - : next_value * base - value; + int remainder = + static_cast<int>(value > next_value * base ? value - next_value * base + : next_value * base - value); char c = remainder < 10 ? '0' + remainder : 'A' + remainder - 10; destination->insert(0, 1, c); value = next_value; @@ -166,7 +170,7 @@ {"0x1234", true, 16, 0x1234}, - // Base-10 std::string version. + // Base-10 string version. {"1234", true, 0, 1234}, {nullptr, false, 0, 0}, }}; @@ -174,6 +178,7 @@ } } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_NUMBERS_TEST_COMMON_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/ostringstream.cc b/third_party/abseil-cpp/absl/strings/internal/ostringstream.cc index d0f0f84b..05324c780 100644 --- a/third_party/abseil-cpp/absl/strings/internal/ostringstream.cc +++ b/third_party/abseil-cpp/absl/strings/internal/ostringstream.cc
@@ -15,6 +15,7 @@ #include "absl/strings/internal/ostringstream.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { OStringStream::Buf::int_type OStringStream::overflow(int c) { @@ -31,4 +32,5 @@ } } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/ostringstream.h b/third_party/abseil-cpp/absl/strings/internal/ostringstream.h index 2079201..d25d6047 100644 --- a/third_party/abseil-cpp/absl/strings/internal/ostringstream.h +++ b/third_party/abseil-cpp/absl/strings/internal/ostringstream.h
@@ -23,6 +23,7 @@ #include "absl/base/port.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { // The same as std::ostringstream but appends to a user-specified std::string, @@ -82,6 +83,7 @@ }; } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_OSTRINGSTREAM_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/pow10_helper.cc b/third_party/abseil-cpp/absl/strings/internal/pow10_helper.cc index 03ed8d0..42e96c34 100644 --- a/third_party/abseil-cpp/absl/strings/internal/pow10_helper.cc +++ b/third_party/abseil-cpp/absl/strings/internal/pow10_helper.cc
@@ -17,6 +17,7 @@ #include <cmath> namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { namespace { @@ -117,4 +118,5 @@ } } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/pow10_helper.h b/third_party/abseil-cpp/absl/strings/internal/pow10_helper.h index 9d1aa71..c37c2c3f 100644 --- a/third_party/abseil-cpp/absl/strings/internal/pow10_helper.h +++ b/third_party/abseil-cpp/absl/strings/internal/pow10_helper.h
@@ -22,7 +22,10 @@ #include <vector> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { // Computes the precise value of 10^exp. (I.e. the nearest representable @@ -31,6 +34,7 @@ double Pow10(int exp); } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_POW10_HELPER_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/pow10_helper_test.cc b/third_party/abseil-cpp/absl/strings/internal/pow10_helper_test.cc index a4a68b5..a4ff76d3 100644 --- a/third_party/abseil-cpp/absl/strings/internal/pow10_helper_test.cc +++ b/third_party/abseil-cpp/absl/strings/internal/pow10_helper_test.cc
@@ -20,6 +20,7 @@ #include "absl/strings/str_format.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { namespace { @@ -117,4 +118,5 @@ } // namespace } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h b/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h index 469962b..e42628e 100644 --- a/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h +++ b/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h
@@ -25,6 +25,7 @@ #include "absl/meta/type_traits.h" // for void_t namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { // Is a subclass of true_type or false_type, depending on whether or not @@ -35,8 +36,7 @@ static void Resize(string_type* s, size_t new_size) { s->resize(new_size); } }; -// __resize_default_init is provided by libc++ >= 8.0 and by Google's internal -// ::string implementation. +// __resize_default_init is provided by libc++ >= 8.0 template <typename string_type> struct ResizeUninitializedTraits< string_type, absl::void_t<decltype(std::declval<string_type&>() @@ -67,6 +67,7 @@ } } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_RESIZE_UNINITIALIZED_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized_test.cc b/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized_test.cc index c5be0b1..0f8b3c2 100644 --- a/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized_test.cc +++ b/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized_test.cc
@@ -20,13 +20,27 @@ int resize_call_count = 0; +// A mock string class whose only purpose is to track how many times its +// resize() method has been called. struct resizable_string { + size_t size() const { return 0; } + char& operator[](size_t) { + static char c = '\0'; + return c; + } void resize(size_t) { resize_call_count += 1; } }; int resize_default_init_call_count = 0; +// A mock string class whose only purpose is to track how many times its +// resize() and __resize_default_init() methods have been called. struct resize_default_init_string { + size_t size() const { return 0; } + char& operator[](size_t) { + static char c = '\0'; + return c; + } void resize(size_t) { resize_call_count += 1; } void __resize_default_init(size_t) { resize_default_init_call_count += 1; } };
diff --git a/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h b/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h index 202ab37..6035ca4 100644 --- a/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +++ b/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h
@@ -40,6 +40,7 @@ #include "absl/meta/type_traits.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { template <typename C, template <typename...> class T> @@ -242,5 +243,6 @@ IsConvertibleToSTLContainer<C>> {}; } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_STL_TYPE_TRAITS_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc b/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc index b40be8f..4d0604e0 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc
@@ -14,6 +14,7 @@ #include "absl/strings/internal/str_format/float_conversion.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace str_format_internal { namespace { @@ -32,6 +33,10 @@ template <typename T> struct MakeUnsigned : std::make_unsigned<T> {}; template <> +struct MakeUnsigned<absl::int128> { + using type = absl::uint128; +}; +template <> struct MakeUnsigned<absl::uint128> { using type = absl::uint128; }; @@ -39,6 +44,8 @@ template <typename T> struct IsSigned : std::is_signed<T> {}; template <> +struct IsSigned<absl::int128> : std::true_type {}; +template <> struct IsSigned<absl::uint128> : std::false_type {}; class ConvertedIntInfo { @@ -81,7 +88,7 @@ template <typename T> void UnsignedToStringRight(T u, ConversionChar conv) { char *p = end(); - switch (conv.radix()) { + switch (FormatConversionCharRadix(conv)) { default: case 10: for (; u; u /= 10) @@ -92,7 +99,7 @@ *--p = static_cast<char>('0' + static_cast<size_t>(u % 8)); break; case 16: { - const char *digits = kDigit[conv.upper() ? 1 : 0]; + const char *digits = kDigit[FormatConversionCharIsUpper(conv) ? 1 : 0]; for (; u; u /= 16) *--p = digits[static_cast<size_t>(u % 16)]; break; } @@ -114,21 +121,20 @@ string_view BaseIndicator(const ConvertedIntInfo &info, const ConversionSpec conv) { bool alt = conv.flags().alt; - int radix = conv.conv().radix(); - if (conv.conv().id() == ConversionChar::p) - alt = true; // always show 0x for %p. + int radix = FormatConversionCharRadix(conv.conv()); + if (conv.conv() == ConversionChar::p) alt = true; // always show 0x for %p. // From the POSIX description of '#' flag: // "For x or X conversion specifiers, a non-zero result shall have // 0x (or 0X) prefixed to it." if (alt && radix == 16 && !info.digits().empty()) { - if (conv.conv().upper()) return "0X"; + if (FormatConversionCharIsUpper(conv.conv())) return "0X"; return "0x"; } return {}; } string_view SignColumn(bool neg, const ConversionSpec conv) { - if (conv.conv().is_signed()) { + if (FormatConversionCharIsSigned(conv.conv())) { if (neg) return "-"; if (conv.flags().show_pos) return "+"; if (conv.flags().sign_col) return " "; @@ -168,7 +174,7 @@ if (!precision_specified) precision = 1; - if (conv.flags().alt && conv.conv().id() == ConversionChar::o) { + if (conv.flags().alt && conv.conv() == ConversionChar::o) { // From POSIX description of the '#' (alt) flag: // "For o conversion, it increases the precision (if necessary) to // force the first digit of the result to be zero." @@ -204,7 +210,7 @@ template <typename T> bool ConvertIntImplInner(T v, const ConversionSpec conv, FormatSinkImpl *sink) { ConvertedIntInfo info(v, conv.conv()); - if (conv.flags().basic && conv.conv().id() != ConversionChar::p) { + if (conv.flags().basic && (conv.conv() != ConversionChar::p)) { if (info.is_neg()) sink->Append(1, '-'); if (info.digits().empty()) { sink->Append(1, '0'); @@ -218,14 +224,13 @@ template <typename T> bool ConvertIntArg(T v, const ConversionSpec conv, FormatSinkImpl *sink) { - if (conv.conv().is_float()) { + if (FormatConversionCharIsFloat(conv.conv())) { return FormatConvertImpl(static_cast<double>(v), conv, sink).value; } - if (conv.conv().id() == ConversionChar::c) + if (conv.conv() == ConversionChar::c) return ConvertCharImpl(static_cast<unsigned char>(v), conv, sink); - if (!conv.conv().is_integral()) - return false; - if (!conv.conv().is_signed() && IsSigned<T>::value) { + if (!FormatConversionCharIsIntegral(conv.conv())) return false; + if (!FormatConversionCharIsSigned(conv.conv()) && IsSigned<T>::value) { using U = typename MakeUnsigned<T>::type; return FormatConvertImpl(static_cast<U>(v), conv, sink).value; } @@ -234,13 +239,13 @@ template <typename T> bool ConvertFloatArg(T v, const ConversionSpec conv, FormatSinkImpl *sink) { - return conv.conv().is_float() && ConvertFloatImpl(v, conv, sink); + return FormatConversionCharIsFloat(conv.conv()) && + ConvertFloatImpl(v, conv, sink); } inline bool ConvertStringArg(string_view v, const ConversionSpec conv, FormatSinkImpl *sink) { - if (conv.conv().id() != ConversionChar::s) - return false; + if (conv.conv() != ConversionChar::s) return false; if (conv.flags().basic) { sink->Append(v); return true; @@ -267,7 +272,7 @@ ConvertResult<Conv::s | Conv::p> FormatConvertImpl(const char *v, const ConversionSpec conv, FormatSinkImpl *sink) { - if (conv.conv().id() == ConversionChar::p) + if (conv.conv() == ConversionChar::p) return {FormatConvertImpl(VoidPtr(v), conv, sink).value}; size_t len; if (v == nullptr) { @@ -275,7 +280,7 @@ } else if (conv.precision() < 0) { len = std::strlen(v); } else { - // If precision is set, we look for the null terminator on the valid range. + // If precision is set, we look for the NUL-terminator on the valid range. len = std::find(v, v + conv.precision(), '\0') - v; } return {ConvertStringArg(string_view(v, len), conv, sink)}; @@ -284,8 +289,7 @@ // ==================== Raw pointers ==================== ConvertResult<Conv::p> FormatConvertImpl(VoidPtr v, const ConversionSpec conv, FormatSinkImpl *sink) { - if (conv.conv().id() != ConversionChar::p) - return {false}; + if (conv.conv() != ConversionChar::p) return {false}; if (!v.value) { sink->Append("(nil)"); return {true}; @@ -363,6 +367,11 @@ FormatSinkImpl *sink) { return {ConvertIntArg(v, conv, sink)}; } +IntegralConvertResult FormatConvertImpl(absl::int128 v, + const ConversionSpec conv, + FormatSinkImpl *sink) { + return {ConvertIntArg(v, conv, sink)}; +} IntegralConvertResult FormatConvertImpl(absl::uint128 v, const ConversionSpec conv, FormatSinkImpl *sink) { @@ -372,6 +381,8 @@ ABSL_INTERNAL_FORMAT_DISPATCH_OVERLOADS_EXPAND_(); + } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h b/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h index 5cb3a14d..7a93756 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h
@@ -18,11 +18,10 @@ #include "absl/strings/internal/str_format/extension.h" #include "absl/strings/string_view.h" -class Cord; -class CordReader; - namespace absl { +ABSL_NAMESPACE_BEGIN +class Cord; class FormatCountCapture; class FormatSink; @@ -67,12 +66,11 @@ FormatSinkImpl* sink); template <class AbslCord, typename std::enable_if< - std::is_same<AbslCord, ::Cord>::value>::type* = nullptr, - class AbslCordReader = ::CordReader> + std::is_same<AbslCord, absl::Cord>::value>::type* = nullptr> ConvertResult<Conv::s> FormatConvertImpl(const AbslCord& value, ConversionSpec conv, FormatSinkImpl* sink) { - if (conv.conv().id() != ConversionChar::s) return {false}; + if (conv.conv() != ConversionChar::s) return {false}; bool is_left = conv.flags().left; size_t space_remaining = 0; @@ -90,11 +88,17 @@ if (space_remaining > 0 && !is_left) sink->Append(space_remaining, ' '); - string_view piece; - for (AbslCordReader reader(value); - to_write > 0 && reader.ReadFragment(&piece); to_write -= piece.size()) { - if (piece.size() > to_write) piece.remove_suffix(piece.size() - to_write); + for (string_view piece : value.Chunks()) { + if (piece.size() > to_write) { + piece.remove_suffix(piece.size() - to_write); + to_write = 0; + } else { + to_write -= piece.size(); + } sink->Append(piece); + if (to_write == 0) { + break; + } } if (space_remaining > 0 && is_left) sink->Append(space_remaining, ' '); @@ -144,6 +148,8 @@ IntegralConvertResult FormatConvertImpl(unsigned long long v, // NOLINT ConversionSpec conv, FormatSinkImpl* sink); +IntegralConvertResult FormatConvertImpl(int128 v, ConversionSpec conv, + FormatSinkImpl* sink); IntegralConvertResult FormatConvertImpl(uint128 v, ConversionSpec conv, FormatSinkImpl* sink); template <typename T, enable_if_t<std::is_same<T, bool>::value, int> = 0> @@ -179,8 +185,7 @@ FormatSinkImpl* sink) { const absl::enable_if_t<sizeof(T) != 0, FormatCountCapture>& v2 = v; - if (conv.conv().id() != str_format_internal::ConversionChar::n) - return {false}; + if (conv.conv() != str_format_internal::ConversionChar::n) return {false}; *v2.p_ = static_cast<int>(sink->size()); return {true}; } @@ -372,7 +377,7 @@ template <typename T> static bool Dispatch(Data arg, ConversionSpec spec, void* out) { // A `none` conv indicates that we want the `int` conversion. - if (ABSL_PREDICT_FALSE(spec.conv().id() == ConversionChar::none)) { + if (ABSL_PREDICT_FALSE(spec.conv() == ConversionChar::none)) { return ToInt<T>(arg, static_cast<int*>(out), std::is_integral<T>(), std::is_enum<T>()); } @@ -408,6 +413,7 @@ __VA_ARGS__); \ ABSL_INTERNAL_FORMAT_DISPATCH_INSTANTIATE_(unsigned long long, /* NOLINT */ \ __VA_ARGS__); \ + ABSL_INTERNAL_FORMAT_DISPATCH_INSTANTIATE_(int128, __VA_ARGS__); \ ABSL_INTERNAL_FORMAT_DISPATCH_INSTANTIATE_(uint128, __VA_ARGS__); \ ABSL_INTERNAL_FORMAT_DISPATCH_INSTANTIATE_(float, __VA_ARGS__); \ ABSL_INTERNAL_FORMAT_DISPATCH_INSTANTIATE_(double, __VA_ARGS__); \ @@ -418,7 +424,9 @@ ABSL_INTERNAL_FORMAT_DISPATCH_OVERLOADS_EXPAND_(extern); + } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_ARG_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/arg_test.cc b/third_party/abseil-cpp/absl/strings/internal/str_format/arg_test.cc index 3421fac..8d30d8b 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/arg_test.cc +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/arg_test.cc
@@ -14,6 +14,7 @@ #include "absl/strings/str_format.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace str_format_internal { namespace { @@ -95,10 +96,10 @@ std::string s; FormatSinkImpl sink(&s); ConversionSpec conv; - conv.set_conv(ConversionChar::FromChar('s')); - conv.set_flags(Flags()); - conv.set_width(-1); - conv.set_precision(-1); + FormatConversionSpecImplFriend::SetConversionChar(ConversionChar::s, &conv); + FormatConversionSpecImplFriend::SetFlags(Flags(), &conv); + FormatConversionSpecImplFriend::SetWidth(-1, &conv); + FormatConversionSpecImplFriend::SetPrecision(-1, &conv); EXPECT_TRUE( FormatArgImplFriend::Convert(FormatArgImpl(kMyArray), conv, &sink)); sink.Flush(); @@ -108,4 +109,5 @@ } // namespace } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc b/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc index a31859ec..27522fdb 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc
@@ -6,6 +6,7 @@ #include <string> namespace absl { +ABSL_NAMESPACE_BEGIN namespace str_format_internal { namespace { @@ -65,19 +66,22 @@ return false; } - bound->set_width(width); - bound->set_precision(precision); - bound->set_flags(unbound->flags); - if (force_left) - bound->set_left(true); - } else { - bound->set_flags(unbound->flags); - bound->set_width(-1); - bound->set_precision(-1); - } + FormatConversionSpecImplFriend::SetWidth(width, bound); + FormatConversionSpecImplFriend::SetPrecision(precision, bound); - bound->set_length_mod(unbound->length_mod); - bound->set_conv(unbound->conv); + if (force_left) { + Flags flags = unbound->flags; + flags.left = true; + FormatConversionSpecImplFriend::SetFlags(flags, bound); + } else { + FormatConversionSpecImplFriend::SetFlags(unbound->flags, bound); + } + } else { + FormatConversionSpecImplFriend::SetFlags(unbound->flags, bound); + FormatConversionSpecImplFriend::SetWidth(-1, bound); + FormatConversionSpecImplFriend::SetPrecision(-1, bound); + } + FormatConversionSpecImplFriend::SetConversionChar(unbound->conv, bound); bound->set_arg(arg); return true; } @@ -139,10 +143,11 @@ UntypedFormatSpecImpl spec("%d"); std::ostringstream ss; - ss << "{" << Streamable(spec, {*bound.arg()}) << ":" << bound.flags(); + ss << "{" << Streamable(spec, {*bound.arg()}) << ":" + << FormatConversionSpecImplFriend::FlagsToString(bound); if (bound.width() >= 0) ss << bound.width(); if (bound.precision() >= 0) ss << "." << bound.precision(); - ss << bound.length_mod() << bound.conv() << "}"; + ss << bound.conv() << "}"; Append(ss.str()); return true; } @@ -196,6 +201,15 @@ return *out; } +std::string FormatPack(const UntypedFormatSpecImpl format, + absl::Span<const FormatArgImpl> args) { + std::string out; + if (ABSL_PREDICT_FALSE(!FormatUntyped(&out, format, args))) { + out.clear(); + } + return out; +} + int FprintF(std::FILE* output, const UntypedFormatSpecImpl format, absl::Span<const FormatArgImpl> args) { FILERawSink sink(output); @@ -227,4 +241,5 @@ } } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h b/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h index 7df140a4..ee4475e0 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h
@@ -13,6 +13,7 @@ #include "absl/types/span.h" namespace absl { +ABSL_NAMESPACE_BEGIN class UntypedFormatSpec; @@ -73,13 +74,13 @@ using Base = typename MakeDependent<UntypedFormatSpec, Args...>::type; public: -#if ABSL_INTERNAL_ENABLE_FORMAT_CHECKER +#ifdef ABSL_INTERNAL_ENABLE_FORMAT_CHECKER - // Honeypot overload for when the std::string is not constexpr. + // Honeypot overload for when the string is not constexpr. // We use the 'unavailable' attribute to give a better compiler error than // just 'method is deleted'. FormatSpecTemplate(...) // NOLINT - __attribute__((unavailable("Format std::string is not constexpr."))); + __attribute__((unavailable("Format string is not constexpr."))); // Honeypot overload for when the format is constexpr and invalid. // We use the 'unavailable' attribute to give a better compiler error than @@ -121,8 +122,8 @@ #endif // ABSL_INTERNAL_ENABLE_FORMAT_CHECKER template <Conv... C, typename = typename std::enable_if< - sizeof...(C) == sizeof...(Args) && - AllOf(Contains(ArgumentToConv<Args>(), + AllOf(sizeof...(C) == sizeof...(Args), + Contains(ArgumentToConv<Args>(), C)...)>::type> FormatSpecTemplate(const ExtendedParsedFormat<C...>& pc) // NOLINT : Base(&pc) {} @@ -178,12 +179,8 @@ std::string& AppendPack(std::string* out, UntypedFormatSpecImpl format, absl::Span<const FormatArgImpl> args); -inline std::string FormatPack(const UntypedFormatSpecImpl format, - absl::Span<const FormatArgImpl> args) { - std::string out; - AppendPack(&out, format, args); - return out; -} +std::string FormatPack(const UntypedFormatSpecImpl format, + absl::Span<const FormatArgImpl> args); int FprintF(std::FILE* output, UntypedFormatSpecImpl format, absl::Span<const FormatArgImpl> args); @@ -206,6 +203,7 @@ }; } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_BIND_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/bind_test.cc b/third_party/abseil-cpp/absl/strings/internal/str_format/bind_test.cc index 2574801..64790a8 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/bind_test.cc +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/bind_test.cc
@@ -6,6 +6,7 @@ #include "gtest/gtest.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace str_format_internal { namespace { @@ -112,18 +113,18 @@ FormatArgImpl(ia[2]), FormatArgImpl(ia[3]), FormatArgImpl(ia[4])}; const Expectation kExpect[] = { - {__LINE__, "a%4db%dc", "a{10:4d}b{20:d}c"}, - {__LINE__, "a%.4db%dc", "a{10:.4d}b{20:d}c"}, - {__LINE__, "a%4.5db%dc", "a{10:4.5d}b{20:d}c"}, - {__LINE__, "a%db%4.5dc", "a{10:d}b{20:4.5d}c"}, - {__LINE__, "a%db%*.*dc", "a{10:d}b{40:20.30d}c"}, - {__LINE__, "a%.*fb", "a{20:.10f}b"}, - {__LINE__, "a%1$db%2$*3$.*4$dc", "a{10:d}b{20:30.40d}c"}, - {__LINE__, "a%4$db%3$*2$.*1$dc", "a{40:d}b{30:20.10d}c"}, - {__LINE__, "a%04ldb", "a{10:04ld}b"}, - {__LINE__, "a%-#04lldb", "a{10:-#04lld}b"}, - {__LINE__, "a%1$*5$db", "a{10:-10d}b"}, - {__LINE__, "a%1$.*5$db", "a{10:d}b"}, + {__LINE__, "a%4db%dc", "a{10:4d}b{20:d}c"}, + {__LINE__, "a%.4db%dc", "a{10:.4d}b{20:d}c"}, + {__LINE__, "a%4.5db%dc", "a{10:4.5d}b{20:d}c"}, + {__LINE__, "a%db%4.5dc", "a{10:d}b{20:4.5d}c"}, + {__LINE__, "a%db%*.*dc", "a{10:d}b{40:20.30d}c"}, + {__LINE__, "a%.*fb", "a{20:.10f}b"}, + {__LINE__, "a%1$db%2$*3$.*4$dc", "a{10:d}b{20:30.40d}c"}, + {__LINE__, "a%4$db%3$*2$.*1$dc", "a{40:d}b{30:20.10d}c"}, + {__LINE__, "a%04ldb", "a{10:04d}b"}, + {__LINE__, "a%-#04lldb", "a{10:-#04d}b"}, + {__LINE__, "a%1$*5$db", "a{10:-10d}b"}, + {__LINE__, "a%1$.*5$db", "a{10:d}b"}, }; for (const Expectation &e : kExpect) { absl::string_view fmt = e.fmt; @@ -138,4 +139,5 @@ } // namespace } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h b/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h index 8b594f2d..8993a79b 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h
@@ -1,20 +1,20 @@ #ifndef ABSL_STRINGS_INTERNAL_STR_FORMAT_CHECKER_H_ #define ABSL_STRINGS_INTERNAL_STR_FORMAT_CHECKER_H_ +#include "absl/base/attributes.h" #include "absl/strings/internal/str_format/arg.h" #include "absl/strings/internal/str_format/extension.h" // Compile time check support for entry points. #ifndef ABSL_INTERNAL_ENABLE_FORMAT_CHECKER -#if defined(__clang__) && !defined(__native_client__) -#if __has_attribute(enable_if) +#if ABSL_HAVE_ATTRIBUTE(enable_if) && !defined(__native_client__) #define ABSL_INTERNAL_ENABLE_FORMAT_CHECKER 1 -#endif // __has_attribute(enable_if) -#endif // defined(__clang__) && !defined(__native_client__) +#endif // ABSL_HAVE_ATTRIBUTE(enable_if) && !defined(__native_client__) #endif // ABSL_INTERNAL_ENABLE_FORMAT_CHECKER namespace absl { +ABSL_NAMESPACE_BEGIN namespace str_format_internal { constexpr bool AllOf() { return true; } @@ -31,7 +31,7 @@ std::declval<FormatSinkImpl*>()))::kConv; } -#if ABSL_INTERNAL_ENABLE_FORMAT_CHECKER +#ifdef ABSL_INTERNAL_ENABLE_FORMAT_CHECKER constexpr bool ContainsChar(const char* chars, char c) { return *chars == c || (*chars && ContainsChar(chars + 1, c)); @@ -320,6 +320,7 @@ #endif // ABSL_INTERNAL_ENABLE_FORMAT_CHECKER } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_CHECKER_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/checker_test.cc b/third_party/abseil-cpp/absl/strings/internal/str_format/checker_test.cc index c1d8c769..ea2a7681 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/checker_test.cc +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/checker_test.cc
@@ -5,6 +5,7 @@ #include "absl/strings/str_format.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace str_format_internal { namespace { @@ -12,7 +13,7 @@ std::string out; #define CONV_SET_CASE(c) \ if (Contains(conv, Conv::c)) out += #c; - ABSL_CONVERSION_CHARS_EXPAND_(CONV_SET_CASE, ) + ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(CONV_SET_CASE, ) #undef CONV_SET_CASE if (Contains(conv, Conv::star)) out += "*"; return out; @@ -35,7 +36,7 @@ EXPECT_EQ(ConvToString(conv), "p"); } -#if ABSL_INTERNAL_ENABLE_FORMAT_CHECKER +#ifdef ABSL_INTERNAL_ENABLE_FORMAT_CHECKER struct Case { bool result; @@ -147,4 +148,5 @@ } // namespace } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/convert_test.cc b/third_party/abseil-cpp/absl/strings/internal/str_format/convert_test.cc index 814ccf4..cbcd7caf 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/convert_test.cc +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/convert_test.cc
@@ -5,10 +5,13 @@ #include <cmath> #include <string> +#include "gmock/gmock.h" #include "gtest/gtest.h" +#include "absl/base/internal/raw_logging.h" #include "absl/strings/internal/str_format/bind.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace str_format_internal { namespace { @@ -151,18 +154,26 @@ UntypedFormatSpecImpl format("%.1s"); EXPECT_EQ("a", FormatPack(format, {FormatArgImpl(p)})); - // We cap at the nul terminator. + // We cap at the NUL-terminator. p = "ABC"; UntypedFormatSpecImpl format2("%.10s"); EXPECT_EQ("ABC", FormatPack(format2, {FormatArgImpl(p)})); } +// Pointer formatting is implementation defined. This checks that the argument +// can be matched to `ptr`. +MATCHER_P(MatchesPointerString, ptr, "") { + if (ptr == nullptr && arg == "(nil)") { + return true; + } + void* parsed = nullptr; + if (sscanf(arg.c_str(), "%p", &parsed) != 1) { + ABSL_RAW_LOG(FATAL, "Could not parse %s", arg.c_str()); + } + return ptr == parsed; +} + TEST_F(FormatConvertTest, Pointer) { -#ifdef _MSC_VER - // MSVC's printf implementation prints pointers differently. We can't easily - // compare our implementation to theirs. - return; -#endif static int x = 0; const int *xp = &x; char c = 'h'; @@ -173,48 +184,62 @@ using VoidF = void (*)(); VoidF fp = [] {}, fnil = nullptr; volatile char vc; - volatile char* vcp = &vc; - volatile char* vcnil = nullptr; - const FormatArgImpl args[] = { + volatile char *vcp = &vc; + volatile char *vcnil = nullptr; + const FormatArgImpl args_array[] = { FormatArgImpl(xp), FormatArgImpl(cp), FormatArgImpl(inil), FormatArgImpl(cnil), FormatArgImpl(mcp), FormatArgImpl(fp), FormatArgImpl(fnil), FormatArgImpl(vcp), FormatArgImpl(vcnil), }; - struct Expectation { - std::string out; - const char *fmt; - }; - const Expectation kExpect[] = { - {StrPrint("%p", &x), "%p"}, - {StrPrint("%20p", &x), "%20p"}, - {StrPrint("%.1p", &x), "%.1p"}, - {StrPrint("%.20p", &x), "%.20p"}, - {StrPrint("%30.20p", &x), "%30.20p"}, + auto args = absl::MakeConstSpan(args_array); - {StrPrint("%-p", &x), "%-p"}, - {StrPrint("%-20p", &x), "%-20p"}, - {StrPrint("%-.1p", &x), "%-.1p"}, - {StrPrint("%.20p", &x), "%.20p"}, - {StrPrint("%-30.20p", &x), "%-30.20p"}, + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%p"), args), + MatchesPointerString(&x)); + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%20p"), args), + MatchesPointerString(&x)); + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%.1p"), args), + MatchesPointerString(&x)); + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%.20p"), args), + MatchesPointerString(&x)); + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%30.20p"), args), + MatchesPointerString(&x)); - {StrPrint("%p", cp), "%2$p"}, // const char* - {"(nil)", "%3$p"}, // null const char * - {"(nil)", "%4$p"}, // null const int * - {StrPrint("%p", mcp), "%5$p"}, // nonconst char* + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%-p"), args), + MatchesPointerString(&x)); + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%-20p"), args), + MatchesPointerString(&x)); + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%-.1p"), args), + MatchesPointerString(&x)); + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%.20p"), args), + MatchesPointerString(&x)); + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%-30.20p"), args), + MatchesPointerString(&x)); - {StrPrint("%p", fp), "%6$p"}, // function pointer - {StrPrint("%p", vcp), "%8$p"}, // function pointer + // const char* + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%2$p"), args), + MatchesPointerString(cp)); + // null const int* + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%3$p"), args), + MatchesPointerString(nullptr)); + // null const char* + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%4$p"), args), + MatchesPointerString(nullptr)); + // nonconst char* + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%5$p"), args), + MatchesPointerString(mcp)); -#ifndef __APPLE__ - // Apple's printf differs here (0x0 vs. nil) - {StrPrint("%p", fnil), "%7$p"}, // null function pointer - {StrPrint("%p", vcnil), "%9$p"}, // null function pointer -#endif - }; - for (const Expectation &e : kExpect) { - UntypedFormatSpecImpl format(e.fmt); - EXPECT_EQ(e.out, FormatPack(format, absl::MakeSpan(args))) << e.fmt; - } + // function pointers + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%6$p"), args), + MatchesPointerString(reinterpret_cast<const void*>(fp))); + EXPECT_THAT( + FormatPack(UntypedFormatSpecImpl("%8$p"), args), + MatchesPointerString(reinterpret_cast<volatile const void *>(vcp))); + + // null function pointers + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%7$p"), args), + MatchesPointerString(nullptr)); + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%9$p"), args), + MatchesPointerString(nullptr)); } struct Cardinal { @@ -366,7 +391,6 @@ AllIntTypes; INSTANTIATE_TYPED_TEST_CASE_P(TypedFormatConvertTestWithAllIntTypes, TypedFormatConvertTest, AllIntTypes); - TEST_F(FormatConvertTest, VectorBool) { // Make sure vector<bool>'s values behave as bools. std::vector<bool> v = {true, false}; @@ -378,6 +402,42 @@ FormatArgImpl(cv[0]), FormatArgImpl(cv[1])}))); } + +TEST_F(FormatConvertTest, Int128) { + absl::int128 positive = static_cast<absl::int128>(0x1234567890abcdef) * 1979; + absl::int128 negative = -positive; + absl::int128 max = absl::Int128Max(), min = absl::Int128Min(); + const FormatArgImpl args[] = {FormatArgImpl(positive), + FormatArgImpl(negative), FormatArgImpl(max), + FormatArgImpl(min)}; + + struct Case { + const char* format; + const char* expected; + } cases[] = { + {"%1$d", "2595989796776606496405"}, + {"%1$30d", " 2595989796776606496405"}, + {"%1$-30d", "2595989796776606496405 "}, + {"%1$u", "2595989796776606496405"}, + {"%1$x", "8cba9876066020f695"}, + {"%2$d", "-2595989796776606496405"}, + {"%2$30d", " -2595989796776606496405"}, + {"%2$-30d", "-2595989796776606496405 "}, + {"%2$u", "340282366920938460867384810655161715051"}, + {"%2$x", "ffffffffffffff73456789f99fdf096b"}, + {"%3$d", "170141183460469231731687303715884105727"}, + {"%3$u", "170141183460469231731687303715884105727"}, + {"%3$x", "7fffffffffffffffffffffffffffffff"}, + {"%4$d", "-170141183460469231731687303715884105728"}, + {"%4$x", "80000000000000000000000000000000"}, + }; + + for (auto c : cases) { + UntypedFormatSpecImpl format(c.format); + EXPECT_EQ(c.expected, FormatPack(format, absl::MakeSpan(args))); + } +} + TEST_F(FormatConvertTest, Uint128) { absl::uint128 v = static_cast<absl::uint128>(0x1234567890abcdef) * 1979; absl::uint128 max = absl::Uint128Max(); @@ -587,4 +647,5 @@ } // namespace } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc b/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc index d7f5815..2e5bc2c 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc
@@ -20,38 +20,8 @@ #include <string> namespace absl { +ABSL_NAMESPACE_BEGIN namespace str_format_internal { -namespace { -// clang-format off -#define ABSL_LENGTH_MODS_EXPAND_ \ - X_VAL(h) X_SEP \ - X_VAL(hh) X_SEP \ - X_VAL(l) X_SEP \ - X_VAL(ll) X_SEP \ - X_VAL(L) X_SEP \ - X_VAL(j) X_SEP \ - X_VAL(z) X_SEP \ - X_VAL(t) X_SEP \ - X_VAL(q) -// clang-format on -} // namespace - -const LengthMod::Spec LengthMod::kSpecs[] = { -#define X_VAL(id) { LengthMod::id, #id, strlen(#id) } -#define X_SEP , - ABSL_LENGTH_MODS_EXPAND_, {LengthMod::none, "", 0} -#undef X_VAL -#undef X_SEP -}; - -const ConversionChar::Spec ConversionChar::kSpecs[] = { -#define X_VAL(id) { ConversionChar::id, #id[0] } -#define X_SEP , - ABSL_CONVERSION_CHARS_EXPAND_(X_VAL, X_SEP), - {ConversionChar::none, '\0'}, -#undef X_VAL -#undef X_SEP -}; std::string Flags::ToString() const { std::string s; @@ -63,10 +33,6 @@ return s; } -const size_t LengthMod::kNumValues; - -const size_t ConversionChar::kNumValues; - bool FormatSinkImpl::PutPaddedString(string_view v, int w, int p, bool l) { size_t space_remaining = 0; if (w >= 0) space_remaining = w; @@ -81,4 +47,5 @@ } } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h b/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h index eb81f8a..d1665753 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h
@@ -17,18 +17,18 @@ #define ABSL_STRINGS_INTERNAL_STR_FORMAT_EXTENSION_H_ #include <limits.h> + #include <cstddef> #include <cstring> #include <ostream> +#include "absl/base/config.h" #include "absl/base/port.h" #include "absl/strings/internal/str_format/output.h" #include "absl/strings/string_view.h" -class Cord; - namespace absl { - +ABSL_NAMESPACE_BEGIN namespace str_format_internal { class FormatRawSinkImpl { @@ -136,56 +136,8 @@ } }; -struct LengthMod { - public: - enum Id : uint8_t { - h, hh, l, ll, L, j, z, t, q, none - }; - static const size_t kNumValues = none + 1; - - LengthMod() : id_(none) {} - - // Index into the opaque array of LengthMod enums. - // Requires: i < kNumValues - static LengthMod FromIndex(size_t i) { - return LengthMod(kSpecs[i].value); - } - - static LengthMod FromId(Id id) { return LengthMod(id); } - - // The length modifier std::string associated with a specified LengthMod. - string_view name() const { - const Spec& spec = kSpecs[id_]; - return {spec.name, spec.name_length}; - } - - Id id() const { return id_; } - - friend bool operator==(const LengthMod& a, const LengthMod& b) { - return a.id() == b.id(); - } - friend bool operator!=(const LengthMod& a, const LengthMod& b) { - return !(a == b); - } - friend std::ostream& operator<<(std::ostream& os, const LengthMod& v) { - return os << v.name(); - } - - private: - struct Spec { - Id value; - const char *name; - size_t name_length; - }; - static const Spec kSpecs[]; - - explicit LengthMod(Id id) : id_(id) {} - - Id id_; -}; - // clang-format off -#define ABSL_CONVERSION_CHARS_EXPAND_(X_VAL, X_SEP) \ +#define ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(X_VAL, X_SEP) \ /* text */ \ X_VAL(c) X_SEP X_VAL(C) X_SEP X_VAL(s) X_SEP X_VAL(S) X_SEP \ /* ints */ \ @@ -196,121 +148,135 @@ X_VAL(g) X_SEP X_VAL(G) X_SEP X_VAL(a) X_SEP X_VAL(A) X_SEP \ /* misc */ \ X_VAL(n) X_SEP X_VAL(p) -// clang-format on -struct ConversionChar { - public: - enum Id : uint8_t { +enum class FormatConversionChar : uint8_t { c, C, s, S, // text d, i, o, u, x, X, // int f, F, e, E, g, G, a, A, // float n, p, // misc - none - }; - static const size_t kNumValues = none + 1; - - ConversionChar() : id_(none) {} - - public: - // Index into the opaque array of ConversionChar enums. - // Requires: i < kNumValues - static ConversionChar FromIndex(size_t i) { - return ConversionChar(kSpecs[i].value); - } - - static ConversionChar FromChar(char c) { - ConversionChar::Id out_id = ConversionChar::none; - switch (c) { -#define X_VAL(id) \ - case #id[0]: \ - out_id = ConversionChar::id; \ - break; - ABSL_CONVERSION_CHARS_EXPAND_(X_VAL, ) -#undef X_VAL - default: - break; - } - return ConversionChar(out_id); - } - - static ConversionChar FromId(Id id) { return ConversionChar(id); } - Id id() const { return id_; } - - int radix() const { - switch (id()) { - case x: case X: case a: case A: case p: return 16; - case o: return 8; - default: return 10; - } - } - - bool upper() const { - switch (id()) { - case X: case F: case E: case G: case A: return true; - default: return false; - } - } - - bool is_signed() const { - switch (id()) { - case d: case i: return true; - default: return false; - } - } - - bool is_integral() const { - switch (id()) { - case d: case i: case u: case o: case x: case X: - return true; - default: return false; - } - } - - bool is_float() const { - switch (id()) { - case a: case e: case f: case g: case A: case E: case F: case G: - return true; - default: return false; - } - } - - bool IsValid() const { return id() != none; } - - // The associated char. - char Char() const { return kSpecs[id_].name; } - - friend bool operator==(const ConversionChar& a, const ConversionChar& b) { - return a.id() == b.id(); - } - friend bool operator!=(const ConversionChar& a, const ConversionChar& b) { - return !(a == b); - } - friend std::ostream& operator<<(std::ostream& os, const ConversionChar& v) { - char c = v.Char(); - if (!c) c = '?'; - return os << c; - } - - private: - struct Spec { - Id value; - char name; - }; - static const Spec kSpecs[]; - - explicit ConversionChar(Id id) : id_(id) {} - - Id id_; + kNone, + none = kNone }; +// clang-format on -class ConversionSpec { +inline FormatConversionChar FormatConversionCharFromChar(char c) { + switch (c) { +#define ABSL_INTERNAL_X_VAL(id) \ + case #id[0]: \ + return FormatConversionChar::id; + ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(ABSL_INTERNAL_X_VAL, ) +#undef ABSL_INTERNAL_X_VAL + } + return FormatConversionChar::kNone; +} + +inline int FormatConversionCharRadix(FormatConversionChar c) { + switch (c) { + case FormatConversionChar::x: + case FormatConversionChar::X: + case FormatConversionChar::a: + case FormatConversionChar::A: + case FormatConversionChar::p: + return 16; + case FormatConversionChar::o: + return 8; + default: + return 10; + } +} + +inline bool FormatConversionCharIsUpper(FormatConversionChar c) { + switch (c) { + case FormatConversionChar::X: + case FormatConversionChar::F: + case FormatConversionChar::E: + case FormatConversionChar::G: + case FormatConversionChar::A: + return true; + default: + return false; + } +} + +inline bool FormatConversionCharIsSigned(FormatConversionChar c) { + switch (c) { + case FormatConversionChar::d: + case FormatConversionChar::i: + return true; + default: + return false; + } +} + +inline bool FormatConversionCharIsIntegral(FormatConversionChar c) { + switch (c) { + case FormatConversionChar::d: + case FormatConversionChar::i: + case FormatConversionChar::u: + case FormatConversionChar::o: + case FormatConversionChar::x: + case FormatConversionChar::X: + return true; + default: + return false; + } +} + +inline bool FormatConversionCharIsFloat(FormatConversionChar c) { + switch (c) { + case FormatConversionChar::a: + case FormatConversionChar::e: + case FormatConversionChar::f: + case FormatConversionChar::g: + case FormatConversionChar::A: + case FormatConversionChar::E: + case FormatConversionChar::F: + case FormatConversionChar::G: + return true; + default: + return false; + } +} + +inline char FormatConversionCharToChar(FormatConversionChar c) { + switch (c) { +#define ABSL_INTERNAL_X_VAL(e) \ + case FormatConversionChar::e: \ + return #e[0]; +#define ABSL_INTERNAL_X_SEP + ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(ABSL_INTERNAL_X_VAL, + ABSL_INTERNAL_X_SEP) + case FormatConversionChar::kNone: + return '\0'; +#undef ABSL_INTERNAL_X_VAL +#undef ABSL_INTERNAL_X_SEP + } + return '\0'; +} + +// The associated char. +inline std::ostream& operator<<(std::ostream& os, FormatConversionChar v) { + char c = FormatConversionCharToChar(v); + if (!c) c = '?'; + return os << c; +} + +struct FormatConversionSpecImplFriend; + +class FormatConversionSpec { public: - Flags flags() const { return flags_; } - LengthMod length_mod() const { return length_mod_; } - ConversionChar conv() const { + // Width and precison are not specified, no flags are set. + bool is_basic() const { return flags_.basic; } + bool has_left_flag() const { return flags_.left; } + bool has_show_pos_flag() const { return flags_.show_pos; } + bool has_sign_col_flag() const { return flags_.sign_col; } + bool has_alt_flag() const { return flags_.alt; } + bool has_zero_flag() const { return flags_.zero; } + + FormatConversionChar conversion_char() const { // Keep this field first in the struct . It generates better code when // accessing it when ConversionSpec is passed by value in registers. - static_assert(offsetof(ConversionSpec, conv_) == 0, ""); + static_assert(offsetof(FormatConversionSpec, conv_) == 0, ""); return conv_; } @@ -321,46 +287,71 @@ // negative value. int precision() const { return precision_; } - void set_flags(Flags f) { flags_ = f; } - void set_length_mod(LengthMod lm) { length_mod_ = lm; } - void set_conv(ConversionChar c) { conv_ = c; } - void set_width(int w) { width_ = w; } - void set_precision(int p) { precision_ = p; } - void set_left(bool b) { flags_.left = b; } + // Deprecated (use has_x_flag() instead). + Flags flags() const { return flags_; } + // Deprecated + FormatConversionChar conv() const { return conversion_char(); } private: - ConversionChar conv_; + friend struct str_format_internal::FormatConversionSpecImplFriend; + FormatConversionChar conv_ = FormatConversionChar::kNone; Flags flags_; - LengthMod length_mod_; int width_; int precision_; }; -constexpr uint64_t ConversionCharToConvValue(char conv) { +struct FormatConversionSpecImplFriend final { + static void SetFlags(Flags f, FormatConversionSpec* conv) { + conv->flags_ = f; + } + static void SetConversionChar(FormatConversionChar c, + FormatConversionSpec* conv) { + conv->conv_ = c; + } + static void SetWidth(int w, FormatConversionSpec* conv) { conv->width_ = w; } + static void SetPrecision(int p, FormatConversionSpec* conv) { + conv->precision_ = p; + } + static std::string FlagsToString(const FormatConversionSpec& spec) { + return spec.flags_.ToString(); + } +}; + +constexpr uint64_t FormatConversionCharToConvValue(char conv) { return -#define CONV_SET_CASE(c) \ - conv == #c[0] ? (uint64_t{1} << (1 + ConversionChar::Id::c)): - ABSL_CONVERSION_CHARS_EXPAND_(CONV_SET_CASE, ) -#undef CONV_SET_CASE +#define ABSL_INTERNAL_CHAR_SET_CASE(c) \ + conv == #c[0] \ + ? (uint64_t{1} << (1 + static_cast<uint8_t>(FormatConversionChar::c))) \ + : + ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(ABSL_INTERNAL_CHAR_SET_CASE, ) +#undef ABSL_INTERNAL_CHAR_SET_CASE conv == '*' ? 1 : 0; } -enum class Conv : uint64_t { -#define CONV_SET_CASE(c) c = ConversionCharToConvValue(#c[0]), - ABSL_CONVERSION_CHARS_EXPAND_(CONV_SET_CASE, ) -#undef CONV_SET_CASE +enum class FormatConversionCharSet : uint64_t { +#define ABSL_INTERNAL_CHAR_SET_CASE(c) \ + c = FormatConversionCharToConvValue(#c[0]), + ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(ABSL_INTERNAL_CHAR_SET_CASE, ) +#undef ABSL_INTERNAL_CHAR_SET_CASE // Used for width/precision '*' specification. - star = ConversionCharToConvValue('*'), - + kStar = FormatConversionCharToConvValue('*'), // Some predefined values: - integral = d | i | u | o | x | X, - floating = a | e | f | g | A | E | F | G, - numeric = integral | floating, - string = s, - pointer = p + kIntegral = d | i | u | o | x | X, + kFloating = a | e | f | g | A | E | F | G, + kNumeric = kIntegral | kFloating, + kString = s, + kPointer = p, + + // The following are deprecated + star = kStar, + integral = kIntegral, + floating = kFloating, + numeric = kNumeric, + string = kString, + pointer = kPointer }; // Type safe OR operator. @@ -368,44 +359,57 @@ // 1. operator| on enums makes them decay to integers and the result is an // integer. We need the result to stay as an enum. // 2. We use "enum class" which would not work even if we accepted the decay. -constexpr Conv operator|(Conv a, Conv b) { - return Conv(static_cast<uint64_t>(a) | static_cast<uint64_t>(b)); +constexpr FormatConversionCharSet operator|(FormatConversionCharSet a, + FormatConversionCharSet b) { + return FormatConversionCharSet(static_cast<uint64_t>(a) | + static_cast<uint64_t>(b)); } // Get a conversion with a single character in it. -constexpr Conv ConversionCharToConv(char c) { - return Conv(ConversionCharToConvValue(c)); +constexpr FormatConversionCharSet ConversionCharToConv(char c) { + return FormatConversionCharSet(FormatConversionCharToConvValue(c)); } // Checks whether `c` exists in `set`. -constexpr bool Contains(Conv set, char c) { - return (static_cast<uint64_t>(set) & ConversionCharToConvValue(c)) != 0; +constexpr bool Contains(FormatConversionCharSet set, char c) { + return (static_cast<uint64_t>(set) & FormatConversionCharToConvValue(c)) != 0; } // Checks whether all the characters in `c` are contained in `set` -constexpr bool Contains(Conv set, Conv c) { +constexpr bool Contains(FormatConversionCharSet set, + FormatConversionCharSet c) { return (static_cast<uint64_t>(set) & static_cast<uint64_t>(c)) == static_cast<uint64_t>(c); } // Return type of the AbslFormatConvert() functions. -// The Conv template parameter is used to inform the framework of what -// conversion characters are supported by that AbslFormatConvert routine. -template <Conv C> -struct ConvertResult { - static constexpr Conv kConv = C; +// The FormatConversionCharSet template parameter is used to inform the +// framework of what conversion characters are supported by that +// AbslFormatConvert routine. +template <FormatConversionCharSet C> +struct FormatConvertResult { + static constexpr FormatConversionCharSet kConv = C; bool value; }; -template <Conv C> -constexpr Conv ConvertResult<C>::kConv; + +template <FormatConversionCharSet C> +constexpr FormatConversionCharSet FormatConvertResult<C>::kConv; // Return capacity - used, clipped to a minimum of 0. inline size_t Excess(size_t used, size_t capacity) { return used < capacity ? capacity - used : 0; } +// Type alias for use during migration. +using ConversionChar = FormatConversionChar; +using ConversionSpec = FormatConversionSpec; +using Conv = FormatConversionCharSet; +template <FormatConversionCharSet C> +using ConvertResult = FormatConvertResult<C>; + } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_EXTENSION_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc b/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc index 9236acd..d4c647c 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc
@@ -9,6 +9,7 @@ #include "absl/base/config.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace str_format_internal { namespace { @@ -27,12 +28,12 @@ { char *fp = fmt; *fp++ = '%'; - fp = CopyStringTo(conv.flags().ToString(), fp); + fp = CopyStringTo(FormatConversionSpecImplFriend::FlagsToString(conv), fp); fp = CopyStringTo("*.*", fp); if (std::is_same<long double, Float>()) { *fp++ = 'L'; } - *fp++ = conv.conv().Char(); + *fp++ = FormatConversionCharToChar(conv.conv()); *fp = 0; assert(fp < fmt + sizeof(fmt)); } @@ -99,9 +100,11 @@ char text[4], *ptr = text; if (sign_char) *ptr++ = sign_char; if (std::isnan(v)) { - ptr = std::copy_n(conv.conv().upper() ? "NAN" : "nan", 3, ptr); + ptr = std::copy_n(FormatConversionCharIsUpper(conv.conv()) ? "NAN" : "nan", + 3, ptr); } else if (std::isinf(v)) { - ptr = std::copy_n(conv.conv().upper() ? "INF" : "inf", 3, ptr); + ptr = std::copy_n(FormatConversionCharIsUpper(conv.conv()) ? "INF" : "inf", + 3, ptr); } else { return false; } @@ -398,7 +401,7 @@ Buffer buffer; - switch (conv.conv().id()) { + switch (conv.conv()) { case ConversionChar::f: case ConversionChar::F: if (!FloatToBuffer<FormatStyle::Fixed>(decomposed, precision, &buffer, @@ -415,7 +418,8 @@ return FallbackToSnprintf(v, conv, sink); } if (!conv.flags().alt && buffer.back() == '.') buffer.pop_back(); - PrintExponent(exp, conv.conv().upper() ? 'E' : 'e', &buffer); + PrintExponent(exp, FormatConversionCharIsUpper(conv.conv()) ? 'E' : 'e', + &buffer); break; case ConversionChar::g: @@ -446,7 +450,10 @@ while (buffer.back() == '0') buffer.pop_back(); if (buffer.back() == '.') buffer.pop_back(); } - if (exp) PrintExponent(exp, conv.conv().upper() ? 'E' : 'e', &buffer); + if (exp) { + PrintExponent(exp, FormatConversionCharIsUpper(conv.conv()) ? 'E' : 'e', + &buffer); + } break; case ConversionChar::a: @@ -482,4 +489,5 @@ } } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h b/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h index 8ba5566..49a6a63 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h
@@ -4,6 +4,7 @@ #include "absl/strings/internal/str_format/extension.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace str_format_internal { bool ConvertFloatImpl(float v, const ConversionSpec &conv, @@ -16,6 +17,7 @@ FormatSinkImpl *sink); } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_FLOAT_CONVERSION_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/output.cc b/third_party/abseil-cpp/absl/strings/internal/str_format/output.cc index 38987b6..c4b2470 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/output.cc +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/output.cc
@@ -18,6 +18,7 @@ #include <cstring> namespace absl { +ABSL_NAMESPACE_BEGIN namespace str_format_internal { namespace { @@ -67,4 +68,5 @@ } } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/output.h b/third_party/abseil-cpp/absl/strings/internal/str_format/output.h index 42da641..28b288b7 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/output.h +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/output.h
@@ -28,9 +28,11 @@ #include "absl/base/port.h" #include "absl/strings/string_view.h" +namespace absl { +ABSL_NAMESPACE_BEGIN + class Cord; -namespace absl { namespace str_format_internal { // RawSink implementation that writes into a char* buffer. @@ -76,7 +78,7 @@ } template <class AbslCord, typename = typename std::enable_if< - std::is_same<AbslCord, ::Cord>::value>::type> + std::is_same<AbslCord, absl::Cord>::value>::type> inline void AbslFormatFlush(AbslCord* out, string_view s) { out->Append(s); } @@ -96,6 +98,7 @@ } } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_OUTPUT_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/output_test.cc b/third_party/abseil-cpp/absl/strings/internal/str_format/output_test.cc index 6e04abe..e54e6f7 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/output_test.cc +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/output_test.cc
@@ -21,6 +21,7 @@ #include "gtest/gtest.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { TEST(InvokeFlush, String) { @@ -67,5 +68,6 @@ } } // namespace +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc b/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc index 9ef5615..aab68db 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc
@@ -14,10 +14,12 @@ #include <unordered_set> namespace absl { +ABSL_NAMESPACE_BEGIN namespace str_format_internal { -using CC = ConversionChar::Id; -using LM = LengthMod::Id; +using CC = ConversionChar; +using LM = LengthMod; + ABSL_CONST_INIT const ConvTag kTags[256] = { {}, {}, {}, {}, {}, {}, {}, {}, // 00-07 {}, {}, {}, {}, {}, {}, {}, {}, // 08-0f @@ -204,11 +206,11 @@ using str_format_internal::LengthMod; LengthMod length_mod = tag.as_length(); ABSL_FORMAT_PARSER_INTERNAL_GET_CHAR(); - if (c == 'h' && length_mod.id() == LengthMod::h) { - conv->length_mod = LengthMod::FromId(LengthMod::hh); + if (c == 'h' && length_mod == LengthMod::h) { + conv->length_mod = LengthMod::hh; ABSL_FORMAT_PARSER_INTERNAL_GET_CHAR(); - } else if (c == 'l' && length_mod.id() == LengthMod::l) { - conv->length_mod = LengthMod::FromId(LengthMod::ll); + } else if (c == 'l' && length_mod == LengthMod::l) { + conv->length_mod = LengthMod::ll; ABSL_FORMAT_PARSER_INTERNAL_GET_CHAR(); } else { conv->length_mod = length_mod; @@ -227,6 +229,32 @@ } // namespace +std::string LengthModToString(LengthMod v) { + switch (v) { + case LengthMod::h: + return "h"; + case LengthMod::hh: + return "hh"; + case LengthMod::l: + return "l"; + case LengthMod::ll: + return "ll"; + case LengthMod::L: + return "L"; + case LengthMod::j: + return "j"; + case LengthMod::z: + return "z"; + case LengthMod::t: + return "t"; + case LengthMod::q: + return "q"; + case LengthMod::none: + return ""; + } + return ""; +} + const char *ConsumeUnboundConversion(const char *p, const char *end, UnboundConversion *conv, int *next_arg) { if (*next_arg < 0) return ConsumeConversion<true>(p, end, conv, next_arg); @@ -294,10 +322,13 @@ if (conv.width.is_from_arg() && !add_if_valid_conv(conv.width.get_from_arg(), '*')) return false; - if (!add_if_valid_conv(conv.arg_position, conv.conv.Char())) return false; + if (!add_if_valid_conv(conv.arg_position, + FormatConversionCharToChar(conv.conv))) + return false; } return used.size() == convs.size() || allow_ignored; } } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h b/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h index b7614a0..7d96651 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h
@@ -6,18 +6,25 @@ #include <stdlib.h> #include <cassert> +#include <cstdint> #include <initializer_list> #include <iosfwd> #include <iterator> #include <memory> +#include <string> #include <vector> #include "absl/strings/internal/str_format/checker.h" #include "absl/strings/internal/str_format/extension.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace str_format_internal { +enum class LengthMod : std::uint8_t { h, hh, l, ll, L, j, z, t, q, none }; + +std::string LengthModToString(LengthMod v); + // The analyzed properties of a single specified conversion. struct UnboundConversion { UnboundConversion() @@ -59,8 +66,8 @@ InputValue precision; Flags flags; - LengthMod length_mod; - ConversionChar conv; + LengthMod length_mod = LengthMod::none; + ConversionChar conv = FormatConversionChar::kNone; }; // Consume conversion spec prefix (not including '%') of [p, end) if valid. @@ -72,13 +79,16 @@ UnboundConversion* conv, int* next_arg); // Helper tag class for the table below. -// It allows fast `char -> ConversionChar/LengthMod` checking and conversions. +// It allows fast `char -> ConversionChar/LengthMod` checking and +// conversions. class ConvTag { public: - constexpr ConvTag(ConversionChar::Id id) : tag_(id) {} // NOLINT + constexpr ConvTag(ConversionChar conversion_char) // NOLINT + : tag_(static_cast<int8_t>(conversion_char)) {} // We invert the length modifiers to make them negative so that we can easily // test for them. - constexpr ConvTag(LengthMod::Id id) : tag_(~id) {} // NOLINT + constexpr ConvTag(LengthMod length_mod) // NOLINT + : tag_(~static_cast<std::int8_t>(length_mod)) {} // Everything else is -128, which is negative to make is_conv() simpler. constexpr ConvTag() : tag_(-128) {} @@ -86,11 +96,11 @@ bool is_length() const { return tag_ < 0 && tag_ != -128; } ConversionChar as_conv() const { assert(is_conv()); - return ConversionChar::FromId(static_cast<ConversionChar::Id>(tag_)); + return static_cast<ConversionChar>(tag_); } LengthMod as_length() const { assert(is_length()); - return LengthMod::FromId(static_cast<LengthMod::Id>(~tag_)); + return static_cast<LengthMod>(~tag_); } private: @@ -133,7 +143,7 @@ auto tag = GetTagForChar(percent[1]); if (tag.is_conv()) { if (ABSL_PREDICT_FALSE(next_arg < 0)) { - // This indicates an error in the format std::string. + // This indicates an error in the format string. // The only way to get `next_arg < 0` here is to have a positional // argument first which sets next_arg to -1 and then a non-positional // argument. @@ -274,10 +284,10 @@ class ExtendedParsedFormat : public str_format_internal::ParsedFormatBase { public: explicit ExtendedParsedFormat(string_view format) -#if ABSL_INTERNAL_ENABLE_FORMAT_CHECKER +#ifdef ABSL_INTERNAL_ENABLE_FORMAT_CHECKER __attribute__(( enable_if(str_format_internal::EnsureConstexpr(format), - "Format std::string is not constexpr."), + "Format string is not constexpr."), enable_if(str_format_internal::ValidFormatImpl<C...>(format), "Format specified does not match the template arguments."))) #endif // ABSL_INTERNAL_ENABLE_FORMAT_CHECKER @@ -317,6 +327,7 @@ : ParsedFormatBase(s, allow_ignored, {C...}) {} }; } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_PARSER_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc b/third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc index 6d35609..1b1ee03 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc +++ b/third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc
@@ -7,6 +7,7 @@ #include "absl/base/macros.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace str_format_internal { namespace { @@ -16,7 +17,7 @@ TEST(LengthModTest, Names) { struct Expectation { int line; - LengthMod::Id id; + LengthMod mod; const char *name; }; const Expectation kExpect[] = { @@ -31,18 +32,16 @@ {__LINE__, LengthMod::t, "t" }, {__LINE__, LengthMod::q, "q" }, }; - EXPECT_EQ(ABSL_ARRAYSIZE(kExpect), LengthMod::kNumValues); + EXPECT_EQ(ABSL_ARRAYSIZE(kExpect), 10); for (auto e : kExpect) { SCOPED_TRACE(e.line); - LengthMod mod = LengthMod::FromId(e.id); - EXPECT_EQ(e.id, mod.id()); - EXPECT_EQ(e.name, mod.name()); + EXPECT_EQ(e.name, LengthModToString(e.mod)); } } TEST(ConversionCharTest, Names) { struct Expectation { - ConversionChar::Id id; + ConversionChar id; char name; }; // clang-format off @@ -56,12 +55,10 @@ {ConversionChar::none, '\0'}, }; // clang-format on - EXPECT_EQ(ABSL_ARRAYSIZE(kExpect), ConversionChar::kNumValues); for (auto e : kExpect) { SCOPED_TRACE(e.name); - ConversionChar v = ConversionChar::FromId(e.id); - EXPECT_EQ(e.id, v.id()); - EXPECT_EQ(e.name, v.Char()); + ConversionChar v = e.id; + EXPECT_EQ(e.name, FormatConversionCharToChar(v)); } } @@ -120,13 +117,12 @@ EXPECT_FALSE(Run("dd")); // no excess allowed EXPECT_TRUE(Run("d")); - EXPECT_EQ('d', o.conv.Char()); + EXPECT_EQ('d', FormatConversionCharToChar(o.conv)); EXPECT_FALSE(o.width.is_from_arg()); EXPECT_LT(o.width.value(), 0); EXPECT_FALSE(o.precision.is_from_arg()); EXPECT_LT(o.precision.value(), 0); EXPECT_EQ(1, o.arg_position); - EXPECT_EQ(LengthMod::none, o.length_mod.id()); } TEST_F(ConsumeUnboundConversionTest, ArgPosition) { @@ -162,7 +158,7 @@ TEST_F(ConsumeUnboundConversionTest, WidthAndPrecision) { EXPECT_TRUE(Run("14d")); - EXPECT_EQ('d', o.conv.Char()); + EXPECT_EQ('d', FormatConversionCharToChar(o.conv)); EXPECT_FALSE(o.width.is_from_arg()); EXPECT_EQ(14, o.width.value()); EXPECT_FALSE(o.precision.is_from_arg()); @@ -289,6 +285,29 @@ } } +TEST_F(ConsumeUnboundConversionTest, LengthMod) { + EXPECT_TRUE(Run("d")); + EXPECT_EQ(LengthMod::none, o.length_mod); + EXPECT_TRUE(Run("hd")); + EXPECT_EQ(LengthMod::h, o.length_mod); + EXPECT_TRUE(Run("hhd")); + EXPECT_EQ(LengthMod::hh, o.length_mod); + EXPECT_TRUE(Run("ld")); + EXPECT_EQ(LengthMod::l, o.length_mod); + EXPECT_TRUE(Run("lld")); + EXPECT_EQ(LengthMod::ll, o.length_mod); + EXPECT_TRUE(Run("Lf")); + EXPECT_EQ(LengthMod::L, o.length_mod); + EXPECT_TRUE(Run("qf")); + EXPECT_EQ(LengthMod::q, o.length_mod); + EXPECT_TRUE(Run("jd")); + EXPECT_EQ(LengthMod::j, o.length_mod); + EXPECT_TRUE(Run("zd")); + EXPECT_EQ(LengthMod::z, o.length_mod); + EXPECT_TRUE(Run("td")); + EXPECT_EQ(LengthMod::t, o.length_mod); +} + struct SummarizeConsumer { std::string* out; explicit SummarizeConsumer(std::string* out) : out(out) {} @@ -309,7 +328,7 @@ if (conv.precision.is_from_arg()) { *out += "." + std::to_string(conv.precision.get_from_arg()) + "$*"; } - *out += conv.conv.Char(); + *out += FormatConversionCharToChar(conv.conv); *out += "}"; return true; } @@ -389,4 +408,5 @@ } // namespace } // namespace str_format_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h b/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h index 7c35f4d..31dbf67 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +++ b/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h
@@ -43,6 +43,7 @@ #include "absl/strings/str_cat.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { // @@ -307,6 +308,7 @@ } } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_STR_JOIN_INTERNAL_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h b/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h index 52f6222..6f5bc09 100644 --- a/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +++ b/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h
@@ -47,6 +47,7 @@ #endif // _GLIBCXX_DEBUG namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { // This class is implicitly constructible from everything that absl::string_view @@ -64,8 +65,8 @@ : value_(s) {} // Matches rvalue strings and moves their data to a member. -ConvertibleToStringView(std::string&& s) // NOLINT(runtime/explicit) - : copy_(std::move(s)), value_(copy_) {} + ConvertibleToStringView(std::string&& s) // NOLINT(runtime/explicit) + : copy_(std::move(s)), value_(copy_) {} ConvertibleToStringView(const ConvertibleToStringView& other) : copy_(other.copy_), @@ -448,6 +449,7 @@ }; } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_STR_SPLIT_INTERNAL_H_
diff --git a/third_party/abseil-cpp/absl/strings/internal/utf8.cc b/third_party/abseil-cpp/absl/strings/internal/utf8.cc index 82d36c2..8fd8edc1 100644 --- a/third_party/abseil-cpp/absl/strings/internal/utf8.cc +++ b/third_party/abseil-cpp/absl/strings/internal/utf8.cc
@@ -17,6 +17,7 @@ #include "absl/strings/internal/utf8.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { size_t EncodeUTF8Char(char *buffer, char32_t utf8_char) { @@ -48,4 +49,5 @@ } } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/internal/utf8.h b/third_party/abseil-cpp/absl/strings/internal/utf8.h index 04236304..32fb109 100644 --- a/third_party/abseil-cpp/absl/strings/internal/utf8.h +++ b/third_party/abseil-cpp/absl/strings/internal/utf8.h
@@ -20,7 +20,10 @@ #include <cstddef> #include <cstdint> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { // For Unicode code points 0 through 0x10FFFF, EncodeUTF8Char writes @@ -41,6 +44,7 @@ size_t EncodeUTF8Char(char *buffer, char32_t utf8_char); } // namespace strings_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_UTF8_H_
diff --git a/third_party/abseil-cpp/absl/strings/match.cc b/third_party/abseil-cpp/absl/strings/match.cc index 7b24241..8127cb0 100644 --- a/third_party/abseil-cpp/absl/strings/match.cc +++ b/third_party/abseil-cpp/absl/strings/match.cc
@@ -17,6 +17,7 @@ #include "absl/strings/internal/memutil.h" namespace absl { +ABSL_NAMESPACE_BEGIN bool EqualsIgnoreCase(absl::string_view piece1, absl::string_view piece2) { return (piece1.size() == piece2.size() && @@ -35,4 +36,5 @@ EqualsIgnoreCase(text.substr(text.size() - suffix.size()), suffix); } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/match.h b/third_party/abseil-cpp/absl/strings/match.h index 762f359..90fca98a 100644 --- a/third_party/abseil-cpp/absl/strings/match.h +++ b/third_party/abseil-cpp/absl/strings/match.h
@@ -20,7 +20,7 @@ // This file contains simple utilities for performing string matching checks. // All of these function parameters are specified as `absl::string_view`, // meaning that these functions can accept `std::string`, `absl::string_view` or -// nul-terminated C-style strings. +// NUL-terminated C-style strings. // // Examples: // std::string s = "foo"; @@ -38,6 +38,7 @@ #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN // StrContains() // @@ -83,6 +84,7 @@ // case in the comparison. bool EndsWithIgnoreCase(absl::string_view text, absl::string_view suffix); +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_MATCH_H_
diff --git a/third_party/abseil-cpp/absl/strings/numbers.cc b/third_party/abseil-cpp/absl/strings/numbers.cc index 38d1486..68c26dd 100644 --- a/third_party/abseil-cpp/absl/strings/numbers.cc +++ b/third_party/abseil-cpp/absl/strings/numbers.cc
@@ -19,8 +19,8 @@ #include <algorithm> #include <cassert> -#include <cfloat> // for DBL_DIG and FLT_DIG -#include <cmath> // for HUGE_VAL +#include <cfloat> // for DBL_DIG and FLT_DIG +#include <cmath> // for HUGE_VAL #include <cstdint> #include <cstdio> #include <cstdlib> @@ -30,15 +30,18 @@ #include <memory> #include <utility> +#include "absl/base/attributes.h" #include "absl/base/internal/bits.h" #include "absl/base/internal/raw_logging.h" #include "absl/strings/ascii.h" #include "absl/strings/charconv.h" +#include "absl/strings/escaping.h" #include "absl/strings/internal/memutil.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" namespace absl { +ABSL_NAMESPACE_BEGIN bool SimpleAtof(absl::string_view str, float* out) { *out = 0.0; @@ -92,43 +95,6 @@ return true; } -namespace { - -// Writes a two-character representation of 'i' to 'buf'. 'i' must be in the -// range 0 <= i < 100, and buf must have space for two characters. Example: -// char buf[2]; -// PutTwoDigits(42, buf); -// // buf[0] == '4' -// // buf[1] == '2' -inline void PutTwoDigits(size_t i, char* buf) { - static const char two_ASCII_digits[100][2] = { - {'0', '0'}, {'0', '1'}, {'0', '2'}, {'0', '3'}, {'0', '4'}, - {'0', '5'}, {'0', '6'}, {'0', '7'}, {'0', '8'}, {'0', '9'}, - {'1', '0'}, {'1', '1'}, {'1', '2'}, {'1', '3'}, {'1', '4'}, - {'1', '5'}, {'1', '6'}, {'1', '7'}, {'1', '8'}, {'1', '9'}, - {'2', '0'}, {'2', '1'}, {'2', '2'}, {'2', '3'}, {'2', '4'}, - {'2', '5'}, {'2', '6'}, {'2', '7'}, {'2', '8'}, {'2', '9'}, - {'3', '0'}, {'3', '1'}, {'3', '2'}, {'3', '3'}, {'3', '4'}, - {'3', '5'}, {'3', '6'}, {'3', '7'}, {'3', '8'}, {'3', '9'}, - {'4', '0'}, {'4', '1'}, {'4', '2'}, {'4', '3'}, {'4', '4'}, - {'4', '5'}, {'4', '6'}, {'4', '7'}, {'4', '8'}, {'4', '9'}, - {'5', '0'}, {'5', '1'}, {'5', '2'}, {'5', '3'}, {'5', '4'}, - {'5', '5'}, {'5', '6'}, {'5', '7'}, {'5', '8'}, {'5', '9'}, - {'6', '0'}, {'6', '1'}, {'6', '2'}, {'6', '3'}, {'6', '4'}, - {'6', '5'}, {'6', '6'}, {'6', '7'}, {'6', '8'}, {'6', '9'}, - {'7', '0'}, {'7', '1'}, {'7', '2'}, {'7', '3'}, {'7', '4'}, - {'7', '5'}, {'7', '6'}, {'7', '7'}, {'7', '8'}, {'7', '9'}, - {'8', '0'}, {'8', '1'}, {'8', '2'}, {'8', '3'}, {'8', '4'}, - {'8', '5'}, {'8', '6'}, {'8', '7'}, {'8', '8'}, {'8', '9'}, - {'9', '0'}, {'9', '1'}, {'9', '2'}, {'9', '3'}, {'9', '4'}, - {'9', '5'}, {'9', '6'}, {'9', '7'}, {'9', '8'}, {'9', '9'} - }; - assert(i < 100); - memcpy(buf, two_ASCII_digits[i], 2); -} - -} // namespace - bool SimpleAtob(absl::string_view str, bool* out) { ABSL_RAW_CHECK(out != nullptr, "Output pointer must not be nullptr."); if (EqualsIgnoreCase(str, "true") || EqualsIgnoreCase(str, "t") || @@ -495,13 +461,13 @@ int two_digits = dddddd / 10000; dddddd -= two_digits * 10000; - PutTwoDigits(two_digits, &exp_dig.digits[0]); + numbers_internal::PutTwoDigits(two_digits, &exp_dig.digits[0]); two_digits = dddddd / 100; dddddd -= two_digits * 100; - PutTwoDigits(two_digits, &exp_dig.digits[2]); + numbers_internal::PutTwoDigits(two_digits, &exp_dig.digits[2]); - PutTwoDigits(dddddd, &exp_dig.digits[4]); + numbers_internal::PutTwoDigits(dddddd, &exp_dig.digits[4]); return exp_dig; } @@ -754,8 +720,8 @@ // commonly used bases. template <typename IntType> struct LookupTables { - static const IntType kVmaxOverBase[]; - static const IntType kVminOverBase[]; + ABSL_CONST_INIT static const IntType kVmaxOverBase[]; + ABSL_CONST_INIT static const IntType kVminOverBase[]; }; // An array initializer macro for X/base where base in [0, 36]. @@ -770,6 +736,49 @@ X / 35, X / 36, \ } +// uint128& operator/=(uint128) is not constexpr, so hardcode the resulting +// array to avoid a static initializer. +template <> +const uint128 LookupTables<uint128>::kVmaxOverBase[] = { + 0, + 0, + MakeUint128(9223372036854775807u, 18446744073709551615u), + MakeUint128(6148914691236517205u, 6148914691236517205u), + MakeUint128(4611686018427387903u, 18446744073709551615u), + MakeUint128(3689348814741910323u, 3689348814741910323u), + MakeUint128(3074457345618258602u, 12297829382473034410u), + MakeUint128(2635249153387078802u, 5270498306774157604u), + MakeUint128(2305843009213693951u, 18446744073709551615u), + MakeUint128(2049638230412172401u, 14347467612885206812u), + MakeUint128(1844674407370955161u, 11068046444225730969u), + MakeUint128(1676976733973595601u, 8384883669867978007u), + MakeUint128(1537228672809129301u, 6148914691236517205u), + MakeUint128(1418980313362273201u, 4256940940086819603u), + MakeUint128(1317624576693539401u, 2635249153387078802u), + MakeUint128(1229782938247303441u, 1229782938247303441u), + MakeUint128(1152921504606846975u, 18446744073709551615u), + MakeUint128(1085102592571150095u, 1085102592571150095u), + MakeUint128(1024819115206086200u, 16397105843297379214u), + MakeUint128(970881267037344821u, 16504981539634861972u), + MakeUint128(922337203685477580u, 14757395258967641292u), + MakeUint128(878416384462359600u, 14054662151397753612u), + MakeUint128(838488366986797800u, 13415813871788764811u), + MakeUint128(802032351030850070u, 4812194106185100421u), + MakeUint128(768614336404564650u, 12297829382473034410u), + MakeUint128(737869762948382064u, 11805916207174113034u), + MakeUint128(709490156681136600u, 11351842506898185609u), + MakeUint128(683212743470724133u, 17080318586768103348u), + MakeUint128(658812288346769700u, 10540996613548315209u), + MakeUint128(636094623231363848u, 15266270957552732371u), + MakeUint128(614891469123651720u, 9838263505978427528u), + MakeUint128(595056260442243600u, 9520900167075897608u), + MakeUint128(576460752303423487u, 18446744073709551615u), + MakeUint128(558992244657865200u, 8943875914525843207u), + MakeUint128(542551296285575047u, 9765923333140350855u), + MakeUint128(527049830677415760u, 8432797290838652167u), + MakeUint128(512409557603043100u, 8198552921648689607u), +}; + template <typename IntType> const IntType LookupTables<IntType>::kVmaxOverBase[] = X_OVER_BASE_INITIALIZER(std::numeric_limits<IntType>::max()); @@ -789,6 +798,8 @@ assert(base >= 0); assert(vmax >= static_cast<IntType>(base)); const IntType vmax_over_base = LookupTables<IntType>::kVmaxOverBase[base]; + assert(base < 2 || + std::numeric_limits<IntType>::max() / base == vmax_over_base); const char* start = text.data(); const char* end = start + text.size(); // loop over digits @@ -822,6 +833,8 @@ assert(vmin < 0); assert(vmin <= 0 - base); IntType vmin_over_base = LookupTables<IntType>::kVminOverBase[base]; + assert(base < 2 || + std::numeric_limits<IntType>::min() / base == vmin_over_base); // 2003 c++ standard [expr.mul] // "... the sign of the remainder is implementation-defined." // Although (vmin/base)*base + vmin%base is always vmin. @@ -885,6 +898,48 @@ } // anonymous namespace namespace numbers_internal { + +// Digit conversion. +ABSL_CONST_INIT ABSL_DLL const char kHexChar[] = + "0123456789abcdef"; + +ABSL_CONST_INIT ABSL_DLL const char kHexTable[513] = + "000102030405060708090a0b0c0d0e0f" + "101112131415161718191a1b1c1d1e1f" + "202122232425262728292a2b2c2d2e2f" + "303132333435363738393a3b3c3d3e3f" + "404142434445464748494a4b4c4d4e4f" + "505152535455565758595a5b5c5d5e5f" + "606162636465666768696a6b6c6d6e6f" + "707172737475767778797a7b7c7d7e7f" + "808182838485868788898a8b8c8d8e8f" + "909192939495969798999a9b9c9d9e9f" + "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf" + "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" + "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf" + "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf" + "e0e1e2e3e4e5e6e7e8e9eaebecedeeef" + "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"; + +ABSL_CONST_INIT ABSL_DLL const char two_ASCII_digits[100][2] = { + {'0', '0'}, {'0', '1'}, {'0', '2'}, {'0', '3'}, {'0', '4'}, {'0', '5'}, + {'0', '6'}, {'0', '7'}, {'0', '8'}, {'0', '9'}, {'1', '0'}, {'1', '1'}, + {'1', '2'}, {'1', '3'}, {'1', '4'}, {'1', '5'}, {'1', '6'}, {'1', '7'}, + {'1', '8'}, {'1', '9'}, {'2', '0'}, {'2', '1'}, {'2', '2'}, {'2', '3'}, + {'2', '4'}, {'2', '5'}, {'2', '6'}, {'2', '7'}, {'2', '8'}, {'2', '9'}, + {'3', '0'}, {'3', '1'}, {'3', '2'}, {'3', '3'}, {'3', '4'}, {'3', '5'}, + {'3', '6'}, {'3', '7'}, {'3', '8'}, {'3', '9'}, {'4', '0'}, {'4', '1'}, + {'4', '2'}, {'4', '3'}, {'4', '4'}, {'4', '5'}, {'4', '6'}, {'4', '7'}, + {'4', '8'}, {'4', '9'}, {'5', '0'}, {'5', '1'}, {'5', '2'}, {'5', '3'}, + {'5', '4'}, {'5', '5'}, {'5', '6'}, {'5', '7'}, {'5', '8'}, {'5', '9'}, + {'6', '0'}, {'6', '1'}, {'6', '2'}, {'6', '3'}, {'6', '4'}, {'6', '5'}, + {'6', '6'}, {'6', '7'}, {'6', '8'}, {'6', '9'}, {'7', '0'}, {'7', '1'}, + {'7', '2'}, {'7', '3'}, {'7', '4'}, {'7', '5'}, {'7', '6'}, {'7', '7'}, + {'7', '8'}, {'7', '9'}, {'8', '0'}, {'8', '1'}, {'8', '2'}, {'8', '3'}, + {'8', '4'}, {'8', '5'}, {'8', '6'}, {'8', '7'}, {'8', '8'}, {'8', '9'}, + {'9', '0'}, {'9', '1'}, {'9', '2'}, {'9', '3'}, {'9', '4'}, {'9', '5'}, + {'9', '6'}, {'9', '7'}, {'9', '8'}, {'9', '9'}}; + bool safe_strto32_base(absl::string_view text, int32_t* value, int base) { return safe_int_internal<int32_t>(text, value, base); } @@ -900,6 +955,11 @@ bool safe_strtou64_base(absl::string_view text, uint64_t* value, int base) { return safe_uint_internal<uint64_t>(text, value, base); } -} // namespace numbers_internal +bool safe_strtou128_base(absl::string_view text, uint128* value, int base) { + return safe_uint_internal<absl::uint128>(text, value, base); +} + +} // namespace numbers_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/numbers.h b/third_party/abseil-cpp/absl/strings/numbers.h index 100839b0..d872cca 100644 --- a/third_party/abseil-cpp/absl/strings/numbers.h +++ b/third_party/abseil-cpp/absl/strings/numbers.h
@@ -24,6 +24,10 @@ #ifndef ABSL_STRINGS_NUMBERS_H_ #define ABSL_STRINGS_NUMBERS_H_ +#ifdef __SSE4_2__ +#include <x86intrin.h> +#endif + #include <cstddef> #include <cstdlib> #include <cstring> @@ -32,38 +36,54 @@ #include <string> #include <type_traits> +#include "absl/base/config.h" +#include "absl/base/internal/bits.h" +#ifdef __SSE4_2__ +// TODO(jorg): Remove this when we figure out the right way +// to swap bytes on SSE 4.2 that works with the compilers +// we claim to support. Also, add tests for the compiler +// that doesn't support the Intel _bswap64 intrinsic but +// does support all the SSE 4.2 intrinsics +#include "absl/base/internal/endian.h" +#endif #include "absl/base/macros.h" #include "absl/base/port.h" #include "absl/numeric/int128.h" #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN // SimpleAtoi() // -// Converts the given string into an integer value, returning `true` if -// successful. The string must reflect a base-10 integer (optionally followed or -// preceded by ASCII whitespace) whose value falls within the range of the -// integer type. If any errors are encountered, this function returns `false`, -// leaving `out` in an unspecified state. +// Converts the given string (optionally followed or preceded by ASCII +// whitespace) into an integer value, returning `true` if successful. The string +// must reflect a base-10 integer whose value falls within the range of the +// integer type (optionally preceded by a `+` or `-`). If any errors are +// encountered, this function returns `false`, leaving `out` in an unspecified +// state. template <typename int_type> ABSL_MUST_USE_RESULT bool SimpleAtoi(absl::string_view str, int_type* out); // SimpleAtof() // // Converts the given string (optionally followed or preceded by ASCII -// whitespace) into a float, which may be rounded on overflow or underflow. +// whitespace) into a float, which may be rounded on overflow or underflow, +// returning `true` if successful. // See https://en.cppreference.com/w/c/string/byte/strtof for details about the -// allowed formats for `str`. If any errors are encountered, this function +// allowed formats for `str`, except SimpleAtof() is locale-independent and will +// always use the "C" locale. If any errors are encountered, this function // returns `false`, leaving `out` in an unspecified state. ABSL_MUST_USE_RESULT bool SimpleAtof(absl::string_view str, float* out); // SimpleAtod() // // Converts the given string (optionally followed or preceded by ASCII -// whitespace) into a double, which may be rounded on overflow or underflow. +// whitespace) into a double, which may be rounded on overflow or underflow, +// returning `true` if successful. // See https://en.cppreference.com/w/c/string/byte/strtof for details about the -// allowed formats for `str`. If any errors are encountered, this function +// allowed formats for `str`, except SimpleAtod is locale-independent and will +// always use the "C" locale. If any errors are encountered, this function // returns `false`, leaving `out` in an unspecified state. ABSL_MUST_USE_RESULT bool SimpleAtod(absl::string_view str, double* out); @@ -77,18 +97,40 @@ // unspecified state. ABSL_MUST_USE_RESULT bool SimpleAtob(absl::string_view str, bool* out); +ABSL_NAMESPACE_END } // namespace absl // End of public API. Implementation details follow. namespace absl { +ABSL_NAMESPACE_BEGIN namespace numbers_internal { +// Digit conversion. +ABSL_DLL extern const char kHexChar[17]; // 0123456789abcdef +ABSL_DLL extern const char + kHexTable[513]; // 000102030405060708090a0b0c0d0e0f1011... +ABSL_DLL extern const char + two_ASCII_digits[100][2]; // 00, 01, 02, 03... + +// Writes a two-character representation of 'i' to 'buf'. 'i' must be in the +// range 0 <= i < 100, and buf must have space for two characters. Example: +// char buf[2]; +// PutTwoDigits(42, buf); +// // buf[0] == '4' +// // buf[1] == '2' +inline void PutTwoDigits(size_t i, char* buf) { + assert(i < 100); + memcpy(buf, two_ASCII_digits[i], 2); +} + // safe_strto?() functions for implementing SimpleAtoi() bool safe_strto32_base(absl::string_view text, int32_t* value, int base); bool safe_strto64_base(absl::string_view text, int64_t* value, int base); bool safe_strtou32_base(absl::string_view text, uint32_t* value, int base); bool safe_strtou64_base(absl::string_view text, uint64_t* value, int base); +bool safe_strtou128_base(absl::string_view text, absl::uint128* value, + int base); static const int kFastToBufferSize = 32; static const int kSixDigitsToBufferSize = 16; @@ -170,6 +212,35 @@ return parsed; } +// FastHexToBufferZeroPad16() +// +// Outputs `val` into `out` as if by `snprintf(out, 17, "%016x", val)` but +// without the terminating null character. Thus `out` must be of length >= 16. +// Returns the number of non-pad digits of the output (it can never be zero +// since 0 has one digit). +inline size_t FastHexToBufferZeroPad16(uint64_t val, char* out) { +#ifdef __SSE4_2__ + uint64_t be = absl::big_endian::FromHost64(val); + const auto kNibbleMask = _mm_set1_epi8(0xf); + const auto kHexDigits = _mm_setr_epi8('0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'); + auto v = _mm_loadl_epi64(reinterpret_cast<__m128i*>(&be)); // load lo dword + auto v4 = _mm_srli_epi64(v, 4); // shift 4 right + auto il = _mm_unpacklo_epi8(v4, v); // interleave bytes + auto m = _mm_and_si128(il, kNibbleMask); // mask out nibbles + auto hexchars = _mm_shuffle_epi8(kHexDigits, m); // hex chars + _mm_storeu_si128(reinterpret_cast<__m128i*>(out), hexchars); +#else + for (int i = 0; i < 8; ++i) { + auto byte = (val >> (56 - 8 * i)) & 0xFF; + auto* hex = &absl::numbers_internal::kHexTable[byte * 2]; + std::memcpy(out + 2 * i, hex, 2); + } +#endif + // | 0x1 so that even 0 has 1 digit. + return 16 - absl::base_internal::CountLeadingZeros64(val | 0x1) / 4; +} + } // namespace numbers_internal // SimpleAtoi() @@ -184,6 +255,12 @@ return numbers_internal::safe_strtoi_base(str, out, 10); } +ABSL_MUST_USE_RESULT inline bool SimpleAtoi(absl::string_view str, + absl::uint128* out) { + return numbers_internal::safe_strtou128_base(str, out, 10); +} + +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_NUMBERS_H_
diff --git a/third_party/abseil-cpp/absl/strings/numbers_benchmark.cc b/third_party/abseil-cpp/absl/strings/numbers_benchmark.cc index 54dbedd..6e79b3e 100644 --- a/third_party/abseil-cpp/absl/strings/numbers_benchmark.cc +++ b/third_party/abseil-cpp/absl/strings/numbers_benchmark.cc
@@ -20,6 +20,8 @@ #include "benchmark/benchmark.h" #include "absl/base/internal/raw_logging.h" +#include "absl/random/distributions.h" +#include "absl/random/random.h" #include "absl/strings/numbers.h" namespace { @@ -260,4 +262,25 @@ ->ArgPair(10, 4) ->ArgPair(10, 8); +void BM_FastHexToBufferZeroPad16(benchmark::State& state) { + absl::BitGen rng; + std::vector<uint64_t> nums; + nums.resize(1000); + auto min = std::numeric_limits<uint64_t>::min(); + auto max = std::numeric_limits<uint64_t>::max(); + for (auto& num : nums) { + num = absl::LogUniform(rng, min, max); + } + + char buf[16]; + while (state.KeepRunningBatch(nums.size())) { + for (auto num : nums) { + auto digits = absl::numbers_internal::FastHexToBufferZeroPad16(num, buf); + benchmark::DoNotOptimize(digits); + benchmark::DoNotOptimize(buf); + } + } +} +BENCHMARK(BM_FastHexToBufferZeroPad16); + } // namespace
diff --git a/third_party/abseil-cpp/absl/strings/numbers_test.cc b/third_party/abseil-cpp/absl/strings/numbers_test.cc index 77d7e7835..bd4e116 100644 --- a/third_party/abseil-cpp/absl/strings/numbers_test.cc +++ b/third_party/abseil-cpp/absl/strings/numbers_test.cc
@@ -17,6 +17,7 @@ #include "absl/strings/numbers.h" #include <sys/types.h> + #include <cfenv> // NOLINT(build/c++11) #include <cinttypes> #include <climits> @@ -36,10 +37,11 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/base/internal/raw_logging.h" -#include "absl/strings/str_cat.h" - +#include "absl/random/distributions.h" +#include "absl/random/random.h" #include "absl/strings/internal/numbers_test_common.h" #include "absl/strings/internal/pow10_helper.h" +#include "absl/strings/str_cat.h" namespace { @@ -204,6 +206,9 @@ std::string actual = absl::StrCat(absl::Hex(v, absl::kZeroPad16)); snprintf(expected, sizeof(expected), "%016" PRIx64, static_cast<uint64_t>(v)); EXPECT_EQ(expected, actual) << " Input " << v; + actual = absl::StrCat(absl::Hex(v, absl::kSpacePad16)); + snprintf(expected, sizeof(expected), "%16" PRIx64, static_cast<uint64_t>(v)); + EXPECT_EQ(expected, actual) << " Input " << v; } TEST(Numbers, TestFastPrints) { @@ -244,7 +249,9 @@ template <typename int_type, typename in_val_type> void VerifySimpleAtoiGood(in_val_type in_value, int_type exp_value) { - std::string s = absl::StrCat(in_value); + std::string s; + // uint128 can be streamed but not StrCat'd + absl::strings_internal::OStringStream(&s) << in_value; int_type x = static_cast<int_type>(~exp_value); EXPECT_TRUE(SimpleAtoi(s, &x)) << "in_value=" << in_value << " s=" << s << " x=" << x; @@ -320,6 +327,25 @@ VerifySimpleAtoiGood<uint64_t>(std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::max()); + // SimpleAtoi(absl::string_view, absl::uint128) + VerifySimpleAtoiGood<absl::uint128>(0, 0); + VerifySimpleAtoiGood<absl::uint128>(42, 42); + VerifySimpleAtoiBad<absl::uint128>(-42); + + VerifySimpleAtoiBad<absl::uint128>(std::numeric_limits<int32_t>::min()); + VerifySimpleAtoiGood<absl::uint128>(std::numeric_limits<int32_t>::max(), + std::numeric_limits<int32_t>::max()); + VerifySimpleAtoiGood<absl::uint128>(std::numeric_limits<uint32_t>::max(), + std::numeric_limits<uint32_t>::max()); + VerifySimpleAtoiBad<absl::uint128>(std::numeric_limits<int64_t>::min()); + VerifySimpleAtoiGood<absl::uint128>(std::numeric_limits<int64_t>::max(), + std::numeric_limits<int64_t>::max()); + VerifySimpleAtoiGood<absl::uint128>(std::numeric_limits<uint64_t>::max(), + std::numeric_limits<uint64_t>::max()); + VerifySimpleAtoiGood<absl::uint128>( + std::numeric_limits<absl::uint128>::max(), + std::numeric_limits<absl::uint128>::max()); + // Some other types VerifySimpleAtoiGood<int>(-42, -42); VerifySimpleAtoiGood<int32_t>(-42, -42); @@ -455,7 +481,7 @@ EXPECT_TRUE(safe_strto32_base(std::string("0x1234"), &value, 16)); EXPECT_EQ(0x1234, value); - // Base-10 std::string version. + // Base-10 string version. EXPECT_TRUE(safe_strto32_base("1234", &value, 10)); EXPECT_EQ(1234, value); } @@ -596,7 +622,7 @@ EXPECT_TRUE(safe_strto64_base(std::string("0x1234"), &value, 16)); EXPECT_EQ(0x1234, value); - // Base-10 std::string version. + // Base-10 string version. EXPECT_TRUE(safe_strto64_base("1234", &value, 10)); EXPECT_EQ(1234, value); } @@ -652,6 +678,46 @@ TEST(stringtest, safe_strtou64_random) { test_random_integer_parse_base<uint64_t>(&safe_strtou64_base); } +TEST(stringtest, safe_strtou128_random) { + // random number generators don't work for uint128, and + // uint128 can be streamed but not StrCat'd, so this code must be custom + // implemented for uint128, but is generally the same as what's above. + // test_random_integer_parse_base<absl::uint128>( + // &absl::numbers_internal::safe_strtou128_base); + using RandomEngine = std::minstd_rand0; + using IntType = absl::uint128; + constexpr auto parse_func = &absl::numbers_internal::safe_strtou128_base; + + std::random_device rd; + RandomEngine rng(rd()); + std::uniform_int_distribution<uint64_t> random_uint64( + std::numeric_limits<uint64_t>::min()); + std::uniform_int_distribution<int> random_base(2, 35); + + for (size_t i = 0; i < kNumRandomTests; i++) { + IntType value = random_uint64(rng); + value = (value << 64) + random_uint64(rng); + int base = random_base(rng); + std::string str_value; + EXPECT_TRUE(Itoa<IntType>(value, base, &str_value)); + IntType parsed_value; + + // Test successful parse + EXPECT_TRUE(parse_func(str_value, &parsed_value, base)); + EXPECT_EQ(parsed_value, value); + + // Test overflow + std::string s; + absl::strings_internal::OStringStream(&s) + << std::numeric_limits<IntType>::max() << value; + EXPECT_FALSE(parse_func(s, &parsed_value, base)); + + // Test underflow + s.clear(); + absl::strings_internal::OStringStream(&s) << "-" << value; + EXPECT_FALSE(parse_func(s, &parsed_value, base)); + } +} TEST(stringtest, safe_strtou32_base) { for (int i = 0; strtouint32_test_cases()[i].str != nullptr; ++i) { @@ -713,11 +779,11 @@ } } -// feenableexcept() and fedisableexcept() are missing on macOS, MSVC, -// and WebAssembly. -#if defined(_MSC_VER) || defined(__APPLE__) || defined(__EMSCRIPTEN__) -#define ABSL_MISSING_FEENABLEEXCEPT 1 -#define ABSL_MISSING_FEDISABLEEXCEPT 1 +// feenableexcept() and fedisableexcept() are extensions supported by some libc +// implementations. +#if defined(__GLIBC__) || defined(__BIONIC__) +#define ABSL_HAVE_FEENABLEEXCEPT 1 +#define ABSL_HAVE_FEDISABLEEXCEPT 1 #endif class SimpleDtoaTest : public testing::Test { @@ -725,7 +791,7 @@ void SetUp() override { // Store the current floating point env & clear away any pending exceptions. feholdexcept(&fp_env_); -#ifndef ABSL_MISSING_FEENABLEEXCEPT +#ifdef ABSL_HAVE_FEENABLEEXCEPT // Turn on floating point exceptions. feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); #endif @@ -735,7 +801,7 @@ // Restore the floating point environment to the original state. // In theory fedisableexcept is unnecessary; fesetenv will also do it. // In practice, our toolchains have subtle bugs. -#ifndef ABSL_MISSING_FEDISABLEEXCEPT +#ifdef ABSL_HAVE_FEDISABLEEXCEPT fedisableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); #endif fesetenv(&fp_env_); @@ -1184,4 +1250,28 @@ } } +void TestFastHexToBufferZeroPad16(uint64_t v) { + char buf[16]; + auto digits = absl::numbers_internal::FastHexToBufferZeroPad16(v, buf); + absl::string_view res(buf, 16); + char buf2[17]; + snprintf(buf2, sizeof(buf2), "%016" PRIx64, v); + EXPECT_EQ(res, buf2) << v; + size_t expected_digits = snprintf(buf2, sizeof(buf2), "%" PRIx64, v); + EXPECT_EQ(digits, expected_digits) << v; +} + +TEST(FastHexToBufferZeroPad16, Smoke) { + TestFastHexToBufferZeroPad16(std::numeric_limits<uint64_t>::min()); + TestFastHexToBufferZeroPad16(std::numeric_limits<uint64_t>::max()); + TestFastHexToBufferZeroPad16(std::numeric_limits<int64_t>::min()); + TestFastHexToBufferZeroPad16(std::numeric_limits<int64_t>::max()); + absl::BitGen rng; + for (int i = 0; i < 100000; ++i) { + TestFastHexToBufferZeroPad16( + absl::LogUniform(rng, std::numeric_limits<uint64_t>::min(), + std::numeric_limits<uint64_t>::max())); + } +} + } // namespace
diff --git a/third_party/abseil-cpp/absl/strings/str_cat.cc b/third_party/abseil-cpp/absl/strings/str_cat.cc index ffe99db..d9afe2f 100644 --- a/third_party/abseil-cpp/absl/strings/str_cat.cc +++ b/third_party/abseil-cpp/absl/strings/str_cat.cc
@@ -15,34 +15,34 @@ #include "absl/strings/str_cat.h" #include <assert.h> + #include <algorithm> #include <cstdint> #include <cstring> #include "absl/strings/ascii.h" #include "absl/strings/internal/resize_uninitialized.h" +#include "absl/strings/numbers.h" namespace absl { +ABSL_NAMESPACE_BEGIN AlphaNum::AlphaNum(Hex hex) { + static_assert(numbers_internal::kFastToBufferSize >= 32, + "This function only works when output buffer >= 32 bytes long"); char* const end = &digits_[numbers_internal::kFastToBufferSize]; - char* writer = end; - uint64_t value = hex.value; - static const char hexdigits[] = "0123456789abcdef"; - do { - *--writer = hexdigits[value & 0xF]; - value >>= 4; - } while (value != 0); - - char* beg; - if (end - writer < hex.width) { - beg = end - hex.width; - std::fill_n(beg, writer - beg, hex.fill); + auto real_width = + absl::numbers_internal::FastHexToBufferZeroPad16(hex.value, end - 16); + if (real_width >= hex.width) { + piece_ = absl::string_view(end - real_width, real_width); } else { - beg = writer; + // Pad first 16 chars because FastHexToBufferZeroPad16 pads only to 16 and + // max pad width can be up to 20. + std::memset(end - 32, hex.fill, 16); + // Patch up everything else up to the real_width. + std::memset(end - real_width - 16, hex.fill, 16); + piece_ = absl::string_view(end - hex.width, hex.width); } - - piece_ = absl::string_view(beg, end - beg); } AlphaNum::AlphaNum(Dec dec) { @@ -99,7 +99,7 @@ std::string result; absl::strings_internal::STLStringResizeUninitialized(&result, a.size() + b.size()); - char* const begin = &*result.begin(); + char* const begin = &result[0]; char* out = begin; out = Append(out, a); out = Append(out, b); @@ -111,7 +111,7 @@ std::string result; strings_internal::STLStringResizeUninitialized( &result, a.size() + b.size() + c.size()); - char* const begin = &*result.begin(); + char* const begin = &result[0]; char* out = begin; out = Append(out, a); out = Append(out, b); @@ -125,7 +125,7 @@ std::string result; strings_internal::STLStringResizeUninitialized( &result, a.size() + b.size() + c.size() + d.size()); - char* const begin = &*result.begin(); + char* const begin = &result[0]; char* out = begin; out = Append(out, a); out = Append(out, b); @@ -144,7 +144,7 @@ for (const absl::string_view piece : pieces) total_size += piece.size(); strings_internal::STLStringResizeUninitialized(&result, total_size); - char* const begin = &*result.begin(); + char* const begin = &result[0]; char* out = begin; for (const absl::string_view piece : pieces) { const size_t this_size = piece.size(); @@ -176,7 +176,7 @@ } strings_internal::STLStringResizeUninitialized(dest, total_size); - char* const begin = &*dest->begin(); + char* const begin = &(*dest)[0]; char* out = begin + old_size; for (const absl::string_view piece : pieces) { const size_t this_size = piece.size(); @@ -201,7 +201,7 @@ std::string::size_type old_size = dest->size(); strings_internal::STLStringResizeUninitialized( dest, old_size + a.size() + b.size()); - char* const begin = &*dest->begin(); + char* const begin = &(*dest)[0]; char* out = begin + old_size; out = Append(out, a); out = Append(out, b); @@ -216,7 +216,7 @@ std::string::size_type old_size = dest->size(); strings_internal::STLStringResizeUninitialized( dest, old_size + a.size() + b.size() + c.size()); - char* const begin = &*dest->begin(); + char* const begin = &(*dest)[0]; char* out = begin + old_size; out = Append(out, a); out = Append(out, b); @@ -233,7 +233,7 @@ std::string::size_type old_size = dest->size(); strings_internal::STLStringResizeUninitialized( dest, old_size + a.size() + b.size() + c.size() + d.size()); - char* const begin = &*dest->begin(); + char* const begin = &(*dest)[0]; char* out = begin + old_size; out = Append(out, a); out = Append(out, b); @@ -242,4 +242,5 @@ assert(out == begin + dest->size()); } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/str_cat.h b/third_party/abseil-cpp/absl/strings/str_cat.h index a99aac0..a8a85c7 100644 --- a/third_party/abseil-cpp/absl/strings/str_cat.h +++ b/third_party/abseil-cpp/absl/strings/str_cat.h
@@ -64,6 +64,7 @@ #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { // AlphaNumBuffer allows a way to pass a string to StrCat without having to do @@ -252,7 +253,7 @@ const std::basic_string<char, std::char_traits<char>, Allocator>& str) : piece_(str) {} - // Use std::string literals ":" instead of character literals ':'. + // Use string literals ":" instead of character literals ':'. AlphaNum(char c) = delete; // NOLINT(runtime/explicit) AlphaNum(const AlphaNum&) = delete; @@ -290,7 +291,8 @@ // StrCat() // ----------------------------------------------------------------------------- // -// Merges given strings or numbers, using no delimiter(s). +// Merges given strings or numbers, using no delimiter(s), returning the merged +// result as a string. // // `StrCat()` is designed to be the fastest possible way to construct a string // out of a mix of raw C strings, string_views, strings, bool values, @@ -400,6 +402,7 @@ return result; } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_STR_CAT_H_
diff --git a/third_party/abseil-cpp/absl/strings/str_cat_benchmark.cc b/third_party/abseil-cpp/absl/strings/str_cat_benchmark.cc index 14c63b3..ee4ad112f 100644 --- a/third_party/abseil-cpp/absl/strings/str_cat_benchmark.cc +++ b/third_party/abseil-cpp/absl/strings/str_cat_benchmark.cc
@@ -23,7 +23,7 @@ namespace { const char kStringOne[] = "Once Upon A Time, "; -const char kStringTwo[] = "There was a std::string benchmark"; +const char kStringTwo[] = "There was a string benchmark"; // We want to include negative numbers in the benchmark, so this function // is used to count 0, 1, -1, 2, -2, 3, -3, ...
diff --git a/third_party/abseil-cpp/absl/strings/str_cat_test.cc b/third_party/abseil-cpp/absl/strings/str_cat_test.cc index 29db9c02..f3770dc 100644 --- a/third_party/abseil-cpp/absl/strings/str_cat_test.cc +++ b/third_party/abseil-cpp/absl/strings/str_cat_test.cc
@@ -162,7 +162,7 @@ EXPECT_EQ(result, "12345678910, 10987654321!"); std::string one = - "1"; // Actually, it's the size of this std::string that we want; a + "1"; // Actually, it's the size of this string that we want; a // 64-bit build distinguishes between size_t and uint64_t, // even though they're both unsigned 64-bit values. result = absl::StrCat("And a ", one.size(), " and a ", @@ -195,6 +195,21 @@ EXPECT_EQ(result, "12333444455555666666777777788888888999999999"); } +TEST(StrCat, CornerCases) { + std::string result; + + result = absl::StrCat(""); // NOLINT + EXPECT_EQ(result, ""); + result = absl::StrCat("", ""); + EXPECT_EQ(result, ""); + result = absl::StrCat("", "", ""); + EXPECT_EQ(result, ""); + result = absl::StrCat("", "", "", ""); + EXPECT_EQ(result, ""); + result = absl::StrCat("", "", "", "", ""); + EXPECT_EQ(result, ""); +} + // A minimal allocator that uses malloc(). template <typename T> struct Mallocator { @@ -360,7 +375,7 @@ EXPECT_EQ(result.substr(old_size), "12345678910, 10987654321!"); std::string one = - "1"; // Actually, it's the size of this std::string that we want; a + "1"; // Actually, it's the size of this string that we want; a // 64-bit build distinguishes between size_t and uint64_t, // even though they're both unsigned 64-bit values. old_size = result.size(); @@ -433,10 +448,34 @@ } #endif // GTEST_HAS_DEATH_TEST -TEST(StrAppend, EmptyString) { - std::string s = ""; - absl::StrAppend(&s, s); - EXPECT_EQ(s, ""); +TEST(StrAppend, CornerCases) { + std::string result; + absl::StrAppend(&result, ""); + EXPECT_EQ(result, ""); + absl::StrAppend(&result, "", ""); + EXPECT_EQ(result, ""); + absl::StrAppend(&result, "", "", ""); + EXPECT_EQ(result, ""); + absl::StrAppend(&result, "", "", "", ""); + EXPECT_EQ(result, ""); + absl::StrAppend(&result, "", "", "", "", ""); + EXPECT_EQ(result, ""); +} + +TEST(StrAppend, CornerCasesNonEmptyAppend) { + for (std::string result : {"hello", "a string too long to fit in the SSO"}) { + const std::string expected = result; + absl::StrAppend(&result, ""); + EXPECT_EQ(result, expected); + absl::StrAppend(&result, "", ""); + EXPECT_EQ(result, expected); + absl::StrAppend(&result, "", "", ""); + EXPECT_EQ(result, expected); + absl::StrAppend(&result, "", "", "", ""); + EXPECT_EQ(result, expected); + absl::StrAppend(&result, "", "", "", "", ""); + EXPECT_EQ(result, expected); + } } template <typename IntType>
diff --git a/third_party/abseil-cpp/absl/strings/str_format.h b/third_party/abseil-cpp/absl/strings/str_format.h index 607e2bc..2f9b4b2 100644 --- a/third_party/abseil-cpp/absl/strings/str_format.h +++ b/third_party/abseil-cpp/absl/strings/str_format.h
@@ -82,6 +82,7 @@ #include "absl/strings/internal/str_format/parser.h" // IWYU pragma: export namespace absl { +ABSL_NAMESPACE_BEGIN // UntypedFormatSpec // @@ -400,6 +401,12 @@ // This function is functionally equivalent to `std::snprintf()` (and // type-safe); prefer `absl::SNPrintF()` over `std::snprintf()`. // +// In particular, a successful call to `absl::SNPrintF()` writes at most `size` +// bytes of the formatted output to `output`, including a NUL-terminator, and +// returns the number of bytes that would have been written if truncation did +// not occur. In the event of an error, a negative value is returned and `errno` +// is set. +// // Example: // // std::string_view s = "Ulaanbaatar"; @@ -524,6 +531,7 @@ str_format_internal::UntypedFormatSpecImpl::Extract(format), args); } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_STR_FORMAT_H_
diff --git a/third_party/abseil-cpp/absl/strings/str_format_test.cc b/third_party/abseil-cpp/absl/strings/str_format_test.cc index cfd81bb..554dca7 100644 --- a/third_party/abseil-cpp/absl/strings/str_format_test.cc +++ b/third_party/abseil-cpp/absl/strings/str_format_test.cc
@@ -10,6 +10,7 @@ #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { using str_format_internal::FormatArgImpl; @@ -241,7 +242,7 @@ std::FILE* file() const { return file_; } - // Read the file into a std::string. + // Read the file into a string. std::string ReadFile() { std::fseek(file_, 0, SEEK_END); int size = std::ftell(file_); @@ -344,7 +345,7 @@ EXPECT_EQ(StrFormat("%c", int{'a'}), "a"); EXPECT_EQ(StrFormat("%c", long{'a'}), "a"); // NOLINT EXPECT_EQ(StrFormat("%c", uint64_t{'a'}), "a"); - // "s" - std::string Eg: "C" -> "C", std::string("C++") -> "C++" + // "s" - string Eg: "C" -> "C", std::string("C++") -> "C++" // Formats std::string, char*, string_view, and Cord. EXPECT_EQ(StrFormat("%s", "C"), "C"); EXPECT_EQ(StrFormat("%s", std::string("C++")), "C++"); @@ -449,7 +450,7 @@ if (conv.precision.is_from_arg()) { *out += "." + std::to_string(conv.precision.get_from_arg()) + "$*"; } - *out += conv.conv.Char(); + *out += FormatConversionCharToChar(conv.conv); *out += "}"; return true; } @@ -622,6 +623,7 @@ } } // namespace +ABSL_NAMESPACE_END } // namespace absl // Some codegen thunks that we can use to easily dump the generated assembly for
diff --git a/third_party/abseil-cpp/absl/strings/str_join.h b/third_party/abseil-cpp/absl/strings/str_join.h index 4772f5d..ae5731a 100644 --- a/third_party/abseil-cpp/absl/strings/str_join.h +++ b/third_party/abseil-cpp/absl/strings/str_join.h
@@ -60,6 +60,7 @@ #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // Concept: Formatter @@ -286,6 +287,7 @@ return strings_internal::JoinAlgorithm(value, separator, AlphaNumFormatter()); } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_STR_JOIN_H_
diff --git a/third_party/abseil-cpp/absl/strings/str_join_test.cc b/third_party/abseil-cpp/absl/strings/str_join_test.cc index 921d9c2..2be6256 100644 --- a/third_party/abseil-cpp/absl/strings/str_join_test.cc +++ b/third_party/abseil-cpp/absl/strings/str_join_test.cc
@@ -134,26 +134,26 @@ // { - // Empty range yields an empty std::string. + // Empty range yields an empty string. std::vector<std::string> v; EXPECT_EQ("", absl::StrJoin(v, "-")); } { - // A range of 1 element gives a std::string with that element but no + // A range of 1 element gives a string with that element but no // separator. std::vector<std::string> v = {"foo"}; EXPECT_EQ("foo", absl::StrJoin(v, "-")); } { - // A range with a single empty std::string element + // A range with a single empty string element std::vector<std::string> v = {""}; EXPECT_EQ("", absl::StrJoin(v, "-")); } { - // A range with 2 elements, one of which is an empty std::string + // A range with 2 elements, one of which is an empty string std::vector<std::string> v = {"a", ""}; EXPECT_EQ("a-", absl::StrJoin(v, "-")); }
diff --git a/third_party/abseil-cpp/absl/strings/str_replace.cc b/third_party/abseil-cpp/absl/strings/str_replace.cc index 280f63d..2bd5fa9 100644 --- a/third_party/abseil-cpp/absl/strings/str_replace.cc +++ b/third_party/abseil-cpp/absl/strings/str_replace.cc
@@ -17,6 +17,7 @@ #include "absl/strings/str_cat.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace strings_internal { using FixedMapping = @@ -77,4 +78,5 @@ return StrReplaceAll<strings_internal::FixedMapping>(replacements, target); } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/str_replace.h b/third_party/abseil-cpp/absl/strings/str_replace.h index 30540d02..273c707 100644 --- a/third_party/abseil-cpp/absl/strings/str_replace.h +++ b/third_party/abseil-cpp/absl/strings/str_replace.h
@@ -46,6 +46,7 @@ #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN // StrReplaceAll() // @@ -212,6 +213,7 @@ return substitutions; } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_STR_REPLACE_H_
diff --git a/third_party/abseil-cpp/absl/strings/str_replace_benchmark.cc b/third_party/abseil-cpp/absl/strings/str_replace_benchmark.cc index 95b2dc10..01331da 100644 --- a/third_party/abseil-cpp/absl/strings/str_replace_benchmark.cc +++ b/third_party/abseil-cpp/absl/strings/str_replace_benchmark.cc
@@ -62,7 +62,7 @@ } } // big_string->resize(50); - // OK, we've set up the std::string, now let's set up expectations - first by + // OK, we've set up the string, now let's set up expectations - first by // just replacing "the" with "box" after_replacing_the = new std::string(*big_string); for (size_t pos = 0;
diff --git a/third_party/abseil-cpp/absl/strings/str_replace_test.cc b/third_party/abseil-cpp/absl/strings/str_replace_test.cc index 1ca23af..9d8c7f75b 100644 --- a/third_party/abseil-cpp/absl/strings/str_replace_test.cc +++ b/third_party/abseil-cpp/absl/strings/str_replace_test.cc
@@ -25,7 +25,7 @@ TEST(StrReplaceAll, OneReplacement) { std::string s; - // Empty std::string. + // Empty string. s = absl::StrReplaceAll(s, {{"", ""}}); EXPECT_EQ(s, ""); s = absl::StrReplaceAll(s, {{"x", ""}}); @@ -47,7 +47,7 @@ s = absl::StrReplaceAll("abc", {{"xyz", "123"}}); EXPECT_EQ(s, "abc"); - // Replace entire std::string. + // Replace entire string. s = absl::StrReplaceAll("abc", {{"abc", "xyz"}}); EXPECT_EQ(s, "xyz"); @@ -88,7 +88,7 @@ TEST(StrReplaceAll, ManyReplacements) { std::string s; - // Empty std::string. + // Empty string. s = absl::StrReplaceAll("", {{"", ""}, {"x", ""}, {"", "y"}, {"x", "y"}}); EXPECT_EQ(s, ""); @@ -96,7 +96,7 @@ s = absl::StrReplaceAll("abc", {{"", ""}, {"", "y"}, {"x", ""}}); EXPECT_EQ(s, "abc"); - // Replace entire std::string, one char at a time + // Replace entire string, one char at a time s = absl::StrReplaceAll("abc", {{"a", "x"}, {"b", "y"}, {"c", "z"}}); EXPECT_EQ(s, "xyz"); s = absl::StrReplaceAll("zxy", {{"z", "x"}, {"x", "y"}, {"y", "z"}}); @@ -264,7 +264,7 @@ std::string s; int reps; - // Empty std::string. + // Empty string. s = ""; reps = absl::StrReplaceAll({{"", ""}, {"x", ""}, {"", "y"}, {"x", "y"}}, &s); EXPECT_EQ(reps, 0); @@ -276,7 +276,7 @@ EXPECT_EQ(reps, 0); EXPECT_EQ(s, "abc"); - // Replace entire std::string, one char at a time + // Replace entire string, one char at a time s = "abc"; reps = absl::StrReplaceAll({{"a", "x"}, {"b", "y"}, {"c", "z"}}, &s); EXPECT_EQ(reps, 3);
diff --git a/third_party/abseil-cpp/absl/strings/str_split.cc b/third_party/abseil-cpp/absl/strings/str_split.cc index 2593130..e08c26b6 100644 --- a/third_party/abseil-cpp/absl/strings/str_split.cc +++ b/third_party/abseil-cpp/absl/strings/str_split.cc
@@ -27,6 +27,7 @@ #include "absl/strings/ascii.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { @@ -41,7 +42,7 @@ absl::string_view delimiter, size_t pos, FindPolicy find_policy) { if (delimiter.empty() && text.length() > 0) { - // Special case for empty std::string delimiters: always return a zero-length + // Special case for empty string delimiters: always return a zero-length // absl::string_view referring to the item at position 1 past pos. return absl::string_view(text.data() + pos + 1, 0); } @@ -126,7 +127,7 @@ size_t pos) const { pos = std::min(pos, text.size()); // truncate `pos` absl::string_view substr = text.substr(pos); - // If the std::string is shorter than the chunk size we say we + // If the string is shorter than the chunk size we say we // "can't find the delimiter" so this will be the last chunk. if (substr.length() <= static_cast<size_t>(length_)) return absl::string_view(text.data() + text.size(), 0); @@ -134,4 +135,5 @@ return absl::string_view(substr.data() + length_, 0); } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/str_split.h b/third_party/abseil-cpp/absl/strings/str_split.h index 7333078..a79cd4a0 100644 --- a/third_party/abseil-cpp/absl/strings/str_split.h +++ b/third_party/abseil-cpp/absl/strings/str_split.h
@@ -49,6 +49,7 @@ #include "absl/strings/strip.h" namespace absl { +ABSL_NAMESPACE_BEGIN //------------------------------------------------------------------------------ // Delimiters @@ -506,6 +507,7 @@ std::move(text), DelimiterType(d), std::move(p)); } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_STR_SPLIT_H_
diff --git a/third_party/abseil-cpp/absl/strings/str_split_test.cc b/third_party/abseil-cpp/absl/strings/str_split_test.cc index 658bca1..be58494 100644 --- a/third_party/abseil-cpp/absl/strings/str_split_test.cc +++ b/third_party/abseil-cpp/absl/strings/str_split_test.cc
@@ -71,7 +71,7 @@ // namespaces just like callers will need to use. TEST(Split, APIExamples) { { - // Passes std::string delimiter. Assumes the default of ByString. + // Passes string delimiter. Assumes the default of ByString. std::vector<std::string> v = absl::StrSplit("a,b,c", ","); // NOLINT EXPECT_THAT(v, ElementsAre("a", "b", "c")); @@ -97,7 +97,7 @@ } { - // Uses the Literal std::string "=>" as the delimiter. + // Uses the Literal string "=>" as the delimiter. const std::vector<std::string> v = absl::StrSplit("a=>b=>c", "=>"); EXPECT_THAT(v, ElementsAre("a", "b", "c")); } @@ -121,17 +121,17 @@ } { - // Splits the input std::string into individual characters by using an empty - // std::string as the delimiter. + // Splits the input string into individual characters by using an empty + // string as the delimiter. std::vector<std::string> v = absl::StrSplit("abc", ""); EXPECT_THAT(v, ElementsAre("a", "b", "c")); } { - // Splits std::string data with embedded NUL characters, using NUL as the + // Splits string data with embedded NUL characters, using NUL as the // delimiter. A simple delimiter of "\0" doesn't work because strlen() will - // say that's the empty std::string when constructing the absl::string_view - // delimiter. Instead, a non-empty std::string containing NUL can be used as the + // say that's the empty string when constructing the absl::string_view + // delimiter. Instead, a non-empty string containing NUL can be used as the // delimiter. std::string embedded_nulls("a\0b\0c", 5); std::string null_delim("\0", 1); @@ -436,7 +436,7 @@ // less-than, equal-to, and more-than 2 strings. TEST(Splitter, ToPair) { { - // Empty std::string + // Empty string std::pair<std::string, std::string> p = absl::StrSplit("", ','); EXPECT_EQ("", p.first); EXPECT_EQ("", p.second); @@ -565,7 +565,7 @@ TEST(Split, Temporary) { // Use a std::string longer than the SSO length, so that when the temporary is - // destroyed, if the splitter keeps a reference to the std::string's contents, + // destroyed, if the splitter keeps a reference to the string's contents, // it'll reference freed memory instead of just dead on-stack memory. const char input[] = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u"; EXPECT_LT(sizeof(std::string), ABSL_ARRAYSIZE(input)) @@ -651,14 +651,14 @@ // Tests splitting utf8 strings and utf8 delimiters. std::string utf8_string = u8"\u03BA\u1F79\u03C3\u03BC\u03B5"; { - // A utf8 input std::string with an ascii delimiter. + // A utf8 input string with an ascii delimiter. std::string to_split = "a," + utf8_string; std::vector<absl::string_view> v = absl::StrSplit(to_split, ','); EXPECT_THAT(v, ElementsAre("a", utf8_string)); } { - // A utf8 input std::string and a utf8 delimiter. + // A utf8 input string and a utf8 delimiter. std::string to_split = "a," + utf8_string + ",b"; std::string unicode_delimiter = "," + utf8_string + ","; std::vector<absl::string_view> v = @@ -667,7 +667,7 @@ } { - // A utf8 input std::string and ByAnyChar with ascii chars. + // A utf8 input string and ByAnyChar with ascii chars. std::vector<absl::string_view> v = absl::StrSplit(u8"Foo h\u00E4llo th\u4E1Ere", absl::ByAnyChar(" \t")); EXPECT_THAT(v, ElementsAre("Foo", u8"h\u00E4llo", u8"th\u4E1Ere")); @@ -814,10 +814,10 @@ ByString comma_string(","); TestComma(comma_string); - // The first occurrence of empty std::string ("") in a std::string is at position 0. + // The first occurrence of empty string ("") in a string is at position 0. // There is a test below that demonstrates this for absl::string_view::find(). // If the ByString delimiter returned position 0 for this, there would - // be an infinite loop in the SplitIterator code. To avoid this, empty std::string + // be an infinite loop in the SplitIterator code. To avoid this, empty string // is a special case in that it always returns the item at position 1. absl::string_view abc("abc"); EXPECT_EQ(0, abc.find("")); // "" is found at position 0 @@ -876,7 +876,7 @@ EXPECT_FALSE(IsFoundAt("=", two_delims, -1)); // ByAnyChar behaves just like ByString when given a delimiter of empty - // std::string. That is, it always returns a zero-length absl::string_view + // string. That is, it always returns a zero-length absl::string_view // referring to the item at position 1, not position 0. ByAnyChar empty(""); EXPECT_FALSE(IsFoundAt("", empty, 0)); @@ -913,7 +913,7 @@ std::vector<absl::string_view> v = absl::StrSplit(s, '-'); EXPECT_EQ(2, v.size()); // The first element will contain 2G of 'x's. - // testing::StartsWith is too slow with a 2G std::string. + // testing::StartsWith is too slow with a 2G string. EXPECT_EQ('x', v[0][0]); EXPECT_EQ('x', v[0][1]); EXPECT_EQ('x', v[0][3]);
diff --git a/third_party/abseil-cpp/absl/strings/string_view.cc b/third_party/abseil-cpp/absl/strings/string_view.cc index dc034a8..c5f5de93 100644 --- a/third_party/abseil-cpp/absl/strings/string_view.cc +++ b/third_party/abseil-cpp/absl/strings/string_view.cc
@@ -14,7 +14,7 @@ #include "absl/strings/string_view.h" -#ifndef ABSL_HAVE_STD_STRING_VIEW +#ifndef ABSL_USES_STD_STRING_VIEW #include <algorithm> #include <climits> @@ -24,6 +24,7 @@ #include "absl/strings/internal/memutil.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { void WritePadding(std::ostream& o, size_t pad) { @@ -228,6 +229,7 @@ ABSL_STRING_VIEW_SELECTANY constexpr string_view::size_type string_view::kMaxSize; +ABSL_NAMESPACE_END } // namespace absl -#endif // ABSL_HAVE_STD_STRING_VIEW +#endif // ABSL_USES_STD_STRING_VIEW
diff --git a/third_party/abseil-cpp/absl/strings/string_view.h b/third_party/abseil-cpp/absl/strings/string_view.h index 25a4d1e..b314bc3 100644 --- a/third_party/abseil-cpp/absl/strings/string_view.h +++ b/third_party/abseil-cpp/absl/strings/string_view.h
@@ -28,18 +28,6 @@ #define ABSL_STRINGS_STRING_VIEW_H_ #include <algorithm> -#include "absl/base/config.h" - -#ifdef ABSL_HAVE_STD_STRING_VIEW - -#include <string_view> // IWYU pragma: export - -namespace absl { -using std::string_view; -} // namespace absl - -#else // ABSL_HAVE_STD_STRING_VIEW - #include <cassert> #include <cstddef> #include <cstring> @@ -48,12 +36,33 @@ #include <limits> #include <string> +#include "absl/base/config.h" #include "absl/base/internal/throw_delegate.h" #include "absl/base/macros.h" #include "absl/base/optimization.h" #include "absl/base/port.h" +#ifdef ABSL_USES_STD_STRING_VIEW + +#include <string_view> // IWYU pragma: export + namespace absl { +ABSL_NAMESPACE_BEGIN +using std::string_view; +ABSL_NAMESPACE_END +} // namespace absl + +#else // ABSL_USES_STD_STRING_VIEW + +#if ABSL_HAVE_BUILTIN(__builtin_memcmp) || \ + (defined(__GNUC__) && !defined(__clang__)) +#define ABSL_INTERNAL_STRING_VIEW_MEMCMP __builtin_memcmp +#else // ABSL_HAVE_BUILTIN(__builtin_memcmp) +#define ABSL_INTERNAL_STRING_VIEW_MEMCMP memcmp +#endif // ABSL_HAVE_BUILTIN(__builtin_memcmp) + +namespace absl { +ABSL_NAMESPACE_BEGIN // absl::string_view // @@ -102,17 +111,17 @@ // example, when splitting a string, `std::vector<absl::string_view>` is a // natural data type for the output. // -// When constructed from a source which is nul-terminated, the `string_view` -// itself will not include the nul-terminator unless a specific size (including -// the nul) is passed to the constructor. As a result, common idioms that work -// on nul-terminated strings do not work on `string_view` objects. If you write +// When constructed from a source which is NUL-terminated, the `string_view` +// itself will not include the NUL-terminator unless a specific size (including +// the NUL) is passed to the constructor. As a result, common idioms that work +// on NUL-terminated strings do not work on `string_view` objects. If you write // code that scans a `string_view`, you must check its length rather than test // for nul, for example. Note, however, that nuls may still be embedded within // a `string_view` explicitly. // // You may create a null `string_view` in two ways: // -// absl::string_view sv(); +// absl::string_view sv; // absl::string_view sv(nullptr, 0); // // For the above, `sv.data() == nullptr`, `sv.length() == 0`, and @@ -168,9 +177,11 @@ string_view( // NOLINT(runtime/explicit) const std::basic_string<char, std::char_traits<char>, Allocator>& str) noexcept - : ptr_(str.data()), length_(CheckLengthInternal(str.size())) {} + // This is implemented in terms of `string_view(p, n)` so `str.size()` + // doesn't need to be reevaluated after `ptr_` is set. + : string_view(str.data(), str.size()) {} - // Implicit constructor of a `string_view` from nul-terminated `str`. When + // Implicit constructor of a `string_view` from NUL-terminated `str`. When // accepting possibly null strings, use `absl::NullSafeStringView(str)` // instead (see below). constexpr string_view(const char* str) // NOLINT(runtime/explicit) @@ -269,27 +280,46 @@ // string_view::operator[] // - // Returns the ith element of an `string_view` using the array operator. + // Returns the ith element of the `string_view` using the array operator. // Note that this operator does not perform any bounds checking. - constexpr const_reference operator[](size_type i) const { return ptr_[i]; } + constexpr const_reference operator[](size_type i) const { + return ABSL_ASSERT(i < size()), ptr_[i]; + } + + // string_view::at() + // + // Returns the ith element of the `string_view`. Bounds checking is performed, + // and an exception of type `std::out_of_range` will be thrown on invalid + // access. + constexpr const_reference at(size_type i) const { + return ABSL_PREDICT_TRUE(i < size()) + ? ptr_[i] + : ((void)base_internal::ThrowStdOutOfRange( + "absl::string_view::at"), + ptr_[i]); + } // string_view::front() // // Returns the first element of a `string_view`. - constexpr const_reference front() const { return ptr_[0]; } + constexpr const_reference front() const { + return ABSL_ASSERT(!empty()), ptr_[0]; + } // string_view::back() // // Returns the last element of a `string_view`. - constexpr const_reference back() const { return ptr_[size() - 1]; } + constexpr const_reference back() const { + return ABSL_ASSERT(!empty()), ptr_[size() - 1]; + } // string_view::data() // // Returns a pointer to the underlying character array (which is of course // stored elsewhere). Note that `string_view::data()` may contain embedded nul - // characters, but the returned buffer may or may not be nul-terminated; - // therefore, do not pass `data()` to a routine that expects a nul-terminated - // std::string. + // characters, but the returned buffer may or may not be NUL-terminated; + // therefore, do not pass `data()` to a routine that expects a NUL-terminated + // string. constexpr const_pointer data() const noexcept { return ptr_; } // Modifiers @@ -297,7 +327,7 @@ // string_view::remove_prefix() // // Removes the first `n` characters from the `string_view`. Note that the - // underlying std::string is not changed, only the view. + // underlying string is not changed, only the view. void remove_prefix(size_type n) { assert(n <= length_); ptr_ += n; @@ -307,7 +337,7 @@ // string_view::remove_suffix() // // Removes the last `n` characters from the `string_view`. Note that the - // underlying std::string is not changed, only the view. + // underlying string is not changed, only the view. void remove_suffix(size_type n) { assert(n <= length_); length_ -= n; @@ -342,7 +372,7 @@ size_type rlen = (std::min)(length_ - pos, n); if (rlen > 0) { const char* start = ptr_ + pos; - std::copy(start, start + rlen, buf); + traits_type::copy(buf, start, rlen); } return rlen; } @@ -352,31 +382,28 @@ // Returns a "substring" of the `string_view` (at offset `pos` and length // `n`) as another string_view. This function throws `std::out_of_bounds` if // `pos > size`. - string_view substr(size_type pos, size_type n = npos) const { - if (ABSL_PREDICT_FALSE(pos > length_)) - base_internal::ThrowStdOutOfRange("absl::string_view::substr"); - n = (std::min)(n, length_ - pos); - return string_view(ptr_ + pos, n); + constexpr string_view substr(size_type pos, size_type n = npos) const { + return ABSL_PREDICT_FALSE(pos > length_) + ? (base_internal::ThrowStdOutOfRange( + "absl::string_view::substr"), + string_view()) + : string_view(ptr_ + pos, Min(n, length_ - pos)); } // string_view::compare() // // Performs a lexicographical comparison between the `string_view` and // another `absl::string_view`, returning -1 if `this` is less than, 0 if - // `this` is equal to, and 1 if `this` is greater than the passed std::string + // `this` is equal to, and 1 if `this` is greater than the passed string // view. Note that in the case of data equality, a further comparison is made // on the respective sizes of the two `string_view`s to determine which is // smaller, equal, or greater. - int compare(string_view x) const noexcept { - auto min_length = (std::min)(length_, x.length_); - if (min_length > 0) { - int r = memcmp(ptr_, x.ptr_, min_length); - if (r < 0) return -1; - if (r > 0) return 1; - } - if (length_ < x.length_) return -1; - if (length_ > x.length_) return 1; - return 0; + constexpr int compare(string_view x) const noexcept { + return CompareImpl(length_, x.length_, + Min(length_, x.length_) == 0 + ? 0 + : ABSL_INTERNAL_STRING_VIEW_MEMCMP( + ptr_, x.ptr_, Min(length_, x.length_))); } // Overload of `string_view::compare()` for comparing a substring of the @@ -393,17 +420,17 @@ } // Overload of `string_view::compare()` for comparing a `string_view` and a - // a different C-style std::string `s`. + // a different C-style string `s`. int compare(const char* s) const { return compare(string_view(s)); } // Overload of `string_view::compare()` for comparing a substring of the - // `string_view` and a different std::string C-style std::string `s`. + // `string_view` and a different string C-style string `s`. int compare(size_type pos1, size_type count1, const char* s) const { return substr(pos1, count1).compare(string_view(s)); } // Overload of `string_view::compare()` for comparing a substring of the - // `string_view` and a substring of a different C-style std::string `s`. + // `string_view` and a substring of a different C-style string `s`. int compare(size_type pos1, size_type count1, const char* s, size_type count2) const { return substr(pos1, count1).compare(string_view(s, count2)); @@ -493,7 +520,7 @@ (std::numeric_limits<difference_type>::max)(); static constexpr size_type CheckLengthInternal(size_type len) { - return ABSL_ASSERT(len <= kMaxSize), len; + return (void)ABSL_ASSERT(len <= kMaxSize), len; } static constexpr size_type StrlenInternal(const char* str) { @@ -514,6 +541,17 @@ #endif } + static constexpr size_t Min(size_type length_a, size_type length_b) { + return length_a < length_b ? length_a : length_b; + } + + static constexpr int CompareImpl(size_type length_a, size_type length_b, + int compare_result) { + return compare_result == 0 ? static_cast<int>(length_a > length_b) - + static_cast<int>(length_a < length_b) + : (compare_result < 0 ? -1 : 1); + } + const char* ptr_; size_type length_; }; @@ -521,44 +559,44 @@ // This large function is defined inline so that in a fairly common case where // one of the arguments is a literal, the compiler can elide a lot of the // following comparisons. -inline bool operator==(string_view x, string_view y) noexcept { - auto len = x.size(); - if (len != y.size()) { - return false; - } - - return x.data() == y.data() || len <= 0 || - memcmp(x.data(), y.data(), len) == 0; +constexpr bool operator==(string_view x, string_view y) noexcept { + return x.size() == y.size() && + (x.empty() || + ABSL_INTERNAL_STRING_VIEW_MEMCMP(x.data(), y.data(), x.size()) == 0); } -inline bool operator!=(string_view x, string_view y) noexcept { +constexpr bool operator!=(string_view x, string_view y) noexcept { return !(x == y); } -inline bool operator<(string_view x, string_view y) noexcept { - auto min_size = (std::min)(x.size(), y.size()); - const int r = min_size == 0 ? 0 : memcmp(x.data(), y.data(), min_size); - return (r < 0) || (r == 0 && x.size() < y.size()); +constexpr bool operator<(string_view x, string_view y) noexcept { + return x.compare(y) < 0; } -inline bool operator>(string_view x, string_view y) noexcept { return y < x; } +constexpr bool operator>(string_view x, string_view y) noexcept { + return y < x; +} -inline bool operator<=(string_view x, string_view y) noexcept { +constexpr bool operator<=(string_view x, string_view y) noexcept { return !(y < x); } -inline bool operator>=(string_view x, string_view y) noexcept { +constexpr bool operator>=(string_view x, string_view y) noexcept { return !(x < y); } // IO Insertion Operator std::ostream& operator<<(std::ostream& o, string_view piece); +ABSL_NAMESPACE_END } // namespace absl -#endif // ABSL_HAVE_STD_STRING_VIEW +#undef ABSL_INTERNAL_STRING_VIEW_MEMCMP + +#endif // ABSL_USES_STD_STRING_VIEW namespace absl { +ABSL_NAMESPACE_BEGIN // ClippedSubstr() // @@ -575,10 +613,11 @@ // Creates an `absl::string_view` from a pointer `p` even if it's null-valued. // This function should be used where an `absl::string_view` can be created from // a possibly-null pointer. -inline string_view NullSafeStringView(const char* p) { +constexpr string_view NullSafeStringView(const char* p) { return p ? string_view(p) : string_view(); } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_STRING_VIEW_H_
diff --git a/third_party/abseil-cpp/absl/strings/string_view_benchmark.cc b/third_party/abseil-cpp/absl/strings/string_view_benchmark.cc index 46909cb0..0d74e23 100644 --- a/third_party/abseil-cpp/absl/strings/string_view_benchmark.cc +++ b/third_party/abseil-cpp/absl/strings/string_view_benchmark.cc
@@ -30,6 +30,24 @@ namespace { +void BM_StringViewFromString(benchmark::State& state) { + std::string s(state.range(0), 'x'); + std::string* ps = &s; + struct SV { + SV() = default; + explicit SV(const std::string& s) : sv(s) {} + absl::string_view sv; + } sv; + SV* psv = &sv; + benchmark::DoNotOptimize(ps); + benchmark::DoNotOptimize(psv); + for (auto _ : state) { + new (psv) SV(*ps); + benchmark::DoNotOptimize(sv); + } +} +BENCHMARK(BM_StringViewFromString)->Arg(12)->Arg(128); + // Provide a forcibly out-of-line wrapper for operator== that can be used in // benchmarks to measure the impact of inlining. ABSL_ATTRIBUTE_NOINLINE @@ -142,11 +160,45 @@ absl::string_view b = y; for (auto _ : state) { + benchmark::DoNotOptimize(a); + benchmark::DoNotOptimize(b); benchmark::DoNotOptimize(a.compare(b)); } } BENCHMARK(BM_CompareSame)->DenseRange(0, 3)->Range(4, 1 << 10); +void BM_CompareFirstOneLess(benchmark::State& state) { + const int len = state.range(0); + std::string x(len, 'a'); + std::string y = x; + y.back() = 'b'; + absl::string_view a = x; + absl::string_view b = y; + + for (auto _ : state) { + benchmark::DoNotOptimize(a); + benchmark::DoNotOptimize(b); + benchmark::DoNotOptimize(a.compare(b)); + } +} +BENCHMARK(BM_CompareFirstOneLess)->DenseRange(1, 3)->Range(4, 1 << 10); + +void BM_CompareSecondOneLess(benchmark::State& state) { + const int len = state.range(0); + std::string x(len, 'a'); + std::string y = x; + x.back() = 'b'; + absl::string_view a = x; + absl::string_view b = y; + + for (auto _ : state) { + benchmark::DoNotOptimize(a); + benchmark::DoNotOptimize(b); + benchmark::DoNotOptimize(a.compare(b)); + } +} +BENCHMARK(BM_CompareSecondOneLess)->DenseRange(1, 3)->Range(4, 1 << 10); + void BM_find_string_view_len_one(benchmark::State& state) { std::string haystack(state.range(0), '0'); absl::string_view s(haystack);
diff --git a/third_party/abseil-cpp/absl/strings/string_view_test.cc b/third_party/abseil-cpp/absl/strings/string_view_test.cc index 419353f..ef1af46 100644 --- a/third_party/abseil-cpp/absl/strings/string_view_test.cc +++ b/third_party/abseil-cpp/absl/strings/string_view_test.cc
@@ -29,7 +29,8 @@ #include "absl/base/config.h" #include "absl/base/dynamic_annotations.h" -#ifdef __ANDROID__ +#if defined(ABSL_HAVE_STD_STRING_VIEW) || defined(__ANDROID__) +// We don't control the death messaging when using std::string_view. // Android assert messages only go to system log, so death tests cannot inspect // the message for matching. #define ABSL_EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ @@ -372,7 +373,7 @@ #ifdef ABSL_HAVE_EXCEPTIONS EXPECT_THROW(a.copy(buf, 1, 27), std::out_of_range); #else - EXPECT_DEATH(a.copy(buf, 1, 27), "absl::string_view::copy"); + ABSL_EXPECT_DEATH_IF_SUPPORTED(a.copy(buf, 1, 27), "absl::string_view::copy"); #endif } @@ -409,7 +410,7 @@ EXPECT_EQ(a.find(e, 17), 17); absl::string_view g("xx not found bb"); EXPECT_EQ(a.find(g), absl::string_view::npos); - // empty std::string nonsense + // empty string nonsense EXPECT_EQ(d.find(b), absl::string_view::npos); EXPECT_EQ(e.find(b), absl::string_view::npos); EXPECT_EQ(d.find(b, 4), absl::string_view::npos); @@ -437,7 +438,7 @@ EXPECT_EQ(g.find('o', 4), 4); EXPECT_EQ(g.find('o', 5), 8); EXPECT_EQ(a.find('b', 5), absl::string_view::npos); - // empty std::string nonsense + // empty string nonsense EXPECT_EQ(d.find('\0'), absl::string_view::npos); EXPECT_EQ(e.find('\0'), absl::string_view::npos); EXPECT_EQ(d.find('\0', 4), absl::string_view::npos); @@ -464,7 +465,7 @@ EXPECT_EQ(e.rfind(b), absl::string_view::npos); EXPECT_EQ(d.rfind(b, 4), absl::string_view::npos); EXPECT_EQ(e.rfind(b, 7), absl::string_view::npos); - // empty std::string nonsense + // empty string nonsense EXPECT_EQ(d.rfind(d, 4), std::string().rfind(std::string())); EXPECT_EQ(e.rfind(d, 7), std::string().rfind(std::string())); EXPECT_EQ(d.rfind(e, 4), std::string().rfind(std::string())); @@ -483,7 +484,7 @@ EXPECT_EQ(f.rfind('\0', 12), 3); EXPECT_EQ(f.rfind('3'), 2); EXPECT_EQ(f.rfind('5'), 5); - // empty std::string nonsense + // empty string nonsense EXPECT_EQ(d.rfind('o'), absl::string_view::npos); EXPECT_EQ(e.rfind('o'), absl::string_view::npos); EXPECT_EQ(d.rfind('o', 4), absl::string_view::npos); @@ -519,7 +520,7 @@ EXPECT_EQ(g.find_first_of(c), 0); EXPECT_EQ(a.find_first_of(f), absl::string_view::npos); EXPECT_EQ(f.find_first_of(a), absl::string_view::npos); - // empty std::string nonsense + // empty string nonsense EXPECT_EQ(a.find_first_of(d), absl::string_view::npos); EXPECT_EQ(a.find_first_of(e), absl::string_view::npos); EXPECT_EQ(d.find_first_of(b), absl::string_view::npos); @@ -537,7 +538,7 @@ EXPECT_EQ(a.find_first_not_of(f), 0); EXPECT_EQ(a.find_first_not_of(d), 0); EXPECT_EQ(a.find_first_not_of(e), 0); - // empty std::string nonsense + // empty string nonsense EXPECT_EQ(a.find_first_not_of(d), 0); EXPECT_EQ(a.find_first_not_of(e), 0); EXPECT_EQ(a.find_first_not_of(d, 1), 1); @@ -565,7 +566,7 @@ EXPECT_EQ(f.find_first_not_of('\0'), 0); EXPECT_EQ(f.find_first_not_of('\0', 3), 4); EXPECT_EQ(f.find_first_not_of('\0', 2), 2); - // empty std::string nonsense + // empty string nonsense EXPECT_EQ(d.find_first_not_of('x'), absl::string_view::npos); EXPECT_EQ(e.find_first_not_of('x'), absl::string_view::npos); EXPECT_EQ(d.find_first_not_of('\0'), absl::string_view::npos); @@ -605,7 +606,7 @@ EXPECT_EQ(f.find_last_of(i, 5), 5); EXPECT_EQ(f.find_last_of(i, 6), 6); EXPECT_EQ(f.find_last_of(a, 4), absl::string_view::npos); - // empty std::string nonsense + // empty string nonsense EXPECT_EQ(f.find_last_of(d), absl::string_view::npos); EXPECT_EQ(f.find_last_of(e), absl::string_view::npos); EXPECT_EQ(f.find_last_of(d, 4), absl::string_view::npos); @@ -631,7 +632,7 @@ EXPECT_EQ(a.find_last_not_of(c, 24), 22); EXPECT_EQ(a.find_last_not_of(b, 3), 3); EXPECT_EQ(a.find_last_not_of(b, 2), absl::string_view::npos); - // empty std::string nonsense + // empty string nonsense EXPECT_EQ(f.find_last_not_of(d), f.size()-1); EXPECT_EQ(f.find_last_not_of(e), f.size()-1); EXPECT_EQ(f.find_last_not_of(d, 4), 4); @@ -655,7 +656,7 @@ EXPECT_EQ(h.find_last_not_of('x', 2), 2); EXPECT_EQ(h.find_last_not_of('=', 2), absl::string_view::npos); EXPECT_EQ(b.find_last_not_of('b', 1), 0); - // empty std::string nonsense + // empty string nonsense EXPECT_EQ(d.find_last_not_of('x'), absl::string_view::npos); EXPECT_EQ(e.find_last_not_of('x'), absl::string_view::npos); EXPECT_EQ(d.find_last_not_of('\0'), absl::string_view::npos); @@ -677,7 +678,7 @@ EXPECT_EQ(a.substr(23, 99), c); EXPECT_EQ(a.substr(0), a); EXPECT_EQ(a.substr(3, 2), "de"); - // empty std::string nonsense + // empty string nonsense EXPECT_EQ(d.substr(0, 99), e); // use of npos EXPECT_EQ(a.substr(0, absl::string_view::npos), a); @@ -686,7 +687,8 @@ #ifdef ABSL_HAVE_EXCEPTIONS EXPECT_THROW((void)a.substr(99, 2), std::out_of_range); #else - EXPECT_DEATH((void)a.substr(99, 2), "absl::string_view::substr"); + ABSL_EXPECT_DEATH_IF_SUPPORTED((void)a.substr(99, 2), + "absl::string_view::substr"); #endif } @@ -816,21 +818,35 @@ EXPECT_EQ(&c, &csp.back()); } +TEST(StringViewTest, FrontBackEmpty) { +#ifndef ABSL_USES_STD_STRING_VIEW +#ifndef NDEBUG + // Abseil's string_view implementation has debug assertions that check that + // front() and back() are not called on an empty string_view. + absl::string_view sv; + ABSL_EXPECT_DEATH_IF_SUPPORTED(sv.front(), ""); + ABSL_EXPECT_DEATH_IF_SUPPORTED(sv.back(), ""); +#endif +#endif +} + // `std::string_view::string_view(const char*)` calls // `std::char_traits<char>::length(const char*)` to get the string length. In // libc++, it doesn't allow `nullptr` in the constexpr context, with the error // "read of dereferenced null pointer is not allowed in a constant expression". // At run time, the behavior of `std::char_traits::length()` on `nullptr` is // undefined by the standard and usually results in crash with libc++. +// GCC also started rejected this in libstdc++ starting in GCC9. // In MSVC, creating a constexpr string_view from nullptr also triggers an // "unevaluable pointer value" error. This compiler implementation conforms // to the standard, but `absl::string_view` implements a different // behavior for historical reasons. We work around tests that construct // `string_view` from `nullptr` when using libc++. -#if !defined(ABSL_HAVE_STD_STRING_VIEW) || \ - (!defined(_LIBCPP_VERSION) && !defined(_MSC_VER)) +#if !defined(ABSL_USES_STD_STRING_VIEW) || \ + (!(defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE >= 9) && \ + !defined(_LIBCPP_VERSION) && !defined(_MSC_VER)) #define ABSL_HAVE_STRING_VIEW_FROM_NULLPTR 1 -#endif // !defined(ABSL_HAVE_STD_STRING_VIEW) || !defined(_LIBCPP_VERSION) +#endif TEST(StringViewTest, NULLInput) { absl::string_view s; @@ -843,7 +859,7 @@ EXPECT_EQ(s.size(), 0); // .ToString() on a absl::string_view with nullptr should produce the empty - // std::string. + // string. EXPECT_EQ("", std::string(s)); #endif // ABSL_HAVE_STRING_VIEW_FROM_NULLPTR } @@ -892,6 +908,18 @@ EXPECT_LT(digits.compare(0, npos, "0123456789", 3, 5), 0); // 6 } +TEST(StringViewTest, At) { + absl::string_view abc = "abc"; + EXPECT_EQ(abc.at(0), 'a'); + EXPECT_EQ(abc.at(1), 'b'); + EXPECT_EQ(abc.at(2), 'c'); +#ifdef ABSL_HAVE_EXCEPTIONS + EXPECT_THROW(abc.at(3), std::out_of_range); +#else + ABSL_EXPECT_DEATH_IF_SUPPORTED(abc.at(3), "absl::string_view::at"); +#endif +} + struct MyCharAlloc : std::allocator<char> {}; TEST(StringViewTest, ExplicitConversionOperator) { @@ -915,6 +943,31 @@ } } +TEST(StringViewTest, ConstexprNullSafeStringView) { + { + constexpr absl::string_view s = absl::NullSafeStringView(nullptr); + EXPECT_EQ(nullptr, s.data()); + EXPECT_EQ(0, s.size()); + EXPECT_EQ(absl::string_view(), s); + } +#if !defined(_MSC_VER) || _MSC_VER >= 1910 + // MSVC 2017+ is required for good constexpr string_view support. + // See the implementation of `absl::string_view::StrlenInternal()`. + { + static constexpr char kHi[] = "hi"; + absl::string_view s = absl::NullSafeStringView(kHi); + EXPECT_EQ(kHi, s.data()); + EXPECT_EQ(strlen(kHi), s.size()); + EXPECT_EQ(absl::string_view("hi"), s); + } + { + constexpr absl::string_view s = absl::NullSafeStringView("hello"); + EXPECT_EQ(s.size(), 5); + EXPECT_EQ("hello", s); + } +#endif +} + TEST(StringViewTest, ConstexprCompiles) { constexpr absl::string_view sp; #ifdef ABSL_HAVE_STRING_VIEW_FROM_NULLPTR @@ -922,9 +975,9 @@ #endif constexpr absl::string_view cstr_len("cstr", 4); -#if defined(ABSL_HAVE_STD_STRING_VIEW) +#if defined(ABSL_USES_STD_STRING_VIEW) // In libstdc++ (as of 7.2), `std::string_view::string_view(const char*)` - // calls `std::char_traits<char>::length(const char*)` to get the std::string + // calls `std::char_traits<char>::length(const char*)` to get the string // length, but it is not marked constexpr yet. See GCC bug: // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78156 // Also, there is a LWG issue that adds constexpr to length() which was just @@ -936,7 +989,7 @@ #define ABSL_HAVE_CONSTEXPR_STRING_VIEW_FROM_CSTR 1 #endif // !__GLIBCXX__ -#else // ABSL_HAVE_STD_STRING_VIEW +#else // ABSL_USES_STD_STRING_VIEW // This duplicates the check for __builtin_strlen in the header. #if ABSL_HAVE_BUILTIN(__builtin_strlen) || \ @@ -951,13 +1004,36 @@ #define ABSL_HAVE_CONSTEXPR_STRING_VIEW_FROM_CSTR 1 #endif -#endif // ABSL_HAVE_STD_STRING_VIEW +#endif // ABSL_USES_STD_STRING_VIEW #ifdef ABSL_HAVE_CONSTEXPR_STRING_VIEW_FROM_CSTR constexpr absl::string_view cstr_strlen("foo"); EXPECT_EQ(cstr_strlen.length(), 3); constexpr absl::string_view cstr_strlen2 = "bar"; EXPECT_EQ(cstr_strlen2, "bar"); + +#if ABSL_HAVE_BUILTIN(__builtin_memcmp) || \ + (defined(__GNUC__) && !defined(__clang__)) +#define ABSL_HAVE_CONSTEXPR_STRING_VIEW_COMPARISON 1 +#endif +#ifdef ABSL_HAVE_CONSTEXPR_STRING_VIEW_COMPARISON + constexpr absl::string_view foo = "foo"; + constexpr absl::string_view bar = "bar"; + constexpr bool foo_eq_bar = foo == bar; + constexpr bool foo_ne_bar = foo != bar; + constexpr bool foo_lt_bar = foo < bar; + constexpr bool foo_le_bar = foo <= bar; + constexpr bool foo_gt_bar = foo > bar; + constexpr bool foo_ge_bar = foo >= bar; + constexpr int foo_compare_bar = foo.compare(bar); + EXPECT_FALSE(foo_eq_bar); + EXPECT_TRUE(foo_ne_bar); + EXPECT_FALSE(foo_lt_bar); + EXPECT_FALSE(foo_le_bar); + EXPECT_TRUE(foo_gt_bar); + EXPECT_TRUE(foo_ge_bar); + EXPECT_GT(foo_compare_bar, 0); +#endif #endif #if !defined(__clang__) || 3 < __clang_major__ || \ @@ -1010,6 +1086,14 @@ EXPECT_EQ(sp_npos, -1); } +TEST(StringViewTest, ConstexprSubstr) { + constexpr absl::string_view foobar("foobar", 6); + constexpr absl::string_view foo = foobar.substr(0, 3); + constexpr absl::string_view bar = foobar.substr(3); + EXPECT_EQ(foo, "foo"); + EXPECT_EQ(bar, "bar"); +} + TEST(StringViewTest, Noexcept) { EXPECT_TRUE((std::is_nothrow_constructible<absl::string_view, const std::string&>::value)); @@ -1044,6 +1128,17 @@ EXPECT_TRUE(noexcept(sp.find_last_not_of('f'))); } +TEST(StringViewTest, BoundsCheck) { +#ifndef ABSL_USES_STD_STRING_VIEW +#ifndef NDEBUG + // Abseil's string_view implementation has bounds-checking in debug mode. + absl::string_view h = "hello"; + ABSL_EXPECT_DEATH_IF_SUPPORTED(h[5], ""); + ABSL_EXPECT_DEATH_IF_SUPPORTED(h[-1], ""); +#endif +#endif +} + TEST(ComparisonOpsTest, StringCompareNotAmbiguous) { EXPECT_EQ("hello", std::string("hello")); EXPECT_LT("hello", std::string("world")); @@ -1085,7 +1180,7 @@ TEST(HugeStringView, TwoPointTwoGB) { if (sizeof(size_t) <= 4 || AbslRunningOnValgrind()) return; - // Try a huge std::string piece. + // Try a huge string piece. const size_t size = size_t{2200} * 1000 * 1000; std::string s(size, 'a'); absl::string_view sp(s); @@ -1097,7 +1192,7 @@ } #endif // THREAD_SANITIZER -#if !defined(NDEBUG) && !defined(ABSL_HAVE_STD_STRING_VIEW) +#if !defined(NDEBUG) && !defined(ABSL_USES_STD_STRING_VIEW) TEST(NonNegativeLenTest, NonNegativeLen) { ABSL_EXPECT_DEATH_IF_SUPPORTED(absl::string_view("xyz", -1), "len <= kMaxSize"); @@ -1113,7 +1208,7 @@ ABSL_EXPECT_DEATH_IF_SUPPORTED(absl::string_view("", max_size + 1), "len <= kMaxSize"); } -#endif // !defined(NDEBUG) && !defined(ABSL_HAVE_STD_STRING_VIEW) +#endif // !defined(NDEBUG) && !defined(ABSL_USES_STD_STRING_VIEW) class StringViewStreamTest : public ::testing::Test { public:
diff --git a/third_party/abseil-cpp/absl/strings/strip.h b/third_party/abseil-cpp/absl/strings/strip.h index e1341e0..111872c 100644 --- a/third_party/abseil-cpp/absl/strings/strip.h +++ b/third_party/abseil-cpp/absl/strings/strip.h
@@ -30,6 +30,7 @@ #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN // ConsumePrefix() // @@ -84,6 +85,7 @@ return str; } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_STRIP_H_
diff --git a/third_party/abseil-cpp/absl/strings/substitute.cc b/third_party/abseil-cpp/absl/strings/substitute.cc index bc17695..1f3c740 100644 --- a/third_party/abseil-cpp/absl/strings/substitute.cc +++ b/third_party/abseil-cpp/absl/strings/substitute.cc
@@ -23,6 +23,7 @@ #include "absl/strings/string_view.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace substitute_internal { void SubstituteAndAppendArray(std::string* output, absl::string_view format, @@ -35,7 +36,7 @@ if (i + 1 >= format.size()) { #ifndef NDEBUG ABSL_RAW_LOG(FATAL, - "Invalid strings::Substitute() format std::string: \"%s\".", + "Invalid absl::Substitute() format string: \"%s\".", absl::CEscape(format).c_str()); #endif return; @@ -45,8 +46,8 @@ #ifndef NDEBUG ABSL_RAW_LOG( FATAL, - "Invalid strings::Substitute() format std::string: asked for \"$" - "%d\", but only %d args were given. Full format std::string was: " + "Invalid absl::Substitute() format string: asked for \"$" + "%d\", but only %d args were given. Full format string was: " "\"%s\".", index, static_cast<int>(num_args), absl::CEscape(format).c_str()); #endif @@ -60,7 +61,7 @@ } else { #ifndef NDEBUG ABSL_RAW_LOG(FATAL, - "Invalid strings::Substitute() format std::string: \"%s\".", + "Invalid absl::Substitute() format string: \"%s\".", absl::CEscape(format).c_str()); #endif return; @@ -72,7 +73,7 @@ if (size == 0) return; - // Build the std::string. + // Build the string. size_t original_size = output->size(); strings_internal::STLStringResizeUninitialized(output, original_size + size); char* target = &(*output)[original_size]; @@ -94,7 +95,6 @@ assert(target == output->data() + output->size()); } -static const char kHexDigits[] = "0123456789abcdef"; Arg::Arg(const void* value) { static_assert(sizeof(scratch_) >= sizeof(value) * 2 + 2, "fix sizeof(scratch_)"); @@ -104,7 +104,7 @@ char* ptr = scratch_ + sizeof(scratch_); uintptr_t num = reinterpret_cast<uintptr_t>(value); do { - *--ptr = kHexDigits[num & 0xf]; + *--ptr = absl::numbers_internal::kHexChar[num & 0xf]; num >>= 4; } while (num != 0); *--ptr = 'x'; @@ -119,7 +119,7 @@ char* writer = end; uint64_t value = hex.value; do { - *--writer = kHexDigits[value & 0xF]; + *--writer = absl::numbers_internal::kHexChar[value & 0xF]; value >>= 4; } while (value != 0); @@ -167,4 +167,5 @@ } } // namespace substitute_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/strings/substitute.h b/third_party/abseil-cpp/absl/strings/substitute.h index 233e9dc..e7b4c1e 100644 --- a/third_party/abseil-cpp/absl/strings/substitute.h +++ b/third_party/abseil-cpp/absl/strings/substitute.h
@@ -86,6 +86,7 @@ #include "absl/strings/strip.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace substitute_internal { // Arg @@ -98,7 +99,7 @@ // This class has implicit constructors. class Arg { public: - // Overloads for std::string-y things + // Overloads for string-y things // // Explicitly overload `const char*` so the compiler doesn't cast to `bool`. Arg(const char* value) // NOLINT(runtime/explicit) @@ -189,7 +190,12 @@ #if defined(ABSL_BAD_CALL_IF) constexpr int CalculateOneBit(const char* format) { - return (*format < '0' || *format > '9') ? 0 : (1 << (*format - '0')); + // Returns: + // * 2^N for '$N' when N is in [0-9] + // * 0 for correct '$' escaping: '$$'. + // * -1 otherwise. + return (*format < '0' || *format > '9') ? (*format == '$' ? 0 : -1) + : (1 << (*format - '0')); } constexpr const char* SkipNumber(const char* format) { @@ -354,13 +360,13 @@ void SubstituteAndAppend(std::string* output, const char* format) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 0, "There were no substitution arguments " - "but this format std::string has a $[0-9] in it"); + "but this format string has a $[0-9] in it"); void SubstituteAndAppend(std::string* output, const char* format, const substitute_internal::Arg& a0) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 1, "There was 1 substitution argument given, but " - "this format std::string is either missing its $0, or " + "this format string is either missing its $0, or " "contains one of $1-$9"); void SubstituteAndAppend(std::string* output, const char* format, @@ -368,7 +374,7 @@ const substitute_internal::Arg& a1) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 3, "There were 2 substitution arguments given, but " - "this format std::string is either missing its $0/$1, or " + "this format string is either missing its $0/$1, or " "contains one of $2-$9"); void SubstituteAndAppend(std::string* output, const char* format, @@ -377,7 +383,7 @@ const substitute_internal::Arg& a2) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 7, "There were 3 substitution arguments given, but " - "this format std::string is either missing its $0/$1/$2, or " + "this format string is either missing its $0/$1/$2, or " "contains one of $3-$9"); void SubstituteAndAppend(std::string* output, const char* format, @@ -387,7 +393,7 @@ const substitute_internal::Arg& a3) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 15, "There were 4 substitution arguments given, but " - "this format std::string is either missing its $0-$3, or " + "this format string is either missing its $0-$3, or " "contains one of $4-$9"); void SubstituteAndAppend(std::string* output, const char* format, @@ -398,7 +404,7 @@ const substitute_internal::Arg& a4) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 31, "There were 5 substitution arguments given, but " - "this format std::string is either missing its $0-$4, or " + "this format string is either missing its $0-$4, or " "contains one of $5-$9"); void SubstituteAndAppend(std::string* output, const char* format, @@ -410,7 +416,7 @@ const substitute_internal::Arg& a5) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 63, "There were 6 substitution arguments given, but " - "this format std::string is either missing its $0-$5, or " + "this format string is either missing its $0-$5, or " "contains one of $6-$9"); void SubstituteAndAppend( @@ -420,7 +426,7 @@ const substitute_internal::Arg& a5, const substitute_internal::Arg& a6) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 127, "There were 7 substitution arguments given, but " - "this format std::string is either missing its $0-$6, or " + "this format string is either missing its $0-$6, or " "contains one of $7-$9"); void SubstituteAndAppend( @@ -431,7 +437,7 @@ const substitute_internal::Arg& a7) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 255, "There were 8 substitution arguments given, but " - "this format std::string is either missing its $0-$7, or " + "this format string is either missing its $0-$7, or " "contains one of $8-$9"); void SubstituteAndAppend( @@ -443,7 +449,7 @@ ABSL_BAD_CALL_IF( substitute_internal::PlaceholderBitmask(format) != 511, "There were 9 substitution arguments given, but " - "this format std::string is either missing its $0-$8, or contains a $9"); + "this format string is either missing its $0-$8, or contains a $9"); void SubstituteAndAppend( std::string* output, const char* format, const substitute_internal::Arg& a0, @@ -454,7 +460,7 @@ const substitute_internal::Arg& a9) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 1023, "There were 10 substitution arguments given, but this " - "format std::string doesn't contain all of $0 through $9"); + "format string doesn't contain all of $0 through $9"); #endif // ABSL_BAD_CALL_IF // Substitute() @@ -580,19 +586,19 @@ std::string Substitute(const char* format) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 0, "There were no substitution arguments " - "but this format std::string has a $[0-9] in it"); + "but this format string has a $[0-9] in it"); std::string Substitute(const char* format, const substitute_internal::Arg& a0) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 1, "There was 1 substitution argument given, but " - "this format std::string is either missing its $0, or " + "this format string is either missing its $0, or " "contains one of $1-$9"); std::string Substitute(const char* format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 3, "There were 2 substitution arguments given, but " - "this format std::string is either missing its $0/$1, or " + "this format string is either missing its $0/$1, or " "contains one of $2-$9"); std::string Substitute(const char* format, const substitute_internal::Arg& a0, @@ -600,7 +606,7 @@ const substitute_internal::Arg& a2) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 7, "There were 3 substitution arguments given, but " - "this format std::string is either missing its $0/$1/$2, or " + "this format string is either missing its $0/$1/$2, or " "contains one of $3-$9"); std::string Substitute(const char* format, const substitute_internal::Arg& a0, @@ -609,7 +615,7 @@ const substitute_internal::Arg& a3) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 15, "There were 4 substitution arguments given, but " - "this format std::string is either missing its $0-$3, or " + "this format string is either missing its $0-$3, or " "contains one of $4-$9"); std::string Substitute(const char* format, const substitute_internal::Arg& a0, @@ -619,7 +625,7 @@ const substitute_internal::Arg& a4) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 31, "There were 5 substitution arguments given, but " - "this format std::string is either missing its $0-$4, or " + "this format string is either missing its $0-$4, or " "contains one of $5-$9"); std::string Substitute(const char* format, const substitute_internal::Arg& a0, @@ -630,7 +636,7 @@ const substitute_internal::Arg& a5) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 63, "There were 6 substitution arguments given, but " - "this format std::string is either missing its $0-$5, or " + "this format string is either missing its $0-$5, or " "contains one of $6-$9"); std::string Substitute(const char* format, const substitute_internal::Arg& a0, @@ -642,7 +648,7 @@ const substitute_internal::Arg& a6) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 127, "There were 7 substitution arguments given, but " - "this format std::string is either missing its $0-$6, or " + "this format string is either missing its $0-$6, or " "contains one of $7-$9"); std::string Substitute(const char* format, const substitute_internal::Arg& a0, @@ -655,7 +661,7 @@ const substitute_internal::Arg& a7) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 255, "There were 8 substitution arguments given, but " - "this format std::string is either missing its $0-$7, or " + "this format string is either missing its $0-$7, or " "contains one of $8-$9"); std::string Substitute( @@ -667,7 +673,7 @@ ABSL_BAD_CALL_IF( substitute_internal::PlaceholderBitmask(format) != 511, "There were 9 substitution arguments given, but " - "this format std::string is either missing its $0-$8, or contains a $9"); + "this format string is either missing its $0-$8, or contains a $9"); std::string Substitute( const char* format, const substitute_internal::Arg& a0, @@ -678,9 +684,10 @@ const substitute_internal::Arg& a9) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 1023, "There were 10 substitution arguments given, but this " - "format std::string doesn't contain all of $0 through $9"); + "format string doesn't contain all of $0 through $9"); #endif // ABSL_BAD_CALL_IF +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_SUBSTITUTE_H_
diff --git a/third_party/abseil-cpp/absl/strings/substitute_test.cc b/third_party/abseil-cpp/absl/strings/substitute_test.cc index e27abb1..442c921 100644 --- a/third_party/abseil-cpp/absl/strings/substitute_test.cc +++ b/third_party/abseil-cpp/absl/strings/substitute_test.cc
@@ -89,7 +89,7 @@ str = absl::Substitute("$0", char_buf); EXPECT_EQ("print me too", str); - // null char* is "doubly" special. Represented as the empty std::string. + // null char* is "doubly" special. Represented as the empty string. char_p = nullptr; str = absl::Substitute("$0", char_p); EXPECT_EQ("", str); @@ -189,14 +189,14 @@ TEST(SubstituteDeathTest, SubstituteDeath) { EXPECT_DEBUG_DEATH( static_cast<void>(absl::Substitute(absl::string_view("-$2"), "a", "b")), - "Invalid strings::Substitute\\(\\) format std::string: asked for \"\\$2\", " + "Invalid absl::Substitute\\(\\) format string: asked for \"\\$2\", " "but only 2 args were given."); EXPECT_DEBUG_DEATH( - static_cast<void>(absl::Substitute("-$z-")), - "Invalid strings::Substitute\\(\\) format std::string: \"-\\$z-\""); + static_cast<void>(absl::Substitute(absl::string_view("-$z-"))), + "Invalid absl::Substitute\\(\\) format string: \"-\\$z-\""); EXPECT_DEBUG_DEATH( - static_cast<void>(absl::Substitute("-$")), - "Invalid strings::Substitute\\(\\) format std::string: \"-\\$\""); + static_cast<void>(absl::Substitute(absl::string_view("-$"))), + "Invalid absl::Substitute\\(\\) format string: \"-\\$\""); } #endif // GTEST_HAS_DEATH_TEST
diff --git a/third_party/abseil-cpp/absl/synchronization/BUILD.bazel b/third_party/abseil-cpp/absl/synchronization/BUILD.bazel index fca8cb69..3f876b9 100644 --- a/third_party/abseil-cpp/absl/synchronization/BUILD.bazel +++ b/third_party/abseil-cpp/absl/synchronization/BUILD.bazel
@@ -14,6 +14,7 @@ # limitations under the License. # +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", @@ -42,8 +43,25 @@ deps = [ "//absl/base", "//absl/base:base_internal", + "//absl/base:config", "//absl/base:core_headers", "//absl/base:malloc_internal", + "//absl/base:raw_logging_internal", + ], +) + +cc_library( + name = "kernel_timeout_internal", + hdrs = ["internal/kernel_timeout.h"], + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + visibility = [ + "//absl/synchronization:__pkg__", + ], + deps = [ + "//absl/base:core_headers", + "//absl/base:raw_logging_internal", + "//absl/time", ], ) @@ -63,7 +81,6 @@ "barrier.h", "blocking_counter.h", "internal/create_thread_identity.h", - "internal/kernel_timeout.h", "internal/mutex_nonprod.inc", "internal/per_thread_sem.h", "internal/waiter.h", @@ -77,6 +94,7 @@ }) + ABSL_DEFAULT_LINKOPTS, deps = [ ":graphcycles_internal", + ":kernel_timeout_internal", "//absl/base", "//absl/base:atomic_hook", "//absl/base:base_internal", @@ -84,6 +102,7 @@ "//absl/base:core_headers", "//absl/base:dynamic_annotations", "//absl/base:malloc_internal", + "//absl/base:raw_logging_internal", "//absl/debugging:stacktrace", "//absl/debugging:symbolize", "//absl/time", @@ -124,8 +143,8 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":graphcycles_internal", - "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "@com_google_googletest//:gtest_main", ], ) @@ -140,7 +159,7 @@ ], deps = [ ":graphcycles_internal", - "//absl/base", + "//absl/base:raw_logging_internal", "@com_github_google_benchmark//:benchmark_main", ], ) @@ -171,6 +190,7 @@ ":thread_pool", "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "//absl/memory", "//absl/time", "@com_google_googletest//:gtest_main", @@ -243,7 +263,6 @@ deps = [ ":per_thread_sem_test_common", ":synchronization", - "//absl/base", "//absl/strings", "//absl/time", "@com_google_googletest//:gtest_main", @@ -260,7 +279,7 @@ tags = ["no_test_ios_x86_64"], deps = [ ":synchronization", - "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", ], )
diff --git a/third_party/abseil-cpp/absl/synchronization/BUILD.gn b/third_party/abseil-cpp/absl/synchronization/BUILD.gn index 8529824..35e119bb3 100644 --- a/third_party/abseil-cpp/absl/synchronization/BUILD.gn +++ b/third_party/abseil-cpp/absl/synchronization/BUILD.gn
@@ -29,13 +29,32 @@ deps = [ "../base", "../base:base_internal", + "../base:config", "../base:core_headers", "../base:malloc_internal", + "../base:raw_logging_internal", ] visibility = [] visibility += [ "../*" ] } +source_set("kernel_timeout_internal") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] + public = [ "internal/kernel_timeout.h" ] + deps = [ + "../base:core_headers", + "../base:raw_logging_internal", + "../time", + ] + visibility = [] + visibility += [ ":*" ] +} + source_set("synchronization") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ @@ -56,7 +75,6 @@ "barrier.h", "blocking_counter.h", "internal/create_thread_identity.h", - "internal/kernel_timeout.h", "internal/mutex_nonprod.inc", "internal/per_thread_sem.h", "internal/waiter.h", @@ -65,6 +83,7 @@ ] deps = [ ":graphcycles_internal", + ":kernel_timeout_internal", "../base", "../base:atomic_hook", "../base:base_internal", @@ -72,6 +91,7 @@ "../base:core_headers", "../base:dynamic_annotations", "../base:malloc_internal", + "../base:raw_logging_internal", "../debugging:stacktrace", "../debugging:symbolize", "../time",
diff --git a/third_party/abseil-cpp/absl/synchronization/CMakeLists.txt b/third_party/abseil-cpp/absl/synchronization/CMakeLists.txt index 4b70882..dfe5d05 100644 --- a/third_party/abseil-cpp/absl/synchronization/CMakeLists.txt +++ b/third_party/abseil-cpp/absl/synchronization/CMakeLists.txt
@@ -26,8 +26,23 @@ DEPS absl::base absl::base_internal + absl::config absl::core_headers absl::malloc_internal + absl::raw_logging_internal +) + +absl_cc_library( + NAME + kernel_timeout_internal + HDRS + "internal/kernel_timeout.h" + COPTS + ${ABSL_DEFAULT_COPTS} + DEPS + absl::core_headers + absl::raw_logging_internal + absl::time ) absl_cc_library( @@ -37,7 +52,6 @@ "barrier.h" "blocking_counter.h" "internal/create_thread_identity.h" - "internal/kernel_timeout.h" "internal/mutex_nonprod.inc" "internal/per_thread_sem.h" "internal/waiter.h" @@ -55,6 +69,7 @@ ${ABSL_DEFAULT_COPTS} DEPS absl::graphcycles_internal + absl::kernel_timeout_internal absl::atomic_hook absl::base absl::base_internal @@ -62,6 +77,7 @@ absl::core_headers absl::dynamic_annotations absl::malloc_internal + absl::raw_logging_internal absl::stacktrace absl::symbolize absl::time @@ -104,8 +120,8 @@ ${ABSL_TEST_COPTS} DEPS absl::graphcycles_internal - absl::base absl::core_headers + absl::raw_logging_internal gmock_main ) @@ -135,6 +151,7 @@ absl::base absl::core_headers absl::memory + absl::raw_logging_internal absl::time gmock_main ) @@ -178,7 +195,6 @@ DEPS absl::per_thread_sem_test_common absl::synchronization - absl::base absl::strings absl::time gmock_main @@ -193,6 +209,6 @@ ${ABSL_TEST_COPTS} DEPS absl::synchronization - absl::base absl::core_headers + absl::raw_logging_internal )
diff --git a/third_party/abseil-cpp/absl/synchronization/barrier.cc b/third_party/abseil-cpp/absl/synchronization/barrier.cc index c2c539a..0dfd795 100644 --- a/third_party/abseil-cpp/absl/synchronization/barrier.cc +++ b/third_party/abseil-cpp/absl/synchronization/barrier.cc
@@ -18,6 +18,7 @@ #include "absl/synchronization/mutex.h" namespace absl { +ABSL_NAMESPACE_BEGIN // Return whether int *arg is zero. static bool IsZero(void *arg) { @@ -47,4 +48,5 @@ return this->num_to_exit_ == 0; } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/synchronization/barrier.h b/third_party/abseil-cpp/absl/synchronization/barrier.h index cb5d821..d8e75440 100644 --- a/third_party/abseil-cpp/absl/synchronization/barrier.h +++ b/third_party/abseil-cpp/absl/synchronization/barrier.h
@@ -23,6 +23,7 @@ #include "absl/synchronization/mutex.h" namespace absl { +ABSL_NAMESPACE_BEGIN // Barrier // @@ -73,5 +74,6 @@ int num_to_exit_ ABSL_GUARDED_BY(lock_); }; +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_SYNCHRONIZATION_BARRIER_H_
diff --git a/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc b/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc index 481a06b..3cea7ae 100644 --- a/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc +++ b/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc
@@ -17,6 +17,7 @@ #include "absl/base/internal/raw_logging.h" namespace absl { +ABSL_NAMESPACE_BEGIN // Return whether int *arg is zero. static bool IsZero(void *arg) { @@ -52,4 +53,5 @@ // after we return from this method. } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/synchronization/blocking_counter.h b/third_party/abseil-cpp/absl/synchronization/blocking_counter.h index 77560fc0..1f53f9f2 100644 --- a/third_party/abseil-cpp/absl/synchronization/blocking_counter.h +++ b/third_party/abseil-cpp/absl/synchronization/blocking_counter.h
@@ -24,6 +24,7 @@ #include "absl/synchronization/mutex.h" namespace absl { +ABSL_NAMESPACE_BEGIN // BlockingCounter // @@ -92,6 +93,7 @@ int num_waiting_ ABSL_GUARDED_BY(lock_); }; +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_SYNCHRONIZATION_BLOCKING_COUNTER_H_
diff --git a/third_party/abseil-cpp/absl/synchronization/blocking_counter_test.cc b/third_party/abseil-cpp/absl/synchronization/blocking_counter_test.cc index c63e339..2926224a 100644 --- a/third_party/abseil-cpp/absl/synchronization/blocking_counter_test.cc +++ b/third_party/abseil-cpp/absl/synchronization/blocking_counter_test.cc
@@ -22,6 +22,7 @@ #include "absl/time/time.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { void PauseAndDecreaseCounter(BlockingCounter* counter, int* done) { @@ -63,4 +64,5 @@ } } // namespace +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc b/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc index ce3676a..fa0070a 100644 --- a/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +++ b/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc
@@ -27,6 +27,7 @@ #include "absl/synchronization/internal/per_thread_sem.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { // ThreadIdentity storage is persistent, we maintain a free-list of previously @@ -37,7 +38,7 @@ // A per-thread destructor for reclaiming associated ThreadIdentity objects. // Since we must preserve their storage we cache them for re-use. -static void ReclaimThreadIdentity(void* v) { +void ReclaimThreadIdentity(void* v) { base_internal::ThreadIdentity* identity = static_cast<base_internal::ThreadIdentity*>(v); @@ -47,6 +48,8 @@ base_internal::LowLevelAlloc::Free(identity->per_thread_synch.all_locks); } + PerThreadSem::Destroy(identity); + // We must explicitly clear the current thread's identity: // (a) Subsequent (unrelated) per-thread destructors may require an identity. // We must guarantee a new identity is used in this case (this instructor @@ -84,7 +87,6 @@ pts->wake = false; pts->cond_waiter = false; pts->all_locks = nullptr; - identity->waiter_state = {}; identity->blocked_count_ptr = nullptr; identity->ticker.store(0, std::memory_order_relaxed); identity->wait_start.store(0, std::memory_order_relaxed); @@ -132,6 +134,7 @@ } } // namespace synchronization_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_LOW_LEVEL_ALLOC_MISSING
diff --git a/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h b/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h index ebb16c5..e121f683 100644 --- a/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h +++ b/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h
@@ -29,12 +29,17 @@ #include "absl/base/port.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { // Allocates and attaches a ThreadIdentity object for the calling thread. // For private use only. base_internal::ThreadIdentity* CreateThreadIdentity(); +// A per-thread destructor for reclaiming associated ThreadIdentity objects. +// For private use only. +void ReclaimThreadIdentity(void* v); + // Returns the ThreadIdentity object representing the calling thread; guaranteed // to be unique for its lifetime. The returned object will remain valid for the // program's lifetime; although it may be re-assigned to a subsequent thread. @@ -49,6 +54,7 @@ } } // namespace synchronization_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_SYNCHRONIZATION_INTERNAL_CREATE_THREAD_IDENTITY_H_
diff --git a/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc b/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc index 0c8c7564..6a2bcdf 100644 --- a/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +++ b/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc
@@ -44,6 +44,7 @@ // Do not use STL. This module does not use standard memory allocation. namespace absl { +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { namespace { @@ -690,6 +691,7 @@ } } // namespace synchronization_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_LOW_LEVEL_ALLOC_MISSING
diff --git a/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.h b/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.h index e5bde007c..ceba33e4 100644 --- a/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.h +++ b/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.h
@@ -36,11 +36,14 @@ // InsertEdge() is very fast when the edge already exists, and reasonably fast // otherwise. // FindPath() is linear in the size of the graph. -// The current implemenation uses O(|V|+|E|) space. +// The current implementation uses O(|V|+|E|) space. #include <cstdint> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { // Opaque identifier for a graph node. @@ -132,6 +135,7 @@ }; } // namespace synchronization_internal +ABSL_NAMESPACE_END } // namespace absl #endif
diff --git a/third_party/abseil-cpp/absl/synchronization/internal/graphcycles_test.cc b/third_party/abseil-cpp/absl/synchronization/internal/graphcycles_test.cc index 58e8477b..74eaffe 100644 --- a/third_party/abseil-cpp/absl/synchronization/internal/graphcycles_test.cc +++ b/third_party/abseil-cpp/absl/synchronization/internal/graphcycles_test.cc
@@ -25,6 +25,7 @@ #include "absl/base/macros.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { // We emulate a GraphCycles object with a node vector and an edge vector. @@ -459,4 +460,5 @@ } } // namespace synchronization_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h b/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h index 61c72e7..d6ac5db 100644 --- a/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +++ b/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h
@@ -34,6 +34,7 @@ #include "absl/time/time.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { class Futex; @@ -148,6 +149,7 @@ }; } // namespace synchronization_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_SYNCHRONIZATION_INTERNAL_KERNEL_TIMEOUT_H_
diff --git a/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.cc b/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.cc index 267deaf..4590b98d 100644 --- a/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.cc +++ b/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.cc
@@ -31,6 +31,7 @@ #include "absl/time/time.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { namespace { @@ -315,4 +316,5 @@ void RegisterSymbolizer(bool (*)(const void*, char*, int)) {} +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc b/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc index b8d5af7..a1502e72 100644 --- a/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +++ b/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc
@@ -36,6 +36,7 @@ #endif namespace absl { +ABSL_NAMESPACE_BEGIN class Condition; namespace synchronization_internal { @@ -251,9 +252,10 @@ absl::once_flag once_; - // An aligned space for T. - typename std::aligned_storage<sizeof(T), alignof(T)>::type space_; + // An aligned space for the T. + alignas(T) unsigned char space_[sizeof(T)]; }; } // namespace synchronization_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc b/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc index b7014fb..821ca9b 100644 --- a/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +++ b/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc
@@ -25,6 +25,7 @@ #include "absl/synchronization/internal/waiter.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { void PerThreadSem::SetThreadBlockedCounter(std::atomic<int> *counter) { @@ -40,12 +41,16 @@ } void PerThreadSem::Init(base_internal::ThreadIdentity *identity) { - Waiter::GetWaiter(identity)->Init(); + new (Waiter::GetWaiter(identity)) Waiter(); identity->ticker.store(0, std::memory_order_relaxed); identity->wait_start.store(0, std::memory_order_relaxed); identity->is_idle.store(false, std::memory_order_relaxed); } +void PerThreadSem::Destroy(base_internal::ThreadIdentity *identity) { + Waiter::GetWaiter(identity)->~Waiter(); +} + void PerThreadSem::Tick(base_internal::ThreadIdentity *identity) { const int ticker = identity->ticker.fetch_add(1, std::memory_order_relaxed) + 1; @@ -58,6 +63,7 @@ } } // namespace synchronization_internal +ABSL_NAMESPACE_END } // namespace absl extern "C" {
diff --git a/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h b/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h index e7da070..8ab4391 100644 --- a/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +++ b/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h
@@ -32,6 +32,7 @@ #include "absl/synchronization/internal/kernel_timeout.h" namespace absl { +ABSL_NAMESPACE_BEGIN class Mutex; @@ -65,6 +66,10 @@ // REQUIRES: May only be called by ThreadIdentity. static void Init(base_internal::ThreadIdentity* identity); + // Destroy the PerThreadSem associated with "identity". + // REQUIRES: May only be called by ThreadIdentity. + static void Destroy(base_internal::ThreadIdentity* identity); + // Increments "identity"'s count. static inline void Post(base_internal::ThreadIdentity* identity); @@ -77,9 +82,11 @@ friend class PerThreadSemTest; friend class absl::Mutex; friend absl::base_internal::ThreadIdentity* CreateThreadIdentity(); + friend void ReclaimThreadIdentity(void* v); }; } // namespace synchronization_internal +ABSL_NAMESPACE_END } // namespace absl // In some build configurations we pass --detect-odr-violations to the
diff --git a/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem_test.cc b/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem_test.cc index dba7239..b5a2f6d4b 100644 --- a/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem_test.cc +++ b/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem_test.cc
@@ -33,6 +33,7 @@ // primitives which might use PerThreadSem, most notably absl::Mutex. namespace absl { +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { class SimpleSemaphore { @@ -175,4 +176,5 @@ } // namespace } // namespace synchronization_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/synchronization/internal/thread_pool.h b/third_party/abseil-cpp/absl/synchronization/internal/thread_pool.h index a00f2be..0cb96da 100644 --- a/third_party/abseil-cpp/absl/synchronization/internal/thread_pool.h +++ b/third_party/abseil-cpp/absl/synchronization/internal/thread_pool.h
@@ -26,6 +26,7 @@ #include "absl/synchronization/mutex.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { // A simple ThreadPool implementation for tests. @@ -86,6 +87,7 @@ }; } // namespace synchronization_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_SYNCHRONIZATION_INTERNAL_THREAD_POOL_H_
diff --git a/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc b/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc index f17ea56..2949f5a 100644 --- a/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +++ b/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc
@@ -49,6 +49,7 @@ #include "absl/synchronization/internal/kernel_timeout.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { static void MaybeBecomeIdle() { @@ -122,16 +123,21 @@ } }; -void Waiter::Init() { +Waiter::Waiter() { futex_.store(0, std::memory_order_relaxed); } +Waiter::~Waiter() = default; + bool Waiter::Wait(KernelTimeout t) { // Loop until we can atomically decrement futex from a positive // value, waiting on a futex while we believe it is zero. + // Note that, since the thread ticker is just reset, we don't need to check + // whether the thread is idle on the very first pass of the loop. + bool first_pass = true; while (true) { int32_t x = futex_.load(std::memory_order_relaxed); - if (x != 0) { + while (x != 0) { if (!futex_.compare_exchange_weak(x, x - 1, std::memory_order_acquire, std::memory_order_relaxed)) { @@ -140,6 +146,8 @@ return true; // Consumed a wakeup, we are done. } + + if (!first_pass) MaybeBecomeIdle(); const int err = Futex::WaitUntil(&futex_, 0, t); if (err != 0) { if (err == -EINTR || err == -EWOULDBLOCK) { @@ -150,14 +158,13 @@ ABSL_RAW_LOG(FATAL, "Futex operation failed with error %d\n", err); } } - - MaybeBecomeIdle(); + first_pass = false; } } void Waiter::Post() { if (futex_.fetch_add(1, std::memory_order_release) == 0) { - // We incremented from 0, need to wake a potential waker. + // We incremented from 0, need to wake a potential waiter. Poke(); } } @@ -195,7 +202,7 @@ pthread_mutex_t *mu_; }; -void Waiter::Init() { +Waiter::Waiter() { const int err = pthread_mutex_init(&mu_, 0); if (err != 0) { ABSL_RAW_LOG(FATAL, "pthread_mutex_init failed: %d", err); @@ -206,8 +213,20 @@ ABSL_RAW_LOG(FATAL, "pthread_cond_init failed: %d", err2); } - waiter_count_.store(0, std::memory_order_relaxed); - wakeup_count_.store(0, std::memory_order_relaxed); + waiter_count_ = 0; + wakeup_count_ = 0; +} + +Waiter::~Waiter() { + const int err = pthread_mutex_destroy(&mu_); + if (err != 0) { + ABSL_RAW_LOG(FATAL, "pthread_mutex_destroy failed: %d", err); + } + + const int err2 = pthread_cond_destroy(&cv_); + if (err2 != 0) { + ABSL_RAW_LOG(FATAL, "pthread_cond_destroy failed: %d", err2); + } } bool Waiter::Wait(KernelTimeout t) { @@ -217,21 +236,13 @@ } PthreadMutexHolder h(&mu_); - waiter_count_.fetch_add(1, std::memory_order_relaxed); + ++waiter_count_; // Loop until we find a wakeup to consume or timeout. - while (true) { - int x = wakeup_count_.load(std::memory_order_relaxed); - if (x != 0) { - if (!wakeup_count_.compare_exchange_weak(x, x - 1, - std::memory_order_acquire, - std::memory_order_relaxed)) { - continue; // Raced with someone, retry. - } - // Successfully consumed a wakeup, we're done. - waiter_count_.fetch_sub(1, std::memory_order_relaxed); - return true; - } - + // Note that, since the thread ticker is just reset, we don't need to check + // whether the thread is idle on the very first pass of the loop. + bool first_pass = true; + while (wakeup_count_ == 0) { + if (!first_pass) MaybeBecomeIdle(); // No wakeups available, time to wait. if (!t.has_timeout()) { const int err = pthread_cond_wait(&cv_, &mu_); @@ -241,46 +252,56 @@ } else { const int err = pthread_cond_timedwait(&cv_, &mu_, &abs_timeout); if (err == ETIMEDOUT) { - waiter_count_.fetch_sub(1, std::memory_order_relaxed); + --waiter_count_; return false; } if (err != 0) { - ABSL_RAW_LOG(FATAL, "pthread_cond_wait failed: %d", err); + ABSL_RAW_LOG(FATAL, "pthread_cond_timedwait failed: %d", err); } } - MaybeBecomeIdle(); + first_pass = false; } + // Consume a wakeup and we're done. + --wakeup_count_; + --waiter_count_; + return true; } void Waiter::Post() { - wakeup_count_.fetch_add(1, std::memory_order_release); - Poke(); + PthreadMutexHolder h(&mu_); + ++wakeup_count_; + InternalCondVarPoke(); } void Waiter::Poke() { - if (waiter_count_.load(std::memory_order_relaxed) == 0) { - return; - } - // Potentially a waker. Take the lock and check again. PthreadMutexHolder h(&mu_); - if (waiter_count_.load(std::memory_order_relaxed) == 0) { - return; - } - const int err = pthread_cond_signal(&cv_); - if (err != 0) { - ABSL_RAW_LOG(FATAL, "pthread_cond_signal failed: %d", err); + InternalCondVarPoke(); +} + +void Waiter::InternalCondVarPoke() { + if (waiter_count_ != 0) { + const int err = pthread_cond_signal(&cv_); + if (ABSL_PREDICT_FALSE(err != 0)) { + ABSL_RAW_LOG(FATAL, "pthread_cond_signal failed: %d", err); + } } } #elif ABSL_WAITER_MODE == ABSL_WAITER_MODE_SEM -void Waiter::Init() { +Waiter::Waiter() { if (sem_init(&sem_, 0, 0) != 0) { ABSL_RAW_LOG(FATAL, "sem_init failed with errno %d\n", errno); } wakeups_.store(0, std::memory_order_relaxed); } +Waiter::~Waiter() { + if (sem_destroy(&sem_) != 0) { + ABSL_RAW_LOG(FATAL, "sem_destroy failed with errno %d\n", errno); + } +} + bool Waiter::Wait(KernelTimeout t) { struct timespec abs_timeout; if (t.has_timeout()) { @@ -288,9 +309,12 @@ } // Loop until we timeout or consume a wakeup. + // Note that, since the thread ticker is just reset, we don't need to check + // whether the thread is idle on the very first pass of the loop. + bool first_pass = true; while (true) { int x = wakeups_.load(std::memory_order_relaxed); - if (x != 0) { + while (x != 0) { if (!wakeups_.compare_exchange_weak(x, x - 1, std::memory_order_acquire, std::memory_order_relaxed)) { @@ -300,6 +324,7 @@ return true; } + if (!first_pass) MaybeBecomeIdle(); // Nothing to consume, wait (looping on EINTR). while (true) { if (!t.has_timeout()) { @@ -313,13 +338,16 @@ ABSL_RAW_LOG(FATAL, "sem_timedwait failed: %d", errno); } } - MaybeBecomeIdle(); + first_pass = false; } } void Waiter::Post() { - wakeups_.fetch_add(1, std::memory_order_release); // Post a wakeup. - Poke(); + // Post a wakeup. + if (wakeups_.fetch_add(1, std::memory_order_release) == 0) { + // We incremented from 0, need to wake a potential waiter. + Poke(); + } } void Waiter::Poke() { @@ -340,31 +368,29 @@ return reinterpret_cast<CONDITION_VARIABLE *>(&w->cv_storage_); } - static_assert(sizeof(SRWLOCK) == sizeof(Waiter::SRWLockStorage), - "SRWLockStorage does not have the same size as SRWLOCK"); + static_assert(sizeof(SRWLOCK) == sizeof(void *), + "`mu_storage_` does not have the same size as SRWLOCK"); + static_assert(alignof(SRWLOCK) == alignof(void *), + "`mu_storage_` does not have the same alignment as SRWLOCK"); + + static_assert(sizeof(CONDITION_VARIABLE) == sizeof(void *), + "`ABSL_CONDITION_VARIABLE_STORAGE` does not have the same size " + "as `CONDITION_VARIABLE`"); static_assert( - alignof(SRWLOCK) == alignof(Waiter::SRWLockStorage), - "SRWLockStorage does not have the same alignment as SRWLOCK"); + alignof(CONDITION_VARIABLE) == alignof(void *), + "`cv_storage_` does not have the same alignment as `CONDITION_VARIABLE`"); - static_assert(sizeof(CONDITION_VARIABLE) == - sizeof(Waiter::ConditionVariableStorage), - "ABSL_CONDITION_VARIABLE_STORAGE does not have the same size " - "as CONDITION_VARIABLE"); - static_assert(alignof(CONDITION_VARIABLE) == - alignof(Waiter::ConditionVariableStorage), - "ConditionVariableStorage does not have the same " - "alignment as CONDITION_VARIABLE"); - - // The SRWLOCK and CONDITION_VARIABLE types must be trivially constuctible + // The SRWLOCK and CONDITION_VARIABLE types must be trivially constructible // and destructible because we never call their constructors or destructors. static_assert(std::is_trivially_constructible<SRWLOCK>::value, - "The SRWLOCK type must be trivially constructible"); - static_assert(std::is_trivially_constructible<CONDITION_VARIABLE>::value, - "The CONDITION_VARIABLE type must be trivially constructible"); + "The `SRWLOCK` type must be trivially constructible"); + static_assert( + std::is_trivially_constructible<CONDITION_VARIABLE>::value, + "The `CONDITION_VARIABLE` type must be trivially constructible"); static_assert(std::is_trivially_destructible<SRWLOCK>::value, - "The SRWLOCK type must be trivially destructible"); + "The `SRWLOCK` type must be trivially destructible"); static_assert(std::is_trivially_destructible<CONDITION_VARIABLE>::value, - "The CONDITION_VARIABLE type must be trivially destructible"); + "The `CONDITION_VARIABLE` type must be trivially destructible"); }; class LockHolder { @@ -384,36 +410,33 @@ SRWLOCK* mu_; }; -void Waiter::Init() { +Waiter::Waiter() { auto *mu = ::new (static_cast<void *>(&mu_storage_)) SRWLOCK; auto *cv = ::new (static_cast<void *>(&cv_storage_)) CONDITION_VARIABLE; InitializeSRWLock(mu); InitializeConditionVariable(cv); - waiter_count_.store(0, std::memory_order_relaxed); - wakeup_count_.store(0, std::memory_order_relaxed); + waiter_count_ = 0; + wakeup_count_ = 0; } +// SRW locks and condition variables do not need to be explicitly destroyed. +// https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-initializesrwlock +// https://stackoverflow.com/questions/28975958/why-does-windows-have-no-deleteconditionvariable-function-to-go-together-with +Waiter::~Waiter() = default; + bool Waiter::Wait(KernelTimeout t) { SRWLOCK *mu = WinHelper::GetLock(this); CONDITION_VARIABLE *cv = WinHelper::GetCond(this); LockHolder h(mu); - waiter_count_.fetch_add(1, std::memory_order_relaxed); + ++waiter_count_; // Loop until we find a wakeup to consume or timeout. - while (true) { - int x = wakeup_count_.load(std::memory_order_relaxed); - if (x != 0) { - if (!wakeup_count_.compare_exchange_weak(x, x - 1, - std::memory_order_acquire, - std::memory_order_relaxed)) { - continue; // Raced with someone, retry. - } - // Successfully consumed a wakeup, we're done. - waiter_count_.fetch_sub(1, std::memory_order_relaxed); - return true; - } - + // Note that, since the thread ticker is just reset, we don't need to check + // whether the thread is idle on the very first pass of the loop. + bool first_pass = true; + while (wakeup_count_ == 0) { + if (!first_pass) MaybeBecomeIdle(); // No wakeups available, time to wait. if (!SleepConditionVariableSRW(cv, mu, t.InMillisecondsFromNow(), 0)) { // GetLastError() returns a Win32 DWORD, but we assign to @@ -421,32 +444,35 @@ // initialization guarantees this is not a narrowing conversion. const unsigned long err{GetLastError()}; // NOLINT(runtime/int) if (err == ERROR_TIMEOUT) { - waiter_count_.fetch_sub(1, std::memory_order_relaxed); + --waiter_count_; return false; } else { ABSL_RAW_LOG(FATAL, "SleepConditionVariableSRW failed: %lu", err); } } - - MaybeBecomeIdle(); + first_pass = false; } + // Consume a wakeup and we're done. + --wakeup_count_; + --waiter_count_; + return true; } void Waiter::Post() { - wakeup_count_.fetch_add(1, std::memory_order_release); - Poke(); + LockHolder h(WinHelper::GetLock(this)); + ++wakeup_count_; + InternalCondVarPoke(); } void Waiter::Poke() { - if (waiter_count_.load(std::memory_order_relaxed) == 0) { - return; - } - // Potentially a waker. Take the lock and check again. LockHolder h(WinHelper::GetLock(this)); - if (waiter_count_.load(std::memory_order_relaxed) == 0) { - return; + InternalCondVarPoke(); +} + +void Waiter::InternalCondVarPoke() { + if (waiter_count_ != 0) { + WakeConditionVariable(WinHelper::GetCond(this)); } - WakeConditionVariable(WinHelper::GetCond(this)); } #else @@ -454,4 +480,5 @@ #endif } // namespace synchronization_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/synchronization/internal/waiter.h b/third_party/abseil-cpp/absl/synchronization/internal/waiter.h index a3e3124..a6e6d4c 100644 --- a/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +++ b/third_party/abseil-cpp/absl/synchronization/internal/waiter.h
@@ -18,10 +18,16 @@ #include "absl/base/config.h" -#ifndef _WIN32 +#ifdef _WIN32 +#include <sdkddkver.h> +#else #include <pthread.h> #endif +#ifdef __linux__ +#include <linux/futex.h> +#endif + #ifdef ABSL_HAVE_SEMAPHORE_H #include <semaphore.h> #endif @@ -40,9 +46,14 @@ #if defined(ABSL_FORCE_WAITER_MODE) #define ABSL_WAITER_MODE ABSL_FORCE_WAITER_MODE -#elif defined(_WIN32) +#elif defined(_WIN32) && _WIN32_WINNT >= _WIN32_WINNT_VISTA #define ABSL_WAITER_MODE ABSL_WAITER_MODE_WIN32 -#elif defined(__linux__) +#elif defined(__BIONIC__) +// Bionic supports all the futex operations we need even when some of the futex +// definitions are missing. +#define ABSL_WAITER_MODE ABSL_WAITER_MODE_FUTEX +#elif defined(__linux__) && defined(FUTEX_CLOCK_REALTIME) +// FUTEX_CLOCK_REALTIME requires Linux >= 2.6.28. #define ABSL_WAITER_MODE ABSL_WAITER_MODE_FUTEX #elif defined(ABSL_HAVE_SEMAPHORE_H) #define ABSL_WAITER_MODE ABSL_WAITER_MODE_SEM @@ -51,19 +62,21 @@ #endif namespace absl { +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { // Waiter is an OS-specific semaphore. class Waiter { public: - // No constructor, instances use the reserved space in ThreadIdentity. - // All initialization logic belongs in `Init()`. - Waiter() = delete; + // Prepare any data to track waits. + Waiter(); + + // Not copyable or movable Waiter(const Waiter&) = delete; Waiter& operator=(const Waiter&) = delete; - // Prepare any data to track waits. - void Init(); + // Destroy any data to track waits. + ~Waiter(); // Blocks the calling thread until a matching call to `Post()` or // `t` has passed. Returns `true` if woken (`Post()` called), @@ -104,10 +117,13 @@ static_assert(sizeof(int32_t) == sizeof(futex_), "Wrong size for futex"); #elif ABSL_WAITER_MODE == ABSL_WAITER_MODE_CONDVAR + // REQUIRES: mu_ must be held. + void InternalCondVarPoke(); + pthread_mutex_t mu_; pthread_cond_t cv_; - std::atomic<int> waiter_count_; - std::atomic<int> wakeup_count_; // Unclaimed wakeups, written under lock. + int waiter_count_; + int wakeup_count_; // Unclaimed wakeups. #elif ABSL_WAITER_MODE == ABSL_WAITER_MODE_SEM sem_t sem_; @@ -117,26 +133,19 @@ std::atomic<int> wakeups_; #elif ABSL_WAITER_MODE == ABSL_WAITER_MODE_WIN32 - // The Windows API has lots of choices for synchronization - // primivitives. We are using SRWLOCK and CONDITION_VARIABLE - // because they don't require a destructor to release system - // resources. - // - // However, we can't include Windows.h in our headers, so we use aligned - // storage buffers to define the storage. - using SRWLockStorage = - typename std::aligned_storage<sizeof(void*), alignof(void*)>::type; - using ConditionVariableStorage = - typename std::aligned_storage<sizeof(void*), alignof(void*)>::type; - // WinHelper - Used to define utilities for accessing the lock and // condition variable storage once the types are complete. class WinHelper; - SRWLockStorage mu_storage_; - ConditionVariableStorage cv_storage_; - std::atomic<int> waiter_count_; - std::atomic<int> wakeup_count_; + // REQUIRES: WinHelper::GetLock(this) must be held. + void InternalCondVarPoke(); + + // We can't include Windows.h in our headers, so we use aligned charachter + // buffers to define the storage of SRWLOCK and CONDITION_VARIABLE. + alignas(void*) unsigned char mu_storage_[sizeof(void*)]; + alignas(void*) unsigned char cv_storage_[sizeof(void*)]; + int waiter_count_; + int wakeup_count_; #else #error Unknown ABSL_WAITER_MODE @@ -144,6 +153,7 @@ }; } // namespace synchronization_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_SYNCHRONIZATION_INTERNAL_WAITER_H_
diff --git a/third_party/abseil-cpp/absl/synchronization/lifetime_test.cc b/third_party/abseil-cpp/absl/synchronization/lifetime_test.cc index 34b8875..cc973a3 100644 --- a/third_party/abseil-cpp/absl/synchronization/lifetime_test.cc +++ b/third_party/abseil-cpp/absl/synchronization/lifetime_test.cc
@@ -122,6 +122,11 @@ Function fn_; }; +// These tests require that the compiler correctly supports C++11 constant +// initialization... but MSVC has a known regression since v19.10: +// https://developercommunity.visualstudio.com/content/problem/336946/class-with-constexpr-constructor-not-using-static.html +// TODO(epastor): Limit the affected range once MSVC fixes this bug. +#if defined(__clang__) || !(defined(_MSC_VER) && _MSC_VER > 1900) // kConstInit // Test early usage. (Declaration comes first; definitions must appear after // the test runner.) @@ -151,6 +156,7 @@ const_init_sanity_mutex.AssertHeld(); const_init_sanity_mutex.Unlock(); }); +#endif // defined(__clang__) || !(defined(_MSC_VER) && _MSC_VER > 1900) // Test shutdown usage. (Declarations come first; definitions must appear after // the test runner.)
diff --git a/third_party/abseil-cpp/absl/synchronization/mutex.cc b/third_party/abseil-cpp/absl/synchronization/mutex.cc index acac740..bf6079f 100644 --- a/third_party/abseil-cpp/absl/synchronization/mutex.cc +++ b/third_party/abseil-cpp/absl/synchronization/mutex.cc
@@ -71,6 +71,7 @@ } // extern "C" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { @@ -106,13 +107,16 @@ sizeof(MutexGlobals) == ABSL_CACHELINE_SIZE, "MutexGlobals must occupy an entire cacheline to prevent false sharing"); -ABSL_CONST_INIT absl::base_internal::AtomicHook<void (*)(int64_t wait_cycles)> - submit_profile_data; -ABSL_CONST_INIT absl::base_internal::AtomicHook< - void (*)(const char *msg, const void *obj, int64_t wait_cycles)> mutex_tracer; -ABSL_CONST_INIT absl::base_internal::AtomicHook< - void (*)(const char *msg, const void *cv)> cond_var_tracer; -ABSL_CONST_INIT absl::base_internal::AtomicHook< +ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES + absl::base_internal::AtomicHook<void (*)(int64_t wait_cycles)> + submit_profile_data; +ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES absl::base_internal::AtomicHook<void (*)( + const char *msg, const void *obj, int64_t wait_cycles)> + mutex_tracer; +ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES + absl::base_internal::AtomicHook<void (*)(const char *msg, const void *cv)> + cond_var_tracer; +ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES absl::base_internal::AtomicHook< bool (*)(const void *pc, char *out, int out_size)> symbolizer(absl::Symbolize); @@ -295,8 +299,8 @@ bool log; // logging turned on // Constant after initialization - char name[1]; // actually longer---null-terminated std::string -} *synch_event[kNSynchEvent] ABSL_GUARDED_BY(synch_event_mu); + char name[1]; // actually longer---NUL-terminated string +} * synch_event[kNSynchEvent] ABSL_GUARDED_BY(synch_event_mu); // Ensure that the object at "addr" has a SynchEvent struct associated with it, // set "bits" in the word there (waiting until lockbit is clear before doing @@ -2720,4 +2724,5 @@ a->arg_ == b->arg_ && a->method_ == b->method_; } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/synchronization/mutex.h b/third_party/abseil-cpp/absl/synchronization/mutex.h index af770e85..8c70c4c 100644 --- a/third_party/abseil-cpp/absl/synchronization/mutex.h +++ b/third_party/abseil-cpp/absl/synchronization/mutex.h
@@ -82,6 +82,7 @@ #endif namespace absl { +ABSL_NAMESPACE_BEGIN class Condition; struct SynchWaitParams; @@ -558,8 +559,7 @@ // releases a shared lock on a `Mutex` via RAII. class ABSL_SCOPED_LOCKABLE ReaderMutexLock { public: - explicit ReaderMutexLock(Mutex *mu) ABSL_SHARED_LOCK_FUNCTION(mu) - : mu_(mu) { + explicit ReaderMutexLock(Mutex *mu) ABSL_SHARED_LOCK_FUNCTION(mu) : mu_(mu) { mu->ReaderLock(); } @@ -568,9 +568,7 @@ ReaderMutexLock& operator=(const ReaderMutexLock&) = delete; ReaderMutexLock& operator=(ReaderMutexLock&&) = delete; - ~ReaderMutexLock() ABSL_UNLOCK_FUNCTION() { - this->mu_->ReaderUnlock(); - } + ~ReaderMutexLock() ABSL_UNLOCK_FUNCTION() { this->mu_->ReaderUnlock(); } private: Mutex *const mu_; @@ -592,9 +590,7 @@ WriterMutexLock& operator=(const WriterMutexLock&) = delete; WriterMutexLock& operator=(WriterMutexLock&&) = delete; - ~WriterMutexLock() ABSL_UNLOCK_FUNCTION() { - this->mu_->WriterUnlock(); - } + ~WriterMutexLock() ABSL_UNLOCK_FUNCTION() { this->mu_->WriterUnlock(); } private: Mutex *const mu_; @@ -863,10 +859,15 @@ class ABSL_SCOPED_LOCKABLE MutexLockMaybe { public: explicit MutexLockMaybe(Mutex *mu) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu) - : mu_(mu) { if (this->mu_ != nullptr) { this->mu_->Lock(); } } + : mu_(mu) { + if (this->mu_ != nullptr) { + this->mu_->Lock(); + } + } ~MutexLockMaybe() ABSL_UNLOCK_FUNCTION() { if (this->mu_ != nullptr) { this->mu_->Unlock(); } } + private: Mutex *const mu_; MutexLockMaybe(const MutexLockMaybe&) = delete; @@ -1000,7 +1001,7 @@ // // 'pc' is the program counter being symbolized, 'out' is the buffer to write // into, and 'out_size' is the size of the buffer. This function can return -// false if symbolizing failed, or true if a null-terminated symbol was written +// false if symbolizing failed, or true if a NUL-terminated symbol was written // to 'out.' // // This has the same memory ordering concerns as RegisterMutexProfiler() above. @@ -1039,6 +1040,7 @@ // the manner chosen here. void SetMutexDeadlockDetectionMode(OnDeadlockCycle mode); +ABSL_NAMESPACE_END } // namespace absl // In some build configurations we pass --detect-odr-violations to the
diff --git a/third_party/abseil-cpp/absl/synchronization/notification.cc b/third_party/abseil-cpp/absl/synchronization/notification.cc index 53ace008..e91b903 100644 --- a/third_party/abseil-cpp/absl/synchronization/notification.cc +++ b/third_party/abseil-cpp/absl/synchronization/notification.cc
@@ -22,6 +22,7 @@ #include "absl/time/time.h" namespace absl { +ABSL_NAMESPACE_BEGIN void Notification::Notify() { MutexLock l(&this->mutex_); @@ -44,15 +45,6 @@ MutexLock l(&this->mutex_); } -static inline bool HasBeenNotifiedInternal( - const std::atomic<bool> *notified_yet) { - return notified_yet->load(std::memory_order_acquire); -} - -bool Notification::HasBeenNotified() const { - return HasBeenNotifiedInternal(&this->notified_yet_); -} - void Notification::WaitForNotification() const { if (!HasBeenNotifiedInternal(&this->notified_yet_)) { this->mutex_.LockWhen(Condition(&HasBeenNotifiedInternal, @@ -82,4 +74,5 @@ return notified; } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/synchronization/notification.h b/third_party/abseil-cpp/absl/synchronization/notification.h index 82d111a..9a354ca 100644 --- a/third_party/abseil-cpp/absl/synchronization/notification.h +++ b/third_party/abseil-cpp/absl/synchronization/notification.h
@@ -57,6 +57,7 @@ #include "absl/time/time.h" namespace absl { +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // Notification @@ -73,7 +74,9 @@ // Notification::HasBeenNotified() // // Returns the value of the notification's internal "notified" state. - bool HasBeenNotified() const; + bool HasBeenNotified() const { + return HasBeenNotifiedInternal(&this->notified_yet_); + } // Notification::WaitForNotification() // @@ -105,10 +108,16 @@ void Notify(); private: + static inline bool HasBeenNotifiedInternal( + const std::atomic<bool>* notified_yet) { + return notified_yet->load(std::memory_order_acquire); + } + mutable Mutex mutex_; std::atomic<bool> notified_yet_; // written under mutex_ }; +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_SYNCHRONIZATION_NOTIFICATION_H_
diff --git a/third_party/abseil-cpp/absl/synchronization/notification_test.cc b/third_party/abseil-cpp/absl/synchronization/notification_test.cc index 059d4cd2..100ea76 100644 --- a/third_party/abseil-cpp/absl/synchronization/notification_test.cc +++ b/third_party/abseil-cpp/absl/synchronization/notification_test.cc
@@ -21,6 +21,7 @@ #include "absl/synchronization/mutex.h" namespace absl { +ABSL_NAMESPACE_BEGIN // A thread-safe class that holds a counter. class ThreadSafeCounter { @@ -128,4 +129,5 @@ BasicTests(true, &local_notification2); } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/BUILD.bazel b/third_party/abseil-cpp/absl/time/BUILD.bazel index 55e83a8c..9ab2adb8 100644 --- a/third_party/abseil-cpp/absl/time/BUILD.bazel +++ b/third_party/abseil-cpp/absl/time/BUILD.bazel
@@ -14,6 +14,7 @@ # limitations under the License. # +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", @@ -46,6 +47,7 @@ deps = [ "//absl/base", "//absl/base:core_headers", + "//absl/base:raw_logging_internal", "//absl/numeric:int128", "//absl/strings", "//absl/time/internal/cctz:civil_time", @@ -68,7 +70,7 @@ ], deps = [ ":time", - "//absl/base", + "//absl/base:raw_logging_internal", "//absl/time/internal/cctz:time_zone", "@com_google_googletest//:gtest", ], @@ -89,9 +91,9 @@ deps = [ ":test_util", ":time", - "//absl/base", "//absl/base:config", "//absl/base:core_headers", + "//absl/numeric:int128", "//absl/time/internal/cctz:time_zone", "@com_google_googletest//:gtest_main", ],
diff --git a/third_party/abseil-cpp/absl/time/BUILD.gn b/third_party/abseil-cpp/absl/time/BUILD.gn index 2b10fd4..cce8921 100644 --- a/third_party/abseil-cpp/absl/time/BUILD.gn +++ b/third_party/abseil-cpp/absl/time/BUILD.gn
@@ -41,6 +41,7 @@ deps = [ "../base", "../base:core_headers", + "../base:raw_logging_internal", "../numeric:int128", "../strings", "../time/internal/cctz:civil_time", @@ -63,7 +64,7 @@ public = [ "internal/test_util.h" ] deps = [ ":time", - "../base", + "../base:raw_logging_internal", "../time/internal/cctz:time_zone", "//testing/gmock", "//testing/gtest",
diff --git a/third_party/abseil-cpp/absl/time/CMakeLists.txt b/third_party/abseil-cpp/absl/time/CMakeLists.txt index 59098321..853563e 100644 --- a/third_party/abseil-cpp/absl/time/CMakeLists.txt +++ b/third_party/abseil-cpp/absl/time/CMakeLists.txt
@@ -22,21 +22,22 @@ "clock.h" "time.h" SRCS - "civil_time.cc" - "clock.cc" - "duration.cc" - "format.cc" - "internal/get_current_time_chrono.inc" - "internal/get_current_time_posix.inc" - "time.cc" + "civil_time.cc" + "clock.cc" + "duration.cc" + "format.cc" + "internal/get_current_time_chrono.inc" + "internal/get_current_time_posix.inc" + "time.cc" COPTS ${ABSL_DEFAULT_COPTS} DEPS absl::base + absl::civil_time absl::core_headers absl::int128 + absl::raw_logging_internal absl::strings - absl::civil_time absl::time_zone PUBLIC ) @@ -88,7 +89,7 @@ absl_cc_library( NAME - test_util + time_internal_test_util HDRS "internal/test_util.h" SRCS @@ -98,7 +99,7 @@ ${ABSL_DEFAULT_COPTS} DEPS absl::time - absl::base + absl::raw_logging_internal absl::time_zone gmock TESTONLY @@ -117,9 +118,8 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::test_util + absl::time_internal_test_util absl::time - absl::base absl::config absl::core_headers absl::time_zone
diff --git a/third_party/abseil-cpp/absl/time/civil_time.cc b/third_party/abseil-cpp/absl/time/civil_time.cc index 7527fc11..c4202c7 100644 --- a/third_party/abseil-cpp/absl/time/civil_time.cc +++ b/third_party/abseil-cpp/absl/time/civil_time.cc
@@ -21,6 +21,7 @@ #include "absl/time/time.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { @@ -37,11 +38,63 @@ const CivilSecond ncs(NormalizeYear(cs.year()), cs.month(), cs.day(), cs.hour(), cs.minute(), cs.second()); const TimeZone utc = UTCTimeZone(); - // TODO(absl-team): Avoid conversion of fmt std::string. + // TODO(absl-team): Avoid conversion of fmt string. return StrCat(cs.year(), FormatTime(std::string(fmt), FromCivil(ncs, utc), utc)); } +template <typename CivilT> +bool ParseYearAnd(string_view fmt, string_view s, CivilT* c) { + // Civil times support a larger year range than absl::Time, so we need to + // parse the year separately, normalize it, then use absl::ParseTime on the + // normalized string. + const std::string ss = std::string(s); // TODO(absl-team): Avoid conversion. + const char* const np = ss.c_str(); + char* endp; + errno = 0; + const civil_year_t y = + std::strtoll(np, &endp, 10); // NOLINT(runtime/deprecated_fn) + if (endp == np || errno == ERANGE) return false; + const std::string norm = StrCat(NormalizeYear(y), endp); + + const TimeZone utc = UTCTimeZone(); + Time t; + if (ParseTime(StrCat("%Y", fmt), norm, utc, &t, nullptr)) { + const auto cs = ToCivilSecond(t, utc); + *c = CivilT(y, cs.month(), cs.day(), cs.hour(), cs.minute(), cs.second()); + return true; + } + + return false; +} + +// Tries to parse the type as a CivilT1, but then assigns the result to the +// argument of type CivilT2. +template <typename CivilT1, typename CivilT2> +bool ParseAs(string_view s, CivilT2* c) { + CivilT1 t1; + if (ParseCivilTime(s, &t1)) { + *c = CivilT2(t1); + return true; + } + return false; +} + +template <typename CivilT> +bool ParseLenient(string_view s, CivilT* c) { + // A fastpath for when the given string data parses exactly into the given + // type T (e.g., s="YYYY-MM-DD" and CivilT=CivilDay). + if (ParseCivilTime(s, c)) return true; + // Try parsing as each of the 6 types, trying the most common types first + // (based on csearch results). + if (ParseAs<CivilDay>(s, c)) return true; + if (ParseAs<CivilSecond>(s, c)) return true; + if (ParseAs<CivilHour>(s, c)) return true; + if (ParseAs<CivilMonth>(s, c)) return true; + if (ParseAs<CivilMinute>(s, c)) return true; + if (ParseAs<CivilYear>(s, c)) return true; + return false; +} } // namespace std::string FormatCivilTime(CivilSecond c) { @@ -57,6 +110,44 @@ std::string FormatCivilTime(CivilMonth c) { return FormatYearAnd("-%m", c); } std::string FormatCivilTime(CivilYear c) { return FormatYearAnd("", c); } +bool ParseCivilTime(string_view s, CivilSecond* c) { + return ParseYearAnd("-%m-%dT%H:%M:%S", s, c); +} +bool ParseCivilTime(string_view s, CivilMinute* c) { + return ParseYearAnd("-%m-%dT%H:%M", s, c); +} +bool ParseCivilTime(string_view s, CivilHour* c) { + return ParseYearAnd("-%m-%dT%H", s, c); +} +bool ParseCivilTime(string_view s, CivilDay* c) { + return ParseYearAnd("-%m-%d", s, c); +} +bool ParseCivilTime(string_view s, CivilMonth* c) { + return ParseYearAnd("-%m", s, c); +} +bool ParseCivilTime(string_view s, CivilYear* c) { + return ParseYearAnd("", s, c); +} + +bool ParseLenientCivilTime(string_view s, CivilSecond* c) { + return ParseLenient(s, c); +} +bool ParseLenientCivilTime(string_view s, CivilMinute* c) { + return ParseLenient(s, c); +} +bool ParseLenientCivilTime(string_view s, CivilHour* c) { + return ParseLenient(s, c); +} +bool ParseLenientCivilTime(string_view s, CivilDay* c) { + return ParseLenient(s, c); +} +bool ParseLenientCivilTime(string_view s, CivilMonth* c) { + return ParseLenient(s, c); +} +bool ParseLenientCivilTime(string_view s, CivilYear* c) { + return ParseLenient(s, c); +} + namespace time_internal { std::ostream& operator<<(std::ostream& os, CivilYear y) { @@ -80,4 +171,5 @@ } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/civil_time.h b/third_party/abseil-cpp/absl/time/civil_time.h index beaf7d8..bb46004 100644 --- a/third_party/abseil-cpp/absl/time/civil_time.h +++ b/third_party/abseil-cpp/absl/time/civil_time.h
@@ -76,6 +76,7 @@ #include "absl/time/internal/cctz/include/cctz/civil_time.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { struct second_tag : cctz::detail::second_tag {}; @@ -247,7 +248,7 @@ // int minute() // int second() // -// Recall that fields inferior to the type's aligment will be set to their +// Recall that fields inferior to the type's alignment will be set to their // minimum valid value. // // Example: @@ -459,6 +460,57 @@ std::string FormatCivilTime(CivilMonth c); std::string FormatCivilTime(CivilYear c); +// absl::ParseCivilTime() +// +// Parses a civil-time value from the specified `absl::string_view` into the +// passed output parameter. Returns `true` upon successful parsing. +// +// The expected form of the input string is as follows: +// +// Type | Format +// --------------------------------- +// CivilSecond | YYYY-MM-DDTHH:MM:SS +// CivilMinute | YYYY-MM-DDTHH:MM +// CivilHour | YYYY-MM-DDTHH +// CivilDay | YYYY-MM-DD +// CivilMonth | YYYY-MM +// CivilYear | YYYY +// +// Example: +// +// absl::CivilDay d; +// bool ok = absl::ParseCivilTime("2018-01-02", &d); // OK +// +// Note that parsing will fail if the string's format does not match the +// expected type exactly. `ParseLenientCivilTime()` below is more lenient. +// +bool ParseCivilTime(absl::string_view s, CivilSecond* c); +bool ParseCivilTime(absl::string_view s, CivilMinute* c); +bool ParseCivilTime(absl::string_view s, CivilHour* c); +bool ParseCivilTime(absl::string_view s, CivilDay* c); +bool ParseCivilTime(absl::string_view s, CivilMonth* c); +bool ParseCivilTime(absl::string_view s, CivilYear* c); + +// ParseLenientCivilTime() +// +// Parses any of the formats accepted by `absl::ParseCivilTime()`, but is more +// lenient if the format of the string does not exactly match the associated +// type. +// +// Example: +// +// absl::CivilDay d; +// bool ok = absl::ParseLenientCivilTime("1969-07-20", &d); // OK +// ok = absl::ParseLenientCivilTime("1969-07-20T10", &d); // OK: T10 floored +// ok = absl::ParseLenientCivilTime("1969-07", &d); // OK: day defaults to 1 +// +bool ParseLenientCivilTime(absl::string_view s, CivilSecond* c); +bool ParseLenientCivilTime(absl::string_view s, CivilMinute* c); +bool ParseLenientCivilTime(absl::string_view s, CivilHour* c); +bool ParseLenientCivilTime(absl::string_view s, CivilDay* c); +bool ParseLenientCivilTime(absl::string_view s, CivilMonth* c); +bool ParseLenientCivilTime(absl::string_view s, CivilYear* c); + namespace time_internal { // For functions found via ADL on civil-time tags. // Streaming Operators @@ -468,7 +520,7 @@ // // Example: // -// absl::CivilDay d = absl::CivilDay("1969-07-20"); +// absl::CivilDay d = absl::CivilDay(1969, 7, 20); // std::cout << "Date is: " << d << "\n"; // std::ostream& operator<<(std::ostream& os, CivilYear y); @@ -480,6 +532,7 @@ } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TIME_CIVIL_TIME_H_
diff --git a/third_party/abseil-cpp/absl/time/civil_time_benchmark.cc b/third_party/abseil-cpp/absl/time/civil_time_benchmark.cc index 40869835..f04dbe2 100644 --- a/third_party/abseil-cpp/absl/time/civil_time_benchmark.cc +++ b/third_party/abseil-cpp/absl/time/civil_time_benchmark.cc
@@ -66,6 +66,26 @@ } BENCHMARK(BM_Format); +void BM_Parse(benchmark::State& state) { + const std::string f = "2014-01-02T03:04:05"; + absl::CivilSecond c; + while (state.KeepRunning()) { + const bool b = absl::ParseCivilTime(f, &c); + benchmark::DoNotOptimize(b); + } +} +BENCHMARK(BM_Parse); + +void BM_RoundTripFormatParse(benchmark::State& state) { + const absl::CivilSecond c(2014, 1, 2, 3, 4, 5); + absl::CivilSecond out; + while (state.KeepRunning()) { + const bool b = absl::ParseCivilTime(absl::FormatCivilTime(c), &out); + benchmark::DoNotOptimize(b); + } +} +BENCHMARK(BM_RoundTripFormatParse); + template <typename T> void BM_CivilTimeAbslHash(benchmark::State& state) { const int kSize = 100000;
diff --git a/third_party/abseil-cpp/absl/time/civil_time_test.cc b/third_party/abseil-cpp/absl/time/civil_time_test.cc index 03cd1f1..0ebd97ad 100644 --- a/third_party/abseil-cpp/absl/time/civil_time_test.cc +++ b/third_party/abseil-cpp/absl/time/civil_time_test.cc
@@ -690,6 +690,69 @@ EXPECT_EQ("1970", absl::FormatCivilTime(y)); } +TEST(CivilTime, Parse) { + absl::CivilSecond ss; + absl::CivilMinute mm; + absl::CivilHour hh; + absl::CivilDay d; + absl::CivilMonth m; + absl::CivilYear y; + + // CivilSecond OK; others fail + EXPECT_TRUE(absl::ParseCivilTime("2015-01-02T03:04:05", &ss)); + EXPECT_EQ("2015-01-02T03:04:05", absl::FormatCivilTime(ss)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02T03:04:05", &mm)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02T03:04:05", &hh)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02T03:04:05", &d)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02T03:04:05", &m)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02T03:04:05", &y)); + + // CivilMinute OK; others fail + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02T03:04", &ss)); + EXPECT_TRUE(absl::ParseCivilTime("2015-01-02T03:04", &mm)); + EXPECT_EQ("2015-01-02T03:04", absl::FormatCivilTime(mm)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02T03:04", &hh)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02T03:04", &d)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02T03:04", &m)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02T03:04", &y)); + + // CivilHour OK; others fail + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02T03", &ss)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02T03", &mm)); + EXPECT_TRUE(absl::ParseCivilTime("2015-01-02T03", &hh)); + EXPECT_EQ("2015-01-02T03", absl::FormatCivilTime(hh)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02T03", &d)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02T03", &m)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02T03", &y)); + + // CivilDay OK; others fail + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02", &ss)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02", &mm)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02", &hh)); + EXPECT_TRUE(absl::ParseCivilTime("2015-01-02", &d)); + EXPECT_EQ("2015-01-02", absl::FormatCivilTime(d)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02", &m)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01-02", &y)); + + // CivilMonth OK; others fail + EXPECT_FALSE(absl::ParseCivilTime("2015-01", &ss)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01", &mm)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01", &hh)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01", &d)); + EXPECT_TRUE(absl::ParseCivilTime("2015-01", &m)); + EXPECT_EQ("2015-01", absl::FormatCivilTime(m)); + EXPECT_FALSE(absl::ParseCivilTime("2015-01", &y)); + + // CivilYear OK; others fail + EXPECT_FALSE(absl::ParseCivilTime("2015", &ss)); + EXPECT_FALSE(absl::ParseCivilTime("2015", &mm)); + EXPECT_FALSE(absl::ParseCivilTime("2015", &hh)); + EXPECT_FALSE(absl::ParseCivilTime("2015", &d)); + EXPECT_FALSE(absl::ParseCivilTime("2015", &m)); + EXPECT_TRUE(absl::ParseCivilTime("2015", &y)); + EXPECT_EQ("2015", absl::FormatCivilTime(y)); +} + TEST(CivilTime, FormatAndParseLenient) { absl::CivilSecond ss; EXPECT_EQ("1970-01-01T00:00:00", absl::FormatCivilTime(ss)); @@ -708,6 +771,101 @@ absl::CivilYear y; EXPECT_EQ("1970", absl::FormatCivilTime(y)); + + EXPECT_TRUE(absl::ParseLenientCivilTime("2015-01-02T03:04:05", &ss)); + EXPECT_EQ("2015-01-02T03:04:05", absl::FormatCivilTime(ss)); + + EXPECT_TRUE(absl::ParseLenientCivilTime("2015-01-02T03:04:05", &mm)); + EXPECT_EQ("2015-01-02T03:04", absl::FormatCivilTime(mm)); + + EXPECT_TRUE(absl::ParseLenientCivilTime("2015-01-02T03:04:05", &hh)); + EXPECT_EQ("2015-01-02T03", absl::FormatCivilTime(hh)); + + EXPECT_TRUE(absl::ParseLenientCivilTime("2015-01-02T03:04:05", &d)); + EXPECT_EQ("2015-01-02", absl::FormatCivilTime(d)); + + EXPECT_TRUE(absl::ParseLenientCivilTime("2015-01-02T03:04:05", &m)); + EXPECT_EQ("2015-01", absl::FormatCivilTime(m)); + + EXPECT_TRUE(absl::ParseLenientCivilTime("2015-01-02T03:04:05", &y)); + EXPECT_EQ("2015", absl::FormatCivilTime(y)); +} + +TEST(CivilTime, ParseEdgeCases) { + absl::CivilSecond ss; + EXPECT_TRUE( + absl::ParseLenientCivilTime("9223372036854775807-12-31T23:59:59", &ss)); + EXPECT_EQ("9223372036854775807-12-31T23:59:59", absl::FormatCivilTime(ss)); + EXPECT_TRUE( + absl::ParseLenientCivilTime("-9223372036854775808-01-01T00:00:00", &ss)); + EXPECT_EQ("-9223372036854775808-01-01T00:00:00", absl::FormatCivilTime(ss)); + + absl::CivilMinute mm; + EXPECT_TRUE( + absl::ParseLenientCivilTime("9223372036854775807-12-31T23:59", &mm)); + EXPECT_EQ("9223372036854775807-12-31T23:59", absl::FormatCivilTime(mm)); + EXPECT_TRUE( + absl::ParseLenientCivilTime("-9223372036854775808-01-01T00:00", &mm)); + EXPECT_EQ("-9223372036854775808-01-01T00:00", absl::FormatCivilTime(mm)); + + absl::CivilHour hh; + EXPECT_TRUE( + absl::ParseLenientCivilTime("9223372036854775807-12-31T23", &hh)); + EXPECT_EQ("9223372036854775807-12-31T23", absl::FormatCivilTime(hh)); + EXPECT_TRUE( + absl::ParseLenientCivilTime("-9223372036854775808-01-01T00", &hh)); + EXPECT_EQ("-9223372036854775808-01-01T00", absl::FormatCivilTime(hh)); + + absl::CivilDay d; + EXPECT_TRUE(absl::ParseLenientCivilTime("9223372036854775807-12-31", &d)); + EXPECT_EQ("9223372036854775807-12-31", absl::FormatCivilTime(d)); + EXPECT_TRUE(absl::ParseLenientCivilTime("-9223372036854775808-01-01", &d)); + EXPECT_EQ("-9223372036854775808-01-01", absl::FormatCivilTime(d)); + + absl::CivilMonth m; + EXPECT_TRUE(absl::ParseLenientCivilTime("9223372036854775807-12", &m)); + EXPECT_EQ("9223372036854775807-12", absl::FormatCivilTime(m)); + EXPECT_TRUE(absl::ParseLenientCivilTime("-9223372036854775808-01", &m)); + EXPECT_EQ("-9223372036854775808-01", absl::FormatCivilTime(m)); + + absl::CivilYear y; + EXPECT_TRUE(absl::ParseLenientCivilTime("9223372036854775807", &y)); + EXPECT_EQ("9223372036854775807", absl::FormatCivilTime(y)); + EXPECT_TRUE(absl::ParseLenientCivilTime("-9223372036854775808", &y)); + EXPECT_EQ("-9223372036854775808", absl::FormatCivilTime(y)); + + // Tests some valid, but interesting, cases + EXPECT_TRUE(absl::ParseLenientCivilTime("0", &ss)) << ss; + EXPECT_EQ(absl::CivilYear(0), ss); + EXPECT_TRUE(absl::ParseLenientCivilTime("0-1", &ss)) << ss; + EXPECT_EQ(absl::CivilMonth(0, 1), ss); + EXPECT_TRUE(absl::ParseLenientCivilTime(" 2015 ", &ss)) << ss; + EXPECT_EQ(absl::CivilYear(2015), ss); + EXPECT_TRUE(absl::ParseLenientCivilTime(" 2015-6 ", &ss)) << ss; + EXPECT_EQ(absl::CivilMonth(2015, 6), ss); + EXPECT_TRUE(absl::ParseLenientCivilTime("2015-6-7", &ss)) << ss; + EXPECT_EQ(absl::CivilDay(2015, 6, 7), ss); + EXPECT_TRUE(absl::ParseLenientCivilTime(" 2015-6-7 ", &ss)) << ss; + EXPECT_EQ(absl::CivilDay(2015, 6, 7), ss); + EXPECT_TRUE(absl::ParseLenientCivilTime("2015-06-07T10:11:12 ", &ss)) << ss; + EXPECT_EQ(absl::CivilSecond(2015, 6, 7, 10, 11, 12), ss); + EXPECT_TRUE(absl::ParseLenientCivilTime(" 2015-06-07T10:11:12 ", &ss)) << ss; + EXPECT_EQ(absl::CivilSecond(2015, 6, 7, 10, 11, 12), ss); + EXPECT_TRUE(absl::ParseLenientCivilTime("-01-01", &ss)) << ss; + EXPECT_EQ(absl::CivilMonth(-1, 1), ss); + + // Tests some invalid cases + EXPECT_FALSE(absl::ParseLenientCivilTime("01-01-2015", &ss)) << ss; + EXPECT_FALSE(absl::ParseLenientCivilTime("2015-", &ss)) << ss; + EXPECT_FALSE(absl::ParseLenientCivilTime("0xff-01", &ss)) << ss; + EXPECT_FALSE(absl::ParseLenientCivilTime("2015-02-30T04:05:06", &ss)) << ss; + EXPECT_FALSE(absl::ParseLenientCivilTime("2015-02-03T04:05:96", &ss)) << ss; + EXPECT_FALSE(absl::ParseLenientCivilTime("X2015-02-03T04:05:06", &ss)) << ss; + EXPECT_FALSE(absl::ParseLenientCivilTime("2015-02-03T04:05:003", &ss)) << ss; + EXPECT_FALSE(absl::ParseLenientCivilTime("2015 -02-03T04:05:06", &ss)) << ss; + EXPECT_FALSE(absl::ParseLenientCivilTime("2015-02-03-04:05:06", &ss)) << ss; + EXPECT_FALSE(absl::ParseLenientCivilTime("2015:02:03T04-05-06", &ss)) << ss; + EXPECT_FALSE(absl::ParseLenientCivilTime("9223372036854775808", &y)) << y; } TEST(CivilTime, OutputStream) {
diff --git a/third_party/abseil-cpp/absl/time/clock.cc b/third_party/abseil-cpp/absl/time/clock.cc index 396c55f..3b895c3 100644 --- a/third_party/abseil-cpp/absl/time/clock.cc +++ b/third_party/abseil-cpp/absl/time/clock.cc
@@ -34,6 +34,7 @@ #include "absl/base/thread_annotations.h" namespace absl { +ABSL_NAMESPACE_BEGIN Time Now() { // TODO(bww): Get a timespec instead so we don't have to divide. int64_t n = absl::GetCurrentTimeNanos(); @@ -43,6 +44,7 @@ } return time_internal::FromUnixDuration(absl::Nanoseconds(n)); } +ABSL_NAMESPACE_END } // namespace absl // Decide if we should use the fast GetCurrentTimeNanos() algorithm @@ -71,9 +73,11 @@ #if !ABSL_USE_CYCLECLOCK_FOR_GET_CURRENT_TIME_NANOS namespace absl { +ABSL_NAMESPACE_BEGIN int64_t GetCurrentTimeNanos() { return GET_CURRENT_TIME_NANOS_FROM_SYSTEM(); } +ABSL_NAMESPACE_END } // namespace absl #else // Use the cyclecounter-based implementation below. @@ -91,6 +95,7 @@ static int64_t stats_fast_slow_paths; namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { // This is a friend wrapper around UnscaledCycleClock::Now() // (needed to access UnscaledCycleClock). @@ -449,7 +454,7 @@ last_sample.min_cycles_per_sample.store(0, std::memory_order_relaxed); stats_initializations++; } else if (sample->raw_ns + 500 * 1000 * 1000 < now_ns && - sample->base_cycles + 100 < now_cycles) { + sample->base_cycles + 50 < now_cycles) { // Enough time has passed to compute the cycle time. if (sample->nsscaled_per_cycle != 0) { // Have a cycle time estimate. // Compute time from counter reading, but avoiding overflow @@ -515,10 +520,12 @@ return estimated_base_ns; } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_USE_CYCLECLOCK_FOR_GET_CURRENT_TIME_NANOS namespace absl { +ABSL_NAMESPACE_BEGIN namespace { // Returns the maximum duration that SleepOnce() can sleep for. @@ -546,6 +553,7 @@ } } // namespace +ABSL_NAMESPACE_END } // namespace absl extern "C" {
diff --git a/third_party/abseil-cpp/absl/time/clock.h b/third_party/abseil-cpp/absl/time/clock.h index bb52e4f..27764a9 100644 --- a/third_party/abseil-cpp/absl/time/clock.h +++ b/third_party/abseil-cpp/absl/time/clock.h
@@ -26,6 +26,7 @@ #include "absl/time/time.h" namespace absl { +ABSL_NAMESPACE_BEGIN // Now() // @@ -49,6 +50,7 @@ // * Returns immediately when passed a nonpositive duration. void SleepFor(absl::Duration duration); +ABSL_NAMESPACE_END } // namespace absl // -----------------------------------------------------------------------------
diff --git a/third_party/abseil-cpp/absl/time/duration.cc b/third_party/abseil-cpp/absl/time/duration.cc index a3ac61a9..1353fa0 100644 --- a/third_party/abseil-cpp/absl/time/duration.cc +++ b/third_party/abseil-cpp/absl/time/duration.cc
@@ -71,6 +71,7 @@ #include "absl/time/time.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { @@ -197,11 +198,11 @@ // double as overflow cases. inline bool SafeAddRepHi(double a_hi, double b_hi, Duration* d) { double c = a_hi + b_hi; - if (c >= kint64max) { + if (c >= static_cast<double>(kint64max)) { *d = InfiniteDuration(); return false; } - if (c <= kint64min) { + if (c <= static_cast<double>(kint64min)) { *d = -InfiniteDuration(); return false; } @@ -873,12 +874,12 @@ ++start; } - // Can't parse a duration from an empty std::string. + // Can't parse a duration from an empty string. if (*start == '\0') { return false; } - // Special case for a std::string of "0". + // Special case for a string of "0". if (*start == '0' && *(start + 1) == '\0') { *d = ZeroDuration(); return true; @@ -906,10 +907,16 @@ return true; } +bool AbslParseFlag(absl::string_view text, Duration* dst, std::string*) { + return ParseDuration(std::string(text), dst); +} + +std::string AbslUnparseFlag(Duration d) { return FormatDuration(d); } bool ParseFlag(const std::string& text, Duration* dst, std::string* ) { return ParseDuration(text, dst); } std::string UnparseFlag(Duration d) { return FormatDuration(d); } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/duration_test.cc b/third_party/abseil-cpp/absl/time/duration_test.cc index 5dce9ac..4d85a2c 100644 --- a/third_party/abseil-cpp/absl/time/duration_test.cc +++ b/third_party/abseil-cpp/absl/time/duration_test.cc
@@ -762,11 +762,6 @@ const double dbl_inf = std::numeric_limits<double>::infinity(); const double dbl_denorm = std::numeric_limits<double>::denorm_min(); - // IEEE 754 behavior - double z = 0.0, two = 2.0; - EXPECT_TRUE(std::isinf(two / z)); - EXPECT_TRUE(std::isnan(z / z)); // We'll return inf - // Operator/(Duration, double) EXPECT_EQ(inf, zero / 0.0); EXPECT_EQ(-inf, zero / -0.0); @@ -1050,7 +1045,7 @@ EXPECT_EQ(absl::Seconds(666666666) + absl::Nanoseconds(666666667) + absl::Nanoseconds(1) / 2, sigfigs / 3); - sigfigs = absl::Seconds(7000000000LL); + sigfigs = absl::Seconds(int64_t{7000000000}); EXPECT_EQ(absl::Seconds(2333333333) + absl::Nanoseconds(333333333) + absl::Nanoseconds(1) / 4, sigfigs / 3);
diff --git a/third_party/abseil-cpp/absl/time/format.cc b/third_party/abseil-cpp/absl/time/format.cc index d6ca860..ee088f3 100644 --- a/third_party/abseil-cpp/absl/time/format.cc +++ b/third_party/abseil-cpp/absl/time/format.cc
@@ -22,12 +22,16 @@ namespace cctz = absl::time_internal::cctz; namespace absl { +ABSL_NAMESPACE_BEGIN -extern const char RFC3339_full[] = "%Y-%m-%dT%H:%M:%E*S%Ez"; -extern const char RFC3339_sec[] = "%Y-%m-%dT%H:%M:%S%Ez"; +ABSL_DLL extern const char RFC3339_full[] = + "%Y-%m-%dT%H:%M:%E*S%Ez"; +ABSL_DLL extern const char RFC3339_sec[] = "%Y-%m-%dT%H:%M:%S%Ez"; -extern const char RFC1123_full[] = "%a, %d %b %E4Y %H:%M:%S %z"; -extern const char RFC1123_no_wday[] = "%d %b %E4Y %H:%M:%S %z"; +ABSL_DLL extern const char RFC1123_full[] = + "%a, %d %b %E4Y %H:%M:%S %z"; +ABSL_DLL extern const char RFC1123_no_wday[] = + "%d %b %E4Y %H:%M:%S %z"; namespace { @@ -129,6 +133,14 @@ } // Functions required to support absl::Time flags. +bool AbslParseFlag(absl::string_view text, absl::Time* t, std::string* error) { + return absl::ParseTime(RFC3339_full, std::string(text), absl::UTCTimeZone(), + t, error); +} + +std::string AbslUnparseFlag(absl::Time t) { + return absl::FormatTime(RFC3339_full, t, absl::UTCTimeZone()); +} bool ParseFlag(const std::string& text, absl::Time* t, std::string* error) { return absl::ParseTime(RFC3339_full, text, absl::UTCTimeZone(), t, error); } @@ -137,4 +149,5 @@ return absl::FormatTime(RFC3339_full, t, absl::UTCTimeZone()); } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/format_test.cc b/third_party/abseil-cpp/absl/time/format_test.cc index ab1f305..a9a1eb8 100644 --- a/third_party/abseil-cpp/absl/time/format_test.cc +++ b/third_party/abseil-cpp/absl/time/format_test.cc
@@ -173,7 +173,7 @@ absl::Time t; std::string e; - // We can parse a std::string without a UTC offset if we supply a timezone. + // We can parse a string without a UTC offset if we supply a timezone. EXPECT_TRUE( absl::ParseTime("%Y-%m-%d %H:%M:%S", "2013-06-28 19:08:09", tz, &t, &e)) << e; @@ -327,7 +327,7 @@ EXPECT_TRUE(absl::ParseTime("%H:%M blah", " infinite-past ", &t, &err)); EXPECT_EQ(absl::InfinitePast(), t); - // "infinite-future" as literal std::string + // "infinite-future" as literal string absl::TimeZone tz = absl::UTCTimeZone(); EXPECT_TRUE(absl::ParseTime("infinite-future %H:%M", "infinite-future 03:04", &t, &err)); @@ -335,7 +335,7 @@ EXPECT_EQ(3, tz.At(t).cs.hour()); EXPECT_EQ(4, tz.At(t).cs.minute()); - // "infinite-past" as literal std::string + // "infinite-past" as literal string EXPECT_TRUE( absl::ParseTime("infinite-past %H:%M", "infinite-past 03:04", &t, &err)); EXPECT_NE(absl::InfinitePast(), t);
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/BUILD.bazel b/third_party/abseil-cpp/absl/time/internal/cctz/BUILD.bazel index b05c234..7a53c81 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/BUILD.bazel +++ b/third_party/abseil-cpp/absl/time/internal/cctz/BUILD.bazel
@@ -12,10 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") + package(features = ["-parse_headers"]) licenses(["notice"]) # Apache License +filegroup( + name = "zoneinfo", + srcs = glob(["testdata/zoneinfo/**"]), +) + config_setting( name = "osx", constraint_values = [ @@ -33,16 +40,6 @@ ### libraries cc_library( - name = "includes", - textual_hdrs = [ - "include/cctz/civil_time.h", - "include/cctz/civil_time_detail.h", - "include/cctz/time_zone.h", - ], - visibility = ["//absl/time:__pkg__"], -) - -cc_library( name = "civil_time", srcs = ["src/civil_time_detail.cc"], hdrs = [ @@ -50,6 +47,7 @@ ], textual_hdrs = ["include/cctz/civil_time_detail.h"], visibility = ["//visibility:public"], + deps = ["//absl/base:config"], ) cc_library( @@ -86,7 +84,10 @@ "//conditions:default": [], }), visibility = ["//visibility:public"], - deps = [":civil_time"], + deps = [ + ":civil_time", + "//absl/base:config", + ], ) ### tests @@ -97,6 +98,7 @@ srcs = ["src/civil_time_test.cc"], deps = [ ":civil_time", + "//absl/base:config", "@com_google_googletest//:gtest_main", ], ) @@ -114,6 +116,7 @@ deps = [ ":civil_time", ":time_zone", + "//absl/base:config", "@com_google_googletest//:gtest_main", ], ) @@ -132,6 +135,7 @@ deps = [ ":civil_time", ":time_zone", + "//absl/base:config", "@com_google_googletest//:gtest_main", ], ) @@ -152,6 +156,7 @@ deps = [ ":civil_time", ":time_zone", + "//absl/base:config", "@com_github_google_benchmark//:benchmark_main", ], ) @@ -159,8 +164,3 @@ ### examples ### binaries - -filegroup( - name = "zoneinfo", - srcs = glob(["testdata/zoneinfo/**"]), -)
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/BUILD.gn b/third_party/abseil-cpp/absl/time/internal/cctz/BUILD.gn index 879c4016..2d28130 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/BUILD.gn +++ b/third_party/abseil-cpp/absl/time/internal/cctz/BUILD.gn
@@ -17,19 +17,6 @@ visibility = [ "*" ] } -source_set("includes") { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] - public = [ - "include/cctz/civil_time.h", - "include/cctz/civil_time_detail.h", - "include/cctz/time_zone.h", - ] - visibility = [] - visibility += [ "../time:*" ] -} - source_set("civil_time") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] @@ -39,6 +26,7 @@ "include/cctz/civil_time.h", "include/cctz/civil_time_detail.h", ] + deps = [ "../../../base:config" ] } source_set("time_zone") { @@ -70,5 +58,8 @@ if (is_mac || is_ios) { libs = [ "Foundation.framework" ] } - deps = [ ":civil_time" ] + deps = [ + ":civil_time", + "../../../base:config", + ] }
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time.h b/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time.h index 85d0d3f..d47ff86 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time.h +++ b/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time.h
@@ -15,9 +15,11 @@ #ifndef ABSL_TIME_INTERNAL_CCTZ_CIVIL_TIME_H_ #define ABSL_TIME_INTERNAL_CCTZ_CIVIL_TIME_H_ +#include "absl/base/config.h" #include "absl/time/internal/cctz/include/cctz/civil_time_detail.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -150,7 +152,7 @@ // // All civil-time types have accessors for all six of the civil-time fields: // year, month, day, hour, minute, and second. Recall that fields inferior to -// the type's aligment will be set to their minimum valid value. +// the type's alignment will be set to their minimum valid value. // // civil_day d(2015, 6, 28); // // d.year() == 2015 @@ -324,6 +326,7 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TIME_INTERNAL_CCTZ_CIVIL_TIME_H_
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h b/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h index 433078a7..4cde96f 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +++ b/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h
@@ -20,6 +20,8 @@ #include <ostream> #include <type_traits> +#include "absl/base/config.h" + // Disable constexpr support unless we are in C++14 mode. #if __cpp_constexpr >= 201304 || (defined(_MSC_VER) && _MSC_VER >= 1910) #define CONSTEXPR_D constexpr // data @@ -32,6 +34,7 @@ #endif namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -53,8 +56,8 @@ // Normalized civil-time fields: Y-M-D HH:MM:SS. struct fields { - CONSTEXPR_M fields(year_t year, month_t month, day_t day, - hour_t hour, minute_t minute, second_t second) + CONSTEXPR_M fields(year_t year, month_t month, day_t day, hour_t hour, + minute_t minute, second_t second) : y(year), m(month), d(day), hh(hour), mm(minute), ss(second) {} std::int_least64_t y; std::int_least8_t m; @@ -101,8 +104,8 @@ return k_days_per_month[m] + (m == 2 && is_leap_year(y)); } -CONSTEXPR_F fields n_day(year_t y, month_t m, diff_t d, diff_t cd, - hour_t hh, minute_t mm, second_t ss) noexcept { +CONSTEXPR_F fields n_day(year_t y, month_t m, diff_t d, diff_t cd, hour_t hh, + minute_t mm, second_t ss) noexcept { y += (cd / 146097) * 400; cd %= 146097; if (cd < 0) { @@ -152,8 +155,8 @@ } return fields(y, m, static_cast<day_t>(d), hh, mm, ss); } -CONSTEXPR_F fields n_mon(year_t y, diff_t m, diff_t d, diff_t cd, - hour_t hh, minute_t mm, second_t ss) noexcept { +CONSTEXPR_F fields n_mon(year_t y, diff_t m, diff_t d, diff_t cd, hour_t hh, + minute_t mm, second_t ss) noexcept { if (m != 12) { y += m / 12; m %= 12; @@ -164,8 +167,8 @@ } return n_day(y, static_cast<month_t>(m), d, cd, hh, mm, ss); } -CONSTEXPR_F fields n_hour(year_t y, diff_t m, diff_t d, diff_t cd, - diff_t hh, minute_t mm, second_t ss) noexcept { +CONSTEXPR_F fields n_hour(year_t y, diff_t m, diff_t d, diff_t cd, diff_t hh, + minute_t mm, second_t ss) noexcept { cd += hh / 24; hh %= 24; if (hh < 0) { @@ -264,8 +267,8 @@ // yet the difference between two such extreme values may actually be // small, so we take a little care to avoid overflow when possible by // exploiting the 146097-day cycle. -CONSTEXPR_F diff_t day_difference(year_t y1, month_t m1, day_t d1, - year_t y2, month_t m2, day_t d2) noexcept { +CONSTEXPR_F diff_t day_difference(year_t y1, month_t m1, day_t d1, year_t y2, + month_t m2, day_t d2) noexcept { const diff_t a_c4_off = y1 % 400; const diff_t b_c4_off = y2 % 400; diff_t c4_diff = (y1 - a_c4_off) - (y2 - b_c4_off); @@ -305,9 +308,7 @@ //////////////////////////////////////////////////////////////////////// // Aligns the (normalized) fields struct to the indicated field. -CONSTEXPR_F fields align(second_tag, fields f) noexcept { - return f; -} +CONSTEXPR_F fields align(second_tag, fields f) noexcept { return f; } CONSTEXPR_F fields align(minute_tag, fields f) noexcept { return fields{f.y, f.m, f.d, f.hh, f.mm, 0}; } @@ -386,11 +387,11 @@ : civil_time(ct.f_) {} // Factories for the maximum/minimum representable civil_time. - static CONSTEXPR_F civil_time (max)() { + static CONSTEXPR_F civil_time(max)() { const auto max_year = (std::numeric_limits<std::int_least64_t>::max)(); return civil_time(max_year, 12, 31, 23, 59, 59); } - static CONSTEXPR_F civil_time (min)() { + static CONSTEXPR_F civil_time(min)() { const auto min_year = (std::numeric_limits<std::int_least64_t>::min)(); return civil_time(min_year, 1, 1, 0, 0, 0); } @@ -416,17 +417,13 @@ } return *this; } - CONSTEXPR_M civil_time& operator++() noexcept { - return *this += 1; - } + CONSTEXPR_M civil_time& operator++() noexcept { return *this += 1; } CONSTEXPR_M civil_time operator++(int) noexcept { const civil_time a = *this; ++*this; return a; } - CONSTEXPR_M civil_time& operator--() noexcept { - return *this -= 1; - } + CONSTEXPR_M civil_time& operator--() noexcept { return *this -= 1; } CONSTEXPR_M civil_time operator--(int) noexcept { const civil_time a = *this; --*this; @@ -483,17 +480,17 @@ template <typename T1, typename T2> CONSTEXPR_F bool operator<(const civil_time<T1>& lhs, const civil_time<T2>& rhs) noexcept { - return (lhs.year() < rhs.year() || - (lhs.year() == rhs.year() && - (lhs.month() < rhs.month() || - (lhs.month() == rhs.month() && - (lhs.day() < rhs.day() || - (lhs.day() == rhs.day() && - (lhs.hour() < rhs.hour() || - (lhs.hour() == rhs.hour() && - (lhs.minute() < rhs.minute() || - (lhs.minute() == rhs.minute() && - (lhs.second() < rhs.second()))))))))))); + return ( + lhs.year() < rhs.year() || + (lhs.year() == rhs.year() && + (lhs.month() < rhs.month() || + (lhs.month() == rhs.month() && + (lhs.day() < rhs.day() || (lhs.day() == rhs.day() && + (lhs.hour() < rhs.hour() || + (lhs.hour() == rhs.hour() && + (lhs.minute() < rhs.minute() || + (lhs.minute() == rhs.minute() && + (lhs.second() < rhs.second()))))))))))); } template <typename T1, typename T2> CONSTEXPR_F bool operator<=(const civil_time<T1>& lhs, @@ -615,6 +612,7 @@ } // namespace detail } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl #undef CONSTEXPR_M
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h b/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h index ef6c4ba..d4ea90e 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +++ b/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h
@@ -25,9 +25,11 @@ #include <string> #include <utility> +#include "absl/base/config.h" #include "absl/time/internal/cctz/include/cctz/civil_time.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -39,8 +41,8 @@ namespace detail { template <typename D> -inline std::pair<time_point<seconds>, D> -split_seconds(const time_point<D>& tp) { +inline std::pair<time_point<seconds>, D> split_seconds( + const time_point<D>& tp) { auto sec = std::chrono::time_point_cast<seconds>(tp); auto sub = tp - sec; if (sub.count() < 0) { @@ -49,8 +51,8 @@ } return {sec, std::chrono::duration_cast<D>(sub)}; } -inline std::pair<time_point<seconds>, seconds> -split_seconds(const time_point<seconds>& tp) { +inline std::pair<time_point<seconds>, seconds> split_seconds( + const time_point<seconds>& tp) { return {tp, seconds::zero()}; } } // namespace detail @@ -194,22 +196,20 @@ bool next_transition(const time_point<seconds>& tp, civil_transition* trans) const; template <typename D> - bool next_transition(const time_point<D>& tp, - civil_transition* trans) const { + bool next_transition(const time_point<D>& tp, civil_transition* trans) const { return next_transition(detail::split_seconds(tp).first, trans); } bool prev_transition(const time_point<seconds>& tp, civil_transition* trans) const; template <typename D> - bool prev_transition(const time_point<D>& tp, - civil_transition* trans) const { + bool prev_transition(const time_point<D>& tp, civil_transition* trans) const { return prev_transition(detail::split_seconds(tp).first, trans); } // version() and description() provide additional information about the // time zone. The content of each of the returned strings is unspecified, // however, when the IANA Time Zone Database is the underlying data source - // the version() std::string will be in the familar form (e.g, "2018e") or + // the version() string will be in the familar form (e.g, "2018e") or // empty when unavailable. // // Note: These functions are for informational or testing purposes only. @@ -220,9 +220,7 @@ friend bool operator==(time_zone lhs, time_zone rhs) { return &lhs.effective_impl() == &rhs.effective_impl(); } - friend bool operator!=(time_zone lhs, time_zone rhs) { - return !(lhs == rhs); - } + friend bool operator!=(time_zone lhs, time_zone rhs) { return !(lhs == rhs); } template <typename H> friend H AbslHashValue(H h, time_zone tz) { @@ -380,6 +378,7 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_H_
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/zone_info_source.h b/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/zone_info_source.h index 2b898d18..012eb4ec 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/zone_info_source.h +++ b/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/zone_info_source.h
@@ -20,7 +20,10 @@ #include <memory> #include <string> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -30,19 +33,21 @@ virtual ~ZoneInfoSource(); virtual std::size_t Read(void* ptr, std::size_t size) = 0; // like fread() - virtual int Skip(std::size_t offset) = 0; // like fseek() + virtual int Skip(std::size_t offset) = 0; // like fseek() // Until the zoneinfo data supports versioning information, we provide // a way for a ZoneInfoSource to indicate it out-of-band. The default - // implementation returns an empty std::string. + // implementation returns an empty string. virtual std::string Version() const; }; } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz_extension { @@ -52,8 +57,8 @@ using ZoneInfoSourceFactory = std::unique_ptr<absl::time_internal::cctz::ZoneInfoSource> (*)( const std::string&, - const std::function<std::unique_ptr<absl::time_internal::cctz::ZoneInfoSource>( - const std::string&)>&); + const std::function<std::unique_ptr< + absl::time_internal::cctz::ZoneInfoSource>(const std::string&)>&); // The user can control the mapping of zone names to zoneinfo data by // providing a definition for cctz_extension::zone_info_source_factory. @@ -91,6 +96,7 @@ } // namespace cctz_extension } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TIME_INTERNAL_CCTZ_ZONE_INFO_SOURCE_H_
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/cctz_benchmark.cc b/third_party/abseil-cpp/absl/time/internal/cctz/src/cctz_benchmark.cc index a40f504..d30a644 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/cctz_benchmark.cc +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/cctz_benchmark.cc
@@ -105,601 +105,599 @@ // A list of known time-zone names. // TODO: Refactor with src/time_zone_lookup_test.cc. -const char* const kTimeZoneNames[] = { - "Africa/Abidjan", - "Africa/Accra", - "Africa/Addis_Ababa", - "Africa/Algiers", - "Africa/Asmara", - "Africa/Asmera", - "Africa/Bamako", - "Africa/Bangui", - "Africa/Banjul", - "Africa/Bissau", - "Africa/Blantyre", - "Africa/Brazzaville", - "Africa/Bujumbura", - "Africa/Cairo", - "Africa/Casablanca", - "Africa/Ceuta", - "Africa/Conakry", - "Africa/Dakar", - "Africa/Dar_es_Salaam", - "Africa/Djibouti", - "Africa/Douala", - "Africa/El_Aaiun", - "Africa/Freetown", - "Africa/Gaborone", - "Africa/Harare", - "Africa/Johannesburg", - "Africa/Juba", - "Africa/Kampala", - "Africa/Khartoum", - "Africa/Kigali", - "Africa/Kinshasa", - "Africa/Lagos", - "Africa/Libreville", - "Africa/Lome", - "Africa/Luanda", - "Africa/Lubumbashi", - "Africa/Lusaka", - "Africa/Malabo", - "Africa/Maputo", - "Africa/Maseru", - "Africa/Mbabane", - "Africa/Mogadishu", - "Africa/Monrovia", - "Africa/Nairobi", - "Africa/Ndjamena", - "Africa/Niamey", - "Africa/Nouakchott", - "Africa/Ouagadougou", - "Africa/Porto-Novo", - "Africa/Sao_Tome", - "Africa/Timbuktu", - "Africa/Tripoli", - "Africa/Tunis", - "Africa/Windhoek", - "America/Adak", - "America/Anchorage", - "America/Anguilla", - "America/Antigua", - "America/Araguaina", - "America/Argentina/Buenos_Aires", - "America/Argentina/Catamarca", - "America/Argentina/ComodRivadavia", - "America/Argentina/Cordoba", - "America/Argentina/Jujuy", - "America/Argentina/La_Rioja", - "America/Argentina/Mendoza", - "America/Argentina/Rio_Gallegos", - "America/Argentina/Salta", - "America/Argentina/San_Juan", - "America/Argentina/San_Luis", - "America/Argentina/Tucuman", - "America/Argentina/Ushuaia", - "America/Aruba", - "America/Asuncion", - "America/Atikokan", - "America/Atka", - "America/Bahia", - "America/Bahia_Banderas", - "America/Barbados", - "America/Belem", - "America/Belize", - "America/Blanc-Sablon", - "America/Boa_Vista", - "America/Bogota", - "America/Boise", - "America/Buenos_Aires", - "America/Cambridge_Bay", - "America/Campo_Grande", - "America/Cancun", - "America/Caracas", - "America/Catamarca", - "America/Cayenne", - "America/Cayman", - "America/Chicago", - "America/Chihuahua", - "America/Coral_Harbour", - "America/Cordoba", - "America/Costa_Rica", - "America/Creston", - "America/Cuiaba", - "America/Curacao", - "America/Danmarkshavn", - "America/Dawson", - "America/Dawson_Creek", - "America/Denver", - "America/Detroit", - "America/Dominica", - "America/Edmonton", - "America/Eirunepe", - "America/El_Salvador", - "America/Ensenada", - "America/Fort_Nelson", - "America/Fort_Wayne", - "America/Fortaleza", - "America/Glace_Bay", - "America/Godthab", - "America/Goose_Bay", - "America/Grand_Turk", - "America/Grenada", - "America/Guadeloupe", - "America/Guatemala", - "America/Guayaquil", - "America/Guyana", - "America/Halifax", - "America/Havana", - "America/Hermosillo", - "America/Indiana/Indianapolis", - "America/Indiana/Knox", - "America/Indiana/Marengo", - "America/Indiana/Petersburg", - "America/Indiana/Tell_City", - "America/Indiana/Vevay", - "America/Indiana/Vincennes", - "America/Indiana/Winamac", - "America/Indianapolis", - "America/Inuvik", - "America/Iqaluit", - "America/Jamaica", - "America/Jujuy", - "America/Juneau", - "America/Kentucky/Louisville", - "America/Kentucky/Monticello", - "America/Knox_IN", - "America/Kralendijk", - "America/La_Paz", - "America/Lima", - "America/Los_Angeles", - "America/Louisville", - "America/Lower_Princes", - "America/Maceio", - "America/Managua", - "America/Manaus", - "America/Marigot", - "America/Martinique", - "America/Matamoros", - "America/Mazatlan", - "America/Mendoza", - "America/Menominee", - "America/Merida", - "America/Metlakatla", - "America/Mexico_City", - "America/Miquelon", - "America/Moncton", - "America/Monterrey", - "America/Montevideo", - "America/Montreal", - "America/Montserrat", - "America/Nassau", - "America/New_York", - "America/Nipigon", - "America/Nome", - "America/Noronha", - "America/North_Dakota/Beulah", - "America/North_Dakota/Center", - "America/North_Dakota/New_Salem", - "America/Ojinaga", - "America/Panama", - "America/Pangnirtung", - "America/Paramaribo", - "America/Phoenix", - "America/Port-au-Prince", - "America/Port_of_Spain", - "America/Porto_Acre", - "America/Porto_Velho", - "America/Puerto_Rico", - "America/Punta_Arenas", - "America/Rainy_River", - "America/Rankin_Inlet", - "America/Recife", - "America/Regina", - "America/Resolute", - "America/Rio_Branco", - "America/Rosario", - "America/Santa_Isabel", - "America/Santarem", - "America/Santiago", - "America/Santo_Domingo", - "America/Sao_Paulo", - "America/Scoresbysund", - "America/Shiprock", - "America/Sitka", - "America/St_Barthelemy", - "America/St_Johns", - "America/St_Kitts", - "America/St_Lucia", - "America/St_Thomas", - "America/St_Vincent", - "America/Swift_Current", - "America/Tegucigalpa", - "America/Thule", - "America/Thunder_Bay", - "America/Tijuana", - "America/Toronto", - "America/Tortola", - "America/Vancouver", - "America/Virgin", - "America/Whitehorse", - "America/Winnipeg", - "America/Yakutat", - "America/Yellowknife", - "Antarctica/Casey", - "Antarctica/Davis", - "Antarctica/DumontDUrville", - "Antarctica/Macquarie", - "Antarctica/Mawson", - "Antarctica/McMurdo", - "Antarctica/Palmer", - "Antarctica/Rothera", - "Antarctica/South_Pole", - "Antarctica/Syowa", - "Antarctica/Troll", - "Antarctica/Vostok", - "Arctic/Longyearbyen", - "Asia/Aden", - "Asia/Almaty", - "Asia/Amman", - "Asia/Anadyr", - "Asia/Aqtau", - "Asia/Aqtobe", - "Asia/Ashgabat", - "Asia/Ashkhabad", - "Asia/Atyrau", - "Asia/Baghdad", - "Asia/Bahrain", - "Asia/Baku", - "Asia/Bangkok", - "Asia/Barnaul", - "Asia/Beirut", - "Asia/Bishkek", - "Asia/Brunei", - "Asia/Calcutta", - "Asia/Chita", - "Asia/Choibalsan", - "Asia/Chongqing", - "Asia/Chungking", - "Asia/Colombo", - "Asia/Dacca", - "Asia/Damascus", - "Asia/Dhaka", - "Asia/Dili", - "Asia/Dubai", - "Asia/Dushanbe", - "Asia/Famagusta", - "Asia/Gaza", - "Asia/Harbin", - "Asia/Hebron", - "Asia/Ho_Chi_Minh", - "Asia/Hong_Kong", - "Asia/Hovd", - "Asia/Irkutsk", - "Asia/Istanbul", - "Asia/Jakarta", - "Asia/Jayapura", - "Asia/Jerusalem", - "Asia/Kabul", - "Asia/Kamchatka", - "Asia/Karachi", - "Asia/Kashgar", - "Asia/Kathmandu", - "Asia/Katmandu", - "Asia/Khandyga", - "Asia/Kolkata", - "Asia/Krasnoyarsk", - "Asia/Kuala_Lumpur", - "Asia/Kuching", - "Asia/Kuwait", - "Asia/Macao", - "Asia/Macau", - "Asia/Magadan", - "Asia/Makassar", - "Asia/Manila", - "Asia/Muscat", - "Asia/Nicosia", - "Asia/Novokuznetsk", - "Asia/Novosibirsk", - "Asia/Omsk", - "Asia/Oral", - "Asia/Phnom_Penh", - "Asia/Pontianak", - "Asia/Pyongyang", - "Asia/Qatar", - "Asia/Qostanay", - "Asia/Qyzylorda", - "Asia/Rangoon", - "Asia/Riyadh", - "Asia/Saigon", - "Asia/Sakhalin", - "Asia/Samarkand", - "Asia/Seoul", - "Asia/Shanghai", - "Asia/Singapore", - "Asia/Srednekolymsk", - "Asia/Taipei", - "Asia/Tashkent", - "Asia/Tbilisi", - "Asia/Tehran", - "Asia/Tel_Aviv", - "Asia/Thimbu", - "Asia/Thimphu", - "Asia/Tokyo", - "Asia/Tomsk", - "Asia/Ujung_Pandang", - "Asia/Ulaanbaatar", - "Asia/Ulan_Bator", - "Asia/Urumqi", - "Asia/Ust-Nera", - "Asia/Vientiane", - "Asia/Vladivostok", - "Asia/Yakutsk", - "Asia/Yangon", - "Asia/Yekaterinburg", - "Asia/Yerevan", - "Atlantic/Azores", - "Atlantic/Bermuda", - "Atlantic/Canary", - "Atlantic/Cape_Verde", - "Atlantic/Faeroe", - "Atlantic/Faroe", - "Atlantic/Jan_Mayen", - "Atlantic/Madeira", - "Atlantic/Reykjavik", - "Atlantic/South_Georgia", - "Atlantic/St_Helena", - "Atlantic/Stanley", - "Australia/ACT", - "Australia/Adelaide", - "Australia/Brisbane", - "Australia/Broken_Hill", - "Australia/Canberra", - "Australia/Currie", - "Australia/Darwin", - "Australia/Eucla", - "Australia/Hobart", - "Australia/LHI", - "Australia/Lindeman", - "Australia/Lord_Howe", - "Australia/Melbourne", - "Australia/NSW", - "Australia/North", - "Australia/Perth", - "Australia/Queensland", - "Australia/South", - "Australia/Sydney", - "Australia/Tasmania", - "Australia/Victoria", - "Australia/West", - "Australia/Yancowinna", - "Brazil/Acre", - "Brazil/DeNoronha", - "Brazil/East", - "Brazil/West", - "CET", - "CST6CDT", - "Canada/Atlantic", - "Canada/Central", - "Canada/Eastern", - "Canada/Mountain", - "Canada/Newfoundland", - "Canada/Pacific", - "Canada/Saskatchewan", - "Canada/Yukon", - "Chile/Continental", - "Chile/EasterIsland", - "Cuba", - "EET", - "EST", - "EST5EDT", - "Egypt", - "Eire", - "Etc/GMT", - "Etc/GMT+0", - "Etc/GMT+1", - "Etc/GMT+10", - "Etc/GMT+11", - "Etc/GMT+12", - "Etc/GMT+2", - "Etc/GMT+3", - "Etc/GMT+4", - "Etc/GMT+5", - "Etc/GMT+6", - "Etc/GMT+7", - "Etc/GMT+8", - "Etc/GMT+9", - "Etc/GMT-0", - "Etc/GMT-1", - "Etc/GMT-10", - "Etc/GMT-11", - "Etc/GMT-12", - "Etc/GMT-13", - "Etc/GMT-14", - "Etc/GMT-2", - "Etc/GMT-3", - "Etc/GMT-4", - "Etc/GMT-5", - "Etc/GMT-6", - "Etc/GMT-7", - "Etc/GMT-8", - "Etc/GMT-9", - "Etc/GMT0", - "Etc/Greenwich", - "Etc/UCT", - "Etc/UTC", - "Etc/Universal", - "Etc/Zulu", - "Europe/Amsterdam", - "Europe/Andorra", - "Europe/Astrakhan", - "Europe/Athens", - "Europe/Belfast", - "Europe/Belgrade", - "Europe/Berlin", - "Europe/Bratislava", - "Europe/Brussels", - "Europe/Bucharest", - "Europe/Budapest", - "Europe/Busingen", - "Europe/Chisinau", - "Europe/Copenhagen", - "Europe/Dublin", - "Europe/Gibraltar", - "Europe/Guernsey", - "Europe/Helsinki", - "Europe/Isle_of_Man", - "Europe/Istanbul", - "Europe/Jersey", - "Europe/Kaliningrad", - "Europe/Kiev", - "Europe/Kirov", - "Europe/Lisbon", - "Europe/Ljubljana", - "Europe/London", - "Europe/Luxembourg", - "Europe/Madrid", - "Europe/Malta", - "Europe/Mariehamn", - "Europe/Minsk", - "Europe/Monaco", - "Europe/Moscow", - "Europe/Nicosia", - "Europe/Oslo", - "Europe/Paris", - "Europe/Podgorica", - "Europe/Prague", - "Europe/Riga", - "Europe/Rome", - "Europe/Samara", - "Europe/San_Marino", - "Europe/Sarajevo", - "Europe/Saratov", - "Europe/Simferopol", - "Europe/Skopje", - "Europe/Sofia", - "Europe/Stockholm", - "Europe/Tallinn", - "Europe/Tirane", - "Europe/Tiraspol", - "Europe/Ulyanovsk", - "Europe/Uzhgorod", - "Europe/Vaduz", - "Europe/Vatican", - "Europe/Vienna", - "Europe/Vilnius", - "Europe/Volgograd", - "Europe/Warsaw", - "Europe/Zagreb", - "Europe/Zaporozhye", - "Europe/Zurich", - "GB", - "GB-Eire", - "GMT", - "GMT+0", - "GMT-0", - "GMT0", - "Greenwich", - "HST", - "Hongkong", - "Iceland", - "Indian/Antananarivo", - "Indian/Chagos", - "Indian/Christmas", - "Indian/Cocos", - "Indian/Comoro", - "Indian/Kerguelen", - "Indian/Mahe", - "Indian/Maldives", - "Indian/Mauritius", - "Indian/Mayotte", - "Indian/Reunion", - "Iran", - "Israel", - "Jamaica", - "Japan", - "Kwajalein", - "Libya", - "MET", - "MST", - "MST7MDT", - "Mexico/BajaNorte", - "Mexico/BajaSur", - "Mexico/General", - "NZ", - "NZ-CHAT", - "Navajo", - "PRC", - "PST8PDT", - "Pacific/Apia", - "Pacific/Auckland", - "Pacific/Bougainville", - "Pacific/Chatham", - "Pacific/Chuuk", - "Pacific/Easter", - "Pacific/Efate", - "Pacific/Enderbury", - "Pacific/Fakaofo", - "Pacific/Fiji", - "Pacific/Funafuti", - "Pacific/Galapagos", - "Pacific/Gambier", - "Pacific/Guadalcanal", - "Pacific/Guam", - "Pacific/Honolulu", - "Pacific/Johnston", - "Pacific/Kiritimati", - "Pacific/Kosrae", - "Pacific/Kwajalein", - "Pacific/Majuro", - "Pacific/Marquesas", - "Pacific/Midway", - "Pacific/Nauru", - "Pacific/Niue", - "Pacific/Norfolk", - "Pacific/Noumea", - "Pacific/Pago_Pago", - "Pacific/Palau", - "Pacific/Pitcairn", - "Pacific/Pohnpei", - "Pacific/Ponape", - "Pacific/Port_Moresby", - "Pacific/Rarotonga", - "Pacific/Saipan", - "Pacific/Samoa", - "Pacific/Tahiti", - "Pacific/Tarawa", - "Pacific/Tongatapu", - "Pacific/Truk", - "Pacific/Wake", - "Pacific/Wallis", - "Pacific/Yap", - "Poland", - "Portugal", - "ROC", - "ROK", - "Singapore", - "Turkey", - "UCT", - "US/Alaska", - "US/Aleutian", - "US/Arizona", - "US/Central", - "US/East-Indiana", - "US/Eastern", - "US/Hawaii", - "US/Indiana-Starke", - "US/Michigan", - "US/Mountain", - "US/Pacific", - "US/Samoa", - "UTC", - "Universal", - "W-SU", - "WET", - "Zulu", - nullptr -}; +const char* const kTimeZoneNames[] = {"Africa/Abidjan", + "Africa/Accra", + "Africa/Addis_Ababa", + "Africa/Algiers", + "Africa/Asmara", + "Africa/Asmera", + "Africa/Bamako", + "Africa/Bangui", + "Africa/Banjul", + "Africa/Bissau", + "Africa/Blantyre", + "Africa/Brazzaville", + "Africa/Bujumbura", + "Africa/Cairo", + "Africa/Casablanca", + "Africa/Ceuta", + "Africa/Conakry", + "Africa/Dakar", + "Africa/Dar_es_Salaam", + "Africa/Djibouti", + "Africa/Douala", + "Africa/El_Aaiun", + "Africa/Freetown", + "Africa/Gaborone", + "Africa/Harare", + "Africa/Johannesburg", + "Africa/Juba", + "Africa/Kampala", + "Africa/Khartoum", + "Africa/Kigali", + "Africa/Kinshasa", + "Africa/Lagos", + "Africa/Libreville", + "Africa/Lome", + "Africa/Luanda", + "Africa/Lubumbashi", + "Africa/Lusaka", + "Africa/Malabo", + "Africa/Maputo", + "Africa/Maseru", + "Africa/Mbabane", + "Africa/Mogadishu", + "Africa/Monrovia", + "Africa/Nairobi", + "Africa/Ndjamena", + "Africa/Niamey", + "Africa/Nouakchott", + "Africa/Ouagadougou", + "Africa/Porto-Novo", + "Africa/Sao_Tome", + "Africa/Timbuktu", + "Africa/Tripoli", + "Africa/Tunis", + "Africa/Windhoek", + "America/Adak", + "America/Anchorage", + "America/Anguilla", + "America/Antigua", + "America/Araguaina", + "America/Argentina/Buenos_Aires", + "America/Argentina/Catamarca", + "America/Argentina/ComodRivadavia", + "America/Argentina/Cordoba", + "America/Argentina/Jujuy", + "America/Argentina/La_Rioja", + "America/Argentina/Mendoza", + "America/Argentina/Rio_Gallegos", + "America/Argentina/Salta", + "America/Argentina/San_Juan", + "America/Argentina/San_Luis", + "America/Argentina/Tucuman", + "America/Argentina/Ushuaia", + "America/Aruba", + "America/Asuncion", + "America/Atikokan", + "America/Atka", + "America/Bahia", + "America/Bahia_Banderas", + "America/Barbados", + "America/Belem", + "America/Belize", + "America/Blanc-Sablon", + "America/Boa_Vista", + "America/Bogota", + "America/Boise", + "America/Buenos_Aires", + "America/Cambridge_Bay", + "America/Campo_Grande", + "America/Cancun", + "America/Caracas", + "America/Catamarca", + "America/Cayenne", + "America/Cayman", + "America/Chicago", + "America/Chihuahua", + "America/Coral_Harbour", + "America/Cordoba", + "America/Costa_Rica", + "America/Creston", + "America/Cuiaba", + "America/Curacao", + "America/Danmarkshavn", + "America/Dawson", + "America/Dawson_Creek", + "America/Denver", + "America/Detroit", + "America/Dominica", + "America/Edmonton", + "America/Eirunepe", + "America/El_Salvador", + "America/Ensenada", + "America/Fort_Nelson", + "America/Fort_Wayne", + "America/Fortaleza", + "America/Glace_Bay", + "America/Godthab", + "America/Goose_Bay", + "America/Grand_Turk", + "America/Grenada", + "America/Guadeloupe", + "America/Guatemala", + "America/Guayaquil", + "America/Guyana", + "America/Halifax", + "America/Havana", + "America/Hermosillo", + "America/Indiana/Indianapolis", + "America/Indiana/Knox", + "America/Indiana/Marengo", + "America/Indiana/Petersburg", + "America/Indiana/Tell_City", + "America/Indiana/Vevay", + "America/Indiana/Vincennes", + "America/Indiana/Winamac", + "America/Indianapolis", + "America/Inuvik", + "America/Iqaluit", + "America/Jamaica", + "America/Jujuy", + "America/Juneau", + "America/Kentucky/Louisville", + "America/Kentucky/Monticello", + "America/Knox_IN", + "America/Kralendijk", + "America/La_Paz", + "America/Lima", + "America/Los_Angeles", + "America/Louisville", + "America/Lower_Princes", + "America/Maceio", + "America/Managua", + "America/Manaus", + "America/Marigot", + "America/Martinique", + "America/Matamoros", + "America/Mazatlan", + "America/Mendoza", + "America/Menominee", + "America/Merida", + "America/Metlakatla", + "America/Mexico_City", + "America/Miquelon", + "America/Moncton", + "America/Monterrey", + "America/Montevideo", + "America/Montreal", + "America/Montserrat", + "America/Nassau", + "America/New_York", + "America/Nipigon", + "America/Nome", + "America/Noronha", + "America/North_Dakota/Beulah", + "America/North_Dakota/Center", + "America/North_Dakota/New_Salem", + "America/Ojinaga", + "America/Panama", + "America/Pangnirtung", + "America/Paramaribo", + "America/Phoenix", + "America/Port-au-Prince", + "America/Port_of_Spain", + "America/Porto_Acre", + "America/Porto_Velho", + "America/Puerto_Rico", + "America/Punta_Arenas", + "America/Rainy_River", + "America/Rankin_Inlet", + "America/Recife", + "America/Regina", + "America/Resolute", + "America/Rio_Branco", + "America/Rosario", + "America/Santa_Isabel", + "America/Santarem", + "America/Santiago", + "America/Santo_Domingo", + "America/Sao_Paulo", + "America/Scoresbysund", + "America/Shiprock", + "America/Sitka", + "America/St_Barthelemy", + "America/St_Johns", + "America/St_Kitts", + "America/St_Lucia", + "America/St_Thomas", + "America/St_Vincent", + "America/Swift_Current", + "America/Tegucigalpa", + "America/Thule", + "America/Thunder_Bay", + "America/Tijuana", + "America/Toronto", + "America/Tortola", + "America/Vancouver", + "America/Virgin", + "America/Whitehorse", + "America/Winnipeg", + "America/Yakutat", + "America/Yellowknife", + "Antarctica/Casey", + "Antarctica/Davis", + "Antarctica/DumontDUrville", + "Antarctica/Macquarie", + "Antarctica/Mawson", + "Antarctica/McMurdo", + "Antarctica/Palmer", + "Antarctica/Rothera", + "Antarctica/South_Pole", + "Antarctica/Syowa", + "Antarctica/Troll", + "Antarctica/Vostok", + "Arctic/Longyearbyen", + "Asia/Aden", + "Asia/Almaty", + "Asia/Amman", + "Asia/Anadyr", + "Asia/Aqtau", + "Asia/Aqtobe", + "Asia/Ashgabat", + "Asia/Ashkhabad", + "Asia/Atyrau", + "Asia/Baghdad", + "Asia/Bahrain", + "Asia/Baku", + "Asia/Bangkok", + "Asia/Barnaul", + "Asia/Beirut", + "Asia/Bishkek", + "Asia/Brunei", + "Asia/Calcutta", + "Asia/Chita", + "Asia/Choibalsan", + "Asia/Chongqing", + "Asia/Chungking", + "Asia/Colombo", + "Asia/Dacca", + "Asia/Damascus", + "Asia/Dhaka", + "Asia/Dili", + "Asia/Dubai", + "Asia/Dushanbe", + "Asia/Famagusta", + "Asia/Gaza", + "Asia/Harbin", + "Asia/Hebron", + "Asia/Ho_Chi_Minh", + "Asia/Hong_Kong", + "Asia/Hovd", + "Asia/Irkutsk", + "Asia/Istanbul", + "Asia/Jakarta", + "Asia/Jayapura", + "Asia/Jerusalem", + "Asia/Kabul", + "Asia/Kamchatka", + "Asia/Karachi", + "Asia/Kashgar", + "Asia/Kathmandu", + "Asia/Katmandu", + "Asia/Khandyga", + "Asia/Kolkata", + "Asia/Krasnoyarsk", + "Asia/Kuala_Lumpur", + "Asia/Kuching", + "Asia/Kuwait", + "Asia/Macao", + "Asia/Macau", + "Asia/Magadan", + "Asia/Makassar", + "Asia/Manila", + "Asia/Muscat", + "Asia/Nicosia", + "Asia/Novokuznetsk", + "Asia/Novosibirsk", + "Asia/Omsk", + "Asia/Oral", + "Asia/Phnom_Penh", + "Asia/Pontianak", + "Asia/Pyongyang", + "Asia/Qatar", + "Asia/Qostanay", + "Asia/Qyzylorda", + "Asia/Rangoon", + "Asia/Riyadh", + "Asia/Saigon", + "Asia/Sakhalin", + "Asia/Samarkand", + "Asia/Seoul", + "Asia/Shanghai", + "Asia/Singapore", + "Asia/Srednekolymsk", + "Asia/Taipei", + "Asia/Tashkent", + "Asia/Tbilisi", + "Asia/Tehran", + "Asia/Tel_Aviv", + "Asia/Thimbu", + "Asia/Thimphu", + "Asia/Tokyo", + "Asia/Tomsk", + "Asia/Ujung_Pandang", + "Asia/Ulaanbaatar", + "Asia/Ulan_Bator", + "Asia/Urumqi", + "Asia/Ust-Nera", + "Asia/Vientiane", + "Asia/Vladivostok", + "Asia/Yakutsk", + "Asia/Yangon", + "Asia/Yekaterinburg", + "Asia/Yerevan", + "Atlantic/Azores", + "Atlantic/Bermuda", + "Atlantic/Canary", + "Atlantic/Cape_Verde", + "Atlantic/Faeroe", + "Atlantic/Faroe", + "Atlantic/Jan_Mayen", + "Atlantic/Madeira", + "Atlantic/Reykjavik", + "Atlantic/South_Georgia", + "Atlantic/St_Helena", + "Atlantic/Stanley", + "Australia/ACT", + "Australia/Adelaide", + "Australia/Brisbane", + "Australia/Broken_Hill", + "Australia/Canberra", + "Australia/Currie", + "Australia/Darwin", + "Australia/Eucla", + "Australia/Hobart", + "Australia/LHI", + "Australia/Lindeman", + "Australia/Lord_Howe", + "Australia/Melbourne", + "Australia/NSW", + "Australia/North", + "Australia/Perth", + "Australia/Queensland", + "Australia/South", + "Australia/Sydney", + "Australia/Tasmania", + "Australia/Victoria", + "Australia/West", + "Australia/Yancowinna", + "Brazil/Acre", + "Brazil/DeNoronha", + "Brazil/East", + "Brazil/West", + "CET", + "CST6CDT", + "Canada/Atlantic", + "Canada/Central", + "Canada/Eastern", + "Canada/Mountain", + "Canada/Newfoundland", + "Canada/Pacific", + "Canada/Saskatchewan", + "Canada/Yukon", + "Chile/Continental", + "Chile/EasterIsland", + "Cuba", + "EET", + "EST", + "EST5EDT", + "Egypt", + "Eire", + "Etc/GMT", + "Etc/GMT+0", + "Etc/GMT+1", + "Etc/GMT+10", + "Etc/GMT+11", + "Etc/GMT+12", + "Etc/GMT+2", + "Etc/GMT+3", + "Etc/GMT+4", + "Etc/GMT+5", + "Etc/GMT+6", + "Etc/GMT+7", + "Etc/GMT+8", + "Etc/GMT+9", + "Etc/GMT-0", + "Etc/GMT-1", + "Etc/GMT-10", + "Etc/GMT-11", + "Etc/GMT-12", + "Etc/GMT-13", + "Etc/GMT-14", + "Etc/GMT-2", + "Etc/GMT-3", + "Etc/GMT-4", + "Etc/GMT-5", + "Etc/GMT-6", + "Etc/GMT-7", + "Etc/GMT-8", + "Etc/GMT-9", + "Etc/GMT0", + "Etc/Greenwich", + "Etc/UCT", + "Etc/UTC", + "Etc/Universal", + "Etc/Zulu", + "Europe/Amsterdam", + "Europe/Andorra", + "Europe/Astrakhan", + "Europe/Athens", + "Europe/Belfast", + "Europe/Belgrade", + "Europe/Berlin", + "Europe/Bratislava", + "Europe/Brussels", + "Europe/Bucharest", + "Europe/Budapest", + "Europe/Busingen", + "Europe/Chisinau", + "Europe/Copenhagen", + "Europe/Dublin", + "Europe/Gibraltar", + "Europe/Guernsey", + "Europe/Helsinki", + "Europe/Isle_of_Man", + "Europe/Istanbul", + "Europe/Jersey", + "Europe/Kaliningrad", + "Europe/Kiev", + "Europe/Kirov", + "Europe/Lisbon", + "Europe/Ljubljana", + "Europe/London", + "Europe/Luxembourg", + "Europe/Madrid", + "Europe/Malta", + "Europe/Mariehamn", + "Europe/Minsk", + "Europe/Monaco", + "Europe/Moscow", + "Europe/Nicosia", + "Europe/Oslo", + "Europe/Paris", + "Europe/Podgorica", + "Europe/Prague", + "Europe/Riga", + "Europe/Rome", + "Europe/Samara", + "Europe/San_Marino", + "Europe/Sarajevo", + "Europe/Saratov", + "Europe/Simferopol", + "Europe/Skopje", + "Europe/Sofia", + "Europe/Stockholm", + "Europe/Tallinn", + "Europe/Tirane", + "Europe/Tiraspol", + "Europe/Ulyanovsk", + "Europe/Uzhgorod", + "Europe/Vaduz", + "Europe/Vatican", + "Europe/Vienna", + "Europe/Vilnius", + "Europe/Volgograd", + "Europe/Warsaw", + "Europe/Zagreb", + "Europe/Zaporozhye", + "Europe/Zurich", + "GB", + "GB-Eire", + "GMT", + "GMT+0", + "GMT-0", + "GMT0", + "Greenwich", + "HST", + "Hongkong", + "Iceland", + "Indian/Antananarivo", + "Indian/Chagos", + "Indian/Christmas", + "Indian/Cocos", + "Indian/Comoro", + "Indian/Kerguelen", + "Indian/Mahe", + "Indian/Maldives", + "Indian/Mauritius", + "Indian/Mayotte", + "Indian/Reunion", + "Iran", + "Israel", + "Jamaica", + "Japan", + "Kwajalein", + "Libya", + "MET", + "MST", + "MST7MDT", + "Mexico/BajaNorte", + "Mexico/BajaSur", + "Mexico/General", + "NZ", + "NZ-CHAT", + "Navajo", + "PRC", + "PST8PDT", + "Pacific/Apia", + "Pacific/Auckland", + "Pacific/Bougainville", + "Pacific/Chatham", + "Pacific/Chuuk", + "Pacific/Easter", + "Pacific/Efate", + "Pacific/Enderbury", + "Pacific/Fakaofo", + "Pacific/Fiji", + "Pacific/Funafuti", + "Pacific/Galapagos", + "Pacific/Gambier", + "Pacific/Guadalcanal", + "Pacific/Guam", + "Pacific/Honolulu", + "Pacific/Johnston", + "Pacific/Kiritimati", + "Pacific/Kosrae", + "Pacific/Kwajalein", + "Pacific/Majuro", + "Pacific/Marquesas", + "Pacific/Midway", + "Pacific/Nauru", + "Pacific/Niue", + "Pacific/Norfolk", + "Pacific/Noumea", + "Pacific/Pago_Pago", + "Pacific/Palau", + "Pacific/Pitcairn", + "Pacific/Pohnpei", + "Pacific/Ponape", + "Pacific/Port_Moresby", + "Pacific/Rarotonga", + "Pacific/Saipan", + "Pacific/Samoa", + "Pacific/Tahiti", + "Pacific/Tarawa", + "Pacific/Tongatapu", + "Pacific/Truk", + "Pacific/Wake", + "Pacific/Wallis", + "Pacific/Yap", + "Poland", + "Portugal", + "ROC", + "ROK", + "Singapore", + "Turkey", + "UCT", + "US/Alaska", + "US/Aleutian", + "US/Arizona", + "US/Central", + "US/East-Indiana", + "US/Eastern", + "US/Hawaii", + "US/Indiana-Starke", + "US/Michigan", + "US/Mountain", + "US/Pacific", + "US/Samoa", + "UTC", + "Universal", + "W-SU", + "WET", + "Zulu", + nullptr}; std::vector<std::string> AllTimeZoneNames() { std::vector<std::string> names;
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_detail.cc b/third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_detail.cc index cb40b6b..0b07e397 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_detail.cc +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_detail.cc
@@ -18,7 +18,10 @@ #include <ostream> #include <sstream> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { namespace detail { @@ -87,4 +90,5 @@ } // namespace detail } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_test.cc b/third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_test.cc index 10a5ffe..be894d70 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_test.cc +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_test.cc
@@ -21,8 +21,10 @@ #include <type_traits> #include "gtest/gtest.h" +#include "absl/base/config.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -1014,19 +1016,13 @@ int day; } leap_day; // The date of the day after Feb 28. } kLeapYearTable[]{ - {1900, 365, {3, 1}}, - {1999, 365, {3, 1}}, + {1900, 365, {3, 1}}, {1999, 365, {3, 1}}, {2000, 366, {2, 29}}, // leap year - {2001, 365, {3, 1}}, - {2002, 365, {3, 1}}, - {2003, 365, {3, 1}}, - {2004, 366, {2, 29}}, // leap year - {2005, 365, {3, 1}}, - {2006, 365, {3, 1}}, - {2007, 365, {3, 1}}, - {2008, 366, {2, 29}}, // leap year - {2009, 365, {3, 1}}, - {2100, 365, {3, 1}}, + {2001, 365, {3, 1}}, {2002, 365, {3, 1}}, + {2003, 365, {3, 1}}, {2004, 366, {2, 29}}, // leap year + {2005, 365, {3, 1}}, {2006, 365, {3, 1}}, + {2007, 365, {3, 1}}, {2008, 366, {2, 29}}, // leap year + {2009, 365, {3, 1}}, {2100, 365, {3, 1}}, }; for (const auto& e : kLeapYearTable) { @@ -1056,4 +1052,5 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc index b0d159a2..303c024 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc
@@ -20,7 +20,10 @@ #include <cstring> #include <string> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -59,11 +62,9 @@ const char* const ep = kFixedZonePrefix + prefix_len; if (name.size() != prefix_len + 9) // <prefix>+99:99:99 return false; - if (!std::equal(kFixedZonePrefix, ep, name.begin())) - return false; + if (!std::equal(kFixedZonePrefix, ep, name.begin())) return false; const char* np = name.data() + prefix_len; - if (np[0] != '+' && np[0] != '-') - return false; + if (np[0] != '+' && np[0] != '-') return false; if (np[3] != ':' || np[6] != ':') // see note below about large offsets return false; @@ -88,29 +89,29 @@ // offsets and to (somewhat) limit the total number of zones. return "UTC"; } - int seconds = static_cast<int>(offset.count()); - const char sign = (seconds < 0 ? '-' : '+'); - int minutes = seconds / 60; - seconds %= 60; + int offset_seconds = static_cast<int>(offset.count()); + const char sign = (offset_seconds < 0 ? '-' : '+'); + int offset_minutes = offset_seconds / 60; + offset_seconds %= 60; if (sign == '-') { - if (seconds > 0) { - seconds -= 60; - minutes += 1; + if (offset_seconds > 0) { + offset_seconds -= 60; + offset_minutes += 1; } - seconds = -seconds; - minutes = -minutes; + offset_seconds = -offset_seconds; + offset_minutes = -offset_minutes; } - int hours = minutes / 60; - minutes %= 60; + int offset_hours = offset_minutes / 60; + offset_minutes %= 60; const std::size_t prefix_len = sizeof(kFixedZonePrefix) - 1; char buf[prefix_len + sizeof("-24:00:00")]; char* ep = std::copy(kFixedZonePrefix, kFixedZonePrefix + prefix_len, buf); *ep++ = sign; - ep = Format02d(ep, hours); + ep = Format02d(ep, offset_hours); *ep++ = ':'; - ep = Format02d(ep, minutes); + ep = Format02d(ep, offset_minutes); *ep++ = ':'; - ep = Format02d(ep, seconds); + ep = Format02d(ep, offset_seconds); *ep++ = '\0'; assert(ep == buf + sizeof(buf)); return buf; @@ -135,4 +136,5 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.h b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.h index 9c1f5e7..e74a0bb 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.h +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.h
@@ -17,9 +17,11 @@ #include <string> +#include "absl/base/config.h" #include "absl/time/internal/cctz/include/cctz/time_zone.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -44,6 +46,7 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_FIXED_H_
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc index 84e280b..179975e0 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc
@@ -13,17 +13,18 @@ // limitations under the License. #if !defined(HAS_STRPTIME) -# if !defined(_MSC_VER) && !defined(__MINGW32__) -# define HAS_STRPTIME 1 // assume everyone has strptime() except windows -# endif +#if !defined(_MSC_VER) && !defined(__MINGW32__) +#define HAS_STRPTIME 1 // assume everyone has strptime() except windows +#endif #endif #if defined(HAS_STRPTIME) && HAS_STRPTIME -# if !defined(_XOPEN_SOURCE) -# define _XOPEN_SOURCE // Definedness suffices for strptime. -# endif +#if !defined(_XOPEN_SOURCE) +#define _XOPEN_SOURCE // Definedness suffices for strptime. +#endif #endif +#include "absl/base/config.h" #include "absl/time/internal/cctz/include/cctz/time_zone.h" // Include time.h directly since, by C++ standards, ctime doesn't have to @@ -48,6 +49,7 @@ #include "time_zone_if.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { namespace detail { @@ -187,7 +189,7 @@ // strftime(3) returns the number of characters placed in the output // array (which may be 0 characters). It also returns 0 to indicate // an error, like the array wasn't large enough. To accommodate this, - // the following code grows the buffer size from 2x the format std::string + // the following code grows the buffer size from 2x the format string // length up to 32x. for (std::size_t i = 2; i != 32; i *= 2) { std::size_t buf_size = fmt.size() * i; @@ -502,8 +504,9 @@ bp = ep; if (n > 0) { if (n > kDigits10_64) n = kDigits10_64; - bp = Format64(bp, n, (n > 15) ? fs.count() * kExp10[n - 15] - : fs.count() / kExp10[15 - n]); + bp = Format64(bp, n, + (n > 15) ? fs.count() * kExp10[n - 15] + : fs.count() / kExp10[15 - n]); if (*np == 'S') *--bp = '.'; } if (*np == 'S') bp = Format02d(bp, al.cs.second()); @@ -720,10 +723,9 @@ data = ParseZone(data, &zone); continue; case 's': - data = ParseInt(data, 0, - std::numeric_limits<std::int_fast64_t>::min(), - std::numeric_limits<std::int_fast64_t>::max(), - &percent_s); + data = + ParseInt(data, 0, std::numeric_limits<std::int_fast64_t>::min(), + std::numeric_limits<std::int_fast64_t>::max(), &percent_s); if (data != nullptr) saw_percent_s = true; continue; case ':': @@ -837,7 +839,7 @@ // Skip any remaining whitespace. while (std::isspace(*data)) ++data; - // parse() must consume the entire input std::string. + // parse() must consume the entire input string. if (*data != '\0') { if (err != nullptr) *err = "Illegal trailing data in input string"; return false; @@ -916,4 +918,5 @@ } // namespace detail } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format_test.cc b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format_test.cc index 705ccdcd..87382e15 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format_test.cc +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format_test.cc
@@ -12,20 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "absl/time/internal/cctz/include/cctz/time_zone.h" - #include <chrono> #include <iomanip> #include <sstream> #include <string> -#include "absl/time/internal/cctz/include/cctz/civil_time.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "absl/base/config.h" +#include "absl/time/internal/cctz/include/cctz/civil_time.h" +#include "absl/time/internal/cctz/include/cctz/time_zone.h" namespace chrono = std::chrono; namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -48,10 +49,10 @@ } while (0) const char RFC3339_full[] = "%Y-%m-%dT%H:%M:%E*S%Ez"; -const char RFC3339_sec[] = "%Y-%m-%dT%H:%M:%S%Ez"; +const char RFC3339_sec[] = "%Y-%m-%dT%H:%M:%S%Ez"; const char RFC1123_full[] = "%a, %d %b %Y %H:%M:%S %z"; -const char RFC1123_no_wday[] = "%d %b %Y %H:%M:%S %z"; +const char RFC1123_no_wday[] = "%d %b %Y %H:%M:%S %z"; // A helper that tests the given format specifier by itself, and with leading // and trailing characters. For example: TestFormatSpecifier(tp, "%a", "Thu"). @@ -88,8 +89,11 @@ format(kFmt, chrono::time_point_cast<chrono::milliseconds>(t0), utc)); EXPECT_EQ("03:04:05", format(kFmt, chrono::time_point_cast<chrono::seconds>(t0), utc)); - EXPECT_EQ("03:04:05", - format(kFmt, chrono::time_point_cast<absl::time_internal::cctz::seconds>(t0), utc)); + EXPECT_EQ( + "03:04:05", + format(kFmt, + chrono::time_point_cast<absl::time_internal::cctz::seconds>(t0), + utc)); EXPECT_EQ("03:04:00", format(kFmt, chrono::time_point_cast<chrono::minutes>(t0), utc)); EXPECT_EQ("03:00:00", @@ -110,12 +114,10 @@ EXPECT_EQ( "12:34:56.012345678901234", detail::format(kFmt, tp, detail::femtoseconds(12345678901234), utc)); - EXPECT_EQ( - "12:34:56.001234567890123", - detail::format(kFmt, tp, detail::femtoseconds(1234567890123), utc)); - EXPECT_EQ( - "12:34:56.000123456789012", - detail::format(kFmt, tp, detail::femtoseconds(123456789012), utc)); + EXPECT_EQ("12:34:56.001234567890123", + detail::format(kFmt, tp, detail::femtoseconds(1234567890123), utc)); + EXPECT_EQ("12:34:56.000123456789012", + detail::format(kFmt, tp, detail::femtoseconds(123456789012), utc)); EXPECT_EQ("12:34:56.000000000000123", detail::format(kFmt, tp, detail::femtoseconds(123), utc)); @@ -765,7 +767,7 @@ EXPECT_TRUE(load_time_zone("America/Los_Angeles", &tz)); time_point<chrono::nanoseconds> tp; - // We can parse a std::string without a UTC offset if we supply a timezone. + // We can parse a string without a UTC offset if we supply a timezone. EXPECT_TRUE(parse("%Y-%m-%d %H:%M:%S", "2013-06-28 19:08:09", tz, &tp)); ExpectTime(tp, tz, 2013, 6, 28, 19, 8, 9, -7 * 60 * 60, true, "PDT"); @@ -1250,9 +1252,9 @@ const auto expected = chrono::system_clock::from_time_t(0) + chrono::nanoseconds(micros * 1000 + ns); for (int ps = 0; ps < 1000; ps += 250) { - std::ostringstream oss; + std::ostringstream ps_oss; oss << std::setfill('0') << std::setw(3) << ps; - const std::string input = nanos + oss.str() + "999"; + const std::string input = nanos + ps_oss.str() + "999"; EXPECT_TRUE(parse("%E*f", input, tz, &tp)); EXPECT_EQ(expected + chrono::nanoseconds(ps) / 1000, tp) << input; } @@ -1416,8 +1418,8 @@ parse(RFC3339_sec, "-292277022657-01-27T08:29:51+01:00", utc, &tp)); // tests max/min civil-second overflow - EXPECT_FALSE(parse(RFC3339_sec, "9223372036854775807-12-31T23:59:59-00:01", - utc, &tp)); + EXPECT_FALSE( + parse(RFC3339_sec, "9223372036854775807-12-31T23:59:59-00:01", utc, &tp)); EXPECT_FALSE(parse(RFC3339_sec, "-9223372036854775808-01-01T00:00:00+00:01", utc, &tp)); @@ -1474,7 +1476,8 @@ TEST(FormatParse, RoundTripDistantFuture) { const time_zone utc = utc_time_zone(); - const time_point<absl::time_internal::cctz::seconds> in = time_point<absl::time_internal::cctz::seconds>::max(); + const time_point<absl::time_internal::cctz::seconds> in = + time_point<absl::time_internal::cctz::seconds>::max(); const std::string s = format(RFC3339_full, in, utc); time_point<absl::time_internal::cctz::seconds> out; EXPECT_TRUE(parse(RFC3339_full, s, utc, &out)) << s; @@ -1483,7 +1486,8 @@ TEST(FormatParse, RoundTripDistantPast) { const time_zone utc = utc_time_zone(); - const time_point<absl::time_internal::cctz::seconds> in = time_point<absl::time_internal::cctz::seconds>::min(); + const time_point<absl::time_internal::cctz::seconds> in = + time_point<absl::time_internal::cctz::seconds>::min(); const std::string s = format(RFC3339_full, in, utc); time_point<absl::time_internal::cctz::seconds> out; EXPECT_TRUE(parse(RFC3339_full, s, utc, &out)) << s; @@ -1492,4 +1496,5 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc index 09aaee5..0319b2f 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc
@@ -13,10 +13,13 @@ // limitations under the License. #include "time_zone_if.h" + +#include "absl/base/config.h" #include "time_zone_info.h" #include "time_zone_libc.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -38,4 +41,5 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.h b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.h index d000b7a..32c0891 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.h +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.h
@@ -20,10 +20,12 @@ #include <memory> #include <string> +#include "absl/base/config.h" #include "absl/time/internal/cctz/include/cctz/civil_time.h" #include "absl/time/internal/cctz/include/cctz/time_zone.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -38,8 +40,7 @@ virtual time_zone::absolute_lookup BreakTime( const time_point<seconds>& tp) const = 0; - virtual time_zone::civil_lookup MakeTime( - const civil_second& cs) const = 0; + virtual time_zone::civil_lookup MakeTime(const civil_second& cs) const = 0; virtual bool NextTransition(const time_point<seconds>& tp, time_zone::civil_transition* trans) const = 0; @@ -58,15 +59,18 @@ // Unix clock are second aligned, but not that they share an epoch. inline std::int_fast64_t ToUnixSeconds(const time_point<seconds>& tp) { return (tp - std::chrono::time_point_cast<seconds>( - std::chrono::system_clock::from_time_t(0))).count(); + std::chrono::system_clock::from_time_t(0))) + .count(); } inline time_point<seconds> FromUnixSeconds(std::int_fast64_t t) { return std::chrono::time_point_cast<seconds>( - std::chrono::system_clock::from_time_t(0)) + seconds(t); + std::chrono::system_clock::from_time_t(0)) + + seconds(t); } } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_IF_H_
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc index 3cbc674..030ae0e1 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc
@@ -14,14 +14,17 @@ #include "time_zone_impl.h" +#include <deque> #include <mutex> #include <string> #include <unordered_map> #include <utility> +#include "absl/base/config.h" #include "time_zone_fixed.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -33,13 +36,16 @@ TimeZoneImplByName* time_zone_map = nullptr; // Mutual exclusion for time_zone_map. -std::mutex time_zone_mutex; +std::mutex& TimeZoneMutex() { + // This mutex is intentionally "leaked" to avoid the static deinitialization + // order fiasco (std::mutex's destructor is not trivial on many platforms). + static std::mutex* time_zone_mutex = new std::mutex; + return *time_zone_mutex; +} } // namespace -time_zone time_zone::Impl::UTC() { - return time_zone(UTCImpl()); -} +time_zone time_zone::Impl::UTC() { return time_zone(UTCImpl()); } bool time_zone::Impl::LoadTimeZone(const std::string& name, time_zone* tz) { const time_zone::Impl* const utc_impl = UTCImpl(); @@ -54,7 +60,7 @@ // Then check, under a shared lock, whether the time zone has already // been loaded. This is the common path. TODO: Move to shared_mutex. { - std::lock_guard<std::mutex> lock(time_zone_mutex); + std::lock_guard<std::mutex> lock(TimeZoneMutex()); if (time_zone_map != nullptr) { TimeZoneImplByName::const_iterator itr = time_zone_map->find(name); if (itr != time_zone_map->end()) { @@ -65,7 +71,7 @@ } // Now check again, under an exclusive lock. - std::lock_guard<std::mutex> lock(time_zone_mutex); + std::lock_guard<std::mutex> lock(TimeZoneMutex()); if (time_zone_map == nullptr) time_zone_map = new TimeZoneImplByName; const Impl*& impl = (*time_zone_map)[name]; if (impl == nullptr) { @@ -84,10 +90,16 @@ } void time_zone::Impl::ClearTimeZoneMapTestOnly() { - std::lock_guard<std::mutex> lock(time_zone_mutex); + std::lock_guard<std::mutex> lock(TimeZoneMutex()); if (time_zone_map != nullptr) { - // Existing time_zone::Impl* entries are in the wild, so we simply - // leak them. Future requests will result in reloading the data. + // Existing time_zone::Impl* entries are in the wild, so we can't delete + // them. Instead, we move them to a private container, where they are + // logically unreachable but not "leaked". Future requests will result + // in reloading the data. + static auto* cleared = new std::deque<const time_zone::Impl*>; + for (const auto& element : *time_zone_map) { + cleared->push_back(element.second); + } time_zone_map->clear(); } } @@ -105,4 +117,5 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h index b73fad9bb..7d747ba9 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h
@@ -18,12 +18,14 @@ #include <memory> #include <string> +#include "absl/base/config.h" #include "absl/time/internal/cctz/include/cctz/civil_time.h" #include "absl/time/internal/cctz/include/cctz/time_zone.h" #include "time_zone_if.h" #include "time_zone_info.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -69,7 +71,7 @@ return zone_->PrevTransition(tp, trans); } - // Returns an implementation-defined version std::string for this time zone. + // Returns an implementation-defined version string for this time zone. std::string Version() const { return zone_->Version(); } // Returns an implementation-defined description of this time zone. @@ -85,6 +87,7 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_IMPL_H_
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc index 9db72e0..665fb42 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc
@@ -45,11 +45,13 @@ #include <sstream> #include <string> +#include "absl/base/config.h" #include "absl/time/internal/cctz/include/cctz/civil_time.h" #include "time_zone_fixed.h" #include "time_zone_posix.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -65,8 +67,8 @@ // The day offsets of the beginning of each (1-based) month in non-leap and // leap years respectively (e.g., 335 days before December in a leap year). const std::int_least16_t kMonthOffsets[2][1 + 12 + 1] = { - {-1, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, - {-1, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}, + {-1, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, + {-1, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}, }; // We reject leap-second encoded zoneinfo and so assume 60-second minutes. @@ -77,8 +79,8 @@ // Like kDaysPerYear[] but scaled up by a factor of kSecsPerDay. const std::int_least32_t kSecsPerYear[2] = { - 365 * kSecsPerDay, - 366 * kSecsPerDay, + 365 * kSecsPerDay, + 366 * kSecsPerDay, }; // Single-byte, unsigned numeric values are encoded directly. @@ -172,8 +174,8 @@ } inline civil_second YearShift(const civil_second& cs, year_t shift) { - return civil_second(cs.year() + shift, cs.month(), cs.day(), - cs.hour(), cs.minute(), cs.second()); + return civil_second(cs.year() + shift, cs.month(), cs.day(), cs.hour(), + cs.minute(), cs.second()); } } // namespace @@ -216,7 +218,7 @@ default_transition_type_ = 0; abbreviations_ = FixedOffsetToAbbr(offset); abbreviations_.append(1, '\0'); // add NUL - future_spec_.clear(); // never needed for a fixed-offset zone + future_spec_.clear(); // never needed for a fixed-offset zone extended_ = false; tt.civil_max = LocalTime(seconds::max().count(), tt).cs; @@ -393,31 +395,24 @@ bool TimeZoneInfo::Load(const std::string& name, ZoneInfoSource* zip) { // Read and validate the header. tzhead tzh; - if (zip->Read(&tzh, sizeof(tzh)) != sizeof(tzh)) - return false; + if (zip->Read(&tzh, sizeof(tzh)) != sizeof(tzh)) return false; if (strncmp(tzh.tzh_magic, TZ_MAGIC, sizeof(tzh.tzh_magic)) != 0) return false; Header hdr; - if (!hdr.Build(tzh)) - return false; + if (!hdr.Build(tzh)) return false; std::size_t time_len = 4; if (tzh.tzh_version[0] != '\0') { // Skip the 4-byte data. - if (zip->Skip(hdr.DataLength(time_len)) != 0) - return false; + if (zip->Skip(hdr.DataLength(time_len)) != 0) return false; // Read and validate the header for the 8-byte data. - if (zip->Read(&tzh, sizeof(tzh)) != sizeof(tzh)) - return false; + if (zip->Read(&tzh, sizeof(tzh)) != sizeof(tzh)) return false; if (strncmp(tzh.tzh_magic, TZ_MAGIC, sizeof(tzh.tzh_magic)) != 0) return false; - if (tzh.tzh_version[0] == '\0') - return false; - if (!hdr.Build(tzh)) - return false; + if (tzh.tzh_version[0] == '\0') return false; + if (!hdr.Build(tzh)) return false; time_len = 8; } - if (hdr.typecnt == 0) - return false; + if (hdr.typecnt == 0) return false; if (hdr.leapcnt != 0) { // This code assumes 60-second minutes so we do not want // the leap-second encoded zoneinfo. We could reverse the @@ -425,16 +420,13 @@ // so currently we simply reject such data. return false; } - if (hdr.ttisstdcnt != 0 && hdr.ttisstdcnt != hdr.typecnt) - return false; - if (hdr.ttisutcnt != 0 && hdr.ttisutcnt != hdr.typecnt) - return false; + if (hdr.ttisstdcnt != 0 && hdr.ttisstdcnt != hdr.typecnt) return false; + if (hdr.ttisutcnt != 0 && hdr.ttisutcnt != hdr.typecnt) return false; // Read the data into a local buffer. std::size_t len = hdr.DataLength(time_len); std::vector<char> tbuf(len); - if (zip->Read(tbuf.data(), len) != len) - return false; + if (zip->Read(tbuf.data(), len) != len) return false; const char* bp = tbuf.data(); // Decode and validate the transitions. @@ -452,10 +444,8 @@ bool seen_type_0 = false; for (std::size_t i = 0; i != hdr.timecnt; ++i) { transitions_[i].type_index = Decode8(bp++); - if (transitions_[i].type_index >= hdr.typecnt) - return false; - if (transitions_[i].type_index == 0) - seen_type_0 = true; + if (transitions_[i].type_index >= hdr.typecnt) return false; + if (transitions_[i].type_index == 0) seen_type_0 = true; } // Decode and validate the transition types. @@ -469,8 +459,7 @@ bp += 4; transition_types_[i].is_dst = (Decode8(bp++) != 0); transition_types_[i].abbr_index = Decode8(bp++); - if (transition_types_[i].abbr_index >= hdr.charcnt) - return false; + if (transition_types_[i].abbr_index >= hdr.charcnt) return false; } // Determine the before-first-transition type. @@ -479,13 +468,10 @@ std::uint_fast8_t index = 0; if (transition_types_[0].is_dst) { index = transitions_[0].type_index; - while (index != 0 && transition_types_[index].is_dst) - --index; + while (index != 0 && transition_types_[index].is_dst) --index; } - while (index != hdr.typecnt && transition_types_[index].is_dst) - ++index; - if (index != hdr.typecnt) - default_transition_type_ = index; + while (index != hdr.typecnt && transition_types_[index].is_dst) ++index; + if (index != hdr.typecnt) default_transition_type_ = index; } // Copy all the abbreviations. @@ -509,11 +495,9 @@ unsigned char ch; // all non-EOF results are positive return (azip->Read(&ch, 1) == 1) ? ch : EOF; }; - if (get_char(zip) != '\n') - return false; + if (get_char(zip) != '\n') return false; for (int c = get_char(zip); c != '\n'; c = get_char(zip)) { - if (c == EOF) - return false; + if (c == EOF) return false; future_spec_.push_back(static_cast<char>(c)); } } @@ -522,7 +506,7 @@ // If we did not find version information during the standard loading // process (as of tzh_version '3' that is unsupported), then ask the - // ZoneInfoSource for any out-of-bound version std::string it may be privy to. + // ZoneInfoSource for any out-of-bound version string it may be privy to. if (version_.empty()) { version_ = zip->Version(); } @@ -624,18 +608,18 @@ : fp_(fp, fclose), len_(len) {} private: - std::unique_ptr<FILE, int(*)(FILE*)> fp_; + std::unique_ptr<FILE, int (*)(FILE*)> fp_; std::size_t len_; }; std::unique_ptr<ZoneInfoSource> FileZoneInfoSource::Open( const std::string& name) { // Use of the "file:" prefix is intended for testing purposes only. - if (name.compare(0, 5, "file:") == 0) return Open(name.substr(5)); + const std::size_t pos = (name.compare(0, 5, "file:") == 0) ? 5 : 0; // Map the time-zone name to a path name. std::string path; - if (name.empty() || name[0] != '/') { + if (pos == name.size() || name[pos] != '/') { const char* tzdir = "/usr/share/zoneinfo"; char* tzdir_env = nullptr; #if defined(_MSC_VER) @@ -650,16 +634,16 @@ free(tzdir_env); #endif } - path += name; + path.append(name, pos, std::string::npos); // Open the zoneinfo file. FILE* fp = FOpen(path.c_str(), "rb"); if (fp == nullptr) return nullptr; std::size_t length = 0; if (fseek(fp, 0, SEEK_END) == 0) { - long pos = ftell(fp); - if (pos >= 0) { - length = static_cast<std::size_t>(pos); + long offset = ftell(fp); + if (offset >= 0) { + length = static_cast<std::size_t>(offset); } rewind(fp); } @@ -680,7 +664,7 @@ std::unique_ptr<ZoneInfoSource> AndroidZoneInfoSource::Open( const std::string& name) { // Use of the "file:" prefix is intended for testing purposes only. - if (name.compare(0, 5, "file:") == 0) return Open(name.substr(5)); + const std::size_t pos = (name.compare(0, 5, "file:") == 0) ? 5 : 0; // See Android's libc/tzcode/bionic.cpp for additional information. for (const char* tzdata : {"/data/misc/zoneinfo/current/tzdata", @@ -709,7 +693,7 @@ const std::int_fast32_t length = Decode32(ebuf + 44); if (start < 0 || length < 0) break; ebuf[40] = '\0'; // ensure zone name is NUL terminated - if (strcmp(name.c_str(), ebuf) == 0) { + if (strcmp(name.c_str() + pos, ebuf) == 0) { if (fseek(fp.get(), static_cast<long>(start), SEEK_SET) != 0) break; return std::unique_ptr<ZoneInfoSource>(new AndroidZoneInfoSource( fp.release(), static_cast<std::size_t>(length), vers)); @@ -748,13 +732,13 @@ // A civil time in "+offset" looks like (time+offset) in UTC. // Note: We perform two additions in the civil_second domain to // sidestep the chance of overflow in (unix_time + tt.utc_offset). - return {(civil_second() + unix_time) + tt.utc_offset, - tt.utc_offset, tt.is_dst, &abbreviations_[tt.abbr_index]}; + return {(civil_second() + unix_time) + tt.utc_offset, tt.utc_offset, + tt.is_dst, &abbreviations_[tt.abbr_index]}; } // BreakTime() translation for a particular transition. -time_zone::absolute_lookup TimeZoneInfo::LocalTime( - std::int_fast64_t unix_time, const Transition& tr) const { +time_zone::absolute_lookup TimeZoneInfo::LocalTime(std::int_fast64_t unix_time, + const Transition& tr) const { const TransitionType& tt = transition_types_[tr.type_index]; // Note: (unix_time - tr.unix_time) will never overflow as we // have ensured that there is always a "nearby" transition. @@ -897,9 +881,7 @@ return MakeUnique(tr->unix_time + (cs - tr->civil_sec)); } -std::string TimeZoneInfo::Version() const { - return version_; -} +std::string TimeZoneInfo::Version() const { return version_; } std::string TimeZoneInfo::Description() const { std::ostringstream oss; @@ -921,8 +903,8 @@ } std::int_fast64_t unix_time = ToUnixSeconds(tp); const Transition target = {unix_time, 0, civil_second(), civil_second()}; - const Transition* tr = std::upper_bound(begin, end, target, - Transition::ByUnixTime()); + const Transition* tr = + std::upper_bound(begin, end, target, Transition::ByUnixTime()); for (; tr != end; ++tr) { // skip no-op transitions std::uint_fast8_t prev_type_index = (tr == begin) ? default_transition_type_ : tr[-1].type_index; @@ -956,8 +938,8 @@ unix_time += 1; // ceils } const Transition target = {unix_time, 0, civil_second(), civil_second()}; - const Transition* tr = std::lower_bound(begin, end, target, - Transition::ByUnixTime()); + const Transition* tr = + std::lower_bound(begin, end, target, Transition::ByUnixTime()); for (; tr != begin; --tr) { // skip no-op transitions std::uint_fast8_t prev_type_index = (tr - 1 == begin) ? default_transition_type_ : tr[-2].type_index; @@ -972,4 +954,5 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h index 81cd402f..2a10c06 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h
@@ -21,6 +21,7 @@ #include <string> #include <vector> +#include "absl/base/config.h" #include "absl/time/internal/cctz/include/cctz/civil_time.h" #include "absl/time/internal/cctz/include/cctz/time_zone.h" #include "absl/time/internal/cctz/include/cctz/zone_info_source.h" @@ -28,6 +29,7 @@ #include "tzfile.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -72,8 +74,7 @@ // TimeZoneIf implementations. time_zone::absolute_lookup BreakTime( const time_point<seconds>& tp) const override; - time_zone::civil_lookup MakeTime( - const civil_second& cs) const override; + time_zone::civil_lookup MakeTime(const civil_second& cs) const override; bool NextTransition(const time_point<seconds>& tp, time_zone::civil_transition* trans) const override; bool PrevTransition(const time_point<seconds>& tp, @@ -82,7 +83,7 @@ std::string Description() const override; private: - struct Header { // counts of: + struct Header { // counts of: std::size_t timecnt; // transition times std::size_t typecnt; // transition types std::size_t charcnt; // zone abbreviation characters @@ -114,7 +115,7 @@ std::vector<Transition> transitions_; // ordered by unix_time and civil_sec std::vector<TransitionType> transition_types_; // distinct transition types - std::uint_fast8_t default_transition_type_; // for before first transition + std::uint_fast8_t default_transition_type_; // for before first transition std::string abbreviations_; // all the NUL-terminated abbreviations std::string version_; // the tzdata version if available @@ -131,6 +132,7 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_INFO_H_
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc index 6095e764..47cf84c 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc
@@ -23,10 +23,12 @@ #include <limits> #include <utility> +#include "absl/base/config.h" #include "absl/time/internal/cctz/include/cctz/civil_time.h" #include "absl/time/internal/cctz/include/cctz/time_zone.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -84,9 +86,7 @@ } #endif // tm_gmtoff #if defined(tm_zone) -auto tm_zone(const std::tm& tm) -> decltype(tm.tm_zone) { - return tm.tm_zone; -} +auto tm_zone(const std::tm& tm) -> decltype(tm.tm_zone) { return tm.tm_zone; } #elif defined(__tm_zone) auto tm_zone(const std::tm& tm) -> decltype(tm.__tm_zone) { return tm.__tm_zone; @@ -103,19 +103,19 @@ #endif // tm_zone #endif -inline std::tm* gm_time(const std::time_t *timep, std::tm *result) { +inline std::tm* gm_time(const std::time_t* timep, std::tm* result) { #if defined(_WIN32) || defined(_WIN64) - return gmtime_s(result, timep) ? nullptr : result; + return gmtime_s(result, timep) ? nullptr : result; #else - return gmtime_r(timep, result); + return gmtime_r(timep, result); #endif } -inline std::tm* local_time(const std::time_t *timep, std::tm *result) { +inline std::tm* local_time(const std::time_t* timep, std::tm* result) { #if defined(_WIN32) || defined(_WIN64) - return localtime_s(result, timep) ? nullptr : result; + return localtime_s(result, timep) ? nullptr : result; #else - return localtime_r(timep, result); + return localtime_r(timep, result); #endif } @@ -208,8 +208,8 @@ } const year_t year = tmp->tm_year + year_t{1900}; - al.cs = civil_second(year, tmp->tm_mon + 1, tmp->tm_mday, - tmp->tm_hour, tmp->tm_min, tmp->tm_sec); + al.cs = civil_second(year, tmp->tm_mon + 1, tmp->tm_mday, tmp->tm_hour, + tmp->tm_min, tmp->tm_sec); al.offset = static_cast<int>(tm_gmtoff(*tmp)); al.abbr = local_ ? tm_zone(*tmp) : "UTC"; // as expected by cctz al.is_dst = tmp->tm_isdst > 0; @@ -304,4 +304,5 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.h b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.h index 0d18e9a7..1da9039 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.h +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.h
@@ -17,9 +17,11 @@ #include <string> +#include "absl/base/config.h" #include "time_zone_if.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -33,8 +35,7 @@ // TimeZoneIf implementations. time_zone::absolute_lookup BreakTime( const time_point<seconds>& tp) const override; - time_zone::civil_lookup MakeTime( - const civil_second& cs) const override; + time_zone::civil_lookup MakeTime(const civil_second& cs) const override; bool NextTransition(const time_point<seconds>& tp, time_zone::civil_transition* trans) const override; bool PrevTransition(const time_point<seconds>& tp, @@ -48,6 +49,7 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_LIBC_H_
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc index 3c53dd1..efdea64b 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc
@@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "absl/base/config.h" #include "absl/time/internal/cctz/include/cctz/time_zone.h" #if defined(__ANDROID__) @@ -23,6 +24,7 @@ #if defined(__APPLE__) #include <CoreFoundation/CFTimeZone.h> + #include <vector> #endif @@ -34,6 +36,7 @@ #include "time_zone_impl.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -66,9 +69,7 @@ } // namespace #endif -std::string time_zone::name() const { - return effective_impl().Name(); -} +std::string time_zone::name() const { return effective_impl().Name(); } time_zone::absolute_lookup time_zone::lookup( const time_point<seconds>& tp) const { @@ -89,9 +90,7 @@ return effective_impl().PrevTransition(tp, trans); } -std::string time_zone::version() const { - return effective_impl().Version(); -} +std::string time_zone::version() const { return effective_impl().Version(); } std::string time_zone::description() const { return effective_impl().Description(); @@ -184,4 +183,5 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup_test.cc b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup_test.cc index 42dd6d55..35911ce 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup_test.cc +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup_test.cc
@@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "absl/time/internal/cctz/include/cctz/time_zone.h" - #include <chrono> #include <cstddef> #include <cstdlib> @@ -23,613 +21,614 @@ #include <thread> #include <vector> -#include "absl/time/internal/cctz/include/cctz/civil_time.h" #include "gtest/gtest.h" +#include "absl/base/config.h" +#include "absl/time/internal/cctz/include/cctz/civil_time.h" +#include "absl/time/internal/cctz/include/cctz/time_zone.h" namespace chrono = std::chrono; namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { namespace { // A list of known time-zone names. -const char* const kTimeZoneNames[] = { - "Africa/Abidjan", - "Africa/Accra", - "Africa/Addis_Ababa", - "Africa/Algiers", - "Africa/Asmara", - "Africa/Asmera", - "Africa/Bamako", - "Africa/Bangui", - "Africa/Banjul", - "Africa/Bissau", - "Africa/Blantyre", - "Africa/Brazzaville", - "Africa/Bujumbura", - "Africa/Cairo", - "Africa/Casablanca", - "Africa/Ceuta", - "Africa/Conakry", - "Africa/Dakar", - "Africa/Dar_es_Salaam", - "Africa/Djibouti", - "Africa/Douala", - "Africa/El_Aaiun", - "Africa/Freetown", - "Africa/Gaborone", - "Africa/Harare", - "Africa/Johannesburg", - "Africa/Juba", - "Africa/Kampala", - "Africa/Khartoum", - "Africa/Kigali", - "Africa/Kinshasa", - "Africa/Lagos", - "Africa/Libreville", - "Africa/Lome", - "Africa/Luanda", - "Africa/Lubumbashi", - "Africa/Lusaka", - "Africa/Malabo", - "Africa/Maputo", - "Africa/Maseru", - "Africa/Mbabane", - "Africa/Mogadishu", - "Africa/Monrovia", - "Africa/Nairobi", - "Africa/Ndjamena", - "Africa/Niamey", - "Africa/Nouakchott", - "Africa/Ouagadougou", - "Africa/Porto-Novo", - "Africa/Sao_Tome", - "Africa/Timbuktu", - "Africa/Tripoli", - "Africa/Tunis", - "Africa/Windhoek", - "America/Adak", - "America/Anchorage", - "America/Anguilla", - "America/Antigua", - "America/Araguaina", - "America/Argentina/Buenos_Aires", - "America/Argentina/Catamarca", - "America/Argentina/ComodRivadavia", - "America/Argentina/Cordoba", - "America/Argentina/Jujuy", - "America/Argentina/La_Rioja", - "America/Argentina/Mendoza", - "America/Argentina/Rio_Gallegos", - "America/Argentina/Salta", - "America/Argentina/San_Juan", - "America/Argentina/San_Luis", - "America/Argentina/Tucuman", - "America/Argentina/Ushuaia", - "America/Aruba", - "America/Asuncion", - "America/Atikokan", - "America/Atka", - "America/Bahia", - "America/Bahia_Banderas", - "America/Barbados", - "America/Belem", - "America/Belize", - "America/Blanc-Sablon", - "America/Boa_Vista", - "America/Bogota", - "America/Boise", - "America/Buenos_Aires", - "America/Cambridge_Bay", - "America/Campo_Grande", - "America/Cancun", - "America/Caracas", - "America/Catamarca", - "America/Cayenne", - "America/Cayman", - "America/Chicago", - "America/Chihuahua", - "America/Coral_Harbour", - "America/Cordoba", - "America/Costa_Rica", - "America/Creston", - "America/Cuiaba", - "America/Curacao", - "America/Danmarkshavn", - "America/Dawson", - "America/Dawson_Creek", - "America/Denver", - "America/Detroit", - "America/Dominica", - "America/Edmonton", - "America/Eirunepe", - "America/El_Salvador", - "America/Ensenada", - "America/Fort_Nelson", - "America/Fort_Wayne", - "America/Fortaleza", - "America/Glace_Bay", - "America/Godthab", - "America/Goose_Bay", - "America/Grand_Turk", - "America/Grenada", - "America/Guadeloupe", - "America/Guatemala", - "America/Guayaquil", - "America/Guyana", - "America/Halifax", - "America/Havana", - "America/Hermosillo", - "America/Indiana/Indianapolis", - "America/Indiana/Knox", - "America/Indiana/Marengo", - "America/Indiana/Petersburg", - "America/Indiana/Tell_City", - "America/Indiana/Vevay", - "America/Indiana/Vincennes", - "America/Indiana/Winamac", - "America/Indianapolis", - "America/Inuvik", - "America/Iqaluit", - "America/Jamaica", - "America/Jujuy", - "America/Juneau", - "America/Kentucky/Louisville", - "America/Kentucky/Monticello", - "America/Knox_IN", - "America/Kralendijk", - "America/La_Paz", - "America/Lima", - "America/Los_Angeles", - "America/Louisville", - "America/Lower_Princes", - "America/Maceio", - "America/Managua", - "America/Manaus", - "America/Marigot", - "America/Martinique", - "America/Matamoros", - "America/Mazatlan", - "America/Mendoza", - "America/Menominee", - "America/Merida", - "America/Metlakatla", - "America/Mexico_City", - "America/Miquelon", - "America/Moncton", - "America/Monterrey", - "America/Montevideo", - "America/Montreal", - "America/Montserrat", - "America/Nassau", - "America/New_York", - "America/Nipigon", - "America/Nome", - "America/Noronha", - "America/North_Dakota/Beulah", - "America/North_Dakota/Center", - "America/North_Dakota/New_Salem", - "America/Ojinaga", - "America/Panama", - "America/Pangnirtung", - "America/Paramaribo", - "America/Phoenix", - "America/Port-au-Prince", - "America/Port_of_Spain", - "America/Porto_Acre", - "America/Porto_Velho", - "America/Puerto_Rico", - "America/Punta_Arenas", - "America/Rainy_River", - "America/Rankin_Inlet", - "America/Recife", - "America/Regina", - "America/Resolute", - "America/Rio_Branco", - "America/Rosario", - "America/Santa_Isabel", - "America/Santarem", - "America/Santiago", - "America/Santo_Domingo", - "America/Sao_Paulo", - "America/Scoresbysund", - "America/Shiprock", - "America/Sitka", - "America/St_Barthelemy", - "America/St_Johns", - "America/St_Kitts", - "America/St_Lucia", - "America/St_Thomas", - "America/St_Vincent", - "America/Swift_Current", - "America/Tegucigalpa", - "America/Thule", - "America/Thunder_Bay", - "America/Tijuana", - "America/Toronto", - "America/Tortola", - "America/Vancouver", - "America/Virgin", - "America/Whitehorse", - "America/Winnipeg", - "America/Yakutat", - "America/Yellowknife", - "Antarctica/Casey", - "Antarctica/Davis", - "Antarctica/DumontDUrville", - "Antarctica/Macquarie", - "Antarctica/Mawson", - "Antarctica/McMurdo", - "Antarctica/Palmer", - "Antarctica/Rothera", - "Antarctica/South_Pole", - "Antarctica/Syowa", - "Antarctica/Troll", - "Antarctica/Vostok", - "Arctic/Longyearbyen", - "Asia/Aden", - "Asia/Almaty", - "Asia/Amman", - "Asia/Anadyr", - "Asia/Aqtau", - "Asia/Aqtobe", - "Asia/Ashgabat", - "Asia/Ashkhabad", - "Asia/Atyrau", - "Asia/Baghdad", - "Asia/Bahrain", - "Asia/Baku", - "Asia/Bangkok", - "Asia/Barnaul", - "Asia/Beirut", - "Asia/Bishkek", - "Asia/Brunei", - "Asia/Calcutta", - "Asia/Chita", - "Asia/Choibalsan", - "Asia/Chongqing", - "Asia/Chungking", - "Asia/Colombo", - "Asia/Dacca", - "Asia/Damascus", - "Asia/Dhaka", - "Asia/Dili", - "Asia/Dubai", - "Asia/Dushanbe", - "Asia/Famagusta", - "Asia/Gaza", - "Asia/Harbin", - "Asia/Hebron", - "Asia/Ho_Chi_Minh", - "Asia/Hong_Kong", - "Asia/Hovd", - "Asia/Irkutsk", - "Asia/Istanbul", - "Asia/Jakarta", - "Asia/Jayapura", - "Asia/Jerusalem", - "Asia/Kabul", - "Asia/Kamchatka", - "Asia/Karachi", - "Asia/Kashgar", - "Asia/Kathmandu", - "Asia/Katmandu", - "Asia/Khandyga", - "Asia/Kolkata", - "Asia/Krasnoyarsk", - "Asia/Kuala_Lumpur", - "Asia/Kuching", - "Asia/Kuwait", - "Asia/Macao", - "Asia/Macau", - "Asia/Magadan", - "Asia/Makassar", - "Asia/Manila", - "Asia/Muscat", - "Asia/Nicosia", - "Asia/Novokuznetsk", - "Asia/Novosibirsk", - "Asia/Omsk", - "Asia/Oral", - "Asia/Phnom_Penh", - "Asia/Pontianak", - "Asia/Pyongyang", - "Asia/Qatar", - "Asia/Qostanay", - "Asia/Qyzylorda", - "Asia/Rangoon", - "Asia/Riyadh", - "Asia/Saigon", - "Asia/Sakhalin", - "Asia/Samarkand", - "Asia/Seoul", - "Asia/Shanghai", - "Asia/Singapore", - "Asia/Srednekolymsk", - "Asia/Taipei", - "Asia/Tashkent", - "Asia/Tbilisi", - "Asia/Tehran", - "Asia/Tel_Aviv", - "Asia/Thimbu", - "Asia/Thimphu", - "Asia/Tokyo", - "Asia/Tomsk", - "Asia/Ujung_Pandang", - "Asia/Ulaanbaatar", - "Asia/Ulan_Bator", - "Asia/Urumqi", - "Asia/Ust-Nera", - "Asia/Vientiane", - "Asia/Vladivostok", - "Asia/Yakutsk", - "Asia/Yangon", - "Asia/Yekaterinburg", - "Asia/Yerevan", - "Atlantic/Azores", - "Atlantic/Bermuda", - "Atlantic/Canary", - "Atlantic/Cape_Verde", - "Atlantic/Faeroe", - "Atlantic/Faroe", - "Atlantic/Jan_Mayen", - "Atlantic/Madeira", - "Atlantic/Reykjavik", - "Atlantic/South_Georgia", - "Atlantic/St_Helena", - "Atlantic/Stanley", - "Australia/ACT", - "Australia/Adelaide", - "Australia/Brisbane", - "Australia/Broken_Hill", - "Australia/Canberra", - "Australia/Currie", - "Australia/Darwin", - "Australia/Eucla", - "Australia/Hobart", - "Australia/LHI", - "Australia/Lindeman", - "Australia/Lord_Howe", - "Australia/Melbourne", - "Australia/NSW", - "Australia/North", - "Australia/Perth", - "Australia/Queensland", - "Australia/South", - "Australia/Sydney", - "Australia/Tasmania", - "Australia/Victoria", - "Australia/West", - "Australia/Yancowinna", - "Brazil/Acre", - "Brazil/DeNoronha", - "Brazil/East", - "Brazil/West", - "CET", - "CST6CDT", - "Canada/Atlantic", - "Canada/Central", - "Canada/Eastern", - "Canada/Mountain", - "Canada/Newfoundland", - "Canada/Pacific", - "Canada/Saskatchewan", - "Canada/Yukon", - "Chile/Continental", - "Chile/EasterIsland", - "Cuba", - "EET", - "EST", - "EST5EDT", - "Egypt", - "Eire", - "Etc/GMT", - "Etc/GMT+0", - "Etc/GMT+1", - "Etc/GMT+10", - "Etc/GMT+11", - "Etc/GMT+12", - "Etc/GMT+2", - "Etc/GMT+3", - "Etc/GMT+4", - "Etc/GMT+5", - "Etc/GMT+6", - "Etc/GMT+7", - "Etc/GMT+8", - "Etc/GMT+9", - "Etc/GMT-0", - "Etc/GMT-1", - "Etc/GMT-10", - "Etc/GMT-11", - "Etc/GMT-12", - "Etc/GMT-13", - "Etc/GMT-14", - "Etc/GMT-2", - "Etc/GMT-3", - "Etc/GMT-4", - "Etc/GMT-5", - "Etc/GMT-6", - "Etc/GMT-7", - "Etc/GMT-8", - "Etc/GMT-9", - "Etc/GMT0", - "Etc/Greenwich", - "Etc/UCT", - "Etc/UTC", - "Etc/Universal", - "Etc/Zulu", - "Europe/Amsterdam", - "Europe/Andorra", - "Europe/Astrakhan", - "Europe/Athens", - "Europe/Belfast", - "Europe/Belgrade", - "Europe/Berlin", - "Europe/Bratislava", - "Europe/Brussels", - "Europe/Bucharest", - "Europe/Budapest", - "Europe/Busingen", - "Europe/Chisinau", - "Europe/Copenhagen", - "Europe/Dublin", - "Europe/Gibraltar", - "Europe/Guernsey", - "Europe/Helsinki", - "Europe/Isle_of_Man", - "Europe/Istanbul", - "Europe/Jersey", - "Europe/Kaliningrad", - "Europe/Kiev", - "Europe/Kirov", - "Europe/Lisbon", - "Europe/Ljubljana", - "Europe/London", - "Europe/Luxembourg", - "Europe/Madrid", - "Europe/Malta", - "Europe/Mariehamn", - "Europe/Minsk", - "Europe/Monaco", - "Europe/Moscow", - "Europe/Nicosia", - "Europe/Oslo", - "Europe/Paris", - "Europe/Podgorica", - "Europe/Prague", - "Europe/Riga", - "Europe/Rome", - "Europe/Samara", - "Europe/San_Marino", - "Europe/Sarajevo", - "Europe/Saratov", - "Europe/Simferopol", - "Europe/Skopje", - "Europe/Sofia", - "Europe/Stockholm", - "Europe/Tallinn", - "Europe/Tirane", - "Europe/Tiraspol", - "Europe/Ulyanovsk", - "Europe/Uzhgorod", - "Europe/Vaduz", - "Europe/Vatican", - "Europe/Vienna", - "Europe/Vilnius", - "Europe/Volgograd", - "Europe/Warsaw", - "Europe/Zagreb", - "Europe/Zaporozhye", - "Europe/Zurich", - "GB", - "GB-Eire", - "GMT", - "GMT+0", - "GMT-0", - "GMT0", - "Greenwich", - "HST", - "Hongkong", - "Iceland", - "Indian/Antananarivo", - "Indian/Chagos", - "Indian/Christmas", - "Indian/Cocos", - "Indian/Comoro", - "Indian/Kerguelen", - "Indian/Mahe", - "Indian/Maldives", - "Indian/Mauritius", - "Indian/Mayotte", - "Indian/Reunion", - "Iran", - "Israel", - "Jamaica", - "Japan", - "Kwajalein", - "Libya", - "MET", - "MST", - "MST7MDT", - "Mexico/BajaNorte", - "Mexico/BajaSur", - "Mexico/General", - "NZ", - "NZ-CHAT", - "Navajo", - "PRC", - "PST8PDT", - "Pacific/Apia", - "Pacific/Auckland", - "Pacific/Bougainville", - "Pacific/Chatham", - "Pacific/Chuuk", - "Pacific/Easter", - "Pacific/Efate", - "Pacific/Enderbury", - "Pacific/Fakaofo", - "Pacific/Fiji", - "Pacific/Funafuti", - "Pacific/Galapagos", - "Pacific/Gambier", - "Pacific/Guadalcanal", - "Pacific/Guam", - "Pacific/Honolulu", - "Pacific/Johnston", - "Pacific/Kiritimati", - "Pacific/Kosrae", - "Pacific/Kwajalein", - "Pacific/Majuro", - "Pacific/Marquesas", - "Pacific/Midway", - "Pacific/Nauru", - "Pacific/Niue", - "Pacific/Norfolk", - "Pacific/Noumea", - "Pacific/Pago_Pago", - "Pacific/Palau", - "Pacific/Pitcairn", - "Pacific/Pohnpei", - "Pacific/Ponape", - "Pacific/Port_Moresby", - "Pacific/Rarotonga", - "Pacific/Saipan", - "Pacific/Samoa", - "Pacific/Tahiti", - "Pacific/Tarawa", - "Pacific/Tongatapu", - "Pacific/Truk", - "Pacific/Wake", - "Pacific/Wallis", - "Pacific/Yap", - "Poland", - "Portugal", - "ROC", - "ROK", - "Singapore", - "Turkey", - "UCT", - "US/Alaska", - "US/Aleutian", - "US/Arizona", - "US/Central", - "US/East-Indiana", - "US/Eastern", - "US/Hawaii", - "US/Indiana-Starke", - "US/Michigan", - "US/Mountain", - "US/Pacific", - "US/Samoa", - "UTC", - "Universal", - "W-SU", - "WET", - "Zulu", - nullptr -}; +const char* const kTimeZoneNames[] = {"Africa/Abidjan", + "Africa/Accra", + "Africa/Addis_Ababa", + "Africa/Algiers", + "Africa/Asmara", + "Africa/Asmera", + "Africa/Bamako", + "Africa/Bangui", + "Africa/Banjul", + "Africa/Bissau", + "Africa/Blantyre", + "Africa/Brazzaville", + "Africa/Bujumbura", + "Africa/Cairo", + "Africa/Casablanca", + "Africa/Ceuta", + "Africa/Conakry", + "Africa/Dakar", + "Africa/Dar_es_Salaam", + "Africa/Djibouti", + "Africa/Douala", + "Africa/El_Aaiun", + "Africa/Freetown", + "Africa/Gaborone", + "Africa/Harare", + "Africa/Johannesburg", + "Africa/Juba", + "Africa/Kampala", + "Africa/Khartoum", + "Africa/Kigali", + "Africa/Kinshasa", + "Africa/Lagos", + "Africa/Libreville", + "Africa/Lome", + "Africa/Luanda", + "Africa/Lubumbashi", + "Africa/Lusaka", + "Africa/Malabo", + "Africa/Maputo", + "Africa/Maseru", + "Africa/Mbabane", + "Africa/Mogadishu", + "Africa/Monrovia", + "Africa/Nairobi", + "Africa/Ndjamena", + "Africa/Niamey", + "Africa/Nouakchott", + "Africa/Ouagadougou", + "Africa/Porto-Novo", + "Africa/Sao_Tome", + "Africa/Timbuktu", + "Africa/Tripoli", + "Africa/Tunis", + "Africa/Windhoek", + "America/Adak", + "America/Anchorage", + "America/Anguilla", + "America/Antigua", + "America/Araguaina", + "America/Argentina/Buenos_Aires", + "America/Argentina/Catamarca", + "America/Argentina/ComodRivadavia", + "America/Argentina/Cordoba", + "America/Argentina/Jujuy", + "America/Argentina/La_Rioja", + "America/Argentina/Mendoza", + "America/Argentina/Rio_Gallegos", + "America/Argentina/Salta", + "America/Argentina/San_Juan", + "America/Argentina/San_Luis", + "America/Argentina/Tucuman", + "America/Argentina/Ushuaia", + "America/Aruba", + "America/Asuncion", + "America/Atikokan", + "America/Atka", + "America/Bahia", + "America/Bahia_Banderas", + "America/Barbados", + "America/Belem", + "America/Belize", + "America/Blanc-Sablon", + "America/Boa_Vista", + "America/Bogota", + "America/Boise", + "America/Buenos_Aires", + "America/Cambridge_Bay", + "America/Campo_Grande", + "America/Cancun", + "America/Caracas", + "America/Catamarca", + "America/Cayenne", + "America/Cayman", + "America/Chicago", + "America/Chihuahua", + "America/Coral_Harbour", + "America/Cordoba", + "America/Costa_Rica", + "America/Creston", + "America/Cuiaba", + "America/Curacao", + "America/Danmarkshavn", + "America/Dawson", + "America/Dawson_Creek", + "America/Denver", + "America/Detroit", + "America/Dominica", + "America/Edmonton", + "America/Eirunepe", + "America/El_Salvador", + "America/Ensenada", + "America/Fort_Nelson", + "America/Fort_Wayne", + "America/Fortaleza", + "America/Glace_Bay", + "America/Godthab", + "America/Goose_Bay", + "America/Grand_Turk", + "America/Grenada", + "America/Guadeloupe", + "America/Guatemala", + "America/Guayaquil", + "America/Guyana", + "America/Halifax", + "America/Havana", + "America/Hermosillo", + "America/Indiana/Indianapolis", + "America/Indiana/Knox", + "America/Indiana/Marengo", + "America/Indiana/Petersburg", + "America/Indiana/Tell_City", + "America/Indiana/Vevay", + "America/Indiana/Vincennes", + "America/Indiana/Winamac", + "America/Indianapolis", + "America/Inuvik", + "America/Iqaluit", + "America/Jamaica", + "America/Jujuy", + "America/Juneau", + "America/Kentucky/Louisville", + "America/Kentucky/Monticello", + "America/Knox_IN", + "America/Kralendijk", + "America/La_Paz", + "America/Lima", + "America/Los_Angeles", + "America/Louisville", + "America/Lower_Princes", + "America/Maceio", + "America/Managua", + "America/Manaus", + "America/Marigot", + "America/Martinique", + "America/Matamoros", + "America/Mazatlan", + "America/Mendoza", + "America/Menominee", + "America/Merida", + "America/Metlakatla", + "America/Mexico_City", + "America/Miquelon", + "America/Moncton", + "America/Monterrey", + "America/Montevideo", + "America/Montreal", + "America/Montserrat", + "America/Nassau", + "America/New_York", + "America/Nipigon", + "America/Nome", + "America/Noronha", + "America/North_Dakota/Beulah", + "America/North_Dakota/Center", + "America/North_Dakota/New_Salem", + "America/Ojinaga", + "America/Panama", + "America/Pangnirtung", + "America/Paramaribo", + "America/Phoenix", + "America/Port-au-Prince", + "America/Port_of_Spain", + "America/Porto_Acre", + "America/Porto_Velho", + "America/Puerto_Rico", + "America/Punta_Arenas", + "America/Rainy_River", + "America/Rankin_Inlet", + "America/Recife", + "America/Regina", + "America/Resolute", + "America/Rio_Branco", + "America/Rosario", + "America/Santa_Isabel", + "America/Santarem", + "America/Santiago", + "America/Santo_Domingo", + "America/Sao_Paulo", + "America/Scoresbysund", + "America/Shiprock", + "America/Sitka", + "America/St_Barthelemy", + "America/St_Johns", + "America/St_Kitts", + "America/St_Lucia", + "America/St_Thomas", + "America/St_Vincent", + "America/Swift_Current", + "America/Tegucigalpa", + "America/Thule", + "America/Thunder_Bay", + "America/Tijuana", + "America/Toronto", + "America/Tortola", + "America/Vancouver", + "America/Virgin", + "America/Whitehorse", + "America/Winnipeg", + "America/Yakutat", + "America/Yellowknife", + "Antarctica/Casey", + "Antarctica/Davis", + "Antarctica/DumontDUrville", + "Antarctica/Macquarie", + "Antarctica/Mawson", + "Antarctica/McMurdo", + "Antarctica/Palmer", + "Antarctica/Rothera", + "Antarctica/South_Pole", + "Antarctica/Syowa", + "Antarctica/Troll", + "Antarctica/Vostok", + "Arctic/Longyearbyen", + "Asia/Aden", + "Asia/Almaty", + "Asia/Amman", + "Asia/Anadyr", + "Asia/Aqtau", + "Asia/Aqtobe", + "Asia/Ashgabat", + "Asia/Ashkhabad", + "Asia/Atyrau", + "Asia/Baghdad", + "Asia/Bahrain", + "Asia/Baku", + "Asia/Bangkok", + "Asia/Barnaul", + "Asia/Beirut", + "Asia/Bishkek", + "Asia/Brunei", + "Asia/Calcutta", + "Asia/Chita", + "Asia/Choibalsan", + "Asia/Chongqing", + "Asia/Chungking", + "Asia/Colombo", + "Asia/Dacca", + "Asia/Damascus", + "Asia/Dhaka", + "Asia/Dili", + "Asia/Dubai", + "Asia/Dushanbe", + "Asia/Famagusta", + "Asia/Gaza", + "Asia/Harbin", + "Asia/Hebron", + "Asia/Ho_Chi_Minh", + "Asia/Hong_Kong", + "Asia/Hovd", + "Asia/Irkutsk", + "Asia/Istanbul", + "Asia/Jakarta", + "Asia/Jayapura", + "Asia/Jerusalem", + "Asia/Kabul", + "Asia/Kamchatka", + "Asia/Karachi", + "Asia/Kashgar", + "Asia/Kathmandu", + "Asia/Katmandu", + "Asia/Khandyga", + "Asia/Kolkata", + "Asia/Krasnoyarsk", + "Asia/Kuala_Lumpur", + "Asia/Kuching", + "Asia/Kuwait", + "Asia/Macao", + "Asia/Macau", + "Asia/Magadan", + "Asia/Makassar", + "Asia/Manila", + "Asia/Muscat", + "Asia/Nicosia", + "Asia/Novokuznetsk", + "Asia/Novosibirsk", + "Asia/Omsk", + "Asia/Oral", + "Asia/Phnom_Penh", + "Asia/Pontianak", + "Asia/Pyongyang", + "Asia/Qatar", + "Asia/Qostanay", + "Asia/Qyzylorda", + "Asia/Rangoon", + "Asia/Riyadh", + "Asia/Saigon", + "Asia/Sakhalin", + "Asia/Samarkand", + "Asia/Seoul", + "Asia/Shanghai", + "Asia/Singapore", + "Asia/Srednekolymsk", + "Asia/Taipei", + "Asia/Tashkent", + "Asia/Tbilisi", + "Asia/Tehran", + "Asia/Tel_Aviv", + "Asia/Thimbu", + "Asia/Thimphu", + "Asia/Tokyo", + "Asia/Tomsk", + "Asia/Ujung_Pandang", + "Asia/Ulaanbaatar", + "Asia/Ulan_Bator", + "Asia/Urumqi", + "Asia/Ust-Nera", + "Asia/Vientiane", + "Asia/Vladivostok", + "Asia/Yakutsk", + "Asia/Yangon", + "Asia/Yekaterinburg", + "Asia/Yerevan", + "Atlantic/Azores", + "Atlantic/Bermuda", + "Atlantic/Canary", + "Atlantic/Cape_Verde", + "Atlantic/Faeroe", + "Atlantic/Faroe", + "Atlantic/Jan_Mayen", + "Atlantic/Madeira", + "Atlantic/Reykjavik", + "Atlantic/South_Georgia", + "Atlantic/St_Helena", + "Atlantic/Stanley", + "Australia/ACT", + "Australia/Adelaide", + "Australia/Brisbane", + "Australia/Broken_Hill", + "Australia/Canberra", + "Australia/Currie", + "Australia/Darwin", + "Australia/Eucla", + "Australia/Hobart", + "Australia/LHI", + "Australia/Lindeman", + "Australia/Lord_Howe", + "Australia/Melbourne", + "Australia/NSW", + "Australia/North", + "Australia/Perth", + "Australia/Queensland", + "Australia/South", + "Australia/Sydney", + "Australia/Tasmania", + "Australia/Victoria", + "Australia/West", + "Australia/Yancowinna", + "Brazil/Acre", + "Brazil/DeNoronha", + "Brazil/East", + "Brazil/West", + "CET", + "CST6CDT", + "Canada/Atlantic", + "Canada/Central", + "Canada/Eastern", + "Canada/Mountain", + "Canada/Newfoundland", + "Canada/Pacific", + "Canada/Saskatchewan", + "Canada/Yukon", + "Chile/Continental", + "Chile/EasterIsland", + "Cuba", + "EET", + "EST", + "EST5EDT", + "Egypt", + "Eire", + "Etc/GMT", + "Etc/GMT+0", + "Etc/GMT+1", + "Etc/GMT+10", + "Etc/GMT+11", + "Etc/GMT+12", + "Etc/GMT+2", + "Etc/GMT+3", + "Etc/GMT+4", + "Etc/GMT+5", + "Etc/GMT+6", + "Etc/GMT+7", + "Etc/GMT+8", + "Etc/GMT+9", + "Etc/GMT-0", + "Etc/GMT-1", + "Etc/GMT-10", + "Etc/GMT-11", + "Etc/GMT-12", + "Etc/GMT-13", + "Etc/GMT-14", + "Etc/GMT-2", + "Etc/GMT-3", + "Etc/GMT-4", + "Etc/GMT-5", + "Etc/GMT-6", + "Etc/GMT-7", + "Etc/GMT-8", + "Etc/GMT-9", + "Etc/GMT0", + "Etc/Greenwich", + "Etc/UCT", + "Etc/UTC", + "Etc/Universal", + "Etc/Zulu", + "Europe/Amsterdam", + "Europe/Andorra", + "Europe/Astrakhan", + "Europe/Athens", + "Europe/Belfast", + "Europe/Belgrade", + "Europe/Berlin", + "Europe/Bratislava", + "Europe/Brussels", + "Europe/Bucharest", + "Europe/Budapest", + "Europe/Busingen", + "Europe/Chisinau", + "Europe/Copenhagen", + "Europe/Dublin", + "Europe/Gibraltar", + "Europe/Guernsey", + "Europe/Helsinki", + "Europe/Isle_of_Man", + "Europe/Istanbul", + "Europe/Jersey", + "Europe/Kaliningrad", + "Europe/Kiev", + "Europe/Kirov", + "Europe/Lisbon", + "Europe/Ljubljana", + "Europe/London", + "Europe/Luxembourg", + "Europe/Madrid", + "Europe/Malta", + "Europe/Mariehamn", + "Europe/Minsk", + "Europe/Monaco", + "Europe/Moscow", + "Europe/Nicosia", + "Europe/Oslo", + "Europe/Paris", + "Europe/Podgorica", + "Europe/Prague", + "Europe/Riga", + "Europe/Rome", + "Europe/Samara", + "Europe/San_Marino", + "Europe/Sarajevo", + "Europe/Saratov", + "Europe/Simferopol", + "Europe/Skopje", + "Europe/Sofia", + "Europe/Stockholm", + "Europe/Tallinn", + "Europe/Tirane", + "Europe/Tiraspol", + "Europe/Ulyanovsk", + "Europe/Uzhgorod", + "Europe/Vaduz", + "Europe/Vatican", + "Europe/Vienna", + "Europe/Vilnius", + "Europe/Volgograd", + "Europe/Warsaw", + "Europe/Zagreb", + "Europe/Zaporozhye", + "Europe/Zurich", + "GB", + "GB-Eire", + "GMT", + "GMT+0", + "GMT-0", + "GMT0", + "Greenwich", + "HST", + "Hongkong", + "Iceland", + "Indian/Antananarivo", + "Indian/Chagos", + "Indian/Christmas", + "Indian/Cocos", + "Indian/Comoro", + "Indian/Kerguelen", + "Indian/Mahe", + "Indian/Maldives", + "Indian/Mauritius", + "Indian/Mayotte", + "Indian/Reunion", + "Iran", + "Israel", + "Jamaica", + "Japan", + "Kwajalein", + "Libya", + "MET", + "MST", + "MST7MDT", + "Mexico/BajaNorte", + "Mexico/BajaSur", + "Mexico/General", + "NZ", + "NZ-CHAT", + "Navajo", + "PRC", + "PST8PDT", + "Pacific/Apia", + "Pacific/Auckland", + "Pacific/Bougainville", + "Pacific/Chatham", + "Pacific/Chuuk", + "Pacific/Easter", + "Pacific/Efate", + "Pacific/Enderbury", + "Pacific/Fakaofo", + "Pacific/Fiji", + "Pacific/Funafuti", + "Pacific/Galapagos", + "Pacific/Gambier", + "Pacific/Guadalcanal", + "Pacific/Guam", + "Pacific/Honolulu", + "Pacific/Johnston", + "Pacific/Kiritimati", + "Pacific/Kosrae", + "Pacific/Kwajalein", + "Pacific/Majuro", + "Pacific/Marquesas", + "Pacific/Midway", + "Pacific/Nauru", + "Pacific/Niue", + "Pacific/Norfolk", + "Pacific/Noumea", + "Pacific/Pago_Pago", + "Pacific/Palau", + "Pacific/Pitcairn", + "Pacific/Pohnpei", + "Pacific/Ponape", + "Pacific/Port_Moresby", + "Pacific/Rarotonga", + "Pacific/Saipan", + "Pacific/Samoa", + "Pacific/Tahiti", + "Pacific/Tarawa", + "Pacific/Tongatapu", + "Pacific/Truk", + "Pacific/Wake", + "Pacific/Wallis", + "Pacific/Yap", + "Poland", + "Portugal", + "ROC", + "ROK", + "Singapore", + "Turkey", + "UCT", + "US/Alaska", + "US/Aleutian", + "US/Arizona", + "US/Central", + "US/East-Indiana", + "US/Eastern", + "US/Hawaii", + "US/Indiana-Starke", + "US/Michigan", + "US/Mountain", + "US/Pacific", + "US/Samoa", + "UTC", + "Universal", + "W-SU", + "WET", + "Zulu", + nullptr}; // Helper to return a loaded time zone by value (UTC on error). time_zone LoadZone(const std::string& name) { @@ -724,7 +723,8 @@ EXPECT_EQ("America/New_York", nyc.name()); const time_zone syd = LoadZone("Australia/Sydney"); EXPECT_EQ("Australia/Sydney", syd.name()); - const time_zone fixed0 = fixed_time_zone(absl::time_internal::cctz::seconds::zero()); + const time_zone fixed0 = + fixed_time_zone(absl::time_internal::cctz::seconds::zero()); EXPECT_EQ("UTC", fixed0.name()); const time_zone fixed_pos = fixed_time_zone( chrono::hours(3) + chrono::minutes(25) + chrono::seconds(45)); @@ -749,7 +749,7 @@ EXPECT_EQ(chrono::system_clock::from_time_t(0), convert(civil_second(1970, 1, 1, 0, 0, 0), tz)); // UTC - // Loading an empty std::string timezone should fail. + // Loading an empty string timezone should fail. tz = LoadZone("America/Los_Angeles"); EXPECT_FALSE(load_time_zone("", &tz)); EXPECT_EQ(chrono::system_clock::from_time_t(0), @@ -767,7 +767,8 @@ EXPECT_EQ(implicit_utc, explicit_utc); EXPECT_EQ(implicit_utc.name(), explicit_utc.name()); - const time_zone fixed_zero = fixed_time_zone(absl::time_internal::cctz::seconds::zero()); + const time_zone fixed_zero = + fixed_time_zone(absl::time_internal::cctz::seconds::zero()); EXPECT_EQ(fixed_zero, LoadZone(fixed_zero.name())); EXPECT_EQ(fixed_zero, explicit_utc); @@ -806,8 +807,8 @@ TEST(StdChronoTimePoint, TimeTAlignment) { // Ensures that the Unix epoch and the system clock epoch are an integral // number of seconds apart. This simplifies conversions to/from time_t. - auto diff = chrono::system_clock::time_point() - - chrono::system_clock::from_time_t(0); + auto diff = + chrono::system_clock::time_point() - chrono::system_clock::from_time_t(0); EXPECT_EQ(chrono::system_clock::time_point::duration::zero(), diff % chrono::seconds(1)); } @@ -816,20 +817,20 @@ const time_zone utc = utc_time_zone(); const auto t0 = chrono::system_clock::from_time_t(0); - ExpectTime(chrono::time_point_cast<chrono::nanoseconds>(t0), utc, - 1970, 1, 1, 0, 0, 0, 0, false, "UTC"); - ExpectTime(chrono::time_point_cast<chrono::microseconds>(t0), utc, - 1970, 1, 1, 0, 0, 0, 0, false, "UTC"); - ExpectTime(chrono::time_point_cast<chrono::milliseconds>(t0), utc, - 1970, 1, 1, 0, 0, 0, 0, false, "UTC"); - ExpectTime(chrono::time_point_cast<chrono::seconds>(t0), utc, - 1970, 1, 1, 0, 0, 0, 0, false, "UTC"); - ExpectTime(chrono::time_point_cast<absl::time_internal::cctz::seconds>(t0), utc, - 1970, 1, 1, 0, 0, 0, 0, false, "UTC"); - ExpectTime(chrono::time_point_cast<chrono::minutes>(t0), utc, - 1970, 1, 1, 0, 0, 0, 0, false, "UTC"); - ExpectTime(chrono::time_point_cast<chrono::hours>(t0), utc, - 1970, 1, 1, 0, 0, 0, 0, false, "UTC"); + ExpectTime(chrono::time_point_cast<chrono::nanoseconds>(t0), utc, 1970, 1, 1, + 0, 0, 0, 0, false, "UTC"); + ExpectTime(chrono::time_point_cast<chrono::microseconds>(t0), utc, 1970, 1, 1, + 0, 0, 0, 0, false, "UTC"); + ExpectTime(chrono::time_point_cast<chrono::milliseconds>(t0), utc, 1970, 1, 1, + 0, 0, 0, 0, false, "UTC"); + ExpectTime(chrono::time_point_cast<chrono::seconds>(t0), utc, 1970, 1, 1, 0, + 0, 0, 0, false, "UTC"); + ExpectTime(chrono::time_point_cast<absl::time_internal::cctz::seconds>(t0), + utc, 1970, 1, 1, 0, 0, 0, 0, false, "UTC"); + ExpectTime(chrono::time_point_cast<chrono::minutes>(t0), utc, 1970, 1, 1, 0, + 0, 0, 0, false, "UTC"); + ExpectTime(chrono::time_point_cast<chrono::hours>(t0), utc, 1970, 1, 1, 0, 0, + 0, 0, false, "UTC"); } TEST(BreakTime, LocalTimeInUTC) { @@ -911,9 +912,8 @@ chrono::time_point_cast<chrono::minutes>( convert(civil_second(2015, 1, 2, 3, 4, 5), utc)); EXPECT_EQ("04:00", format("%M:%E*S", tp_m, utc)); - const time_point<chrono::hours> tp_h = - chrono::time_point_cast<chrono::hours>( - convert(civil_second(2015, 1, 2, 3, 4, 5), utc)); + const time_point<chrono::hours> tp_h = chrono::time_point_cast<chrono::hours>( + convert(civil_second(2015, 1, 2, 3, 4, 5), utc)); EXPECT_EQ("00:00", format("%M:%E*S", tp_h, utc)); } @@ -932,7 +932,7 @@ // NOTE: Run this with -ftrapv to detect overflow problems. TEST(MakeTime, SysSecondsLimits) { - const char RFC3339[] = "%Y-%m-%dT%H:%M:%S%Ez"; + const char RFC3339[] = "%Y-%m-%dT%H:%M:%S%Ez"; const time_zone utc = utc_time_zone(); const time_zone east = fixed_time_zone(chrono::hours(14)); const time_zone west = fixed_time_zone(-chrono::hours(14)); @@ -1028,17 +1028,17 @@ ASSERT_EQ(0, setenv("TZ", *np, 1)); // change what "localtime" means const auto zi = local_time_zone(); const auto lc = LoadZone("libc:localtime"); - time_zone::civil_transition trans; + time_zone::civil_transition transition; for (auto tp = zi.lookup(civil_second()).trans; - zi.next_transition(tp, &trans); - tp = zi.lookup(trans.to).trans) { - const auto fcl = zi.lookup(trans.from); - const auto tcl = zi.lookup(trans.to); + zi.next_transition(tp, &transition); + tp = zi.lookup(transition.to).trans) { + const auto fcl = zi.lookup(transition.from); + const auto tcl = zi.lookup(transition.to); civil_second cs; // compare cs in zi and lc if (fcl.kind == time_zone::civil_lookup::UNIQUE) { if (tcl.kind == time_zone::civil_lookup::UNIQUE) { // Both unique; must be an is_dst or abbr change. - ASSERT_EQ(trans.from, trans.to); + ASSERT_EQ(transition.from, transition.to); const auto trans = fcl.trans; const auto tal = zi.lookup(trans); const auto tprev = trans - absl::time_internal::cctz::seconds(1); @@ -1049,11 +1049,11 @@ continue; } ASSERT_EQ(time_zone::civil_lookup::REPEATED, tcl.kind); - cs = trans.to; + cs = transition.to; } else { ASSERT_EQ(time_zone::civil_lookup::UNIQUE, tcl.kind); ASSERT_EQ(time_zone::civil_lookup::SKIPPED, fcl.kind); - cs = trans.from; + cs = transition.from; } if (cs.year() > 2037) break; // limit test time (and to 32-bit time_t) const auto cl_zi = zi.lookup(cs); @@ -1433,4 +1433,5 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc index 038740e..5cdd09e 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc
@@ -19,7 +19,10 @@ #include <limits> #include <string> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -152,4 +155,5 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h index 6a60022..0cf2905 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h
@@ -55,7 +55,10 @@ #include <cstdint> #include <string> +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -123,6 +126,7 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_POSIX_H_
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h b/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h index 51b1f1f..269fa36 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h
@@ -22,36 +22,35 @@ */ #ifndef TZDIR -#define TZDIR "/usr/share/zoneinfo" /* Time zone object file directory */ -#endif /* !defined TZDIR */ +#define TZDIR "/usr/share/zoneinfo" /* Time zone object file directory */ +#endif /* !defined TZDIR */ #ifndef TZDEFAULT -#define TZDEFAULT "/etc/localtime" +#define TZDEFAULT "/etc/localtime" #endif /* !defined TZDEFAULT */ #ifndef TZDEFRULES -#define TZDEFRULES "posixrules" +#define TZDEFRULES "posixrules" #endif /* !defined TZDEFRULES */ - /* See Internet RFC 8536 for more details about the following format. */ /* ** Each file begins with. . . */ -#define TZ_MAGIC "TZif" +#define TZ_MAGIC "TZif" struct tzhead { - char tzh_magic[4]; /* TZ_MAGIC */ - char tzh_version[1]; /* '\0' or '2' or '3' as of 2013 */ - char tzh_reserved[15]; /* reserved; must be zero */ - char tzh_ttisutcnt[4]; /* coded number of trans. time flags */ - char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ - char tzh_leapcnt[4]; /* coded number of leap seconds */ - char tzh_timecnt[4]; /* coded number of transition times */ - char tzh_typecnt[4]; /* coded number of local time types */ - char tzh_charcnt[4]; /* coded number of abbr. chars */ + char tzh_magic[4]; /* TZ_MAGIC */ + char tzh_version[1]; /* '\0' or '2' or '3' as of 2013 */ + char tzh_reserved[15]; /* reserved; must be zero */ + char tzh_ttisutcnt[4]; /* coded number of trans. time flags */ + char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ + char tzh_leapcnt[4]; /* coded number of leap seconds */ + char tzh_timecnt[4]; /* coded number of transition times */ + char tzh_typecnt[4]; /* coded number of local time types */ + char tzh_charcnt[4]; /* coded number of abbr. chars */ }; /* @@ -84,13 +83,13 @@ ** If tzh_version is '2' or greater, the above is followed by a second instance ** of tzhead and a second instance of the data in which each coded transition ** time uses 8 rather than 4 chars, -** then a POSIX-TZ-environment-variable-style std::string for use in handling +** then a POSIX-TZ-environment-variable-style string for use in handling ** instants after the last transition time stored in the file ** (with nothing between the newlines if there is no POSIX representation for ** such instants). ** ** If tz_version is '3' or greater, the above is extended as follows. -** First, the POSIX TZ std::string's hour offset may range from -167 +** First, the POSIX TZ string's hour offset may range from -167 ** through 167 as compared to the POSIX-required 0 through 24. ** Second, its DST start time may be January 1 at 00:00 and its stop ** time December 31 at 24:00 plus the difference between DST and @@ -103,21 +102,21 @@ */ #ifndef TZ_MAX_TIMES -#define TZ_MAX_TIMES 2000 +#define TZ_MAX_TIMES 2000 #endif /* !defined TZ_MAX_TIMES */ #ifndef TZ_MAX_TYPES /* This must be at least 17 for Europe/Samara and Europe/Vilnius. */ -#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ -#endif /* !defined TZ_MAX_TYPES */ +#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ +#endif /* !defined TZ_MAX_TYPES */ #ifndef TZ_MAX_CHARS -#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ - /* (limited by what unsigned chars can hold) */ -#endif /* !defined TZ_MAX_CHARS */ +#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ + /* (limited by what unsigned chars can hold) */ +#endif /* !defined TZ_MAX_CHARS */ #ifndef TZ_MAX_LEAPS -#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ -#endif /* !defined TZ_MAX_LEAPS */ +#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ +#endif /* !defined TZ_MAX_LEAPS */ #endif /* !defined TZFILE_H */
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc b/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc index 42f50c5..98ea161 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +++ b/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc
@@ -14,7 +14,10 @@ #include "absl/time/internal/cctz/include/cctz/zone_info_source.h" +#include "absl/base/config.h" + namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -24,9 +27,11 @@ } // namespace cctz } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz_extension { @@ -36,8 +41,9 @@ // defers to the fallback factory. std::unique_ptr<absl::time_internal::cctz::ZoneInfoSource> DefaultFactory( const std::string& name, - const std::function<std::unique_ptr<absl::time_internal::cctz::ZoneInfoSource>( - const std::string& name)>& fallback_factory) { + const std::function< + std::unique_ptr<absl::time_internal::cctz::ZoneInfoSource>( + const std::string& name)>& fallback_factory) { return fallback_factory(name); } @@ -49,21 +55,52 @@ #if !defined(__has_attribute) #define __has_attribute(x) 0 #endif -#if __has_attribute(weak) || defined(__GNUC__) -ZoneInfoSourceFactory zone_info_source_factory - __attribute__((weak)) = DefaultFactory; -#elif defined(_MSC_VER) && !defined(_LIBCPP_VERSION) +// MinGW is GCC on Windows, so while it asserts __has_attribute(weak), the +// Windows linker cannot handle that. Nor does the MinGW compiler know how to +// pass "#pragma comment(linker, ...)" to the Windows linker. +#if (__has_attribute(weak) || defined(__GNUC__)) && !defined(__MINGW32__) +ZoneInfoSourceFactory zone_info_source_factory __attribute__((weak)) = + DefaultFactory; +#elif defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_LIBCPP_VERSION) extern ZoneInfoSourceFactory zone_info_source_factory; extern ZoneInfoSourceFactory default_factory; ZoneInfoSourceFactory default_factory = DefaultFactory; #if defined(_M_IX86) -#pragma comment( \ - linker, \ - "/alternatename:?zone_info_source_factory@cctz_extension@time_internal@absl@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@ABV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@5@@ZA=?default_factory@cctz_extension@time_internal@absl@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@ABV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@5@@ZA") +#pragma comment( \ + linker, \ + "/alternatename:?zone_info_source_factory@cctz_extension@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@ABV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@@ZA=?default_factory@cctz_extension@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@ABV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@@ZA") #elif defined(_M_IA_64) || defined(_M_AMD64) || defined(_M_ARM64) -#pragma comment( \ - linker, \ - "/alternatename:?zone_info_source_factory@cctz_extension@time_internal@absl@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@AEBV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@5@@ZEA=?default_factory@cctz_extension@time_internal@absl@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@AEBV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@5@@ZEA") +#pragma comment( \ + linker, \ + "/alternatename:?zone_info_source_factory@cctz_extension@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@AEBV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@@ZEA=?default_factory@cctz_extension@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@AEBV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@@ZEA") #else #error Unsupported MSVC platform #endif // _M_<PLATFORM> @@ -74,4 +111,5 @@ } // namespace cctz_extension } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/version b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/version index 8d4a43b..db18f83 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/version +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/version
@@ -1 +1 @@ -2019b +2019c
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Detroit b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Detroit index 5e02260..e104faa4 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Detroit +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Detroit Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Edmonton b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Edmonton index 3fa05798..cd78a6f 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Edmonton +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Edmonton Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Indiana/Tell_City b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Indiana/Tell_City index 4ce95c15..7bbb653 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Indiana/Tell_City +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Indiana/Tell_City Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Kentucky/Louisville b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Kentucky/Louisville index f4c4cf96..177836e4 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Kentucky/Louisville +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Kentucky/Louisville Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Louisville b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Louisville index f4c4cf96..177836e4 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Louisville +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Louisville Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Vancouver b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Vancouver index 0f9f832..bb60cbce 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Vancouver +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Vancouver Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Hong_Kong b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Hong_Kong index 378a37f9..23d0375 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Hong_Kong +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Hong_Kong Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Istanbul b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Istanbul index 10d4b21..508446b 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Istanbul +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Istanbul Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Seoul b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Seoul index 73182cf6..96199e7 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Seoul +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Asia/Seoul Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Canada/Mountain b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Canada/Mountain index 3fa05798..cd78a6f 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Canada/Mountain +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Canada/Mountain Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Canada/Pacific b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Canada/Pacific index 0f9f832..bb60cbce 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Canada/Pacific +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Canada/Pacific Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Brussels b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Brussels index 9613c98..40d7124 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Brussels +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Brussels Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Istanbul b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Istanbul index 10d4b21..508446b 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Istanbul +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Istanbul Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Kaliningrad b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Kaliningrad index f774ffd..cc99beab 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Kaliningrad +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Kaliningrad Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Vienna b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Vienna index 696f359d..3582bb15 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Vienna +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Europe/Vienna Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Hongkong b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Hongkong index 378a37f9..23d0375 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Hongkong +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Hongkong Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Pacific/Fiji b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Pacific/Fiji index 6bf667d..d39bf53 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Pacific/Fiji +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Pacific/Fiji Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Pacific/Norfolk b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Pacific/Norfolk index 1f6d610e..53c1aad 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Pacific/Norfolk +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Pacific/Norfolk Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/ROK b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/ROK index 73182cf6..96199e7 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/ROK +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/ROK Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Turkey b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Turkey index 10d4b21..508446b 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Turkey +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Turkey Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/US/Michigan b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/US/Michigan index 5e02260..e104faa4 100644 --- a/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/US/Michigan +++ b/third_party/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/US/Michigan Binary files differ
diff --git a/third_party/abseil-cpp/absl/time/internal/get_current_time_chrono.inc b/third_party/abseil-cpp/absl/time/internal/get_current_time_chrono.inc index 5180230..5eeb640 100644 --- a/third_party/abseil-cpp/absl/time/internal/get_current_time_chrono.inc +++ b/third_party/abseil-cpp/absl/time/internal/get_current_time_chrono.inc
@@ -16,6 +16,7 @@ #include <cstdint> namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { static int64_t GetCurrentTimeNanosFromSystem() { @@ -26,4 +27,5 @@ } } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/get_current_time_posix.inc b/third_party/abseil-cpp/absl/time/internal/get_current_time_posix.inc index 65474ca6..4207200 100644 --- a/third_party/abseil-cpp/absl/time/internal/get_current_time_posix.inc +++ b/third_party/abseil-cpp/absl/time/internal/get_current_time_posix.inc
@@ -7,6 +7,7 @@ #include "absl/base/internal/raw_logging.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { static int64_t GetCurrentTimeNanosFromSystem() { @@ -19,4 +20,5 @@ } } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/test_util.cc b/third_party/abseil-cpp/absl/time/internal/test_util.cc index 59166a7..9bffe12 100644 --- a/third_party/abseil-cpp/absl/time/internal/test_util.cc +++ b/third_party/abseil-cpp/absl/time/internal/test_util.cc
@@ -24,6 +24,7 @@ namespace cctz = absl::time_internal::cctz; namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { TimeZone LoadTimeZone(const std::string& name) { @@ -33,9 +34,11 @@ } } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz_extension { namespace { @@ -116,8 +119,12 @@ } // namespace +#if !defined(__MINGW32__) +// MinGW does not support the weak symbol extension mechanism. ZoneInfoSourceFactory zone_info_source_factory = TestFactory; +#endif } // namespace cctz_extension } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/internal/test_util.h b/third_party/abseil-cpp/absl/time/internal/test_util.h index d7319ea8..5c4bf1f 100644 --- a/third_party/abseil-cpp/absl/time/internal/test_util.h +++ b/third_party/abseil-cpp/absl/time/internal/test_util.h
@@ -20,12 +20,14 @@ #include "absl/time/time.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace time_internal { // Loads the named timezone, but dies on any failure. absl::TimeZone LoadTimeZone(const std::string& name); } // namespace time_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TIME_INTERNAL_TEST_UTIL_H_
diff --git a/third_party/abseil-cpp/absl/time/time.cc b/third_party/abseil-cpp/absl/time/time.cc index 6a387bc..6bb36cb 100644 --- a/third_party/abseil-cpp/absl/time/time.cc +++ b/third_party/abseil-cpp/absl/time/time.cc
@@ -47,6 +47,7 @@ namespace cctz = absl::time_internal::cctz; namespace absl { +ABSL_NAMESPACE_BEGIN namespace { @@ -430,9 +431,17 @@ } absl::Time FromTM(const struct tm& tm, absl::TimeZone tz) { - const CivilSecond cs(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec); - const auto ti = tz.At(cs); + civil_year_t tm_year = tm.tm_year; + // Avoids years that are too extreme for CivilSecond to normalize. + if (tm_year > 300000000000ll) return InfiniteFuture(); + if (tm_year < -300000000000ll) return InfinitePast(); + int tm_mon = tm.tm_mon; + if (tm_mon == std::numeric_limits<int>::max()) { + tm_mon -= 12; + tm_year += 1; + } + const auto ti = tz.At(CivilSecond(tm_year + 1900, tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec)); return tm.tm_isdst == 0 ? ti.post : ti.pre; } @@ -486,4 +495,5 @@ return tm; } +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/time/time.h b/third_party/abseil-cpp/absl/time/time.h index cebbc91b8..33a4a63 100644 --- a/third_party/abseil-cpp/absl/time/time.h +++ b/third_party/abseil-cpp/absl/time/time.h
@@ -83,11 +83,13 @@ #include <type_traits> #include <utility> +#include "absl/base/macros.h" #include "absl/strings/string_view.h" #include "absl/time/civil_time.h" #include "absl/time/internal/cctz/include/cctz/time_zone.h" namespace absl { +ABSL_NAMESPACE_BEGIN class Duration; // Defined below class Time; // Defined below @@ -421,7 +423,9 @@ template <typename T, time_internal::EnableIfFloat<T> = 0> Duration Seconds(T n) { if (n >= 0) { // Note: `NaN >= 0` is false. - if (n >= (std::numeric_limits<int64_t>::max)()) return InfiniteDuration(); + if (n >= static_cast<T>((std::numeric_limits<int64_t>::max)())) { + return InfiniteDuration(); + } return time_internal::MakePosDoubleDuration(n); } else { if (std::isnan(n)) @@ -545,7 +549,11 @@ // Support for flag values of type Duration. Duration flags must be specified // in a format that is valid input for absl::ParseDuration(). +bool AbslParseFlag(absl::string_view text, Duration* dst, std::string* error); +std::string AbslUnparseFlag(Duration d); +ABSL_DEPRECATED("Use AbslParseFlag() instead.") bool ParseFlag(const std::string& text, Duration* dst, std::string* error); +ABSL_DEPRECATED("Use AbslUnparseFlag() instead.") std::string UnparseFlag(Duration d); // Time @@ -815,7 +823,11 @@ // Additionally, if you'd like to specify a time as a count of // seconds/milliseconds/etc from the Unix epoch, use an absl::Duration flag // and add that duration to absl::UnixEpoch() to get an absl::Time. +bool AbslParseFlag(absl::string_view text, Time* t, std::string* error); +std::string AbslUnparseFlag(Time t); +ABSL_DEPRECATED("Use AbslParseFlag() instead.") bool ParseFlag(const std::string& text, Time* t, std::string* error); +ABSL_DEPRECATED("Use AbslUnparseFlag() instead.") std::string UnparseFlag(Time t); // TimeZone @@ -1103,7 +1115,7 @@ // An `absl::TimeConversion` represents the conversion of year, month, day, // hour, minute, and second values (i.e., a civil time), in a particular // `absl::TimeZone`, to a time instant (an absolute time), as returned by -// `absl::ConvertDateTime()`. Lecacy version of `absl::TimeZone::TimeInfo`. +// `absl::ConvertDateTime()`. Legacy version of `absl::TimeZone::TimeInfo`. // // Deprecated. Use `absl::TimeZone::TimeInfo`. struct @@ -1191,15 +1203,18 @@ // time with UTC offset. Also note the use of "%Y": RFC3339 mandates that // years have exactly four digits, but we allow them to take their natural // width. -extern const char RFC3339_full[]; // %Y-%m-%dT%H:%M:%E*S%Ez -extern const char RFC3339_sec[]; // %Y-%m-%dT%H:%M:%S%Ez +ABSL_DLL extern const char + RFC3339_full[]; // %Y-%m-%dT%H:%M:%E*S%Ez +ABSL_DLL extern const char RFC3339_sec[]; // %Y-%m-%dT%H:%M:%S%Ez // RFC1123_full // RFC1123_no_wday // // FormatTime()/ParseTime() format specifiers for RFC1123 date/time strings. -extern const char RFC1123_full[]; // %a, %d %b %E4Y %H:%M:%S %z -extern const char RFC1123_no_wday[]; // %d %b %E4Y %H:%M:%S %z +ABSL_DLL extern const char + RFC1123_full[]; // %a, %d %b %E4Y %H:%M:%S %z +ABSL_DLL extern const char + RFC1123_no_wday[]; // %d %b %E4Y %H:%M:%S %z // FormatTime() // @@ -1401,8 +1416,7 @@ // IsValidRep64<T>(0) is true if the expression `int64_t{std::declval<T>()}` is // valid. That is, if a T can be assigned to an int64_t without narrowing. template <typename T> -constexpr auto IsValidRep64(int) - -> decltype(int64_t{std::declval<T>()}, bool()) { +constexpr auto IsValidRep64(int) -> decltype(int64_t{std::declval<T>()} == 0) { return true; } template <typename T> @@ -1564,6 +1578,7 @@ return time_internal::FromUnixDuration(Seconds(t)); } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TIME_TIME_H_
diff --git a/third_party/abseil-cpp/absl/time/time_test.cc b/third_party/abseil-cpp/absl/time/time_test.cc index 37af39d..6f89672 100644 --- a/third_party/abseil-cpp/absl/time/time_test.cc +++ b/third_party/abseil-cpp/absl/time/time_test.cc
@@ -27,6 +27,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "absl/numeric/int128.h" #include "absl/time/clock.h" #include "absl/time/internal/test_util.h" @@ -575,6 +576,50 @@ absl::ToChronoTime(absl::UnixEpoch() - tick)); } +// Check that absl::int128 works as a std::chrono::duration representation. +TEST(Time, Chrono128) { + // Define a std::chrono::time_point type whose time[sic]_since_epoch() is + // a signed 128-bit count of attoseconds. This has a range and resolution + // (currently) beyond those of absl::Time, and undoubtedly also beyond those + // of std::chrono::system_clock::time_point. + // + // Note: The to/from-chrono support should probably be updated to handle + // such wide representations. + using Timestamp = + std::chrono::time_point<std::chrono::system_clock, + std::chrono::duration<absl::int128, std::atto>>; + + // Expect that we can round-trip the std::chrono::system_clock::time_point + // extremes through both absl::Time and Timestamp, and that Timestamp can + // handle the (current) absl::Time extremes. + // + // Note: We should use std::chrono::floor() instead of time_point_cast(), + // but floor() is only available since c++17. + for (const auto tp : {std::chrono::system_clock::time_point::min(), + std::chrono::system_clock::time_point::max()}) { + EXPECT_EQ(tp, absl::ToChronoTime(absl::FromChrono(tp))); + EXPECT_EQ(tp, std::chrono::time_point_cast< + std::chrono::system_clock::time_point::duration>( + std::chrono::time_point_cast<Timestamp::duration>(tp))); + } + Timestamp::duration::rep v = std::numeric_limits<int64_t>::min(); + v *= Timestamp::duration::period::den; + auto ts = Timestamp(Timestamp::duration(v)); + ts += std::chrono::duration<int64_t, std::atto>(0); + EXPECT_EQ(std::numeric_limits<int64_t>::min(), + ts.time_since_epoch().count() / Timestamp::duration::period::den); + EXPECT_EQ(0, + ts.time_since_epoch().count() % Timestamp::duration::period::den); + v = std::numeric_limits<int64_t>::max(); + v *= Timestamp::duration::period::den; + ts = Timestamp(Timestamp::duration(v)); + ts += std::chrono::duration<int64_t, std::atto>(999999999750000000); + EXPECT_EQ(std::numeric_limits<int64_t>::max(), + ts.time_since_epoch().count() / Timestamp::duration::period::den); + EXPECT_EQ(999999999750000000, + ts.time_since_epoch().count() % Timestamp::duration::period::den); +} + TEST(Time, TimeZoneAt) { const absl::TimeZone nyc = absl::time_internal::LoadTimeZone("America/New_York"); @@ -795,6 +840,30 @@ tm.tm_isdst = 1; t = FromTM(tm, nyc); EXPECT_EQ("2014-03-09T03:30:42-04:00", absl::FormatTime(t, nyc)); // DST + + // Adjusts tm to refer to a time with a year larger than 2147483647. + tm.tm_year = 2147483647 - 1900 + 1; + tm.tm_mon = 6 - 1; + tm.tm_mday = 28; + tm.tm_hour = 1; + tm.tm_min = 2; + tm.tm_sec = 3; + tm.tm_isdst = -1; + t = FromTM(tm, absl::UTCTimeZone()); + EXPECT_EQ("2147483648-06-28T01:02:03+00:00", + absl::FormatTime(t, absl::UTCTimeZone())); + + // Adjusts tm to refer to a time with a very large month. + tm.tm_year = 2019 - 1900; + tm.tm_mon = 2147483647; + tm.tm_mday = 28; + tm.tm_hour = 1; + tm.tm_min = 2; + tm.tm_sec = 3; + tm.tm_isdst = -1; + t = FromTM(tm, absl::UTCTimeZone()); + EXPECT_EQ("178958989-08-28T01:02:03+00:00", + absl::FormatTime(t, absl::UTCTimeZone())); } TEST(Time, TMRoundTrip) {
diff --git a/third_party/abseil-cpp/absl/time/time_zone_test.cc b/third_party/abseil-cpp/absl/time/time_zone_test.cc index 8f1e74a..229fcfc 100644 --- a/third_party/abseil-cpp/absl/time/time_zone_test.cc +++ b/third_party/abseil-cpp/absl/time/time_zone_test.cc
@@ -88,7 +88,7 @@ EXPECT_FALSE(LoadTimeZone("Invalid/TimeZone", &tz)); EXPECT_EQ(absl::UTCTimeZone(), tz); // guaranteed fallback to UTC - // Loading an empty std::string timezone should fail. + // Loading an empty string timezone should fail. tz = absl::time_internal::LoadTimeZone("America/Los_Angeles"); EXPECT_FALSE(LoadTimeZone("", &tz)); EXPECT_EQ(absl::UTCTimeZone(), tz); // guaranteed fallback to UTC
diff --git a/third_party/abseil-cpp/absl/types/BUILD.bazel b/third_party/abseil-cpp/absl/types/BUILD.bazel index 66ecb04..f2ea9f3 100644 --- a/third_party/abseil-cpp/absl/types/BUILD.bazel +++ b/third_party/abseil-cpp/absl/types/BUILD.bazel
@@ -14,12 +14,11 @@ # limitations under the License. # +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", "ABSL_DEFAULT_LINKOPTS", - "ABSL_EXCEPTIONS_FLAG", - "ABSL_EXCEPTIONS_FLAG_LINKOPTS", "ABSL_TEST_COPTS", ) @@ -58,12 +57,12 @@ "bad_any_cast.cc", "bad_any_cast.h", ], - copts = ABSL_EXCEPTIONS_FLAG + ABSL_DEFAULT_COPTS, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, visibility = ["//visibility:private"], deps = [ - "//absl/base", "//absl/base:config", + "//absl/base:raw_logging_internal", ], ) @@ -73,31 +72,13 @@ srcs = [ "any_test.cc", ], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, - deps = [ - ":any", - "//absl/base", - "//absl/base:config", - "//absl/base:exception_testing", - "//absl/container:test_instance_tracker", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "any_test_noexceptions", - size = "small", - srcs = [ - "any_test.cc", - ], copts = ABSL_TEST_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":any", - "//absl/base", "//absl/base:config", "//absl/base:exception_testing", + "//absl/base:raw_logging_internal", "//absl/container:test_instance_tracker", "@com_google_googletest//:gtest_main", ], @@ -106,10 +87,11 @@ cc_test( name = "any_exception_safety_test", srcs = ["any_exception_safety_test.cc"], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":any", + "//absl/base:config", "//absl/base:exception_safety_testing", "@com_google_googletest//:gtest_main", ], @@ -137,25 +119,6 @@ name = "span_test", size = "small", srcs = ["span_test.cc"], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, - deps = [ - ":span", - "//absl/base:config", - "//absl/base:core_headers", - "//absl/base:exception_testing", - "//absl/container:fixed_array", - "//absl/container:inlined_vector", - "//absl/hash:hash_testing", - "//absl/strings", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "span_test_noexceptions", - size = "small", - srcs = ["span_test.cc"], copts = ABSL_TEST_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ @@ -192,11 +155,11 @@ name = "bad_optional_access", srcs = ["bad_optional_access.cc"], hdrs = ["bad_optional_access.h"], - copts = ABSL_DEFAULT_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ - "//absl/base", "//absl/base:config", + "//absl/base:raw_logging_internal", ], ) @@ -204,11 +167,11 @@ name = "bad_variant_access", srcs = ["bad_variant_access.cc"], hdrs = ["bad_variant_access.h"], - copts = ABSL_EXCEPTIONS_FLAG + ABSL_DEFAULT_COPTS, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ - "//absl/base", "//absl/base:config", + "//absl/base:raw_logging_internal", ], ) @@ -218,12 +181,12 @@ srcs = [ "optional_test.cc", ], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":optional", - "//absl/base", "//absl/base:config", + "//absl/base:raw_logging_internal", "//absl/meta:type_traits", "//absl/strings", "@com_google_googletest//:gtest_main", @@ -235,16 +198,51 @@ srcs = [ "optional_exception_safety_test.cc", ], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":optional", + "//absl/base:config", "//absl/base:exception_safety_testing", "@com_google_googletest//:gtest_main", ], ) cc_library( + name = "conformance_testing", + testonly = 1, + hdrs = [ + "internal/conformance_aliases.h", + "internal/conformance_archetype.h", + "internal/conformance_profile.h", + ], + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + "//absl/debugging:demangle_internal", + "//absl/meta:type_traits", + "//absl/strings", + "//absl/utility", + "@com_google_googletest//:gtest", + ], +) + +cc_test( + name = "conformance_testing_test", + size = "small", + srcs = [ + "internal/conformance_testing_test.cc", + ], + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + ":conformance_testing", + "//absl/meta:type_traits", + "@com_google_googletest//:gtest_main", + ], +) + +cc_library( name = "variant", srcs = ["internal/variant.h"], hdrs = ["variant.h"], @@ -264,8 +262,8 @@ name = "variant_test", size = "small", srcs = ["variant_test.cc"], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":variant", "//absl/base:config", @@ -298,8 +296,8 @@ srcs = [ "variant_exception_safety_test.cc", ], - copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, - linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS, + copts = ABSL_TEST_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":variant", "//absl/base:config",
diff --git a/third_party/abseil-cpp/absl/types/BUILD.gn b/third_party/abseil-cpp/absl/types/BUILD.gn index 81fee56..63e7e7b 100644 --- a/third_party/abseil-cpp/absl/types/BUILD.gn +++ b/third_party/abseil-cpp/absl/types/BUILD.gn
@@ -63,8 +63,8 @@ sources = [ "bad_any_cast.cc" ] public = [ "bad_any_cast.h" ] deps = [ - "../base", "../base:config", + "../base:raw_logging_internal", ] visibility = [] visibility += [ ":*" ] @@ -117,8 +117,8 @@ sources = [ "bad_optional_access.cc" ] public = [ "bad_optional_access.h" ] deps = [ - "../base", "../base:config", + "../base:raw_logging_internal", ] } @@ -132,8 +132,8 @@ sources = [ "bad_variant_access.cc" ] public = [ "bad_variant_access.h" ] deps = [ - "../base", "../base:config", + "../base:raw_logging_internal", ] }
diff --git a/third_party/abseil-cpp/absl/types/CMakeLists.txt b/third_party/abseil-cpp/absl/types/CMakeLists.txt index 4ce685d..c7c88250 100644 --- a/third_party/abseil-cpp/absl/types/CMakeLists.txt +++ b/third_party/abseil-cpp/absl/types/CMakeLists.txt
@@ -50,12 +50,9 @@ "bad_any_cast.cc" COPTS ${ABSL_DEFAULT_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS - absl::base absl::config + absl::raw_logging_internal ) absl_cc_test( @@ -65,14 +62,11 @@ "any_test.cc" COPTS ${ABSL_TEST_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS absl::any - absl::base absl::config absl::exception_testing + absl::raw_logging_internal absl::test_instance_tracker gmock_main ) @@ -86,9 +80,9 @@ ${ABSL_TEST_COPTS} DEPS absl::any - absl::base absl::config absl::exception_testing + absl::raw_logging_internal absl::test_instance_tracker gmock_main ) @@ -100,11 +94,9 @@ "any_exception_safety_test.cc" COPTS ${ABSL_TEST_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS absl::any + absl::config absl::exception_safety_testing gmock_main ) @@ -133,9 +125,6 @@ "span_test.cc" COPTS ${ABSL_TEST_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS absl::span absl::base @@ -198,12 +187,9 @@ "bad_optional_access.cc" COPTS ${ABSL_DEFAULT_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS - absl::base absl::config + absl::raw_logging_internal PUBLIC ) @@ -216,12 +202,9 @@ "bad_variant_access.cc" COPTS ${ABSL_DEFAULT_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS - absl::base absl::config + absl::raw_logging_internal PUBLIC ) @@ -232,15 +215,12 @@ "optional_test.cc" COPTS ${ABSL_TEST_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS absl::optional - absl::base absl::config - absl::type_traits + absl::raw_logging_internal absl::strings + absl::type_traits gmock_main ) @@ -251,12 +231,56 @@ "optional_exception_safety_test.cc" COPTS ${ABSL_TEST_COPTS} + DEPS + absl::optional + absl::config + absl::exception_safety_testing + gmock_main +) + +absl_cc_library( + NAME + conformance_testing + HDRS + "internal/conformance_aliases.h" + "internal/conformance_archetype.h" + "internal/conformance_profile.h" + COPTS + ${ABSL_DEFAULT_COPTS} + DEPS + absl::debugging + absl::type_traits + absl::strings + absl::utility + gmock_main + PUBLIC +) + +absl_cc_test( + NAME + conformance_testing_test + SRCS + "internal/conformance_testing_test.cc" + COPTS + ${ABSL_TEST_COPTS} ${ABSL_EXCEPTIONS_FLAG} LINKOPTS ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS - absl::optional - absl::exception_safety_testing + absl::conformance_testing + absl::type_traits + gmock_main +) + +absl_cc_test( + NAME + conformance_testing_test_no_exceptions + SRCS + "internal/conformance_testing_test.cc" + COPTS + ${ABSL_TEST_COPTS} + DEPS + absl::conformance_testing gmock_main ) @@ -286,9 +310,6 @@ "variant_test.cc" COPTS ${ABSL_TEST_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS absl::variant absl::config @@ -335,9 +356,6 @@ "variant_exception_safety_test.cc" COPTS ${ABSL_TEST_COPTS} - ${ABSL_EXCEPTIONS_FLAG} - LINKOPTS - ${ABSL_EXCEPTIONS_FLAG_LINKOPTS} DEPS absl::variant absl::config
diff --git a/third_party/abseil-cpp/absl/types/any.h b/third_party/abseil-cpp/absl/types/any.h index f3a3281..16bda79 100644 --- a/third_party/abseil-cpp/absl/types/any.h +++ b/third_party/abseil-cpp/absl/types/any.h
@@ -56,18 +56,20 @@ #include "absl/base/config.h" #include "absl/utility/utility.h" -#ifdef ABSL_HAVE_STD_ANY +#ifdef ABSL_USES_STD_ANY #include <any> // IWYU pragma: export namespace absl { +ABSL_NAMESPACE_BEGIN using std::any; using std::any_cast; using std::bad_any_cast; using std::make_any; +ABSL_NAMESPACE_END } // namespace absl -#else // ABSL_HAVE_STD_ANY +#else // ABSL_USES_STD_ANY #include <algorithm> #include <cstddef> @@ -91,6 +93,7 @@ #endif // !defined(__GNUC__) || defined(__GXX_RTTI) namespace absl { +ABSL_NAMESPACE_BEGIN namespace any_internal { @@ -182,7 +185,7 @@ // object, when containing a value, must contain a value type; storing a // reference type is neither desired nor supported. // -// An `absl::any` can only store a type that is copy-constructable; move-only +// An `absl::any` can only store a type that is copy-constructible; move-only // types are not allowed within an `any` object. // // Example: @@ -190,7 +193,7 @@ // auto a = absl::any(65); // Literal, copyable // auto b = absl::any(std::vector<int>()); // Default-initialized, copyable // std::unique_ptr<Foo> my_foo; -// auto c = absl::any(std::move(my_foo)); // Error, not copy-constructable +// auto c = absl::any(std::move(my_foo)); // Error, not copy-constructible // // Note that `absl::any` makes use of decayed types (`absl::decay_t` in this // context) to remove const-volatile qualifiers (known as "cv qualifiers"), @@ -515,25 +518,30 @@ // Description at the declaration site (top of file). template <typename T> const T* any_cast(const any* operand) noexcept { - return operand && operand->GetObjTypeId() == any::IdForType<T>() + using U = + typename std::remove_cv<typename std::remove_reference<T>::type>::type; + return operand && operand->GetObjTypeId() == any::IdForType<U>() ? std::addressof( - static_cast<const any::Obj<T>*>(operand->obj_.get())->value) + static_cast<const any::Obj<U>*>(operand->obj_.get())->value) : nullptr; } // Description at the declaration site (top of file). template <typename T> T* any_cast(any* operand) noexcept { - return operand && operand->GetObjTypeId() == any::IdForType<T>() + using U = + typename std::remove_cv<typename std::remove_reference<T>::type>::type; + return operand && operand->GetObjTypeId() == any::IdForType<U>() ? std::addressof( - static_cast<any::Obj<T>*>(operand->obj_.get())->value) + static_cast<any::Obj<U>*>(operand->obj_.get())->value) : nullptr; } +ABSL_NAMESPACE_END } // namespace absl #undef ABSL_ANY_DETAIL_HAS_RTTI -#endif // ABSL_HAVE_STD_ANY +#endif // ABSL_USES_STD_ANY #endif // ABSL_TYPES_ANY_H_
diff --git a/third_party/abseil-cpp/absl/types/any_exception_safety_test.cc b/third_party/abseil-cpp/absl/types/any_exception_safety_test.cc index 5d7d8a5c..31c11401 100644 --- a/third_party/abseil-cpp/absl/types/any_exception_safety_test.cc +++ b/third_party/abseil-cpp/absl/types/any_exception_safety_test.cc
@@ -14,6 +14,12 @@ #include "absl/types/any.h" +#include "absl/base/config.h" + +// This test is a no-op when absl::any is an alias for std::any and when +// exceptions are not enabled. +#if !defined(ABSL_USES_STD_ANY) && defined(ABSL_HAVE_EXCEPTIONS) + #include <typeinfo> #include <vector> @@ -136,8 +142,6 @@ EXPECT_TRUE(strong_empty_any_tester.Test(move)); } -// libstdc++ std::any fails this test -#if !defined(ABSL_HAVE_STD_ANY) TEST(AnyExceptionSafety, Emplace) { auto initial_val = absl::any{absl::in_place_type_t<Thrower>(), 1, testing::nothrow_ctor}; @@ -163,6 +167,7 @@ EXPECT_TRUE(empty_tester.Test(emp_thrower)); EXPECT_TRUE(empty_tester.Test(emp_throwervec)); } -#endif // ABSL_HAVE_STD_ANY } // namespace + +#endif // #if !defined(ABSL_USES_STD_ANY) && defined(ABSL_HAVE_EXCEPTIONS)
diff --git a/third_party/abseil-cpp/absl/types/any_test.cc b/third_party/abseil-cpp/absl/types/any_test.cc index 8710472..70e4ba2 100644 --- a/third_party/abseil-cpp/absl/types/any_test.cc +++ b/third_party/abseil-cpp/absl/types/any_test.cc
@@ -14,6 +14,9 @@ #include "absl/types/any.h" +// This test is a no-op when absl::any is an alias for std::any. +#if !defined(ABSL_USES_STD_ANY) + #include <initializer_list> #include <type_traits> #include <utility> @@ -639,7 +642,7 @@ // Tests for Exception Behavior // ////////////////////////////////// -#if defined(ABSL_HAVE_STD_ANY) +#if defined(ABSL_USES_STD_ANY) // If using a std `any` implementation, we can't check for a specific message. #define ABSL_ANY_TEST_EXPECT_BAD_ANY_CAST(...) \ @@ -653,7 +656,7 @@ ABSL_BASE_INTERNAL_EXPECT_FAIL((__VA_ARGS__), absl::bad_any_cast, \ "Bad any cast") -#endif // defined(ABSL_HAVE_STD_ANY) +#endif // defined(ABSL_USES_STD_ANY) TEST(AnyTest, ThrowBadAlloc) { { @@ -761,7 +764,7 @@ BadCopyable bad; absl::any target(absl::in_place_type<int>); ABSL_ANY_TEST_EXPECT_BAD_COPY(target.emplace<BadCopyable>(bad)); -#if defined(ABSL_HAVE_STD_ANY) && defined(__GLIBCXX__) +#if defined(ABSL_USES_STD_ANY) && defined(__GLIBCXX__) // libstdc++ std::any::emplace() implementation (as of 7.2) has a bug: if an // exception is thrown, *this contains a value. #define ABSL_GLIBCXX_ANY_EMPLACE_EXCEPTION_BUG 1 @@ -774,3 +777,5 @@ } } // namespace + +#endif // #if !defined(ABSL_USES_STD_ANY)
diff --git a/third_party/abseil-cpp/absl/types/bad_any_cast.cc b/third_party/abseil-cpp/absl/types/bad_any_cast.cc index 505919a5..b0592cc 100644 --- a/third_party/abseil-cpp/absl/types/bad_any_cast.cc +++ b/third_party/abseil-cpp/absl/types/bad_any_cast.cc
@@ -14,7 +14,7 @@ #include "absl/types/bad_any_cast.h" -#ifndef ABSL_HAVE_STD_ANY +#ifndef ABSL_USES_STD_ANY #include <cstdlib> @@ -22,6 +22,7 @@ #include "absl/base/internal/raw_logging.h" namespace absl { +ABSL_NAMESPACE_BEGIN bad_any_cast::~bad_any_cast() = default; @@ -39,6 +40,7 @@ } } // namespace any_internal +ABSL_NAMESPACE_END } // namespace absl -#endif // ABSL_HAVE_STD_ANY +#endif // ABSL_USES_STD_ANY
diff --git a/third_party/abseil-cpp/absl/types/bad_any_cast.h b/third_party/abseil-cpp/absl/types/bad_any_cast.h index 8d020ed..114cef8 100644 --- a/third_party/abseil-cpp/absl/types/bad_any_cast.h +++ b/third_party/abseil-cpp/absl/types/bad_any_cast.h
@@ -25,17 +25,20 @@ #include "absl/base/config.h" -#ifdef ABSL_HAVE_STD_ANY +#ifdef ABSL_USES_STD_ANY #include <any> namespace absl { +ABSL_NAMESPACE_BEGIN using std::bad_any_cast; +ABSL_NAMESPACE_END } // namespace absl -#else // ABSL_HAVE_STD_ANY +#else // ABSL_USES_STD_ANY namespace absl { +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // bad_any_cast @@ -64,8 +67,9 @@ [[noreturn]] void ThrowBadAnyCast(); } // namespace any_internal +ABSL_NAMESPACE_END } // namespace absl -#endif // ABSL_HAVE_STD_ANY +#endif // ABSL_USES_STD_ANY #endif // ABSL_TYPES_BAD_ANY_CAST_H_
diff --git a/third_party/abseil-cpp/absl/types/bad_optional_access.cc b/third_party/abseil-cpp/absl/types/bad_optional_access.cc index a791c7c..26aca70 100644 --- a/third_party/abseil-cpp/absl/types/bad_optional_access.cc +++ b/third_party/abseil-cpp/absl/types/bad_optional_access.cc
@@ -14,7 +14,7 @@ #include "absl/types/bad_optional_access.h" -#ifndef ABSL_HAVE_STD_OPTIONAL +#ifndef ABSL_USES_STD_OPTIONAL #include <cstdlib> @@ -22,6 +22,7 @@ #include "absl/base/internal/raw_logging.h" namespace absl { +ABSL_NAMESPACE_BEGIN bad_optional_access::~bad_optional_access() = default; @@ -41,6 +42,7 @@ } } // namespace optional_internal +ABSL_NAMESPACE_END } // namespace absl -#endif // ABSL_HAVE_STD_OPTIONAL +#endif // ABSL_USES_STD_OPTIONAL
diff --git a/third_party/abseil-cpp/absl/types/bad_optional_access.h b/third_party/abseil-cpp/absl/types/bad_optional_access.h index add5c45..a500286 100644 --- a/third_party/abseil-cpp/absl/types/bad_optional_access.h +++ b/third_party/abseil-cpp/absl/types/bad_optional_access.h
@@ -25,17 +25,20 @@ #include "absl/base/config.h" -#ifdef ABSL_HAVE_STD_OPTIONAL +#ifdef ABSL_USES_STD_OPTIONAL #include <optional> namespace absl { +ABSL_NAMESPACE_BEGIN using std::bad_optional_access; +ABSL_NAMESPACE_END } // namespace absl -#else // ABSL_HAVE_STD_OPTIONAL +#else // ABSL_USES_STD_OPTIONAL namespace absl { +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // bad_optional_access @@ -67,8 +70,9 @@ [[noreturn]] void throw_bad_optional_access(); } // namespace optional_internal +ABSL_NAMESPACE_END } // namespace absl -#endif // ABSL_HAVE_STD_OPTIONAL +#endif // ABSL_USES_STD_OPTIONAL #endif // ABSL_TYPES_BAD_OPTIONAL_ACCESS_H_
diff --git a/third_party/abseil-cpp/absl/types/bad_variant_access.cc b/third_party/abseil-cpp/absl/types/bad_variant_access.cc index a4325c8..3dc88cc 100644 --- a/third_party/abseil-cpp/absl/types/bad_variant_access.cc +++ b/third_party/abseil-cpp/absl/types/bad_variant_access.cc
@@ -14,7 +14,7 @@ #include "absl/types/bad_variant_access.h" -#ifndef ABSL_HAVE_STD_VARIANT +#ifndef ABSL_USES_STD_VARIANT #include <cstdlib> #include <stdexcept> @@ -23,6 +23,7 @@ #include "absl/base/internal/raw_logging.h" namespace absl { +ABSL_NAMESPACE_BEGIN ////////////////////////// // [variant.bad.access] // @@ -57,6 +58,7 @@ } } // namespace variant_internal +ABSL_NAMESPACE_END } // namespace absl -#endif // ABSL_HAVE_STD_VARIANT +#endif // ABSL_USES_STD_VARIANT
diff --git a/third_party/abseil-cpp/absl/types/bad_variant_access.h b/third_party/abseil-cpp/absl/types/bad_variant_access.h index 637db43..095969f9 100644 --- a/third_party/abseil-cpp/absl/types/bad_variant_access.h +++ b/third_party/abseil-cpp/absl/types/bad_variant_access.h
@@ -25,17 +25,20 @@ #include "absl/base/config.h" -#ifdef ABSL_HAVE_STD_VARIANT +#ifdef ABSL_USES_STD_VARIANT #include <variant> namespace absl { +ABSL_NAMESPACE_BEGIN using std::bad_variant_access; +ABSL_NAMESPACE_END } // namespace absl -#else // ABSL_HAVE_STD_VARIANT +#else // ABSL_USES_STD_VARIANT namespace absl { +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // bad_variant_access @@ -71,8 +74,9 @@ [[noreturn]] void Rethrow(); } // namespace variant_internal +ABSL_NAMESPACE_END } // namespace absl -#endif // ABSL_HAVE_STD_VARIANT +#endif // ABSL_USES_STD_VARIANT #endif // ABSL_TYPES_BAD_VARIANT_ACCESS_H_
diff --git a/third_party/abseil-cpp/absl/types/compare.h b/third_party/abseil-cpp/absl/types/compare.h index 50361d6..62ca70f 100644 --- a/third_party/abseil-cpp/absl/types/compare.h +++ b/third_party/abseil-cpp/absl/types/compare.h
@@ -39,6 +39,7 @@ #include "absl/meta/type_traits.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace compare_internal { using value_type = int8_t; @@ -79,79 +80,72 @@ enum class ncmp : value_type { unordered = -127 }; +// Define macros to allow for creation or emulation of C++17 inline variables +// based on whether the feature is supported. Note: we can't use +// ABSL_INTERNAL_INLINE_CONSTEXPR here because the variables here are of +// incomplete types so they need to be defined after the types are complete. +#ifdef __cpp_inline_variables + +#define ABSL_COMPARE_INLINE_BASECLASS_DECL(name) + +#define ABSL_COMPARE_INLINE_SUBCLASS_DECL(type, name) \ + static const type name + +#define ABSL_COMPARE_INLINE_INIT(type, name, init) \ + inline constexpr type type::name(init) + +#else // __cpp_inline_variables + +#define ABSL_COMPARE_INLINE_BASECLASS_DECL(name) \ + ABSL_CONST_INIT static const T name + +#define ABSL_COMPARE_INLINE_SUBCLASS_DECL(type, name) + +#define ABSL_COMPARE_INLINE_INIT(type, name, init) \ + template <typename T> \ + const T compare_internal::type##_base<T>::name(init) + +#endif // __cpp_inline_variables + // These template base classes allow for defining the values of the constants // in the header file (for performance) without using inline variables (which // aren't available in C++11). template <typename T> struct weak_equality_base { - ABSL_CONST_INIT static const T equivalent; - ABSL_CONST_INIT static const T nonequivalent; + ABSL_COMPARE_INLINE_BASECLASS_DECL(equivalent); + ABSL_COMPARE_INLINE_BASECLASS_DECL(nonequivalent); }; -template <typename T> -const T weak_equality_base<T>::equivalent(eq::equivalent); -template <typename T> -const T weak_equality_base<T>::nonequivalent(eq::nonequivalent); template <typename T> struct strong_equality_base { - ABSL_CONST_INIT static const T equal; - ABSL_CONST_INIT static const T nonequal; - ABSL_CONST_INIT static const T equivalent; - ABSL_CONST_INIT static const T nonequivalent; + ABSL_COMPARE_INLINE_BASECLASS_DECL(equal); + ABSL_COMPARE_INLINE_BASECLASS_DECL(nonequal); + ABSL_COMPARE_INLINE_BASECLASS_DECL(equivalent); + ABSL_COMPARE_INLINE_BASECLASS_DECL(nonequivalent); }; -template <typename T> -const T strong_equality_base<T>::equal(eq::equal); -template <typename T> -const T strong_equality_base<T>::nonequal(eq::nonequal); -template <typename T> -const T strong_equality_base<T>::equivalent(eq::equivalent); -template <typename T> -const T strong_equality_base<T>::nonequivalent(eq::nonequivalent); template <typename T> struct partial_ordering_base { - ABSL_CONST_INIT static const T less; - ABSL_CONST_INIT static const T equivalent; - ABSL_CONST_INIT static const T greater; - ABSL_CONST_INIT static const T unordered; + ABSL_COMPARE_INLINE_BASECLASS_DECL(less); + ABSL_COMPARE_INLINE_BASECLASS_DECL(equivalent); + ABSL_COMPARE_INLINE_BASECLASS_DECL(greater); + ABSL_COMPARE_INLINE_BASECLASS_DECL(unordered); }; -template <typename T> -const T partial_ordering_base<T>::less(ord::less); -template <typename T> -const T partial_ordering_base<T>::equivalent(eq::equivalent); -template <typename T> -const T partial_ordering_base<T>::greater(ord::greater); -template <typename T> -const T partial_ordering_base<T>::unordered(ncmp::unordered); template <typename T> struct weak_ordering_base { - ABSL_CONST_INIT static const T less; - ABSL_CONST_INIT static const T equivalent; - ABSL_CONST_INIT static const T greater; + ABSL_COMPARE_INLINE_BASECLASS_DECL(less); + ABSL_COMPARE_INLINE_BASECLASS_DECL(equivalent); + ABSL_COMPARE_INLINE_BASECLASS_DECL(greater); }; -template <typename T> -const T weak_ordering_base<T>::less(ord::less); -template <typename T> -const T weak_ordering_base<T>::equivalent(eq::equivalent); -template <typename T> -const T weak_ordering_base<T>::greater(ord::greater); template <typename T> struct strong_ordering_base { - ABSL_CONST_INIT static const T less; - ABSL_CONST_INIT static const T equal; - ABSL_CONST_INIT static const T equivalent; - ABSL_CONST_INIT static const T greater; + ABSL_COMPARE_INLINE_BASECLASS_DECL(less); + ABSL_COMPARE_INLINE_BASECLASS_DECL(equal); + ABSL_COMPARE_INLINE_BASECLASS_DECL(equivalent); + ABSL_COMPARE_INLINE_BASECLASS_DECL(greater); }; -template <typename T> -const T strong_ordering_base<T>::less(ord::less); -template <typename T> -const T strong_ordering_base<T>::equal(eq::equal); -template <typename T> -const T strong_ordering_base<T>::equivalent(eq::equivalent); -template <typename T> -const T strong_ordering_base<T>::greater(ord::greater); } // namespace compare_internal @@ -162,6 +156,9 @@ friend struct compare_internal::weak_equality_base<weak_equality>; public: + ABSL_COMPARE_INLINE_SUBCLASS_DECL(weak_equality, equivalent); + ABSL_COMPARE_INLINE_SUBCLASS_DECL(weak_equality, nonequivalent); + // Comparisons friend constexpr bool operator==( weak_equality v, compare_internal::OnlyLiteralZero<>) noexcept { @@ -179,10 +176,22 @@ weak_equality v) noexcept { return 0 != v.value_; } + friend constexpr bool operator==(weak_equality v1, + weak_equality v2) noexcept { + return v1.value_ == v2.value_; + } + friend constexpr bool operator!=(weak_equality v1, + weak_equality v2) noexcept { + return v1.value_ != v2.value_; + } private: compare_internal::value_type value_; }; +ABSL_COMPARE_INLINE_INIT(weak_equality, equivalent, + compare_internal::eq::equivalent); +ABSL_COMPARE_INLINE_INIT(weak_equality, nonequivalent, + compare_internal::eq::nonequivalent); class strong_equality : public compare_internal::strong_equality_base<strong_equality> { @@ -191,6 +200,11 @@ friend struct compare_internal::strong_equality_base<strong_equality>; public: + ABSL_COMPARE_INLINE_SUBCLASS_DECL(strong_equality, equal); + ABSL_COMPARE_INLINE_SUBCLASS_DECL(strong_equality, nonequal); + ABSL_COMPARE_INLINE_SUBCLASS_DECL(strong_equality, equivalent); + ABSL_COMPARE_INLINE_SUBCLASS_DECL(strong_equality, nonequivalent); + // Conversion constexpr operator weak_equality() const noexcept { // NOLINT return value_ == 0 ? weak_equality::equivalent @@ -213,10 +227,25 @@ strong_equality v) noexcept { return 0 != v.value_; } + friend constexpr bool operator==(strong_equality v1, + strong_equality v2) noexcept { + return v1.value_ == v2.value_; + } + friend constexpr bool operator!=(strong_equality v1, + strong_equality v2) noexcept { + return v1.value_ != v2.value_; + } private: compare_internal::value_type value_; }; +ABSL_COMPARE_INLINE_INIT(strong_equality, equal, compare_internal::eq::equal); +ABSL_COMPARE_INLINE_INIT(strong_equality, nonequal, + compare_internal::eq::nonequal); +ABSL_COMPARE_INLINE_INIT(strong_equality, equivalent, + compare_internal::eq::equivalent); +ABSL_COMPARE_INLINE_INIT(strong_equality, nonequivalent, + compare_internal::eq::nonequivalent); class partial_ordering : public compare_internal::partial_ordering_base<partial_ordering> { @@ -234,6 +263,11 @@ } public: + ABSL_COMPARE_INLINE_SUBCLASS_DECL(partial_ordering, less); + ABSL_COMPARE_INLINE_SUBCLASS_DECL(partial_ordering, equivalent); + ABSL_COMPARE_INLINE_SUBCLASS_DECL(partial_ordering, greater); + ABSL_COMPARE_INLINE_SUBCLASS_DECL(partial_ordering, unordered); + // Conversion constexpr operator weak_equality() const noexcept { // NOLINT return value_ == 0 ? weak_equality::equivalent @@ -288,10 +322,25 @@ partial_ordering v) noexcept { return v.is_ordered() && 0 >= v.value_; } + friend constexpr bool operator==(partial_ordering v1, + partial_ordering v2) noexcept { + return v1.value_ == v2.value_; + } + friend constexpr bool operator!=(partial_ordering v1, + partial_ordering v2) noexcept { + return v1.value_ != v2.value_; + } private: compare_internal::value_type value_; }; +ABSL_COMPARE_INLINE_INIT(partial_ordering, less, compare_internal::ord::less); +ABSL_COMPARE_INLINE_INIT(partial_ordering, equivalent, + compare_internal::eq::equivalent); +ABSL_COMPARE_INLINE_INIT(partial_ordering, greater, + compare_internal::ord::greater); +ABSL_COMPARE_INLINE_INIT(partial_ordering, unordered, + compare_internal::ncmp::unordered); class weak_ordering : public compare_internal::weak_ordering_base<weak_ordering> { @@ -302,6 +351,10 @@ friend struct compare_internal::weak_ordering_base<weak_ordering>; public: + ABSL_COMPARE_INLINE_SUBCLASS_DECL(weak_ordering, less); + ABSL_COMPARE_INLINE_SUBCLASS_DECL(weak_ordering, equivalent); + ABSL_COMPARE_INLINE_SUBCLASS_DECL(weak_ordering, greater); + // Conversions constexpr operator weak_equality() const noexcept { // NOLINT return value_ == 0 ? weak_equality::equivalent @@ -361,10 +414,23 @@ weak_ordering v) noexcept { return 0 >= v.value_; } + friend constexpr bool operator==(weak_ordering v1, + weak_ordering v2) noexcept { + return v1.value_ == v2.value_; + } + friend constexpr bool operator!=(weak_ordering v1, + weak_ordering v2) noexcept { + return v1.value_ != v2.value_; + } private: compare_internal::value_type value_; }; +ABSL_COMPARE_INLINE_INIT(weak_ordering, less, compare_internal::ord::less); +ABSL_COMPARE_INLINE_INIT(weak_ordering, equivalent, + compare_internal::eq::equivalent); +ABSL_COMPARE_INLINE_INIT(weak_ordering, greater, + compare_internal::ord::greater); class strong_ordering : public compare_internal::strong_ordering_base<strong_ordering> { @@ -375,6 +441,11 @@ friend struct compare_internal::strong_ordering_base<strong_ordering>; public: + ABSL_COMPARE_INLINE_SUBCLASS_DECL(strong_ordering, less); + ABSL_COMPARE_INLINE_SUBCLASS_DECL(strong_ordering, equal); + ABSL_COMPARE_INLINE_SUBCLASS_DECL(strong_ordering, equivalent); + ABSL_COMPARE_INLINE_SUBCLASS_DECL(strong_ordering, greater); + // Conversions constexpr operator weak_equality() const noexcept { // NOLINT return value_ == 0 ? weak_equality::equivalent @@ -442,10 +513,28 @@ strong_ordering v) noexcept { return 0 >= v.value_; } + friend constexpr bool operator==(strong_ordering v1, + strong_ordering v2) noexcept { + return v1.value_ == v2.value_; + } + friend constexpr bool operator!=(strong_ordering v1, + strong_ordering v2) noexcept { + return v1.value_ != v2.value_; + } private: compare_internal::value_type value_; }; +ABSL_COMPARE_INLINE_INIT(strong_ordering, less, compare_internal::ord::less); +ABSL_COMPARE_INLINE_INIT(strong_ordering, equal, compare_internal::eq::equal); +ABSL_COMPARE_INLINE_INIT(strong_ordering, equivalent, + compare_internal::eq::equivalent); +ABSL_COMPARE_INLINE_INIT(strong_ordering, greater, + compare_internal::ord::greater); + +#undef ABSL_COMPARE_INLINE_BASECLASS_DECL +#undef ABSL_COMPARE_INLINE_SUBCLASS_DECL +#undef ABSL_COMPARE_INLINE_INIT namespace compare_internal { // We also provide these comparator adapter functions for internal absl use. @@ -503,6 +592,7 @@ } } // namespace compare_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TYPES_COMPARE_H_
diff --git a/third_party/abseil-cpp/absl/types/compare_test.cc b/third_party/abseil-cpp/absl/types/compare_test.cc index 3a855421..8095baf 100644 --- a/third_party/abseil-cpp/absl/types/compare_test.cc +++ b/third_party/abseil-cpp/absl/types/compare_test.cc
@@ -18,6 +18,7 @@ #include "absl/base/casts.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { // This is necessary to avoid a bunch of lint warnings suggesting that we use @@ -30,6 +31,15 @@ EXPECT_TRUE(Identity(0 == weak_equality::equivalent)); EXPECT_TRUE(Identity(weak_equality::nonequivalent != 0)); EXPECT_TRUE(Identity(0 != weak_equality::nonequivalent)); + const weak_equality values[] = {weak_equality::equivalent, + weak_equality::nonequivalent}; + for (const auto& lhs : values) { + for (const auto& rhs : values) { + const bool are_equal = &lhs == &rhs; + EXPECT_EQ(lhs == rhs, are_equal); + EXPECT_EQ(lhs != rhs, !are_equal); + } + } } TEST(Compare, StrongEquality) { @@ -41,6 +51,18 @@ EXPECT_TRUE(Identity(0 == strong_equality::equivalent)); EXPECT_TRUE(Identity(strong_equality::nonequivalent != 0)); EXPECT_TRUE(Identity(0 != strong_equality::nonequivalent)); + const strong_equality values[] = {strong_equality::equal, + strong_equality::nonequal}; + for (const auto& lhs : values) { + for (const auto& rhs : values) { + const bool are_equal = &lhs == &rhs; + EXPECT_EQ(lhs == rhs, are_equal); + EXPECT_EQ(lhs != rhs, !are_equal); + } + } + EXPECT_TRUE(Identity(strong_equality::equivalent == strong_equality::equal)); + EXPECT_TRUE( + Identity(strong_equality::nonequivalent == strong_equality::nonequal)); } TEST(Compare, PartialOrdering) { @@ -64,6 +86,16 @@ EXPECT_FALSE(Identity(0 > partial_ordering::unordered)); EXPECT_FALSE(Identity(partial_ordering::unordered >= 0)); EXPECT_FALSE(Identity(0 >= partial_ordering::unordered)); + const partial_ordering values[] = { + partial_ordering::less, partial_ordering::equivalent, + partial_ordering::greater, partial_ordering::unordered}; + for (const auto& lhs : values) { + for (const auto& rhs : values) { + const bool are_equal = &lhs == &rhs; + EXPECT_EQ(lhs == rhs, are_equal); + EXPECT_EQ(lhs != rhs, !are_equal); + } + } } TEST(Compare, WeakOrdering) { @@ -77,6 +109,15 @@ EXPECT_TRUE(Identity(0 < weak_ordering::greater)); EXPECT_TRUE(Identity(weak_ordering::greater >= 0)); EXPECT_TRUE(Identity(0 <= weak_ordering::greater)); + const weak_ordering values[] = { + weak_ordering::less, weak_ordering::equivalent, weak_ordering::greater}; + for (const auto& lhs : values) { + for (const auto& rhs : values) { + const bool are_equal = &lhs == &rhs; + EXPECT_EQ(lhs == rhs, are_equal); + EXPECT_EQ(lhs != rhs, !are_equal); + } + } } TEST(Compare, StrongOrdering) { @@ -92,6 +133,16 @@ EXPECT_TRUE(Identity(0 < strong_ordering::greater)); EXPECT_TRUE(Identity(strong_ordering::greater >= 0)); EXPECT_TRUE(Identity(0 <= strong_ordering::greater)); + const strong_ordering values[] = { + strong_ordering::less, strong_ordering::equal, strong_ordering::greater}; + for (const auto& lhs : values) { + for (const auto& rhs : values) { + const bool are_equal = &lhs == &rhs; + EXPECT_EQ(lhs == rhs, are_equal); + EXPECT_EQ(lhs != rhs, !are_equal); + } + } + EXPECT_TRUE(Identity(strong_ordering::equivalent == strong_ordering::equal)); } TEST(Compare, Conversions) { @@ -189,7 +240,7 @@ struct WeakOrderingLess { template <typename T> - absl::weak_ordering operator()(const T &a, const T &b) const { + absl::weak_ordering operator()(const T& a, const T& b) const { return a < b ? absl::weak_ordering::less : a == b ? absl::weak_ordering::equivalent : absl::weak_ordering::greater; @@ -223,10 +274,10 @@ } TEST(CompareResultAsOrdering, SanityTest) { - EXPECT_TRUE(Identity( - absl::compare_internal::compare_result_as_ordering(-1) < 0)); - EXPECT_FALSE(Identity( - absl::compare_internal::compare_result_as_ordering(-1) == 0)); + EXPECT_TRUE( + Identity(absl::compare_internal::compare_result_as_ordering(-1) < 0)); + EXPECT_FALSE( + Identity(absl::compare_internal::compare_result_as_ordering(-1) == 0)); EXPECT_FALSE( Identity(absl::compare_internal::compare_result_as_ordering(-1) > 0)); EXPECT_TRUE(Identity(absl::compare_internal::compare_result_as_ordering( @@ -236,31 +287,31 @@ EXPECT_FALSE(Identity(absl::compare_internal::compare_result_as_ordering( weak_ordering::less) > 0)); - EXPECT_FALSE(Identity( - absl::compare_internal::compare_result_as_ordering(0) < 0)); - EXPECT_TRUE(Identity( - absl::compare_internal::compare_result_as_ordering(0) == 0)); - EXPECT_FALSE(Identity( - absl::compare_internal::compare_result_as_ordering(0) > 0)); + EXPECT_FALSE( + Identity(absl::compare_internal::compare_result_as_ordering(0) < 0)); + EXPECT_TRUE( + Identity(absl::compare_internal::compare_result_as_ordering(0) == 0)); + EXPECT_FALSE( + Identity(absl::compare_internal::compare_result_as_ordering(0) > 0)); EXPECT_FALSE(Identity(absl::compare_internal::compare_result_as_ordering( - weak_ordering::equivalent) < 0)); + weak_ordering::equivalent) < 0)); EXPECT_TRUE(Identity(absl::compare_internal::compare_result_as_ordering( - weak_ordering::equivalent) == 0)); + weak_ordering::equivalent) == 0)); EXPECT_FALSE(Identity(absl::compare_internal::compare_result_as_ordering( weak_ordering::equivalent) > 0)); - EXPECT_FALSE(Identity( - absl::compare_internal::compare_result_as_ordering(1) < 0)); - EXPECT_FALSE(Identity( - absl::compare_internal::compare_result_as_ordering(1) == 0)); - EXPECT_TRUE(Identity( - absl::compare_internal::compare_result_as_ordering(1) > 0)); + EXPECT_FALSE( + Identity(absl::compare_internal::compare_result_as_ordering(1) < 0)); + EXPECT_FALSE( + Identity(absl::compare_internal::compare_result_as_ordering(1) == 0)); + EXPECT_TRUE( + Identity(absl::compare_internal::compare_result_as_ordering(1) > 0)); EXPECT_FALSE(Identity(absl::compare_internal::compare_result_as_ordering( - weak_ordering::greater) < 0)); + weak_ordering::greater) < 0)); EXPECT_FALSE(Identity(absl::compare_internal::compare_result_as_ordering( weak_ordering::greater) == 0)); EXPECT_TRUE(Identity(absl::compare_internal::compare_result_as_ordering( - weak_ordering::greater) > 0)); + weak_ordering::greater) > 0)); } TEST(DoThreeWayComparison, SanityTest) { @@ -307,5 +358,32 @@ absl::compare_internal::do_three_way_comparison(weak, 10, 5) > 0)); } +#ifdef __cpp_inline_variables +TEST(Compare, StaticAsserts) { + static_assert(weak_equality::equivalent == 0, ""); + static_assert(weak_equality::nonequivalent != 0, ""); + + static_assert(strong_equality::equal == 0, ""); + static_assert(strong_equality::nonequal != 0, ""); + static_assert(strong_equality::equivalent == 0, ""); + static_assert(strong_equality::nonequivalent != 0, ""); + + static_assert(partial_ordering::less < 0, ""); + static_assert(partial_ordering::equivalent == 0, ""); + static_assert(partial_ordering::greater > 0, ""); + static_assert(partial_ordering::unordered != 0, ""); + + static_assert(weak_ordering::less < 0, ""); + static_assert(weak_ordering::equivalent == 0, ""); + static_assert(weak_ordering::greater > 0, ""); + + static_assert(strong_ordering::less < 0, ""); + static_assert(strong_ordering::equal == 0, ""); + static_assert(strong_ordering::equivalent == 0, ""); + static_assert(strong_ordering::greater > 0, ""); +} +#endif // __cpp_inline_variables + } // namespace +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/types/internal/conformance_aliases.h b/third_party/abseil-cpp/absl/types/internal/conformance_aliases.h new file mode 100644 index 0000000..0cc6884 --- /dev/null +++ b/third_party/abseil-cpp/absl/types/internal/conformance_aliases.h
@@ -0,0 +1,447 @@ +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------- +// regularity_aliases.h +// ----------------------------------------------------------------------------- +// +// This file contains type aliases of common ConformanceProfiles and Archetypes +// so that they can be directly used by name without creating them from scratch. + +#ifndef ABSL_TYPES_INTERNAL_CONFORMANCE_ALIASES_H_ +#define ABSL_TYPES_INTERNAL_CONFORMANCE_ALIASES_H_ + +#include "absl/types/internal/conformance_archetype.h" +#include "absl/types/internal/conformance_profile.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace types_internal { + +// Creates both a Profile and a corresponding Archetype with root name "name". +#define ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS(name, ...) \ + struct name##Profile : __VA_ARGS__ {}; \ + \ + using name##Archetype = ::absl::types_internal::Archetype<name##Profile>; \ + \ + template <class AbslInternalProfileTag> \ + using name##Archetype##_ = ::absl::types_internal::Archetype< \ + ::absl::types_internal::StrongProfileTypedef<name##Profile, \ + AbslInternalProfileTag>> + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasTrivialDefaultConstructor, + ConformanceProfile<default_constructible::trivial>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowDefaultConstructor, + ConformanceProfile<default_constructible::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasDefaultConstructor, ConformanceProfile<default_constructible::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasTrivialMoveConstructor, ConformanceProfile<default_constructible::maybe, + move_constructible::trivial>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowMoveConstructor, ConformanceProfile<default_constructible::maybe, + move_constructible::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasMoveConstructor, + ConformanceProfile<default_constructible::maybe, move_constructible::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasTrivialCopyConstructor, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::trivial>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowCopyConstructor, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasCopyConstructor, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasTrivialMoveAssign, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::trivial>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowMoveAssign, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasMoveAssign, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasTrivialCopyAssign, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::trivial>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowCopyAssign, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasCopyAssign, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasTrivialDestructor, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::trivial>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowDestructor, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasDestructor, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowEquality, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasEquality, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowInequality, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::maybe, + inequality_comparable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasInequality, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::maybe, inequality_comparable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowLessThan, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::maybe, inequality_comparable::maybe, + less_than_comparable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasLessThan, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::maybe, inequality_comparable::maybe, + less_than_comparable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowLessEqual, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::maybe, inequality_comparable::maybe, + less_than_comparable::maybe, + less_equal_comparable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasLessEqual, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::maybe, inequality_comparable::maybe, + less_than_comparable::maybe, + less_equal_comparable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowGreaterEqual, + ConformanceProfile< + default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, + inequality_comparable::maybe, less_than_comparable::maybe, + less_equal_comparable::maybe, greater_equal_comparable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasGreaterEqual, + ConformanceProfile< + default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, + inequality_comparable::maybe, less_than_comparable::maybe, + less_equal_comparable::maybe, greater_equal_comparable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowGreaterThan, + ConformanceProfile< + default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, + inequality_comparable::maybe, less_than_comparable::maybe, + less_equal_comparable::maybe, greater_equal_comparable::maybe, + greater_than_comparable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasGreaterThan, + ConformanceProfile< + default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, + inequality_comparable::maybe, less_than_comparable::maybe, + less_equal_comparable::maybe, greater_equal_comparable::maybe, + greater_than_comparable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowSwap, + ConformanceProfile< + default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, + inequality_comparable::maybe, less_than_comparable::maybe, + less_equal_comparable::maybe, greater_equal_comparable::maybe, + greater_than_comparable::maybe, swappable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasSwap, + ConformanceProfile< + default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, + inequality_comparable::maybe, less_than_comparable::maybe, + less_equal_comparable::maybe, greater_equal_comparable::maybe, + greater_than_comparable::maybe, swappable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasStdHashSpecialization, + ConformanceProfile< + default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, + inequality_comparable::maybe, less_than_comparable::maybe, + less_equal_comparable::maybe, greater_equal_comparable::maybe, + greater_than_comparable::maybe, swappable::maybe, hashable::yes>); + +//////////////////////////////////////////////////////////////////////////////// +//// The remaining aliases are combinations of the previous aliases. //// +//////////////////////////////////////////////////////////////////////////////// + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + Equatable, CombineProfiles<HasEqualityProfile, HasInequalityProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + Comparable, + CombineProfiles<EquatableProfile, HasLessThanProfile, HasLessEqualProfile, + HasGreaterEqualProfile, HasGreaterThanProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + NothrowEquatable, + CombineProfiles<HasNothrowEqualityProfile, HasNothrowInequalityProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + NothrowComparable, + CombineProfiles<NothrowEquatableProfile, HasNothrowLessThanProfile, + HasNothrowLessEqualProfile, HasNothrowGreaterEqualProfile, + HasNothrowGreaterThanProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + Value, + CombineProfiles<HasNothrowMoveConstructorProfile, HasCopyConstructorProfile, + HasNothrowMoveAssignProfile, HasCopyAssignProfile, + HasNothrowDestructorProfile, HasNothrowSwapProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + EquatableValue, CombineProfiles<EquatableProfile, ValueProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + ComparableValue, CombineProfiles<ComparableProfile, ValueProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + DefaultConstructibleValue, + CombineProfiles<HasDefaultConstructorProfile, ValueProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + NothrowMoveConstructible, CombineProfiles<HasNothrowMoveConstructorProfile, + HasNothrowDestructorProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + EquatableNothrowMoveConstructible, + CombineProfiles<EquatableProfile, NothrowMoveConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + ComparableNothrowMoveConstructible, + CombineProfiles<ComparableProfile, NothrowMoveConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + DefaultConstructibleNothrowMoveConstructible, + CombineProfiles<HasDefaultConstructorProfile, + NothrowMoveConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + CopyConstructible, + CombineProfiles<HasNothrowMoveConstructorProfile, HasCopyConstructorProfile, + HasNothrowDestructorProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + EquatableCopyConstructible, + CombineProfiles<EquatableProfile, CopyConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + ComparableCopyConstructible, + CombineProfiles<ComparableProfile, CopyConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + DefaultConstructibleCopyConstructible, + CombineProfiles<HasDefaultConstructorProfile, CopyConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + NothrowMovable, + CombineProfiles<HasNothrowMoveConstructorProfile, + HasNothrowMoveAssignProfile, HasNothrowDestructorProfile, + HasNothrowSwapProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + EquatableNothrowMovable, + CombineProfiles<EquatableProfile, NothrowMovableProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + ComparableNothrowMovable, + CombineProfiles<ComparableProfile, NothrowMovableProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + DefaultConstructibleNothrowMovable, + CombineProfiles<HasDefaultConstructorProfile, NothrowMovableProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + TrivialSpecialMemberFunctions, + CombineProfiles<HasTrivialDefaultConstructorProfile, + HasTrivialMoveConstructorProfile, + HasTrivialCopyConstructorProfile, + HasTrivialMoveAssignProfile, HasTrivialCopyAssignProfile, + HasTrivialDestructorProfile, HasNothrowSwapProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + TriviallyComplete, + CombineProfiles<TrivialSpecialMemberFunctionsProfile, ComparableProfile, + HasStdHashSpecializationProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HashableNothrowMoveConstructible, + CombineProfiles<HasStdHashSpecializationProfile, + NothrowMoveConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HashableCopyConstructible, + CombineProfiles<HasStdHashSpecializationProfile, CopyConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HashableNothrowMovable, + CombineProfiles<HasStdHashSpecializationProfile, NothrowMovableProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HashableValue, + CombineProfiles<HasStdHashSpecializationProfile, ValueProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + ComparableHashableValue, + CombineProfiles<HashableValueProfile, ComparableProfile>); + +// The "preferred" profiles that we support in Abseil. +template <template <class...> class Receiver> +using ExpandBasicProfiles = + Receiver<NothrowMoveConstructibleProfile, CopyConstructibleProfile, + NothrowMovableProfile, ValueProfile>; + +// The basic profiles except that they are also all Equatable. +template <template <class...> class Receiver> +using ExpandBasicEquatableProfiles = + Receiver<EquatableNothrowMoveConstructibleProfile, + EquatableCopyConstructibleProfile, EquatableNothrowMovableProfile, + EquatableValueProfile>; + +// The basic profiles except that they are also all Comparable. +template <template <class...> class Receiver> +using ExpandBasicComparableProfiles = + Receiver<ComparableNothrowMoveConstructibleProfile, + ComparableCopyConstructibleProfile, + ComparableNothrowMovableProfile, ComparableValueProfile>; + +// The basic profiles except that they are also all Hashable. +template <template <class...> class Receiver> +using ExpandBasicHashableProfiles = + Receiver<HashableNothrowMoveConstructibleProfile, + HashableCopyConstructibleProfile, HashableNothrowMovableProfile, + HashableValueProfile>; + +// The basic profiles except that they are also all DefaultConstructible. +template <template <class...> class Receiver> +using ExpandBasicDefaultConstructibleProfiles = + Receiver<DefaultConstructibleNothrowMoveConstructibleProfile, + DefaultConstructibleCopyConstructibleProfile, + DefaultConstructibleNothrowMovableProfile, + DefaultConstructibleValueProfile>; + +// The type profiles that we support in Abseil (all of the previous lists). +template <template <class...> class Receiver> +using ExpandSupportedProfiles = Receiver< + NothrowMoveConstructibleProfile, CopyConstructibleProfile, + NothrowMovableProfile, ValueProfile, + EquatableNothrowMoveConstructibleProfile, EquatableCopyConstructibleProfile, + EquatableNothrowMovableProfile, EquatableValueProfile, + ComparableNothrowMoveConstructibleProfile, + ComparableCopyConstructibleProfile, ComparableNothrowMovableProfile, + ComparableValueProfile, DefaultConstructibleNothrowMoveConstructibleProfile, + DefaultConstructibleCopyConstructibleProfile, + DefaultConstructibleNothrowMovableProfile, DefaultConstructibleValueProfile, + HashableNothrowMoveConstructibleProfile, HashableCopyConstructibleProfile, + HashableNothrowMovableProfile, HashableValueProfile>; + +// TODO(calabrese) Include types that have throwing move constructors, since in +// practice we still need to support them because of standard library types with +// (potentially) non-noexcept moves. + +} // namespace types_internal +ABSL_NAMESPACE_END +} // namespace absl + +#undef ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS + +#endif // ABSL_TYPES_INTERNAL_CONFORMANCE_ALIASES_H_
diff --git a/third_party/abseil-cpp/absl/types/internal/conformance_archetype.h b/third_party/abseil-cpp/absl/types/internal/conformance_archetype.h new file mode 100644 index 0000000..2349e0f --- /dev/null +++ b/third_party/abseil-cpp/absl/types/internal/conformance_archetype.h
@@ -0,0 +1,978 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------- +// conformance_archetype.h +// ----------------------------------------------------------------------------- +// +// This file contains a facility for generating "archetypes" of out of +// "Conformance Profiles" (see "conformance_profiles.h" for more information +// about Conformance Profiles). An archetype is a type that aims to support the +// bare minimum requirements of a given Conformance Profile. For instance, an +// archetype that corresponds to an ImmutableProfile has exactly a nothrow +// move-constructor, a potentially-throwing copy constructor, a nothrow +// destructor, with all other special-member-functions deleted. These archetypes +// are useful for testing to make sure that templates are able to work with the +// kinds of types that they claim to support (i.e. that they do not accidentally +// under-constrain), +// +// The main type template in this file is the Archetype template, which takes +// a Conformance Profile as a template argument and its instantiations are a +// minimum-conforming model of that profile. + +#ifndef ABSL_TYPES_INTERNAL_CONFORMANCE_ARCHETYPE_H_ +#define ABSL_TYPES_INTERNAL_CONFORMANCE_ARCHETYPE_H_ + +#include <cstddef> +#include <functional> +#include <type_traits> +#include <utility> + +#include "absl/meta/type_traits.h" +#include "absl/types/internal/conformance_profile.h" + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace types_internal { + +// A minimum-conforming implementation of a type with properties specified in +// `Prof`, where `Prof` is a valid Conformance Profile. +template <class Prof, class /*Enabler*/ = void> +class Archetype; + +// Given an Archetype, obtain the properties of the profile associated with that +// archetype. +template <class Archetype> +struct PropertiesOfArchetype; + +template <class Prof> +struct PropertiesOfArchetype<Archetype<Prof>> { + using type = PropertiesOfT<Prof>; +}; + +template <class Archetype> +using PropertiesOfArchetypeT = typename PropertiesOfArchetype<Archetype>::type; + +// A metafunction to determine if a type is an `Archetype`. +template <class T> +struct IsArchetype : std::false_type {}; + +template <class Prof> +struct IsArchetype<Archetype<Prof>> : std::true_type {}; + +// A constructor tag type used when creating an Archetype with internal state. +struct MakeArchetypeState {}; + +// Data stored within an archetype that is copied/compared/hashed when the +// corresponding operations are used. +using ArchetypeState = std::size_t; + +//////////////////////////////////////////////////////////////////////////////// +// This section of the file defines a chain of base classes for Archetype, // +// where each base defines a specific special member function with the // +// appropriate properties (deleted, noexcept(false), noexcept, or trivial). // +//////////////////////////////////////////////////////////////////////////////// + +// The bottom-most base, which contains the state and the default constructor. +template <default_constructible DefaultConstructibleValue> +struct ArchetypeStateBase { + static_assert(DefaultConstructibleValue == default_constructible::yes || + DefaultConstructibleValue == default_constructible::nothrow, + ""); + + ArchetypeStateBase() noexcept( + DefaultConstructibleValue == + default_constructible:: + nothrow) /*Vacuous archetype_state initialization*/ {} + explicit ArchetypeStateBase(MakeArchetypeState, ArchetypeState state) noexcept + : archetype_state(state) {} + + ArchetypeState archetype_state; +}; + +template <> +struct ArchetypeStateBase<default_constructible::maybe> { + explicit ArchetypeStateBase() = delete; + explicit ArchetypeStateBase(MakeArchetypeState, ArchetypeState state) noexcept + : archetype_state(state) {} + + ArchetypeState archetype_state; +}; + +template <> +struct ArchetypeStateBase<default_constructible::trivial> { + ArchetypeStateBase() = default; + explicit ArchetypeStateBase(MakeArchetypeState, ArchetypeState state) noexcept + : archetype_state(state) {} + + ArchetypeState archetype_state; +}; + +// The move-constructor base +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue> +struct ArchetypeMoveConstructor + : ArchetypeStateBase<DefaultConstructibleValue> { + static_assert(MoveConstructibleValue == move_constructible::yes || + MoveConstructibleValue == move_constructible::nothrow, + ""); + + explicit ArchetypeMoveConstructor(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeStateBase<DefaultConstructibleValue>(MakeArchetypeState(), + state) {} + + ArchetypeMoveConstructor() = default; + ArchetypeMoveConstructor(ArchetypeMoveConstructor&& other) noexcept( + MoveConstructibleValue == move_constructible::nothrow) + : ArchetypeStateBase<DefaultConstructibleValue>(MakeArchetypeState(), + other.archetype_state) {} + ArchetypeMoveConstructor(const ArchetypeMoveConstructor&) = default; + ArchetypeMoveConstructor& operator=(ArchetypeMoveConstructor&&) = default; + ArchetypeMoveConstructor& operator=(const ArchetypeMoveConstructor&) = + default; +}; + +template <default_constructible DefaultConstructibleValue> +struct ArchetypeMoveConstructor<DefaultConstructibleValue, + move_constructible::trivial> + : ArchetypeStateBase<DefaultConstructibleValue> { + explicit ArchetypeMoveConstructor(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeStateBase<DefaultConstructibleValue>(MakeArchetypeState(), + state) {} + + ArchetypeMoveConstructor() = default; +}; + +// The copy-constructor base +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue> +struct ArchetypeCopyConstructor + : ArchetypeMoveConstructor<DefaultConstructibleValue, + MoveConstructibleValue> { + static_assert(CopyConstructibleValue == copy_constructible::yes || + CopyConstructibleValue == copy_constructible::nothrow, + ""); + explicit ArchetypeCopyConstructor(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeMoveConstructor<DefaultConstructibleValue, + MoveConstructibleValue>(MakeArchetypeState(), + state) {} + + ArchetypeCopyConstructor() = default; + ArchetypeCopyConstructor(ArchetypeCopyConstructor&&) = default; + ArchetypeCopyConstructor(const ArchetypeCopyConstructor& other) noexcept( + CopyConstructibleValue == copy_constructible::nothrow) + : ArchetypeMoveConstructor<DefaultConstructibleValue, + MoveConstructibleValue>( + MakeArchetypeState(), other.archetype_state) {} + ArchetypeCopyConstructor& operator=(ArchetypeCopyConstructor&&) = default; + ArchetypeCopyConstructor& operator=(const ArchetypeCopyConstructor&) = + default; +}; + +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue> +struct ArchetypeCopyConstructor<DefaultConstructibleValue, + MoveConstructibleValue, + copy_constructible::maybe> + : ArchetypeMoveConstructor<DefaultConstructibleValue, + MoveConstructibleValue> { + explicit ArchetypeCopyConstructor(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeMoveConstructor<DefaultConstructibleValue, + MoveConstructibleValue>(MakeArchetypeState(), + state) {} + + ArchetypeCopyConstructor() = default; + ArchetypeCopyConstructor(ArchetypeCopyConstructor&&) = default; + ArchetypeCopyConstructor(const ArchetypeCopyConstructor&) = delete; + ArchetypeCopyConstructor& operator=(ArchetypeCopyConstructor&&) = default; + ArchetypeCopyConstructor& operator=(const ArchetypeCopyConstructor&) = + default; +}; + +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue> +struct ArchetypeCopyConstructor<DefaultConstructibleValue, + MoveConstructibleValue, + copy_constructible::trivial> + : ArchetypeMoveConstructor<DefaultConstructibleValue, + MoveConstructibleValue> { + explicit ArchetypeCopyConstructor(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeMoveConstructor<DefaultConstructibleValue, + MoveConstructibleValue>(MakeArchetypeState(), + state) {} + + ArchetypeCopyConstructor() = default; +}; + +// The move-assign base +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue, + move_assignable MoveAssignableValue> +struct ArchetypeMoveAssign + : ArchetypeCopyConstructor<DefaultConstructibleValue, + MoveConstructibleValue, CopyConstructibleValue> { + static_assert(MoveAssignableValue == move_assignable::yes || + MoveAssignableValue == move_assignable::nothrow, + ""); + explicit ArchetypeMoveAssign(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeCopyConstructor<DefaultConstructibleValue, + MoveConstructibleValue, + CopyConstructibleValue>(MakeArchetypeState(), + state) {} + + ArchetypeMoveAssign() = default; + ArchetypeMoveAssign(ArchetypeMoveAssign&&) = default; + ArchetypeMoveAssign(const ArchetypeMoveAssign&) = default; + ArchetypeMoveAssign& operator=(ArchetypeMoveAssign&& other) noexcept( + MoveAssignableValue == move_assignable::nothrow) { + this->archetype_state = other.archetype_state; + return *this; + } + + ArchetypeMoveAssign& operator=(const ArchetypeMoveAssign&) = default; +}; + +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue> +struct ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, move_assignable::trivial> + : ArchetypeCopyConstructor<DefaultConstructibleValue, + MoveConstructibleValue, CopyConstructibleValue> { + explicit ArchetypeMoveAssign(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeCopyConstructor<DefaultConstructibleValue, + MoveConstructibleValue, + CopyConstructibleValue>(MakeArchetypeState(), + state) {} + + ArchetypeMoveAssign() = default; +}; + +// The copy-assign base +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue, + move_assignable MoveAssignableValue, + copy_assignable CopyAssignableValue> +struct ArchetypeCopyAssign + : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue> { + static_assert(CopyAssignableValue == copy_assignable::yes || + CopyAssignableValue == copy_assignable::nothrow, + ""); + explicit ArchetypeCopyAssign(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue>( + MakeArchetypeState(), state) {} + + ArchetypeCopyAssign() = default; + ArchetypeCopyAssign(ArchetypeCopyAssign&&) = default; + ArchetypeCopyAssign(const ArchetypeCopyAssign&) = default; + ArchetypeCopyAssign& operator=(ArchetypeCopyAssign&&) = default; + + ArchetypeCopyAssign& operator=(const ArchetypeCopyAssign& other) noexcept( + CopyAssignableValue == copy_assignable::nothrow) { + this->archetype_state = other.archetype_state; + return *this; + } +}; + +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue, + move_assignable MoveAssignableValue> +struct ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue, + copy_assignable::maybe> + : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue> { + explicit ArchetypeCopyAssign(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue>( + MakeArchetypeState(), state) {} + + ArchetypeCopyAssign() = default; + ArchetypeCopyAssign(ArchetypeCopyAssign&&) = default; + ArchetypeCopyAssign(const ArchetypeCopyAssign&) = default; + ArchetypeCopyAssign& operator=(ArchetypeCopyAssign&&) = default; + ArchetypeCopyAssign& operator=(const ArchetypeCopyAssign&) = delete; +}; + +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue, + move_assignable MoveAssignableValue> +struct ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue, + copy_assignable::trivial> + : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue> { + explicit ArchetypeCopyAssign(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue>( + MakeArchetypeState(), state) {} + + ArchetypeCopyAssign() = default; +}; + +// The destructor base +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue, + move_assignable MoveAssignableValue, + copy_assignable CopyAssignableValue, destructible DestructibleValue> +struct ArchetypeDestructor + : ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue, + CopyAssignableValue> { + static_assert(DestructibleValue == destructible::yes || + DestructibleValue == destructible::nothrow, + ""); + + explicit ArchetypeDestructor(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue, + CopyAssignableValue>(MakeArchetypeState(), state) {} + + ArchetypeDestructor() = default; + ArchetypeDestructor(ArchetypeDestructor&&) = default; + ArchetypeDestructor(const ArchetypeDestructor&) = default; + ArchetypeDestructor& operator=(ArchetypeDestructor&&) = default; + ArchetypeDestructor& operator=(const ArchetypeDestructor&) = default; + ~ArchetypeDestructor() noexcept(DestructibleValue == destructible::nothrow) {} +}; + +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue, + move_assignable MoveAssignableValue, + copy_assignable CopyAssignableValue> +struct ArchetypeDestructor<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue, + CopyAssignableValue, destructible::trivial> + : ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue, + CopyAssignableValue> { + explicit ArchetypeDestructor(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue, + CopyAssignableValue>(MakeArchetypeState(), state) {} + + ArchetypeDestructor() = default; +}; + +// An alias to the top of the chain of bases for special-member functions. +// NOTE: move_constructible::maybe, move_assignable::maybe, and +// destructible::maybe are handled in the top-level type by way of SFINAE. +// Because of this, we never instantiate the base classes with +// move_constructible::maybe, move_assignable::maybe, or destructible::maybe so +// that we minimize the number of different possible type-template +// instantiations. +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue, + move_assignable MoveAssignableValue, + copy_assignable CopyAssignableValue, destructible DestructibleValue> +using ArchetypeSpecialMembersBase = ArchetypeDestructor< + DefaultConstructibleValue, + MoveConstructibleValue != move_constructible::maybe + ? MoveConstructibleValue + : move_constructible::nothrow, + CopyConstructibleValue, + MoveAssignableValue != move_assignable::maybe ? MoveAssignableValue + : move_assignable::nothrow, + CopyAssignableValue, + DestructibleValue != destructible::maybe ? DestructibleValue + : destructible::nothrow>; + +// A function that is used to create an archetype with some associated state. +template <class Arch> +Arch MakeArchetype(ArchetypeState state) noexcept { + static_assert(IsArchetype<Arch>::value, + "The explicit template argument to MakeArchetype is required " + "to be an Archetype."); + return Arch(MakeArchetypeState(), state); +} + +// This is used to conditionally delete "copy" and "move" constructors in a way +// that is consistent with what the ConformanceProfile requires and that also +// strictly enforces the arguments to the copy/move to not come from implicit +// conversions when dealing with the Archetype. +template <class Prof, class T> +constexpr bool ShouldDeleteConstructor() { + return !((PropertiesOfT<Prof>::move_constructible_support != + move_constructible::maybe && + std::is_same<T, Archetype<Prof>>::value) || + (PropertiesOfT<Prof>::copy_constructible_support != + copy_constructible::maybe && + (std::is_same<T, const Archetype<Prof>&>::value || + std::is_same<T, Archetype<Prof>&>::value || + std::is_same<T, const Archetype<Prof>>::value))); +} + +// This is used to conditionally delete "copy" and "move" assigns in a way +// that is consistent with what the ConformanceProfile requires and that also +// strictly enforces the arguments to the copy/move to not come from implicit +// conversions when dealing with the Archetype. +template <class Prof, class T> +constexpr bool ShouldDeleteAssign() { + return !( + (PropertiesOfT<Prof>::move_assignable_support != move_assignable::maybe && + std::is_same<T, Archetype<Prof>>::value) || + (PropertiesOfT<Prof>::copy_assignable_support != copy_assignable::maybe && + (std::is_same<T, const Archetype<Prof>&>::value || + std::is_same<T, Archetype<Prof>&>::value || + std::is_same<T, const Archetype<Prof>>::value))); +} + +// TODO(calabrese) Inherit from a chain of secondary bases to pull in the +// associated functions of other concepts. +template <class Prof, class Enabler> +class Archetype : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support> { + static_assert(std::is_same<Enabler, void>::value, + "An explicit type must not be passed as the second template " + "argument to 'Archetype`."); + + // The cases mentioned in these static_asserts are expected to be handled in + // the partial template specializations of Archetype that follow this + // definition. + static_assert(PropertiesOfT<Prof>::destructible_support != + destructible::maybe, + ""); + static_assert(PropertiesOfT<Prof>::move_constructible_support != + move_constructible::maybe || + PropertiesOfT<Prof>::copy_constructible_support == + copy_constructible::maybe, + ""); + static_assert(PropertiesOfT<Prof>::move_assignable_support != + move_assignable::maybe || + PropertiesOfT<Prof>::copy_assignable_support == + copy_assignable::maybe, + ""); + + public: + Archetype() = default; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> + Archetype(T&&) = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteAssign<Prof, T>()>::type* = nullptr> + Archetype& operator=(T&&) = delete; + + using ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>::archetype_state; + + private: + explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), + state) {} + + friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; +}; + +template <class Prof> +class Archetype<Prof, typename std::enable_if< + PropertiesOfT<Prof>::move_constructible_support != + move_constructible::maybe && + PropertiesOfT<Prof>::move_assignable_support == + move_assignable::maybe && + PropertiesOfT<Prof>::destructible_support != + destructible::maybe>::type> + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support> { + public: + Archetype() = default; + Archetype(Archetype&&) = default; + Archetype(const Archetype&) = default; + Archetype& operator=(Archetype&&) = delete; + Archetype& operator=(const Archetype&) = default; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> + Archetype(T&&) = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteAssign<Prof, T>()>::type* = nullptr> + Archetype& operator=(T&&) = delete; + + using ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>::archetype_state; + + private: + explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), + state) {} + + friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; +}; + +template <class Prof> +class Archetype<Prof, typename std::enable_if< + PropertiesOfT<Prof>::move_constructible_support == + move_constructible::maybe && + PropertiesOfT<Prof>::move_assignable_support == + move_assignable::maybe && + PropertiesOfT<Prof>::destructible_support != + destructible::maybe>::type> + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support> { + public: + Archetype() = default; + Archetype(Archetype&&) = delete; + Archetype(const Archetype&) = default; + Archetype& operator=(Archetype&&) = delete; + Archetype& operator=(const Archetype&) = default; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> + Archetype(T&&) = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteAssign<Prof, T>()>::type* = nullptr> + Archetype& operator=(T&&) = delete; + + using ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>::archetype_state; + + private: + explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), + state) {} + + friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; +}; + +template <class Prof> +class Archetype<Prof, typename std::enable_if< + PropertiesOfT<Prof>::move_constructible_support == + move_constructible::maybe && + PropertiesOfT<Prof>::move_assignable_support != + move_assignable::maybe && + PropertiesOfT<Prof>::destructible_support != + destructible::maybe>::type> + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support> { + public: + Archetype() = default; + Archetype(Archetype&&) = delete; + Archetype(const Archetype&) = default; + Archetype& operator=(Archetype&&) = default; + Archetype& operator=(const Archetype&) = default; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> + Archetype(T&&) = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteAssign<Prof, T>()>::type* = nullptr> + Archetype& operator=(T&&) = delete; + + using ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>::archetype_state; + + private: + explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), + state) {} + + friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; +}; + +template <class Prof> +class Archetype<Prof, typename std::enable_if< + PropertiesOfT<Prof>::move_constructible_support != + move_constructible::maybe && + PropertiesOfT<Prof>::move_assignable_support == + move_assignable::maybe && + PropertiesOfT<Prof>::destructible_support == + destructible::maybe>::type> + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support> { + public: + Archetype() = default; + Archetype(Archetype&&) = default; + Archetype(const Archetype&) = default; + Archetype& operator=(Archetype&&) = delete; + Archetype& operator=(const Archetype&) = default; + ~Archetype() = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> + Archetype(T&&) = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteAssign<Prof, T>()>::type* = nullptr> + Archetype& operator=(T&&) = delete; + + using ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>::archetype_state; + + private: + explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), + state) {} + + friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; +}; + +template <class Prof> +class Archetype<Prof, typename std::enable_if< + PropertiesOfT<Prof>::move_constructible_support == + move_constructible::maybe && + PropertiesOfT<Prof>::move_assignable_support == + move_assignable::maybe && + PropertiesOfT<Prof>::destructible_support == + destructible::maybe>::type> + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support> { + public: + Archetype() = default; + Archetype(Archetype&&) = delete; + Archetype(const Archetype&) = default; + Archetype& operator=(Archetype&&) = delete; + Archetype& operator=(const Archetype&) = default; + ~Archetype() = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> + Archetype(T&&) = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteAssign<Prof, T>()>::type* = nullptr> + Archetype& operator=(T&&) = delete; + + using ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>::archetype_state; + + private: + explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), + state) {} + + friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; +}; + +template <class Prof> +class Archetype<Prof, typename std::enable_if< + PropertiesOfT<Prof>::move_constructible_support == + move_constructible::maybe && + PropertiesOfT<Prof>::move_assignable_support != + move_assignable::maybe && + PropertiesOfT<Prof>::destructible_support == + destructible::maybe>::type> + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support> { + public: + Archetype() = default; + Archetype(Archetype&&) = delete; + Archetype(const Archetype&) = default; + Archetype& operator=(Archetype&&) = default; + Archetype& operator=(const Archetype&) = default; + ~Archetype() = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> + Archetype(T&&) = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteAssign<Prof, T>()>::type* = nullptr> + Archetype& operator=(T&&) = delete; + + using ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>::archetype_state; + + private: + explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), + state) {} + + friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; +}; + +// Explicitly deleted swap for Archetype if the profile does not require swap. +// It is important to delete it rather than simply leave it out so that the +// "using std::swap;" idiom will result in this deleted overload being picked. +template <class Prof, + absl::enable_if_t<!PropertiesOfT<Prof>::is_swappable, int> = 0> +void swap(Archetype<Prof>&, Archetype<Prof>&) = delete; // NOLINT + +// A conditionally-noexcept swap implementation for Archetype when the profile +// supports swap. +template <class Prof, + absl::enable_if_t<PropertiesOfT<Prof>::is_swappable, int> = 0> +void swap(Archetype<Prof>& lhs, Archetype<Prof>& rhs) // NOLINT + noexcept(PropertiesOfT<Prof>::swappable_support != swappable::yes) { + std::swap(lhs.archetype_state, rhs.archetype_state); +} + +// A convertible-to-bool type that is used as the return type of comparison +// operators since the standard doesn't always require exactly bool. +struct NothrowBool { + explicit NothrowBool() = delete; + ~NothrowBool() = default; + + // TODO(calabrese) Delete the copy constructor in C++17 mode since guaranteed + // elision makes it not required when returning from a function. + // NothrowBool(NothrowBool const&) = delete; + + NothrowBool& operator=(NothrowBool const&) = delete; + + explicit operator bool() const noexcept { return value; } + + static NothrowBool make(bool const value) noexcept { + return NothrowBool(value); + } + + private: + explicit NothrowBool(bool const value) noexcept : value(value) {} + + bool value; +}; + +// A convertible-to-bool type that is used as the return type of comparison +// operators since the standard doesn't always require exactly bool. +// Note: ExceptionalBool has a conversion operator that is not noexcept, so +// that even when a comparison operator is noexcept, that operation may still +// potentially throw when converted to bool. +struct ExceptionalBool { + explicit ExceptionalBool() = delete; + ~ExceptionalBool() = default; + + // TODO(calabrese) Delete the copy constructor in C++17 mode since guaranteed + // elision makes it not required when returning from a function. + // ExceptionalBool(ExceptionalBool const&) = delete; + + ExceptionalBool& operator=(ExceptionalBool const&) = delete; + + explicit operator bool() const { return value; } // NOLINT + + static ExceptionalBool make(bool const value) noexcept { + return ExceptionalBool(value); + } + + private: + explicit ExceptionalBool(bool const value) noexcept : value(value) {} + + bool value; +}; + +// The following macro is only used as a helper in this file to stamp out +// comparison operator definitions. It is undefined after usage. +// +// NOTE: Non-nothrow operators throw via their result's conversion to bool even +// though the operation itself is noexcept. +#define ABSL_TYPES_INTERNAL_OP(enum_name, op) \ + template <class Prof> \ + absl::enable_if_t<!PropertiesOfT<Prof>::is_##enum_name, bool> operator op( \ + const Archetype<Prof>&, const Archetype<Prof>&) = delete; \ + \ + template <class Prof> \ + typename absl::enable_if_t< \ + PropertiesOfT<Prof>::is_##enum_name, \ + std::conditional<PropertiesOfT<Prof>::enum_name##_support == \ + enum_name::nothrow, \ + NothrowBool, ExceptionalBool>>::type \ + operator op(const Archetype<Prof>& lhs, \ + const Archetype<Prof>& rhs) noexcept { \ + return absl::conditional_t< \ + PropertiesOfT<Prof>::enum_name##_support == enum_name::nothrow, \ + NothrowBool, ExceptionalBool>::make(lhs.archetype_state op \ + rhs.archetype_state); \ + } + +ABSL_TYPES_INTERNAL_OP(equality_comparable, ==); +ABSL_TYPES_INTERNAL_OP(inequality_comparable, !=); +ABSL_TYPES_INTERNAL_OP(less_than_comparable, <); +ABSL_TYPES_INTERNAL_OP(less_equal_comparable, <=); +ABSL_TYPES_INTERNAL_OP(greater_equal_comparable, >=); +ABSL_TYPES_INTERNAL_OP(greater_than_comparable, >); + +#undef ABSL_TYPES_INTERNAL_OP + +// Base class for std::hash specializations when an Archetype doesn't support +// hashing. +struct PoisonedHash { + PoisonedHash() = delete; + PoisonedHash(const PoisonedHash&) = delete; + PoisonedHash& operator=(const PoisonedHash&) = delete; +}; + +// Base class for std::hash specializations when an Archetype supports hashing. +template <class Prof> +struct EnabledHash { + using argument_type = Archetype<Prof>; + using result_type = std::size_t; + result_type operator()(const argument_type& arg) const { + return std::hash<ArchetypeState>()(arg.archetype_state); + } +}; + +} // namespace types_internal +ABSL_NAMESPACE_END +} // namespace absl + +namespace std { + +template <class Prof> // NOLINT +struct hash<::absl::types_internal::Archetype<Prof>> + : conditional<::absl::types_internal::PropertiesOfT<Prof>::is_hashable, + ::absl::types_internal::EnabledHash<Prof>, + ::absl::types_internal::PoisonedHash>::type {}; + +} // namespace std + +#endif // ABSL_TYPES_INTERNAL_CONFORMANCE_ARCHETYPE_H_
diff --git a/third_party/abseil-cpp/absl/types/internal/conformance_profile.h b/third_party/abseil-cpp/absl/types/internal/conformance_profile.h new file mode 100644 index 0000000..e62004f --- /dev/null +++ b/third_party/abseil-cpp/absl/types/internal/conformance_profile.h
@@ -0,0 +1,376 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------- +// conformance_profiles.h +// ----------------------------------------------------------------------------- +// +// This file contains templates for representing "Regularity Profiles" and +// concisely-named versions of commonly used Regularity Profiles. +// +// A Regularity Profile is a compile-time description of the types of operations +// that a given type supports, along with properties of those operations when +// they do exist. For instance, a Regularity Profile may describe a type that +// has a move-constructor that is noexcept and a copy constructor that is not +// noexcept. This description can then be examined and passed around to other +// templates for the purposes of asserting expectations on user-defined types +// via a series trait checks, or for determining what kinds of run-time tests +// are able to be performed. +// +// Regularity Profiles are also used when creating "archetypes," which are +// minimum-conforming types that meet all of the requirements of a given +// Regularity Profile. For more information regarding archetypes, see +// "conformance_archetypes.h". + +#ifndef ABSL_TYPES_INTERNAL_CONFORMANCE_PROFILE_H_ +#define ABSL_TYPES_INTERNAL_CONFORMANCE_PROFILE_H_ + +#include <type_traits> +#include <utility> + +#include "absl/meta/type_traits.h" + +// TODO(calabrese) Add support for extending profiles. + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace types_internal { + +template <class T, class /*Enabler*/ = void> +struct PropertiesOfImpl {}; + +template <class T> +struct PropertiesOfImpl<T, absl::void_t<typename T::properties>> { + using type = typename T::properties; +}; + +template <class T> +struct PropertiesOfImpl<T, absl::void_t<typename T::profile_alias_of>> { + using type = typename PropertiesOfImpl<typename T::profile_alias_of>::type; +}; + +template <class T> +struct PropertiesOf : PropertiesOfImpl<T> {}; + +template <class T> +using PropertiesOfT = typename PropertiesOf<T>::type; + +// NOTE: These enums use this naming convention to be consistent with the +// standard trait names, which is useful since it allows us to match up each +// enum name with a corresponding trait name in macro definitions. + +enum class function_kind { maybe, yes, nothrow, trivial }; + +#define ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM(name) \ + enum class name { maybe, yes, nothrow, trivial } + +ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM(default_constructible); +ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM(move_constructible); +ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM(copy_constructible); +ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM(move_assignable); +ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM(copy_assignable); +ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM(destructible); + +#undef ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM + +#define ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(name) \ + enum class name { maybe, yes, nothrow } + +ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(equality_comparable); +ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(inequality_comparable); +ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(less_than_comparable); +ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(less_equal_comparable); +ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(greater_equal_comparable); +ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(greater_than_comparable); + +ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(swappable); + +#undef ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM + +enum class hashable { maybe, yes }; + +constexpr const char* PropertyName(hashable v) { + return "support for std::hash"; +} + +template < + default_constructible DefaultConstructibleValue = + default_constructible::maybe, + move_constructible MoveConstructibleValue = move_constructible::maybe, + copy_constructible CopyConstructibleValue = copy_constructible::maybe, + move_assignable MoveAssignableValue = move_assignable::maybe, + copy_assignable CopyAssignableValue = copy_assignable::maybe, + destructible DestructibleValue = destructible::maybe, + equality_comparable EqualityComparableValue = equality_comparable::maybe, + inequality_comparable InequalityComparableValue = + inequality_comparable::maybe, + less_than_comparable LessThanComparableValue = less_than_comparable::maybe, + less_equal_comparable LessEqualComparableValue = + less_equal_comparable::maybe, + greater_equal_comparable GreaterEqualComparableValue = + greater_equal_comparable::maybe, + greater_than_comparable GreaterThanComparableValue = + greater_than_comparable::maybe, + swappable SwappableValue = swappable::maybe, + hashable HashableValue = hashable::maybe> +struct ConformanceProfile { + using properties = ConformanceProfile; + + static constexpr default_constructible + default_constructible_support = // NOLINT + DefaultConstructibleValue; + + static constexpr move_constructible move_constructible_support = // NOLINT + MoveConstructibleValue; + + static constexpr copy_constructible copy_constructible_support = // NOLINT + CopyConstructibleValue; + + static constexpr move_assignable move_assignable_support = // NOLINT + MoveAssignableValue; + + static constexpr copy_assignable copy_assignable_support = // NOLINT + CopyAssignableValue; + + static constexpr destructible destructible_support = // NOLINT + DestructibleValue; + + static constexpr equality_comparable equality_comparable_support = // NOLINT + EqualityComparableValue; + + static constexpr inequality_comparable + inequality_comparable_support = // NOLINT + InequalityComparableValue; + + static constexpr less_than_comparable + less_than_comparable_support = // NOLINT + LessThanComparableValue; + + static constexpr less_equal_comparable + less_equal_comparable_support = // NOLINT + LessEqualComparableValue; + + static constexpr greater_equal_comparable + greater_equal_comparable_support = // NOLINT + GreaterEqualComparableValue; + + static constexpr greater_than_comparable + greater_than_comparable_support = // NOLINT + GreaterThanComparableValue; + + static constexpr swappable swappable_support = SwappableValue; // NOLINT + + static constexpr hashable hashable_support = HashableValue; // NOLINT + + static constexpr bool is_default_constructible = // NOLINT + DefaultConstructibleValue != default_constructible::maybe; + + static constexpr bool is_move_constructible = // NOLINT + MoveConstructibleValue != move_constructible::maybe; + + static constexpr bool is_copy_constructible = // NOLINT + CopyConstructibleValue != copy_constructible::maybe; + + static constexpr bool is_move_assignable = // NOLINT + MoveAssignableValue != move_assignable::maybe; + + static constexpr bool is_copy_assignable = // NOLINT + CopyAssignableValue != copy_assignable::maybe; + + static constexpr bool is_destructible = // NOLINT + DestructibleValue != destructible::maybe; + + static constexpr bool is_equality_comparable = // NOLINT + EqualityComparableValue != equality_comparable::maybe; + + static constexpr bool is_inequality_comparable = // NOLINT + InequalityComparableValue != inequality_comparable::maybe; + + static constexpr bool is_less_than_comparable = // NOLINT + LessThanComparableValue != less_than_comparable::maybe; + + static constexpr bool is_less_equal_comparable = // NOLINT + LessEqualComparableValue != less_equal_comparable::maybe; + + static constexpr bool is_greater_equal_comparable = // NOLINT + GreaterEqualComparableValue != greater_equal_comparable::maybe; + + static constexpr bool is_greater_than_comparable = // NOLINT + GreaterThanComparableValue != greater_than_comparable::maybe; + + static constexpr bool is_swappable = // NOLINT + SwappableValue != swappable::maybe; + + static constexpr bool is_hashable = // NOLINT + HashableValue != hashable::maybe; +}; + +#define ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF_IMPL(type, name) \ + template <default_constructible DefaultConstructibleValue, \ + move_constructible MoveConstructibleValue, \ + copy_constructible CopyConstructibleValue, \ + move_assignable MoveAssignableValue, \ + copy_assignable CopyAssignableValue, \ + destructible DestructibleValue, \ + equality_comparable EqualityComparableValue, \ + inequality_comparable InequalityComparableValue, \ + less_than_comparable LessThanComparableValue, \ + less_equal_comparable LessEqualComparableValue, \ + greater_equal_comparable GreaterEqualComparableValue, \ + greater_than_comparable GreaterThanComparableValue, \ + swappable SwappableValue, hashable HashableValue> \ + constexpr type ConformanceProfile< \ + DefaultConstructibleValue, MoveConstructibleValue, \ + CopyConstructibleValue, MoveAssignableValue, CopyAssignableValue, \ + DestructibleValue, EqualityComparableValue, InequalityComparableValue, \ + LessThanComparableValue, LessEqualComparableValue, \ + GreaterEqualComparableValue, GreaterThanComparableValue, SwappableValue, \ + HashableValue>::name + +#define ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(type) \ + ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF_IMPL(type, \ + type##_support); \ + ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF_IMPL(bool, is_##type) + +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(default_constructible); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(move_constructible); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(copy_constructible); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(move_assignable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(copy_assignable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(destructible); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(equality_comparable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(inequality_comparable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(less_than_comparable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(less_equal_comparable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(greater_equal_comparable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(greater_than_comparable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(swappable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(hashable); + +#undef ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF +#undef ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF_IMPL + +// Converts an enum to its underlying integral value. +template <class Enum> +constexpr absl::underlying_type_t<Enum> UnderlyingValue(Enum value) { + return static_cast<absl::underlying_type_t<Enum>>(value); +} + +// Retrieve the enum with the greatest underlying value. +// Note: std::max is not constexpr in C++11, which is why this is necessary. +template <class H> +constexpr H MaxEnum(H head) { + return head; +} + +template <class H, class N, class... T> +constexpr H MaxEnum(H head, N next, T... tail) { + return (UnderlyingValue)(next) < (UnderlyingValue)(head) + ? (MaxEnum)(head, tail...) + : (MaxEnum)(next, tail...); +} + +template <class... Profs> +struct CombineProfilesImpl { + static constexpr default_constructible + default_constructible_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::default_constructible_support...); + + static constexpr move_constructible move_constructible_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::move_constructible_support...); + + static constexpr copy_constructible copy_constructible_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::copy_constructible_support...); + + static constexpr move_assignable move_assignable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::move_assignable_support...); + + static constexpr copy_assignable copy_assignable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::copy_assignable_support...); + + static constexpr destructible destructible_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::destructible_support...); + + static constexpr equality_comparable equality_comparable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::equality_comparable_support...); + + static constexpr inequality_comparable + inequality_comparable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::inequality_comparable_support...); + + static constexpr less_than_comparable + less_than_comparable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::less_than_comparable_support...); + + static constexpr less_equal_comparable + less_equal_comparable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::less_equal_comparable_support...); + + static constexpr greater_equal_comparable + greater_equal_comparable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::greater_equal_comparable_support...); + + static constexpr greater_than_comparable + greater_than_comparable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::greater_than_comparable_support...); + + static constexpr swappable swappable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::swappable_support...); + + static constexpr hashable hashable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::hashable_support...); + + using properties = ConformanceProfile< + default_constructible_support, move_constructible_support, + copy_constructible_support, move_assignable_support, + copy_assignable_support, destructible_support, + equality_comparable_support, inequality_comparable_support, + less_than_comparable_support, less_equal_comparable_support, + greater_equal_comparable_support, greater_than_comparable_support, + swappable_support, hashable_support>; +}; + +// NOTE: We use this as opposed to a direct alias of CombineProfilesImpl so that +// when named aliases of CombineProfiles are created (such as in +// conformance_aliases.h), we only pay for the combination algorithm on the +// profiles that are actually used. +template <class... Profs> +struct CombineProfiles { + using profile_alias_of = CombineProfilesImpl<Profs...>; +}; + +template <> +struct CombineProfiles<> { + using properties = ConformanceProfile<>; +}; + +template <class Profile, class Tag> +struct StrongProfileTypedef { + using properties = PropertiesOfT<Profile>; +}; + +template <class T, class /*Enabler*/ = void> +struct IsProfileImpl : std::false_type {}; + +template <class T> +struct IsProfileImpl<T, absl::void_t<PropertiesOfT<T>>> : std::true_type {}; + +template <class T> +struct IsProfile : IsProfileImpl<T>::type {}; + +} // namespace types_internal +ABSL_NAMESPACE_END +} // namespace absl + +#endif // ABSL_TYPES_INTERNAL_CONFORMANCE_PROFILE_H_
diff --git a/third_party/abseil-cpp/absl/types/internal/conformance_testing_test.cc b/third_party/abseil-cpp/absl/types/internal/conformance_testing_test.cc new file mode 100644 index 0000000..3dcf530 --- /dev/null +++ b/third_party/abseil-cpp/absl/types/internal/conformance_testing_test.cc
@@ -0,0 +1,1186 @@ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include <new> +#include <type_traits> +#include <utility> + +#include "gtest/gtest.h" +#include "absl/meta/type_traits.h" +#include "absl/types/internal/conformance_aliases.h" + +namespace { + +namespace ti = absl::types_internal; + +template <class T> +using DefaultConstructibleWithNewImpl = decltype(::new (std::nothrow) T); + +template <class T> +using DefaultConstructibleWithNew = + absl::type_traits_internal::is_detected<DefaultConstructibleWithNewImpl, T>; + +template <class T> +using MoveConstructibleWithNewImpl = + decltype(::new (std::nothrow) T(std::declval<T>())); + +template <class T> +using MoveConstructibleWithNew = + absl::type_traits_internal::is_detected<MoveConstructibleWithNewImpl, T>; + +template <class T> +using CopyConstructibleWithNewImpl = + decltype(::new (std::nothrow) T(std::declval<const T&>())); + +template <class T> +using CopyConstructibleWithNew = + absl::type_traits_internal::is_detected<CopyConstructibleWithNewImpl, T>; + +template <class T, + class Result = + std::integral_constant<bool, noexcept(::new (std::nothrow) T)>> +using NothrowDefaultConstructibleWithNewImpl = + typename std::enable_if<Result::value>::type; + +template <class T> +using NothrowDefaultConstructibleWithNew = + absl::type_traits_internal::is_detected< + NothrowDefaultConstructibleWithNewImpl, T>; + +template <class T, + class Result = std::integral_constant< + bool, noexcept(::new (std::nothrow) T(std::declval<T>()))>> +using NothrowMoveConstructibleWithNewImpl = + typename std::enable_if<Result::value>::type; + +template <class T> +using NothrowMoveConstructibleWithNew = + absl::type_traits_internal::is_detected<NothrowMoveConstructibleWithNewImpl, + T>; + +template <class T, + class Result = std::integral_constant< + bool, noexcept(::new (std::nothrow) T(std::declval<const T&>()))>> +using NothrowCopyConstructibleWithNewImpl = + typename std::enable_if<Result::value>::type; + +template <class T> +using NothrowCopyConstructibleWithNew = + absl::type_traits_internal::is_detected<NothrowCopyConstructibleWithNewImpl, + T>; + +// NOTE: ?: is used to verify contextually-convertible to bool and not simply +// implicit or explicit convertibility. +#define ABSL_INTERNAL_COMPARISON_OP_EXPR(op) \ + ((std::declval<const T&>() op std::declval<const T&>()) ? true : true) + +#define ABSL_INTERNAL_COMPARISON_OP_TRAIT(name, op) \ + template <class T> \ + using name##Impl = decltype(ABSL_INTERNAL_COMPARISON_OP_EXPR(op)); \ + \ + template <class T> \ + using name = absl::type_traits_internal::is_detected<name##Impl, T>; \ + \ + template <class T, \ + class Result = std::integral_constant< \ + bool, noexcept(ABSL_INTERNAL_COMPARISON_OP_EXPR(op))>> \ + using Nothrow##name##Impl = typename std::enable_if<Result::value>::type; \ + \ + template <class T> \ + using Nothrow##name = \ + absl::type_traits_internal::is_detected<Nothrow##name##Impl, T> + +ABSL_INTERNAL_COMPARISON_OP_TRAIT(EqualityComparable, ==); +ABSL_INTERNAL_COMPARISON_OP_TRAIT(InequalityComparable, !=); +ABSL_INTERNAL_COMPARISON_OP_TRAIT(LessThanComparable, <); +ABSL_INTERNAL_COMPARISON_OP_TRAIT(LessEqualComparable, <=); +ABSL_INTERNAL_COMPARISON_OP_TRAIT(GreaterEqualComparable, >=); +ABSL_INTERNAL_COMPARISON_OP_TRAIT(GreaterThanComparable, >); + +#undef ABSL_INTERNAL_COMPARISON_OP_TRAIT + +template <class T> +class ProfileTest : public ::testing::Test {}; + +TYPED_TEST_SUITE_P(ProfileTest); + +TYPED_TEST_P(ProfileTest, HasAppropriateConstructionProperties) { + using profile = typename TypeParam::profile; + using arch = typename TypeParam::arch; + using expected_profile = typename TypeParam::expected_profile; + + using props = ti::PropertiesOfT<profile>; + using arch_props = ti::PropertiesOfArchetypeT<arch>; + using expected_props = ti::PropertiesOfT<expected_profile>; + + // Make sure all of the properties are as expected. + // There are seemingly redundant tests here to make it easier to diagnose + // the specifics of the failure if something were to go wrong. + EXPECT_TRUE((std::is_same<props, arch_props>::value)); + EXPECT_TRUE((std::is_same<props, expected_props>::value)); + EXPECT_TRUE((std::is_same<arch_props, expected_props>::value)); + + EXPECT_EQ(props::default_constructible_support, + expected_props::default_constructible_support); + + EXPECT_EQ(props::move_constructible_support, + expected_props::move_constructible_support); + + EXPECT_EQ(props::copy_constructible_support, + expected_props::copy_constructible_support); + + EXPECT_EQ(props::destructible_support, expected_props::destructible_support); + + // Avoid additional error message noise when profile and archetype match with + // each other but were not what was expected. + if (!std::is_same<props, arch_props>::value) { + EXPECT_EQ(arch_props::default_constructible_support, + expected_props::default_constructible_support); + + EXPECT_EQ(arch_props::move_constructible_support, + expected_props::move_constructible_support); + + EXPECT_EQ(arch_props::copy_constructible_support, + expected_props::copy_constructible_support); + + EXPECT_EQ(arch_props::destructible_support, + expected_props::destructible_support); + } + + ////////////////////////////////////////////////////////////////////////////// + // Default constructor checks // + ////////////////////////////////////////////////////////////////////////////// + EXPECT_EQ(props::default_constructible_support, + expected_props::default_constructible_support); + + switch (expected_props::default_constructible_support) { + case ti::default_constructible::maybe: + EXPECT_FALSE(DefaultConstructibleWithNew<arch>::value); + EXPECT_FALSE(NothrowDefaultConstructibleWithNew<arch>::value); + + // Standard constructible traits depend on the destructor. + if (std::is_destructible<arch>::value) { + EXPECT_FALSE(std::is_default_constructible<arch>::value); + EXPECT_FALSE(std::is_nothrow_default_constructible<arch>::value); + EXPECT_FALSE(absl::is_trivially_default_constructible<arch>::value); + } + break; + case ti::default_constructible::yes: + EXPECT_TRUE(DefaultConstructibleWithNew<arch>::value); + EXPECT_FALSE(NothrowDefaultConstructibleWithNew<arch>::value); + + // Standard constructible traits depend on the destructor. + if (std::is_destructible<arch>::value) { + EXPECT_TRUE(std::is_default_constructible<arch>::value); + EXPECT_FALSE(std::is_nothrow_default_constructible<arch>::value); + EXPECT_FALSE(absl::is_trivially_default_constructible<arch>::value); + } + break; + case ti::default_constructible::nothrow: + EXPECT_TRUE(DefaultConstructibleWithNew<arch>::value); + EXPECT_TRUE(NothrowDefaultConstructibleWithNew<arch>::value); + + // Standard constructible traits depend on the destructor. + if (std::is_destructible<arch>::value) { + EXPECT_TRUE(std::is_default_constructible<arch>::value); + EXPECT_TRUE(std::is_nothrow_default_constructible<arch>::value); + EXPECT_FALSE(absl::is_trivially_default_constructible<arch>::value); + + // Constructor traits also check the destructor. + if (std::is_nothrow_destructible<arch>::value) { + EXPECT_TRUE(std::is_nothrow_default_constructible<arch>::value); + } + } + break; + case ti::default_constructible::trivial: + EXPECT_TRUE(DefaultConstructibleWithNew<arch>::value); + EXPECT_TRUE(NothrowDefaultConstructibleWithNew<arch>::value); + + // Standard constructible traits depend on the destructor. + if (std::is_destructible<arch>::value) { + EXPECT_TRUE(std::is_default_constructible<arch>::value); + EXPECT_TRUE(std::is_nothrow_default_constructible<arch>::value); + + // Constructor triviality traits require trivially destructible types. + if (absl::is_trivially_destructible<arch>::value) { + EXPECT_TRUE(absl::is_trivially_default_constructible<arch>::value); + } + } + break; + } + + ////////////////////////////////////////////////////////////////////////////// + // Move constructor checks // + ////////////////////////////////////////////////////////////////////////////// + EXPECT_EQ(props::move_constructible_support, + expected_props::move_constructible_support); + + switch (expected_props::move_constructible_support) { + case ti::move_constructible::maybe: + EXPECT_FALSE(MoveConstructibleWithNew<arch>::value); + EXPECT_FALSE(NothrowMoveConstructibleWithNew<arch>::value); + + // Standard constructible traits depend on the destructor. + if (std::is_destructible<arch>::value) { + EXPECT_FALSE(std::is_move_constructible<arch>::value); + EXPECT_FALSE(std::is_nothrow_move_constructible<arch>::value); + EXPECT_FALSE(absl::is_trivially_move_constructible<arch>::value); + } + break; + case ti::move_constructible::yes: + EXPECT_TRUE(MoveConstructibleWithNew<arch>::value); + EXPECT_FALSE(NothrowMoveConstructibleWithNew<arch>::value); + + // Standard constructible traits depend on the destructor. + if (std::is_destructible<arch>::value) { + EXPECT_TRUE(std::is_move_constructible<arch>::value); + EXPECT_FALSE(std::is_nothrow_move_constructible<arch>::value); + EXPECT_FALSE(absl::is_trivially_move_constructible<arch>::value); + } + break; + case ti::move_constructible::nothrow: + EXPECT_TRUE(MoveConstructibleWithNew<arch>::value); + EXPECT_TRUE(NothrowMoveConstructibleWithNew<arch>::value); + + // Standard constructible traits depend on the destructor. + if (std::is_destructible<arch>::value) { + EXPECT_TRUE(std::is_move_constructible<arch>::value); + EXPECT_TRUE(std::is_nothrow_move_constructible<arch>::value); + EXPECT_FALSE(absl::is_trivially_move_constructible<arch>::value); + + // Constructor traits also check the destructor. + if (std::is_nothrow_destructible<arch>::value) { + EXPECT_TRUE(std::is_nothrow_move_constructible<arch>::value); + } + } + break; + case ti::move_constructible::trivial: + EXPECT_TRUE(MoveConstructibleWithNew<arch>::value); + EXPECT_TRUE(NothrowMoveConstructibleWithNew<arch>::value); + + // Standard constructible traits depend on the destructor. + if (std::is_destructible<arch>::value) { + EXPECT_TRUE(std::is_move_constructible<arch>::value); + EXPECT_TRUE(std::is_nothrow_move_constructible<arch>::value); + + // Constructor triviality traits require trivially destructible types. + if (absl::is_trivially_destructible<arch>::value) { + EXPECT_TRUE(absl::is_trivially_move_constructible<arch>::value); + } + } + break; + } + + ////////////////////////////////////////////////////////////////////////////// + // Copy constructor checks // + ////////////////////////////////////////////////////////////////////////////// + EXPECT_EQ(props::copy_constructible_support, + expected_props::copy_constructible_support); + + switch (expected_props::copy_constructible_support) { + case ti::copy_constructible::maybe: + EXPECT_FALSE(CopyConstructibleWithNew<arch>::value); + EXPECT_FALSE(NothrowCopyConstructibleWithNew<arch>::value); + + // Standard constructible traits depend on the destructor. + if (std::is_destructible<arch>::value) { + EXPECT_FALSE(std::is_copy_constructible<arch>::value); + EXPECT_FALSE(std::is_nothrow_copy_constructible<arch>::value); + EXPECT_FALSE(absl::is_trivially_copy_constructible<arch>::value); + } + break; + case ti::copy_constructible::yes: + EXPECT_TRUE(CopyConstructibleWithNew<arch>::value); + EXPECT_FALSE(NothrowCopyConstructibleWithNew<arch>::value); + + // Standard constructible traits depend on the destructor. + if (std::is_destructible<arch>::value) { + EXPECT_TRUE(std::is_copy_constructible<arch>::value); + EXPECT_FALSE(std::is_nothrow_copy_constructible<arch>::value); + EXPECT_FALSE(absl::is_trivially_copy_constructible<arch>::value); + } + break; + case ti::copy_constructible::nothrow: + EXPECT_TRUE(CopyConstructibleWithNew<arch>::value); + EXPECT_TRUE(NothrowCopyConstructibleWithNew<arch>::value); + + // Standard constructible traits depend on the destructor. + if (std::is_destructible<arch>::value) { + EXPECT_TRUE(std::is_copy_constructible<arch>::value); + EXPECT_TRUE(std::is_nothrow_copy_constructible<arch>::value); + EXPECT_FALSE(absl::is_trivially_copy_constructible<arch>::value); + + // Constructor traits also check the destructor. + if (std::is_nothrow_destructible<arch>::value) { + EXPECT_TRUE(std::is_nothrow_copy_constructible<arch>::value); + } + } + break; + case ti::copy_constructible::trivial: + EXPECT_TRUE(CopyConstructibleWithNew<arch>::value); + EXPECT_TRUE(NothrowCopyConstructibleWithNew<arch>::value); + + // Standard constructible traits depend on the destructor. + if (std::is_destructible<arch>::value) { + EXPECT_TRUE(std::is_copy_constructible<arch>::value); + EXPECT_TRUE(std::is_nothrow_copy_constructible<arch>::value); + + // Constructor triviality traits require trivially destructible types. + if (absl::is_trivially_destructible<arch>::value) { + EXPECT_TRUE(absl::is_trivially_copy_constructible<arch>::value); + } + } + break; + } + + ////////////////////////////////////////////////////////////////////////////// + // Destructible checks // + ////////////////////////////////////////////////////////////////////////////// + EXPECT_EQ(props::destructible_support, expected_props::destructible_support); + + switch (expected_props::destructible_support) { + case ti::destructible::maybe: + EXPECT_FALSE(std::is_destructible<arch>::value); + EXPECT_FALSE(std::is_nothrow_destructible<arch>::value); + EXPECT_FALSE(absl::is_trivially_destructible<arch>::value); + break; + case ti::destructible::yes: + EXPECT_TRUE(std::is_destructible<arch>::value); + EXPECT_FALSE(std::is_nothrow_destructible<arch>::value); + EXPECT_FALSE(absl::is_trivially_destructible<arch>::value); + break; + case ti::destructible::nothrow: + EXPECT_TRUE(std::is_destructible<arch>::value); + EXPECT_TRUE(std::is_nothrow_destructible<arch>::value); + EXPECT_FALSE(absl::is_trivially_destructible<arch>::value); + break; + case ti::destructible::trivial: + EXPECT_TRUE(std::is_destructible<arch>::value); + EXPECT_TRUE(std::is_nothrow_destructible<arch>::value); + EXPECT_TRUE(absl::is_trivially_destructible<arch>::value); + break; + } +} + +TYPED_TEST_P(ProfileTest, HasAppropriateAssignmentProperties) { + using profile = typename TypeParam::profile; + using arch = typename TypeParam::arch; + using expected_profile = typename TypeParam::expected_profile; + + using props = ti::PropertiesOfT<profile>; + using arch_props = ti::PropertiesOfArchetypeT<arch>; + using expected_props = ti::PropertiesOfT<expected_profile>; + + // Make sure all of the properties are as expected. + // There are seemingly redundant tests here to make it easier to diagnose + // the specifics of the failure if something were to go wrong. + EXPECT_TRUE((std::is_same<props, arch_props>::value)); + EXPECT_TRUE((std::is_same<props, expected_props>::value)); + EXPECT_TRUE((std::is_same<arch_props, expected_props>::value)); + + EXPECT_EQ(props::move_assignable_support, + expected_props::move_assignable_support); + + EXPECT_EQ(props::copy_assignable_support, + expected_props::copy_assignable_support); + + // Avoid additional error message noise when profile and archetype match with + // each other but were not what was expected. + if (!std::is_same<props, arch_props>::value) { + EXPECT_EQ(arch_props::move_assignable_support, + expected_props::move_assignable_support); + + EXPECT_EQ(arch_props::copy_assignable_support, + expected_props::copy_assignable_support); + } + + ////////////////////////////////////////////////////////////////////////////// + // Move assignment checks // + ////////////////////////////////////////////////////////////////////////////// + EXPECT_EQ(props::move_assignable_support, + expected_props::move_assignable_support); + + switch (expected_props::move_assignable_support) { + case ti::move_assignable::maybe: + EXPECT_FALSE(std::is_move_assignable<arch>::value); + EXPECT_FALSE(std::is_nothrow_move_assignable<arch>::value); + EXPECT_FALSE(absl::is_trivially_move_assignable<arch>::value); + break; + case ti::move_assignable::yes: + EXPECT_TRUE(std::is_move_assignable<arch>::value); + EXPECT_FALSE(std::is_nothrow_move_assignable<arch>::value); + EXPECT_FALSE(absl::is_trivially_move_assignable<arch>::value); + break; + case ti::move_assignable::nothrow: + EXPECT_TRUE(std::is_move_assignable<arch>::value); + EXPECT_TRUE(std::is_nothrow_move_assignable<arch>::value); + EXPECT_FALSE(absl::is_trivially_move_assignable<arch>::value); + break; + case ti::move_assignable::trivial: + EXPECT_TRUE(std::is_move_assignable<arch>::value); + EXPECT_TRUE(std::is_nothrow_move_assignable<arch>::value); + EXPECT_TRUE(absl::is_trivially_move_assignable<arch>::value); + break; + } + + ////////////////////////////////////////////////////////////////////////////// + // Copy assignment checks // + ////////////////////////////////////////////////////////////////////////////// + EXPECT_EQ(props::copy_assignable_support, + expected_props::copy_assignable_support); + + switch (expected_props::copy_assignable_support) { + case ti::copy_assignable::maybe: + EXPECT_FALSE(std::is_copy_assignable<arch>::value); + EXPECT_FALSE(std::is_nothrow_copy_assignable<arch>::value); + EXPECT_FALSE(absl::is_trivially_copy_assignable<arch>::value); + break; + case ti::copy_assignable::yes: + EXPECT_TRUE(std::is_copy_assignable<arch>::value); + EXPECT_FALSE(std::is_nothrow_copy_assignable<arch>::value); + EXPECT_FALSE(absl::is_trivially_copy_assignable<arch>::value); + break; + case ti::copy_assignable::nothrow: + EXPECT_TRUE(std::is_copy_assignable<arch>::value); + EXPECT_TRUE(std::is_nothrow_copy_assignable<arch>::value); + EXPECT_FALSE(absl::is_trivially_copy_assignable<arch>::value); + break; + case ti::copy_assignable::trivial: + EXPECT_TRUE(std::is_copy_assignable<arch>::value); + EXPECT_TRUE(std::is_nothrow_copy_assignable<arch>::value); + EXPECT_TRUE(absl::is_trivially_copy_assignable<arch>::value); + break; + } +} + +TYPED_TEST_P(ProfileTest, HasAppropriateComparisonProperties) { + using profile = typename TypeParam::profile; + using arch = typename TypeParam::arch; + using expected_profile = typename TypeParam::expected_profile; + + using props = ti::PropertiesOfT<profile>; + using arch_props = ti::PropertiesOfArchetypeT<arch>; + using expected_props = ti::PropertiesOfT<expected_profile>; + + // Make sure all of the properties are as expected. + // There are seemingly redundant tests here to make it easier to diagnose + // the specifics of the failure if something were to go wrong. + EXPECT_TRUE((std::is_same<props, arch_props>::value)); + EXPECT_TRUE((std::is_same<props, expected_props>::value)); + EXPECT_TRUE((std::is_same<arch_props, expected_props>::value)); + + EXPECT_EQ(props::equality_comparable_support, + expected_props::equality_comparable_support); + + EXPECT_EQ(props::inequality_comparable_support, + expected_props::inequality_comparable_support); + + EXPECT_EQ(props::less_than_comparable_support, + expected_props::less_than_comparable_support); + + EXPECT_EQ(props::less_equal_comparable_support, + expected_props::less_equal_comparable_support); + + EXPECT_EQ(props::greater_equal_comparable_support, + expected_props::greater_equal_comparable_support); + + EXPECT_EQ(props::greater_than_comparable_support, + expected_props::greater_than_comparable_support); + + // Avoid additional error message noise when profile and archetype match with + // each other but were not what was expected. + if (!std::is_same<props, arch_props>::value) { + EXPECT_EQ(arch_props::equality_comparable_support, + expected_props::equality_comparable_support); + + EXPECT_EQ(arch_props::inequality_comparable_support, + expected_props::inequality_comparable_support); + + EXPECT_EQ(arch_props::less_than_comparable_support, + expected_props::less_than_comparable_support); + + EXPECT_EQ(arch_props::less_equal_comparable_support, + expected_props::less_equal_comparable_support); + + EXPECT_EQ(arch_props::greater_equal_comparable_support, + expected_props::greater_equal_comparable_support); + + EXPECT_EQ(arch_props::greater_than_comparable_support, + expected_props::greater_than_comparable_support); + } + + ////////////////////////////////////////////////////////////////////////////// + // Equality comparable checks // + ////////////////////////////////////////////////////////////////////////////// + switch (expected_props::equality_comparable_support) { + case ti::equality_comparable::maybe: + EXPECT_FALSE(EqualityComparable<arch>::value); + EXPECT_FALSE(NothrowEqualityComparable<arch>::value); + break; + case ti::equality_comparable::yes: + EXPECT_TRUE(EqualityComparable<arch>::value); + EXPECT_FALSE(NothrowEqualityComparable<arch>::value); + break; + case ti::equality_comparable::nothrow: + EXPECT_TRUE(EqualityComparable<arch>::value); + EXPECT_TRUE(NothrowEqualityComparable<arch>::value); + break; + } + + ////////////////////////////////////////////////////////////////////////////// + // Inequality comparable checks // + ////////////////////////////////////////////////////////////////////////////// + switch (expected_props::inequality_comparable_support) { + case ti::inequality_comparable::maybe: + EXPECT_FALSE(InequalityComparable<arch>::value); + EXPECT_FALSE(NothrowInequalityComparable<arch>::value); + break; + case ti::inequality_comparable::yes: + EXPECT_TRUE(InequalityComparable<arch>::value); + EXPECT_FALSE(NothrowInequalityComparable<arch>::value); + break; + case ti::inequality_comparable::nothrow: + EXPECT_TRUE(InequalityComparable<arch>::value); + EXPECT_TRUE(NothrowInequalityComparable<arch>::value); + break; + } + + ////////////////////////////////////////////////////////////////////////////// + // Less than comparable checks // + ////////////////////////////////////////////////////////////////////////////// + switch (expected_props::less_than_comparable_support) { + case ti::less_than_comparable::maybe: + EXPECT_FALSE(LessThanComparable<arch>::value); + EXPECT_FALSE(NothrowLessThanComparable<arch>::value); + break; + case ti::less_than_comparable::yes: + EXPECT_TRUE(LessThanComparable<arch>::value); + EXPECT_FALSE(NothrowLessThanComparable<arch>::value); + break; + case ti::less_than_comparable::nothrow: + EXPECT_TRUE(LessThanComparable<arch>::value); + EXPECT_TRUE(NothrowLessThanComparable<arch>::value); + break; + } + + ////////////////////////////////////////////////////////////////////////////// + // Less equal comparable checks // + ////////////////////////////////////////////////////////////////////////////// + switch (expected_props::less_equal_comparable_support) { + case ti::less_equal_comparable::maybe: + EXPECT_FALSE(LessEqualComparable<arch>::value); + EXPECT_FALSE(NothrowLessEqualComparable<arch>::value); + break; + case ti::less_equal_comparable::yes: + EXPECT_TRUE(LessEqualComparable<arch>::value); + EXPECT_FALSE(NothrowLessEqualComparable<arch>::value); + break; + case ti::less_equal_comparable::nothrow: + EXPECT_TRUE(LessEqualComparable<arch>::value); + EXPECT_TRUE(NothrowLessEqualComparable<arch>::value); + break; + } + + ////////////////////////////////////////////////////////////////////////////// + // Greater equal comparable checks // + ////////////////////////////////////////////////////////////////////////////// + switch (expected_props::greater_equal_comparable_support) { + case ti::greater_equal_comparable::maybe: + EXPECT_FALSE(GreaterEqualComparable<arch>::value); + EXPECT_FALSE(NothrowGreaterEqualComparable<arch>::value); + break; + case ti::greater_equal_comparable::yes: + EXPECT_TRUE(GreaterEqualComparable<arch>::value); + EXPECT_FALSE(NothrowGreaterEqualComparable<arch>::value); + break; + case ti::greater_equal_comparable::nothrow: + EXPECT_TRUE(GreaterEqualComparable<arch>::value); + EXPECT_TRUE(NothrowGreaterEqualComparable<arch>::value); + break; + } + + ////////////////////////////////////////////////////////////////////////////// + // Greater than comparable checks // + ////////////////////////////////////////////////////////////////////////////// + switch (expected_props::greater_than_comparable_support) { + case ti::greater_than_comparable::maybe: + EXPECT_FALSE(GreaterThanComparable<arch>::value); + EXPECT_FALSE(NothrowGreaterThanComparable<arch>::value); + break; + case ti::greater_than_comparable::yes: + EXPECT_TRUE(GreaterThanComparable<arch>::value); + EXPECT_FALSE(NothrowGreaterThanComparable<arch>::value); + break; + case ti::greater_than_comparable::nothrow: + EXPECT_TRUE(GreaterThanComparable<arch>::value); + EXPECT_TRUE(NothrowGreaterThanComparable<arch>::value); + break; + } +} + +TYPED_TEST_P(ProfileTest, HasAppropriateAuxilliaryProperties) { + using profile = typename TypeParam::profile; + using arch = typename TypeParam::arch; + using expected_profile = typename TypeParam::expected_profile; + + using props = ti::PropertiesOfT<profile>; + using arch_props = ti::PropertiesOfArchetypeT<arch>; + using expected_props = ti::PropertiesOfT<expected_profile>; + + // Make sure all of the properties are as expected. + // There are seemingly redundant tests here to make it easier to diagnose + // the specifics of the failure if something were to go wrong. + EXPECT_TRUE((std::is_same<props, arch_props>::value)); + EXPECT_TRUE((std::is_same<props, expected_props>::value)); + EXPECT_TRUE((std::is_same<arch_props, expected_props>::value)); + + EXPECT_EQ(props::swappable_support, expected_props::swappable_support); + + EXPECT_EQ(props::hashable_support, expected_props::hashable_support); + + // Avoid additional error message noise when profile and archetype match with + // each other but were not what was expected. + if (!std::is_same<props, arch_props>::value) { + EXPECT_EQ(arch_props::swappable_support, expected_props::swappable_support); + + EXPECT_EQ(arch_props::hashable_support, expected_props::hashable_support); + } + + ////////////////////////////////////////////////////////////////////////////// + // Swappable checks // + ////////////////////////////////////////////////////////////////////////////// + switch (expected_props::swappable_support) { + case ti::swappable::maybe: + EXPECT_FALSE(absl::type_traits_internal::IsSwappable<arch>::value); + EXPECT_FALSE(absl::type_traits_internal::IsNothrowSwappable<arch>::value); + break; + case ti::swappable::yes: + EXPECT_TRUE(absl::type_traits_internal::IsSwappable<arch>::value); + EXPECT_FALSE(absl::type_traits_internal::IsNothrowSwappable<arch>::value); + break; + case ti::swappable::nothrow: + EXPECT_TRUE(absl::type_traits_internal::IsSwappable<arch>::value); + EXPECT_TRUE(absl::type_traits_internal::IsNothrowSwappable<arch>::value); + break; + } + + ////////////////////////////////////////////////////////////////////////////// + // Hashable checks // + ////////////////////////////////////////////////////////////////////////////// + switch (expected_props::hashable_support) { + case ti::hashable::maybe: +#if ABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ + EXPECT_FALSE(absl::type_traits_internal::IsHashable<arch>::value); +#endif // ABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ + break; + case ti::hashable::yes: + EXPECT_TRUE(absl::type_traits_internal::IsHashable<arch>::value); + break; + } +} + +REGISTER_TYPED_TEST_SUITE_P(ProfileTest, HasAppropriateConstructionProperties, + HasAppropriateAssignmentProperties, + HasAppropriateComparisonProperties, + HasAppropriateAuxilliaryProperties); + +template <class Profile, class Arch, class ExpectedProfile> +struct ProfileAndExpectation { + using profile = Profile; + using arch = Arch; + using expected_profile = ExpectedProfile; +}; + +using CoreProfilesToTest = ::testing::Types< + // The terminating case of combine (all properties are "maybe"). + ProfileAndExpectation<ti::CombineProfiles<>, + ti::Archetype<ti::CombineProfiles<>>, + ti::ConformanceProfile<>>, + + // Core default constructor profiles + ProfileAndExpectation< + ti::HasDefaultConstructorProfile, ti::HasDefaultConstructorArchetype, + ti::ConformanceProfile<ti::default_constructible::yes>>, + ProfileAndExpectation< + ti::HasNothrowDefaultConstructorProfile, + ti::HasNothrowDefaultConstructorArchetype, + ti::ConformanceProfile<ti::default_constructible::nothrow>>, + ProfileAndExpectation< + ti::HasTrivialDefaultConstructorProfile, + ti::HasTrivialDefaultConstructorArchetype, + ti::ConformanceProfile<ti::default_constructible::trivial>>, + + // Core move constructor profiles + ProfileAndExpectation< + ti::HasMoveConstructorProfile, ti::HasMoveConstructorArchetype, + ti::ConformanceProfile<ti::default_constructible::maybe, + ti::move_constructible::yes>>, + ProfileAndExpectation< + ti::HasNothrowMoveConstructorProfile, + ti::HasNothrowMoveConstructorArchetype, + ti::ConformanceProfile<ti::default_constructible::maybe, + ti::move_constructible::nothrow>>, + ProfileAndExpectation< + ti::HasTrivialMoveConstructorProfile, + ti::HasTrivialMoveConstructorArchetype, + ti::ConformanceProfile<ti::default_constructible::maybe, + ti::move_constructible::trivial>>, + + // Core copy constructor profiles + ProfileAndExpectation< + ti::HasCopyConstructorProfile, ti::HasCopyConstructorArchetype, + ti::ConformanceProfile<ti::default_constructible::maybe, + ti::move_constructible::maybe, + ti::copy_constructible::yes>>, + ProfileAndExpectation< + ti::HasNothrowCopyConstructorProfile, + ti::HasNothrowCopyConstructorArchetype, + ti::ConformanceProfile<ti::default_constructible::maybe, + ti::move_constructible::maybe, + ti::copy_constructible::nothrow>>, + ProfileAndExpectation< + ti::HasTrivialCopyConstructorProfile, + ti::HasTrivialCopyConstructorArchetype, + ti::ConformanceProfile<ti::default_constructible::maybe, + ti::move_constructible::maybe, + ti::copy_constructible::trivial>>, + + // Core move assignment profiles + ProfileAndExpectation< + ti::HasMoveAssignProfile, ti::HasMoveAssignArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::yes>>, + ProfileAndExpectation< + ti::HasNothrowMoveAssignProfile, ti::HasNothrowMoveAssignArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::nothrow>>, + ProfileAndExpectation< + ti::HasTrivialMoveAssignProfile, ti::HasTrivialMoveAssignArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::trivial>>, + + // Core copy assignment profiles + ProfileAndExpectation< + ti::HasCopyAssignProfile, ti::HasCopyAssignArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::yes>>, + ProfileAndExpectation< + ti::HasNothrowCopyAssignProfile, ti::HasNothrowCopyAssignArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::nothrow>>, + ProfileAndExpectation< + ti::HasTrivialCopyAssignProfile, ti::HasTrivialCopyAssignArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::trivial>>, + + // Core destructor profiles + ProfileAndExpectation< + ti::HasDestructorProfile, ti::HasDestructorArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::yes>>, + ProfileAndExpectation< + ti::HasNothrowDestructorProfile, ti::HasNothrowDestructorArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::nothrow>>, + ProfileAndExpectation< + ti::HasTrivialDestructorProfile, ti::HasTrivialDestructorArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::trivial>>, + + // Core equality comparable profiles + ProfileAndExpectation< + ti::HasEqualityProfile, ti::HasEqualityArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::yes>>, + ProfileAndExpectation< + ti::HasNothrowEqualityProfile, ti::HasNothrowEqualityArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::nothrow>>, + + // Core inequality comparable profiles + ProfileAndExpectation< + ti::HasInequalityProfile, ti::HasInequalityArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::maybe, ti::inequality_comparable::yes>>, + ProfileAndExpectation< + ti::HasNothrowInequalityProfile, ti::HasNothrowInequalityArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::maybe, + ti::inequality_comparable::nothrow>>, + + // Core less than comparable profiles + ProfileAndExpectation< + ti::HasLessThanProfile, ti::HasLessThanArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::yes>>, + ProfileAndExpectation< + ti::HasNothrowLessThanProfile, ti::HasNothrowLessThanArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::nothrow>>, + + // Core less equal comparable profiles + ProfileAndExpectation< + ti::HasLessEqualProfile, ti::HasLessEqualArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::maybe, ti::less_equal_comparable::yes>>, + ProfileAndExpectation< + ti::HasNothrowLessEqualProfile, ti::HasNothrowLessEqualArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::maybe, + ti::less_equal_comparable::nothrow>>, + + // Core greater equal comparable profiles + ProfileAndExpectation< + ti::HasGreaterEqualProfile, ti::HasGreaterEqualArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::maybe, ti::less_equal_comparable::maybe, + ti::greater_equal_comparable::yes>>, + ProfileAndExpectation< + ti::HasNothrowGreaterEqualProfile, ti::HasNothrowGreaterEqualArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::maybe, ti::less_equal_comparable::maybe, + ti::greater_equal_comparable::nothrow>>, + + // Core greater than comparable profiles + ProfileAndExpectation< + ti::HasGreaterThanProfile, ti::HasGreaterThanArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::maybe, ti::less_equal_comparable::maybe, + ti::greater_equal_comparable::maybe, + ti::greater_than_comparable::yes>>, + ProfileAndExpectation< + ti::HasNothrowGreaterThanProfile, ti::HasNothrowGreaterThanArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::maybe, ti::less_equal_comparable::maybe, + ti::greater_equal_comparable::maybe, + ti::greater_than_comparable::nothrow>>, + + // Core swappable profiles + ProfileAndExpectation< + ti::HasSwapProfile, ti::HasSwapArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::maybe, ti::less_equal_comparable::maybe, + ti::greater_equal_comparable::maybe, + ti::greater_than_comparable::maybe, ti::swappable::yes>>, + ProfileAndExpectation< + ti::HasNothrowSwapProfile, ti::HasNothrowSwapArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::maybe, ti::less_equal_comparable::maybe, + ti::greater_equal_comparable::maybe, + ti::greater_than_comparable::maybe, ti::swappable::nothrow>>, + + // Core hashable profiles + ProfileAndExpectation< + ti::HasStdHashSpecializationProfile, + ti::HasStdHashSpecializationArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::maybe, ti::less_equal_comparable::maybe, + ti::greater_equal_comparable::maybe, + ti::greater_than_comparable::maybe, ti::swappable::maybe, + ti::hashable::yes>>>; + +using CommonProfilesToTest = ::testing::Types< + // NothrowMoveConstructible + ProfileAndExpectation< + ti::NothrowMoveConstructibleProfile, + ti::NothrowMoveConstructibleArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::nothrow, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::nothrow>>, + + // CopyConstructible + ProfileAndExpectation< + ti::CopyConstructibleProfile, ti::CopyConstructibleArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::nothrow, + ti::copy_constructible::yes, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::nothrow>>, + + // NothrowMovable + ProfileAndExpectation< + ti::NothrowMovableProfile, ti::NothrowMovableArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::nothrow, + ti::copy_constructible::maybe, ti::move_assignable::nothrow, + ti::copy_assignable::maybe, ti::destructible::nothrow, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::maybe, ti::less_equal_comparable::maybe, + ti::greater_equal_comparable::maybe, + ti::greater_than_comparable::maybe, ti::swappable::nothrow>>, + + // Value + ProfileAndExpectation< + ti::ValueProfile, ti::ValueArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::nothrow, + ti::copy_constructible::yes, ti::move_assignable::nothrow, + ti::copy_assignable::yes, ti::destructible::nothrow, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::maybe, ti::less_equal_comparable::maybe, + ti::greater_equal_comparable::maybe, + ti::greater_than_comparable::maybe, ti::swappable::nothrow>>, + + //////////////////////////////////////////////////////////////////////////// + // Common but also DefaultConstructible // + //////////////////////////////////////////////////////////////////////////// + + // DefaultConstructibleNothrowMoveConstructible + ProfileAndExpectation< + ti::DefaultConstructibleNothrowMoveConstructibleProfile, + ti::DefaultConstructibleNothrowMoveConstructibleArchetype, + ti::ConformanceProfile< + ti::default_constructible::yes, ti::move_constructible::nothrow, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::nothrow>>, + + // DefaultConstructibleCopyConstructible + ProfileAndExpectation< + ti::DefaultConstructibleCopyConstructibleProfile, + ti::DefaultConstructibleCopyConstructibleArchetype, + ti::ConformanceProfile< + ti::default_constructible::yes, ti::move_constructible::nothrow, + ti::copy_constructible::yes, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::nothrow>>, + + // DefaultConstructibleNothrowMovable + ProfileAndExpectation< + ti::DefaultConstructibleNothrowMovableProfile, + ti::DefaultConstructibleNothrowMovableArchetype, + ti::ConformanceProfile< + ti::default_constructible::yes, ti::move_constructible::nothrow, + ti::copy_constructible::maybe, ti::move_assignable::nothrow, + ti::copy_assignable::maybe, ti::destructible::nothrow, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::maybe, ti::less_equal_comparable::maybe, + ti::greater_equal_comparable::maybe, + ti::greater_than_comparable::maybe, ti::swappable::nothrow>>, + + // DefaultConstructibleValue + ProfileAndExpectation< + ti::DefaultConstructibleValueProfile, + ti::DefaultConstructibleValueArchetype, + ti::ConformanceProfile< + ti::default_constructible::yes, ti::move_constructible::nothrow, + ti::copy_constructible::yes, ti::move_assignable::nothrow, + ti::copy_assignable::yes, ti::destructible::nothrow, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::maybe, ti::less_equal_comparable::maybe, + ti::greater_equal_comparable::maybe, + ti::greater_than_comparable::maybe, ti::swappable::nothrow>>>; + +using ComparableHelpersProfilesToTest = ::testing::Types< + // Equatable + ProfileAndExpectation< + ti::EquatableProfile, ti::EquatableArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::yes, ti::inequality_comparable::yes>>, + + // Comparable + ProfileAndExpectation< + ti::ComparableProfile, ti::ComparableArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::yes, ti::inequality_comparable::yes, + ti::less_than_comparable::yes, ti::less_equal_comparable::yes, + ti::greater_equal_comparable::yes, + ti::greater_than_comparable::yes>>, + + // NothrowEquatable + ProfileAndExpectation< + ti::NothrowEquatableProfile, ti::NothrowEquatableArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::nothrow, + ti::inequality_comparable::nothrow>>, + + // NothrowComparable + ProfileAndExpectation< + ti::NothrowComparableProfile, ti::NothrowComparableArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::maybe, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::maybe, + ti::equality_comparable::nothrow, + ti::inequality_comparable::nothrow, + ti::less_than_comparable::nothrow, + ti::less_equal_comparable::nothrow, + ti::greater_equal_comparable::nothrow, + ti::greater_than_comparable::nothrow>>>; + +using CommonComparableProfilesToTest = ::testing::Types< + // ComparableNothrowMoveConstructible + ProfileAndExpectation< + ti::ComparableNothrowMoveConstructibleProfile, + ti::ComparableNothrowMoveConstructibleArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::nothrow, + ti::copy_constructible::maybe, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::nothrow, + ti::equality_comparable::yes, ti::inequality_comparable::yes, + ti::less_than_comparable::yes, ti::less_equal_comparable::yes, + ti::greater_equal_comparable::yes, + ti::greater_than_comparable::yes>>, + + // ComparableCopyConstructible + ProfileAndExpectation< + ti::ComparableCopyConstructibleProfile, + ti::ComparableCopyConstructibleArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::nothrow, + ti::copy_constructible::yes, ti::move_assignable::maybe, + ti::copy_assignable::maybe, ti::destructible::nothrow, + ti::equality_comparable::yes, ti::inequality_comparable::yes, + ti::less_than_comparable::yes, ti::less_equal_comparable::yes, + ti::greater_equal_comparable::yes, + ti::greater_than_comparable::yes>>, + + // ComparableNothrowMovable + ProfileAndExpectation< + ti::ComparableNothrowMovableProfile, + ti::ComparableNothrowMovableArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::nothrow, + ti::copy_constructible::maybe, ti::move_assignable::nothrow, + ti::copy_assignable::maybe, ti::destructible::nothrow, + ti::equality_comparable::yes, ti::inequality_comparable::yes, + ti::less_than_comparable::yes, ti::less_equal_comparable::yes, + ti::greater_equal_comparable::yes, ti::greater_than_comparable::yes, + ti::swappable::nothrow>>, + + // ComparableValue + ProfileAndExpectation< + ti::ComparableValueProfile, ti::ComparableValueArchetype, + ti::ConformanceProfile< + ti::default_constructible::maybe, ti::move_constructible::nothrow, + ti::copy_constructible::yes, ti::move_assignable::nothrow, + ti::copy_assignable::yes, ti::destructible::nothrow, + ti::equality_comparable::yes, ti::inequality_comparable::yes, + ti::less_than_comparable::yes, ti::less_equal_comparable::yes, + ti::greater_equal_comparable::yes, ti::greater_than_comparable::yes, + ti::swappable::nothrow>>>; + +using TrivialProfilesToTest = ::testing::Types< + ProfileAndExpectation< + ti::TrivialSpecialMemberFunctionsProfile, + ti::TrivialSpecialMemberFunctionsArchetype, + ti::ConformanceProfile< + ti::default_constructible::trivial, ti::move_constructible::trivial, + ti::copy_constructible::trivial, ti::move_assignable::trivial, + ti::copy_assignable::trivial, ti::destructible::trivial, + ti::equality_comparable::maybe, ti::inequality_comparable::maybe, + ti::less_than_comparable::maybe, ti::less_equal_comparable::maybe, + ti::greater_equal_comparable::maybe, + ti::greater_than_comparable::maybe, ti::swappable::nothrow>>, + + ProfileAndExpectation< + ti::TriviallyCompleteProfile, ti::TriviallyCompleteArchetype, + ti::ConformanceProfile< + ti::default_constructible::trivial, ti::move_constructible::trivial, + ti::copy_constructible::trivial, ti::move_assignable::trivial, + ti::copy_assignable::trivial, ti::destructible::trivial, + ti::equality_comparable::yes, ti::inequality_comparable::yes, + ti::less_than_comparable::yes, ti::less_equal_comparable::yes, + ti::greater_equal_comparable::yes, ti::greater_than_comparable::yes, + ti::swappable::nothrow, ti::hashable::yes>>>; + +INSTANTIATE_TYPED_TEST_SUITE_P(Core, ProfileTest, CoreProfilesToTest); +INSTANTIATE_TYPED_TEST_SUITE_P(Common, ProfileTest, CommonProfilesToTest); +INSTANTIATE_TYPED_TEST_SUITE_P(ComparableHelpers, ProfileTest, + ComparableHelpersProfilesToTest); +INSTANTIATE_TYPED_TEST_SUITE_P(CommonComparable, ProfileTest, + CommonComparableProfilesToTest); +INSTANTIATE_TYPED_TEST_SUITE_P(Trivial, ProfileTest, TrivialProfilesToTest); + +// TODO(calabrese) Test runtime results + +} // namespace
diff --git a/third_party/abseil-cpp/absl/types/internal/optional.h b/third_party/abseil-cpp/absl/types/internal/optional.h index 8acbda2..92932b60 100644 --- a/third_party/abseil-cpp/absl/types/internal/optional.h +++ b/third_party/abseil-cpp/absl/types/internal/optional.h
@@ -54,6 +54,7 @@ #endif namespace absl { +ABSL_NAMESPACE_BEGIN // Forward declaration template <typename T> @@ -84,8 +85,8 @@ bool engaged_; // Data storage union { - dummy_type dummy_; T data_; + dummy_type dummy_; }; void destruct() noexcept { @@ -119,8 +120,8 @@ bool engaged_; // Data storage union { - dummy_type dummy_; T data_; + dummy_type dummy_; }; void destruct() noexcept { engaged_ = false; } @@ -387,6 +388,7 @@ }; } // namespace optional_internal +ABSL_NAMESPACE_END } // namespace absl #undef ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS
diff --git a/third_party/abseil-cpp/absl/types/internal/span.h b/third_party/abseil-cpp/absl/types/internal/span.h index d203aad..112612f 100644 --- a/third_party/abseil-cpp/absl/types/internal/span.h +++ b/third_party/abseil-cpp/absl/types/internal/span.h
@@ -26,6 +26,7 @@ #include "absl/meta/type_traits.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace span_internal { // A constexpr min function @@ -121,6 +122,7 @@ using EnableIfConvertibleTo = typename std::enable_if<IsConvertible<From, To>::value>::type; } // namespace span_internal +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TYPES_INTERNAL_SPAN_H_
diff --git a/third_party/abseil-cpp/absl/types/internal/variant.h b/third_party/abseil-cpp/absl/types/internal/variant.h index 19de2e13..71bd3adf 100644 --- a/third_party/abseil-cpp/absl/types/internal/variant.h +++ b/third_party/abseil-cpp/absl/types/internal/variant.h
@@ -37,9 +37,10 @@ #include "absl/types/bad_variant_access.h" #include "absl/utility/utility.h" -#if !defined(ABSL_HAVE_STD_VARIANT) +#if !defined(ABSL_USES_STD_VARIANT) namespace absl { +ABSL_NAMESPACE_BEGIN template <class... Types> class variant; @@ -1638,7 +1639,8 @@ }; } // namespace variant_internal +ABSL_NAMESPACE_END } // namespace absl -#endif // !defined(ABSL_HAVE_STD_VARIANT) +#endif // !defined(ABSL_USES_STD_VARIANT) #endif // ABSL_TYPES_variant_internal_H_
diff --git a/third_party/abseil-cpp/absl/types/optional.h b/third_party/abseil-cpp/absl/types/optional.h index ed8faf9..01d747d7 100644 --- a/third_party/abseil-cpp/absl/types/optional.h +++ b/third_party/abseil-cpp/absl/types/optional.h
@@ -38,19 +38,21 @@ #include "absl/base/config.h" // TODO(calabrese) IWYU removal? #include "absl/utility/utility.h" -#ifdef ABSL_HAVE_STD_OPTIONAL +#ifdef ABSL_USES_STD_OPTIONAL #include <optional> // IWYU pragma: export namespace absl { +ABSL_NAMESPACE_BEGIN using std::bad_optional_access; using std::optional; using std::make_optional; using std::nullopt_t; using std::nullopt; +ABSL_NAMESPACE_END } // namespace absl -#else // ABSL_HAVE_STD_OPTIONAL +#else // ABSL_USES_STD_OPTIONAL #include <cassert> #include <functional> @@ -65,6 +67,7 @@ #include "absl/types/internal/optional.h" namespace absl { +ABSL_NAMESPACE_BEGIN // nullopt_t // @@ -441,7 +444,7 @@ // Returns false if and only if the `optional` is empty. // // if (opt) { - // // do something with opt.value(); + // // do something with *opt or opt->; // } else { // // opt is empty. // } @@ -754,6 +757,7 @@ return static_cast<bool>(x) ? static_cast<bool>(v >= *x) : true; } +ABSL_NAMESPACE_END } // namespace absl namespace std { @@ -767,6 +771,6 @@ #undef ABSL_MSVC_CONSTEXPR_BUG_IN_UNION_LIKE_CLASS -#endif // ABSL_HAVE_STD_OPTIONAL +#endif // ABSL_USES_STD_OPTIONAL #endif // ABSL_TYPES_OPTIONAL_H_
diff --git a/third_party/abseil-cpp/absl/types/optional_exception_safety_test.cc b/third_party/abseil-cpp/absl/types/optional_exception_safety_test.cc index aaf8ebcd..8e5fe851 100644 --- a/third_party/abseil-cpp/absl/types/optional_exception_safety_test.cc +++ b/third_party/abseil-cpp/absl/types/optional_exception_safety_test.cc
@@ -14,10 +14,17 @@ #include "absl/types/optional.h" +#include "absl/base/config.h" + +// This test is a no-op when absl::optional is an alias for std::optional and +// when exceptions are not enabled. +#if !defined(ABSL_USES_STD_OPTIONAL) && defined(ABSL_HAVE_EXCEPTIONS) + #include "gtest/gtest.h" #include "absl/base/internal/exception_safety_testing.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { @@ -279,4 +286,7 @@ } // namespace +ABSL_NAMESPACE_END } // namespace absl + +#endif // #if !defined(ABSL_USES_STD_OPTIONAL) && defined(ABSL_HAVE_EXCEPTIONS)
diff --git a/third_party/abseil-cpp/absl/types/optional_test.cc b/third_party/abseil-cpp/absl/types/optional_test.cc index e6a36eb..47d5c8a2 100644 --- a/third_party/abseil-cpp/absl/types/optional_test.cc +++ b/third_party/abseil-cpp/absl/types/optional_test.cc
@@ -14,6 +14,9 @@ #include "absl/types/optional.h" +// This test is a no-op when absl::optional is an alias for std::optional. +#if !defined(ABSL_USES_STD_OPTIONAL) + #include <string> #include <type_traits> #include <utility> @@ -221,7 +224,7 @@ EXPECT_FALSE( absl::is_trivially_copy_constructible<absl::optional<Copyable>>::value); -#if defined(ABSL_HAVE_STD_OPTIONAL) && defined(__GLIBCXX__) +#if defined(ABSL_USES_STD_OPTIONAL) && defined(__GLIBCXX__) // libstdc++ std::optional implementation (as of 7.2) has a bug: when T is // trivially copyable, optional<T> is not trivially copyable (due to one of // its base class is unconditionally nontrivial). @@ -276,7 +279,7 @@ // std::optional when T is volatile-qualified. So skipping this test. // Bug report: // https://connect.microsoft.com/VisualStudio/feedback/details/3142534 -#if defined(ABSL_HAVE_STD_OPTIONAL) && defined(_MSC_VER) && _MSC_VER >= 1911 +#if defined(ABSL_USES_STD_OPTIONAL) && defined(_MSC_VER) && _MSC_VER >= 1911 #define ABSL_MSVC_OPTIONAL_VOLATILE_COPY_BUG 1 #endif #ifndef ABSL_MSVC_OPTIONAL_VOLATILE_COPY_BUG @@ -302,7 +305,7 @@ EXPECT_FALSE(std::is_move_constructible<absl::optional<NonMovable>>::value); // test noexcept EXPECT_TRUE(std::is_nothrow_move_constructible<absl::optional<int>>::value); -#ifndef ABSL_HAVE_STD_OPTIONAL +#ifndef ABSL_USES_STD_OPTIONAL EXPECT_EQ( absl::default_allocator_is_nothrow::value, std::is_nothrow_move_constructible<absl::optional<MoveableThrow>>::value); @@ -636,7 +639,7 @@ EXPECT_FALSE(absl::is_trivially_copy_assignable<NonTrivial>::value); // std::optional doesn't support volatile nontrivial types. -#ifndef ABSL_HAVE_STD_OPTIONAL +#ifndef ABSL_USES_STD_OPTIONAL { StructorListener listener; Listenable::listener = &listener; @@ -655,7 +658,7 @@ EXPECT_EQ(1, listener.destruct); EXPECT_EQ(1, listener.volatile_copy_assign); } -#endif // ABSL_HAVE_STD_OPTIONAL +#endif // ABSL_USES_STD_OPTIONAL } TEST(optionalTest, MoveAssignment) { @@ -679,7 +682,7 @@ EXPECT_EQ(1, listener.move_assign); } // std::optional doesn't support volatile nontrivial types. -#ifndef ABSL_HAVE_STD_OPTIONAL +#ifndef ABSL_USES_STD_OPTIONAL { StructorListener listener; Listenable::listener = &listener; @@ -699,7 +702,7 @@ EXPECT_EQ(1, listener.destruct); EXPECT_EQ(1, listener.volatile_move_assign); } -#endif // ABSL_HAVE_STD_OPTIONAL +#endif // ABSL_USES_STD_OPTIONAL EXPECT_FALSE(absl::is_move_assignable<absl::optional<const int>>::value); EXPECT_TRUE(absl::is_move_assignable<absl::optional<Copyable>>::value); EXPECT_TRUE(absl::is_move_assignable<absl::optional<MoveableThrow>>::value); @@ -941,7 +944,7 @@ template <int v> struct DeletedOpAddr { - constexpr static const int value = v; + int value = v; constexpr DeletedOpAddr() = default; constexpr const DeletedOpAddr<v>* operator&() const = delete; // NOLINT DeletedOpAddr<v>* operator&() = delete; // NOLINT @@ -951,9 +954,9 @@ // to document the fact that the current implementation of absl::optional<T> // expects such usecases to be malformed and not compile. TEST(optionalTest, OperatorAddr) { - constexpr const int v = -1; + constexpr int v = -1; { // constexpr - constexpr const absl::optional<DeletedOpAddr<v>> opt(absl::in_place_t{}); + constexpr absl::optional<DeletedOpAddr<v>> opt(absl::in_place_t{}); static_assert(opt.has_value(), ""); // static_assert(opt->value == v, ""); static_assert((*opt).value == v, ""); @@ -1557,7 +1560,7 @@ static_assert( std::is_nothrow_move_constructible<absl::optional<MoveMeNoThrow>>::value, ""); -#ifndef ABSL_HAVE_STD_OPTIONAL +#ifndef ABSL_USES_STD_OPTIONAL static_assert(absl::default_allocator_is_nothrow::value == std::is_nothrow_move_constructible< absl::optional<MoveMeThrow>>::value, @@ -1654,3 +1657,5 @@ #endif // !defined(__EMSCRIPTEN__) } // namespace + +#endif // #if !defined(ABSL_USES_STD_OPTIONAL)
diff --git a/third_party/abseil-cpp/absl/types/span.h b/third_party/abseil-cpp/absl/types/span.h index b007fc1..21cda34 100644 --- a/third_party/abseil-cpp/absl/types/span.h +++ b/third_party/abseil-cpp/absl/types/span.h
@@ -71,6 +71,7 @@ #include "absl/types/internal/span.h" namespace absl { +ABSL_NAMESPACE_BEGIN //------------------------------------------------------------------------------ // Span @@ -275,7 +276,7 @@ // Returns a reference to the i'th element of this span. constexpr reference operator[](size_type i) const noexcept { // MSVC 2015 accepts this as constexpr, but not ptr_[i] - return *(data() + i); + return ABSL_ASSERT(i < size()), *(data() + i); } // Span::at() @@ -291,60 +292,74 @@ // Span::front() // - // Returns a reference to the first element of this span. + // Returns a reference to the first element of this span. The span must not + // be empty. constexpr reference front() const noexcept { return ABSL_ASSERT(size() > 0), *data(); } // Span::back() // - // Returns a reference to the last element of this span. + // Returns a reference to the last element of this span. The span must not + // be empty. constexpr reference back() const noexcept { return ABSL_ASSERT(size() > 0), *(data() + size() - 1); } // Span::begin() // - // Returns an iterator to the first element of this span. + // Returns an iterator pointing to the first element of this span, or `end()` + // if the span is empty. constexpr iterator begin() const noexcept { return data(); } // Span::cbegin() // - // Returns a const iterator to the first element of this span. + // Returns a const iterator pointing to the first element of this span, or + // `end()` if the span is empty. constexpr const_iterator cbegin() const noexcept { return begin(); } // Span::end() // - // Returns an iterator to the last element of this span. + // Returns an iterator pointing just beyond the last element at the + // end of this span. This iterator acts as a placeholder; attempting to + // access it results in undefined behavior. constexpr iterator end() const noexcept { return data() + size(); } // Span::cend() // - // Returns a const iterator to the last element of this span. + // Returns a const iterator pointing just beyond the last element at the + // end of this span. This iterator acts as a placeholder; attempting to + // access it results in undefined behavior. constexpr const_iterator cend() const noexcept { return end(); } // Span::rbegin() // - // Returns a reverse iterator starting at the last element of this span. + // Returns a reverse iterator pointing to the last element at the end of this + // span, or `rend()` if the span is empty. constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } // Span::crbegin() // - // Returns a reverse const iterator starting at the last element of this span. + // Returns a const reverse iterator pointing to the last element at the end of + // this span, or `crend()` if the span is empty. constexpr const_reverse_iterator crbegin() const noexcept { return rbegin(); } // Span::rend() // - // Returns a reverse iterator starting at the first element of this span. + // Returns a reverse iterator pointing just before the first element + // at the beginning of this span. This pointer acts as a placeholder; + // attempting to access its element results in undefined behavior. constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } // Span::crend() // - // Returns a reverse iterator starting at the first element of this span. + // Returns a reverse const iterator pointing just before the first element + // at the beginning of this span. This pointer acts as a placeholder; + // attempting to access its element results in undefined behavior. constexpr const_reverse_iterator crend() const noexcept { return rend(); } // Span mutations @@ -707,5 +722,6 @@ constexpr Span<const T> MakeConstSpan(const T (&array)[N]) noexcept { return Span<const T>(array, N); } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TYPES_SPAN_H_
diff --git a/third_party/abseil-cpp/absl/types/span_test.cc b/third_party/abseil-cpp/absl/types/span_test.cc index 9269f91..6ac234d 100644 --- a/third_party/abseil-cpp/absl/types/span_test.cc +++ b/third_party/abseil-cpp/absl/types/span_test.cc
@@ -35,7 +35,7 @@ namespace { MATCHER_P(DataIs, data, - absl::StrCat("data() is ", negation ? "is " : "isn't ", + absl::StrCat("data() ", negation ? "isn't " : "is ", testing::PrintToString(data))) { return arg.data() == data; } @@ -232,6 +232,11 @@ EXPECT_EQ(s.front(), s[0]); EXPECT_EQ(s.back(), s[9]); + +#ifndef NDEBUG + EXPECT_DEATH_IF_SUPPORTED(s[-1], ""); + EXPECT_DEATH_IF_SUPPORTED(s[10], ""); +#endif } TEST(IntSpan, AtThrows) {
diff --git a/third_party/abseil-cpp/absl/types/variant.h b/third_party/abseil-cpp/absl/types/variant.h index ebd52d28..776d19a 100644 --- a/third_party/abseil-cpp/absl/types/variant.h +++ b/third_party/abseil-cpp/absl/types/variant.h
@@ -24,7 +24,7 @@ // should always hold a value of one of its alternative types (except in the // "valueless by exception state" -- see below). A default-constructed // `absl::variant` will hold the value of its first alternative type, provided -// it is default-constructable. +// it is default-constructible. // // In exceptional cases due to error, an `absl::variant` can hold no // value (known as a "valueless by exception" state), though this is not the @@ -45,11 +45,12 @@ #include "absl/base/config.h" #include "absl/utility/utility.h" -#ifdef ABSL_HAVE_STD_VARIANT +#ifdef ABSL_USES_STD_VARIANT #include <variant> // IWYU pragma: export namespace absl { +ABSL_NAMESPACE_BEGIN using std::bad_variant_access; using std::get; using std::get_if; @@ -62,9 +63,10 @@ using std::variant_size; using std::variant_size_v; using std::visit; +ABSL_NAMESPACE_END } // namespace absl -#else // ABSL_HAVE_STD_VARIANT +#else // ABSL_USES_STD_VARIANT #include <functional> #include <new> @@ -77,6 +79,7 @@ #include "absl/types/internal/variant.h" namespace absl { +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // absl::variant @@ -92,7 +95,7 @@ // // assign it to a std::string. // absl::variant<int, std::string> v = std::string("abc"); // -// // A default-contructed variant will hold a value-initialized value of +// // A default-constructed variant will hold a value-initialized value of // // the first alternative type. // auto a = absl::variant<int, std::string>(); // Holds an int of value '0'. // @@ -795,6 +798,7 @@ a.index()); } +ABSL_NAMESPACE_END } // namespace absl namespace std { @@ -812,9 +816,10 @@ } // namespace std -#endif // ABSL_HAVE_STD_VARIANT +#endif // ABSL_USES_STD_VARIANT namespace absl { +ABSL_NAMESPACE_BEGIN namespace variant_internal { // Helper visitor for converting a variant<Ts...>` into another type (mostly @@ -850,6 +855,7 @@ std::forward<Variant>(variant)); } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_TYPES_VARIANT_H_
diff --git a/third_party/abseil-cpp/absl/types/variant_benchmark.cc b/third_party/abseil-cpp/absl/types/variant_benchmark.cc index a5f52164..350b1753 100644 --- a/third_party/abseil-cpp/absl/types/variant_benchmark.cc +++ b/third_party/abseil-cpp/absl/types/variant_benchmark.cc
@@ -28,6 +28,7 @@ #include "absl/utility/utility.h" namespace absl { +ABSL_NAMESPACE_BEGIN namespace { template <std::size_t I> @@ -217,4 +218,5 @@ ->DenseRange(0, integral_pow(4, 2) - 1); } // namespace +ABSL_NAMESPACE_END } // namespace absl
diff --git a/third_party/abseil-cpp/absl/types/variant_exception_safety_test.cc b/third_party/abseil-cpp/absl/types/variant_exception_safety_test.cc index 76beb5959..439c6e1 100644 --- a/third_party/abseil-cpp/absl/types/variant_exception_safety_test.cc +++ b/third_party/abseil-cpp/absl/types/variant_exception_safety_test.cc
@@ -14,6 +14,12 @@ #include "absl/types/variant.h" +#include "absl/base/config.h" + +// This test is a no-op when absl::variant is an alias for std::variant and when +// exceptions are not enabled. +#if !defined(ABSL_USES_STD_VARIANT) && defined(ABSL_HAVE_EXCEPTIONS) + #include <iostream> #include <memory> #include <utility> @@ -21,7 +27,6 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "absl/base/config.h" #include "absl/base/internal/exception_safety_testing.h" #include "absl/memory/memory.h" @@ -29,6 +34,7 @@ #if !defined(ABSL_INTERNAL_MSVC_2017_DBG_MODE) namespace absl { +ABSL_NAMESPACE_BEGIN namespace { using ::testing::MakeExceptionSafetyTester; @@ -232,7 +238,7 @@ } // libstdc++ std::variant has bugs on copy assignment regarding exception // safety. -#if !(defined(ABSL_HAVE_STD_VARIANT) && defined(__GLIBCXX__)) +#if !(defined(ABSL_USES_STD_VARIANT) && defined(__GLIBCXX__)) // index() != j // if is_nothrow_copy_constructible_v<Tj> or // !is_nothrow_move_constructible<Tj> is true, equivalent to @@ -263,7 +269,7 @@ .Test()); EXPECT_FALSE(tester.WithContracts(strong_guarantee).Test()); } -#endif // !(defined(ABSL_HAVE_STD_VARIANT) && defined(__GLIBCXX__)) +#endif // !(defined(ABSL_USES_STD_VARIANT) && defined(__GLIBCXX__)) { // is_nothrow_copy_constructible_v<Tj> == false && // is_nothrow_move_constructible_v<Tj> == true @@ -320,7 +326,7 @@ // The fix is targeted for gcc-9. // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87431#c7 // https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=267614 -#if !(defined(ABSL_HAVE_STD_VARIANT) && \ +#if !(defined(ABSL_USES_STD_VARIANT) && \ defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE == 8) // - otherwise (index() != j), equivalent to // emplace<j>(get<j>(std::move(rhs))) @@ -337,7 +343,7 @@ auto copy = rhs; *lhs = std::move(copy); })); -#endif // !(defined(ABSL_HAVE_STD_VARIANT) && +#endif // !(defined(ABSL_USES_STD_VARIANT) && // defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE == 8) } } @@ -440,7 +446,7 @@ // and operator=(variant&&) invokes Tj's move ctor which doesn't throw. // libstdc++ std::variant has bugs on conversion assignment regarding // exception safety. -#if !(defined(ABSL_HAVE_STD_VARIANT) && defined(__GLIBCXX__)) +#if !(defined(ABSL_USES_STD_VARIANT) && defined(__GLIBCXX__)) { MoveNothrow rhs; EXPECT_TRUE(MakeExceptionSafetyTester() @@ -448,7 +454,7 @@ .WithContracts(VariantInvariants, strong_guarantee) .Test([&rhs](ThrowingVariant* lhs) { *lhs = rhs; })); } -#endif // !(defined(ABSL_HAVE_STD_VARIANT) && defined(__GLIBCXX__)) +#endif // !(defined(ABSL_USES_STD_VARIANT) && defined(__GLIBCXX__)) } TEST(VariantExceptionSafetyTest, Emplace) { @@ -518,6 +524,9 @@ } } // namespace +ABSL_NAMESPACE_END } // namespace absl #endif // !defined(ABSL_INTERNAL_MSVC_2017_DBG_MODE) + +#endif // #if !defined(ABSL_USES_STD_VARIANT) && defined(ABSL_HAVE_EXCEPTIONS)
diff --git a/third_party/abseil-cpp/absl/types/variant_test.cc b/third_party/abseil-cpp/absl/types/variant_test.cc index 85201b3..4639c42e 100644 --- a/third_party/abseil-cpp/absl/types/variant_test.cc +++ b/third_party/abseil-cpp/absl/types/variant_test.cc
@@ -19,6 +19,9 @@ #include "absl/types/variant.h" +// This test is a no-op when absl::variant is an alias for std::variant. +#if !defined(ABSL_USES_STD_VARIANT) + #include <algorithm> #include <cstddef> #include <functional> @@ -67,6 +70,7 @@ struct NonHashable {}; namespace absl { +ABSL_NAMESPACE_BEGIN namespace { using ::testing::DoubleEq; @@ -675,7 +679,7 @@ object.operator=(object); EXPECT_EQ(0, counter); - // A std::string long enough that it's likely to defeat any inline representation + // A string long enough that it's likely to defeat any inline representation // optimization. const std::string long_str(128, 'a'); @@ -839,7 +843,7 @@ } // libstdc++ doesn't pass this test -#if !(defined(ABSL_HAVE_STD_VARIANT) && defined(__GLIBCXX__)) +#if !(defined(ABSL_USES_STD_VARIANT) && defined(__GLIBCXX__)) EXPECT_EQ(3, counter[0]); EXPECT_EQ(2, counter[1]); EXPECT_EQ(2, counter[2]); @@ -1039,8 +1043,6 @@ using V = variant<MoveCanThrow, std::string, int>; int i = 33; std::string s = "abc"; - V valueless(in_place_index<0>); - ToValuelessByException(valueless); { // lhs and rhs holds different alternative V lhs(i), rhs(s); @@ -1048,6 +1050,9 @@ EXPECT_THAT(lhs, VariantWith<std::string>(s)); EXPECT_THAT(rhs, VariantWith<int>(i)); } +#ifdef ABSL_HAVE_EXCEPTIONS + V valueless(in_place_index<0>); + ToValuelessByException(valueless); { // lhs is valueless V lhs(valueless), rhs(i); @@ -1069,6 +1074,7 @@ EXPECT_TRUE(lhs.valueless_by_exception()); EXPECT_TRUE(rhs.valueless_by_exception()); } +#endif // ABSL_HAVE_EXCEPTIONS } ////////////////////// @@ -1928,7 +1934,7 @@ } // libstdc++ std::variant doesn't support the INVOKE semantics. -#if !(defined(ABSL_HAVE_STD_VARIANT) && defined(__GLIBCXX__)) +#if !(defined(ABSL_USES_STD_VARIANT) && defined(__GLIBCXX__)) TEST(VariantTest, VisitMemberFunction) { absl::variant<std::unique_ptr<Class>> p(absl::make_unique<Class>()); absl::variant<std::unique_ptr<const Class>> cp( @@ -1952,7 +1958,7 @@ EXPECT_EQ(42, absl::visit(&Class::member, cp)); } -#endif // !(defined(ABSL_HAVE_STD_VARIANT) && defined(__GLIBCXX__)) +#endif // !(defined(ABSL_USES_STD_VARIANT) && defined(__GLIBCXX__)) ///////////////////////// // [variant.monostate] // @@ -2030,7 +2036,7 @@ std::swap(a, b); EXPECT_THAT(a, VariantWith<SpecialSwap>(v2)); EXPECT_THAT(b, VariantWith<SpecialSwap>(v1)); -#ifndef ABSL_HAVE_STD_VARIANT +#ifndef ABSL_USES_STD_VARIANT EXPECT_FALSE(absl::get<SpecialSwap>(a).special_swap); #endif @@ -2078,7 +2084,7 @@ // MSVC std::hash<std::variant> does not use the index, thus produce the same // result on the same value as different alternative. -#if !(defined(_MSC_VER) && defined(ABSL_HAVE_STD_VARIANT)) +#if !(defined(_MSC_VER) && defined(ABSL_USES_STD_VARIANT)) { // same value as different alternative variant<int, int> v0(in_place_index<0>, 42); @@ -2086,7 +2092,7 @@ std::hash<variant<int, int>> hash; EXPECT_NE(hash(v0), hash(v1)); } -#endif // !(defined(_MSC_VER) && defined(ABSL_HAVE_STD_VARIANT)) +#endif // !(defined(_MSC_VER) && defined(ABSL_USES_STD_VARIANT)) { std::hash<variant<int>> hash; @@ -2113,7 +2119,7 @@ //////////////////////////////////////// // Test that a set requiring a basic type conversion works correctly -#if !defined(ABSL_HAVE_STD_VARIANT) +#if !defined(ABSL_USES_STD_VARIANT) TEST(VariantTest, TestConvertingSet) { typedef variant<double> Variant; Variant v(1.0); @@ -2123,7 +2129,7 @@ ASSERT_TRUE(nullptr != absl::get_if<double>(&v)); EXPECT_DOUBLE_EQ(2, absl::get<double>(v)); } -#endif // ABSL_HAVE_STD_VARIANT +#endif // ABSL_USES_STD_VARIANT // Test that a vector of variants behaves reasonably. TEST(VariantTest, Container) { @@ -2275,7 +2281,7 @@ }; TEST(VariantTest, TestRvalueConversion) { -#if !defined(ABSL_HAVE_STD_VARIANT) +#if !defined(ABSL_USES_STD_VARIANT) variant<double, std::string> var( ConvertVariantTo<variant<double, std::string>>( variant<std::string, int>(0))); @@ -2308,7 +2314,7 @@ variant2 = ConvertVariantTo<variant<int32_t, uint32_t>>(variant<uint32_t>(42)); ASSERT_TRUE(absl::holds_alternative<uint32_t>(variant2)); EXPECT_EQ(42, absl::get<uint32_t>(variant2)); -#endif // !ABSL_HAVE_STD_VARIANT +#endif // !ABSL_USES_STD_VARIANT variant<Convertible1, Convertible2> variant3( ConvertVariantTo<variant<Convertible1, Convertible2>>( @@ -2321,7 +2327,7 @@ } TEST(VariantTest, TestLvalueConversion) { -#if !defined(ABSL_HAVE_STD_VARIANT) +#if !defined(ABSL_USES_STD_VARIANT) variant<std::string, int> source1 = 0; variant<double, std::string> destination( ConvertVariantTo<variant<double, std::string>>(source1)); @@ -2423,7 +2429,7 @@ } TEST(VariantTest, TestRvalueConversionViaConvertVariantTo) { -#if !defined(ABSL_HAVE_STD_VARIANT) +#if !defined(ABSL_USES_STD_VARIANT) variant<double, std::string> var( ConvertVariantTo<variant<double, std::string>>( variant<std::string, int>(3))); @@ -2462,7 +2468,7 @@ } TEST(VariantTest, TestLvalueConversionViaConvertVariantTo) { -#if !defined(ABSL_HAVE_STD_VARIANT) +#if !defined(ABSL_USES_STD_VARIANT) variant<std::string, int> source1 = 3; variant<double, std::string> destination( ConvertVariantTo<variant<double, std::string>>(source1)); @@ -2494,7 +2500,7 @@ variant<uint32_t> source6(42); variant2 = ConvertVariantTo<variant<int32_t, uint32_t>>(source6); EXPECT_THAT(absl::get_if<uint32_t>(&variant2), Pointee(42)); -#endif // !ABSL_HAVE_STD_VARIANT +#endif // !ABSL_USES_STD_VARIANT variant<Convertible2, Convertible1> source7((Convertible1())); variant<Convertible1, Convertible2> variant3( @@ -2528,7 +2534,7 @@ // standard and we know that libstdc++ variant doesn't have this feature. // For more details see the paper: // http://open-std.org/JTC1/SC22/WG21/docs/papers/2017/p0602r0.html -#if !(defined(ABSL_HAVE_STD_VARIANT) && defined(__GLIBCXX__)) +#if !(defined(ABSL_USES_STD_VARIANT) && defined(__GLIBCXX__)) #define ABSL_VARIANT_PROPAGATE_COPY_MOVE_TRIVIALITY 1 #endif @@ -2704,4 +2710,7 @@ } } // namespace +ABSL_NAMESPACE_END } // namespace absl + +#endif // #if !defined(ABSL_USES_STD_VARIANT)
diff --git a/third_party/abseil-cpp/absl/utility/BUILD.bazel b/third_party/abseil-cpp/absl/utility/BUILD.bazel index d41317e..6881f93 100644 --- a/third_party/abseil-cpp/absl/utility/BUILD.bazel +++ b/third_party/abseil-cpp/absl/utility/BUILD.bazel
@@ -1,3 +1,20 @@ +# +# Copyright 2019 The Abseil Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", @@ -11,7 +28,9 @@ cc_library( name = "utility", - hdrs = ["utility.h"], + hdrs = [ + "utility.h", + ], copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [
diff --git a/third_party/abseil-cpp/absl/utility/utility.h b/third_party/abseil-cpp/absl/utility/utility.h index eef8fb4..e6647c7b 100644 --- a/third_party/abseil-cpp/absl/utility/utility.h +++ b/third_party/abseil-cpp/absl/utility/utility.h
@@ -51,6 +51,7 @@ #include "absl/meta/type_traits.h" namespace absl { +ABSL_NAMESPACE_BEGIN // integer_sequence // @@ -158,12 +159,12 @@ // Tag types -#ifdef ABSL_HAVE_STD_OPTIONAL +#ifdef ABSL_USES_STD_OPTIONAL using std::in_place_t; using std::in_place; -#else // ABSL_HAVE_STD_OPTIONAL +#else // ABSL_USES_STD_OPTIONAL // in_place_t // @@ -174,9 +175,9 @@ ABSL_INTERNAL_INLINE_CONSTEXPR(in_place_t, in_place, {}); -#endif // ABSL_HAVE_STD_OPTIONAL +#endif // ABSL_USES_STD_OPTIONAL -#if defined(ABSL_HAVE_STD_ANY) || defined(ABSL_HAVE_STD_VARIANT) +#if defined(ABSL_USES_STD_ANY) || defined(ABSL_USES_STD_VARIANT) using std::in_place_type; using std::in_place_type_t; #else @@ -191,9 +192,9 @@ template <typename T> void in_place_type(utility_internal::InPlaceTypeTag<T>) {} -#endif // ABSL_HAVE_STD_ANY || ABSL_HAVE_STD_VARIANT +#endif // ABSL_USES_STD_ANY || ABSL_USES_STD_VARIANT -#ifdef ABSL_HAVE_STD_VARIANT +#ifdef ABSL_USES_STD_VARIANT using std::in_place_index; using std::in_place_index_t; #else @@ -208,7 +209,7 @@ template <size_t I> void in_place_index(utility_internal::InPlaceIndexTag<I>) {} -#endif // ABSL_HAVE_STD_VARIANT +#endif // ABSL_USES_STD_VARIANT // Constexpr move and forward @@ -343,6 +344,7 @@ std::tuple_size<absl::decay_t<Tuple>>::value>{}); } +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_UTILITY_UTILITY_H_
diff --git a/third_party/apk-patch-size-estimator/LICENSE b/third_party/apk-patch-size-estimator/LICENSE deleted file mode 100644 index d645695..0000000 --- a/third_party/apk-patch-size-estimator/LICENSE +++ /dev/null
@@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.
diff --git a/third_party/apk-patch-size-estimator/OWNERS b/third_party/apk-patch-size-estimator/OWNERS deleted file mode 100644 index d1f9484..0000000 --- a/third_party/apk-patch-size-estimator/OWNERS +++ /dev/null
@@ -1,4 +0,0 @@ -agrieve@chromium.org -wnwen@chromium.org - -# COMPONENT: Build
diff --git a/third_party/apk-patch-size-estimator/README.chromium b/third_party/apk-patch-size-estimator/README.chromium deleted file mode 100644 index 6ed5efee5..0000000 --- a/third_party/apk-patch-size-estimator/README.chromium +++ /dev/null
@@ -1,16 +0,0 @@ -Name: APK patch size estimator -URL: https://github.com/googlesamples/apk-patch-size-estimator -Version: 0.2 -Date: Dec 16, 2016 -Revision: 823a9504f237e4bb236cadf8b804ed27498e54fd -License: Apache 2.0 -License File: NOT_SHIPPED -Security Critical: No - -Description: -Estimates the size of Google Play patches and the new gzipped APK. See README.md -for more details. - -Local Modifications: -- Removed the following files: CONTRIBUTING.md, tests/, images/. -- Changed file-by-file-tools.jar path to be absolute instead of relative.
diff --git a/third_party/apk-patch-size-estimator/README.md b/third_party/apk-patch-size-estimator/README.md deleted file mode 100644 index ff3385ba..0000000 --- a/third_party/apk-patch-size-estimator/README.md +++ /dev/null
@@ -1,77 +0,0 @@ -# APK patch size estimator -Estimates the size of Google Play patches and the new gzipped APK. - -From two APKs it estimates the size of the new patches as well as the size of the gzipped version of the new APK, which would be used in -cases where the patches are unexpectedly large, unavailable, or unsuitable. -Google Play uses multiple techniques to generate patches and generally picks the best match for the device. The best match is usually, but not always, the smallest patch file produced. The numbers that this script produces are **ESTIMATES** that can be used to characterize the impact of arbitrary changes to APKs. There is **NO GUARANTEE** that this tool produces the same patches or patch sizes that Google Play generates, stores or transmits, and the actual implementation within Google Play may change at any time, without notice. - -***This is not an official Google product*** - -## Usage - -The script uses *Python 2.7.X*, *bsdiff* and *Java* (you may need to install them in your system) - -For the file-by-file estimation we use a jar (at /lib/file-by-file-tools.jar) generated from: https://github.com/andrewhayden/archive-patcher - -#### To estimate the patches sizes of two APKs run: -```bash -$ python apk_patch_size_estimator.py --old-file old.apk --new-file new.apk -``` - -#### Output: -```bash -New APK size on disk: 18,271,850 bytes [17.4MB] - -Estimated download size for new installs: - Full new APK (gzipped) size: 16,339,603 bytes [15.6MB] - -Estimated download size for updates from the old APK, using Bsdiff: - Bsdiff patch (gzipped) size: 2,989,691 bytes [2.85MB] - -Estimated download size for updates from the old APK, - using File-by-File: - File-by-File patch (gzipped) size: 1,912,751 bytes [1.82MB] -``` - -## Patches estimation process - -### Bsdiff estimation - - -### File-by-file estimation -Please visit https://github.com/andrewhayden/archive-patcher for further details. - -## Installing external dependencies -The script uses *bsdiff*, *gzip*, *head*, *tail*, *bunzip2* and *java* binaries, [**bsdiff**](https://www.freebsd.org/cgi/man.cgi?query=bsdiff) is the only one not installed by defult in a unix based OS. - -#### Linux debian-based -Install bsdiff: -```bash -sudo apt-get install bsdiff -``` - -#### OS X -Install bsdiff using [Homebrew](http://brew.sh/): -```bash -brew install bsdiff -``` - -#### Windows - -The easiest way to run the script in Windows is by using [Cygwin](https://www.cygwin.com/), make sure you install *python* and *bsdiff* using Cygwin's installer/setup. - -## Runing the unittests - -#### Install unittest.mock -```bash -pip install mock -``` - -#### Run the test -```bash -python -m unittest discover tests/ -``` - -## Authors - Julian Toledo - Andrew Hayden
diff --git a/third_party/apk-patch-size-estimator/apk_patch_size_estimator.py b/third_party/apk-patch-size-estimator/apk_patch_size_estimator.py deleted file mode 100755 index 64b4bb63..0000000 --- a/third_party/apk-patch-size-estimator/apk_patch_size_estimator.py +++ /dev/null
@@ -1,353 +0,0 @@ -#!/usr/bin/python -# -# Copyright 2016 Google Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Estimates the size of Google Play patches and the new gzipped APK. - -From two APKs it estimates the size of new patches as well as -the size of a gzipped version of the APK, which would be used in -cases where patches are unexpectedly large, unavailable, or unsuitable. -Google Play uses multiple techniques to generate patches and generally picks -the best match for the device. The best match is usually, but not always, the -smallest patch file produced. The numbers that this script produces are -ESTIMATES that can be used to characterize the impact of arbitrary changes to -APKs. There is NO GUARANTEE that this tool produces the same patches or patch -sizes that Google Play generates, stores or transmits, and the actual -implementation within Google Play may change at any time, without notice. - -""" - -import sys -import argparse -import locale -import math -import os -import subprocess - -_FILEBYFILE_JAR_PATH = os.path.abspath( - os.path.join(os.path.dirname(__file__), 'lib', 'file-by-file-tools.jar')) - -bsdiff_path = None -gzip_path = None -head_path = None -tail_path = None -bunzip2_path = None -java_path = None - - -def find_bins_or_die(): - """Checks that all the binaries needed are available. - - The script needs bsdiff, gzip, head, tail and bunzip2 - binaries availables in the system. - """ - - global bsdiff_path - if not bsdiff_path: - bsdiff_path = find_binary('bsdiff') - global gzip_path - if not gzip_path: - gzip_path = find_binary('gzip') - global head_path - if not head_path: - head_path = find_binary('head') - global tail_path - if not tail_path: - tail_path = find_binary('tail') - global bunzip2_path - if not bunzip2_path: - bunzip2_path = find_binary('bunzip2') - global java_path - if not java_path: - java_path = find_binary('java') - - -def find_binary(binary_name): - """Finds the path of a binary.""" - - try: - return subprocess.check_output(['which', binary_name]).strip() - except subprocess.CalledProcessError: - raise Exception( - 'No "' + binary_name + '" on PATH, please install or fix PATH.') - - -def human_file_size(size): - """Converts a byte size number into a human readable value.""" - - size = abs(size) - if size == 0: - return '0B' - units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] - p = math.floor(math.log(size, 2) / 10) - return '%.3g%s' % (size/math.pow(1024, p), units[int(p)]) - - -def calculate_bsdiff(old_file, new_file, save_patch_path, temp_path): - """Estimates the size the Bsdiff patch gzipped. - - Args: - old_file: the old APK file - new_file: the new APK file - save_patch_path: the path including filename to save the generated patch. - temp_path: the directory to use for the process - - Returns: - a dictionary with: - 'gzipped_new_file_size': the estimated size of the new gzipped APK - 'bsdiff_patch_size': the estimated size of the patch from the two APKs - - Raises: - Exception: if there is a problem calling the binaries needed in the process - """ - - # Oddities: - # Bsdiff forces bzip2 compression, which starts after byte 32. Bzip2 isn't - # necessarily the best choice in all cases, and isn't necessarily what Google - # Play uses, so it has to be uncompressed and rewritten with gzip. - - # Checks that the OS binaries needed are available - find_bins_or_die() - # Clean temp files - if os.path.exists(temp_path): os.remove(temp_path) - - # Create the bsdiff of the two APKs - subprocess.check_output( - [bsdiff_path, old_file, new_file, temp_path]) - - # bsdiff paths - raw_bsdiff_path = temp_path + '.raw_bsdiff' - bzipped_bsdiff_path = raw_bsdiff_path + '.bz2' - gzipped_bsdiff_path = raw_bsdiff_path + '.gz' - bsdiff_header_path = temp_path + '.raw_bsdiff_header' - if os.path.exists(raw_bsdiff_path): os.remove(raw_bsdiff_path) - if os.path.exists(bzipped_bsdiff_path): os.remove(bzipped_bsdiff_path) - if os.path.exists(gzipped_bsdiff_path): os.remove(gzipped_bsdiff_path) - if os.path.exists(bsdiff_header_path): os.remove(bsdiff_header_path) - - # Strip the first 32 bytes the bsdiff file, which is a bsdiff-specific header. - bsdiff_header = open(bsdiff_header_path, 'w') - p = subprocess.Popen( - [head_path, '-c', '32', bsdiff_header_path], - shell=False, stdout=bsdiff_header) - ret_code = p.wait() - if ret_code != 0: - raise Exception('Problem at the bsdiff step, returned code: %s' % ret_code) - bsdiff_header.flush() - bsdiff_header.close() - - # Take the remainder of the file to gain an uncompressed copy. - bzipped_bsdiff_patch = open(bzipped_bsdiff_path, 'w') - p = subprocess.Popen( - [tail_path, '-c', '+33', temp_path], - shell=False, stdout=bzipped_bsdiff_patch) - ret_code = p.wait() - if ret_code != 0: - raise Exception('Problem at the tail step, returned code: %s' % ret_code) - bzipped_bsdiff_patch.flush() - bzipped_bsdiff_patch.close() - subprocess.check_output([bunzip2_path, '-d', '-q', bzipped_bsdiff_path]) - - # Prepend the 32 bytes of bsdiff header back onto the uncompressed file. - if save_patch_path: - rebuilt_bsdiff_path = save_patch_path + '-bsdiff-patch' - else: - rebuilt_bsdiff_path = raw_bsdiff_path + '.rebuilt' - gzipped_rebuilt_bsdiff_path = rebuilt_bsdiff_path + '.gz' - if os.path.exists(rebuilt_bsdiff_path): os.remove(rebuilt_bsdiff_path) - if os.path.exists(gzipped_rebuilt_bsdiff_path): - os.remove(gzipped_rebuilt_bsdiff_path) - rebuilt_bsdiff = open(rebuilt_bsdiff_path, 'w') - p = subprocess.Popen( - ['cat', bsdiff_header_path, raw_bsdiff_path], - shell=False, stdout=rebuilt_bsdiff) - ret_code = p.wait() - if ret_code != 0: - raise Exception('Problem at the cat step, returned code: %s' % ret_code) - rebuilt_bsdiff.flush() - rebuilt_bsdiff.close() - - # gzip the patch and get its size. - subprocess.check_output([gzip_path, '-9', rebuilt_bsdiff_path]) - bsdiff_patch_size = os.stat(gzipped_rebuilt_bsdiff_path).st_size - - # Clean up. - if os.path.exists(temp_path): os.remove(temp_path) - if os.path.exists(raw_bsdiff_path): os.remove(raw_bsdiff_path) - if os.path.exists(bsdiff_header_path): os.remove(bsdiff_header_path) - if os.path.exists(gzipped_bsdiff_path): os.remove(gzipped_bsdiff_path) - if not save_patch_path and os.path.exists(gzipped_rebuilt_bsdiff_path): - os.remove(gzipped_rebuilt_bsdiff_path) - - return bsdiff_patch_size - - -def calculate_new_apk(new_file, temp_path): - """Estimates the size the new APK gzipped. - - Args: - new_file: the new APK file - temp_path: the directory to use for the process - - Returns: - the size of the new APK gzipped - - Raises: - Exception: if there is a problem calling the binaries needed in the process - """ - - # Checks that the OS binaries needed are available - find_bins_or_die() - # Clean temp files - if os.path.exists(temp_path + '.gz'): os.remove(temp_path + '.gz') - - # gzip new APK and get its size - gzipped_new_file = open(temp_path, 'w') - p = subprocess.Popen( - [gzip_path, '--keep', '-c', '-9', new_file], - shell=False, stdout=gzipped_new_file) - ret_code = p.wait() - if ret_code != 0: raise Exception( - 'Problem gzipping the new APK, returned code: %s' % ret_code) - gzipped_new_file.flush() - gzipped_new_file.close() - gzipped_size = os.stat(temp_path).st_size - # Clean up - if os.path.exists(temp_path + '.gz'): os.remove(temp_path + '.gz') - return gzipped_size - - -def calculate_filebyfile(old_file, new_file, save_patch_path, temp_path): - """Estimates the size the File-by-File patch gzipped. - - Args: - old_file: the old APK file - new_file: the new APK file - save_patch_path: the path including filename to save the generated patch. - temp_path: the directory to use for the process - - Returns: - the size the File-by-File patch gzipped - - Raises: - Exception: if there is a problem calling the binaries needed in the process - """ - - # Checks that the OS binaries needed are available - find_bins_or_die() - # Clean temp files - if os.path.exists(temp_path): os.remove(temp_path) - - if save_patch_path: - filebyfile_patch_path = save_patch_path + '-file-by-file-patch' - else: - filebyfile_patch_path = temp_path + '.filebyfile' - gzipped_filebyfile_patch_path = filebyfile_patch_path + '.gz' - if os.path.exists(gzipped_filebyfile_patch_path): - os.remove(gzipped_filebyfile_patch_path) - - # file by file patch - # We use a jar from https://github.com/andrewhayden/archive-patcher - if os.path.exists(filebyfile_patch_path): os.remove(filebyfile_patch_path) - p = subprocess.Popen( - [java_path, '-jar', _FILEBYFILE_JAR_PATH, '--generate', '--old', old_file, - '--new', new_file, '--patch', filebyfile_patch_path], - shell=False) - ret_code = p.wait() - if ret_code != 0: raise Exception( - 'Problem creating file by file patch, returned code: %s' % ret_code) - - # gzip file by file patch and get its size - subprocess.check_output([gzip_path, '-9', filebyfile_patch_path]) - gzipped_filebyfile_patch_size = os.stat(gzipped_filebyfile_patch_path).st_size - # Clean temp files - if os.path.exists(temp_path): os.remove(temp_path) - if not save_patch_path and os.path.exists(gzipped_filebyfile_patch_path): - os.remove(gzipped_filebyfile_patch_path) - return gzipped_filebyfile_patch_size - - -def main(): - locale.setlocale(locale.LC_ALL, '') - - parser = argparse.ArgumentParser( - description='Estimate the sizes of APK patches for Google Play') - parser.add_argument( - '--old-file', default=None, required=True, - help='the path to the "old" file to generate patches from.') - parser.add_argument( - '--new-file', default=None, required=True, - help='the path to the "new" file to generate patches from.') - parser.add_argument( - '--save-patch', default=None, - help='the path prefix to save the generated patches.') - parser.add_argument( - '--temp-dir', default='/tmp', - help='the temp directory to use for patch generation; defaults to /tmp') - if not sys.argv[1:]: - parser.print_help() - parser.exit() - args = parser.parse_args() - - if not os.path.isfile(args.old_file): - raise Exception('File does not exist: %s' % args.old_file) - if not os.path.isfile(args.new_file): - raise Exception('File does not exist: %s' % args.new_file) - if args.save_patch and not os.access( - os.path.dirname(os.path.abspath(args.save_patch)), os.W_OK): - raise Exception('The save patch path is not writable: %s' % args.save_patch) - if args.save_patch and os.path.isdir(args.save_patch): - raise Exception('Please include the filename in the path: %s' - % args.save_patch) - save_patch_path = args.save_patch - if not os.path.isdir(args.temp_dir): - raise Exception('Temp directory does not exist: %s' % args.temp_dir) - temp_path = args.temp_dir + '/patch.tmp' - - new_file_size = os.stat(args.new_file).st_size - - bsdiff_size = calculate_bsdiff( - args.old_file, args.new_file, save_patch_path, temp_path) - - gzipped_size = calculate_new_apk(args.new_file, temp_path) - - # Calculate the size of the File-by-File patch gzipped - gzipped_filebyfile_patch_size = calculate_filebyfile( - args.old_file, args.new_file, save_patch_path, temp_path) - - print ('\nNew APK size on disk: %s bytes [%s]' - % (locale.format('%d', new_file_size, grouping=True), - human_file_size(new_file_size))) - - print '\nEstimated download size for new installs:' - print (' Full new APK (gzipped) size:' - ' %s bytes [%s]' - % (locale.format('%d', gzipped_size, grouping=True), - human_file_size(gzipped_size))) - - print '\nEstimated download size for updates from the old APK, using Bsdiff:' - print (' Bsdiff patch (gzipped) size: %s bytes [%s]' - % (locale.format('%d', bsdiff_size, grouping=True), - human_file_size(bsdiff_size))) - - print '\nEstimated download size for updates from the old APK,' - print ' using File-by-File:' - print (' File-by-File patch (gzipped) size: %s bytes [%s]\n' - % (locale.format('%d', gzipped_filebyfile_patch_size, grouping=True), - human_file_size(gzipped_filebyfile_patch_size))) - - -if __name__ == '__main__': - main()
diff --git a/third_party/apk-patch-size-estimator/cipd.yaml b/third_party/apk-patch-size-estimator/cipd.yaml deleted file mode 100644 index 2c6df0d..0000000 --- a/third_party/apk-patch-size-estimator/cipd.yaml +++ /dev/null
@@ -1,10 +0,0 @@ -# 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. - -# To create CIPD package run the following command. -# cipd create --pkg-def cipd.yaml -tag version:$(cat version.txt) -package: chromium/third_party/apk-patch-size-estimator -description: apk-patch-size-estimator Java library -data: - - file: lib/file-by-file-tools.jar \ No newline at end of file
diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc index 1d93518..e1567d4 100644 --- a/third_party/blink/common/features.cc +++ b/third_party/blink/common/features.cc
@@ -404,9 +404,6 @@ const base::Feature kDisableForceDeferInChildFrames{ "DisableForceDeferInChildFrames", base::FEATURE_DISABLED_BY_DEFAULT}; -const base::Feature kHtmlImportsRequestInitiatorLock{ - "HtmlImportsRequestInitiatorLock", base::FEATURE_ENABLED_BY_DEFAULT}; - // Enables redirecting subresources in the page to better compressed and // optimized versions to provide data savings. const base::Feature kSubresourceRedirect{"SubresourceRedirect",
diff --git a/third_party/blink/public/common/features.h b/third_party/blink/public/common/features.h index bbf0e7b..ef858de 100644 --- a/third_party/blink/public/common/features.h +++ b/third_party/blink/public/common/features.h
@@ -117,7 +117,6 @@ BLINK_COMMON_EXPORT extern const base::Feature kBlinkCompositorUseDisplayThreadPriority; -BLINK_COMMON_EXPORT extern const base::Feature kHtmlImportsRequestInitiatorLock; BLINK_COMMON_EXPORT extern const base::Feature kIgnoreCrossOriginWindowWhenNamedAccessOnWindow;
diff --git a/third_party/blink/public/mojom/page/widget.mojom b/third_party/blink/public/mojom/page/widget.mojom index 4b51345..4eceec7 100644 --- a/third_party/blink/public/mojom/page/widget.mojom +++ b/third_party/blink/public/mojom/page/widget.mojom
@@ -9,6 +9,9 @@ interface FrameWidget { // Notifies the Widget that the system drag and drop operation has ended. DragSourceSystemDragEnded(); + + // Makes the Widget background transparent or opaque. + SetBackgroundOpaque(bool opaque); }; // Implemented in Browser, this interface defines frame-widget-specific methods that
diff --git a/third_party/blink/public/mojom/web_feature/web_feature.mojom b/third_party/blink/public/mojom/web_feature/web_feature.mojom index 83503cb..56979bc 100644 --- a/third_party/blink/public/mojom/web_feature/web_feature.mojom +++ b/third_party/blink/public/mojom/web_feature/web_feature.mojom
@@ -2160,7 +2160,6 @@ kCSSValueAppearanceSearchCancel = 2820, kCSSValueAppearanceTextarea = 2821, kCSSValueAppearanceTextFieldForTemporalRendered = 2823, - kBuiltInModuleVirtualScroller = 2825, kAdClickNavigation = 2826, kRTCStatsRelativePacketArrivalDelay = 2827, // The above items are available in M74 branch. @@ -2259,12 +2258,10 @@ kUnsizedMediaPolicy = 2918, kScrollByPrecisionTouchPad = 2919, kPinchZoom = 2920, - kBuiltInModuleSwitchImported = 2921, kFeaturePolicyCommaSeparatedDeclarations = 2922, kFeaturePolicySemicolonSeparatedDeclarations = 2923, kV8CallSiteAPIGetFunctionSloppyCall = 2924, kV8CallSiteAPIGetThisSloppyCall = 2925, - kBuiltInModuleToast = 2926, kLargestContentfulPaintExplicitlyRequested = 2927, kPageFreezeOptIn = 2928, kPageFreezeOptOut = 2929,
diff --git a/third_party/blink/public/platform/web_spell_check_panel_host_client.h b/third_party/blink/public/platform/web_spell_check_panel_host_client.h index 9673109..a0f8d6b 100644 --- a/third_party/blink/public/platform/web_spell_check_panel_host_client.h +++ b/third_party/blink/public/platform/web_spell_check_panel_host_client.h
@@ -17,7 +17,8 @@ // Returns true if the spelling panel UI is showing. virtual bool IsShowingSpellingUI() = 0; - // Update the spelling panel UI with the given |word|. + // Update the spelling panel UI with the given |word|. Pass the empty string + // to indicate that there are no misspelled words left. virtual void UpdateSpellingUIWithMisspelledWord(const WebString& word) = 0; };
diff --git a/third_party/blink/public/web/web_external_widget_client.h b/third_party/blink/public/web/web_external_widget_client.h index 4fa83804..62addbf1 100644 --- a/third_party/blink/public/web/web_external_widget_client.h +++ b/third_party/blink/public/web/web_external_widget_client.h
@@ -32,6 +32,10 @@ // Called when the associated WebExternalWidget has adjusted its size. virtual void DidResize(const gfx::Size& size) = 0; + + // Record the time it took for the first paint after the widget transitioned + // from background inactive to active. + virtual void RecordTimeToFirstActivePaint(base::TimeDelta duration) {} }; } // namespace blink
diff --git a/third_party/blink/public/web/web_view.h b/third_party/blink/public/web/web_view.h index c614265..406c19b 100644 --- a/third_party/blink/public/web/web_view.h +++ b/third_party/blink/public/web/web_view.h
@@ -399,16 +399,6 @@ // well. virtual void SetBaseBackgroundColor(SkColor) {} - // Overrides the page's background and base background color. You - // can use this to enforce a transparent background, which is useful if you - // want to have some custom background rendered behind the widget. - // - // These may are only called for composited WebViews. - virtual void SetBackgroundColorOverride(SkColor) {} - virtual void ClearBackgroundColorOverride() {} - virtual void SetBaseBackgroundColorOverride(SkColor) {} - virtual void ClearBaseBackgroundColorOverride() {} - // Scheduling ----------------------------------------------------------- virtual PageScheduler* Scheduler() const = 0;
diff --git a/third_party/blink/public/web/web_widget.h b/third_party/blink/public/web/web_widget.h index 80989ac1..a8fb3381 100644 --- a/third_party/blink/public/web/web_widget.h +++ b/third_party/blink/public/web/web_widget.h
@@ -69,6 +69,14 @@ // the pointers valid until Close() is called. virtual void SetCompositorHosts(cc::LayerTreeHost*, cc::AnimationHost*) = 0; + // Adjust the compositor visible state. This does method does not get called + // if this widget does not composite. + virtual void SetCompositorVisible(bool visible) = 0; + + // Update the visual state of the page. Updating the document + // lifecycle. + virtual void UpdateVisualState() = 0; + // This method closes and deletes the WebWidget. virtual void Close() {} @@ -82,9 +90,6 @@ virtual void DidEnterFullscreen() {} virtual void DidExitFullscreen() {} - // TODO(crbug.com/704763): Remove the need for this. - virtual void SetSuppressFrameRequestsWorkaroundFor704763Only(bool) {} - // Called to update imperative animation state. This should be called before // paint, although the client can rate-limit these calls. // |last_frame_time| is in seconds. @@ -130,6 +135,8 @@ virtual void BeginCommitCompositorFrame() {} virtual void EndCommitCompositorFrame(base::TimeTicks) {} + virtual void WillBeginCompositorFrame() {} + // Called to run through the entire set of document lifecycle phases needed // to render a frame of the web widget. This MUST be called before Paint, // and it may result in calls to WebViewClient::DidInvalidateRect (for
diff --git a/third_party/blink/public/web/web_widget_client.h b/third_party/blink/public/web/web_widget_client.h index 7111102a..cce1b587 100644 --- a/third_party/blink/public/web/web_widget_client.h +++ b/third_party/blink/public/web/web_widget_client.h
@@ -267,6 +267,10 @@ virtual void AddPresentationCallback( uint32_t frame_token, base::OnceCallback<void(base::TimeTicks)> callback) {} + + // Record the time it took for the first paint after the widget transitioned + // from background inactive to active. + virtual void RecordTimeToFirstActivePaint(base::TimeDelta duration) {} }; } // namespace blink
diff --git a/third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h b/third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h index f8dcc75..9f80279 100644 --- a/third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h +++ b/third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h
@@ -462,10 +462,6 @@ const String& enum_name, ExceptionState&); -// Result values for platform object 'deleter' methods, -// http://www.w3.org/TR/WebIDL/#delete -enum DeleteResult { kDeleteSuccess, kDeleteReject, kDeleteUnknownProperty }; - CORE_EXPORT v8::Local<v8::Value> FromJSONString(v8::Isolate*, v8::Local<v8::Context>, const String& stringified_json,
diff --git a/third_party/blink/renderer/bindings/generated_in_modules.gni b/third_party/blink/renderer/bindings/generated_in_modules.gni index a6dbfcf..8e1ddac47 100644 --- a/third_party/blink/renderer/bindings/generated_in_modules.gni +++ b/third_party/blink/renderer/bindings/generated_in_modules.gni
@@ -1030,10 +1030,6 @@ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_shadow_root.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_shared_worker_global_scope.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_shared_worker_global_scope.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_sms.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_sms.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_sms_receiver.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_sms_receiver.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_source_buffer.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_source_buffer.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_source_buffer_list.cc",
diff --git a/third_party/blink/renderer/bindings/templates/interface.cc.tmpl b/third_party/blink/renderer/bindings/templates/interface.cc.tmpl index 43e7f38b..b8f328b7 100644 --- a/third_party/blink/renderer/bindings/templates/interface.cc.tmpl +++ b/third_party/blink/renderer/bindings/templates/interface.cc.tmpl
@@ -110,12 +110,12 @@ {% if setter.is_raises_exception %} {% set setter_arguments = setter_arguments + ['exception_state'] %} {% endif %} - bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); + IndexedPropertySetterResult result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); {% if setter.is_raises_exception %} if (exception_state.HadException()) return; {% endif %} - if (!result) + if (result == IndexedPropertySetterResult::kDidNotIntercept) return; V8SetReturnValue(info, v8_value); } @@ -303,14 +303,14 @@ {% if deleter.is_raises_exception %} {% set deleter_arguments = deleter_arguments + ['exception_state'] %} {% endif %} - DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ')}}); + NamedPropertyDeleterResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ')}}); {% if deleter.is_raises_exception %} if (exception_state.HadException()) return; {% endif %} - if (result == kDeleteUnknownProperty) + if (result == NamedPropertyDeleterResult::kDidNotIntercept) return; - V8SetReturnValue(info, result == kDeleteSuccess); + V8SetReturnValue(info, result == NamedPropertyDeleterResult::kDeleted); } {% endif %} @@ -494,12 +494,12 @@ {% if setter.is_raises_exception %} {% set setter_arguments = setter_arguments + ['exception_state'] %} {% endif %} - bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); + NamedPropertySetterResult result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); {% if setter.is_raises_exception %} if (exception_state.HadException()) return; {% endif %} - if (!result) + if (result == NamedPropertySetterResult::kDidNotIntercept) return; V8SetReturnValue(info, v8_value); } @@ -563,14 +563,14 @@ {% if deleter.is_raises_exception %} {% set deleter_arguments = deleter_arguments + ['exception_state'] %} {% endif %} - DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ')}}); + NamedPropertyDeleterResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ')}}); {% if deleter.is_raises_exception %} if (exception_state.HadException()) return; {% endif %} - if (result == kDeleteUnknownProperty) + if (result == NamedPropertyDeleterResult::kDidNotIntercept) return; - V8SetReturnValue(info, result == kDeleteSuccess); + V8SetReturnValue(info, result == NamedPropertyDeleterResult::kDeleted); } {% endif %}
diff --git a/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface.cc b/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface.cc index 6ad8659..c517db1 100644 --- a/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface.cc +++ b/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface.cc
@@ -2714,8 +2714,8 @@ if (!property_value.Prepare()) return; - bool result = impl->AnonymousNamedSetter(name, property_value); - if (!result) + NamedPropertySetterResult result = impl->AnonymousNamedSetter(name, property_value); + if (result == NamedPropertySetterResult::kDidNotIntercept) return; V8SetReturnValue(info, v8_value); } @@ -2724,10 +2724,10 @@ const AtomicString& name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { TestInterfaceImplementation* impl = V8TestInterface::ToImpl(info.Holder()); - DeleteResult result = impl->AnonymousNamedDeleter(name); - if (result == kDeleteUnknownProperty) + NamedPropertyDeleterResult result = impl->AnonymousNamedDeleter(name); + if (result == NamedPropertyDeleterResult::kDidNotIntercept) return; - V8SetReturnValue(info, result == kDeleteSuccess); + V8SetReturnValue(info, result == NamedPropertyDeleterResult::kDeleted); } static void NamedPropertyQuery( @@ -2817,8 +2817,8 @@ if (!property_value.Prepare()) return; - bool result = impl->AnonymousIndexedSetter(index, property_value); - if (!result) + IndexedPropertySetterResult result = impl->AnonymousIndexedSetter(index, property_value); + if (result == IndexedPropertySetterResult::kDidNotIntercept) return; V8SetReturnValue(info, v8_value); } @@ -2827,10 +2827,10 @@ uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) { TestInterfaceImplementation* impl = V8TestInterface::ToImpl(info.Holder()); - DeleteResult result = impl->AnonymousIndexedDeleter(index); - if (result == kDeleteUnknownProperty) + NamedPropertyDeleterResult result = impl->AnonymousIndexedDeleter(index); + if (result == NamedPropertyDeleterResult::kDidNotIntercept) return; - V8SetReturnValue(info, result == kDeleteSuccess); + V8SetReturnValue(info, result == NamedPropertyDeleterResult::kDeleted); } } // namespace test_interface_implementation_v8_internal
diff --git a/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface_2.cc b/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface_2.cc index 3553ffc..bab13e4 100644 --- a/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface_2.cc +++ b/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface_2.cc
@@ -397,10 +397,10 @@ return; } - bool result = impl->setNamedItem(name, property_value, exception_state); + NamedPropertySetterResult result = impl->setNamedItem(name, property_value, exception_state); if (exception_state.HadException()) return; - if (!result) + if (result == NamedPropertySetterResult::kDidNotIntercept) return; V8SetReturnValue(info, v8_value); } @@ -416,12 +416,12 @@ TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder()); - DeleteResult result = impl->deleteNamedItem(name, exception_state); + NamedPropertyDeleterResult result = impl->deleteNamedItem(name, exception_state); if (exception_state.HadException()) return; - if (result == kDeleteUnknownProperty) + if (result == NamedPropertyDeleterResult::kDidNotIntercept) return; - V8SetReturnValue(info, result == kDeleteSuccess); + V8SetReturnValue(info, result == NamedPropertyDeleterResult::kDeleted); } static void NamedPropertyQuery( @@ -520,10 +520,10 @@ return; } - bool result = impl->setItem(index, property_value, exception_state); + IndexedPropertySetterResult result = impl->setItem(index, property_value, exception_state); if (exception_state.HadException()) return; - if (!result) + if (result == IndexedPropertySetterResult::kDidNotIntercept) return; V8SetReturnValue(info, v8_value); } @@ -537,12 +537,12 @@ TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder()); - DeleteResult result = impl->deleteItem(index, exception_state); + NamedPropertyDeleterResult result = impl->deleteItem(index, exception_state); if (exception_state.HadException()) return; - if (result == kDeleteUnknownProperty) + if (result == NamedPropertyDeleterResult::kDidNotIntercept) return; - V8SetReturnValue(info, result == kDeleteSuccess); + V8SetReturnValue(info, result == NamedPropertyDeleterResult::kDeleted); } } // namespace test_interface_2_v8_internal
diff --git a/third_party/blink/renderer/bindings/tests/results/core/v8_test_object.cc b/third_party/blink/renderer/bindings/tests/results/core/v8_test_object.cc index 395255961..012ddbf 100644 --- a/third_party/blink/renderer/bindings/tests/results/core/v8_test_object.cc +++ b/third_party/blink/renderer/bindings/tests/results/core/v8_test_object.cc
@@ -8934,8 +8934,8 @@ if (!property_value.Prepare()) return; - bool result = impl->AnonymousNamedSetter(script_state, name, property_value); - if (!result) + NamedPropertySetterResult result = impl->AnonymousNamedSetter(script_state, name, property_value); + if (result == NamedPropertySetterResult::kDidNotIntercept) return; V8SetReturnValue(info, v8_value); } @@ -8946,10 +8946,10 @@ TestObject* impl = V8TestObject::ToImpl(info.Holder()); - DeleteResult result = impl->AnonymousNamedDeleter(script_state, name); - if (result == kDeleteUnknownProperty) + NamedPropertyDeleterResult result = impl->AnonymousNamedDeleter(script_state, name); + if (result == NamedPropertyDeleterResult::kDidNotIntercept) return; - V8SetReturnValue(info, result == kDeleteSuccess); + V8SetReturnValue(info, result == NamedPropertyDeleterResult::kDeleted); } static void NamedPropertyQuery( @@ -9042,8 +9042,8 @@ return; ScriptState* script_state = ScriptState::ForRelevantRealm(info); - bool result = impl->setItem(script_state, index, property_value); - if (!result) + IndexedPropertySetterResult result = impl->setItem(script_state, index, property_value); + if (result == IndexedPropertySetterResult::kDidNotIntercept) return; V8SetReturnValue(info, v8_value); } @@ -9058,12 +9058,12 @@ TestObject* impl = V8TestObject::ToImpl(info.Holder()); ScriptState* script_state = ScriptState::ForRelevantRealm(info); - DeleteResult result = impl->AnonymousIndexedDeleter(script_state, index, exception_state); + NamedPropertyDeleterResult result = impl->AnonymousIndexedDeleter(script_state, index, exception_state); if (exception_state.HadException()) return; - if (result == kDeleteUnknownProperty) + if (result == NamedPropertyDeleterResult::kDidNotIntercept) return; - V8SetReturnValue(info, result == kDeleteSuccess); + V8SetReturnValue(info, result == NamedPropertyDeleterResult::kDeleted); } } // namespace test_object_v8_internal
diff --git a/third_party/blink/renderer/bindings/tests/results/core/v8_test_special_operations.cc b/third_party/blink/renderer/bindings/tests/results/core/v8_test_special_operations.cc index a57dcdf..f6d51a0f 100644 --- a/third_party/blink/renderer/bindings/tests/results/core/v8_test_special_operations.cc +++ b/third_party/blink/renderer/bindings/tests/results/core/v8_test_special_operations.cc
@@ -111,8 +111,8 @@ return; } - bool result = impl->AnonymousNamedSetter(name, property_value); - if (!result) + NamedPropertySetterResult result = impl->AnonymousNamedSetter(name, property_value); + if (result == NamedPropertySetterResult::kDidNotIntercept) return; V8SetReturnValue(info, v8_value); }
diff --git a/third_party/blink/renderer/bindings/tests/results/modules/v8_test_interface_5.cc b/third_party/blink/renderer/bindings/tests/results/modules/v8_test_interface_5.cc index c5094781..7b827af3 100644 --- a/third_party/blink/renderer/bindings/tests/results/modules/v8_test_interface_5.cc +++ b/third_party/blink/renderer/bindings/tests/results/modules/v8_test_interface_5.cc
@@ -613,8 +613,8 @@ if (!property_value.Prepare()) return; - bool result = impl->AnonymousIndexedSetter(index, property_value); - if (!result) + IndexedPropertySetterResult result = impl->AnonymousIndexedSetter(index, property_value); + if (result == IndexedPropertySetterResult::kDidNotIntercept) return; V8SetReturnValue(info, v8_value); } @@ -623,10 +623,10 @@ uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) { TestInterface5Implementation* impl = V8TestInterface5::ToImpl(info.Holder()); - DeleteResult result = impl->AnonymousIndexedDeleter(index); - if (result == kDeleteUnknownProperty) + NamedPropertyDeleterResult result = impl->AnonymousIndexedDeleter(index); + if (result == NamedPropertyDeleterResult::kDidNotIntercept) return; - V8SetReturnValue(info, result == kDeleteSuccess); + V8SetReturnValue(info, result == NamedPropertyDeleterResult::kDeleted); } } // namespace test_interface_5_implementation_v8_internal
diff --git a/third_party/blink/renderer/core/aom/accessible_node_list.cc b/third_party/blink/renderer/core/aom/accessible_node_list.cc index 6d4c57e86..de6ea7a 100644 --- a/third_party/blink/renderer/core/aom/accessible_node_list.cc +++ b/third_party/blink/renderer/core/aom/accessible_node_list.cc
@@ -71,15 +71,16 @@ nodes_.EraseAt(index); } -bool AccessibleNodeList::AnonymousIndexedSetter(unsigned index, - AccessibleNode* node, - ExceptionState& state) { +IndexedPropertySetterResult AccessibleNodeList::AnonymousIndexedSetter( + unsigned index, + AccessibleNode* node, + ExceptionState& state) { if (!node) { remove(index); - return true; + return IndexedPropertySetterResult::kIntercepted; } if (index >= kMaxItems) - return false; + return IndexedPropertySetterResult::kDidNotIntercept; if (index >= nodes_.size()) { wtf_size_t old_size = nodes_.size(); nodes_.resize(index + 1); @@ -87,7 +88,7 @@ nodes_[i] = nullptr; } nodes_[index] = node; - return true; + return IndexedPropertySetterResult::kIntercepted; } unsigned AccessibleNodeList::length() const {
diff --git a/third_party/blink/renderer/core/aom/accessible_node_list.h b/third_party/blink/renderer/core/aom/accessible_node_list.h index f522f69..e6b5bd1 100644 --- a/third_party/blink/renderer/core/aom/accessible_node_list.h +++ b/third_party/blink/renderer/core/aom/accessible_node_list.h
@@ -7,6 +7,7 @@ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" +#include "third_party/blink/renderer/platform/bindings/v8_binding.h" namespace blink { @@ -32,7 +33,9 @@ AccessibleNode* item(unsigned offset) const; void add(AccessibleNode*, AccessibleNode* = nullptr); void remove(int index); - bool AnonymousIndexedSetter(unsigned, AccessibleNode*, ExceptionState&); + IndexedPropertySetterResult AnonymousIndexedSetter(unsigned, + AccessibleNode*, + ExceptionState&); unsigned length() const; void setLength(unsigned);
diff --git a/third_party/blink/renderer/core/css/css_style_declaration.cc b/third_party/blink/renderer/core/css/css_style_declaration.cc index 8a2a60c7..5ab57f1 100644 --- a/third_party/blink/renderer/core/css/css_style_declaration.cc +++ b/third_party/blink/renderer/core/css/css_style_declaration.cc
@@ -168,16 +168,17 @@ return GetPropertyValueInternal(resolveCSSPropertyID(unresolved_property)); } -bool CSSStyleDeclaration::AnonymousNamedSetter(ScriptState* script_state, - const AtomicString& name, - const String& value) { +NamedPropertySetterResult CSSStyleDeclaration::AnonymousNamedSetter( + ScriptState* script_state, + const AtomicString& name, + const String& value) { const ExecutionContext* execution_context = ExecutionContext::From(script_state); if (!execution_context) - return false; + return NamedPropertySetterResult::kDidNotIntercept; CSSPropertyID unresolved_property = CssPropertyInfo(execution_context, name); if (!isValidCSSPropertyID(unresolved_property)) - return false; + return NamedPropertySetterResult::kDidNotIntercept; // We create the ExceptionState manually due to performance issues: adding // [RaisesException] to the IDL causes the bindings layer to expensively // create a std::string to set the ExceptionState's |property_name| argument, @@ -191,8 +192,8 @@ execution_context->GetSecureContextMode(), exception_state); if (exception_state.HadException()) - return false; - return true; + return NamedPropertySetterResult::kIntercepted; + return NamedPropertySetterResult::kIntercepted; } void CSSStyleDeclaration::NamedPropertyEnumerator(Vector<String>& names,
diff --git a/third_party/blink/renderer/core/css/css_style_declaration.h b/third_party/blink/renderer/core/css/css_style_declaration.h index 4b60546..ad53e5b 100644 --- a/third_party/blink/renderer/core/css/css_style_declaration.h +++ b/third_party/blink/renderer/core/css/css_style_declaration.h
@@ -27,6 +27,7 @@ #include "third_party/blink/renderer/core/execution_context/execution_context.h" #include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" +#include "third_party/blink/renderer/platform/bindings/v8_binding.h" #include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" @@ -98,9 +99,9 @@ // Note: AnonymousNamedSetter() can end up throwing an exception via // SetPropertyInternal() even though it does not take an |ExceptionState| as // an argument (see bug 829408). - bool AnonymousNamedSetter(ScriptState*, - const AtomicString& name, - const String& value); + NamedPropertySetterResult AnonymousNamedSetter(ScriptState*, + const AtomicString& name, + const String& value); void NamedPropertyEnumerator(Vector<String>& names, ExceptionState&); bool NamedPropertyQuery(const AtomicString&, ExceptionState&);
diff --git a/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc b/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc index 6e7f341..aacccd5 100644 --- a/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc +++ b/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc
@@ -15,160 +15,19 @@ #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/pseudo_element.h" #include "third_party/blink/renderer/core/style/computed_style.h" -#include "third_party/blink/renderer/platform/transforms/matrix_3d_transform_operation.h" -#include "third_party/blink/renderer/platform/transforms/matrix_transform_operation.h" -#include "third_party/blink/renderer/platform/transforms/perspective_transform_operation.h" -#include "third_party/blink/renderer/platform/transforms/skew_transform_operation.h" namespace blink { namespace { -// We collapse functions like translateX into translate, since we will reify -// them as a translate anyway. -const CSSValue* ComputedTransformComponent(const TransformOperation& operation, - float zoom) { - switch (operation.GetType()) { - case TransformOperation::kScaleX: - case TransformOperation::kScaleY: - case TransformOperation::kScaleZ: - case TransformOperation::kScale: - case TransformOperation::kScale3D: { - const auto& scale = To<ScaleTransformOperation>(operation); - CSSFunctionValue* result = MakeGarbageCollected<CSSFunctionValue>( - operation.Is3DOperation() ? CSSValueID::kScale3d - : CSSValueID::kScale); - result->Append(*CSSNumericLiteralValue::Create( - scale.X(), CSSPrimitiveValue::UnitType::kNumber)); - result->Append(*CSSNumericLiteralValue::Create( - scale.Y(), CSSPrimitiveValue::UnitType::kNumber)); - if (operation.Is3DOperation()) { - result->Append(*CSSNumericLiteralValue::Create( - scale.Z(), CSSPrimitiveValue::UnitType::kNumber)); - } - return result; - } - case TransformOperation::kTranslateX: - case TransformOperation::kTranslateY: - case TransformOperation::kTranslateZ: - case TransformOperation::kTranslate: - case TransformOperation::kTranslate3D: { - const auto& translate = To<TranslateTransformOperation>(operation); - CSSFunctionValue* result = MakeGarbageCollected<CSSFunctionValue>( - operation.Is3DOperation() ? CSSValueID::kTranslate3d - : CSSValueID::kTranslate); - result->Append(*CSSPrimitiveValue::CreateFromLength(translate.X(), zoom)); - result->Append(*CSSPrimitiveValue::CreateFromLength(translate.Y(), zoom)); - if (operation.Is3DOperation()) { - result->Append(*CSSNumericLiteralValue::Create( - translate.Z(), CSSPrimitiveValue::UnitType::kPixels)); - } - return result; - } - case TransformOperation::kRotateX: - case TransformOperation::kRotateY: - case TransformOperation::kRotate3D: { - const auto& rotate = To<RotateTransformOperation>(operation); - CSSFunctionValue* result = - MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kRotate3d); - result->Append(*CSSNumericLiteralValue::Create( - rotate.X(), CSSPrimitiveValue::UnitType::kNumber)); - result->Append(*CSSNumericLiteralValue::Create( - rotate.Y(), CSSPrimitiveValue::UnitType::kNumber)); - result->Append(*CSSNumericLiteralValue::Create( - rotate.Z(), CSSPrimitiveValue::UnitType::kNumber)); - result->Append(*CSSNumericLiteralValue::Create( - rotate.Angle(), CSSPrimitiveValue::UnitType::kDegrees)); - return result; - } - case TransformOperation::kRotate: { - const auto& rotate = To<RotateTransformOperation>(operation); - auto* result = - MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kRotate); - result->Append(*CSSNumericLiteralValue::Create( - rotate.Angle(), CSSPrimitiveValue::UnitType::kDegrees)); - return result; - } - case TransformOperation::kSkewX: { - const auto& skew = To<SkewTransformOperation>(operation); - auto* result = MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kSkewX); - result->Append(*CSSNumericLiteralValue::Create( - skew.AngleX(), CSSPrimitiveValue::UnitType::kDegrees)); - return result; - } - case TransformOperation::kSkewY: { - const auto& skew = To<SkewTransformOperation>(operation); - auto* result = MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kSkewY); - result->Append(*CSSNumericLiteralValue::Create( - skew.AngleY(), CSSPrimitiveValue::UnitType::kDegrees)); - return result; - } - case TransformOperation::kSkew: { - const auto& skew = To<SkewTransformOperation>(operation); - auto* result = MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kSkew); - result->Append(*CSSNumericLiteralValue::Create( - skew.AngleX(), CSSPrimitiveValue::UnitType::kDegrees)); - result->Append(*CSSNumericLiteralValue::Create( - skew.AngleY(), CSSPrimitiveValue::UnitType::kDegrees)); - return result; - } - case TransformOperation::kPerspective: { - const auto& perspective = To<PerspectiveTransformOperation>(operation); - auto* result = - MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kPerspective); - result->Append(*CSSNumericLiteralValue::Create( - perspective.Perspective() / zoom, - CSSPrimitiveValue::UnitType::kPixels)); - return result; - } - case TransformOperation::kMatrix: { - const auto& matrix = To<MatrixTransformOperation>(operation).Matrix(); - auto* result = - MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kMatrix); - double values[6] = {matrix.A(), matrix.B(), matrix.C(), - matrix.D(), matrix.E() / zoom, matrix.F() / zoom}; - for (double value : values) { - result->Append(*CSSNumericLiteralValue::Create( - value, CSSPrimitiveValue::UnitType::kNumber)); - } - return result; - } - case TransformOperation::kMatrix3D: { - const auto& matrix = To<Matrix3DTransformOperation>(operation).Matrix(); - CSSFunctionValue* result = - MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kMatrix3d); - double values[16] = { - matrix.M11(), matrix.M12(), matrix.M13(), - matrix.M14(), matrix.M21(), matrix.M22(), - matrix.M23(), matrix.M24(), matrix.M31(), - matrix.M32(), matrix.M33(), matrix.M34(), - matrix.M41() / zoom, matrix.M42() / zoom, matrix.M43() / zoom, - matrix.M44()}; - for (double value : values) { - result->Append(*CSSNumericLiteralValue::Create( - value, CSSPrimitiveValue::UnitType::kNumber)); - } - return result; - } - case TransformOperation::kInterpolated: - // TODO(816803): The computed value in this case is not fully spec'd - // See https://github.com/w3c/css-houdini-drafts/issues/425 - return CSSIdentifierValue::Create(CSSValueID::kNone); - default: - // The remaining operations are unsupported. - NOTREACHED(); - return CSSIdentifierValue::Create(CSSValueID::kNone); - } -} - const CSSValue* ComputedTransform(const ComputedStyle& style) { if (style.Transform().Operations().size() == 0) return CSSIdentifierValue::Create(CSSValueID::kNone); CSSValueList* components = CSSValueList::CreateSpaceSeparated(); for (const auto& operation : style.Transform().Operations()) { - components->Append( - *ComputedTransformComponent(*operation, style.EffectiveZoom())); + components->Append(*ComputedStyleUtils::ValueForTransformOperation( + *operation, style.EffectiveZoom())); } return components; }
diff --git a/third_party/blink/renderer/core/css/cssom/css_transform_value.cc b/third_party/blink/renderer/core/css/cssom/css_transform_value.cc index 4876fa3..53b81ac 100644 --- a/third_party/blink/renderer/core/css/cssom/css_transform_value.cc +++ b/third_party/blink/renderer/core/css/cssom/css_transform_value.cc
@@ -77,25 +77,25 @@ return transform_css_value; } -bool CSSTransformValue::AnonymousIndexedSetter( +IndexedPropertySetterResult CSSTransformValue::AnonymousIndexedSetter( unsigned index, const Member<CSSTransformComponent> component, ExceptionState& exception_state) { if (index < transform_components_.size()) { transform_components_[index] = component; - return true; + return IndexedPropertySetterResult::kIntercepted; } if (index == transform_components_.size()) { transform_components_.push_back(component); - return true; + return IndexedPropertySetterResult::kIntercepted; } exception_state.ThrowRangeError( ExceptionMessages::IndexOutsideRange<unsigned>( "index", index, 0, ExceptionMessages::kInclusiveBound, transform_components_.size(), ExceptionMessages::kInclusiveBound)); - return false; + return IndexedPropertySetterResult::kIntercepted; } } // namespace blink
diff --git a/third_party/blink/renderer/core/css/cssom/css_transform_value.h b/third_party/blink/renderer/core/css/cssom/css_transform_value.h index 87f3d031..7cfb9f5 100644 --- a/third_party/blink/renderer/core/css/cssom/css_transform_value.h +++ b/third_party/blink/renderer/core/css/cssom/css_transform_value.h
@@ -10,6 +10,7 @@ #include "third_party/blink/renderer/core/css/cssom/css_style_value.h" #include "third_party/blink/renderer/core/css/cssom/css_transform_component.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" +#include "third_party/blink/renderer/platform/bindings/v8_binding.h" #include "third_party/blink/renderer/platform/heap/heap_allocator.h" namespace blink { @@ -45,9 +46,10 @@ CSSTransformComponent* AnonymousIndexedGetter(wtf_size_t index) { return transform_components_.at(index); } - bool AnonymousIndexedSetter(unsigned, - const Member<CSSTransformComponent>, - ExceptionState&); + IndexedPropertySetterResult AnonymousIndexedSetter( + unsigned, + const Member<CSSTransformComponent>, + ExceptionState&); wtf_size_t length() const { return transform_components_.size(); }
diff --git a/third_party/blink/renderer/core/css/cssom/css_unparsed_value.cc b/third_party/blink/renderer/core/css/cssom/css_unparsed_value.cc index 8d7badb..48193970 100644 --- a/third_party/blink/renderer/core/css/cssom/css_unparsed_value.cc +++ b/third_party/blink/renderer/core/css/cssom/css_unparsed_value.cc
@@ -94,24 +94,25 @@ return {}; } -bool CSSUnparsedValue::AnonymousIndexedSetter(unsigned index, - const CSSUnparsedSegment& segment, - ExceptionState& exception_state) { +IndexedPropertySetterResult CSSUnparsedValue::AnonymousIndexedSetter( + unsigned index, + const CSSUnparsedSegment& segment, + ExceptionState& exception_state) { if (index < tokens_.size()) { tokens_[index] = segment; - return true; + return IndexedPropertySetterResult::kIntercepted; } if (index == tokens_.size()) { tokens_.push_back(segment); - return true; + return IndexedPropertySetterResult::kIntercepted; } exception_state.ThrowRangeError( ExceptionMessages::IndexOutsideRange<unsigned>( "index", index, 0, ExceptionMessages::kInclusiveBound, tokens_.size(), ExceptionMessages::kInclusiveBound)); - return false; + return IndexedPropertySetterResult::kIntercepted; } const CSSValue* CSSUnparsedValue::ToCSSValue() const {
diff --git a/third_party/blink/renderer/core/css/cssom/css_unparsed_value.h b/third_party/blink/renderer/core/css/cssom/css_unparsed_value.h index 7c87b47..b64678a 100644 --- a/third_party/blink/renderer/core/css/cssom/css_unparsed_value.h +++ b/third_party/blink/renderer/core/css/cssom/css_unparsed_value.h
@@ -48,9 +48,9 @@ StyleValueType GetType() const override { return kUnparsedType; } CSSUnparsedSegment AnonymousIndexedGetter(unsigned, ExceptionState&) const; - bool AnonymousIndexedSetter(unsigned, - const CSSUnparsedSegment&, - ExceptionState&); + IndexedPropertySetterResult AnonymousIndexedSetter(unsigned, + const CSSUnparsedSegment&, + ExceptionState&); wtf_size_t length() const { return tokens_.size(); }
diff --git a/third_party/blink/renderer/core/css/properties/computed_style_utils.cc b/third_party/blink/renderer/core/css/properties/computed_style_utils.cc index c2d04d1..940913be 100644 --- a/third_party/blink/renderer/core/css/properties/computed_style_utils.cc +++ b/third_party/blink/renderer/core/css/properties/computed_style_utils.cc
@@ -45,6 +45,10 @@ #include "third_party/blink/renderer/core/style/style_svg_resource.h" #include "third_party/blink/renderer/core/style_property_shorthand.h" #include "third_party/blink/renderer/core/svg_element_type_helpers.h" +#include "third_party/blink/renderer/platform/transforms/matrix_3d_transform_operation.h" +#include "third_party/blink/renderer/platform/transforms/matrix_transform_operation.h" +#include "third_party/blink/renderer/platform/transforms/perspective_transform_operation.h" +#include "third_party/blink/renderer/platform/transforms/skew_transform_operation.h" namespace blink { @@ -1711,7 +1715,7 @@ CSSValuePair::kDropIdenticalValues); } -CSSFunctionValue* ValueForMatrixTransform( +CSSValue* ComputedStyleUtils::ValueForMatrixTransform( const TransformationMatrix& transform_param, const ComputedStyle& style) { // Take TransformationMatrix by reference and then copy it because VC++ @@ -1779,6 +1783,144 @@ return transform_value; } +// We collapse functions like translateX into translate, since we will reify +// them as a translate anyway. +CSSValue* ComputedStyleUtils::ValueForTransformOperation( + const TransformOperation& operation, + float zoom) { + switch (operation.GetType()) { + case TransformOperation::kScaleX: + case TransformOperation::kScaleY: + case TransformOperation::kScaleZ: + case TransformOperation::kScale: + case TransformOperation::kScale3D: { + const auto& scale = To<ScaleTransformOperation>(operation); + CSSFunctionValue* result = MakeGarbageCollected<CSSFunctionValue>( + operation.Is3DOperation() ? CSSValueID::kScale3d + : CSSValueID::kScale); + result->Append(*CSSNumericLiteralValue::Create( + scale.X(), CSSPrimitiveValue::UnitType::kNumber)); + result->Append(*CSSNumericLiteralValue::Create( + scale.Y(), CSSPrimitiveValue::UnitType::kNumber)); + if (operation.Is3DOperation()) { + result->Append(*CSSNumericLiteralValue::Create( + scale.Z(), CSSPrimitiveValue::UnitType::kNumber)); + } + return result; + } + case TransformOperation::kTranslateX: + case TransformOperation::kTranslateY: + case TransformOperation::kTranslateZ: + case TransformOperation::kTranslate: + case TransformOperation::kTranslate3D: { + const auto& translate = To<TranslateTransformOperation>(operation); + CSSFunctionValue* result = MakeGarbageCollected<CSSFunctionValue>( + operation.Is3DOperation() ? CSSValueID::kTranslate3d + : CSSValueID::kTranslate); + result->Append(*CSSPrimitiveValue::CreateFromLength(translate.X(), zoom)); + result->Append(*CSSPrimitiveValue::CreateFromLength(translate.Y(), zoom)); + if (operation.Is3DOperation()) { + result->Append(*CSSNumericLiteralValue::Create( + translate.Z(), CSSPrimitiveValue::UnitType::kPixels)); + } + return result; + } + case TransformOperation::kRotateX: + case TransformOperation::kRotateY: + case TransformOperation::kRotate3D: { + const auto& rotate = To<RotateTransformOperation>(operation); + CSSFunctionValue* result = + MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kRotate3d); + result->Append(*CSSNumericLiteralValue::Create( + rotate.X(), CSSPrimitiveValue::UnitType::kNumber)); + result->Append(*CSSNumericLiteralValue::Create( + rotate.Y(), CSSPrimitiveValue::UnitType::kNumber)); + result->Append(*CSSNumericLiteralValue::Create( + rotate.Z(), CSSPrimitiveValue::UnitType::kNumber)); + result->Append(*CSSNumericLiteralValue::Create( + rotate.Angle(), CSSPrimitiveValue::UnitType::kDegrees)); + return result; + } + case TransformOperation::kRotate: { + const auto& rotate = To<RotateTransformOperation>(operation); + auto* result = + MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kRotate); + result->Append(*CSSNumericLiteralValue::Create( + rotate.Angle(), CSSPrimitiveValue::UnitType::kDegrees)); + return result; + } + case TransformOperation::kSkewX: { + const auto& skew = To<SkewTransformOperation>(operation); + auto* result = MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kSkewX); + result->Append(*CSSNumericLiteralValue::Create( + skew.AngleX(), CSSPrimitiveValue::UnitType::kDegrees)); + return result; + } + case TransformOperation::kSkewY: { + const auto& skew = To<SkewTransformOperation>(operation); + auto* result = MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kSkewY); + result->Append(*CSSNumericLiteralValue::Create( + skew.AngleY(), CSSPrimitiveValue::UnitType::kDegrees)); + return result; + } + case TransformOperation::kSkew: { + const auto& skew = To<SkewTransformOperation>(operation); + auto* result = MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kSkew); + result->Append(*CSSNumericLiteralValue::Create( + skew.AngleX(), CSSPrimitiveValue::UnitType::kDegrees)); + result->Append(*CSSNumericLiteralValue::Create( + skew.AngleY(), CSSPrimitiveValue::UnitType::kDegrees)); + return result; + } + case TransformOperation::kPerspective: { + const auto& perspective = To<PerspectiveTransformOperation>(operation); + auto* result = + MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kPerspective); + result->Append(*CSSNumericLiteralValue::Create( + perspective.Perspective() / zoom, + CSSPrimitiveValue::UnitType::kPixels)); + return result; + } + case TransformOperation::kMatrix: { + const auto& matrix = To<MatrixTransformOperation>(operation).Matrix(); + auto* result = + MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kMatrix); + double values[6] = {matrix.A(), matrix.B(), matrix.C(), + matrix.D(), matrix.E() / zoom, matrix.F() / zoom}; + for (double value : values) { + result->Append(*CSSNumericLiteralValue::Create( + value, CSSPrimitiveValue::UnitType::kNumber)); + } + return result; + } + case TransformOperation::kMatrix3D: { + const auto& matrix = To<Matrix3DTransformOperation>(operation).Matrix(); + CSSFunctionValue* result = + MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kMatrix3d); + double values[16] = { + matrix.M11(), matrix.M12(), matrix.M13(), + matrix.M14(), matrix.M21(), matrix.M22(), + matrix.M23(), matrix.M24(), matrix.M31(), + matrix.M32(), matrix.M33(), matrix.M34(), + matrix.M41() / zoom, matrix.M42() / zoom, matrix.M43() / zoom, + matrix.M44()}; + for (double value : values) { + result->Append(*CSSNumericLiteralValue::Create( + value, CSSPrimitiveValue::UnitType::kNumber)); + } + return result; + } + case TransformOperation::kInterpolated: + // TODO(816803): The computed value in this case is not fully spec'd + // See https://github.com/w3c/css-houdini-drafts/issues/425 + return CSSIdentifierValue::Create(CSSValueID::kNone); + default: + // The remaining operations are unsupported. + NOTREACHED(); + return CSSIdentifierValue::Create(CSSValueID::kNone); + } +} + FloatRect ComputedStyleUtils::ReferenceBoxForTransform( const LayoutObject& layout_object, UsePixelSnappedBox pixel_snap_box) {
diff --git a/third_party/blink/renderer/core/css/properties/computed_style_utils.h b/third_party/blink/renderer/core/css/properties/computed_style_utils.h index 5ae6563a..51fcb47 100644 --- a/third_party/blink/renderer/core/css/properties/computed_style_utils.h +++ b/third_party/blink/renderer/core/css/properties/computed_style_utils.h
@@ -146,6 +146,10 @@ kDontUsePixelSnappedBox, kUsePixelSnappedBox, }; + static CSSValue* ValueForMatrixTransform(const TransformationMatrix&, + const ComputedStyle&); + static CSSValue* ValueForTransformOperation(const TransformOperation&, + float zoom); static FloatRect ReferenceBoxForTransform( const LayoutObject&, UsePixelSnappedBox = kUsePixelSnappedBox);
diff --git a/third_party/blink/renderer/core/css/resolver/style_cascade.cc b/third_party/blink/renderer/core/css/resolver/style_cascade.cc index e49a9867..e665fce 100644 --- a/third_party/blink/renderer/core/css/resolver/style_cascade.cc +++ b/third_party/blink/renderer/core/css/resolver/style_cascade.cc
@@ -112,7 +112,16 @@ uint32_t position = EncodeInterpolationPosition( i, active_interpolation.key.IsPresentationAttribute()); CascadePriority priority(entries[i].origin, false, 0, position); - map_.Add(active_interpolation.key.GetCSSPropertyName(), priority); + + auto name = active_interpolation.key.GetCSSPropertyName(); + CSSPropertyRef ref(name, GetDocument()); + DCHECK(ref.IsValid()); + const CSSProperty& property = ref.GetProperty(); + + if (filter.Rejects(property)) + continue; + + map_.Add(name, priority); } } }
diff --git a/third_party/blink/renderer/core/css/resolver/style_cascade_test.cc b/third_party/blink/renderer/core/css/resolver/style_cascade_test.cc index fc1046d..a44a833 100644 --- a/third_party/blink/renderer/core/css/resolver/style_cascade_test.cc +++ b/third_party/blink/renderer/core/css/resolver/style_cascade_test.cc
@@ -161,13 +161,13 @@ &GetDocument().EnsureStyleResolver()); } - void AnalyzeAnimations() { + void AnalyzeAnimations(CascadeFilter filter = CascadeFilter()) { CalculateAnimationUpdate(); - cascade_.Analyze(GetInterpolations(), CascadeFilter()); + cascade_.Analyze(GetInterpolations(), filter); } - void AnalyzeTransitions() { + void AnalyzeTransitions(CascadeFilter filter = CascadeFilter()) { CalculateTransitionUpdate(); - cascade_.Analyze(GetInterpolations(), CascadeFilter()); + cascade_.Analyze(GetInterpolations(), filter); } private: @@ -1418,6 +1418,49 @@ EXPECT_EQ("rgb(255, 0, 0)", cascade.ComputedValue("background-color")); } +TEST_F(StyleCascadeTest, AnimationAnalyzeFilter) { + AppendSheet(R"HTML( + @keyframes test { + from { color: white; background-color: white; } + to { color: gray; background-color: gray; } + } + )HTML"); + + TestCascade cascade(GetDocument()); + + cascade.Add("animation: test 1s"); + cascade.Apply(); + + cascade.AnalyzeAnimations(CascadeFilter(CSSProperty::kInherited, true)); + + EXPECT_EQ(CascadeOrigin::kAnimation, cascade.GetOrigin("background-color")); + EXPECT_EQ(CascadeOrigin::kNone, cascade.GetOrigin("color")); +} + +TEST_F(StyleCascadeTest, TransitionAnalyzeFilter) { + TestCascade cascade1(GetDocument()); + cascade1.Add("background-color: white"); + cascade1.Add("color: white"); + cascade1.Add("transition: all 1s"); + cascade1.Apply(); + + // Set the old style on the element, so that the transition + // update detects it. + GetDocument().body()->SetComputedStyle(cascade1.TakeStyle()); + + // Now simulate a new style, with new color values. + TestCascade cascade2(GetDocument()); + cascade2.Add("background-color: gray"); + cascade2.Add("color: gray"); + cascade2.Add("transition: all 1s"); + cascade2.Apply(); + + cascade2.AnalyzeTransitions(CascadeFilter(CSSProperty::kInherited, true)); + + EXPECT_EQ(CascadeOrigin::kTransition, cascade2.GetOrigin("background-color")); + EXPECT_EQ(CascadeOrigin::kAuthor, cascade2.GetOrigin("color")); +} + TEST_F(StyleCascadeTest, PendingKeyframeAnimation) { RegisterProperty(GetDocument(), "--x", "<length>", "0px", false);
diff --git a/third_party/blink/renderer/core/css/style_rule_import.cc b/third_party/blink/renderer/core/css/style_rule_import.cc index ed89757..55a0036c 100644 --- a/third_party/blink/renderer/core/css/style_rule_import.cc +++ b/third_party/blink/renderer/core/css/style_rule_import.cc
@@ -22,7 +22,6 @@ #include "third_party/blink/renderer/core/css/style_rule_import.h" -#include "third_party/blink/public/common/features.h" #include "third_party/blink/renderer/core/css/style_sheet_contents.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/loader/resource/css_style_sheet_resource.h" @@ -109,9 +108,7 @@ return; Document* document_for_origin = document; - if (base::FeatureList::IsEnabled( - features::kHtmlImportsRequestInitiatorLock) && - document->ImportsController()) { + if (document->ImportsController()) { // For @imports from HTML imported Documents, we use the // context document for getting origin and ResourceFetcher to use the main // Document's origin, while using the element document for CompleteURL() to
diff --git a/third_party/blink/renderer/core/dom/document.cc b/third_party/blink/renderer/core/dom/document.cc index 7b9939e..47bec85 100644 --- a/third_party/blink/renderer/core/dom/document.cc +++ b/third_party/blink/renderer/core/dom/document.cc
@@ -586,8 +586,8 @@ USING_GARBAGE_COLLECTED_MIXIN(Document::NetworkStateObserver); public: - explicit NetworkStateObserver(Document& document) - : ExecutionContextLifecycleObserver(&document) { + explicit NetworkStateObserver(ExecutionContext* context) + : ExecutionContextLifecycleObserver(context) { online_observer_handle_ = GetNetworkStateNotifier().AddOnLineObserver( this, GetExecutionContext()->GetTaskRunner(TaskType::kNetworking)); } @@ -595,11 +595,9 @@ void OnLineStateChange(bool on_line) override { AtomicString event_name = on_line ? event_type_names::kOnline : event_type_names::kOffline; - Document* document = Document::From(GetExecutionContext()); - if (!document->domWindow()) - return; - document->domWindow()->DispatchEvent(*Event::Create(event_name)); - probe::NetworkStateChanged(document->GetFrame(), on_line); + auto* window = To<LocalDOMWindow>(GetExecutionContext()); + window->DispatchEvent(*Event::Create(event_name)); + probe::NetworkStateChanged(window->GetFrame(), on_line); } void ContextDestroyed() override { @@ -727,7 +725,7 @@ write_recursion_is_too_deep_(false), write_recursion_depth_(0), scripted_animation_controller_( - MakeGarbageCollected<ScriptedAnimationController>(this)), + MakeGarbageCollected<ScriptedAnimationController>(domWindow())), current_frame_is_throttled_(false), registration_context_(initializer.RegistrationContext(this)), element_data_cache_clear_timer_( @@ -755,7 +753,7 @@ isolated_world_csp_map_( MakeGarbageCollected< HeapHashMap<int, Member<ContentSecurityPolicy>>>()), - permission_service_(this->ToExecutionContext()), + permission_service_(GetExecutionContext()), font_preload_manager_(*this) { security_initializer.ApplyPendingDataToDocument(*this); GetOriginTrialContext()->BindExecutionContext(GetExecutionContext()); @@ -777,10 +775,6 @@ if (registry && registration_context_) registry->Entangle(registration_context_); cookie_jar_ = MakeGarbageCollected<CookieJar>(this); - } else if (imports_controller_ && - !base::FeatureList::IsEnabled( - features::kHtmlImportsRequestInitiatorLock)) { - fetcher_ = FrameFetchContext::CreateFetcherForImportedDocument(this); } else { // We disable fetches for frame-less Documents, including HTML-imported // Documents (if kHtmlImportsRequestInitiatorLock is enabled). Subresources @@ -3196,7 +3190,8 @@ // Observer(s) should not be initialized until the document is initialized / // attached to a frame. Otherwise // ExecutionContextLifecycleObserver::contextDestroyed wouldn't be fired. - network_state_observer_ = MakeGarbageCollected<NetworkStateObserver>(*this); + network_state_observer_ = + MakeGarbageCollected<NetworkStateObserver>(GetExecutionContext()); // Check for frame_ so we only attach documents with its own scheduler. if (frame_)
diff --git a/third_party/blink/renderer/core/dom/document_test.cc b/third_party/blink/renderer/core/dom/document_test.cc index 8a4c4061..45832eb 100644 --- a/third_party/blink/renderer/core/dom/document_test.cc +++ b/third_party/blink/renderer/core/dom/document_test.cc
@@ -528,14 +528,14 @@ if (test.is_legacy) { // Legacy keyword support must be explicitly enabled for the policy to // parse successfully. - GetDocument().ToExecutionContext()->ParseAndSetReferrerPolicy( + GetDocument().GetExecutionContext()->ParseAndSetReferrerPolicy( test.policy); EXPECT_EQ(network::mojom::ReferrerPolicy::kDefault, GetDocument().GetReferrerPolicy()); - GetDocument().ToExecutionContext()->ParseAndSetReferrerPolicy(test.policy, - true); + GetDocument().GetExecutionContext()->ParseAndSetReferrerPolicy( + test.policy, true); } else { - GetDocument().ToExecutionContext()->ParseAndSetReferrerPolicy( + GetDocument().GetExecutionContext()->ParseAndSetReferrerPolicy( test.policy); } EXPECT_EQ(test.expected, GetDocument().GetReferrerPolicy()) << test.policy;
diff --git a/third_party/blink/renderer/core/dom/dom_string_map.h b/third_party/blink/renderer/core/dom/dom_string_map.h index 04d281d..5ae98a1 100644 --- a/third_party/blink/renderer/core/dom/dom_string_map.h +++ b/third_party/blink/renderer/core/dom/dom_string_map.h
@@ -47,15 +47,16 @@ const String& value, ExceptionState&) = 0; virtual bool DeleteItem(const String& name) = 0; - bool AnonymousNamedSetter(const String& name, - const String& value, - ExceptionState& exception_state) { + NamedPropertySetterResult AnonymousNamedSetter( + const String& name, + const String& value, + ExceptionState& exception_state) { SetItem(name, value, exception_state); - return true; + return NamedPropertySetterResult::kIntercepted; } - DeleteResult AnonymousNamedDeleter(const AtomicString& name) { - bool known_property = DeleteItem(name); - return known_property ? kDeleteSuccess : kDeleteUnknownProperty; + NamedPropertyDeleterResult AnonymousNamedDeleter(const AtomicString& name) { + return DeleteItem(name) ? NamedPropertyDeleterResult::kDeleted + : NamedPropertyDeleterResult::kDidNotIntercept; } void NamedPropertyEnumerator(Vector<String>& names, ExceptionState&) { GetNames(names);
diff --git a/third_party/blink/renderer/core/dom/element.cc b/third_party/blink/renderer/core/dom/element.cc index ef0f9bc0..2bcd4ad 100644 --- a/third_party/blink/renderer/core/dom/element.cc +++ b/third_party/blink/renderer/core/dom/element.cc
@@ -2264,7 +2264,7 @@ String trusted_value = TrustedTypesCheckFor(ExpectedTrustedTypeForAttribute(q_name), value, - GetDocument().ToExecutionContext(), exception_state); + GetExecutionContext(), exception_state); if (exception_state.HadException()) return; @@ -2292,7 +2292,7 @@ String trusted_value = TrustedTypesCheckFor(ExpectedTrustedTypeForAttribute(name), value, - GetDocument().ToExecutionContext(), exception_state); + GetExecutionContext(), exception_state); if (exception_state.HadException()) return; @@ -2324,9 +2324,9 @@ wtf_size_t index; QualifiedName q_name = QualifiedName::Null(); std::tie(index, q_name) = LookupAttributeQNameInternal(local_name); - String value = TrustedTypesCheckFor( - ExpectedTrustedTypeForAttribute(q_name), string_or_trusted, - GetDocument().ToExecutionContext(), exception_state); + String value = TrustedTypesCheckFor(ExpectedTrustedTypeForAttribute(q_name), + string_or_trusted, GetExecutionContext(), + exception_state); if (exception_state.HadException()) return; SetAttributeInternal(index, q_name, AtomicString(value), @@ -3907,7 +3907,7 @@ String value = TrustedTypesCheckFor( ExpectedTrustedTypeForAttribute(attr_node->GetQualifiedName()), - attr_node->value(), GetDocument().ToExecutionContext(), exception_state); + attr_node->value(), GetExecutionContext(), exception_state); if (exception_state.HadException()) return nullptr; @@ -4028,7 +4028,7 @@ String value = TrustedTypesCheckFor( ExpectedTrustedTypeForAttribute(parsed_name), string_or_trusted, - GetDocument().ToExecutionContext(), exception_state); + GetExecutionContext(), exception_state); if (exception_state.HadException()) return; @@ -4649,8 +4649,7 @@ void Element::setInnerHTML(const String& html, ExceptionState& exception_state) { - probe::BreakableLocation(GetDocument().ToExecutionContext(), - "Element.setInnerHTML"); + probe::BreakableLocation(GetExecutionContext(), "Element.setInnerHTML"); if (html.IsEmpty() && !HasNonInBodyInsertionMode()) { setTextContent(html); } else {
diff --git a/third_party/blink/renderer/core/dom/mutation_observer_test.cc b/third_party/blink/renderer/core/dom/mutation_observer_test.cc index f0220ca..9ee4b3d 100644 --- a/third_party/blink/renderer/core/dom/mutation_observer_test.cc +++ b/third_party/blink/renderer/core/dom/mutation_observer_test.cc
@@ -20,7 +20,7 @@ explicit EmptyMutationCallback(Document& document) : document_(document) {} ExecutionContext* GetExecutionContext() const override { - return document_->ToExecutionContext(); + return document_->GetExecutionContext(); } void Deliver(const MutationRecordVector&, MutationObserver&) override {}
diff --git a/third_party/blink/renderer/core/dom/node.cc b/third_party/blink/renderer/core/dom/node.cc index 7cbcc09..371f39cbe 100644 --- a/third_party/blink/renderer/core/dom/node.cc +++ b/third_party/blink/renderer/core/dom/node.cc
@@ -827,7 +827,7 @@ : node_or_string.GetAsNode()->textContent(); string_value = TrustedTypesCheckForScript( - string_value, document.ToExecutionContext(), exception_state); + string_value, document.GetExecutionContext(), exception_state); if (exception_state.HadException()) return nullptr; return Text::Create(document, string_value);
diff --git a/third_party/blink/renderer/core/dom/processing_instruction.cc b/third_party/blink/renderer/core/dom/processing_instruction.cc index 99f8064..be57801 100644 --- a/third_party/blink/renderer/core/dom/processing_instruction.cc +++ b/third_party/blink/renderer/core/dom/processing_instruction.cc
@@ -219,7 +219,7 @@ title_); } css_sheet->SetMediaQueries( - MediaQuerySet::Create(media_, GetDocument().ToExecutionContext())); + MediaQuerySet::Create(media_, GetExecutionContext())); sheet_ = css_sheet; // We don't need the cross-origin security check here because we are // getting the sheet text in "strict" mode. This enforces a valid CSS MIME
diff --git a/third_party/blink/renderer/core/dom/scripted_animation_controller.cc b/third_party/blink/renderer/core/dom/scripted_animation_controller.cc index ba4ef43..aec9aa6c 100644 --- a/third_party/blink/renderer/core/dom/scripted_animation_controller.cc +++ b/third_party/blink/renderer/core/dom/scripted_animation_controller.cc
@@ -58,9 +58,9 @@ } } -ScriptedAnimationController::ScriptedAnimationController(Document* document) - : ExecutionContextLifecycleStateObserver(document), - callback_collection_(document->ToExecutionContext()) { +ScriptedAnimationController::ScriptedAnimationController(LocalDOMWindow* window) + : ExecutionContextLifecycleStateObserver(window), + callback_collection_(window) { UpdateStateIfNeeded(); } @@ -160,8 +160,8 @@ } void ScriptedAnimationController::ExecuteVideoRafCallbacks() { - // dispatchEvents() runs script which can cause the document to be destroyed. - if (!GetDocument()) + // dispatchEvents() runs script which can cause the context to be destroyed. + if (!GetExecutionContext()) return; Vector<VideoRafExecutionCallback> video_raf_callbacks; @@ -171,8 +171,8 @@ } void ScriptedAnimationController::ExecuteFrameCallbacks() { - // dispatchEvents() runs script which can cause the document to be destroyed. - if (!GetDocument()) + // dispatchEvents() runs script which can cause the context to be destroyed. + if (!GetExecutionContext()) return; callback_collection_.ExecuteFrameCallbacks(current_frame_time_ms_, @@ -191,26 +191,24 @@ bool ScriptedAnimationController::HasScheduledFrameTasks() const { return callback_collection_.HasFrameCallback() || !task_queue_.IsEmpty() || !event_queue_.IsEmpty() || !media_query_list_listeners_.IsEmpty() || - GetDocument()->HasAutofocusCandidates() || !video_raf_queue_.IsEmpty(); + GetWindow()->document()->HasAutofocusCandidates() || + !video_raf_queue_.IsEmpty(); } void ScriptedAnimationController::ServiceScriptedAnimations( base::TimeTicks monotonic_time_now) { - if (!GetDocument() || !GetDocument()->Loader() || - GetDocument()->IsContextPaused()) { + if (!GetExecutionContext() || GetExecutionContext()->IsContextPaused()) return; - } + auto* loader = GetWindow()->document()->Loader(); + if (!loader) + return; current_frame_time_ms_ = - GetDocument() - ->Loader() - ->GetTiming() + loader->GetTiming() .MonotonicTimeToZeroBasedDocumentTime(monotonic_time_now) .InMillisecondsF(); current_frame_legacy_time_ms_ = - GetDocument() - ->Loader() - ->GetTiming() + loader->GetTiming() .MonotonicTimeToPseudoWallTime(monotonic_time_now) .InMillisecondsF(); current_frame_had_raf_ = HasFrameCallback(); @@ -223,7 +221,7 @@ // 10.5. For each fully active Document in docs, flush autofocus // candidates for that Document if its browsing context is a top-level // browsing context. - GetDocument()->FlushAutofocusCandidates(); + GetWindow()->document()->FlushAutofocusCandidates(); // 10.8. For each fully active Document in docs, evaluate media // queries and report changes for that Document, passing in now as the @@ -296,15 +294,17 @@ } void ScriptedAnimationController::ScheduleAnimationIfNeeded() { - if (!GetDocument() || !GetDocument()->GetFrame() || - GetDocument()->IsContextPaused()) { + if (!GetExecutionContext() || GetExecutionContext()->IsContextPaused()) return; - } + + auto* frame = GetWindow()->GetFrame(); + if (!frame) + return; // If there is any pre-frame work to do, schedule an animation // unconditionally. if (HasScheduledFrameTasks()) { - GetDocument()->View()->ScheduleAnimation(); + frame->View()->ScheduleAnimation(); return; } @@ -313,13 +313,13 @@ // scheduled post-frame tasks will get run at the end of the current frame, so // no need to schedule another one. if (callback_collection_.HasPostFrameCallback() && - !GetDocument()->GetPage()->Animator().IsServicingAnimations()) { - GetDocument()->View()->ScheduleAnimation(); + !frame->GetPage()->Animator().IsServicingAnimations()) { + frame->View()->ScheduleAnimation(); } } -Document* ScriptedAnimationController::GetDocument() const { - return Document::From(GetExecutionContext()); +LocalDOMWindow* ScriptedAnimationController::GetWindow() const { + return To<LocalDOMWindow>(GetExecutionContext()); } } // namespace blink
diff --git a/third_party/blink/renderer/core/dom/scripted_animation_controller.h b/third_party/blink/renderer/core/dom/scripted_animation_controller.h index c3dd17e..271781a 100644 --- a/third_party/blink/renderer/core/dom/scripted_animation_controller.h +++ b/third_party/blink/renderer/core/dom/scripted_animation_controller.h
@@ -39,9 +39,9 @@ namespace blink { -class Document; class Event; class EventTarget; +class LocalDOMWindow; class MediaQueryListListener; class CORE_EXPORT ScriptedAnimationController @@ -51,7 +51,7 @@ USING_GARBAGE_COLLECTED_MIXIN(ScriptedAnimationController); public: - explicit ScriptedAnimationController(Document*); + explicit ScriptedAnimationController(LocalDOMWindow*); ~ScriptedAnimationController() override = default; void Trace(Visitor*) override; @@ -117,7 +117,7 @@ bool HasScheduledFrameTasks() const; - Document* GetDocument() const; + LocalDOMWindow* GetWindow() const; ALWAYS_INLINE bool InsertToPerFrameEventsMap(const Event* event); ALWAYS_INLINE void EraseFromPerFrameEventsMap(const Event* event);
diff --git a/third_party/blink/renderer/core/dom/scripted_animation_controller_test.cc b/third_party/blink/renderer/core/dom/scripted_animation_controller_test.cc index 72057a2..e757b3d 100644 --- a/third_party/blink/renderer/core/dom/scripted_animation_controller_test.cc +++ b/third_party/blink/renderer/core/dom/scripted_animation_controller_test.cc
@@ -36,10 +36,10 @@ dummy_page_holder_ = std::make_unique<DummyPageHolder>(IntSize(800, 600)); // Note: The document doesn't know about this ScriptedAnimationController - // instance, and will create another if - // Document::ensureScriptedAnimationController is called. - controller_ = WrapPersistent( - MakeGarbageCollected<ScriptedAnimationController>(&GetDocument())); + // instance. + controller_ = + WrapPersistent(MakeGarbageCollected<ScriptedAnimationController>( + dummy_page_holder_->GetFrame().DomWindow())); } namespace {
diff --git a/third_party/blink/renderer/core/editing/commands/style_commands.cc b/third_party/blink/renderer/core/editing/commands/style_commands.cc index a92dd98..7d1900ad 100644 --- a/third_party/blink/renderer/core/editing/commands/style_commands.cc +++ b/third_party/blink/renderer/core/editing/commands/style_commands.cc
@@ -352,7 +352,7 @@ EditorCommandSource, const String& value) { frame.GetEditor().SetShouldStyleWithCSS( - !DeprecatedEqualIgnoringCase(value, "false")); + !EqualIgnoringASCIICase(value, "false")); return true; } @@ -361,7 +361,7 @@ EditorCommandSource, const String& value) { frame.GetEditor().SetShouldStyleWithCSS( - DeprecatedEqualIgnoringCase(value, "false")); + EqualIgnoringASCIICase(value, "false")); return true; }
diff --git a/third_party/blink/renderer/core/editing/dom_selection.cc b/third_party/blink/renderer/core/editing/dom_selection.cc index 9c12f4e..5c6960c 100644 --- a/third_party/blink/renderer/core/editing/dom_selection.cc +++ b/third_party/blink/renderer/core/editing/dom_selection.cc
@@ -422,7 +422,7 @@ SelectionModifyDirection direction; if (EqualIgnoringASCIICase(direction_string, "forward")) direction = SelectionModifyDirection::kForward; - else if (DeprecatedEqualIgnoringCase(direction_string, "backward")) + else if (EqualIgnoringASCIICase(direction_string, "backward")) direction = SelectionModifyDirection::kBackward; else if (EqualIgnoringASCIICase(direction_string, "left")) direction = SelectionModifyDirection::kLeft; @@ -436,7 +436,7 @@ granularity = TextGranularity::kCharacter; else if (EqualIgnoringASCIICase(granularity_string, "word")) granularity = TextGranularity::kWord; - else if (DeprecatedEqualIgnoringCase(granularity_string, "sentence")) + else if (EqualIgnoringASCIICase(granularity_string, "sentence")) granularity = TextGranularity::kSentence; else if (EqualIgnoringASCIICase(granularity_string, "line")) granularity = TextGranularity::kLine; @@ -444,7 +444,7 @@ granularity = TextGranularity::kParagraph; else if (EqualIgnoringASCIICase(granularity_string, "lineboundary")) granularity = TextGranularity::kLineBoundary; - else if (DeprecatedEqualIgnoringCase(granularity_string, "sentenceboundary")) + else if (EqualIgnoringASCIICase(granularity_string, "sentenceboundary")) granularity = TextGranularity::kSentenceBoundary; else if (EqualIgnoringASCIICase(granularity_string, "paragraphboundary")) granularity = TextGranularity::kParagraphBoundary;
diff --git a/third_party/blink/renderer/core/editing/spellcheck/spell_checker.cc b/third_party/blink/renderer/core/editing/spellcheck/spell_checker.cc index 3c4abdb..b2199ba 100644 --- a/third_party/blink/renderer/core/editing/spellcheck/spell_checker.cc +++ b/third_party/blink/renderer/core/editing/spellcheck/spell_checker.cc
@@ -221,7 +221,9 @@ FindFirstMisspelling(spelling_search_start, spelling_search_end); } - if (!misspelled_word.IsEmpty()) { + if (misspelled_word.IsEmpty()) { + SpellCheckPanelHostClient().UpdateSpellingUIWithMisspelledWord({}); + } else { // We found a misspelling. Select the misspelling, update the spelling // panel, and store a marker so we draw the red squiggle later.
diff --git a/third_party/blink/renderer/core/exported/web_external_widget_impl.cc b/third_party/blink/renderer/core/exported/web_external_widget_impl.cc index 4cb9b8e..c755f17 100644 --- a/third_party/blink/renderer/core/exported/web_external_widget_impl.cc +++ b/third_party/blink/renderer/core/exported/web_external_widget_impl.cc
@@ -5,6 +5,7 @@ #include "third_party/blink/renderer/core/exported/web_external_widget_impl.h" #include "cc/trees/layer_tree_host.h" +#include "third_party/blink/renderer/platform/widget/widget_base.h" namespace blink { @@ -28,7 +29,9 @@ widget) : client_(client), debug_url_(debug_url), - widget_base_(this, std::move(widget_host), std::move(widget)) { + widget_base_(std::make_unique<WidgetBase>(this, + std::move(widget_host), + std::move(widget))) { DCHECK(client_); } @@ -37,7 +40,19 @@ void WebExternalWidgetImpl::SetCompositorHosts( cc::LayerTreeHost* layer_tree_host, cc::AnimationHost* animation_host) { - widget_base_.SetCompositorHosts(layer_tree_host, animation_host); + widget_base_->SetCompositorHosts(layer_tree_host, animation_host); +} + +void WebExternalWidgetImpl::SetCompositorVisible(bool visible) { + widget_base_->SetCompositorVisible(visible); +} + +void WebExternalWidgetImpl::UpdateVisualState() { + widget_base_->UpdateVisualState(); +} + +void WebExternalWidgetImpl::WillBeginCompositorFrame() { + widget_base_->WillBeginCompositorFrame(); } WebHitTestResult WebExternalWidgetImpl::HitTestResultAt(const gfx::Point&) { @@ -70,7 +85,12 @@ } void WebExternalWidgetImpl::SetRootLayer(scoped_refptr<cc::Layer> layer) { - widget_base_.LayerTreeHost()->SetNonBlinkManagedRootLayer(layer); + widget_base_->LayerTreeHost()->SetNonBlinkManagedRootLayer(layer); +} + +void WebExternalWidgetImpl::RecordTimeToFirstActivePaint( + base::TimeDelta duration) { + client_->RecordTimeToFirstActivePaint(duration); } } // namespace blink
diff --git a/third_party/blink/renderer/core/exported/web_external_widget_impl.h b/third_party/blink/renderer/core/exported/web_external_widget_impl.h index 14d6cda..7f014b6 100644 --- a/third_party/blink/renderer/core/exported/web_external_widget_impl.h +++ b/third_party/blink/renderer/core/exported/web_external_widget_impl.h
@@ -7,11 +7,13 @@ #include "third_party/blink/public/web/web_external_widget.h" +#include "third_party/blink/public/mojom/page/widget.mojom-blink.h" +#include "third_party/blink/public/platform/cross_variant_mojo_util.h" #include "third_party/blink/public/platform/web_url.h" -#include "third_party/blink/renderer/platform/widget/widget_base.h" #include "third_party/blink/renderer/platform/widget/widget_base_client.h" namespace blink { +class WidgetBase; class WebExternalWidgetImpl : public WebExternalWidget, public WidgetBaseClient { @@ -27,6 +29,9 @@ // WebWidget overrides: void SetCompositorHosts(cc::LayerTreeHost*, cc::AnimationHost*) override; + void SetCompositorVisible(bool visible) override; + void UpdateVisualState() override; + void WillBeginCompositorFrame() override; WebHitTestResult HitTestResultAt(const gfx::Point&) override; WebURL GetURLForDebugTrace() override; WebSize Size() override; @@ -41,12 +46,15 @@ // WidgetBaseClient overrides: void DispatchRafAlignedInput(base::TimeTicks frame_time) override {} void BeginMainFrame(base::TimeTicks last_frame_time) override {} + void RecordTimeToFirstActivePaint(base::TimeDelta duration) override; + void UpdateLifecycle(WebLifecycleUpdate requested_update, + DocumentUpdateReason reason) override {} private: WebExternalWidgetClient* const client_; const WebURL debug_url_; WebSize size_; - WidgetBase widget_base_; + std::unique_ptr<WidgetBase> widget_base_; }; } // namespace blink
diff --git a/third_party/blink/renderer/core/exported/web_page_popup_impl.cc b/third_party/blink/renderer/core/exported/web_page_popup_impl.cc index e62bec5b..68313af 100644 --- a/third_party/blink/renderer/core/exported/web_page_popup_impl.cc +++ b/third_party/blink/renderer/core/exported/web_page_popup_impl.cc
@@ -69,6 +69,7 @@ #include "third_party/blink/renderer/platform/keyboard_codes.h" #include "third_party/blink/renderer/platform/text/text_direction.h" #include "third_party/blink/renderer/platform/web_test_support.h" +#include "third_party/blink/renderer/platform/widget/widget_base.h" namespace blink { @@ -155,13 +156,13 @@ void AttachCompositorAnimationTimeline(CompositorAnimationTimeline* timeline, LocalFrame*) override { - popup_->widget_base_.AnimationHost()->AddAnimationTimeline( + popup_->widget_base_->AnimationHost()->AddAnimationTimeline( timeline->GetAnimationTimeline()); } void DetachCompositorAnimationTimeline(CompositorAnimationTimeline* timeline, LocalFrame*) override { - popup_->widget_base_.AnimationHost()->RemoveAnimationTimeline( + popup_->widget_base_->AnimationHost()->RemoveAnimationTimeline( timeline->GetAnimationTimeline()); } @@ -251,7 +252,9 @@ CrossVariantMojoAssociatedReceiver<mojom::blink::WidgetInterfaceBase> widget) : web_page_popup_client_(client), - widget_base_(this, std::move(widget_host), std::move(widget)) { + widget_base_(std::make_unique<WidgetBase>(this, + std::move(widget_host), + std::move(widget))) { DCHECK(client); } @@ -311,7 +314,7 @@ cache->ChildrenChanged(&popup_client_->OwnerElement()); } - page_->AnimationHostInitialized(*widget_base_.AnimationHost(), nullptr); + page_->AnimationHostInitialized(*widget_base_->AnimationHost(), nullptr); scoped_refptr<SharedBuffer> data = SharedBuffer::Create(); popup_client_->WriteDocument(data.get()); @@ -326,7 +329,19 @@ cc::AnimationHost* animation_host) { // Careful Initialize() is called after SetCompositorHosts, so don't do // much work here. - widget_base_.SetCompositorHosts(layer_tree_host, animation_host); + widget_base_->SetCompositorHosts(layer_tree_host, animation_host); +} + +void WebPagePopupImpl::SetCompositorVisible(bool visible) { + widget_base_->SetCompositorVisible(visible); +} + +void WebPagePopupImpl::UpdateVisualState() { + widget_base_->UpdateVisualState(); +} + +void WebPagePopupImpl::WillBeginCompositorFrame() { + widget_base_->WillBeginCompositorFrame(); } void WebPagePopupImpl::PostMessageToPopup(const String& message) { @@ -361,7 +376,7 @@ void WebPagePopupImpl::SetRootLayer(scoped_refptr<cc::Layer> layer) { root_layer_ = std::move(layer); - widget_base_.LayerTreeHost()->SetRootLayer(root_layer_); + widget_base_->LayerTreeHost()->SetRootLayer(root_layer_); } void WebPagePopupImpl::SetSuppressFrameRequestsWorkaroundFor704763Only( @@ -373,7 +388,11 @@ } void WebPagePopupImpl::BeginFrame(base::TimeTicks last_frame_time) { - widget_base_.BeginMainFrame(last_frame_time); + widget_base_->BeginMainFrame(last_frame_time); +} + +void WebPagePopupImpl::RecordTimeToFirstActivePaint(base::TimeDelta duration) { + WidgetClient()->RecordTimeToFirstActivePaint(duration); } void WebPagePopupImpl::UpdateLifecycle(WebLifecycleUpdate requested_update, @@ -552,7 +571,7 @@ } web_page_popup_client_ = nullptr; - SetCompositorHosts(nullptr, nullptr); + widget_base_.reset(); // Self-delete on Close(). Release();
diff --git a/third_party/blink/renderer/core/exported/web_page_popup_impl.h b/third_party/blink/renderer/core/exported/web_page_popup_impl.h index 5d89fd3..fbdb7bad 100644 --- a/third_party/blink/renderer/core/exported/web_page_popup_impl.h +++ b/third_party/blink/renderer/core/exported/web_page_popup_impl.h
@@ -32,12 +32,13 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_EXPORTED_WEB_PAGE_POPUP_IMPL_H_ #include "base/macros.h" +#include "third_party/blink/public/mojom/page/widget.mojom-blink.h" +#include "third_party/blink/public/platform/cross_variant_mojo_util.h" #include "third_party/blink/public/web/web_page_popup.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/page/page_popup.h" #include "third_party/blink/renderer/core/page/page_widget_delegate.h" #include "third_party/blink/renderer/platform/heap/persistent.h" -#include "third_party/blink/renderer/platform/widget/widget_base.h" #include "third_party/blink/renderer/platform/widget/widget_base_client.h" #include "third_party/blink/renderer/platform/wtf/casting.h" #include "third_party/blink/renderer/platform/wtf/ref_counted.h" @@ -53,6 +54,7 @@ class PagePopupClient; class WebViewImpl; class LocalDOMWindow; +class WidgetBase; class CORE_EXPORT WebPagePopupImpl final : public WebPagePopup, public PageWidgetEventHandler, @@ -98,6 +100,9 @@ // WebWidget implementation. WebInputEventResult DispatchBufferedTouchEvents() override; + void SetCompositorVisible(bool visible) override; + void UpdateVisualState() override; + void WillBeginCompositorFrame() override; // WebPagePopup implementation. gfx::Point PositionRelativeToOwner() override; @@ -110,11 +115,13 @@ // PageWidgetEventHandler implementation. WebInputEventResult HandleKeyEvent(const WebKeyboardEvent&) override; + private: // WidgetBaseClient overrides: void DispatchRafAlignedInput(base::TimeTicks frame_time) override; void BeginMainFrame(base::TimeTicks last_frame_time) override; + void RecordTimeToFirstActivePaint(base::TimeDelta duration) override; + void SetSuppressFrameRequestsWorkaroundFor704763Only(bool) final; - private: // WebWidget implementation. // NOTE: The WebWidget may still be used after requesting the popup to be // closed and destroyed. But the Page and the MainFrame are destroyed @@ -122,7 +129,6 @@ // of the WebWidget need to check if close has already been initiated (they // can do so by checking |page_|) and not crash! https://crbug.com/906340 void SetCompositorHosts(cc::LayerTreeHost*, cc::AnimationHost*) override; - void SetSuppressFrameRequestsWorkaroundFor704763Only(bool) final; void BeginFrame(base::TimeTicks last_frame_time) override; void UpdateLifecycle(WebLifecycleUpdate requested_update, DocumentUpdateReason reason) override; @@ -181,7 +187,7 @@ // Base functionality all widgets have. This is a member as to avoid // complicated inheritance structures. - WidgetBase widget_base_; + std::unique_ptr<WidgetBase> widget_base_; friend class WebPagePopup; friend class PagePopupChromeClient;
diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc index 2706aa2..f7ab37c 100644 --- a/third_party/blink/renderer/core/exported/web_view_impl.cc +++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
@@ -161,6 +161,7 @@ #include "third_party/blink/renderer/platform/scheduler/public/page_scheduler.h" #include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h" #include "third_party/blink/renderer/platform/weborigin/scheme_registry.h" +#include "third_party/blink/renderer/platform/widget/widget_base.h" #include "ui/gfx/skia_util.h" @@ -1506,7 +1507,7 @@ MainFrameImpl()->GetFrame()->GetDocument()->Lifecycle()); base::Optional<LocalFrameUkmAggregator::ScopedUkmHierarchicalTimer> ukm_timer; - if (WebFrameWidgetBase::ShouldRecordMainFrameMetrics()) { + if (WidgetBase::ShouldRecordBeginMainFrameMetrics()) { ukm_timer.emplace(MainFrameImpl() ->GetFrame() ->View()
diff --git a/third_party/blink/renderer/core/exported/web_view_impl.h b/third_party/blink/renderer/core/exported/web_view_impl.h index da22a08..d717113 100644 --- a/third_party/blink/renderer/core/exported/web_view_impl.h +++ b/third_party/blink/renderer/core/exported/web_view_impl.h
@@ -208,14 +208,20 @@ base::TimeTicks navigation_start) override; WebFrameWidget* MainFrameWidget() override; void SetBaseBackgroundColor(SkColor) override; - void SetBackgroundColorOverride(SkColor) override; - void ClearBackgroundColorOverride() override; - void SetBaseBackgroundColorOverride(SkColor) override; - void ClearBaseBackgroundColorOverride() override; void SetInsidePortal(bool inside_portal) override; void PaintContent(cc::PaintCanvas*, const gfx::Rect&) override; void SetTextAutosizerPageInfo(const WebTextAutosizerPageInfo&) override; + // Overrides the page's background and base background color. You + // can use this to enforce a transparent background, which is useful if you + // want to have some custom background rendered behind the widget. + // + // These may are only called for composited WebViews. + void SetBackgroundColorOverride(SkColor); + void ClearBackgroundColorOverride(); + void SetBaseBackgroundColorOverride(SkColor); + void ClearBaseBackgroundColorOverride(); + // Requests a page-scale animation based on the specified point/rect. void AnimateDoubleTapZoom(const gfx::Point&, const WebRect& block_bounds);
diff --git a/third_party/blink/renderer/core/exported/web_view_test.cc b/third_party/blink/renderer/core/exported/web_view_test.cc index d11d0f3..558c9b1 100644 --- a/third_party/blink/renderer/core/exported/web_view_test.cc +++ b/third_party/blink/renderer/core/exported/web_view_test.cc
@@ -527,6 +527,7 @@ CrossVariantMojoAssociatedReceiver<mojom::WidgetInterfaceBase>()); widget->SetCompositorHosts(web_widget_client.layer_tree_host(), web_widget_client.animation_host()); + widget->SetCompositorVisible(true); web_view->DidAttachLocalMainFrame(); }
diff --git a/third_party/blink/renderer/core/frame/frame_serializer.cc b/third_party/blink/renderer/core/frame/frame_serializer.cc index 137d066..eabf1e1 100644 --- a/third_party/blink/renderer/core/frame/frame_serializer.cc +++ b/third_party/blink/renderer/core/frame/frame_serializer.cc
@@ -30,10 +30,8 @@ #include "third_party/blink/renderer/core/frame/frame_serializer.h" -#include "base/feature_list.h" #include "base/metrics/histogram.h" #include "base/metrics/histogram_functions.h" -#include "third_party/blink/public/common/features.h" #include "third_party/blink/renderer/core/css/css_font_face_rule.h" #include "third_party/blink/renderer/core/css/css_font_face_src_value.h" #include "third_party/blink/renderer/core/css/css_image_value.h" @@ -622,9 +620,7 @@ if (font_face_src_value->IsLocal()) return; - if (base::FeatureList::IsEnabled( - features::kHtmlImportsRequestInitiatorLock) && - document.ImportsController()) { + if (document.ImportsController()) { if (Document* context_document = document.ContextDocument()) { // For @imports from HTML imported Documents, we use the // context document for getting origin and ResourceFetcher to use the
diff --git a/third_party/blink/renderer/core/frame/local_frame_view.cc b/third_party/blink/renderer/core/frame/local_frame_view.cc index bd47439..29deb6f7 100644 --- a/third_party/blink/renderer/core/frame/local_frame_view.cc +++ b/third_party/blink/renderer/core/frame/local_frame_view.cc
@@ -2166,42 +2166,50 @@ // phase of this cycle. } -void LocalFrameView::NotifyResizeObservers() { +bool LocalFrameView::NotifyResizeObservers( + DocumentLifecycle::LifecycleState target_state) { + // Return true if lifecycles need to be re-run TRACE_EVENT0("blink,benchmark", "LocalFrameView::NotifyResizeObservers"); + + if (target_state < DocumentLifecycle::kPaintClean) + return false; + // Controller exists only if ResizeObserver was created. if (!GetFrame().GetDocument()->GetResizeObserverController()) - return; + return false; ResizeObserverController& resize_controller = frame_->GetDocument()->EnsureResizeObserverController(); - DCHECK(Lifecycle().GetState() >= DocumentLifecycle::kLayoutClean); + DCHECK(Lifecycle().GetState() >= DocumentLifecycle::kPrePaintClean); - size_t min_depth = 0; - for (min_depth = resize_controller.GatherObservations(0); - min_depth != ResizeObserverController::kDepthBottom; - min_depth = resize_controller.GatherObservations(min_depth)) { + size_t min_depth = resize_controller.GatherObservations(); + + if (min_depth != ResizeObserverController::kDepthBottom) { resize_controller.DeliverObservations(); - GetFrame().GetDocument()->UpdateStyleAndLayout( - DocumentUpdateReason::kSizeChange); + } else { + // Observation depth limit reached + if (resize_controller.SkippedObservations()) { + resize_controller.ClearObservations(); + ErrorEvent* error = ErrorEvent::Create( + "ResizeObserver loop limit exceeded", + SourceLocation::Capture(frame_->GetDocument()->ToExecutionContext()), + nullptr); + // We're using |SanitizeScriptErrors::kDoNotSanitize| as the error is made + // by blink itself. + // TODO(yhirano): Reconsider this. + frame_->GetDocument()->ToExecutionContext()->DispatchErrorEvent( + error, SanitizeScriptErrors::kDoNotSanitize); + // Ensure notifications will get delivered in next cycle. + ScheduleAnimation(); + DCHECK(Lifecycle().GetState() >= DocumentLifecycle::kPrePaintClean); + } + if (Lifecycle().GetState() >= DocumentLifecycle::kPrePaintClean) + return false; } - if (resize_controller.SkippedObservations()) { - resize_controller.ClearObservations(); - ErrorEvent* error = ErrorEvent::Create( - "ResizeObserver loop limit exceeded", - SourceLocation::Capture(frame_->GetDocument()->ToExecutionContext()), - nullptr); - // We're using |SanitizeScriptErrors::kDoNotSanitize| as the error is made - // by blink itself. - // TODO(yhirano): Reconsider this. - frame_->GetDocument()->ToExecutionContext()->DispatchErrorEvent( - error, SanitizeScriptErrors::kDoNotSanitize); - // Ensure notifications will get delivered in next cycle. - ScheduleAnimation(); - } - - DCHECK(!GetLayoutView()->NeedsLayout()); + // Lifecycle needs to be run again because Resize Observer affected layout + return true; } // TODO(leviw): We don't assert lifecycle information from documents in child @@ -2309,39 +2317,56 @@ void LocalFrameView::UpdateLifecyclePhasesInternal( DocumentLifecycle::LifecycleState target_state) { - bool run_more_lifecycle_phases = - RunStyleAndLayoutLifecyclePhases(target_state); - if (!run_more_lifecycle_phases) - return; - DCHECK(Lifecycle().GetState() >= DocumentLifecycle::kLayoutClean); + // Run style, layout, compositing and prepaint lifecycle phases and deliver + // resize observations if required. Resize observer callbacks/delegates have + // the potential to dirty layout (until loop limit is reached) and therefore + // the above lifecycle phases need to be re-run until the limit is reached + // or no layout is pending. + while (true) { + bool run_more_lifecycle_phases = + RunStyleAndLayoutLifecyclePhases(target_state); + if (!run_more_lifecycle_phases) + return; + DCHECK(Lifecycle().GetState() >= DocumentLifecycle::kLayoutClean); - if (!GetLayoutView()) - return; + if (!GetLayoutView()) + return; + { + // We need scoping braces here because this + // DisallowLayoutInvalidationScope is meant to be in effect during + // pre-paint, but not during ResizeObserver. +#if DCHECK_IS_ON() + DisallowLayoutInvalidationScope disallow_layout_invalidation(this); +#endif + TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), + "SetLayerTreeId", TRACE_EVENT_SCOPE_THREAD, "data", + inspector_set_layer_tree_id::Data(frame_.Get())); + TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", + inspector_update_layer_tree_event::Data(frame_.Get())); + + run_more_lifecycle_phases = RunCompositingLifecyclePhase(target_state); + if (!run_more_lifecycle_phases) + return; + + // TODO(pdr): PrePaint should be under the "Paint" devtools timeline step + // when CompositeAfterPaint is enabled. + run_more_lifecycle_phases = RunPrePaintLifecyclePhase(target_state); + DCHECK(ShouldThrottleRendering() || + Lifecycle().GetState() >= DocumentLifecycle::kPrePaintClean); + if (!run_more_lifecycle_phases) + return; + } + + run_more_lifecycle_phases = RunResizeObserverSteps(target_state); + if (!run_more_lifecycle_phases) + break; + } + // Layout invalidation scope was disabled for resize observer + // re-enable it for subsequent steps #if DCHECK_IS_ON() DisallowLayoutInvalidationScope disallow_layout_invalidation(this); #endif - - { - TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), - "SetLayerTreeId", TRACE_EVENT_SCOPE_THREAD, "data", - inspector_set_layer_tree_id::Data(frame_.Get())); - TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", - inspector_update_layer_tree_event::Data(frame_.Get())); - - run_more_lifecycle_phases = RunCompositingLifecyclePhase(target_state); - if (!run_more_lifecycle_phases) - return; - - // TODO(pdr): PrePaint should be under the "Paint" devtools timeline step - // when CompositeAfterPaint is enabled. - run_more_lifecycle_phases = RunPrePaintLifecyclePhase(target_state); - DCHECK(ShouldThrottleRendering() || - Lifecycle().GetState() >= DocumentLifecycle::kPrePaintClean); - if (!run_more_lifecycle_phases) - return; - } - // Now that we have run the lifecycle up to paint, we can reset // |need_paint_phase_after_throttling_| so that the paint phase will // properly see us as being throttled (if that was the only reason we remained @@ -2358,6 +2383,27 @@ [](RemoteFrameView& frame_view) { frame_view.UpdateCompositingRect(); }); } +bool LocalFrameView::RunResizeObserverSteps( + DocumentLifecycle::LifecycleState target_state) { + bool re_run_lifecycles = false; + if (target_state == DocumentLifecycle::kPaintClean) { + ForAllNonThrottledLocalFrameViews( + [&re_run_lifecycles](LocalFrameView& frame_view) { + bool result = + frame_view.NotifyResizeObservers(DocumentLifecycle::kPaintClean); + re_run_lifecycles = re_run_lifecycles || result; + }); + } + if (!re_run_lifecycles) { + ForAllNonThrottledLocalFrameViews([](LocalFrameView& frame_view) { + ResizeObserverController& resize_controller = + frame_view.frame_->GetDocument()->EnsureResizeObserverController(); + resize_controller.ClearMinDepth(); + }); + } + return re_run_lifecycles; +} + bool LocalFrameView::RunStyleAndLayoutLifecyclePhases( DocumentLifecycle::LifecycleState target_state) { TRACE_EVENT0("blink,benchmark", @@ -2409,18 +2455,11 @@ frame_->GetPage()->GetValidationMessageClient().LayoutOverlay(); if (target_state == DocumentLifecycle::kPaintClean) { - ForAllNonThrottledLocalFrameViews( - [](LocalFrameView& frame_view) { frame_view.NotifyResizeObservers(); }); - ForAllNonThrottledLocalFrameViews([](LocalFrameView& frame_view) { frame_view.NotifyFrameRectsChangedIfNeeded(); }); } - // If we exceed the number of re-layouts during ResizeObserver notifications, - // then we shouldn't continue with the lifecycle updates. At that time, we - // have scheduled an animation and we'll try again. - DCHECK(Lifecycle().GetState() >= DocumentLifecycle::kLayoutClean || - Lifecycle().GetState() == DocumentLifecycle::kVisualUpdatePending); + return Lifecycle().GetState() >= DocumentLifecycle::kLayoutClean; }
diff --git a/third_party/blink/renderer/core/frame/local_frame_view.h b/third_party/blink/renderer/core/frame/local_frame_view.h index 33c66bbf8..6068d82 100644 --- a/third_party/blink/renderer/core/frame/local_frame_view.h +++ b/third_party/blink/renderer/core/frame/local_frame_view.h
@@ -824,7 +824,8 @@ bool UpdateViewportIntersectionsForSubtree(unsigned parent_flags) override; void DeliverSynchronousIntersectionObservations(); - void NotifyResizeObservers(); + bool NotifyResizeObservers(DocumentLifecycle::LifecycleState target_state); + bool RunResizeObserverSteps(DocumentLifecycle::LifecycleState target_state); bool CheckLayoutInvalidationIsAllowed() const;
diff --git a/third_party/blink/renderer/core/frame/web_frame_widget_base.cc b/third_party/blink/renderer/core/frame/web_frame_widget_base.cc index e8a7a23c..5125246 100644 --- a/third_party/blink/renderer/core/frame/web_frame_widget_base.cc +++ b/third_party/blink/renderer/core/frame/web_frame_widget_base.cc
@@ -40,6 +40,7 @@ #include "third_party/blink/renderer/platform/graphics/compositor_mutator_client.h" #include "third_party/blink/renderer/platform/graphics/paint_worklet_paint_dispatcher.h" #include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h" +#include "third_party/blink/renderer/platform/widget/widget_base.h" #include "third_party/blink/renderer/platform/wtf/assertions.h" #include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h" @@ -77,7 +78,9 @@ widget_host, CrossVariantMojoAssociatedReceiver<mojom::blink::WidgetInterfaceBase> widget) - : widget_base_(this, std::move(widget_host), std::move(widget)), + : widget_base_(std::make_unique<WidgetBase>(this, + std::move(widget_host), + std::move(widget))), client_(&client), frame_widget_host_(std::move(frame_widget_host)), receiver_(this, std::move(frame_widget)) {} @@ -99,7 +102,7 @@ local_root_ = nullptr; client_ = nullptr; request_animation_after_delay_timer_.reset(); - widget_base_.SetCompositorHosts(nullptr, nullptr); + widget_base_.reset(); } WebLocalFrame* WebFrameWidgetBase::LocalRoot() const { @@ -260,6 +263,16 @@ CancelDrag(); } +void WebFrameWidgetBase::SetBackgroundOpaque(bool opaque) { + if (opaque) { + View()->ClearBaseBackgroundColorOverride(); + View()->ClearBackgroundColorOverride(); + } else { + View()->SetBaseBackgroundColorOverride(SK_ColorTRANSPARENT); + View()->SetBackgroundColorOverride(SK_ColorTRANSPARENT); + } +} + void WebFrameWidgetBase::CancelDrag() { // It's possible for this to be called while we're not doing a drag if // it's from a previous page that got unloaded. @@ -382,33 +395,29 @@ visitor->Trace(current_drag_data_); } -bool WebFrameWidgetBase::ShouldRecordMainFrameMetrics() { - return !!Thread::CompositorThread(); -} - void WebFrameWidgetBase::SetNeedsRecalculateRasterScales() { if (!View()->does_composite()) return; - widget_base_.LayerTreeHost()->SetNeedsRecalculateRasterScales(); + widget_base_->LayerTreeHost()->SetNeedsRecalculateRasterScales(); } void WebFrameWidgetBase::SetBackgroundColor(SkColor color) { if (!View()->does_composite()) return; - widget_base_.LayerTreeHost()->set_background_color(color); + widget_base_->LayerTreeHost()->set_background_color(color); } void WebFrameWidgetBase::SetOverscrollBehavior( const cc::OverscrollBehavior& overscroll_behavior) { if (!View()->does_composite()) return; - widget_base_.LayerTreeHost()->SetOverscrollBehavior(overscroll_behavior); + widget_base_->LayerTreeHost()->SetOverscrollBehavior(overscroll_behavior); } void WebFrameWidgetBase::RegisterSelection(cc::LayerSelection selection) { if (!View()->does_composite()) return; - widget_base_.LayerTreeHost()->RegisterSelection(selection); + widget_base_->LayerTreeHost()->RegisterSelection(selection); } void WebFrameWidgetBase::StartPageScaleAnimation( @@ -416,75 +425,75 @@ bool use_anchor, float new_page_scale, base::TimeDelta duration) { - widget_base_.LayerTreeHost()->StartPageScaleAnimation( + widget_base_->LayerTreeHost()->StartPageScaleAnimation( destination, use_anchor, new_page_scale, duration); } void WebFrameWidgetBase::RequestBeginMainFrameNotExpected(bool request) { if (!View()->does_composite()) return; - widget_base_.LayerTreeHost()->RequestBeginMainFrameNotExpected(request); + widget_base_->LayerTreeHost()->RequestBeginMainFrameNotExpected(request); } int WebFrameWidgetBase::GetLayerTreeId() { if (!View()->does_composite()) return 0; - return widget_base_.LayerTreeHost()->GetId(); + return widget_base_->LayerTreeHost()->GetId(); } void WebFrameWidgetBase::SetHaveScrollEventHandlers(bool has_handlers) { - widget_base_.LayerTreeHost()->SetHaveScrollEventHandlers(has_handlers); + widget_base_->LayerTreeHost()->SetHaveScrollEventHandlers(has_handlers); } void WebFrameWidgetBase::SetEventListenerProperties( cc::EventListenerClass listener_class, cc::EventListenerProperties listener_properties) { - widget_base_.LayerTreeHost()->SetEventListenerProperties(listener_class, - listener_properties); + widget_base_->LayerTreeHost()->SetEventListenerProperties( + listener_class, listener_properties); } cc::EventListenerProperties WebFrameWidgetBase::EventListenerProperties( cc::EventListenerClass listener_class) const { - return widget_base_.LayerTreeHost()->event_listener_properties( + return widget_base_->LayerTreeHost()->event_listener_properties( listener_class); } void WebFrameWidgetBase::StartDeferringCommits(base::TimeDelta timeout) { if (!View()->does_composite()) return; - widget_base_.LayerTreeHost()->StartDeferringCommits(timeout); + widget_base_->LayerTreeHost()->StartDeferringCommits(timeout); } void WebFrameWidgetBase::StopDeferringCommits( cc::PaintHoldingCommitTrigger triggger) { if (!View()->does_composite()) return; - widget_base_.LayerTreeHost()->StopDeferringCommits(triggger); + widget_base_->LayerTreeHost()->StopDeferringCommits(triggger); } std::unique_ptr<cc::ScopedDeferMainFrameUpdate> WebFrameWidgetBase::DeferMainFrameUpdate() { - return widget_base_.LayerTreeHost()->DeferMainFrameUpdate(); + return widget_base_->LayerTreeHost()->DeferMainFrameUpdate(); } void WebFrameWidgetBase::SetBrowserControlsShownRatio(float top_ratio, float bottom_ratio) { - widget_base_.LayerTreeHost()->SetBrowserControlsShownRatio(top_ratio, - bottom_ratio); + widget_base_->LayerTreeHost()->SetBrowserControlsShownRatio(top_ratio, + bottom_ratio); } void WebFrameWidgetBase::SetBrowserControlsParams( cc::BrowserControlsParams params) { - widget_base_.LayerTreeHost()->SetBrowserControlsParams(params); + widget_base_->LayerTreeHost()->SetBrowserControlsParams(params); } cc::LayerTreeDebugState WebFrameWidgetBase::GetLayerTreeDebugState() { - return widget_base_.LayerTreeHost()->GetDebugState(); + return widget_base_->LayerTreeHost()->GetDebugState(); } void WebFrameWidgetBase::SetLayerTreeDebugState( const cc::LayerTreeDebugState& state) { - widget_base_.LayerTreeHost()->SetDebugState(state); + widget_base_->LayerTreeHost()->SetDebugState(state); } // TODO(665924): Remove direct dispatches of mouse events from @@ -568,24 +577,41 @@ void WebFrameWidgetBase::SetCompositorHosts(cc::LayerTreeHost* layer_tree_host, cc::AnimationHost* animation_host) { - widget_base_.SetCompositorHosts(layer_tree_host, animation_host); + widget_base_->SetCompositorHosts(layer_tree_host, animation_host); GetPage()->AnimationHostInitialized(*AnimationHost(), GetLocalFrameViewForAnimationScrolling()); } +void WebFrameWidgetBase::SetCompositorVisible(bool visible) { + widget_base_->SetCompositorVisible(visible); +} + +void WebFrameWidgetBase::UpdateVisualState() { + widget_base_->UpdateVisualState(); +} + +void WebFrameWidgetBase::RecordTimeToFirstActivePaint( + base::TimeDelta duration) { + Client()->RecordTimeToFirstActivePaint(duration); +} + void WebFrameWidgetBase::BeginFrame(base::TimeTicks frame_time) { - widget_base_.BeginMainFrame(frame_time); + widget_base_->BeginMainFrame(frame_time); +} + +void WebFrameWidgetBase::WillBeginCompositorFrame() { + widget_base_->WillBeginCompositorFrame(); } void WebFrameWidgetBase::DispatchRafAlignedInput(base::TimeTicks frame_time) { base::TimeTicks raf_aligned_input_start_time; - if (LocalRootImpl() && ShouldRecordMainFrameMetrics()) { + if (LocalRootImpl() && WidgetBase::ShouldRecordBeginMainFrameMetrics()) { raf_aligned_input_start_time = base::TimeTicks::Now(); } Client()->DispatchRafAlignedInput(frame_time); - if (LocalRootImpl() && ShouldRecordMainFrameMetrics()) { + if (LocalRootImpl() && WidgetBase::ShouldRecordBeginMainFrameMetrics()) { LocalRootImpl()->GetFrame()->View()->EnsureUkmAggregator().RecordSample( LocalFrameUkmAggregator::kHandleInputEvents, raf_aligned_input_start_time, base::TimeTicks::Now()); @@ -621,7 +647,7 @@ WebFrameWidgetBase::EnsureCompositorMutatorDispatcher( scoped_refptr<base::SingleThreadTaskRunner>* mutator_task_runner) { if (!mutator_task_runner_) { - widget_base_.LayerTreeHost()->SetLayerTreeMutator( + widget_base_->LayerTreeHost()->SetLayerTreeMutator( AnimationWorkletMutatorDispatcherImpl::CreateCompositorThreadClient( &mutator_dispatcher_, &mutator_task_runner_)); } @@ -632,7 +658,7 @@ } cc::AnimationHost* WebFrameWidgetBase::AnimationHost() const { - return widget_base_.AnimationHost(); + return widget_base_->AnimationHost(); } base::WeakPtr<PaintWorkletPaintDispatcher> @@ -641,7 +667,7 @@ // We check paint_task_runner_ not paint_dispatcher_ because the dispatcher is // a base::WeakPtr that should only be used on the compositor thread. if (!paint_task_runner_) { - widget_base_.LayerTreeHost()->SetPaintWorkletLayerPainter( + widget_base_->LayerTreeHost()->SetPaintWorkletLayerPainter( PaintWorkletPaintDispatcher::CreateCompositorThreadPainter( &paint_dispatcher_)); paint_task_runner_ = Thread::CompositorThread()->GetTaskRunner(); @@ -791,10 +817,10 @@ WebReportTimeCallback presentation_time_callback) { if (!View()->does_composite()) return; - widget_base_.LayerTreeHost()->QueueSwapPromise( + widget_base_->LayerTreeHost()->QueueSwapPromise( std::make_unique<ReportTimeSwapPromise>( std::move(swap_time_callback), std::move(presentation_time_callback), - widget_base_.LayerTreeHost() + widget_base_->LayerTreeHost() ->GetTaskRunnerProvider() ->MainThreadTaskRunner(), this));
diff --git a/third_party/blink/renderer/core/frame/web_frame_widget_base.h b/third_party/blink/renderer/core/frame/web_frame_widget_base.h index cef9fb2..011f0aaa 100644 --- a/third_party/blink/renderer/core/frame/web_frame_widget_base.h +++ b/third_party/blink/renderer/core/frame/web_frame_widget_base.h
@@ -10,9 +10,12 @@ #include "cc/input/layer_selection_bound.h" #include "cc/input/overscroll_behavior.h" #include "cc/trees/layer_tree_host.h" +#include "mojo/public/cpp/bindings/associated_receiver.h" +#include "mojo/public/cpp/bindings/associated_remote.h" #include "services/network/public/mojom/referrer_policy.mojom-blink-forward.h" #include "third_party/blink/public/common/input/web_gesture_device.h" #include "third_party/blink/public/mojom/page/widget.mojom-blink.h" +#include "third_party/blink/public/platform/cross_variant_mojo_util.h" #include "third_party/blink/public/platform/web_coalesced_input_event.h" #include "third_party/blink/public/platform/web_drag_data.h" #include "third_party/blink/public/web/web_frame_widget.h" @@ -23,7 +26,6 @@ #include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/timer.h" #include "third_party/blink/renderer/platform/widget/frame_widget.h" -#include "third_party/blink/renderer/platform/widget/widget_base.h" #include "third_party/blink/renderer/platform/widget/widget_base_client.h" #include "third_party/blink/renderer/platform/wtf/casting.h" @@ -41,6 +43,7 @@ class PaintWorkletPaintDispatcher; class WebLocalFrameImpl; class WebViewImpl; +class WidgetBase; struct IntrinsicSizingInfo; class CORE_EXPORT WebFrameWidgetBase @@ -161,12 +164,17 @@ void DidLosePointerLock() override; void ShowContextMenu(WebMenuSourceType) override; void BeginFrame(base::TimeTicks frame_time) final; + void SetCompositorVisible(bool visible) override; + void UpdateVisualState() override; + void WillBeginCompositorFrame() final; // WidgetBaseClient methods. void DispatchRafAlignedInput(base::TimeTicks frame_time) override; + void RecordTimeToFirstActivePaint(base::TimeDelta duration) override; // mojom::blink::FrameWidget methods. void DragSourceSystemDragEnded() override; + void SetBackgroundOpaque(bool opaque) override; // Called when the FrameView for this Widget's local root is created. virtual void DidCreateLocalRootView() {} @@ -232,10 +240,6 @@ cc::LayerTreeDebugState GetLayerTreeDebugState(); void SetLayerTreeDebugState(const cc::LayerTreeDebugState& state); - // Returns if we should gather main frame metrics. If there is no compositor - // thread this returns false. - static bool ShouldRecordMainFrameMetrics(); - protected: enum DragAction { kDragEnter, kDragOver }; @@ -282,7 +286,7 @@ // Base functionality all widgets have. This is a member as to avoid // complicated inheritance structures. - WidgetBase widget_base_; + std::unique_ptr<WidgetBase> widget_base_; private: void CancelDrag();
diff --git a/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc b/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc index 4bf62f6..dd8f1641 100644 --- a/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc +++ b/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc
@@ -84,6 +84,7 @@ #include "third_party/blink/renderer/platform/graphics/color.h" #include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/keyboard_codes.h" +#include "third_party/blink/renderer/platform/widget/widget_base.h" namespace blink { namespace { @@ -285,6 +286,7 @@ GetPage()->Animator().SetSuppressFrameRequestsWorkaroundFor704763Only( suppress_frame_requests); } + void WebFrameWidgetImpl::BeginMainFrame(base::TimeTicks last_frame_time) { TRACE_EVENT1("blink", "WebFrameWidgetImpl::beginFrame", "frameTime", last_frame_time); @@ -295,7 +297,7 @@ DocumentLifecycle::AllowThrottlingScope throttling_scope( LocalRootImpl()->GetFrame()->GetDocument()->Lifecycle()); - if (ShouldRecordMainFrameMetrics()) { + if (WidgetBase::ShouldRecordBeginMainFrameMetrics()) { SCOPED_UMA_AND_UKM_TIMER( LocalRootImpl()->GetFrame()->View()->EnsureUkmAggregator(), LocalFrameUkmAggregator::kAnimate); @@ -1018,14 +1020,14 @@ // WebFrameWidgetImpl is used for child frames, which always have a // transparent background color. - widget_base_.LayerTreeHost()->set_background_color(SK_ColorTRANSPARENT); + widget_base_->LayerTreeHost()->set_background_color(SK_ColorTRANSPARENT); // Pass the limits even though this is for subframes, as the limits will // be needed in setting the raster scale. Client()->SetPageScaleStateAndLimits(1.f, false /* is_pinch_gesture_active */, View()->MinimumPageScaleFactor(), View()->MaximumPageScaleFactor()); - widget_base_.LayerTreeHost()->SetRootLayer(layer); + widget_base_->LayerTreeHost()->SetRootLayer(layer); } HitTestResult WebFrameWidgetImpl::CoreHitTestResultAt(
diff --git a/third_party/blink/renderer/core/frame/web_frame_widget_impl.h b/third_party/blink/renderer/core/frame/web_frame_widget_impl.h index 3c28583..eb9c8bb 100644 --- a/third_party/blink/renderer/core/frame/web_frame_widget_impl.h +++ b/third_party/blink/renderer/core/frame/web_frame_widget_impl.h
@@ -89,7 +89,6 @@ void Resize(const WebSize&) override; void DidEnterFullscreen() override; void DidExitFullscreen() override; - void SetSuppressFrameRequestsWorkaroundFor704763Only(bool) final; void DidBeginFrame() override; void BeginUpdateLayers() override; void EndUpdateLayers() override; @@ -144,6 +143,7 @@ // WidgetBaseClient overrides: void BeginMainFrame(base::TimeTicks last_frame_time) override; + void SetSuppressFrameRequestsWorkaroundFor704763Only(bool) final; void UpdateMainFrameLayoutSize();
diff --git a/third_party/blink/renderer/core/frame/web_view_frame_widget.cc b/third_party/blink/renderer/core/frame/web_view_frame_widget.cc index df277a3b..241e51c 100644 --- a/third_party/blink/renderer/core/frame/web_view_frame_widget.cc +++ b/third_party/blink/renderer/core/frame/web_view_frame_widget.cc
@@ -7,6 +7,7 @@ #include "third_party/blink/renderer/core/exported/web_view_impl.h" #include "third_party/blink/renderer/core/frame/web_local_frame_impl.h" #include "third_party/blink/renderer/platform/scheduler/public/thread.h" +#include "third_party/blink/renderer/platform/widget/widget_base.h" namespace blink { @@ -187,7 +188,7 @@ DCHECK(!root_layer); return; } - cc::LayerTreeHost* layer_tree_host = widget_base_.LayerTreeHost(); + cc::LayerTreeHost* layer_tree_host = widget_base_->LayerTreeHost(); layer_tree_host->SetRootLayer(root_layer); web_view_->DidChangeRootLayer(!!root_layer); }
diff --git a/third_party/blink/renderer/core/frame/web_view_frame_widget.h b/third_party/blink/renderer/core/frame/web_view_frame_widget.h index 53ac226..1bc5f79 100644 --- a/third_party/blink/renderer/core/frame/web_view_frame_widget.h +++ b/third_party/blink/renderer/core/frame/web_view_frame_widget.h
@@ -59,7 +59,6 @@ void Resize(const WebSize&) override; void DidEnterFullscreen() override; void DidExitFullscreen() override; - void SetSuppressFrameRequestsWorkaroundFor704763Only(bool) final; void DidBeginFrame() override; void BeginUpdateLayers() override; void EndUpdateLayers() override; @@ -106,6 +105,7 @@ // WidgetBaseClient overrides: void BeginMainFrame(base::TimeTicks last_frame_time) override; + void SetSuppressFrameRequestsWorkaroundFor704763Only(bool) final; void Trace(Visitor*) override;
diff --git a/third_party/blink/renderer/core/html/forms/file_input_type.cc b/third_party/blink/renderer/core/html/forms/file_input_type.cc index e36a7cd9..68800687 100644 --- a/third_party/blink/renderer/core/html/forms/file_input_type.cc +++ b/third_party/blink/renderer/core/html/forms/file_input_type.cc
@@ -325,8 +325,10 @@ void FileInputType::CreateShadowSubtree() { DCHECK(IsShadowHost(GetElement())); - auto* button = MakeGarbageCollected<HTMLInputElement>( - GetElement().GetDocument(), CreateElementFlags()); + Document& document = GetElement().GetDocument(); + + auto* button = + MakeGarbageCollected<HTMLInputElement>(document, CreateElementFlags()); button->setType(input_type_names::kButton); button->setAttribute( html_names::kValueAttr, @@ -338,6 +340,15 @@ shadow_element_names::FileUploadButton()); button->SetActive(GetElement().CanReceiveDroppedFiles()); GetElement().UserAgentShadowRoot()->AppendChild(button); + + // The following element is used only in LayoutNG. + // See LayoutFileUploadControl::IsChildAllowed(). + auto* span = document.CreateRawElement(html_names::kSpanTag); + // This element is hidden from AX trees for a historical reason. + span->setAttribute(html_names::kAriaHiddenAttr, "true"); + GetElement().UserAgentShadowRoot()->AppendChild(span); + + UpdateView(); } HTMLInputElement* FileInputType::UploadButton() const { @@ -347,6 +358,10 @@ return To<HTMLInputElement>(element); } +Node* FileInputType::FileStatusElement() const { + return GetElement().UserAgentShadowRoot()->lastChild(); +} + void FileInputType::DisabledAttributeChanged() { DCHECK(IsShadowHost(GetElement())); if (Element* button = UploadButton()) { @@ -545,8 +560,12 @@ } void FileInputType::UpdateView() { - if (auto* layout_object = GetElement().GetLayoutObject()) + auto* layout_object = GetElement().GetLayoutObject(); + if (layout_object && layout_object->IsFileUploadControl()) layout_object->SetShouldDoFullPaintInvalidation(); + + if (auto* span = FileStatusElement()) + span->setTextContent(FileStatusText()); } } // namespace blink
diff --git a/third_party/blink/renderer/core/html/forms/file_input_type.h b/third_party/blink/renderer/core/html/forms/file_input_type.h index 3c27ba6..425bf6b 100644 --- a/third_party/blink/renderer/core/html/forms/file_input_type.h +++ b/third_party/blink/renderer/core/html/forms/file_input_type.h
@@ -111,6 +111,7 @@ void WillOpenPopup() override; void SetFilesFromDirectory(const String&); + Node* FileStatusElement() const; Member<FileList> file_list_; String dropped_file_system_id_;
diff --git a/third_party/blink/renderer/core/html/forms/html_options_collection.cc b/third_party/blink/renderer/core/html/forms/html_options_collection.cc index 13c3d22..569dfb3 100644 --- a/third_party/blink/renderer/core/html/forms/html_options_collection.cc +++ b/third_party/blink/renderer/core/html/forms/html_options_collection.cc
@@ -94,17 +94,17 @@ To<HTMLSelectElement>(ownerNode()).setLength(length, exception_state); } -bool HTMLOptionsCollection::AnonymousIndexedSetter( +IndexedPropertySetterResult HTMLOptionsCollection::AnonymousIndexedSetter( unsigned index, HTMLOptionElement* value, ExceptionState& exception_state) { auto& base = To<HTMLSelectElement>(ownerNode()); if (!value) { // undefined or null base.remove(index); - return true; + return IndexedPropertySetterResult::kIntercepted; } base.SetOption(index, value, exception_state); - return true; + return IndexedPropertySetterResult::kIntercepted; } } // namespace blink
diff --git a/third_party/blink/renderer/core/html/forms/html_options_collection.h b/third_party/blink/renderer/core/html/forms/html_options_collection.h index 30411954..d9e50d9 100644 --- a/third_party/blink/renderer/core/html/forms/html_options_collection.h +++ b/third_party/blink/renderer/core/html/forms/html_options_collection.h
@@ -26,6 +26,7 @@ #include "third_party/blink/renderer/core/html/forms/html_option_element.h" #include "third_party/blink/renderer/core/html/html_collection.h" +#include "third_party/blink/renderer/platform/bindings/v8_binding.h" #include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink { @@ -54,7 +55,9 @@ void setSelectedIndex(int); void setLength(unsigned, ExceptionState&); - bool AnonymousIndexedSetter(unsigned, HTMLOptionElement*, ExceptionState&); + IndexedPropertySetterResult AnonymousIndexedSetter(unsigned, + HTMLOptionElement*, + ExceptionState&); bool ElementMatches(const HTMLElement&) const;
diff --git a/third_party/blink/renderer/core/html/forms/html_select_element.cc b/third_party/blink/renderer/core/html/forms/html_select_element.cc index c3d5937..37ca88b 100644 --- a/third_party/blink/renderer/core/html/forms/html_select_element.cc +++ b/third_party/blink/renderer/core/html/forms/html_select_element.cc
@@ -290,8 +290,8 @@ flags |= kDispatchInputAndChangeEventFlag; SelectOption(option, flags); - if (send_events && previous_selected_option != option && !UsesMenuList()) - ListBoxOnChange(); + if (send_events && previous_selected_option != option) + select_type_->ListBoxOnChange(); } String HTMLSelectElement::SuggestedValue() const { @@ -509,20 +509,6 @@ select_type_->SelectAll(); } -void HTMLSelectElement::SaveLastSelection() { - if (UsesMenuList()) { - last_on_change_option_ = SelectedOption(); - return; - } - - last_on_change_selection_.clear(); - for (auto& element : GetListItems()) { - auto* option_element = DynamicTo<HTMLOptionElement>(element.Get()); - last_on_change_selection_.push_back(option_element && - option_element->Selected()); - } -} - void HTMLSelectElement::SetActiveSelectionAnchor(HTMLOptionElement* option) { active_selection_anchor_ = option; select_type_->SaveListboxActiveSelection(); @@ -532,37 +518,6 @@ active_selection_end_ = option; } -void HTMLSelectElement::ListBoxOnChange() { - DCHECK(!UsesMenuList()); - - const ListItems& items = GetListItems(); - - // If the cached selection list is empty, or the size has changed, then fire - // dispatchFormControlChangeEvent, and return early. - // FIXME: Why? This looks unreasonable. - if (last_on_change_selection_.IsEmpty() || - last_on_change_selection_.size() != items.size()) { - DispatchChangeEvent(); - return; - } - - // Update last_on_change_selection_ and fire a 'change' event. - bool fire_on_change = false; - for (unsigned i = 0; i < items.size(); ++i) { - HTMLElement* element = items[i]; - auto* option_element = DynamicTo<HTMLOptionElement>(element); - bool selected = option_element && option_element->Selected(); - if (selected != last_on_change_selection_[i]) - fire_on_change = true; - last_on_change_selection_[i] = selected; - } - - if (fire_on_change) { - DispatchInputEvent(); - DispatchChangeEvent(); - } -} - void HTMLSelectElement::ScrollToSelection() { if (!IsFinishedParsingChildren()) return; @@ -958,7 +913,7 @@ // Save the selection so it can be compared to the new selection when // dispatching change events during blur event dispatch. if (UsesMenuList()) - SaveLastSelection(); + select_type_->SaveLastSelection(); HTMLFormControlElementWithState::DispatchFocusEvent(old_focused_element, type, source_capabilities); } @@ -1223,8 +1178,7 @@ SelectOption(OptionAtListIndex(index), kDeselectOtherOptionsFlag | kMakeOptionDirtyFlag | kDispatchInputAndChangeEventFlag); - if (!UsesMenuList()) - ListBoxOnChange(); + select_type_->ListBoxOnChange(); } void HTMLSelectElement::SelectOptionByAccessKey(HTMLOptionElement* option) { @@ -1250,7 +1204,7 @@ option->SetDirty(true); if (UsesMenuList()) return; - ListBoxOnChange(); + select_type_->ListBoxOnChange(); ScrollToSelection(); } @@ -1272,16 +1226,16 @@ cache->ListboxActiveIndexChanged(this); } -bool HTMLSelectElement::AnonymousIndexedSetter( +IndexedPropertySetterResult HTMLSelectElement::AnonymousIndexedSetter( unsigned index, HTMLOptionElement* value, ExceptionState& exception_state) { if (!value) { // undefined or null remove(index); - return true; + return IndexedPropertySetterResult::kIntercepted; } SetOption(index, value, exception_state); - return true; + return IndexedPropertySetterResult::kIntercepted; } bool HTMLSelectElement::IsInteractiveContent() const {
diff --git a/third_party/blink/renderer/core/html/forms/html_select_element.h b/third_party/blink/renderer/core/html/forms/html_select_element.h index 3f33e6cd..515f43b42 100644 --- a/third_party/blink/renderer/core/html/forms/html_select_element.h +++ b/third_party/blink/renderer/core/html/forms/html_select_element.h
@@ -127,7 +127,6 @@ bool CanSelectAll() const; void SelectAll(); - void ListBoxOnChange(); int ActiveSelectionEndListIndex() const; HTMLOptionElement* ActiveSelectionEnd() const; void SetActiveSelectionAnchor(HTMLOptionElement*); @@ -137,7 +136,9 @@ void OptionSelectionStateChanged(HTMLOptionElement*, bool option_is_selected); void OptionInserted(HTMLOptionElement&, bool option_is_selected); void OptionRemoved(HTMLOptionElement&); - bool AnonymousIndexedSetter(unsigned, HTMLOptionElement*, ExceptionState&); + IndexedPropertySetterResult AnonymousIndexedSetter(unsigned, + HTMLOptionElement*, + ExceptionState&); void OptGroupInsertedOrRemoved(HTMLOptGroupElement&); void HrInsertedOrRemoved(HTMLHRElement&); @@ -230,7 +231,6 @@ enum ResetReason { kResetReasonSelectedOptionRemoved, kResetReasonOthers }; void ResetToDefaultSelection(ResetReason = kResetReasonOthers); void TypeAheadFind(const KeyboardEvent&); - void SaveLastSelection(); // Returns the first selected OPTION, or nullptr. HTMLOptionElement* SelectedOption() const;
diff --git a/third_party/blink/renderer/core/html/forms/select_type.cc b/third_party/blink/renderer/core/html/forms/select_type.cc index 98be879..6dabffec 100644 --- a/third_party/blink/renderer/core/html/forms/select_type.cc +++ b/third_party/blink/renderer/core/html/forms/select_type.cc
@@ -80,6 +80,7 @@ void DidDetachLayoutTree() override; void DidRecalcStyle(const StyleRecalcChange change) override; void DidSetSuggestedOption(HTMLOptionElement* option) override; + void SaveLastSelection() override; void UpdateTextStyle() override { UpdateTextStyleInternal(); } void UpdateTextStyleAndContent() override; @@ -234,7 +235,7 @@ // when we call onChange during selectOption, which gets called // from selectOptionByPopup, which gets called after the user // makes a selection from the menu. - select_->SaveLastSelection(); + SaveLastSelection(); // TODO(lanwei): Will check if we need to add // InputDeviceCapabilities here when select menu list gets // focus, see https://crbug.com/476530. @@ -284,7 +285,7 @@ // dispatching change events during SelectOption, which gets called from // SelectOptionByPopup, which gets called after the user makes a selection // from the menu. - select_->SaveLastSelection(); + SaveLastSelection(); ShowPopup(); return true; } @@ -403,6 +404,10 @@ popup_->UpdateFromElement(PopupMenu::kBySelectionChange); } +void MenuListSelectType::SaveLastSelection() { + select_->last_on_change_option_ = select_->SelectedOption(); +} + void MenuListSelectType::DidDetachLayoutTree() { if (popup_) popup_->DisconnectClient(); @@ -609,9 +614,11 @@ explicit ListBoxSelectType(HTMLSelectElement& select) : SelectType(select) {} bool DefaultEventHandler(const Event& event) override; void DidSetSuggestedOption(HTMLOptionElement* option) override; + void SaveLastSelection() override; void SelectAll() override; void SaveListboxActiveSelection() override; void HandleMouseRelease() override; + void ListBoxOnChange() override; private: HTMLOptionElement* NextSelectableOptionPageAway(HTMLOptionElement*, @@ -649,7 +656,7 @@ UpdateSelectedState(option, gesture_event->shiftKey() ? SelectionMode::kRange : SelectionMode::kNotChangeOthers); - select_->ListBoxOnChange(); + ListBoxOnChange(); } return true; } @@ -821,7 +828,7 @@ // Save the selection so it can be compared to the new selection // when dispatching change events immediately after making the new // selection. - select_->SaveLastSelection(); + SaveLastSelection(); select_->SetActiveSelectionEnd(end_option); @@ -846,7 +853,7 @@ if (select_new_item || is_in_non_contiguous_selection_) { if (select_new_item) { UpdateListBoxSelection(deselect_others); - select_->ListBoxOnChange(); + ListBoxOnChange(); } UpdateMultiSelectFocus(); } else { @@ -892,6 +899,15 @@ select_->ScrollToOption(option); } +void ListBoxSelectType::SaveLastSelection() { + select_->last_on_change_selection_.clear(); + for (auto& element : select_->GetListItems()) { + auto* option_element = DynamicTo<HTMLOptionElement>(element.Get()); + select_->last_on_change_selection_.push_back(option_element && + option_element->Selected()); + } +} + void ListBoxSelectType::UpdateMultiSelectFocus() { if (!select_->is_multiple_) return; @@ -912,14 +928,14 @@ // Save the selection so it can be compared to the new selectAll selection // when dispatching change events. - select_->SaveLastSelection(); + SaveLastSelection(); active_selection_state_ = true; select_->SetActiveSelectionAnchor(NextSelectableOption(nullptr)); select_->SetActiveSelectionEnd(PreviousSelectableOption(nullptr)); UpdateListBoxSelection(false, false); - select_->ListBoxOnChange(); + ListBoxOnChange(); select_->SetNeedsValidityCheck(); } @@ -947,7 +963,7 @@ void ListBoxSelectType::ToggleSelection(HTMLOptionElement& option) { active_selection_state_ = !active_selection_state_; UpdateSelectedState(&option, SelectionMode::kNotChangeOthers); - select_->ListBoxOnChange(); + ListBoxOnChange(); } void ListBoxSelectType::UpdateSelectedState(HTMLOptionElement* clicked_option, @@ -955,7 +971,7 @@ DCHECK(clicked_option); // Save the selection so it can be compared to the new selection when // dispatching change events during mouseup, or after autoscroll finishes. - select_->SaveLastSelection(); + SaveLastSelection(); active_selection_state_ = true; @@ -1058,7 +1074,36 @@ // We didn't start this click/drag on any options. if (select_->last_on_change_selection_.IsEmpty()) return; - select_->ListBoxOnChange(); + ListBoxOnChange(); +} + +void ListBoxSelectType::ListBoxOnChange() { + const auto& items = select_->GetListItems(); + + // If the cached selection list is empty, or the size has changed, then fire + // 'change' event, and return early. + // FIXME: Why? This looks unreasonable. + if (select_->last_on_change_selection_.IsEmpty() || + select_->last_on_change_selection_.size() != items.size()) { + select_->DispatchChangeEvent(); + return; + } + + // Update last_on_change_selection_ and fire a 'change' event. + bool fire_on_change = false; + for (unsigned i = 0; i < items.size(); ++i) { + HTMLElement* element = items[i]; + auto* option_element = DynamicTo<HTMLOptionElement>(element); + bool selected = option_element && option_element->Selected(); + if (selected != select_->last_on_change_selection_[i]) + fire_on_change = true; + select_->last_on_change_selection_[i] = selected; + } + + if (fire_on_change) { + select_->DispatchInputEvent(); + select_->DispatchChangeEvent(); + } } // ============================================================================ @@ -1119,6 +1164,8 @@ void SelectType::HandleMouseRelease() {} +void SelectType::ListBoxOnChange() {} + void SelectType::ShowPopup() { NOTREACHED(); }
diff --git a/third_party/blink/renderer/core/html/forms/select_type.h b/third_party/blink/renderer/core/html/forms/select_type.h index 1e78fc9..065bd30f 100644 --- a/third_party/blink/renderer/core/html/forms/select_type.h +++ b/third_party/blink/renderer/core/html/forms/select_type.h
@@ -32,6 +32,7 @@ virtual void DidDetachLayoutTree(); virtual void DidRecalcStyle(const StyleRecalcChange change); virtual void DidSetSuggestedOption(HTMLOptionElement* option) = 0; + virtual void SaveLastSelection() = 0; // Update style of text in the CSS box on style or selected OPTION change. virtual void UpdateTextStyle(); @@ -47,6 +48,7 @@ virtual void SelectAll(); virtual void SaveListboxActiveSelection(); virtual void HandleMouseRelease(); + virtual void ListBoxOnChange(); virtual void ShowPopup(); virtual void HidePopup();
diff --git a/third_party/blink/renderer/core/html/imports/html_imports_controller.cc b/third_party/blink/renderer/core/html/imports/html_imports_controller.cc index 8a3ea3e..89f0c961e 100644 --- a/third_party/blink/renderer/core/html/imports/html_imports_controller.cc +++ b/third_party/blink/renderer/core/html/imports/html_imports_controller.cc
@@ -30,7 +30,6 @@ #include "third_party/blink/renderer/core/html/imports/html_imports_controller.h" -#include "third_party/blink/public/common/features.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/frame/web_feature.h" #include "third_party/blink/renderer/core/html/imports/html_import_child.h" @@ -121,9 +120,7 @@ Master()->GetSecurityOrigin(); ResourceFetcher* fetcher = parent->GetDocument()->Fetcher(); - if (base::FeatureList::IsEnabled( - features::kHtmlImportsRequestInitiatorLock) && - parent->GetDocument()->ImportsController()) { + if (parent->GetDocument()->ImportsController()) { Document* context_document = parent->GetDocument()->ContextDocument(); if (!context_document) return nullptr;
diff --git a/third_party/blink/renderer/core/input/event_handler.cc b/third_party/blink/renderer/core/input/event_handler.cc index fa20739..0d86017 100644 --- a/third_party/blink/renderer/core/input/event_handler.cc +++ b/third_party/blink/renderer/core/input/event_handler.cc
@@ -919,6 +919,7 @@ const Vector<WebMouseEvent>& coalesced_events, const Vector<WebMouseEvent>& predicted_events) { TRACE_EVENT0("blink", "EventHandler::handleMouseMoveEvent"); + DCHECK(event.GetType() == WebInputEvent::kMouseMove); HitTestResult hovered_node_result; HitTestLocation location; WebInputEventResult result = @@ -953,13 +954,13 @@ void EventHandler::HandleMouseLeaveEvent(const WebMouseEvent& event) { TRACE_EVENT0("blink", "EventHandler::handleMouseLeaveEvent"); + DCHECK(event.GetType() == WebInputEvent::kMouseLeave); Page* page = frame_->GetPage(); if (page) page->GetChromeClient().ClearToolTip(*frame_); HandleMouseMoveOrLeaveEvent(event, Vector<WebMouseEvent>(), - Vector<WebMouseEvent>(), nullptr, nullptr, false, - true); + Vector<WebMouseEvent>()); pointer_event_manager_->RemoveLastMousePosition(); } @@ -968,11 +969,11 @@ const Vector<WebMouseEvent>& coalesced_events, const Vector<WebMouseEvent>& predicted_events, HitTestResult* hovered_node_result, - HitTestLocation* hit_test_location, - bool only_update_scrollbars, - bool force_leave) { + HitTestLocation* hit_test_location) { DCHECK(frame_); DCHECK(frame_->View()); + DCHECK(mouse_event.GetType() == WebInputEvent::kMouseMove || + mouse_event.GetType() == WebInputEvent::kMouseLeave); mouse_event_manager_->SetLastKnownMousePosition(mouse_event); hover_timer_.Stop(); @@ -1016,31 +1017,27 @@ HitTestRequest::kMove | HitTestRequest::kRetargetForInert; if (mouse_event_manager_->MousePressed()) { hit_type |= HitTestRequest::kActive; - } else if (only_update_scrollbars) { - // Mouse events should be treated as "read-only" if we're updating only - // scrollbars. This means that :hover and :active freeze in the state they - // were in, rather than updating for nodes the mouse moves while the - // window is not key (which will be the case if onlyUpdateScrollbars is - // true). - hit_type |= HitTestRequest::kReadOnly; } // Treat any mouse move events as readonly if the user is currently touching // the screen. - if (pointer_event_manager_->IsAnyTouchActive() && !force_leave) + if (pointer_event_manager_->IsAnyTouchActive() && + mouse_event.GetType() == WebInputEvent::kMouseMove) { hit_type |= HitTestRequest::kActive | HitTestRequest::kReadOnly; + } HitTestRequest request(hit_type); HitTestLocation out_location((PhysicalOffset())); MouseEventWithHitTestResults mev = MouseEventWithHitTestResults( mouse_event, out_location, HitTestResult(request, out_location)); - // We don't want to do a hit-test in forceLeave scenarios because there + // We don't want to do a hit-test in MouseLeave scenarios because there // might actually be some other frame above this one at the specified - // co-ordinate. So we must force the hit-test to fail, while still clearing - // hover/active state. - if (force_leave) { + // coordinate. So we avoid the hit test but still clear the hover/active + // state. + if (mouse_event.GetType() == WebInputEvent::kMouseLeave) { frame_->GetDocument()->UpdateHoverActiveState(request.Active(), - !request.Move(), nullptr); + /*update_active_chain=*/false, + nullptr); } else { mev = GetMouseEventTarget(request, mouse_event); } @@ -1056,34 +1053,35 @@ if (scroll_manager_->InResizeMode()) { scroll_manager_->Resize(mev.Event()); } else { - if (!scrollbar) - scrollbar = mev.GetScrollbar(); + scrollbar = mev.GetScrollbar(); UpdateLastScrollbarUnderMouse(scrollbar, !mouse_event_manager_->MousePressed()); - if (only_update_scrollbars) - return WebInputEventResult::kHandledSuppressed; } WebInputEventResult event_result = WebInputEventResult::kNotHandled; bool is_portal = mev.InnerElement() && IsA<HTMLPortalElement>(*mev.InnerElement()); bool is_remote_frame = false; - LocalFrame* new_subframe = event_handling_util::GetTargetSubframe( + LocalFrame* current_subframe = event_handling_util::GetTargetSubframe( mev, capturing_mouse_events_element_, &is_remote_frame); // We want mouseouts to happen first, from the inside out. First send a // move event to the last subframe so that it will fire mouseouts. + // TODO(lanwei): figure out here if we should call HandleMouseLeaveEvent on a + // mouse move event. if (last_mouse_move_event_subframe_ && last_mouse_move_event_subframe_->Tree().IsDescendantOf(frame_) && - last_mouse_move_event_subframe_ != new_subframe) { + last_mouse_move_event_subframe_ != current_subframe) { + WebMouseEvent event = mev.Event(); + event.SetType(WebInputEvent::kMouseLeave); last_mouse_move_event_subframe_->GetEventHandler().HandleMouseLeaveEvent( - mev.Event()); + event); last_mouse_move_event_subframe_->GetEventHandler() .mouse_event_manager_->SetLastMousePositionAsUnknown(); } - if (new_subframe) { + if (current_subframe) { // Update over/out state before passing the event to the subframe. pointer_event_manager_->SendMouseAndPointerBoundaryEvents( EffectiveMouseEventTargetElement(mev.InnerElement()), @@ -1092,10 +1090,10 @@ // Event dispatch in sendMouseAndPointerBoundaryEvents may have caused the // subframe of the target node to be detached from its LocalFrameView, in // which case the event should not be passed. - if (new_subframe->View()) { + if (current_subframe->View()) { event_result = PassMouseMoveEventToSubframe(mev, coalesced_events, predicted_events, - new_subframe, hovered_node_result); + current_subframe, hovered_node_result); } } else { if (scrollbar && !mouse_event_manager_->MousePressed()) { @@ -1113,7 +1111,7 @@ } } - last_mouse_move_event_subframe_ = new_subframe; + last_mouse_move_event_subframe_ = current_subframe; if (event_result != WebInputEventResult::kNotHandled) return event_result; @@ -1985,7 +1983,7 @@ // Adjust the location of the gesture to the most likely nearby node, as // appropriate for the type of event. ApplyTouchAdjustment(&adjusted_event, location, &hit_test_result); - // Do a new hit-test at the (adjusted) gesture co-ordinates. This is + // Do a new hit-test at the (adjusted) gesture coordinates. This is // necessary because rect-based hit testing and touch adjustment sometimes // return a different node than what a point-based hit test would return for // the same point.
diff --git a/third_party/blink/renderer/core/input/event_handler.h b/third_party/blink/renderer/core/input/event_handler.h index 8645fc7..887ec3f 100644 --- a/third_party/blink/renderer/core/input/event_handler.h +++ b/third_party/blink/renderer/core/input/event_handler.h
@@ -276,9 +276,7 @@ const Vector<WebMouseEvent>& coalesced_events, const Vector<WebMouseEvent>& predicted_events, HitTestResult* hovered_node = nullptr, - HitTestLocation* hit_test_location = nullptr, - bool only_update_scrollbars = false, - bool force_leave = false); + HitTestLocation* hit_test_location = nullptr); // Updates the event, location and result to the adjusted target. void ApplyTouchAdjustment(WebGestureEvent*, HitTestLocation&, HitTestResult*); @@ -372,6 +370,7 @@ const Member<SelectionController> selection_controller_; + // TODO(lanwei): Remove the below timers for updating hover and cursor. TaskRunnerTimer<EventHandler> hover_timer_; // TODO(rbyers): Mouse cursor update is page-wide, not per-frame. Page-wide
diff --git a/third_party/blink/renderer/core/inspector/inspector_resource_content_loader.cc b/third_party/blink/renderer/core/inspector/inspector_resource_content_loader.cc index 7ee53ff..1a72eca 100644 --- a/third_party/blink/renderer/core/inspector/inspector_resource_content_loader.cc +++ b/third_party/blink/renderer/core/inspector/inspector_resource_content_loader.cc
@@ -4,7 +4,6 @@ #include "third_party/blink/renderer/core/inspector/inspector_resource_content_loader.h" -#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h" #include "third_party/blink/public/platform/web_url_request.h" #include "third_party/blink/renderer/core/css/css_style_sheet.h" @@ -94,9 +93,7 @@ } ResourceFetcher* fetcher = document->Fetcher(); - if (base::FeatureList::IsEnabled( - features::kHtmlImportsRequestInitiatorLock) && - document->ImportsController()) { + if (document->ImportsController()) { // For @imports from HTML imported Documents, we use the // context document for getting origin and ResourceFetcher to use the // main Document's origin, while using the element document for
diff --git a/third_party/blink/renderer/core/layout/layout_block.cc b/third_party/blink/renderer/core/layout/layout_block.cc index 27109de..55ed364b 100644 --- a/third_party/blink/renderer/core/layout/layout_block.cc +++ b/third_party/blink/renderer/core/layout/layout_block.cc
@@ -32,7 +32,6 @@ #include "third_party/blink/renderer/core/css/style_engine.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/element.h" -#include "third_party/blink/renderer/core/dom/shadow_root.h" #include "third_party/blink/renderer/core/editing/drag_caret.h" #include "third_party/blink/renderer/core/editing/editing_utilities.h" #include "third_party/blink/renderer/core/editing/frame_selection.h" @@ -1680,11 +1679,6 @@ if (GetNode()) { if (IsRootEditableElement(*GetNode())) return true; - - if (auto* shadow_root = DynamicTo<ShadowRoot>(GetNode())) { - if (IsA<HTMLInputElement>(shadow_root->host())) - return true; - } } return FirstLineStyleRef().HasLineIfEmpty(); }
diff --git a/third_party/blink/renderer/core/layout/layout_file_upload_control.cc b/third_party/blink/renderer/core/layout/layout_file_upload_control.cc index 5a9c6ec..589ba9e 100644 --- a/third_party/blink/renderer/core/layout/layout_file_upload_control.cc +++ b/third_party/blink/renderer/core/layout/layout_file_upload_control.cc
@@ -42,6 +42,16 @@ LayoutFileUploadControl::~LayoutFileUploadControl() = default; +bool LayoutFileUploadControl::IsChildAllowed(LayoutObject* child, + const ComputedStyle& style) const { + const Node* child_node = child->GetNode(); + // Reject shadow nodes other than UploadButton. + if (child_node && child_node->OwnerShadowHost() == GetNode() && + child_node != UploadButton()) + return false; + return LayoutBlockFlow::IsChildAllowed(child, style); +} + int LayoutFileUploadControl::MaxFilenameWidth() const { int upload_button_width = (UploadButton() && UploadButton()->GetLayoutBox())
diff --git a/third_party/blink/renderer/core/layout/layout_file_upload_control.h b/third_party/blink/renderer/core/layout/layout_file_upload_control.h index 3e9ac619..372714a 100644 --- a/third_party/blink/renderer/core/layout/layout_file_upload_control.h +++ b/third_party/blink/renderer/core/layout/layout_file_upload_control.h
@@ -54,6 +54,8 @@ const char* GetName() const override { return "LayoutFileUploadControl"; } private: + bool IsChildAllowed(LayoutObject* child, + const ComputedStyle& style) const override; void PaintObject(const PaintInfo&, const PhysicalOffset& paint_offset) const override;
diff --git a/third_party/blink/renderer/core/layout/layout_inline_test.cc b/third_party/blink/renderer/core/layout/layout_inline_test.cc index 26a6ca7..2c8922ef 100644 --- a/third_party/blink/renderer/core/layout/layout_inline_test.cc +++ b/third_party/blink/renderer/core/layout/layout_inline_test.cc
@@ -8,6 +8,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/renderer/core/layout/layout_block_flow.h" +#include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_cursor.h" #include "third_party/blink/renderer/core/testing/core_unit_test_helper.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h" #include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h" @@ -110,6 +111,14 @@ ToLayoutInline(GetLayoutObjectByElementId("lotsOfBoxes")); ASSERT_TRUE(lots_of_boxes); + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) { + NGInlineCursor cursor; + cursor.MoveTo(*lots_of_boxes); + ASSERT_TRUE(cursor); + EXPECT_EQ(lots_of_boxes, cursor.Current().GetLayoutObject()); + return; + } + HitTestRequest hit_request(HitTestRequest::kTouchEvent | HitTestRequest::kListBased);
diff --git a/third_party/blink/renderer/core/layout/layout_slider.h b/third_party/blink/renderer/core/layout/layout_slider.h index 064eed2..32caaa6 100644 --- a/third_party/blink/renderer/core/layout/layout_slider.h +++ b/third_party/blink/renderer/core/layout/layout_slider.h
@@ -23,6 +23,7 @@ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/layout/layout_flexible_box.h" +#include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink { @@ -52,7 +53,12 @@ LayoutUnit& max_logical_width) const override; }; -DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSlider, IsSlider()); +template <> +struct DowncastTraits<LayoutSlider> { + static bool AllowFrom(const LayoutObject& object) { + return object.IsSlider(); + } +}; } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/layout_theme_default.cc b/third_party/blink/renderer/core/layout/layout_theme_default.cc index eae1671..9e6dcd5 100644 --- a/third_party/blink/renderer/core/layout/layout_theme_default.cc +++ b/third_party/blink/renderer/core/layout/layout_theme_default.cc
@@ -46,10 +46,16 @@ static const float kMinCancelButtonSize = 5; static const float kMaxCancelButtonSize = 21; -LayoutThemeDefault::LayoutThemeDefault() - : LayoutTheme(), - caret_blink_interval_(LayoutTheme::CaretBlinkInterval()), - painter_(*this) {} +base::TimeDelta LayoutThemeDefault::caret_blink_interval_; + +Color LayoutThemeDefault::active_selection_background_color_ = 0xff1e90ff; +Color LayoutThemeDefault::active_selection_foreground_color_ = Color::kBlack; +Color LayoutThemeDefault::inactive_selection_background_color_ = 0xffc8c8c8; +Color LayoutThemeDefault::inactive_selection_foreground_color_ = 0xff323232; + +LayoutThemeDefault::LayoutThemeDefault() : LayoutTheme(), painter_(*this) { + caret_blink_interval_ = LayoutTheme::CaretBlinkInterval(); +} LayoutThemeDefault::~LayoutThemeDefault() = default;
diff --git a/third_party/blink/renderer/core/layout/layout_theme_default.h b/third_party/blink/renderer/core/layout/layout_theme_default.h index 397383f4..50588077 100644 --- a/third_party/blink/renderer/core/layout/layout_theme_default.h +++ b/third_party/blink/renderer/core/layout/layout_theme_default.h
@@ -150,12 +150,13 @@ int MenuListInternalPadding(const ComputedStyle&, int padding) const; static const RGBA32 kDefaultTapHighlightColor = 0x2e000000; // 18% black. - base::TimeDelta caret_blink_interval_; - Color active_selection_background_color_ = 0xff1e90ff; - Color active_selection_foreground_color_ = Color::kBlack; - Color inactive_selection_background_color_ = 0xffc8c8c8; - Color inactive_selection_foreground_color_ = 0xff323232; + static base::TimeDelta caret_blink_interval_; + + static Color active_selection_background_color_; + static Color active_selection_foreground_color_; + static Color inactive_selection_background_color_; + static Color inactive_selection_foreground_color_; ThemePainterDefault painter_; // Cached values for crbug.com/673754.
diff --git a/third_party/blink/renderer/core/layout/layout_theme_test.cc b/third_party/blink/renderer/core/layout/layout_theme_test.cc index ea37c45..7461a34 100644 --- a/third_party/blink/renderer/core/layout/layout_theme_test.cc +++ b/third_party/blink/renderer/core/layout/layout_theme_test.cc
@@ -80,8 +80,8 @@ EXPECT_EQ(custom_color, OutlineColor(span)); } -// The expectations are based on LayoutThemeDefault::SystemColor. -// LayoutThemeMac doesn't use that code path. +// The expectations in the tests below are relying on LayoutThemeDefault. +// LayoutThemeMac doesn't inherit from that class. #if !defined(OS_MACOSX) TEST_F(LayoutThemeTest, SystemColorWithColorScheme) { SetHtmlInnerHTML(R"HTML( @@ -112,6 +112,32 @@ EXPECT_EQ(Color(0x44, 0x44, 0x44), style->VisitedDependentColor(GetCSSPropertyColor())); } + +TEST_F(LayoutThemeTest, SetSelectionColors) { + LayoutTheme::GetTheme().SetSelectionColors(Color::kBlack, Color::kBlack, + Color::kBlack, Color::kBlack); + EXPECT_EQ(Color::kBlack, + LayoutTheme::GetTheme().ActiveSelectionForegroundColor( + WebColorScheme::kLight)); + { + // Enabling MobileLayoutTheme switches which instance is returned from + // LayoutTheme::GetTheme(). Devtools expect SetSelectionColors() to affect + // both LayoutTheme instances. + ScopedMobileLayoutThemeForTest scope(true); + EXPECT_EQ(Color::kBlack, + LayoutTheme::GetTheme().ActiveSelectionForegroundColor( + WebColorScheme::kLight)); + + LayoutTheme::GetTheme().SetSelectionColors(Color::kWhite, Color::kWhite, + Color::kWhite, Color::kWhite); + EXPECT_EQ(Color::kWhite, + LayoutTheme::GetTheme().ActiveSelectionForegroundColor( + WebColorScheme::kLight)); + } + EXPECT_EQ(Color::kWhite, + LayoutTheme::GetTheme().ActiveSelectionForegroundColor( + WebColorScheme::kLight)); +} #endif // !defined(OS_MACOSX) } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/ng/inline/ng_offset_mapping_test.cc b/third_party/blink/renderer/core/layout/ng/inline/ng_offset_mapping_test.cc index 791524b..3e2c8f22 100644 --- a/third_party/blink/renderer/core/layout/ng/inline/ng_offset_mapping_test.cc +++ b/third_party/blink/renderer/core/layout/ng/inline/ng_offset_mapping_test.cc
@@ -1495,7 +1495,8 @@ // For the purpose of this test, ensure this is laid out by each layout // engine. - DCHECK_EQ(layout_block_flow->IsLayoutNGMixin(), GetParam()); + DCHECK_EQ(layout_block_flow->IsLayoutNGMixin(), + RuntimeEnabledFeatures::LayoutNGEnabled()); const NGOffsetMapping* mapping = NGInlineNode::GetOffsetMapping(layout_block_flow);
diff --git a/third_party/blink/renderer/core/layout/ng/inline/ng_physical_text_fragment_test.cc b/third_party/blink/renderer/core/layout/ng/inline/ng_physical_text_fragment_test.cc index 7de65ceb..ebb2a5a 100644 --- a/third_party/blink/renderer/core/layout/ng/inline/ng_physical_text_fragment_test.cc +++ b/third_party/blink/renderer/core/layout/ng/inline/ng_physical_text_fragment_test.cc
@@ -43,6 +43,8 @@ }; TEST_F(NGPhysicalTextFragmentTest, LocalRect) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <style> @@ -59,6 +61,8 @@ } TEST_F(NGPhysicalTextFragmentTest, LocalRectRTL) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <style> @@ -81,6 +85,8 @@ } TEST_F(NGPhysicalTextFragmentTest, LocalRectVLR) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <style> @@ -98,6 +104,8 @@ } TEST_F(NGPhysicalTextFragmentTest, LocalRectVRL) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <style> @@ -115,6 +123,8 @@ } TEST_F(NGPhysicalTextFragmentTest, NormalTextIsNotAnonymousText) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; SetBodyInnerHTML("<div id=div>text</div>"); auto text_fragments = CollectTextFragmentsInContainer("div"); @@ -125,6 +135,8 @@ } TEST_F(NGPhysicalTextFragmentTest, FirstLetterIsNotAnonymousText) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; SetBodyInnerHTML( "<style>::first-letter {color:red}</style>" "<div id=div>text</div>"); @@ -139,6 +151,8 @@ } TEST_F(NGPhysicalTextFragmentTest, BeforeAndAfterAreAnonymousText) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; SetBodyInnerHTML( "<style>::before{content:'x'} ::after{content:'x'}</style>" "<div id=div>text</div>"); @@ -155,6 +169,8 @@ } TEST_F(NGPhysicalTextFragmentTest, Ellipsis) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <style> @@ -191,6 +207,8 @@ } TEST_F(NGPhysicalTextFragmentTest, ListMarkerIsGeneratedText) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; SetBodyInnerHTML( "<ol style='list-style-position:inside'>" "<li id=list>text</li>" @@ -206,6 +224,8 @@ } TEST_F(NGPhysicalTextFragmentTest, SoftHyphen) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <style> @@ -234,6 +254,8 @@ } TEST_F(NGPhysicalTextFragmentTest, QuotationMarksAreAnonymousText) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; SetBodyInnerHTML("<div id=div><q>text</q></div>"); auto text_fragments = CollectTextFragmentsInContainer("div"); @@ -248,6 +270,8 @@ } TEST_F(NGPhysicalTextFragmentTest, TextOffsetForPointForTabulation) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <style> @@ -270,6 +294,8 @@ } TEST_F(NGPhysicalTextFragmentTest, TextOffsetForPointForTabulationRtl) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <style>
diff --git a/third_party/blink/renderer/core/layout/ng/ng_flex_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/ng_flex_layout_algorithm.cc index 8d1faa3..c6ef4b7 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_flex_layout_algorithm.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_flex_layout_algorithm.cc
@@ -325,7 +325,8 @@ } NGConstraintSpace NGFlexLayoutAlgorithm::BuildSpaceForIntrinsicBlockSize( - const NGBlockNode& flex_item) const { + const NGBlockNode& flex_item, + const NGPhysicalBoxStrut& physical_margins) const { const ComputedStyle& child_style = flex_item.Style(); NGConstraintSpaceBuilder space_builder(ConstraintSpace(), child_style.GetWritingMode(), @@ -334,16 +335,25 @@ space_builder.SetCacheSlot(NGCacheSlot::kMeasure); space_builder.SetIsPaintedAtomically(true); - if (ShouldItemShrinkToFit(flex_item)) + NGBoxStrut margins = physical_margins.ConvertToLogical( + ConstraintSpace().GetWritingMode(), Style().Direction()); + LogicalSize child_available_size = content_box_size_; + if (ShouldItemShrinkToFit(flex_item)) { space_builder.SetIsShrinkToFit(true); - // TODO(dgrogan): Do you need to account for item's min and max cross sizes - // before SetIsFixed{Inline,Block}Size(true) ? - if (WillChildCrossSizeBeContainerCrossSize(flex_item)) { + } else if (WillChildCrossSizeBeContainerCrossSize(flex_item)) { + // TODO(dgrogan): Do you need to further adjust available size by item's min + // and max cross sizes before SetIsFixed{Inline,Block}Size(true) ? if (is_column_) { space_builder.SetIsFixedInlineSize(true); + child_available_size.inline_size = + (child_available_size.inline_size - margins.InlineSum()) + .ClampNegativeToZero(); } else { space_builder.SetIsFixedBlockSize(true); DCHECK_NE(content_box_size_.block_size, kIndefiniteSize); + child_available_size.block_size = + (child_available_size.block_size - margins.BlockSum()) + .ClampNegativeToZero(); } } @@ -358,10 +368,10 @@ if (is_column_) child_percentage_size.block_size = kIndefiniteSize; + space_builder.SetAvailableSize(child_available_size); + space_builder.SetPercentageResolutionSize(child_percentage_size); // TODO(dgrogan): The SetReplacedPercentageResolutionSize calls in this file // may be untested. Write a test or determine why they're unnecessary. - space_builder.SetAvailableSize(content_box_size_); - space_builder.SetPercentageResolutionSize(child_percentage_size); space_builder.SetReplacedPercentageResolutionSize(child_percentage_size); space_builder.SetTextDirection(child_style.Direction()); return space_builder.ToConstraintSpace(); @@ -394,6 +404,9 @@ const ComputedStyle& child_style = child.Style(); NGConstraintSpace flex_basis_space = BuildSpaceForFlexBasis(child); + NGPhysicalBoxStrut physical_child_margins = + ComputePhysicalMargins(flex_basis_space, child_style); + NGBoxStrut border_padding_in_child_writing_mode = ComputeBorders(flex_basis_space, child_style) + ComputePadding(flex_basis_space, child_style); @@ -412,7 +425,8 @@ base::Optional<LayoutUnit> intrinsic_block_size; auto IntrinsicBlockSizeFunc = [&]() -> LayoutUnit { if (!intrinsic_block_size) { - NGConstraintSpace child_space = BuildSpaceForIntrinsicBlockSize(child); + NGConstraintSpace child_space = + BuildSpaceForIntrinsicBlockSize(child, physical_child_margins); intrinsic_block_size = child.Layout(child_space, /* break_token */ nullptr) ->IntrinsicBlockSize(); @@ -423,14 +437,15 @@ base::Optional<MinMaxSizes> min_max_size; auto MinMaxSizesFunc = [&]() -> MinMaxSizes { if (!min_max_size) { - // We want the child's min/max size in its writing mode, not ours. - // We'll only ever use it if the child's inline axis is our main axis. - NGConstraintSpace child_space = BuildSpaceForIntrinsicBlockSize(child); + NGConstraintSpace child_space = + BuildSpaceForIntrinsicBlockSize(child, physical_child_margins); if (child.Style().OverflowBlockDirection() == EOverflow::kAuto) { // Ensure this child has been laid out so its auto scrollbars are // included in its intrinsic sizes. IntrinsicBlockSizeFunc(); } + // We want the child's min/max size in its writing mode, not ours. + // We'll only ever use it if the child's inline axis is our main axis. min_max_size = child.ComputeMinMaxSizes( child_style.GetWritingMode(), MinMaxSizesInput(content_box_size_.block_size), &child_space); @@ -690,8 +705,6 @@ // TODO(dgrogan): Should min_max_sizes_in_cross_axis_direction include // cross_axis_border_padding? - NGPhysicalBoxStrut physical_child_margins = - ComputePhysicalMargins(flex_basis_space, child_style); algorithm_ ->emplace_back(nullptr, child.Style(), flex_base_content_size, min_max_sizes_in_main_axis_direction,
diff --git a/third_party/blink/renderer/core/layout/ng/ng_flex_layout_algorithm.h b/third_party/blink/renderer/core/layout/ng/ng_flex_layout_algorithm.h index d8d87e3..b7a0338 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_flex_layout_algorithm.h +++ b/third_party/blink/renderer/core/layout/ng/ng_flex_layout_algorithm.h
@@ -52,7 +52,8 @@ NGConstraintSpace BuildSpaceForFlexBasis(const NGBlockNode& flex_item) const; NGConstraintSpace BuildSpaceForIntrinsicBlockSize( - const NGBlockNode& flex_item) const; + const NGBlockNode& flex_item, + const NGPhysicalBoxStrut& physical_margins) const; void ConstructAndAppendFlexItems(); void ApplyStretchAlignmentToChild(FlexItem& flex_item); void GiveLinesAndItemsFinalPositionAndSize();
diff --git a/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h b/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h index da01a03..ab4061d 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h +++ b/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h
@@ -124,6 +124,14 @@ // Compute visual overflow of this box in the local coordinate. PhysicalRect ComputeSelfInkOverflow() const; + // Contents ink overflow includes anything that would bleed out of the box and + // would be clipped by the overflow clip ('overflow' != visible). This + // corresponds to children that overflows their parent. + PhysicalRect ContentsInkOverflow() const { + // TODO(layout-dev): Implement box fragment overflow. + return LocalRect(); + } + // Fragment offset is this fragment's offset from parent. // Needed to compensate for LayoutInline Legacy code offsets. void AddSelfOutlineRects(const PhysicalOffset& additional_offset,
diff --git a/third_party/blink/renderer/core/layout/ng/ng_physical_fragment.h b/third_party/blink/renderer/core/layout/ng/ng_physical_fragment.h index eaddf64..fe4422e0 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_physical_fragment.h +++ b/third_party/blink/renderer/core/layout/ng/ng_physical_fragment.h
@@ -11,7 +11,7 @@ #include "third_party/blink/renderer/core/layout/geometry/physical_offset.h" #include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" #include "third_party/blink/renderer/core/layout/geometry/physical_size.h" -#include "third_party/blink/renderer/core/layout/layout_object.h" +#include "third_party/blink/renderer/core/layout/layout_box.h" #include "third_party/blink/renderer/core/layout/ng/ng_style_variant.h" #include "third_party/blink/renderer/platform/graphics/touch_action.h" #include "third_party/blink/renderer/platform/wtf/ref_counted.h" @@ -210,6 +210,17 @@ // from GetNode() when this fragment is content of a pseudo node. Node* NodeForHitTest() const { return layout_object_->NodeForHitTest(); } + bool IsInSelfHitTestingPhase(HitTestAction action) const { + if (const auto* box = ToLayoutBoxOrNull(GetLayoutObject())) + return box->IsInSelfHitTestingPhase(action); + if (IsInlineBox()) + return action == kHitTestForeground; + // Assuming this is some sort of container, e.g. a fragmentainer (they don't + // have a LayoutObject associated). + return action == kHitTestBlockBackground || + action == kHitTestChildBlockBackground; + } + // Whether there is a PaintLayer associated with the fragment. bool HasLayer() const { return IsCSSBox() && layout_object_->HasLayer(); } @@ -273,6 +284,11 @@ // check if there were newer generations. const NGPhysicalFragment* PostLayout() const; + PhysicalRect InkOverflow() const { + // TODO(layout-dev): Implement box fragment overflow. + return LocalRect(); + } + // Scrollable overflow. including contents, in the local coordinate. PhysicalRect ScrollableOverflow() const;
diff --git a/third_party/blink/renderer/core/layout/scrollbars_test.cc b/third_party/blink/renderer/core/layout/scrollbars_test.cc index bc31ea9..a8efe8b0 100644 --- a/third_party/blink/renderer/core/layout/scrollbars_test.cc +++ b/third_party/blink/renderer/core/layout/scrollbars_test.cc
@@ -182,7 +182,7 @@ } void HandleMouseLeaveEvent() { - WebMouseEvent event(WebInputEvent::kMouseMove, gfx::PointF(1, 1), + WebMouseEvent event(WebInputEvent::kMouseLeave, gfx::PointF(1, 1), gfx::PointF(1, 1), WebPointerProperties::Button::kLeft, 0, WebInputEvent::Modifiers::kLeftButtonDown, base::TimeTicks::Now()); @@ -2313,7 +2313,8 @@ WebInputEvent::Modifiers::kLeftButtonDown, base::TimeTicks::Now()); event.SetFrameScale(1); - GetEventHandler().HandleMouseLeaveEvent(event); + GetEventHandler().HandleMouseMoveEvent(event, Vector<WebMouseEvent>(), + Vector<WebMouseEvent>()); EXPECT_EQ(scrollbar->PressedPart(), ScrollbarPart::kThumbPart); // Middle click should not release scrollbar press state.
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_container.h b/third_party/blink/renderer/core/layout/svg/layout_svg_container.h index ba23efa4..c0ec38b 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_container.h +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_container.h
@@ -24,6 +24,7 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LAYOUT_SVG_CONTAINER_H_ #include "third_party/blink/renderer/core/layout/svg/layout_svg_model_object.h" +#include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink { @@ -108,7 +109,12 @@ mutable bool has_non_isolated_blending_descendants_dirty_ : 1; }; -DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGContainer, IsSVGContainer()); +template <> +struct DowncastTraits<LayoutSVGContainer> { + static bool AllowFrom(const LayoutObject& object) { + return object.IsSVGContainer(); + } +}; } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object.h b/third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object.h index 838ac43a..9d38aab 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object.h +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object.h
@@ -22,6 +22,7 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LAYOUT_SVG_FOREIGN_OBJECT_H_ #include "third_party/blink/renderer/core/layout/svg/layout_svg_block.h" +#include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink { @@ -104,7 +105,12 @@ bool needs_transform_update_; }; -DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGForeignObject, IsSVGForeignObject()); +template <> +struct DowncastTraits<LayoutSVGForeignObject> { + static bool AllowFrom(const LayoutObject& object) { + return object.IsSVGForeignObject(); + } +}; } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/svg_layout_support.cc b/third_party/blink/renderer/core/layout/svg/svg_layout_support.cc index 8b262852..14eabbb 100644 --- a/third_party/blink/renderer/core/layout/svg/svg_layout_support.cc +++ b/third_party/blink/renderer/core/layout/svg/svg_layout_support.cc
@@ -210,10 +210,9 @@ bool& object_bounding_box_valid, LayoutObject* other, FloatRect other_bounding_box) { + auto* svg_container = DynamicTo<LayoutSVGContainer>(other); bool other_valid = - other->IsSVGContainer() - ? ToLayoutSVGContainer(other)->IsObjectBoundingBoxValid() - : true; + svg_container ? svg_container->IsObjectBoundingBoxValid() : true; if (!other_valid) return; @@ -236,8 +235,8 @@ if (object->IsSVGHiddenContainer()) return false; - if (object->IsSVGForeignObject()) - return ToLayoutSVGForeignObject(object)->IsObjectBoundingBoxValid(); + if (auto* foreign_object = DynamicTo<LayoutSVGForeignObject>(object)) + return foreign_object->IsObjectBoundingBoxValid(); if (object->IsSVGImage()) return ToLayoutSVGImage(object)->IsObjectBoundingBoxValid(); @@ -470,8 +469,8 @@ HitTestAction hit_test_action) { for (LayoutObject* child = last_child; child; child = child->PreviousSibling()) { - if (child->IsSVGForeignObject()) { - if (ToLayoutSVGForeignObject(child)->NodeAtPointFromSVG( + if (auto* foreign_object = DynamicTo<LayoutSVGForeignObject>(child)) { + if (foreign_object->NodeAtPointFromSVG( result, location, accumulated_offset, hit_test_action)) return true; } else {
diff --git a/third_party/blink/renderer/core/loader/frame_loader.cc b/third_party/blink/renderer/core/loader/frame_loader.cc index 61275b91..1bd9250 100644 --- a/third_party/blink/renderer/core/loader/frame_loader.cc +++ b/third_party/blink/renderer/core/loader/frame_loader.cc
@@ -700,7 +700,8 @@ mojo::PendingRemote<mojom::blink::NavigationInitiator> navigation_initiator; WTF::Vector<network::mojom::blink::ContentSecurityPolicyPtr> initiator_csp; network::mojom::blink::CSPSourcePtr initiator_self_source; - if (origin_document) { + if (origin_document && origin_document->GetContentSecurityPolicy() + ->ExperimentalFeaturesEnabled()) { initiator_csp = origin_document->GetContentSecurityPolicy() ->ExposeForNavigationalChecks(); initiator_self_source = origin_document->GetContentSecurityPolicy()
diff --git a/third_party/blink/renderer/core/loader/link_loader.cc b/third_party/blink/renderer/core/loader/link_loader.cc index 03514f9..7552148 100644 --- a/third_party/blink/renderer/core/loader/link_loader.cc +++ b/third_party/blink/renderer/core/loader/link_loader.cc
@@ -31,7 +31,6 @@ #include "third_party/blink/renderer/core/loader/link_loader.h" -#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/prerender/prerender_rel_type.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/frame/local_frame.h" @@ -219,9 +218,7 @@ Document& document, ResourceClient* link_client) { Document* document_for_origin = &document; - if (base::FeatureList::IsEnabled( - features::kHtmlImportsRequestInitiatorLock) && - document.ImportsController()) { + if (document.ImportsController()) { // For stylesheets loaded from HTML imported Documents, we use // context document for getting origin and ResourceFetcher to use the main // Document's origin, while using element document for CompleteURL() to use
diff --git a/third_party/blink/renderer/core/loader/resource/font_resource.cc b/third_party/blink/renderer/core/loader/resource/font_resource.cc index 96ae6ba..794161c5 100644 --- a/third_party/blink/renderer/core/loader/resource/font_resource.cc +++ b/third_party/blink/renderer/core/loader/resource/font_resource.cc
@@ -82,7 +82,7 @@ static_cast<FontResourceClient*>(c)->FontLoadLongLimitExceeded(this); } -void FontResource::SetRevalidatingRequest(const ResourceRequest& request) { +void FontResource::SetRevalidatingRequest(const ResourceRequestHead& request) { // Reload will use the same object, and needs to reset |m_loadLimitState| // before any didAddClient() is called again. DCHECK(IsLoaded());
diff --git a/third_party/blink/renderer/core/loader/resource/font_resource.h b/third_party/blink/renderer/core/loader/resource/font_resource.h index db0ad1d8..d31b28d 100644 --- a/third_party/blink/renderer/core/loader/resource/font_resource.h +++ b/third_party/blink/renderer/core/loader/resource/font_resource.h
@@ -53,7 +53,7 @@ void DidAddClient(ResourceClient*) override; - void SetRevalidatingRequest(const ResourceRequest&) override; + void SetRevalidatingRequest(const ResourceRequestHead&) override; void AllClientsAndObserversRemoved() override; void StartLoadLimitTimersIfNecessary(base::SingleThreadTaskRunner*);
diff --git a/third_party/blink/renderer/core/loader/resource/script_resource.cc b/third_party/blink/renderer/core/loader/resource/script_resource.cc index e7cc5bb0..a7a69c2 100644 --- a/third_party/blink/renderer/core/loader/resource/script_resource.cc +++ b/third_party/blink/renderer/core/loader/resource/script_resource.cc
@@ -231,7 +231,8 @@ SetDecodedSize(0); } -void ScriptResource::SetRevalidatingRequest(const ResourceRequest& request) { +void ScriptResource::SetRevalidatingRequest( + const ResourceRequestHead& request) { CHECK_EQ(streaming_state_, StreamingState::kFinishedNotificationSent); if (streamer_) { CHECK(streamer_->IsStreamingFinished());
diff --git a/third_party/blink/renderer/core/loader/resource/script_resource.h b/third_party/blink/renderer/core/loader/resource/script_resource.h index 8e07c12..791b32f9 100644 --- a/third_party/blink/renderer/core/loader/resource/script_resource.h +++ b/third_party/blink/renderer/core/loader/resource/script_resource.h
@@ -150,7 +150,7 @@ bool HasFinishedStreamer() { return streamer_ && streamer_->IsFinished(); } // Visible for tests. - void SetRevalidatingRequest(const ResourceRequest&) override; + void SetRevalidatingRequest(const ResourceRequestHead&) override; protected: CachedMetadataHandler* CreateCachedMetadataHandler(
diff --git a/third_party/blink/renderer/core/loader/resource_load_observer_for_frame.cc b/third_party/blink/renderer/core/loader/resource_load_observer_for_frame.cc index 4f37590..6d296c8 100644 --- a/third_party/blink/renderer/core/loader/resource_load_observer_for_frame.cc +++ b/third_party/blink/renderer/core/loader/resource_load_observer_for_frame.cc
@@ -133,7 +133,7 @@ if (response_source == ResponseSource::kFromMemoryCache) { frame_client->DispatchDidLoadResourceFromMemoryCache( - resource->GetResourceRequest(), response); + ResourceRequest(resource->GetResourceRequest()), response); // Note: probe::WillSendRequest needs to precede before this probe method. probe::MarkResourceAsCached(&frame, &document_loader, identifier);
diff --git a/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.cc b/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.cc index 336c095..c1db8fad 100644 --- a/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.cc +++ b/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.cc
@@ -424,6 +424,7 @@ base::UmaHistogramEnumeration("Blink.Canvas.ResourceProviderType", ResourceProvider()->GetType()); ResourceProvider()->Clear(); + DidDraw(); if (needs_matrix_clip_restore_) { needs_matrix_clip_restore_ = false;
diff --git a/third_party/blink/renderer/core/paint/box_painter.cc b/third_party/blink/renderer/core/paint/box_painter.cc index b6069eb..1027a56 100644 --- a/third_party/blink/renderer/core/paint/box_painter.cc +++ b/third_party/blink/renderer/core/paint/box_painter.cc
@@ -46,9 +46,8 @@ PaintInfo child_info(paint_info); for (LayoutObject* child = layout_box_.SlowFirstChild(); child; child = child->NextSibling()) { - if (child->IsSVGForeignObject()) { - SVGForeignObjectPainter(ToLayoutSVGForeignObject(*child)) - .PaintLayer(paint_info); + if (auto* foreign_object = DynamicTo<LayoutSVGForeignObject>(*child)) { + SVGForeignObjectPainter(*foreign_object).PaintLayer(paint_info); } else { child->Paint(child_info); }
diff --git a/third_party/blink/renderer/core/paint/image_element_timing_test.cc b/third_party/blink/renderer/core/paint/image_element_timing_test.cc index 9940891..c39619a 100644 --- a/third_party/blink/renderer/core/paint/image_element_timing_test.cc +++ b/third_party/blink/renderer/core/paint/image_element_timing_test.cc
@@ -10,6 +10,7 @@ #include "third_party/blink/renderer/core/layout/svg/layout_svg_image.h" #include "third_party/blink/renderer/core/loader/resource/image_resource_content.h" #include "third_party/blink/renderer/platform/graphics/unaccelerated_static_bitmap_image.h" +#include "third_party/blink/renderer/platform/testing/paint_test_configurations.h" #include "third_party/blink/renderer/platform/testing/url_test_helpers.h" #include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/core/SkSurface.h" @@ -22,7 +23,8 @@ } -class ImageElementTimingTest : public testing::Test { +class ImageElementTimingTest : public testing::Test, + public PaintTestConfigurations { protected: void SetUp() override { web_view_helper_.Initialize(); @@ -107,13 +109,18 @@ } }; -TEST_F(ImageElementTimingTest, TestIsExplicitlyRegisteredForTiming) { +INSTANTIATE_PAINT_TEST_SUITE_P(ImageElementTimingTest); + +TEST_P(ImageElementTimingTest, TestIsExplicitlyRegisteredForTiming) { frame_test_helpers::LoadHTMLString( web_view_helper_.GetWebView()->MainFrameImpl(), R"HTML( <img id="missing-attribute" style='width: 100px; height: 100px;'/> - <img id="unset-attribute" elementtiming style='width: 100px; height: 100px;'/> - <img id="empty-attribute" elementtiming="" style='width: 100px; height: 100px;'/> - <img id="valid-attribute" elementtiming="valid-id" style='width: 100px; height: 100px;'/> + <img id="unset-attribute" elementtiming + style='width: 100px; height: 100px;'/> + <img id="empty-attribute" elementtiming="" + style='width: 100px; height: 100px;'/> + <img id="valid-attribute" elementtiming="valid-id" + style='width: 100px; height: 100px;'/> )HTML", base_url_); @@ -141,7 +148,7 @@ "should be explicitly registered."; } -TEST_F(ImageElementTimingTest, IgnoresUnmarkedElement) { +TEST_P(ImageElementTimingTest, IgnoresUnmarkedElement) { // Tests that, if the 'elementtiming' attribute is missing, the element isn't // considered by ImageElementTiming. frame_test_helpers::LoadHTMLString( @@ -156,12 +163,13 @@ std::make_pair(layout_image, layout_image->CachedImage()))); } -TEST_F(ImageElementTimingTest, ImageInsideSVG) { +TEST_P(ImageElementTimingTest, ImageInsideSVG) { frame_test_helpers::LoadHTMLString( web_view_helper_.GetWebView()->MainFrameImpl(), R"HTML( <svg> <foreignObject width="100" height="100"> - <img elementtiming="image-inside-svg" id="target" style='width: 100px; height: 100px;'/> + <img elementtiming="image-inside-svg" id="target" + style='width: 100px; height: 100px;'/> </foreignObject> </svg> )HTML", @@ -175,13 +183,14 @@ std::make_pair(layout_image, layout_image->CachedImage()))); } -TEST_F(ImageElementTimingTest, ImageInsideNonRenderedSVG) { +TEST_P(ImageElementTimingTest, ImageInsideNonRenderedSVG) { frame_test_helpers::LoadHTMLString( web_view_helper_.GetWebView()->MainFrameImpl(), R"HTML( <svg mask="url(#mask)"> <mask id="mask"> <foreignObject width="100" height="100"> - <img elementtiming="image-inside-svg" id="target" style='width: 100px; height: 100px;'/> + <img elementtiming="image-inside-svg" id="target" + style='width: 100px; height: 100px;'/> </foreignObject> </mask> <rect width="100" height="100" fill="green"/> @@ -195,10 +204,11 @@ EXPECT_FALSE(GetLayoutObjectById("target")); } -TEST_F(ImageElementTimingTest, ImageRemoved) { +TEST_P(ImageElementTimingTest, ImageRemoved) { frame_test_helpers::LoadHTMLString( web_view_helper_.GetWebView()->MainFrameImpl(), R"HTML( - <img elementtiming="will-be-removed" id="target" style='width: 100px; height: 100px;'/> + <img elementtiming="will-be-removed" id="target" + style='width: 100px; height: 100px;'/> )HTML", base_url_); LayoutImage* layout_image = SetImageResource("target", 5, 5); @@ -213,11 +223,12 @@ EXPECT_EQ(ImagesNotifiedSize(), 0u); } -TEST_F(ImageElementTimingTest, SVGImageRemoved) { +TEST_P(ImageElementTimingTest, SVGImageRemoved) { frame_test_helpers::LoadHTMLString( web_view_helper_.GetWebView()->MainFrameImpl(), R"HTML( <svg> - <image elementtiming="svg-will-be-removed" id="target" style='width: 100px; height: 100px;'/> + <image elementtiming="svg-will-be-removed" id="target" + style='width: 100px; height: 100px;'/> </svg> )HTML", base_url_); @@ -233,7 +244,7 @@ EXPECT_EQ(ImagesNotifiedSize(), 0u); } -TEST_F(ImageElementTimingTest, BackgroundImageRemoved) { +TEST_P(ImageElementTimingTest, BackgroundImageRemoved) { frame_test_helpers::LoadHTMLString( web_view_helper_.GetWebView()->MainFrameImpl(), R"HTML( <style>
diff --git a/third_party/blink/renderer/core/paint/image_paint_timing_detector_test.cc b/third_party/blink/renderer/core/paint/image_paint_timing_detector_test.cc index 83f3a70..66125f8 100644 --- a/third_party/blink/renderer/core/paint/image_paint_timing_detector_test.cc +++ b/third_party/blink/renderer/core/paint/image_paint_timing_detector_test.cc
@@ -25,7 +25,7 @@ #include "third_party/blink/renderer/platform/graphics/unaccelerated_static_bitmap_image.h" #include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h" -#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h" +#include "third_party/blink/renderer/platform/testing/paint_test_configurations.h" #include "third_party/blink/renderer/platform/testing/unit_test_helpers.h" #include "third_party/blink/renderer/platform/testing/url_test_helpers.h" #include "third_party/skia/include/core/SkImage.h" @@ -33,7 +33,25 @@ namespace blink { -class ImagePaintTimingDetectorTest : public testing::Test { +#define SIMPLE_IMAGE \ + "url(data:image/gif;base64," \ + "R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==)" + +#define LARGE_IMAGE \ + "url(data:image/gif;base64," \ + "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSF" \ + "lzAAAN1wAADdcBQiibeAAAAb5JREFUOMulkr1KA0EQgGdvTwwnYmER0gQsrFKmSy+pLESw9Qm0" \ + "F/ICNnba+h6iEOuAEWslKJKTOyJJvIT72d1xZuOFC0giOLA77O7Mt/PnNptN+I+49Xr9GhH3f3" \ + "mb0v1ht9vtLAUYYw5ItkgDL3KyD8PhcLvdbl/WarXT3DjLMnAcR/f7/YfxeKwtgC5RKQVhGILW" \ + "eg4hQ6hUKjWyucmhLFEUuWR3QYBWAZABQ9i5CCmXy16pVALP80BKaaG+70MQBLvzFMjRKKXh8j" \ + "6FSYKF7ITdEWLa4/ktokN74wiqjSMpnVcbQZqmEJHz+ckeCPFjWKwULpyspAqhdXVXdcnZcPjs" \ + "Ign+2BsVA8jVYuWlgJ3yBj0icgq2uoK+lg4t+ZvLomSKamSQ4AI5BcMADtMhyNoSgNIISUaFNt" \ + "wlazcDcBc4gjjVwCWid2usCWroYEhnaqbzFJLUzAHIXRDChXCcQP8zhkSZ5eNLgHAUzwDcRu4C" \ + "oIRn/wsGUQIIy4Vr9TH6SYFCNzw4nALn5627K4vIttOUOwfa5YnrDYzt/9OLv9I5l8kk5hZ3XL" \ + "O20b7tbR7zHLy/BX8G0IeBEM7ZN1NGIaFUaKLgAAAAAElFTkSuQmCC)" + +class ImagePaintTimingDetectorTest : public testing::Test, + public PaintTestConfigurations { public: ImagePaintTimingDetectorTest() : test_task_runner_( @@ -270,7 +288,9 @@ constexpr base::TimeDelta ImagePaintTimingDetectorTest::kQuantumOfTime; -TEST_F(ImagePaintTimingDetectorTest, LargestImagePaint_NoImage) { +INSTANTIATE_PAINT_TEST_SUITE_P(ImagePaintTimingDetectorTest); + +TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_NoImage) { SetBodyInnerHTML(R"HTML( <div></div> )HTML"); @@ -278,7 +298,7 @@ EXPECT_FALSE(record); } -TEST_F(ImagePaintTimingDetectorTest, LargestImagePaint_OneImage) { +TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_OneImage) { SetBodyInnerHTML(R"HTML( <img id="target"></img> )HTML"); @@ -290,7 +310,7 @@ EXPECT_TRUE(record->loaded); } -TEST_F(ImagePaintTimingDetectorTest, InsertionOrderIsSecondaryRankingKey) { +TEST_P(ImagePaintTimingDetectorTest, InsertionOrderIsSecondaryRankingKey) { SetBodyInnerHTML(R"HTML( )HTML"); @@ -315,7 +335,7 @@ DOMNodeIds::ExistingIdForNode(image1)); } -TEST_F(ImagePaintTimingDetectorTest, LargestImagePaint_TraceEvent_Candidate) { +TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_TraceEvent_Candidate) { using trace_analyzer::Query; trace_analyzer::Start("loading"); { @@ -356,7 +376,7 @@ EXPECT_EQ(false, isOOPIF); } -TEST_F(ImagePaintTimingDetectorTest, LargestImagePaint_TraceEvent_NoCandidate) { +TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_TraceEvent_NoCandidate) { using trace_analyzer::Query; trace_analyzer::Start("*"); { @@ -406,7 +426,7 @@ } } -TEST_F(ImagePaintTimingDetectorTest, UpdatePerformanceTiming) { +TEST_P(ImagePaintTimingDetectorTest, UpdatePerformanceTiming) { EXPECT_EQ(GetPerformanceTiming().LargestImagePaintSize(), 0u); EXPECT_EQ(GetPerformanceTiming().LargestImagePaint(), 0u); SetBodyInnerHTML(R"HTML( @@ -418,7 +438,7 @@ EXPECT_GT(GetPerformanceTiming().LargestImagePaint(), 0u); } -TEST_F(ImagePaintTimingDetectorTest, +TEST_P(ImagePaintTimingDetectorTest, PerformanceTimingHasZeroTimeNonZeroSizeWhenTheLargestIsNotPainted) { EXPECT_EQ(GetPerformanceTiming().LargestImagePaintSize(), 0u); EXPECT_EQ(GetPerformanceTiming().LargestImagePaint(), 0u); @@ -431,7 +451,7 @@ EXPECT_EQ(GetPerformanceTiming().LargestImagePaint(), 0u); } -TEST_F(ImagePaintTimingDetectorTest, UpdatePerformanceTimingToZero) { +TEST_P(ImagePaintTimingDetectorTest, UpdatePerformanceTimingToZero) { SetBodyInnerHTML(R"HTML( <img id="target"></img> )HTML"); @@ -445,7 +465,7 @@ EXPECT_EQ(GetPerformanceTiming().LargestImagePaint(), 0u); } -TEST_F(ImagePaintTimingDetectorTest, LargestImagePaint_OpacityZero) { +TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_OpacityZero) { SetBodyInnerHTML(R"HTML( <style> img { @@ -461,7 +481,7 @@ EXPECT_FALSE(record); } -TEST_F(ImagePaintTimingDetectorTest, LargestImagePaint_VisibilityHidden) { +TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_VisibilityHidden) { SetBodyInnerHTML(R"HTML( <style> img { @@ -477,7 +497,7 @@ EXPECT_FALSE(record); } -TEST_F(ImagePaintTimingDetectorTest, LargestImagePaint_DisplayNone) { +TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_DisplayNone) { SetBodyInnerHTML(R"HTML( <style> img { @@ -493,7 +513,7 @@ EXPECT_FALSE(record); } -TEST_F(ImagePaintTimingDetectorTest, LargestImagePaint_OpacityNonZero) { +TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_OpacityNonZero) { SetBodyInnerHTML(R"HTML( <style> img { @@ -509,7 +529,7 @@ EXPECT_TRUE(record); } -TEST_F(ImagePaintTimingDetectorTest, +TEST_P(ImagePaintTimingDetectorTest, IgnoreImageUntilInvalidatedRectSizeNonZero) { SetBodyInnerHTML(R"HTML( <img id="target"></img> @@ -523,7 +543,7 @@ EXPECT_EQ(CountVisibleImageRecords(), 1u); } -TEST_F(ImagePaintTimingDetectorTest, LargestImagePaint_Largest) { +TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_Largest) { SetBodyInnerHTML(R"HTML( <style>img { display:block }</style> <img id="smaller"></img> @@ -541,7 +561,7 @@ UpdateAllLifecyclePhasesAndInvokeCallbackIfAny(); } -TEST_F(ImagePaintTimingDetectorTest, +TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_IgnoreThoseOutsideViewport) { SetBodyInnerHTML(R"HTML( <style> @@ -558,7 +578,7 @@ EXPECT_FALSE(record); } -TEST_F(ImagePaintTimingDetectorTest, +TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_UpdateOnRemovingTheLastImage) { SetBodyInnerHTML(R"HTML( <div id="parent"> @@ -580,7 +600,7 @@ EXPECT_EQ(LargestPaintStoredResult(), base::TimeTicks()); } -TEST_F(ImagePaintTimingDetectorTest, LargestImagePaint_UpdateOnRemoving) { +TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_UpdateOnRemoving) { SetBodyInnerHTML(R"HTML( <div id="parent"> <img id="target1"></img> @@ -612,7 +632,7 @@ EXPECT_EQ(first_largest_image_paint, LargestPaintStoredResult()); } -TEST_F(ImagePaintTimingDetectorTest, +TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_NodeRemovedBetweenRegistrationAndInvocation) { SetBodyInnerHTML(R"HTML( <div id="parent"> @@ -632,7 +652,7 @@ EXPECT_FALSE(record); } -TEST_F(ImagePaintTimingDetectorTest, +TEST_P(ImagePaintTimingDetectorTest, RemoveRecordFromAllContainersAfterImageRemoval) { SetBodyInnerHTML(R"HTML( <div id="parent"> @@ -648,8 +668,12 @@ EXPECT_EQ(ContainerTotalSize(), 0u); } -TEST_F(ImagePaintTimingDetectorTest, +TEST_P(ImagePaintTimingDetectorTest, RemoveRecordFromAllContainersAfterInvisibleImageRemoved) { + // TODO(wangxianzhu): Fix this test for CompositeAfterPaint. + if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) + return; + SetBodyInnerHTML(R"HTML( <style> #target { @@ -677,12 +701,12 @@ EXPECT_EQ(CountInvisibleRecords(), 0u); } -TEST_F(ImagePaintTimingDetectorTest, +TEST_P(ImagePaintTimingDetectorTest, RemoveRecordFromAllContainersAfterBackgroundImageRemoval) { SetBodyInnerHTML(R"HTML( <style> #target { - background-image: url(data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==); + background-image: )HTML" SIMPLE_IMAGE R"HTML(; } </style> <div id="parent"> @@ -699,7 +723,7 @@ EXPECT_EQ(ContainerTotalSize(), 0u); } -TEST_F(ImagePaintTimingDetectorTest, +TEST_P(ImagePaintTimingDetectorTest, RemoveRecordFromAllContainersAfterImageRemovedAndCallbackInvoked) { SetBodyInnerHTML(R"HTML( <div id="parent"> @@ -717,7 +741,7 @@ EXPECT_EQ(ContainerTotalSize(), 0u); } -TEST_F(ImagePaintTimingDetectorTest, +TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_ReattachedNodeTreatedAsNew) { SetBodyInnerHTML(R"HTML( <div id="parent"> @@ -760,7 +784,7 @@ // This is to prove that a swap time is assigned only to nodes of the frame who // register the swap time. In other words, swap time A should match frame A; // swap time B should match frame B. -TEST_F(ImagePaintTimingDetectorTest, MatchSwapTimeToNodesOfDifferentFrames) { +TEST_P(ImagePaintTimingDetectorTest, MatchSwapTimeToNodesOfDifferentFrames) { SetBodyInnerHTML(R"HTML( <div id="parent"> <img height="5" width="5" id="smaller"></img> @@ -788,7 +812,7 @@ EXPECT_NE(record1Time, record2->paint_time); } -TEST_F(ImagePaintTimingDetectorTest, +TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_UpdateResultWhenLargestChanged) { base::TimeTicks time1 = test_task_runner_->NowTicks(); SetBodyInnerHTML(R"HTML( @@ -812,7 +836,7 @@ EXPECT_GE(time3, result2); } -TEST_F(ImagePaintTimingDetectorTest, OneSwapPromiseForOneFrame) { +TEST_P(ImagePaintTimingDetectorTest, OneSwapPromiseForOneFrame) { SetBodyInnerHTML(R"HTML( <style>img { display:block }</style> <div id="parent"> @@ -844,7 +868,7 @@ EXPECT_FALSE(record->paint_time.is_null()); } -TEST_F(ImagePaintTimingDetectorTest, VideoImage) { +TEST_P(ImagePaintTimingDetectorTest, VideoImage) { SetBodyInnerHTML(R"HTML( <video id="target"></video> )HTML"); @@ -858,17 +882,15 @@ EXPECT_TRUE(record->loaded); } -TEST_F(ImagePaintTimingDetectorTest, VideoImage_ImageNotLoaded) { - SetBodyInnerHTML(R"HTML( - <video id="target"></video> - )HTML"); +TEST_P(ImagePaintTimingDetectorTest, VideoImage_ImageNotLoaded) { + SetBodyInnerHTML("<video id='target'></video>"); UpdateAllLifecyclePhasesAndInvokeCallbackIfAny(); ImageRecord* record = FindLargestPaintCandidate(); EXPECT_FALSE(record); } -TEST_F(ImagePaintTimingDetectorTest, SVGImage) { +TEST_P(ImagePaintTimingDetectorTest, SVGImage) { SetBodyInnerHTML(R"HTML( <svg> <image id="target" width="10" height="10"/> @@ -884,28 +906,26 @@ EXPECT_TRUE(record->loaded); } -TEST_F(ImagePaintTimingDetectorTest, BackgroundImage) { +TEST_P(ImagePaintTimingDetectorTest, BackgroundImage) { SetBodyInnerHTML(R"HTML( <style> div { - background-image: url(data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==); + background-image: )HTML" SIMPLE_IMAGE R"HTML(; } </style> - <div> - place-holder - </div> + <div>place-holder</div> )HTML"); ImageRecord* record = FindLargestPaintCandidate(); EXPECT_TRUE(record); EXPECT_EQ(CountVisibleImageRecords(), 1u); } -TEST_F(ImagePaintTimingDetectorTest, +TEST_P(ImagePaintTimingDetectorTest, BackgroundImageAndLayoutImageTrackedDifferently) { SetBodyInnerHTML(R"HTML( <style> img { - background-image: url(data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAAb5JREFUOMulkr1KA0EQgGdvTwwnYmER0gQsrFKmSy+pLESw9Qm0F/ICNnba+h6iEOuAEWslKJKTOyJJvIT72d1xZuOFC0giOLA77O7Mt/PnNptN+I+49Xr9GhH3f3mb0v1ht9vtLAUYYw5ItkgDL3KyD8PhcLvdbl/WarXT3DjLMnAcR/f7/YfxeKwtgC5RKQVhGILWeg4hQ6hUKjWyucmhLFEUuWR3QYBWAZABQ9i5CCmXy16pVALP80BKaaG+70MQBLvzFMjRKKXh8j6FSYKF7ITdEWLa4/ktokN74wiqjSMpnVcbQZqmEJHz+ckeCPFjWKwULpyspAqhdXVXdcnZcPjsIgn+2BsVA8jVYuWlgJ3yBj0icgq2uoK+lg4t+ZvLomSKamSQ4AI5BcMADtMhyNoSgNIISUaFNtwlazcDcBc4gjjVwCWid2usCWroYEhnaqbzFJLUzAHIXRDChXCcQP8zhkSZ5eNLgHAUzwDcRu4CoIRn/wsGUQIIy4Vr9TH6SYFCNzw4nALn5627K4vIttOUOwfa5YnrDYzt/9OLv9I5l8kk5hZ3XLO20b7tbR7zHLy/BX8G0IeBEM7ZN1NGIaFUaKLgAAAAAElFTkSuQmCC); + background-image: )HTML" LARGE_IMAGE R"HTML(; } </style> <img id="target"> @@ -920,31 +940,17 @@ EXPECT_EQ(record->first_size, 1u); } -TEST_F(ImagePaintTimingDetectorTest, BackgroundImage_IgnoreBody) { - SetBodyInnerHTML(R"HTML( - <style> - body { - background-image: url(data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==); - } - </style> - )HTML"); +TEST_P(ImagePaintTimingDetectorTest, BackgroundImage_IgnoreBody) { + SetBodyInnerHTML("<style>body { background-image: " SIMPLE_IMAGE "}</style>"); EXPECT_EQ(CountVisibleImageRecords(), 0u); } -TEST_F(ImagePaintTimingDetectorTest, BackgroundImage_IgnoreHtml) { - SetBodyInnerHTML(R"HTML( - <html> - <style> - html { - background-image: url(data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==); - } - </style> - </html> - )HTML"); +TEST_P(ImagePaintTimingDetectorTest, BackgroundImage_IgnoreHtml) { + SetBodyInnerHTML("<style>html { background-image: " SIMPLE_IMAGE "}</style>"); EXPECT_EQ(CountVisibleImageRecords(), 0u); } -TEST_F(ImagePaintTimingDetectorTest, BackgroundImage_IgnoreGradient) { +TEST_P(ImagePaintTimingDetectorTest, BackgroundImage_IgnoreGradient) { SetBodyInnerHTML(R"HTML( <style> div { @@ -960,15 +966,14 @@ // We put two background images in the same object, and test whether FCP++ can // find two different images. -TEST_F(ImagePaintTimingDetectorTest, BackgroundImageTrackedDifferently) { +TEST_P(ImagePaintTimingDetectorTest, BackgroundImageTrackedDifferently) { SetBodyInnerHTML(R"HTML( <style> #d { width: 50px; height: 50px; background-image: - url("data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="), - url("data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAAb5JREFUOMulkr1KA0EQgGdvTwwnYmER0gQsrFKmSy+pLESw9Qm0F/ICNnba+h6iEOuAEWslKJKTOyJJvIT72d1xZuOFC0giOLA77O7Mt/PnNptN+I+49Xr9GhH3f3mb0v1ht9vtLAUYYw5ItkgDL3KyD8PhcLvdbl/WarXT3DjLMnAcR/f7/YfxeKwtgC5RKQVhGILWeg4hQ6hUKjWyucmhLFEUuWR3QYBWAZABQ9i5CCmXy16pVALP80BKaaG+70MQBLvzFMjRKKXh8j6FSYKF7ITdEWLa4/ktokN74wiqjSMpnVcbQZqmEJHz+ckeCPFjWKwULpyspAqhdXVXdcnZcPjsIgn+2BsVA8jVYuWlgJ3yBj0icgq2uoK+lg4t+ZvLomSKamSQ4AI5BcMADtMhyNoSgNIISUaFNtwlazcDcBc4gjjVwCWid2usCWroYEhnaqbzFJLUzAHIXRDChXCcQP8zhkSZ5eNLgHAUzwDcRu4CoIRn/wsGUQIIy4Vr9TH6SYFCNzw4nALn5627K4vIttOUOwfa5YnrDYzt/9OLv9I5l8kk5hZ3XLO20b7tbR7zHLy/BX8G0IeBEM7ZN1NGIaFUaKLgAAAAAElFTkSuQmCC"); + )HTML" SIMPLE_IMAGE "," LARGE_IMAGE R"HTML(; } </style> <div id="d"></div> @@ -976,7 +981,7 @@ EXPECT_EQ(CountVisibleImageRecords(), 2u); } -TEST_F(ImagePaintTimingDetectorTest, DeactivateAfterUserInput) { +TEST_P(ImagePaintTimingDetectorTest, DeactivateAfterUserInput) { SetBodyInnerHTML(R"HTML( <div id="parent"> <img id="target"></img> @@ -988,7 +993,7 @@ EXPECT_FALSE(GetPaintTimingDetector().GetImagePaintTimingDetector()); } -TEST_F(ImagePaintTimingDetectorTest, ContinueAfterKeyUp) { +TEST_P(ImagePaintTimingDetectorTest, ContinueAfterKeyUp) { SetBodyInnerHTML(R"HTML( <div id="parent"> <img id="target"></img> @@ -1000,7 +1005,7 @@ EXPECT_TRUE(GetPaintTimingDetector().GetImagePaintTimingDetector()); } -TEST_F(ImagePaintTimingDetectorTest, NullTimeNoCrash) { +TEST_P(ImagePaintTimingDetectorTest, NullTimeNoCrash) { SetBodyInnerHTML(R"HTML( <img id="target"></img> )HTML"); @@ -1009,7 +1014,7 @@ UpdateCandidate(); } -TEST_F(ImagePaintTimingDetectorTest, Iframe) { +TEST_P(ImagePaintTimingDetectorTest, Iframe) { SetBodyInnerHTML(R"HTML( <iframe width=100px height=100px></iframe> )HTML"); @@ -1029,7 +1034,7 @@ EXPECT_EQ(image->first_size, 25ul); } -TEST_F(ImagePaintTimingDetectorTest, Iframe_ClippedByMainFrameViewport) { +TEST_P(ImagePaintTimingDetectorTest, Iframe_ClippedByMainFrameViewport) { SetBodyInnerHTML(R"HTML( <style> #f { margin-top: 1234567px } @@ -1047,7 +1052,7 @@ EXPECT_EQ(CountVisibleImageRecords(), 0u); } -TEST_F(ImagePaintTimingDetectorTest, Iframe_HalfClippedByMainFrameViewport) { +TEST_P(ImagePaintTimingDetectorTest, Iframe_HalfClippedByMainFrameViewport) { SetBodyInnerHTML(R"HTML( <style> #f { margin-left: -5px; } @@ -1068,7 +1073,7 @@ EXPECT_LT(image->first_size, 100ul); } -TEST_F(ImagePaintTimingDetectorTest, SameSizeShouldNotBeIgnored) { +TEST_P(ImagePaintTimingDetectorTest, SameSizeShouldNotBeIgnored) { SetBodyInnerHTML(R"HTML( <style>img { display:block }</style> <img id='1'></img> @@ -1082,7 +1087,7 @@ EXPECT_EQ(CountRankingSetRecords(), 3u); } -TEST_F(ImagePaintTimingDetectorTest, UseIntrinsicSizeIfSmaller_Image) { +TEST_P(ImagePaintTimingDetectorTest, UseIntrinsicSizeIfSmaller_Image) { SetBodyInnerHTML(R"HTML( <img height="300" width="300" display="block" id="target"> </img> @@ -1094,7 +1099,7 @@ EXPECT_EQ(record->first_size, 25u); } -TEST_F(ImagePaintTimingDetectorTest, NotUseIntrinsicSizeIfLarger_Image) { +TEST_P(ImagePaintTimingDetectorTest, NotUseIntrinsicSizeIfLarger_Image) { SetBodyInnerHTML(R"HTML( <img height="1" width="1" display="block" id="target"> </img> @@ -1106,14 +1111,14 @@ EXPECT_EQ(record->first_size, 1u); } -TEST_F(ImagePaintTimingDetectorTest, +TEST_P(ImagePaintTimingDetectorTest, UseIntrinsicSizeIfSmaller_BackgroundImage) { SetBodyInnerHTML(R"HTML( <style> #d { width: 50px; height: 50px; - background-image: url("data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="); + background-image: )HTML" SIMPLE_IMAGE R"HTML(; } </style> <div id="d"></div> @@ -1123,7 +1128,7 @@ EXPECT_EQ(record->first_size, 1u); } -TEST_F(ImagePaintTimingDetectorTest, +TEST_P(ImagePaintTimingDetectorTest, NotUseIntrinsicSizeIfLarger_BackgroundImage) { // The image is in 16x16. SetBodyInnerHTML(R"HTML( @@ -1131,7 +1136,7 @@ #d { width: 5px; height: 5px; - background-image: url("data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAAb5JREFUOMulkr1KA0EQgGdvTwwnYmER0gQsrFKmSy+pLESw9Qm0F/ICNnba+h6iEOuAEWslKJKTOyJJvIT72d1xZuOFC0giOLA77O7Mt/PnNptN+I+49Xr9GhH3f3mb0v1ht9vtLAUYYw5ItkgDL3KyD8PhcLvdbl/WarXT3DjLMnAcR/f7/YfxeKwtgC5RKQVhGILWeg4hQ6hUKjWyucmhLFEUuWR3QYBWAZABQ9i5CCmXy16pVALP80BKaaG+70MQBLvzFMjRKKXh8j6FSYKF7ITdEWLa4/ktokN74wiqjSMpnVcbQZqmEJHz+ckeCPFjWKwULpyspAqhdXVXdcnZcPjsIgn+2BsVA8jVYuWlgJ3yBj0icgq2uoK+lg4t+ZvLomSKamSQ4AI5BcMADtMhyNoSgNIISUaFNtwlazcDcBc4gjjVwCWid2usCWroYEhnaqbzFJLUzAHIXRDChXCcQP8zhkSZ5eNLgHAUzwDcRu4CoIRn/wsGUQIIy4Vr9TH6SYFCNzw4nALn5627K4vIttOUOwfa5YnrDYzt/9OLv9I5l8kk5hZ3XLO20b7tbR7zHLy/BX8G0IeBEM7ZN1NGIaFUaKLgAAAAAElFTkSuQmCC"); + background-image: )HTML" LARGE_IMAGE R"HTML(; } </style> <div id="d"></div>
diff --git a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc index 1b481a5a..f55446f 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc
@@ -297,9 +297,9 @@ } PhysicalRect NGBoxFragmentPainter::ContentsInkOverflow() const { - const NGPhysicalFragment& fragment = PhysicalFragment(); - return ToLayoutBox(fragment.GetLayoutObject()) - ->PhysicalContentsVisualOverflowRect(); + if (const LayoutObject* layout_object = box_fragment_.GetLayoutObject()) + return ToLayoutBox(layout_object)->PhysicalContentsVisualOverflowRect(); + return box_fragment_.ContentsInkOverflow(); } void NGBoxFragmentPainter::Paint(const PaintInfo& paint_info) { @@ -490,7 +490,7 @@ paint_offset); } } else { - PaintBlockChildren(paint_info); + PaintBlockChildren(paint_info, paint_offset); } } @@ -537,7 +537,8 @@ // When the layout-tree gets into a bad state, we can end up trying to paint // a fragment with inline children, without a paint fragment. See: // http://crbug.com/1022545 - if ((!paint_fragment_ && !items_) || layout_object->NeedsLayout()) { + if ((!paint_fragment_ && !items_) || + (layout_object && layout_object->NeedsLayout())) { NOTREACHED(); return; } @@ -560,9 +561,6 @@ if (!paint_info.GetCullRect().Intersects(content_ink_rect.ToLayoutRect())) return; - DCHECK(layout_object->IsLayoutBlockFlow()); - const auto& layout_block = To<LayoutBlock>(*layout_object); - DCHECK(layout_block.ChildrenInline()); if (paint_fragment_) { NGInlineCursor children(*paint_fragment_); PaintLineBoxChildren(&children, paint_info.ForDescendants(), paint_offset); @@ -573,7 +571,8 @@ PaintLineBoxChildren(&children, paint_info.ForDescendants(), paint_offset); } -void NGBoxFragmentPainter::PaintBlockChildren(const PaintInfo& paint_info) { +void NGBoxFragmentPainter::PaintBlockChildren(const PaintInfo& paint_info, + PhysicalOffset paint_offset) { DCHECK(!box_fragment_.IsInlineFormattingContext()); PaintInfo paint_info_for_descendants = paint_info.ForDescendants(); for (const NGLink& child : box_fragment_.Children()) { @@ -585,6 +584,19 @@ const auto& box_child_fragment = To<NGPhysicalBoxFragment>(child_fragment); if (box_child_fragment.CanTraverse()) { + if (!box_child_fragment.GetLayoutObject()) { + // It's normally FragmentData that provides us with the paint offset. + // FragmentData is (at least currently) associated with a LayoutObject. + // If we have no LayoutObject, we have no FragmentData, so we need to + // calculate the offset on our own (which is very simple, anyway). + // Bypass Paint() and jump directly to PaintObject(), to skip the code + // that assumes that we have a LayoutObject (and FragmentData). + PhysicalOffset child_offset = paint_offset + child.offset; + NGBoxFragmentPainter(box_child_fragment) + .PaintObject(paint_info, child_offset); + continue; + } + NGBoxFragmentPainter(box_child_fragment) .Paint(paint_info_for_descendants); continue; @@ -1207,7 +1219,7 @@ // The only way an inline could paint like this is if it has a layer. const auto* layout_object = box_fragment_.GetLayoutObject(); - DCHECK(layout_object->IsLayoutBlock() || + DCHECK(!layout_object || layout_object->IsLayoutBlock() || (layout_object->IsLayoutInline() && layout_object->HasLayer())); // if (paint_info.phase == PaintPhase::kForeground && paint_info.IsPrinting()) @@ -1219,7 +1231,7 @@ return; if (paint_info.phase == PaintPhase::kForcedColorsModeBackplate && - layout_object->GetDocument().InForcedColorsMode()) { + box_fragment_.GetDocument().InForcedColorsMode()) { PaintBackplate(children, paint_info, paint_offset); return; } @@ -1629,14 +1641,6 @@ is_painting_scrolling_background); } -bool NGBoxFragmentPainter::IsInSelfHitTestingPhase(HitTestAction action) const { - // TODO(layout-dev): We should set an IsContainingBlock flag on - // NGPhysicalBoxFragment, instead of routing back to LayoutObject. - if (const auto* box = ToLayoutBoxOrNull(PhysicalFragment().GetLayoutObject())) - return box->IsInSelfHitTestingPhase(action); - return action == kHitTestForeground; -} - bool NGBoxFragmentPainter::HitTestContext::AddNodeToResult( Node* node, const PhysicalRect& bounds_rect, @@ -1661,14 +1665,16 @@ const PhysicalSize& size = box_fragment_.Size(); const ComputedStyle& style = box_fragment_.Style(); - bool hit_test_self = IsInSelfHitTestingPhase(hit_test.action); + bool hit_test_self = fragment.IsInSelfHitTestingPhase(hit_test.action); if (hit_test_self && box_fragment_.HasOverflowClip() && HitTestOverflowControl(hit_test, physical_offset)) return true; - bool skip_children = hit_test.result->GetHitTestRequest().GetStopNode() == - PhysicalFragment().GetLayoutObject(); + const LayoutObject* layout_object = PhysicalFragment().GetLayoutObject(); + bool skip_children = + layout_object && + layout_object == hit_test.result->GetHitTestRequest().GetStopNode(); if (!skip_children && box_fragment_.ShouldClipOverflow()) { // PaintLayer::HitTestContentsForFragments checked the fragments' // foreground rect for intersection if a layer is self painting,
diff --git a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.h b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.h index 8c5aa81a..bdc9417 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.h +++ b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.h
@@ -109,7 +109,7 @@ void PaintInternal(const PaintInfo&); void PaintAllPhasesAtomically(const PaintInfo&); - void PaintBlockChildren(const PaintInfo&); + void PaintBlockChildren(const PaintInfo&, PhysicalOffset); void PaintInlineItems(const PaintInfo&, const PhysicalOffset& paint_offset, const PhysicalOffset& parent_offset, @@ -176,7 +176,6 @@ bool ShouldRecordHitTestData(const PaintInfo&); - bool IsInSelfHitTestingPhase(HitTestAction) const; bool VisibleToHitTestRequest(const HitTestRequest&) const; // This struct has common data needed while traversing trees for the hit
diff --git a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter_test.cc b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter_test.cc index bbdb593f..ccaf7fc 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter_test.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter_test.cc
@@ -6,6 +6,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_cursor.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_block_flow.h" #include "third_party/blink/renderer/core/layout/ng/ng_block_node.h" #include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h" @@ -44,9 +45,15 @@ )HTML"); auto& scroller = ToLayoutBox(*GetLayoutObjectByElementId("scroller")); - const NGPaintFragment& root_fragment = *scroller.PaintFragment(); - const NGPaintFragment& line_box_fragment = *root_fragment.FirstChild(); - const NGPaintFragment& text_fragment = *line_box_fragment.FirstChild(); + const DisplayItemClient& root_fragment = + scroller.PaintFragment() + ? static_cast<const DisplayItemClient&>(*scroller.PaintFragment()) + : static_cast<const DisplayItemClient&>(scroller); + + NGInlineCursor cursor; + cursor.MoveTo(*scroller.SlowFirstChild()); + const DisplayItemClient& text_fragment = + *cursor.Current().GetDisplayItemClient(); EXPECT_THAT(RootPaintController().GetDisplayItemList(), ElementsAre(IsSameId(&ViewScrollingBackgroundClient(),
diff --git a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment_test.cc b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment_test.cc index 1662754..d778705c 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment_test.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment_test.cc
@@ -45,6 +45,8 @@ }; TEST_F(NGPaintFragmentTest, InlineFragmentsFor) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <!DOCTYPE html> @@ -102,6 +104,8 @@ } while (false) TEST_F(NGPaintFragmentTest, InlineBox) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <!DOCTYPE html> @@ -145,6 +149,8 @@ } TEST_F(NGPaintFragmentTest, InlineBoxVerticalRL) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <!DOCTYPE html> @@ -189,6 +195,8 @@ } TEST_F(NGPaintFragmentTest, InlineBoxWithDecorations) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <!DOCTYPE html> @@ -244,6 +252,8 @@ } TEST_F(NGPaintFragmentTest, InlineBoxWithDecorationsVerticalRL) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <!DOCTYPE html> @@ -300,6 +310,8 @@ } TEST_F(NGPaintFragmentTest, InlineBlock) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <!DOCTYPE html> @@ -404,6 +416,8 @@ } TEST_F(NGPaintFragmentTest, InlineBlockVerticalRL) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <!DOCTYPE html> @@ -511,6 +525,8 @@ } TEST_F(NGPaintFragmentTest, RelativeBlock) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <!DOCTYPE html> @@ -550,6 +566,8 @@ } TEST_F(NGPaintFragmentTest, RelativeInline) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <!DOCTYPE html> @@ -604,6 +622,8 @@ } TEST_F(NGPaintFragmentTest, RelativeBlockAndInline) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; LoadAhem(); SetBodyInnerHTML(R"HTML( <!DOCTYPE html> @@ -659,6 +679,8 @@ // Test that OOF should not create a NGPaintFragment. TEST_F(NGPaintFragmentTest, OutOfFlow) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; SetBodyInnerHTML(R"HTML( <!DOCTYPE html> <style> @@ -683,6 +705,8 @@ } TEST_F(NGPaintFragmentTest, MarkLineBoxesDirtyByRemoveBr) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; if (!RuntimeEnabledFeatures::LayoutNGLineCacheEnabled()) return; SetBodyInnerHTML( @@ -710,6 +734,8 @@ testing::ValuesIn(inline_child_data)); TEST_P(InlineChildTest, RemoveInlineChild) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; SetBodyInnerHTML(String(R"HTML( <!DOCTYPE html> <style> @@ -735,6 +761,8 @@ } TEST_F(NGPaintFragmentTest, MarkLineBoxesDirtyByRemoveChild) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; if (!RuntimeEnabledFeatures::LayoutNGLineCacheEnabled()) return; SetBodyInnerHTML( @@ -750,6 +778,8 @@ } TEST_F(NGPaintFragmentTest, MarkLineBoxesDirtyByRemoveSpanWithBr) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; if (!RuntimeEnabledFeatures::LayoutNGLineCacheEnabled()) return; SetBodyInnerHTML( @@ -768,6 +798,8 @@ // to update |IsDirty|, but NGPaintFragment maybe re-used during the layout. In // such case, the result is not deterministic. TEST_F(NGPaintFragmentTest, DISABLED_MarkLineBoxesDirtyByInsertAtStart) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; if (!RuntimeEnabledFeatures::LayoutNGLineCacheEnabled()) return; SetBodyInnerHTML( @@ -796,6 +828,8 @@ // to update |IsDirty|, but NGPaintFragment maybe re-used during the layout. In // such case, the result is not deterministic. TEST_F(NGPaintFragmentTest, DISABLED_MarkLineBoxesDirtyByInsertAtLast) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; if (!RuntimeEnabledFeatures::LayoutNGLineCacheEnabled()) return; SetBodyInnerHTML( @@ -823,6 +857,8 @@ // to update |IsDirty|, but NGPaintFragment maybe re-used during the layout. In // such case, the result is not deterministic. TEST_F(NGPaintFragmentTest, DISABLED_MarkLineBoxesDirtyByInsertAtMiddle) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; if (!RuntimeEnabledFeatures::LayoutNGLineCacheEnabled()) return; SetBodyInnerHTML( @@ -848,6 +884,8 @@ } TEST_F(NGPaintFragmentTest, MarkLineBoxesDirtyByTextSetData) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; if (!RuntimeEnabledFeatures::LayoutNGLineCacheEnabled()) return; SetBodyInnerHTML( @@ -863,6 +901,8 @@ } TEST_F(NGPaintFragmentTest, MarkLineBoxesDirtyWrappedLine) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; if (!RuntimeEnabledFeatures::LayoutNGLineCacheEnabled()) return; SetBodyInnerHTML(R"HTML( @@ -887,6 +927,8 @@ } TEST_F(NGPaintFragmentTest, MarkLineBoxesDirtyInsideInlineBlock) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; if (!RuntimeEnabledFeatures::LayoutNGLineCacheEnabled()) return; SetBodyInnerHTML(R"HTML(
diff --git a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment_traversal_test.cc b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment_traversal_test.cc index e4e8110..78d6455 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment_traversal_test.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment_traversal_test.cc
@@ -63,6 +63,8 @@ }; TEST_F(NGPaintFragmentTraversalTest, MoveToNext) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; SetUpHtml("t", R"HTML( <div id=t> line0 @@ -83,6 +85,8 @@ } TEST_F(NGPaintFragmentTraversalTest, MoveToNextWithRoot) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; SetUpHtml("t", R"HTML( <div id=t> line0 @@ -101,6 +105,8 @@ } TEST_F(NGPaintFragmentTraversalTest, MoveToPrevious) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; SetUpHtml("t", R"HTML( <div id=t> line0 @@ -122,6 +128,8 @@ } TEST_F(NGPaintFragmentTraversalTest, MoveToPreviousWithRoot) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; SetUpHtml("t", R"HTML( <div id=t> line0 @@ -141,6 +149,8 @@ } TEST_F(NGPaintFragmentTraversalTest, MoveTo) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; SetUpHtml("t", R"HTML( <div id=t> line0 @@ -162,6 +172,8 @@ } TEST_F(NGPaintFragmentTraversalTest, MoveToWithRoot) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; SetUpHtml("t", R"HTML( <div id=t> line0 @@ -181,6 +193,8 @@ } TEST_F(NGPaintFragmentTraversalTest, InlineDescendantsOf) { + if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) + return; SetUpHtml("t", "<ul>" "<li id=t style='position: absolute'>"
diff --git a/third_party/blink/renderer/core/paint/ng/ng_text_fragment_painter_test.cc b/third_party/blink/renderer/core/paint/ng/ng_text_fragment_painter_test.cc index b4352057..e1d5ac5f 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_text_fragment_painter_test.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_text_fragment_painter_test.cc
@@ -6,6 +6,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_cursor.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_block_flow.h" #include "third_party/blink/renderer/core/layout/ng/ng_block_node.h" #include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h" @@ -43,11 +44,10 @@ DocumentUpdateReason::kTest); Paint(IntRect(0, 0, 640, 480)); - const NGPaintFragment& root_fragment = *block_flow.PaintFragment(); - EXPECT_EQ(1u, root_fragment.Children().size()); - const NGPaintFragment& line_box_fragment = *root_fragment.FirstChild(); - EXPECT_EQ(1u, line_box_fragment.Children().size()); - const NGPaintFragment& text_fragment = *line_box_fragment.FirstChild(); + NGInlineCursor cursor; + cursor.MoveTo(*block_flow.FirstChild()); + const DisplayItemClient& text_fragment = + *cursor.Current().GetDisplayItemClient(); EXPECT_THAT(RootPaintController().GetDisplayItemList(), ElementsAre(IsSameId(&ViewScrollingBackgroundClient(),
diff --git a/third_party/blink/renderer/core/paint/paint_controller_paint_test.cc b/third_party/blink/renderer/core/paint/paint_controller_paint_test.cc index 3fec058..b0e73c5 100644 --- a/third_party/blink/renderer/core/paint/paint_controller_paint_test.cc +++ b/third_party/blink/renderer/core/paint/paint_controller_paint_test.cc
@@ -8,6 +8,7 @@ #include "third_party/blink/renderer/core/editing/frame_selection.h" #include "third_party/blink/renderer/core/layout/layout_text.h" #include "third_party/blink/renderer/core/layout/line/inline_text_box.h" +#include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_cursor.h" #include "third_party/blink/renderer/core/page/focus_controller.h" #include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h" #include "third_party/blink/renderer/core/paint/object_paint_properties.h" @@ -58,37 +59,39 @@ auto& div_block = *To<LayoutBlock>(GetDocument().body()->firstChild()->GetLayoutObject()); LayoutText& text = *ToLayoutText(div_block.FirstChild()); - DisplayItemClient& first_text_box = - text.FirstInlineFragment() - ? (DisplayItemClient&)*text.FirstInlineFragment() - : (DisplayItemClient&)*text.FirstTextBox(); + const DisplayItemClient* first_text_box = text.FirstTextBox(); + if (text.IsInLayoutNGInlineFormattingContext()) { + NGInlineCursor cursor; + cursor.MoveTo(text); + first_text_box = cursor.Current().GetDisplayItemClient(); + } EXPECT_THAT(RootPaintController().GetDisplayItemList(), ElementsAre(IsSameId(&ViewScrollingBackgroundClient(), kDocumentBackgroundType), - IsSameId(&first_text_box, kForegroundType))); + IsSameId(first_text_box, kForegroundType))); div.setAttribute(html_names::kStyleAttr, "width: 10px; height: 200px"); UpdateAllLifecyclePhasesForTest(); LayoutText& new_text = *ToLayoutText(div_block.FirstChild()); - DisplayItemClient& new_first_text_box = - new_text.FirstInlineFragment() - ? (DisplayItemClient&)*new_text.FirstInlineFragment() - : (DisplayItemClient&)*text.FirstTextBox(); - DisplayItemClient& second_text_box = - new_text.FirstInlineFragment() - ? (DisplayItemClient&)*NGPaintFragment:: - TraverseNextForSameLayoutObject::Next( - new_text.FirstInlineFragment()) - : (DisplayItemClient&)*new_text.FirstTextBox() - ->NextForSameLayoutObject(); + const DisplayItemClient* new_first_text_box = text.FirstTextBox(); + const DisplayItemClient* second_text_box = nullptr; + if (!text.IsInLayoutNGInlineFormattingContext()) { + second_text_box = new_text.FirstTextBox()->NextForSameLayoutObject(); + } else { + NGInlineCursor cursor; + cursor.MoveTo(text); + new_first_text_box = cursor.Current().GetDisplayItemClient(); + cursor.MoveToNextForSameLayoutObject(); + second_text_box = cursor.Current().GetDisplayItemClient(); + } EXPECT_THAT(RootPaintController().GetDisplayItemList(), ElementsAre(IsSameId(&ViewScrollingBackgroundClient(), kDocumentBackgroundType), - IsSameId(&new_first_text_box, kForegroundType), - IsSameId(&second_text_box, kForegroundType))); + IsSameId(new_first_text_box, kForegroundType), + IsSameId(second_text_box, kForegroundType))); } TEST_P(PaintControllerPaintTest, ChunkIdClientCacheFlag) {
diff --git a/third_party/blink/renderer/core/paint/paint_layer_painter.cc b/third_party/blink/renderer/core/paint/paint_layer_painter.cc index 79a1a8d..07e8e9e 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_painter.cc +++ b/third_party/blink/renderer/core/paint/paint_layer_painter.cc
@@ -17,6 +17,7 @@ #include "third_party/blink/renderer/core/paint/paint_layer.h" #include "third_party/blink/renderer/core/paint/paint_layer_paint_order_iterator.h" #include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h" +#include "third_party/blink/renderer/core/paint/paint_timing_detector.h" #include "third_party/blink/renderer/core/paint/scrollable_area_painter.h" #include "third_party/blink/renderer/platform/geometry/float_point_3d.h" #include "third_party/blink/renderer/platform/graphics/graphics_layer.h" @@ -48,8 +49,6 @@ } bool PaintLayerPainter::PaintedOutputInvisible(const ComputedStyle& style) { - DCHECK(!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()); - if (style.HasBackdropFilter()) return false; @@ -86,10 +85,10 @@ !paint_layer_.HasSelfPaintingLayerDescendant()) return kFullyPainted; - // If this layer is totally invisible then there is nothing to paint. In CAP - // we simplify this optimization by painting even when effectively invisible - // but skipping the painted content during layerization in - // PaintArtifactCompositor. + // If this layer is totally invisible then there is nothing to paint. + // In CompositeAfterPaint we simplify this optimization by painting even when + // effectively invisible but skipping the painted content during layerization + // in PaintArtifactCompositor. if (paint_layer_.PaintsWithTransparency( painting_info.GetGlobalPaintFlags())) { if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled() && @@ -325,6 +324,10 @@ return kMayBeClippedByCullRect; } + base::Optional<IgnorePaintTimingScope> ignore_paint_timing; + if (PaintedOutputInvisible(paint_layer_.GetLayoutObject().StyleRef())) + ignore_paint_timing.emplace(); + PaintLayerFlags paint_flags = paint_flags_arg; PaintLayerPaintingInfo painting_info = painting_info_arg; AdjustForPaintProperties(context, painting_info, paint_flags);
diff --git a/third_party/blink/renderer/core/paint/paint_timing_detector.cc b/third_party/blink/renderer/core/paint/paint_timing_detector.cc index 65903fe..a5940c4d 100644 --- a/third_party/blink/renderer/core/paint/paint_timing_detector.cc +++ b/third_party/blink/renderer/core/paint/paint_timing_detector.cc
@@ -63,6 +63,8 @@ } // namespace +bool IgnorePaintTimingScope::should_ignore_ = false; + PaintTimingDetector::PaintTimingDetector(LocalFrameView* frame_view) : frame_view_(frame_view), text_paint_timing_detector_( @@ -106,6 +108,9 @@ const StyleFetchedImage* style_image, const PropertyTreeState& current_paint_chunk_properties, const IntRect& image_border) { + if (IgnorePaintTimingScope::ShouldIgnore()) + return; + DCHECK(image); DCHECK(style_image->CachedImage()); if (!node) @@ -132,6 +137,9 @@ const IntSize& intrinsic_size, const ImageResourceContent* cached_image, const PropertyTreeState& current_paint_chunk_properties) { + if (IgnorePaintTimingScope::ShouldIgnore()) + return; + LocalFrameView* frame_view = object.GetFrameView(); if (!frame_view) return; @@ -349,6 +357,9 @@ void ScopedPaintTimingDetectorBlockPaintHook::EmplaceIfNeeded( const LayoutBoxModelObject& aggregator, const PropertyTreeState& property_tree_state) { + if (IgnorePaintTimingScope::ShouldIgnore()) + return; + // |reset_top_| is unset when |aggregator| is anonymous so that each // aggregation corresponds to an element. See crbug.com/988593. When set, // |top_| becomes |this|, and |top_| is restored to the previous value when
diff --git a/third_party/blink/renderer/core/paint/paint_timing_detector.h b/third_party/blink/renderer/core/paint/paint_timing_detector.h index 96d995a..82391ba 100644 --- a/third_party/blink/renderer/core/paint/paint_timing_detector.h +++ b/third_party/blink/renderer/core/paint/paint_timing_detector.h
@@ -273,9 +273,27 @@ DISALLOW_COPY_AND_ASSIGN(ScopedPaintTimingDetectorBlockPaintHook); }; +// Creates a scope to ignore paint timing, e.g. when we are painting contents +// under opacity:0. +class IgnorePaintTimingScope { + STACK_ALLOCATED(); + + public: + IgnorePaintTimingScope() : auto_reset_(&should_ignore_, true) {} + ~IgnorePaintTimingScope() = default; + + static bool ShouldIgnore() { return should_ignore_; } + + private: + base::AutoReset<bool> auto_reset_; + static bool should_ignore_; +}; + // static inline void PaintTimingDetector::NotifyTextPaint( const IntRect& text_visual_rect) { + if (IgnorePaintTimingScope::ShouldIgnore()) + return; ScopedPaintTimingDetectorBlockPaintHook::AggregateTextPaint(text_visual_rect); }
diff --git a/third_party/blink/renderer/core/paint/svg_container_painter.cc b/third_party/blink/renderer/core/paint/svg_container_painter.cc index 3e550a6d..e178f973 100644 --- a/third_party/blink/renderer/core/paint/svg_container_painter.cc +++ b/third_party/blink/renderer/core/paint/svg_container_painter.cc
@@ -83,8 +83,9 @@ if (continue_rendering) { for (LayoutObject* child = layout_svg_container_.FirstChild(); child; child = child->NextSibling()) { + auto* foreign_object = DynamicTo<LayoutSVGForeignObject>(*child); if (child->IsSVGForeignObject()) { - SVGForeignObjectPainter(ToLayoutSVGForeignObject(*child)) + SVGForeignObjectPainter(*foreign_object) .PaintLayer(paint_state.GetPaintInfo()); } else { child->Paint(paint_state.GetPaintInfo());
diff --git a/third_party/blink/renderer/core/resize_observer/resize_observation.cc b/third_party/blink/renderer/core/resize_observer/resize_observation.cc index abb5fa9..f6eb3c33 100644 --- a/third_party/blink/renderer/core/resize_observer/resize_observation.cc +++ b/third_party/blink/renderer/core/resize_observer/resize_observation.cc
@@ -4,11 +4,13 @@ #include "third_party/blink/renderer/core/resize_observer/resize_observation.h" #include "third_party/blink/renderer/core/display_lock/display_lock_utilities.h" +#include "third_party/blink/renderer/core/layout/adjust_for_absolute_zoom.h" #include "third_party/blink/renderer/core/layout/layout_box.h" #include "third_party/blink/renderer/core/resize_observer/resize_observer.h" #include "third_party/blink/renderer/core/resize_observer/resize_observer_box_options.h" #include "third_party/blink/renderer/core/svg/svg_element.h" #include "third_party/blink/renderer/core/svg/svg_graphics_element.h" +#include "third_party/blink/renderer/platform/geometry/layout_unit.h" namespace blink { @@ -60,13 +62,31 @@ return LayoutSize(); if (LayoutBox* layout_box = ToLayoutBox(layout_object)) { + const ComputedStyle& style = layout_object->StyleRef(); switch (observed_box_) { case ResizeObserverBoxOptions::BorderBox: - return LayoutSize(layout_box->LogicalWidth(), - layout_box->LogicalHeight()); + return LayoutSize(AdjustForAbsoluteZoom::AdjustLayoutUnit( + layout_box->LogicalWidth(), style), + AdjustForAbsoluteZoom::AdjustLayoutUnit( + layout_box->LogicalHeight(), style)); case ResizeObserverBoxOptions::ContentBox: - return LayoutSize(layout_box->ContentLogicalWidth(), - layout_box->ContentLogicalHeight()); + return LayoutSize(AdjustForAbsoluteZoom::AdjustLayoutUnit( + layout_box->ContentLogicalWidth(), style), + AdjustForAbsoluteZoom::AdjustLayoutUnit( + layout_box->ContentLogicalHeight(), style)); + case ResizeObserverBoxOptions::DevicePixelContentBox: { + LayoutSize paint_offset = + layout_object->FirstFragment().PaintOffset().ToLayoutSize(); + return LayoutSize( + SnapSizeToPixel(layout_box->ContentLogicalWidth(), + style.IsHorizontalWritingMode() + ? paint_offset.Width() + : paint_offset.Height()), + SnapSizeToPixel(layout_box->ContentLogicalHeight(), + style.IsHorizontalWritingMode() + ? paint_offset.Height() + : paint_offset.Width())); + } default: NOTREACHED(); }
diff --git a/third_party/blink/renderer/core/resize_observer/resize_observer.cc b/third_party/blink/renderer/core/resize_observer/resize_observer.cc index 9c80cd0..2290704a 100644 --- a/third_party/blink/renderer/core/resize_observer/resize_observer.cc +++ b/third_party/blink/renderer/core/resize_observer/resize_observer.cc
@@ -18,6 +18,8 @@ constexpr const char* kBoxOptionBorderBox = "border-box"; constexpr const char* kBoxOptionContentBox = "content-box"; +constexpr const char* kBoxOptionDevicePixelContentBox = + "device-pixel-content-box"; ResizeObserver* ResizeObserver::Create(Document& document, V8ResizeObserverCallback* callback) { @@ -53,6 +55,8 @@ return ResizeObserverBoxOptions::BorderBox; if (box_options == kBoxOptionContentBox) return ResizeObserverBoxOptions::ContentBox; + if (box_options == kBoxOptionDevicePixelContentBox) + return ResizeObserverBoxOptions::DevicePixelContentBox; return ResizeObserverBoxOptions::ContentBox; }
diff --git a/third_party/blink/renderer/core/resize_observer/resize_observer_box_options.h b/third_party/blink/renderer/core/resize_observer/resize_observer_box_options.h index d8bbd70..15e4cd9 100644 --- a/third_party/blink/renderer/core/resize_observer/resize_observer_box_options.h +++ b/third_party/blink/renderer/core/resize_observer/resize_observer_box_options.h
@@ -5,6 +5,7 @@ enum class ResizeObserverBoxOptions { BorderBox, ContentBox, + DevicePixelContentBox }; }
diff --git a/third_party/blink/renderer/core/resize_observer/resize_observer_controller.cc b/third_party/blink/renderer/core/resize_observer/resize_observer_controller.cc index d2bfdb5..4a7aa87 100644 --- a/third_party/blink/renderer/core/resize_observer/resize_observer_controller.cc +++ b/third_party/blink/renderer/core/resize_observer/resize_observer_controller.cc
@@ -14,15 +14,16 @@ observers_.insert(&observer); } -size_t ResizeObserverController::GatherObservations(size_t deeper_than) { +size_t ResizeObserverController::GatherObservations() { size_t shallowest = ResizeObserverController::kDepthBottom; for (auto& observer : observers_) { - size_t depth = observer->GatherObservations(deeper_than); + size_t depth = observer->GatherObservations(min_depth_); if (depth < shallowest) shallowest = depth; } - return shallowest; + min_depth_ = shallowest; + return min_depth_; } bool ResizeObserverController::SkippedObservations() {
diff --git a/third_party/blink/renderer/core/resize_observer/resize_observer_controller.h b/third_party/blink/renderer/core/resize_observer/resize_observer_controller.h index 9ee120d..f8de314 100644 --- a/third_party/blink/renderer/core/resize_observer/resize_observer_controller.h +++ b/third_party/blink/renderer/core/resize_observer/resize_observer_controller.h
@@ -28,14 +28,16 @@ void AddObserver(ResizeObserver&); // observation API - // Returns depth of shallowest observed node, kDepthLimit if none. - size_t GatherObservations(size_t deeper_than); + // Returns min depth of shallowest observed node, kDepthLimit if none. + size_t GatherObservations(); // Returns true if gatherObservations has skipped observations // because they were too shallow. bool SkippedObservations(); void DeliverObservations(); void ClearObservations(); + void ClearMinDepth() { min_depth_ = 0; } + void Trace(Visitor*); // For testing only. @@ -46,6 +48,8 @@ private: // Active observers HeapLinkedHashSet<WeakMember<ResizeObserver>> observers_; + // Minimum depth for observations to be active + size_t min_depth_ = 0; }; } // namespace blink
diff --git a/third_party/blink/renderer/core/resize_observer/resize_observer_entry.cc b/third_party/blink/renderer/core/resize_observer/resize_observer_entry.cc index 2f57512..7b6c7e0 100644 --- a/third_party/blink/renderer/core/resize_observer/resize_observer_entry.cc +++ b/third_party/blink/renderer/core/resize_observer/resize_observer_entry.cc
@@ -13,6 +13,7 @@ #include "third_party/blink/renderer/core/svg/svg_graphics_element.h" #include "third_party/blink/renderer/platform/geometry/layout_rect.h" #include "third_party/blink/renderer/platform/geometry/layout_size.h" +#include "third_party/blink/renderer/platform/geometry/layout_unit.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h" namespace blink { @@ -48,11 +49,13 @@ if (auto* svg_graphics_element = DynamicTo<SVGGraphicsElement>(target)) { LayoutSize bounding_box_size = LayoutSize(svg_graphics_element->GetBBox().Size()); - LayoutRect content_rect(LayoutPoint(), bounding_box_size); - content_rect_ = ZoomAdjustedLayoutRect(content_rect, style); + content_rect_ = DOMRectReadOnly::FromFloatRect( + FloatRect(FloatPoint(), FloatSize(bounding_box_size))); if (RuntimeEnabledFeatures::ResizeObserverUpdatesEnabled()) { - content_box_size_ = ZoomAdjustedSize(bounding_box_size, style); - border_box_size_ = ZoomAdjustedSize(bounding_box_size, style); + content_box_size_ = ResizeObserverSize::Create( + bounding_box_size.Width(), bounding_box_size.Height()); + border_box_size_ = content_box_size_; + device_pixel_content_box_size_ = content_box_size_; } } else if (layout_object->IsBox()) { LayoutBox* layout_box = target->GetLayoutBox(); @@ -70,6 +73,18 @@ content_box_size_ = ZoomAdjustedSize(content_box_size, style); border_box_size_ = ZoomAdjustedSize(border_box_size, style); + LayoutSize paint_offset = + layout_object->FirstFragment().PaintOffset().ToLayoutSize(); + + device_pixel_content_box_size_ = ResizeObserverSize::Create( + SnapSizeToPixel(layout_box->ContentLogicalWidth(), + style.IsHorizontalWritingMode() + ? paint_offset.Width() + : paint_offset.Height()), + SnapSizeToPixel(layout_box->ContentLogicalHeight(), + style.IsHorizontalWritingMode() + ? paint_offset.Height() + : paint_offset.Width())); } } } @@ -81,6 +96,8 @@ content_box_size_ = ResizeObserverSize::Create(0, 0); if (!border_box_size_) border_box_size_ = ResizeObserverSize::Create(0, 0); + if (!device_pixel_content_box_size_) + device_pixel_content_box_size_ = ResizeObserverSize::Create(0, 0); } } @@ -89,6 +106,7 @@ visitor->Trace(content_rect_); visitor->Trace(content_box_size_); visitor->Trace(border_box_size_); + visitor->Trace(device_pixel_content_box_size_); ScriptWrappable::Trace(visitor); }
diff --git a/third_party/blink/renderer/core/resize_observer/resize_observer_entry.h b/third_party/blink/renderer/core/resize_observer/resize_observer_entry.h index 95b9a2e..a0afb79 100644 --- a/third_party/blink/renderer/core/resize_observer/resize_observer_entry.h +++ b/third_party/blink/renderer/core/resize_observer/resize_observer_entry.h
@@ -28,6 +28,9 @@ DOMRectReadOnly* contentRect() const { return content_rect_; } ResizeObserverSize* contentBoxSize() const { return content_box_size_; } ResizeObserverSize* borderBoxSize() const { return border_box_size_; } + ResizeObserverSize* devicePixelContentBoxSize() const { + return device_pixel_content_box_size_; + } void Trace(Visitor*) override; @@ -36,6 +39,7 @@ Member<DOMRectReadOnly> content_rect_; Member<ResizeObserverSize> content_box_size_; Member<ResizeObserverSize> border_box_size_; + Member<ResizeObserverSize> device_pixel_content_box_size_; static DOMRectReadOnly* ZoomAdjustedLayoutRect(LayoutRect content_rect, const ComputedStyle& style);
diff --git a/third_party/blink/renderer/core/resize_observer/resize_observer_entry.idl b/third_party/blink/renderer/core/resize_observer/resize_observer_entry.idl index 833bc5f..69f7c61 100644 --- a/third_party/blink/renderer/core/resize_observer/resize_observer_entry.idl +++ b/third_party/blink/renderer/core/resize_observer/resize_observer_entry.idl
@@ -10,4 +10,5 @@ readonly attribute DOMRectReadOnly contentRect; [RuntimeEnabled=ResizeObserverUpdates] readonly attribute ResizeObserverSize contentBoxSize; [RuntimeEnabled=ResizeObserverUpdates] readonly attribute ResizeObserverSize borderBoxSize; + [RuntimeEnabled=ResizeObserverUpdates] readonly attribute ResizeObserverSize devicePixelContentBoxSize; };
diff --git a/third_party/blink/renderer/core/resize_observer/resize_observer_options.idl b/third_party/blink/renderer/core/resize_observer/resize_observer_options.idl index ac2ee1e..4b58e04 100644 --- a/third_party/blink/renderer/core/resize_observer/resize_observer_options.idl +++ b/third_party/blink/renderer/core/resize_observer/resize_observer_options.idl
@@ -5,7 +5,7 @@ // https://drafts.csswg.org/resize-observer/#enumdef-resizeobserverboxoptions enum ResizeObserverBoxOptions { - "border-box", "content-box" + "border-box", "content-box", "device-pixel-content-box" }; // https://drafts.csswg.org/resize-observer/#dictdef-resizeobserveroptions
diff --git a/third_party/blink/renderer/core/resize_observer/resize_observer_test.cc b/third_party/blink/renderer/core/resize_observer/resize_observer_test.cc index c754edbb..dce0962 100644 --- a/third_party/blink/renderer/core/resize_observer/resize_observer_test.cc +++ b/third_party/blink/renderer/core/resize_observer/resize_observer_test.cc
@@ -60,13 +60,12 @@ */ class ResizeObserverUnitTest : public SimTest {}; -TEST_F(ResizeObserverUnitTest, ResizeObservationSize) { +TEST_F(ResizeObserverUnitTest, ResizeObserverDOMContentBoxAndSVG) { SimRequest main_resource("https://example.com/", "text/html"); LoadURL("https://example.com/"); main_resource.Write(R"HTML( <div id='domTarget' style='width:100px;height:100px'>yo</div> - <div id='domBorderTarget' style='width:100px;height:100px;padding:5px'>yoyo</div> <svg height='200' width='200'> <circle id='svgTarget' cx='100' cy='100' r='100'/> </svg> @@ -77,19 +76,14 @@ MakeGarbageCollected<TestResizeObserverDelegate>(GetDocument()); ResizeObserver* observer = ResizeObserver::Create(GetDocument(), delegate); Element* dom_target = GetDocument().getElementById("domTarget"); - Element* dom_border_target = GetDocument().getElementById("domBorderTarget"); Element* svg_target = GetDocument().getElementById("svgTarget"); ResizeObservation* dom_observation = MakeGarbageCollected<ResizeObservation>( dom_target, observer, ResizeObserverBoxOptions::ContentBox); - ResizeObservation* dom_border_observation = - MakeGarbageCollected<ResizeObservation>( - dom_border_target, observer, ResizeObserverBoxOptions::BorderBox); ResizeObservation* svg_observation = MakeGarbageCollected<ResizeObservation>( svg_target, observer, ResizeObserverBoxOptions::ContentBox); // Initial observation is out of sync ASSERT_TRUE(dom_observation->ObservationSizeOutOfSync()); - ASSERT_TRUE(dom_border_observation->ObservationSizeOutOfSync()); ASSERT_TRUE(svg_observation->ObservationSizeOutOfSync()); // Target size is correct @@ -98,11 +92,6 @@ ASSERT_EQ(size.Height(), 100); dom_observation->SetObservationSize(size); - size = dom_border_observation->ComputeTargetSize(); - ASSERT_EQ(size.Width(), 110); - ASSERT_EQ(size.Height(), 110); - dom_border_observation->SetObservationSize(size); - size = svg_observation->ComputeTargetSize(); ASSERT_EQ(size.Width(), 200); ASSERT_EQ(size.Height(), 200); @@ -110,13 +99,94 @@ // Target size is in sync ASSERT_FALSE(dom_observation->ObservationSizeOutOfSync()); - ASSERT_FALSE(dom_border_observation->ObservationSizeOutOfSync()); + ASSERT_FALSE(svg_observation->ObservationSizeOutOfSync()); // Target depths ASSERT_EQ(svg_observation->TargetDepth() - dom_observation->TargetDepth(), (size_t)1); } +TEST_F(ResizeObserverUnitTest, ResizeObserverDOMBorderBox) { + SimRequest main_resource("https://example.com/", "text/html"); + LoadURL("https://example.com/"); + + main_resource.Write(R"HTML( + <div id='domBorderTarget' style='width:100px;height:100px;padding:5px'> + yoyo + </div> + )HTML"); + main_resource.Finish(); + + ResizeObserver::Delegate* delegate = + MakeGarbageCollected<TestResizeObserverDelegate>(GetDocument()); + ResizeObserver* observer = ResizeObserver::Create(GetDocument(), delegate); + Element* dom_border_target = GetDocument().getElementById("domBorderTarget"); + ResizeObservation* dom_border_observation = + MakeGarbageCollected<ResizeObservation>( + dom_border_target, observer, ResizeObserverBoxOptions::BorderBox); + + // Initial observation is out of sync + ASSERT_TRUE(dom_border_observation->ObservationSizeOutOfSync()); + + // Target size is correct + LayoutSize size = dom_border_observation->ComputeTargetSize(); + ASSERT_EQ(size.Width(), 110); + ASSERT_EQ(size.Height(), 110); + dom_border_observation->SetObservationSize(size); + + // Target size is in sync + ASSERT_FALSE(dom_border_observation->ObservationSizeOutOfSync()); +} + +TEST_F(ResizeObserverUnitTest, ResizeObserverDOMDevicePixelContentBox) { + SimRequest main_resource("https://example.com/", "text/html"); + LoadURL("https://example.com/"); + + main_resource.Write(R"HTML( + <div id='domTarget' style='width:100px;height:100px'>yo</div> + <svg height='200' width='200'> + <div style='zoom:3;'> + <div id='domDPTarget' style='width:50px;height:30px'></div> + </div> + </svg> + )HTML"); + main_resource.Finish(); + + ResizeObserver::Delegate* delegate = + MakeGarbageCollected<TestResizeObserverDelegate>(GetDocument()); + ResizeObserver* observer = ResizeObserver::Create(GetDocument(), delegate); + Element* dom_target = GetDocument().getElementById("domTarget"); + Element* dom_dp_target = GetDocument().getElementById("domDPTarget"); + + ResizeObservation* dom_dp_nested_observation = + MakeGarbageCollected<ResizeObservation>( + dom_dp_target, observer, + ResizeObserverBoxOptions::DevicePixelContentBox); + ResizeObservation* dom_dp_observation = + MakeGarbageCollected<ResizeObservation>( + dom_target, observer, + ResizeObserverBoxOptions::DevicePixelContentBox); + + // Initial observation is out of sync + ASSERT_TRUE(dom_dp_observation->ObservationSizeOutOfSync()); + ASSERT_TRUE(dom_dp_nested_observation->ObservationSizeOutOfSync()); + + // Target size is correct + LayoutSize size = dom_dp_observation->ComputeTargetSize(); + ASSERT_EQ(size.Width(), 100); + ASSERT_EQ(size.Height(), 100); + dom_dp_observation->SetObservationSize(size); + + size = dom_dp_nested_observation->ComputeTargetSize(); + ASSERT_EQ(size.Width(), 150); + ASSERT_EQ(size.Height(), 90); + dom_dp_nested_observation->SetObservationSize(size); + + // Target size is in sync + ASSERT_FALSE(dom_dp_observation->ObservationSizeOutOfSync()); + ASSERT_FALSE(dom_dp_nested_observation->ObservationSizeOutOfSync()); +} + // Test whether a new observation is created when an observation's // observed box is changed TEST_F(ResizeObserverUnitTest, TestBoxOverwrite) { @@ -175,6 +245,8 @@ EXPECT_EQ(entry->contentBoxSize()->blockSize(), 0); EXPECT_EQ(entry->borderBoxSize()->inlineSize(), 0); EXPECT_EQ(entry->borderBoxSize()->blockSize(), 0); + EXPECT_EQ(entry->devicePixelContentBoxSize()->inlineSize(), 0); + EXPECT_EQ(entry->devicePixelContentBoxSize()->blockSize(), 0); } TEST_F(ResizeObserverUnitTest, TestMemoryLeaks) {
diff --git a/third_party/blink/renderer/core/script/script_loader.cc b/third_party/blink/renderer/core/script/script_loader.cc index b411003..c364064 100644 --- a/third_party/blink/renderer/core/script/script_loader.cc +++ b/third_party/blink/renderer/core/script/script_loader.cc
@@ -26,7 +26,6 @@ #include "base/feature_list.h" #include "third_party/blink/public/common/feature_policy/feature_policy.h" -#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/mojom/feature_policy/feature_policy_feature.mojom-blink.h" #include "third_party/blink/renderer/bindings/core/v8/sanitize_script_errors.h" #include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h" @@ -592,9 +591,7 @@ // Fetch a classic script given url, settings object, options, classic // script CORS setting, and encoding.</spec> Document* document_for_origin = &element_document; - if (base::FeatureList::IsEnabled( - features::kHtmlImportsRequestInitiatorLock) && - element_document.ImportsController()) { + if (element_document.ImportsController()) { document_for_origin = context_document; } FetchClassicScript(url, *document_for_origin, options, cross_origin,
diff --git a/third_party/blink/renderer/core/svg/properties/svg_list_property_tear_off_helper.h b/third_party/blink/renderer/core/svg/properties/svg_list_property_tear_off_helper.h index 6435cba..a98b0cc 100644 --- a/third_party/blink/renderer/core/svg/properties/svg_list_property_tear_off_helper.h +++ b/third_party/blink/renderer/core/svg/properties/svg_list_property_tear_off_helper.h
@@ -32,6 +32,7 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_SVG_PROPERTIES_SVG_LIST_PROPERTY_TEAR_OFF_HELPER_H_ #include "third_party/blink/renderer/core/svg/properties/svg_property_tear_off.h" +#include "third_party/blink/renderer/platform/bindings/v8_binding.h" #include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/wtf/type_traits.h" @@ -141,11 +142,12 @@ return CreateItemTearOff(value); } - bool AnonymousIndexedSetter(uint32_t index, - ItemTearOffType* item, - ExceptionState& exception_state) { + IndexedPropertySetterResult AnonymousIndexedSetter( + uint32_t index, + ItemTearOffType* item, + ExceptionState& exception_state) { replaceItem(item, index, exception_state); - return true; + return IndexedPropertySetterResult::kIntercepted; } ItemTearOffType* removeItem(uint32_t index, ExceptionState& exception_state) {
diff --git a/third_party/blink/renderer/core/svg/svg_string_list_tear_off.h b/third_party/blink/renderer/core/svg/svg_string_list_tear_off.h index f941d7c..bbc7d87 100644 --- a/third_party/blink/renderer/core/svg/svg_string_list_tear_off.h +++ b/third_party/blink/renderer/core/svg/svg_string_list_tear_off.h
@@ -33,6 +33,7 @@ #include "third_party/blink/renderer/core/svg/properties/svg_property_tear_off.h" #include "third_party/blink/renderer/core/svg/svg_string_list.h" +#include "third_party/blink/renderer/platform/bindings/v8_binding.h" namespace blink { @@ -96,11 +97,12 @@ return item; } - bool AnonymousIndexedSetter(uint32_t index, - const String& item, - ExceptionState& exception_state) { + IndexedPropertySetterResult AnonymousIndexedSetter( + uint32_t index, + const String& item, + ExceptionState& exception_state) { replaceItem(item, index, exception_state); - return true; + return IndexedPropertySetterResult::kIntercepted; } String removeItem(uint32_t index, ExceptionState& exception_state) {
diff --git a/third_party/blink/renderer/core/svg/svg_use_element.cc b/third_party/blink/renderer/core/svg/svg_use_element.cc index 1ee1e84..8cd5633 100644 --- a/third_party/blink/renderer/core/svg/svg_use_element.cc +++ b/third_party/blink/renderer/core/svg/svg_use_element.cc
@@ -25,7 +25,6 @@ #include "third_party/blink/renderer/core/svg/svg_use_element.h" -#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/renderer/core/css/style_change_reason.h" #include "third_party/blink/renderer/core/dom/document.h" @@ -206,9 +205,7 @@ params.MutableResourceRequest().SetMode( network::mojom::RequestMode::kSameOrigin); auto* context_document = &GetDocument(); - if (base::FeatureList::IsEnabled( - features::kHtmlImportsRequestInitiatorLock) && - GetDocument().ImportsController()) { + if (GetDocument().ImportsController()) { // For @imports from HTML imported Documents, we use the // context document for getting origin and ResourceFetcher to use the // main Document's origin, while using the element document for
diff --git a/third_party/blink/renderer/core/testing/internal_settings.cc b/third_party/blink/renderer/core/testing/internal_settings.cc index 7daf488..65ed71e7 100644 --- a/third_party/blink/renderer/core/testing/internal_settings.cc +++ b/third_party/blink/renderer/core/testing/internal_settings.cc
@@ -170,7 +170,7 @@ GetSettings()->SetViewportStyle(WebViewportStyle::kDefault); else if (EqualIgnoringASCIICase(style, "mobile")) GetSettings()->SetViewportStyle(WebViewportStyle::kMobile); - else if (DeprecatedEqualIgnoringCase(style, "television")) + else if (EqualIgnoringASCIICase(style, "television")) GetSettings()->SetViewportStyle(WebViewportStyle::kTelevision); else exception_state.ThrowDOMException(
diff --git a/third_party/blink/renderer/core/testing/internals.cc b/third_party/blink/renderer/core/testing/internals.cc index e4f1756f..5a22eb5a 100644 --- a/third_party/blink/renderer/core/testing/internals.cc +++ b/third_party/blink/renderer/core/testing/internals.cc
@@ -225,17 +225,17 @@ static base::Optional<DocumentMarker::MarkerType> MarkerTypeFrom( const String& marker_type) { - if (DeprecatedEqualIgnoringCase(marker_type, "Spelling")) + if (EqualIgnoringASCIICase(marker_type, "Spelling")) return DocumentMarker::kSpelling; if (EqualIgnoringASCIICase(marker_type, "Grammar")) return DocumentMarker::kGrammar; if (EqualIgnoringASCIICase(marker_type, "TextMatch")) return DocumentMarker::kTextMatch; - if (DeprecatedEqualIgnoringCase(marker_type, "Composition")) + if (EqualIgnoringASCIICase(marker_type, "Composition")) return DocumentMarker::kComposition; - if (DeprecatedEqualIgnoringCase(marker_type, "ActiveSuggestion")) + if (EqualIgnoringASCIICase(marker_type, "ActiveSuggestion")) return DocumentMarker::kActiveSuggestion; - if (DeprecatedEqualIgnoringCase(marker_type, "Suggestion")) + if (EqualIgnoringASCIICase(marker_type, "Suggestion")) return DocumentMarker::kSuggestion; return base::nullopt; }
diff --git a/third_party/blink/renderer/modules/accessibility/ax_object.cc b/third_party/blink/renderer/modules/accessibility/ax_object.cc index fe9007e7..7e015f1 100644 --- a/third_party/blink/renderer/modules/accessibility/ax_object.cc +++ b/third_party/blink/renderer/modules/accessibility/ax_object.cc
@@ -1421,6 +1421,9 @@ } bool AXObject::IsARIAControlledByTextboxWithActiveDescendant() const { + if (IsDetached()) + return false; + // This situation should mostly arise when using an active descendant on a // textbox inside an ARIA 1.1 combo box widget, which points to the selected // option in a list. In such situations, the active descendant is useful only
diff --git a/third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.cc b/third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.cc index d415126..344439c 100644 --- a/third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.cc +++ b/third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.cc
@@ -458,8 +458,8 @@ } // input type=range - if (css_box->IsSlider()) - return MakeGarbageCollected<AXSlider>(ToLayoutSlider(css_box), *this); + if (auto* slider = DynamicTo<LayoutSlider>(css_box)) + return MakeGarbageCollected<AXSlider>(slider, *this); } return MakeGarbageCollected<AXLayoutObject>(layout_object, *this);
diff --git a/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.cc b/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.cc index f9cbe157..bc2b60c 100644 --- a/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.cc +++ b/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.cc
@@ -87,7 +87,7 @@ // Clear the background transparent or opaque. if (IsCanvas2DBufferValid()) { - GetOrCreateCanvasResourceProvider()->Clear(); + GetCanvasResourceProvider()->Clear(); DidDraw(); } @@ -120,13 +120,12 @@ } void OffscreenCanvasRenderingContext2D::FlushRecording() { - if (!have_recorded_draw_commands_) + if (!GetCanvasResourceProvider() || + !GetCanvasResourceProvider()->HasRecordedDrawOps()) return; GetCanvasResourceProvider()->FlushCanvas(); GetCanvasResourceProvider()->ReleaseLockedImages(); - - have_recorded_draw_commands_ = false; } void OffscreenCanvasRenderingContext2D::FinalizeFrame() { @@ -272,7 +271,6 @@ } void OffscreenCanvasRenderingContext2D::DidDraw() { - have_recorded_draw_commands_ = true; dirty_rect_for_commit_.setWH(Width(), Height()); Host()->DidDraw(); if (GetCanvasResourceProvider() && GetCanvasResourceProvider()->needs_flush()) @@ -280,7 +278,6 @@ } void OffscreenCanvasRenderingContext2D::DidDraw(const SkIRect& dirty_rect) { - have_recorded_draw_commands_ = true; dirty_rect_for_commit_.join(dirty_rect); Host()->DidDraw(SkRect::Make(dirty_rect_for_commit_)); if (GetCanvasResourceProvider() && GetCanvasResourceProvider()->needs_flush()) @@ -340,7 +337,6 @@ DCHECK(IsPaintable()); FinalizeFrame(); - have_recorded_draw_commands_ = false; return offscreenCanvasForBinding()->ResourceProvider()->WritePixels( orig_info, pixels, row_bytes, x, y);
diff --git a/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.h b/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.h index 9e76f227..bd98a0a 100644 --- a/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.h +++ b/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.h
@@ -127,8 +127,6 @@ bool PushFrame() override; - bool HasRecordedDrawCommands() { return have_recorded_draw_commands_; } - protected: CanvasColorParams ColorParams() const override; bool WritePixels(const SkImageInfo& orig_info, @@ -139,7 +137,6 @@ void WillOverwriteCanvas() override; private: - bool have_recorded_draw_commands_; void FinalizeFrame() final; void FlushRecording();
diff --git a/third_party/blink/renderer/modules/exported/OWNERS b/third_party/blink/renderer/modules/exported/OWNERS index 6cb3ea7..d0ff0ac 100644 --- a/third_party/blink/renderer/modules/exported/OWNERS +++ b/third_party/blink/renderer/modules/exported/OWNERS
@@ -3,3 +3,7 @@ # Workers per-file web_embedded_worker_impl.h=file://content/browser/service_worker/OWNERS per-file web_embedded_worker_impl.cc=file://content/browser/service_worker/OWNERS + +# Accessibility +per-file web_ax_object.h=file://third_party/blink/renderer/modules/accessibility/OWNERS +per-file web_ax_object.cc=file://third_party/blink/renderer/modules/accessibility/OWNERS
diff --git a/third_party/blink/renderer/modules/storage/storage_area.cc b/third_party/blink/renderer/modules/storage/storage_area.cc index dc2d507..cc24c65 100644 --- a/third_party/blink/renderer/modules/storage/storage_area.cc +++ b/third_party/blink/renderer/modules/storage/storage_area.cc
@@ -97,29 +97,32 @@ return cached_area_->GetItem(key); } -bool StorageArea::setItem(const String& key, - const String& value, - ExceptionState& exception_state) { +NamedPropertySetterResult StorageArea::setItem( + const String& key, + const String& value, + ExceptionState& exception_state) { if (!CanAccessStorage()) { exception_state.ThrowSecurityError("access is denied for this document."); - return true; + return NamedPropertySetterResult::kIntercepted; } if (!cached_area_->SetItem(key, value, this)) { exception_state.ThrowDOMException( DOMExceptionCode::kQuotaExceededError, "Setting the value of '" + key + "' exceeded the quota."); + return NamedPropertySetterResult::kIntercepted; } - return true; + return NamedPropertySetterResult::kIntercepted; } -DeleteResult StorageArea::removeItem(const String& key, - ExceptionState& exception_state) { +NamedPropertyDeleterResult StorageArea::removeItem( + const String& key, + ExceptionState& exception_state) { if (!CanAccessStorage()) { exception_state.ThrowSecurityError("access is denied for this document."); - return kDeleteSuccess; + return NamedPropertyDeleterResult::kDidNotDelete; } cached_area_->RemoveItem(key, this); - return kDeleteSuccess; + return NamedPropertyDeleterResult::kDeleted; } void StorageArea::clear(ExceptionState& exception_state) {
diff --git a/third_party/blink/renderer/modules/storage/storage_area.h b/third_party/blink/renderer/modules/storage/storage_area.h index d68f899..e9ea330 100644 --- a/third_party/blink/renderer/modules/storage/storage_area.h +++ b/third_party/blink/renderer/modules/storage/storage_area.h
@@ -66,8 +66,10 @@ unsigned length(ExceptionState&) const; String key(unsigned index, ExceptionState&) const; String getItem(const String& key, ExceptionState&) const; - bool setItem(const String& key, const String& value, ExceptionState&); - DeleteResult removeItem(const String& key, ExceptionState&); + NamedPropertySetterResult setItem(const String& key, + const String& value, + ExceptionState&); + NamedPropertyDeleterResult removeItem(const String& key, ExceptionState&); void clear(ExceptionState&); bool Contains(const String& key, ExceptionState& ec) const;
diff --git a/third_party/blink/renderer/platform/BUILD.gn b/third_party/blink/renderer/platform/BUILD.gn index 0d83f02c..9233201 100644 --- a/third_party/blink/renderer/platform/BUILD.gn +++ b/third_party/blink/renderer/platform/BUILD.gn
@@ -1984,6 +1984,7 @@ "//ui/gfx", "//ui/gfx/geometry", "//ui/gfx/geometry/mojom:test_interfaces_blink", + "//ui/gfx/mojom:test_interfaces_blink", "//url", "//url/mojom:test_url_mojom_gurl_blink", ]
diff --git a/third_party/blink/renderer/platform/bindings/v8_binding.h b/third_party/blink/renderer/platform/bindings/v8_binding.h index ba23a62..028ef596 100644 --- a/third_party/blink/renderer/platform/bindings/v8_binding.h +++ b/third_party/blink/renderer/platform/bindings/v8_binding.h
@@ -376,6 +376,24 @@ PLATFORM_EXPORT v8::Local<v8::Value> FreezeV8Object(v8::Local<v8::Value>, v8::Isolate*); +// Return values of indexed properties and named properties + +enum class IndexedPropertySetterResult { + kDidNotIntercept, // Fallback to the default set operation. + kIntercepted, // Intercepted regardless of whether it succeeded or not. +}; + +enum class NamedPropertySetterResult { + kDidNotIntercept, // Fallback to the default set operation. + kIntercepted, // Intercepted regardless of whether it succeeded or not. +}; + +enum class NamedPropertyDeleterResult { + kDidNotIntercept, // Fallback to the default delete operation. + kDeleted, // Successfully deleted. + kDidNotDelete, // Intercepted but failed to delete. +}; + } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_V8_BINDING_H_
diff --git a/third_party/blink/renderer/platform/fonts/font_data.h b/third_party/blink/renderer/platform/fonts/font_data.h index 3535115d..d79e7fd 100644 --- a/third_party/blink/renderer/platform/fonts/font_data.h +++ b/third_party/blink/renderer/platform/fonts/font_data.h
@@ -57,15 +57,6 @@ DISALLOW_COPY_AND_ASSIGN(FontData); }; -#define DEFINE_FONT_DATA_TYPE_CASTS(thisType, predicate) \ - template <typename T> \ - inline thisType* To##thisType(const scoped_refptr<T>& fontData) { \ - return To##thisType(fontData.get()); \ - } \ - DEFINE_TYPE_CASTS(thisType, FontData, fontData, \ - fontData->IsSegmented() == predicate, \ - fontData.IsSegmented() == predicate) - } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_FONT_DATA_H_
diff --git a/third_party/blink/renderer/platform/fonts/font_fallback_iterator.cc b/third_party/blink/renderer/platform/fonts/font_fallback_iterator.cc index 1362d48..eb07672 100644 --- a/third_party/blink/renderer/platform/fonts/font_fallback_iterator.cc +++ b/third_party/blink/renderer/platform/fonts/font_fallback_iterator.cc
@@ -153,7 +153,7 @@ current_font_data_index_++; if (!font_data->IsLoading()) { scoped_refptr<SimpleFontData> non_segmented = - const_cast<SimpleFontData*>(ToSimpleFontData(font_data)); + const_cast<SimpleFontData*>(To<SimpleFontData>(font_data)); // The fontData object that we have here is tracked in m_fontList of // FontFallbackList and gets released in the font cache when the // FontFallbackList is destroyed. @@ -165,7 +165,7 @@ // Iterate over ranges of a segmented font below. - const SegmentedFontData* segmented = ToSegmentedFontData(font_data); + const auto* segmented = To<SegmentedFontData>(font_data); if (fallback_stage_ != kSegmentedFace) { segmented_face_index_ = 0; fallback_stage_ = kSegmentedFace;
diff --git a/third_party/blink/renderer/platform/fonts/font_fallback_list.cc b/third_party/blink/renderer/platform/fonts/font_fallback_list.cc index 7762213..1d1ccdd 100644 --- a/third_party/blink/renderer/platform/fonts/font_fallback_list.cc +++ b/third_party/blink/renderer/platform/fonts/font_fallback_list.cc
@@ -69,7 +69,7 @@ if (!font_list_[i]->IsCustomFont()) { DCHECK(!font_list_[i]->IsSegmented()); FontCache::GetFontCache()->ReleaseFontData( - ToSimpleFontData(font_list_[i])); + To<SimpleFontData>(font_list_[i].get())); } } shape_cache_.reset(); // Clear the weak pointer to the cache instance. @@ -125,8 +125,8 @@ return last_resort_fallback; } - if (font_data->IsSegmented() && - !ToSegmentedFontData(font_data)->ContainsCharacter(kSpaceCharacter)) + const auto* segmented = DynamicTo<SegmentedFontData>(font_data); + if (segmented && !segmented->ContainsCharacter(kSpaceCharacter)) continue; const SimpleFontData* font_data_for_space = @@ -139,8 +139,7 @@ if (!font_data_for_space->IsLoadingFallback()) return font_data_for_space; - if (font_data->IsSegmented()) { - const SegmentedFontData* segmented = ToSegmentedFontData(font_data); + if (segmented) { for (unsigned i = 0; i < segmented->NumFaces(); i++) { const SimpleFontData* range_font_data = segmented->FaceAt(i)->FontData(); @@ -223,8 +222,9 @@ if (result) { bool is_unique_match = false; key.Add(font_description.CacheKey(params, is_unique_match)); - if (!result->IsSegmented() && !result->IsCustomFont()) - FontCache::GetFontCache()->ReleaseFontData(ToSimpleFontData(result)); + auto* font_data = DynamicTo<SimpleFontData>(result.get()); + if (!font_data && !result->IsCustomFont()) + FontCache::GetFontCache()->ReleaseFontData(font_data); } } current_family = current_family->Next();
diff --git a/third_party/blink/renderer/platform/fonts/mac/font_cache_mac.mm b/third_party/blink/renderer/platform/fonts/mac/font_cache_mac.mm index 04d802c6..fedd1b9 100644 --- a/third_party/blink/renderer/platform/fonts/mac/font_cache_mac.mm +++ b/third_party/blink/renderer/platform/fonts/mac/font_cache_mac.mm
@@ -326,6 +326,7 @@ } std::vector<FontEnumerationEntry> FontCache::EnumeratePlatformAvailableFonts() { + DCHECK(RuntimeEnabledFeatures::FontAccessEnabled()); @autoreleasepool { std::vector<FontEnumerationEntry> output;
diff --git a/third_party/blink/renderer/platform/fonts/segmented_font_data.h b/third_party/blink/renderer/platform/fonts/segmented_font_data.h index 61b2872..17cc3ed 100644 --- a/third_party/blink/renderer/platform/fonts/segmented_font_data.h +++ b/third_party/blink/renderer/platform/fonts/segmented_font_data.h
@@ -29,6 +29,7 @@ #include "third_party/blink/renderer/platform/fonts/font_data.h" #include "third_party/blink/renderer/platform/fonts/font_data_for_range_set.h" #include "third_party/blink/renderer/platform/platform_export.h" +#include "third_party/blink/renderer/platform/wtf/casting.h" class SimpleFontData; @@ -61,7 +62,12 @@ Vector<scoped_refptr<FontDataForRangeSet>, 1> faces_; }; -DEFINE_FONT_DATA_TYPE_CASTS(SegmentedFontData, true); +template <> +struct DowncastTraits<SegmentedFontData> { + static bool AllowFrom(const FontData& fontData) { + return fontData.IsSegmented(); + } +}; } // namespace blink
diff --git a/third_party/blink/renderer/platform/fonts/simple_font_data.h b/third_party/blink/renderer/platform/fonts/simple_font_data.h index 7c5e9561..070cde2e 100644 --- a/third_party/blink/renderer/platform/fonts/simple_font_data.h +++ b/third_party/blink/renderer/platform/fonts/simple_font_data.h
@@ -39,6 +39,7 @@ #include "third_party/blink/renderer/platform/fonts/typesetting_features.h" #include "third_party/blink/renderer/platform/geometry/float_rect.h" #include "third_party/blink/renderer/platform/platform_export.h" +#include "third_party/blink/renderer/platform/wtf/casting.h" #include "third_party/blink/renderer/platform/wtf/text/string_hash.h" #include "third_party/skia/include/core/SkFont.h" @@ -245,7 +246,12 @@ #endif } -DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false); +template <> +struct DowncastTraits<SimpleFontData> { + static bool AllowFrom(const FontData& fontData) { + return !fontData.IsSegmented(); + } +}; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_SIMPLE_FONT_DATA_H_
diff --git a/third_party/blink/renderer/platform/graphics/canvas_resource_provider.cc b/third_party/blink/renderer/platform/graphics/canvas_resource_provider.cc index 7c23790..0cccec5 100644 --- a/third_party/blink/renderer/platform/graphics/canvas_resource_provider.cc +++ b/third_party/blink/renderer/platform/graphics/canvas_resource_provider.cc
@@ -1129,7 +1129,7 @@ } void CanvasResourceProvider::FlushCanvas() { - if (!recorder_ || !recorder_->ListHasDrawOps()) + if (!HasRecordedDrawOps()) return; EnsureSkiaCanvas(); last_recording_ = recorder_->finishRecordingAsPicture(); @@ -1156,7 +1156,7 @@ TRACE_EVENT0("blink", "CanvasResourceProvider::WritePixels"); DCHECK(IsValid()); - DCHECK(!recorder_->ListHasDrawOps()); + DCHECK(!HasRecordedDrawOps()); EnsureSkiaCanvas(); @@ -1282,7 +1282,7 @@ // so always update the |mode_| to discard the old copy of canvas content. mode_ = SkSurface::kDiscard_ContentChangeMode; - if (!recorder_ || !recorder_->ListHasDrawOps()) + if (!HasRecordedDrawOps()) return; recorder_->finishRecordingAsPicture(); cc::PaintCanvas* canvas = @@ -1306,4 +1306,8 @@ skia_canvas_->drawImage(image, 0, 0, ©_paint); } +bool CanvasResourceProvider::HasRecordedDrawOps() const { + return recorder_ && recorder_->ListHasDrawOps(); +} + } // namespace blink
diff --git a/third_party/blink/renderer/platform/graphics/canvas_resource_provider.h b/third_party/blink/renderer/platform/graphics/canvas_resource_provider.h index 36cd0b2..96b881e 100644 --- a/third_party/blink/renderer/platform/graphics/canvas_resource_provider.h +++ b/third_party/blink/renderer/platform/graphics/canvas_resource_provider.h
@@ -218,6 +218,7 @@ void RestoreBackBuffer(const cc::PaintImage&); ResourceProviderType GetType() const { return type_; } + bool HasRecordedDrawOps() const; protected: gpu::gles2::GLES2Interface* ContextGL() const;
diff --git a/third_party/blink/renderer/platform/graphics/intercepting_canvas.h b/third_party/blink/renderer/platform/graphics/intercepting_canvas.h index 57fbf5d..8ede555 100644 --- a/third_party/blink/renderer/platform/graphics/intercepting_canvas.h +++ b/third_party/blink/renderer/platform/graphics/intercepting_canvas.h
@@ -86,15 +86,6 @@ void onDrawOval(const SkRect&, const SkPaint&) override = 0; void onDrawRRect(const SkRRect&, const SkPaint&) override = 0; void onDrawPath(const SkPath&, const SkPaint&) override = 0; - void onDrawBitmap(const SkBitmap&, - SkScalar left, - SkScalar top, - const SkPaint*) override = 0; - void onDrawBitmapRect(const SkBitmap&, - const SkRect* src, - const SkRect& dst, - const SkPaint*, - SrcRectConstraint) override = 0; void onDrawImage(const SkImage*, SkScalar, SkScalar, @@ -186,23 +177,6 @@ this->SkCanvas::onDrawPath(path, paint); } - void onDrawBitmap(const SkBitmap& bitmap, - SkScalar left, - SkScalar top, - const SkPaint* paint) override { - Interceptor interceptor(this); - this->SkCanvas::onDrawBitmap(bitmap, left, top, paint); - } - - void onDrawBitmapRect(const SkBitmap& bitmap, - const SkRect* src, - const SkRect& dst, - const SkPaint* paint, - SrcRectConstraint constraint) override { - Interceptor interceptor(this); - this->SkCanvas::onDrawBitmapRect(bitmap, src, dst, paint, constraint); - } - void onDrawImage(const SkImage* image, SkScalar x, SkScalar y,
diff --git a/third_party/blink/renderer/platform/graphics/logging_canvas.cc b/third_party/blink/renderer/platform/graphics/logging_canvas.cc index ec3b0aba..9fe75a4 100644 --- a/third_party/blink/renderer/platform/graphics/logging_canvas.cc +++ b/third_party/blink/renderer/platform/graphics/logging_canvas.cc
@@ -239,57 +239,6 @@ return path_item; } -String ColorTypeName(SkColorType color_type) { - switch (color_type) { - case kUnknown_SkColorType: - return "None"; - case kAlpha_8_SkColorType: - return "A8"; - case kRGB_565_SkColorType: - return "RGB565"; - case kARGB_4444_SkColorType: - return "ARGB4444"; - case kN32_SkColorType: - return "ARGB8888"; - default: - NOTREACHED(); - return "?"; - }; -} - -std::unique_ptr<JSONObject> ObjectForBitmapData(const SkBitmap& bitmap) { - Vector<unsigned char> output; - - SkPixmap src; - bool peekResult = bitmap.peekPixels(&src); - DCHECK(peekResult); - - SkPngEncoder::Options options; - options.fFilterFlags = SkPngEncoder::FilterFlag::kSub; - options.fZLibLevel = 3; - if (!ImageEncoder::Encode(&output, src, options)) { - return nullptr; - } - - auto data_item = std::make_unique<JSONObject>(); - data_item->SetString("base64", Base64Encode(output)); - data_item->SetString("mimeType", "image/png"); - return data_item; -} - -std::unique_ptr<JSONObject> ObjectForSkBitmap(const SkBitmap& bitmap) { - auto bitmap_item = std::make_unique<JSONObject>(); - bitmap_item->SetInteger("width", bitmap.width()); - bitmap_item->SetInteger("height", bitmap.height()); - bitmap_item->SetString("config", ColorTypeName(bitmap.colorType())); - bitmap_item->SetBoolean("opaque", bitmap.isOpaque()); - bitmap_item->SetBoolean("immutable", bitmap.isImmutable()); - bitmap_item->SetBoolean("volatile", bitmap.isVolatile()); - bitmap_item->SetInteger("genID", bitmap.getGenerationID()); - bitmap_item->SetObject("data", ObjectForBitmapData(bitmap)); - return bitmap_item; -} - std::unique_ptr<JSONObject> ObjectForSkImage(const SkImage* image) { auto image_item = std::make_unique<JSONObject>(); image_item->SetInteger("width", image->width()); @@ -519,37 +468,6 @@ this->SkCanvas::onDrawPath(path, paint); } -void LoggingCanvas::onDrawBitmap(const SkBitmap& bitmap, - SkScalar left, - SkScalar top, - const SkPaint* paint) { - AutoLogger logger(this); - JSONObject* params = logger.LogItemWithParams("drawBitmap"); - params->SetDouble("left", left); - params->SetDouble("top", top); - params->SetObject("bitmap", ObjectForSkBitmap(bitmap)); - if (paint) - params->SetObject("paint", ObjectForSkPaint(*paint)); - this->SkCanvas::onDrawBitmap(bitmap, left, top, paint); -} - -void LoggingCanvas::onDrawBitmapRect(const SkBitmap& bitmap, - const SkRect* src, - const SkRect& dst, - const SkPaint* paint, - SrcRectConstraint constraint) { - AutoLogger logger(this); - JSONObject* params = logger.LogItemWithParams("drawBitmapRectToRect"); - params->SetObject("bitmap", ObjectForSkBitmap(bitmap)); - if (src) - params->SetObject("src", ObjectForSkRect(*src)); - params->SetObject("dst", ObjectForSkRect(dst)); - if (paint) - params->SetObject("paint", ObjectForSkPaint(*paint)); - params->SetInteger("flags", constraint); - this->SkCanvas::onDrawBitmapRect(bitmap, src, dst, paint, constraint); -} - void LoggingCanvas::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
diff --git a/third_party/blink/renderer/platform/graphics/logging_canvas.h b/third_party/blink/renderer/platform/graphics/logging_canvas.h index 1f516d53..82b0097 100644 --- a/third_party/blink/renderer/platform/graphics/logging_canvas.h +++ b/third_party/blink/renderer/platform/graphics/logging_canvas.h
@@ -53,15 +53,6 @@ void onDrawOval(const SkRect&, const SkPaint&) override; void onDrawRRect(const SkRRect&, const SkPaint&) override; void onDrawPath(const SkPath&, const SkPaint&) override; - void onDrawBitmap(const SkBitmap&, - SkScalar left, - SkScalar top, - const SkPaint*) override; - void onDrawBitmapRect(const SkBitmap&, - const SkRect* src, - const SkRect& dst, - const SkPaint*, - SrcRectConstraint) override; void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override; void onDrawImageRect(const SkImage*, const SkRect* src,
diff --git a/third_party/blink/renderer/platform/graphics/video_frame_submitter_test.cc b/third_party/blink/renderer/platform/graphics/video_frame_submitter_test.cc index ae0a22c..8a772fda 100644 --- a/third_party/blink/renderer/platform/graphics/video_frame_submitter_test.cc +++ b/third_party/blink/renderer/platform/graphics/video_frame_submitter_test.cc
@@ -12,10 +12,12 @@ #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/memory/read_only_shared_memory_region.h" +#include "base/test/bind_test_util.h" #include "base/test/simple_test_tick_clock.h" #include "base/test/task_environment.h" #include "base/time/time.h" #include "cc/layers/video_frame_provider.h" +#include "cc/metrics/video_playback_roughness_reporter.h" #include "cc/test/layer_test_common.h" #include "cc/trees/layer_tree_settings.h" #include "cc/trees/task_runner_provider.h" @@ -37,6 +39,7 @@ using testing::_; using testing::AnyNumber; +using testing::Invoke; using testing::Return; using testing::StrictMock; @@ -955,4 +958,66 @@ task_environment_.RunUntilIdle(); } +// Check that given enough frames with wallclock duration and enough +// presentation feedback data, VideoFrameSubmitter will call the video roughness +// reporting callback. +TEST_F(VideoFrameSubmitterTest, ProcessTimingDetails) { + int fps = 24; + int reports = 0; + base::TimeDelta frame_duration = base::TimeDelta::FromSecondsD(1.0 / fps); + int frames_to_run = + (fps / 2) * + (cc::VideoPlaybackRoughnessReporter::kMinWindowsBeforeSubmit + 1); + WTF::HashMap<uint32_t, viz::mojom::blink::FrameTimingDetailsPtr> + timing_details; + + MakeSubmitter( + base::BindLambdaForTesting([&](int frames, base::TimeDelta duration, + double roughness) { reports++; })); + EXPECT_CALL(*sink_, SetNeedsBeginFrame(true)); + submitter_->StartRendering(); + task_environment_.RunUntilIdle(); + EXPECT_TRUE(IsRendering()); + + auto sink_submit = [&](const viz::LocalSurfaceId&, + viz::CompositorFrame* frame) { + auto token = frame->metadata.frame_token; + viz::mojom::blink::FrameTimingDetailsPtr details = + viz::mojom::blink::FrameTimingDetails::New(); + details->presentation_feedback = + gfx::mojom::blink::PresentationFeedback::New(); + details->presentation_feedback->timestamp = + base::TimeTicks() + frame_duration * token; + timing_details.clear(); + timing_details.Set(token, std::move(details)); + }; + + EXPECT_CALL(*video_frame_provider_, UpdateCurrentFrame) + .WillRepeatedly(Return(true)); + EXPECT_CALL(*video_frame_provider_, PutCurrentFrame).Times(AnyNumber()); + EXPECT_CALL(*sink_, DoSubmitCompositorFrame) + .WillRepeatedly(Invoke(sink_submit)); + EXPECT_CALL(*resource_provider_, AppendQuads).Times(AnyNumber()); + EXPECT_CALL(*resource_provider_, PrepareSendToParent).Times(AnyNumber()); + EXPECT_CALL(*resource_provider_, ReleaseFrameResources).Times(AnyNumber()); + + for (int i = 0; i < frames_to_run; i++) { + auto frame = media::VideoFrame::CreateFrame( + media::PIXEL_FORMAT_YV12, gfx::Size(8, 8), gfx::Rect(gfx::Size(8, 8)), + gfx::Size(8, 8), i * frame_duration); + frame->metadata()->SetTimeDelta( + media::VideoFrameMetadata::WALLCLOCK_FRAME_DURATION, frame_duration); + EXPECT_CALL(*video_frame_provider_, GetCurrentFrame()) + .WillRepeatedly(Return(frame)); + + auto args = begin_frame_source_->CreateBeginFrameArgs(BEGINFRAME_FROM_HERE, + now_src_.get()); + submitter_->OnBeginFrame(args, std::move(timing_details)); + task_environment_.RunUntilIdle(); + AckSubmittedFrame(); + } + submitter_->StopRendering(); + EXPECT_EQ(reports, 1); +} + } // namespace blink
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource.cc b/third_party/blink/renderer/platform/loader/fetch/resource.cc index f998c66..5348736 100644 --- a/third_party/blink/renderer/platform/loader/fetch/resource.cc +++ b/third_party/blink/renderer/platform/loader/fetch/resource.cc
@@ -146,7 +146,7 @@ return clock->Now(); } -Resource::Resource(const ResourceRequest& request, +Resource::Resource(const ResourceRequestHead& request, ResourceType type, const ResourceLoaderOptions& options) : type_(type), @@ -162,8 +162,8 @@ integrity_disposition_(ResourceIntegrityDisposition::kNotChecked), options_(options), response_timestamp_(Now()), + resource_request_(request), overhead_size_(CalculateOverheadSize()) { - resource_request_.CopyFrom(request); InstanceCounters::IncrementCounter(InstanceCounters::kResourceCounter); if (IsMainThread()) @@ -484,13 +484,13 @@ return &redirect_chain_.back().redirect_response_; } -void Resource::SetRevalidatingRequest(const ResourceRequest& request) { +void Resource::SetRevalidatingRequest(const ResourceRequestHead& request) { SECURITY_CHECK(redirect_chain_.IsEmpty()); SECURITY_CHECK(!is_unused_preload_); DCHECK(!request.IsNull()); CHECK(!is_revalidation_start_forbidden_); is_revalidating_ = true; - resource_request_.CopyHeadFrom(request); + resource_request_ = request; status_ = ResourceStatus::kNotStarted; }
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource.h b/third_party/blink/renderer/platform/loader/fetch/resource.h index ffb2d1e..57f26c801 100644 --- a/third_party/blink/renderer/platform/loader/fetch/resource.h +++ b/third_party/blink/renderer/platform/loader/fetch/resource.h
@@ -176,13 +176,13 @@ virtual bool ShouldIgnoreHTTPStatusCodeErrors() const { return false; } - const ResourceRequest& GetResourceRequest() const { + const ResourceRequestHead& GetResourceRequest() const { return resource_request_; } const ResourceRequestHead& LastResourceRequest() const; const ResourceResponse* LastResourceResponse() const; - virtual void SetRevalidatingRequest(const ResourceRequest&); + virtual void SetRevalidatingRequest(const ResourceRequestHead&); // This url can have a fragment, but it can match resources that differ by the // fragment only. @@ -420,7 +420,9 @@ static void SetClockForTesting(const base::Clock* clock); protected: - Resource(const ResourceRequest&, ResourceType, const ResourceLoaderOptions&); + Resource(const ResourceRequestHead&, + ResourceType, + const ResourceLoaderOptions&); // Returns true if the resource has finished any processing it wanted to do // after loading. Should only be used to decide whether to call @@ -559,7 +561,7 @@ TaskHandle async_finish_pending_clients_task_; - ResourceRequest resource_request_; + ResourceRequestHead resource_request_; // Resource::CalculateOverheadSize() is affected by changes in // |m_resourceRequest.url()|, but |m_overheadSize| is not updated after
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc b/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc index e95156fc..bfa2bec5 100644 --- a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc +++ b/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc
@@ -191,7 +191,7 @@ ResourceLoadPriority AdjustPriorityWithPriorityHint( ResourceLoadPriority priority_so_far, ResourceType type, - const ResourceRequest& resource_request, + const ResourceRequestHead& resource_request, FetchParameters::DeferOption defer_option, bool is_link_preload) { mojom::FetchImportanceMode importance_mode = @@ -241,7 +241,7 @@ const FetchContext& fetch_context, ResourceLoadPriority priority_so_far, ResourceType type, - const ResourceRequest& resource_request, + const ResourceRequestHead& resource_request, FetchParameters::DeferOption defer_option, bool is_link_preload) { if (!base::FeatureList::IsEnabled( @@ -417,7 +417,7 @@ // images, which may need to be reprioritized. ResourceLoadPriority ResourceFetcher::ComputeLoadPriority( ResourceType type, - const ResourceRequest& resource_request, + const ResourceRequestHead& resource_request, ResourcePriority::VisibilityStatus visibility, FetchParameters::DeferOption defer_option, FetchParameters::SpeculativePreloadType speculative_preload_type, @@ -1093,7 +1093,8 @@ // the resource was already initialized for the revalidation here, but won't // start loading. if (ResourceNeedsLoad(resource, params, policy)) { - if (!StartLoad(resource)) { + if (!StartLoad(resource, + std::move(params.MutableResourceRequest().MutableBody()))) { resource->FinishAsError(ResourceError::CancelledError(params.Url()), task_runner_.get()); } @@ -1849,6 +1850,11 @@ } bool ResourceFetcher::StartLoad(Resource* resource) { + return StartLoad(resource, ResourceRequestBody()); +} + +bool ResourceFetcher::StartLoad(Resource* resource, + ResourceRequestBody request_body) { DCHECK(resource); DCHECK(resource->StillNeedsLoad()); @@ -1866,11 +1872,13 @@ return false; } - const auto& request = resource->GetResourceRequest(); - ResourceResponse response; + const ResourceRequestHead& request_head = resource->GetResourceRequest(); if (resource_load_observer_) { DCHECK(!IsDetached()); + ResourceRequest request(request_head); + request.SetHttpBody(request_body.FormBody()); + ResourceResponse response; resource_load_observer_->WillSendRequest( resource->InspectorId(), request, response, resource->GetType(), resource->Options().initiator_info); @@ -1878,8 +1886,8 @@ using QuotaType = decltype(inflight_keepalive_bytes_); QuotaType size = 0; - if (request.GetKeepalive() && request.HttpBody()) { - auto original_size = request.HttpBody()->SizeInBytes(); + if (request_head.GetKeepalive() && request_body.FormBody()) { + auto original_size = request_body.FormBody()->SizeInBytes(); DCHECK_LE(inflight_keepalive_bytes_, kKeepaliveInflightBytesQuota); if (original_size > std::numeric_limits<QuotaType>::max()) return false; @@ -1890,8 +1898,8 @@ inflight_keepalive_bytes_ += size; } - loader = - MakeGarbageCollected<ResourceLoader>(this, scheduler_, resource, size); + loader = MakeGarbageCollected<ResourceLoader>( + this, scheduler_, resource, std::move(request_body), size); // Preload requests should not block the load event. IsLinkPreload() // actually continues to return true for Resources matched from the preload // cache that must block the load event, but that is OK because this method
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h b/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h index ea8ca0597..75ac244 100644 --- a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h +++ b/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h
@@ -168,6 +168,7 @@ // call this method explicitly on cases such as ResourceNeedsLoad() returning // false. bool StartLoad(Resource*); + bool StartLoad(Resource*, ResourceRequestBody); void SetAutoLoadImages(bool); void SetImagesEnabled(bool); @@ -257,7 +258,7 @@ ResourceLoadPriority ComputeLoadPriorityForTesting( ResourceType type, - const ResourceRequest& request, + const ResourceRequestHead& request, ResourcePriority::VisibilityStatus visibility_statue, FetchParameters::DeferOption defer_option, FetchParameters::SpeculativePreloadType speculative_preload_type, @@ -288,7 +289,7 @@ void StorePerformanceTimingInitiatorInformation(Resource*); ResourceLoadPriority ComputeLoadPriority( ResourceType, - const ResourceRequest&, + const ResourceRequestHead&, ResourcePriority::VisibilityStatus, FetchParameters::DeferOption = FetchParameters::kNoDefer, FetchParameters::SpeculativePreloadType =
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_loader.cc b/third_party/blink/renderer/platform/loader/fetch/resource_loader.cc index 667a786..53e105f 100644 --- a/third_party/blink/renderer/platform/loader/fetch/resource_loader.cc +++ b/third_party/blink/renderer/platform/loader/fetch/resource_loader.cc
@@ -148,7 +148,7 @@ builder.Record(recorder); } -bool CanHandleDataURLRequestLocally(const ResourceRequest& request) { +bool CanHandleDataURLRequestLocally(const ResourceRequestHead& request) { if (!request.Url().ProtocolIsData()) return false; @@ -368,11 +368,13 @@ ResourceLoader::ResourceLoader(ResourceFetcher* fetcher, ResourceLoadScheduler* scheduler, Resource* resource, + ResourceRequestBody request_body, uint32_t inflight_keepalive_bytes) : scheduler_client_id_(ResourceLoadScheduler::kInvalidClientId), fetcher_(fetcher), scheduler_(scheduler), resource_(resource), + request_body_(std::move(request_body)), inflight_keepalive_bytes_(inflight_keepalive_bytes), is_cache_aware_loading_activated_(false), cancel_timer_(fetcher_->GetTaskRunner(), @@ -412,7 +414,7 @@ if (!RuntimeEnabledFeatures::IsolatedCodeCacheEnabled()) return false; - const ResourceRequest& request = resource_->GetResourceRequest(); + const ResourceRequestHead& request = resource_->GetResourceRequest(); if (!request.Url().ProtocolIsInHTTPFamily()) return false; // When loading the service worker scripts, we don't need to check the @@ -441,9 +443,12 @@ } void ResourceLoader::Start() { - const ResourceRequest& request = resource_->GetResourceRequest(); + const ResourceRequestHead& request = resource_->GetResourceRequest(); ActivateCacheAwareLoadingIfNeeded(request); - loader_ = fetcher_->CreateURLLoader(request, resource_->Options()); + // TODO(yoichio): Have CreateURLLoader take a ResourceRequestHead, not + // ResourceRequest. + loader_ = + fetcher_->CreateURLLoader(ResourceRequest(request), resource_->Options()); task_runner_for_body_loader_ = loader_->GetTaskRunner(); DCHECK_EQ(ResourceLoadScheduler::kInvalidClientId, scheduler_client_id_); auto throttle_option = ResourceLoadScheduler::ThrottleOption::kThrottleable; @@ -471,8 +476,6 @@ request.IsolatedWorldOrigin().get(), GetCorsFlag() ? CorsFlag::Set : CorsFlag::Unset); } - if (!RuntimeEnabledFeatures::OutOfBlinkCorsEnabled()) - request_body_for_reidirect_ = request.HttpBody(); if (request.IsAutomaticUpgrade()) { mojo::PendingRemote<ukm::mojom::UkmRecorderInterface> pending_recorder; @@ -542,7 +545,7 @@ Cancel(); } -void ResourceLoader::StartWith(const ResourceRequest& request) { +void ResourceLoader::StartWith(const ResourceRequestHead& request) { DCHECK_NE(ResourceLoadScheduler::kInvalidClientId, scheduler_client_id_); DCHECK(loader_); @@ -565,8 +568,7 @@ if (is_cache_aware_loading_activated_) { // Override cache policy for cache-aware loading. If this request fails, a // reload with original request will be triggered in DidFail(). - ResourceRequest cache_aware_request; - cache_aware_request.CopyFrom(request); + ResourceRequestHead cache_aware_request(request); cache_aware_request.SetCacheMode( mojom::FetchCacheMode::kUnspecifiedOnlyIfCachedStrict); RequestAsynchronously(cache_aware_request); @@ -590,9 +592,10 @@ feature_handle_for_scheduler_.reset(); } -void ResourceLoader::Restart(const ResourceRequest& request) { +void ResourceLoader::Restart(const ResourceRequestHead& request) { CHECK_EQ(resource_->Options().synchronous_policy, kRequestAsynchronously); - loader_ = fetcher_->CreateURLLoader(request, resource_->Options()); + loader_ = + fetcher_->CreateURLLoader(ResourceRequest(request), resource_->Options()); task_runner_for_body_loader_ = loader_->GetTaskRunner(); StartWith(request); } @@ -674,7 +677,7 @@ } } -static bool IsManualRedirectFetchRequest(const ResourceRequest& request) { +static bool IsManualRedirectFetchRequest(const ResourceRequestHead& request) { return request.GetRedirectMode() == network::mojom::RedirectMode::kManual && request.GetRequestContext() == mojom::RequestContextType::FETCH; } @@ -704,12 +707,12 @@ if (!RuntimeEnabledFeatures::OutOfBlinkCorsEnabled() && (new_request->HttpMethod() != http_names::kGET && new_request->HttpMethod() != http_names::kHEAD)) { - new_request->SetHttpBody(request_body_for_reidirect_); + new_request->SetHttpBody(request_body_.FormBody()); } ResourceType resource_type = resource_->GetType(); - const ResourceRequest& initial_request = resource_->GetResourceRequest(); + const ResourceRequestHead& initial_request = resource_->GetResourceRequest(); // The following parameters never change during the lifetime of a request. mojom::RequestContextType request_context = initial_request.GetRequestContext(); @@ -912,7 +915,7 @@ void ResourceLoader::DidReceiveResponseInternal( const ResourceResponse& response) { - const ResourceRequest& request = resource_->GetResourceRequest(); + const ResourceRequestHead& request = resource_->GetResourceRequest(); if (request.IsAutomaticUpgrade()) { mojo::PendingRemote<ukm::mojom::UkmRecorderInterface> pending_recorder; @@ -935,7 +938,7 @@ ResourceType resource_type = resource_->GetType(); - const ResourceRequest& initial_request = resource_->GetResourceRequest(); + const ResourceRequestHead& initial_request = resource_->GetResourceRequest(); // The following parameters never change during the lifetime of a request. mojom::RequestContextType request_context = initial_request.GetRequestContext(); @@ -966,9 +969,7 @@ request_mode == network::mojom::RequestMode::kCors && response.WasFallbackRequiredByServiceWorker()) { DCHECK(resource_->RedirectChain().IsEmpty()); - ResourceRequest last_request; - last_request.CopyHeadFrom(resource_->GetResourceRequest()); - last_request.SetHttpBody(resource_->GetResourceRequest().HttpBody()); + ResourceRequestHead last_request(resource_->GetResourceRequest()); DCHECK(!last_request.GetSkipServiceWorker()); // This code handles the case when a controlling service worker doesn't // handle a cross origin request. @@ -1010,8 +1011,8 @@ base::Optional<ResourceRequestBlockedReason> blocked_reason = Context().CanRequest( - resource_type, initial_request, response_url, options, - ReportingDisposition::kReport, + resource_type, ResourceRequest(initial_request), response_url, + options, ReportingDisposition::kReport, ResourceRequest::RedirectStatus::kFollowedRedirect); if (blocked_reason) { HandleError(ResourceError::CancelledDueToAccessCheckError( @@ -1044,9 +1045,12 @@ // FrameType never changes during the lifetime of a request. if (auto* observer = fetcher_->GetResourceLoadObserver()) { + ResourceRequest request_for_obserber(initial_request); + // TODO(yoichio): Have DidReceiveResponse take a ResourceResponseHead, not + // ResourceRequest. observer->DidReceiveResponse( - resource_->InspectorId(), initial_request, response_to_pass, resource_, - ResourceLoadObserver::ResponseSource::kNotFromMemoryCache); + resource_->InspectorId(), request_for_obserber, response_to_pass, + resource_, ResourceLoadObserver::ResponseSource::kNotFromMemoryCache); } resource_->ResponseReceived(response_to_pass); @@ -1186,7 +1190,7 @@ int64_t encoded_data_length, int64_t encoded_body_length, int64_t decoded_body_length) { - const ResourceRequest& request = resource_->GetResourceRequest(); + const ResourceRequestHead& request = resource_->GetResourceRequest(); if (request.IsAutomaticUpgrade()) { mojo::PendingRemote<ukm::mojom::UkmRecorderInterface> pending_recorder; @@ -1246,12 +1250,16 @@ inflight_keepalive_bytes_); } -void ResourceLoader::RequestSynchronously(const ResourceRequest& request) { +void ResourceLoader::RequestSynchronously(const ResourceRequestHead& request) { DCHECK(loader_); DCHECK_EQ(request.Priority(), ResourceLoadPriority::kHighest); auto network_resource_request = std::make_unique<network::ResourceRequest>(); - PopulateResourceRequest(request, network_resource_request.get()); + scoped_refptr<EncodedFormData> form_body = request_body_.FormBody(); + PopulateResourceRequest(request, std::move(request_body_), + network_resource_request.get()); + if (form_body) + request_body_ = ResourceRequestBody(std::move(form_body)); WebURLResponse response_out; base::Optional<WebURLError> error_out; WebData data_out; @@ -1323,7 +1331,7 @@ encoded_body_length, decoded_body_length, false); } -void ResourceLoader::RequestAsynchronously(const ResourceRequest& request) { +void ResourceLoader::RequestAsynchronously(const ResourceRequestHead& request) { DCHECK(loader_); if (CanHandleDataURLRequestLocally(request)) { DCHECK(!code_cache_request_); @@ -1338,7 +1346,11 @@ // Don't do mime sniffing for fetch (crbug.com/2016) bool no_mime_sniffing = request.GetRequestContext() == blink::mojom::RequestContextType::FETCH; - PopulateResourceRequest(request, network_resource_request.get()); + scoped_refptr<EncodedFormData> form_body = request_body_.FormBody(); + PopulateResourceRequest(request, std::move(request_body_), + network_resource_request.get()); + if (form_body) + request_body_ = ResourceRequestBody(std::move(form_body)); loader_->LoadAsynchronously(std::move(network_resource_request), request.GetExtraData(), request.RequestorID(), request.IsDownloadToNetworkCacheOnly(), @@ -1365,7 +1377,7 @@ } void ResourceLoader::ActivateCacheAwareLoadingIfNeeded( - const ResourceRequest& request) { + const ResourceRequestHead& request) { DCHECK(!is_cache_aware_loading_activated_); if (resource_->Options().cache_aware_loading_enabled !=
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_loader.h b/third_party/blink/renderer/platform/loader/fetch/resource_loader.h index ebb2308e..ba73d21 100644 --- a/third_party/blink/renderer/platform/loader/fetch/resource_loader.h +++ b/third_party/blink/renderer/platform/loader/fetch/resource_loader.h
@@ -75,6 +75,7 @@ ResourceLoader(ResourceFetcher*, ResourceLoadScheduler*, Resource*, + ResourceRequestBody request_body = ResourceRequestBody(), uint32_t inflight_keepalive_bytes = 0); ~ResourceLoader() override; void Trace(Visitor*) override; @@ -90,7 +91,7 @@ // Called before start() to activate cache-aware loading if enabled in // |m_resource->options()| and applicable. - void ActivateCacheAwareLoadingIfNeeded(const ResourceRequest&); + void ActivateCacheAwareLoadingIfNeeded(const ResourceRequestHead&); bool IsCacheAwareLoadingActivated() const { return is_cache_aware_loading_activated_; @@ -165,7 +166,7 @@ void DidCancelLoadingBody() override; bool ShouldFetchCodeCache(); - void StartWith(const ResourceRequest&); + void StartWith(const ResourceRequestHead&); void Release(ResourceLoadScheduler::ReleaseOption, const ResourceLoadScheduler::TrafficReportHints&); @@ -173,7 +174,7 @@ // This method is currently only used for service worker fallback request and // cache-aware loading, other users should be careful not to break // ResourceLoader state. - void Restart(const ResourceRequest&); + void Restart(const ResourceRequestHead&); FetchContext& Context() const; @@ -183,8 +184,8 @@ void CancelForRedirectAccessCheckError(const KURL&, ResourceRequestBlockedReason); - void RequestSynchronously(const ResourceRequest&); - void RequestAsynchronously(const ResourceRequest&); + void RequestSynchronously(const ResourceRequestHead&); + void RequestAsynchronously(const ResourceRequestHead&); void Dispose(); void DidReceiveResponseInternal(const ResourceResponse&); @@ -210,8 +211,7 @@ Member<ResourceFetcher> fetcher_; Member<ResourceLoadScheduler> scheduler_; Member<Resource> resource_; - // This flag is only needed when OOB-CORS is disabled. - scoped_refptr<EncodedFormData> request_body_for_reidirect_; + ResourceRequestBody request_body_; Member<ResponseBodyLoader> response_body_loader_; Member<DataPipeBytesConsumer::CompletionNotifier> data_pipe_completion_notifier_;
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_request.cc b/third_party/blink/renderer/platform/loader/fetch/resource_request.cc index 6428325..8ee020a 100644 --- a/third_party/blink/renderer/platform/loader/fetch/resource_request.cc +++ b/third_party/blink/renderer/platform/loader/fetch/resource_request.cc
@@ -91,6 +91,22 @@ ResourceRequestHead::~ResourceRequestHead() = default; +ResourceRequestBody::ResourceRequestBody() : ResourceRequestBody(nullptr) {} + +ResourceRequestBody::ResourceRequestBody( + scoped_refptr<EncodedFormData> form_body) + : form_body_(form_body) {} + +ResourceRequestBody::ResourceRequestBody(ResourceRequestBody&& src) + : ResourceRequestBody(std::move(src.form_body_)) {} + +ResourceRequestBody& ResourceRequestBody::operator=(ResourceRequestBody&& src) { + form_body_ = std::move(src.form_body_); + return *this; +} + +ResourceRequestBody::~ResourceRequestBody() = default; + ResourceRequest::ResourceRequest() : ResourceRequestHead(NullURL()) {} ResourceRequest::ResourceRequest(const String& url_string) @@ -101,7 +117,11 @@ ResourceRequest::ResourceRequest(const ResourceRequestHead& head) : ResourceRequestHead(head) {} -ResourceRequest& ResourceRequest::operator=(const ResourceRequest&) = default; +ResourceRequest& ResourceRequest::operator=(const ResourceRequest& src) { + this->ResourceRequestHead::operator=(src); + body_.SetFormBody(src.body_.FormBody()); + return *this; +} ResourceRequest::ResourceRequest(ResourceRequest&&) = default; @@ -274,12 +294,17 @@ http_header_fields_.Remove(http_names::kUserAgent); } -EncodedFormData* ResourceRequest::HttpBody() const { - return http_body_.get(); +void ResourceRequestBody::SetFormBody( + scoped_refptr<EncodedFormData> form_body) { + form_body_ = std::move(form_body); +} + +const scoped_refptr<EncodedFormData>& ResourceRequest::HttpBody() const { + return body_.FormBody(); } void ResourceRequest::SetHttpBody(scoped_refptr<EncodedFormData> http_body) { - http_body_ = std::move(http_body); + body_.SetFormBody(std::move(http_body)); } bool ResourceRequestHead::AllowStoredCredentials() const {
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_request.h b/third_party/blink/renderer/platform/loader/fetch/resource_request.h index ede0698e8..71139b09 100644 --- a/third_party/blink/renderer/platform/loader/fetch/resource_request.h +++ b/third_party/blink/renderer/platform/loader/fetch/resource_request.h
@@ -547,6 +547,25 @@ base::Optional<base::UnguessableToken> recursive_prefetch_token_; }; +class PLATFORM_EXPORT ResourceRequestBody { + public: + ResourceRequestBody(); + explicit ResourceRequestBody(scoped_refptr<EncodedFormData> form_body); + ResourceRequestBody(const ResourceRequestBody&) = delete; + ResourceRequestBody(ResourceRequestBody&&); + + ResourceRequestBody& operator=(const ResourceRequestBody&) = delete; + ResourceRequestBody& operator=(ResourceRequestBody&&); + + ~ResourceRequestBody(); + + const scoped_refptr<EncodedFormData>& FormBody() const { return form_body_; } + void SetFormBody(scoped_refptr<EncodedFormData>); + + private: + scoped_refptr<EncodedFormData> form_body_; +}; + // A ResourceRequest is a "request" object for ResourceLoader. Conceptually // it is https://fetch.spec.whatwg.org/#concept-request, but it contains // a lot of blink specific fields. WebURLRequest is the "public version" @@ -581,13 +600,15 @@ void CopyFrom(const ResourceRequest&); void CopyHeadFrom(const ResourceRequestHead&); - EncodedFormData* HttpBody() const; + const scoped_refptr<EncodedFormData>& HttpBody() const; void SetHttpBody(scoped_refptr<EncodedFormData>); + ResourceRequestBody& MutableBody() { return body_; } + private: ResourceRequest& operator=(const ResourceRequest&); - scoped_refptr<EncodedFormData> http_body_; + ResourceRequestBody body_; }; } // namespace blink
diff --git a/third_party/blink/renderer/platform/loader/fetch/url_loader/request_conversion.cc b/third_party/blink/renderer/platform/loader/fetch/url_loader/request_conversion.cc index a1b14d70..7647a1f7 100644 --- a/third_party/blink/renderer/platform/loader/fetch/url_loader/request_conversion.cc +++ b/third_party/blink/renderer/platform/loader/fetch/url_loader/request_conversion.cc
@@ -251,7 +251,8 @@ } } -void PopulateResourceRequest(const ResourceRequest& src, +void PopulateResourceRequest(const ResourceRequestHead& src, + ResourceRequestBody src_body, network::ResourceRequest* dest) { dest->method = src.HttpMethod().Latin1(); dest->url = src.Url(); @@ -296,7 +297,8 @@ } // TODO(yhirano): Remove this WrappedResourceRequest. - dest->load_flags = WrappedResourceRequest(src).GetLoadFlagsForWebUrlRequest(); + dest->load_flags = WrappedResourceRequest(ResourceRequest(src)) + .GetLoadFlagsForWebUrlRequest(); dest->recursive_prefetch_token = src.RecursivePrefetchToken(); dest->priority = ConvertWebKitPriorityToNetPriority(src.Priority()); dest->should_reset_appcache = src.ShouldResetAppCache(); @@ -348,7 +350,7 @@ dest->is_signed_exchange_prefetch_cache_enabled = true; } - if (const EncodedFormData* body = src.HttpBody()) { + if (const EncodedFormData* body = src_body.FormBody().get()) { DCHECK_NE(dest->method, net::HttpRequestHeaders::kGetMethod); DCHECK_NE(dest->method, net::HttpRequestHeaders::kHeadMethod); dest->request_body = base::MakeRefCounted<network::ResourceRequestBody>();
diff --git a/third_party/blink/renderer/platform/loader/fetch/url_loader/request_conversion.h b/third_party/blink/renderer/platform/loader/fetch/url_loader/request_conversion.h index 918b2a7f..a94fba68 100644 --- a/third_party/blink/renderer/platform/loader/fetch/url_loader/request_conversion.h +++ b/third_party/blink/renderer/platform/loader/fetch/url_loader/request_conversion.h
@@ -14,13 +14,15 @@ namespace blink { -class ResourceRequest; +class ResourceRequestHead; +class ResourceRequestBody; class EncodedFormData; void PopulateResourceRequestBody(const EncodedFormData& src, network::ResourceRequestBody* dest); -void PopulateResourceRequest(const ResourceRequest& src, +void PopulateResourceRequest(const ResourceRequestHead& src, + ResourceRequestBody src_body, network::ResourceRequest* dest); } // namespace blink
diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5 index 4ab8fbd..466ac070 100644 --- a/third_party/blink/renderer/platform/runtime_enabled_features.json5 +++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5
@@ -741,6 +741,10 @@ settable_from_internals: true, }, { + name: "FontAccess", + status: "experimental", + }, + { name: "FontSrcLocalMatching", // No status, as the web platform runtime enabled feature is controlled by // a Chromium level feature.
diff --git a/third_party/blink/renderer/platform/widget/widget_base.cc b/third_party/blink/renderer/platform/widget/widget_base.cc index 0107272c..800bb29 100644 --- a/third_party/blink/renderer/platform/widget/widget_base.cc +++ b/third_party/blink/renderer/platform/widget/widget_base.cc
@@ -6,6 +6,7 @@ #include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "mojo/public/cpp/bindings/pending_associated_remote.h" +#include "third_party/blink/renderer/platform/scheduler/public/thread.h" #include "third_party/blink/renderer/platform/widget/widget_base_client.h" namespace blink { @@ -35,9 +36,44 @@ return animation_host_; } +void WidgetBase::SetCompositorVisible(bool visible) { + if (visible) + was_shown_time_ = base::TimeTicks::Now(); + else + first_update_visual_state_after_hidden_ = true; +} + +void WidgetBase::UpdateVisualState() { + // When recording main frame metrics set the lifecycle reason to + // kBeginMainFrame, because this is the calller of UpdateLifecycle + // for the main frame. Otherwise, set the reason to kTests, which is + // the only other reason this method is called. + DocumentUpdateReason lifecycle_reason = + ShouldRecordBeginMainFrameMetrics() + ? DocumentUpdateReason::kBeginMainFrame + : DocumentUpdateReason::kTest; + client_->UpdateLifecycle(WebLifecycleUpdate::kAll, lifecycle_reason); + client_->SetSuppressFrameRequestsWorkaroundFor704763Only(false); + if (first_update_visual_state_after_hidden_) { + client_->RecordTimeToFirstActivePaint(base::TimeTicks::Now() - + was_shown_time_); + first_update_visual_state_after_hidden_ = false; + } +} + +void WidgetBase::WillBeginCompositorFrame() { + client_->SetSuppressFrameRequestsWorkaroundFor704763Only(true); +} + void WidgetBase::BeginMainFrame(base::TimeTicks frame_time) { client_->DispatchRafAlignedInput(frame_time); client_->BeginMainFrame(frame_time); } +bool WidgetBase::ShouldRecordBeginMainFrameMetrics() { + // We record metrics only when running in multi-threaded mode, not + // single-thread mode for testing. + return Thread::CompositorThread(); +} + } // namespace blink
diff --git a/third_party/blink/renderer/platform/widget/widget_base.h b/third_party/blink/renderer/platform/widget/widget_base.h index 5fa03af5..3d70fae9 100644 --- a/third_party/blink/renderer/platform/widget/widget_base.h +++ b/third_party/blink/renderer/platform/widget/widget_base.h
@@ -37,13 +37,28 @@ // Set the current compositor hosts. void SetCompositorHosts(cc::LayerTreeHost*, cc::AnimationHost*); - cc::AnimationHost* AnimationHost() const; - cc::LayerTreeHost* LayerTreeHost() const; + // Set the compositor as visible. If |visible| is true, then the compositor + // will request a new layer frame sink, begin producing frames from the + // compositor scheduler, and in turn will update the document lifecycle. + void SetCompositorVisible(bool visible); // Called to update the document lifecycle, advance the state of animations // and dispatch rAF. void BeginMainFrame(base::TimeTicks frame_time); + // Update the visual state of the document, running the document lifecycle. + void UpdateVisualState(); + + // Called when a compositor frame will begin. + void WillBeginCompositorFrame(); + + cc::AnimationHost* AnimationHost() const; + cc::LayerTreeHost* LayerTreeHost() const; + + // Returns if we should gather begin main frame metrics. If there is no + // compositor thread this returns false. + static bool ShouldRecordBeginMainFrameMetrics(); + private: // Not owned, they are owned by the RenderWidget. cc::LayerTreeHost* layer_tree_host_ = nullptr; @@ -51,6 +66,8 @@ WidgetBaseClient* client_; mojo::AssociatedRemote<mojom::blink::WidgetHost> widget_host_; mojo::AssociatedReceiver<mojom::blink::Widget> receiver_; + bool first_update_visual_state_after_hidden_ = false; + base::TimeTicks was_shown_time_ = base::TimeTicks::Now(); }; } // namespace blink
diff --git a/third_party/blink/renderer/platform/widget/widget_base_client.h b/third_party/blink/renderer/platform/widget/widget_base_client.h index ed9fde5a..4d9d803 100644 --- a/third_party/blink/renderer/platform/widget/widget_base_client.h +++ b/third_party/blink/renderer/platform/widget/widget_base_client.h
@@ -6,6 +6,8 @@ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_WIDGET_WIDGET_BASE_CLIENT_H_ #include "base/time/time.h" +#include "third_party/blink/public/common/metrics/document_update_reason.h" +#include "third_party/blink/public/web/web_lifecycle_update.h" namespace blink { @@ -21,6 +23,17 @@ // Called to update the document lifecycle, advance the state of animations // and dispatch rAF. virtual void BeginMainFrame(base::TimeTicks frame_time) = 0; + + // Called to record the time between when the widget was marked visible + // until the compositor begain producing a frame. + virtual void RecordTimeToFirstActivePaint(base::TimeDelta duration) = 0; + + // Requests that the lifecycle of the widget be updated. + virtual void UpdateLifecycle(WebLifecycleUpdate requested_update, + DocumentUpdateReason reason) = 0; + + // TODO(crbug.com/704763): Remove the need for this. + virtual void SetSuppressFrameRequestsWorkaroundFor704763Only(bool) {} }; } // namespace blink
diff --git a/third_party/blink/renderer/platform/wtf/allocator/allocator.cc b/third_party/blink/renderer/platform/wtf/allocator/allocator.cc index 1bbc4cd..11349c5e 100644 --- a/third_party/blink/renderer/platform/wtf/allocator/allocator.cc +++ b/third_party/blink/renderer/platform/wtf/allocator/allocator.cc
@@ -22,6 +22,9 @@ namespace WTF { void AtomicReadMemcpy(void* to, const void* from, size_t bytes) { + // Check alignment of |to| and |from| + DCHECK_EQ(0u, reinterpret_cast<size_t>(to) & (sizeof(size_t) - 1)); + DCHECK_EQ(0u, reinterpret_cast<size_t>(from) & (sizeof(size_t) - 1)); size_t* sizet_to = reinterpret_cast<size_t*>(to); const size_t* sizet_from = reinterpret_cast<const size_t*>(from); for (; bytes > sizeof(size_t); @@ -37,6 +40,9 @@ } void AtomicWriteMemcpy(void* to, const void* from, size_t bytes) { + // Check alignment of |to| and |from| + DCHECK_EQ(0u, reinterpret_cast<size_t>(to) & (sizeof(size_t) - 1)); + DCHECK_EQ(0u, reinterpret_cast<size_t>(from) & (sizeof(size_t) - 1)); size_t* sizet_to = reinterpret_cast<size_t*>(to); const size_t* sizet_from = reinterpret_cast<const size_t*>(from); for (; bytes > sizeof(size_t); @@ -51,4 +57,18 @@ DCHECK_EQ(0u, bytes); } +void AtomicMemzero(void* buf, size_t bytes) { + // Check alignment of |buf| + DCHECK_EQ(0u, reinterpret_cast<size_t>(buf) & (sizeof(size_t) - 1)); + size_t* sizet_buf = reinterpret_cast<size_t*>(buf); + for (; bytes > sizeof(size_t); bytes -= sizeof(size_t), ++sizet_buf) { + AsAtomicPtr(sizet_buf)->store(0, std::memory_order_relaxed); + } + uint8_t* uint8t_buf = reinterpret_cast<uint8_t*>(sizet_buf); + for (; bytes > 0; bytes -= sizeof(uint8_t), ++uint8t_buf) { + AsAtomicPtr(uint8t_buf)->store(0, std::memory_order_relaxed); + } + DCHECK_EQ(0u, bytes); +} + } // namespace WTF
diff --git a/third_party/blink/renderer/platform/wtf/allocator/allocator.h b/third_party/blink/renderer/platform/wtf/allocator/allocator.h index cdc5f3a..66fc994 100644 --- a/third_party/blink/renderer/platform/wtf/allocator/allocator.h +++ b/third_party/blink/renderer/platform/wtf/allocator/allocator.h
@@ -170,8 +170,6 @@ template <size_t bytes> ALWAYS_INLINE void AtomicReadMemcpy(void* to, const void* from) { static_assert(bytes > 0, "Number of copied bytes should be greater than 0"); - DCHECK_EQ(0u, reinterpret_cast<size_t>(from) & (sizeof(size_t) - 1)); - DCHECK_EQ(0u, reinterpret_cast<size_t>(to) & (sizeof(size_t) - 1)); AtomicReadMemcpy(to, from, bytes); } @@ -181,6 +179,8 @@ template <> ALWAYS_INLINE void AtomicReadMemcpy<sizeof(uint32_t)>(void* to, const void* from) { + DCHECK_EQ(0u, reinterpret_cast<size_t>(to) & (sizeof(uint32_t) - 1)); + DCHECK_EQ(0u, reinterpret_cast<size_t>(from) & (sizeof(uint32_t) - 1)); *reinterpret_cast<uint32_t*>(to) = AsAtomicPtr(reinterpret_cast<const uint32_t*>(from)) ->load(std::memory_order_relaxed); @@ -190,6 +190,8 @@ template <> ALWAYS_INLINE void AtomicReadMemcpy<sizeof(size_t)>(void* to, const void* from) { + DCHECK_EQ(0u, reinterpret_cast<size_t>(to) & (sizeof(size_t) - 1)); + DCHECK_EQ(0u, reinterpret_cast<size_t>(from) & (sizeof(size_t) - 1)); *reinterpret_cast<size_t*>(to) = AsAtomicPtr(reinterpret_cast<const size_t*>(from)) ->load(std::memory_order_relaxed); @@ -198,6 +200,8 @@ template <> ALWAYS_INLINE void AtomicReadMemcpy<2 * sizeof(size_t)>(void* to, const void* from) { + DCHECK_EQ(0u, reinterpret_cast<size_t>(to) & (sizeof(size_t) - 1)); + DCHECK_EQ(0u, reinterpret_cast<size_t>(from) & (sizeof(size_t) - 1)); *reinterpret_cast<size_t*>(to) = AsAtomicPtr(reinterpret_cast<const size_t*>(from)) ->load(std::memory_order_relaxed); @@ -209,6 +213,8 @@ template <> ALWAYS_INLINE void AtomicReadMemcpy<3 * sizeof(size_t)>(void* to, const void* from) { + DCHECK_EQ(0u, reinterpret_cast<size_t>(to) & (sizeof(size_t) - 1)); + DCHECK_EQ(0u, reinterpret_cast<size_t>(from) & (sizeof(size_t) - 1)); *reinterpret_cast<size_t*>(to) = AsAtomicPtr(reinterpret_cast<const size_t*>(from)) ->load(std::memory_order_relaxed); @@ -229,8 +235,6 @@ template <size_t bytes> ALWAYS_INLINE void AtomicWriteMemcpy(void* to, const void* from) { static_assert(bytes > 0, "Number of copied bytes should be greater than 0"); - DCHECK_EQ(0u, reinterpret_cast<size_t>(from) & (sizeof(size_t) - 1)); - DCHECK_EQ(0u, reinterpret_cast<size_t>(to) & (sizeof(size_t) - 1)); AtomicWriteMemcpy(to, from, bytes); } @@ -240,6 +244,8 @@ template <> ALWAYS_INLINE void AtomicWriteMemcpy<sizeof(uint32_t)>(void* to, const void* from) { + DCHECK_EQ(0u, reinterpret_cast<size_t>(to) & (sizeof(uint32_t) - 1)); + DCHECK_EQ(0u, reinterpret_cast<size_t>(from) & (sizeof(uint32_t) - 1)); AsAtomicPtr(reinterpret_cast<uint32_t*>(to)) ->store(*reinterpret_cast<const uint32_t*>(from), std::memory_order_relaxed); @@ -249,6 +255,8 @@ template <> ALWAYS_INLINE void AtomicWriteMemcpy<sizeof(size_t)>(void* to, const void* from) { + DCHECK_EQ(0u, reinterpret_cast<size_t>(to) & (sizeof(size_t) - 1)); + DCHECK_EQ(0u, reinterpret_cast<size_t>(from) & (sizeof(size_t) - 1)); AsAtomicPtr(reinterpret_cast<size_t*>(to)) ->store(*reinterpret_cast<const size_t*>(from), std::memory_order_relaxed); @@ -257,6 +265,8 @@ template <> ALWAYS_INLINE void AtomicWriteMemcpy<2 * sizeof(size_t)>(void* to, const void* from) { + DCHECK_EQ(0u, reinterpret_cast<size_t>(to) & (sizeof(size_t) - 1)); + DCHECK_EQ(0u, reinterpret_cast<size_t>(from) & (sizeof(size_t) - 1)); AsAtomicPtr(reinterpret_cast<size_t*>(to)) ->store(*reinterpret_cast<const size_t*>(from), std::memory_order_relaxed); @@ -268,6 +278,8 @@ template <> ALWAYS_INLINE void AtomicWriteMemcpy<3 * sizeof(size_t)>(void* to, const void* from) { + DCHECK_EQ(0u, reinterpret_cast<size_t>(to) & (sizeof(size_t) - 1)); + DCHECK_EQ(0u, reinterpret_cast<size_t>(from) & (sizeof(size_t) - 1)); AsAtomicPtr(reinterpret_cast<size_t*>(to)) ->store(*reinterpret_cast<const size_t*>(from), std::memory_order_relaxed); @@ -279,6 +291,64 @@ std::memory_order_relaxed); } +// Set the first |bytes| bytes of |buf| to 0 using atomic writes. Assumes |buf| +// is size_t-aligned and points to a buffer of size at least |bytes|. Note +// that atomicity is guaranteed only per word, not for the entire |bytes| bytes +// as a whole. +WTF_EXPORT void AtomicMemzero(void* buf, size_t bytes); + +template <size_t bytes> +ALWAYS_INLINE void AtomicMemzero(void* buf) { + static_assert(bytes > 0, "Number of copied bytes should be greater than 0"); + AtomicMemzero(buf, bytes); +} + +// AtomicReadMemcpy specializations: + +#if defined(ARCH_CPU_X86_64) +template <> +ALWAYS_INLINE void AtomicMemzero<sizeof(uint32_t)>(void* buf) { + DCHECK_EQ(0u, reinterpret_cast<size_t>(buf) & (sizeof(uint32_t) - 1)); + AsAtomicPtr(reinterpret_cast<uint32_t*>(buf)) + ->store(0, std::memory_order_relaxed); +} +#endif // ARCH_CPU_X86_64 + +template <> +ALWAYS_INLINE void AtomicMemzero<sizeof(size_t)>(void* buf) { + DCHECK_EQ(0u, reinterpret_cast<size_t>(buf) & (sizeof(size_t) - 1)); + AsAtomicPtr(reinterpret_cast<size_t*>(buf)) + ->store(0, std::memory_order_relaxed); +} + +template <> +ALWAYS_INLINE void AtomicMemzero<2 * sizeof(size_t)>(void* buf) { + DCHECK_EQ(0u, reinterpret_cast<size_t>(buf) & (sizeof(size_t) - 1)); + AsAtomicPtr(reinterpret_cast<size_t*>(buf)) + ->store(0, std::memory_order_relaxed); + AsAtomicPtr(reinterpret_cast<size_t*>(buf) + 1) + ->store(0, std::memory_order_relaxed); +} + +template <> +ALWAYS_INLINE void AtomicMemzero<3 * sizeof(size_t)>(void* buf) { + DCHECK_EQ(0u, reinterpret_cast<size_t>(buf) & (sizeof(size_t) - 1)); + AsAtomicPtr(reinterpret_cast<size_t*>(buf)) + ->store(0, std::memory_order_relaxed); + AsAtomicPtr(reinterpret_cast<size_t*>(buf) + 1) + ->store(0, std::memory_order_relaxed); + AsAtomicPtr(reinterpret_cast<size_t*>(buf) + 2) + ->store(0, std::memory_order_relaxed); +} + +// Swaps values using atomic writes. +template <typename T> +ALWAYS_INLINE void AtomicWriteSwap(T& lhs, T& rhs) { + T tmp_val = rhs; + AsAtomicPtr(&rhs)->store(lhs, std::memory_order_relaxed); + AsAtomicPtr(&lhs)->store(tmp_val, std::memory_order_relaxed); +} + } // namespace WTF // This version of placement new omits a 0 check.
diff --git a/third_party/blink/renderer/platform/wtf/allocator/atomic_operations_test.cc b/third_party/blink/renderer/platform/wtf/allocator/atomic_operations_test.cc index 6637afe..819b3bff 100644 --- a/third_party/blink/renderer/platform/wtf/allocator/atomic_operations_test.cc +++ b/third_party/blink/renderer/platform/wtf/allocator/atomic_operations_test.cc
@@ -92,4 +92,48 @@ TestAtomicWriteMemcpy<127>(); } +// Tests for AtomicMemzero +template <size_t buffer_size> +void TestAtomicMemzero() { + // Allocating extra memory before and after the buffer to make sure the + // AtomicMemzero doesn't exceed the buffer in any direction. + alignas(sizeof(size_t)) unsigned char buf[buffer_size + (2 * sizeof(size_t))]; + memset(buf, ~uint8_t{0}, buffer_size + (2 * sizeof(size_t))); + AtomicMemzero<buffer_size>(buf + sizeof(size_t)); + // Check nothing before the buffer was changed + EXPECT_EQ(~size_t{0}, *reinterpret_cast<size_t*>(&buf[0])); + // Check buffer was copied correctly + static const unsigned char for_comparison[buffer_size] = {0}; + EXPECT_TRUE(!memcmp(buf + sizeof(size_t), for_comparison, buffer_size)); + // Check nothing after the buffer was changed + EXPECT_EQ(~size_t{0}, + *reinterpret_cast<size_t*>(&buf[sizeof(size_t) + buffer_size])); +} + +TEST_F(AtomicOperationsTest, AtomicMemzero_UINT8T) { + TestAtomicMemzero<sizeof(uint8_t)>(); +} +TEST_F(AtomicOperationsTest, AtomicMemzero_UINT16T) { + TestAtomicMemzero<sizeof(uint16_t)>(); +} +TEST_F(AtomicOperationsTest, AtomicMemzero_UINT32T) { + TestAtomicMemzero<sizeof(uint32_t)>(); +} +TEST_F(AtomicOperationsTest, AtomicMemzero_UINT64T) { + TestAtomicMemzero<sizeof(uint64_t)>(); +} + +TEST_F(AtomicOperationsTest, AtomicMemzero_17Bytes) { + TestAtomicMemzero<17>(); +} +TEST_F(AtomicOperationsTest, AtomicMemzero_34Bytes) { + TestAtomicMemzero<34>(); +} +TEST_F(AtomicOperationsTest, AtomicMemzero_68Bytes) { + TestAtomicMemzero<68>(); +} +TEST_F(AtomicOperationsTest, AtomicMemzero_127Bytes) { + TestAtomicMemzero<127>(); +} + } // namespace WTF
diff --git a/third_party/blink/renderer/platform/wtf/hash_table.h b/third_party/blink/renderer/platform/wtf/hash_table.h index 99415588..7999282 100644 --- a/third_party/blink/renderer/platform/wtf/hash_table.h +++ b/third_party/blink/renderer/platform/wtf/hash_table.h
@@ -2012,9 +2012,7 @@ // race). Atomic reads are not needed here because this method is only called // on the mutator thread, which is also the only one that writes to them, so // there is *no* risk of data races when reading. - Value* tmp_table = other.table_; - AsAtomicPtr(&other.table_)->store(table_, std::memory_order_relaxed); - AsAtomicPtr(&table_)->store(tmp_table, std::memory_order_relaxed); + AtomicWriteSwap(table_, other.table_); Allocator::template BackingWriteBarrierForHashTable<HashTable>(&table_); Allocator::template BackingWriteBarrierForHashTable<HashTable>(&other.table_); if (IsWeak<ValueType>::value) {
diff --git a/third_party/blink/renderer/platform/wtf/vector.h b/third_party/blink/renderer/platform/wtf/vector.h index 4953226..1096fe1 100644 --- a/third_party/blink/renderer/platform/wtf/vector.h +++ b/third_party/blink/renderer/platform/wtf/vector.h
@@ -108,7 +108,7 @@ struct VectorUnusedSlotClearer<true, T> { STATIC_ONLY(VectorUnusedSlotClearer); static void Clear(T* begin, T* end) { - memset(reinterpret_cast<void*>(begin), 0, sizeof(T) * (end - begin)); + AtomicMemzero(reinterpret_cast<void*>(begin), sizeof(T) * (end - begin)); } #if DCHECK_IS_ON() @@ -583,7 +583,7 @@ OffsetRange other_hole) { static_assert(VectorTraits<T>::kCanSwapUsingCopyOrMove, "Cannot swap using copy or move."); - std::swap(buffer_, other.buffer_); + AtomicWriteSwap(buffer_, other.buffer_); std::swap(capacity_, other.capacity_); std::swap(size_, other.size_); Allocator::BackingWriteBarrier(&buffer_);
diff --git a/third_party/blink/web_tests/FlagExpectations/composite-after-paint b/third_party/blink/web_tests/FlagExpectations/composite-after-paint index 20591e3..39c2d9a4 100644 --- a/third_party/blink/web_tests/FlagExpectations/composite-after-paint +++ b/third_party/blink/web_tests/FlagExpectations/composite-after-paint
@@ -45,11 +45,6 @@ # Wrong clipping of the right side of nested composited reflection with non-zero filter origin. compositing/reflections/deeply-nested-reflections.html [ Failure ] -# We always paint opacity:0 which breaks LCP's expectation. -crbug.com/957674 cexternal/wpt/largest-contentful-paint/invisible-images.html [ Failure ] -crbug.com/957674 virtual/scalefactor200/external/wpt/largest-contentful-paint/invisible-images.html [ Skip ] -crbug.com/957674 virtual/scalefactor200withoutzoom/external/wpt/largest-contentful-paint/invisible-images.html [ Skip ] - # A fieldset paints its background twice. external/wpt/html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/fieldset-overflow.html [ Crash ]
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index b0f308f..a23e33c9 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations
@@ -2989,6 +2989,12 @@ crbug.com/1053965 external/wpt/css/css-values/ex-unit-004.html [ Failure ] # ====== New tests from wpt-importer added here ====== +crbug.com/626703 [ Linux ] external/wpt/css/css-text/line-break/line-break-strict-015.xht [ Failure ] +crbug.com/626703 [ Mac ] external/wpt/css/css-text/line-break/line-break-strict-015.xht [ Failure ] +crbug.com/626703 [ Win ] external/wpt/css/css-text/line-break/line-break-strict-015.xht [ Failure ] +crbug.com/626703 [ Linux ] external/wpt/css/css-text/line-break/line-break-normal-015.xht [ Failure ] +crbug.com/626703 [ Mac ] external/wpt/css/css-text/line-break/line-break-normal-015.xht [ Failure ] +crbug.com/626703 [ Win ] external/wpt/css/css-text/line-break/line-break-normal-015.xht [ Failure ] crbug.com/626703 [ Linux ] external/wpt/css/cssom/CSSStyleSheet-constructable-disallow-import.tentative.html [ Timeout ] crbug.com/626703 [ Mac ] external/wpt/css/cssom/CSSStyleSheet-constructable-disallow-import.tentative.html [ Timeout ] crbug.com/626703 [ Win ] external/wpt/css/cssom/CSSStyleSheet-constructable-disallow-import.tentative.html [ Timeout ] @@ -6955,6 +6961,9 @@ crbug.com/1011811 http/tests/devtools/changes/changes-sidebar.js [ Pass Failure ] crbug.com/1011811 http/tests/devtools/search/search-in-static.js [ Pass Failure ] +# Temporarily disabled to land https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2101972 +crbug.com/174309 http/tests/devtools/quick-open/command-menu.js [ Pass Failure ] + # Sheriff 2020-03-12 crbug.com/1060175 [ Mac ] css3/calc/simple-calcs-prefixed.html [ Pass Timeout ] crbug.com/1060175 [ Mac ] css3/calc/simple-calcs.html [ Pass Timeout ]
diff --git a/third_party/blink/web_tests/VirtualTestSuites b/third_party/blink/web_tests/VirtualTestSuites index 536cf45..d3cdb68 100644 --- a/third_party/blink/web_tests/VirtualTestSuites +++ b/third_party/blink/web_tests/VirtualTestSuites
@@ -96,7 +96,6 @@ "http/tests/serviceworker/webexposed", "inspector-protocol/dom-snapshot", "media/stable", - "resize-observer", "webexposed"], "args": ["--stable-release-mode"] },
diff --git a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_7.json b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_7.json index 0e97c77..c5fc6f4 100644 --- a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_7.json +++ b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_7.json
@@ -45165,6 +45165,18 @@ {} ] ], + "css/css-flexbox/flex-basis-item-margins-001.html": [ + [ + "css/css-flexbox/flex-basis-item-margins-001.html", + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] + ], "css/css-flexbox/flex-box-wrap.html": [ [ "css/css-flexbox/flex-box-wrap.html", @@ -120601,6 +120613,18 @@ {} ] ], + "html/infrastructure/common-microsyntaxes/colours/parsing-legacy-colour-value-ascii-case-insensitive.html": [ + [ + "html/infrastructure/common-microsyntaxes/colours/parsing-legacy-colour-value-ascii-case-insensitive.html", + [ + [ + "/html/infrastructure/common-microsyntaxes/colours/parsing-legacy-colour-value-ascii-case-insensitive-ref.html", + "==" + ] + ], + {} + ] + ], "html/rendering/bindings/the-button-element/button-type-menu-historical.html": [ [ "html/rendering/bindings/the-button-element/button-type-menu-historical.html", @@ -121165,6 +121189,18 @@ {} ] ], + "html/rendering/non-replaced-elements/tables/table-border-presentational-hints-ascii-case-insensitive.html": [ + [ + "html/rendering/non-replaced-elements/tables/table-border-presentational-hints-ascii-case-insensitive.html", + [ + [ + "/html/rendering/non-replaced-elements/tables/table-border-presentational-hints-ascii-case-insensitive-ref.html", + "==" + ] + ], + {} + ] + ], "html/rendering/non-replaced-elements/tables/table-cell-width-s.html": [ [ "html/rendering/non-replaced-elements/tables/table-cell-width-s.html", @@ -122329,6 +122365,18 @@ {} ] ], + "html/semantics/document-metadata/the-style-element/update-style-block-ascii-case-insensitive.html": [ + [ + "html/semantics/document-metadata/the-style-element/update-style-block-ascii-case-insensitive.html", + [ + [ + "/html/semantics/document-metadata/the-style-element/update-style-block-ascii-case-insensitive-ref.html", + "==" + ] + ], + {} + ] + ], "html/semantics/embedded-content/media-elements/track/track-element/track-cue-rendering-after-controls-added.html": [ [ "html/semantics/embedded-content/media-elements/track/track-element/track-cue-rendering-after-controls-added.html", @@ -123121,6 +123169,18 @@ {} ] ], + "html/semantics/links/linktypes/link-type-stylesheet/process-stylesheet-linked-resource-ascii-case-insensitive.html": [ + [ + "html/semantics/links/linktypes/link-type-stylesheet/process-stylesheet-linked-resource-ascii-case-insensitive.html", + [ + [ + "/html/semantics/links/linktypes/link-type-stylesheet/process-stylesheet-linked-resource-ascii-case-insensitive-ref.html", + "==" + ] + ], + {} + ] + ], "html/semantics/scripting-1/the-template-element/additions-to-the-css-user-agent-style-sheet/css-user-agent-style-sheet-test-001.html": [ [ "html/semantics/scripting-1/the-template-element/additions-to-the-css-user-agent-style-sheet/css-user-agent-style-sheet-test-001.html", @@ -125745,6 +125805,18 @@ {} ] ], + "resize-observer/devicepixel.html": [ + [ + "resize-observer/devicepixel.html", + [ + [ + "/resize-observer/devicepixel-ref.html", + "==" + ] + ], + {} + ] + ], "scroll-animations/animation-with-display-none.html": [ [ "scroll-animations/animation-with-display-none.html", @@ -162226,6 +162298,9 @@ "feature-policy/experimental-features/resources/document-write.html": [ [] ], + "feature-policy/experimental-features/resources/feature-policy-trust-token-redemption.html": [ + [] + ], "feature-policy/experimental-features/resources/focus_steal.html": [ [] ], @@ -168124,6 +168199,9 @@ "html/infrastructure/common-dom-interfaces/collections/htmlallcollection-expected.txt": [ [] ], + "html/infrastructure/common-microsyntaxes/colours/parsing-legacy-colour-value-ascii-case-insensitive-ref.html": [ + [] + ], "html/infrastructure/conformance-requirements/extensibility/OWNERS": [ [] ], @@ -168628,6 +168706,9 @@ "html/rendering/non-replaced-elements/tables/table-border-3-ref.html": [ [] ], + "html/rendering/non-replaced-elements/tables/table-border-presentational-hints-ascii-case-insensitive-ref.html": [ + [] + ], "html/rendering/non-replaced-elements/tables/table-cell-width-ref.html": [ [] ], @@ -168823,6 +168904,9 @@ "html/rendering/replaced-elements/attributes-for-embedded-content-and-images/align-expected.txt": [ [] ], + "html/rendering/replaced-elements/attributes-for-embedded-content-and-images/embedded-and-images-presentational-hints-ascii-case-insensitive-expected.txt": [ + [] + ], "html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-dim-ref.html": [ [] ], @@ -169078,6 +169162,18 @@ "html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/x;url=foo": [ [] ], + "html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-lower.html": [ + [] + ], + "html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-message.js": [ + [] + ], + "html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-mixed.html": [ + [] + ], + "html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-other.html": [ + [] + ], "html/semantics/document-metadata/the-style-element/html_style_in_comment-ref.html": [ [] ], @@ -169087,6 +169183,9 @@ "html/semantics/document-metadata/the-style-element/support/css-red.txt": [ [] ], + "html/semantics/document-metadata/the-style-element/update-style-block-ascii-case-insensitive-ref.html": [ + [] + ], "html/semantics/embedded-content/META.yml": [ [] ], @@ -170095,6 +170194,12 @@ "html/semantics/forms/the-input-element/datetime-local-expected.txt": [ [] ], + "html/semantics/forms/the-input-element/hidden-charset-case-sensitive-child.html": [ + [] + ], + "html/semantics/forms/the-input-element/hidden-charset-case-sensitive-expected.txt": [ + [] + ], "html/semantics/forms/the-input-element/image01-ref.html": [ [] ], @@ -170137,6 +170242,9 @@ "html/semantics/forms/the-textarea-element/textarea-newline-bidi-ref.html": [ [] ], + "html/semantics/forms/the-textarea-element/wrap-enumerated-ascii-case-insensitive-child.html": [ + [] + ], "html/semantics/forms/the-textarea-element/wrap-reflect-1-ref.html": [ [] ], @@ -170281,6 +170389,21 @@ "html/semantics/links/linktypes/alternate.css": [ [] ], + "html/semantics/links/linktypes/link-type-stylesheet/process-stylesheet-linked-resource-ascii-case-insensitive-lower.css": [ + [] + ], + "html/semantics/links/linktypes/link-type-stylesheet/process-stylesheet-linked-resource-ascii-case-insensitive-mixed.css": [ + [] + ], + "html/semantics/links/linktypes/link-type-stylesheet/process-stylesheet-linked-resource-ascii-case-insensitive-other.css": [ + [] + ], + "html/semantics/links/linktypes/link-type-stylesheet/process-stylesheet-linked-resource-ascii-case-insensitive-ref.html": [ + [] + ], + "html/semantics/links/linktypes/link-type-stylesheet/process-stylesheet-linked-resource-ascii-case-insensitive.css": [ + [] + ], "html/semantics/links/linktypes/original-id.json": [ [] ], @@ -171073,6 +171196,9 @@ "html/semantics/selectors/pseudo-classes/dir-expected.txt": [ [] ], + "html/semantics/selectors/pseudo-classes/dir-html-input-dynamic-text-expected.txt": [ + [] + ], "html/semantics/selectors/pseudo-classes/dir01-expected.txt": [ [] ], @@ -176458,6 +176584,9 @@ "resize-observer/OWNERS": [ [] ], + "resize-observer/devicepixel-ref.html": [ + [] + ], "resize-observer/idlharness.window-expected.txt": [ [] ], @@ -184474,6 +184603,24 @@ "upgrade-insecure-requests/gen/iframe-blank-inherit.meta/upgrade/worker-module.https-expected.txt": [ [] ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/fetch.https.html.headers": [ + [] + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/websocket.https.html.headers": [ + [] + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/xhr.https.html.headers": [ + [] + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/fetch.https.html.headers": [ + [] + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/websocket.https.html.headers": [ + [] + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/xhr.https.html.headers": [ + [] + ], "upgrade-insecure-requests/gen/srcdoc-inherit.meta/upgrade/sharedworker-classic.https-expected.txt": [ [] ], @@ -184594,6 +184741,15 @@ "upgrade-insecure-requests/gen/worker-classic-inherit.meta/upgrade/worker-module.https-expected.txt": [ [] ], + "upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/fetch.https.html.headers": [ + [] + ], + "upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/websocket.https.html.headers": [ + [] + ], + "upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/xhr.https.html.headers": [ + [] + ], "upgrade-insecure-requests/gen/worker-module-inherit.http-rp/upgrade/fetch.https.html.headers": [ [] ], @@ -213783,7 +213939,9 @@ "cookies/http-state/attribute-tests.html": [ [ "cookies/http-state/attribute-tests.html", - {} + { + "timeout": "long" + } ] ], "cookies/http-state/charset-tests.html": [ @@ -250371,6 +250529,18 @@ {} ] ], + "feature-policy/experimental-features/trust-token-redemption-default-feature-policy.tentative.https.sub.html": [ + [ + "feature-policy/experimental-features/trust-token-redemption-default-feature-policy.tentative.https.sub.html", + {} + ] + ], + "feature-policy/experimental-features/trust-token-redemption-supported-by-feature-policy.tentative.html": [ + [ + "feature-policy/experimental-features/trust-token-redemption-supported-by-feature-policy.tentative.html", + {} + ] + ], "feature-policy/experimental-features/vertical-scroll-scrollintoview.tentative.html": [ [ "feature-policy/experimental-features/vertical-scroll-scrollintoview.tentative.html", @@ -254403,6 +254573,14 @@ {} ] ], + "generic-sensor/generic-sensor-permission.https.html": [ + [ + "generic-sensor/generic-sensor-permission.https.html", + { + "testdriver": true + } + ] + ], "generic-sensor/idlharness.https.window.js": [ [ "generic-sensor/idlharness.https.window.html", @@ -258002,6 +258180,12 @@ {} ] ], + "html/dom/elements/global-attributes/translate-enumerated-ascii-case-insensitive.html": [ + [ + "html/dom/elements/global-attributes/translate-enumerated-ascii-case-insensitive.html", + {} + ] + ], "html/dom/elements/name-content-attribute-and-property.html": [ [ "html/dom/elements/name-content-attribute-and-property.html", @@ -258206,6 +258390,12 @@ {} ] ], + "html/editing/dnd/the-draggable-attribute/draggable-enumerated-ascii-case-insensitive.html": [ + [ + "html/editing/dnd/the-draggable-attribute/draggable-enumerated-ascii-case-insensitive.html", + {} + ] + ], "html/editing/dnd/the-draggable-attribute/draggable_attribute.html": [ [ "html/editing/dnd/the-draggable-attribute/draggable_attribute.html", @@ -258236,6 +258426,12 @@ {} ] ], + "html/editing/editing-0/contenteditable/contenteditable-enumerated-ascii-case-insensitive.html": [ + [ + "html/editing/editing-0/contenteditable/contenteditable-enumerated-ascii-case-insensitive.html", + {} + ] + ], "html/editing/editing-0/contenteditable/selection-in-contentEditable-at-turning-designMode-on-off.tentative.html": [ [ "html/editing/editing-0/contenteditable/selection-in-contentEditable-at-turning-designMode-on-off.tentative.html", @@ -258266,6 +258462,12 @@ {} ] ], + "html/editing/editing-0/spelling-and-grammar-checking/spellcheck-enumerated-ascii-case-insensitive.html": [ + [ + "html/editing/editing-0/spelling-and-grammar-checking/spellcheck-enumerated-ascii-case-insensitive.html", + {} + ] + ], "html/editing/editing-0/spelling-and-grammar-checking/user-interaction-editing-spellcheck.html": [ [ "html/editing/editing-0/spelling-and-grammar-checking/user-interaction-editing-spellcheck.html", @@ -258314,6 +258516,12 @@ {} ] ], + "html/infrastructure/fetching-resources/crossorigin-enumerated-ascii-case-insensitive.html": [ + [ + "html/infrastructure/fetching-resources/crossorigin-enumerated-ascii-case-insensitive.html", + {} + ] + ], "html/infrastructure/safe-passing-of-structured-data/messagechannel.any.js": [ [ "html/infrastructure/safe-passing-of-structured-data/messagechannel.any.html", @@ -259570,6 +259778,12 @@ {} ] ], + "html/rendering/non-replaced-elements/lists/lists-presentational-hints-ascii-case-insensitive.html": [ + [ + "html/rendering/non-replaced-elements/lists/lists-presentational-hints-ascii-case-insensitive.html", + {} + ] + ], "html/rendering/non-replaced-elements/margin-collapsing-quirks/multicol-quirks-mode.html": [ [ "html/rendering/non-replaced-elements/margin-collapsing-quirks/multicol-quirks-mode.html", @@ -259624,6 +259838,12 @@ {} ] ], + "html/rendering/non-replaced-elements/tables/table-valign-baseline-ascii-case-insensitive.html": [ + [ + "html/rendering/non-replaced-elements/tables/table-valign-baseline-ascii-case-insensitive.html", + {} + ] + ], "html/rendering/non-replaced-elements/tables/table-vspace-hspace-s.html": [ [ "html/rendering/non-replaced-elements/tables/table-vspace-hspace-s.html", @@ -259830,6 +260050,12 @@ {} ] ], + "html/rendering/replaced-elements/attributes-for-embedded-content-and-images/embedded-and-images-presentational-hints-ascii-case-insensitive.html": [ + [ + "html/rendering/replaced-elements/attributes-for-embedded-content-and-images/embedded-and-images-presentational-hints-ascii-case-insensitive.html", + {} + ] + ], "html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-alt-crash-001.html": [ [ "html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-alt-crash-001.html", @@ -260248,6 +260474,12 @@ {} ] ], + "html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive.html": [ + [ + "html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive.html", + {} + ] + ], "html/semantics/document-metadata/the-meta-element/the-lang-attribute-012.html": [ [ "html/semantics/document-metadata/the-meta-element/the-lang-attribute-012.html", @@ -264062,6 +264294,12 @@ {} ] ], + "html/semantics/forms/the-button-element/button-type-enumerated-ascii-case-insensitive.html": [ + [ + "html/semantics/forms/the-button-element/button-type-enumerated-ascii-case-insensitive.html", + {} + ] + ], "html/semantics/forms/the-button-element/button-type.html": [ [ "html/semantics/forms/the-button-element/button-type.html", @@ -264320,6 +264558,12 @@ {} ] ], + "html/semantics/forms/the-input-element/hidden-charset-case-sensitive.html": [ + [ + "html/semantics/forms/the-input-element/hidden-charset-case-sensitive.html", + {} + ] + ], "html/semantics/forms/the-input-element/hidden.html": [ [ "html/semantics/forms/the-input-element/hidden.html", @@ -264892,6 +265136,12 @@ {} ] ], + "html/semantics/forms/the-textarea-element/wrap-enumerated-ascii-case-insensitive.html": [ + [ + "html/semantics/forms/the-textarea-element/wrap-enumerated-ascii-case-insensitive.html", + {} + ] + ], "html/semantics/grouping-content/the-dd-element/grouping-dd.html": [ [ "html/semantics/grouping-content/the-dd-element/grouping-dd.html", @@ -267034,9 +267284,9 @@ {} ] ], - "html/semantics/scripting-1/the-script-element/script-crossorigin-network.html": [ + "html/semantics/scripting-1/the-script-element/script-crossorigin-network.sub.html": [ [ - "html/semantics/scripting-1/the-script-element/script-crossorigin-network.html", + "html/semantics/scripting-1/the-script-element/script-crossorigin-network.sub.html", {} ] ], @@ -267288,6 +267538,12 @@ {} ] ], + "html/semantics/selectors/pseudo-classes/dir-html-input-dynamic-text.html": [ + [ + "html/semantics/selectors/pseudo-classes/dir-html-input-dynamic-text.html", + {} + ] + ], "html/semantics/selectors/pseudo-classes/dir.html": [ [ "html/semantics/selectors/pseudo-classes/dir.html", @@ -272327,6 +272583,12 @@ {} ] ], + "largest-contentful-paint/invisible-images-composited.html": [ + [ + "largest-contentful-paint/invisible-images-composited.html", + {} + ] + ], "largest-contentful-paint/invisible-images.html": [ [ "largest-contentful-paint/invisible-images.html", @@ -311745,6 +312007,78 @@ } ] ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/fetch.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/fetch.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/websocket.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/websocket.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/xhr.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/xhr.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/fetch.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/fetch.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/websocket.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/websocket.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/xhr.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/xhr.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/fetch.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/fetch.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/websocket.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/websocket.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/xhr.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/xhr.https.html", + { + "timeout": "long" + } + ] + ], "upgrade-insecure-requests/gen/sharedworker-classic.http-rp/upgrade/fetch.https.html": [ [ "upgrade-insecure-requests/gen/sharedworker-classic.http-rp/upgrade/fetch.https.html", @@ -311769,6 +312103,78 @@ } ] ], + "upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/fetch.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/fetch.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/websocket.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/websocket.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/xhr.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/xhr.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/fetch.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/fetch.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/websocket.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/websocket.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/xhr.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/xhr.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/fetch.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/fetch.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/websocket.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/websocket.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/xhr.https.html": [ + [ + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/xhr.https.html", + { + "timeout": "long" + } + ] + ], "upgrade-insecure-requests/gen/sharedworker-module.http-rp/upgrade/fetch.https.html": [ [ "upgrade-insecure-requests/gen/sharedworker-module.http-rp/upgrade/fetch.https.html", @@ -312721,6 +313127,78 @@ } ] ], + "upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/fetch.https.html": [ + [ + "upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/fetch.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/websocket.https.html": [ + [ + "upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/websocket.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/xhr.https.html": [ + [ + "upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/xhr.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/worker-module-data.meta/unset/fetch.https.html": [ + [ + "upgrade-insecure-requests/gen/worker-module-data.meta/unset/fetch.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/worker-module-data.meta/unset/websocket.https.html": [ + [ + "upgrade-insecure-requests/gen/worker-module-data.meta/unset/websocket.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/worker-module-data.meta/unset/xhr.https.html": [ + [ + "upgrade-insecure-requests/gen/worker-module-data.meta/unset/xhr.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/fetch.https.html": [ + [ + "upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/fetch.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/websocket.https.html": [ + [ + "upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/websocket.https.html", + { + "timeout": "long" + } + ] + ], + "upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/xhr.https.html": [ + [ + "upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/xhr.https.html", + { + "timeout": "long" + } + ] + ], "upgrade-insecure-requests/gen/worker-module-inherit.http-rp/upgrade/fetch.https.html": [ [ "upgrade-insecure-requests/gen/worker-module-inherit.http-rp/upgrade/fetch.https.html", @@ -348611,7 +349089,7 @@ "support" ], "common/security-features/tools/generate.py": [ - "205259854a537de81acf8c6b8b6871f7d5675e5a", + "75b7c1da5ac19288d25e2664b764b5cc631506d8", "support" ], "common/security-features/tools/spec.src.json": [ @@ -352267,7 +352745,7 @@ "support" ], "cookies/http-state/attribute-tests.html": [ - "8cb820564f455ea545ce0124bb477a211141bc5d", + "d008f3cfa0dd3d785c3609bc94cd1b61d6fd67ca", "testharness" ], "cookies/http-state/charset-tests.html": [ @@ -375759,7 +376237,7 @@ "testharness" ], "css/css-color/parsing/color-valid.html": [ - "62df82623a4e958da46dbe91b1cd64e95a57c5af", + "48e97561f40c370acd88bf41220b5482eedf245e", "testharness" ], "css/css-color/parsing/opacity-computed.html": [ @@ -378922,6 +379400,10 @@ "79992974b054b553b9052cba32a16fd89c37a866", "reftest" ], + "css/css-flexbox/flex-basis-item-margins-001.html": [ + "5f65b267bb5bf1b8de1a742aef0a8fc0865bd902", + "reftest" + ], "css/css-flexbox/flex-box-wrap.html": [ "2a1ab9c00cda7b78026eb04e31894bda43392a5d", "reftest" @@ -410959,7 +411441,7 @@ "reftest" ], "css/css-text/line-break/line-break-normal-015.xht": [ - "6debeedc35a72115f1abaf48034eabf3edf213ca", + "3d2f239bbdbce1cb8fe181d753a880c54fafadca", "reftest" ], "css/css-text/line-break/line-break-normal-016a.xht": [ @@ -411015,7 +411497,7 @@ "reftest" ], "css/css-text/line-break/line-break-strict-015.xht": [ - "ec3d6520f6b5b6c64e2cfb61fb92284894a7dad9", + "ea8caab699fbe16fcdab530809a44867cd7299d3", "reftest" ], "css/css-text/line-break/line-break-strict-016a.xht": [ @@ -411131,7 +411613,7 @@ "support" ], "css/css-text/line-break/reference/line-break-normal-015-ref.xht": [ - "886c4a30a03e392524a0a23a4c8c64b9064927ae", + "b4697babbc212753389385a1376f04331af44817", "support" ], "css/css-text/line-break/reference/line-break-normal-016a-ref.xht": [ @@ -411183,7 +411665,7 @@ "support" ], "css/css-text/line-break/reference/line-break-strict-015-ref.xht": [ - "320870299d2adb5458283e6bdcb77c2625b55616", + "8eceb2ae9dc30e4a757675ae952829ba8e932ecd", "support" ], "css/css-text/line-break/reference/line-break-strict-016a-ref.xht": [ @@ -451022,6 +451504,10 @@ "633fa85e6acd6c5dd9cfcd1dfd9929abf15214f8", "support" ], + "feature-policy/experimental-features/resources/feature-policy-trust-token-redemption.html": [ + "2449df3abe2cb54e830976df127d6345692a9e83", + "support" + ], "feature-policy/experimental-features/resources/focus_steal.html": [ "43e8688117d7ae01169793edb9392a03350749e5", "support" @@ -451078,6 +451564,14 @@ "b468c8b1822d57cbf8c78523397a43813cefe51c", "support" ], + "feature-policy/experimental-features/trust-token-redemption-default-feature-policy.tentative.https.sub.html": [ + "efbb75aa4761b76ca5978cd33b9cf208eea4432f", + "testharness" + ], + "feature-policy/experimental-features/trust-token-redemption-supported-by-feature-policy.tentative.html": [ + "e349eadc5d1f79b4423052bee9b1903ae6c5e437", + "testharness" + ], "feature-policy/experimental-features/vertical-scroll-disabled-frame-no-scroll-manual.tentative.html": [ "6f827c919a43042ff4f1e481f676423239d4c336", "manual" @@ -454818,6 +455312,10 @@ "c4195fee5f5ed10c4c30f1556e8ad8284f106a8d", "support" ], + "generic-sensor/generic-sensor-permission.https.html": [ + "a86ed5dae215793c2f231151faabeed794271ef4", + "testharness" + ], "generic-sensor/generic-sensor-tests.js": [ "1843734a3bb0adf4d9e853af4ba74ae39aa33f41", "support" @@ -454827,7 +455325,7 @@ "testharness" ], "generic-sensor/resources/generic-sensor-helpers.js": [ - "afc2fadec9d8da2771424e72f17e38f5b633adad", + "ad11e58c7175a6add05c39cbab6123ad822b9515", "support" ], "generic-sensor/resources/iframe_sensor_handler.html": [ @@ -459670,6 +460168,10 @@ "d781172bbadcc51c4b203200f1a0adfe50ae4246", "manual" ], + "html/dom/elements/global-attributes/translate-enumerated-ascii-case-insensitive.html": [ + "dedf559b98f84861ff087976a2303302ed874846", + "testharness" + ], "html/dom/elements/name-content-attribute-and-property.html": [ "bcfbd29c33c1e8e68c6f712ad7e2f3ded8cc6686", "testharness" @@ -459935,7 +460437,7 @@ "testharness" ], "html/dom/reflection-forms-expected.txt": [ - "97c98daf132757ef860173f35d4898b0dfd0d064", + "b79da4cbd96a9476b9fc0889b43d8ff9c2facccf", "support" ], "html/dom/reflection-forms.html": [ @@ -463426,6 +463928,10 @@ "c328f0031b8e04cb7494e3e97516eb92787eb68c", "manual" ], + "html/editing/dnd/the-draggable-attribute/draggable-enumerated-ascii-case-insensitive.html": [ + "8c33a6c25b26b3aab45502e664af4b2f2a4fe3ef", + "testharness" + ], "html/editing/dnd/the-draggable-attribute/draggable_attribute.html": [ "cd9073e1055d9286299e2df1d2db7c60c309796b", "testharness" @@ -463454,6 +463960,10 @@ "42da515920e6eacf35bc2ac9ffd43765b667a362", "testharness" ], + "html/editing/editing-0/contenteditable/contenteditable-enumerated-ascii-case-insensitive.html": [ + "209686680e91472bf064f7b37972c54f47bc8a15", + "testharness" + ], "html/editing/editing-0/contenteditable/selection-in-contentEditable-at-turning-designMode-on-off.tentative.html": [ "9502196b8459fc53eb5086e0f3d0d6613024fc01", "testharness" @@ -463494,6 +464004,10 @@ "68dcc54702cef01ee8490f6ba7c49e5ff1995848", "support" ], + "html/editing/editing-0/spelling-and-grammar-checking/spellcheck-enumerated-ascii-case-insensitive.html": [ + "9f00f1dff12661685c50146caa39b94c547feac0", + "testharness" + ], "html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-001.html": [ "7dd891374bcdd40c7b88f9a2b693945d62077054", "reftest" @@ -463638,6 +464152,14 @@ "fc70d7172c377111dd17febceae89313925aab87", "testharness" ], + "html/infrastructure/common-microsyntaxes/colours/parsing-legacy-colour-value-ascii-case-insensitive-ref.html": [ + "6565e0e7504b32ba7132eb064efaf9c230b4942a", + "support" + ], + "html/infrastructure/common-microsyntaxes/colours/parsing-legacy-colour-value-ascii-case-insensitive.html": [ + "eee4a9c7c8141667d65ebdb6960f1ead860ef35d", + "reftest" + ], "html/infrastructure/conformance-requirements/extensibility/OWNERS": [ "422c227ea95706b5eaa67c8784b0ce8ac4fca8e1", "support" @@ -463646,6 +464168,10 @@ "eaa133badee16d1dade6de02e4cf646515289eb5", "testharness" ], + "html/infrastructure/fetching-resources/crossorigin-enumerated-ascii-case-insensitive.html": [ + "7207d43c6097dd9dd19e126a5ad5abdb17ad33c0", + "testharness" + ], "html/infrastructure/safe-passing-of-structured-data/messagechannel.any.js": [ "1814df30328d3192dc62ef6efb1e92470704d98c", "testharness" @@ -464738,6 +465264,10 @@ "bd8dafc9c252522966a7dcd091dd436243aabb26", "reftest" ], + "html/rendering/non-replaced-elements/lists/lists-presentational-hints-ascii-case-insensitive.html": [ + "396055f73b40950d18dc28808b7b3d44a9049ba9", + "testharness" + ], "html/rendering/non-replaced-elements/lists/ol-type-supported-ref.html": [ "fb61db3261cd5bc75a6a23382cad371fab31f8ae", "support" @@ -464950,6 +465480,14 @@ "c4c019c8eb308d382b960f8ad7a44fd4d00c03bb", "reftest" ], + "html/rendering/non-replaced-elements/tables/table-border-presentational-hints-ascii-case-insensitive-ref.html": [ + "c8d6a20726fd84900f192b34206954eeec57f61d", + "support" + ], + "html/rendering/non-replaced-elements/tables/table-border-presentational-hints-ascii-case-insensitive.html": [ + "45c9da925dd56cf94aed363bb60daae637ffe438", + "reftest" + ], "html/rendering/non-replaced-elements/tables/table-cell-width-ref.html": [ "b5ba0443f3cfacef82352ee792bc4963c582099d", "support" @@ -465014,6 +465552,10 @@ "dc3e45f5a468568825487f0f2874d6ba5ce2a41f", "testharness" ], + "html/rendering/non-replaced-elements/tables/table-valign-baseline-ascii-case-insensitive.html": [ + "f64bb9aa08952b391d612fa9ba23c9b2a4d45eb5", + "testharness" + ], "html/rendering/non-replaced-elements/tables/table-vspace-hspace-s.html": [ "9f462b5768621858ce152b96c835f8c737b3be02", "testharness" @@ -465598,6 +466140,14 @@ "42be8ce7a81b824f0e62553490ae406b6b736f9f", "testharness" ], + "html/rendering/replaced-elements/attributes-for-embedded-content-and-images/embedded-and-images-presentational-hints-ascii-case-insensitive-expected.txt": [ + "d975347f9d295e121e3fabadf85329fdefb55ae4", + "support" + ], + "html/rendering/replaced-elements/attributes-for-embedded-content-and-images/embedded-and-images-presentational-hints-ascii-case-insensitive.html": [ + "8fafb0c7f0fb5c1f0651d6e8c06b7dcc1fd7de3f", + "testharness" + ], "html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-alt-crash-001.html": [ "b057967e7e967b1b3113c69f71f1298b86ce4df8", "testharness" @@ -466298,6 +466848,26 @@ "f10371aa7b8ccabca8479196d6cd640676fd4a04", "support" ], + "html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-lower.html": [ + "026e61c2ca3f8a7d1b14904de53aac901ccbd52e", + "support" + ], + "html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-message.js": [ + "1dc218a0a591564cc56ef2fb9ff1ee885a2e9c7a", + "support" + ], + "html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-mixed.html": [ + "b4c547d342b5a700d701f0d7dd96fc3b94fa58ac", + "support" + ], + "html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-other.html": [ + "5c89a5e8bca050ee84935c05bb161a1af2478ae2", + "support" + ], + "html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive.html": [ + "6d19be4149c8c6c2eddd0d50c467718fb10279d1", + "testharness" + ], "html/semantics/document-metadata/the-meta-element/the-lang-attribute-012.html": [ "af872d6e3a263308d69cb995ea42e449b41f850c", "testharness" @@ -466366,6 +466936,14 @@ "9ef04cbd12daf19dd8810cae8844bd22f3264926", "support" ], + "html/semantics/document-metadata/the-style-element/update-style-block-ascii-case-insensitive-ref.html": [ + "5ac2432547ea7b4caa6e28a563ce3e80832a09c9", + "support" + ], + "html/semantics/document-metadata/the-style-element/update-style-block-ascii-case-insensitive.html": [ + "3c5cd152d6273c2491aae1249bace7ad8b79118c", + "reftest" + ], "html/semantics/document-metadata/the-title-element/title.text-01.html": [ "7f25400ea89ca7835b72fdb1eb21fcb220f2cd01", "testharness" @@ -470358,6 +470936,10 @@ "1dc259564cadadb99105a329b62dc12eea6bd878", "testharness" ], + "html/semantics/forms/the-button-element/button-type-enumerated-ascii-case-insensitive.html": [ + "30a2c24a80bab390c3401ee70c8bdc985cd8a21d", + "testharness" + ], "html/semantics/forms/the-button-element/button-type.html": [ "6cfd6687c707479600534de03156afa698daa314", "testharness" @@ -470674,6 +471256,18 @@ "a4157a3d6baaa021bc7a403baa5842e5711db43a", "testharness" ], + "html/semantics/forms/the-input-element/hidden-charset-case-sensitive-child.html": [ + "92c9981a1123454af8462cea7840a099721109a0", + "support" + ], + "html/semantics/forms/the-input-element/hidden-charset-case-sensitive-expected.txt": [ + "8b2c792e1a95e93bf6ebaf4b926b0257836bbce7", + "support" + ], + "html/semantics/forms/the-input-element/hidden-charset-case-sensitive.html": [ + "a6df6bcb6d7861e68426f5f0c78c9975f5d8a99c", + "testharness" + ], "html/semantics/forms/the-input-element/hidden.html": [ "9274b5cddb33227ce1ddb895470524b3a8e747c1", "testharness" @@ -471174,6 +471768,14 @@ "a1a405fdbe756ae45a25d633c7d50a128290f965", "testharness" ], + "html/semantics/forms/the-textarea-element/wrap-enumerated-ascii-case-insensitive-child.html": [ + "92c9981a1123454af8462cea7840a099721109a0", + "support" + ], + "html/semantics/forms/the-textarea-element/wrap-enumerated-ascii-case-insensitive.html": [ + "9bb16bb681c16ec5b0ea11350d7167f987bbc89e", + "testharness" + ], "html/semantics/forms/the-textarea-element/wrap-reflect-1-ref.html": [ "98a7f8a3af6999f798d47b280b10247bd5f01b2f", "support" @@ -471766,6 +472368,30 @@ "b101ab91f01281c0919dffe8165f51274890719e", "support" ], + "html/semantics/links/linktypes/link-type-stylesheet/process-stylesheet-linked-resource-ascii-case-insensitive-lower.css": [ + "a19c9dfd72dd1f863bb84f5c430ad8ac6c79ee7f", + "support" + ], + "html/semantics/links/linktypes/link-type-stylesheet/process-stylesheet-linked-resource-ascii-case-insensitive-mixed.css": [ + "7389ea1a1a362bbc1341c87cdc845b54c73b6378", + "support" + ], + "html/semantics/links/linktypes/link-type-stylesheet/process-stylesheet-linked-resource-ascii-case-insensitive-other.css": [ + "a6c2616d868186046a6dcefe8c8f84076cb35df6", + "support" + ], + "html/semantics/links/linktypes/link-type-stylesheet/process-stylesheet-linked-resource-ascii-case-insensitive-ref.html": [ + "5ac2432547ea7b4caa6e28a563ce3e80832a09c9", + "support" + ], + "html/semantics/links/linktypes/link-type-stylesheet/process-stylesheet-linked-resource-ascii-case-insensitive.css": [ + "5d647d0f2ea84d9702d6f418120590d8fce51a12", + "support" + ], + "html/semantics/links/linktypes/link-type-stylesheet/process-stylesheet-linked-resource-ascii-case-insensitive.html": [ + "39fd5520d213367272ef820e08618458eec97e06", + "reftest" + ], "html/semantics/links/linktypes/original-id.json": [ "1e5f7b5ed36035ed92670cc161750cfbe28976f1", "support" @@ -473751,7 +474377,7 @@ "support" ], "html/semantics/scripting-1/the-script-element/resources/cross-origin.py": [ - "f8e05d9662734bccd176d95a0121d119141e12e9", + "c319119ffd3ef43cdebccfd2f71ea3f0c1b5a61b", "support" ], "html/semantics/scripting-1/the-script-element/resources/exports-cocoa.js": [ @@ -473798,8 +474424,8 @@ "4ff4cc6b0bae715005ec31a42709fe2b8dc690b3", "testharness" ], - "html/semantics/scripting-1/the-script-element/script-crossorigin-network.html": [ - "488dd4488a4d55853ca82c4cd8dcf29178289250", + "html/semantics/scripting-1/the-script-element/script-crossorigin-network.sub.html": [ + "5886ab6f32c85af027872947d3b4682228e75dc1", "testharness" ], "html/semantics/scripting-1/the-script-element/script-crossorigin.html": [ @@ -474142,6 +474768,14 @@ "8d4f29793fd8ae7579e70dbb941c6b754e003b6b", "support" ], + "html/semantics/selectors/pseudo-classes/dir-html-input-dynamic-text-expected.txt": [ + "d26b681aec70675ecaf32b09d874c73487b81aa2", + "support" + ], + "html/semantics/selectors/pseudo-classes/dir-html-input-dynamic-text.html": [ + "0c50cec369ba87122aed0982c26a50605fba910b", + "testharness" + ], "html/semantics/selectors/pseudo-classes/dir.html": [ "8edd9b8ab2b19569e4ea20f66cc9d7b1b32f0c27", "testharness" @@ -479342,6 +479976,10 @@ "cbe46f402b4e344571932fc501d4d3410eadc125", "testharness" ], + "largest-contentful-paint/invisible-images-composited.html": [ + "f652180d4641d00beeb52fea67b13bf50f69e061", + "testharness" + ], "largest-contentful-paint/invisible-images.html": [ "49324663f22688c36dbf0ae1f131bda5339151f1", "testharness" @@ -499610,6 +500248,14 @@ "e8dd0b916eb51dd80442bd7de90d46183df6cc21", "support" ], + "resize-observer/devicepixel-ref.html": [ + "a006732015be3bbf07c79ecd11d8a50c4ebbda3f", + "support" + ], + "resize-observer/devicepixel.html": [ + "6ecb8246d14dcfb4de9895f9920b4e30832214b6", + "reftest" + ], "resize-observer/eventloop.html": [ "3a9e453faf2eaef798daaa1171a426ea281009f5", "testharness" @@ -499627,7 +500273,7 @@ "testharness" ], "resize-observer/observe.html": [ - "1ab5f786877cb6aa6ae85dd566db0f4e38f1c330", + "58f200463df1ff9def0eb8337dd067068f470a1e", "testharness" ], "resize-observer/resources/iframe.html": [ @@ -499639,11 +500285,11 @@ "support" ], "resize-observer/resources/resizeTestHelper.js": [ - "738fb6563c6fbcd13d457515ec2361dda97f5735", + "032eb4b3a04d10c0de48cc74c27e57a6d106169d", "support" ], "resize-observer/svg.html": [ - "648a4995702f951d06cc5604dca7a463a6fc3b88", + "fe8d4282a905ce9451d58e7dfeee90d7bec4066d", "testharness" ], "resource-timing/META.yml": [ @@ -500295,7 +500941,7 @@ "support" ], "resources/chromium/generic_sensor_mocks.js": [ - "ac6043d7a7fad384e904800d4b10cf54b25eeb09", + "8f134202ff8bd91e47608214e029fb497e7207c4", "support" ], "resources/chromium/generic_sensor_mocks.js.headers": [ @@ -516150,6 +516796,54 @@ "7d0ff6e1a372e03e92ad156485ae13f87ca81a2a", "testharness" ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/fetch.https.html": [ + "b65bb8451f0f184a431620ba90fc4c5a117b0eb9", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/fetch.https.html.headers": [ + "602d9dc38d0a5975e8d40c26daae9329de69840c", + "support" + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/websocket.https.html": [ + "f1933b620e9b60b4dbf54589eef8c164ccff4d4d", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/websocket.https.html.headers": [ + "602d9dc38d0a5975e8d40c26daae9329de69840c", + "support" + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/xhr.https.html": [ + "026d771dd7f2eed34eacb4e743591f9ecfb6903f", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/xhr.https.html.headers": [ + "602d9dc38d0a5975e8d40c26daae9329de69840c", + "support" + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/fetch.https.html": [ + "95c36dab7034119665014c2d1404d254857dc17a", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/websocket.https.html": [ + "116967e02074081ddbe0ee5176d9b745b43e4d23", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/xhr.https.html": [ + "89ab0fe4ef9f8fa5151daa253f943652bccbf5a1", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/fetch.https.html": [ + "eea46ce9648d52c3cbf64c2e9d44a041a34bfd19", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/websocket.https.html": [ + "4347f0118885cf42eaeb2e7afc5199b3f732a568", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/xhr.https.html": [ + "c0447cf3c021d6a7b5b439ed1d1b800d568e2385", + "testharness" + ], "upgrade-insecure-requests/gen/sharedworker-classic.http-rp/upgrade/fetch.https.html": [ "eef8276f29ec861d8b4671fb272df243242a53d9", "testharness" @@ -516162,6 +516856,54 @@ "6fc52891e287e2c0bd30ee0b92d548ce53964b34", "testharness" ], + "upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/fetch.https.html": [ + "ea2320e6ce728ef5dfb3a12cf82de59decc9ff12", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/fetch.https.html.headers": [ + "602d9dc38d0a5975e8d40c26daae9329de69840c", + "support" + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/websocket.https.html": [ + "124a03c37f4cc249708cf4f58bd7efc77c9257af", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/websocket.https.html.headers": [ + "602d9dc38d0a5975e8d40c26daae9329de69840c", + "support" + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/xhr.https.html": [ + "b04b07adb5740fff3b9c22ae22c444189d753a92", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/xhr.https.html.headers": [ + "602d9dc38d0a5975e8d40c26daae9329de69840c", + "support" + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/fetch.https.html": [ + "d6b8cdf41712c1c9edc4b5ba5c5e2b5eb62bdda7", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/websocket.https.html": [ + "a4798e53a062c221e0d21b988a4a304377c52d80", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/xhr.https.html": [ + "681c1cee442f6fa825727cbfd03fd0c1be837730", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/fetch.https.html": [ + "b355fd0c14c2765bec501b73fd2258d2773460bd", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/websocket.https.html": [ + "36bac646a02d69de9da34768698458ba335846f9", + "testharness" + ], + "upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/xhr.https.html": [ + "befbb210fc88f7cb9cd041e4b8fe8ab82114f7aa", + "testharness" + ], "upgrade-insecure-requests/gen/sharedworker-module.http-rp/upgrade/fetch.https.html": [ "4dcb71be9dc18427f79658b25dfd5c630e191fce", "testharness" @@ -516798,6 +517540,54 @@ "5140fc4800ac9245009a2cafc4e3e3d1a5eaf273", "testharness" ], + "upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/fetch.https.html": [ + "a3fa13ecfd9cd997db80d523a481f7e586cf760b", + "testharness" + ], + "upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/fetch.https.html.headers": [ + "602d9dc38d0a5975e8d40c26daae9329de69840c", + "support" + ], + "upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/websocket.https.html": [ + "53dc448d6c497c673505ab8c44bac3efb3a50167", + "testharness" + ], + "upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/websocket.https.html.headers": [ + "602d9dc38d0a5975e8d40c26daae9329de69840c", + "support" + ], + "upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/xhr.https.html": [ + "1125fa454346c5897dba66c4b3dd6a72f5a9dd60", + "testharness" + ], + "upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/xhr.https.html.headers": [ + "602d9dc38d0a5975e8d40c26daae9329de69840c", + "support" + ], + "upgrade-insecure-requests/gen/worker-module-data.meta/unset/fetch.https.html": [ + "a3cd2146663d34f350d169a7de36c7c664639234", + "testharness" + ], + "upgrade-insecure-requests/gen/worker-module-data.meta/unset/websocket.https.html": [ + "27e0c78bb8e20de711d27a9bf159066a8e1be3d4", + "testharness" + ], + "upgrade-insecure-requests/gen/worker-module-data.meta/unset/xhr.https.html": [ + "cc450bfef7a0e55367d85228189f80c61a9e363c", + "testharness" + ], + "upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/fetch.https.html": [ + "b50873f80858af44755b497e8bdfc06549255911", + "testharness" + ], + "upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/websocket.https.html": [ + "0173f7986b03472771c1bddd115808188c9d8a4f", + "testharness" + ], + "upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/xhr.https.html": [ + "cc0a17b9f1acd9ead23e96aeacedbba28e538508", + "testharness" + ], "upgrade-insecure-requests/gen/worker-module-inherit.http-rp/upgrade/fetch.https.html": [ "4cde804eb79399c49f30ed68f12f26e3ea6005d7", "testharness" @@ -516983,7 +517773,7 @@ "support" ], "upgrade-insecure-requests/spec.src.json": [ - "139b5c451f7438cea55b1f47fb8102626970f91f", + "43f2d6dbc1867c668198e2570414fd08df817dc8", "support" ], "upgrade-insecure-requests/support/redirect-cors.py": [
diff --git a/third_party/blink/web_tests/external/wpt/common/security-features/tools/generate.py b/third_party/blink/web_tests/external/wpt/common/security-features/tools/generate.py index 20525985..75b7c1d 100755 --- a/third_party/blink/web_tests/external/wpt/common/security-features/tools/generate.py +++ b/third_party/blink/web_tests/external/wpt/common/security-features/tools/generate.py
@@ -258,14 +258,15 @@ test_expansion_schema = spec_json['test_expansion_schema'] specification = spec_json['specification'] - spec_json_js_template = util.get_template('spec_json.js.template') - util.write_file( - os.path.join(spec_directory, "generic", "spec_json.js"), - spec_json_js_template % {'spec_json': json.dumps(spec_json)}) - - util.write_file( - os.path.join(spec_directory, "generic", "debug-output.spec.src.json"), - json.dumps(spec_json, indent=2, separators=(',', ': '))) + if target == "debug": + spec_json_js_template = util.get_template('spec_json.js.template') + util.write_file( + os.path.join(spec_directory, "generic", "spec_json.js"), + spec_json_js_template % {'spec_json': json.dumps(spec_json)}) + util.write_file( + os.path.join(spec_directory, "generic", + "debug-output.spec.src.json"), + json.dumps(spec_json, indent=2, separators=(',', ': '))) # Choose a debug/release template depending on the target. html_template = "test.%s.html.template" % target
diff --git a/third_party/blink/web_tests/external/wpt/css/css-color/parsing/color-valid.html b/third_party/blink/web_tests/external/wpt/css/css-color/parsing/color-valid.html index 62df826..48e9756 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-color/parsing/color-valid.html +++ b/third_party/blink/web_tests/external/wpt/css/css-color/parsing/color-valid.html
@@ -28,8 +28,6 @@ test_valid_value("color", "rgb(100, 200, 300)", "rgb(100, 200, 255)"); test_valid_value("color", "rgb(20, 10, 0, -10)", "rgba(20, 10, 0, 0)"); // Not supported by Edge/Safari. test_valid_value("color", "rgb(100%, 200%, 300%)", "rgb(255, 255, 255)"); -test_valid_value("color", "field"); -test_valid_value("color", "fieldtext"); </script> </body> </html>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-flexbox/flex-basis-item-margins-001.html b/third_party/blink/web_tests/external/wpt/css/css-flexbox/flex-basis-item-margins-001.html new file mode 100644 index 0000000..5f65b267b --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-flexbox/flex-basis-item-margins-001.html
@@ -0,0 +1,34 @@ +<!DOCTYPE html> +<title>Flexbox: margins and available space</title> +<link rel="author" title="David Grogan" href="mailto:dgrogan@chromium.org"> +<link rel="help" href="https://drafts.csswg.org/css-flexbox/#algo-main-item" title="Case E"> +<link rel="match" href="../reference/ref-filled-green-100px-square.xht"> +<meta name="flags" content="" /> +<meta name="assert" content="An item's inline margins are subtracted from available space when laying out to determine flex-basis in a column container." /> + +<style> +.inline-block { + display: inline-block; + width: 40px; + height: 50px; +} + +#reference-overlapped-red { + position: absolute; + background-color: red; + width: 100px; + height: 100px; + z-index: -1; +} +</style> + +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> + +<div id="reference-overlapped-red"></div> + +<div style="display: flex; flex-direction: column; width: 100px; background: green;"> + <!-- 21px makes the inline-blocks wrap --> + <div style="margin-right: 21px; flex: 0 0 auto; line-height: 0px;"> + <div class="inline-block"></div><div class="inline-block"></div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-text/line-break/line-break-normal-015.xht b/third_party/blink/web_tests/external/wpt/css/css-text/line-break/line-break-normal-015.xht index 6debeed..3d2f239 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-text/line-break/line-break-normal-015.xht +++ b/third_party/blink/web_tests/external/wpt/css/css-text/line-break/line-break-normal-015.xht
@@ -50,7 +50,7 @@ <span>サンプルサンプル。<span class="target">‥‥</span>サンプル文</span> </p> <p class="control" lang="ja"> - <span>サンプルサンプル。<br /><span class="target">‥‥</span>サンプル文</span> + <span>サンプルサンプ<br />ル。<span class="target">‥‥</span>サンプル文</span> </p> </div> <div class="wrapper"> @@ -59,7 +59,7 @@ <span>サンプルサンプル。<span class="target">……</span>サンプル文</span> </p> <p class="control" lang="ja"> - <span>サンプルサンプル。<br /><span class="target">……</span>サンプル文</span> + <span>サンプルサンプ<br />ル。<span class="target">……</span>サンプル文</span> </p> </div> </body>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-text/line-break/line-break-strict-015.xht b/third_party/blink/web_tests/external/wpt/css/css-text/line-break/line-break-strict-015.xht index ec3d6520..ea8caab 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-text/line-break/line-break-strict-015.xht +++ b/third_party/blink/web_tests/external/wpt/css/css-text/line-break/line-break-strict-015.xht
@@ -50,7 +50,7 @@ <span>サンプルサンプル。<span class="target">‥‥</span>サンプル文</span> </p> <p class="control" lang="ja"> - <span>サンプルサンプル。<br /><span class="target">‥‥</span>サンプル文</span> + <span>サンプルサンプ<br />ル。<span class="target">‥‥</span>サンプル文</span> </p> </div> <div class="wrapper"> @@ -59,7 +59,7 @@ <span>サンプルサンプル。<span class="target">……</span>サンプル文</span> </p> <p class="control" lang="ja"> - <span>サンプルサンプル。<br /><span class="target">……</span>サンプル文</span> + <span>サンプルサンプ<br />ル。<span class="target">……</span>サンプル文</span> </p> </div> </body>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-text/line-break/reference/line-break-normal-015-ref.xht b/third_party/blink/web_tests/external/wpt/css/css-text/line-break/reference/line-break-normal-015-ref.xht index 886c4a30..b4697ba 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-text/line-break/reference/line-break-normal-015-ref.xht +++ b/third_party/blink/web_tests/external/wpt/css/css-text/line-break/reference/line-break-normal-015-ref.xht
@@ -41,19 +41,19 @@ <div class="wrapper"> <!-- inseparable characters TWO DOT LEADER --> <p class="control" lang="ja"> - <span>サンプルサンプル。<br /><span class="target">‥‥</span>サンプル文</span> + <span>サンプルサンプ<br />ル。<span class="target">‥‥</span>サンプル文</span> </p> <p class="control" lang="ja"> - <span>サンプルサンプル。<br /><span class="target">‥‥</span>サンプル文</span> + <span>サンプルサンプ<br />ル。<span class="target">‥‥</span>サンプル文</span> </p> </div> <div class="wrapper"> <!-- inseparable characters HORIZONTAL ELLIPSIS --> <p class="control" lang="ja"> - <span>サンプルサンプル。<br /><span class="target">……</span>サンプル文</span> + <span>サンプルサンプ<br />ル。<span class="target">……</span>サンプル文</span> </p> <p class="control" lang="ja"> - <span>サンプルサンプル。<br /><span class="target">……</span>サンプル文</span> + <span>サンプルサンプ<br />ル。<span class="target">……</span>サンプル文</span> </p> </div> </body>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-text/line-break/reference/line-break-strict-015-ref.xht b/third_party/blink/web_tests/external/wpt/css/css-text/line-break/reference/line-break-strict-015-ref.xht index 3208702..8eceb2a 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-text/line-break/reference/line-break-strict-015-ref.xht +++ b/third_party/blink/web_tests/external/wpt/css/css-text/line-break/reference/line-break-strict-015-ref.xht
@@ -41,19 +41,19 @@ <div class="wrapper"> <!-- inseparable characters TWO DOT LEADER --> <p class="control" lang="ja"> - <span>サンプルサンプル。<br /><span class="target">‥‥</span>サンプル文</span> + <span>サンプルサンプ<br />ル。<span class="target">‥‥</span>サンプル文</span> </p> <p class="control" lang="ja"> - <span>サンプルサンプル。<br /><span class="target">‥‥</span>サンプル文</span> + <span>サンプルサンプ<br />ル。<span class="target">‥‥</span>サンプル文</span> </p> </div> <div class="wrapper"> <!-- inseparable characters HORIZONTAL ELLIPSIS --> <p class="control" lang="ja"> - <span>サンプルサンプル。<br /><span class="target">……</span>サンプル文</span> + <span>サンプルサンプ<br />ル。<span class="target">……</span>サンプル文</span> </p> <p class="control" lang="ja"> - <span>サンプルサンプル。<br /><span class="target">……</span>サンプル文</span> + <span>サンプルサンプ<br />ル。<span class="target">……</span>サンプル文</span> </p> </div> </body>
diff --git a/third_party/blink/web_tests/external/wpt/generic-sensor/generic-sensor-permission.https.html b/third_party/blink/web_tests/external/wpt/generic-sensor/generic-sensor-permission.https.html new file mode 100644 index 0000000..a86ed5d --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/generic-sensor/generic-sensor-permission.https.html
@@ -0,0 +1,32 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>sensor: permission</title> +<link rel="help" href="https://w3c.github.io/sensors/"/> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<script> + +"use strict"; + +for (const entry of ['accelerometer', 'gyroscope', + 'magnetometer', 'ambient-light-sensor']) { + promise_test(async t => { + await test_driver.set_permission({ name: entry }, 'denied', false); + + const status = await navigator.permissions.query({ name: entry }); + assert_class_string(status, "PermissionStatus"); + assert_equals(status.state, "denied"); + }, `Deny ${entry} permission should work.`); + + promise_test(async t => { + await test_driver.set_permission({ name: entry }, 'granted', false); + + const status = await navigator.permissions.query({ name: entry }); + assert_class_string(status, "PermissionStatus"); + assert_equals(status.state, "granted"); + }, `Grant ${entry} permission should work.`); +}; + +</script> \ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/generic-sensor/resources/generic-sensor-helpers.js b/third_party/blink/web_tests/external/wpt/generic-sensor/resources/generic-sensor-helpers.js index afc2fadec..ad11e58 100644 --- a/third_party/blink/web_tests/external/wpt/generic-sensor/resources/generic-sensor-helpers.js +++ b/third_party/blink/web_tests/external/wpt/generic-sensor/resources/generic-sensor-helpers.js
@@ -20,6 +20,8 @@ '/gen/mojo/public/mojom/base/string16.mojom.js', '/gen/services/device/public/mojom/sensor.mojom.js', '/gen/services/device/public/mojom/sensor_provider.mojom.js', + '/resources/testdriver.js', + '/resources/testdriver-vendor.js', '/resources/chromium/generic_sensor_mocks.js', ];
diff --git a/third_party/blink/web_tests/external/wpt/html/semantics/selectors/pseudo-classes/dir-html-input-dynamic-text-expected.txt b/third_party/blink/web_tests/external/wpt/html/semantics/selectors/pseudo-classes/dir-html-input-dynamic-text-expected.txt new file mode 100644 index 0000000..d26b681 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/semantics/selectors/pseudo-classes/dir-html-input-dynamic-text-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +FAIL :dir on <input> isn't altered by text children Failed to execute 'matches' on 'Element': ':dir(ltr)' is not a valid selector. +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/external/wpt/html/semantics/selectors/pseudo-classes/dir-html-input-dynamic-text.html b/third_party/blink/web_tests/external/wpt/html/semantics/selectors/pseudo-classes/dir-html-input-dynamic-text.html new file mode 100644 index 0000000..0c50cec --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/semantics/selectors/pseudo-classes/dir-html-input-dynamic-text.html
@@ -0,0 +1,21 @@ +<!doctype html> +<meta charset="utf-8"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1622900"> +<link rel="help" href="https://html.spec.whatwg.org/#the-directionality"> +<input value="ltr" dir="auto"> +<script> +test(function() { + let input = document.querySelector("input"); + assert_true(input.matches(":dir(ltr)"), "Input with ltr value should match dir(ltr)"); + input.textContent = "ï·º"; + assert_true(input.matches(":dir(ltr)"), "Should still match dir(ltr) after text change"); + input.value = "ltr2"; + assert_true(input.matches(":dir(ltr)"), "Should still match dir(ltr) after value change"); + input.value = "ï·º"; + assert_true(input.matches(":dir(rtl)"), "Should match dir(rtl) after value change"); + input.textContent = "ltr"; + assert_true(input.matches(":dir(rtl)"), "Should match dir(rtl) after text change"); +}, ":dir on <input> isn't altered by text children") +</script>
diff --git a/third_party/blink/web_tests/external/wpt/largest-contentful-paint/invisible-images-composited.html b/third_party/blink/web_tests/external/wpt/largest-contentful-paint/invisible-images-composited.html new file mode 100644 index 0000000..f652180d --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/largest-contentful-paint/invisible-images-composited.html
@@ -0,0 +1,56 @@ +<!DOCTYPE HTML> +<meta charset=utf-8> +<head> +<title>Largest Contentful Paint: invisible images are not observable</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> + .opacity0 { + opacity: 0; + } + .visibilityHidden { + visibility: hidden; + } + .displayNone { + display: none; + } + .composited { + will-change: transform; + } +</style> +</head> +<body> +<script> + async_test(t => { + assert_precondition(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented"); + const observer = new PerformanceObserver( + t.step_func(entryList => { + entryList.getEntries().forEach(entry => { + // May receive a text entry. Ignore that entry. + if (!entry.url) { + return; + } + // The images should not have caused an entry, so fail test. + assert_unreached('Should not have received an entry! Received one with id ' + + entryList.getEntries()[0].id); + }); + }) + ); + observer.observe({type: 'largest-contentful-paint', buffered: true}); + // Images have been added but should not cause entries to be dispatched. + // Wait for 500ms and end test, ensuring no entry was created. + t.step_timeout(() => { + t.done(); + }, 500); + }, 'Images with opacity: 0, visibility: hidden, or display: none are not observable by LargestContentfulPaint.'); +</script> +<img src='/images/blue.png' class='opacity0 composited' id='opacity0'/> +<img src='/images/green.png' class='visibilityHidden composited' id='visibilityHidden'/> +<img src='/images/red.png' class='displayNone composited' id='displayNone'/> +<div class='opacity0 composited'><img class='composited' src='/images/yellow.png' id='divOpacity0'/></div> +<div class='visibilityHidden composited'><img class='composited' src='/images/yellow.png' id='divVisibilityHidden'/></div> +<div class='displayNone composited'><img src='/images/yellow.png' id='divDisplayNone'/></div> +<div class='opacity0 composited'><img src='/images/yellow.png' id='divOpacity0Composited'/></div> +<div class='visibilityHidden composited'><img src='/images/yellow.png' id='divVisibilityHiddenComposited'/></div> +<div class='displayNone composited'><img src='/images/yellow.png' id='divDisplayNoneComposited'/></div> +</body>
diff --git a/third_party/blink/web_tests/external/wpt/resize-observer/devicepixel-ref.html b/third_party/blink/web_tests/external/wpt/resize-observer/devicepixel-ref.html new file mode 100644 index 0000000..a0067320 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/resize-observer/devicepixel-ref.html
@@ -0,0 +1,27 @@ +<!doctype html> +<style> + #greenrect { + width: 100%; + height: 100%; + border: 1px solid green; + box-sizing: border-box; + } + #outer { + padding-top: 1.7px; + width: 300.8px; + height: 250.1px; + } + #outer2 { + padding-top: 1.4px; + width: 300.8px; + height: 250.1px; + } +</style> +<body> + <div id="outer"> + <div id="greenrect"></div> + </div> + <div id="outer2"> + <div id="greenrect"></div> + </div> +</body>
diff --git a/third_party/blink/web_tests/external/wpt/resize-observer/devicepixel.html b/third_party/blink/web_tests/external/wpt/resize-observer/devicepixel.html new file mode 100644 index 0000000..6ecb824 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/resize-observer/devicepixel.html
@@ -0,0 +1,85 @@ +<!doctype html> +<link rel="match" href="devicepixel-ref.html"> +<meta name="assert" content="Device pixel content box sizes and pixel snapping are correct in Resize Observer callback"> +<!-- + This test verifies that the device pixel content box sizes available + in a resize observer callback are correct. Resize observer notifications + are delivered as the element is loaded. A box is then drawn using the + available dimensions in device pixels. The result is compared to the reference + which uses div and border to draw a box. +--> + +<style> + #canvas2D { + width: 100%; + height: 100%; + } + #canvas2DPadding14 { + width: 100%; + height: 100%; + } + #outer { + padding-top: 1.7px; + width: 300.8px; + height: 250.1px; + } + #outer2 { + padding-top: 1.4px; + width: 300.8px; + height: 250.1px; + } + +</style> +<body> + <div id="outer"> + <canvas id="canvas2D"></canvas> + </div> + <div id="outer2"> + <canvas id="canvas2DPadding14"></canvas> + </div> +</body> + +<script> + // Create a box using device pixel content box dimensions + function paint2D(ctx, snappedSize) { + ctx.beginPath(); + // Use a linewidth of 2. Because the rectangle is drawn at 0,0 with + // its dimensions being the same as canvas dimensions, linewidth as it + // is drawn on the canvas will be 1. + ctx.lineWidth = "2"; + ctx.strokeStyle = "green"; + ctx.rect(0, 0, snappedSize.inlineSize, snappedSize.blockSize); + ctx.stroke(); + } + + function updateCanvasSize2D(canvas2D, ctx, snappedSize) { + canvas2D.width = snappedSize.inlineSize; + canvas2D.height = snappedSize.blockSize; + paint2D(ctx, snappedSize); + } + + (function() { + let canvas2D = document.querySelector("#canvas2D"); + let canvas2DPadding14 = document.querySelector("#canvas2DPadding14"); + + function observeSizes() { + let ro = new ResizeObserver( entries => { + for (entry of entries) { + let size = entry.devicePixelContentBoxSize; + if (entry.target == canvas2D) { + let canvas2D = document.querySelector("#canvas2D"); + let ctx = canvas2D.getContext("2d"); + updateCanvasSize2D(canvas2D, ctx, size); + } else if (entry.target == canvas2DPadding14){ + let canvas2DPadding14 = document.querySelector("#canvas2DPadding14"); + let ctx = canvas2DPadding14.getContext("2d"); + updateCanvasSize2D(canvas2DPadding14, ctx, size); + } + } + }); + ro.observe(canvas2D, {box: "device-pixel-content-box"}); + ro.observe(canvas2DPadding14, {box: "device-pixel-content-box"}); + } + observeSizes(); + })(); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/resize-observer/observe.html b/third_party/blink/web_tests/external/wpt/resize-observer/observe.html index 1ab5f78..58f2004 100644 --- a/third_party/blink/web_tests/external/wpt/resize-observer/observe.html +++ b/third_party/blink/web_tests/external/wpt/resize-observer/observe.html
@@ -716,7 +716,6 @@ } - function test17() { // <div id="outer"> // <div id="nested"> @@ -847,6 +846,66 @@ return helper.start(() => nested.remove()); } +function test18() { + let t = createAndAppendElement("div"); + t.style.height = "100px"; + t.style.width = "50px"; + + let helper = new ResizeTestHelper( + "test18: an observation is fired when device-pixel-content-box is being " + + "observed", + [ + { + setup: observer => { + observer.observe(t, {box: "device-pixel-content-box"}); + }, + notify: entries => { + assert_equals(entries.length, 1, "1 pending notification"); + assert_equals(entries[0].target, t, "target is t"); + assert_equals(entries[0].contentRect.width, 50, "target width"); + assert_equals(entries[0].contentRect.height, 100, "target height"); + assert_equals(entries[0].contentBoxSize.inlineSize, 50, + "target content-box inline size"); + assert_equals(entries[0].contentBoxSize.blockSize, 100, + "target content-box block size"); + assert_equals(entries[0].borderBoxSize.inlineSize, 50, + "target border-box inline size"); + assert_equals(entries[0].borderBoxSize.blockSize, 100, + "target border-box block size"); + assert_equals(entries[0].devicePixelContentBoxSize.inlineSize, 50, + "target device-pixel-content-box inline size"); + assert_equals(entries[0].devicePixelContentBoxSize.blockSize, 100, + "target device-pixel-content-box block size"); + } + }, + { + setup: observer => { + document.body.style.zoom = 3; + }, + notify: entries => { + assert_equals(entries.length, 1, "1 pending notification"); + assert_equals(entries[0].target, t, "target is t"); + assert_equals(entries[0].contentRect.width, 50, "target width"); + assert_equals(entries[0].contentRect.height, 100, "target height"); + assert_equals(entries[0].contentBoxSize.inlineSize, 50, + "target content-box inline size"); + assert_equals(entries[0].contentBoxSize.blockSize, 100, + "target content-box block size"); + assert_equals(entries[0].borderBoxSize.inlineSize, 50, + "target border-box inline size"); + assert_equals(entries[0].borderBoxSize.blockSize, 100, + "target border-box block size"); + assert_equals(entries[0].devicePixelContentBoxSize.inlineSize, 150, + "target device-pixel-content-box inline size"); + assert_equals(entries[0].devicePixelContentBoxSize.blockSize, 300, + "target device-pixel-content-box block size"); + } + } + ]); + + return helper.start(() => t.remove()); +} + let guard; test(_ => { assert_own_property(window, "ResizeObserver"); @@ -871,6 +930,7 @@ .then(() => test15()) .then(() => test16()) .then(() => test17()) + .then(() => test18()) .then(() => guard.done()); </script>
diff --git a/third_party/blink/web_tests/external/wpt/resize-observer/resources/resizeTestHelper.js b/third_party/blink/web_tests/external/wpt/resize-observer/resources/resizeTestHelper.js index 738fb65..032eb4b 100644 --- a/third_party/blink/web_tests/external/wpt/resize-observer/resources/resizeTestHelper.js +++ b/third_party/blink/web_tests/external/wpt/resize-observer/resources/resizeTestHelper.js
@@ -9,7 +9,7 @@ Features: - can queue multiple notification steps in a test - handles timeouts - - returns Promise that is fullfilled when test completes. + - returns Promise that is fulfilled when test completes. Use to chain tests (since parallel async ResizeObserver tests would conflict if reusing same DOM elements).
diff --git a/third_party/blink/web_tests/external/wpt/resize-observer/svg.html b/third_party/blink/web_tests/external/wpt/resize-observer/svg.html index 648a4995..fe8d428 100644 --- a/third_party/blink/web_tests/external/wpt/resize-observer/svg.html +++ b/third_party/blink/web_tests/external/wpt/resize-observer/svg.html
@@ -496,6 +496,46 @@ return helper.start(); } +function test16() { + let target = document.querySelector('#g_rect'); + let helper = new ResizeTestHelper( + "test16: observe g:rect content, border and device-pixel-content boxes", + [ + { + setup: observer => { + observer.observe(target, {box: "device-pixel-content-box"}); + target.setAttribute('width', 50); + document.body.style.zoom = 0.1; + }, + notify: (entries, observer) => { + // Ensure zoom does not impact the sizes + assert_equals(entries.length, 1); + assert_equals(entries[0].contentRect.width, 50); + assert_equals(entries[0].contentRect.height, 20); + assert_equals(entries[0].contentBoxSize.inlineSize, 50); + assert_equals(entries[0].contentBoxSize.blockSize, 20); + assert_equals(entries[0].borderBoxSize.inlineSize, 50); + assert_equals(entries[0].borderBoxSize.blockSize, 20); + assert_equals(entries[0].devicePixelContentBoxSize.inlineSize, 50); + assert_equals(entries[0].devicePixelContentBoxSize.blockSize, 20); + return true; // Delay next step + } + }, + { + setup: observer => { + document.body.style.zoom = 10; + }, + notify: (entries, observer) => { + + }, + timeout: () => { + // SVG computed size is always bounding box inline and block lengths + } + } + ]); + return helper.start(); +} + let guard; test(_ => { assert_own_property(window, "ResizeObserver"); @@ -518,6 +558,7 @@ .then(() => { return test13(); }) .then(() => { return test14(); }) .then(() => { return test15(); }) + .then(() => { return test16(); }) .then(() => { guard.done(); }); </script>
diff --git a/third_party/blink/web_tests/external/wpt/resources/chromium/generic_sensor_mocks.js b/third_party/blink/web_tests/external/wpt/resources/chromium/generic_sensor_mocks.js index ac6043d..8f13420 100644 --- a/third_party/blink/web_tests/external/wpt/resources/chromium/generic_sensor_mocks.js +++ b/third_party/blink/web_tests/external/wpt/resources/chromium/generic_sensor_mocks.js
@@ -309,18 +309,15 @@ Object.freeze(this); // Make it immutable. } - initialize() { + async initialize() { if (testInternal.initialized) throw new Error('Call reset() before initialize().'); - if (window.testRunner) { - // Grant sensor permissions for Chromium testrunner. - ['accelerometer', 'gyroscope', - 'magnetometer', 'ambient-light-sensor'].forEach((entry) => { - window.testRunner.setPermission(entry, 'granted', - location.origin, location.origin); - }); - } + // Grant sensor permissions for Chromium testdriver. + for (const entry of ['accelerometer', 'gyroscope', + 'magnetometer', 'ambient-light-sensor']) { + await test_driver.set_permission({ name: entry }, 'granted', false); + }; testInternal.sensorProvider = new MockSensorProvider; testInternal.initialized = true;
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/fetch.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/fetch.https.html new file mode 100644 index 0000000..b65bb84 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/fetch.https.html
@@ -0,0 +1,112 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-http-downgrade origin and downgrade redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/fetch.https.html.headers b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/fetch.https.html.headers new file mode 100644 index 0000000..602d9dc3 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/fetch.https.html.headers
@@ -0,0 +1 @@ +Content-Security-Policy: upgrade-insecure-requests
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/websocket.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/websocket.https.html new file mode 100644 index 0000000..f1933b6 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/websocket.https.html
@@ -0,0 +1,52 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "same-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for websocket to same-ws-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for websocket to cross-ws-downgrade origin and no-redirect redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/websocket.https.html.headers b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/websocket.https.html.headers new file mode 100644 index 0000000..602d9dc3 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/websocket.https.html.headers
@@ -0,0 +1 @@ +Content-Security-Policy: upgrade-insecure-requests
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/xhr.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/xhr.https.html new file mode 100644 index 0000000..026d771 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/xhr.https.html
@@ -0,0 +1,112 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-http-downgrade origin and downgrade redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/xhr.https.html.headers b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/xhr.https.html.headers new file mode 100644 index 0000000..602d9dc3 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.http-rp/upgrade/xhr.https.html.headers
@@ -0,0 +1 @@ +Content-Security-Policy: upgrade-insecure-requests
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/fetch.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/fetch.https.html new file mode 100644 index 0000000..95c36da --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/fetch.https.html
@@ -0,0 +1,112 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "blocked", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to same-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to cross-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to cross-https origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to same-https origin and downgrade redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/websocket.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/websocket.https.html new file mode 100644 index 0000000..116967e0 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/websocket.https.html
@@ -0,0 +1,52 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "blocked", + "origin": "cross-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for websocket to cross-ws-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for websocket to same-ws-downgrade origin and no-redirect redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/xhr.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/xhr.https.html new file mode 100644 index 0000000..89ab0fe --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/unset/xhr.https.html
@@ -0,0 +1,112 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "blocked", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to same-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to cross-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to same-https origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to cross-https origin and downgrade redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/fetch.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/fetch.https.html new file mode 100644 index 0000000..eea46ce --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/fetch.https.html
@@ -0,0 +1,113 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-http-downgrade origin and downgrade redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/websocket.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/websocket.https.html new file mode 100644 index 0000000..4347f01 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/websocket.https.html
@@ -0,0 +1,53 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "cross-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for websocket to cross-ws-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for websocket to same-ws-downgrade origin and no-redirect redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/xhr.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/xhr.https.html new file mode 100644 index 0000000..c0447cf --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/xhr.https.html
@@ -0,0 +1,113 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-classic-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-https origin and downgrade redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/fetch.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/fetch.https.html new file mode 100644 index 0000000..ea2320e --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/fetch.https.html
@@ -0,0 +1,112 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-http-downgrade origin and no-redirect redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/fetch.https.html.headers b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/fetch.https.html.headers new file mode 100644 index 0000000..602d9dc3 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/fetch.https.html.headers
@@ -0,0 +1 @@ +Content-Security-Policy: upgrade-insecure-requests
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/websocket.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/websocket.https.html new file mode 100644 index 0000000..124a03c --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/websocket.https.html
@@ -0,0 +1,52 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "same-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for websocket to same-ws-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for websocket to cross-ws-downgrade origin and no-redirect redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/websocket.https.html.headers b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/websocket.https.html.headers new file mode 100644 index 0000000..602d9dc3 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/websocket.https.html.headers
@@ -0,0 +1 @@ +Content-Security-Policy: upgrade-insecure-requests
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/xhr.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/xhr.https.html new file mode 100644 index 0000000..b04b07a --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/xhr.https.html
@@ -0,0 +1,112 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-http-downgrade origin and no-redirect redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/xhr.https.html.headers b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/xhr.https.html.headers new file mode 100644 index 0000000..602d9dc3 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.http-rp/upgrade/xhr.https.html.headers
@@ -0,0 +1 @@ +Content-Security-Policy: upgrade-insecure-requests
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/fetch.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/fetch.https.html new file mode 100644 index 0000000..d6b8cdf4 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/fetch.https.html
@@ -0,0 +1,112 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "blocked", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to same-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to same-https origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to cross-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to cross-https origin and downgrade redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/websocket.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/websocket.https.html new file mode 100644 index 0000000..a4798e53 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/websocket.https.html
@@ -0,0 +1,52 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "blocked", + "origin": "same-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for websocket to same-ws-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for websocket to cross-ws-downgrade origin and no-redirect redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/xhr.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/xhr.https.html new file mode 100644 index 0000000..681c1cee --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/xhr.https.html
@@ -0,0 +1,112 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "blocked", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to cross-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to same-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to same-https origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to cross-https origin and downgrade redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/fetch.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/fetch.https.html new file mode 100644 index 0000000..b355fd0 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/fetch.https.html
@@ -0,0 +1,113 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-https origin and downgrade redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/websocket.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/websocket.https.html new file mode 100644 index 0000000..36bac646 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/websocket.https.html
@@ -0,0 +1,53 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "cross-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for websocket to cross-ws-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for websocket to same-ws-downgrade origin and no-redirect redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/xhr.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/xhr.https.html new file mode 100644 index 0000000..befbb21 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/xhr.https.html
@@ -0,0 +1,113 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "sharedworker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-https origin and downgrade redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/fetch.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/fetch.https.html new file mode 100644 index 0000000..a3fa13ecf --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/fetch.https.html
@@ -0,0 +1,112 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-http-downgrade origin and no-redirect redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/fetch.https.html.headers b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/fetch.https.html.headers new file mode 100644 index 0000000..602d9dc3 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/fetch.https.html.headers
@@ -0,0 +1 @@ +Content-Security-Policy: upgrade-insecure-requests
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/websocket.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/websocket.https.html new file mode 100644 index 0000000..53dc448 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/websocket.https.html
@@ -0,0 +1,52 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "same-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for websocket to same-ws-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for websocket to cross-ws-downgrade origin and no-redirect redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/websocket.https.html.headers b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/websocket.https.html.headers new file mode 100644 index 0000000..602d9dc3 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/websocket.https.html.headers
@@ -0,0 +1 @@ +Content-Security-Policy: upgrade-insecure-requests
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/xhr.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/xhr.https.html new file mode 100644 index 0000000..1125fa4 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/xhr.https.html
@@ -0,0 +1,112 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-https origin and downgrade redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/xhr.https.html.headers b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/xhr.https.html.headers new file mode 100644 index 0000000..602d9dc3 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.http-rp/upgrade/xhr.https.html.headers
@@ -0,0 +1 @@ +Content-Security-Policy: upgrade-insecure-requests
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/unset/fetch.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/unset/fetch.https.html new file mode 100644 index 0000000..a3cd214 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/unset/fetch.https.html
@@ -0,0 +1,112 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "blocked", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to same-https origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to cross-https origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to same-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for fetch to cross-http-downgrade origin and no-redirect redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/unset/websocket.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/unset/websocket.https.html new file mode 100644 index 0000000..27e0c78 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/unset/websocket.https.html
@@ -0,0 +1,52 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "blocked", + "origin": "cross-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for websocket to cross-ws-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for websocket to same-ws-downgrade origin and no-redirect redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/unset/xhr.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/unset/xhr.https.html new file mode 100644 index 0000000..cc450bfe --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/unset/xhr.https.html
@@ -0,0 +1,112 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "blocked", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to same-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to cross-https origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to cross-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "blocked", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to same-https origin and downgrade redirection from https context." + }, + { + "expectation": "blocked", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects blocked for xhr to cross-http-downgrade origin and downgrade redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/fetch.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/fetch.https.html new file mode 100644 index 0000000..b50873f80 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/fetch.https.html
@@ -0,0 +1,113 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to cross-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "fetch", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for fetch to same-http-downgrade origin and no-redirect redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/websocket.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/websocket.https.html new file mode 100644 index 0000000..0173f798 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/websocket.https.html
@@ -0,0 +1,53 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "cross-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for websocket to cross-ws-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-ws-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "websocket", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for websocket to same-ws-downgrade origin and no-redirect redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/xhr.https.html b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/xhr.https.html new file mode 100644 index 0000000..cc0a17b --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/gen/worker-module-data.meta/upgrade/xhr.https.html
@@ -0,0 +1,113 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec upgrade-insecure-requests/` --> +<html> + <head> + <meta charset="utf-8"> + <meta name="timeout" content="long"> + <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/security-features/resources/common.sub.js"></script> + <script src="../../../generic/test-case.sub.js"></script> + </head> + <body> + <script> + TestCase( + [ + { + "expectation": "allowed", + "origin": "same-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-http-downgrade origin and no-redirect redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-https", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-https origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "same-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to same-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "downgrade", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-http-downgrade origin and downgrade redirection from https context." + }, + { + "expectation": "allowed", + "origin": "cross-http-downgrade", + "redirection": "no-redirect", + "source_context_list": [ + { + "policyDeliveries": [], + "sourceContextType": "worker-module-data" + } + ], + "source_scheme": "https", + "subresource": "xhr", + "subresource_policy_deliveries": [], + "test_description": "Upgrade-Insecure-Requests: Expects allowed for xhr to cross-http-downgrade origin and no-redirect redirection from https context." + } + ], + new SanityChecker() + ).start(); + </script> + <div id="log"></div> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/spec.src.json b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/spec.src.json index 139b5c4..43f2d6d 100644 --- a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/spec.src.json +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/spec.src.json
@@ -102,10 +102,7 @@ "source_context_list": [ "req", "srcdoc", - "iframe", - "worker-module-data", - "sharedworker-classic-data", - "sharedworker-module-data" + "iframe" ], "delivery_type": "*", "delivery_value": "*",
diff --git a/third_party/blink/web_tests/fast/animation/report-violation-in-detached-coument-crash-expected.txt b/third_party/blink/web_tests/fast/animation/report-violation-in-detached-coument-crash-expected.txt new file mode 100644 index 0000000..c2541f4 --- /dev/null +++ b/third_party/blink/web_tests/fast/animation/report-violation-in-detached-coument-crash-expected.txt
@@ -0,0 +1 @@ +PASS if no crash.
diff --git a/third_party/blink/web_tests/fast/animation/report-violation-in-detached-coument-crash.html b/third_party/blink/web_tests/fast/animation/report-violation-in-detached-coument-crash.html new file mode 100644 index 0000000..41eb612 --- /dev/null +++ b/third_party/blink/web_tests/fast/animation/report-violation-in-detached-coument-crash.html
@@ -0,0 +1,11 @@ +<body> +PASS if no crash. +<script> +if (window.testRunner) + testRunner.dumpAsText(); +var doc = new Document(); +var div = document.createElement('div'); +doc.prepend(div); +div.animate({'right':['auto']}) +</script> +</body>
diff --git a/third_party/blink/web_tests/fast/canvas/OffscreenCanvas-2d-imageData.html b/third_party/blink/web_tests/fast/canvas/OffscreenCanvas-2d-imageData.html new file mode 100644 index 0000000..eb5f6452 --- /dev/null +++ b/third_party/blink/web_tests/fast/canvas/OffscreenCanvas-2d-imageData.html
@@ -0,0 +1,24 @@ +<!DOCTYPE html> +<script src="../../resources/testharness.js"></script> +<script src="../../resources/testharnessreport.js"></script> +<canvas style="background: red"></canvas> +<script> + +test(function() { + var canvas = document.querySelector('canvas'); + var offscreenCtx = (new OffscreenCanvas(canvas.width, canvas.height)).getContext('2d'); + + var imageData = offscreenCtx.createImageData(canvas.width, canvas.height); + var data = imageData.data; + + // Set all pixels to [0, 255, 0, 255] + for (var i = 0; i < data.length; i += 4) { + data[i + 1] = data[i + 3] = 255; + } + + offscreenCtx.putImageData(imageData, 0, 0); + + assert_array_equals(offscreenCtx.getImageData(0, 0, 1, 1).data, [0, 255, 0, 255]); +}, "Verify that imageData is properly set"); + +</script>
diff --git a/third_party/blink/web_tests/fast/events/continuous-platform-wheelevent-in-scrolling-div-expected.txt b/third_party/blink/web_tests/fast/events/continuous-platform-wheelevent-in-scrolling-div-expected.txt deleted file mode 100644 index 61fd4332..0000000 --- a/third_party/blink/web_tests/fast/events/continuous-platform-wheelevent-in-scrolling-div-expected.txt +++ /dev/null
@@ -1,8 +0,0 @@ -PASS event.wheelDeltaY is window.expectedScrollTop*-3 -PASS event.wheelDeltaX is window.expectedScrollLeft*-3 -PASS event.wheelDelta is window.expectedScrollTop*-3 -PASS div.scrollTop == window.expectedScrollTop && div.scrollLeft == window.expectedScrollLeft became true -PASS successfullyParsed is true - -TEST COMPLETE -
diff --git a/third_party/blink/web_tests/fast/events/continuous-platform-wheelevent-in-scrolling-div.html b/third_party/blink/web_tests/fast/events/continuous-platform-wheelevent-in-scrolling-div.html index 05ce7fb8..9eeff63f 100644 --- a/third_party/blink/web_tests/fast/events/continuous-platform-wheelevent-in-scrolling-div.html +++ b/third_party/blink/web_tests/fast/events/continuous-platform-wheelevent-in-scrolling-div.html
@@ -1,49 +1,47 @@ -<html> - <head> - <script src="../../resources/js-test.js"></script> - <script> - window.jsTestIsAsync = true; - var expectedScrollTop = 200; - var expectedScrollLeft = 100; - var event; - var div; +<!DOCTYPE html> +<script src='../../resources/gesture-util.js'></script> +<script src="../../resources/testharness.js"></script> +<script src="../../resources/testharnessreport.js"></script> +<div id="overflow" style="border:2px solid black;overflow:auto;height:200px;width:200px;"> + <div style="background-color:red;height:200px;width:400px;"></div> + <div style="background-color:green;height:200px;width:400px;"></div> + <div style="background-color:red;height:200px;width:400px;"></div> +</div> - function runTest() - { - var overflowElement = document.getElementById("overflow"); - if (overflowElement) - overflowElement.addEventListener("mousewheel", mousewheelHandler, false); +<script> - if (window.eventSender) { - eventSender.mouseMoveTo(100, 110); - eventSender.continuousMouseScrollBy(-window.expectedScrollLeft, -window.expectedScrollTop); - } +var expectedScrollTop = 200; +var expectedScrollLeft = 100; +var last_event = null; +var source = GestureSourceType.MOUSE_INPUT; +const numTicksX = expectedScrollLeft / pixelsPerTick(); +const numTicksY = expectedScrollTop / pixelsPerTick(); +const expectedWheelDeltaX = numTicksX * LEGACY_MOUSE_WHEEL_TICK_MULTIPLIER; +const expectedWheelDeltaY = numTicksY * LEGACY_MOUSE_WHEEL_TICK_MULTIPLIER; - div = document.getElementById("overflow"); - shouldBecomeEqual("div.scrollTop == window.expectedScrollTop && " + - "div.scrollLeft == window.expectedScrollLeft", "true", finishJSTest); - } +function mousewheelHandler(e) +{ + last_event = e; +} - function mousewheelHandler(e) - { - event = e; - shouldBe("event.wheelDeltaY", "window.expectedScrollTop*-3"); - shouldBe("event.wheelDeltaX", "window.expectedScrollLeft*-3"); +promise_test(async () => { + var overflowElement = document.getElementById("overflow"); + overflowElement.addEventListener("mousewheel", mousewheelHandler, false); - if (e.wheelDeltaY) - shouldBe("event.wheelDelta", "window.expectedScrollTop*-3"); - else - shouldBe("event.wheelDelta", "window.expectedScrollLeft*-3"); - } - </script> - </head> + await smoothScroll(window.expectedScrollLeft, 100, 110, source, 'right', SPEED_INSTANT); + await waitFor( () => { + return overflowElement.scrollLeft == window.expectedScrollLeft; + }); + assert_equals(last_event.wheelDeltaX, -Math.floor(expectedWheelDeltaX)); + assert_equals(last_event.wheelDelta, -Math.floor(expectedWheelDeltaX)); + last_event = null; - <body style="margin:0" onload="runTest()"> - <div id="overflow" style="border:2px solid black;overflow:auto;height:200px;width:200px;"> - <div style="background-color:red;height:200px;width:400px;"></div> - <div style="background-color:green;height:200px;width:400px;"></div> - <div style="background-color:red;height:200px;width:400px;"></div> - </div> - <div id="console"></div> - </body> -</html> + await smoothScroll(window.expectedScrollTop, 100, 110, source, 'down', SPEED_INSTANT); + await waitFor( () => { + return overflowElement.scrollTop == window.expectedScrollTop; + }); + assert_equals(last_event.wheelDeltaY, -Math.floor(expectedWheelDeltaY)); + assert_equals(last_event.wheelDelta, -Math.floor(expectedWheelDeltaY)); +}, 'This test checks the wheel delta value of wheel events, which should be the number of ticks multiplies the legacy mouse wheel tick multiplier.'); + +</script> \ No newline at end of file
diff --git a/third_party/blink/web_tests/resize-observer/device-pixel-notification.html b/third_party/blink/web_tests/resize-observer/device-pixel-notification.html new file mode 100644 index 0000000..167a812 --- /dev/null +++ b/third_party/blink/web_tests/resize-observer/device-pixel-notification.html
@@ -0,0 +1,146 @@ +<!doctype HTML> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> +<script src="./resources/resizeTestHelper.js"></script> +<body></body> + +<script> +'use strict'; + +// allow uncaught exception because ResizeObserver posts exceptions +// to window error handler when limit is exceeded. +setup({allow_uncaught_exception: true}); + +function test() { + let t = document.createElement("div"); + document.body.appendChild(t); + t.style.height = "25.25px"; + t.style.width = "55.5px"; + document.body.style.zoom = 1; + let helper = new ResizeTestHelper( + "An observation is fired when device-pixel-content-box is being " + + "observed and sub pixel values are used", + [ + { + setup: observer => { + observer.observe(t, {box: "device-pixel-content-box"}); + }, + notify: entries => { + assert_equals(entries.length, 1, "1 pending notification"); + assert_equals(entries[0].target, t, "target is t"); + assert_equals(entries[0].contentRect.width, 55.5, "target width"); + assert_equals(entries[0].contentRect.height, 25.25, "target height"); + assert_equals(entries[0].contentBoxSize.inlineSize, 55.5, + "target content-box inline size"); + assert_equals(entries[0].contentBoxSize.blockSize, 25.25, + "target content-box block size"); + assert_equals(entries[0].borderBoxSize.inlineSize, 55.5, + "target border-box inline size"); + assert_equals(entries[0].borderBoxSize.blockSize, 25.25, + "target border-box block size"); + assert_equals(entries[0].devicePixelContentBoxSize.inlineSize, 56, + "target device-pixel-content-box inline size"); + assert_equals(entries[0].devicePixelContentBoxSize.blockSize, 25, + "target device-pixel-content-box block size"); + } + }, + { + setup: observer => { + t.style.marginLeft = "10.5px" + }, + notify: entries => { + assert_equals(entries.length, 1, "1 pending notification"); + assert_equals(entries[0].target, t, "target is t"); + assert_equals(entries[0].contentRect.width, 55.5, "target width"); + assert_equals(entries[0].contentRect.height, 25.25, "target height"); + assert_equals(entries[0].contentBoxSize.inlineSize, 55.5, + "target content-box inline size"); + assert_equals(entries[0].contentBoxSize.blockSize, 25.25, + "target content-box block size"); + assert_equals(entries[0].borderBoxSize.inlineSize, 55.5, + "target border-box inline size"); + assert_equals(entries[0].borderBoxSize.blockSize, 25.25, + "target border-box block size"); + assert_equals(entries[0].devicePixelContentBoxSize.inlineSize, 55, + "target device-pixel-content-box inline size"); + assert_equals(entries[0].devicePixelContentBoxSize.blockSize, 25, + "target device-pixel-content-box block size"); + } + }, + { + setup: observer => { + document.body.style.zoom = 3; + }, + notify: entries => { + assert_equals(entries.length, 1, "1 pending notification"); + assert_equals(entries[0].target, t, "target is t"); + assert_equals(entries[0].contentRect.width, 55.5, "target width"); + assert_equals(entries[0].contentRect.height, 25.25, "target height"); + assert_equals(entries[0].contentBoxSize.inlineSize, 55.5, + "target content-box inline size"); + assert_equals(entries[0].contentBoxSize.blockSize, 25.25, + "target content-box block size"); + assert_equals(entries[0].borderBoxSize.inlineSize, 55.5, + "target content-box inline size"); + assert_equals(entries[0].borderBoxSize.blockSize, 25.25, + "target content-box block size"); + assert_equals(entries[0].devicePixelContentBoxSize.inlineSize, 166, + "target content-box inline size"); + assert_equals(entries[0].devicePixelContentBoxSize.blockSize, 76, + "target content-box block size"); + } + } + ]); + + return helper.start(() => t.remove()); +} + +function test2() { + // Ensure a resize observer callback that triggers only layout does not crash + // the browser + + let c = document.createElement('canvas'); + let a = document.createElement('div'); + a.style.height = '10px'; + a.style.width = '20px'; + c.width = "500"; + c.height = "500"; + document.body.appendChild(c); + document.body.appendChild(a); + + let helper = new ResizeTestHelper( + "Resize observer callback triggers layout without style change", + [ + { + setup: observer => { + observer.observe(a, { box: "border-box" }); + }, + notify: entries => { + + } + }, + { + setup: observer => { + a.style.width = '50px'; + }, + notify: entries => { + c.height = "100"; + assert_equals(entries.length, 1, "1 pending notification"); + assert_equals(entries[0].target, a, "target is t"); + assert_equals(entries[0].contentRect.width, 50, "target width"); + assert_equals(entries[0].contentRect.height, 10, "target height"); + assert_equals(entries[0].borderBoxSize.inlineSize, 50, + "target border-box inline size"); + assert_equals(entries[0].borderBoxSize.blockSize, 10, + "target border-box block size"); + } + }, + ]); + return helper.start(() => assert_equals(c.height, 100, + "canvas height")); +} + +test(); +test2(); + +</script>
diff --git a/third_party/blink/web_tests/resize-observer/resources/resizeTestHelper.js b/third_party/blink/web_tests/resize-observer/resources/resizeTestHelper.js new file mode 100644 index 0000000..032eb4b --- /dev/null +++ b/third_party/blink/web_tests/resize-observer/resources/resizeTestHelper.js
@@ -0,0 +1,180 @@ +'use strict'; + +/** + ResizeTestHelper is a framework to test ResizeObserver + notifications. Use it to make assertions about ResizeObserverEntries. + This framework is needed because ResizeObservations are + delivered asynchronously inside the event loop. + + Features: + - can queue multiple notification steps in a test + - handles timeouts + - returns Promise that is fulfilled when test completes. + Use to chain tests (since parallel async ResizeObserver tests + would conflict if reusing same DOM elements). + + Usage: + + create ResizeTestHelper for every test. + Make assertions inside notify, timeout callbacks. + Start tests with helper.start() + Chain tests with Promises. + Counts animation frames, see startCountingRaf +*/ + +/* + @param name: test name + @param steps: + { + setup: function(ResizeObserver) { + // called at the beginning of the test step + // your observe/resize code goes here + }, + notify: function(entries, observer) { + // ResizeObserver callback. + // Make assertions here. + // Return true if next step should start on the next event loop. + }, + timeout: function() { + // Define this if your test expects to time out. + // If undefined, timeout is assert_unreached. + } + } +*/ +function ResizeTestHelper(name, steps) +{ + this._name = name; + this._steps = steps || []; + this._stepIdx = -1; + this._harnessTest = null; + this._observer = new ResizeObserver(this._handleNotification.bind(this)); + this._timeoutBind = this._handleTimeout.bind(this); + this._nextStepBind = this._nextStep.bind(this); +} + +ResizeTestHelper.TIMEOUT = 100; + +ResizeTestHelper.prototype = { + get _currentStep() { + return this._steps[this._stepIdx]; + }, + + _nextStep: function() { + if (++this._stepIdx == this._steps.length) + return this._done(); + this._timeoutId = this._harnessTest.step_timeout( + this._timeoutBind, ResizeTestHelper.TIMEOUT); + try { + this._steps[this._stepIdx].setup(this._observer); + } + catch(err) { + this._harnessTest.step(() => { + assert_unreached("Caught a throw, possible syntax error"); + }); + } + }, + + _handleNotification: function(entries) { + if (this._timeoutId) { + window.clearTimeout(this._timeoutId); + delete this._timeoutId; + } + this._harnessTest.step(() => { + try { + let rafDelay = this._currentStep.notify(entries, this._observer); + if (rafDelay) + window.requestAnimationFrame(this._nextStepBind); + else + this._nextStep(); + } + catch(err) { + this._harnessTest.step(() => { + throw err; + }); + // Force to _done() the current test. + this._done(); + } + }); + }, + + _handleTimeout: function() { + delete this._timeoutId; + this._harnessTest.step(() => { + if (this._currentStep.timeout) { + this._currentStep.timeout(); + } + else { + this._harnessTest.step(() => { + assert_unreached("Timed out waiting for notification. (" + ResizeTestHelper.TIMEOUT + "ms)"); + }); + } + this._nextStep(); + }); + }, + + _done: function() { + this._observer.disconnect(); + delete this._observer; + this._harnessTest.done(); + if (this._rafCountRequest) { + window.cancelAnimationFrame(this._rafCountRequest); + delete this._rafCountRequest; + } + window.requestAnimationFrame(() => { this._resolvePromise(); }); + }, + + start: function(cleanup) { + this._harnessTest = async_test(this._name); + + if (cleanup) { + this._harnessTest.add_cleanup(cleanup); + } + + this._harnessTest.step(() => { + assert_equals(this._stepIdx, -1, "start can only be called once"); + this._nextStep(); + }); + return new Promise( (resolve, reject) => { + this._resolvePromise = resolve; + this._rejectPromise = reject; + }); + }, + + get rafCount() { + if (!this._rafCountRequest) + throw "rAF count is not active"; + return this._rafCount; + }, + + get test() { + if (!this._harnessTest) { + throw "_harnessTest is not initialized"; + } + return this._harnessTest; + }, + + _incrementRaf: function() { + if (this._rafCountRequest) { + this._rafCount++; + this._rafCountRequest = window.requestAnimationFrame(this._incrementRafBind); + } + }, + + startCountingRaf: function() { + if (this._rafCountRequest) + window.cancelAnimationFrame(this._rafCountRequest); + if (!this._incrementRafBind) + this._incrementRafBind = this._incrementRaf.bind(this); + this._rafCount = 0; + this._rafCountRequest = window.requestAnimationFrame(this._incrementRafBind); + } +} + +function createAndAppendElement(tagName, parent) { + if (!parent) { + parent = document.body; + } + const element = document.createElement(tagName); + parent.appendChild(element); + return element; +}
diff --git a/third_party/blink/web_tests/resources/gesture-util.js b/third_party/blink/web_tests/resources/gesture-util.js index 51a5382..7f0c68c 100644 --- a/third_party/blink/web_tests/resources/gesture-util.js +++ b/third_party/blink/web_tests/resources/gesture-util.js
@@ -186,6 +186,8 @@ }); } +const LEGACY_MOUSE_WHEEL_TICK_MULTIPLIER = 120; + // Returns the number of pixels per wheel tick which is a platform specific value. function pixelsPerTick() { // Comes from ui/events/event.cc
diff --git a/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt b/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt index 9fd2acc..be454070 100644 --- a/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt +++ b/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt
@@ -6666,6 +6666,7 @@ getter borderBoxSize getter contentBoxSize getter contentRect + getter devicePixelContentBoxSize getter target method constructor interface ResizeObserverSize
diff --git a/third_party/closure_compiler/externs/developer_private.js b/third_party/closure_compiler/externs/developer_private.js index 4cf5d6e3..74d9584 100644 --- a/third_party/closure_compiler/externs/developer_private.js +++ b/third_party/closure_compiler/externs/developer_private.js
@@ -183,8 +183,7 @@ * corruptInstall: boolean, * updateRequired: boolean, * blockedByPolicy: boolean, - * custodianApprovalRequired: boolean, - * blockedMature: boolean + * custodianApprovalRequired: boolean * }} */ chrome.developerPrivate.DisableReasons;
diff --git a/third_party/libaom/BUILD.gn b/third_party/libaom/BUILD.gn index d8b49c5..78dae34 100644 --- a/third_party/libaom/BUILD.gn +++ b/third_party/libaom/BUILD.gn
@@ -75,11 +75,13 @@ sources += aom_dsp_common_asm_ssse3 sources += aom_ports_asm_x86 sources += aom_av1_encoder_asm_sse2 - sources += aom_av1_encoder_asm_ssse3_x86_64 sources += aom_dsp_encoder_asm_sse2 - sources += aom_dsp_encoder_asm_sse2_x86_64 - sources += aom_dsp_encoder_asm_ssse3_x86_64 - sources += aom_dsp_encoder_avx_asm_x86_64 + if (current_cpu == "x64") { + sources += aom_av1_encoder_asm_ssse3_x86_64 + sources += aom_dsp_encoder_asm_sse2_x86_64 + sources += aom_dsp_encoder_asm_ssse3_x86_64 + sources += aom_dsp_encoder_avx_asm_x86_64 + } defines = [ "CHROMIUM" ] include_dirs = libaom_include_dirs }
diff --git a/third_party/metrics_proto/README.chromium b/third_party/metrics_proto/README.chromium index 44f7273..9013205 100644 --- a/third_party/metrics_proto/README.chromium +++ b/third_party/metrics_proto/README.chromium
@@ -1,8 +1,8 @@ Name: Metrics Protos Short Name: metrics_proto URL: This is the canonical public repository -Version: 298662254 -Date: 2020/03/03 UTC +Version: 300778659 +Date: 2020/03/13 UTC License: BSD Security Critical: Yes
diff --git a/third_party/metrics_proto/cast_logs.proto b/third_party/metrics_proto/cast_logs.proto index 46322be..2d5ee01 100644 --- a/third_party/metrics_proto/cast_logs.proto +++ b/third_party/metrics_proto/cast_logs.proto
@@ -241,7 +241,7 @@ optional fixed32 virtual_release_track = 4; // Cast specific device information which is expected to change over time. - // Next tag: 9 + // Next tag: 10 message CastDeviceMutableInfo { // This is the last type of reboot the device encountered // Next tag: 14 @@ -294,6 +294,9 @@ optional string timezone_id = 7; // Optional value to log latest ui version. optional string latest_ui_version = 8; + + // Station ID of the device if connected to Google WiFi network + optional string google_wifi_station_shmac = 9; } // The device sends this information at least once per day. optional CastDeviceMutableInfo cast_device_mutable_info = 5;
diff --git a/third_party/metrics_proto/extension_install.proto b/third_party/metrics_proto/extension_install.proto index d12005c2..5471e9cb 100644 --- a/third_party/metrics_proto/extension_install.proto +++ b/third_party/metrics_proto/extension_install.proto
@@ -139,8 +139,9 @@ // approval for a supervised user. BLOCKED_BY_POLICY = 13; // The extension is disabled because it's blocked // by enterprise policy. - BLOCKED_MATURE = 14; // The extension is disabled because it's blocked - // due to mature content for supervised users. + // Deprecated: The extension is disabled because it's blocked due to mature + // content for supervised users. + DEPRECATED_BLOCKED_MATURE = 14; } // Any DisableReasons in effect for the extension. An empty list means the // extension is not disabled. Note that an extension that is not disabled may
diff --git a/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl.h b/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl.h index 4a508a13b..51bb7a9 100644 --- a/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl.h +++ b/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl.h
@@ -45,6 +45,13 @@ /* Forward Declarations */ +#ifndef __ICompleteStatus_FWD_DEFINED__ +#define __ICompleteStatus_FWD_DEFINED__ +typedef interface ICompleteStatus ICompleteStatus; + +#endif /* __ICompleteStatus_FWD_DEFINED__ */ + + #ifndef __IUpdaterObserver_FWD_DEFINED__ #define __IUpdaterObserver_FWD_DEFINED__ typedef interface IUpdaterObserver IUpdaterObserver; @@ -99,6 +106,96 @@ #endif +#ifndef __ICompleteStatus_INTERFACE_DEFINED__ +#define __ICompleteStatus_INTERFACE_DEFINED__ + +/* interface ICompleteStatus */ +/* [unique][helpstring][uuid][dual][object] */ + + +EXTERN_C const IID IID_ICompleteStatus; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("2FCD14AF-B645-4351-8359-E80A0E202A0B") + ICompleteStatus : public IUnknown + { + public: + virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_statusCode( + /* [retval][out] */ LONG *__MIDL__ICompleteStatus0000) = 0; + + virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_statusMessage( + /* [retval][out] */ BSTR *__MIDL__ICompleteStatus0001) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ICompleteStatusVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ICompleteStatus * This, + /* [in] */ REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ICompleteStatus * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ICompleteStatus * This); + + /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_statusCode )( + ICompleteStatus * This, + /* [retval][out] */ LONG *__MIDL__ICompleteStatus0000); + + /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_statusMessage )( + ICompleteStatus * This, + /* [retval][out] */ BSTR *__MIDL__ICompleteStatus0001); + + END_INTERFACE + } ICompleteStatusVtbl; + + interface ICompleteStatus + { + CONST_VTBL struct ICompleteStatusVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ICompleteStatus_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ICompleteStatus_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ICompleteStatus_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ICompleteStatus_get_statusCode(This,__MIDL__ICompleteStatus0000) \ + ( (This)->lpVtbl -> get_statusCode(This,__MIDL__ICompleteStatus0000) ) + +#define ICompleteStatus_get_statusMessage(This,__MIDL__ICompleteStatus0001) \ + ( (This)->lpVtbl -> get_statusMessage(This,__MIDL__ICompleteStatus0001) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ICompleteStatus_INTERFACE_DEFINED__ */ + + #ifndef __IUpdaterObserver_INTERFACE_DEFINED__ #define __IUpdaterObserver_INTERFACE_DEFINED__ @@ -115,7 +212,7 @@ { public: virtual HRESULT STDMETHODCALLTYPE OnComplete( - /* [in] */ int error_code) = 0; + /* [in] */ ICompleteStatus *status) = 0; }; @@ -140,7 +237,7 @@ HRESULT ( STDMETHODCALLTYPE *OnComplete )( IUpdaterObserver * This, - /* [in] */ int error_code); + /* [in] */ ICompleteStatus *status); END_INTERFACE } IUpdaterObserverVtbl; @@ -165,8 +262,8 @@ ( (This)->lpVtbl -> Release(This) ) -#define IUpdaterObserver_OnComplete(This,error_code) \ - ( (This)->lpVtbl -> OnComplete(This,error_code) ) +#define IUpdaterObserver_OnComplete(This,status) \ + ( (This)->lpVtbl -> OnComplete(This,status) ) #endif /* COBJMACROS */ @@ -327,6 +424,11 @@ /* Additional Prototypes for ALL interfaces */ +unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * ); +unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * ); +unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * ); +void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * ); + /* end of Additional Prototypes */ #ifdef __cplusplus
diff --git a/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl.tlb b/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl.tlb index 1cd50e4c..78f403b 100644 --- a/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl.tlb +++ b/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl.tlb Binary files differ
diff --git a/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl_i.c b/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl_i.c index 071d651c..69a3ab8 100644 --- a/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl_i.c +++ b/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl_i.c
@@ -67,6 +67,9 @@ #endif // !_MIDL_USE_GUIDDEF_ +MIDL_DEFINE_GUID(IID, IID_ICompleteStatus,0x2FCD14AF,0xB645,0x4351,0x83,0x59,0xE8,0x0A,0x0E,0x20,0x2A,0x0B); + + MIDL_DEFINE_GUID(IID, IID_IUpdaterObserver,0x7B416CFD,0x4216,0x4FD6,0xBD,0x83,0x7C,0x58,0x60,0x54,0x67,0x6E);
diff --git a/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl_p.c b/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl_p.c index 170e434..1a11a84 100644 --- a/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl_p.c +++ b/third_party/win_build_output/midl/chrome/updater/server/win/arm64/updater_idl_p.c
@@ -46,11 +46,11 @@ #include "updater_idl.h" -#define TYPE_FORMAT_STRING_SIZE 25 -#define PROC_FORMAT_STRING_SIZE 239 +#define TYPE_FORMAT_STRING_SIZE 87 +#define PROC_FORMAT_STRING_SIZE 323 #define EXPR_FORMAT_STRING_SIZE 1 #define TRANSMIT_AS_TABLE_SIZE 0 -#define WIRE_MARSHAL_TABLE_SIZE 0 +#define WIRE_MARSHAL_TABLE_SIZE 1 typedef struct _updater_idl_MIDL_TYPE_FORMAT_STRING { @@ -83,6 +83,13 @@ extern const MIDL_STUB_DESC Object_StubDesc; +extern const MIDL_SERVER_INFO ICompleteStatus_ServerInfo; +extern const MIDL_STUBLESS_PROXY_INFO ICompleteStatus_ProxyInfo; + + +extern const MIDL_STUB_DESC Object_StubDesc; + + extern const MIDL_SERVER_INFO IUpdaterObserver_ServerInfo; extern const MIDL_STUBLESS_PROXY_INFO IUpdaterObserver_ProxyInfo; @@ -94,6 +101,7 @@ extern const MIDL_STUBLESS_PROXY_INFO IUpdater_ProxyInfo; +extern const USER_MARSHAL_ROUTINE_QUADRUPLE UserMarshalRoutines[ WIRE_MARSHAL_TABLE_SIZE ]; #if !defined(__RPC_ARM64__) #error Invalid build platform for this stub. @@ -104,15 +112,15 @@ 0, { - /* Procedure OnComplete */ + /* Procedure get_statusCode */ 0x33, /* FC_AUTO_HANDLE */ 0x6c, /* Old Flags: object, Oi2 */ /* 2 */ NdrFcLong( 0x0 ), /* 0 */ /* 6 */ NdrFcShort( 0x3 ), /* 3 */ /* 8 */ NdrFcShort( 0x18 ), /* ARM64 Stack size/offset = 24 */ -/* 10 */ NdrFcShort( 0x8 ), /* 8 */ -/* 12 */ NdrFcShort( 0x8 ), /* 8 */ +/* 10 */ NdrFcShort( 0x0 ), /* 0 */ +/* 12 */ NdrFcShort( 0x24 ), /* 36 */ /* 14 */ 0x44, /* Oi2 Flags: has return, has ext, */ 0x2, /* 2 */ /* 16 */ 0xe, /* 14 */ @@ -126,9 +134,9 @@ /* 28 */ 0x81, /* 129 */ 0x0, /* 0 */ - /* Parameter error_code */ + /* Parameter __MIDL__ICompleteStatus0000 */ -/* 30 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 30 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */ /* 32 */ NdrFcShort( 0x8 ), /* ARM64 Stack size/offset = 8 */ /* 34 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ @@ -140,20 +148,20 @@ /* 40 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ - /* Procedure CheckForUpdate */ + /* Procedure get_statusMessage */ /* 42 */ 0x33, /* FC_AUTO_HANDLE */ 0x6c, /* Old Flags: object, Oi2 */ /* 44 */ NdrFcLong( 0x0 ), /* 0 */ -/* 48 */ NdrFcShort( 0x3 ), /* 3 */ +/* 48 */ NdrFcShort( 0x4 ), /* 4 */ /* 50 */ NdrFcShort( 0x18 ), /* ARM64 Stack size/offset = 24 */ /* 52 */ NdrFcShort( 0x0 ), /* 0 */ /* 54 */ NdrFcShort( 0x8 ), /* 8 */ -/* 56 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ +/* 56 */ 0x45, /* Oi2 Flags: srv must size, has return, has ext, */ 0x2, /* 2 */ /* 58 */ 0xe, /* 14 */ - 0x1, /* Ext Flags: new corr desc, */ -/* 60 */ NdrFcShort( 0x0 ), /* 0 */ + 0x3, /* Ext Flags: new corr desc, clt corr check, */ +/* 60 */ NdrFcShort( 0x1 ), /* 1 */ /* 62 */ NdrFcShort( 0x0 ), /* 0 */ /* 64 */ NdrFcShort( 0x0 ), /* 0 */ /* 66 */ NdrFcShort( 0x2 ), /* 2 */ @@ -162,11 +170,11 @@ /* 70 */ 0x81, /* 129 */ 0x0, /* 0 */ - /* Parameter app_id */ + /* Parameter __MIDL__ICompleteStatus0001 */ -/* 72 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 72 */ NdrFcShort( 0x2113 ), /* Flags: must size, must free, out, simple ref, srv alloc size=8 */ /* 74 */ NdrFcShort( 0x8 ), /* ARM64 Stack size/offset = 8 */ -/* 76 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ +/* 76 */ NdrFcShort( 0x24 ), /* Type Offset=36 */ /* Return value */ @@ -175,139 +183,209 @@ /* 82 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ - /* Procedure Register */ + /* Procedure OnComplete */ /* 84 */ 0x33, /* FC_AUTO_HANDLE */ 0x6c, /* Old Flags: object, Oi2 */ /* 86 */ NdrFcLong( 0x0 ), /* 0 */ -/* 90 */ NdrFcShort( 0x4 ), /* 4 */ -/* 92 */ NdrFcShort( 0x38 ), /* ARM64 Stack size/offset = 56 */ +/* 90 */ NdrFcShort( 0x3 ), /* 3 */ +/* 92 */ NdrFcShort( 0x18 ), /* ARM64 Stack size/offset = 24 */ /* 94 */ NdrFcShort( 0x0 ), /* 0 */ /* 96 */ NdrFcShort( 0x8 ), /* 8 */ /* 98 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ - 0x6, /* 6 */ -/* 100 */ 0x12, /* 18 */ + 0x2, /* 2 */ +/* 100 */ 0xe, /* 14 */ 0x1, /* Ext Flags: new corr desc, */ /* 102 */ NdrFcShort( 0x0 ), /* 0 */ /* 104 */ NdrFcShort( 0x0 ), /* 0 */ /* 106 */ NdrFcShort( 0x0 ), /* 0 */ -/* 108 */ NdrFcShort( 0x6 ), /* 6 */ -/* 110 */ 0x6, /* 6 */ +/* 108 */ NdrFcShort( 0x2 ), /* 2 */ +/* 110 */ 0x2, /* 2 */ 0x80, /* 128 */ /* 112 */ 0x81, /* 129 */ - 0x82, /* 130 */ -/* 114 */ 0x83, /* 131 */ - 0x84, /* 132 */ -/* 116 */ 0x85, /* 133 */ + 0x0, /* 0 */ + + /* Parameter status */ + +/* 114 */ NdrFcShort( 0xb ), /* Flags: must size, must free, in, */ +/* 116 */ NdrFcShort( 0x8 ), /* ARM64 Stack size/offset = 8 */ +/* 118 */ NdrFcShort( 0x2e ), /* Type Offset=46 */ + + /* Return value */ + +/* 120 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 122 */ NdrFcShort( 0x10 ), /* ARM64 Stack size/offset = 16 */ +/* 124 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Procedure CheckForUpdate */ + +/* 126 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 128 */ NdrFcLong( 0x0 ), /* 0 */ +/* 132 */ NdrFcShort( 0x3 ), /* 3 */ +/* 134 */ NdrFcShort( 0x18 ), /* ARM64 Stack size/offset = 24 */ +/* 136 */ NdrFcShort( 0x0 ), /* 0 */ +/* 138 */ NdrFcShort( 0x8 ), /* 8 */ +/* 140 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x2, /* 2 */ +/* 142 */ 0xe, /* 14 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 144 */ NdrFcShort( 0x0 ), /* 0 */ +/* 146 */ NdrFcShort( 0x0 ), /* 0 */ +/* 148 */ NdrFcShort( 0x0 ), /* 0 */ +/* 150 */ NdrFcShort( 0x2 ), /* 2 */ +/* 152 */ 0x2, /* 2 */ + 0x80, /* 128 */ +/* 154 */ 0x81, /* 129 */ 0x0, /* 0 */ /* Parameter app_id */ -/* 118 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 120 */ NdrFcShort( 0x8 ), /* ARM64 Stack size/offset = 8 */ -/* 122 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ +/* 156 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 158 */ NdrFcShort( 0x8 ), /* ARM64 Stack size/offset = 8 */ +/* 160 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ + + /* Return value */ + +/* 162 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 164 */ NdrFcShort( 0x10 ), /* ARM64 Stack size/offset = 16 */ +/* 166 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Procedure Register */ + +/* 168 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 170 */ NdrFcLong( 0x0 ), /* 0 */ +/* 174 */ NdrFcShort( 0x4 ), /* 4 */ +/* 176 */ NdrFcShort( 0x38 ), /* ARM64 Stack size/offset = 56 */ +/* 178 */ NdrFcShort( 0x0 ), /* 0 */ +/* 180 */ NdrFcShort( 0x8 ), /* 8 */ +/* 182 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x6, /* 6 */ +/* 184 */ 0x12, /* 18 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 186 */ NdrFcShort( 0x0 ), /* 0 */ +/* 188 */ NdrFcShort( 0x0 ), /* 0 */ +/* 190 */ NdrFcShort( 0x0 ), /* 0 */ +/* 192 */ NdrFcShort( 0x6 ), /* 6 */ +/* 194 */ 0x6, /* 6 */ + 0x80, /* 128 */ +/* 196 */ 0x81, /* 129 */ + 0x82, /* 130 */ +/* 198 */ 0x83, /* 131 */ + 0x84, /* 132 */ +/* 200 */ 0x85, /* 133 */ + 0x0, /* 0 */ + + /* Parameter app_id */ + +/* 202 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 204 */ NdrFcShort( 0x8 ), /* ARM64 Stack size/offset = 8 */ +/* 206 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ /* Parameter brand_code */ -/* 124 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 126 */ NdrFcShort( 0x10 ), /* ARM64 Stack size/offset = 16 */ -/* 128 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ +/* 208 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 210 */ NdrFcShort( 0x10 ), /* ARM64 Stack size/offset = 16 */ +/* 212 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ /* Parameter tag */ -/* 130 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 132 */ NdrFcShort( 0x18 ), /* ARM64 Stack size/offset = 24 */ -/* 134 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ +/* 214 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 216 */ NdrFcShort( 0x18 ), /* ARM64 Stack size/offset = 24 */ +/* 218 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ /* Parameter version */ -/* 136 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 138 */ NdrFcShort( 0x20 ), /* ARM64 Stack size/offset = 32 */ -/* 140 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ +/* 220 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 222 */ NdrFcShort( 0x20 ), /* ARM64 Stack size/offset = 32 */ +/* 224 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ /* Parameter existence_checker_path */ -/* 142 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 144 */ NdrFcShort( 0x28 ), /* ARM64 Stack size/offset = 40 */ -/* 146 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ - - /* Return value */ - -/* 148 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ -/* 150 */ NdrFcShort( 0x30 ), /* ARM64 Stack size/offset = 48 */ -/* 152 */ 0x8, /* FC_LONG */ - 0x0, /* 0 */ - - /* Procedure Update */ - -/* 154 */ 0x33, /* FC_AUTO_HANDLE */ - 0x6c, /* Old Flags: object, Oi2 */ -/* 156 */ NdrFcLong( 0x0 ), /* 0 */ -/* 160 */ NdrFcShort( 0x5 ), /* 5 */ -/* 162 */ NdrFcShort( 0x18 ), /* ARM64 Stack size/offset = 24 */ -/* 164 */ NdrFcShort( 0x0 ), /* 0 */ -/* 166 */ NdrFcShort( 0x8 ), /* 8 */ -/* 168 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ - 0x2, /* 2 */ -/* 170 */ 0xe, /* 14 */ - 0x1, /* Ext Flags: new corr desc, */ -/* 172 */ NdrFcShort( 0x0 ), /* 0 */ -/* 174 */ NdrFcShort( 0x0 ), /* 0 */ -/* 176 */ NdrFcShort( 0x0 ), /* 0 */ -/* 178 */ NdrFcShort( 0x2 ), /* 2 */ -/* 180 */ 0x2, /* 2 */ - 0x80, /* 128 */ -/* 182 */ 0x81, /* 129 */ - 0x0, /* 0 */ - - /* Parameter app_id */ - -/* 184 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 186 */ NdrFcShort( 0x8 ), /* ARM64 Stack size/offset = 8 */ -/* 188 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ - - /* Return value */ - -/* 190 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ -/* 192 */ NdrFcShort( 0x10 ), /* ARM64 Stack size/offset = 16 */ -/* 194 */ 0x8, /* FC_LONG */ - 0x0, /* 0 */ - - /* Procedure UpdateAll */ - -/* 196 */ 0x33, /* FC_AUTO_HANDLE */ - 0x6c, /* Old Flags: object, Oi2 */ -/* 198 */ NdrFcLong( 0x0 ), /* 0 */ -/* 202 */ NdrFcShort( 0x6 ), /* 6 */ -/* 204 */ NdrFcShort( 0x18 ), /* ARM64 Stack size/offset = 24 */ -/* 206 */ NdrFcShort( 0x0 ), /* 0 */ -/* 208 */ NdrFcShort( 0x8 ), /* 8 */ -/* 210 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ - 0x2, /* 2 */ -/* 212 */ 0xe, /* 14 */ - 0x1, /* Ext Flags: new corr desc, */ -/* 214 */ NdrFcShort( 0x0 ), /* 0 */ -/* 216 */ NdrFcShort( 0x0 ), /* 0 */ -/* 218 */ NdrFcShort( 0x0 ), /* 0 */ -/* 220 */ NdrFcShort( 0x2 ), /* 2 */ -/* 222 */ 0x2, /* 2 */ - 0x80, /* 128 */ -/* 224 */ 0x81, /* 129 */ - 0x0, /* 0 */ - - /* Parameter observer */ - -/* 226 */ NdrFcShort( 0xb ), /* Flags: must size, must free, in, */ -/* 228 */ NdrFcShort( 0x8 ), /* ARM64 Stack size/offset = 8 */ -/* 230 */ NdrFcShort( 0x6 ), /* Type Offset=6 */ +/* 226 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 228 */ NdrFcShort( 0x28 ), /* ARM64 Stack size/offset = 40 */ +/* 230 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ /* Return value */ /* 232 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ -/* 234 */ NdrFcShort( 0x10 ), /* ARM64 Stack size/offset = 16 */ +/* 234 */ NdrFcShort( 0x30 ), /* ARM64 Stack size/offset = 48 */ /* 236 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ + /* Procedure Update */ + +/* 238 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 240 */ NdrFcLong( 0x0 ), /* 0 */ +/* 244 */ NdrFcShort( 0x5 ), /* 5 */ +/* 246 */ NdrFcShort( 0x18 ), /* ARM64 Stack size/offset = 24 */ +/* 248 */ NdrFcShort( 0x0 ), /* 0 */ +/* 250 */ NdrFcShort( 0x8 ), /* 8 */ +/* 252 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x2, /* 2 */ +/* 254 */ 0xe, /* 14 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 256 */ NdrFcShort( 0x0 ), /* 0 */ +/* 258 */ NdrFcShort( 0x0 ), /* 0 */ +/* 260 */ NdrFcShort( 0x0 ), /* 0 */ +/* 262 */ NdrFcShort( 0x2 ), /* 2 */ +/* 264 */ 0x2, /* 2 */ + 0x80, /* 128 */ +/* 266 */ 0x81, /* 129 */ + 0x0, /* 0 */ + + /* Parameter app_id */ + +/* 268 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 270 */ NdrFcShort( 0x8 ), /* ARM64 Stack size/offset = 8 */ +/* 272 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ + + /* Return value */ + +/* 274 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 276 */ NdrFcShort( 0x10 ), /* ARM64 Stack size/offset = 16 */ +/* 278 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Procedure UpdateAll */ + +/* 280 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 282 */ NdrFcLong( 0x0 ), /* 0 */ +/* 286 */ NdrFcShort( 0x6 ), /* 6 */ +/* 288 */ NdrFcShort( 0x18 ), /* ARM64 Stack size/offset = 24 */ +/* 290 */ NdrFcShort( 0x0 ), /* 0 */ +/* 292 */ NdrFcShort( 0x8 ), /* 8 */ +/* 294 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x2, /* 2 */ +/* 296 */ 0xe, /* 14 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 298 */ NdrFcShort( 0x0 ), /* 0 */ +/* 300 */ NdrFcShort( 0x0 ), /* 0 */ +/* 302 */ NdrFcShort( 0x0 ), /* 0 */ +/* 304 */ NdrFcShort( 0x2 ), /* 2 */ +/* 306 */ 0x2, /* 2 */ + 0x80, /* 128 */ +/* 308 */ 0x81, /* 129 */ + 0x0, /* 0 */ + + /* Parameter observer */ + +/* 310 */ NdrFcShort( 0xb ), /* Flags: must size, must free, in, */ +/* 312 */ NdrFcShort( 0x8 ), /* ARM64 Stack size/offset = 8 */ +/* 314 */ NdrFcShort( 0x44 ), /* Type Offset=68 */ + + /* Return value */ + +/* 316 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 318 */ NdrFcShort( 0x10 ), /* ARM64 Stack size/offset = 16 */ +/* 320 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + 0x0 } }; @@ -318,41 +396,155 @@ { NdrFcShort( 0x0 ), /* 0 */ /* 2 */ - 0x11, 0x8, /* FC_RP [simple_pointer] */ -/* 4 */ - 0x25, /* FC_C_WSTRING */ + 0x11, 0xc, /* FC_RP [alloced_on_stack] [simple_pointer] */ +/* 4 */ 0x8, /* FC_LONG */ 0x5c, /* FC_PAD */ /* 6 */ + 0x11, 0x4, /* FC_RP [alloced_on_stack] */ +/* 8 */ NdrFcShort( 0x1c ), /* Offset= 28 (36) */ +/* 10 */ + 0x13, 0x0, /* FC_OP */ +/* 12 */ NdrFcShort( 0xe ), /* Offset= 14 (26) */ +/* 14 */ + 0x1b, /* FC_CARRAY */ + 0x1, /* 1 */ +/* 16 */ NdrFcShort( 0x2 ), /* 2 */ +/* 18 */ 0x9, /* Corr desc: FC_ULONG */ + 0x0, /* */ +/* 20 */ NdrFcShort( 0xfffc ), /* -4 */ +/* 22 */ NdrFcShort( 0x1 ), /* Corr flags: early, */ +/* 24 */ 0x6, /* FC_SHORT */ + 0x5b, /* FC_END */ +/* 26 */ + 0x17, /* FC_CSTRUCT */ + 0x3, /* 3 */ +/* 28 */ NdrFcShort( 0x8 ), /* 8 */ +/* 30 */ NdrFcShort( 0xfff0 ), /* Offset= -16 (14) */ +/* 32 */ 0x8, /* FC_LONG */ + 0x8, /* FC_LONG */ +/* 34 */ 0x5c, /* FC_PAD */ + 0x5b, /* FC_END */ +/* 36 */ 0xb4, /* FC_USER_MARSHAL */ + 0x83, /* 131 */ +/* 38 */ NdrFcShort( 0x0 ), /* 0 */ +/* 40 */ NdrFcShort( 0x8 ), /* 8 */ +/* 42 */ NdrFcShort( 0x0 ), /* 0 */ +/* 44 */ NdrFcShort( 0xffde ), /* Offset= -34 (10) */ +/* 46 */ 0x2f, /* FC_IP */ 0x5a, /* FC_CONSTANT_IID */ -/* 8 */ NdrFcLong( 0x7b416cfd ), /* 2067885309 */ -/* 12 */ NdrFcShort( 0x4216 ), /* 16918 */ -/* 14 */ NdrFcShort( 0x4fd6 ), /* 20438 */ -/* 16 */ 0xbd, /* 189 */ +/* 48 */ NdrFcLong( 0x2fcd14af ), /* 801969327 */ +/* 52 */ NdrFcShort( 0xb645 ), /* -18875 */ +/* 54 */ NdrFcShort( 0x4351 ), /* 17233 */ +/* 56 */ 0x83, /* 131 */ + 0x59, /* 89 */ +/* 58 */ 0xe8, /* 232 */ + 0xa, /* 10 */ +/* 60 */ 0xe, /* 14 */ + 0x20, /* 32 */ +/* 62 */ 0x2a, /* 42 */ + 0xb, /* 11 */ +/* 64 */ + 0x11, 0x8, /* FC_RP [simple_pointer] */ +/* 66 */ + 0x25, /* FC_C_WSTRING */ + 0x5c, /* FC_PAD */ +/* 68 */ + 0x2f, /* FC_IP */ + 0x5a, /* FC_CONSTANT_IID */ +/* 70 */ NdrFcLong( 0x7b416cfd ), /* 2067885309 */ +/* 74 */ NdrFcShort( 0x4216 ), /* 16918 */ +/* 76 */ NdrFcShort( 0x4fd6 ), /* 20438 */ +/* 78 */ 0xbd, /* 189 */ 0x83, /* 131 */ -/* 18 */ 0x7c, /* 124 */ +/* 80 */ 0x7c, /* 124 */ 0x58, /* 88 */ -/* 20 */ 0x60, /* 96 */ +/* 82 */ 0x60, /* 96 */ 0x54, /* 84 */ -/* 22 */ 0x67, /* 103 */ +/* 84 */ 0x67, /* 103 */ 0x6e, /* 110 */ 0x0 } }; +static const USER_MARSHAL_ROUTINE_QUADRUPLE UserMarshalRoutines[ WIRE_MARSHAL_TABLE_SIZE ] = + { + + { + BSTR_UserSize + ,BSTR_UserMarshal + ,BSTR_UserUnmarshal + ,BSTR_UserFree + } + + }; + + /* Object interface: IUnknown, ver. 0.0, GUID={0x00000000,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */ +/* Object interface: ICompleteStatus, ver. 0.0, + GUID={0x2FCD14AF,0xB645,0x4351,{0x83,0x59,0xE8,0x0A,0x0E,0x20,0x2A,0x0B}} */ + +#pragma code_seg(".orpc") +static const unsigned short ICompleteStatus_FormatStringOffsetTable[] = + { + 0, + 42 + }; + +static const MIDL_STUBLESS_PROXY_INFO ICompleteStatus_ProxyInfo = + { + &Object_StubDesc, + updater_idl__MIDL_ProcFormatString.Format, + &ICompleteStatus_FormatStringOffsetTable[-3], + 0, + 0, + 0 + }; + + +static const MIDL_SERVER_INFO ICompleteStatus_ServerInfo = + { + &Object_StubDesc, + 0, + updater_idl__MIDL_ProcFormatString.Format, + &ICompleteStatus_FormatStringOffsetTable[-3], + 0, + 0, + 0, + 0}; +CINTERFACE_PROXY_VTABLE(5) _ICompleteStatusProxyVtbl = +{ + &ICompleteStatus_ProxyInfo, + &IID_ICompleteStatus, + IUnknown_QueryInterface_Proxy, + IUnknown_AddRef_Proxy, + IUnknown_Release_Proxy , + (void *) (INT_PTR) -1 /* ICompleteStatus::get_statusCode */ , + (void *) (INT_PTR) -1 /* ICompleteStatus::get_statusMessage */ +}; + +const CInterfaceStubVtbl _ICompleteStatusStubVtbl = +{ + &IID_ICompleteStatus, + &ICompleteStatus_ServerInfo, + 5, + 0, /* pure interpreted */ + CStdStubBuffer_METHODS +}; + + /* Object interface: IUpdaterObserver, ver. 0.0, GUID={0x7B416CFD,0x4216,0x4FD6,{0xBD,0x83,0x7C,0x58,0x60,0x54,0x67,0x6E}} */ #pragma code_seg(".orpc") static const unsigned short IUpdaterObserver_FormatStringOffsetTable[] = { - 0 + 84 }; static const MIDL_STUBLESS_PROXY_INFO IUpdaterObserver_ProxyInfo = @@ -402,10 +594,10 @@ #pragma code_seg(".orpc") static const unsigned short IUpdater_FormatStringOffsetTable[] = { - 42, - 84, - 154, - 196 + 126, + 168, + 238, + 280 }; static const MIDL_STUBLESS_PROXY_INFO IUpdater_ProxyInfo = @@ -467,7 +659,7 @@ 0, 0x801026e, /* MIDL Version 8.1.622 */ 0, - 0, + UserMarshalRoutines, 0, /* notify & notify_flag routine table */ 0x1, /* MIDL flag */ 0, /* cs routines */ @@ -477,6 +669,7 @@ const CInterfaceProxyVtbl * const _updater_idl_ProxyVtblList[] = { + ( CInterfaceProxyVtbl *) &_ICompleteStatusProxyVtbl, ( CInterfaceProxyVtbl *) &_IUpdaterProxyVtbl, ( CInterfaceProxyVtbl *) &_IUpdaterObserverProxyVtbl, 0 @@ -484,6 +677,7 @@ const CInterfaceStubVtbl * const _updater_idl_StubVtblList[] = { + ( CInterfaceStubVtbl *) &_ICompleteStatusStubVtbl, ( CInterfaceStubVtbl *) &_IUpdaterStubVtbl, ( CInterfaceStubVtbl *) &_IUpdaterObserverStubVtbl, 0 @@ -491,6 +685,7 @@ PCInterfaceName const _updater_idl_InterfaceNamesList[] = { + "ICompleteStatus", "IUpdater", "IUpdaterObserver", 0 @@ -503,8 +698,9 @@ { IID_BS_LOOKUP_SETUP - IID_BS_LOOKUP_INITIAL_TEST( _updater_idl, 2, 1 ) - IID_BS_LOOKUP_RETURN_RESULT( _updater_idl, 2, *pIndex ) + IID_BS_LOOKUP_INITIAL_TEST( _updater_idl, 3, 2 ) + IID_BS_LOOKUP_NEXT_TEST( _updater_idl, 1 ) + IID_BS_LOOKUP_RETURN_RESULT( _updater_idl, 3, *pIndex ) } @@ -515,7 +711,7 @@ (const PCInterfaceName * ) & _updater_idl_InterfaceNamesList, 0, /* no delegation */ & _updater_idl_IID_Lookup, - 2, + 3, 2, 0, /* table of [async_uuid] interfaces */ 0, /* Filler1 */
diff --git a/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl.h b/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl.h index 8b5a4de..ce2a56b 100644 --- a/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl.h +++ b/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl.h
@@ -45,6 +45,13 @@ /* Forward Declarations */ +#ifndef __ICompleteStatus_FWD_DEFINED__ +#define __ICompleteStatus_FWD_DEFINED__ +typedef interface ICompleteStatus ICompleteStatus; + +#endif /* __ICompleteStatus_FWD_DEFINED__ */ + + #ifndef __IUpdaterObserver_FWD_DEFINED__ #define __IUpdaterObserver_FWD_DEFINED__ typedef interface IUpdaterObserver IUpdaterObserver; @@ -99,6 +106,96 @@ #endif +#ifndef __ICompleteStatus_INTERFACE_DEFINED__ +#define __ICompleteStatus_INTERFACE_DEFINED__ + +/* interface ICompleteStatus */ +/* [unique][helpstring][uuid][dual][object] */ + + +EXTERN_C const IID IID_ICompleteStatus; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("2FCD14AF-B645-4351-8359-E80A0E202A0B") + ICompleteStatus : public IUnknown + { + public: + virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_statusCode( + /* [retval][out] */ LONG *__MIDL__ICompleteStatus0000) = 0; + + virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_statusMessage( + /* [retval][out] */ BSTR *__MIDL__ICompleteStatus0001) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ICompleteStatusVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ICompleteStatus * This, + /* [in] */ REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ICompleteStatus * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ICompleteStatus * This); + + /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_statusCode )( + ICompleteStatus * This, + /* [retval][out] */ LONG *__MIDL__ICompleteStatus0000); + + /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_statusMessage )( + ICompleteStatus * This, + /* [retval][out] */ BSTR *__MIDL__ICompleteStatus0001); + + END_INTERFACE + } ICompleteStatusVtbl; + + interface ICompleteStatus + { + CONST_VTBL struct ICompleteStatusVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ICompleteStatus_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ICompleteStatus_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ICompleteStatus_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ICompleteStatus_get_statusCode(This,__MIDL__ICompleteStatus0000) \ + ( (This)->lpVtbl -> get_statusCode(This,__MIDL__ICompleteStatus0000) ) + +#define ICompleteStatus_get_statusMessage(This,__MIDL__ICompleteStatus0001) \ + ( (This)->lpVtbl -> get_statusMessage(This,__MIDL__ICompleteStatus0001) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ICompleteStatus_INTERFACE_DEFINED__ */ + + #ifndef __IUpdaterObserver_INTERFACE_DEFINED__ #define __IUpdaterObserver_INTERFACE_DEFINED__ @@ -115,7 +212,7 @@ { public: virtual HRESULT STDMETHODCALLTYPE OnComplete( - /* [in] */ int error_code) = 0; + /* [in] */ ICompleteStatus *status) = 0; }; @@ -140,7 +237,7 @@ HRESULT ( STDMETHODCALLTYPE *OnComplete )( IUpdaterObserver * This, - /* [in] */ int error_code); + /* [in] */ ICompleteStatus *status); END_INTERFACE } IUpdaterObserverVtbl; @@ -165,8 +262,8 @@ ( (This)->lpVtbl -> Release(This) ) -#define IUpdaterObserver_OnComplete(This,error_code) \ - ( (This)->lpVtbl -> OnComplete(This,error_code) ) +#define IUpdaterObserver_OnComplete(This,status) \ + ( (This)->lpVtbl -> OnComplete(This,status) ) #endif /* COBJMACROS */ @@ -327,6 +424,11 @@ /* Additional Prototypes for ALL interfaces */ +unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * ); +unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * ); +unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * ); +void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * ); + /* end of Additional Prototypes */ #ifdef __cplusplus
diff --git a/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl.tlb b/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl.tlb index 1cd50e4c..78f403b 100644 --- a/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl.tlb +++ b/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl.tlb Binary files differ
diff --git a/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl_i.c b/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl_i.c index 688f671..26ac92f 100644 --- a/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl_i.c +++ b/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl_i.c
@@ -67,6 +67,9 @@ #endif // !_MIDL_USE_GUIDDEF_ +MIDL_DEFINE_GUID(IID, IID_ICompleteStatus,0x2FCD14AF,0xB645,0x4351,0x83,0x59,0xE8,0x0A,0x0E,0x20,0x2A,0x0B); + + MIDL_DEFINE_GUID(IID, IID_IUpdaterObserver,0x7B416CFD,0x4216,0x4FD6,0xBD,0x83,0x7C,0x58,0x60,0x54,0x67,0x6E);
diff --git a/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl_p.c b/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl_p.c index 210a091..264d769 100644 --- a/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl_p.c +++ b/third_party/win_build_output/midl/chrome/updater/server/win/x64/updater_idl_p.c
@@ -46,11 +46,11 @@ #include "updater_idl.h" -#define TYPE_FORMAT_STRING_SIZE 25 -#define PROC_FORMAT_STRING_SIZE 215 +#define TYPE_FORMAT_STRING_SIZE 87 +#define PROC_FORMAT_STRING_SIZE 291 #define EXPR_FORMAT_STRING_SIZE 1 #define TRANSMIT_AS_TABLE_SIZE 0 -#define WIRE_MARSHAL_TABLE_SIZE 0 +#define WIRE_MARSHAL_TABLE_SIZE 1 typedef struct _updater_idl_MIDL_TYPE_FORMAT_STRING { @@ -83,6 +83,13 @@ extern const MIDL_STUB_DESC Object_StubDesc; +extern const MIDL_SERVER_INFO ICompleteStatus_ServerInfo; +extern const MIDL_STUBLESS_PROXY_INFO ICompleteStatus_ProxyInfo; + + +extern const MIDL_STUB_DESC Object_StubDesc; + + extern const MIDL_SERVER_INFO IUpdaterObserver_ServerInfo; extern const MIDL_STUBLESS_PROXY_INFO IUpdaterObserver_ProxyInfo; @@ -94,6 +101,7 @@ extern const MIDL_STUBLESS_PROXY_INFO IUpdater_ProxyInfo; +extern const USER_MARSHAL_ROUTINE_QUADRUPLE UserMarshalRoutines[ WIRE_MARSHAL_TABLE_SIZE ]; #if !defined(__RPC_WIN64__) #error Invalid build platform for this stub. @@ -104,15 +112,15 @@ 0, { - /* Procedure OnComplete */ + /* Procedure get_statusCode */ 0x33, /* FC_AUTO_HANDLE */ 0x6c, /* Old Flags: object, Oi2 */ /* 2 */ NdrFcLong( 0x0 ), /* 0 */ /* 6 */ NdrFcShort( 0x3 ), /* 3 */ /* 8 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */ -/* 10 */ NdrFcShort( 0x8 ), /* 8 */ -/* 12 */ NdrFcShort( 0x8 ), /* 8 */ +/* 10 */ NdrFcShort( 0x0 ), /* 0 */ +/* 12 */ NdrFcShort( 0x24 ), /* 36 */ /* 14 */ 0x44, /* Oi2 Flags: has return, has ext, */ 0x2, /* 2 */ /* 16 */ 0xa, /* 10 */ @@ -122,9 +130,9 @@ /* 22 */ NdrFcShort( 0x0 ), /* 0 */ /* 24 */ NdrFcShort( 0x0 ), /* 0 */ - /* Parameter error_code */ + /* Parameter __MIDL__ICompleteStatus0000 */ -/* 26 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 26 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */ /* 28 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ /* 30 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ @@ -136,29 +144,29 @@ /* 36 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ - /* Procedure CheckForUpdate */ + /* Procedure get_statusMessage */ /* 38 */ 0x33, /* FC_AUTO_HANDLE */ 0x6c, /* Old Flags: object, Oi2 */ /* 40 */ NdrFcLong( 0x0 ), /* 0 */ -/* 44 */ NdrFcShort( 0x3 ), /* 3 */ +/* 44 */ NdrFcShort( 0x4 ), /* 4 */ /* 46 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */ /* 48 */ NdrFcShort( 0x0 ), /* 0 */ /* 50 */ NdrFcShort( 0x8 ), /* 8 */ -/* 52 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ +/* 52 */ 0x45, /* Oi2 Flags: srv must size, has return, has ext, */ 0x2, /* 2 */ /* 54 */ 0xa, /* 10 */ - 0x1, /* Ext Flags: new corr desc, */ -/* 56 */ NdrFcShort( 0x0 ), /* 0 */ + 0x3, /* Ext Flags: new corr desc, clt corr check, */ +/* 56 */ NdrFcShort( 0x1 ), /* 1 */ /* 58 */ NdrFcShort( 0x0 ), /* 0 */ /* 60 */ NdrFcShort( 0x0 ), /* 0 */ /* 62 */ NdrFcShort( 0x0 ), /* 0 */ - /* Parameter app_id */ + /* Parameter __MIDL__ICompleteStatus0001 */ -/* 64 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 64 */ NdrFcShort( 0x2113 ), /* Flags: must size, must free, out, simple ref, srv alloc size=8 */ /* 66 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ -/* 68 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ +/* 68 */ NdrFcShort( 0x24 ), /* Type Offset=36 */ /* Return value */ @@ -167,17 +175,17 @@ /* 74 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ - /* Procedure Register */ + /* Procedure OnComplete */ /* 76 */ 0x33, /* FC_AUTO_HANDLE */ 0x6c, /* Old Flags: object, Oi2 */ /* 78 */ NdrFcLong( 0x0 ), /* 0 */ -/* 82 */ NdrFcShort( 0x4 ), /* 4 */ -/* 84 */ NdrFcShort( 0x38 ), /* X64 Stack size/offset = 56 */ +/* 82 */ NdrFcShort( 0x3 ), /* 3 */ +/* 84 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */ /* 86 */ NdrFcShort( 0x0 ), /* 0 */ /* 88 */ NdrFcShort( 0x8 ), /* 8 */ /* 90 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ - 0x6, /* 6 */ + 0x2, /* 2 */ /* 92 */ 0xa, /* 10 */ 0x1, /* Ext Flags: new corr desc, */ /* 94 */ NdrFcShort( 0x0 ), /* 0 */ @@ -185,105 +193,167 @@ /* 98 */ NdrFcShort( 0x0 ), /* 0 */ /* 100 */ NdrFcShort( 0x0 ), /* 0 */ + /* Parameter status */ + +/* 102 */ NdrFcShort( 0xb ), /* Flags: must size, must free, in, */ +/* 104 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 106 */ NdrFcShort( 0x2e ), /* Type Offset=46 */ + + /* Return value */ + +/* 108 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 110 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 112 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Procedure CheckForUpdate */ + +/* 114 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 116 */ NdrFcLong( 0x0 ), /* 0 */ +/* 120 */ NdrFcShort( 0x3 ), /* 3 */ +/* 122 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */ +/* 124 */ NdrFcShort( 0x0 ), /* 0 */ +/* 126 */ NdrFcShort( 0x8 ), /* 8 */ +/* 128 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x2, /* 2 */ +/* 130 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 132 */ NdrFcShort( 0x0 ), /* 0 */ +/* 134 */ NdrFcShort( 0x0 ), /* 0 */ +/* 136 */ NdrFcShort( 0x0 ), /* 0 */ +/* 138 */ NdrFcShort( 0x0 ), /* 0 */ + /* Parameter app_id */ -/* 102 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 104 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ -/* 106 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ +/* 140 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 142 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 144 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ + + /* Return value */ + +/* 146 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 148 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 150 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Procedure Register */ + +/* 152 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 154 */ NdrFcLong( 0x0 ), /* 0 */ +/* 158 */ NdrFcShort( 0x4 ), /* 4 */ +/* 160 */ NdrFcShort( 0x38 ), /* X64 Stack size/offset = 56 */ +/* 162 */ NdrFcShort( 0x0 ), /* 0 */ +/* 164 */ NdrFcShort( 0x8 ), /* 8 */ +/* 166 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x6, /* 6 */ +/* 168 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 170 */ NdrFcShort( 0x0 ), /* 0 */ +/* 172 */ NdrFcShort( 0x0 ), /* 0 */ +/* 174 */ NdrFcShort( 0x0 ), /* 0 */ +/* 176 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter app_id */ + +/* 178 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 180 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 182 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ /* Parameter brand_code */ -/* 108 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 110 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ -/* 112 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ +/* 184 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 186 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 188 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ /* Parameter tag */ -/* 114 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 116 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */ -/* 118 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ +/* 190 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 192 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */ +/* 194 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ /* Parameter version */ -/* 120 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 122 */ NdrFcShort( 0x20 ), /* X64 Stack size/offset = 32 */ -/* 124 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ +/* 196 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 198 */ NdrFcShort( 0x20 ), /* X64 Stack size/offset = 32 */ +/* 200 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ /* Parameter existence_checker_path */ -/* 126 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 128 */ NdrFcShort( 0x28 ), /* X64 Stack size/offset = 40 */ -/* 130 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ - - /* Return value */ - -/* 132 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ -/* 134 */ NdrFcShort( 0x30 ), /* X64 Stack size/offset = 48 */ -/* 136 */ 0x8, /* FC_LONG */ - 0x0, /* 0 */ - - /* Procedure Update */ - -/* 138 */ 0x33, /* FC_AUTO_HANDLE */ - 0x6c, /* Old Flags: object, Oi2 */ -/* 140 */ NdrFcLong( 0x0 ), /* 0 */ -/* 144 */ NdrFcShort( 0x5 ), /* 5 */ -/* 146 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */ -/* 148 */ NdrFcShort( 0x0 ), /* 0 */ -/* 150 */ NdrFcShort( 0x8 ), /* 8 */ -/* 152 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ - 0x2, /* 2 */ -/* 154 */ 0xa, /* 10 */ - 0x1, /* Ext Flags: new corr desc, */ -/* 156 */ NdrFcShort( 0x0 ), /* 0 */ -/* 158 */ NdrFcShort( 0x0 ), /* 0 */ -/* 160 */ NdrFcShort( 0x0 ), /* 0 */ -/* 162 */ NdrFcShort( 0x0 ), /* 0 */ - - /* Parameter app_id */ - -/* 164 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 166 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ -/* 168 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ - - /* Return value */ - -/* 170 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ -/* 172 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ -/* 174 */ 0x8, /* FC_LONG */ - 0x0, /* 0 */ - - /* Procedure UpdateAll */ - -/* 176 */ 0x33, /* FC_AUTO_HANDLE */ - 0x6c, /* Old Flags: object, Oi2 */ -/* 178 */ NdrFcLong( 0x0 ), /* 0 */ -/* 182 */ NdrFcShort( 0x6 ), /* 6 */ -/* 184 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */ -/* 186 */ NdrFcShort( 0x0 ), /* 0 */ -/* 188 */ NdrFcShort( 0x8 ), /* 8 */ -/* 190 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ - 0x2, /* 2 */ -/* 192 */ 0xa, /* 10 */ - 0x1, /* Ext Flags: new corr desc, */ -/* 194 */ NdrFcShort( 0x0 ), /* 0 */ -/* 196 */ NdrFcShort( 0x0 ), /* 0 */ -/* 198 */ NdrFcShort( 0x0 ), /* 0 */ -/* 200 */ NdrFcShort( 0x0 ), /* 0 */ - - /* Parameter observer */ - -/* 202 */ NdrFcShort( 0xb ), /* Flags: must size, must free, in, */ -/* 204 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ -/* 206 */ NdrFcShort( 0x6 ), /* Type Offset=6 */ +/* 202 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 204 */ NdrFcShort( 0x28 ), /* X64 Stack size/offset = 40 */ +/* 206 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ /* Return value */ /* 208 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ -/* 210 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 210 */ NdrFcShort( 0x30 ), /* X64 Stack size/offset = 48 */ /* 212 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ + /* Procedure Update */ + +/* 214 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 216 */ NdrFcLong( 0x0 ), /* 0 */ +/* 220 */ NdrFcShort( 0x5 ), /* 5 */ +/* 222 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */ +/* 224 */ NdrFcShort( 0x0 ), /* 0 */ +/* 226 */ NdrFcShort( 0x8 ), /* 8 */ +/* 228 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x2, /* 2 */ +/* 230 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 232 */ NdrFcShort( 0x0 ), /* 0 */ +/* 234 */ NdrFcShort( 0x0 ), /* 0 */ +/* 236 */ NdrFcShort( 0x0 ), /* 0 */ +/* 238 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter app_id */ + +/* 240 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 242 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 244 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ + + /* Return value */ + +/* 246 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 248 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 250 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Procedure UpdateAll */ + +/* 252 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 254 */ NdrFcLong( 0x0 ), /* 0 */ +/* 258 */ NdrFcShort( 0x6 ), /* 6 */ +/* 260 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */ +/* 262 */ NdrFcShort( 0x0 ), /* 0 */ +/* 264 */ NdrFcShort( 0x8 ), /* 8 */ +/* 266 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x2, /* 2 */ +/* 268 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 270 */ NdrFcShort( 0x0 ), /* 0 */ +/* 272 */ NdrFcShort( 0x0 ), /* 0 */ +/* 274 */ NdrFcShort( 0x0 ), /* 0 */ +/* 276 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter observer */ + +/* 278 */ NdrFcShort( 0xb ), /* Flags: must size, must free, in, */ +/* 280 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 282 */ NdrFcShort( 0x44 ), /* Type Offset=68 */ + + /* Return value */ + +/* 284 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 286 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 288 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + 0x0 } }; @@ -294,41 +364,155 @@ { NdrFcShort( 0x0 ), /* 0 */ /* 2 */ - 0x11, 0x8, /* FC_RP [simple_pointer] */ -/* 4 */ - 0x25, /* FC_C_WSTRING */ + 0x11, 0xc, /* FC_RP [alloced_on_stack] [simple_pointer] */ +/* 4 */ 0x8, /* FC_LONG */ 0x5c, /* FC_PAD */ /* 6 */ + 0x11, 0x4, /* FC_RP [alloced_on_stack] */ +/* 8 */ NdrFcShort( 0x1c ), /* Offset= 28 (36) */ +/* 10 */ + 0x13, 0x0, /* FC_OP */ +/* 12 */ NdrFcShort( 0xe ), /* Offset= 14 (26) */ +/* 14 */ + 0x1b, /* FC_CARRAY */ + 0x1, /* 1 */ +/* 16 */ NdrFcShort( 0x2 ), /* 2 */ +/* 18 */ 0x9, /* Corr desc: FC_ULONG */ + 0x0, /* */ +/* 20 */ NdrFcShort( 0xfffc ), /* -4 */ +/* 22 */ NdrFcShort( 0x1 ), /* Corr flags: early, */ +/* 24 */ 0x6, /* FC_SHORT */ + 0x5b, /* FC_END */ +/* 26 */ + 0x17, /* FC_CSTRUCT */ + 0x3, /* 3 */ +/* 28 */ NdrFcShort( 0x8 ), /* 8 */ +/* 30 */ NdrFcShort( 0xfff0 ), /* Offset= -16 (14) */ +/* 32 */ 0x8, /* FC_LONG */ + 0x8, /* FC_LONG */ +/* 34 */ 0x5c, /* FC_PAD */ + 0x5b, /* FC_END */ +/* 36 */ 0xb4, /* FC_USER_MARSHAL */ + 0x83, /* 131 */ +/* 38 */ NdrFcShort( 0x0 ), /* 0 */ +/* 40 */ NdrFcShort( 0x8 ), /* 8 */ +/* 42 */ NdrFcShort( 0x0 ), /* 0 */ +/* 44 */ NdrFcShort( 0xffde ), /* Offset= -34 (10) */ +/* 46 */ 0x2f, /* FC_IP */ 0x5a, /* FC_CONSTANT_IID */ -/* 8 */ NdrFcLong( 0x7b416cfd ), /* 2067885309 */ -/* 12 */ NdrFcShort( 0x4216 ), /* 16918 */ -/* 14 */ NdrFcShort( 0x4fd6 ), /* 20438 */ -/* 16 */ 0xbd, /* 189 */ +/* 48 */ NdrFcLong( 0x2fcd14af ), /* 801969327 */ +/* 52 */ NdrFcShort( 0xb645 ), /* -18875 */ +/* 54 */ NdrFcShort( 0x4351 ), /* 17233 */ +/* 56 */ 0x83, /* 131 */ + 0x59, /* 89 */ +/* 58 */ 0xe8, /* 232 */ + 0xa, /* 10 */ +/* 60 */ 0xe, /* 14 */ + 0x20, /* 32 */ +/* 62 */ 0x2a, /* 42 */ + 0xb, /* 11 */ +/* 64 */ + 0x11, 0x8, /* FC_RP [simple_pointer] */ +/* 66 */ + 0x25, /* FC_C_WSTRING */ + 0x5c, /* FC_PAD */ +/* 68 */ + 0x2f, /* FC_IP */ + 0x5a, /* FC_CONSTANT_IID */ +/* 70 */ NdrFcLong( 0x7b416cfd ), /* 2067885309 */ +/* 74 */ NdrFcShort( 0x4216 ), /* 16918 */ +/* 76 */ NdrFcShort( 0x4fd6 ), /* 20438 */ +/* 78 */ 0xbd, /* 189 */ 0x83, /* 131 */ -/* 18 */ 0x7c, /* 124 */ +/* 80 */ 0x7c, /* 124 */ 0x58, /* 88 */ -/* 20 */ 0x60, /* 96 */ +/* 82 */ 0x60, /* 96 */ 0x54, /* 84 */ -/* 22 */ 0x67, /* 103 */ +/* 84 */ 0x67, /* 103 */ 0x6e, /* 110 */ 0x0 } }; +static const USER_MARSHAL_ROUTINE_QUADRUPLE UserMarshalRoutines[ WIRE_MARSHAL_TABLE_SIZE ] = + { + + { + BSTR_UserSize + ,BSTR_UserMarshal + ,BSTR_UserUnmarshal + ,BSTR_UserFree + } + + }; + + /* Object interface: IUnknown, ver. 0.0, GUID={0x00000000,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */ +/* Object interface: ICompleteStatus, ver. 0.0, + GUID={0x2FCD14AF,0xB645,0x4351,{0x83,0x59,0xE8,0x0A,0x0E,0x20,0x2A,0x0B}} */ + +#pragma code_seg(".orpc") +static const unsigned short ICompleteStatus_FormatStringOffsetTable[] = + { + 0, + 38 + }; + +static const MIDL_STUBLESS_PROXY_INFO ICompleteStatus_ProxyInfo = + { + &Object_StubDesc, + updater_idl__MIDL_ProcFormatString.Format, + &ICompleteStatus_FormatStringOffsetTable[-3], + 0, + 0, + 0 + }; + + +static const MIDL_SERVER_INFO ICompleteStatus_ServerInfo = + { + &Object_StubDesc, + 0, + updater_idl__MIDL_ProcFormatString.Format, + &ICompleteStatus_FormatStringOffsetTable[-3], + 0, + 0, + 0, + 0}; +CINTERFACE_PROXY_VTABLE(5) _ICompleteStatusProxyVtbl = +{ + &ICompleteStatus_ProxyInfo, + &IID_ICompleteStatus, + IUnknown_QueryInterface_Proxy, + IUnknown_AddRef_Proxy, + IUnknown_Release_Proxy , + (void *) (INT_PTR) -1 /* ICompleteStatus::get_statusCode */ , + (void *) (INT_PTR) -1 /* ICompleteStatus::get_statusMessage */ +}; + +const CInterfaceStubVtbl _ICompleteStatusStubVtbl = +{ + &IID_ICompleteStatus, + &ICompleteStatus_ServerInfo, + 5, + 0, /* pure interpreted */ + CStdStubBuffer_METHODS +}; + + /* Object interface: IUpdaterObserver, ver. 0.0, GUID={0x7B416CFD,0x4216,0x4FD6,{0xBD,0x83,0x7C,0x58,0x60,0x54,0x67,0x6E}} */ #pragma code_seg(".orpc") static const unsigned short IUpdaterObserver_FormatStringOffsetTable[] = { - 0 + 76 }; static const MIDL_STUBLESS_PROXY_INFO IUpdaterObserver_ProxyInfo = @@ -378,10 +562,10 @@ #pragma code_seg(".orpc") static const unsigned short IUpdater_FormatStringOffsetTable[] = { - 38, - 76, - 138, - 176 + 114, + 152, + 214, + 252 }; static const MIDL_STUBLESS_PROXY_INFO IUpdater_ProxyInfo = @@ -443,7 +627,7 @@ 0, 0x801026e, /* MIDL Version 8.1.622 */ 0, - 0, + UserMarshalRoutines, 0, /* notify & notify_flag routine table */ 0x1, /* MIDL flag */ 0, /* cs routines */ @@ -453,6 +637,7 @@ const CInterfaceProxyVtbl * const _updater_idl_ProxyVtblList[] = { + ( CInterfaceProxyVtbl *) &_ICompleteStatusProxyVtbl, ( CInterfaceProxyVtbl *) &_IUpdaterProxyVtbl, ( CInterfaceProxyVtbl *) &_IUpdaterObserverProxyVtbl, 0 @@ -460,6 +645,7 @@ const CInterfaceStubVtbl * const _updater_idl_StubVtblList[] = { + ( CInterfaceStubVtbl *) &_ICompleteStatusStubVtbl, ( CInterfaceStubVtbl *) &_IUpdaterStubVtbl, ( CInterfaceStubVtbl *) &_IUpdaterObserverStubVtbl, 0 @@ -467,6 +653,7 @@ PCInterfaceName const _updater_idl_InterfaceNamesList[] = { + "ICompleteStatus", "IUpdater", "IUpdaterObserver", 0 @@ -479,8 +666,9 @@ { IID_BS_LOOKUP_SETUP - IID_BS_LOOKUP_INITIAL_TEST( _updater_idl, 2, 1 ) - IID_BS_LOOKUP_RETURN_RESULT( _updater_idl, 2, *pIndex ) + IID_BS_LOOKUP_INITIAL_TEST( _updater_idl, 3, 2 ) + IID_BS_LOOKUP_NEXT_TEST( _updater_idl, 1 ) + IID_BS_LOOKUP_RETURN_RESULT( _updater_idl, 3, *pIndex ) } @@ -491,7 +679,7 @@ (const PCInterfaceName * ) & _updater_idl_InterfaceNamesList, 0, /* no delegation */ & _updater_idl_IID_Lookup, - 2, + 3, 2, 0, /* table of [async_uuid] interfaces */ 0, /* Filler1 */
diff --git a/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl.h b/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl.h index 52d7f32..6940fefd 100644 --- a/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl.h +++ b/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl.h
@@ -45,6 +45,13 @@ /* Forward Declarations */ +#ifndef __ICompleteStatus_FWD_DEFINED__ +#define __ICompleteStatus_FWD_DEFINED__ +typedef interface ICompleteStatus ICompleteStatus; + +#endif /* __ICompleteStatus_FWD_DEFINED__ */ + + #ifndef __IUpdaterObserver_FWD_DEFINED__ #define __IUpdaterObserver_FWD_DEFINED__ typedef interface IUpdaterObserver IUpdaterObserver; @@ -99,6 +106,96 @@ #endif +#ifndef __ICompleteStatus_INTERFACE_DEFINED__ +#define __ICompleteStatus_INTERFACE_DEFINED__ + +/* interface ICompleteStatus */ +/* [unique][helpstring][uuid][dual][object] */ + + +EXTERN_C const IID IID_ICompleteStatus; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("2FCD14AF-B645-4351-8359-E80A0E202A0B") + ICompleteStatus : public IUnknown + { + public: + virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_statusCode( + /* [retval][out] */ LONG *__MIDL__ICompleteStatus0000) = 0; + + virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_statusMessage( + /* [retval][out] */ BSTR *__MIDL__ICompleteStatus0001) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ICompleteStatusVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ICompleteStatus * This, + /* [in] */ REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ICompleteStatus * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ICompleteStatus * This); + + /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_statusCode )( + ICompleteStatus * This, + /* [retval][out] */ LONG *__MIDL__ICompleteStatus0000); + + /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_statusMessage )( + ICompleteStatus * This, + /* [retval][out] */ BSTR *__MIDL__ICompleteStatus0001); + + END_INTERFACE + } ICompleteStatusVtbl; + + interface ICompleteStatus + { + CONST_VTBL struct ICompleteStatusVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ICompleteStatus_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ICompleteStatus_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ICompleteStatus_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ICompleteStatus_get_statusCode(This,__MIDL__ICompleteStatus0000) \ + ( (This)->lpVtbl -> get_statusCode(This,__MIDL__ICompleteStatus0000) ) + +#define ICompleteStatus_get_statusMessage(This,__MIDL__ICompleteStatus0001) \ + ( (This)->lpVtbl -> get_statusMessage(This,__MIDL__ICompleteStatus0001) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ICompleteStatus_INTERFACE_DEFINED__ */ + + #ifndef __IUpdaterObserver_INTERFACE_DEFINED__ #define __IUpdaterObserver_INTERFACE_DEFINED__ @@ -115,7 +212,7 @@ { public: virtual HRESULT STDMETHODCALLTYPE OnComplete( - /* [in] */ int error_code) = 0; + /* [in] */ ICompleteStatus *status) = 0; }; @@ -140,7 +237,7 @@ HRESULT ( STDMETHODCALLTYPE *OnComplete )( IUpdaterObserver * This, - /* [in] */ int error_code); + /* [in] */ ICompleteStatus *status); END_INTERFACE } IUpdaterObserverVtbl; @@ -165,8 +262,8 @@ ( (This)->lpVtbl -> Release(This) ) -#define IUpdaterObserver_OnComplete(This,error_code) \ - ( (This)->lpVtbl -> OnComplete(This,error_code) ) +#define IUpdaterObserver_OnComplete(This,status) \ + ( (This)->lpVtbl -> OnComplete(This,status) ) #endif /* COBJMACROS */ @@ -327,6 +424,11 @@ /* Additional Prototypes for ALL interfaces */ +unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * ); +unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * ); +unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * ); +void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * ); + /* end of Additional Prototypes */ #ifdef __cplusplus
diff --git a/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl.tlb b/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl.tlb index 21c02324..171e29b 100644 --- a/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl.tlb +++ b/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl.tlb Binary files differ
diff --git a/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl_i.c b/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl_i.c index 1b53652b..c9225f26 100644 --- a/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl_i.c +++ b/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl_i.c
@@ -67,6 +67,9 @@ #endif // !_MIDL_USE_GUIDDEF_ +MIDL_DEFINE_GUID(IID, IID_ICompleteStatus,0x2FCD14AF,0xB645,0x4351,0x83,0x59,0xE8,0x0A,0x0E,0x20,0x2A,0x0B); + + MIDL_DEFINE_GUID(IID, IID_IUpdaterObserver,0x7B416CFD,0x4216,0x4FD6,0xBD,0x83,0x7C,0x58,0x60,0x54,0x67,0x6E);
diff --git a/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl_p.c b/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl_p.c index 5dffa2fc..b6e0110d 100644 --- a/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl_p.c +++ b/third_party/win_build_output/midl/chrome/updater/server/win/x86/updater_idl_p.c
@@ -49,11 +49,11 @@ #include "updater_idl.h" -#define TYPE_FORMAT_STRING_SIZE 25 -#define PROC_FORMAT_STRING_SIZE 205 +#define TYPE_FORMAT_STRING_SIZE 87 +#define PROC_FORMAT_STRING_SIZE 277 #define EXPR_FORMAT_STRING_SIZE 1 #define TRANSMIT_AS_TABLE_SIZE 0 -#define WIRE_MARSHAL_TABLE_SIZE 0 +#define WIRE_MARSHAL_TABLE_SIZE 1 typedef struct _updater_idl_MIDL_TYPE_FORMAT_STRING { @@ -86,6 +86,13 @@ extern const MIDL_STUB_DESC Object_StubDesc; +extern const MIDL_SERVER_INFO ICompleteStatus_ServerInfo; +extern const MIDL_STUBLESS_PROXY_INFO ICompleteStatus_ProxyInfo; + + +extern const MIDL_STUB_DESC Object_StubDesc; + + extern const MIDL_SERVER_INFO IUpdaterObserver_ServerInfo; extern const MIDL_STUBLESS_PROXY_INFO IUpdaterObserver_ProxyInfo; @@ -97,6 +104,7 @@ extern const MIDL_STUBLESS_PROXY_INFO IUpdater_ProxyInfo; +extern const USER_MARSHAL_ROUTINE_QUADRUPLE UserMarshalRoutines[ WIRE_MARSHAL_TABLE_SIZE ]; #if !defined(__RPC_WIN32__) #error Invalid build platform for this stub. @@ -115,15 +123,15 @@ 0, { - /* Procedure OnComplete */ + /* Procedure get_statusCode */ 0x33, /* FC_AUTO_HANDLE */ 0x6c, /* Old Flags: object, Oi2 */ /* 2 */ NdrFcLong( 0x0 ), /* 0 */ /* 6 */ NdrFcShort( 0x3 ), /* 3 */ /* 8 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ -/* 10 */ NdrFcShort( 0x8 ), /* 8 */ -/* 12 */ NdrFcShort( 0x8 ), /* 8 */ +/* 10 */ NdrFcShort( 0x0 ), /* 0 */ +/* 12 */ NdrFcShort( 0x24 ), /* 36 */ /* 14 */ 0x44, /* Oi2 Flags: has return, has ext, */ 0x2, /* 2 */ /* 16 */ 0x8, /* 8 */ @@ -132,9 +140,9 @@ /* 20 */ NdrFcShort( 0x0 ), /* 0 */ /* 22 */ NdrFcShort( 0x0 ), /* 0 */ - /* Parameter error_code */ + /* Parameter __MIDL__ICompleteStatus0000 */ -/* 24 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 24 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */ /* 26 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ /* 28 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ @@ -146,28 +154,28 @@ /* 34 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ - /* Procedure CheckForUpdate */ + /* Procedure get_statusMessage */ /* 36 */ 0x33, /* FC_AUTO_HANDLE */ 0x6c, /* Old Flags: object, Oi2 */ /* 38 */ NdrFcLong( 0x0 ), /* 0 */ -/* 42 */ NdrFcShort( 0x3 ), /* 3 */ +/* 42 */ NdrFcShort( 0x4 ), /* 4 */ /* 44 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ /* 46 */ NdrFcShort( 0x0 ), /* 0 */ /* 48 */ NdrFcShort( 0x8 ), /* 8 */ -/* 50 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ +/* 50 */ 0x45, /* Oi2 Flags: srv must size, has return, has ext, */ 0x2, /* 2 */ /* 52 */ 0x8, /* 8 */ - 0x1, /* Ext Flags: new corr desc, */ -/* 54 */ NdrFcShort( 0x0 ), /* 0 */ + 0x3, /* Ext Flags: new corr desc, clt corr check, */ +/* 54 */ NdrFcShort( 0x1 ), /* 1 */ /* 56 */ NdrFcShort( 0x0 ), /* 0 */ /* 58 */ NdrFcShort( 0x0 ), /* 0 */ - /* Parameter app_id */ + /* Parameter __MIDL__ICompleteStatus0001 */ -/* 60 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 60 */ NdrFcShort( 0x2113 ), /* Flags: must size, must free, out, simple ref, srv alloc size=8 */ /* 62 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ -/* 64 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ +/* 64 */ NdrFcShort( 0x24 ), /* Type Offset=36 */ /* Return value */ @@ -176,120 +184,180 @@ /* 70 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ - /* Procedure Register */ + /* Procedure OnComplete */ /* 72 */ 0x33, /* FC_AUTO_HANDLE */ 0x6c, /* Old Flags: object, Oi2 */ /* 74 */ NdrFcLong( 0x0 ), /* 0 */ -/* 78 */ NdrFcShort( 0x4 ), /* 4 */ -/* 80 */ NdrFcShort( 0x1c ), /* x86 Stack size/offset = 28 */ +/* 78 */ NdrFcShort( 0x3 ), /* 3 */ +/* 80 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ /* 82 */ NdrFcShort( 0x0 ), /* 0 */ /* 84 */ NdrFcShort( 0x8 ), /* 8 */ /* 86 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ - 0x6, /* 6 */ + 0x2, /* 2 */ /* 88 */ 0x8, /* 8 */ 0x1, /* Ext Flags: new corr desc, */ /* 90 */ NdrFcShort( 0x0 ), /* 0 */ /* 92 */ NdrFcShort( 0x0 ), /* 0 */ /* 94 */ NdrFcShort( 0x0 ), /* 0 */ + /* Parameter status */ + +/* 96 */ NdrFcShort( 0xb ), /* Flags: must size, must free, in, */ +/* 98 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 100 */ NdrFcShort( 0x2e ), /* Type Offset=46 */ + + /* Return value */ + +/* 102 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 104 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ +/* 106 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Procedure CheckForUpdate */ + +/* 108 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 110 */ NdrFcLong( 0x0 ), /* 0 */ +/* 114 */ NdrFcShort( 0x3 ), /* 3 */ +/* 116 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ +/* 118 */ NdrFcShort( 0x0 ), /* 0 */ +/* 120 */ NdrFcShort( 0x8 ), /* 8 */ +/* 122 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x2, /* 2 */ +/* 124 */ 0x8, /* 8 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 126 */ NdrFcShort( 0x0 ), /* 0 */ +/* 128 */ NdrFcShort( 0x0 ), /* 0 */ +/* 130 */ NdrFcShort( 0x0 ), /* 0 */ + /* Parameter app_id */ -/* 96 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 98 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ -/* 100 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ +/* 132 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 134 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 136 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ + + /* Return value */ + +/* 138 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 140 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ +/* 142 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Procedure Register */ + +/* 144 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 146 */ NdrFcLong( 0x0 ), /* 0 */ +/* 150 */ NdrFcShort( 0x4 ), /* 4 */ +/* 152 */ NdrFcShort( 0x1c ), /* x86 Stack size/offset = 28 */ +/* 154 */ NdrFcShort( 0x0 ), /* 0 */ +/* 156 */ NdrFcShort( 0x8 ), /* 8 */ +/* 158 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x6, /* 6 */ +/* 160 */ 0x8, /* 8 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 162 */ NdrFcShort( 0x0 ), /* 0 */ +/* 164 */ NdrFcShort( 0x0 ), /* 0 */ +/* 166 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter app_id */ + +/* 168 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 170 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 172 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ /* Parameter brand_code */ -/* 102 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 104 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ -/* 106 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ +/* 174 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 176 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ +/* 178 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ /* Parameter tag */ -/* 108 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 110 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ -/* 112 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ +/* 180 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 182 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ +/* 184 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ /* Parameter version */ -/* 114 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 116 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */ -/* 118 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ +/* 186 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 188 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */ +/* 190 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ /* Parameter existence_checker_path */ -/* 120 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 122 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */ -/* 124 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ - - /* Return value */ - -/* 126 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ -/* 128 */ NdrFcShort( 0x18 ), /* x86 Stack size/offset = 24 */ -/* 130 */ 0x8, /* FC_LONG */ - 0x0, /* 0 */ - - /* Procedure Update */ - -/* 132 */ 0x33, /* FC_AUTO_HANDLE */ - 0x6c, /* Old Flags: object, Oi2 */ -/* 134 */ NdrFcLong( 0x0 ), /* 0 */ -/* 138 */ NdrFcShort( 0x5 ), /* 5 */ -/* 140 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ -/* 142 */ NdrFcShort( 0x0 ), /* 0 */ -/* 144 */ NdrFcShort( 0x8 ), /* 8 */ -/* 146 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ - 0x2, /* 2 */ -/* 148 */ 0x8, /* 8 */ - 0x1, /* Ext Flags: new corr desc, */ -/* 150 */ NdrFcShort( 0x0 ), /* 0 */ -/* 152 */ NdrFcShort( 0x0 ), /* 0 */ -/* 154 */ NdrFcShort( 0x0 ), /* 0 */ - - /* Parameter app_id */ - -/* 156 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 158 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ -/* 160 */ NdrFcShort( 0x4 ), /* Type Offset=4 */ - - /* Return value */ - -/* 162 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ -/* 164 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ -/* 166 */ 0x8, /* FC_LONG */ - 0x0, /* 0 */ - - /* Procedure UpdateAll */ - -/* 168 */ 0x33, /* FC_AUTO_HANDLE */ - 0x6c, /* Old Flags: object, Oi2 */ -/* 170 */ NdrFcLong( 0x0 ), /* 0 */ -/* 174 */ NdrFcShort( 0x6 ), /* 6 */ -/* 176 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ -/* 178 */ NdrFcShort( 0x0 ), /* 0 */ -/* 180 */ NdrFcShort( 0x8 ), /* 8 */ -/* 182 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ - 0x2, /* 2 */ -/* 184 */ 0x8, /* 8 */ - 0x1, /* Ext Flags: new corr desc, */ -/* 186 */ NdrFcShort( 0x0 ), /* 0 */ -/* 188 */ NdrFcShort( 0x0 ), /* 0 */ -/* 190 */ NdrFcShort( 0x0 ), /* 0 */ - - /* Parameter observer */ - -/* 192 */ NdrFcShort( 0xb ), /* Flags: must size, must free, in, */ -/* 194 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ -/* 196 */ NdrFcShort( 0x6 ), /* Type Offset=6 */ +/* 192 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 194 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */ +/* 196 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ /* Return value */ /* 198 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ -/* 200 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ +/* 200 */ NdrFcShort( 0x18 ), /* x86 Stack size/offset = 24 */ /* 202 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ + /* Procedure Update */ + +/* 204 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 206 */ NdrFcLong( 0x0 ), /* 0 */ +/* 210 */ NdrFcShort( 0x5 ), /* 5 */ +/* 212 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ +/* 214 */ NdrFcShort( 0x0 ), /* 0 */ +/* 216 */ NdrFcShort( 0x8 ), /* 8 */ +/* 218 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x2, /* 2 */ +/* 220 */ 0x8, /* 8 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 222 */ NdrFcShort( 0x0 ), /* 0 */ +/* 224 */ NdrFcShort( 0x0 ), /* 0 */ +/* 226 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter app_id */ + +/* 228 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 230 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 232 */ NdrFcShort( 0x42 ), /* Type Offset=66 */ + + /* Return value */ + +/* 234 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 236 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ +/* 238 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Procedure UpdateAll */ + +/* 240 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 242 */ NdrFcLong( 0x0 ), /* 0 */ +/* 246 */ NdrFcShort( 0x6 ), /* 6 */ +/* 248 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ +/* 250 */ NdrFcShort( 0x0 ), /* 0 */ +/* 252 */ NdrFcShort( 0x8 ), /* 8 */ +/* 254 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x2, /* 2 */ +/* 256 */ 0x8, /* 8 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 258 */ NdrFcShort( 0x0 ), /* 0 */ +/* 260 */ NdrFcShort( 0x0 ), /* 0 */ +/* 262 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter observer */ + +/* 264 */ NdrFcShort( 0xb ), /* Flags: must size, must free, in, */ +/* 266 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 268 */ NdrFcShort( 0x44 ), /* Type Offset=68 */ + + /* Return value */ + +/* 270 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 272 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ +/* 274 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + 0x0 } }; @@ -300,41 +368,155 @@ { NdrFcShort( 0x0 ), /* 0 */ /* 2 */ - 0x11, 0x8, /* FC_RP [simple_pointer] */ -/* 4 */ - 0x25, /* FC_C_WSTRING */ + 0x11, 0xc, /* FC_RP [alloced_on_stack] [simple_pointer] */ +/* 4 */ 0x8, /* FC_LONG */ 0x5c, /* FC_PAD */ /* 6 */ + 0x11, 0x4, /* FC_RP [alloced_on_stack] */ +/* 8 */ NdrFcShort( 0x1c ), /* Offset= 28 (36) */ +/* 10 */ + 0x13, 0x0, /* FC_OP */ +/* 12 */ NdrFcShort( 0xe ), /* Offset= 14 (26) */ +/* 14 */ + 0x1b, /* FC_CARRAY */ + 0x1, /* 1 */ +/* 16 */ NdrFcShort( 0x2 ), /* 2 */ +/* 18 */ 0x9, /* Corr desc: FC_ULONG */ + 0x0, /* */ +/* 20 */ NdrFcShort( 0xfffc ), /* -4 */ +/* 22 */ NdrFcShort( 0x1 ), /* Corr flags: early, */ +/* 24 */ 0x6, /* FC_SHORT */ + 0x5b, /* FC_END */ +/* 26 */ + 0x17, /* FC_CSTRUCT */ + 0x3, /* 3 */ +/* 28 */ NdrFcShort( 0x8 ), /* 8 */ +/* 30 */ NdrFcShort( 0xfff0 ), /* Offset= -16 (14) */ +/* 32 */ 0x8, /* FC_LONG */ + 0x8, /* FC_LONG */ +/* 34 */ 0x5c, /* FC_PAD */ + 0x5b, /* FC_END */ +/* 36 */ 0xb4, /* FC_USER_MARSHAL */ + 0x83, /* 131 */ +/* 38 */ NdrFcShort( 0x0 ), /* 0 */ +/* 40 */ NdrFcShort( 0x4 ), /* 4 */ +/* 42 */ NdrFcShort( 0x0 ), /* 0 */ +/* 44 */ NdrFcShort( 0xffde ), /* Offset= -34 (10) */ +/* 46 */ 0x2f, /* FC_IP */ 0x5a, /* FC_CONSTANT_IID */ -/* 8 */ NdrFcLong( 0x7b416cfd ), /* 2067885309 */ -/* 12 */ NdrFcShort( 0x4216 ), /* 16918 */ -/* 14 */ NdrFcShort( 0x4fd6 ), /* 20438 */ -/* 16 */ 0xbd, /* 189 */ +/* 48 */ NdrFcLong( 0x2fcd14af ), /* 801969327 */ +/* 52 */ NdrFcShort( 0xb645 ), /* -18875 */ +/* 54 */ NdrFcShort( 0x4351 ), /* 17233 */ +/* 56 */ 0x83, /* 131 */ + 0x59, /* 89 */ +/* 58 */ 0xe8, /* 232 */ + 0xa, /* 10 */ +/* 60 */ 0xe, /* 14 */ + 0x20, /* 32 */ +/* 62 */ 0x2a, /* 42 */ + 0xb, /* 11 */ +/* 64 */ + 0x11, 0x8, /* FC_RP [simple_pointer] */ +/* 66 */ + 0x25, /* FC_C_WSTRING */ + 0x5c, /* FC_PAD */ +/* 68 */ + 0x2f, /* FC_IP */ + 0x5a, /* FC_CONSTANT_IID */ +/* 70 */ NdrFcLong( 0x7b416cfd ), /* 2067885309 */ +/* 74 */ NdrFcShort( 0x4216 ), /* 16918 */ +/* 76 */ NdrFcShort( 0x4fd6 ), /* 20438 */ +/* 78 */ 0xbd, /* 189 */ 0x83, /* 131 */ -/* 18 */ 0x7c, /* 124 */ +/* 80 */ 0x7c, /* 124 */ 0x58, /* 88 */ -/* 20 */ 0x60, /* 96 */ +/* 82 */ 0x60, /* 96 */ 0x54, /* 84 */ -/* 22 */ 0x67, /* 103 */ +/* 84 */ 0x67, /* 103 */ 0x6e, /* 110 */ 0x0 } }; +static const USER_MARSHAL_ROUTINE_QUADRUPLE UserMarshalRoutines[ WIRE_MARSHAL_TABLE_SIZE ] = + { + + { + BSTR_UserSize + ,BSTR_UserMarshal + ,BSTR_UserUnmarshal + ,BSTR_UserFree + } + + }; + + /* Object interface: IUnknown, ver. 0.0, GUID={0x00000000,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */ +/* Object interface: ICompleteStatus, ver. 0.0, + GUID={0x2FCD14AF,0xB645,0x4351,{0x83,0x59,0xE8,0x0A,0x0E,0x20,0x2A,0x0B}} */ + +#pragma code_seg(".orpc") +static const unsigned short ICompleteStatus_FormatStringOffsetTable[] = + { + 0, + 36 + }; + +static const MIDL_STUBLESS_PROXY_INFO ICompleteStatus_ProxyInfo = + { + &Object_StubDesc, + updater_idl__MIDL_ProcFormatString.Format, + &ICompleteStatus_FormatStringOffsetTable[-3], + 0, + 0, + 0 + }; + + +static const MIDL_SERVER_INFO ICompleteStatus_ServerInfo = + { + &Object_StubDesc, + 0, + updater_idl__MIDL_ProcFormatString.Format, + &ICompleteStatus_FormatStringOffsetTable[-3], + 0, + 0, + 0, + 0}; +CINTERFACE_PROXY_VTABLE(5) _ICompleteStatusProxyVtbl = +{ + &ICompleteStatus_ProxyInfo, + &IID_ICompleteStatus, + IUnknown_QueryInterface_Proxy, + IUnknown_AddRef_Proxy, + IUnknown_Release_Proxy , + (void *) (INT_PTR) -1 /* ICompleteStatus::get_statusCode */ , + (void *) (INT_PTR) -1 /* ICompleteStatus::get_statusMessage */ +}; + +const CInterfaceStubVtbl _ICompleteStatusStubVtbl = +{ + &IID_ICompleteStatus, + &ICompleteStatus_ServerInfo, + 5, + 0, /* pure interpreted */ + CStdStubBuffer_METHODS +}; + + /* Object interface: IUpdaterObserver, ver. 0.0, GUID={0x7B416CFD,0x4216,0x4FD6,{0xBD,0x83,0x7C,0x58,0x60,0x54,0x67,0x6E}} */ #pragma code_seg(".orpc") static const unsigned short IUpdaterObserver_FormatStringOffsetTable[] = { - 0 + 72 }; static const MIDL_STUBLESS_PROXY_INFO IUpdaterObserver_ProxyInfo = @@ -384,10 +566,10 @@ #pragma code_seg(".orpc") static const unsigned short IUpdater_FormatStringOffsetTable[] = { - 36, - 72, - 132, - 168 + 108, + 144, + 204, + 240 }; static const MIDL_STUBLESS_PROXY_INFO IUpdater_ProxyInfo = @@ -449,7 +631,7 @@ 0, 0x801026e, /* MIDL Version 8.1.622 */ 0, - 0, + UserMarshalRoutines, 0, /* notify & notify_flag routine table */ 0x1, /* MIDL flag */ 0, /* cs routines */ @@ -459,6 +641,7 @@ const CInterfaceProxyVtbl * const _updater_idl_ProxyVtblList[] = { + ( CInterfaceProxyVtbl *) &_ICompleteStatusProxyVtbl, ( CInterfaceProxyVtbl *) &_IUpdaterProxyVtbl, ( CInterfaceProxyVtbl *) &_IUpdaterObserverProxyVtbl, 0 @@ -466,6 +649,7 @@ const CInterfaceStubVtbl * const _updater_idl_StubVtblList[] = { + ( CInterfaceStubVtbl *) &_ICompleteStatusStubVtbl, ( CInterfaceStubVtbl *) &_IUpdaterStubVtbl, ( CInterfaceStubVtbl *) &_IUpdaterObserverStubVtbl, 0 @@ -473,6 +657,7 @@ PCInterfaceName const _updater_idl_InterfaceNamesList[] = { + "ICompleteStatus", "IUpdater", "IUpdaterObserver", 0 @@ -485,8 +670,9 @@ { IID_BS_LOOKUP_SETUP - IID_BS_LOOKUP_INITIAL_TEST( _updater_idl, 2, 1 ) - IID_BS_LOOKUP_RETURN_RESULT( _updater_idl, 2, *pIndex ) + IID_BS_LOOKUP_INITIAL_TEST( _updater_idl, 3, 2 ) + IID_BS_LOOKUP_NEXT_TEST( _updater_idl, 1 ) + IID_BS_LOOKUP_RETURN_RESULT( _updater_idl, 3, *pIndex ) } @@ -497,7 +683,7 @@ (const PCInterfaceName * ) & _updater_idl_InterfaceNamesList, 0, /* no delegation */ & _updater_idl_IID_Lookup, - 2, + 3, 2, 0, /* table of [async_uuid] interfaces */ 0, /* Filler1 */
diff --git a/tools/binary_size/diagnose_bloat.py b/tools/binary_size/diagnose_bloat.py index 881399c..5cc0bc56 100755 --- a/tools/binary_size/diagnose_bloat.py +++ b/tools/binary_size/diagnose_bloat.py
@@ -375,14 +375,13 @@ class _BuildArchive(object): """Class for managing a directory with build results and build metadata.""" - def __init__(self, rev, base_archive_dir, build, subrepo, slow_options, - save_unstripped): + + def __init__(self, rev, base_archive_dir, build, subrepo, save_unstripped): self.build = build self.dir = os.path.join(base_archive_dir, rev) metadata_path = os.path.join(self.dir, 'metadata.txt') self.rev = rev self.metadata = _Metadata([self], build, metadata_path, subrepo) - self._slow_options = slow_options self._save_unstripped = save_unstripped def ArchiveBuildResults(self, supersize_path, tool_prefix=None): @@ -418,8 +417,6 @@ _RESOURCE_SIZES_PATH, self.build.abs_apk_path, '--output-dir', self.dir, '--chartjson', '--chromium-output-dir', self.build.output_directory ] - if self._slow_options: - cmd += ['--estimate-patch-size', '--dump-static-initializers'] _RunCmd(cmd) def _ArchiveFile(self, filename): @@ -448,13 +445,12 @@ class _DiffArchiveManager(object): """Class for maintaining BuildArchives and their related diff artifacts.""" - def __init__(self, revs, archive_dir, diffs, build, subrepo, slow_options, - save_unstripped): + + def __init__(self, revs, archive_dir, diffs, build, subrepo, save_unstripped): self.archive_dir = archive_dir self.build = build self.build_archives = [ - _BuildArchive(rev, archive_dir, build, subrepo, slow_options, - save_unstripped) + _BuildArchive(rev, archive_dir, build, subrepo, save_unstripped) for rev in revs ] self.diffs = diffs @@ -815,11 +811,6 @@ action='store_true', help='Build/download all revs from --reference-rev to ' 'rev and diff the contiguous revisions.') - parser.add_argument('--include-slow-options', - action='store_true', - help='Run some extra steps that take longer to complete. ' - 'This includes apk-patch-size estimation and ' - 'static-initializer counting.') parser.add_argument('--single', action='store_true', help='Sets --reference-rev=rev.') @@ -912,8 +903,7 @@ ResourceSizesDiff(build.apk_name) ] diff_mngr = _DiffArchiveManager(revs, args.archive_directory, diffs, build, - subrepo, args.include_slow_options, - args.unstripped) + subrepo, args.unstripped) consecutive_failures = 0 i = 0 for i, archive in enumerate(diff_mngr.build_archives):
diff --git a/tools/binary_size/libsupersize/parallel.py b/tools/binary_size/libsupersize/parallel.py index b7078396..68b1268 100644 --- a/tools/binary_size/libsupersize/parallel.py +++ b/tools/binary_size/libsupersize/parallel.py
@@ -209,12 +209,14 @@ pool = _MakeProcessPool(arg_tuples, **kwargs) wrapped_func = _FuncWrapper(func) - for result in pool.imap_unordered(wrapped_func, xrange(len(arg_tuples))): - _CheckForException(result) - yield result - pool.close() - pool.join() - _all_pools.remove(pool) + try: + for result in pool.imap_unordered(wrapped_func, xrange(len(arg_tuples))): + _CheckForException(result) + yield result + finally: + pool.close() + pool.join() + _all_pools.remove(pool) def CallOnThread(func, *args, **kwargs):
diff --git a/tools/binary_size/libsupersize/parallel_test.py b/tools/binary_size/libsupersize/parallel_test.py index 449d4d2d..fae7e64 100755 --- a/tools/binary_size/libsupersize/parallel_test.py +++ b/tools/binary_size/libsupersize/parallel_test.py
@@ -149,7 +149,7 @@ def testBulkForkAndCall_exception(self): parent_pid = os.getpid() results = parallel.BulkForkAndCall(_ForkTestHelper, - [(1, 'a', self, parent_pid)]) + [(1, 'a', None, self, parent_pid)]) self.assertRaises(TypeError, results.next)
diff --git a/tools/clang/scripts/goma_link_tests.py b/tools/clang/scripts/goma_link_tests.py index d7494283..d6c5464 100755 --- a/tools/clang/scripts/goma_link_tests.py +++ b/tools/clang/scripts/goma_link_tests.py
@@ -266,7 +266,7 @@ self.assertFalse(os.path.exists(os.path.join(d, 'lto.main'))) # Check that main calls foo. disasm = subprocess.check_output(['llvm-objdump', '-d', 'main']) - main_idx = disasm.index(b' main:\n') + main_idx = disasm.index(b' <main>:\n') after_main_idx = disasm.index(b'\n\n', main_idx) main_disasm = disasm[main_idx:after_main_idx] self.assertIn(b'foo', main_disasm) @@ -290,7 +290,7 @@ self.assertFalse(os.path.exists(os.path.join(d, 'lto.main'))) # Check that main does not call foo. disasm = subprocess.check_output(['llvm-objdump', '-d', 'main']) - main_idx = disasm.index(b' main:\n') + main_idx = disasm.index(b' <main>:\n') after_main_idx = disasm.index(b'\n\n', main_idx) main_disasm = disasm[main_idx:after_main_idx] self.assertNotIn(b'foo', main_disasm) @@ -318,7 +318,7 @@ self.assertIn('build lto.main/foo.o : codegen ', buildrules) # Check that main does not call foo. disasm = subprocess.check_output(['llvm-objdump', '-d', 'main']) - main_idx = disasm.index(b' main:\n') + main_idx = disasm.index(b' <main>:\n') after_main_idx = disasm.index(b'\n\n', main_idx) main_disasm = disasm[main_idx:after_main_idx] self.assertNotIn(b'foo', main_disasm) @@ -350,7 +350,7 @@ self.assertIn('build lto.main/foo.o : codegen ', buildrules) # Check that main does not call foo. disasm = subprocess.check_output(['llvm-objdump', '-d', 'main']) - main_idx = disasm.index(b' main:\n') + main_idx = disasm.index(b' <main>:\n') after_main_idx = disasm.index(b'\n\n', main_idx) main_disasm = disasm[main_idx:after_main_idx] self.assertNotIn(b'foo', main_disasm) @@ -388,7 +388,7 @@ self.assertIn('build lto.main/obj/foo.o : codegen ', buildrules) # Check that main does not call foo. disasm = subprocess.check_output(['llvm-objdump', '-d', 'main']) - main_idx = disasm.index(b' main:\n') + main_idx = disasm.index(b' <main>:\n') after_main_idx = disasm.index(b'\n\n', main_idx) main_disasm = disasm[main_idx:after_main_idx] self.assertNotIn(b'foo', main_disasm) @@ -444,7 +444,7 @@ self.assertIn('main.split.o', link_text) # Check that main does not call foo. disasm = subprocess.check_output(['llvm-objdump', '-d', 'main']) - main_idx = disasm.index(b' main:\n') + main_idx = disasm.index(b' <main>:\n') after_main_idx = disasm.index(b'\n\n', main_idx) main_disasm = disasm[main_idx:after_main_idx] self.assertNotIn(b'foo', main_disasm)
diff --git a/tools/grit/grit_rule.gni b/tools/grit/grit_rule.gni index 36bdade..87c8504d 100644 --- a/tools/grit/grit_rule.gni +++ b/tools/grit/grit_rule.gni
@@ -14,13 +14,13 @@ # source (required) # Path to .grd file. # -# source_is_generated (optional, defaults to false) -# Declares that the input (or one of its dependencies) is generated so -# that grit_info is not run on the file when -# compute_inputs_for_analyze is set (because the file will not -# exist at analyze time). For "analyze" to be correct in this case, the -# inputs to the grit file must either be listed in the inputs variable -# or are listed as inputs to dependencies of this target. +# enable_input_discovery_for_gn_analyze (default=true) +# Runs grit_info.py via exec_script() when compute_inputs_for_analyze=true +# in order to discover all files that affect this target. +# Turn this off when the .grd file is generated, or an <include> with +# flattenhtml=true points to a generated file. +# For "gn analyze" to be correct with this arg disabled, all inputs +# must be listed via |inputs|. # # inputs (optional) # List of additional files, required for grit to process source file. @@ -292,9 +292,10 @@ } _rebased_source_path = rebase_path(invoker.source, root_build_dir) - _source_is_generated = - defined(invoker.source_is_generated) && invoker.source_is_generated - if (!_source_is_generated && compute_inputs_for_analyze) { + _enable_grit_info = + !defined(invoker.enable_input_discovery_for_gn_analyze) || + invoker.enable_input_discovery_for_gn_analyze + if (_enable_grit_info && compute_inputs_for_analyze) { # Only call exec_script when the user has explicitly opted into greater # precision at the expense of performance. _rel_inputs = exec_script("//tools/grit/grit_info.py",
diff --git a/tools/mb/mb.py b/tools/mb/mb.py index 9ab2a625..dabc6fc 100755 --- a/tools/mb/mb.py +++ b/tools/mb/mb.py
@@ -866,23 +866,45 @@ return ' '.join(gn_args) def Lookup(self): - vals = self.ReadIOSBotConfig() - if not vals: - self.ReadConfigFile() + self.ReadConfigFile() + try: if self.group_by_bucket: config = self.ConfigFromArgsBucket() else: config = self.ConfigFromArgs() - if config.startswith('//'): - if not self.Exists(self.ToAbsPath(config)): - raise MBErr('args file "%s" not found' % config) - vals = DefaultVals() - vals['args_file'] = config - else: - if not config in self.configs: - raise MBErr('Config "%s" not found in %s' % - (config, self.args.config_file)) - vals = FlattenConfig(self.configs, self.mixins, config) + except MBErr as e: + # TODO(crbug.com/912681) While iOS bots are migrated to use the + # Chromium recipe, we want to ensure that we're checking MB's + # configurations first before going to iOS. + # This is to be removed once the migration is complete. + vals = self.ReadIOSBotConfig() + if not vals: + raise e + return vals + + # TODO(crbug.com/912681) Some iOS bots have a definition, with ios_error + # as an indicator that it's incorrect. We utilize this to check the + # iOS JSON instead, and error out if there exists no definition at all. + # This is to be removed once the migration is complete. + if config == 'ios_error': + vals = self.ReadIOSBotConfig() + if not vals: + raise MBErr('No iOS definition was found. Please ensure there is a ' + 'definition for the given iOS bot under ' + 'mb_config.pyl or a JSON file definition under ' + '//ios/build/bots.') + return vals + + if config.startswith('//'): + if not self.Exists(self.ToAbsPath(config)): + raise MBErr('args file "%s" not found' % config) + vals = DefaultVals() + vals['args_file'] = config + else: + if not config in self.configs: + raise MBErr( + 'Config "%s" not found in %s' % (config, self.args.config_file)) + vals = FlattenConfig(self.configs, self.mixins, config) return vals def ReadIOSBotConfig(self):
diff --git a/tools/mb/mb_config.pyl b/tools/mb/mb_config.pyl index 7d513b41..448145937 100644 --- a/tools/mb/mb_config.pyl +++ b/tools/mb/mb_config.pyl
@@ -242,7 +242,7 @@ 'ios-simulator-cr-recipe': 'ios_simulator_debug_static_bot', 'linux-annotator-rel': 'release_bot', 'linux-autofill-captured-sites-rel': 'release_bot', - 'linux-bfcache-debug': 'debug_bot', + 'linux-bfcache-rel': 'release_bot', 'linux-blink-animation-use-time-delta': 'debug_bot_enable_blink_animation_use_time_delta', 'linux-blink-cors-rel': 'release_bot_minimal_symbols', 'linux-blink-heap-concurrent-marking-tsan-rel': 'release_trybot_tsan', @@ -810,7 +810,7 @@ 'linux-annotator-rel': 'release_trybot', 'linux-blink-heap-concurrent-marking-tsan-rel': 'release_trybot_tsan', 'linux-blink-heap-verification-try': 'release_trybot_enable_blink_heap_verification', - 'linux-bfcache-debug': 'debug_bot', + 'linux-bfcache-rel': 'release_bot', 'linux-clang-tidy-dbg': 'debug_bot', 'linux-clang-tidy-rel': 'release_trybot', 'linux-dcheck-off-rel': 'release_trybot_dcheck_off',
diff --git a/tools/mb/mb_config_buckets.pyl b/tools/mb/mb_config_buckets.pyl index 77867118..88caa48c 100644 --- a/tools/mb/mb_config_buckets.pyl +++ b/tools/mb/mb_config_buckets.pyl
@@ -227,7 +227,7 @@ 'linux-annotator-rel': 'release_trybot', 'linux-archive-dbg': 'debug_bot', 'linux-archive-rel': 'release_bot', - 'linux-bfcache-debug': 'debug_bot', + 'linux-bfcache-rel': 'release_bot', 'linux-blink-animation-use-time-delta': 'debug_bot_enable_blink_animation_use_time_delta', 'linux-blink-heap-concurrent-marking-tsan-rel': 'release_trybot_tsan', 'linux-blink-heap-verification': 'release_bot_enable_blink_heap_verification_dcheck_always_on', @@ -767,7 +767,7 @@ 'leak_detection_linux': 'release_trybot', 'linux-angle-rel': 'gpu_fyi_tests_release_trybot', 'linux-annotator-rel': 'release_trybot', - 'linux-bfcache-debug': 'debug_bot', + 'linux-bfcache-rel': 'release_bot', 'linux-blink-heap-concurrent-marking-tsan-rel': 'release_trybot_tsan', 'linux-blink-heap-verification-try': 'release_trybot_enable_blink_heap_verification', 'linux-blink-rel': 'release_bot_minimal_symbols', @@ -1093,7 +1093,7 @@ 'leak_detection_linux': 'release_trybot', 'linux-angle-rel': 'gpu_fyi_tests_release_trybot', 'linux-annotator-rel': 'release_trybot', - 'linux-bfcache-debug': 'debug_bot', + 'linux-bfcache-rel': 'release_bot', 'linux-blink-heap-concurrent-marking-tsan-rel': 'release_trybot_tsan', 'linux-blink-heap-verification-try': 'release_trybot_enable_blink_heap_verification', 'linux-blink-rel': 'release_bot_minimal_symbols', @@ -1348,7 +1348,7 @@ 'leak_detection_linux': 'release_trybot', 'linux-angle-rel': 'gpu_fyi_tests_release_trybot', 'linux-annotator-rel': 'release_trybot', - 'linux-bfcache-debug': 'debug_bot', + 'linux-bfcache-rel': 'release_bot', 'linux-blink-heap-concurrent-marking-tsan-rel': 'release_trybot_tsan', 'linux-blink-heap-verification-try': 'release_trybot_enable_blink_heap_verification', 'linux-blink-rel': 'release_bot_minimal_symbols',
diff --git a/tools/mb/mb_unittest.py b/tools/mb/mb_unittest.py index b12be2a..f885e8a 100755 --- a/tools/mb/mb_unittest.py +++ b/tools/mb/mb_unittest.py
@@ -142,6 +142,7 @@ 'fake_args_bot': '//build/args/bots/fake_master/fake_args_bot.gn', 'fake_multi_phase': { 'phase_1': 'phase_1', 'phase_2': 'phase_2'}, 'fake_args_file': 'args_file_goma', + 'fake_ios_error': 'ios_error', }, }, 'configs': { @@ -151,11 +152,15 @@ 'debug_goma': ['debug', 'goma'], 'phase_1': ['phase_1'], 'phase_2': ['phase_2'], + 'ios_error': ['error'], }, 'mixins': { 'cros_chrome_sdk': { 'cros_passthrough': True, }, + 'error': { + 'gn_args': 'error', + }, 'fake_feature1': { 'gn_args': 'enable_doom_melon=true', }, @@ -422,7 +427,6 @@ actual_ret = mbw.Main(args) finally: os.environ = prev_env - self.assertEqual(actual_ret, ret) if out is not None: self.assertEqual(mbw.out, out) @@ -1010,6 +1014,67 @@ self.assertIn(['autoninja.bat', '-C', 'out\\Default', 'base_unittests'], mbw.calls) + def test_ios_error_config_with_ios_json(self): + """Ensures that ios_error config finds the correct iOS JSON file for args""" + files = { + '/fake_src/ios/build/bots/fake_master/fake_ios_error.json': + ('{"gn_args": ["is_debug=true"]}\n') + } + mbw = self.fake_mbw(files) + self.check(['lookup', '-m', 'fake_master', '-b', 'fake_ios_error'], + mbw=mbw, + ret=0, + out=('\n' + 'Writing """\\\n' + 'is_debug = true\n' + '""" to _path_/args.gn.\n\n' + '/fake_src/buildtools/linux64/gn gen _path_\n')) + + def test_bot_definition_in_ios_json_only(self): + """Ensures that logic checks iOS JSON file for args + + When builder definition is not present, ensure that ios/build/bots/ is + checked. + """ + files = { + '/fake_src/ios/build/bots/fake_master/fake_ios_bot.json': + ('{"gn_args": ["is_debug=true"]}\n') + } + mbw = self.fake_mbw(files) + self.check(['lookup', '-m', 'fake_master', '-b', 'fake_ios_bot'], + mbw=mbw, + ret=0, + out=('\n' + 'Writing """\\\n' + 'is_debug = true\n' + '""" to _path_/args.gn.\n\n' + '/fake_src/buildtools/linux64/gn gen _path_\n')) + + def test_ios_error_config_missing_json_definition(self): + """Ensures MBErr is thrown + + Expect MBErr with 'No iOS definition ...' for iOS bots when the bot config + is ios_error, but there is no iOS JSON definition for it. + """ + mbw = self.fake_mbw() + self.check(['lookup', '-m', 'fake_master', '-b', 'fake_ios_error'], + mbw=mbw, + ret=1) + self.assertIn('MBErr: No iOS definition was found.', mbw.out) + + def test_bot_missing_definition(self): + """Ensures builder missing MBErr is thrown + + Expect the original MBErr to be thrown for iOS bots when the bot definition + doesn't exist at all. + """ + mbw = self.fake_mbw() + self.check(['lookup', '-m', 'fake_master', '-b', 'random_bot'], + mbw=mbw, + ret=1) + self.assertIn('MBErr: Builder name "random_bot" not found under masters', + mbw.out) + if __name__ == '__main__': unittest.main()
diff --git a/tools/metrics/OWNERS b/tools/metrics/OWNERS index b5488ef..c929027 100644 --- a/tools/metrics/OWNERS +++ b/tools/metrics/OWNERS
@@ -1,6 +1,3 @@ file://base/metrics/OWNERS -# A "bot" used for updating data such as histogram expiry dates. -chrome-metrics-team+robot@google.com - # COMPONENT: Internals>Metrics
diff --git a/tools/metrics/histograms/OWNERS b/tools/metrics/histograms/OWNERS index 89ea2805..e166495e 100644 --- a/tools/metrics/histograms/OWNERS +++ b/tools/metrics/histograms/OWNERS
@@ -11,7 +11,7 @@ per-file histograms.xml=schenney@chromium.org per-file histograms.xml=tbansal@chromium.org per-file histograms.xml=tby@chromium.org # For chrome knowledge team metrics only. - +per-file histograms.xml=chrome-metrics-team+robot@google.com # For bot updates to expiry. per-file histograms.xml=set noparent # Extending enums by adding new buckets is allowed without OWNERS review, but
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index eb94453..5be1e05 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -20528,7 +20528,7 @@ <int value="16384" label="UPDATE_REQUIRED_BY_POLICY"/> <int value="32768" label="CUSTODIAN_APPROVAL_REQUIRED"/> <int value="65536" label="BLOCKED_BY_POLICY"/> - <int value="131072" label="BLOCKED_MATURE"/> + <int value="131072" label="DEPRECATED_BLOCKED_MATURE"/> </enum> <enum name="ExtensionEvents"> @@ -26440,8 +26440,8 @@ <int value="2822" label="OBSOLETE_CSSValueAppearanceTextFieldForOthersRendered"/> <int value="2823" label="CSSValueAppearanceTextFieldForTemporalRendered"/> - <int value="2824" label="BuiltInModuleKvStorage"/> - <int value="2825" label="BuiltInModuleVirtualScroller"/> + <int value="2824" label="OBSOLETE_BuiltInModuleKvStorage"/> + <int value="2825" label="OBSOLETE_BuiltInModuleVirtualScroller"/> <int value="2826" label="AdClickNavigation"/> <int value="2827" label="RTCStatsRelativePacketArrivalDelay"/> <int value="2829" label="CSSSelectorHostContextInSnapshotProfile"/> @@ -26540,12 +26540,12 @@ <int value="2918" label="UnsizedMediaPolicy"/> <int value="2919" label="ScrollByPrecisionTouchPad"/> <int value="2920" label="PinchZoom"/> - <int value="2921" label="BuiltInModuleSwitchImported"/> + <int value="2921" label="OBSOLETE_BuiltInModuleSwitchImported"/> <int value="2922" label="FeaturePolicyCommaSeparatedDeclarations"/> <int value="2923" label="FeaturePolicySemicolonSeparatedDeclarations"/> <int value="2924" label="V8CallSiteAPIGetFunctionSloppyCall"/> <int value="2925" label="V8CallSiteAPIGetThisSloppyCall"/> - <int value="2926" label="BuiltInModuleToast"/> + <int value="2926" label="OBSOLETE_BuiltInModuleToast"/> <int value="2927" label="LargestContentfulPaintExplicitlyRequested"/> <int value="2928" label="PageFreezeOptIn"/> <int value="2929" label="PageFreezeOptOut"/> @@ -65110,6 +65110,7 @@ <int value="1717226620" label="CROS Cr50 0.4.14 Flags 0x10(pre-pvt)"/> <int value="1733077393" label="IFX 9645 rev 49 fw 133.33 build 00e3"/> <int value="1774347833" label="CROS Cr50 0.0.15"/> + <int value="1787609211" label="CROS Cr50 0.3.26"/> <int value="1799811131" label="CROS Cr50 0.3.9"/> <int value="1828625721" label="IFX 9655 rev 32 fw 4.31 build 02c2"/> <int value="1848357394" label="CROS Cr50 0.4.11 Flags 0x10(pre-pvt)"/>
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index e5d145b5..162c4daf 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml
@@ -292,7 +292,7 @@ </histogram> <histogram name="Accessibility.CrosSelectToSpeak" enum="BooleanEnabled" - expires_after="2020-07-13"> + expires_after="2020-09-13"> <owner>dmazzoni@chromium.org</owner> <owner>katie@chromium.org</owner> <owner>chrome-a11y-core@google.com</owner> @@ -745,7 +745,7 @@ </histogram> <histogram name="Accessibility.Shortcuts.CrosScreenMagnifier" - enum="BooleanEnabled" expires_after="2020-06-20"> + enum="BooleanEnabled" expires_after="2020-09-13"> <owner>amraboelkher@chromium.org</owner> <owner>poromov@chromium.org</owner> <summary> @@ -887,7 +887,7 @@ </histogram> <histogram name="Accessibility.WinScreenReader2" enum="BooleanEnabled" - expires_after="2020-07-06"> + expires_after="2020-09-13"> <!-- expires-never: usage drives a11y prioritization in browser and content. --> <owner>aleventhal@chromium.org</owner> @@ -1861,7 +1861,7 @@ </histogram> <histogram name="Android.AppNotificationStatus" enum="NotificationAppStatus" - expires_after="2020-07-13"> + expires_after="2020-09-13"> <owner>peter@chromium.org</owner> <summary> Records whether notifications are enabled for Chrome, as the Android app, @@ -7837,7 +7837,7 @@ </histogram> <histogram name="Arc.OptInCancel" enum="ArcOptInCancel" - expires_after="2020-07-13"> + expires_after="2020-09-13"> <owner>elijahtaylor@google.com</owner> <owner>shihuis@google.com</owner> <summary>Arc OptIn cancelation reason.</summary> @@ -8886,7 +8886,7 @@ </histogram> <histogram base="true" name="Ash.HotseatWidgetAnimation.AnimationSmoothness" - units="%" expires_after="2020-05-21"> + units="%" expires_after="2020-09-13"> <!-- Name completed by histogram suffixes name="HotseatTransitionType" --> @@ -9211,7 +9211,7 @@ </histogram> <histogram name="Ash.PowerButtonScreenshot.DelayBetweenAccelKeyPressed" - units="ms" expires_after="2020-06-30"> + units="ms" expires_after="2020-09-13"> <owner>zentaro@chromium.org</owner> <owner>baileyberro@chromium.org</owner> <summary> @@ -9280,7 +9280,7 @@ </histogram> <histogram name="Ash.Shelf.NumberOfItems" units="Icons" - expires_after="2020-07-13"> + expires_after="2020-09-13"> <owner>anasalazar@google.com</owner> <owner>mmourgos@google.com</owner> <summary> @@ -9300,7 +9300,7 @@ </histogram> <histogram name="Ash.Shelf.NumberOfUnpinnedItems" units="Icons" - expires_after="2020-07-13"> + expires_after="2020-09-13"> <owner>anasalazar@google.com</owner> <owner>mmourgos@google.com</owner> <summary> @@ -11868,7 +11868,7 @@ </histogram> <histogram name="AuthPolicy.TimeToGetUserKerberosFiles" units="ms" - expires_after="2020-06-07"> + expires_after="2020-09-13"> <owner>fsandrade@chromium.org</owner> <owner>tomdobro@chromium.org</owner> <summary> @@ -19550,7 +19550,7 @@ </histogram> <histogram name="Blink.VisibleBeforeLoaded.LazyLoadImages.AboveTheFold" - enum="NQEEffectiveConnectionType" expires_after="2020-07-13"> + enum="NQEEffectiveConnectionType" expires_after="2020-09-13"> <owner>sclittle@chromium.org</owner> <owner>rajendrant@chromium.org</owner> <summary> @@ -21989,7 +21989,7 @@ </histogram> <histogram name="BrowserSwitcher.LaunchSuccess" enum="BooleanSuccess" - expires_after="2020-06-18"> + expires_after="2020-09-13"> <owner>nicolaso@chromium.org</owner> <owner>pastarmovj@chromium.org</owner> <summary> @@ -21999,7 +21999,7 @@ </histogram> <histogram name="BrowserSwitcher.LaunchTime" units="ms" - expires_after="2020-06-18"> + expires_after="2020-09-13"> <owner>nicolaso@chromium.org</owner> <owner>pastarmovj@chromium.org</owner> <summary> @@ -23785,7 +23785,7 @@ </histogram> <histogram name="ChromeOS.Apps.IntentPickerDestinationPlatform" - enum="ArcIntentHandlerDestinationPlatform" expires_after="2020-07-13"> + enum="ArcIntentHandlerDestinationPlatform" expires_after="2020-09-13"> <owner>elijahtaylor@google.com</owner> <owner>dominickn@chromium.org</owner> <owner>shihuis@google.com</owner> @@ -23809,11 +23809,12 @@ <histogram base="true" name="ChromeOS.Camera.ConfigureStreams.Output.Resolution" units="pixels" - expires_after="2020-04-25"> + expires_after="2021-03-15"> <!-- Name completed by histogram_suffixes name="ChromeOS.Camera.StreamFormat" --> <owner>wtlee@chromium.org</owner> + <owner>chromeos-camera-eng@google.com</owner> <summary> Records the resolution of output stream that is configured by Chrome OS camera service. @@ -23821,17 +23822,22 @@ </histogram> <histogram name="ChromeOS.Camera.ConfigureStreamsLatency" units="microseconds" - expires_after="2020-04-25"> + expires_after="2021-03-15"> <owner>wtlee@chromium.org</owner> + <owner>chromeos-camera-eng@google.com</owner> <summary> Records the process time of ConfigureStreams() method in Chrome OS camera service. + + This metric is reported for all users and will not cause abnormal + distribution since the metric is Chrome OS specified. </summary> </histogram> <histogram name="ChromeOS.Camera.ErrorType" enum="ChromeOSCameraErrorType" - expires_after="2020-04-25"> + expires_after="2021-03-15"> <owner>wtlee@chromium.org</owner> + <owner>chromeos-camera-eng@google.com</owner> <summary> Records the type of the error which triggers the Notify() method in Chrome OS camera service. @@ -23839,35 +23845,41 @@ </histogram> <histogram name="ChromeOS.Camera.Facing" enum="ChromeOSCameraFacing" - expires_after="2020-04-25"> + expires_after="2021-03-15"> <owner>wtlee@chromium.org</owner> + <owner>chromeos-camera-eng@google.com</owner> <summary> Records the camera facing of the camera session in Chrome OS camera service. </summary> </histogram> <histogram base="true" name="ChromeOS.Camera.Jpeg.Latency" units="microseconds" - expires_after="2020-04-25"> + expires_after="2021-03-15"> <!-- Name completed by histogram_suffixes name="ChromeOS.Camera.JpegProcessMethod" and name="ChromeOS.Camera.JpegProcessType" --> <owner>wtlee@chromium.org</owner> + <owner>chromeos-camera-eng@google.com</owner> <summary> Records the process time of the JDA (Jpeg Decode Accelerator) or JEA (Jpeg Encode Accelerator) run on Chrome OS camera service. There are suffixes that record the runner method (hardware/software), the runner type (decode/encode). + + This metric is reported for all users and will not cause abnormal + distribution since the metric is Chrome OS specified. </summary> </histogram> <histogram base="true" name="ChromeOS.Camera.Jpeg.Resolution" units="pixels" - expires_after="2020-04-25"> + expires_after="2021-03-15"> <!-- Name completed by histogram_suffixes name="ChromeOS.Camera.JpegProcessMethod" and name="ChromeOS.Camera.JpegProcessType" --> <owner>wtlee@chromium.org</owner> + <owner>chromeos-camera-eng@google.com</owner> <summary> Records the resolution of the image that JDA/JEA process by Chrome OS camera service. The resolution represents by the total pixels contained in the @@ -23877,16 +23889,21 @@ </histogram> <histogram name="ChromeOS.Camera.OpenDeviceLatency" units="microseconds" - expires_after="2020-04-25"> + expires_after="2021-03-15"> <owner>wtlee@chromium.org</owner> + <owner>chromeos-camera-eng@google.com</owner> <summary> Records the process time of OpenDevice() method in Chrome OS camera service. + + This metric is reported for all users and will not cause abnormal + distribution since the metric is Chrome OS specified. </summary> </histogram> <histogram name="ChromeOS.Camera.SessionDuration" units="seconds" - expires_after="2020-04-25"> + expires_after="2021-03-15"> <owner>wtlee@chromium.org</owner> + <owner>chromeos-camera-eng@google.com</owner> <summary>Records the session duration in Chrome OS camera service.</summary> </histogram> @@ -28752,7 +28769,7 @@ </summary> </histogram> -<histogram name="Cookie.Count" units="units" expires_after="2020-07-13"> +<histogram name="Cookie.Count" units="units" expires_after="2020-09-13"> <owner>battre@chromium.org</owner> <summary> Number of cookies in the store (recorded every 10 minutes of active browsing @@ -28849,7 +28866,7 @@ </summary> </histogram> -<histogram name="Cookie.HeaderLength" units="bytes" expires_after="2020-07-13"> +<histogram name="Cookie.HeaderLength" units="bytes" expires_after="2020-09-13"> <owner>mkwst@chromium.org</owner> <summary> The size of each outgoing request's 'Cookie' header field's value, in bytes. @@ -32208,7 +32225,7 @@ </histogram> <histogram name="Cryptohome.MigrationUI.MigrationResult" - enum="MigrationUIMigrationResult" expires_after="2020-07-01"> + enum="MigrationUIMigrationResult" expires_after="2020-09-13"> <owner>fukino@chromium.org</owner> <summary> The result of encryption migration from eCryptfs to Ext4 dircrypto. The @@ -45588,7 +45605,7 @@ </histogram> <histogram name="EnterpriseCheck.IsDomainJoined" enum="BooleanEnabled" - expires_after="2020-07-06"> + expires_after="2020-09-13"> <owner>mad@chromium.org</owner> <summary> Whether the machine is joined to an AD domain. This check is performed once @@ -47597,7 +47614,7 @@ </histogram> <histogram name="Event.Latency.ScrollBegin.Touch.GpuSwap2" units="microseconds" - expires_after="2020-07-13"> + expires_after="2020-09-13"> <owner>tdresser@chromium.org</owner> <summary> Time between gpu starts to swap the first ScrollUpdate gesture event in a @@ -57477,7 +57494,7 @@ </histogram> <histogram name="FirstRun.NewUserExperience.NtpBackgroundInteraction" - enum="NuxNtpBackgroundInteractions" expires_after="2020-07-13"> + enum="NuxNtpBackgroundInteractions" expires_after="2020-09-13"> <owner>hcarmona@chromium.org</owner> <owner>johntlee@chromium.org</owner> <summary> @@ -59679,7 +59696,7 @@ </summary> </histogram> -<histogram name="GPU.ContextMemory" units="MB" expires_after="2020-07-13"> +<histogram name="GPU.ContextMemory" units="MB" expires_after="2020-09-13"> <owner>ericrk@chromium.org</owner> <summary>The amount of memory used by a GL Context.</summary> </histogram> @@ -59745,7 +59762,7 @@ </histogram> <histogram name="GPU.D3DShaderModel" enum="ShaderModel" - expires_after="2020-07-06"> + expires_after="2020-09-13"> <owner>jmadill@chromium.org</owner> <summary> ANGLE's currently active D3D shader model version. Logged once every startup @@ -61119,7 +61136,7 @@ </histogram> <histogram name="GPU.SwapTimeUs" units="microseconds" - expires_after="2020-07-13"> + expires_after="2020-09-13"> <owner>vasilyt@chromium.org</owner> <owner>backer@chromium.org</owner> <summary> @@ -61239,7 +61256,7 @@ </histogram> <histogram name="GPU.WatchdogThread.ExtraThreadTime" units="# timeouts" - expires_after="2020-07-06"> + expires_after="2020-09-13"> <!-- Name completed by histogram_suffixes name="GPU.WatchdogStage" --> <owner>magchen@chromium.org</owner> @@ -61251,7 +61268,7 @@ </histogram> <histogram name="GPU.WatchdogThread.ExtraThreadTime.NumOfUsers" - units="# timeouts" expires_after="2020-07-06"> + units="# timeouts" expires_after="2020-09-13"> <owner>magchen@chromium.org</owner> <owner>zmo@chromium.org</owner> <summary> @@ -61274,7 +61291,7 @@ </histogram> <histogram name="GPU.WatchdogThread.V1.ExtraThreadTime" units="ms" - expires_after="2020-07-06"> + expires_after="2020-09-13"> <owner>magchen@chromium.org</owner> <owner>zmo@chromium.org</owner> <summary> @@ -61645,7 +61662,7 @@ </histogram> <histogram base="true" name="GridTabSwitcher.DirtySpan" units="ms" - expires_after="2020-05-03"> + expires_after="2020-09-13"> <owner>yusufo@chromium.org</owner> <owner>wychen@chromium.org</owner> <summary> @@ -71056,9 +71073,11 @@ </summary> </histogram> -<histogram name="Media.AudioInputController" units="ms" - expires_after="2020-04-05"> +<histogram name="Media.AudioInputController" units="ms" expires_after="never"> +<!-- expires-never: Audio pipeline health metric. --> + <owner>dalecurtis@chromium.org</owner> + <owner>media-dev@chromium.org</owner> <summary>Measures the time taken for AudioInputController::</summary> </histogram> @@ -71148,8 +71167,11 @@ </histogram> <histogram name="Media.AudioOutputControllerDataNotReady" units="ms" - expires_after="2020-04-05"> + expires_after="never"> +<!-- expires-never: Audio pipeline health metric. --> + <owner>dalecurtis@chromium.org</owner> + <owner>media-dev@chromium.org</owner> <summary> Time spent waiting in AudioOutputController::WaitTillDataReady() if the data was not initially available. @@ -71157,8 +71179,11 @@ </histogram> <histogram name="Media.AudioOutputControllerPlaybackStartupSuccess" - enum="BooleanSuccess" expires_after="2020-04-05"> + enum="BooleanSuccess" expires_after="never"> +<!-- expires-never: Audio pipeline health metric. --> + <owner>dalecurtis@chromium.org</owner> + <owner>media-dev@chromium.org</owner> <summary> Whether playback started successfully after stream startup was requested. </summary> @@ -71507,8 +71532,11 @@ </histogram> <histogram name="Media.AudioThreadStatus" enum="AudioThreadStatus" - expires_after="2020-04-05"> + expires_after="never"> +<!-- expires-never: Audio pipeline health metric. --> + <owner>dalecurtis@chromium.org</owner> + <owner>media-dev@chromium.org</owner> <summary> State of the audio thread. A value of "started" is emitted once the hang monitor has been initialized. If the thread is detected as hung @@ -72763,8 +72791,11 @@ </histogram> <histogram name="Media.FallbackToHighLatencyAudioPath" - enum="BooleanDidFallBack" expires_after="M82"> + enum="BooleanDidFallBack" expires_after="never"> +<!-- expires-never: Media pipeline health metric. --> + <owner>dalecurtis@chromium.org</owner> + <owner>media-dev@chromium.org</owner> <summary> Whether Chrome had to fallback to the high latency audio path or not. </summary> @@ -72997,8 +73028,11 @@ </histogram> <histogram name="Media.HasEverPlayed" enum="BooleanHasPlayed" - expires_after="2020-04-05"> + expires_after="never"> +<!-- expires-never: Media pipeline health metric. --> + <owner>dalecurtis@chromium.org</owner> + <owner>media-dev@chromium.org</owner> <summary> Whether a given WebMediaPlayer instance, after preload, started playback; recorded once at time of player destruction. @@ -74089,8 +74123,11 @@ </summary> </histogram> -<histogram name="Media.RebuffersCount" units="rebuffers" expires_after="M82"> +<histogram name="Media.RebuffersCount" units="rebuffers" expires_after="never"> +<!-- expires-never: Media pipeline health metric. --> + <owner>dalecurtis@chromium.org</owner> + <owner>media-dev@chromium.org</owner> <summary> Indicates the number of rebuffers a given watch time session had. </summary> @@ -75549,8 +75586,11 @@ </histogram> <histogram name="Media.VideoDecoderFallback" enum="BooleanDidFallBack" - expires_after="M82"> + expires_after="never"> +<!-- expires-never: Media pipeline health metric. --> + <owner>dalecurtis@chromium.org</owner> + <owner>media-dev@chromium.org</owner> <summary> Whether Chrome had to fall back to a secondary video decoder after the primary decoder failed reinitialization. @@ -75690,8 +75730,11 @@ </histogram> <histogram name="Media.VideoRenderer.CadenceChanges" units="changes" - expires_after="M82"> + expires_after="never"> +<!-- expires-never: Media pipeline health metric. --> + <owner>dalecurtis@chromium.org</owner> + <owner>media-dev@chromium.org</owner> <summary> Indicates how many cadence changes have occurred during playback, a zero value is emitted at the beginning of playback. Subsequent values are emitted @@ -166197,7 +166240,7 @@ </histogram> <histogram name="Tracing.Background.FinalizationDisallowedReason" - enum="TracingFinalizationDisallowedReason" expires_after="2020-07-13"> + enum="TracingFinalizationDisallowedReason" expires_after="2020-09-13"> <owner>ssid@chromium.org</owner> <summary> Reason why background tracing finalization was not allowed. Also see @@ -166207,7 +166250,7 @@ </histogram> <histogram name="Tracing.Background.FinalizingTraceSizeInKB" units="KB" - expires_after="2020-07-13"> + expires_after="2020-09-13"> <owner>oysteine@chromium.org</owner> <summary> The size, in kilobytes, of a finalized trace ready to be uploaded. @@ -167440,7 +167483,7 @@ </histogram> <histogram name="UKM.UserDemographics.Status" enum="UserDemographicsStatus" - expires_after="2020-07-13"> + expires_after="2020-09-13"> <owner>vincb@google.com</owner> <owner>ukm-team@google.com</owner> <summary> @@ -168631,7 +168674,7 @@ </histogram> <histogram name="UMA.TruncatedEvents.UserAction" units="events" - expires_after="2020-09-06"> + expires_after="2020-09-13"> <owner>rkaplow@chromium.org</owner> <owner>src/base/metrics/OWNERS</owner> <summary> @@ -168717,7 +168760,7 @@ </histogram> <histogram name="UMA.UserDemographics.Status" enum="UserDemographicsStatus" - expires_after="2020-07-13"> + expires_after="2020-09-13"> <owner>vincb@google.com</owner> <owner>src/base/metrics/OWNERS</owner> <summary> @@ -174684,7 +174727,7 @@ </histogram> <histogram name="WebAuthentication.GetAssertionRequestTransport" - enum="WebAuthenticationFidoTransport" expires_after="2020-07-13"> + enum="WebAuthenticationFidoTransport" expires_after="2020-09-13"> <owner>kenrb@chromium.org</owner> <owner>kpaulhamus@chromium.org</owner> <summary> @@ -174695,7 +174738,7 @@ </histogram> <histogram name="WebAuthentication.GetAssertionResponseTransport" - enum="WebAuthenticationFidoTransport" expires_after="2020-07-13"> + enum="WebAuthenticationFidoTransport" expires_after="2020-09-13"> <owner>kenrb@chromium.org</owner> <owner>kpaulhamus@chromium.org</owner> <summary> @@ -174715,7 +174758,7 @@ </histogram> <histogram name="WebAuthentication.MakeCredentialRequestTransport" - enum="WebAuthenticationFidoTransport" expires_after="2020-07-13"> + enum="WebAuthenticationFidoTransport" expires_after="2020-09-13"> <owner>kenrb@chromium.org</owner> <owner>kpaulhamus@chromium.org</owner> <summary> @@ -174726,7 +174769,7 @@ </histogram> <histogram name="WebAuthentication.MakeCredentialResponseTransport" - enum="WebAuthenticationFidoTransport" expires_after="2020-07-13"> + enum="WebAuthenticationFidoTransport" expires_after="2020-09-13"> <owner>kenrb@chromium.org</owner> <owner>kpaulhamus@chromium.org</owner> <summary> @@ -178690,7 +178733,7 @@ </histogram> <histogram name="WebRTC.ReceivedAudioTrackDuration" units="ms" - expires_after="2020-06-07"> + expires_after="2020-09-13"> <owner>perkj@chromium.org</owner> <summary> Durations of audio tracks received over a PeerConnection. The stopwatch @@ -178700,7 +178743,7 @@ </histogram> <histogram name="WebRTC.ReceivedVideoTrackDuration" units="ms" - expires_after="2020-06-28"> + expires_after="2020-09-13"> <owner>perkj@chromium.org</owner> <summary> Durations of video tracks received over a PeerConnection. The stopwatch @@ -178710,7 +178753,7 @@ </histogram> <histogram name="WebRTC.ReliableDataChannelMessageSize" units="bytes" - expires_after="2020-05-31"> + expires_after="2020-09-13"> <owner>perkj@chromium.org</owner> <summary> Sizes of messages sent over reliable data channels. The size of an @@ -178726,7 +178769,7 @@ </histogram> <histogram name="WebRTC.SentAudioTrackDuration" units="ms" - expires_after="2020-06-28"> + expires_after="2020-09-13"> <owner>perkj@chromium.org</owner> <summary> Durations of audio tracks sent over a PeerConnection. The stopwatch starts @@ -178815,7 +178858,7 @@ </histogram> <histogram name="WebRTC.UnreliableDataChannelMessageSize" units="bytes" - expires_after="2020-05-31"> + expires_after="2020-09-13"> <owner>perkj@chromium.org</owner> <summary> Sizes of messages sent over unreliable data channels. The size of an @@ -179244,7 +179287,7 @@ </histogram> <histogram name="WebRTC.Video.InterframeDelay95PercentileInMs" units="ms" - expires_after="2020-07-13"> + expires_after="2020-09-13"> <owner>ilnik@chromium.org</owner> <summary> The 95th percentile of interframe delay for a received video stream. @@ -180171,7 +180214,7 @@ </histogram> <histogram name="WebRTC.Video.TimeInBlockyVideoPercentage" units="%" - expires_after="2020-07-13"> + expires_after="2020-09-13"> <owner>ilnik@chromium.org</owner> <summary> Percentage of time the receive video stream playbacks low quality blocky @@ -180279,7 +180322,7 @@ </histogram> <histogram name="WebRtcEventLogging.Upload" enum="WebRtcEventLoggingUploadEnum" - expires_after="2020-07-13"> + expires_after="2020-09-13"> <owner>eladalon@chromium.org</owner> <owner>saeedj@google.com</owner> <owner>manj@google.com</owner> @@ -187102,6 +187145,18 @@ <suffix name="TotalLatency" label="Total latency from when the event is generated until the frame is presented on screen."/> + <affected-histogram name="EventLatency.GestureScrollBegin.Autoscroll"/> + <affected-histogram name="EventLatency.GestureScrollBegin.Scrollbar"/> + <affected-histogram name="EventLatency.GestureScrollBegin.Touchscreen"/> + <affected-histogram name="EventLatency.GestureScrollBegin.Wheel"/> + <affected-histogram name="EventLatency.GestureScrollEnd.Autoscroll"/> + <affected-histogram name="EventLatency.GestureScrollEnd.Scrollbar"/> + <affected-histogram name="EventLatency.GestureScrollEnd.Touchscreen"/> + <affected-histogram name="EventLatency.GestureScrollEnd.Wheel"/> + <affected-histogram name="EventLatency.GestureScrollUpdate.Autoscroll"/> + <affected-histogram name="EventLatency.GestureScrollUpdate.Scrollbar"/> + <affected-histogram name="EventLatency.GestureScrollUpdate.Touchscreen"/> + <affected-histogram name="EventLatency.GestureScrollUpdate.Wheel"/> <affected-histogram name="EventLatency.KeyPressed"/> <affected-histogram name="EventLatency.KeyReleased"/> <affected-histogram name="EventLatency.MousePressed"/> @@ -187124,7 +187179,27 @@ <affected-histogram name="Event.Latency.OS_NO_VALIDATION.POSITIVE"/> </histogram_suffixes> +<histogram_suffixes name="EventLatencyScrollTypes" separator="."> + <suffix base="true" name="Autoscroll" + label="Event latency for autoscroll events."/> + <suffix base="true" name="Scrollbar" + label="Event latency for scrollbar scroll events."/> + <suffix base="true" name="Touchscreen" + label="Event latency for touchscreen scroll events."/> + <suffix base="true" name="Wheel" + label="Event latency for mousewheel scroll events."/> + <affected-histogram name="EventLatency.GestureScrollBegin"/> + <affected-histogram name="EventLatency.GestureScrollEnd"/> + <affected-histogram name="EventLatency.GestureScrollUpdate"/> +</histogram_suffixes> + <histogram_suffixes name="EventLatencyTypes" separator="."> + <suffix base="true" name="GestureScrollBegin" + label="Event latency for gesture-scroll-begin event."/> + <suffix base="true" name="GestureScrollEnd" + label="Event latency for gesture-scroll-end event."/> + <suffix base="true" name="GestureScrollUpdate" + label="Event latency for gesture-scroll-update event."/> <suffix base="true" name="KeyPressed" label="Event latency for key-pressed event."/> <suffix base="true" name="KeyReleased"
diff --git a/tools/perf/core/tbmv3/metrics/janky_scroll_periods.sql b/tools/perf/core/tbmv3/metrics/janky_scroll_periods.sql index 3bc0ffa..f39477b 100644 --- a/tools/perf/core/tbmv3/metrics/janky_scroll_periods.sql +++ b/tools/perf/core/tbmv3/metrics/janky_scroll_periods.sql
@@ -18,10 +18,9 @@ -- Get the GestureScrollUpdate events by name ordered by timestamp, compute -- the number of frames (relative to 60 fps) that each event took. 1.6e+7 is -- 16 ms in nanoseconds. --- Note that here and further below the result is a table not a view because --- it speeds up the metric computation. -CREATE TABLE GestureScrollUpdates AS +CREATE VIEW GestureScrollUpdates AS SELECT + ROW_NUMBER() OVER (ORDER BY ts ASC) AS rowNumber, id AS ScrollId, ts AS ScrollTs, arg_set_id AS ScrollArgSetId, @@ -34,23 +33,13 @@ name = 'InputLatency::GestureScrollUpdate' ORDER BY ScrollTs; --- TODO(khokhlov): This is pretty slow and should be rewritten using window --- functions when they are enabled in Chrome's sqlite. -CREATE TABLE GestureScrollUpdatesWithRowNumbers AS -SELECT - (SELECT COUNT(*) - FROM GestureScrollUpdates prev - WHERE prev.ScrollTs < next.ScrollTs) + 1 as rowNumber, - * -FROM - GestureScrollUpdates next; - -- This takes the GestureScrollUpdate and joins it to the previous row (NULL -- if there isn't one) and the next row (NULL if there isn't one). And then -- computes whether the duration of the event (relative to 60 fps) varied by -- more than 0.5 (which is 1/2 of 16 ms). -CREATE TABLE ScrollJanksComplete AS +CREATE VIEW ScrollJanksComplete AS SELECT + ROW_NUMBER() OVER (ORDER BY currTs ASC) AS rowNumber, currScrollId, currTs, currScrollFramesExact, @@ -83,23 +72,12 @@ curr.ScrollFramesExact AS currScrollFramesExact, prev.ScrollFramesExact AS prevScrollFramesExact FROM - GestureScrollUpdatesWithRowNumbers curr LEFT JOIN - GestureScrollUpdatesWithRowNumbers prev ON prev.rowNumber + 1 = curr.rowNumber + GestureScrollUpdates curr LEFT JOIN + GestureScrollUpdates prev ON prev.rowNumber + 1 = curr.rowNumber ) currprev JOIN - GestureScrollUpdatesWithRowNumbers next ON currprev.currRowNumber + 1 = next.rowNumber + GestureScrollUpdates next ON currprev.currRowNumber + 1 = next.rowNumber ORDER BY currprev.currTs ASC; --- TODO(khokhlov): This is pretty slow and should be rewritten using window --- functions when they are enabled in Chrome's sqlite. -CREATE TABLE ScrollJanksCompleteWithRowNumbers AS -SELECT - (SELECT COUNT(*) - FROM ScrollJanksComplete prev - WHERE prev.currTs < next.currTs) + 1 as rowNumber, - * -FROM - ScrollJanksComplete next; - -- This just lists outs the rowNumber (which is ordered by timestamp) and -- whether it was a janky slice (as defined by comparing to both the next and -- previous slice). @@ -110,7 +88,7 @@ (nextJank AND prevJank IS NULL) OR (prevJank AND nextJank IS NULL) AS Jank - FROM ScrollJanksCompleteWithRowNumbers; + FROM ScrollJanksComplete; -- This sums the number of periods with sequential janky slices. When Chrome -- experiences a jank it often stumbles for a while, this attempts to
diff --git a/tools/perf/core/tbmv3/metrics/janky_time_per_scroll_processing_time.sql b/tools/perf/core/tbmv3/metrics/janky_time_per_scroll_processing_time.sql index 599413c..3b5c9e4 100644 --- a/tools/perf/core/tbmv3/metrics/janky_time_per_scroll_processing_time.sql +++ b/tools/perf/core/tbmv3/metrics/janky_time_per_scroll_processing_time.sql
@@ -46,10 +46,11 @@ -- IDs to group them together into scrolls later and the timestamp and duration -- to compute the duration of the scroll. -DROP TABLE IF EXISTS ScrollBeginsAndEnds; +DROP VIEW IF EXISTS ScrollBeginsAndEnds; -CREATE TABLE ScrollBeginsAndEnds AS +CREATE VIEW ScrollBeginsAndEnds AS SELECT + ROW_NUMBER() OVER (ORDER BY ts ASC) AS rowNumber, name, id AS scrollId, ts AS scrollTs, @@ -63,31 +64,17 @@ ) ORDER BY ts ASC; --- TODO(nuskos): Once chromium TBMv3 supports windowing functions use --- ROW_NUMBER(ORDER BY ts ASC) OVER() instead. - -DROP TABLE IF EXISTS ScrollBeginsAndEndsRowNumbers; - -CREATE TABLE ScrollBeginsAndEndsRowNumbers AS -SELECT - (SELECT COUNT(*) - FROM ScrollBeginsAndEnds prev - WHERE prev.scrollTs < next.scrollTs) + 1 as rowNumber, - * -FROM - ScrollBeginsAndEnds next; - -- Now we take the Begin and the End events and join the information into a -- single row per scroll. -DROP TABLE IF EXISTS JoinedScrollBeginsAndEnds; +DROP VIEW IF EXISTS JoinedScrollBeginsAndEnds; -CREATE TABLE JoinedScrollBeginsAndEnds AS +CREATE VIEW JoinedScrollBeginsAndEnds AS SELECT begin.scrollId AS beginId, begin.scrollTs AS scrollBegin, end.scrollTs + end.scrollDur AS maybeScrollEnd - FROM ScrollBeginsAndEndsRowNumbers begin JOIN ScrollBeginsAndEndsRowNumbers end ON + FROM ScrollBeginsAndEnds begin JOIN ScrollBeginsAndEnds end ON begin.rowNumber + 1 = end.rowNumber AND begin.name = 'InputLatency::GestureScrollBegin' AND end.name = 'InputLatency::GestureScrollEnd'; @@ -101,10 +88,11 @@ -- and can't reasonably determine what it should be. We have separate tracking -- to ensure this only happens at the end of the trace. -DROP TABLE IF EXISTS GestureScrollUpdates; +DROP VIEW IF EXISTS GestureScrollUpdates; -CREATE TABLE GestureScrollUpdates AS +CREATE VIEW GestureScrollUpdates AS SELECT + ROW_NUMBER() OVER (ORDER BY ts ASC) AS rowNumber, beginId, scrollBegin, CASE WHEN @@ -139,21 +127,6 @@ scrollUpdate.ts >= beginAndEnd.ScrollBegin ORDER BY ts ASC; --- TODO(nuskos): Once chromium TBMv3 supports windowing functions use --- ROW_NUMBER(ORDER BY ts ASC) OVER() instead. - -DROP TABLE IF EXISTS GestureScrollUpdatesRowNumbers; - -CREATE TABLE GestureScrollUpdatesRowNumbers AS -SELECT - (SELECT COUNT(*) - FROM GestureScrollUpdates prev - WHERE prev.scrollTs < next.scrollTs) + 1 as rowNumber, - * -FROM - GestureScrollUpdates next; - - -- This takes the GestureScrollUpdate and joins it to the previous row (NULL -- if there isn't one) and the next row (NULL if there isn't one). And then -- computes if the duration of the event (relative to 60 fps) increased by more @@ -164,10 +137,11 @@ -- (currBeginId == prev/next BeginId). This controls somewhat for variability -- of scrolls. -DROP TABLE IF EXISTS ScrollJanksMaybeNull; +DROP VIEW IF EXISTS ScrollJanksMaybeNull; -CREATE TABLE ScrollJanksMaybeNull AS +CREATE VIEW ScrollJanksMaybeNull AS SELECT + ROW_NUMBER() OVER (ORDER BY currScrollTs ASC) AS rowNumber, currBeginId, currUpdateDur, currScrollDur, @@ -198,35 +172,19 @@ prev.beginId as prevBeginId, prev.scrollFramesExact AS prevScrollFramesExact FROM - GestureScrollUpdatesRowNumbers curr LEFT JOIN - GestureScrollUpdatesRowNumbers prev ON prev.rowNumber + 1 = curr.rowNumber + GestureScrollUpdates curr LEFT JOIN + GestureScrollUpdates prev ON prev.rowNumber + 1 = curr.rowNumber ) currprev JOIN - GestureScrollUpdatesRowNumbers next ON currprev.currRowNumber + 1 = next.rowNumber + GestureScrollUpdates next ON currprev.currRowNumber + 1 = next.rowNumber ORDER BY currprev.currScrollTs ASC; --- TODO(nuskos): Once chromium TBMv3 supports windowing functions use --- ROW_NUMBER(ORDER BY ts ASC) OVER() instead. - -DROP TABLE IF EXISTS ScrollJanksMaybeNullRowNumbers; - -CREATE TABLE ScrollJanksMaybeNullRowNumbers AS -SELECT - (SELECT COUNT(*) - FROM ScrollJanksMaybeNull prev - WHERE prev.currScrollTs < next.currScrollTs) + 1 as rowNumber, - * -FROM - ScrollJanksMaybeNull next; - - - -- This just lists outs the rowNumber (which is ordered by timestamp), its jank -- status and information about the update and scroll overall. Basically -- getting it into a next queriable format. -DROP TABLE IF EXISTS ScrollJanks; +DROP VIEW IF EXISTS ScrollJanks; -CREATE TABLE ScrollJanks AS +CREATE VIEW ScrollJanks AS SELECT rowNumber, currBeginId, @@ -235,7 +193,7 @@ (nextJank IS NOT NULL AND nextJank) OR (prevJank IS NOT NULL AND prevJank) AS jank - FROM ScrollJanksMaybeNullRowNumbers; + FROM ScrollJanksMaybeNull; -- Compute the total amount of nanoseconds from Janky GestureScrollUpdates and -- the total amount of nanoseconds we spent scrolling in the trace. Also need @@ -250,9 +208,9 @@ -- TODO(nuskos): We should support more types (floats and strings) in our -- metrics as well as support for specifying units (nanoseconds). -DROP TABLE IF EXISTS JankyNanosPerScrollNanosMaybeNull; +DROP VIEW IF EXISTS JankyNanosPerScrollNanosMaybeNull; -CREATE TABLE JankyNanosPerScrollNanosMaybeNull AS +CREATE VIEW JankyNanosPerScrollNanosMaybeNull AS SELECT SUM(jank) as numJankyUpdates, SUM(CASE WHEN jank = 1 THEN @@ -270,9 +228,9 @@ ) AS scrollNanos FROM ScrollJanks; -DROP TABLE IF EXISTS janky_time_per_scroll_processing_time; +DROP VIEW IF EXISTS janky_time_per_scroll_processing_time; -CREATE TABLE janky_time_per_scroll_processing_time AS +CREATE VIEW janky_time_per_scroll_processing_time AS SELECT (SELECT CASE WHEN @@ -297,9 +255,9 @@ -- Specify how to fill the metrics proto properly. -DROP TABLE IF EXISTS janky_time_per_scroll_processing_time_output; +DROP VIEW IF EXISTS janky_time_per_scroll_processing_time_output; -CREATE TABLE janky_time_per_scroll_processing_time_output AS +CREATE VIEW janky_time_per_scroll_processing_time_output AS SELECT JankyTimePerScrollProcessingTime( 'janky_time_per_scroll_processing_time_percentage', jankyPercentage, 'gesture_scroll_milliseconds', CAST(scrollMillis AS INT),
diff --git a/tools/perf/core/tbmv3/metrics/scroll_jank_metric.sql b/tools/perf/core/tbmv3/metrics/scroll_jank_metric.sql index 14a5f36b..83f6cfe 100644 --- a/tools/perf/core/tbmv3/metrics/scroll_jank_metric.sql +++ b/tools/perf/core/tbmv3/metrics/scroll_jank_metric.sql
@@ -11,35 +11,22 @@ -- to leave only one of them. -- TODO(khokhlov): Remove one of these metrics. --- This selects GestureScrollUpdate events. Note the result is a table not a --- view to speed up the metric computation. -CREATE TABLE input_latency_events AS +-- This selects GestureScrollUpdate events. +CREATE VIEW input_latency_events AS SELECT ts AS start, ts + dur AS finish FROM slice WHERE name = "InputLatency::GestureScrollUpdate"; --- This selects timestamps of finishes of GestureScrollUpdate events, and for --- each finish, finds the timestamp of the next finish. --- TODO(khokhlov): This query is pretty slow. Rewrite using window functions --- when they are enabled in Chrome's sqlite. -CREATE TABLE next_finish AS -SELECT - finish, - (SELECT MIN(next.finish) - FROM input_latency_events next - WHERE next.finish > prev.finish) AS next_finish -FROM input_latency_events prev; - -- Every row of this query is a span from one event finish to the next. -- Column names 'ts' and 'dur' are as expected by SPAN_JOIN function. CREATE VIEW intervals_between_finishes AS SELECT finish AS ts, - next_finish AS next_ts, - next_finish - finish AS dur -FROM next_finish; + LEAD(finish) OVER (ORDER BY finish) AS next_ts, + LEAD(finish) OVER (ORDER BY finish) - finish AS dur +FROM input_latency_events; -- Every row of this query marks the start of some GestureScrollUpdate event. -- Column names 'ts' and 'dur' are as expected by SPAN_JOIN function.
diff --git a/tools/perf/expectations.config b/tools/perf/expectations.config index 1210778..877283b3 100644 --- a/tools/perf/expectations.config +++ b/tools/perf/expectations.config
@@ -377,6 +377,7 @@ crbug.com/1009838 [ mac ] v8.browsing_desktop/browse:tools:maps:2019 [ Skip ] crbug.com/1008001 [ win ] v8.browsing_desktop/browse:tools:sheets:2019 [ Skip ] crbug.com/1023366 [ desktop ] v8.browsing_desktop/browse:media:youtube:2019 [ Skip ] +crbug.com/1062438 [ win10 ] v8.browsing_desktop/browse:news:cnn:2018 [ Skip ] # Benchmark v8.browsing_desktop-future crbug.com/788796 [ linux ] v8.browsing_desktop-future/browse:media:imgur [ Skip ]
diff --git a/ui/accessibility/ax_language_detection.cc b/ui/accessibility/ax_language_detection.cc index 0229b26..8350e96 100644 --- a/ui/accessibility/ax_language_detection.cc +++ b/ui/accessibility/ax_language_detection.cc
@@ -118,8 +118,8 @@ } void AXLanguageInfoStats::RecordLabelStatistics( - std::string labelled_lang, - std::string author_lang, + const std::string& labelled_lang, + const std::string& author_lang, bool labelled_with_first_result) { // Count the number of nodes we labelled, and the number we labelled with // our highest confidence result. @@ -366,7 +366,7 @@ if (lang_info_stats_.CheckLanguageWithinTop(lang)) { lang_info->language = lang; - std::string author_lang = node->GetInheritedStringAttribute( + const std::string& author_lang = node->GetInheritedStringAttribute( ax::mojom::StringAttribute::kLanguage); lang_info_stats_.RecordLabelStatistics(lang, author_lang, labelled_with_first_result);
diff --git a/ui/accessibility/ax_language_detection.h b/ui/accessibility/ax_language_detection.h index 68f32f5..69401d7 100644 --- a/ui/accessibility/ax_language_detection.h +++ b/ui/accessibility/ax_language_detection.h
@@ -115,6 +115,11 @@ AXLanguageInfoStats(); ~AXLanguageInfoStats(); + // Each AXLanguageInfoStats is tied to a specific AXTree, copying is safe but + // logically doesn't make sense. + AXLanguageInfoStats(const AXLanguageInfoStats&) = delete; + AXLanguageInfoStats& operator=(const AXLanguageInfoStats&) = delete; + // Adjust our statistics to add provided detected languages. void Add(const std::vector<std::string>& languages); @@ -128,8 +133,8 @@ // We consider the language we labelled the node with, the language the author // assigned, and whether or not we assigned our highest confidence detection // result. - void RecordLabelStatistics(std::string labelled_lang, - std::string author_lang, + void RecordLabelStatistics(const std::string& labelled_lang, + const std::string& author_lang, bool labelled_with_first_result); // Update metrics to reflect we attempted to detect language for a node. @@ -197,8 +202,6 @@ // Set of top language detected for every node, used to generate the unique // number of detected languages metric (LangsPerPage). std::unordered_set<std::string> unique_top_lang_detected_; - - DISALLOW_COPY_AND_ASSIGN(AXLanguageInfoStats); }; // AXLanguageDetectionObserver is registered as a change observer on an AXTree @@ -222,6 +225,11 @@ // Observer destructor will remove itself as an observer from the AXTree. ~AXLanguageDetectionObserver() override; + // AXLanguageDetectionObserver contains a pointer so copying is non-trivial. + AXLanguageDetectionObserver(const AXLanguageDetectionObserver&) = delete; + AXLanguageDetectionObserver& operator=(const AXLanguageDetectionObserver&) = + delete; + private: void OnAtomicUpdateFinished(ui::AXTree* tree, bool root_changed, @@ -229,8 +237,6 @@ // Non-owning pointer to AXTree, used to de-register observer on destruction. AXTree* const tree_; - - DISALLOW_COPY_AND_ASSIGN(AXLanguageDetectionObserver); }; // AXLanguageDetectionManager manages all of the context needed for language @@ -238,9 +244,14 @@ class AX_EXPORT AXLanguageDetectionManager { public: // Construct an AXLanguageDetectionManager for the specified tree. - AXLanguageDetectionManager(AXTree* tree); + explicit AXLanguageDetectionManager(AXTree* tree); ~AXLanguageDetectionManager(); + // AXLanguageDetectionManager contains pointers so copying is non-trivial. + AXLanguageDetectionManager(const AXLanguageDetectionManager&) = delete; + AXLanguageDetectionManager& operator=(const AXLanguageDetectionManager&) = + delete; + // Detect languages for each node in the tree managed by this manager. // This is the first pass in detection and labelling. // This only detects the language, it does not label it, for that see @@ -296,8 +307,6 @@ AXTree* tree_; AXLanguageInfoStats lang_info_stats_; - - DISALLOW_COPY_AND_ASSIGN(AXLanguageDetectionManager); }; } // namespace ui
diff --git a/ui/accessibility/ax_language_detection_unittest.cc b/ui/accessibility/ax_language_detection_unittest.cc index b37cac4..c416297 100644 --- a/ui/accessibility/ax_language_detection_unittest.cc +++ b/ui/accessibility/ax_language_detection_unittest.cc
@@ -50,6 +50,11 @@ AXLanguageDetectionTestFixture() = default; ~AXLanguageDetectionTestFixture() override = default; + AXLanguageDetectionTestFixture(const AXLanguageDetectionTestFixture&) = + delete; + AXLanguageDetectionTestFixture& operator=( + const AXLanguageDetectionTestFixture&) = delete; + protected: AXLanguageDetectionObserver* getObserver(AXTree& tree) { return tree.language_detection_manager->language_detection_observer_.get(); @@ -93,9 +98,6 @@ return tree.language_detection_manager->lang_info_stats_ .unique_top_lang_detected_; } - - private: - DISALLOW_COPY_AND_ASSIGN(AXLanguageDetectionTestFixture); }; class AXLanguageDetectionTestStaticContent @@ -104,6 +106,11 @@ AXLanguageDetectionTestStaticContent() = default; ~AXLanguageDetectionTestStaticContent() override = default; + AXLanguageDetectionTestStaticContent( + const AXLanguageDetectionTestStaticContent&) = delete; + AXLanguageDetectionTestStaticContent& operator=( + const AXLanguageDetectionTestStaticContent&) = delete; + void SetUp() override { AXLanguageDetectionTestFixture::SetUp(); @@ -118,6 +125,11 @@ AXLanguageDetectionTestDynamicContent() = default; ~AXLanguageDetectionTestDynamicContent() override = default; + AXLanguageDetectionTestDynamicContent( + const AXLanguageDetectionTestDynamicContent&) = delete; + AXLanguageDetectionTestDynamicContent& operator=( + const AXLanguageDetectionTestDynamicContent&) = delete; + void SetUp() override { AXLanguageDetectionTestStaticContent::SetUp();
diff --git a/ui/accessibility/platform/ax_fragment_root_win.cc b/ui/accessibility/platform/ax_fragment_root_win.cc index c5f8742..6f37698f 100644 --- a/ui/accessibility/platform/ax_fragment_root_win.cc +++ b/ui/accessibility/platform/ax_fragment_root_win.cc
@@ -281,7 +281,7 @@ return nullptr; } -gfx::NativeViewAccessible AXFragmentRootWin::HitTestSync(int x, int y) { +gfx::NativeViewAccessible AXFragmentRootWin::HitTestSync(int x, int y) const { AXPlatformNodeDelegate* child_delegate = GetChildNodeDelegate(); if (child_delegate) return child_delegate->HitTestSync(x, y);
diff --git a/ui/accessibility/platform/ax_fragment_root_win.h b/ui/accessibility/platform/ax_fragment_root_win.h index 1b8b5f96..b5623d6 100644 --- a/ui/accessibility/platform/ax_fragment_root_win.h +++ b/ui/accessibility/platform/ax_fragment_root_win.h
@@ -62,7 +62,7 @@ gfx::NativeViewAccessible ChildAtIndex(int index) override; gfx::NativeViewAccessible GetNextSibling() override; gfx::NativeViewAccessible GetPreviousSibling() override; - gfx::NativeViewAccessible HitTestSync(int x, int y) override; + gfx::NativeViewAccessible HitTestSync(int x, int y) const override; gfx::NativeViewAccessible GetFocus() override; const ui::AXUniqueId& GetUniqueId() const override; gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override;
diff --git a/ui/accessibility/platform/ax_platform_node_base.cc b/ui/accessibility/platform/ax_platform_node_base.cc index 647bca8b..666785b 100644 --- a/ui/accessibility/platform/ax_platform_node_base.cc +++ b/ui/accessibility/platform/ax_platform_node_base.cc
@@ -1761,6 +1761,58 @@ boundary, offset, direction, affinity)); } +AXPlatformNodeBase* AXPlatformNodeBase::NearestLeafToPoint( + gfx::Point point) const { + // First, scope the search to the node that contains point. + AXPlatformNodeBase* nearest_node = + static_cast<AXPlatformNodeBase*>(AXPlatformNode::FromNativeViewAccessible( + GetDelegate()->HitTestSync(point.x(), point.y()))); + + if (!nearest_node) + return nullptr; + + AXPlatformNodeBase* parent = nearest_node; + // GetFirstChild does not consider if the parent is a leaf. + AXPlatformNodeBase* current_descendant = + parent->GetChildCount() ? parent->GetFirstChild() : nullptr; + AXPlatformNodeBase* nearest_descendant = nullptr; + float shortest_distance; + while (parent && current_descendant) { + // Manhattan Distance is used to provide faster distance estimates. + float current_distance = current_descendant->GetDelegate() + ->GetClippedScreenBoundsRect() + .ManhattanDistanceToPoint(point); + + if (!nearest_descendant || current_distance < shortest_distance) { + shortest_distance = current_distance; + nearest_descendant = current_descendant; + } + + // Traverse + AXPlatformNodeBase* next_sibling = current_descendant->GetNextSibling(); + if (next_sibling) { + current_descendant = next_sibling; + } else { + // We have gone through all siblings, update nearest and descend if + // possible. + if (nearest_descendant) { + nearest_node = nearest_descendant; + // If the nearest node is a leaf that does not have a child tree, break. + if (!nearest_node->GetChildCount()) + break; + + parent = nearest_node; + current_descendant = parent->GetFirstChild(); + + // Reset nearest_descendant to force the nearest node to be a descendant + // of "parent". + nearest_descendant = nullptr; + } + } + } + return nearest_node; +} + int AXPlatformNodeBase::NearestTextIndexToPoint(gfx::Point point) { // For text objects, find the text position nearest to the point.The nearest // index of a non-text object is implicitly 0. Text fields such as textarea
diff --git a/ui/accessibility/platform/ax_platform_node_base.h b/ui/accessibility/platform/ax_platform_node_base.h index c00a64d..d5088c0 100644 --- a/ui/accessibility/platform/ax_platform_node_base.h +++ b/ui/accessibility/platform/ax_platform_node_base.h
@@ -278,10 +278,17 @@ }; bool ScrollToNode(ScrollType scroll_type); + // This will return the nearest leaf node to the point, the leaf node will not + // necessarily be directly under the point. This utilizes + // AXPlatformNodeDelegate::HitTestSync, which in the case of + // BrowserAccessibility, may not be accurate after a single call. See + // BrowserAccessibilityManager::CachingAsyncHitTest + AXPlatformNodeBase* NearestLeafToPoint(gfx::Point point) const; + // Return the nearest text index to a point in screen coordinates for an // accessibility node. If the node is not a text only node, the implicit // nearest index is zero. Note this will only find the index of text on the - // input node. The node's subtree will not be searched. + // input node. Due to perf concerns, this should only be called on leaf nodes. int NearestTextIndexToPoint(gfx::Point point); ui::TextAttributeList ComputeTextAttributes() const;
diff --git a/ui/accessibility/platform/ax_platform_node_delegate.h b/ui/accessibility/platform/ax_platform_node_delegate.h index e8eb827..5ddd11b 100644 --- a/ui/accessibility/platform/ax_platform_node_delegate.h +++ b/ui/accessibility/platform/ax_platform_node_delegate.h
@@ -184,6 +184,9 @@ const AXClippingBehavior clipping_behavior, AXOffscreenResult* offscreen_result = nullptr) const = 0; + virtual gfx::Rect GetClippedScreenBoundsRect( + AXOffscreenResult* offscreen_result = nullptr) const = 0; + // Return the bounds of the text range given by text offsets relative to // GetHypertext in the coordinate system indicated. If the clipping behavior // is set to clipped, clipping is applied. If an offscreen result address is @@ -219,7 +222,7 @@ // // This function is mainly used by accessibility debugging software. // Platforms with touch accessibility use a different asynchronous interface. - virtual gfx::NativeViewAccessible HitTestSync(int x, int y) = 0; + virtual gfx::NativeViewAccessible HitTestSync(int x, int y) const = 0; // Return the node within this node's subtree (inclusive) that currently has // focus, or return nullptr if this subtree is not connected to the top
diff --git a/ui/accessibility/platform/ax_platform_node_delegate_base.cc b/ui/accessibility/platform/ax_platform_node_delegate_base.cc index 45d2b7e..c79994d 100644 --- a/ui/accessibility/platform/ax_platform_node_delegate_base.cc +++ b/ui/accessibility/platform/ax_platform_node_delegate_base.cc
@@ -13,6 +13,7 @@ #include "ui/accessibility/ax_role_properties.h" #include "ui/accessibility/ax_tree_data.h" #include "ui/accessibility/platform/ax_platform_node.h" +#include "ui/accessibility/platform/ax_platform_node_base.h" namespace ui { @@ -241,7 +242,7 @@ } gfx::NativeViewAccessible AXPlatformNodeDelegateBase::HitTestSync(int x, - int y) { + int y) const { return nullptr; }
diff --git a/ui/accessibility/platform/ax_platform_node_delegate_base.h b/ui/accessibility/platform/ax_platform_node_delegate_base.h index b72dce5..314e304 100644 --- a/ui/accessibility/platform/ax_platform_node_delegate_base.h +++ b/ui/accessibility/platform/ax_platform_node_delegate_base.h
@@ -129,7 +129,7 @@ // Derivative utils for AXPlatformNodeDelegate::GetBoundsRect gfx::Rect GetClippedScreenBoundsRect( - AXOffscreenResult* offscreen_result = nullptr) const; + AXOffscreenResult* offscreen_result = nullptr) const override; gfx::Rect GetUnclippedScreenBoundsRect( AXOffscreenResult* offscreen_result = nullptr) const; @@ -144,7 +144,7 @@ // // This function is mainly used by accessibility debugging software. // Platforms with touch accessibility use a different asynchronous interface. - gfx::NativeViewAccessible HitTestSync(int x, int y) override; + gfx::NativeViewAccessible HitTestSync(int x, int y) const override; // Return the node within this node's subtree (inclusive) that currently // has focus.
diff --git a/ui/accessibility/platform/ax_platform_node_textprovider_win.cc b/ui/accessibility/platform/ax_platform_node_textprovider_win.cc index d48121b6..9c8d92f1 100644 --- a/ui/accessibility/platform/ax_platform_node_textprovider_win.cc +++ b/ui/accessibility/platform/ax_platform_node_textprovider_win.cc
@@ -229,21 +229,18 @@ UIA_VALIDATE_TEXTPROVIDER_CALL(); *range = nullptr; - // Retrieve the closest accessibility node via hit testing the point. No - // coordinate unit conversion is needed, hit testing input is also in screen - // coordinates. - gfx::NativeViewAccessible nearest_native_view_accessible = - owner()->GetDelegate()->HitTestSync(uia_point.x, uia_point.y); - DCHECK(nearest_native_view_accessible); + gfx::Point point(uia_point.x, uia_point.y); + // Retrieve the closest accessibility node. No coordinate unit conversion is + // needed, hit testing input is also in screen coordinates. - AXPlatformNodeWin* nearest_node = static_cast<AXPlatformNodeWin*>( - AXPlatformNode::FromNativeViewAccessible(nearest_native_view_accessible)); + AXPlatformNodeWin* nearest_node = + static_cast<AXPlatformNodeWin*>(owner()->NearestLeafToPoint(point)); DCHECK(nearest_node); + DCHECK(nearest_node->IsLeaf()); AXNodePosition::AXPositionInstance start, end; start = nearest_node->GetDelegate()->CreateTextPositionAt( - nearest_node->NearestTextIndexToPoint( - gfx::Point(uia_point.x, uia_point.y))); + nearest_node->NearestTextIndexToPoint(point)); DCHECK(!start->IsNullPosition()); end = start->Clone();
diff --git a/ui/accessibility/platform/test_ax_node_wrapper.cc b/ui/accessibility/platform/test_ax_node_wrapper.cc index a820ba73..6ec746f 100644 --- a/ui/accessibility/platform/test_ax_node_wrapper.cc +++ b/ui/accessibility/platform/test_ax_node_wrapper.cc
@@ -276,9 +276,10 @@ return this; } -gfx::NativeViewAccessible TestAXNodeWrapper::HitTestSync(int x, int y) { - TestAXNodeWrapper* wrapper = - HitTestSyncInternal(x / g_scale_factor, y / g_scale_factor); +gfx::NativeViewAccessible TestAXNodeWrapper::HitTestSync(int x, int y) const { + const TestAXNodeWrapper* wrapper = + const_cast<TestAXNodeWrapper*>(this)->HitTestSyncInternal( + x / g_scale_factor, y / g_scale_factor); return wrapper ? wrapper->ax_platform_node()->GetNativeViewAccessible() : nullptr; }
diff --git a/ui/accessibility/platform/test_ax_node_wrapper.h b/ui/accessibility/platform/test_ax_node_wrapper.h index d21120d8..85e1e97 100644 --- a/ui/accessibility/platform/test_ax_node_wrapper.h +++ b/ui/accessibility/platform/test_ax_node_wrapper.h
@@ -86,7 +86,7 @@ const AXCoordinateSystem coordinate_system, const AXClippingBehavior clipping_behavior, AXOffscreenResult* offscreen_result) const override; - gfx::NativeViewAccessible HitTestSync(int x, int y) override; + gfx::NativeViewAccessible HitTestSync(int x, int y) const override; gfx::NativeViewAccessible GetFocus() override; bool IsMinimized() const override; bool IsWebContent() const override;
diff --git a/ui/base/clipboard/custom_data_helper.cc b/ui/base/clipboard/custom_data_helper.cc index 2cb28b39..4cc5b29 100644 --- a/ui/base/clipboard/custom_data_helper.cc +++ b/ui/base/clipboard/custom_data_helper.cc
@@ -16,17 +16,7 @@ namespace { -class SkippablePickle : public base::Pickle { - public: - SkippablePickle(const void* data, size_t data_len); - bool SkipString16(base::PickleIterator* iter); -}; - -SkippablePickle::SkippablePickle(const void* data, size_t data_len) - : base::Pickle(reinterpret_cast<const char*>(data), data_len) { -} - -bool SkippablePickle::SkipString16(base::PickleIterator* iter) { +bool SkipString16(base::PickleIterator* iter) { DCHECK(iter); int len; @@ -40,7 +30,7 @@ void ReadCustomDataTypes(const void* data, size_t data_length, std::vector<base::string16>* types) { - SkippablePickle pickle(data, data_length); + base::Pickle pickle(reinterpret_cast<const char*>(data), data_length); base::PickleIterator iter(pickle); uint32_t size = 0; @@ -54,7 +44,7 @@ for (uint32_t i = 0; i < size; ++i) { types->push_back(base::string16()); - if (!iter.ReadString16(&types->back()) || !pickle.SkipString16(&iter)) { + if (!iter.ReadString16(&types->back()) || !SkipString16(&iter)) { types->resize(original_size); return; } @@ -65,7 +55,7 @@ size_t data_length, const base::string16& type, base::string16* result) { - SkippablePickle pickle(data, data_length); + base::Pickle pickle(reinterpret_cast<const char*>(data), data_length); base::PickleIterator iter(pickle); uint32_t size = 0; @@ -80,7 +70,7 @@ ignore_result(iter.ReadString16(result)); return; } - if (!pickle.SkipString16(&iter)) + if (!SkipString16(&iter)) return; } }
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc index 76c35b1..e94d022 100644 --- a/ui/compositor/compositor.cc +++ b/ui/compositor/compositor.cc
@@ -216,6 +216,10 @@ settings.compositor_threaded_scrollbar_scrolling = true; } + if (base::FeatureList::IsEnabled(features::kPercentBasedScrolling)) { + settings.percent_based_scrolling = true; + } + #if DCHECK_IS_ON() if (command_line->HasSwitch(cc::switches::kLogOnUIDoubleBackgroundBlur)) settings.log_on_ui_double_background_blur = true;
diff --git a/ui/display/manager/display_configurator.cc b/ui/display/manager/display_configurator.cc index a89141c1..d5f0bff 100644 --- a/ui/display/manager/display_configurator.cc +++ b/ui/display/manager/display_configurator.cc
@@ -1058,11 +1058,18 @@ chromeos::DisplayPowerState new_power_state) { chromeos::DisplayPowerState old_power_state = current_power_state_; current_power_state_ = new_power_state; + + // Don't notify observers of |current_power_state_| when there is a pending + // power state. Notifying the observers may confuse them because they may + // already know the up-to-date state via PowerManagerClient. Please refer to + // b/134459602 for details. + if (has_pending_power_state_) + return; + // If the pending power state hasn't changed then make sure that value gets // updated as well since the last requested value may have been dependent on // certain conditions (ie: if only the internal monitor was present). - if (!has_pending_power_state_) - pending_power_state_ = new_power_state; + pending_power_state_ = new_power_state; if (old_power_state != current_power_state_) NotifyPowerStateObservers(); }
diff --git a/ui/display/manager/display_configurator_unittest.cc b/ui/display/manager/display_configurator_unittest.cc index 54b0c258..e4cd880 100644 --- a/ui/display/manager/display_configurator_unittest.cc +++ b/ui/display/manager/display_configurator_unittest.cc
@@ -59,18 +59,24 @@ int num_changes() const { return num_changes_; } int num_failures() const { return num_failures_; } + int num_power_state_changes() const { return num_power_state_changes_; } const DisplayConfigurator::DisplayStateList& latest_outputs() const { return latest_outputs_; } MultipleDisplayState latest_failed_state() const { return latest_failed_state_; } + chromeos::DisplayPowerState latest_power_state() const { + return latest_power_state_; + } void Reset() { num_changes_ = 0; num_failures_ = 0; + num_power_state_changes_ = 0; latest_outputs_.clear(); latest_failed_state_ = MULTIPLE_DISPLAY_STATE_INVALID; + latest_power_state_ = chromeos::DISPLAY_POWER_ALL_OFF; } // DisplayConfigurator::Observer overrides: @@ -87,16 +93,25 @@ latest_failed_state_ = failed_new_state; } + void OnPowerStateChanged(chromeos::DisplayPowerState power_state) override { + num_power_state_changes_++; + latest_power_state_ = power_state; + } + private: DisplayConfigurator* configurator_; // Not owned. // Number of times that OnDisplayMode*() has been called. int num_changes_; int num_failures_; + // Number of times that OnPowerStateChanged() has been called. + int num_power_state_changes_; // Parameters most recently passed to OnDisplayMode*(). DisplayConfigurator::DisplayStateList latest_outputs_; MultipleDisplayState latest_failed_state_; + // Value most recently passed to OnPowerStateChanged(). + chromeos::DisplayPowerState latest_power_state_; DISALLOW_COPY_AND_ASSIGN(TestObserver); }; @@ -1361,6 +1376,61 @@ configurator_.display_state()); } +TEST_F(DisplayConfiguratorTest, PowerStateChange) { + InitWithOutputs(&small_mode_); + + native_display_delegate_->set_run_async(true); + + // Set the initial power state and verify that it is restored on resume. + config_waiter_.Reset(); + configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, + DisplayConfigurator::kSetDisplayPowerNoFlags, + config_waiter_.on_configuration_callback()); + + // SuspendDisplays causes notifying the DISPLAY_POWER_ALL_OFF state to the + // observer. + config_waiter_.Reset(); + observer_.Reset(); + configurator_.SuspendDisplays(config_waiter_.on_configuration_callback()); + EXPECT_EQ(kNoDelay, config_waiter_.Wait()); + EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); + EXPECT_EQ(1, observer_.num_power_state_changes()); + EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_OFF, observer_.latest_power_state()); + + // ResumeDisplays causes notifying the DISPLAY_POWER_ALL_ON state to the + // observer. + config_waiter_.Reset(); + configurator_.ResumeDisplays(); + EXPECT_EQ(base::TimeDelta::Max(), config_waiter_.Wait()); + EXPECT_EQ(CALLBACK_NOT_CALLED, config_waiter_.callback_result()); + EXPECT_EQ(2, observer_.num_power_state_changes()); + EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, observer_.latest_power_state()); + + // SuspendDisplays and ResumeDisplays before running the configuration task + // causes notifying only one power state change to the observer. + config_waiter_.Reset(); + observer_.Reset(); + configurator_.SuspendDisplays(config_waiter_.on_configuration_callback()); + EXPECT_EQ(0, observer_.num_power_state_changes()); + configurator_.ResumeDisplays(); + // Run the task posted by TestNativeDisplayDelegate::GetDisplays() which is + // called by SuspendDisplays(). + EXPECT_EQ(kNoDelay, config_waiter_.Wait()); + EXPECT_EQ(CALLBACK_SUCCESS, config_waiter_.callback_result()); + config_waiter_.Reset(); + // Run the task posted by OnConfigured(). + EXPECT_EQ( + base::TimeDelta::FromMilliseconds(DisplayConfigurator::kConfigureDelayMs), + config_waiter_.Wait()); + EXPECT_EQ(CALLBACK_NOT_CALLED, config_waiter_.callback_result()); + config_waiter_.Reset(); + // Run the task posted by TestNativeDisplayDelegate::GetDisplays(). + EXPECT_EQ(base::TimeDelta::Max(), config_waiter_.Wait()); + EXPECT_EQ(CALLBACK_NOT_CALLED, config_waiter_.callback_result()); + EXPECT_EQ(1, observer_.num_power_state_changes()); + EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, observer_.latest_power_state()); +} + TEST_F(DisplayConfiguratorTest, EnablePrivacyScreenOnSupportedEmbeddedDisplay) { outputs_[0] = FakeDisplaySnapshot::Builder() .SetId(kDisplayIds[0])
diff --git a/ui/events/blink/DEPS b/ui/events/blink/DEPS index c993feb..c3f21f5 100644 --- a/ui/events/blink/DEPS +++ b/ui/events/blink/DEPS
@@ -5,6 +5,7 @@ "+cc/input/scroll_elasticity_helper.h", "+cc/input/scroll_input_type.h", "+cc/input/snap_fling_controller.h", + "+cc/metrics/event_metrics.h", "+cc/trees/swap_promise_monitor.h", "+third_party/blink/public/common/input/web_gesture_device.h",
diff --git a/ui/events/blink/blink_event_util.cc b/ui/events/blink/blink_event_util.cc index 9055ffd..e326bf7 100644 --- a/ui/events/blink/blink_event_util.cc +++ b/ui/events/blink/blink_event_util.cc
@@ -30,6 +30,7 @@ #include "ui/gfx/geometry/vector2d.h" #include "ui/gfx/transform.h" +using blink::WebGestureDevice; using blink::WebGestureEvent; using blink::WebInputEvent; using blink::WebMouseEvent; @@ -578,9 +579,8 @@ return (event_in_queue.GetType() == WebInputEvent::kGestureScrollUpdate || event_in_queue.GetType() == WebInputEvent::kGesturePinchUpdate) && event_in_queue.GetModifiers() == new_event.GetModifiers() && - event_in_queue.SourceDevice() == - blink::WebGestureDevice::kTouchscreen && - new_event.SourceDevice() == blink::WebGestureDevice::kTouchscreen; + event_in_queue.SourceDevice() == WebGestureDevice::kTouchscreen && + new_event.SourceDevice() == WebGestureDevice::kTouchscreen; } std::pair<WebGestureEvent, WebGestureEvent> CoalesceScrollAndPinch( @@ -708,14 +708,13 @@ const gfx::PointF& raw_location, int flags, uint32_t unique_touch_event_id) { - blink::WebGestureDevice source_device = - blink::WebGestureDevice::kUninitialized; + WebGestureDevice source_device = WebGestureDevice::kUninitialized; switch (details.device_type()) { case GestureDeviceType::DEVICE_TOUCHSCREEN: - source_device = blink::WebGestureDevice::kTouchscreen; + source_device = WebGestureDevice::kTouchscreen; break; case GestureDeviceType::DEVICE_TOUCHPAD: - source_device = blink::WebGestureDevice::kTouchpad; + source_device = WebGestureDevice::kTouchpad; break; case GestureDeviceType::DEVICE_UNKNOWN: NOTREACHED() << "Unknown device type is not allowed"; @@ -746,8 +745,7 @@ gesture.data.tap.tap_count = details.tap_count(); gesture.data.tap.width = details.bounding_box_f().width(); gesture.data.tap.height = details.bounding_box_f().height(); - gesture.SetNeedsWheelEvent(source_device == - blink::WebGestureDevice::kTouchpad); + gesture.SetNeedsWheelEvent(source_device == WebGestureDevice::kTouchpad); break; case ET_GESTURE_TAP: gesture.SetType(WebInputEvent::kGestureTap); @@ -806,19 +804,16 @@ break; case ET_GESTURE_PINCH_BEGIN: gesture.SetType(WebInputEvent::kGesturePinchBegin); - gesture.SetNeedsWheelEvent(source_device == - blink::WebGestureDevice::kTouchpad); + gesture.SetNeedsWheelEvent(source_device == WebGestureDevice::kTouchpad); break; case ET_GESTURE_PINCH_UPDATE: gesture.SetType(WebInputEvent::kGesturePinchUpdate); gesture.data.pinch_update.scale = details.scale(); - gesture.SetNeedsWheelEvent(source_device == - blink::WebGestureDevice::kTouchpad); + gesture.SetNeedsWheelEvent(source_device == WebGestureDevice::kTouchpad); break; case ET_GESTURE_PINCH_END: gesture.SetType(WebInputEvent::kGesturePinchEnd); - gesture.SetNeedsWheelEvent(source_device == - blink::WebGestureDevice::kTouchpad); + gesture.SetNeedsWheelEvent(source_device == WebGestureDevice::kTouchpad); break; case ET_GESTURE_TAP_CANCEL: gesture.SetType(WebInputEvent::kGestureTapCancel); @@ -1086,6 +1081,27 @@ } } +base::Optional<cc::ScrollInputType> GetScrollInputTypeForEvent( + const WebInputEvent& event) { + if (event.IsGestureScroll()) { + const auto& gesture = static_cast<const WebGestureEvent&>(event); + switch (gesture.SourceDevice()) { + case WebGestureDevice::kTouchpad: + return cc::ScrollInputType::kWheel; + case WebGestureDevice::kTouchscreen: + return cc::ScrollInputType::kTouchscreen; + case WebGestureDevice::kSyntheticAutoscroll: + return cc::ScrollInputType::kAutoscroll; + case WebGestureDevice::kScrollbar: + return cc::ScrollInputType::kScrollbar; + case WebGestureDevice::kUninitialized: + break; + } + } + + return base::nullopt; +} + void SetWebPointerPropertiesFromMotionEventData( WebPointerProperties& webPointerProperties, int pointer_id, @@ -1245,7 +1261,7 @@ std::unique_ptr<blink::WebGestureEvent> GenerateInjectedScrollGesture( WebInputEvent::Type type, base::TimeTicks timestamp, - blink::WebGestureDevice device, + WebGestureDevice device, gfx::PointF position_in_widget, gfx::Vector2dF scroll_delta, ScrollGranularity granularity) { @@ -1329,9 +1345,9 @@ // event's fields better when extended to handle more cases. web_event->SetPositionInWidget(event.location()); web_event->SetPositionInScreen(event.screen_location()); - web_event->SetSourceDevice(blink::WebGestureDevice::kTouchscreen); + web_event->SetSourceDevice(WebGestureDevice::kTouchscreen); if (event.synthetic_scroll()) - web_event->SetSourceDevice(blink::WebGestureDevice::kSyntheticAutoscroll); + web_event->SetSourceDevice(WebGestureDevice::kSyntheticAutoscroll); if (event_type == WebInputEvent::kGesturePinchUpdate) { web_event->data.pinch_update.scale = event.scale(); } else if (event_type == WebInputEvent::kGestureScrollBegin) {
diff --git a/ui/events/blink/blink_event_util.h b/ui/events/blink/blink_event_util.h index aa73e71..79c798cb 100644 --- a/ui/events/blink/blink_event_util.h +++ b/ui/events/blink/blink_event_util.h
@@ -7,7 +7,9 @@ #include <memory> +#include "base/optional.h" #include "build/build_config.h" +#include "cc/input/scroll_input_type.h" #include "third_party/blink/public/common/input/web_gesture_event.h" #include "third_party/blink/public/common/input/web_input_event.h" #include "third_party/blink/public/common/input/web_touch_event.h" @@ -80,6 +82,11 @@ EventType WebEventTypeToEventType(blink::WebInputEvent::Type type); +// Returns the scroll input type if |event| is a scroll event; otherwise, +// returns base::nullopt. +base::Optional<cc::ScrollInputType> GetScrollInputTypeForEvent( + const blink::WebInputEvent& event); + void SetWebPointerPropertiesFromMotionEventData( blink::WebPointerProperties& webPointerProperties, int pointer_id,
diff --git a/ui/events/blink/input_handler_proxy.cc b/ui/events/blink/input_handler_proxy.cc index fe463d5..c26199d 100644 --- a/ui/events/blink/input_handler_proxy.cc +++ b/ui/events/blink/input_handler_proxy.cc
@@ -23,6 +23,7 @@ #include "build/build_config.h" #include "cc/input/main_thread_scrolling_reason.h" #include "cc/input/scroll_input_type.h" +#include "cc/metrics/event_metrics.h" #include "services/tracing/public/cpp/perfetto/flow_event_utils.h" #include "services/tracing/public/cpp/perfetto/macros.h" #include "third_party/blink/public/common/input/web_input_event.h" @@ -113,10 +114,9 @@ case blink::WebGestureDevice::kScrollbar: return cc::ScrollInputType::kScrollbar; case blink::WebGestureDevice::kUninitialized: - break; + NOTREACHED(); + return cc::ScrollInputType::kMaxValue; } - NOTREACHED(); - return cc::ScrollInputType::kUnknown; } cc::SnapFlingController::GestureScrollType GestureScrollEventType( @@ -338,7 +338,8 @@ auto scoped_event_metrics_monitor = input_handler_->GetScopedEventMetricsMonitor( {WebEventTypeToEventType(event_with_callback->event().GetType()), - event_with_callback->event().TimeStamp()}); + event_with_callback->event().TimeStamp(), + GetScrollInputTypeForEvent(event_with_callback->event())}); current_overscroll_params_.reset();
diff --git a/ui/file_manager/file_manager/foreground/js/ui/directory_tree.js b/ui/file_manager/file_manager/foreground/js/ui/directory_tree.js index a199ded1..7067e53 100644 --- a/ui/file_manager/file_manager/foreground/js/ui/directory_tree.js +++ b/ui/file_manager/file_manager/foreground/js/ui/directory_tree.js
@@ -1145,7 +1145,9 @@ // Populate children of this volume using resolved display root. For SMB // shares, avoid prefetching sub directories to delay authentication. - if (modelItem.volumeInfo_.providerId !== '@smb') { + if (modelItem.volumeInfo_.providerId !== '@smb' && + modelItem.volumeInfo_.volumeType !== + VolumeManagerCommon.VolumeType.SMB) { this.volumeInfo_.resolveDisplayRoot((displayRoot) => { this.resolved_ = true; this.updateSubDirectories(false /* recursive */);
diff --git a/ui/file_manager/file_manager/foreground/js/ui/directory_tree_unittest.js b/ui/file_manager/file_manager/foreground/js/ui/directory_tree_unittest.js index b57e76b..cd6f6ef 100644 --- a/ui/file_manager/file_manager/foreground/js/ui/directory_tree_unittest.js +++ b/ui/file_manager/file_manager/foreground/js/ui/directory_tree_unittest.js
@@ -902,6 +902,15 @@ fakeFileSystemURLEntries['filesystem:smb/child'] = MockDirectoryEntry.create(smbProvider, '/smb_child'); + // Add a volume representing an smbfs share to the mock filesystem. + volumeManager.createVolumeInfo( + VolumeManagerCommon.VolumeType.SMB, 'smbfs', 'SMBFS_LABEL'); + + // Add a sub directory to the Smb provider. + const smbfs = assert(volumeManager.volumeInfoList.item(4).fileSystem); + fakeFileSystemURLEntries['filesystem:smbfs/child'] = + MockDirectoryEntry.create(smbfs, '/smbfs_child'); + // Populate the directory tree with the mock filesystem. let directoryTree = createElements(); const metadataModel = createMockMetadataModel(); @@ -916,14 +925,16 @@ directoryTree.redraw(true); // At top level, Drive and downloads should be listed. - assertEquals(4, directoryTree.items.length); + assertEquals(5, directoryTree.items.length); assertEquals(str('DRIVE_DIRECTORY_LABEL'), directoryTree.items[0].label); assertEquals(str('DOWNLOADS_DIRECTORY_LABEL'), directoryTree.items[1].label); assertEquals('NOT_SMB_LABEL', directoryTree.items[2].label); assertEquals('SMB_LABEL', directoryTree.items[3].label); + assertEquals('SMBFS_LABEL', directoryTree.items[4].label); const providerItem = directoryTree.items[2]; const smbItem = directoryTree.items[3]; + const smbfsItem = directoryTree.items[4]; reportPromise( waitUntil(() => { // Under providerItem there should be 1 entry, 'child'. Ensure there are @@ -932,6 +943,7 @@ }).then(() => { assertEquals('child', providerItem.items[0].label); assertEquals(0, smbItem.items.length); + assertEquals(0, smbfsItem.items.length); }), callback); }
diff --git a/ui/views/accessibility/ax_virtual_view.cc b/ui/views/accessibility/ax_virtual_view.cc index 69b4c4dc..5b54d37d 100644 --- a/ui/views/accessibility/ax_virtual_view.cc +++ b/ui/views/accessibility/ax_virtual_view.cc
@@ -314,7 +314,7 @@ } } -gfx::NativeViewAccessible AXVirtualView::HitTestSync(int x, int y) { +gfx::NativeViewAccessible AXVirtualView::HitTestSync(int x, int y) const { if (custom_data_.relative_bounds.bounds.Contains(static_cast<float>(x), static_cast<float>(y))) { if (!IsIgnored())
diff --git a/ui/views/accessibility/ax_virtual_view.h b/ui/views/accessibility/ax_virtual_view.h index 390a620..65f47f4 100644 --- a/ui/views/accessibility/ax_virtual_view.h +++ b/ui/views/accessibility/ax_virtual_view.h
@@ -143,7 +143,7 @@ const ui::AXCoordinateSystem coordinate_system, const ui::AXClippingBehavior clipping_behavior, ui::AXOffscreenResult* offscreen_result) const override; - gfx::NativeViewAccessible HitTestSync(int x, int y) override; + gfx::NativeViewAccessible HitTestSync(int x, int y) const override; gfx::NativeViewAccessible GetFocus() override; ui::AXPlatformNode* GetFromNodeID(int32_t id) override; bool AccessibilityPerformAction(const ui::AXActionData& data) override;
diff --git a/ui/views/accessibility/view_accessibility.cc b/ui/views/accessibility/view_accessibility.cc index e91e9b11..4ff677b6 100644 --- a/ui/views/accessibility/view_accessibility.cc +++ b/ui/views/accessibility/view_accessibility.cc
@@ -296,7 +296,7 @@ return previous_focus_; } -gfx::NativeViewAccessible ViewAccessibility::GetNativeObject() { +gfx::NativeViewAccessible ViewAccessibility::GetNativeObject() const { return nullptr; }
diff --git a/ui/views/accessibility/view_accessibility.h b/ui/views/accessibility/view_accessibility.h index 4d63d95..50fdcfe 100644 --- a/ui/views/accessibility/view_accessibility.h +++ b/ui/views/accessibility/view_accessibility.h
@@ -97,7 +97,7 @@ Widget* GetNextFocus(); Widget* GetPreviousFocus(); - virtual gfx::NativeViewAccessible GetNativeObject(); + virtual gfx::NativeViewAccessible GetNativeObject() const; virtual void NotifyAccessibilityEvent(ax::mojom::Event event_type); // Causes the screen reader to announce |text|. If the current user is not
diff --git a/ui/views/accessibility/view_ax_platform_node_delegate.cc b/ui/views/accessibility/view_ax_platform_node_delegate.cc index 9a10683..c386f426a 100644 --- a/ui/views/accessibility/view_ax_platform_node_delegate.cc +++ b/ui/views/accessibility/view_ax_platform_node_delegate.cc
@@ -140,7 +140,7 @@ ax_platform_node_->Destroy(); } -gfx::NativeViewAccessible ViewAXPlatformNodeDelegate::GetNativeObject() { +gfx::NativeViewAccessible ViewAXPlatformNodeDelegate::GetNativeObject() const { DCHECK(ax_platform_node_); return ax_platform_node_->GetNativeViewAccessible(); } @@ -384,7 +384,7 @@ } gfx::NativeViewAccessible ViewAXPlatformNodeDelegate::HitTestSync(int x, - int y) { + int y) const { if (!view() || !view()->GetWidget()) return nullptr;
diff --git a/ui/views/accessibility/view_ax_platform_node_delegate.h b/ui/views/accessibility/view_ax_platform_node_delegate.h index ca1e6dea..04b055b 100644 --- a/ui/views/accessibility/view_ax_platform_node_delegate.h +++ b/ui/views/accessibility/view_ax_platform_node_delegate.h
@@ -41,7 +41,7 @@ ~ViewAXPlatformNodeDelegate() override; // ViewAccessibility: - gfx::NativeViewAccessible GetNativeObject() override; + gfx::NativeViewAccessible GetNativeObject() const override; void NotifyAccessibilityEvent(ax::mojom::Event event_type) override; #if defined(OS_MACOSX) void AnnounceText(const base::string16& text) override; @@ -63,7 +63,7 @@ const ui::AXCoordinateSystem coordinate_system, const ui::AXClippingBehavior clipping_behavior, ui::AXOffscreenResult* offscreen_result) const override; - gfx::NativeViewAccessible HitTestSync(int x, int y) override; + gfx::NativeViewAccessible HitTestSync(int x, int y) const override; gfx::NativeViewAccessible GetFocus() override; ui::AXPlatformNode* GetFromNodeID(int32_t id) override; ui::AXPlatformNode* GetFromTreeIDAndNodeID(const ui::AXTreeID& ax_tree_id,
diff --git a/ui/webui/resources/cr_elements/chromeos/cr_picture/BUILD.gn b/ui/webui/resources/cr_elements/chromeos/cr_picture/BUILD.gn index 5b84d95c0..b74caa3 100644 --- a/ui/webui/resources/cr_elements/chromeos/cr_picture/BUILD.gn +++ b/ui/webui/resources/cr_elements/chromeos/cr_picture/BUILD.gn
@@ -10,18 +10,18 @@ ":cr_picture_list", ":cr_picture_pane", ":cr_picture_types", - ":cr_png_behavior", + ":png", ] } js_library("cr_camera") { - deps = [ ":cr_png_behavior" ] + deps = [ ":png" ] } js_library("cr_picture_list") { deps = [ ":cr_picture_types", - ":cr_png_behavior", + ":png", "//third_party/polymer/v1_0/components-chromium/iron-selector:iron-selector-extracted", "//ui/webui/resources/js:assert", ] @@ -31,12 +31,13 @@ deps = [ ":cr_camera", ":cr_picture_types", - ":cr_png_behavior", + ":png", ] } js_library("cr_picture_types") { } -js_library("cr_png_behavior") { +js_library("png") { + deps = [ "//ui/webui/resources/js:cr" ] }
diff --git a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_camera.html b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_camera.html index 01fe4d8..2dd7bde 100644 --- a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_camera.html +++ b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_camera.html
@@ -4,7 +4,7 @@ <link rel="import" href="../../cr_icon_button/cr_icon_button.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-a11y-keys/iron-a11y-keys.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html"> -<link rel="import" href="cr_png_behavior.html"> +<link rel="import" href="png.html"> <link rel="import" href="icons.html"> <dom-module id="cr-camera">
diff --git a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_camera.js b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_camera.js index 2f3509ce..11be5874 100644 --- a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_camera.js +++ b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_camera.js
@@ -33,8 +33,6 @@ Polymer({ is: 'cr-camera', - behaviors: [CrPngBehavior], - properties: { /** Strings provided by host */ takePhotoLabel: String, @@ -285,8 +283,7 @@ encodedImages.concat(encodedImages.slice(1, -1).reverse()); /** Convert image sequence to animated PNG. */ - return CrPngBehavior.convertImageSequenceToPng( - forwardBackwardImageSequence); + return cr.png.convertImageSequenceToPng(forwardBackwardImageSequence); }, /**
diff --git a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_list.html b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_list.html index 67228aef..4ccb9c2 100644 --- a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_list.html +++ b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_list.html
@@ -6,7 +6,7 @@ <link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-selector/iron-selector.html"> <link rel="import" href="cr_picture_types.html"> -<link rel="import" href="cr_png_behavior.html"> +<link rel="import" href="png.html"> <dom-module id="cr-picture-list"> <template>
diff --git a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_list.js b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_list.js index 0bf67b97..3ce3dd7e 100644 --- a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_list.js +++ b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_list.js
@@ -12,8 +12,6 @@ Polymer({ is: 'cr-picture-list', - behaviors: [CrPngBehavior], - properties: { cameraPresent: Boolean, @@ -292,7 +290,7 @@ * url as input if base64 encoded and potentially animated. */ if (url.split(',')[0] === 'data:image/png;base64') { - return CrPngBehavior.convertImageSequenceToPng([url]); + return cr.png.convertImageSequenceToPng([url]); } return url;
diff --git a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_pane.html b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_pane.html index 7e53d18..1c65e1d 100644 --- a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_pane.html +++ b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_pane.html
@@ -4,7 +4,7 @@ <link rel="import" href="../../cr_icon_button/cr_icon_button.html"> <link rel="import" href="cr_camera.html"> <link rel="import" href="cr_picture_types.html"> -<link rel="import" href="cr_png_behavior.html"> +<link rel="import" href="png.html"> <dom-module id="cr-picture-pane"> <template>
diff --git a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_pane.js b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_pane.js index 7b4ff52..db3d118c 100644 --- a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_pane.js +++ b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_pane.js
@@ -11,8 +11,6 @@ Polymer({ is: 'cr-picture-pane', - behaviors: [CrPngBehavior], - properties: { /** Whether the camera is present / available */ @@ -123,8 +121,8 @@ } const blob = new Blob([bytes], {'type': 'image/png'}); // Use first frame as placeholder while rest of image loads. - image.style.backgroundImage = 'url(' + - CrPngBehavior.convertImageSequenceToPng([this.imageSrc]) + ')'; + image.style.backgroundImage = + 'url(' + cr.png.convertImageSequenceToPng([this.imageSrc]) + ')'; this.imageUrl = URL.createObjectURL(blob); } else { image.style.backgroundImage = 'none';
diff --git a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_png_behavior.html b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_png_behavior.html deleted file mode 100644 index 141b0f2..0000000 --- a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_png_behavior.html +++ /dev/null
@@ -1,2 +0,0 @@ -<link rel="import" href="../../../html/polymer.html"> -<script src="cr_png_behavior.js"></script>
diff --git a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_png_behavior.js b/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_png_behavior.js deleted file mode 100644 index 980a110..0000000 --- a/ui/webui/resources/cr_elements/chromeos/cr_picture/cr_png_behavior.js +++ /dev/null
@@ -1,526 +0,0 @@ -// 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. - -/** - * @fileoverview - * 'CrPngBehavior' is a behavior to convert image sequences into APNG (animated - * PNG) images. - */ - -/** - * PNG frame delay fraction numerator. - * @const - */ -const PNG_FRAME_DELAY_NUMERATOR = 1; - -/** - * PNG frame delay fraction denominator. - * @const - */ -const PNG_FRAME_DELAY_DENOMINATOR = 20; - -/** - * PNG signature. - * @const - */ -const PNG_SIGNATURE = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]; - -/** - * PNG bit depth (8 = 32bpp). - * @const - */ -const PNG_BIT_DEPTH = 8; - -/** - * PNG compression method (0 = deflate/inflate compression with a sliding - * window PNG compression). - * @const - */ -const PNG_COMPRESSION_METHOD = 0; - -/** - * PNG filter method (0 = adaptive filtering with five basic filter types). - * @const - */ -const PNG_FILTER_METHOD = 0; - -/** - * PNG interlace method (0 = no interlace). - * @const - */ -const PNG_INTERLACE_METHOD = 0; - -/** - * CRC table for PNG encode. - * - * Generated using: - * - * for (var i = 0; i < 256; i++) { - * var value = i; - * for (var j = 0; j < 8; j++) { - * if (value & 1) - * value = ((0xEDB88320) ^ (value >>> 1)); - * else - * value = (value >>> 1); - * } - * TABLE[i] = value; - * } - * - * @const - */ -const PNG_CRC_TABLE = [ - 0x0, 0x77073096, 0xEE0E612C, 0x990951BA, 0x76DC419, 0x706AF48F, - 0xE963A535, 0x9E6495A3, 0xEDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, - 0x9B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, - 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, - 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, - 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, - 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, - 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, - 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x1DB7106, - 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x6B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0xF00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x86D3D2D, - 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, - 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, - 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, - 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, - 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, - 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, - 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x3B6E20C, 0x74B1D29A, - 0xEAD54739, 0x9DD277AF, 0x4DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, - 0xD6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0xA00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, - 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, - 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, - 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, - 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, - 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, - 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x26D930A, 0x9C0906A9, 0xEB0E363F, - 0x72076785, 0x5005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0xCB61B38, - 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0xBDBDF21, 0x86D3D2D4, 0xF1D4E242, - 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, - 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, - 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, - 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, - 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, - 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D -]; - -/** - * PNG object state. - * @typedef {{ - * frames: number, - * sequences: number, - * width: number, - * height: number, - * colour: number, - * chunks: !Array<Uint8Array> - * }} - */ -let CrPngState; - -/** @polymerBehavior */ -const CrPngBehavior = { - /** - * Returns a data URL for an animated PNG image that is created - * from a sequence of images. - * @param {!Array<string>} images The data URLs for each image. - * @return {string} A data URL for an animated PNG image. - */ - convertImageSequenceToPng(images) { - const png = - /** @type {!CrPngState} */ ({frames: 0, sequences: 0, chunks: []}); - - /** Append signature. */ - png.chunks.push(new Uint8Array(PNG_SIGNATURE)); - - /** - * http://www.w3.org/TR/2003/REC-PNG-20031110/#11IHDR - * - * Width 4 bytes - * Height 4 bytes - * Bit depth 1 byte - * Colour type 1 byte - * Compression method 1 byte - * Filter method 1 byte - * Interlace method 1 byte - */ - const IHDR = new Uint8Array(12 + 13); - this.writeUInt32_(IHDR, 13, 0); - this.writeFourCC_(IHDR, 'IHDR', 4); - /** Write size at the end when known. */ - this.writeUInt8_(IHDR, PNG_BIT_DEPTH, 16); - /** Write colour at the end when known. */ - this.writeUInt8_(IHDR, PNG_COMPRESSION_METHOD, 18); - this.writeUInt8_(IHDR, PNG_FILTER_METHOD, 19); - this.writeUInt8_(IHDR, PNG_INTERLACE_METHOD, 20); - /** Write CRC at the end when size and colour is known. */ - png.chunks.push(IHDR); - - /** - * acTL - * - * Number of frames 4 bytes - * Number of times to loop 4 bytes - */ - const acTL = new Uint8Array(12 + 8); - this.writeUInt32_(acTL, 8, 0); - this.writeFourCC_(acTL, 'acTL', 4); - this.writeUInt32_(acTL, images.length, 8); - this.writeUInt32_(acTL, 0, 12); - this.writeUInt32_(acTL, this.getCRC_(acTL, 4, 16), 16); - png.chunks.push(acTL); - - /** Append each image as a PNG frame. */ - for (let i = 0; i < images.length; ++i) { - this.appendFrameFromDataURL_(images[i], png); - } - - /** Update IHDR now that size and colour is known. */ - this.writeUInt32_(IHDR, png.width, 8); - this.writeUInt32_(IHDR, png.height, 12); - this.writeUInt8_(IHDR, png.colour, 17); - this.writeUInt32_(IHDR, this.getCRC_(IHDR, 4, 8 + 13), 8 + 13); - - /** - * http://www.w3.org/TR/2003/REC-PNG-20031110/#11IEND - */ - const IEND = new Uint8Array(12); - this.writeUInt32_(IEND, 0, 0); - this.writeFourCC_(IEND, 'IEND', 4); - this.writeUInt32_(IEND, this.getCRC_(IEND, 4, 8), 8); - png.chunks.push(IEND); - - return 'data:image/png;base64,' + - btoa(png.chunks - .map(function(chunk) { - return String.fromCharCode.apply(null, chunk); - }) - .join('')); - }, - - /** - * Returns true if the data URL is an animated PNG image. If the PNG is - * animated, then 'acTL' will have been set by convertImageSequenceToPng(). - * acTL is the animation control chunk in the data stream of an animated PNG. - * If it exists we assume the image is animated, regardless of the number of - * frames. The offset is the PNG signature ( 8 bytes) + IHDR (25 bytes) + 4 - * bytes of padding zeros. See https://wiki.mozilla.org/APNG_Specification - * @param {string} url An btoa encoded data URL for a PNG image. - * @return {boolean} True if data URL is an animated PNG image. - */ - isEncodedPngDataUrlAnimated(url) { - const decoded = atob(url.substr('data:image/png;base64,'.length)); - return decoded.substr(37, 4) === 'acTL'; - }, - - /** - * Reads Uint32 from buffer. - * @param {!Uint8Array} buffer Buffer to read UInt32 from. - * @param {number} offset Offset in buffer to read UInt32 at. - * @return {number} The value read. - * @private - */ - readUInt32_(buffer, offset) { - return (buffer[offset + 0] << 24) + (buffer[offset + 1] << 16) + - (buffer[offset + 2] << 8) + (buffer[offset + 3] << 0); - }, - - /** - * Reads string from buffer. - * @param {!Uint8Array} buffer Buffer to read string from. - * @param {number} offset Offset in buffer to read string at. - * @param {number} length Length of string to read. - * @return {string} The value read. - * @private - */ - readString_(buffer, offset, length) { - let str = ''; - for (let i = 0; i < length; i++) { - str += String.fromCharCode(buffer[offset + i]); - } - return str; - }, - - /** - * Write bytes to buffer. - * @param {!Uint8Array} buffer Buffer to write bytes to. - * @param {!Uint8Array} bytes Array of bytes to be written. - * @param {number} offset Offset in buffer to write bytes at. - * @private - */ - writeBytes_(buffer, bytes, offset) { - for (let i = 0; i < bytes.length; i++) { - buffer[offset + i] = bytes[i] & 0xFF; - } - }, - - /** - * Write UInt8 to buffer. - * @param {!Uint8Array} buffer Buffer to write UInt8 to. - * @param {number} u8 UInt8 to be written. - * @param {number} offset Offset in buffer to write UInt8 at. - * @private - */ - writeUInt8_(buffer, u8, offset) { - buffer[offset] = u8 & 0xFF; - }, - - /** - * Write UInt16 to buffer. - * @param {!Uint8Array} buffer Buffer to write UInt16 to. - * @param {number} u16 UInt16 to be written. - * @param {number} offset Offset in buffer to write UInt16 at. - * @private - */ - writeUInt16_(buffer, u16, offset) { - buffer[offset + 0] = (u16 >> 8) & 0xFF; - buffer[offset + 1] = (u16 >> 0) & 0xFF; - }, - - /** - * Write UInt32 to buffer. - * @param {!Uint8Array} buffer Buffer to write UInt32 to. - * @param {number} u32 UInt32 to be written. - * @param {number} offset Offset in buffer to write UInt32 at. - * @private - */ - writeUInt32_(buffer, u32, offset) { - buffer[offset + 0] = (u32 >> 24) & 0xFF; - buffer[offset + 1] = (u32 >> 16) & 0xFF; - buffer[offset + 2] = (u32 >> 8) & 0xFF; - buffer[offset + 3] = (u32 >> 0) & 0xFF; - }, - - /** - * Write string to buffer. - * @param {!Uint8Array} buffer Buffer to write string to. - * @param {string} string String to be written. - * @param {number} offset Offset in buffer to write string at. - * @private - */ - writeString_(buffer, string, offset) { - for (let i = 0; i < string.length; i++) { - buffer[offset + i] = string.charCodeAt(i); - } - }, - - /** - * Write FourCC code to buffer. - * @param {!Uint8Array} buffer Buffer to write FourCC code to. - * @param {string} fourcc FourCC code to be written. - * @param {number} offset Offset in buffer to write FourCC code at. - * @private - */ - writeFourCC_(buffer, fourcc, offset) { - buffer[offset + 0] = fourcc.charCodeAt(0); - buffer[offset + 1] = fourcc.charCodeAt(1); - buffer[offset + 2] = fourcc.charCodeAt(2); - buffer[offset + 3] = fourcc.charCodeAt(3); - }, - - /** - * Compute CRC from buffer data. - * @param {!Uint8Array} buffer Buffer with data to compute CRC from. - * @param {number} start Start index in buffer. - * @param {number} end End index in buffer. - * @return {number} The computed CRC. - * @private - */ - getCRC_(buffer, start, end) { - let crc = 0xFFFFFFFF; - for (let i = start; i < end; i++) { - const crcTableIndex = (crc ^ (buffer[i])) & 0xFF; - crc = PNG_CRC_TABLE[crcTableIndex] ^ (crc >>> 8); - } - return crc ^ 0xFFFFFFFF; - }, - - /** - * Append frame from data URL to PNG object. - * @param {string} dataURL Data URL for frame. - * @param {!CrPngState} png PNG object to add frame to. - * @private - */ - appendFrameFromDataURL_(dataURL, png) { - /** Convert data URL to Uint8Array. */ - const byteString = atob(dataURL.split(',')[1]); - const bytes = new Uint8Array(byteString.length); - this.writeString_(bytes, byteString, 0); - - /** Check signature. */ - const signature = bytes.subarray(0, PNG_SIGNATURE.length); - if (signature.toString() !== PNG_SIGNATURE.toString()) { - console.error('Bad PNG signature'); - } - - /** - * fcTL - * - * Sequence number 4 bytes - * Width 4 bytes - * Height 4 bytes - * X position 4 bytes - * Y position 4 bytes - * Frame delay numerator 2 bytes - * Frame delay denominator 2 bytes - * Dispose op 1 bytes - * Blend op 1 bytes - */ - const fcTL = new Uint8Array(12 + 26); - this.writeUInt32_(fcTL, 26, 0); - this.writeFourCC_(fcTL, 'fcTL', 4); - this.writeUInt32_(fcTL, png.sequences, 8); - /** Write size at the end when known. */ - this.writeUInt32_(fcTL, 0, 20); - this.writeUInt32_(fcTL, 0, 24); - this.writeUInt16_(fcTL, PNG_FRAME_DELAY_NUMERATOR, 28); - this.writeUInt16_(fcTL, PNG_FRAME_DELAY_DENOMINATOR, 30); - this.writeUInt8_(fcTL, 0, 32); - this.writeUInt8_(fcTL, 0, 33); - /** Write CRC at the end when size is known. */ - png.sequences += 1; - png.chunks.push(fcTL); - - /** Append data chunks for frame. */ - let i = PNG_SIGNATURE.length; - while ((i + 12) <= bytes.length) { - /** - * http://www.w3.org/TR/2003/REC-PNG-20031110/#5Chunk-layout - * - * length = 4 bytes - * type = 4 bytes (IHDR, PLTE, IDAT, IEND or others) - * chunk = length bytes - * crc = 4 bytes - */ - const length = this.readUInt32_(bytes, i); - const type = this.readString_(bytes, i + 4, 4); - const chunk = bytes.subarray(i + 8, i + 8 + length); - - /** We should have enough bytes left for length. */ - if (length !== chunk.length) { - console.error('Unexpectedly reached end of file'); - } - - switch (type) { - case 'IHDR': - /** - * http://www.w3.org/TR/2003/REC-PNG-20031110/#11IHDR - * - * Width 4 bytes - * Height 4 bytes - * Bit depth 1 byte - * Colour type 1 byte - * Compression method 1 byte - * Filter method 1 byte - * Interlace method 1 byte - */ - const width = this.readUInt32_(chunk, 0); - const height = this.readUInt32_(chunk, 4); - const depth = chunk[8]; - const colour = chunk[9]; - const compression = chunk[10]; - const filter = chunk[11]; - const interlace = chunk[12]; - - /** Initialize size and colour if this is the first frame. */ - if (png.frames === 0) { - png.width = width; - png.height = height; - png.colour = colour; - } - - /** Check that header matches our expectations. */ - if (width !== png.width) { - console.error('Bad PNG width: ' + width); - } - if (height !== png.height) { - console.error('Bad PNG height: ' + height); - } - if (depth !== PNG_BIT_DEPTH) { - console.error('Bad PNG bit depth: ' + depth); - } - if (colour !== png.colour) { - console.error('Bad PNG colour type: ' + colour); - } - if (compression !== PNG_COMPRESSION_METHOD) { - console.error('Bad PNG compression method: ' + compression); - } - if (filter !== PNG_FILTER_METHOD) { - console.error('Bad PNG filter method: ' + filter); - } - if (interlace !== PNG_INTERLACE_METHOD) { - console.error('Bad PNG interlace method: ' + interlace); - } - break; - case 'IDAT': - /** Append as IDAT chunk if this is the first frame. */ - if (png.frames === 0) { - /** - * http://www.w3.org/TR/2003/REC-PNG-20031110/#11IDAT - * - * Data X bytes - */ - const IDAT = new Uint8Array(12 + length); - this.writeUInt32_(IDAT, length, 0); - this.writeFourCC_(IDAT, 'IDAT', 4); - this.writeBytes_(IDAT, chunk, 8); - this.writeUInt32_( - IDAT, this.getCRC_(IDAT, 4, 8 + length), 8 + length); - png.chunks.push(IDAT); - } else { - /** - * fdAT - * - * Sequence number 4 bytes - * Frame data X bytes - */ - const fdAT = new Uint8Array(12 + 4 + length); - this.writeUInt32_(fdAT, 4 + length, 0); - this.writeFourCC_(fdAT, 'fdAT', 4); - this.writeUInt32_(fdAT, png.sequences, 8); - this.writeBytes_(fdAT, chunk, 12); - this.writeUInt32_( - fdAT, this.getCRC_(fdAT, 4, 12 + length), 12 + length); - png.sequences += 1; - png.chunks.push(fdAT); - } - break; - case 'PLTE': - /** - * https://www.w3.org/TR/2003/REC-PNG-20031110/#11PLTE - * - * Palette data X bytes - */ - const PLTE = new Uint8Array(12 + length); - this.writeUInt32_(PLTE, length, 0); - this.writeFourCC_(PLTE, 'PLTE', 4); - this.writeBytes_(PLTE, chunk, 8); - this.writeUInt32_( - PLTE, this.getCRC_(PLTE, 4, 8 + length), 8 + length); - png.chunks.push(PLTE); - break; - case 'IEND': - /** Update fcTL now that size is known. */ - this.writeUInt32_(fcTL, png.width, 12); - this.writeUInt32_(fcTL, png.height, 16); - this.writeUInt32_(fcTL, this.getCRC_(fcTL, 4, 34), 34); - png.frames += 1; - return; - } - - /** Advance to next chunk. */ - i += 12 + length; - } - console.error('Unexpectedly reached end of file'); - }, -};
diff --git a/ui/webui/resources/cr_elements/chromeos/cr_picture/png.html b/ui/webui/resources/cr_elements/chromeos/cr_picture/png.html new file mode 100644 index 0000000..8525acfe --- /dev/null +++ b/ui/webui/resources/cr_elements/chromeos/cr_picture/png.html
@@ -0,0 +1,2 @@ +<link rel="import" href="../../../html/cr.html"> +<script src="png.js"></script>
diff --git a/ui/webui/resources/cr_elements/chromeos/cr_picture/png.js b/ui/webui/resources/cr_elements/chromeos/cr_picture/png.js new file mode 100644 index 0000000..cc4ea10 --- /dev/null +++ b/ui/webui/resources/cr_elements/chromeos/cr_picture/png.js
@@ -0,0 +1,517 @@ +// 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. + +cr.define('cr.png', function() { + /** + * @fileoverview + * 'CrPngBehavior' is a behavior to convert image sequences into APNG + * (animated PNG) images. + */ + + /** + * PNG frame delay fraction numerator. + * @const + */ + const PNG_FRAME_DELAY_NUMERATOR = 1; + + /** + * PNG frame delay fraction denominator. + * @const + */ + const PNG_FRAME_DELAY_DENOMINATOR = 20; + + /** + * PNG signature. + * @const + */ + const PNG_SIGNATURE = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]; + + /** + * PNG bit depth (8 = 32bpp). + * @const + */ + const PNG_BIT_DEPTH = 8; + + /** + * PNG compression method (0 = deflate/inflate compression with a sliding + * window PNG compression). + * @const + */ + const PNG_COMPRESSION_METHOD = 0; + + /** + * PNG filter method (0 = adaptive filtering with five basic filter types). + * @const + */ + const PNG_FILTER_METHOD = 0; + + /** + * PNG interlace method (0 = no interlace). + * @const + */ + const PNG_INTERLACE_METHOD = 0; + + /** + * CRC table for PNG encode. + * + * Generated using: + * + * for (var i = 0; i < 256; i++) { + * var value = i; + * for (var j = 0; j < 8; j++) { + * if (value & 1) + * value = ((0xEDB88320) ^ (value >>> 1)); + * else + * value = (value >>> 1); + * } + * TABLE[i] = value; + * } + * + * @const + */ + const PNG_CRC_TABLE = [ + 0x0, 0x77073096, 0xEE0E612C, 0x990951BA, 0x76DC419, 0x706AF48F, + 0xE963A535, 0x9E6495A3, 0xEDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, + 0x9B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, + 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, + 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, + 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, + 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x1DB7106, + 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x6B6B51F, 0x9FBFE4A5, 0xE8B8D433, + 0x7807C9A2, 0xF00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x86D3D2D, + 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, + 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, + 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, + 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, + 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x3B6E20C, 0x74B1D29A, + 0xEAD54739, 0x9DD277AF, 0x4DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, + 0xD6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0xA00AE27, 0x7D079EB1, + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, + 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, + 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, + 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, + 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x26D930A, 0x9C0906A9, 0xEB0E363F, + 0x72076785, 0x5005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0xCB61B38, + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0xBDBDF21, 0x86D3D2D4, 0xF1D4E242, + 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, + 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, + 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, + 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D + ]; + + /** + * PNG object state. + * @typedef {{ + * frames: number, + * sequences: number, + * width: number, + * height: number, + * colour: number, + * chunks: !Array<Uint8Array> + * }} + */ + let CrPngState; + + /** + * Returns a data URL for an animated PNG image that is created + * from a sequence of images. + * @param {!Array<string>} images The data URLs for each image. + * @return {string} A data URL for an animated PNG image. + */ + function convertImageSequenceToPng(images) { + const png = + /** @type {!CrPngState} */ ({frames: 0, sequences: 0, chunks: []}); + + /** Append signature. */ + png.chunks.push(new Uint8Array(PNG_SIGNATURE)); + + /** + * http://www.w3.org/TR/2003/REC-PNG-20031110/#11IHDR + * + * Width 4 bytes + * Height 4 bytes + * Bit depth 1 byte + * Colour type 1 byte + * Compression method 1 byte + * Filter method 1 byte + * Interlace method 1 byte + */ + const IHDR = new Uint8Array(12 + 13); + writeUInt32(IHDR, 13, 0); + writeFourCC(IHDR, 'IHDR', 4); + /** Write size at the end when known. */ + writeUInt8(IHDR, PNG_BIT_DEPTH, 16); + /** Write colour at the end when known. */ + writeUInt8(IHDR, PNG_COMPRESSION_METHOD, 18); + writeUInt8(IHDR, PNG_FILTER_METHOD, 19); + writeUInt8(IHDR, PNG_INTERLACE_METHOD, 20); + /** Write CRC at the end when size and colour is known. */ + png.chunks.push(IHDR); + + /** + * acTL + * + * Number of frames 4 bytes + * Number of times to loop 4 bytes + */ + const acTL = new Uint8Array(12 + 8); + writeUInt32(acTL, 8, 0); + writeFourCC(acTL, 'acTL', 4); + writeUInt32(acTL, images.length, 8); + writeUInt32(acTL, 0, 12); + writeUInt32(acTL, getCRC(acTL, 4, 16), 16); + png.chunks.push(acTL); + + /** Append each image as a PNG frame. */ + for (let i = 0; i < images.length; ++i) { + appendFrameFromDataURL(images[i], png); + } + + /** Update IHDR now that size and colour is known. */ + writeUInt32(IHDR, png.width, 8); + writeUInt32(IHDR, png.height, 12); + writeUInt8(IHDR, png.colour, 17); + writeUInt32(IHDR, getCRC(IHDR, 4, 8 + 13), 8 + 13); + + /** + * http://www.w3.org/TR/2003/REC-PNG-20031110/#11IEND + */ + const IEND = new Uint8Array(12); + writeUInt32(IEND, 0, 0); + writeFourCC(IEND, 'IEND', 4); + writeUInt32(IEND, getCRC(IEND, 4, 8), 8); + png.chunks.push(IEND); + + return 'data:image/png;base64,' + + btoa(png.chunks + .map(function(chunk) { + return String.fromCharCode.apply(null, chunk); + }) + .join('')); + } + + /** + * Returns true if the data URL is an animated PNG image. If the PNG is + * animated, then 'acTL' will have been set by convertImageSequenceToPng(). + * acTL is the animation control chunk in the data stream of an animated PNG. + * If it exists we assume the image is animated, regardless of the number of + * frames. The offset is the PNG signature ( 8 bytes) + IHDR (25 bytes) + 4 + * bytes of padding zeros. See https://wiki.mozilla.org/APNG_Specification + * @param {string} url An btoa encoded data URL for a PNG image. + * @return {boolean} True if data URL is an animated PNG image. + */ + function isEncodedPngDataUrlAnimated(url) { + const decoded = atob(url.substr('data:image/png;base64,'.length)); + return decoded.substr(37, 4) === 'acTL'; + } + + /** + * Reads Uint32 from buffer. + * @param {!Uint8Array} buffer Buffer to read UInt32 from. + * @param {number} offset Offset in buffer to read UInt32 at. + * @return {number} The value read. + */ + function readUInt32(buffer, offset) { + return (buffer[offset + 0] << 24) + (buffer[offset + 1] << 16) + + (buffer[offset + 2] << 8) + (buffer[offset + 3] << 0); + } + + /** + * Reads string from buffer. + * @param {!Uint8Array} buffer Buffer to read string from. + * @param {number} offset Offset in buffer to read string at. + * @param {number} length Length of string to read. + * @return {string} The value read. + */ + function readString(buffer, offset, length) { + let str = ''; + for (let i = 0; i < length; i++) { + str += String.fromCharCode(buffer[offset + i]); + } + return str; + } + + /** + * Write bytes to buffer. + * @param {!Uint8Array} buffer Buffer to write bytes to. + * @param {!Uint8Array} bytes Array of bytes to be written. + * @param {number} offset Offset in buffer to write bytes at. + */ + function writeBytes(buffer, bytes, offset) { + for (let i = 0; i < bytes.length; i++) { + buffer[offset + i] = bytes[i] & 0xFF; + } + } + + /** + * Write UInt8 to buffer. + * @param {!Uint8Array} buffer Buffer to write UInt8 to. + * @param {number} u8 UInt8 to be written. + * @param {number} offset Offset in buffer to write UInt8 at. + */ + function writeUInt8(buffer, u8, offset) { + buffer[offset] = u8 & 0xFF; + } + + /** + * Write UInt16 to buffer. + * @param {!Uint8Array} buffer Buffer to write UInt16 to. + * @param {number} u16 UInt16 to be written. + * @param {number} offset Offset in buffer to write UInt16 at. + */ + function writeUInt16(buffer, u16, offset) { + buffer[offset + 0] = (u16 >> 8) & 0xFF; + buffer[offset + 1] = (u16 >> 0) & 0xFF; + } + + /** + * Write UInt32 to buffer. + * @param {!Uint8Array} buffer Buffer to write UInt32 to. + * @param {number} u32 UInt32 to be written. + * @param {number} offset Offset in buffer to write UInt32 at. + */ + function writeUInt32(buffer, u32, offset) { + buffer[offset + 0] = (u32 >> 24) & 0xFF; + buffer[offset + 1] = (u32 >> 16) & 0xFF; + buffer[offset + 2] = (u32 >> 8) & 0xFF; + buffer[offset + 3] = (u32 >> 0) & 0xFF; + } + + /** + * Write string to buffer. + * @param {!Uint8Array} buffer Buffer to write string to. + * @param {string} string String to be written. + * @param {number} offset Offset in buffer to write string at. + */ + function writeString(buffer, string, offset) { + for (let i = 0; i < string.length; i++) { + buffer[offset + i] = string.charCodeAt(i); + } + } + + /** + * Write FourCC code to buffer. + * @param {!Uint8Array} buffer Buffer to write FourCC code to. + * @param {string} fourcc FourCC code to be written. + * @param {number} offset Offset in buffer to write FourCC code at. + */ + function writeFourCC(buffer, fourcc, offset) { + buffer[offset + 0] = fourcc.charCodeAt(0); + buffer[offset + 1] = fourcc.charCodeAt(1); + buffer[offset + 2] = fourcc.charCodeAt(2); + buffer[offset + 3] = fourcc.charCodeAt(3); + } + + /** + * Compute CRC from buffer data. + * @param {!Uint8Array} buffer Buffer with data to compute CRC from. + * @param {number} start Start index in buffer. + * @param {number} end End index in buffer. + * @return {number} The computed CRC. + */ + function getCRC(buffer, start, end) { + let crc = 0xFFFFFFFF; + for (let i = start; i < end; i++) { + const crcTableIndex = (crc ^ (buffer[i])) & 0xFF; + crc = PNG_CRC_TABLE[crcTableIndex] ^ (crc >>> 8); + } + return crc ^ 0xFFFFFFFF; + } + + /** + * Append frame from data URL to PNG object. + * @param {string} dataURL Data URL for frame. + * @param {!CrPngState} png PNG object to add frame to. + */ + function appendFrameFromDataURL(dataURL, png) { + /** Convert data URL to Uint8Array. */ + const byteString = atob(dataURL.split(',')[1]); + const bytes = new Uint8Array(byteString.length); + writeString(bytes, byteString, 0); + + /** Check signature. */ + const signature = bytes.subarray(0, PNG_SIGNATURE.length); + if (signature.toString() !== PNG_SIGNATURE.toString()) { + console.error('Bad PNG signature'); + } + + /** + * fcTL + * + * Sequence number 4 bytes + * Width 4 bytes + * Height 4 bytes + * X position 4 bytes + * Y position 4 bytes + * Frame delay numerator 2 bytes + * Frame delay denominator 2 bytes + * Dispose op 1 bytes + * Blend op 1 bytes + */ + const fcTL = new Uint8Array(12 + 26); + writeUInt32(fcTL, 26, 0); + writeFourCC(fcTL, 'fcTL', 4); + writeUInt32(fcTL, png.sequences, 8); + /** Write size at the end when known. */ + writeUInt32(fcTL, 0, 20); + writeUInt32(fcTL, 0, 24); + writeUInt16(fcTL, PNG_FRAME_DELAY_NUMERATOR, 28); + writeUInt16(fcTL, PNG_FRAME_DELAY_DENOMINATOR, 30); + writeUInt8(fcTL, 0, 32); + writeUInt8(fcTL, 0, 33); + /** Write CRC at the end when size is known. */ + png.sequences += 1; + png.chunks.push(fcTL); + + /** Append data chunks for frame. */ + let i = PNG_SIGNATURE.length; + while ((i + 12) <= bytes.length) { + /** + * http://www.w3.org/TR/2003/REC-PNG-20031110/#5Chunk-layout + * + * length = 4 bytes + * type = 4 bytes (IHDR, PLTE, IDAT, IEND or others) + * chunk = length bytes + * crc = 4 bytes + */ + const length = readUInt32(bytes, i); + const type = readString(bytes, i + 4, 4); + const chunk = bytes.subarray(i + 8, i + 8 + length); + + /** We should have enough bytes left for length. */ + if (length !== chunk.length) { + console.error('Unexpectedly reached end of file'); + } + + switch (type) { + case 'IHDR': + /** + * http://www.w3.org/TR/2003/REC-PNG-20031110/#11IHDR + * + * Width 4 bytes + * Height 4 bytes + * Bit depth 1 byte + * Colour type 1 byte + * Compression method 1 byte + * Filter method 1 byte + * Interlace method 1 byte + */ + const width = readUInt32(chunk, 0); + const height = readUInt32(chunk, 4); + const depth = chunk[8]; + const colour = chunk[9]; + const compression = chunk[10]; + const filter = chunk[11]; + const interlace = chunk[12]; + + /** Initialize size and colour if this is the first frame. */ + if (png.frames === 0) { + png.width = width; + png.height = height; + png.colour = colour; + } + + /** Check that header matches our expectations. */ + if (width !== png.width) { + console.error('Bad PNG width: ' + width); + } + if (height !== png.height) { + console.error('Bad PNG height: ' + height); + } + if (depth !== PNG_BIT_DEPTH) { + console.error('Bad PNG bit depth: ' + depth); + } + if (colour !== png.colour) { + console.error('Bad PNG colour type: ' + colour); + } + if (compression !== PNG_COMPRESSION_METHOD) { + console.error('Bad PNG compression method: ' + compression); + } + if (filter !== PNG_FILTER_METHOD) { + console.error('Bad PNG filter method: ' + filter); + } + if (interlace !== PNG_INTERLACE_METHOD) { + console.error('Bad PNG interlace method: ' + interlace); + } + break; + case 'IDAT': + /** Append as IDAT chunk if this is the first frame. */ + if (png.frames === 0) { + /** + * http://www.w3.org/TR/2003/REC-PNG-20031110/#11IDAT + * + * Data X bytes + */ + const IDAT = new Uint8Array(12 + length); + writeUInt32(IDAT, length, 0); + writeFourCC(IDAT, 'IDAT', 4); + writeBytes(IDAT, chunk, 8); + writeUInt32(IDAT, getCRC(IDAT, 4, 8 + length), 8 + length); + png.chunks.push(IDAT); + } else { + /** + * fdAT + * + * Sequence number 4 bytes + * Frame data X bytes + */ + const fdAT = new Uint8Array(12 + 4 + length); + writeUInt32(fdAT, 4 + length, 0); + writeFourCC(fdAT, 'fdAT', 4); + writeUInt32(fdAT, png.sequences, 8); + writeBytes(fdAT, chunk, 12); + writeUInt32(fdAT, getCRC(fdAT, 4, 12 + length), 12 + length); + png.sequences += 1; + png.chunks.push(fdAT); + } + break; + case 'PLTE': + /** + * https://www.w3.org/TR/2003/REC-PNG-20031110/#11PLTE + * + * Palette data X bytes + */ + const PLTE = new Uint8Array(12 + length); + writeUInt32(PLTE, length, 0); + writeFourCC(PLTE, 'PLTE', 4); + writeBytes(PLTE, chunk, 8); + writeUInt32(PLTE, getCRC(PLTE, 4, 8 + length), 8 + length); + png.chunks.push(PLTE); + break; + case 'IEND': + /** Update fcTL now that size is known. */ + writeUInt32(fcTL, png.width, 12); + writeUInt32(fcTL, png.height, 16); + writeUInt32(fcTL, getCRC(fcTL, 4, 34), 34); + png.frames += 1; + return; + } + + /** Advance to next chunk. */ + i += 12 + length; + } + console.error('Unexpectedly reached end of file'); + } + + return { + convertImageSequenceToPng, + isEncodedPngDataUrlAnimated, + }; +});
diff --git a/ui/webui/resources/cr_elements_resources.grdp b/ui/webui/resources/cr_elements_resources.grdp index a798a40..3cb801ba 100644 --- a/ui/webui/resources/cr_elements_resources.grdp +++ b/ui/webui/resources/cr_elements_resources.grdp
@@ -207,12 +207,12 @@ file="cr_elements/chromeos/cr_picture/cr_picture_types.js" type="chrome_html" compress="gzip" /> - <structure name="IDR_CR_ELEMENTS_CHROMEOS_CR_PICTURE_CR_PNG_BEHAVIOR_HTML" - file="cr_elements/chromeos/cr_picture/cr_png_behavior.html" + <structure name="IDR_CR_ELEMENTS_CHROMEOS_CR_PICTURE_PNG_HTML" + file="cr_elements/chromeos/cr_picture/png.html" type="chrome_html" compress="gzip" /> - <structure name="IDR_CR_ELEMENTS_CHROMEOS_CR_PICTURE_CR_PNG_BEHAVIOR_JS" - file="cr_elements/chromeos/cr_picture/cr_png_behavior.js" + <structure name="IDR_CR_ELEMENTS_CHROMEOS_CR_PICTURE_PNG_JS" + file="cr_elements/chromeos/cr_picture/png.js" type="chrome_html" compress="gzip" /> <structure name="IDR_CR_ELEMENTS_CHROMEOS_CR_PICTURE_ICONS_HTML"
diff --git a/weblayer/browser/java/org/chromium/weblayer_private/WebLayerImpl.java b/weblayer/browser/java/org/chromium/weblayer_private/WebLayerImpl.java index aaf3bac..af4e73c 100644 --- a/weblayer/browser/java/org/chromium/weblayer_private/WebLayerImpl.java +++ b/weblayer/browser/java/org/chromium/weblayer_private/WebLayerImpl.java
@@ -405,20 +405,17 @@ } private void loadNativeLibrary(String packageName) { - // Loading the library triggers disk access. - try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - WebViewFactory.loadWebViewNativeLibraryFromPackage( - packageName, getClass().getClassLoader()); - } else { - try { - Method loadNativeLibrary = - WebViewFactory.class.getDeclaredMethod("loadNativeLibrary"); - loadNativeLibrary.setAccessible(true); - loadNativeLibrary.invoke(null); - } catch (ReflectiveOperationException e) { - Log.e(TAG, "Failed to load native library.", e); - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + WebViewFactory.loadWebViewNativeLibraryFromPackage( + packageName, getClass().getClassLoader()); + } else { + try { + Method loadNativeLibrary = + WebViewFactory.class.getDeclaredMethod("loadNativeLibrary"); + loadNativeLibrary.setAccessible(true); + loadNativeLibrary.invoke(null); + } catch (ReflectiveOperationException e) { + Log.e(TAG, "Failed to load native library.", e); } } }
diff --git a/weblayer/browser/java/org/chromium/weblayer_private/WebLayerTabModalPresenter.java b/weblayer/browser/java/org/chromium/weblayer_private/WebLayerTabModalPresenter.java index de438eb..5bd723f 100644 --- a/weblayer/browser/java/org/chromium/weblayer_private/WebLayerTabModalPresenter.java +++ b/weblayer/browser/java/org/chromium/weblayer_private/WebLayerTabModalPresenter.java
@@ -10,7 +10,6 @@ import android.view.ViewGroup; import android.widget.FrameLayout; -import org.chromium.base.StrictModeContext; import org.chromium.components.browser_ui.modaldialog.R; import org.chromium.components.browser_ui.modaldialog.TabModalPresenter; import org.chromium.content_public.browser.WebContents; @@ -44,17 +43,10 @@ runEnterAnimation(); } - private FrameLayout loadDialogContainer() { - // LayoutInflater may trigger accessing the disk. - try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) { - return (FrameLayout) LayoutInflater.from(mContext).inflate( - R.layout.modal_dialog_container, null); - } - } - @Override protected ViewGroup createDialogContainer() { - FrameLayout dialogContainer = loadDialogContainer(); + FrameLayout dialogContainer = (FrameLayout) LayoutInflater.from(mContext).inflate( + R.layout.modal_dialog_container, null); dialogContainer.setVisibility(View.GONE); dialogContainer.setClickable(true);
diff --git a/weblayer/browser/java/org/chromium/weblayer_private/interfaces/PRESUBMIT.py b/weblayer/browser/java/org/chromium/weblayer_private/interfaces/PRESUBMIT.py index d20d61e..c375ef3b7 100644 --- a/weblayer/browser/java/org/chromium/weblayer_private/interfaces/PRESUBMIT.py +++ b/weblayer/browser/java/org/chromium/weblayer_private/interfaces/PRESUBMIT.py
@@ -19,7 +19,9 @@ Generally this means one of the following: A function has been removed. The arguments of a function has changed. -This tool also reports renames as errors, which are generally okay.""" +This tool also reports renames as errors, which are generally okay. +If the API you are changing was added in the current release, you can +safely ignore this warning.""" class AidlFile: """Provides information about an aidl file in the repo.""" @@ -137,7 +139,7 @@ result = subprocess.call([aidl_tool_path, '--checkapi', tmp_old_aidl_dir, tmp_new_aidl_dir]) if result != 0: - return [output_api.PresubmitError(_INCOMPATIBLE_API_ERROR_STRING)] + return [output_api.PresubmitPromptWarning(_INCOMPATIBLE_API_ERROR_STRING)] finally: shutil.rmtree(tmp_old_contents_dir) shutil.rmtree(tmp_old_aidl_dir)
diff --git a/weblayer/shell/android/shell_apk/src/org/chromium/weblayer/shell/InstrumentationActivity.java b/weblayer/shell/android/shell_apk/src/org/chromium/weblayer/shell/InstrumentationActivity.java index 1a68281..b245ecf7 100644 --- a/weblayer/shell/android/shell_apk/src/org/chromium/weblayer/shell/InstrumentationActivity.java +++ b/weblayer/shell/android/shell_apk/src/org/chromium/weblayer/shell/InstrumentationActivity.java
@@ -8,9 +8,6 @@ import android.content.Intent; import android.net.Uri; import android.os.Bundle; -import android.os.StrictMode; -import android.os.StrictMode.ThreadPolicy; -import android.os.StrictMode.VmPolicy; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; @@ -61,17 +58,6 @@ private Bundle mSavedInstanceState; private TabCallback mTabCallback; - private static boolean isJaCoCoEnabled() { - // Nothing is set at runtime indicating jacoco is being used. This looks for the existence - // of a javacoco class to determine if jacoco is enabled. - try { - Class.forName("org.jacoco.agent.rt.RT"); - return true; - } catch (LinkageError | ClassNotFoundException e) { - } - return false; - } - public Tab getTab() { return mTab; } @@ -109,19 +95,6 @@ @Override protected void onCreate(final Bundle savedInstanceState) { - // JaCoCo injects code that does file access, which doesn't work well with strict mode. - if (!isJaCoCoEnabled()) { - StrictMode.setThreadPolicy( - new ThreadPolicy.Builder().detectAll().penaltyLog().penaltyDeath().build()); - // This doesn't use detectAll() as the untagged sockets policy is encountered in tests - // using TestServer. - StrictMode.setVmPolicy(new VmPolicy.Builder() - .detectLeakedSqlLiteObjects() - .detectLeakedClosableObjects() - .penaltyLog() - .penaltyDeath() - .build()); - } super.onCreate(savedInstanceState); mSavedInstanceState = savedInstanceState; LinearLayout mainView = new LinearLayout(this);