diff --git a/BUILD.gn b/BUILD.gn index b42cb10..3172eb8 100644 --- a/BUILD.gn +++ b/BUILD.gn
@@ -212,8 +212,7 @@ "//ios/public/provider/chrome/browser", "//ios/public/provider/web", "//ios/testing:ocmock_support_unittest", - "//ios/third_party/fishhook", - "//ios/third_party/ochamcrest", + "//ios/third_party/earl_grey", "//ios/web:ios_web_inttests", "//ios/web:ios_web_unittests", "//ios/web/shell:ios_web_shell",
diff --git a/DEPS b/DEPS index fdf374f..25124403 100644 --- a/DEPS +++ b/DEPS
@@ -39,11 +39,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': '5092eacc7e9f8041bb05b678f71e4e917ff5529e', + 'skia_revision': 'f9634b95eccd58acf5b20d98c5d2ee5af353d3d2', # 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': 'f20b9710ceb1142db8a4efcc53daaaefdc7901ba', + 'v8_revision': 'cf55e9aee1a3c17c803ccf33f165973d5b820227', # 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. @@ -220,7 +220,7 @@ Var('chromium_git') + '/native_client/src/third_party/scons-2.0.1.git' + '@' + '1c1550e17fc26355d08627fbdec13d8291227067', 'src/third_party/webrtc': - Var('chromium_git') + '/external/webrtc/trunk/webrtc.git' + '@' + '57d7e7b1f6f36ec8eb8a3380582dc58588a8def5', # commit position 12336 + Var('chromium_git') + '/external/webrtc/trunk/webrtc.git' + '@' + '957712a5a83de8f328feba86cc0310cf5606dc9f', # commit position 12356 'src/third_party/openmax_dl': Var('chromium_git') + '/external/webrtc/deps/third_party/openmax.git' + '@' + Var('openmax_dl_revision'),
diff --git a/android_webview/browser/hardware_renderer.cc b/android_webview/browser/hardware_renderer.cc index 7c3ca15..aee4191 100644 --- a/android_webview/browser/hardware_renderer.cc +++ b/android_webview/browser/hardware_renderer.cc
@@ -59,7 +59,8 @@ surface_manager_->RegisterSurfaceFactoryClient( surface_id_allocator_->id_namespace(), this); display_.reset(new cc::Display(this, surface_manager_.get(), nullptr, nullptr, - settings)); + settings, + surface_id_allocator_->id_namespace())); } HardwareRenderer::~HardwareRenderer() {
diff --git a/android_webview/browser/hardware_renderer.h b/android_webview/browser/hardware_renderer.h index fe6fbe74..922a9403 100644 --- a/android_webview/browser/hardware_renderer.h +++ b/android_webview/browser/hardware_renderer.h
@@ -42,8 +42,6 @@ private: // cc::DisplayClient overrides. - void CommitVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval) override {} void OutputSurfaceLost() override {} void SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) override {}
diff --git a/ash/mus/keyboard_ui_mus.cc b/ash/mus/keyboard_ui_mus.cc index 3e67fa79..d2ca388 100644 --- a/ash/mus/keyboard_ui_mus.cc +++ b/ash/mus/keyboard_ui_mus.cc
@@ -12,7 +12,7 @@ namespace ash { -KeyboardUIMus::KeyboardUIMus(mojo::Connector* connector) +KeyboardUIMus::KeyboardUIMus(::shell::Connector* connector) : is_enabled_(false), observer_binding_(this) { // TODO(sky): should be something like mojo:keyboard, but need mapping. connector->ConnectToInterface("exe:chrome", &keyboard_); @@ -22,7 +22,8 @@ KeyboardUIMus::~KeyboardUIMus() {} // static -std::unique_ptr<KeyboardUI> KeyboardUIMus::Create(mojo::Connector* connector) { +std::unique_ptr<KeyboardUI> KeyboardUIMus::Create( + ::shell::Connector* connector) { return base::WrapUnique(new KeyboardUIMus(connector)); }
diff --git a/ash/mus/keyboard_ui_mus.h b/ash/mus/keyboard_ui_mus.h index 4a0b5521..6e12585 100644 --- a/ash/mus/keyboard_ui_mus.h +++ b/ash/mus/keyboard_ui_mus.h
@@ -12,7 +12,7 @@ #include "mojo/public/cpp/bindings/binding.h" #include "ui/keyboard/keyboard.mojom.h" -namespace mojo { +namespace shell { class Connector; } @@ -21,10 +21,10 @@ class KeyboardUIMus : public KeyboardUI, public keyboard::mojom::KeyboardObserver { public: - explicit KeyboardUIMus(mojo::Connector* connector); + explicit KeyboardUIMus(shell::Connector* connector); ~KeyboardUIMus() override; - static std::unique_ptr<KeyboardUI> Create(mojo::Connector* connector); + static std::unique_ptr<KeyboardUI> Create(shell::Connector* connector); // KeyboardUI: void Hide() override;
diff --git a/ash/mus/main.cc b/ash/mus/main.cc index 614cdb5b..2640ace 100644 --- a/ash/mus/main.cc +++ b/ash/mus/main.cc
@@ -7,6 +7,6 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner(new ash::sysui::SysUIApplication); + shell::ApplicationRunner runner(new ash::sysui::SysUIApplication); return runner.Run(shell_handle); }
diff --git a/ash/mus/shelf_delegate_mus.cc b/ash/mus/shelf_delegate_mus.cc index b5a6623..2dc106ef 100644 --- a/ash/mus/shelf_delegate_mus.cc +++ b/ash/mus/shelf_delegate_mus.cc
@@ -114,7 +114,7 @@ ShelfDelegateMus::ShelfDelegateMus(ShelfModel* model) : model_(model), binding_(this) { - mojo::Connector* connector = + ::shell::Connector* connector = views::WindowManagerConnection::Get()->connector(); connector->ConnectToInterface("mojo:desktop_wm", &user_window_controller_); user_window_controller_->AddUserWindowObserver(
diff --git a/ash/mus/sysui_application.cc b/ash/mus/sysui_application.cc index 6973e018..571523e 100644 --- a/ash/mus/sysui_application.cc +++ b/ash/mus/sysui_application.cc
@@ -193,7 +193,7 @@ aura::Window* root() { return ash::Shell::GetPrimaryRootWindow(); } - void Initialize(mojo::Connector* connector) { + void Initialize(::shell::Connector* connector) { InitializeResourceBundle(connector); aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); views::WindowManagerConnection::Create(connector); @@ -232,7 +232,7 @@ SetupWallpaper(SkColorSetARGB(255, 0, 255, 0)); } - void InitializeResourceBundle(mojo::Connector* connector) { + void InitializeResourceBundle(::shell::Connector* connector) { if (ui::ResourceBundle::HasSharedInstance()) return; @@ -302,20 +302,20 @@ SysUIApplication::~SysUIApplication() {} -void SysUIApplication::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void SysUIApplication::Initialize(::shell::Connector* connector, + const ::shell::Identity& identity, uint32_t id) { ash_init_.reset(new AshInit()); ash_init_->Initialize(connector); } -bool SysUIApplication::AcceptConnection(mojo::Connection* connection) { +bool SysUIApplication::AcceptConnection(::shell::Connection* connection) { connection->AddInterface<mash::shelf::mojom::ShelfController>(this); return true; } void SysUIApplication::Create( - mojo::Connection* connection, + ::shell::Connection* connection, mojo::InterfaceRequest<mash::shelf::mojom::ShelfController> request) { mash::shelf::mojom::ShelfController* shelf_controller = static_cast<ShelfDelegateMus*>(Shell::GetInstance()->GetShelfDelegate());
diff --git a/ash/mus/sysui_application.h b/ash/mus/sysui_application.h index 26e8566..4e8afcee 100644 --- a/ash/mus/sysui_application.h +++ b/ash/mus/sysui_application.h
@@ -19,21 +19,21 @@ class AshInit; class SysUIApplication - : public mojo::ShellClient, - public mojo::InterfaceFactory<mash::shelf::mojom::ShelfController> { + : public shell::ShellClient, + public shell::InterfaceFactory<mash::shelf::mojom::ShelfController> { public: SysUIApplication(); ~SysUIApplication() override; private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, - const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(::shell::Connector* connector, + const ::shell::Identity& identity, uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; // InterfaceFactory<mash::shelf::mojom::ShelfController>: - void Create(mojo::Connection* connection, + void Create(shell::Connection* connection, mojo::InterfaceRequest<mash::shelf::mojom::ShelfController> request) override;
diff --git a/ash/shell.cc b/ash/shell.cc index acffa37..b0c8c4c 100644 --- a/ash/shell.cc +++ b/ash/shell.cc
@@ -877,7 +877,8 @@ #if defined(USE_OZONE) display_configurator_->Init( - ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), + in_mus_ ? nullptr + : ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), !gpu_support_->IsPanelFittingDisabled()); #elif defined(USE_X11) display_configurator_->Init(
diff --git a/ash/wm/dock/docked_window_layout_manager.cc b/ash/wm/dock/docked_window_layout_manager.cc index 71b8929..8714410 100644 --- a/ash/wm/dock/docked_window_layout_manager.cc +++ b/ash/wm/dock/docked_window_layout_manager.cc
@@ -8,7 +8,6 @@ #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_constants.h" #include "ash/shelf/shelf_layout_manager.h" -#include "ash/shelf/shelf_layout_manager_observer.h" #include "ash/shelf/shelf_types.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" @@ -58,8 +57,7 @@ const int kMinimizeDurationMs = 720; class DockedBackgroundWidget : public views::Widget, - public BackgroundAnimatorDelegate, - public ShelfLayoutManagerObserver { + public BackgroundAnimatorDelegate { public: explicit DockedBackgroundWidget(aura::Window* container) : alignment_(DOCKED_ALIGNMENT_NONE), @@ -68,19 +66,9 @@ opaque_background_(ui::LAYER_SOLID_COLOR), visible_background_type_(SHELF_BACKGROUND_DEFAULT), visible_background_change_type_(BACKGROUND_CHANGE_IMMEDIATE) { - Shelf* shelf = Shelf::ForWindow(container); - visible_background_type_ = shelf->shelf_widget()->GetBackgroundType(); - shelf->shelf_layout_manager()->AddObserver(this); - InitWidget(container); } - ~DockedBackgroundWidget() override { - Shelf* shelf = Shelf::ForWindow(GetNativeWindow()); - if (shelf && shelf->shelf_layout_manager()) - shelf->shelf_layout_manager()->RemoveObserver(this); - } - // Sets widget bounds and sizes opaque background layer to fill the widget. void SetBackgroundBounds(const gfx::Rect bounds, DockedAlignment alignment) { SetBounds(bounds); @@ -88,7 +76,17 @@ alignment_ = alignment; } - private: + // Sets the background type. Starts an animation to transition to + // |background_type| if the widget is visible. If the widget is not visible, + // the animation is postponed till the widget becomes visible. + void SetBackgroundType(ShelfBackgroundType background_type, + BackgroundAnimatorChangeType change_type) { + visible_background_type_ = background_type; + visible_background_change_type_ = change_type; + if (IsVisible()) + UpdateBackground(); + } + // views::Widget: void OnNativeWidgetVisibilityChanged(bool visible) override { views::Widget::OnNativeWidgetVisibilityChanged(visible); @@ -126,18 +124,7 @@ SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size())); } - // ShelfLayoutManagerObserver: - void OnBackgroundUpdated(ShelfBackgroundType background_type, - BackgroundAnimatorChangeType change_type) override { - // Sets the background type. Starts an animation to transition to - // |background_type| if the widget is visible. If the widget is not visible, - // the animation is postponed till the widget becomes visible. - visible_background_type_ = background_type; - visible_background_change_type_ = change_type; - if (IsVisible()) - UpdateBackground(); - } - + private: void InitWidget(aura::Window* parent) { views::Widget::InitParams params; params.type = views::Widget::InitParams::TYPE_POPUP; @@ -154,6 +141,7 @@ opaque_background_.SetBounds(gfx::Rect(GetWindowBoundsInScreen().size())); opaque_background_.SetOpacity(0.0f); GetNativeWindow()->layer()->Add(&opaque_background_); + Hide(); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); gfx::ImageSkia shelf_background = @@ -162,9 +150,6 @@ shelf_background, SkBitmapOperations::ROTATION_90_CW); shelf_background_right_ = gfx::ImageSkiaOperations::CreateRotatedImage( shelf_background, SkBitmapOperations::ROTATION_270_CW); - - // Stack the background below any windows already in the dock container. - parent->StackChildAtBottom(GetNativeWindow()); } // Transitions to |visible_background_type_| if the widget is visible and to @@ -416,10 +401,10 @@ : SnapToPixelLayoutManager(dock_container), dock_container_(dock_container), in_layout_(false), - dragged_window_(nullptr), + dragged_window_(NULL), is_dragged_window_docked_(false), is_dragged_from_dock_(false), - shelf_(nullptr), + shelf_(NULL), workspace_controller_(workspace_controller), in_fullscreen_(workspace_controller_->GetWindowState() == WORKSPACE_WINDOW_STATE_FULL_SCREEN), @@ -427,9 +412,9 @@ alignment_(DOCKED_ALIGNMENT_NONE), preferred_alignment_(DOCKED_ALIGNMENT_NONE), event_source_(DOCKED_ACTION_SOURCE_UNKNOWN), - last_active_window_(nullptr), + last_active_window_(NULL), last_action_time_(base::Time::Now()), - background_widget_(nullptr) { + background_widget_(new DockedBackgroundWidget(dock_container_)) { DCHECK(dock_container); aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> AddObserver(this); @@ -441,9 +426,11 @@ } void DockedWindowLayoutManager::Shutdown() { - background_widget_.reset(); - shelf_observer_.reset(); - shelf_ = nullptr; + if (shelf_ && shelf_->shelf_layout_manager()) { + shelf_->shelf_layout_manager()->RemoveObserver(this); + shelf_observer_.reset(); + } + shelf_ = NULL; for (size_t i = 0; i < dock_container_->children().size(); ++i) { aura::Window* child = dock_container_->children()[i]; child->RemoveObserver(this); @@ -530,7 +517,7 @@ dragged_window_->RemoveObserver(this); wm::GetWindowState(dragged_window_)->RemoveObserver(this); if (last_active_window_ == dragged_window_) - last_active_window_ = nullptr; + last_active_window_ = NULL; } else { // If this is the first window that got docked by a move update alignment. if (alignment_ == DOCKED_ALIGNMENT_NONE) @@ -541,7 +528,7 @@ // count limit so do it here. MaybeMinimizeChildrenExcept(dragged_window_); } - dragged_window_ = nullptr; + dragged_window_ = NULL; dragged_bounds_ = gfx::Rect(); Relayout(); UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); @@ -551,7 +538,10 @@ void DockedWindowLayoutManager::SetShelf(Shelf* shelf) { DCHECK(!shelf_); shelf_ = shelf; - shelf_observer_.reset(new ShelfWindowObserver(this)); + if (shelf_->shelf_layout_manager()) { + shelf_->shelf_layout_manager()->AddObserver(this); + shelf_observer_.reset(new ShelfWindowObserver(this)); + } } DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow( @@ -724,7 +714,7 @@ UpdateDockedWidth(0); } if (last_active_window_ == child) - last_active_window_ = nullptr; + last_active_window_ = NULL; child->RemoveObserver(this); wm::GetWindowState(child)->RemoveObserver(this); Relayout(); @@ -831,6 +821,14 @@ } ///////////////////////////////////////////////////////////////////////////// +// DockedWindowLayoutManager, ShelfLayoutManagerObserver implementation: +void DockedWindowLayoutManager::OnBackgroundUpdated( + ShelfBackgroundType background_type, + BackgroundAnimatorChangeType change_type) { + background_widget_->SetBackgroundType(background_type, change_type); +} + +///////////////////////////////////////////////////////////////////////////// // DockedWindowLayoutManager, WindowStateObserver implementation: void DockedWindowLayoutManager::OnPreWindowStateTypeChange( @@ -894,10 +892,11 @@ DCHECK(!is_dragged_window_docked_); } if (window == last_active_window_) - last_active_window_ = nullptr; + last_active_window_ = NULL; RecordUmaAction(DOCKED_ACTION_CLOSE, event_source_); } + //////////////////////////////////////////////////////////////////////////////// // DockedWindowLayoutManager, aura::client::ActivationChangeObserver // implementation: @@ -909,7 +908,7 @@ if (gained_active && IsPopupOrTransient(gained_active)) return; // Ignore if the window that is not managed by this was activated. - aura::Window* ancestor = nullptr; + aura::Window* ancestor = NULL; for (aura::Window* parent = gained_active; parent; parent = parent->parent()) { if (parent->parent() == dock_container_) { @@ -1076,7 +1075,7 @@ base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); gfx::Rect dock_bounds = dock_container_->GetBoundsInScreen(); - aura::Window* active_window = nullptr; + aura::Window* active_window = NULL; std::vector<WindowWithHeight> visible_windows; for (size_t i = 0; i < dock_container_->children().size(); ++i) { aura::Window* window(dock_container_->children()[i]); @@ -1207,8 +1206,9 @@ // Sort windows by their center positions and fan out overlapping // windows. std::sort(visible_windows->begin(), visible_windows->end(), - CompareWindowPos(is_dragged_from_dock_ ? dragged_window_ : nullptr, - dock_container_, delta)); + CompareWindowPos(is_dragged_from_dock_ ? dragged_window_ : NULL, + dock_container_, + delta)); for (std::vector<WindowWithHeight>::iterator iter = visible_windows->begin(); iter != visible_windows->end(); ++iter) { aura::Window* window = iter->window(); @@ -1292,14 +1292,11 @@ gfx::Rect background_bounds(docked_bounds_); if (shelf_observer_) background_bounds.Subtract(shelf_observer_->shelf_bounds_in_screen()); - if (docked_width_ > 0) { - if (!background_widget_) - background_widget_.reset(new DockedBackgroundWidget(dock_container_)); - background_widget_->SetBackgroundBounds(background_bounds, alignment_); + background_widget_->SetBackgroundBounds(background_bounds, alignment_); + if (docked_width_ > 0) background_widget_->Show(); - } else if (background_widget_) { + else background_widget_->Hide(); - } } void DockedWindowLayoutManager::UpdateStacking(aura::Window* active_window) { @@ -1335,7 +1332,7 @@ } int active_center_y = active_window->bounds().CenterPoint().y(); - aura::Window* previous_window = nullptr; + aura::Window* previous_window = NULL; for (std::map<int, aura::Window*>::const_iterator it = window_ordering.begin(); it != window_ordering.end() && it->first < active_center_y; ++it) {
diff --git a/ash/wm/dock/docked_window_layout_manager.h b/ash/wm/dock/docked_window_layout_manager.h index e89be0d8..b1589bd 100644 --- a/ash/wm/dock/docked_window_layout_manager.h +++ b/ash/wm/dock/docked_window_layout_manager.h
@@ -8,6 +8,7 @@ #include <memory> #include "ash/ash_export.h" +#include "ash/shelf/shelf_layout_manager_observer.h" #include "ash/shell_observer.h" #include "ash/snap_to_pixel_layout_manager.h" #include "ash/wm/dock/dock_types.h" @@ -40,6 +41,7 @@ class DockedWindowLayoutManagerObserver; class DockedWindowResizerTest; class Shelf; +class ShelfLayoutManager; class WorkspaceController; struct WindowWithHeight { @@ -70,6 +72,7 @@ public aura::WindowObserver, public aura::client::ActivationChangeObserver, public keyboard::KeyboardControllerObserver, + public ShelfLayoutManagerObserver, public wm::WindowStateObserver { public: // Maximum width of the docked windows area. @@ -160,6 +163,10 @@ aura::Window* root_window) override; void OnShelfAlignmentChanged(aura::Window* root_window) override; + // ShelfLayoutManagerObserver: + void OnBackgroundUpdated(ShelfBackgroundType background_type, + BackgroundAnimatorChangeType change_type) override; + // wm::WindowStateObserver: void OnPreWindowStateTypeChange(wm::WindowState* window_state, wm::WindowStateType old_type) override;
diff --git a/build/args/bots/official.desktop/blimp-engine.gn b/build/args/bots/official.desktop/blimp-engine.gn new file mode 100644 index 0000000..0cd50c9 --- /dev/null +++ b/build/args/bots/official.desktop/blimp-engine.gn
@@ -0,0 +1,2 @@ +import("//build/args/blimp_engine.gn") +is_debug = true
diff --git a/build/config/ios/rules.gni b/build/config/ios/rules.gni index 2c079d4..3265700 100644 --- a/build/config/ios/rules.gni +++ b/build/config/ios/rules.gni
@@ -198,8 +198,7 @@ invoker.source, ] outputs = [ - "$target_gen_dir/$_nib_filename/objects.nib", - "$target_gen_dir/$_nib_filename/runtime.nib", + "$target_gen_dir/$_nib_filename", ] args = [ "--minimum-deployment-target", @@ -220,11 +219,10 @@ public_deps += [ ":$_compile_xib" ] sources = [ - "$target_gen_dir/$_nib_filename/objects.nib", - "$target_gen_dir/$_nib_filename/runtime.nib", + "$target_gen_dir/$_nib_filename", ] outputs = [ - "{{bundle_resources_dir}}/$_nib_filename/{{source_file_part}}", + "{{bundle_resources_dir}}/$_nib_filename", ] } } @@ -255,19 +253,18 @@ # See "gn help shared_library" for more information on arguments supported # by shared library target. template("ios_framework_bundle") { + _target_name = target_name + _output_name = target_name + if (defined(invoker.output_name)) { + _output_name = invoker.output_name + } + _framework_target = _target_name + if (defined(invoker.public_headers) && invoker.public_headers != []) { - assert(defined(invoker.sources) && invoker.sources != [], - "sources must be set for $target_name when public_headers is set") - - _target_name = target_name - _output_name = target_name - if (defined(invoker.output_name)) { - _output_name = invoker.output_name - } - _public_headers = invoker.public_headers _framework_name = _output_name + ".framework" _framework_root = "$root_out_dir/$_framework_name" + _framework_target = target_name + "_internal" _header_map_filename = "$target_gen_dir/$_output_name.headers.hmap" _framework_headers_target = _target_name + "_framework_headers" @@ -327,6 +324,22 @@ config(_headers_map_config) { visibility = [ ":$_target_name" ] include_dirs = [ _header_map_filename ] + ldflags = [ + "-install_name", + "@rpath/$_framework_name/$_output_name", + ] + } + + _framework_public_config = _target_name + "_public_config" + config(_framework_public_config) { + # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs + # and include_dirs to avoid duplicate values on the command-line. + common_flags = [ "-F" + rebase_path("$root_out_dir/.", root_out_dir) ] + cflags_objc = common_flags + cflags_objcc = common_flags + ldflags = common_flags + lib_dirs = [ root_out_dir ] + libs = [ _framework_name ] } group(_framework_headers_target) { @@ -338,15 +351,45 @@ } } - framework_bundle(target_name) { - forward_variables_from(invoker, "*", [ "public_headers" ]) + framework_bundle(_framework_target) { + forward_variables_from(invoker, + "*", + [ + "output_name", + "public_headers", + "visibility", + ]) + output_name = _output_name if (defined(_public_headers)) { + visibility = [ ":$_target_name" ] configs += [ ":$_headers_map_config" ] + if (!defined(deps)) { deps = [] } deps += [ ":$_framework_headers_target" ] + } else { + forward_variables_from(invoker, [ "visibility" ]) + } + } + + if (defined(_public_headers)) { + group(_target_name) { + forward_variables_from(invoker, + [ + "testonly", + "visibility", + "public_configs", + ]) + + deps = [ + ":$_framework_target", + ] + if (!defined(public_configs)) { + public_configs = [] + } + public_configs += [ ":$_framework_public_config" ] } } }
diff --git a/build/config/mac/rules.gni b/build/config/mac/rules.gni index 6ffe613e..2bcfbd68 100644 --- a/build/config/mac/rules.gni +++ b/build/config/mac/rules.gni
@@ -88,10 +88,10 @@ forward_variables_from(invoker, [ "visibility" ]) } - if (!defined(deps)) { - deps = [] + if (!defined(public_deps)) { + public_deps = [] } - deps += [ ":$_shared_library_bundle_data" ] + public_deps += [ ":$_shared_library_bundle_data" ] bundle_root_dir = _framework_root_dir bundle_resources_dir = "$bundle_root_dir/Resources" @@ -114,7 +114,7 @@ "$_framework_name", "$_framework_version", ] - deps = [ + public_deps = [ ":$_framework_target", ] }
diff --git a/cc/output/output_surface.cc b/cc/output/output_surface.cc index 64b1d3b..2263174 100644 --- a/cc/output/output_surface.cc +++ b/cc/output/output_surface.cc
@@ -189,17 +189,6 @@ std::move(software_device)) { } -void OutputSurface::CommitVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval) { - TRACE_EVENT2("cc", - "OutputSurface::CommitVSyncParameters", - "timebase", - (timebase - base::TimeTicks()).InSecondsF(), - "interval", - interval.InSecondsF()); - client_->CommitVSyncParameters(timebase, interval); -} - // Forwarded to OutputSurfaceClient void OutputSurface::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { TRACE_EVENT0("cc", "OutputSurface::SetNeedsRedrawRect");
diff --git a/cc/output/output_surface.h b/cc/output/output_surface.h index 062fd00..da4b647 100644 --- a/cc/output/output_surface.h +++ b/cc/output/output_surface.h
@@ -199,9 +199,6 @@ bool has_alpha_; base::ThreadChecker client_thread_checker_; - void CommitVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval); - void SetNeedsRedrawRect(const gfx::Rect& damage_rect); void ReclaimResources(const CompositorFrameAck* ack); void SetExternalStencilTest(bool enabled);
diff --git a/cc/output/output_surface_client.h b/cc/output/output_surface_client.h index 8f7f36e..dae7358 100644 --- a/cc/output/output_surface_client.h +++ b/cc/output/output_surface_client.h
@@ -18,13 +18,20 @@ namespace cc { +class BeginFrameSource; class CompositorFrameAck; struct ManagedMemoryPolicy; class CC_EXPORT OutputSurfaceClient { public: + // TODO(enne): Remove this in favor of using SetBeginFrameSource. virtual void CommitVSyncParameters(base::TimeTicks timebase, base::TimeDelta interval) = 0; + // Pass the begin frame source for the client to observe. Client does not own + // the BeginFrameSource. OutputSurface should call this once after binding to + // the client and then call again with a null while detaching. + virtual void SetBeginFrameSource(BeginFrameSource* source) = 0; + virtual void SetNeedsRedrawRect(const gfx::Rect& damage_rect) = 0; virtual void DidSwapBuffers() = 0; virtual void DidSwapBuffersComplete() = 0; @@ -39,7 +46,7 @@ // valid for the lifetime of the OutputSurfaceClient or until unregisted -- // use SetTreeActivationCallback(base::Closure()) to unregister it. virtual void SetTreeActivationCallback(const base::Closure& callback) = 0; - // This allows the output surface to ask it's client for a draw. + // This allows the output surface to ask its client for a draw. virtual void OnDraw(const gfx::Transform& transform, const gfx::Rect& viewport, const gfx::Rect& clip,
diff --git a/cc/output/output_surface_unittest.cc b/cc/output/output_surface_unittest.cc index 1014ad1..bebd245 100644 --- a/cc/output/output_surface_unittest.cc +++ b/cc/output/output_surface_unittest.cc
@@ -42,11 +42,6 @@ client_->DidSwapBuffersComplete(); } - void CommitVSyncParametersForTesting(base::TimeTicks timebase, - base::TimeDelta interval) { - CommitVSyncParameters(timebase, interval); - } - void DidSwapBuffersForTesting() { client_->DidSwapBuffers(); } void OnSwapBuffersCompleteForTesting() { client_->DidSwapBuffersComplete(); }
diff --git a/cc/surfaces/display.cc b/cc/surfaces/display.cc index 2632827..7c1941d 100644 --- a/cc/surfaces/display.cc +++ b/cc/surfaces/display.cc
@@ -24,50 +24,94 @@ #include "gpu/command_buffer/client/gles2_interface.h" #include "ui/gfx/buffer_types.h" +namespace { + +class EmptyBeginFrameSource : public cc::BeginFrameSource { + public: + void DidFinishFrame(size_t remaining_frames) override{}; + void AddObserver(cc::BeginFrameObserver* obs) override{}; + void RemoveObserver(cc::BeginFrameObserver* obs) override{}; + void AsValueInto(base::trace_event::TracedValue* dict) const override{}; +}; + +} // namespace + namespace cc { Display::Display(DisplayClient* client, SurfaceManager* manager, SharedBitmapManager* bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, - const RendererSettings& settings) + const RendererSettings& settings, + uint32_t compositor_surface_namespace) : client_(client), - manager_(manager), + surface_manager_(manager), bitmap_manager_(bitmap_manager), gpu_memory_buffer_manager_(gpu_memory_buffer_manager), settings_(settings), + compositor_surface_namespace_(compositor_surface_namespace), device_scale_factor_(1.f), swapped_since_resize_(false), - scheduler_(nullptr), + vsync_begin_frame_source_(nullptr), + observed_begin_frame_source_(nullptr), texture_mailbox_deleter_(new TextureMailboxDeleter(nullptr)) { - manager_->AddObserver(this); + surface_manager_->AddObserver(this); } Display::~Display() { - manager_->RemoveObserver(this); + if (observed_begin_frame_source_) + surface_manager_->UnregisterBeginFrameSource(observed_begin_frame_source_); + surface_manager_->RemoveObserver(this); if (aggregator_) { for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { - Surface* surface = manager_->GetSurfaceForId(id_entry.first); + Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first); if (surface) surface->RunDrawCallbacks(SurfaceDrawStatus::DRAW_SKIPPED); } } } +void Display::CreateScheduler(base::SingleThreadTaskRunner* task_runner) { + DCHECK(!scheduler_); + if (!task_runner) { + // WebView doesn't have a task runner or a real begin frame source, + // so just create something fake here. + internal_begin_frame_source_.reset(new EmptyBeginFrameSource()); + vsync_begin_frame_source_ = internal_begin_frame_source_.get(); + observed_begin_frame_source_ = vsync_begin_frame_source_; + } else { + DCHECK(vsync_begin_frame_source_); + + observed_begin_frame_source_ = vsync_begin_frame_source_; + if (settings_.disable_display_vsync) { + internal_begin_frame_source_.reset( + new BackToBackBeginFrameSource(task_runner)); + observed_begin_frame_source_ = internal_begin_frame_source_.get(); + } + } + + scheduler_.reset( + new DisplayScheduler(this, observed_begin_frame_source_, task_runner, + output_surface_->capabilities().max_frames_pending)); + surface_manager_->RegisterBeginFrameSource(observed_begin_frame_source_, + compositor_surface_namespace_); +} + bool Display::Initialize(std::unique_ptr<OutputSurface> output_surface, - DisplayScheduler* scheduler) { - // TODO(enne): register/unregister BeginFrameSource with SurfaceManager here. + base::SingleThreadTaskRunner* task_runner) { output_surface_ = std::move(output_surface); - scheduler_ = scheduler; - return output_surface_->BindToClient(this); + if (!output_surface_->BindToClient(this)) + return false; + CreateScheduler(task_runner); + return true; } void Display::SetSurfaceId(SurfaceId id, float device_scale_factor) { + DCHECK_EQ(id.id_namespace(), compositor_surface_namespace_); if (current_surface_id_ == id && device_scale_factor_ == device_scale_factor) return; TRACE_EVENT0("cc", "Display::SetSurfaceId"); - current_surface_id_ = id; device_scale_factor_ = device_scale_factor; @@ -136,8 +180,8 @@ // overlays. bool output_partial_list = renderer_->Capabilities().using_partial_swap && !output_surface_->GetOverlayCandidateValidator(); - aggregator_.reset(new SurfaceAggregator(manager_, resource_provider_.get(), - output_partial_list)); + aggregator_.reset(new SurfaceAggregator( + surface_manager_, resource_provider_.get(), output_partial_list)); } void Display::DidLoseOutputSurface() { @@ -149,7 +193,7 @@ } void Display::UpdateRootSurfaceResourcesLocked() { - Surface* surface = manager_->GetSurfaceForId(current_surface_id_); + Surface* surface = surface_manager_->GetSurfaceForId(current_surface_id_); bool root_surface_resources_locked = !surface || !surface->GetEligibleFrame(); if (scheduler_) scheduler_->SetRootSurfaceResourcesLocked(root_surface_resources_locked); @@ -179,7 +223,7 @@ // Run callbacks early to allow pipelining. for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { - Surface* surface = manager_->GetSurfaceForId(id_entry.first); + Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first); if (surface) surface->RunDrawCallbacks(SurfaceDrawStatus::DRAWN); } @@ -277,9 +321,15 @@ renderer_->SwapBuffersComplete(); } -void Display::CommitVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval) { - client_->CommitVSyncParameters(timebase, interval); +void Display::SetBeginFrameSource(BeginFrameSource* source) { + // It's expected that there's only a single source from the + // BrowserCompositorOutputSurface that corresponds to vsync. The BFS is + // passed BrowserCompositorOutputSurface -> Display -> DisplayScheduler as an + // input. DisplayScheduler makes a decision about which BFS to use and + // calls back to Display as DisplaySchedulerClient to register for that + // surface id. + DCHECK(!vsync_begin_frame_source_); + vsync_begin_frame_source_ = source; } void Display::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { @@ -321,7 +371,7 @@ void Display::OnSurfaceDamaged(SurfaceId surface_id, bool* changed) { if (aggregator_ && aggregator_->previous_contained_surfaces().count(surface_id)) { - Surface* surface = manager_->GetSurfaceForId(surface_id); + Surface* surface = surface_manager_->GetSurfaceForId(surface_id); if (surface) { const CompositorFrame* current_frame = surface->GetEligibleFrame(); if (!current_frame || !current_frame->delegated_frame_data ||
diff --git a/cc/surfaces/display.h b/cc/surfaces/display.h index 3ab9cefb..d3e256d 100644 --- a/cc/surfaces/display.h +++ b/cc/surfaces/display.h
@@ -55,11 +55,12 @@ SurfaceManager* manager, SharedBitmapManager* bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, - const RendererSettings& settings); + const RendererSettings& settings, + uint32_t compositor_surface_namespace); ~Display() override; bool Initialize(std::unique_ptr<OutputSurface> output_surface, - DisplayScheduler* scheduler); + base::SingleThreadTaskRunner* task_runner); // device_scale_factor is used to communicate to the external window system // what scale this was rendered at. @@ -74,7 +75,8 @@ // OutputSurfaceClient implementation. void CommitVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval) override; + base::TimeDelta interval) override {} + void SetBeginFrameSource(BeginFrameSource* source) override; void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override; void DidSwapBuffers() override; void DidSwapBuffersComplete() override; @@ -96,28 +98,39 @@ // SurfaceDamageObserver implementation. void OnSurfaceDamaged(SurfaceId surface, bool* changed) override; - private: + protected: + // Virtual for tests. + virtual void CreateScheduler(base::SingleThreadTaskRunner* task_runner); + void InitializeRenderer(); void UpdateRootSurfaceResourcesLocked(); DisplayClient* client_; - SurfaceManager* manager_; + SurfaceManager* surface_manager_; SharedBitmapManager* bitmap_manager_; gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; RendererSettings settings_; SurfaceId current_surface_id_; + uint32_t compositor_surface_namespace_; gfx::Size current_surface_size_; float device_scale_factor_; bool swapped_since_resize_; gfx::Rect external_clip_; std::unique_ptr<OutputSurface> output_surface_; - DisplayScheduler* scheduler_; + // An internal synthetic BFS. May be null when not used. + std::unique_ptr<BeginFrameSource> internal_begin_frame_source_; + // The real BFS tied to vsync provided by the BrowserCompositorOutputSurface. + BeginFrameSource* vsync_begin_frame_source_; + // The current BFS driving the Display/DisplayScheduler. + BeginFrameSource* observed_begin_frame_source_; + std::unique_ptr<DisplayScheduler> scheduler_; std::unique_ptr<ResourceProvider> resource_provider_; std::unique_ptr<SurfaceAggregator> aggregator_; std::unique_ptr<DirectRenderer> renderer_; std::unique_ptr<TextureMailboxDeleter> texture_mailbox_deleter_; std::vector<ui::LatencyInfo> stored_latency_info_; + private: DISALLOW_COPY_AND_ASSIGN(Display); };
diff --git a/cc/surfaces/display_client.h b/cc/surfaces/display_client.h index 1e3ccb2..bc455bb9 100644 --- a/cc/surfaces/display_client.h +++ b/cc/surfaces/display_client.h
@@ -11,12 +11,11 @@ namespace cc { +class BeginFrameSource; struct ManagedMemoryPolicy; class DisplayClient { public: - virtual void CommitVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval) = 0; virtual void OutputSurfaceLost() = 0; virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) = 0;
diff --git a/cc/surfaces/display_scheduler.cc b/cc/surfaces/display_scheduler.cc index 9f19fdcb..dd524b88 100644 --- a/cc/surfaces/display_scheduler.cc +++ b/cc/surfaces/display_scheduler.cc
@@ -33,10 +33,6 @@ weak_ptr_factory_(this) { begin_frame_deadline_closure_ = base::Bind( &DisplayScheduler::OnBeginFrameDeadline, weak_ptr_factory_.GetWeakPtr()); - - // TODO(tansell): Set this to something useful. - begin_frame_source_for_children_.reset(new SyntheticBeginFrameSource( - task_runner, BeginFrameArgs::DefaultInterval())); } DisplayScheduler::~DisplayScheduler() {
diff --git a/cc/surfaces/display_scheduler.h b/cc/surfaces/display_scheduler.h index cd4b5db..fd868b8d 100644 --- a/cc/surfaces/display_scheduler.h +++ b/cc/surfaces/display_scheduler.h
@@ -11,6 +11,7 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/single_thread_task_runner.h" +#include "cc/output/renderer_settings.h" #include "cc/scheduler/begin_frame_source.h" #include "cc/surfaces/surface_id.h" #include "cc/surfaces/surfaces_export.h" @@ -50,10 +51,6 @@ bool OnBeginFrameDerivedImpl(const BeginFrameArgs& args) override; void OnBeginFrameSourcePausedChanged(bool paused) override; - BeginFrameSource* begin_frame_source_for_children() { - return begin_frame_source_for_children_.get(); - } - protected: base::TimeTicks DesiredBeginFrameDeadlineTime(); virtual void ScheduleBeginFrameDeadline(); @@ -70,9 +67,6 @@ base::CancelableClosure begin_frame_deadline_task_; base::TimeTicks begin_frame_deadline_task_time_; - // TODO(tansell): Set this to something useful. - std::unique_ptr<BeginFrameSource> begin_frame_source_for_children_; - bool output_surface_lost_; bool root_surface_resources_locked_;
diff --git a/cc/surfaces/display_unittest.cc b/cc/surfaces/display_unittest.cc index 4a2de66..312c3a4 100644 --- a/cc/surfaces/display_unittest.cc +++ b/cc/surfaces/display_unittest.cc
@@ -57,8 +57,11 @@ public: DisplayTest() : factory_(&manager_, &surface_factory_client_), + id_allocator_(kArbitrarySurfaceNamespace), software_output_device_(nullptr), - task_runner_(new base::NullTaskRunner) {} + task_runner_(new base::NullTaskRunner) { + id_allocator_.RegisterSurfaceIdNamespace(&manager_); + } protected: void SetUpContext(std::unique_ptr<TestWebGraphicsContext3D> context) { @@ -87,13 +90,15 @@ SurfaceFactory::DrawCallback()); } + enum { kArbitrarySurfaceNamespace = 3 }; + SurfaceManager manager_; FakeSurfaceFactoryClient surface_factory_client_; SurfaceFactory factory_; + SurfaceIdAllocator id_allocator_; TestSoftwareOutputDevice* software_output_device_; std::unique_ptr<FakeOutputSurface> output_surface_; FakeOutputSurface* output_surface_ptr_; - FakeBeginFrameSource fake_begin_frame_source_; scoped_refptr<base::NullTaskRunner> task_runner_; std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; }; @@ -103,8 +108,6 @@ TestDisplayClient() {} ~TestDisplayClient() override {} - void CommitVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval) override {} void OutputSurfaceLost() override {} void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override {} }; @@ -113,14 +116,12 @@ public: TestDisplayScheduler(DisplaySchedulerClient* client, BeginFrameSource* begin_frame_source, - base::NullTaskRunner* task_runner) + base::SingleThreadTaskRunner* task_runner) : DisplayScheduler(client, begin_frame_source, task_runner, 1), damaged(false), display_resized_(false), has_new_root_surface(false), - swapped(false) { - begin_frame_source_for_children_.reset(new FakeBeginFrameSource); - } + swapped(false) {} ~TestDisplayScheduler() override {} @@ -147,6 +148,35 @@ bool display_resized_; bool has_new_root_surface; bool swapped; + + private: + RendererSettings settings_; +}; + +class TestDisplay : public Display { + public: + TestDisplay(DisplayClient* client, + SurfaceManager* manager, + SharedBitmapManager* bitmap_manager, + gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + const RendererSettings& settings, + uint32_t compositor_surface_namespace) + : Display(client, + manager, + bitmap_manager, + gpu_memory_buffer_manager, + settings, + compositor_surface_namespace) {} + + TestDisplayScheduler& scheduler() { + return *static_cast<TestDisplayScheduler*>(scheduler_.get()); + } + + protected: + void CreateScheduler(base::SingleThreadTaskRunner* task_runner) override { + scheduler_.reset( + new TestDisplayScheduler(this, vsync_begin_frame_source_, task_runner)); + } }; void CopyCallback(bool* called, std::unique_ptr<CopyOutputResult> result) { @@ -160,14 +190,12 @@ RendererSettings settings; settings.partial_swap_enabled = true; settings.finish_rendering_on_resize = true; - Display display(&client, &manager_, shared_bitmap_manager_.get(), nullptr, - settings); + TestDisplay display(&client, &manager_, shared_bitmap_manager_.get(), nullptr, + settings, id_allocator_.id_namespace()); + display.Initialize(std::move(output_surface_), task_runner_.get()); + TestDisplayScheduler& scheduler = display.scheduler(); - TestDisplayScheduler scheduler(&display, &fake_begin_frame_source_, - task_runner_.get()); - display.Initialize(std::move(output_surface_), &scheduler); - - SurfaceId surface_id(7u); + SurfaceId surface_id(id_allocator_.GenerateId()); EXPECT_FALSE(scheduler.damaged); EXPECT_FALSE(scheduler.has_new_root_surface); display.SetSurfaceId(surface_id, 1.f); @@ -422,18 +450,17 @@ SetUpContext(std::move(context)); EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); + + SurfaceId surface_id(id_allocator_.GenerateId()); + TestDisplayClient client; RendererSettings settings; settings.partial_swap_enabled = true; settings.finish_rendering_on_resize = true; - Display display(&client, &manager_, shared_bitmap_manager_.get(), nullptr, - settings); + TestDisplay display(&client, &manager_, shared_bitmap_manager_.get(), nullptr, + settings, surface_id.id_namespace()); + display.Initialize(std::move(output_surface_), task_runner_.get()); - TestDisplayScheduler scheduler(&display, &fake_begin_frame_source_, - task_runner_.get()); - display.Initialize(std::move(output_surface_), &scheduler); - - SurfaceId surface_id(7u); display.SetSurfaceId(surface_id, 1.f); display.Resize(gfx::Size(100, 100));
diff --git a/cc/surfaces/onscreen_display_client.cc b/cc/surfaces/onscreen_display_client.cc index 0f34a20..b408ed4 100644 --- a/cc/surfaces/onscreen_display_client.cc +++ b/cc/surfaces/onscreen_display_client.cc
@@ -20,51 +20,24 @@ SharedBitmapManager* bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, const RendererSettings& settings, - scoped_refptr<base::SingleThreadTaskRunner> task_runner) + scoped_refptr<base::SingleThreadTaskRunner> task_runner, + uint32_t compositor_surface_namespace) : output_surface_(std::move(output_surface)), task_runner_(task_runner), display_(new Display(this, manager, bitmap_manager, gpu_memory_buffer_manager, - settings)), - output_surface_lost_(false), - disable_display_vsync_(settings.disable_display_vsync) {} + settings, + compositor_surface_namespace)), + output_surface_lost_(false) {} OnscreenDisplayClient::~OnscreenDisplayClient() { } bool OnscreenDisplayClient::Initialize() { DCHECK(output_surface_); - - BeginFrameSource* frame_source; - if (disable_display_vsync_) { - unthrottled_frame_source_.reset( - new BackToBackBeginFrameSource(task_runner_.get())); - frame_source = unthrottled_frame_source_.get(); - } else { - synthetic_frame_source_.reset(new SyntheticBeginFrameSource( - task_runner_.get(), BeginFrameArgs::DefaultInterval())); - frame_source = synthetic_frame_source_.get(); - } - - scheduler_.reset( - new DisplayScheduler(display_.get(), frame_source, task_runner_.get(), - output_surface_->capabilities().max_frames_pending)); - - return display_->Initialize(std::move(output_surface_), scheduler_.get()); -} - -void OnscreenDisplayClient::CommitVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval) { - if (interval == base::TimeDelta()) { - // TODO(brianderson): We should not be receiving 0 intervals. - interval = BeginFrameArgs::DefaultInterval(); - } - - surface_display_output_surface_->ReceivedVSyncParameters(timebase, interval); - if (synthetic_frame_source_.get()) - synthetic_frame_source_->OnUpdateVSyncParameters(timebase, interval); + return display_->Initialize(std::move(output_surface_), task_runner_.get()); } void OnscreenDisplayClient::OutputSurfaceLost() {
diff --git a/cc/surfaces/onscreen_display_client.h b/cc/surfaces/onscreen_display_client.h index bf87523..91bb5c09 100644 --- a/cc/surfaces/onscreen_display_client.h +++ b/cc/surfaces/onscreen_display_client.h
@@ -19,7 +19,6 @@ } namespace cc { -class BeginFrameSource; class ContextProvider; class DisplayScheduler; class SurfaceManager; @@ -30,13 +29,13 @@ class CC_SURFACES_EXPORT OnscreenDisplayClient : NON_EXPORTED_BASE(DisplayClient) { public: - OnscreenDisplayClient( - std::unique_ptr<OutputSurface> output_surface, - SurfaceManager* manager, - SharedBitmapManager* bitmap_manager, - gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, - const RendererSettings& settings, - scoped_refptr<base::SingleThreadTaskRunner> task_runner); + OnscreenDisplayClient(std::unique_ptr<OutputSurface> output_surface, + SurfaceManager* manager, + SharedBitmapManager* bitmap_manager, + gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, + const RendererSettings& settings, + scoped_refptr<base::SingleThreadTaskRunner> task_runner, + uint32_t compositor_surface_namespace); ~OnscreenDisplayClient() override; bool Initialize(); @@ -46,8 +45,6 @@ } // DisplayClient implementation. - void CommitVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval) override; void OutputSurfaceLost() override; void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override; @@ -59,13 +56,9 @@ // Display depends on DisplayScheduler depends on *BeginFrameSource // depends on TaskRunner. scoped_refptr<base::SingleThreadTaskRunner> task_runner_; - std::unique_ptr<SyntheticBeginFrameSource> synthetic_frame_source_; - std::unique_ptr<BackToBackBeginFrameSource> unthrottled_frame_source_; - std::unique_ptr<DisplayScheduler> scheduler_; std::unique_ptr<Display> display_; SurfaceDisplayOutputSurface* surface_display_output_surface_; bool output_surface_lost_; - bool disable_display_vsync_; private: DISALLOW_COPY_AND_ASSIGN(OnscreenDisplayClient);
diff --git a/cc/surfaces/surface_display_output_surface.cc b/cc/surfaces/surface_display_output_surface.cc index 396f7bb..260e5cd 100644 --- a/cc/surfaces/surface_display_output_surface.cc +++ b/cc/surfaces/surface_display_output_surface.cc
@@ -21,7 +21,7 @@ scoped_refptr<ContextProvider> worker_context_provider) : OutputSurface(std::move(context_provider), std::move(worker_context_provider)), - display_client_(NULL), + display_client_(nullptr), factory_(surface_manager, this), allocator_(allocator) { factory_.set_needs_sync_points(false); @@ -41,12 +41,6 @@ } } -void SurfaceDisplayOutputSurface::ReceivedVSyncParameters( - base::TimeTicks timebase, - base::TimeDelta interval) { - CommitVSyncParameters(timebase, interval); -} - void SurfaceDisplayOutputSurface::SwapBuffers(CompositorFrame* frame) { gfx::Size frame_size = frame->delegated_frame_data->render_pass_list.back()->output_rect.size(); @@ -74,10 +68,10 @@ bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) { DCHECK(client); DCHECK(display_client_); + client_ = client; factory_.manager()->RegisterSurfaceFactoryClient(allocator_->id_namespace(), this); - client_ = client; // Avoid initializing GL context here, as this should be sharing the // Display's context. return display_client_->Initialize(); @@ -109,7 +103,8 @@ void SurfaceDisplayOutputSurface::SetBeginFrameSource( BeginFrameSource* begin_frame_source) { - // TODO(tansell): Hook this up. + DCHECK(client_); + client_->SetBeginFrameSource(begin_frame_source); } void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) {
diff --git a/cc/surfaces/surface_display_output_surface.h b/cc/surfaces/surface_display_output_surface.h index cececd3..098a3e18 100644 --- a/cc/surfaces/surface_display_output_surface.h +++ b/cc/surfaces/surface_display_output_surface.h
@@ -33,11 +33,10 @@ ~SurfaceDisplayOutputSurface() override; void set_display_client(OnscreenDisplayClient* display_client) { + DCHECK(!display_client_); display_client_ = display_client; } SurfaceFactory* factory() { return &factory_; } - void ReceivedVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval); // OutputSurface implementation. void SwapBuffers(CompositorFrame* frame) override;
diff --git a/cc/surfaces/surface_display_output_surface_unittest.cc b/cc/surfaces/surface_display_output_surface_unittest.cc index de06bd3..8315130 100644 --- a/cc/surfaces/surface_display_output_surface_unittest.cc +++ b/cc/surfaces/surface_display_output_surface_unittest.cc
@@ -25,13 +25,15 @@ SharedBitmapManager* bitmap_manager, gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, const RendererSettings& settings, - scoped_refptr<base::SingleThreadTaskRunner> task_runner) + scoped_refptr<base::SingleThreadTaskRunner> task_runner, + uint32_t compositor_surface_namespace) : OnscreenDisplayClient(FakeOutputSurface::Create3d(), manager, bitmap_manager, gpu_memory_buffer_manager, settings, - task_runner) { + task_runner, + compositor_surface_namespace) { // Ownership is passed to another object later, store a pointer // to it now for future reference. fake_output_surface_ = @@ -57,7 +59,8 @@ &bitmap_manager_, &gpu_memory_buffer_manager_, renderer_settings_, - task_runner_), + task_runner_, + allocator_.id_namespace()), context_provider_(TestContextProvider::Create()), surface_display_output_surface_(&surface_manager_, &allocator_, @@ -68,8 +71,16 @@ display_client_.set_surface_output_surface( &surface_display_output_surface_); surface_display_output_surface_.set_display_client(&display_client_); + + // Set the Display's begin frame source like a real browser compositor + // output surface would. + begin_frame_source_.reset( + new BackToBackBeginFrameSource(task_runner_.get())); + display_client_.display()->SetBeginFrameSource(begin_frame_source_.get()); + surface_display_output_surface_.BindToClient( &surface_display_output_surface_client_); + display_client_.display()->Resize(display_size_); EXPECT_FALSE(surface_display_output_surface_client_ @@ -104,6 +115,7 @@ protected: std::unique_ptr<base::SimpleTestTickClock> now_src_; scoped_refptr<OrderedSimpleTaskRunner> task_runner_; + scoped_ptr<BackToBackBeginFrameSource> begin_frame_source_; SurfaceIdAllocator allocator_; const gfx::Size display_size_;
diff --git a/cc/test/fake_layer_tree_host_impl_client.h b/cc/test/fake_layer_tree_host_impl_client.h index 9f0f433..f3e8e98 100644 --- a/cc/test/fake_layer_tree_host_impl_client.h +++ b/cc/test/fake_layer_tree_host_impl_client.h
@@ -18,6 +18,7 @@ void DidLoseOutputSurfaceOnImplThread() override {} void CommitVSyncParameters(base::TimeTicks timebase, base::TimeDelta interval) override {} + void SetBeginFrameSource(BeginFrameSource* source) override {} void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override {} void DidSwapBuffersOnImplThread() override {} void DidSwapBuffersCompleteOnImplThread() override {}
diff --git a/cc/test/fake_output_surface_client.h b/cc/test/fake_output_surface_client.h index c9a5efa..bb03715 100644 --- a/cc/test/fake_output_surface_client.h +++ b/cc/test/fake_output_surface_client.h
@@ -21,6 +21,7 @@ void CommitVSyncParameters(base::TimeTicks timebase, base::TimeDelta interval) override {} + void SetBeginFrameSource(BeginFrameSource* source) override {} void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override {} void DidSwapBuffers() override; void DidSwapBuffersComplete() override {}
diff --git a/cc/test/layer_tree_pixel_test.cc b/cc/test/layer_tree_pixel_test.cc index aaf0b5a..db48d97 100644 --- a/cc/test/layer_tree_pixel_test.cc +++ b/cc/test/layer_tree_pixel_test.cc
@@ -8,7 +8,6 @@ #include <stdint.h> #include "base/command_line.h" -#include "base/memory/ptr_util.h" #include "base/path_service.h" #include "cc/base/switches.h" #include "cc/layers/solid_color_layer.h" @@ -49,8 +48,8 @@ new PixelTestSoftwareOutputDevice); software_output_device->set_surface_expansion_size( surface_expansion_size); - output_surface = base::WrapUnique( - new PixelTestOutputSurface(std::move(software_output_device))); + output_surface = base::WrapUnique(new PixelTestOutputSurface( + std::move(software_output_device), nullptr)); break; } case PIXEL_TEST_GL: { @@ -59,8 +58,9 @@ new TestInProcessContextProvider(nullptr)); scoped_refptr<TestInProcessContextProvider> worker( new TestInProcessContextProvider(compositor.get())); - output_surface = base::WrapUnique(new PixelTestOutputSurface( - std::move(compositor), std::move(worker), flipped_output_surface)); + output_surface = base::WrapUnique( + new PixelTestOutputSurface(std::move(compositor), std::move(worker), + flipped_output_surface, nullptr)); break; } }
diff --git a/cc/test/pixel_test.cc b/cc/test/pixel_test.cc index 918eafbf..515faf6 100644 --- a/cc/test/pixel_test.cc +++ b/cc/test/pixel_test.cc
@@ -5,7 +5,6 @@ #include "cc/test/pixel_test.h" #include "base/command_line.h" -#include "base/memory/ptr_util.h" #include "base/path_service.h" #include "base/run_loop.h" #include "base/thread_task_runner_handle.h" @@ -19,6 +18,7 @@ #include "cc/output/texture_mailbox_deleter.h" #include "cc/raster/tile_task_worker_pool.h" #include "cc/resources/resource_provider.h" +#include "cc/scheduler/begin_frame_source.h" #include "cc/test/fake_output_surface_client.h" #include "cc/test/paths.h" #include "cc/test/pixel_test_output_surface.h" @@ -128,8 +128,9 @@ new TestInProcessContextProvider(nullptr)); scoped_refptr<TestInProcessContextProvider> worker( new TestInProcessContextProvider(compositor.get())); - output_surface_.reset(new PixelTestOutputSurface( - std::move(compositor), std::move(worker), flipped_output_surface)); + output_surface_.reset( + new PixelTestOutputSurface(std::move(compositor), std::move(worker), + flipped_output_surface, nullptr)); output_surface_->BindToClient(output_surface_client_.get()); shared_bitmap_manager_.reset(new TestSharedBitmapManager); @@ -174,7 +175,7 @@ void PixelTest::SetUpSoftwareRenderer() { std::unique_ptr<SoftwareOutputDevice> device( new PixelTestSoftwareOutputDevice()); - output_surface_.reset(new PixelTestOutputSurface(std::move(device))); + output_surface_.reset(new PixelTestOutputSurface(std::move(device), nullptr)); output_surface_->BindToClient(output_surface_client_.get()); shared_bitmap_manager_.reset(new TestSharedBitmapManager()); resource_provider_ = ResourceProvider::Create(
diff --git a/cc/test/pixel_test_output_surface.cc b/cc/test/pixel_test_output_surface.cc index 883f809..9250ee44 100644 --- a/cc/test/pixel_test_output_surface.cc +++ b/cc/test/pixel_test_output_surface.cc
@@ -5,6 +5,7 @@ #include "cc/test/pixel_test_output_surface.h" #include "cc/output/output_surface_client.h" +#include "cc/scheduler/begin_frame_source.h" #include "ui/gfx/transform.h" namespace cc { @@ -12,8 +13,10 @@ PixelTestOutputSurface::PixelTestOutputSurface( scoped_refptr<ContextProvider> context_provider, scoped_refptr<ContextProvider> worker_context_provider, - bool flipped_output_surface) + bool flipped_output_surface, + std::unique_ptr<BeginFrameSource> begin_frame_source) : OutputSurface(context_provider, worker_context_provider), + begin_frame_source_(std::move(begin_frame_source)), external_stencil_test_(false) { capabilities_.adjust_deadline_for_parent = false; capabilities_.flipped_output_surface = flipped_output_surface; @@ -21,17 +24,33 @@ PixelTestOutputSurface::PixelTestOutputSurface( scoped_refptr<ContextProvider> context_provider, - bool flipped_output_surface) + bool flipped_output_surface, + std::unique_ptr<BeginFrameSource> begin_frame_source) : PixelTestOutputSurface(context_provider, nullptr, - flipped_output_surface) { -} + flipped_output_surface, + std::move(begin_frame_source)) {} PixelTestOutputSurface::PixelTestOutputSurface( - std::unique_ptr<SoftwareOutputDevice> software_device) + std::unique_ptr<SoftwareOutputDevice> software_device, + std::unique_ptr<BeginFrameSource> begin_frame_source) : OutputSurface(std::move(software_device)), + begin_frame_source_(std::move(begin_frame_source)), external_stencil_test_(false) {} +PixelTestOutputSurface::~PixelTestOutputSurface() {} + +bool PixelTestOutputSurface::BindToClient(OutputSurfaceClient* client) { + if (!OutputSurface::BindToClient(client)) + return false; + + // TODO(enne): Once the renderer uses begin frame sources, this will + // always be valid. + if (begin_frame_source_) + client->SetBeginFrameSource(begin_frame_source_.get()); + return true; +} + void PixelTestOutputSurface::Reshape(const gfx::Size& size, float scale_factor, bool has_alpha) {
diff --git a/cc/test/pixel_test_output_surface.h b/cc/test/pixel_test_output_surface.h index e0ddcb5..6cd4191 100644 --- a/cc/test/pixel_test_output_surface.h +++ b/cc/test/pixel_test_output_surface.h
@@ -9,18 +9,25 @@ namespace cc { +class BeginFrameSource; + class PixelTestOutputSurface : public OutputSurface { public: explicit PixelTestOutputSurface( scoped_refptr<ContextProvider> context_provider, scoped_refptr<ContextProvider> worker_context_provider, - bool flipped_output_surface); + bool flipped_output_surface, + std::unique_ptr<BeginFrameSource> begin_frame_source); explicit PixelTestOutputSurface( scoped_refptr<ContextProvider> context_provider, - bool flipped_output_surface); + bool flipped_output_surface, + std::unique_ptr<BeginFrameSource> begin_frame_source); explicit PixelTestOutputSurface( - std::unique_ptr<SoftwareOutputDevice> software_device); + std::unique_ptr<SoftwareOutputDevice> software_device, + std::unique_ptr<BeginFrameSource> begin_frame_source); + ~PixelTestOutputSurface() override; + bool BindToClient(OutputSurfaceClient* client) override; void Reshape(const gfx::Size& size, float scale_factor, bool alpha) override; bool HasExternalStencilTest() const override; void SwapBuffers(CompositorFrame* frame) override; @@ -33,6 +40,7 @@ } private: + std::unique_ptr<BeginFrameSource> begin_frame_source_; gfx::Size surface_expansion_size_; bool external_stencil_test_; };
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index af18e6cd5..03004e1e 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc
@@ -2368,6 +2368,10 @@ client_->CommitVSyncParameters(timebase, interval); } +void LayerTreeHostImpl::SetBeginFrameSource(BeginFrameSource* source) { + client_->SetBeginFrameSource(source); +} + void LayerTreeHostImpl::SetViewportSize(const gfx::Size& device_viewport_size) { if (device_viewport_size == device_viewport_size_) return;
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index fc31bff..9feb348 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h
@@ -99,6 +99,7 @@ virtual void DidLoseOutputSurfaceOnImplThread() = 0; virtual void CommitVSyncParameters(base::TimeTicks timebase, base::TimeDelta interval) = 0; + virtual void SetBeginFrameSource(BeginFrameSource* source) = 0; virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) = 0; virtual void DidSwapBuffersOnImplThread() = 0; virtual void DidSwapBuffersCompleteOnImplThread() = 0; @@ -354,6 +355,7 @@ // OutputSurfaceClient implementation. void CommitVSyncParameters(base::TimeTicks timebase, base::TimeDelta interval) override; + void SetBeginFrameSource(BeginFrameSource* source) override; void SetNeedsRedrawRect(const gfx::Rect& rect) override; void SetExternalTilePriorityConstraints( const gfx::Rect& viewport_rect,
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 4a763091..3c2bb86d 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -124,6 +124,7 @@ void DidLoseOutputSurfaceOnImplThread() override {} void CommitVSyncParameters(base::TimeTicks timebase, base::TimeDelta interval) override {} + void SetBeginFrameSource(BeginFrameSource* source) override {} void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override {} void DidSwapBuffersOnImplThread() override {} void DidSwapBuffersCompleteOnImplThread() override {}
diff --git a/cc/trees/layer_tree_settings.cc b/cc/trees/layer_tree_settings.cc index 7d548b84..26a5462 100644 --- a/cc/trees/layer_tree_settings.cc +++ b/cc/trees/layer_tree_settings.cc
@@ -57,6 +57,7 @@ LayerTreeSettings::LayerTreeSettings() : single_thread_proxy_scheduler(true), use_external_begin_frame_source(false), + use_output_surface_begin_frame_source(false), main_frame_before_activation_enabled(false), using_synchronous_renderer_compositor(false), can_use_lcd_text(true),
diff --git a/cc/trees/layer_tree_settings.h b/cc/trees/layer_tree_settings.h index 285f6e6..0ed9ee9 100644 --- a/cc/trees/layer_tree_settings.h +++ b/cc/trees/layer_tree_settings.h
@@ -38,7 +38,10 @@ RendererSettings renderer_settings; bool single_thread_proxy_scheduler; + // TODO(enne): Remove this after everything uses output surface begin frames. bool use_external_begin_frame_source; + // TODO(enne): Temporary staging for unified begin frame source work. + bool use_output_surface_begin_frame_source; bool main_frame_before_activation_enabled; bool using_synchronous_renderer_compositor; bool can_use_lcd_text;
diff --git a/cc/trees/proxy_impl.cc b/cc/trees/proxy_impl.cc index 39be373..bca90cb 100644 --- a/cc/trees/proxy_impl.cc +++ b/cc/trees/proxy_impl.cc
@@ -303,6 +303,12 @@ synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); } +void ProxyImpl::SetBeginFrameSource(BeginFrameSource* source) { + // TODO(enne): this overrides any preexisting begin frame source. Those + // other sources will eventually be removed and this will be the only path. + scheduler_->SetBeginFrameSource(source); +} + void ProxyImpl::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { DCHECK(IsImplThread()); scheduler_->SetEstimatedParentDrawTime(draw_time);
diff --git a/cc/trees/proxy_impl.h b/cc/trees/proxy_impl.h index 5aa4655..ba4c8df03 100644 --- a/cc/trees/proxy_impl.h +++ b/cc/trees/proxy_impl.h
@@ -79,6 +79,7 @@ void DidLoseOutputSurfaceOnImplThread() override; void CommitVSyncParameters(base::TimeTicks timebase, base::TimeDelta interval) override; + void SetBeginFrameSource(BeginFrameSource* source) override; void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override; void DidSwapBuffersOnImplThread() override; void DidSwapBuffersCompleteOnImplThread() override;
diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc index 8194f38..3d991c0 100644 --- a/cc/trees/single_thread_proxy.cc +++ b/cc/trees/single_thread_proxy.cc
@@ -73,18 +73,21 @@ CompositorTimingHistory::BROWSER_UMA, layer_tree_host_->rendering_stats_instrumentation())); - BeginFrameSource* frame_source = external_begin_frame_source_.get(); - if (!scheduler_settings.throttle_frame_production) { - // Unthrottled source takes precedence over external sources. - unthrottled_begin_frame_source_.reset(new BackToBackBeginFrameSource( - task_runner_provider_->MainThreadTaskRunner())); - frame_source = unthrottled_begin_frame_source_.get(); - } - if (!frame_source) { - synthetic_begin_frame_source_.reset(new SyntheticBeginFrameSource( - task_runner_provider_->MainThreadTaskRunner(), - BeginFrameArgs::DefaultInterval())); - frame_source = synthetic_begin_frame_source_.get(); + BeginFrameSource* frame_source = nullptr; + if (!layer_tree_host_->settings().use_output_surface_begin_frame_source) { + frame_source = external_begin_frame_source_.get(); + if (!scheduler_settings.throttle_frame_production) { + // Unthrottled source takes precedence over external sources. + unthrottled_begin_frame_source_.reset(new BackToBackBeginFrameSource( + task_runner_provider_->MainThreadTaskRunner())); + frame_source = unthrottled_begin_frame_source_.get(); + } + if (!frame_source) { + synthetic_begin_frame_source_.reset(new SyntheticBeginFrameSource( + task_runner_provider_->MainThreadTaskRunner(), + BeginFrameArgs::DefaultInterval())); + frame_source = synthetic_begin_frame_source_.get(); + } } scheduler_on_impl_thread_ = @@ -491,6 +494,16 @@ synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); } +void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { + DCHECK(layer_tree_host_->settings().single_thread_proxy_scheduler); + // TODO(enne): this overrides any preexisting begin frame source. Those + // other sources will eventually be removed and this will be the only path. + if (!layer_tree_host_->settings().use_output_surface_begin_frame_source) + return; + if (scheduler_on_impl_thread_) + scheduler_on_impl_thread_->SetBeginFrameSource(source); +} + void SingleThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->SetEstimatedParentDrawTime(draw_time);
diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h index e3ee4f1..6f515299 100644 --- a/cc/trees/single_thread_proxy.h +++ b/cc/trees/single_thread_proxy.h
@@ -84,6 +84,7 @@ void DidLoseOutputSurfaceOnImplThread() override; void CommitVSyncParameters(base::TimeTicks timebase, base::TimeDelta interval) override; + void SetBeginFrameSource(BeginFrameSource* source) override; void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override; void DidSwapBuffersOnImplThread() override; void DidSwapBuffersCompleteOnImplThread() override;
diff --git a/chrome/VERSION b/chrome/VERSION index 76c15db..1c180f29 100644 --- a/chrome/VERSION +++ b/chrome/VERSION
@@ -1,4 +1,4 @@ MAJOR=52 MINOR=0 -BUILD=2708 +BUILD=2709 PATCH=0
diff --git a/chrome/android/java/res/drawable/ic_snippet_thumbnail_placeholder.xml b/chrome/android/java/res/drawable/ic_snippet_thumbnail_placeholder.xml new file mode 100644 index 0000000..52b085d --- /dev/null +++ b/chrome/android/java/res/drawable/ic_snippet_thumbnail_placeholder.xml
@@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- TODO(https://crbug.com/602627) tools:targetApi added to mute the NewApi lint error. --> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + tools:targetApi="21" + android:width="@dimen/snippets_thumbnail_size" + android:height="@dimen/snippets_thumbnail_size" + android:viewportWidth="72" + android:viewportHeight="72"> + + <path android:pathData="M0,0 L72,0 L72,71.9997 L0,71.9997 Z" /> + <path android:fillColor="@color/snippets_thumnail_placeholder_fg" + android:pathData="M45,42.9997 L45,28.9997 C45,27.8997,44.1,26.9997,43,26.9997 L29,26.9997 +C27.9,26.9997,27,27.8997,27,28.9997 L27,42.9997 +C27,44.0997,27.9,44.9997,29,44.9997 L43,44.9997 +C44.1,44.9997,45,44.0997,45,42.9997 Z M32.5,37.4997 L35,40.5097 L38.5,35.9997 +L43,41.9997 L29,41.9997 L32.5,37.4997 Z" /> +</vector>
diff --git a/chrome/android/java/res/layout/new_tab_page_snippets_card.xml b/chrome/android/java/res/layout/new_tab_page_snippets_card.xml index 8464c146..703bfec 100644 --- a/chrome/android/java/res/layout/new_tab_page_snippets_card.xml +++ b/chrome/android/java/res/layout/new_tab_page_snippets_card.xml
@@ -46,9 +46,10 @@ android:ellipsize="end" android:textSize="14sp" android:textColor="@color/snippets_publisher_name_color" /> - + <ImageView android:id="@+id/article_thumbnail" + android:background="@color/snippets_thumnail_placeholder_bg" android:layout_width="@dimen/snippets_thumbnail_size" android:layout_height="@dimen/snippets_thumbnail_size" android:layout_alignParentTop="true"
diff --git a/chrome/android/java/res/values/colors.xml b/chrome/android/java/res/values/colors.xml index 68db0f4..67bf25f0 100644 --- a/chrome/android/java/res/values/colors.xml +++ b/chrome/android/java/res/values/colors.xml
@@ -96,6 +96,8 @@ <color name="ntp_list_header_subtext">#969696</color> <color name="ntp_list_header_subtext_active">#7cadff</color> <color name="ntp_with_cards_bg">#f2f2f2</color> + <color name="snippets_thumnail_placeholder_bg">#f2f2f2</color> + <color name="snippets_thumnail_placeholder_fg">#757575</color> <color name="snippets_background_color">#fff</color> <color name="snippets_publisher_name_color">#646464</color> <color name="snippets_text_color">#646464</color>
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticle.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticle.java index 7d99986f..f4c81f8 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticle.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticle.java
@@ -3,27 +3,14 @@ // found in the LICENSE file. package org.chromium.chrome.browser.ntp.snippets; -import android.graphics.drawable.Drawable; -import android.os.AsyncTask; -import android.view.View; -import android.widget.ImageView; +import android.graphics.Bitmap; -import org.chromium.base.Log; -import org.chromium.base.StreamUtil; import org.chromium.chrome.browser.ntp.cards.NewTabPageListItem; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; - /** * Represents the data for an article card on the NTP. */ public class SnippetArticle implements NewTabPageListItem { - private static final String TAG = "SnippetArticle"; - - private static final int FADE_IN_ANIMATION_TIME_MS = 300; public final String mTitle; public final String mPublisher; @@ -33,54 +20,8 @@ public final long mTimestamp; public final int mPosition; - private ThumbnailRenderingTask mThumbnailRenderingTask; - - // Async task to create the thumbnail from a URL - // TODO(maybelle): This task to retrieve the thumbnail from the web is temporary while - // we are prototyping this feature for clank. For the real production feature, we - // will likely have to download/decode the thumbnail on the native side. - private static class ThumbnailRenderingTask extends AsyncTask<String, Void, Drawable> { - private ImageView mThumbnailView; - - ThumbnailRenderingTask(ImageView thumbnailView) { - mThumbnailView = thumbnailView; - - // The view might be already holding the thumbnail from another snippet, as the view - // is recycled. We start by hiding it to avoid having a stale image be displayed while - // the new one is being downloaded. - mThumbnailView.setVisibility(View.INVISIBLE); - } - - @Override - protected Drawable doInBackground(String... params) { - if (params[0].isEmpty()) return null; - InputStream is = null; - try { - is = (InputStream) new URL(params[0]).getContent(); - return Drawable.createFromStream(is, "thumbnail"); - } catch (MalformedURLException e) { - Log.e(TAG, "Could not get image thumbnail due to malformed URL", e); - } catch (IOException e) { - Log.e(TAG, "Could not get image thumbnail", e); - } finally { - StreamUtil.closeQuietly(is); - } - return null; - } - - @Override - protected void onPostExecute(Drawable thumbnail) { - if (thumbnail == null) { - mThumbnailView.setVisibility(View.GONE); - } else { - // Fade in the image thumbnail - mThumbnailView.setImageDrawable(thumbnail); - mThumbnailView.setVisibility(View.VISIBLE); - mThumbnailView.setAlpha(0f); - mThumbnailView.animate().alpha(1f).setDuration(FADE_IN_ANIMATION_TIME_MS); - } - } - } + /** Bitmap of the thumbnail, fetched lazily, when the RecyclerView wants to show the snippet. */ + private Bitmap mThumbnailBitmap; /** * Creates a SnippetArticle object that will hold the data @@ -109,15 +50,15 @@ } /** - * Retrieves this SnippetArticle's thumbnail asynchronously and sets it onto the given - * ImageView. - * - * @param view The ImageView to set the thumbnail onto. + * Returns this article's tumbnail as a {@link Bitmap}. Can return {@code null} as it is + * initially unset. */ - public void setThumbnailOnView(ImageView view) { - if (mThumbnailRenderingTask != null) mThumbnailRenderingTask.cancel(true); + Bitmap getThumbnailBitmap() { + return mThumbnailBitmap; + } - mThumbnailRenderingTask = new ThumbnailRenderingTask(view); - mThumbnailRenderingTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, mThumbnailUrl); + /** Sets the tumbnail bitmap for this article. */ + void setThumbnailBitmap(Bitmap bitmap) { + mThumbnailBitmap = bitmap; } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java index d76bd1c5..9a5f179 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
@@ -4,6 +4,14 @@ package org.chromium.chrome.browser.ntp.snippets; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.TransitionDrawable; +import android.media.ThumbnailUtils; +import android.os.AsyncTask; import android.text.format.DateUtils; import android.view.LayoutInflater; import android.view.View; @@ -11,6 +19,8 @@ import android.widget.ImageView; import android.widget.TextView; +import org.chromium.base.Log; +import org.chromium.base.StreamUtil; import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordUserAction; import org.chromium.chrome.R; @@ -19,15 +29,24 @@ import org.chromium.chrome.browser.ntp.cards.NewTabPageListItem; import org.chromium.chrome.browser.ntp.cards.NewTabPageViewHolder; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + /** * A class that represents the view for a single card snippet. */ public class SnippetArticleViewHolder extends NewTabPageViewHolder implements View.OnClickListener { + private static final String TAG = "NtpSnippets"; + private static final int FADE_IN_ANIMATION_TIME_MS = 300; + private final NewTabPageManager mNewTabPageManager; - public TextView mHeadlineTextView; - public TextView mPublisherTextView; - public TextView mArticleSnippetTextView; - public ImageView mThumbnailView; + private final TextView mHeadlineTextView; + private final TextView mPublisherTextView; + private final TextView mArticleSnippetTextView; + private final ImageView mThumbnailView; + + private AsyncTask<String, Void, Bitmap> mThumbnailFetchingTask; public String mUrl; public int mPosition; @@ -90,7 +109,72 @@ mUrl = item.mUrl; mPosition = item.mPosition; - item.setThumbnailOnView(mThumbnailView); + updateThumbnail(item); + } + + private void updateThumbnail(final SnippetArticle snippet) { + // If this view has a pending fetching task, it will display the stale thumbnail when it + // finishes, so we need to cancel that task. + if (mThumbnailFetchingTask != null) mThumbnailFetchingTask.cancel(true); + + if (snippet.getThumbnailBitmap() != null) { + mThumbnailView.setImageBitmap(snippet.getThumbnailBitmap()); + return; + } + + mThumbnailView.setImageResource(R.drawable.ic_snippet_thumbnail_placeholder); + + if (snippet.mThumbnailUrl.isEmpty()) { + Log.e(TAG, "Could not get image thumbnail due to empty URL"); + return; + } + + mThumbnailFetchingTask = new AsyncTask<String, Void, Bitmap>() { + + @Override + protected Bitmap doInBackground(String... params) { + InputStream is = null; + try { + is = new URL(params[0]).openStream(); + return BitmapFactory.decodeStream(is); + } catch (IOException e) { + Log.e(TAG, "Could not get image thumbnail", e); + } finally { + StreamUtil.closeQuietly(is); + } + + return null; + } + + @Override + protected void onPostExecute(Bitmap result) { + if (result == null) return; // Nothing to do, we keep the placeholder. + fadeThumbnailIn(snippet, result); + } + }; + + mThumbnailFetchingTask.executeOnExecutor( + AsyncTask.THREAD_POOL_EXECUTOR, snippet.mThumbnailUrl); + } + + private void fadeThumbnailIn(SnippetArticle snippet, Bitmap thumbnail) { + // We need to crop and scale the downloaded bitmap, as the ImageView we set it on won't be + // able to do so when using a TransitionDrawable (as opposed to the straight bitmap). + // That's a limitation of TransitionDrawable, which doesn't handle layers of varying sizes. + Resources res = mThumbnailView.getResources(); + int targetSize = res.getDimensionPixelSize(R.dimen.snippets_thumbnail_size); + Bitmap scaledThumbnail = ThumbnailUtils.extractThumbnail( + thumbnail, targetSize, targetSize, ThumbnailUtils.OPTIONS_RECYCLE_INPUT); + + // Store the bitmap to skip the download task next time we display this snippet. + snippet.setThumbnailBitmap(scaledThumbnail); + + // Cross-fade between the placeholder and the thumbnail. + Drawable[] layers = {mThumbnailView.getDrawable(), + new BitmapDrawable(mThumbnailView.getResources(), scaledThumbnail)}; + TransitionDrawable transitionDrawable = new TransitionDrawable(layers); + mThumbnailView.setImageDrawable(transitionDrawable); + transitionDrawable.startTransition(FADE_IN_ANIMATION_TIME_MS); } @Override
diff --git a/chrome/app/chromeos_strings.grdp b/chrome/app/chromeos_strings.grdp index ddf6680e..35d4fa1 100644 --- a/chrome/app/chromeos_strings.grdp +++ b/chrome/app/chromeos_strings.grdp
@@ -719,6 +719,12 @@ Save file as </message> + <message name="IDS_FILE_BROWSER_ONE_FILE_SELECTED" desc="One file selected."> + 1 file selected + </message> + <message name="IDS_FILE_BROWSER_ONE_DIRECTORY_SELECTED" desc="One directory selected."> + 1 directory selected + </message> <message name="IDS_FILE_BROWSER_MANY_FILES_SELECTED" desc="Many files selected."> <ph name="SELCTED_FILE_COUNT">$1<ex>13</ex></ph> files selected </message>
diff --git a/chrome/app/mash/mash_runner.cc b/chrome/app/mash/mash_runner.cc index 554fb757..f940c8a 100644 --- a/chrome/app/mash/mash_runner.cc +++ b/chrome/app/mash/mash_runner.cc
@@ -37,7 +37,7 @@ #include "components/font_service/font_service_app.h" #endif -using mojo::shell::mojom::ShellClientFactory; +using shell::mojom::ShellClientFactory; namespace { @@ -45,27 +45,27 @@ const char* kMashChild = "mash-child"; // ShellClient responsible for starting the appropriate app. -class DefaultShellClient : public mojo::ShellClient, +class DefaultShellClient : public shell::ShellClient, public ShellClientFactory, - public mojo::InterfaceFactory<ShellClientFactory> { + public shell::InterfaceFactory<ShellClientFactory> { public: DefaultShellClient() {} ~DefaultShellClient() override {} - // mojo::ShellClient: - bool AcceptConnection(mojo::Connection* connection) override { + // shell::ShellClient: + bool AcceptConnection(shell::Connection* connection) override { connection->AddInterface<ShellClientFactory>(this); return true; } - // mojo::InterfaceFactory<ShellClientFactory> - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<ShellClientFactory> + void Create(shell::Connection* connection, mojo::InterfaceRequest<ShellClientFactory> request) override { shell_client_factory_bindings_.AddBinding(this, std::move(request)); } // ShellClientFactory: - void CreateShellClient(mojo::shell::mojom::ShellClientRequest request, + void CreateShellClient(shell::mojom::ShellClientRequest request, const mojo::String& mojo_name) override { if (shell_client_) { LOG(ERROR) << "request to create additional app " << mojo_name; @@ -74,7 +74,7 @@ shell_client_ = CreateShellClient(mojo_name); if (shell_client_) { shell_connection_.reset( - new mojo::ShellConnection(shell_client_.get(), std::move(request))); + new shell::ShellConnection(shell_client_.get(), std::move(request))); return; } LOG(ERROR) << "unknown name " << mojo_name; @@ -83,7 +83,7 @@ private: // TODO(sky): move this into mash. - scoped_ptr<mojo::ShellClient> CreateShellClient(const std::string& name) { + scoped_ptr<shell::ShellClient> CreateShellClient(const std::string& name) { if (name == "mojo:ash_sysui") return base::WrapUnique(new ash::sysui::SysUIApplication); if (name == "mojo:desktop_wm") @@ -112,8 +112,8 @@ } mojo::BindingSet<ShellClientFactory> shell_client_factory_bindings_; - scoped_ptr<mojo::ShellClient> shell_client_; - scoped_ptr<mojo::ShellConnection> shell_connection_; + scoped_ptr<shell::ShellClient> shell_client_; + scoped_ptr<shell::ShellConnection> shell_connection_; DISALLOW_COPY_AND_ASSIGN(DefaultShellClient); }; @@ -137,15 +137,15 @@ command_line->SetProgram(exe_path); } -class NativeRunnerDelegateImpl : public mojo::shell::NativeRunnerDelegate { +class NativeRunnerDelegateImpl : public shell::NativeRunnerDelegate { public: NativeRunnerDelegateImpl() {} ~NativeRunnerDelegateImpl() override {} private: - // mojo::shell::NativeRunnerDelegate: + // shell::NativeRunnerDelegate: void AdjustCommandLineArgumentsForTarget( - const mojo::Identity& target, + const shell::Identity& target, base::CommandLine* command_line) override { command_line->AppendSwitch(switches::kWaitForMojoShell); if (target.name() != "exe:chrome") { @@ -187,13 +187,13 @@ // shouldn't we using context as it has a lot of stuff we don't really want // in chrome. NativeRunnerDelegateImpl native_runner_delegate; - mojo::shell::BackgroundShell background_shell; - scoped_ptr<mojo::shell::BackgroundShell::InitParams> init_params( - new mojo::shell::BackgroundShell::InitParams); + shell::BackgroundShell background_shell; + scoped_ptr<shell::BackgroundShell::InitParams> init_params( + new shell::BackgroundShell::InitParams); init_params->native_runner_delegate = &native_runner_delegate; background_shell.Init(std::move(init_params)); shell_client_.reset(new DefaultShellClient); - shell_connection_.reset(new mojo::ShellConnection( + shell_connection_.reset(new shell::ShellConnection( shell_client_.get(), background_shell.CreateShellClientRequest("exe:chrome_mash"))); shell_connection_->connector()->Connect("mojo:mash_session"); @@ -202,17 +202,17 @@ void MashRunner::RunChild() { base::i18n::InitializeICU(); - mojo::shell::ChildProcessMain( + shell::ChildProcessMain( base::Bind(&MashRunner::StartChildApp, base::Unretained(this))); } void MashRunner::StartChildApp( - mojo::shell::mojom::ShellClientRequest client_request) { + shell::mojom::ShellClientRequest client_request) { // TODO(sky): use MessagePumpMojo. base::MessageLoop message_loop(base::MessageLoop::TYPE_UI); shell_client_.reset(new DefaultShellClient); - shell_connection_.reset(new mojo::ShellConnection(shell_client_.get(), - std::move(client_request))); + shell_connection_.reset(new shell::ShellConnection( + shell_client_.get(), std::move(client_request))); message_loop.Run(); }
diff --git a/chrome/app/mash/mash_runner.h b/chrome/app/mash/mash_runner.h index b62cde4..db20df79 100644 --- a/chrome/app/mash/mash_runner.h +++ b/chrome/app/mash/mash_runner.h
@@ -9,7 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "services/shell/public/interfaces/shell_client.mojom.h" -namespace mojo { +namespace shell { class ShellClient; class ShellConnection; } @@ -26,10 +26,10 @@ void RunMain(); void RunChild(); - void StartChildApp(mojo::shell::mojom::ShellClientRequest client_request); + void StartChildApp(shell::mojom::ShellClientRequest client_request); - scoped_ptr<mojo::ShellClient> shell_client_; - scoped_ptr<mojo::ShellConnection> shell_connection_; + scoped_ptr<shell::ShellClient> shell_client_; + scoped_ptr<shell::ShellConnection> shell_connection_; DISALLOW_COPY_AND_ASSIGN(MashRunner); };
diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp index ed1c5c10..4203604 100644 --- a/chrome/app/settings_strings.grdp +++ b/chrome/app/settings_strings.grdp
@@ -573,12 +573,18 @@ <message name="IDS_SETTINGS_ON_STARTUP_ADD_NEW_PAGE" desc="Entry prompt to add a new page."> Add a new page </message> + <message name="IDS_SETTINGS_ON_STARTUP_EDIT_PAGE" desc="Title of the dialog that allows the user to edit an existing startup page."> + Edit page + </message> <message name="IDS_SETTINGS_ON_STARTUP_SITE_URL" desc="Prompt to add a new page."> Site URL </message> <message name="IDS_SETTINGS_ON_STARTUP_REMOVE" desc="Text displayed on a menu button allowing the user to remove a URL from the list of startup URLs."> Remove </message> + <message name="IDS_SETTINGS_ON_STARTUP_EDIT" desc="Text displayed on a menu button allowing the user to edit a URL from the list of startup URLs."> + Edit + </message> <!-- Languages Page --> <message name="IDS_SETTINGS_LANGUAGES_PAGE_TITLE" desc="Name of the settings page which displays language preferences.">
diff --git a/chrome/browser/chromeos/chrome_interface_factory.cc b/chrome/browser/chromeos/chrome_interface_factory.cc index 6306bdd..7e0a30a2 100644 --- a/chrome/browser/chromeos/chrome_interface_factory.cc +++ b/chrome/browser/chromeos/chrome_interface_factory.cc
@@ -12,13 +12,13 @@ ChromeInterfaceFactory::ChromeInterfaceFactory() {} ChromeInterfaceFactory::~ChromeInterfaceFactory() {} -bool ChromeInterfaceFactory::AcceptConnection(mojo::Connection* connection) { +bool ChromeInterfaceFactory::AcceptConnection(shell::Connection* connection) { connection->AddInterface(this); return true; } void ChromeInterfaceFactory::Create( - mojo::Connection* connection, + shell::Connection* connection, mojo::InterfaceRequest<keyboard::mojom::Keyboard> request) { if (!keyboard_ui_service_) keyboard_ui_service_.reset(new KeyboardUIService);
diff --git a/chrome/browser/chromeos/chrome_interface_factory.h b/chrome/browser/chromeos/chrome_interface_factory.h index 8f57d3a8..74feaec 100644 --- a/chrome/browser/chromeos/chrome_interface_factory.h +++ b/chrome/browser/chromeos/chrome_interface_factory.h
@@ -17,18 +17,18 @@ // InterfaceFactory for creating all services provided by chrome. class ChromeInterfaceFactory : public content::MojoShellConnection::Listener, - public mojo::InterfaceFactory<keyboard::mojom::Keyboard> { + public shell::InterfaceFactory<keyboard::mojom::Keyboard> { public: ChromeInterfaceFactory(); ~ChromeInterfaceFactory() override; private: // content::MojoShellConnection::Listener: - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; - // mojo::InterfaceFactory<keyboard::Keyboard>: + // shell::InterfaceFactory<keyboard::Keyboard>: void Create( - mojo::Connection* connection, + shell::Connection* connection, mojo::InterfaceRequest<keyboard::mojom::Keyboard> request) override; std::unique_ptr<KeyboardUIService> keyboard_ui_service_;
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_strings.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_strings.cc index ef40741..7217131 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_strings.cc +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_strings.cc
@@ -510,6 +510,8 @@ SET_STRING("OFFLINE_MESSAGE", IDS_FILE_BROWSER_OFFLINE_MESSAGE); SET_STRING("OFFLINE_MESSAGE_PLURAL", IDS_FILE_BROWSER_OFFLINE_MESSAGE_PLURAL); SET_STRING("OK_LABEL", IDS_FILE_BROWSER_OK_LABEL); + SET_STRING("ONE_DIRECTORY_SELECTED", IDS_FILE_BROWSER_ONE_DIRECTORY_SELECTED); + SET_STRING("ONE_FILE_SELECTED", IDS_FILE_BROWSER_ONE_FILE_SELECTED); SET_STRING("OPEN_IN_OTHER_DESKTOP_MESSAGE", IDS_FILE_BROWSER_OPEN_IN_OTHER_DESKTOP_MESSAGE); SET_STRING("OPEN_IN_OTHER_DESKTOP_MESSAGE_PLURAL",
diff --git a/chrome/browser/chromeos/extensions/wallpaper_api.cc b/chrome/browser/chromeos/extensions/wallpaper_api.cc index c08a9be2..8cb46e56 100644 --- a/chrome/browser/chromeos/extensions/wallpaper_api.cc +++ b/chrome/browser/chromeos/extensions/wallpaper_api.cc
@@ -17,6 +17,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h" #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" +#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/extensions/extension_constants.h" @@ -93,6 +94,18 @@ base::LazyInstance<WallpaperFetcher> g_wallpaper_fetcher = LAZY_INSTANCE_INITIALIZER; +// Gets the |User| for a given |BrowserContext|. The function will only return +// valid objects. +const user_manager::User* GetUserFromBrowserContext( + content::BrowserContext* context) { + Profile* profile = Profile::FromBrowserContext(context); + DCHECK(profile); + const user_manager::User* user = + chromeos::ProfileHelper::Get()->GetUserByProfile(profile); + DCHECK(user); + return user; +} + } // namespace WallpaperSetWallpaperFunction::WallpaperSetWallpaperFunction() { @@ -106,13 +119,12 @@ params_ = set_wallpaper::Params::Create(*args_); EXTENSION_FUNCTION_VALIDATE(params_); - // Gets account id and user wallpaper files id while at UI thread. - const user_manager::User* user = - user_manager::UserManager::Get()->GetLoggedInUser(); + // Gets account id from the caller, ensuring multiprofile compatibility. + const user_manager::User* user = GetUserFromBrowserContext(browser_context()); account_id_ = user->GetAccountId(); chromeos::WallpaperManager* wallpaper_manager = chromeos::WallpaperManager::Get(); - wallpaper_files_id_ = wallpaper_manager->GetFilesId(*user); + wallpaper_files_id_ = wallpaper_manager->GetFilesId(account_id_); if (params_->details.data) { StartDecode(*params_->details.data);
diff --git a/chrome/browser/chromeos/extensions/wallpaper_apitest.cc b/chrome/browser/chromeos/extensions/wallpaper_apitest.cc index 66e69e5..10a6f33 100644 --- a/chrome/browser/chromeos/extensions/wallpaper_apitest.cc +++ b/chrome/browser/chromeos/extensions/wallpaper_apitest.cc
@@ -3,9 +3,12 @@ // found in the LICENSE file. #include "chrome/browser/extensions/extension_apitest.h" +#include "chromeos/cryptohome/system_salt_getter.h" #include "net/dns/mock_host_resolver.h" IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Wallpaper) { + chromeos::SystemSaltGetter::Get()->SetRawSaltForTesting( + chromeos::SystemSaltGetter::RawSalt({1, 2, 3, 4, 5, 6, 7, 8})); host_resolver()->AddRule("a.com", "127.0.0.1"); ASSERT_TRUE(StartEmbeddedTestServer()); ASSERT_TRUE(RunExtensionTest("wallpaper")) << message_;
diff --git a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc index 4bcf858b..67591fd 100644 --- a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc +++ b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
@@ -621,7 +621,7 @@ account_id_ = user->GetAccountId(); chromeos::WallpaperManager* wallpaper_manager = chromeos::WallpaperManager::Get(); - wallpaper_files_id_ = wallpaper_manager->GetFilesId(*user); + wallpaper_files_id_ = wallpaper_manager->GetFilesId(account_id_); StartDecode(params->wallpaper);
diff --git a/chrome/browser/chromeos/extensions/wallpaper_private_apitest.cc b/chrome/browser/chromeos/extensions/wallpaper_private_apitest.cc index 7b73d103..0ea850f 100644 --- a/chrome/browser/chromeos/extensions/wallpaper_private_apitest.cc +++ b/chrome/browser/chromeos/extensions/wallpaper_private_apitest.cc
@@ -3,9 +3,12 @@ // found in the LICENSE file. #include "chrome/browser/extensions/extension_apitest.h" +#include "chromeos/cryptohome/system_salt_getter.h" #include "net/dns/mock_host_resolver.h" IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WallpaperPrivateApiTest) { + chromeos::SystemSaltGetter::Get()->SetRawSaltForTesting( + chromeos::SystemSaltGetter::RawSalt({1, 2, 3, 4, 5, 6, 7, 8})); host_resolver()->AddRule("a.com", "127.0.0.1"); ASSERT_TRUE(StartEmbeddedTestServer()); ASSERT_TRUE(RunComponentExtensionTest("wallpaper_manager")) << message_;
diff --git a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc index 03cfad1..eac4ab8 100644 --- a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc +++ b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc
@@ -21,6 +21,7 @@ #include "base/macros.h" #include "base/metrics/histogram.h" #include "base/path_service.h" +#include "base/sha1.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -39,8 +40,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chromeos/chromeos_switches.h" -#include "chromeos/cryptohome/async_method_caller.h" -#include "chromeos/cryptohome/cryptohome_parameters.h" +#include "chromeos/cryptohome/system_salt_getter.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/login/user_names.h" #include "components/prefs/pref_registry_simple.h" @@ -129,22 +129,40 @@ return index; } -cryptohome::Identification GetUnhashedSourceForWallpaperFilesId( - const user_manager::User& user) { - const AccountId& account_id = user.GetAccountId(); - const std::string& old_id = account_id.GetUserEmail(); // Migrated - return cryptohome::Identification::FromString(old_id); -} +// This has once been copied from +// brillo::cryptohome::home::SanitizeUserName(username) to be used for +// wallpaper identification purpose only. +// +// Historic note: We need some way to identify users wallpaper files in +// the device filesystem. Historically User::username_hash() was used for this +// purpose, but it has two caveats: +// 1. username_hash() is defined only after user has logged in. +// 2. If cryptohome identifier changes, username_hash() will also change, +// and we may loose user => wallpaper files mapping at that point. +// So this function gives WallpaperManager independent hashing method to break +// this dependency. +// +wallpaper::WallpaperFilesId HashWallpaperFilesIdStr( + const std::string& files_id_unhashed) { + SystemSaltGetter* salt_getter = SystemSaltGetter::Get(); + DCHECK(salt_getter); -wallpaper::WallpaperFilesId GetKnownUserWallpaperFilesId( - const user_manager::User& user) { - const AccountId& account_id = user.GetAccountId(); - std::string stored_value; - if (user_manager::known_user::GetStringPref(account_id, kWallpaperFilesId, - &stored_value)) { - return wallpaper::WallpaperFilesId::FromString(stored_value); - } - return wallpaper::WallpaperFilesId::FromString(user.username_hash()); + // System salt must be defined at this point. + const SystemSaltGetter::RawSalt* salt = salt_getter->GetRawSalt(); + if (!salt) + LOG(FATAL) << "WallpaperManager HashWallpaperFilesIdStr(): no salt!"; + + unsigned char binmd[base::kSHA1Length]; + std::string lowercase(files_id_unhashed); + std::transform(lowercase.begin(), lowercase.end(), lowercase.begin(), + ::tolower); + std::vector<uint8_t> data = *salt; + std::copy(files_id_unhashed.begin(), files_id_unhashed.end(), + std::back_inserter(data)); + base::SHA1HashBytes(data.data(), data.size(), binmd); + std::string result = base::HexEncode(binmd, sizeof(binmd)); + std::transform(result.begin(), result.end(), result.begin(), ::tolower); + return wallpaper::WallpaperFilesId::FromString(result); } void SetKnownUserWallpaperFilesId( @@ -828,43 +846,15 @@ void WallpaperManager::SetPolicyControlledWallpaper( const AccountId& account_id, std::unique_ptr<user_manager::UserImage> user_image) { - const user_manager::User* user = - user_manager::UserManager::Get()->FindUser(account_id); - if (!user) { - NOTREACHED() << "Unknown user."; - return; - } + const wallpaper::WallpaperFilesId wallpaper_files_id = GetFilesId(account_id); - const wallpaper::WallpaperFilesId wallpaper_files_id = - GetKnownUserWallpaperFilesId(*user); - if (!wallpaper_files_id.is_valid()) { - cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( - GetUnhashedSourceForWallpaperFilesId(*user), - base::Bind(&WallpaperManager::SetCustomWallpaperOnSanitizedUsername, - weak_factory_.GetWeakPtr(), account_id, user_image->image(), - true /* update wallpaper */)); - } else { - SetCustomWallpaper(account_id, wallpaper_files_id, "policy-controlled.jpeg", - wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED, - user_manager::User::POLICY, user_image->image(), - true /* update wallpaper */); - } -} + if (!wallpaper_files_id.is_valid()) + LOG(FATAL) << "Wallpaper flies id if invalid!"; -void WallpaperManager::SetCustomWallpaperOnSanitizedUsername( - const AccountId& account_id, - const gfx::ImageSkia& image, - bool update_wallpaper, - bool cryptohome_success, - const std::string& wallpaper_files_id_str) { - if (!cryptohome_success) - return; - const wallpaper::WallpaperFilesId wallpaper_files_id = - wallpaper::WallpaperFilesId::FromString(wallpaper_files_id_str); - SetKnownUserWallpaperFilesId(account_id, wallpaper_files_id); SetCustomWallpaper(account_id, wallpaper_files_id, "policy-controlled.jpeg", wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED, - user_manager::User::POLICY, image, update_wallpaper); + user_manager::User::POLICY, user_image->image(), + true /* update wallpaper */); } void WallpaperManager::InitializeRegisteredDeviceWallpaper() { @@ -1139,8 +1129,16 @@ } wallpaper::WallpaperFilesId WallpaperManager::GetFilesId( - const user_manager::User& user) const { - return GetKnownUserWallpaperFilesId(user); + const AccountId& account_id) const { + std::string stored_value; + if (user_manager::known_user::GetStringPref(account_id, kWallpaperFilesId, + &stored_value)) { + return wallpaper::WallpaperFilesId::FromString(stored_value); + } + const std::string& old_id = account_id.GetUserEmail(); // Migrated + const wallpaper::WallpaperFilesId files_id = HashWallpaperFilesIdStr(old_id); + SetKnownUserWallpaperFilesId(account_id, files_id); + return files_id; } } // namespace chromeos
diff --git a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h index b277c10b..8a93346b 100644 --- a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h +++ b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h
@@ -128,9 +128,9 @@ // Returns queue size. size_t GetPendingListSizeForTesting() const override; - // Returns wallpaper files id for the user. + // Returns wallpaper files id for the |account_id|. wallpaper::WallpaperFilesId GetFilesId( - const user_manager::User& user) const override; + const AccountId& account_id) const override; // Overridden from user_manager::UserManager::UserSessionStateObserver: void UserChangedChildStatus(user_manager::User* user) override; @@ -157,15 +157,6 @@ const AccountId& account_id, std::unique_ptr<user_manager::UserImage> user_image); - // Calls SetCustomWallpaper() with |wallpaper_files_id_str| received from - // cryptohome. - void SetCustomWallpaperOnSanitizedUsername( - const AccountId& account_id, - const gfx::ImageSkia& image, - bool update_wallpaper, - bool cryptohome_success, - const std::string& wallpaper_files_id_str); - // WallpaperManagerBase overrides: void InitializeRegisteredDeviceWallpaper() override; bool GetUserWallpaperInfo(const AccountId& account_id,
diff --git a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_policy_browsertest.cc b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_policy_browsertest.cc index 781484b8..d431f64 100644 --- a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_policy_browsertest.cc +++ b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_policy_browsertest.cc
@@ -32,6 +32,7 @@ #include "chrome/common/chrome_paths.h" #include "chromeos/chromeos_paths.h" #include "chromeos/chromeos_switches.h" +#include "chromeos/cryptohome/system_salt_getter.h" #include "chromeos/dbus/cryptohome_client.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_session_manager_client.h" @@ -127,6 +128,12 @@ return ComputeAverageColor(bitmap); } +// Initialize system salt to calculate wallpaper file names. +void SetSystemSalt() { + chromeos::SystemSaltGetter::Get()->SetRawSaltForTesting( + chromeos::SystemSaltGetter::RawSalt({1, 2, 3, 4, 5, 6, 7, 8})); +} + } // namespace class WallpaperManagerPolicyTest @@ -295,6 +302,7 @@ // user. Also verifies that after the policy has been cleared, the wallpaper // reverts to default. IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, SetResetClear) { + SetSystemSalt(); wallpaper::WallpaperInfo info; LoginUser(testUsers_[0].GetUserEmail()); base::RunLoop().RunUntilIdle(); @@ -388,11 +396,13 @@ } IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_PRE_PersistOverLogout) { + SetSystemSalt(); RegisterUser(testUsers_[0].GetUserEmail()); StartupUtils::MarkOobeCompleted(); } IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_PersistOverLogout) { + SetSystemSalt(); LoginUser(testUsers_[0].GetUserEmail()); // Wait until default wallpaper has been loaded.
diff --git a/chrome/browser/resources/settings/appearance_page/appearance_page.html b/chrome/browser/resources/settings/appearance_page/appearance_page.html index 9bc323e4..21c63de 100644 --- a/chrome/browser/resources/settings/appearance_page/appearance_page.html +++ b/chrome/browser/resources/settings/appearance_page/appearance_page.html
@@ -24,7 +24,7 @@ <template> <style include="settings-shared"> .settings-box iron-icon { - -webkit-margin-end: var(--checkbox-spacing); + -webkit-margin-end: var(--iron-icon-spacing); } </style> <settings-animated-pages id="pages" current-route="{{currentRoute}}"
diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_add_device_dialog.html b/chrome/browser/resources/settings/bluetooth_page/bluetooth_add_device_dialog.html index e936a724..f528aba 100644 --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_add_device_dialog.html +++ b/chrome/browser/resources/settings/bluetooth_page/bluetooth_add_device_dialog.html
@@ -6,7 +6,6 @@ <link rel="import" href="chrome://md-settings/settings_shared_css.html"> <dom-module id="settings-bluetooth-add-device-dialog"> - <link rel="import" type="css" href="bluetooth_page.css"> <link rel="import" type="css" href="bluetooth_dialog.css"> <template> <style include="settings-shared"></style>
diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_list_item.css b/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_list_item.css deleted file mode 100644 index bd41095e..0000000 --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_list_item.css +++ /dev/null
@@ -1,35 +0,0 @@ -/* Copyright 2015 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. */ - -#outer { - -webkit-padding-end: 5px; - -webkit-padding-start: 15px; - padding-bottom: 5px; - padding-top: 5px; -} - -#outer:hover:not([dropdown]) { - background-color: #f0f0f0; -} - -iron-icon { - -webkit-padding-start: 10px; -} - -paper-item:hover { - background-color: #f0f0f0; -} - -span.name { - padding: 10px 0; -} - -span.name[connected] { - font-weight: bold; -} - -.dropdown-content { - background: white; - box-shadow: 0 2px 6px grey; -}
diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_list_item.html b/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_list_item.html index 55a16906..6a98854 100644 --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_list_item.html +++ b/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_list_item.html
@@ -7,10 +7,28 @@ <link rel="import" href="chrome://resources/polymer/v1_0/paper-item/paper-item.html"> <dom-module id="bluetooth-device-list-item"> - <link rel="import" type="css" href="bluetooth_device_list_item.css"> + <style> + iron-icon { + -webkit-padding-start: 10px; + } + + span.name { + padding: 10px 0; + } + + span.name[connected] { + font-weight: 500; + } + + /* TODO(dbeam): combine with other similar styles. */ + .dropdown-content { + background: white; + box-shadow: 0 2px 6px grey; + } + </style> <template> - <div id="outer" class="layout horizontal center" - dropdown$="[[dropdownOpened]]" on-tap="itemTapped_"> + <div class="flex layout horizontal center" dropdown$="[[dropdownOpened]]" + on-tap="itemTapped_"> <span class="name" connected$="[[device.connected]]"> [[getDeviceName_(device)]] </span>
diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.css b/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.css deleted file mode 100644 index 2eb7bd8..0000000 --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.css +++ /dev/null
@@ -1,32 +0,0 @@ -/* Copyright 2015 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. */ - -#addDevice { - color: blue; -} - -#deviceList { - -webkit-margin-start: 15px; - max-height: 300px; - overflow-y: auto; -} - -cr-expand-button { - -webkit-margin-end: 10px; -} - -iron-icon { - -webkit-margin-end: 10px; -} - -settings-bluetooth-add-device-dialog, -settings-bluetooth-pair-device-dialog { - height: 400px; - padding: 0; - width: 500px; -} - -span.no-devices { - margin: 10px 20px; -}
diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.html b/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.html index 7c720a64..e2cbde9 100644 --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.html +++ b/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.html
@@ -14,14 +14,37 @@ <link rel="import" href="bluetooth_pair_device_dialog.html"> <dom-module id="settings-bluetooth-page"> - <link rel="import" type="css" href="bluetooth_page.css"> <template> - <style include="settings-shared"></style> + <style include="settings-shared"> + iron-icon[icon="device:bluetooth"] { + -webkit-margin-end: var(--iron-icon-spacing); + } + + cr-expand-button { + -webkit-margin-end: 10px; + } + + #deviceList { + max-height: 300px; + overflow-y: auto; + } + + .no-devices { + min-height: var(--settings-row-min-height); + } + + settings-bluetooth-add-device-dialog, + settings-bluetooth-pair-device-dialog { + height: 400px; + padding: 0; + width: 500px; + } + </style> <settings-animated-pages id="pages" current-route="{{currentRoute}}" section="bluetooth"> <neon-animatable id="main"> <div class="settings-box first"> - <div class="layout horizontal center"> + <div class="layout horizontal center flex"> <iron-icon icon="device:bluetooth"></iron-icon> <span class="flex" i18n-content="bluetoothEnable"></span> <cr-expand-button id="expandListButton" @@ -33,26 +56,27 @@ on-change="onBluetoothEnabledChange_"> </paper-toggle-button> </div> - <iron-collapse opened="[[deviceListExpanded]]"> - <div id="deviceList" class="layout vertical" - on-device-event="onDeviceEvent_"> - <span class="no-devices" - hidden$="[[haveDevices_(deviceList.splices)]]" - i18n-content="bluetoothNoDevices"> - </span> - <template is="dom-repeat" items="[[deviceList]]" - filter="deviceIsPairedOrConnecting_"> - <bluetooth-device-list-item device="[[item]]"> - </bluetooth-device-list-item> - </template> - </div> - <div class="settings-box" hidden$="[[!bluetoothEnabled]]"> - <paper-button id="addDevice" i18n-content="bluetoothAddDevice" - on-tap="onAddDeviceTap_"> - </paper-button> - </div> - </iron-collapse> </div> + <iron-collapse opened="[[canShowDeviceList_(bluetoothEnabled, + deviceListExpanded)]]"> + <div id="deviceList" class="list-frame vertical-list" + on-device-event="onDeviceEvent_"> + <template is="dom-repeat" items="[[deviceList]]" + filter="deviceIsPairedOrConnecting_"> + <bluetooth-device-list-item device="[[item]]" class="list-item"> + </bluetooth-device-list-item> + </template> + <div class="no-devices layout horizontal center" + hidden$="[[haveDevices_(deviceList.splices)]]" + i18n-content="bluetoothNoDevices"> + </div> + </div> + <div class="settings-box" hidden$="[[!bluetoothEnabled]]"> + <paper-button i18n-content="bluetoothAddDevice" + class="primary-button" on-tap="onAddDeviceTap_"> + </paper-button> + </div> + </iron-collapse> </neon-animatable> </settings-animated-pages>
diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js b/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js index 41ba307b..405d29b 100644 --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js +++ b/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js
@@ -197,6 +197,16 @@ }, /** + * @param {boolean} bluetoothEnabled + * @param {boolean} deviceListExpanded + * @return {boolean} Whether the <iron-collapse> can be shown. + * @private + */ + canShowDeviceList_: function(bluetoothEnabled, deviceListExpanded) { + return bluetoothEnabled && deviceListExpanded; + }, + + /** * If bluetooth is enabled, request the complete list of devices and update * |deviceList|. * @private
diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_pair_device_dialog.html b/chrome/browser/resources/settings/bluetooth_page/bluetooth_pair_device_dialog.html index 2705f4e1..755d418 100644 --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_pair_device_dialog.html +++ b/chrome/browser/resources/settings/bluetooth_page/bluetooth_pair_device_dialog.html
@@ -6,7 +6,6 @@ <link rel="import" href="chrome://md-settings/settings_shared_css.html"> <dom-module id="settings-bluetooth-pair-device-dialog"> - <link rel="import" type="css" href="bluetooth_page.css"> <link rel="import" type="css" href="bluetooth_dialog.css"> <template> <style include="settings-shared"></style>
diff --git a/chrome/browser/resources/settings/on_startup_page/compiled_resources2.gyp b/chrome/browser/resources/settings/on_startup_page/compiled_resources2.gyp index d7d8531..1836509 100644 --- a/chrome/browser/resources/settings/on_startup_page/compiled_resources2.gyp +++ b/chrome/browser/resources/settings/on_startup_page/compiled_resources2.gyp
@@ -12,10 +12,9 @@ 'dependencies': [ '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', - '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:promise_resolver', - '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior', 'startup_urls_page_browser_proxy', + 'startup_url_entry', ], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], }, @@ -24,10 +23,18 @@ 'dependencies': [ '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', - '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:promise_resolver', '<(EXTERNS_GYP):chrome_send', ], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], }, + { + 'target_name': 'startup_url_entry', + 'dependencies': [ + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util', + 'startup_urls_page_browser_proxy', + ], + 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], + }, ], }
diff --git a/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.html b/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.html index 0f7f4a6..17b885c 100644 --- a/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.html +++ b/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.html
@@ -9,7 +9,7 @@ <template> <style include="settings-shared"></style> <settings-dialog id="dialog"> - <div class="title">$i18n{onStartupAddNewPage}</div> + <div class="title">[[dialogTitle_]]</div> <div class="body"> <paper-input always-float-label id="url" value="{{url_}}" on-input="validate_"> @@ -20,8 +20,8 @@ <div class="action-buttons"> <paper-button class="cancel-button" on-tap="onCancelTap_" id="cancel">$i18n{cancel}</paper-button> - <paper-button id="add" class="action-button" on-tap="onAddTap_" - disabled>$i18n{add}</paper-button> + <paper-button id="actionButton" class="action-button" + on-tap="onActionButtonTap_">[[actionButtonText_]]</paper-button> </div> </div> </settings-dialog>
diff --git a/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.js b/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.js index 363d376..516d730 100644 --- a/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.js +++ b/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.js
@@ -12,18 +12,39 @@ properties: { /** @private {string} */ url_: String, + + /** + * If specified the dialog acts as an "Edit page" dialog, otherwise as an + * "Add new page" dialog. + * @type {?StartupPageInfo} + */ + model: Object, + + /** @private {string} */ + dialogTitle_: String, + + /** @private {string} */ + actionButtonText_: String, }, /** @private {!settings.SearchEnginesBrowserProxy} */ browserProxy_: null, /** @override */ - ready: function() { - this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance(); - }, - - /** @override */ attached: function() { + this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance(); + + if (this.model) { + this.dialogTitle_ = loadTimeData.getString('onStartupEditPage'); + this.actionButtonText_ = loadTimeData.getString('onStartupEdit'); + this.$.actionButton.disabled = false; + // Pre-populate the input field. + this.url_ = this.model.url; + } else { + this.dialogTitle_ = loadTimeData.getString('onStartupAddNewPage'); + this.actionButtonText_ = loadTimeData.getString('add'); + this.$.actionButton.disabled = true; + } this.$.dialog.open(); }, @@ -33,8 +54,12 @@ }, /** @private */ - onAddTap_: function() { - this.browserProxy_.addStartupPage(this.url_).then(function(success) { + onActionButtonTap_: function() { + var whenDone = this.model ? + this.browserProxy_.editStartupPage(this.model.modelIndex, this.url_) : + this.browserProxy_.addStartupPage(this.url_); + + whenDone.then(function(success) { if (success) this.$.dialog.close(); // If the URL was invalid, there is nothing to do, just leave the dialog @@ -45,7 +70,7 @@ /** @private */ validate_: function() { this.browserProxy_.validateStartupPage(this.url_).then(function(isValid) { - this.$.add.disabled = !isValid; + this.$.actionButton.disabled = !isValid; }.bind(this)); }, });
diff --git a/chrome/browser/resources/settings/on_startup_page/startup_url_entry.html b/chrome/browser/resources/settings/on_startup_page/startup_url_entry.html index 1b908177..99dadd36 100644 --- a/chrome/browser/resources/settings/on_startup_page/startup_url_entry.html +++ b/chrome/browser/resources/settings/on_startup_page/startup_url_entry.html
@@ -40,6 +40,7 @@ <iron-dropdown vertical-align="top" horizontal-align="right" opened="{{menuOpened}}"> <div class="dropdown-content"> + <paper-item on-tap="onEditTap_">$i18n{onStartupEdit}</paper-item> <paper-item id="remove" on-tap="onRemoveTap_"> $i18n{onStartupRemove} </paper-item>
diff --git a/chrome/browser/resources/settings/on_startup_page/startup_url_entry.js b/chrome/browser/resources/settings/on_startup_page/startup_url_entry.js index c3fbeb98..89750cb6 100644 --- a/chrome/browser/resources/settings/on_startup_page/startup_url_entry.js +++ b/chrome/browser/resources/settings/on_startup_page/startup_url_entry.js
@@ -7,6 +7,16 @@ * displayes a URL that is loaded during startup. It includes a menu that allows * the user to edit/remove the entry. */ + +cr.exportPath('settings'); + +/** + * The name of the event fired from this element when the "Edit" option is + * tapped. + * @const {string} + */ +settings.EDIT_STARTUP_URL_EVENT = 'edit-startup-url'; + Polymer({ is: 'settings-startup-url-entry', @@ -26,7 +36,14 @@ /** @private */ onRemoveTap_: function() { + this.$$('iron-dropdown').close(); settings.StartupUrlsPageBrowserProxyImpl.getInstance().removeStartupPage( this.model.modelIndex); }, + + /** @private */ + onEditTap_: function() { + this.$$('iron-dropdown').close(); + this.fire(settings.EDIT_STARTUP_URL_EVENT, this.model); + }, });
diff --git a/chrome/browser/resources/settings/on_startup_page/startup_urls_page.html b/chrome/browser/resources/settings/on_startup_page/startup_urls_page.html index ac42d096..4576fff 100644 --- a/chrome/browser/resources/settings/on_startup_page/startup_urls_page.html +++ b/chrome/browser/resources/settings/on_startup_page/startup_urls_page.html
@@ -21,7 +21,8 @@ on-tap="onUseCurrentPagesTap_">$i18n{onStartupUseCurrent}</div> </div> <template is="dom-if" if="[[showStartupUrlDialog_]]" restamp> - <settings-startup-url-dialog></settings-startup-url-dialog> + <settings-startup-url-dialog model="[[startupUrlDialogModel_]]"> + </settings-startup-url-dialog> </template> </template> <script src="startup_urls_page.js"></script>
diff --git a/chrome/browser/resources/settings/on_startup_page/startup_urls_page.js b/chrome/browser/resources/settings/on_startup_page/startup_urls_page.js index a3d0fab..6941c08 100644 --- a/chrome/browser/resources/settings/on_startup_page/startup_urls_page.js +++ b/chrome/browser/resources/settings/on_startup_page/startup_urls_page.js
@@ -22,7 +22,11 @@ */ startupPages_: Array, + /** @private */ showStartupUrlDialog_: Boolean, + + /** @private {?StartupPageInfo} */ + startupUrlDialogModel_: Object, }, /** @override */ @@ -32,6 +36,17 @@ this.startupPages_ = startupPages; }.bind(this)); this.browserProxy_.loadStartupPages(); + + this.addEventListener(settings.EDIT_STARTUP_URL_EVENT, function(event) { + this.startupUrlDialogModel_ = event.detail; + this.openDialog_(); + event.stopPropagation(); + }.bind(this)); + }, + + /** @private */ + onAddPageTap_: function() { + this.openDialog_(); }, /** @@ -40,12 +55,13 @@ * (because of 'restamp'). * @private */ - onAddPageTap_: function() { + openDialog_: function() { this.showStartupUrlDialog_ = true; this.async(function() { var dialog = this.$$('settings-startup-url-dialog'); dialog.addEventListener('iron-overlay-closed', function() { this.showStartupUrlDialog_ = false; + this.startupUrlDialogModel_ = null; }.bind(this)); }.bind(this)); },
diff --git a/chrome/browser/resources/settings/settings_resources.grd b/chrome/browser/resources/settings/settings_resources.grd index fa44346..6941880 100644 --- a/chrome/browser/resources/settings/settings_resources.grd +++ b/chrome/browser/resources/settings/settings_resources.grd
@@ -697,9 +697,6 @@ file="site_settings/website_usage_private_api.js" type="chrome_html" /> <if expr="chromeos"> - <structure name="IDR_SETTINGS_BLUETOOTH_DEVICE_LIST_ITEM_CSS" - file="bluetooth_page/bluetooth_device_list_item.css" - type="chrome_html" /> <structure name="IDR_SETTINGS_BLUETOOTH_DEVICE_LIST_ITEM_HTML" file="bluetooth_page/bluetooth_device_list_item.html" type="chrome_html" /> @@ -709,9 +706,6 @@ <structure name="IDR_SETTINGS_BLUETOOTH_DIALOG_CSS" file="bluetooth_page/bluetooth_dialog.css" type="chrome_html" /> - <structure name="IDR_SETTINGS_BLUETOOTH_PAGE_CSS" - file="bluetooth_page/bluetooth_page.css" - type="chrome_html" /> <structure name="IDR_SETTINGS_BLUETOOTH_PAGE_HTML" file="bluetooth_page/bluetooth_page.html" type="chrome_html" />
diff --git a/chrome/browser/resources/settings/settings_shared_css.html b/chrome/browser/resources/settings/settings_shared_css.html index 33e504aa..ee62edbd 100644 --- a/chrome/browser/resources/settings/settings_shared_css.html +++ b/chrome/browser/resources/settings/settings_shared_css.html
@@ -8,12 +8,17 @@ --checkbox-spacing: 18px; --iron-icon-fill-color: var(--paper-grey-600); --iron-icon-height: 20px; + --iron-icon-spacing: 16px; --iron-icon-width: 20px; --paper-icon-button: { width: 36px; height: 36px; }; --paper-input-max-width: 264px; + --paper-item: { + font-size: inherit; + }; + --settings-background-color: var(--paper-blue-grey-50); --settings-secondary: { color: var(--paper-grey-600); @@ -25,6 +30,9 @@ /* Some colors use non-MD colors. These custom colors are specified by * UX design (bettes@). */ --settings-nav-grey: rgb(90, 90, 90); + + --settings-row-min-height: 40px; + --settings-title-bar-background-color: rgb(52, 73, 94); --settings-title-bar-color: rgb(255, 255, 255); } @@ -36,7 +44,7 @@ font-size: 100%; font-weight: 500; margin: 0; - min-height: 40px; + min-height: var(--settings-row-min-height); } iron-icon[icon=check], @@ -144,7 +152,7 @@ .list-item { @apply(--layout-center); display: flex; - min-height: 40px; + min-height: var(--settings-row-min-height); padding: 0; } @@ -188,7 +196,7 @@ @apply(--layout-center); border-top: 1px solid var(--paper-grey-300); display: flex; - min-height: 40px; + min-height: var(--settings-row-min-height); padding: 0 20px; } @@ -239,11 +247,7 @@ padding: 8px; } - .vertical-list > div:first-of-type { - border-top: none; - } - - .vertical-list > div { + .vertical-list > *:not(:first-of-type) { border-top: 1px solid var(--paper-grey-300); }
diff --git a/chrome/browser/ui/ash/launcher/chrome_mash_shelf_controller.cc b/chrome/browser/ui/ash/launcher/chrome_mash_shelf_controller.cc index 29af846..f6ab2ceb7 100644 --- a/chrome/browser/ui/ash/launcher/chrome_mash_shelf_controller.cc +++ b/chrome/browser/ui/ash/launcher/chrome_mash_shelf_controller.cc
@@ -59,7 +59,7 @@ : observer_binding_(this) {} void ChromeMashShelfController::Init() { - mojo::Connector* connector = + shell::Connector* connector = content::MojoShellConnection::Get()->GetConnector(); connector->ConnectToInterface("mojo:ash_sysui", &shelf_controller_);
diff --git a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc index 73c79b2..32e65e2a 100644 --- a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc +++ b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
@@ -24,25 +24,15 @@ namespace { -bool IsNTPWebUI(content::WebContents* web_contents) { - content::WebUI* web_ui = NULL; - // Use the committed entry so the bookmarks bar disappears at the same time - // the page does. - if (web_contents->GetController().GetLastCommittedEntry()) - web_ui = web_contents->GetCommittedWebUI(); - else - web_ui = web_contents->GetWebUI(); - return web_ui && NewTabUI::FromWebUIController(web_ui->GetController()); -} - -bool IsInstantNTP(content::WebContents* web_contents) { +bool IsNTP(content::WebContents* web_contents) { // Use the committed entry so the bookmarks bar disappears at the same time // the page does. const content::NavigationEntry* entry = web_contents->GetController().GetLastCommittedEntry(); if (!entry) entry = web_contents->GetController().GetVisibleEntry(); - return search::NavEntryIsInstantNTP(web_contents, entry); + return (entry && NewTabUI::IsNewTab(entry->GetURL())) || + search::NavEntryIsInstantNTP(web_contents, entry); } } // namespace @@ -77,7 +67,7 @@ !prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)) return false; - return IsNTPWebUI(web_contents()) || IsInstantNTP(web_contents()); + return IsNTP(web_contents()); } BookmarkTabHelper::BookmarkTabHelper(content::WebContents* web_contents)
diff --git a/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc b/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc index 4451a34..ed748443 100644 --- a/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc +++ b/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc
@@ -20,24 +20,19 @@ // Checks that the |bubble| is using the |expected_reference_view|, and is in // approximately the correct position. -void CheckBubbleAndReferenceView(views::BubbleDelegateView* bubble, +void CheckBubbleAndReferenceView(views::BubbleDialogDelegateView* bubble, views::View* expected_reference_view) { ASSERT_TRUE(bubble); ASSERT_TRUE(expected_reference_view); EXPECT_EQ(expected_reference_view, bubble->GetAnchorView()); // Do a rough check that the bubble is in the right place. - gfx::Rect bubble_bounds = bubble->GetBoundsInScreen(); + gfx::Rect bubble_bounds = bubble->GetWidget()->GetWindowBoundsInScreen(); gfx::Rect reference_bounds = expected_reference_view->GetBoundsInScreen(); // It should be below the reference view, but not too far below. - EXPECT_GE(bubble_bounds.y(), reference_bounds.bottom()); - // "Too far below" is kind of ambiguous. The exact logic of where a bubble - // is positioned with respect to its anchor view should be tested as part of - // the bubble logic, but we still want to make sure we didn't accidentally - // place it somewhere crazy (which can happen if we draw it, and then - // animate or reposition the reference view). - const int kFudgeFactor = 50; - EXPECT_LE(bubble_bounds.y(), reference_bounds.bottom() + kFudgeFactor); + EXPECT_GE(bubble_bounds.y(), reference_bounds.y()); + // The arrow should be poking into the anchor. + EXPECT_LE(bubble_bounds.y(), reference_bounds.bottom()); // The bubble should intersect the reference view somewhere along the x-axis. EXPECT_FALSE(bubble_bounds.x() > reference_bounds.right()); EXPECT_FALSE(reference_bounds.x() > bubble_bounds.right()); @@ -69,7 +64,7 @@ AnchorPosition anchor) { ToolbarView* toolbar_view = GetToolbarViewForBrowser(browser); BrowserActionsContainer* container = toolbar_view->browser_actions(); - views::BubbleDelegateView* bubble = container->active_bubble(); + views::BubbleDialogDelegateView* bubble = container->active_bubble(); views::View* anchor_view = nullptr; switch (anchor) { case ANCHOR_BROWSER_ACTION: @@ -85,7 +80,7 @@ void ExtensionMessageBubbleViewBrowserTest::CloseBubble(Browser* browser) { BrowserActionsContainer* container = GetToolbarViewForBrowser(browser)->browser_actions(); - views::BubbleDelegateView* bubble = container->active_bubble(); + views::BubbleDialogDelegateView* bubble = container->active_bubble(); ASSERT_TRUE(bubble); bubble->GetWidget()->Close(); EXPECT_EQ(nullptr, container->active_bubble());
diff --git a/chrome/browser/ui/views/settings_api_bubble_helper_views.cc b/chrome/browser/ui/views/settings_api_bubble_helper_views.cc index 1485789..6bda4f6 100644 --- a/chrome/browser/ui/views/settings_api_bubble_helper_views.cc +++ b/chrome/browser/ui/views/settings_api_bubble_helper_views.cc
@@ -45,7 +45,7 @@ new ExtensionMessageBubbleBridge( std::move(settings_api_bubble)))); bubble->set_arrow(arrow); - views::BubbleDelegateView::CreateBubble(bubble); + views::BubbleDialogDelegateView::CreateBubble(bubble); bubble->Show(); } @@ -122,7 +122,7 @@ std::unique_ptr<ToolbarActionsBarBubbleDelegate>( new ExtensionMessageBubbleBridge(std::move(ntp_overridden_bubble)))); bubble->set_arrow(views::BubbleBorder::TOP_RIGHT); - views::BubbleDelegateView::CreateBubble(bubble); + views::BubbleDialogDelegateView::CreateBubble(bubble); bubble->Show(); }
diff --git a/chrome/browser/ui/views/toolbar/browser_actions_container.cc b/chrome/browser/ui/views/toolbar/browser_actions_container.cc index 90ed0b1e..49a4732 100644 --- a/chrome/browser/ui/views/toolbar/browser_actions_container.cc +++ b/chrome/browser/ui/views/toolbar/browser_actions_container.cc
@@ -328,9 +328,9 @@ ToolbarActionsBarBubbleViews* bubble = new ToolbarActionsBarBubbleViews(anchor_view, std::move(controller)); - views::BubbleDelegateView::CreateBubble(bubble); active_bubble_ = bubble; - active_bubble_->GetWidget()->AddObserver(this); + views::BubbleDialogDelegateView::CreateBubble(bubble); + bubble->GetWidget()->AddObserver(this); bubble->Show(); }
diff --git a/chrome/browser/ui/views/toolbar/browser_actions_container.h b/chrome/browser/ui/views/toolbar/browser_actions_container.h index fc29542..da220d2 100644 --- a/chrome/browser/ui/views/toolbar/browser_actions_container.h +++ b/chrome/browser/ui/views/toolbar/browser_actions_container.h
@@ -32,7 +32,7 @@ } namespace views { -class BubbleDelegateView; +class BubbleDialogDelegateView; class ResizeArea; } @@ -246,7 +246,7 @@ void OnWidgetClosing(views::Widget* widget) override; void OnWidgetDestroying(views::Widget* widget) override; - views::BubbleDelegateView* active_bubble() { return active_bubble_; } + views::BubbleDialogDelegateView* active_bubble() { return active_bubble_; } ChevronMenuButton* chevron_for_testing() { return chevron_; } @@ -328,7 +328,7 @@ std::unique_ptr<DropPosition> drop_position_; // The extension bubble that is actively showing, if any. - views::BubbleDelegateView* active_bubble_; + views::BubbleDialogDelegateView* active_bubble_; DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); };
diff --git a/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc b/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc index b27c5153..a5530f6 100644 --- a/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc +++ b/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc
@@ -11,7 +11,7 @@ #include "ui/views/controls/button/label_button.h" #include "ui/views/controls/label.h" #include "ui/views/controls/link.h" -#include "ui/views/layout/grid_layout.h" +#include "ui/views/layout/box_layout.h" #include "ui/views/layout/layout_constants.h" namespace { @@ -21,16 +21,11 @@ ToolbarActionsBarBubbleViews::ToolbarActionsBarBubbleViews( views::View* anchor_view, std::unique_ptr<ToolbarActionsBarBubbleDelegate> delegate) - : views::BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), - anchor_view_(anchor_view), + : views::BubbleDialogDelegateView(anchor_view, + views::BubbleBorder::TOP_RIGHT), delegate_(std::move(delegate)), - heading_label_(nullptr), - content_label_(nullptr), item_list_(nullptr), - learn_more_button_(nullptr), - dismiss_button_(nullptr), - action_button_(nullptr), - acknowledged_(false) { + learn_more_button_(nullptr) { set_close_on_deactivate(delegate_->ShouldCloseOnDeactivate()); } @@ -41,129 +36,82 @@ GetWidget()->Show(); } +views::View* ToolbarActionsBarBubbleViews::CreateExtraView() { + base::string16 text = delegate_->GetLearnMoreButtonText(); + if (text.empty()) + return nullptr; + + learn_more_button_ = new views::Link(text); + learn_more_button_->set_listener(this); + return learn_more_button_; +} + +base::string16 ToolbarActionsBarBubbleViews::GetWindowTitle() const { + return delegate_->GetHeadingText(); +} + +bool ToolbarActionsBarBubbleViews::Cancel() { + delegate_->OnBubbleClosed( + ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_USER_ACTION); + return true; +} + +bool ToolbarActionsBarBubbleViews::Accept() { + delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE); + return true; +} + +bool ToolbarActionsBarBubbleViews::Close() { + if (delegate_) { + delegate_->OnBubbleClosed( + ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_DEACTIVATION); + } + return true; +} + void ToolbarActionsBarBubbleViews::Init() { - views::GridLayout* layout = new views::GridLayout(this); - layout->SetInsets(views::kPanelVertMargin, views::kPanelHorizMargin, - views::kPanelVertMargin, views::kPanelHorizMargin); - SetLayoutManager(layout); - - enum ColumnSetId { - HEADER_AND_BODY_COLUMN_SET = 0, - LIST_COLUMN_SET, - BUTTON_STRIP_COLUMN_SET, - }; - - views::ColumnSet* header_and_body_cs = - layout->AddColumnSet(HEADER_AND_BODY_COLUMN_SET); - header_and_body_cs->AddColumn(views::GridLayout::LEADING, - views::GridLayout::LEADING, 1, - views::GridLayout::USE_PREF, 0, 0); - views::ColumnSet* buttons_cs = layout->AddColumnSet(BUTTON_STRIP_COLUMN_SET); - buttons_cs->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, - 0, views::GridLayout::USE_PREF, 0, 0); - buttons_cs->AddPaddingColumn(1, 0); - buttons_cs->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, - 0, views::GridLayout::USE_PREF, 0, 0); - buttons_cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); - buttons_cs->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, - 0, views::GridLayout::USE_PREF, 0, 0); - - // Add a header. - layout->StartRow(0, HEADER_AND_BODY_COLUMN_SET); - heading_label_ = new views::Label(delegate_->GetHeadingText()); - heading_label_->SetFontList( - ui::ResourceBundle::GetSharedInstance().GetFontList( - ui::ResourceBundle::MediumFont)); - heading_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); - layout->AddView(heading_label_); - layout->AddPaddingRow(0, views::kLabelToControlVerticalSpacing); - int width = views::Widget::GetLocalizedContentsWidth( - IDS_EXTENSION_TOOLBAR_REDESIGN_NOTIFICATION_BUBBLE_WIDTH_CHARS); + SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, + views::kRelatedControlVerticalSpacing)); // Add the content string. - layout->StartRow(0, HEADER_AND_BODY_COLUMN_SET); - content_label_ = new views::Label( - delegate_->GetBodyText(anchor_view_->id() == VIEW_ID_BROWSER_ACTION)); - content_label_->SetMultiLine(true); - content_label_->SizeToFit(width); - content_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); - layout->AddView(content_label_); + views::Label* content_label = new views::Label( + delegate_->GetBodyText(GetAnchorView()->id() == VIEW_ID_BROWSER_ACTION)); + content_label->SetMultiLine(true); + int width = views::Widget::GetLocalizedContentsWidth( + IDS_EXTENSION_TOOLBAR_REDESIGN_NOTIFICATION_BUBBLE_WIDTH_CHARS); + content_label->SizeToFit(width); + content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); + AddChildView(content_label); base::string16 item_list = delegate_->GetItemListText(); if (!item_list.empty()) { - views::ColumnSet* list_cs = layout->AddColumnSet(LIST_COLUMN_SET); - list_cs->AddPaddingColumn(0, kListPadding); - list_cs->AddColumn(views::GridLayout::LEADING, - views::GridLayout::CENTER, - 0, - views::GridLayout::USE_PREF, - 0, 0); - - layout->StartRowWithPadding(0, LIST_COLUMN_SET, 0, 0); item_list_ = new views::Label(item_list); + item_list_->SetBorder( + views::Border::CreateEmptyBorder(0, kListPadding, 0, 0)); item_list_->SetMultiLine(true); - item_list_->SetHorizontalAlignment(gfx::ALIGN_LEFT); item_list_->SizeToFit(width); - layout->AddView(item_list_); - } - - layout->AddPaddingRow(0, views::kLabelToControlVerticalSpacing); - - layout->StartRow(0, BUTTON_STRIP_COLUMN_SET); - base::string16 learn_more_text = delegate_->GetLearnMoreButtonText(); - if (!learn_more_text.empty()) { - learn_more_button_ = new views::Link(learn_more_text); - learn_more_button_->set_listener(this); - layout->AddView(learn_more_button_); - } else { - layout->SkipColumns(1); - } - - base::string16 dismiss_button_text = delegate_->GetDismissButtonText(); - if (!dismiss_button_text.empty()) { - dismiss_button_ = new views::LabelButton(this, dismiss_button_text); - dismiss_button_->SetStyle(views::Button::STYLE_BUTTON); - layout->AddView(dismiss_button_, 1, 1, views::GridLayout::TRAILING, - views::GridLayout::FILL); - } else { - layout->SkipColumns(1); - } - - action_button_ = - new views::LabelButton(this, delegate_->GetActionButtonText()); - action_button_->SetStyle(views::Button::STYLE_BUTTON); - layout->AddView(action_button_, 1, 1, views::GridLayout::TRAILING, - views::GridLayout::FILL); -} - -void ToolbarActionsBarBubbleViews::OnWidgetDestroying(views::Widget* widget) { - BubbleDelegateView::OnWidgetDestroying(widget); - if (!acknowledged_) { - ToolbarActionsBarBubbleDelegate::CloseAction close_action = - close_reason() == CloseReason::DEACTIVATION - ? ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_DEACTIVATION - : ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_USER_ACTION; - delegate_->OnBubbleClosed(close_action); - acknowledged_ = true; + item_list_->SetHorizontalAlignment(gfx::ALIGN_LEFT); + AddChildView(item_list_); } } -void ToolbarActionsBarBubbleViews::ButtonPressed(views::Button* sender, - const ui::Event& event) { - if (sender == action_button_) { - delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE); - } else { - DCHECK_EQ(dismiss_button_, sender); - delegate_->OnBubbleClosed( - ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_USER_ACTION); - } - acknowledged_ = true; - GetWidget()->Close(); +int ToolbarActionsBarBubbleViews::GetDialogButtons() const { + int buttons = ui::DIALOG_BUTTON_OK; + if (!delegate_->GetDismissButtonText().empty()) + buttons |= ui::DIALOG_BUTTON_CANCEL; + return buttons; +} + +base::string16 ToolbarActionsBarBubbleViews::GetDialogButtonLabel( + ui::DialogButton button) const { + return button == ui::DIALOG_BUTTON_OK ? delegate_->GetActionButtonText() + : delegate_->GetDismissButtonText(); } void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link, int event_flags) { delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE); - acknowledged_ = true; + // Reset delegate so we don't send extra OnBubbleClosed()s. + delegate_.reset(); GetWidget()->Close(); }
diff --git a/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h b/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h index e46bfe26..70a51d58 100644 --- a/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h +++ b/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h
@@ -8,7 +8,7 @@ #include <memory> #include "base/macros.h" -#include "ui/views/bubble/bubble_delegate.h" +#include "ui/views/bubble/bubble_dialog_delegate.h" #include "ui/views/controls/button/button.h" #include "ui/views/controls/link_listener.h" @@ -22,10 +22,7 @@ class Link; } -// TODO(devlin): It might be best for this to combine with -// ExtensionMessageBubbleView, similar to what we do on Mac. -class ToolbarActionsBarBubbleViews : public views::BubbleDelegateView, - public views::ButtonListener, +class ToolbarActionsBarBubbleViews : public views::BubbleDialogDelegateView, public views::LinkListener { public: ToolbarActionsBarBubbleViews( @@ -35,39 +32,29 @@ void Show(); - const views::Label* heading_label() const { return heading_label_; } - const views::Label* content_label() const { return content_label_; } const views::Label* item_list() const { return item_list_; } - const views::LabelButton* action_button() const { return action_button_; } - const views::LabelButton* dismiss_button() const { return dismiss_button_; } const views::Link* learn_more_button() const { return learn_more_button_; } private: - // views::BubbleDelegateView: + // views::BubbleDialogDelegateView: + base::string16 GetWindowTitle() const override; + views::View* CreateExtraView() override; + bool Cancel() override; + bool Accept() override; + bool Close() override; + int GetDialogButtons() const override; + base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; void Init() override; - void OnWidgetDestroying(views::Widget* widget) override; - - // views::ButtonListener: - void ButtonPressed(views::Button* sender, const ui::Event& event) override; // views::LinkListener: void LinkClicked(views::Link* source, int event_flags) override; - views::View* anchor_view_; - std::unique_ptr<ToolbarActionsBarBubbleDelegate> delegate_; - views::Label* heading_label_; views::Label* content_label_; views::Label* item_list_; views::Link* learn_more_button_; - views::LabelButton* dismiss_button_; - views::LabelButton* action_button_; - - // Whether or not the user acknowledged the bubble by clicking the "ok" - // button. - bool acknowledged_; DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBarBubbleViews); };
diff --git a/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views_unittest.cc b/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views_unittest.cc index 39754c7..46ffe167 100644 --- a/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views_unittest.cc +++ b/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views_unittest.cc
@@ -2,29 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h" + #include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/ui/toolbar/test_toolbar_actions_bar_bubble_delegate.h" -#include "chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h" #include "ui/events/event_utils.h" #include "ui/events/test/event_generator.h" -#include "ui/views/bubble/bubble_delegate.h" #include "ui/views/controls/button/label_button.h" #include "ui/views/controls/link.h" #include "ui/views/test/test_widget_observer.h" #include "ui/views/test/views_test_base.h" #include "ui/views/widget/widget.h" - -namespace { - -gfx::Point GetCenterInScreenCoordinates(const views::View* view) { - gfx::Point center(view->width() / 2, view->height() / 2); - views::View::ConvertPointToScreen(view, ¢er); - return center; -} - -} // namespace +#include "ui/views/window/dialog_client_view.h" class ToolbarActionsBarBubbleViewsTest : public views::ViewsTestBase { protected: @@ -52,8 +43,7 @@ anchor_widget_ = CreateAnchorWidget(); bubble_ = new ToolbarActionsBarBubbleViews( anchor_widget_->GetContentsView(), delegate->GetDelegate()); - bubble_widget_ = - views::BubbleDelegateView::CreateBubble(bubble_); + bubble_widget_ = views::BubbleDialogDelegateView::CreateBubble(bubble_); bubble_->Show(); } @@ -69,7 +59,7 @@ ASSERT_TRUE(view); ui::test::EventGenerator generator(GetContext(), anchor_widget_->GetNativeWindow()); - generator.MoveMouseTo(GetCenterInScreenCoordinates(view)); + generator.MoveMouseTo(view->GetBoundsInScreen().CenterPoint()); generator.ClickLeftButton(); base::RunLoop().RunUntilIdle(); } @@ -100,15 +90,10 @@ ActionString()); ShowBubble(&delegate); - EXPECT_TRUE(bubble()->heading_label()); - EXPECT_EQ(HeadingString(), bubble()->heading_label()->text()); - EXPECT_TRUE(bubble()->content_label()); - EXPECT_EQ(BodyString(), bubble()->content_label()->text()); - EXPECT_TRUE(bubble()->action_button()); - EXPECT_EQ(ActionString(), bubble()->action_button()->GetText()); - EXPECT_FALSE(bubble()->dismiss_button()); - EXPECT_FALSE(bubble()->learn_more_button()); - EXPECT_FALSE(bubble()->item_list()); + EXPECT_TRUE(bubble()->GetDialogClientView()->ok_button()); + EXPECT_EQ(ActionString(), + bubble()->GetDialogClientView()->ok_button()->GetText()); + EXPECT_FALSE(bubble()->GetDialogClientView()->cancel_button()); CloseBubble(); } @@ -118,16 +103,16 @@ TestToolbarActionsBarBubbleDelegate delegate(HeadingString(), BodyString(), ActionString()); delegate.set_dismiss_button_text(DismissString()); + ShowBubble(&delegate); - EXPECT_TRUE(bubble()->heading_label()); - EXPECT_EQ(HeadingString(), bubble()->heading_label()->text()); - EXPECT_TRUE(bubble()->content_label()); - EXPECT_EQ(BodyString(), bubble()->content_label()->text()); - EXPECT_TRUE(bubble()->action_button()); - EXPECT_EQ(ActionString(), bubble()->action_button()->GetText()); - EXPECT_TRUE(bubble()->dismiss_button()); - EXPECT_EQ(DismissString(), bubble()->dismiss_button()->GetText()); + EXPECT_TRUE(bubble()->GetDialogClientView()->ok_button()); + EXPECT_EQ(ActionString(), + bubble()->GetDialogClientView()->ok_button()->GetText()); + EXPECT_TRUE(bubble()->GetDialogClientView()->cancel_button()); + EXPECT_EQ(DismissString(), + bubble()->GetDialogClientView()->cancel_button()->GetText()); + EXPECT_FALSE(bubble()->learn_more_button()); EXPECT_FALSE(bubble()->item_list()); @@ -142,14 +127,12 @@ delegate.set_learn_more_button_text(LearnMoreString()); ShowBubble(&delegate); - EXPECT_TRUE(bubble()->heading_label()); - EXPECT_EQ(HeadingString(), bubble()->heading_label()->text()); - EXPECT_TRUE(bubble()->content_label()); - EXPECT_EQ(BodyString(), bubble()->content_label()->text()); - EXPECT_TRUE(bubble()->action_button()); - EXPECT_EQ(ActionString(), bubble()->action_button()->GetText()); - EXPECT_TRUE(bubble()->dismiss_button()); - EXPECT_EQ(DismissString(), bubble()->dismiss_button()->GetText()); + EXPECT_TRUE(bubble()->GetDialogClientView()->ok_button()); + EXPECT_EQ(ActionString(), + bubble()->GetDialogClientView()->ok_button()->GetText()); + EXPECT_TRUE(bubble()->GetDialogClientView()->cancel_button()); + EXPECT_EQ(DismissString(), + bubble()->GetDialogClientView()->cancel_button()->GetText()); EXPECT_TRUE(bubble()->learn_more_button()); EXPECT_EQ(LearnMoreString(), bubble()->learn_more_button()->text()); EXPECT_FALSE(bubble()->item_list()); @@ -163,13 +146,10 @@ delegate.set_item_list_text(ItemListString()); ShowBubble(&delegate); - EXPECT_TRUE(bubble()->heading_label()); - EXPECT_EQ(HeadingString(), bubble()->heading_label()->text()); - EXPECT_TRUE(bubble()->content_label()); - EXPECT_EQ(BodyString(), bubble()->content_label()->text()); - EXPECT_TRUE(bubble()->action_button()); - EXPECT_EQ(ActionString(), bubble()->action_button()->GetText()); - EXPECT_FALSE(bubble()->dismiss_button()); + EXPECT_TRUE(bubble()->GetDialogClientView()->ok_button()); + EXPECT_EQ(ActionString(), + bubble()->GetDialogClientView()->ok_button()->GetText()); + EXPECT_FALSE(bubble()->GetDialogClientView()->cancel_button()); EXPECT_FALSE(bubble()->learn_more_button()); EXPECT_TRUE(bubble()->item_list()); EXPECT_EQ(ItemListString(), bubble()->item_list()->text()); @@ -188,13 +168,13 @@ EXPECT_FALSE(delegate.shown()); EXPECT_FALSE(delegate.close_action()); views::Widget* bubble_widget = - views::BubbleDelegateView::CreateBubble(bubble); + views::BubbleDialogDelegateView::CreateBubble(bubble); views::test::TestWidgetObserver bubble_observer(bubble_widget); bubble->Show(); EXPECT_TRUE(delegate.shown()); EXPECT_FALSE(delegate.close_action()); - bubble_widget->Close(); + bubble->GetDialogClientView()->CancelWindow(); base::RunLoop().RunUntilIdle(); ASSERT_TRUE(delegate.close_action()); EXPECT_EQ(ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_USER_ACTION, @@ -211,7 +191,7 @@ views::test::TestWidgetObserver bubble_observer(bubble_widget()); EXPECT_FALSE(delegate.close_action()); - ClickView(bubble()->action_button()); + ClickView(bubble()->GetDialogClientView()->ok_button()); ASSERT_TRUE(delegate.close_action()); EXPECT_EQ(ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE, *delegate.close_action()); @@ -227,7 +207,7 @@ views::test::TestWidgetObserver bubble_observer(bubble_widget()); EXPECT_FALSE(delegate.close_action()); - ClickView(bubble()->dismiss_button()); + ClickView(bubble()->GetDialogClientView()->cancel_button()); ASSERT_TRUE(delegate.close_action()); EXPECT_EQ(ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_USER_ACTION, *delegate.close_action());
diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui.cc b/chrome/browser/ui/webui/ntp/new_tab_ui.cc index 84547a3..ae162b6 100644 --- a/chrome/browser/ui/webui/ntp/new_tab_ui.cc +++ b/chrome/browser/ui/webui/ntp/new_tab_ui.cc
@@ -5,10 +5,8 @@ #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" #include <memory> -#include <set> #include "base/i18n/rtl.h" -#include "base/lazy_instance.h" #include "base/memory/ref_counted_memory.h" #include "base/strings/utf_string_conversions.h" #include "base/values.h" @@ -45,8 +43,6 @@ const char kRTLHtmlTextDirection[] = "rtl"; const char kLTRHtmlTextDirection[] = "ltr"; -static base::LazyInstance<std::set<const WebUIController*> > g_live_new_tabs; - const char* GetHtmlTextDirection(const base::string16& text) { if (base::i18n::IsRTL() && base::i18n::StringContainsStrongRTLChars(text)) return kRTLHtmlTextDirection; @@ -61,7 +57,6 @@ NewTabUI::NewTabUI(content::WebUI* web_ui) : WebUIController(web_ui) { - g_live_new_tabs.Pointer()->insert(this); web_ui->OverrideTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); Profile* profile = GetProfile(); @@ -95,9 +90,7 @@ base::Unretained(this))); } -NewTabUI::~NewTabUI() { - g_live_new_tabs.Pointer()->erase(this); -} +NewTabUI::~NewTabUI() {} void NewTabUI::OnShowBookmarkBarChanged() { base::StringValue attached( @@ -114,6 +107,11 @@ } // static +bool NewTabUI::IsNewTab(const GURL& url) { + return url.GetOrigin() == GURL(chrome::kChromeUINewTabURL).GetOrigin(); +} + +// static bool NewTabUI::ShouldShowApps() { // Ash shows apps in app list thus should not show apps page in NTP4. #if defined(USE_ASH) @@ -164,13 +162,6 @@ dictionary->SetString("full_name_direction", GetHtmlTextDirection(full_name)); } -// static -NewTabUI* NewTabUI::FromWebUIController(WebUIController* ui) { - if (!g_live_new_tabs.Pointer()->count(ui)) - return NULL; - return static_cast<NewTabUI*>(ui); -} - Profile* NewTabUI::GetProfile() const { return Profile::FromWebUI(web_ui()); }
diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui.h b/chrome/browser/ui/webui/ntp/new_tab_ui.h index 99fd0ee..9124574 100644 --- a/chrome/browser/ui/webui/ntp/new_tab_ui.h +++ b/chrome/browser/ui/webui/ntp/new_tab_ui.h
@@ -33,6 +33,11 @@ static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); + // Checks whether the given URL points to an NTP WebUI. Note that this only + // applies to incognito and guest mode NTPs - you probably want to check + // search::NavEntryIsInstantNTP too! + static bool IsNewTab(const GURL& url); + // Returns whether or not to show apps pages. static bool ShouldShowApps(); @@ -48,10 +53,6 @@ static void SetFullNameAndDirection(const base::string16& full_name, base::DictionaryValue* dictionary); - // Returns a pointer to a NewTabUI if the WebUIController object is a new tab - // page. - static NewTabUI* FromWebUIController(content::WebUIController* ui); - private: class NewTabHTMLSource : public content::URLDataSource { public:
diff --git a/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc index 361fa0f..f90fbf7c 100644 --- a/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc +++ b/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc
@@ -566,8 +566,10 @@ {"onStartupOpenSpecific", IDS_SETTINGS_ON_STARTUP_OPEN_SPECIFIC}, {"onStartupUseCurrent", IDS_SETTINGS_ON_STARTUP_USE_CURRENT}, {"onStartupAddNewPage", IDS_SETTINGS_ON_STARTUP_ADD_NEW_PAGE}, + {"onStartupEditPage", IDS_SETTINGS_ON_STARTUP_EDIT_PAGE}, {"onStartupSiteUrl", IDS_SETTINGS_ON_STARTUP_SITE_URL}, {"onStartupRemove", IDS_SETTINGS_ON_STARTUP_REMOVE}, + {"onStartupEdit", IDS_SETTINGS_ON_STARTUP_EDIT}, }; AddLocalizedStringsBulk(html_source, localized_strings, arraysize(localized_strings));
diff --git a/chrome/test/base/mash_browser_tests_main.cc b/chrome/test/base/mash_browser_tests_main.cc index e3e7a8eb..0b52269 100644 --- a/chrome/test/base/mash_browser_tests_main.cc +++ b/chrome/test/base/mash_browser_tests_main.cc
@@ -24,7 +24,7 @@ namespace { -void ConnectToDefaultApps(mojo::Connector* connector) { +void ConnectToDefaultApps(shell::Connector* connector) { connector->Connect("mojo:mash_session"); } @@ -80,8 +80,8 @@ base::TestLauncher::LaunchOptions* test_launch_options) override { if (!mojo_test_connector_) { mojo_test_connector_.reset(new MojoTestConnector); - shell_client_.reset(new mojo::ShellClient); - shell_connection_.reset(new mojo::ShellConnection( + shell_client_.reset(new shell::ShellClient); + shell_connection_.reset(new shell::ShellConnection( shell_client_.get(), mojo_test_connector_->Init())); ConnectToDefaultApps(shell_connection_->connector()); } @@ -98,8 +98,8 @@ std::unique_ptr<MashTestSuite> test_suite_; std::unique_ptr<MojoTestConnector> mojo_test_connector_; - std::unique_ptr<mojo::ShellClient> shell_client_; - std::unique_ptr<mojo::ShellConnection> shell_connection_; + std::unique_ptr<shell::ShellClient> shell_client_; + std::unique_ptr<shell::ShellConnection> shell_connection_; DISALLOW_COPY_AND_ASSIGN(MashTestLauncherDelegate); }; @@ -124,12 +124,12 @@ if (command_line.HasSwitch(switches::kChildProcess) && !command_line.HasSwitch(MojoTestConnector::kTestSwitch)) { base::AtExitManager at_exit; - mojo::shell::InitializeLogging(); - mojo::shell::WaitForDebuggerIfNecessary(); + shell::InitializeLogging(); + shell::WaitForDebuggerIfNecessary(); #if !defined(OFFICIAL_BUILD) && defined(OS_WIN) base::RouteStdioToConsole(false); #endif - *exit_code = mojo::shell::ChildProcessMain(); + *exit_code = shell::ChildProcessMain(); return true; }
diff --git a/chrome/test/base/mojo_test_connector.cc b/chrome/test/base/mojo_test_connector.cc index 21fa403..123db3a 100644 --- a/chrome/test/base/mojo_test_connector.cc +++ b/chrome/test/base/mojo_test_connector.cc
@@ -29,8 +29,8 @@ #include "services/shell/shell.h" #include "services/shell/switches.h" -using mojo::shell::mojom::ShellClient; -using mojo::shell::mojom::ShellClientPtr; +using shell::mojom::ShellClient; +using shell::mojom::ShellClientPtr; namespace { @@ -54,10 +54,10 @@ // This builds a permissive catalog with the addition of the 'instance_name' // permission. -std::unique_ptr<mojo::shell::TestCatalogStore> BuildTestCatalogStore() { +std::unique_ptr<shell::TestCatalogStore> BuildTestCatalogStore() { std::unique_ptr<base::ListValue> apps(new base::ListValue); std::unique_ptr<base::DictionaryValue> test_app_config = - mojo::shell::BuildPermissiveSerializedAppInfo(kTestRunnerName, "test"); + shell::BuildPermissiveSerializedAppInfo(kTestRunnerName, "test"); base::DictionaryValue* capabilities = EnsureDictionary(test_app_config.get(), catalog::Store::kCapabilitiesKey); base::DictionaryValue* required_capabilities = @@ -70,7 +70,7 @@ std::move(required_shell_classes)); required_capabilities->Set("mojo:shell", std::move(shell_caps)); apps->Append(std::move(test_app_config)); - return base::WrapUnique(new mojo::shell::TestCatalogStore(std::move(apps))); + return base::WrapUnique(new shell::TestCatalogStore(std::move(apps))); } // BackgroundTestState maintains all the state necessary to bind the test to @@ -83,7 +83,7 @@ // Prepares the command line and other setup for connecting the test to mojo. // Must be paired with a clal to ChildProcessLaunched(). void Connect(base::CommandLine* command_line, - mojo::shell::Shell* shell, + shell::Shell* shell, const std::string& instance, base::TestLauncher::LaunchOptions* test_launch_options) { command_line->AppendSwitch(MojoTestConnector::kTestSwitch); @@ -103,17 +103,16 @@ #else #error "Unsupported" #endif - mojo::shell::mojom::ShellClientPtr client = - mojo::shell::PassShellClientRequestOnCommandLine(command_line); + shell::mojom::ShellClientPtr client = + shell::PassShellClientRequestOnCommandLine(command_line); - std::unique_ptr<mojo::shell::ConnectParams> params( - new mojo::shell::ConnectParams); - params->set_source(mojo::shell::CreateShellIdentity()); + std::unique_ptr<shell::ConnectParams> params(new shell::ConnectParams); + params->set_source(shell::CreateShellIdentity()); params->set_target( - mojo::Identity(kTestName, mojo::shell::mojom::kRootUserID, instance)); + shell::Identity(kTestName, shell::mojom::kRootUserID, instance)); - mojo::shell::mojom::ClientProcessConnectionPtr client_process_connection = - mojo::shell::mojom::ClientProcessConnection::New(); + shell::mojom::ClientProcessConnectionPtr client_process_connection = + shell::mojom::ClientProcessConnection::New(); client_process_connection->shell_client = client.PassInterface().PassHandle(); client_process_connection->pid_receiver_request = @@ -138,7 +137,7 @@ mojo::edk::HandlePassingInformation handle_passing_info_; - mojo::shell::mojom::PIDReceiverPtr pid_receiver_; + shell::mojom::PIDReceiverPtr pid_receiver_; DISALLOW_COPY_AND_ASSIGN(BackgroundTestState); }; @@ -146,13 +145,13 @@ // Called used destroy BackgroundTestState on the background thread. void DestroyBackgroundStateOnBackgroundThread( std::unique_ptr<BackgroundTestState> state, - mojo::shell::Shell* shell) {} + shell::Shell* shell) {} // State created per test. Manages creation of the corresponding // BackgroundTestState and making sure processing runs on the right threads. class MojoTestState : public content::TestState { public: - explicit MojoTestState(mojo::shell::BackgroundShell* background_shell) + explicit MojoTestState(shell::BackgroundShell* background_shell) : background_shell_(background_shell) {} ~MojoTestState() override { @@ -192,7 +191,7 @@ void ChildProcessLaunchedOnBackgroundThread(base::ProcessHandle handle, base::ProcessId pid, base::WaitableEvent* signal, - mojo::shell::Shell* shell) { + shell::Shell* shell) { background_state_->ChildProcessLaunched(handle, pid); signal->Signal(); } @@ -201,7 +200,7 @@ base::WaitableEvent* signal, base::CommandLine* command_line, base::TestLauncher::LaunchOptions* test_launch_options, - mojo::shell::Shell* shell) { + shell::Shell* shell) { static int instance_id = 0; const std::string instance_name = "instance-" + base::IntToString(instance_id++); @@ -211,7 +210,7 @@ signal->Signal(); } - mojo::shell::BackgroundShell* background_shell_; + shell::BackgroundShell* background_shell_; std::unique_ptr<BackgroundTestState> background_state_; DISALLOW_COPY_AND_ASSIGN(MojoTestState); @@ -220,15 +219,15 @@ } // namespace class MojoTestConnector::NativeRunnerDelegateImpl - : public mojo::shell::NativeRunnerDelegate { + : public shell::NativeRunnerDelegate { public: NativeRunnerDelegateImpl() {} ~NativeRunnerDelegateImpl() override {} private: - // mojo::shell::NativeRunnerDelegate: + // shell::NativeRunnerDelegate: void AdjustCommandLineArgumentsForTarget( - const mojo::Identity& target, + const shell::Identity& target, base::CommandLine* command_line) override { if (target.name() == "exe:chrome") command_line->AppendSwitch(switches::kWaitForMojoShell); @@ -242,10 +241,10 @@ MojoTestConnector::MojoTestConnector() {} -mojo::shell::mojom::ShellClientRequest MojoTestConnector::Init() { +shell::mojom::ShellClientRequest MojoTestConnector::Init() { native_runner_delegate_.reset(new NativeRunnerDelegateImpl); - std::unique_ptr<mojo::shell::BackgroundShell::InitParams> init_params( - new mojo::shell::BackgroundShell::InitParams); + std::unique_ptr<shell::BackgroundShell::InitParams> init_params( + new shell::BackgroundShell::InitParams); init_params->catalog_store = BuildTestCatalogStore(); // When running in single_process mode chrome initializes the edk. init_params->init_edk = !base::CommandLine::ForCurrentProcess()->HasSwitch(
diff --git a/chrome/test/base/mojo_test_connector.h b/chrome/test/base/mojo_test_connector.h index 9da36b1..31f4515b 100644 --- a/chrome/test/base/mojo_test_connector.h +++ b/chrome/test/base/mojo_test_connector.h
@@ -39,7 +39,7 @@ ~MojoTestConnector(); // Initializes the background thread the Shell runs on. - mojo::shell::mojom::ShellClientRequest Init(); + shell::mojom::ShellClientRequest Init(); std::unique_ptr<content::TestState> PrepareForTest( base::CommandLine* command_line, @@ -49,7 +49,7 @@ class NativeRunnerDelegateImpl; std::unique_ptr<NativeRunnerDelegateImpl> native_runner_delegate_; - mojo::shell::BackgroundShell background_shell_; + shell::BackgroundShell background_shell_; DISALLOW_COPY_AND_ASSIGN(MojoTestConnector); };
diff --git a/chrome/test/data/webui/settings/bluetooth_page_browsertest_chromeos.js b/chrome/test/data/webui/settings/bluetooth_page_browsertest_chromeos.js index 52e57e4..f9416cd 100644 --- a/chrome/test/data/webui/settings/bluetooth_page_browsertest_chromeos.js +++ b/chrome/test/data/webui/settings/bluetooth_page_browsertest_chromeos.js
@@ -130,13 +130,13 @@ // Set enabled, with default (empty) device list. self.bluetoothApi_.setEnabled(true); Polymer.dom.flush(); - // Ensure that initially the 'device list empty' span is visible. + // Ensure that initially the 'no devices' element is visible. expectFalse(deviceList.hidden); - var noDevices = deviceList.querySelector('span'); + var noDevices = deviceList.querySelector('.no-devices'); assertTrue(!!noDevices); expectFalse(noDevices.hidden); - // Set some devices (triggers onDeviceAdded events). 'empty' span should - // be hidden. + // Set some devices (triggers onDeviceAdded events). 'no devices' element + // should be hidden. self.bluetoothApi_.setDevicesForTest(fakeDevices_); Polymer.dom.flush(); expectTrue(noDevices.hidden); @@ -157,7 +157,7 @@ self.bluetoothApi_.setEnabled(true); // Tap the 'add device' button. - MockInteractions.tap(bluetooth.$.addDevice); + MockInteractions.tap(bluetooth.$$('.primary-button')); Polymer.dom.flush(); // Ensure the dialog appears. var dialog = bluetooth.$.deviceDialog;
diff --git a/chrome/test/data/webui/settings/startup_urls_page_test.js b/chrome/test/data/webui/settings/startup_urls_page_test.js index 54f98fa..53489dc6 100644 --- a/chrome/test/data/webui/settings/startup_urls_page_test.js +++ b/chrome/test/data/webui/settings/startup_urls_page_test.js
@@ -11,6 +11,7 @@ function TestStartupUrlsPageBrowserProxy() { settings.TestBrowserProxy.call(this, [ 'addStartupPage', + 'editStartupPage', 'loadStartupPages', 'removeStartupPage', 'useCurrentPages', @@ -36,6 +37,12 @@ }, /** @override */ + editStartupPage: function(modelIndex, url) { + this.methodCalled('editStartupPage', [modelIndex, url]); + return Promise.resolve(this.urlIsValid_); + }, + + /** @override */ loadStartupPages: function() { this.methodCalled('loadStartupPages'); }, @@ -78,21 +85,48 @@ settings.StartupUrlsPageBrowserProxyImpl.instance_ = browserProxy; PolymerTest.clearBody(); dialog = document.createElement('settings-startup-url-dialog'); - document.body.appendChild(dialog); }); teardown(function() { dialog.remove(); }); + test('Initialization_Add', function() { + document.body.appendChild(dialog); + assertTrue(dialog.$.dialog.opened); + + // Assert that the "Add" button is disabled. + var actionButton = dialog.$.actionButton; + assertTrue(!!actionButton); + assertTrue(actionButton.disabled); + + // Assert that the text field is empty. + var inputElement = dialog.$.url; + assertTrue(!!inputElement); + assertEquals('', inputElement.value); + }); + + test('Initialization_Edit', function() { + dialog.model = createSampleUrlEntry(); + document.body.appendChild(dialog); + assertTrue(dialog.$.dialog.opened); + + // Assert that the "Edit" button is enabled. + var actionButton = dialog.$.actionButton; + assertTrue(!!actionButton); + assertFalse(actionButton.disabled); + // Assert that the text field is pre-populated. + var inputElement = dialog.$.url; + assertTrue(!!inputElement); + assertEquals(dialog.model.url, inputElement.value); + }); + // Test that validation occurs as the user is typing, and that the action // button is updated accordingly. test('Validation', function() { - assertTrue(dialog.$.dialog.opened); - var addButton = dialog.$.add; - assertTrue(!!addButton); - assertTrue(addButton.disabled); + document.body.appendChild(dialog); + var actionButton = dialog.$.actionButton; + assertTrue(actionButton.disabled); var inputElement = dialog.$.url; - assertTrue(!!inputElement); var expectedUrl = "dummy-foo.com"; inputElement.value = expectedUrl; @@ -101,7 +135,7 @@ return browserProxy.whenCalled('validateStartupPage').then(function(url) { assertEquals(expectedUrl, url); - assertTrue(addButton.disabled); + assertTrue(actionButton.disabled); browserProxy.setUrlValidity(true); browserProxy.resetResolver('validateStartupPage'); @@ -109,30 +143,45 @@ return browserProxy.whenCalled('validateStartupPage'); }).then(function() { - assertFalse(addButton.disabled); + assertFalse(actionButton.disabled); }); }); - test('AddStartupPage', function() { - assertTrue(dialog.$.dialog.opened); - var addButton = dialog.$.add; - addButton.disabled = false; + /** + * Tests that the appropritae browser proxy method is called when the action + * button is tapped. + * @param {string} proxyMethodName + */ + function testProxyCalled(proxyMethodName) { + var actionButton = dialog.$.actionButton; + actionButton.disabled = false; // Test that the dialog remains open if the user somehow manages to submit // an invalid URL. browserProxy.setUrlValidity(false); - MockInteractions.tap(addButton); - return browserProxy.whenCalled('addStartupPage').then(function() { + MockInteractions.tap(actionButton); + return browserProxy.whenCalled(proxyMethodName).then(function() { assertTrue(dialog.$.dialog.opened); // Test that dialog is closed if the user submits a valid URL. browserProxy.setUrlValidity(true); - browserProxy.resetResolver('addStartupPage'); - MockInteractions.tap(addButton); - return browserProxy.whenCalled('addStartupPage'); + browserProxy.resetResolver(proxyMethodName); + MockInteractions.tap(actionButton); + return browserProxy.whenCalled(proxyMethodName); }).then(function() { assertFalse(dialog.$.dialog.opened); }); + } + + test('AddStartupPage', function() { + document.body.appendChild(dialog); + return testProxyCalled('addStartupPage'); + }); + + test('EditStartupPage', function() { + dialog.model = createSampleUrlEntry(); + document.body.appendChild(dialog); + return testProxyCalled('editStartupPage'); }); }); @@ -173,6 +222,13 @@ Polymer.dom.flush(); assertTrue(!!page.$$('settings-startup-url-dialog')); }); + + test('EditPage_OpensDialog', function() { + assertFalse(!!page.$$('settings-startup-url-dialog')); + page.fire(settings.EDIT_STARTUP_URL_EVENT, createSampleUrlEntry()); + Polymer.dom.flush(); + assertTrue(!!page.$$('settings-startup-url-dialog')); + }); }); /** @return {!StartupPageInfo} */
diff --git a/chromecast/browser/cast_content_browser_client.cc b/chromecast/browser/cast_content_browser_client.cc index 6bf5c92..3fe72b1 100644 --- a/chromecast/browser/cast_content_browser_client.cc +++ b/chromecast/browser/cast_content_browser_client.cc
@@ -68,14 +68,15 @@ namespace { #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) -static std::unique_ptr<mojo::ShellClient> CreateCastMojoMediaApplication( +static std::unique_ptr<shell::ShellClient> CreateCastMojoMediaApplication( CastContentBrowserClient* browser_client) { std::unique_ptr<media::CastMojoMediaClient> mojo_media_client( new media::CastMojoMediaClient( base::Bind(&CastContentBrowserClient::CreateMediaPipelineBackend, base::Unretained(browser_client)))); - return std::unique_ptr<mojo::ShellClient>(new media::CastMojoMediaApplication( - std::move(mojo_media_client), browser_client->GetMediaTaskRunner())); + return std::unique_ptr<shell::ShellClient>( + new media::CastMojoMediaApplication( + std::move(mojo_media_client), browser_client->GetMediaTaskRunner())); } #endif // ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS } // namespace
diff --git a/chromecast/browser/media/cast_mojo_media_application.cc b/chromecast/browser/media/cast_mojo_media_application.cc index 9f2295d..93addceb 100644 --- a/chromecast/browser/media/cast_mojo_media_application.cc +++ b/chromecast/browser/media/cast_mojo_media_application.cc
@@ -14,9 +14,9 @@ namespace { void CreateServiceFactory( mojo::InterfaceRequest<media::interfaces::ServiceFactory> request, - mojo::shell::mojom::InterfaceProvider* interfaces, + shell::mojom::InterfaceProvider* interfaces, scoped_refptr<media::MediaLog> media_log, - std::unique_ptr<mojo::MessageLoopRef> app_refcount, + std::unique_ptr<shell::MessageLoopRef> app_refcount, media::MojoMediaClient* mojo_media_client) { new ::media::ServiceFactoryImpl(std::move(request), interfaces, std::move(media_log), std::move(app_refcount), @@ -39,24 +39,25 @@ CastMojoMediaApplication::~CastMojoMediaApplication() {} -void CastMojoMediaApplication::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void CastMojoMediaApplication::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t /* id */) {} -bool CastMojoMediaApplication::AcceptConnection(mojo::Connection* connection) { +bool CastMojoMediaApplication::AcceptConnection(shell::Connection* connection) { connection->AddInterface<::media::interfaces::ServiceFactory>(this); return true; } void CastMojoMediaApplication::Create( - mojo::Connection* connection, + shell::Connection* connection, mojo::InterfaceRequest<::media::interfaces::ServiceFactory> request) { // Create the app refcount here on the application task runner so that // 1. It is bound to the application task runner, which in turn will // stop the app message loop when destroyed on the app task runner. // 2. It will prevent CastMojoMediaApplication from getting destroyed until // the task posted to the media thread is run. - std::unique_ptr<mojo::MessageLoopRef> app_refcount = ref_factory_.CreateRef(); + std::unique_ptr<shell::MessageLoopRef> app_refcount = + ref_factory_.CreateRef(); media_task_runner_->PostTask( FROM_HERE, base::Bind(&CreateServiceFactory, base::Passed(&request),
diff --git a/chromecast/browser/media/cast_mojo_media_application.h b/chromecast/browser/media/cast_mojo_media_application.h index 7636000a..e2b7367 100644 --- a/chromecast/browser/media/cast_mojo_media_application.h +++ b/chromecast/browser/media/cast_mojo_media_application.h
@@ -27,8 +27,8 @@ class CastMojoMediaClient; class CastMojoMediaApplication - : public mojo::ShellClient, - public mojo::InterfaceFactory<::media::interfaces::ServiceFactory> { + : public shell::ShellClient, + public shell::InterfaceFactory<::media::interfaces::ServiceFactory> { public: CastMojoMediaApplication( std::unique_ptr<CastMojoMediaClient> mojo_media_client, @@ -36,21 +36,21 @@ ~CastMojoMediaApplication() final; private: - // mojo::ShellClient implementation. - void Initialize(mojo::Connector* connector, - const mojo::Identity& identity, + // shell::ShellClient implementation. + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) final; - bool AcceptConnection(mojo::Connection* connection) final; + bool AcceptConnection(shell::Connection* connection) final; - // mojo::InterfaceFactory<interfaces::ServiceFactory> implementation. - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<interfaces::ServiceFactory> implementation. + void Create(shell::Connection* connection, mojo::InterfaceRequest<::media::interfaces::ServiceFactory> request) final; std::unique_ptr<CastMojoMediaClient> mojo_media_client_; scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; scoped_refptr<::media::MediaLog> media_log_; - mojo::MessageLoopRefFactory ref_factory_; + shell::MessageLoopRefFactory ref_factory_; }; } // namespace media
diff --git a/chromeos/CHROMEOS_LKGM b/chromeos/CHROMEOS_LKGM index 881e6f8..483930e 100644 --- a/chromeos/CHROMEOS_LKGM +++ b/chromeos/CHROMEOS_LKGM
@@ -1 +1 @@ -8184.0.0 \ No newline at end of file +8186.0.0 \ No newline at end of file
diff --git a/chromeos/cryptohome/system_salt_getter.cc b/chromeos/cryptohome/system_salt_getter.cc index 0e79fc12..5109f107 100644 --- a/chromeos/cryptohome/system_salt_getter.cc +++ b/chromeos/cryptohome/system_salt_getter.cc
@@ -42,6 +42,15 @@ callback)); } +const SystemSaltGetter::RawSalt* SystemSaltGetter::GetRawSalt() const { + return raw_salt_.empty() ? nullptr : &raw_salt_; +} + +void SystemSaltGetter::SetRawSaltForTesting( + const SystemSaltGetter::RawSalt& raw_salt) { + raw_salt_ = raw_salt; +} + void SystemSaltGetter::DidWaitForServiceToBeAvailable( const GetSystemSaltCallback& callback, bool service_is_available) {
diff --git a/chromeos/cryptohome/system_salt_getter.h b/chromeos/cryptohome/system_salt_getter.h index 8654e50..a42dd25 100644 --- a/chromeos/cryptohome/system_salt_getter.h +++ b/chromeos/cryptohome/system_salt_getter.h
@@ -24,6 +24,8 @@ typedef base::Callback<void(const std::string& system_salt)> GetSystemSaltCallback; + using RawSalt = std::vector<uint8_t>; + // Manage an explicitly initialized global instance. static void Initialize(); static bool IsInitialized(); @@ -31,13 +33,19 @@ static SystemSaltGetter* Get(); // Converts |salt| to a hex encoded string. - static std::string ConvertRawSaltToHexString( - const std::vector<uint8_t>& salt); + static std::string ConvertRawSaltToHexString(const RawSalt& salt); // Returns system hash in hex encoded ascii format. Note: this may return // an empty string (e.g. errors in D-Bus layer) void GetSystemSalt(const GetSystemSaltCallback& callback); + // Returns pointer to binary system salt if it is already known. + // Returns nullptr if system salt is not known. + const RawSalt* GetRawSalt() const; + + // This is for browser tests API. + void SetRawSaltForTesting(const RawSalt& raw_salt); + protected: SystemSaltGetter(); ~SystemSaltGetter(); @@ -48,8 +56,9 @@ bool service_is_available); void DidGetSystemSalt(const GetSystemSaltCallback& callback, DBusMethodCallStatus call_status, - const std::vector<uint8_t>& system_salt); + const RawSalt& system_salt); + RawSalt raw_salt_; std::string system_salt_; base::WeakPtrFactory<SystemSaltGetter> weak_ptr_factory_;
diff --git a/components/bitmap_uploader/bitmap_uploader.cc b/components/bitmap_uploader/bitmap_uploader.cc index a0029fc..1b8a073 100644 --- a/components/bitmap_uploader/bitmap_uploader.cc +++ b/components/bitmap_uploader/bitmap_uploader.cc
@@ -45,7 +45,7 @@ MojoGLES2DestroyContext(gles2_context_); } -void BitmapUploader::Init(mojo::Connector* connector) { +void BitmapUploader::Init(shell::Connector* connector) { surface_ = window_->RequestSurface(mus::mojom::SurfaceType::DEFAULT); surface_->BindToThread(); surface_->set_client(this);
diff --git a/components/bitmap_uploader/bitmap_uploader.h b/components/bitmap_uploader/bitmap_uploader.h index 48efe00..37ae1d0 100644 --- a/components/bitmap_uploader/bitmap_uploader.h +++ b/components/bitmap_uploader/bitmap_uploader.h
@@ -19,7 +19,7 @@ #include "gpu/GLES2/gl2extchromium.h" #include "mojo/public/c/gles2/gles2.h" -namespace mojo { +namespace shell { class Connector; } @@ -35,7 +35,7 @@ explicit BitmapUploader(mus::Window* window); ~BitmapUploader() override; - void Init(mojo::Connector* connector); + void Init(shell::Connector* connector); // Sets the color which is RGBA. void SetColor(uint32_t color);
diff --git a/components/filesystem/file_system_app.cc b/components/filesystem/file_system_app.cc index a74eb78..14408e8 100644 --- a/components/filesystem/file_system_app.cc +++ b/components/filesystem/file_system_app.cc
@@ -37,19 +37,19 @@ FileSystemApp::~FileSystemApp() {} -void FileSystemApp::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void FileSystemApp::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { tracing_.Initialize(connector, identity.name()); } -bool FileSystemApp::AcceptConnection(mojo::Connection* connection) { +bool FileSystemApp::AcceptConnection(shell::Connection* connection) { connection->AddInterface<FileSystem>(this); return true; } // |InterfaceFactory<Files>| implementation: -void FileSystemApp::Create(mojo::Connection* connection, +void FileSystemApp::Create(shell::Connection* connection, mojo::InterfaceRequest<FileSystem> request) { new FileSystemImpl(connection, std::move(request), GetUserDataDir(), lock_table_);
diff --git a/components/filesystem/file_system_app.h b/components/filesystem/file_system_app.h index 62b2c70..fa3e2d92 100644 --- a/components/filesystem/file_system_app.h +++ b/components/filesystem/file_system_app.h
@@ -20,8 +20,8 @@ namespace filesystem { -class FileSystemApp : public mojo::ShellClient, - public mojo::InterfaceFactory<FileSystem> { +class FileSystemApp : public shell::ShellClient, + public shell::InterfaceFactory<FileSystem> { public: FileSystemApp(); ~FileSystemApp() override; @@ -30,12 +30,13 @@ // Gets the system specific toplevel profile directory. static base::FilePath GetUserDataDir(); - // |mojo::ShellClient| override: - void Initialize(mojo::Connector* connector, const mojo::Identity& identity, + // |shell::ShellClient| override: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; // |InterfaceFactory<Files>| implementation: - void Create(mojo::Connection* connection, + void Create(shell::Connection* connection, mojo::InterfaceRequest<FileSystem> request) override; mojo::TracingImpl tracing_;
diff --git a/components/filesystem/file_system_impl.cc b/components/filesystem/file_system_impl.cc index 18ae573..9b308bb 100644 --- a/components/filesystem/file_system_impl.cc +++ b/components/filesystem/file_system_impl.cc
@@ -21,8 +21,8 @@ namespace filesystem { -FileSystemImpl::FileSystemImpl(mojo::Connection* connection, - mojo::InterfaceRequest<FileSystem> request, +FileSystemImpl::FileSystemImpl(shell::Connection* connection, + FileSystemRequest request, base::FilePath persistent_dir, scoped_refptr<LockTable> lock_table) : remote_application_name_(connection->GetRemoteIdentity().name()),
diff --git a/components/filesystem/file_system_impl.h b/components/filesystem/file_system_impl.h index ff5d9bc4..30a6e20 100644 --- a/components/filesystem/file_system_impl.h +++ b/components/filesystem/file_system_impl.h
@@ -15,7 +15,7 @@ class FilePath; } -namespace mojo { +namespace shell { class Connection; } @@ -29,7 +29,7 @@ public: // |persistent_dir| is the directory served to callers of // |OpenPersistentFileSystem(). - FileSystemImpl(mojo::Connection* connection, + FileSystemImpl(shell::Connection* connection, mojo::InterfaceRequest<FileSystem> request, base::FilePath persistent_dir, scoped_refptr<LockTable> lock_table);
diff --git a/components/filesystem/files_test_base.h b/components/filesystem/files_test_base.h index c990236..54f2e32 100644 --- a/components/filesystem/files_test_base.h +++ b/components/filesystem/files_test_base.h
@@ -12,12 +12,12 @@ namespace filesystem { -class FilesTestBase : public mojo::test::ShellTest { +class FilesTestBase : public shell::test::ShellTest { public: FilesTestBase(); ~FilesTestBase() override; - // Overridden from mojo::test::ShellTest: + // Overridden from shell::test::ShellTest: void SetUp() override; protected:
diff --git a/components/filesystem/main.cc b/components/filesystem/main.cc index 5174889..f73576e6 100644 --- a/components/filesystem/main.cc +++ b/components/filesystem/main.cc
@@ -8,6 +8,6 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle request) { - mojo::ApplicationRunner runner(new filesystem::FileSystemApp()); + shell::ApplicationRunner runner(new filesystem::FileSystemApp()); return runner.Run(request); }
diff --git a/components/filesystem/public/cpp/prefs/pref_service_factory.cc b/components/filesystem/public/cpp/prefs/pref_service_factory.cc index d3cd0cc..67871add 100644 --- a/components/filesystem/public/cpp/prefs/pref_service_factory.cc +++ b/components/filesystem/public/cpp/prefs/pref_service_factory.cc
@@ -23,7 +23,7 @@ } // namespace -scoped_ptr<PrefService> CreatePrefService(mojo::Connector* connector, +scoped_ptr<PrefService> CreatePrefService(shell::Connector* connector, PrefRegistry* pref_registry) { filesystem::FileSystemPtr filesystem; connector->ConnectToInterface("mojo:filesystem", &filesystem);
diff --git a/components/filesystem/public/cpp/prefs/pref_service_factory.h b/components/filesystem/public/cpp/prefs/pref_service_factory.h index 23ee9ff..55b4ad6d 100644 --- a/components/filesystem/public/cpp/prefs/pref_service_factory.h +++ b/components/filesystem/public/cpp/prefs/pref_service_factory.h
@@ -19,7 +19,7 @@ // This factory method creates a PrefService for the local process based on the // preference registry passed in. This PrefService will synchronize with a JSON // file in the mojo:filesystem. -scoped_ptr<PrefService> CreatePrefService(mojo::Connector* connector, +scoped_ptr<PrefService> CreatePrefService(shell::Connector* connector, PrefRegistry* registry); } // namespace filesystem
diff --git a/components/font_service/font_service_app.cc b/components/font_service/font_service_app.cc index f4d17086..ae87c8d 100644 --- a/components/font_service/font_service_app.cc +++ b/components/font_service/font_service_app.cc
@@ -51,18 +51,18 @@ FontServiceApp::~FontServiceApp() {} -void FontServiceApp::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void FontServiceApp::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { tracing_.Initialize(connector, identity.name()); } -bool FontServiceApp::AcceptConnection(mojo::Connection* connection) { +bool FontServiceApp::AcceptConnection(shell::Connection* connection) { connection->AddInterface(this); return true; } -void FontServiceApp::Create(mojo::Connection* connection, +void FontServiceApp::Create(shell::Connection* connection, mojo::InterfaceRequest<FontService> request) { bindings_.AddBinding(this, std::move(request)); }
diff --git a/components/font_service/font_service_app.h b/components/font_service/font_service_app.h index da89269..53a3b0b4 100644 --- a/components/font_service/font_service_app.h +++ b/components/font_service/font_service_app.h
@@ -18,21 +18,22 @@ namespace font_service { -class FontServiceApp : public mojo::ShellClient, - public mojo::InterfaceFactory<FontService>, +class FontServiceApp : public shell::ShellClient, + public shell::InterfaceFactory<FontService>, public FontService { public: FontServiceApp(); ~FontServiceApp() override; private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; - // mojo::InterfaceFactory<FontService>: - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<FontService>: + void Create(shell::Connection* connection, mojo::InterfaceRequest<FontService> request) override; // FontService:
diff --git a/components/font_service/main.cc b/components/font_service/main.cc index e513244..698358c 100644 --- a/components/font_service/main.cc +++ b/components/font_service/main.cc
@@ -7,6 +7,6 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner(new font_service::FontServiceApp); + shell::ApplicationRunner runner(new font_service::FontServiceApp); return runner.Run(shell_handle); }
diff --git a/components/font_service/public/cpp/font_loader.cc b/components/font_service/public/cpp/font_loader.cc index b70a802..b6d8af0a 100644 --- a/components/font_service/public/cpp/font_loader.cc +++ b/components/font_service/public/cpp/font_loader.cc
@@ -13,7 +13,7 @@ namespace font_service { -FontLoader::FontLoader(mojo::Connector* connector) { +FontLoader::FontLoader(shell::Connector* connector) { FontServicePtr font_service; connector->ConnectToInterface("mojo:font_service", &font_service); thread_ = new internal::FontServiceThread(std::move(font_service));
diff --git a/components/font_service/public/cpp/font_loader.h b/components/font_service/public/cpp/font_loader.h index ba79e09..add2f4f0 100644 --- a/components/font_service/public/cpp/font_loader.h +++ b/components/font_service/public/cpp/font_loader.h
@@ -17,7 +17,7 @@ #include "third_party/skia/include/core/SkTypeface.h" #include "third_party/skia/include/ports/SkFontConfigInterface.h" -namespace mojo { +namespace shell { class Connector; } @@ -35,7 +35,7 @@ class FontLoader : public SkFontConfigInterface, public internal::MappedFontFile::Observer { public: - explicit FontLoader(mojo::Connector* connector); + explicit FontLoader(shell::Connector* connector); ~FontLoader() override; // Shuts down the background thread.
diff --git a/components/leveldb/leveldb_app.cc b/components/leveldb/leveldb_app.cc index 192c8ff5..6612625 100644 --- a/components/leveldb/leveldb_app.cc +++ b/components/leveldb/leveldb_app.cc
@@ -14,18 +14,18 @@ LevelDBApp::~LevelDBApp() {} -void LevelDBApp::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void LevelDBApp::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { tracing_.Initialize(connector, identity.name()); } -bool LevelDBApp::AcceptConnection(mojo::Connection* connection) { +bool LevelDBApp::AcceptConnection(shell::Connection* connection) { connection->AddInterface<LevelDBService>(this); return true; } -void LevelDBApp::Create(mojo::Connection* connection, +void LevelDBApp::Create(shell::Connection* connection, leveldb::LevelDBServiceRequest request) { if (!service_) service_.reset(
diff --git a/components/leveldb/leveldb_app.h b/components/leveldb/leveldb_app.h index 5c127a1..829bc2c2 100644 --- a/components/leveldb/leveldb_app.h +++ b/components/leveldb/leveldb_app.h
@@ -13,21 +13,21 @@ namespace leveldb { -class LevelDBApp : public mojo::ShellClient, - public mojo::InterfaceFactory<LevelDBService> { +class LevelDBApp : public shell::ShellClient, + public shell::InterfaceFactory<LevelDBService> { public: LevelDBApp(); ~LevelDBApp() override; private: // |ShellClient| override: - void Initialize(mojo::Connector* connector, - const mojo::Identity& identity, + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; // |InterfaceFactory<LevelDBService>| implementation: - void Create(mojo::Connection* connection, + void Create(shell::Connection* connection, leveldb::LevelDBServiceRequest request) override; mojo::TracingImpl tracing_;
diff --git a/components/leveldb/leveldb_service_unittest.cc b/components/leveldb/leveldb_service_unittest.cc index 6acd0f85..785478b 100644 --- a/components/leveldb/leveldb_service_unittest.cc +++ b/components/leveldb/leveldb_service_unittest.cc
@@ -19,7 +19,7 @@ namespace leveldb { namespace { -class LevelDBServiceTest : public mojo::test::ShellTest { +class LevelDBServiceTest : public shell::test::ShellTest { public: LevelDBServiceTest() : ShellTest("exe:leveldb_service_unittests") {} ~LevelDBServiceTest() override {}
diff --git a/components/leveldb/main.cc b/components/leveldb/main.cc index d16a21a3..7e5c9fb4 100644 --- a/components/leveldb/main.cc +++ b/components/leveldb/main.cc
@@ -8,6 +8,6 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle application_request) { - mojo::ApplicationRunner runner(new leveldb::LevelDBApp()); + shell::ApplicationRunner runner(new leveldb::LevelDBApp()); return runner.Run(application_request); }
diff --git a/components/leveldb/remote_iterator_unittest.cc b/components/leveldb/remote_iterator_unittest.cc index 93b5f0b..3aad423 100644 --- a/components/leveldb/remote_iterator_unittest.cc +++ b/components/leveldb/remote_iterator_unittest.cc
@@ -17,7 +17,7 @@ namespace leveldb { namespace { -class RemoteIteratorTest : public mojo::test::ShellTest { +class RemoteIteratorTest : public shell::test::ShellTest { public: RemoteIteratorTest() : ShellTest("exe:leveldb_service_unittests") {} ~RemoteIteratorTest() override {}
diff --git a/components/mus/demo/main.cc b/components/mus/demo/main.cc index 30f5a0b9..62be1b7d 100644 --- a/components/mus/demo/main.cc +++ b/components/mus/demo/main.cc
@@ -7,7 +7,7 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner(new mus_demo::MusDemo); + shell::ApplicationRunner runner(new mus_demo::MusDemo); runner.set_message_loop_type(base::MessageLoop::TYPE_UI); return runner.Run(shell_handle); }
diff --git a/components/mus/demo/mus_demo.cc b/components/mus/demo/mus_demo.cc index 0f9e369..32a23ff3 100644 --- a/components/mus/demo/mus_demo.cc +++ b/components/mus/demo/mus_demo.cc
@@ -58,8 +58,8 @@ MusDemo::~MusDemo() {} -void MusDemo::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void MusDemo::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { connector_ = connector; @@ -67,7 +67,7 @@ window_tree_host_->SetTitle("MUS Demo"); } -bool MusDemo::AcceptConnection(mojo::Connection* connection) { +bool MusDemo::AcceptConnection(shell::Connection* connection) { return true; }
diff --git a/components/mus/demo/mus_demo.h b/components/mus/demo/mus_demo.h index 71779bb..3c5268c 100644 --- a/components/mus/demo/mus_demo.h +++ b/components/mus/demo/mus_demo.h
@@ -31,7 +31,7 @@ // A simple MUS Demo mojo app. This app connects to the mojo:mus, creates a new // window and draws a spinning square in the center of the window. Provides a // simple way to demonstrate that the graphic stack works as intended. -class MusDemo : public mojo::ShellClient, +class MusDemo : public shell::ShellClient, public mus::WindowTreeDelegate, public mus::WindowManagerDelegate { public: @@ -39,11 +39,11 @@ ~MusDemo() override; private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, - const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; // WindowTreeDelegate: void OnEmbed(mus::Window* root) override; @@ -66,7 +66,7 @@ // Draws one frame, incrementing the rotation angle. void DrawFrame(); - mojo::Connector* connector_ = nullptr; + shell::Connector* connector_ = nullptr; mus::Window* window_ = nullptr; mus::mojom::WindowTreeHostPtr window_tree_host_;
diff --git a/components/mus/main.cc b/components/mus/main.cc index 134bb72..3486f41 100644 --- a/components/mus/main.cc +++ b/components/mus/main.cc
@@ -7,7 +7,7 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner(new mus::MandolineUIServicesApp); + shell::ApplicationRunner runner(new mus::MandolineUIServicesApp); runner.set_message_loop_type(base::MessageLoop::TYPE_UI); return runner.Run(shell_handle); }
diff --git a/components/mus/mus_app.cc b/components/mus/mus_app.cc index 4323fc5a..40cc5423 100644 --- a/components/mus/mus_app.cc +++ b/components/mus/mus_app.cc
@@ -42,7 +42,7 @@ #include "ui/ozone/public/ozone_platform.h" #endif -using mojo::Connection; +using shell::Connection; using mojo::InterfaceRequest; using mus::mojom::WindowTreeHostFactory; using mus::mojom::Gpu; @@ -59,7 +59,7 @@ // TODO(sky): this is a pretty typical pattern, make it easier to do. struct MandolineUIServicesApp::PendingRequest { - mojo::Connection* connection; + shell::Connection* connection; scoped_ptr<mojo::InterfaceRequest<mojom::WindowTreeFactory>> wtf_request; }; @@ -80,7 +80,7 @@ platform_display_init_params_.gpu_state->StopThreads(); } -void MandolineUIServicesApp::InitializeResources(mojo::Connector* connector) { +void MandolineUIServicesApp::InitializeResources(shell::Connector* connector) { if (ui::ResourceBundle::HasSharedInstance()) return; @@ -106,7 +106,7 @@ } MandolineUIServicesApp::UserState* MandolineUIServicesApp::GetUserState( - mojo::Connection* connection) { + shell::Connection* connection) { const ws::UserId& user_id = connection->GetRemoteIdentity().user_id(); auto it = user_id_to_user_state_.find(user_id); if (it != user_id_to_user_state_.end()) @@ -115,13 +115,13 @@ return user_id_to_user_state_[user_id].get(); } -void MandolineUIServicesApp::AddUserIfNecessary(mojo::Connection* connection) { +void MandolineUIServicesApp::AddUserIfNecessary(shell::Connection* connection) { window_server_->user_id_tracker()->AddUserId( connection->GetRemoteIdentity().user_id()); } -void MandolineUIServicesApp::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void MandolineUIServicesApp::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { platform_display_init_params_.connector = connector; platform_display_init_params_.surfaces_state = new SurfacesState; @@ -197,20 +197,20 @@ host_impl->Init(nullptr); } -void MandolineUIServicesApp::Create(mojo::Connection* connection, +void MandolineUIServicesApp::Create(shell::Connection* connection, mojom::DisplayManagerRequest request) { window_server_->display_manager() ->GetUserDisplayManager(connection->GetRemoteIdentity().user_id()) ->AddDisplayManagerBinding(std::move(request)); } -void MandolineUIServicesApp::Create(mojo::Connection* connection, +void MandolineUIServicesApp::Create(shell::Connection* connection, mojom::UserAccessManagerRequest request) { window_server_->user_id_tracker()->Bind(std::move(request)); } void MandolineUIServicesApp::Create( - mojo::Connection* connection, + shell::Connection* connection, mojom::WindowManagerFactoryServiceRequest request) { AddUserIfNecessary(connection); window_server_->window_manager_factory_registry()->Register( @@ -250,7 +250,7 @@ user_state->window_tree_host_factory->AddBinding(std::move(request)); } -void MandolineUIServicesApp::Create(mojo::Connection* connection, +void MandolineUIServicesApp::Create(shell::Connection* connection, mojom::GpuRequest request) { DCHECK(platform_display_init_params_.gpu_state); new GpuImpl(std::move(request), platform_display_init_params_.gpu_state);
diff --git a/components/mus/mus_app.h b/components/mus/mus_app.h index 289faca..e90311a4 100644 --- a/components/mus/mus_app.h +++ b/components/mus/mus_app.h
@@ -26,7 +26,7 @@ #include "services/shell/public/cpp/shell_client.h" #include "services/tracing/public/cpp/tracing_impl.h" -namespace mojo { +namespace shell { class Connector; } @@ -41,14 +41,14 @@ } class MandolineUIServicesApp - : public mojo::ShellClient, + : public shell::ShellClient, public ws::WindowServerDelegate, - public mojo::InterfaceFactory<mojom::DisplayManager>, - public mojo::InterfaceFactory<mojom::UserAccessManager>, - public mojo::InterfaceFactory<mojom::WindowManagerFactoryService>, - public mojo::InterfaceFactory<mojom::WindowTreeFactory>, - public mojo::InterfaceFactory<mojom::WindowTreeHostFactory>, - public mojo::InterfaceFactory<mojom::Gpu> { + public shell::InterfaceFactory<mojom::DisplayManager>, + public shell::InterfaceFactory<mojom::UserAccessManager>, + public shell::InterfaceFactory<mojom::WindowManagerFactoryService>, + public shell::InterfaceFactory<mojom::WindowTreeFactory>, + public shell::InterfaceFactory<mojom::WindowTreeHostFactory>, + public shell::InterfaceFactory<mojom::Gpu> { public: MandolineUIServicesApp(); ~MandolineUIServicesApp() override; @@ -61,48 +61,50 @@ using UserIdToUserState = std::map<ws::UserId, scoped_ptr<UserState>>; - void InitializeResources(mojo::Connector* connector); + void InitializeResources(shell::Connector* connector); // Returns the user specific state for the user id of |connection|. MusApp // owns the return value. // TODO(sky): if we allow removal of user ids then we need to close anything // associated with the user (all incoming pipes...) on removal. - UserState* GetUserState(mojo::Connection* connection); + UserState* GetUserState(shell::Connection* connection); - void AddUserIfNecessary(mojo::Connection* connection); + void AddUserIfNecessary(shell::Connection* connection); - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; // WindowServerDelegate: void OnFirstDisplayReady() override; void OnNoMoreDisplays() override; void CreateDefaultDisplays() override; - // mojo::InterfaceFactory<mojom::DisplayManager> implementation. - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<mojom::DisplayManager> implementation. + void Create(shell::Connection* connection, mojom::DisplayManagerRequest request) override; - // mojo::InterfaceFactory<mojom::UserAccessManager> implementation. - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<mojom::UserAccessManager> implementation. + void Create(shell::Connection* connection, mojom::UserAccessManagerRequest request) override; - // mojo::InterfaceFactory<mojom::WindowManagerFactoryService> implementation. - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<mojom::WindowManagerFactoryService> implementation. + void Create(shell::Connection* connection, mojom::WindowManagerFactoryServiceRequest request) override; - // mojo::InterfaceFactory<mojom::WindowTreeFactory>: - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<mojom::WindowTreeFactory>: + void Create(shell::Connection* connection, mojom::WindowTreeFactoryRequest request) override; - // mojo::InterfaceFactory<mojom::WindowTreeHostFactory>: - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<mojom::WindowTreeHostFactory>: + void Create(shell::Connection* connection, mojom::WindowTreeHostFactoryRequest request) override; - // mojo::InterfaceFactory<mojom::Gpu> implementation. - void Create(mojo::Connection* connection, mojom::GpuRequest request) override; + // shell::InterfaceFactory<mojom::Gpu> implementation. + void Create(shell::Connection* connection, + mojom::GpuRequest request) override; ws::PlatformDisplayInitParams platform_display_init_params_; scoped_ptr<ws::WindowServer> window_server_;
diff --git a/components/mus/public/cpp/lib/window_tree_client_impl.cc b/components/mus/public/cpp/lib/window_tree_client_impl.cc index 520b9de..9b199da 100644 --- a/components/mus/public/cpp/lib/window_tree_client_impl.cc +++ b/components/mus/public/cpp/lib/window_tree_client_impl.cc
@@ -85,8 +85,9 @@ return root; } -WindowTreeConnection* WindowTreeConnection::Create(WindowTreeDelegate* delegate, - mojo::Connector* connector) { +WindowTreeConnection* WindowTreeConnection::Create( + WindowTreeDelegate* delegate, + shell::Connector* connector) { WindowTreeClientImpl* client = new WindowTreeClientImpl(delegate, nullptr, nullptr); client->ConnectViaWindowTreeFactory(connector); @@ -164,7 +165,7 @@ } void WindowTreeClientImpl::ConnectViaWindowTreeFactory( - mojo::Connector* connector) { + shell::Connector* connector) { // Clients created with no root shouldn't delete automatically. delete_on_no_roots_ = false;
diff --git a/components/mus/public/cpp/lib/window_tree_client_impl.h b/components/mus/public/cpp/lib/window_tree_client_impl.h index 09050de3..3d8d765 100644 --- a/components/mus/public/cpp/lib/window_tree_client_impl.h +++ b/components/mus/public/cpp/lib/window_tree_client_impl.h
@@ -45,7 +45,7 @@ ~WindowTreeClientImpl() override; // Establishes the connection by way of the WindowTreeFactory. - void ConnectViaWindowTreeFactory(mojo::Connector* connector); + void ConnectViaWindowTreeFactory(shell::Connector* connector); // Wait for OnEmbed(), returning when done. void WaitForEmbed();
diff --git a/components/mus/public/cpp/lib/window_tree_host_factory.cc b/components/mus/public/cpp/lib/window_tree_host_factory.cc index 12b9780..7e93468 100644 --- a/components/mus/public/cpp/lib/window_tree_host_factory.cc +++ b/components/mus/public/cpp/lib/window_tree_host_factory.cc
@@ -22,7 +22,7 @@ factory->CreateWindowTreeHost(GetProxy(host), std::move(tree_client)); } -void CreateWindowTreeHost(mojo::Connector* connector, +void CreateWindowTreeHost(shell::Connector* connector, WindowTreeDelegate* delegate, mojom::WindowTreeHostPtr* host, WindowManagerDelegate* window_manager_delegate) {
diff --git a/components/mus/public/cpp/tests/window_server_shelltest_base.cc b/components/mus/public/cpp/tests/window_server_shelltest_base.cc index 74197fa1..3f97150 100644 --- a/components/mus/public/cpp/tests/window_server_shelltest_base.cc +++ b/components/mus/public/cpp/tests/window_server_shelltest_base.cc
@@ -18,15 +18,15 @@ const char kTestAppName[] = "mojo:mus_ws_unittests_app"; -class WindowServerShellTestClient : public mojo::test::ShellTestClient { +class WindowServerShellTestClient : public shell::test::ShellTestClient { public: explicit WindowServerShellTestClient(WindowServerShellTestBase* test) : ShellTestClient(test), test_(test) {} ~WindowServerShellTestClient() override {} private: - // mojo::test::ShellTestClient: - bool AcceptConnection(mojo::Connection* connection) override { + // shell::test::ShellTestClient: + bool AcceptConnection(shell::Connection* connection) override { return test_->AcceptConnection(connection); } @@ -51,7 +51,7 @@ WindowServerShellTestBase::~WindowServerShellTestBase() {} -scoped_ptr<mojo::ShellClient> WindowServerShellTestBase::CreateShellClient() { +scoped_ptr<shell::ShellClient> WindowServerShellTestBase::CreateShellClient() { return make_scoped_ptr(new WindowServerShellTestClient(this)); }
diff --git a/components/mus/public/cpp/tests/window_server_shelltest_base.h b/components/mus/public/cpp/tests/window_server_shelltest_base.h index 173fa81..f03f65c 100644 --- a/components/mus/public/cpp/tests/window_server_shelltest_base.h +++ b/components/mus/public/cpp/tests/window_server_shelltest_base.h
@@ -12,16 +12,16 @@ namespace mus { // Base class for all window manager shelltests to perform some common setup. -class WindowServerShellTestBase : public mojo::test::ShellTest { +class WindowServerShellTestBase : public shell::test::ShellTest { public: WindowServerShellTestBase(); ~WindowServerShellTestBase() override; - virtual bool AcceptConnection(mojo::Connection* connection) = 0; + virtual bool AcceptConnection(shell::Connection* connection) = 0; private: - // mojo::test::ShellTest: - scoped_ptr<mojo::ShellClient> CreateShellClient() override; + // shell::test::ShellTest: + scoped_ptr<shell::ShellClient> CreateShellClient() override; DISALLOW_COPY_AND_ASSIGN(WindowServerShellTestBase); };
diff --git a/components/mus/public/cpp/tests/window_server_test_base.cc b/components/mus/public/cpp/tests/window_server_test_base.cc index 1cc440c0..90e9738 100644 --- a/components/mus/public/cpp/tests/window_server_test_base.cc +++ b/components/mus/public/cpp/tests/window_server_test_base.cc
@@ -71,7 +71,7 @@ std::swap(window_manager_, most_recent_connection_); } -bool WindowServerTestBase::AcceptConnection(mojo::Connection* connection) { +bool WindowServerTestBase::AcceptConnection(shell::Connection* connection) { connection->AddInterface<mojom::WindowTreeClient>(this); return true; } @@ -119,7 +119,7 @@ } void WindowServerTestBase::Create( - mojo::Connection* connection, + shell::Connection* connection, mojo::InterfaceRequest<mojom::WindowTreeClient> request) { WindowTreeConnection::Create( this, std::move(request),
diff --git a/components/mus/public/cpp/tests/window_server_test_base.h b/components/mus/public/cpp/tests/window_server_test_base.h index 5d98fa5..b47ea4c 100644 --- a/components/mus/public/cpp/tests/window_server_test_base.h +++ b/components/mus/public/cpp/tests/window_server_test_base.h
@@ -24,7 +24,7 @@ : public WindowServerShellTestBase, public WindowTreeDelegate, public WindowManagerDelegate, - public mojo::InterfaceFactory<mojom::WindowTreeClient> { + public shell::InterfaceFactory<mojom::WindowTreeClient> { public: WindowServerTestBase(); ~WindowServerTestBase() override; @@ -62,7 +62,7 @@ void SetUp() override; // WindowServerShellTestBase: - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; // WindowTreeDelegate: void OnEmbed(Window* root) override; @@ -79,7 +79,7 @@ void OnAccelerator(uint32_t id, const ui::Event& event) override; // InterfaceFactory<WindowTreeClient>: - void Create(mojo::Connection* connection, + void Create(shell::Connection* connection, mojo::InterfaceRequest<mojom::WindowTreeClient> request) override; // Used to receive the most recent window tree connection loaded by an embed
diff --git a/components/mus/public/cpp/window_tree_connection.h b/components/mus/public/cpp/window_tree_connection.h index e7d58cc..daa2f68 100644 --- a/components/mus/public/cpp/window_tree_connection.h +++ b/components/mus/public/cpp/window_tree_connection.h
@@ -15,7 +15,7 @@ #include "components/mus/public/interfaces/window_tree.mojom.h" #include "mojo/public/cpp/bindings/interface_request.h" -namespace mojo { +namespace shell { class Connector; } @@ -43,7 +43,7 @@ // Creates a WindowTreeConnection with no roots. Use this to establish a // connection directly to mus and create top level windows. static WindowTreeConnection* Create(WindowTreeDelegate* delegate, - mojo::Connector* connector); + shell::Connector* connector); // Creates a WindowTreeConnection to service the specified request for // a WindowTreeClient. Use this to be embedded in another app.
diff --git a/components/mus/public/cpp/window_tree_host_factory.h b/components/mus/public/cpp/window_tree_host_factory.h index b3a5bab..eebb839 100644 --- a/components/mus/public/cpp/window_tree_host_factory.h +++ b/components/mus/public/cpp/window_tree_host_factory.h
@@ -10,7 +10,7 @@ #include "components/mus/public/interfaces/window_tree_host.mojom.h" #include "mojo/public/cpp/bindings/binding.h" -namespace mojo { +namespace shell { class Connector; } @@ -26,7 +26,7 @@ WindowTreeDelegate* delegate, mojom::WindowTreeHostPtr* host, WindowManagerDelegate* window_manager_delegate); -void CreateWindowTreeHost(mojo::Connector* connector, +void CreateWindowTreeHost(shell::Connector* connector, WindowTreeDelegate* delegate, mojom::WindowTreeHostPtr* host, WindowManagerDelegate* window_manager_delegate);
diff --git a/components/mus/surfaces/direct_output_surface.cc b/components/mus/surfaces/direct_output_surface.cc index 8700900..da6b35e 100644 --- a/components/mus/surfaces/direct_output_surface.cc +++ b/components/mus/surfaces/direct_output_surface.cc
@@ -16,8 +16,15 @@ namespace mus { DirectOutputSurface::DirectOutputSurface( - const scoped_refptr<cc::ContextProvider>& context_provider) - : cc::OutputSurface(context_provider), weak_ptr_factory_(this) {} + scoped_refptr<SurfacesContextProvider> context_provider, + base::SingleThreadTaskRunner* task_runner) + : cc::OutputSurface(context_provider), + synthetic_begin_frame_source_(new cc::SyntheticBeginFrameSource( + task_runner, + cc::BeginFrameArgs::DefaultInterval())), + weak_ptr_factory_(this) { + context_provider->SetDelegate(this); +} DirectOutputSurface::~DirectOutputSurface() {} @@ -25,6 +32,8 @@ if (!cc::OutputSurface::BindToClient(client)) return false; + client->SetBeginFrameSource(synthetic_begin_frame_source_.get()); + if (capabilities_.uses_default_gl_framebuffer) { capabilities_.flipped_output_surface = context_provider()->ContextCapabilities().gpu.flips_vertically; @@ -32,6 +41,20 @@ return true; } +void DirectOutputSurface::OnVSyncParametersUpdated(int64_t timebase, + int64_t interval) { + auto timebase_time_ticks = base::TimeTicks::FromInternalValue(timebase); + auto interval_time_delta = base::TimeDelta::FromInternalValue(interval); + + if (interval_time_delta.is_zero()) { + // TODO(brianderson): We should not be receiving 0 intervals. + interval_time_delta = cc::BeginFrameArgs::DefaultInterval(); + } + + synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase_time_ticks, + interval_time_delta); +} + void DirectOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { DCHECK(context_provider_); DCHECK(frame->gl_frame_data);
diff --git a/components/mus/surfaces/direct_output_surface.h b/components/mus/surfaces/direct_output_surface.h index b32d0cdd85..73c6e8a 100644 --- a/components/mus/surfaces/direct_output_surface.h +++ b/components/mus/surfaces/direct_output_surface.h
@@ -6,22 +6,31 @@ #define COMPONENTS_MUS_SURFACES_DIRECT_OUTPUT_SURFACE_H_ #include "cc/output/output_surface.h" +#include "cc/scheduler/begin_frame_source.h" +#include "components/mus/surfaces/surfaces_context_provider.h" +#include "components/mus/surfaces/surfaces_context_provider_delegate.h" namespace mus { // An OutputSurface implementation that directly draws and // swaps to an actual GL surface. -class DirectOutputSurface : public cc::OutputSurface { +class DirectOutputSurface : public cc::OutputSurface, + public SurfacesContextProviderDelegate { public: explicit DirectOutputSurface( - const scoped_refptr<cc::ContextProvider>& context_provider); + scoped_refptr<SurfacesContextProvider> context_provider, + base::SingleThreadTaskRunner* task_runner); ~DirectOutputSurface() override; // cc::OutputSurface implementation bool BindToClient(cc::OutputSurfaceClient* client) override; void SwapBuffers(cc::CompositorFrame* frame) override; + // SurfacesContextProviderDelegate implementation + void OnVSyncParametersUpdated(int64_t timebase, int64_t interval) override; + private: + scoped_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source_; base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; };
diff --git a/components/mus/surfaces/direct_output_surface_ozone.cc b/components/mus/surfaces/direct_output_surface_ozone.cc index c71230eec..e04a4796 100644 --- a/components/mus/surfaces/direct_output_surface_ozone.cc +++ b/components/mus/surfaces/direct_output_surface_ozone.cc
@@ -21,11 +21,15 @@ DirectOutputSurfaceOzone::DirectOutputSurfaceOzone( const scoped_refptr<SurfacesContextProvider>& context_provider, gfx::AcceleratedWidget widget, + base::SingleThreadTaskRunner* task_runner, uint32_t target, uint32_t internalformat) : cc::OutputSurface(context_provider), output_surface_( new BufferQueue(context_provider, target, internalformat, widget)), + synthetic_begin_frame_source_(new cc::SyntheticBeginFrameSource( + task_runner, + cc::BeginFrameArgs::DefaultInterval())), weak_ptr_factory_(this) { capabilities_.uses_default_gl_framebuffer = false; capabilities_.flipped_output_surface = true; @@ -88,6 +92,8 @@ if (!cc::OutputSurface::BindToClient(client)) return false; + client->SetBeginFrameSource(synthetic_begin_frame_source_.get()); + if (capabilities_.uses_default_gl_framebuffer) { capabilities_.flipped_output_surface = context_provider()->ContextCapabilities().gpu.flips_vertically; @@ -95,13 +101,11 @@ return true; } -// TODO(rjkroege): Plumb vsync properties. void DirectOutputSurfaceOzone::OnUpdateVSyncParametersFromGpu( base::TimeTicks timebase, base::TimeDelta interval) { DCHECK(HasClient()); - CommitVSyncParameters(timebase, interval); - // vsync_manager_->UpdateVSyncParameters(timebase, interval); + synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); } void DirectOutputSurfaceOzone::OnGpuSwapBuffersCompleted(
diff --git a/components/mus/surfaces/direct_output_surface_ozone.h b/components/mus/surfaces/direct_output_surface_ozone.h index b3ed3ea..ec62cac 100644 --- a/components/mus/surfaces/direct_output_surface_ozone.h +++ b/components/mus/surfaces/direct_output_surface_ozone.h
@@ -10,6 +10,7 @@ #include "base/memory/weak_ptr.h" #include "cc/output/context_provider.h" #include "cc/output/output_surface.h" +#include "cc/scheduler/begin_frame_source.h" #include "ui/gfx/geometry/size.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/swap_result.h" @@ -37,6 +38,7 @@ DirectOutputSurfaceOzone( const scoped_refptr<SurfacesContextProvider>& context_provider, gfx::AcceleratedWidget widget, + base::SingleThreadTaskRunner* task_runner, uint32_t target, uint32_t internalformat); @@ -61,6 +63,7 @@ void OnGpuSwapBuffersCompleted(gfx::SwapResult result); std::unique_ptr<BufferQueue> output_surface_; + std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source_; base::WeakPtrFactory<DirectOutputSurfaceOzone> weak_ptr_factory_; };
diff --git a/components/mus/surfaces/surfaces_context_provider.cc b/components/mus/surfaces/surfaces_context_provider.cc index 3079a83..44e45798 100644 --- a/components/mus/surfaces/surfaces_context_provider.cc +++ b/components/mus/surfaces/surfaces_context_provider.cc
@@ -28,14 +28,19 @@ } SurfacesContextProvider::SurfacesContextProvider( - SurfacesContextProviderDelegate* delegate, gfx::AcceleratedWidget widget, const scoped_refptr<GpuState>& state) - : delegate_(delegate), widget_(widget), command_buffer_local_(nullptr) { + : delegate_(nullptr), widget_(widget), command_buffer_local_(nullptr) { capabilities_.gpu.image = true; command_buffer_local_ = new CommandBufferLocal(this, widget_, state); } +void SurfacesContextProvider::SetDelegate( + SurfacesContextProviderDelegate* delegate) { + DCHECK(!delegate_); + delegate_ = delegate; +} + // This routine needs to be safe to call more than once. // This is called when we have an accelerated widget. bool SurfacesContextProvider::BindToCurrentThread() {
diff --git a/components/mus/surfaces/surfaces_context_provider.h b/components/mus/surfaces/surfaces_context_provider.h index d6051075..9fa6d47 100644 --- a/components/mus/surfaces/surfaces_context_provider.h +++ b/components/mus/surfaces/surfaces_context_provider.h
@@ -39,10 +39,11 @@ public CommandBufferLocalClient, public base::NonThreadSafe { public: - SurfacesContextProvider(SurfacesContextProviderDelegate* delegate, - gfx::AcceleratedWidget widget, + SurfacesContextProvider(gfx::AcceleratedWidget widget, const scoped_refptr<GpuState>& state); + void SetDelegate(SurfacesContextProviderDelegate* delegate); + // cc::ContextProvider implementation. bool BindToCurrentThread() override; gpu::gles2::GLES2Interface* ContextGL() override;
diff --git a/components/mus/surfaces/top_level_display_client.cc b/components/mus/surfaces/top_level_display_client.cc index 537e0890..b70f8b3 100644 --- a/components/mus/surfaces/top_level_display_client.cc +++ b/components/mus/surfaces/top_level_display_client.cc
@@ -42,12 +42,14 @@ factory_(surfaces_state->manager(), this), cc_id_(static_cast<uint64_t>(surfaces_state->next_id_namespace()) << 32) { factory_.Create(cc_id_); + surfaces_state_->manager()->RegisterSurfaceIdNamespace(cc_id_.id_namespace()); display_.reset(new cc::Display(this, surfaces_state_->manager(), nullptr, - nullptr, cc::RendererSettings())); + nullptr, cc::RendererSettings(), + cc_id_.id_namespace())); scoped_refptr<SurfacesContextProvider> surfaces_context_provider( - new SurfacesContextProvider(this, widget, gpu_state)); + new SurfacesContextProvider(widget, gpu_state)); // TODO(rjkroege): If there is something better to do than CHECK, add it. CHECK(surfaces_context_provider->BindToCurrentThread()); @@ -55,27 +57,21 @@ if (surfaces_context_provider->ContextCapabilities().gpu.surfaceless) { #if defined(USE_OZONE) output_surface = base::WrapUnique(new DirectOutputSurfaceOzone( - surfaces_context_provider, widget, GL_TEXTURE_2D, GL_RGB)); + surfaces_context_provider, widget, task_runner_.get(), GL_TEXTURE_2D, + GL_RGB)); #else NOTREACHED(); #endif } else { - output_surface = - base::WrapUnique(new DirectOutputSurface(surfaces_context_provider)); + output_surface = base::WrapUnique( + new DirectOutputSurface(surfaces_context_provider, task_runner_.get())); } int max_frames_pending = output_surface->capabilities().max_frames_pending; DCHECK_GT(max_frames_pending, 0); - synthetic_frame_source_.reset(new cc::SyntheticBeginFrameSource( - task_runner_.get(), cc::BeginFrameArgs::DefaultInterval())); - - scheduler_.reset( - new cc::DisplayScheduler(display_.get(), synthetic_frame_source_.get(), - task_runner_.get(), max_frames_pending)); - if (gpu_state->HardwareRenderingAvailable()) { - display_->Initialize(std::move(output_surface), scheduler_.get()); + display_->Initialize(std::move(output_surface), task_runner_.get()); } else { // TODO(rjkroege): Implement software compositing. } @@ -86,6 +82,8 @@ } TopLevelDisplayClient::~TopLevelDisplayClient() { + surfaces_state_->manager()->InvalidateSurfaceIdNamespace( + cc_id_.id_namespace()); factory_.Destroy(cc_id_); } @@ -107,9 +105,6 @@ factory_.RequestCopyOfSurface(cc_id_, std::move(output_request)); } -void TopLevelDisplayClient::CommitVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval) {} - void TopLevelDisplayClient::OutputSurfaceLost() { if (!display_) // Shutdown case return; @@ -119,20 +114,6 @@ void TopLevelDisplayClient::SetMemoryPolicy( const cc::ManagedMemoryPolicy& policy) {} -void TopLevelDisplayClient::OnVSyncParametersUpdated(int64_t timebase, - int64_t interval) { - auto timebase_time_ticks = base::TimeTicks::FromInternalValue(timebase); - auto interval_time_delta = base::TimeDelta::FromInternalValue(interval); - - if (interval_time_delta.is_zero()) { - // TODO(brianderson): We should not be receiving 0 intervals. - interval_time_delta = cc::BeginFrameArgs::DefaultInterval(); - } - - synthetic_frame_source_->OnUpdateVSyncParameters(timebase_time_ticks, - interval_time_delta); -} - void TopLevelDisplayClient::ReturnResources( const cc::ReturnedResourceArray& resources) { // TODO(fsamuel): Implement this.
diff --git a/components/mus/surfaces/top_level_display_client.h b/components/mus/surfaces/top_level_display_client.h index b701769..9dfeb0a0 100644 --- a/components/mus/surfaces/top_level_display_client.h +++ b/components/mus/surfaces/top_level_display_client.h
@@ -16,8 +16,6 @@ #include "cc/surfaces/surface_factory_client.h" #include "components/mus/gles2/gpu_state.h" #include "components/mus/public/interfaces/window_manager.mojom.h" -#include "components/mus/surfaces/surfaces_context_provider.h" -#include "components/mus/surfaces/surfaces_context_provider_delegate.h" #include "components/mus/surfaces/surfaces_state.h" #include "mojo/public/cpp/bindings/strong_binding.h" #include "ui/gfx/native_widget_types.h" @@ -27,7 +25,6 @@ class Display; class DisplayScheduler; class SurfaceFactory; -class SyntheticBeginFrameSource; } namespace mus { @@ -39,8 +36,7 @@ // provided AcceleratedWidget. Frames are submitted here. New frames are // scheduled to be generated here based on VSync. class TopLevelDisplayClient : public cc::DisplayClient, - public cc::SurfaceFactoryClient, - public SurfacesContextProviderDelegate { + public cc::SurfaceFactoryClient { public: TopLevelDisplayClient(gfx::AcceleratedWidget widget, const scoped_refptr<GpuState>& gpu_state, @@ -56,15 +52,9 @@ private: // DisplayClient implementation. - // TODO(rjkroege, fsamuel): This won't work correctly with multiple displays. - void CommitVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval) override; void OutputSurfaceLost() override; void SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) override; - // SurfacesContextProviderDelegate: - void OnVSyncParametersUpdated(int64_t timebase, int64_t interval) override; - // SurfaceFactoryClient implementation. void ReturnResources(const cc::ReturnedResourceArray& resources) override; void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; @@ -77,8 +67,6 @@ gfx::Size last_submitted_frame_size_; std::unique_ptr<cc::CompositorFrame> pending_frame_; - std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_frame_source_; - std::unique_ptr<cc::DisplayScheduler> scheduler_; std::unique_ptr<cc::Display> display_; DISALLOW_COPY_AND_ASSIGN(TopLevelDisplayClient);
diff --git a/components/mus/ws/display.cc b/components/mus/ws/display.cc index b9344aa..d2b0499 100644 --- a/components/mus/ws/display.cc +++ b/components/mus/ws/display.cc
@@ -255,8 +255,7 @@ WindowManagerState* wms = wms_ptr.get(); // For this case we never create additional WindowManagerStates, so any // id works. - window_manager_state_map_[mojo::shell::mojom::kRootUserID] = - std::move(wms_ptr); + window_manager_state_map_[shell::mojom::kRootUserID] = std::move(wms_ptr); wms->tree_ = binding_->CreateWindowTree(wms->root()); } else { CreateWindowManagerStatesFromRegistry();
diff --git a/components/mus/ws/platform_display.h b/components/mus/ws/platform_display.h index ea11212..e293dbc3 100644 --- a/components/mus/ws/platform_display.h +++ b/components/mus/ws/platform_display.h
@@ -35,9 +35,9 @@ class GpuState; } // namespace gles2 -namespace mojo { +namespace shell { class Connector; -} // namespace mojo +} // namespace shell namespace ui { class CursorLoader; @@ -157,7 +157,7 @@ void OnAcceleratedWidgetDestroyed() override; void OnActivationChanged(bool active) override; - mojo::Connector* connector_; + shell::Connector* connector_; scoped_refptr<GpuState> gpu_state_; scoped_refptr<SurfacesState> surfaces_state_; PlatformDisplayDelegate* delegate_;
diff --git a/components/mus/ws/platform_display_init_params.h b/components/mus/ws/platform_display_init_params.h index f097a0f..5232eff 100644 --- a/components/mus/ws/platform_display_init_params.h +++ b/components/mus/ws/platform_display_init_params.h
@@ -7,7 +7,7 @@ #include "base/memory/ref_counted.h" -namespace mojo { +namespace shell { class Connector; } @@ -23,7 +23,7 @@ PlatformDisplayInitParams(const PlatformDisplayInitParams& other); ~PlatformDisplayInitParams(); - mojo::Connector* connector = nullptr; + shell::Connector* connector = nullptr; scoped_refptr<GpuState> gpu_state; scoped_refptr<SurfacesState> surfaces_state; };
diff --git a/components/mus/ws/test_utils.cc b/components/mus/ws/test_utils.cc index 8d78b6d0..d1563da 100644 --- a/components/mus/ws/test_utils.cc +++ b/components/mus/ws/test_utils.cc
@@ -129,7 +129,7 @@ WindowTree* TestDisplayBinding::CreateWindowTree(ServerWindow* root) { return window_server_->EmbedAtWindow( - root, mojo::shell::mojom::kRootUserID, mus::mojom::WindowTreeClientPtr(), + root, shell::mojom::kRootUserID, mus::mojom::WindowTreeClientPtr(), make_scoped_ptr(new WindowManagerAccessPolicy)); }
diff --git a/components/mus/ws/user_id_tracker.cc b/components/mus/ws/user_id_tracker.cc index 58c55de..f80fe42 100644 --- a/components/mus/ws/user_id_tracker.cc +++ b/components/mus/ws/user_id_tracker.cc
@@ -10,7 +10,7 @@ namespace mus { namespace ws { -UserIdTracker::UserIdTracker() : active_id_(mojo::shell::mojom::kRootUserID) { +UserIdTracker::UserIdTracker() : active_id_(shell::mojom::kRootUserID) { ids_.insert(active_id_); } UserIdTracker::~UserIdTracker() {
diff --git a/components/mus/ws/window_manager_state.cc b/components/mus/ws/window_manager_state.cc index 9d0a9f0..f383906 100644 --- a/components/mus/ws/window_manager_state.cc +++ b/components/mus/ws/window_manager_state.cc
@@ -94,7 +94,7 @@ platform_display, surface_id, false, - mojo::shell::mojom::kRootUserID) {} + shell::mojom::kRootUserID) {} WindowManagerState::WindowManagerState(Display* display, PlatformDisplay* platform_display,
diff --git a/components/mus/ws/window_tree_client_unittest.cc b/components/mus/ws/window_tree_client_unittest.cc index 68c4bbc..db7b86b 100644 --- a/components/mus/ws/window_tree_client_unittest.cc +++ b/components/mus/ws/window_tree_client_unittest.cc
@@ -21,10 +21,10 @@ using mojo::Array; using mojo::Callback; -using mojo::Connection; +using shell::Connection; using mojo::InterfaceRequest; using mojo::RectPtr; -using mojo::ShellClient; +using shell::ShellClient; using mojo::String; using mus::mojom::ErrorCode; using mus::mojom::EventPtr; @@ -64,7 +64,7 @@ // ----------------------------------------------------------------------------- -bool EmbedUrl(mojo::Connector* connector, +bool EmbedUrl(shell::Connector* connector, WindowTree* tree, const String& url, Id root_id) { @@ -444,7 +444,7 @@ // InterfaceFactory for vending TestWindowTreeClientImpls. class WindowTreeClientFactory - : public mojo::InterfaceFactory<WindowTreeClient> { + : public shell::InterfaceFactory<WindowTreeClient> { public: WindowTreeClientFactory() {} ~WindowTreeClientFactory() override {} @@ -573,7 +573,7 @@ } // WindowServerShellTestBase: - bool AcceptConnection(mojo::Connection* connection) override { + bool AcceptConnection(shell::Connection* connection) override { connection->AddInterface(client_factory_.get()); return true; }
diff --git a/components/resource_provider/main.cc b/components/resource_provider/main.cc index 5d0b8f81..013d99c 100644 --- a/components/resource_provider/main.cc +++ b/components/resource_provider/main.cc
@@ -7,7 +7,7 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner( + shell::ApplicationRunner runner( new resource_provider::ResourceProviderApp("mojo:resource_provider")); return runner.Run(shell_handle); }
diff --git a/components/resource_provider/public/cpp/resource_loader.cc b/components/resource_provider/public/cpp/resource_loader.cc index 992d8e9..32ae5ef 100644 --- a/components/resource_provider/public/cpp/resource_loader.cc +++ b/components/resource_provider/public/cpp/resource_loader.cc
@@ -26,7 +26,7 @@ } } -ResourceLoader::ResourceLoader(mojo::Connector* connector, +ResourceLoader::ResourceLoader(shell::Connector* connector, const std::set<std::string>& paths) : loaded_(false), did_block_(false) { connector->ConnectToInterface("mojo:resource_provider", &resource_provider_);
diff --git a/components/resource_provider/public/cpp/resource_loader.h b/components/resource_provider/public/cpp/resource_loader.h index 033cfddf..533ec21 100644 --- a/components/resource_provider/public/cpp/resource_loader.h +++ b/components/resource_provider/public/cpp/resource_loader.h
@@ -21,7 +21,7 @@ class File; } -namespace mojo { +namespace shell { class Connector; } @@ -33,7 +33,7 @@ // have been obtained. class ResourceLoader { public: - ResourceLoader(mojo::Connector* connector, + ResourceLoader(shell::Connector* connector, const std::set<std::string>& paths); ~ResourceLoader();
diff --git a/components/resource_provider/resource_provider_app.cc b/components/resource_provider/resource_provider_app.cc index a4bc38a..5e84fb4 100644 --- a/components/resource_provider/resource_provider_app.cc +++ b/components/resource_provider/resource_provider_app.cc
@@ -21,13 +21,13 @@ ResourceProviderApp::~ResourceProviderApp() { } -void ResourceProviderApp::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void ResourceProviderApp::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { tracing_.Initialize(connector, identity.name()); } -bool ResourceProviderApp::AcceptConnection(mojo::Connection* connection) { +bool ResourceProviderApp::AcceptConnection(shell::Connection* connection) { const base::FilePath app_path( GetPathForApplicationName(connection->GetRemoteIdentity().name())); if (app_path.empty()) @@ -38,7 +38,7 @@ } void ResourceProviderApp::Create( - mojo::Connection* connection, + shell::Connection* connection, mojo::InterfaceRequest<ResourceProvider> request) { const base::FilePath app_path( GetPathForApplicationName(connection->GetRemoteIdentity().name()));
diff --git a/components/resource_provider/resource_provider_app.h b/components/resource_provider/resource_provider_app.h index 5861abe..db2cf633 100644 --- a/components/resource_provider/resource_provider_app.h +++ b/components/resource_provider/resource_provider_app.h
@@ -17,20 +17,21 @@ namespace resource_provider { -class ResourceProviderApp : public mojo::ShellClient, - public mojo::InterfaceFactory<ResourceProvider> { +class ResourceProviderApp : public shell::ShellClient, + public shell::InterfaceFactory<ResourceProvider> { public: explicit ResourceProviderApp(const std::string& resource_provider_app_url); ~ResourceProviderApp() override; private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; - // mojo::InterfaceFactory<ResourceProvider>: - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<ResourceProvider>: + void Create(shell::Connection* connection, mojo::InterfaceRequest<ResourceProvider> request) override; mojo::TracingImpl tracing_;
diff --git a/components/resource_provider/resource_provider_test_app.cc b/components/resource_provider/resource_provider_test_app.cc index 8454dac..8cab63f8 100644 --- a/components/resource_provider/resource_provider_test_app.cc +++ b/components/resource_provider/resource_provider_test_app.cc
@@ -46,7 +46,7 @@ class Test : public mojom::Test { public: - explicit Test(mojo::Connector* connector) : connector_(connector) {} + explicit Test(shell::Connector* connector) : connector_(connector) {} ~Test() override {} // mojom::Test: @@ -78,30 +78,30 @@ return results; } - mojo::Connector* connector_; + shell::Connector* connector_; DISALLOW_COPY_AND_ASSIGN(Test); }; -class TestApp : public mojo::ShellClient, - public mojo::InterfaceFactory<mojom::Test> { +class TestApp : public shell::ShellClient, + public shell::InterfaceFactory<mojom::Test> { public: TestApp() {} ~TestApp() override {} - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, - const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override { test_.reset(new Test(connector)); } - bool AcceptConnection(mojo::Connection* connection) override { + bool AcceptConnection(shell::Connection* connection) override { connection->AddInterface<mojom::Test>(this); return true; } // InterfaceFactory<mojom::Test>: - void Create(mojo::Connection* connection, + void Create(shell::Connection* connection, mojom::TestRequest request) override { printf("test app create\n"); bindings_.AddBinding(test_.get(), std::move(request)); @@ -118,6 +118,6 @@ } // namespace resource_provider MojoResult MojoMain(MojoHandle shell_handle) { - return mojo::ApplicationRunner(new resource_provider::test::TestApp) + return shell::ApplicationRunner(new resource_provider::test::TestApp) .Run(shell_handle); }
diff --git a/components/resource_provider/resource_provider_unittest.cc b/components/resource_provider/resource_provider_unittest.cc index ac4e144..46e60d7 100644 --- a/components/resource_provider/resource_provider_unittest.cc +++ b/components/resource_provider/resource_provider_unittest.cc
@@ -10,10 +10,10 @@ namespace resource_provider { namespace test { -class ResourceProviderTest : public mojo::test::ShellTest { +class ResourceProviderTest : public shell::test::ShellTest { public: ResourceProviderTest() - : mojo::test::ShellTest("exe:resource_provider_unittests") {} + : shell::test::ShellTest("exe:resource_provider_unittests") {} ~ResourceProviderTest() override {} private:
diff --git a/components/wallpaper/wallpaper_manager_base.cc b/components/wallpaper/wallpaper_manager_base.cc index 8b3409c1..f247f0cd 100644 --- a/components/wallpaper/wallpaper_manager_base.cc +++ b/components/wallpaper/wallpaper_manager_base.cc
@@ -864,7 +864,8 @@ task_runner_->PostTask( FROM_HERE, base::Bind(&WallpaperManagerBase::MoveCustomWallpapersOnWorker, - logged_in_user->GetAccountId(), GetFilesId(*logged_in_user), + logged_in_user->GetAccountId(), + GetFilesId(logged_in_user->GetAccountId()), base::ThreadTaskRunnerHandle::Get(), weak_factory_.GetWeakPtr())); }
diff --git a/components/wallpaper/wallpaper_manager_base.h b/components/wallpaper/wallpaper_manager_base.h index d66abc0..1c80e4a7 100644 --- a/components/wallpaper/wallpaper_manager_base.h +++ b/components/wallpaper/wallpaper_manager_base.h
@@ -346,8 +346,8 @@ // Returns queue size. virtual size_t GetPendingListSizeForTesting() const = 0; - // Ruturns files identifier for the user. - virtual WallpaperFilesId GetFilesId(const user_manager::User& user) const = 0; + // Ruturns files identifier for the |account_id|. + virtual WallpaperFilesId GetFilesId(const AccountId& account_id) const = 0; protected: friend class TestApi;
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc index cfa57462..f568fe0 100644 --- a/content/browser/browser_context.cc +++ b/content/browser/browser_context.cc
@@ -127,8 +127,8 @@ : public base::SupportsUserData::Data { public: BrowserContextShellConnectionHolder( - std::unique_ptr<mojo::Connection> connection, - mojo::shell::mojom::ShellClientRequest request) + std::unique_ptr<shell::Connection> connection, + shell::mojom::ShellClientRequest request) : root_connection_(std::move(connection)), shell_connection_(new BrowserShellConnection(std::move(request))) {} ~BrowserContextShellConnectionHolder() override {} @@ -136,7 +136,7 @@ BrowserShellConnection* shell_connection() { return shell_connection_.get(); } private: - std::unique_ptr<mojo::Connection> root_connection_; + std::unique_ptr<shell::Connection> root_connection_; std::unique_ptr<BrowserShellConnection> shell_connection_; DISALLOW_COPY_AND_ASSIGN(BrowserContextShellConnectionHolder); @@ -383,13 +383,13 @@ // NOTE: Many unit tests create a TestBrowserContext without initializing // Mojo or the global Mojo shell connection. - mojo::shell::mojom::ShellClientPtr shell_client; - mojo::shell::mojom::ShellClientRequest shell_client_request = + shell::mojom::ShellClientPtr shell_client; + shell::mojom::ShellClientRequest shell_client_request = mojo::GetProxy(&shell_client); - mojo::shell::mojom::PIDReceiverPtr pid_receiver; - mojo::Connector::ConnectParams params( - mojo::Identity(kBrowserMojoApplicationName, new_id)); + shell::mojom::PIDReceiverPtr pid_receiver; + shell::Connector::ConnectParams params( + shell::Identity(kBrowserMojoApplicationName, new_id)); params.set_client_process_connection(std::move(shell_client), mojo::GetProxy(&pid_receiver)); pid_receiver->SetPID(base::GetCurrentProcId()); @@ -434,7 +434,7 @@ } // static -mojo::Connector* BrowserContext::GetMojoConnectorFor( +shell::Connector* BrowserContext::GetMojoConnectorFor( BrowserContext* browser_context) { BrowserContextShellConnectionHolder* connection_holder = static_cast<BrowserContextShellConnectionHolder*>(
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc index b36fe10..e96d2f92 100644 --- a/content/browser/browser_main_loop.cc +++ b/content/browser/browser_main_loop.cc
@@ -83,7 +83,6 @@ #include "net/base/network_change_notifier.h" #include "net/socket/client_socket_factory.h" #include "net/ssl/ssl_config_service.h" -#include "services/shell/public/cpp/shell.h" #include "skia/ext/event_tracer_impl.h" #include "skia/ext/skia_memory_dump_provider.h" #include "sql/sql_memory_dump_provider.h"
diff --git a/content/browser/compositor/browser_compositor_output_surface.cc b/content/browser/compositor/browser_compositor_output_surface.cc index 900845d..bfcebe44 100644 --- a/content/browser/compositor/browser_compositor_output_surface.cc +++ b/content/browser/compositor/browser_compositor_output_surface.cc
@@ -11,6 +11,7 @@ #include "base/location.h" #include "base/strings/string_number_conversions.h" #include "cc/base/switches.h" +#include "cc/output/output_surface_client.h" #include "content/browser/compositor/browser_compositor_overlay_candidate_validator.h" #include "content/browser/compositor/reflector_impl.h" #include "content/common/gpu/client/context_provider_command_buffer.h" @@ -21,10 +22,14 @@ const scoped_refptr<cc::ContextProvider>& context_provider, const scoped_refptr<cc::ContextProvider>& worker_context_provider, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, + base::SingleThreadTaskRunner* task_runner, std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator) : OutputSurface(context_provider, worker_context_provider), vsync_manager_(vsync_manager), + synthetic_begin_frame_source_(new cc::SyntheticBeginFrameSource( + task_runner, + cc::BeginFrameArgs::DefaultInterval())), reflector_(nullptr), use_begin_frame_scheduling_( base::CommandLine::ForCurrentProcess()->HasSwitch( @@ -35,9 +40,13 @@ BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( std::unique_ptr<cc::SoftwareOutputDevice> software_device, - const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) + const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, + base::SingleThreadTaskRunner* task_runner) : OutputSurface(std::move(software_device)), vsync_manager_(vsync_manager), + synthetic_begin_frame_source_(new cc::SyntheticBeginFrameSource( + task_runner, + cc::BeginFrameArgs::DefaultInterval())), reflector_(nullptr), use_begin_frame_scheduling_( base::CommandLine::ForCurrentProcess()->HasSwitch( @@ -67,18 +76,31 @@ if (!OutputSurface::BindToClient(client)) return false; + // Pass begin frame source up to Display to use for DisplayScheduler. + client->SetBeginFrameSource(synthetic_begin_frame_source_.get()); + // Don't want vsync notifications until there is a client. if (!use_begin_frame_scheduling_) vsync_manager_->AddObserver(this); return true; } +void BrowserCompositorOutputSurface::UpdateVSyncParametersInternal( + base::TimeTicks timebase, + base::TimeDelta interval) { + if (interval == base::TimeDelta()) { + // TODO(brianderson): We should not be receiving 0 intervals. + interval = cc::BeginFrameArgs::DefaultInterval(); + } + synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); +} + void BrowserCompositorOutputSurface::OnUpdateVSyncParameters( base::TimeTicks timebase, base::TimeDelta interval) { DCHECK(HasClient()); DCHECK(!use_begin_frame_scheduling_); - CommitVSyncParameters(timebase, interval); + UpdateVSyncParametersInternal(timebase, interval); } void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu( @@ -86,7 +108,7 @@ base::TimeDelta interval) { DCHECK(HasClient()); if (use_begin_frame_scheduling_) { - CommitVSyncParameters(timebase, interval); + UpdateVSyncParametersInternal(timebase, interval); return; }
diff --git a/content/browser/compositor/browser_compositor_output_surface.h b/content/browser/compositor/browser_compositor_output_surface.h index c5ddab1..02f284c1 100644 --- a/content/browser/compositor/browser_compositor_output_surface.h +++ b/content/browser/compositor/browser_compositor_output_surface.h
@@ -5,12 +5,11 @@ #ifndef CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ #define CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ -#include <memory> - #include "base/macros.h" #include "base/threading/non_thread_safe.h" #include "build/build_config.h" #include "cc/output/output_surface.h" +#include "cc/scheduler/begin_frame_source.h" #include "content/common/content_export.h" #include "ui/compositor/compositor_vsync_manager.h" @@ -70,15 +69,18 @@ const scoped_refptr<cc::ContextProvider>& context, const scoped_refptr<cc::ContextProvider>& worker_context, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, + base::SingleThreadTaskRunner* task_runner, std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator); // Constructor used by the software implementation. BrowserCompositorOutputSurface( std::unique_ptr<cc::SoftwareOutputDevice> software_device, - const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager); + const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, + base::SingleThreadTaskRunner* task_runner); scoped_refptr<ui::CompositorVSyncManager> vsync_manager_; + std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source_; ReflectorImpl* reflector_; // True when BeginFrame scheduling is enabled. @@ -87,6 +89,9 @@ private: void Initialize(); + void UpdateVSyncParametersInternal(base::TimeTicks timebase, + base::TimeDelta interval); + std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator_;
diff --git a/content/browser/compositor/gpu_browser_compositor_output_surface.cc b/content/browser/compositor/gpu_browser_compositor_output_surface.cc index e6a7aa1..7075406 100644 --- a/content/browser/compositor/gpu_browser_compositor_output_surface.cc +++ b/content/browser/compositor/gpu_browser_compositor_output_surface.cc
@@ -22,11 +22,13 @@ const scoped_refptr<ContextProviderCommandBuffer>& context, const scoped_refptr<ContextProviderCommandBuffer>& worker_context, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, + base::SingleThreadTaskRunner* task_runner, std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator) : BrowserCompositorOutputSurface(context, worker_context, vsync_manager, + task_runner, std::move(overlay_candidate_validator)), #if defined(OS_MACOSX) should_show_frames_state_(SHOULD_SHOW_FRAMES),
diff --git a/content/browser/compositor/gpu_browser_compositor_output_surface.h b/content/browser/compositor/gpu_browser_compositor_output_surface.h index 950a23a..fe2dd8b 100644 --- a/content/browser/compositor/gpu_browser_compositor_output_surface.h +++ b/content/browser/compositor/gpu_browser_compositor_output_surface.h
@@ -33,6 +33,7 @@ const scoped_refptr<ContextProviderCommandBuffer>& context, const scoped_refptr<ContextProviderCommandBuffer>& worker_context, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, + base::SingleThreadTaskRunner* task_runner, std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator);
diff --git a/content/browser/compositor/gpu_process_transport_factory.cc b/content/browser/compositor/gpu_process_transport_factory.cc index 14718e5b..cdc8798 100644 --- a/content/browser/compositor/gpu_process_transport_factory.cc +++ b/content/browser/compositor/gpu_process_transport_factory.cc
@@ -10,7 +10,6 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/location.h" -#include "base/memory/ptr_util.h" #include "base/metrics/histogram.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" @@ -329,7 +328,7 @@ if (!create_gpu_output_surface) { surface = base::WrapUnique(new SoftwareBrowserCompositorOutputSurface( CreateSoftwareOutputDevice(compositor.get()), - compositor->vsync_manager())); + compositor->vsync_manager(), compositor->task_runner().get())); } else { DCHECK(context_provider); ContextProvider::Capabilities capabilities = @@ -337,7 +336,7 @@ if (!data->surface_id) { surface = base::WrapUnique(new OffscreenBrowserCompositorOutputSurface( context_provider, shared_worker_context_provider_, - compositor->vsync_manager(), + compositor->vsync_manager(), compositor->task_runner().get(), std::unique_ptr<BrowserCompositorOverlayCandidateValidator>())); } else if (capabilities.gpu.surfaceless) { GLenum target = GL_TEXTURE_2D; @@ -350,6 +349,7 @@ base::WrapUnique(new GpuSurfacelessBrowserCompositorOutputSurface( context_provider, shared_worker_context_provider_, data->surface_id, compositor->vsync_manager(), + compositor->task_runner().get(), CreateOverlayCandidateValidator(compositor->widget()), target, format, BrowserGpuMemoryBufferManager::current())); } else { @@ -360,7 +360,8 @@ #endif surface = base::WrapUnique(new GpuBrowserCompositorOutputSurface( context_provider, shared_worker_context_provider_, - compositor->vsync_manager(), std::move(validator))); + compositor->vsync_manager(), compositor->task_runner().get(), + std::move(validator))); } } @@ -385,7 +386,8 @@ new cc::OnscreenDisplayClient( std::move(surface), manager, HostSharedBitmapManager::current(), BrowserGpuMemoryBufferManager::current(), - compositor->GetRendererSettings(), compositor->task_runner())); + compositor->GetRendererSettings(), compositor->task_runner(), + compositor->surface_id_allocator()->id_namespace())); std::unique_ptr<cc::SurfaceDisplayOutputSurface> output_surface( new cc::SurfaceDisplayOutputSurface( @@ -440,7 +442,7 @@ // causing things to request a new GLHelper. Due to crbug.com/176091 the // GLHelper created in this case would be lost/leaked if we just reset() // on the |gl_helper_| variable directly. So instead we call reset() on a - // local scoped_ptr. + // local std::unique_ptr. std::unique_ptr<GLHelper> helper = std::move(gl_helper_); // If there are any observer left at this point, make sure they clean up
diff --git a/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc b/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc index ecd3a0cb..2081727 100644 --- a/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc +++ b/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc
@@ -25,6 +25,7 @@ const scoped_refptr<ContextProviderCommandBuffer>& worker_context, int surface_id, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, + base::SingleThreadTaskRunner* task_runner, std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator, unsigned int target, @@ -33,6 +34,7 @@ : GpuBrowserCompositorOutputSurface(context, worker_context, vsync_manager, + task_runner, std::move(overlay_candidate_validator)), internalformat_(internalformat), gpu_memory_buffer_manager_(gpu_memory_buffer_manager) {
diff --git a/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h b/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h index 4bc208a..7b428a3 100644 --- a/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h +++ b/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h
@@ -24,6 +24,7 @@ const scoped_refptr<ContextProviderCommandBuffer>& worker_context, int surface_id, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, + base::SingleThreadTaskRunner* task_runner, std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator, unsigned int target,
diff --git a/content/browser/compositor/offscreen_browser_compositor_output_surface.cc b/content/browser/compositor/offscreen_browser_compositor_output_surface.cc index 35a3a6ce..2254cbfc 100644 --- a/content/browser/compositor/offscreen_browser_compositor_output_surface.cc +++ b/content/browser/compositor/offscreen_browser_compositor_output_surface.cc
@@ -35,11 +35,13 @@ const scoped_refptr<ContextProviderCommandBuffer>& context, const scoped_refptr<ContextProviderCommandBuffer>& worker_context, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, + base::SingleThreadTaskRunner* task_runner, std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator) : BrowserCompositorOutputSurface(context, worker_context, vsync_manager, + task_runner, std::move(overlay_candidate_validator)), fbo_(0), is_backbuffer_discarded_(false),
diff --git a/content/browser/compositor/offscreen_browser_compositor_output_surface.h b/content/browser/compositor/offscreen_browser_compositor_output_surface.h index 3af0c85..5f88209 100644 --- a/content/browser/compositor/offscreen_browser_compositor_output_surface.h +++ b/content/browser/compositor/offscreen_browser_compositor_output_surface.h
@@ -30,6 +30,7 @@ const scoped_refptr<ContextProviderCommandBuffer>& context, const scoped_refptr<ContextProviderCommandBuffer>& worker_context, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, + base::SingleThreadTaskRunner* task_runner, std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator);
diff --git a/content/browser/compositor/reflector_impl_unittest.cc b/content/browser/compositor/reflector_impl_unittest.cc index e05af8b..00e57c6 100644 --- a/content/browser/compositor/reflector_impl_unittest.cc +++ b/content/browser/compositor/reflector_impl_unittest.cc
@@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/compositor/reflector_impl.h" - -#include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "build/build_config.h" @@ -13,6 +10,7 @@ #include "cc/test/test_web_graphics_context_3d.h" #include "content/browser/compositor/browser_compositor_output_surface.h" #include "content/browser/compositor/browser_compositor_overlay_candidate_validator.h" +#include "content/browser/compositor/reflector_impl.h" #include "content/browser/compositor/reflector_texture.h" #include "content/browser/compositor/test/no_transport_image_transport_factory.h" #include "testing/gtest/include/gtest/gtest.h" @@ -75,10 +73,12 @@ public: TestOutputSurface( const scoped_refptr<cc::ContextProvider>& context_provider, - const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) + const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, + base::SingleThreadTaskRunner* task_runner) : BrowserCompositorOutputSurface(context_provider, nullptr, vsync_manager, + task_runner, CreateTestValidatorOzone()) { surface_size_ = gfx::Size(256, 256); device_scale_factor_ = 1.f; @@ -136,7 +136,8 @@ context_provider_ = cc::TestContextProvider::Create(cc::TestWebGraphicsContext3D::Create()); output_surface_ = std::unique_ptr<TestOutputSurface>( - new TestOutputSurface(context_provider_, compositor_->vsync_manager())); + new TestOutputSurface(context_provider_, compositor_->vsync_manager(), + compositor_task_runner_.get())); CHECK(output_surface_->BindToClient(&output_surface_client_)); root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
diff --git a/content/browser/compositor/software_browser_compositor_output_surface.cc b/content/browser/compositor/software_browser_compositor_output_surface.cc index 1ceacaae..ed5e51ca 100644 --- a/content/browser/compositor/software_browser_compositor_output_surface.cc +++ b/content/browser/compositor/software_browser_compositor_output_surface.cc
@@ -23,8 +23,11 @@ SoftwareBrowserCompositorOutputSurface::SoftwareBrowserCompositorOutputSurface( std::unique_ptr<cc::SoftwareOutputDevice> software_device, - const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) - : BrowserCompositorOutputSurface(std::move(software_device), vsync_manager), + const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, + base::SingleThreadTaskRunner* task_runner) + : BrowserCompositorOutputSurface(std::move(software_device), + vsync_manager, + task_runner), weak_factory_(this) {} SoftwareBrowserCompositorOutputSurface::
diff --git a/content/browser/compositor/software_browser_compositor_output_surface.h b/content/browser/compositor/software_browser_compositor_output_surface.h index 90a5fc9..352f157 100644 --- a/content/browser/compositor/software_browser_compositor_output_surface.h +++ b/content/browser/compositor/software_browser_compositor_output_surface.h
@@ -26,7 +26,8 @@ public: SoftwareBrowserCompositorOutputSurface( std::unique_ptr<cc::SoftwareOutputDevice> software_device, - const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager); + const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, + base::SingleThreadTaskRunner* task_runner); ~SoftwareBrowserCompositorOutputSurface() override;
diff --git a/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc b/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc index 7dd7707..f7e42a3 100644 --- a/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc +++ b/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc
@@ -109,7 +109,8 @@ std::unique_ptr<cc::SoftwareOutputDevice> device) { return std::unique_ptr<content::BrowserCompositorOutputSurface>( new content::SoftwareBrowserCompositorOutputSurface( - std::move(device), compositor_->vsync_manager())); + std::move(device), compositor_->vsync_manager(), + message_loop_->task_runner().get())); } TEST_F(SoftwareBrowserCompositorOutputSurfaceTest, NoVSyncProvider) {
diff --git a/content/browser/dom_storage/dom_storage_context_wrapper.cc b/content/browser/dom_storage/dom_storage_context_wrapper.cc index 7d2e19f..83d699d 100644 --- a/content/browser/dom_storage/dom_storage_context_wrapper.cc +++ b/content/browser/dom_storage/dom_storage_context_wrapper.cc
@@ -80,7 +80,7 @@ // for now). class DOMStorageContextWrapper::MojoState { public: - MojoState(mojo::Connector* connector, const base::FilePath& subdirectory) + MojoState(shell::Connector* connector, const base::FilePath& subdirectory) : connector_(connector), subdirectory_(subdirectory), connection_state_(NO_CONNECTION), @@ -109,7 +109,7 @@ // Maps between an origin and its prefixed LevelDB view. std::map<url::Origin, std::unique_ptr<LevelDBWrapperImpl>> level_db_wrappers_; - mojo::Connector* const connector_; + shell::Connector* const connector_; const base::FilePath subdirectory_; enum ConnectionState { @@ -118,7 +118,7 @@ CONNECTION_FINISHED } connection_state_; - std::unique_ptr<mojo::Connection> user_service_connection_; + std::unique_ptr<shell::Connection> user_service_connection_; user_service::mojom::UserServicePtr user_service_; filesystem::DirectoryPtr directory_; @@ -232,7 +232,7 @@ } DOMStorageContextWrapper::DOMStorageContextWrapper( - mojo::Connector* connector, + shell::Connector* connector, const base::FilePath& profile_path, const base::FilePath& local_partition_path, storage::SpecialStoragePolicy* special_storage_policy) {
diff --git a/content/browser/dom_storage/dom_storage_context_wrapper.h b/content/browser/dom_storage/dom_storage_context_wrapper.h index b631101..17796ff 100644 --- a/content/browser/dom_storage/dom_storage_context_wrapper.h +++ b/content/browser/dom_storage/dom_storage_context_wrapper.h
@@ -19,7 +19,7 @@ class FilePath; } -namespace mojo { +namespace shell { class Connector; } @@ -40,7 +40,7 @@ public: // If |data_path| is empty, nothing will be saved to disk. DOMStorageContextWrapper( - mojo::Connector* connector, + shell::Connector* connector, const base::FilePath& data_path, const base::FilePath& local_partition_path, storage::SpecialStoragePolicy* special_storage_policy);
diff --git a/content/browser/frame_host/frame_mojo_shell.cc b/content/browser/frame_host/frame_mojo_shell.cc index 556bfc9..8eb6f70 100644 --- a/content/browser/frame_host/frame_mojo_shell.cc +++ b/content/browser/frame_host/frame_mojo_shell.cc
@@ -42,7 +42,7 @@ FrameMojoShell::~FrameMojoShell() { } -void FrameMojoShell::BindRequest(mojo::shell::mojom::ConnectorRequest request) { +void FrameMojoShell::BindRequest(shell::mojom::ConnectorRequest request) { connectors_.AddBinding(this, std::move(request)); } @@ -50,12 +50,12 @@ // drop it and replace it with services we provide in the browser. In the // future we may need to support both. void FrameMojoShell::Connect( - mojo::shell::mojom::IdentityPtr target, - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr /* exposed_services */, - mojo::shell::mojom::ClientProcessConnectionPtr client_process_connection, - const mojo::shell::mojom::Connector::ConnectCallback& callback) { - mojo::shell::mojom::InterfaceProviderPtr frame_services; + shell::mojom::IdentityPtr target, + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr /* exposed_services */, + shell::mojom::ClientProcessConnectionPtr client_process_connection, + const shell::mojom::Connector::ConnectCallback& callback) { + shell::mojom::InterfaceProviderPtr frame_services; service_provider_bindings_.AddBinding(GetServiceRegistry(), GetProxy(&frame_services)); std::string mojo_user_id = BrowserContext::GetMojoUserIdFor( @@ -66,7 +66,7 @@ std::move(frame_services), callback); } -void FrameMojoShell::Clone(mojo::shell::mojom::ConnectorRequest request) { +void FrameMojoShell::Clone(shell::mojom::ConnectorRequest request) { connectors_.AddBinding(this, std::move(request)); }
diff --git a/content/browser/frame_host/frame_mojo_shell.h b/content/browser/frame_host/frame_mojo_shell.h index 190ffcc..63d386d0 100644 --- a/content/browser/frame_host/frame_mojo_shell.h +++ b/content/browser/frame_host/frame_mojo_shell.h
@@ -17,35 +17,34 @@ class RenderFrameHost; class ServiceRegistryImpl; -// This provides the |mojo::shell::mojom::Shell| service interface to each +// This provides the |shell::mojom::Shell| service interface to each // frame's ServiceRegistry, giving frames the ability to connect to Mojo // applications. -class FrameMojoShell : public mojo::shell::mojom::Connector { +class FrameMojoShell : public shell::mojom::Connector { public: explicit FrameMojoShell(RenderFrameHost* frame_host); ~FrameMojoShell() override; - void BindRequest(mojo::shell::mojom::ConnectorRequest request); + void BindRequest(shell::mojom::ConnectorRequest request); private: - // mojo::Connector: + // shell::Connector: void Connect( - mojo::shell::mojom::IdentityPtr target, - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr exposed_services, - mojo::shell::mojom::ClientProcessConnectionPtr client_process_connection, - const mojo::shell::mojom::Connector::ConnectCallback& callback) override; - void Clone(mojo::shell::mojom::ConnectorRequest request) override; + shell::mojom::IdentityPtr target, + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr exposed_services, + shell::mojom::ClientProcessConnectionPtr client_process_connection, + const shell::mojom::Connector::ConnectCallback& callback) override; + void Clone(shell::mojom::ConnectorRequest request) override; ServiceRegistryImpl* GetServiceRegistry(); RenderFrameHost* frame_host_; - mojo::BindingSet<mojo::shell::mojom::Connector> connectors_; + mojo::BindingSet<shell::mojom::Connector> connectors_; // ServiceRegistry providing browser services to connected applications. std::unique_ptr<ServiceRegistryImpl> service_registry_; - mojo::BindingSet<mojo::shell::mojom::InterfaceProvider> - service_provider_bindings_; + mojo::BindingSet<shell::mojom::InterfaceProvider> service_provider_bindings_; DISALLOW_COPY_AND_ASSIGN(FrameMojoShell); };
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc index b83ef55f..1e8b7fd 100644 --- a/content/browser/frame_host/render_frame_host_impl.cc +++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -1912,7 +1912,7 @@ if (!frame_mojo_shell_) frame_mojo_shell_.reset(new FrameMojoShell(this)); - GetServiceRegistry()->AddService<mojo::shell::mojom::Connector>(base::Bind( + GetServiceRegistry()->AddService<shell::mojom::Connector>(base::Bind( &FrameMojoShell::BindRequest, base::Unretained(frame_mojo_shell_.get()))); #if defined(ENABLE_WEBVR) @@ -2244,10 +2244,10 @@ GetProcess()->GetServiceRegistry()->ConnectToRemoteService( mojo::GetProxy(&setup)); - mojo::shell::mojom::InterfaceProviderPtr exposed_services; + shell::mojom::InterfaceProviderPtr exposed_services; service_registry_->Bind(GetProxy(&exposed_services)); - mojo::shell::mojom::InterfaceProviderPtr services; + shell::mojom::InterfaceProviderPtr services; setup->ExchangeInterfaceProviders(routing_id_, GetProxy(&services), std::move(exposed_services)); service_registry_->BindRemoteServiceProvider(std::move(services));
diff --git a/content/browser/mojo/browser_shell_connection.cc b/content/browser/mojo/browser_shell_connection.cc index 8fb9121..5b762a2a 100644 --- a/content/browser/mojo/browser_shell_connection.cc +++ b/content/browser/mojo/browser_shell_connection.cc
@@ -10,12 +10,12 @@ namespace content { BrowserShellConnection::BrowserShellConnection( - mojo::shell::mojom::ShellClientRequest request) - : shell_connection_(new mojo::ShellConnection(this, std::move(request))) {} + shell::mojom::ShellClientRequest request) + : shell_connection_(new shell::ShellConnection(this, std::move(request))) {} BrowserShellConnection::~BrowserShellConnection() {} -mojo::Connector* BrowserShellConnection::GetConnector() { +shell::Connector* BrowserShellConnection::GetConnector() { return shell_connection_->connector(); } @@ -30,18 +30,17 @@ DCHECK(result.second); } -bool BrowserShellConnection::AcceptConnection(mojo::Connection* connection) { +bool BrowserShellConnection::AcceptConnection(shell::Connection* connection) { std::string remote_app = connection->GetRemoteIdentity().name(); if (remote_app == "mojo:shell") { // Only expose the SCF interface to the shell. - connection->AddInterface<mojo::shell::mojom::ShellClientFactory>(this); + connection->AddInterface<shell::mojom::ShellClientFactory>(this); return true; } // Allow connections from the root browser application. if (remote_app == kBrowserMojoApplicationName && - connection->GetRemoteIdentity().user_id() == - mojo::shell::mojom::kRootUserID) + connection->GetRemoteIdentity().user_id() == shell::mojom::kRootUserID) return true; // Reject all other connections to this application. @@ -49,13 +48,13 @@ } void BrowserShellConnection::Create( - mojo::Connection* connection, - mojo::shell::mojom::ShellClientFactoryRequest request) { + shell::Connection* connection, + shell::mojom::ShellClientFactoryRequest request) { factory_bindings_.AddBinding(this, std::move(request)); } void BrowserShellConnection::CreateShellClient( - mojo::shell::mojom::ShellClientRequest request, + shell::mojom::ShellClientRequest request, const mojo::String& name) { auto it = embedded_apps_.find(name); if (it != embedded_apps_.end())
diff --git a/content/browser/mojo/browser_shell_connection.h b/content/browser/mojo/browser_shell_connection.h index 6a38234..2130856 100644 --- a/content/browser/mojo/browser_shell_connection.h +++ b/content/browser/mojo/browser_shell_connection.h
@@ -29,15 +29,14 @@ // multiple connections in a single browser process. Each connection may have // its own identity, e.g., a connection with unique user ID per BrowserContext. class BrowserShellConnection - : public mojo::ShellClient, - public mojo::InterfaceFactory<mojo::shell::mojom::ShellClientFactory>, - public mojo::shell::mojom::ShellClientFactory { + : public shell::ShellClient, + public shell::InterfaceFactory<shell::mojom::ShellClientFactory>, + public shell::mojom::ShellClientFactory { public: - explicit BrowserShellConnection( - mojo::shell::mojom::ShellClientRequest request); + explicit BrowserShellConnection(shell::mojom::ShellClientRequest request); ~BrowserShellConnection() override; - mojo::Connector* GetConnector(); + shell::Connector* GetConnector(); // Adds an embedded application to this connection's ShellClientFactory. // |callback| will be used to create a new instance of the application on @@ -50,19 +49,19 @@ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); private: - // mojo::ShellClient: - bool AcceptConnection(mojo::Connection* connection) override; + // shell::ShellClient: + bool AcceptConnection(shell::Connection* connection) override; - // mojo::InterfaceFactory<mojo::shell::mojom::ShellClientFactory>: - void Create(mojo::Connection* connection, - mojo::shell::mojom::ShellClientFactoryRequest request) override; + // shell::InterfaceFactory<shell::mojom::ShellClientFactory>: + void Create(shell::Connection* connection, + shell::mojom::ShellClientFactoryRequest request) override; - // mojo::shell::mojom::ShellClientFactory: - void CreateShellClient(mojo::shell::mojom::ShellClientRequest request, + // shell::mojom::ShellClientFactory: + void CreateShellClient(shell::mojom::ShellClientRequest request, const mojo::String& name) override; - std::unique_ptr<mojo::ShellConnection> shell_connection_; - mojo::BindingSet<mojo::shell::mojom::ShellClientFactory> factory_bindings_; + std::unique_ptr<shell::ShellConnection> shell_connection_; + mojo::BindingSet<shell::mojom::ShellClientFactory> factory_bindings_; std::unordered_map<std::string, std::unique_ptr<EmbeddedApplicationRunner>> embedded_apps_;
diff --git a/content/browser/mojo/mojo_app_connection_impl.cc b/content/browser/mojo/mojo_app_connection_impl.cc index 8e4cd8c5..582da64d 100644 --- a/content/browser/mojo/mojo_app_connection_impl.cc +++ b/content/browser/mojo/mojo_app_connection_impl.cc
@@ -15,8 +15,9 @@ const char kBrowserMojoAppUrl[] = "system:content_browser"; namespace { -void OnGotInstanceID(mojo::shell::mojom::ConnectResult result, - const std::string& user_id, uint32_t remote_id) {} +void OnGotInstanceID(shell::mojom::ConnectResult result, + const std::string& user_id, + uint32_t remote_id) {} } // namespace // static @@ -34,7 +35,7 @@ const std::string& requestor_name) { MojoShellContext::ConnectToApplication( user_id, name, requestor_name, mojo::GetProxy(&interfaces_), - mojo::shell::mojom::InterfaceProviderPtr(), base::Bind(&OnGotInstanceID)); + shell::mojom::InterfaceProviderPtr(), base::Bind(&OnGotInstanceID)); } MojoAppConnectionImpl::~MojoAppConnectionImpl() {
diff --git a/content/browser/mojo/mojo_app_connection_impl.h b/content/browser/mojo/mojo_app_connection_impl.h index b95c140..e2ed0bd 100644 --- a/content/browser/mojo/mojo_app_connection_impl.h +++ b/content/browser/mojo/mojo_app_connection_impl.h
@@ -26,7 +26,7 @@ void GetInterface(const std::string& interface_name, mojo::ScopedMessagePipeHandle handle) override; - mojo::shell::mojom::InterfaceProviderPtr interfaces_; + shell::mojom::InterfaceProviderPtr interfaces_; DISALLOW_COPY_AND_ASSIGN(MojoAppConnectionImpl); };
diff --git a/content/browser/mojo/mojo_application_host.cc b/content/browser/mojo/mojo_application_host.cc index 1e5f1f43..f2b110e 100644 --- a/content/browser/mojo/mojo_application_host.cc +++ b/content/browser/mojo/mojo_application_host.cc
@@ -26,8 +26,8 @@ private: // mojom::ApplicationSetup implementation. void ExchangeInterfaceProviders( - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr exposed_services) override { + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr exposed_services) override { service_registry_->Bind(std::move(services)); service_registry_->BindRemoteServiceProvider(std::move(exposed_services)); }
diff --git a/content/browser/mojo/mojo_child_connection.cc b/content/browser/mojo/mojo_child_connection.cc index 9f1e7b8a..6da74e2 100644 --- a/content/browser/mojo/mojo_child_connection.cc +++ b/content/browser/mojo/mojo_child_connection.cc
@@ -32,20 +32,20 @@ class RenderProcessHostConnection : public base::SupportsUserData::Data { public: explicit RenderProcessHostConnection( - std::unique_ptr<mojo::Connection> connection) + std::unique_ptr<shell::Connection> connection) : connection_(std::move(connection)) {} ~RenderProcessHostConnection() override {} - mojo::Connection* get() const { return connection_.get(); } + shell::Connection* get() const { return connection_.get(); } private: - std::unique_ptr<mojo::Connection> connection_; + std::unique_ptr<shell::Connection> connection_; DISALLOW_COPY_AND_ASSIGN(RenderProcessHostConnection); }; void SetMojoConnection(RenderProcessHost* render_process_host, - std::unique_ptr<mojo::Connection> connection) { + std::unique_ptr<shell::Connection> connection) { render_process_host->SetUserData( kMojoRenderProcessHostConnection, new RenderProcessHostConnection(std::move(connection))); @@ -53,11 +53,8 @@ class PIDSender : public RenderProcessHostObserver { public: - PIDSender( - RenderProcessHost* host, - mojo::shell::mojom::PIDReceiverPtr pid_receiver) - : host_(host), - pid_receiver_(std::move(pid_receiver)) { + PIDSender(RenderProcessHost* host, shell::mojom::PIDReceiverPtr pid_receiver) + : host_(host), pid_receiver_(std::move(pid_receiver)) { pid_receiver_.set_connection_error_handler([this]() { delete this; }); DCHECK(!host_->IsReady()); host_->AddObserver(this); @@ -80,7 +77,7 @@ } RenderProcessHost* host_; - mojo::shell::mojom::PIDReceiverPtr pid_receiver_; + shell::mojom::PIDReceiverPtr pid_receiver_; DISALLOW_COPY_AND_ASSIGN(PIDSender); }; @@ -102,23 +99,22 @@ if (!MojoShellConnection::Get()) return pipe_token; - mojo::shell::mojom::ShellClientPtr client; - client.Bind(mojo::InterfacePtrInfo<mojo::shell::mojom::ShellClient>( + shell::mojom::ShellClientPtr client; + client.Bind(mojo::InterfacePtrInfo<shell::mojom::ShellClient>( std::move(shell_client_pipe), 0u)); - mojo::shell::mojom::PIDReceiverPtr pid_receiver; - mojo::shell::mojom::PIDReceiverRequest pid_receiver_request = + shell::mojom::PIDReceiverPtr pid_receiver; + shell::mojom::PIDReceiverRequest pid_receiver_request = GetProxy(&pid_receiver); // PIDSender manages its own lifetime. new PIDSender(render_process_host, std::move(pid_receiver)); - mojo::Identity target(kRendererMojoApplicationName, - mojo::shell::mojom::kInheritUserID, - base::StringPrintf("%d_%d", child_process_id, - instance_id)); - mojo::Connector::ConnectParams params(target); + shell::Identity target( + kRendererMojoApplicationName, shell::mojom::kInheritUserID, + base::StringPrintf("%d_%d", child_process_id, instance_id)); + shell::Connector::ConnectParams params(target); params.set_client_process_connection(std::move(client), std::move(pid_receiver_request)); - std::unique_ptr<mojo::Connection> connection = + std::unique_ptr<shell::Connection> connection = MojoShellConnection::Get()->GetConnector()->Connect(¶ms); // Store the connection on the RPH so client code can access it later via @@ -128,7 +124,7 @@ return pipe_token; } -mojo::Connection* GetMojoConnection(RenderProcessHost* render_process_host) { +shell::Connection* GetMojoConnection(RenderProcessHost* render_process_host) { RenderProcessHostConnection* connection = static_cast<RenderProcessHostConnection*>( render_process_host->GetUserData(kMojoRenderProcessHostConnection));
diff --git a/content/browser/mojo/mojo_child_connection.h b/content/browser/mojo/mojo_child_connection.h index 955ed7fe..6ee88bb 100644 --- a/content/browser/mojo/mojo_child_connection.h +++ b/content/browser/mojo/mojo_child_connection.h
@@ -10,7 +10,7 @@ #include "base/process/process_handle.h" #include "services/shell/public/interfaces/shell.mojom.h" -namespace mojo { +namespace shell { class Connection; } @@ -18,7 +18,7 @@ class RenderProcessHost; -// Establish a mojo::Connection to the child process, using a pipe created for +// Establish a shell::Connection to the child process, using a pipe created for // that purpose. Returns a token that should be passed to the child process and // exchanged for a pipe there. That pipe can in turn be passed to // MojoShellConnectionImpl::BindToMessagePipe() to initialize the child's @@ -29,7 +29,7 @@ // Returns a mojo connection to the provided render process host. This // connection was opened when MojoConnectToChild() was called. -mojo::Connection* GetMojoConnection(RenderProcessHost* render_process_host); +shell::Connection* GetMojoConnection(RenderProcessHost* render_process_host); } // namespace content
diff --git a/content/browser/mojo/mojo_shell_context.cc b/content/browser/mojo/mojo_shell_context.cc index 40136f4b..af716e2 100644 --- a/content/browser/mojo/mojo_shell_context.cc +++ b/content/browser/mojo/mojo_shell_context.cc
@@ -73,16 +73,16 @@ // This launches a utility process and forwards the Load request the // mojom::ProcessControl service there. The utility process is sandboxed iff // |use_sandbox| is true. -class UtilityProcessLoader : public mojo::shell::Loader { +class UtilityProcessLoader : public shell::Loader { public: UtilityProcessLoader(const base::string16& process_name, bool use_sandbox) : process_name_(process_name), use_sandbox_(use_sandbox) {} ~UtilityProcessLoader() override {} private: - // mojo::shell::Loader: + // shell::Loader: void Load(const std::string& name, - mojo::shell::mojom::ShellClientRequest request) override { + shell::mojom::ShellClientRequest request) override { mojom::ProcessControlPtr process_control; auto process_request = mojo::GetProxy(&process_control); BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, @@ -121,15 +121,15 @@ } // Forwards the load request to the GPU process. -class GpuProcessLoader : public mojo::shell::Loader { +class GpuProcessLoader : public shell::Loader { public: GpuProcessLoader() {} ~GpuProcessLoader() override {} private: - // mojo::shell::Loader: + // shell::Loader: void Load(const std::string& name, - mojo::shell::mojom::ShellClientRequest request) override { + shell::mojom::ShellClientRequest request) override { mojom::ProcessControlPtr process_control; auto process_request = mojo::GetProxy(&process_control); BrowserThread::PostTask( @@ -188,9 +188,9 @@ const std::string& user_id, const std::string& name, const std::string& requestor_name, - mojo::shell::mojom::InterfaceProviderRequest request, - mojo::shell::mojom::InterfaceProviderPtr exposed_services, - const mojo::shell::mojom::Connector::ConnectCallback& callback) { + shell::mojom::InterfaceProviderRequest request, + shell::mojom::InterfaceProviderPtr exposed_services, + const shell::mojom::Connector::ConnectCallback& callback) { if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) { if (shell_context_) { shell_context_->ConnectToApplicationOnOwnThread( @@ -230,8 +230,8 @@ scoped_refptr<base::SingleThreadTaskRunner> file_task_runner = BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); - std::unique_ptr<mojo::shell::NativeRunnerFactory> native_runner_factory( - new mojo::shell::InProcessNativeRunnerFactory( + std::unique_ptr<shell::NativeRunnerFactory> native_runner_factory( + new shell::InProcessNativeRunnerFactory( BrowserThread::GetBlockingPool())); manifest_provider_.reset(new BuiltinManifestProvider); @@ -246,8 +246,8 @@ catalog_.reset(new catalog::Factory(file_task_runner.get(), nullptr, manifest_provider_.get())); - shell_.reset(new mojo::shell::Shell(std::move(native_runner_factory), - catalog_->TakeShellClient())); + shell_.reset(new shell::Shell(std::move(native_runner_factory), + catalog_->TakeShellClient())); StaticApplicationMap apps; GetContentClient()->browser()->RegisterInProcessMojoApplications(&apps); @@ -304,9 +304,9 @@ const std::string& user_id, const std::string& name, const std::string& requestor_name, - mojo::shell::mojom::InterfaceProviderRequest request, - mojo::shell::mojom::InterfaceProviderPtr exposed_services, - const mojo::shell::mojom::Connector::ConnectCallback& callback) { + shell::mojom::InterfaceProviderRequest request, + shell::mojom::InterfaceProviderPtr exposed_services, + const shell::mojom::Connector::ConnectCallback& callback) { proxy_.Get()->ConnectToApplication(user_id, name, requestor_name, std::move(request), std::move(exposed_services), callback); @@ -316,14 +316,13 @@ const std::string& user_id, const std::string& name, const std::string& requestor_name, - mojo::shell::mojom::InterfaceProviderRequest request, - mojo::shell::mojom::InterfaceProviderPtr exposed_services, - const mojo::shell::mojom::Connector::ConnectCallback& callback) { - std::unique_ptr<mojo::shell::ConnectParams> params( - new mojo::shell::ConnectParams); - mojo::Identity source_id(requestor_name, user_id); + shell::mojom::InterfaceProviderRequest request, + shell::mojom::InterfaceProviderPtr exposed_services, + const shell::mojom::Connector::ConnectCallback& callback) { + std::unique_ptr<shell::ConnectParams> params(new shell::ConnectParams); + shell::Identity source_id(requestor_name, user_id); params->set_source(source_id); - params->set_target(mojo::Identity(name, user_id)); + params->set_target(shell::Identity(name, user_id)); params->set_remote_interfaces(std::move(request)); params->set_local_interfaces(std::move(exposed_services)); params->set_connect_callback(callback);
diff --git a/content/browser/mojo/mojo_shell_context.h b/content/browser/mojo/mojo_shell_context.h index 08a9500f1..5fa2b56 100644 --- a/content/browser/mojo/mojo_shell_context.h +++ b/content/browser/mojo/mojo_shell_context.h
@@ -32,7 +32,7 @@ public: using StaticApplicationMap = std::map<std::string, - base::Callback<std::unique_ptr<mojo::ShellClient>()>>; + base::Callback<std::unique_ptr<shell::ShellClient>()>>; MojoShellContext(); ~MojoShellContext(); @@ -45,9 +45,9 @@ const std::string& user_id, const std::string& name, const std::string& requestor_name, - mojo::shell::mojom::InterfaceProviderRequest request, - mojo::shell::mojom::InterfaceProviderPtr exposed_services, - const mojo::shell::mojom::Connector::ConnectCallback& callback); + shell::mojom::InterfaceProviderRequest request, + shell::mojom::InterfaceProviderPtr exposed_services, + const shell::mojom::Connector::ConnectCallback& callback); static void SetApplicationsForTest(const StaticApplicationMap* apps); @@ -60,15 +60,15 @@ const std::string& user_id, const std::string& name, const std::string& requestor_name, - mojo::shell::mojom::InterfaceProviderRequest request, - mojo::shell::mojom::InterfaceProviderPtr exposed_services, - const mojo::shell::mojom::Connector::ConnectCallback& callback); + shell::mojom::InterfaceProviderRequest request, + shell::mojom::InterfaceProviderPtr exposed_services, + const shell::mojom::Connector::ConnectCallback& callback); static base::LazyInstance<std::unique_ptr<Proxy>> proxy_; std::unique_ptr<BuiltinManifestProvider> manifest_provider_; std::unique_ptr<catalog::Factory> catalog_; - std::unique_ptr<mojo::shell::Shell> shell_; + std::unique_ptr<shell::Shell> shell_; DISALLOW_COPY_AND_ASSIGN(MojoShellContext); };
diff --git a/content/browser/mojo_shell_browsertest.cc b/content/browser/mojo_shell_browsertest.cc index f72cd98..26811e01 100644 --- a/content/browser/mojo_shell_browsertest.cc +++ b/content/browser/mojo_shell_browsertest.cc
@@ -35,8 +35,8 @@ } private: - static std::unique_ptr<mojo::ShellClient> CreateTestApp() { - return std::unique_ptr<mojo::ShellClient>(new TestMojoApp); + static std::unique_ptr<shell::ShellClient> CreateTestApp() { + return std::unique_ptr<shell::ShellClient>(new TestMojoApp); } MojoShellContext::StaticApplicationMap test_apps_;
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc index 4569a64..6a91f32 100644 --- a/content/browser/renderer_host/compositor_impl_android.cc +++ b/content/browser/renderer_host/compositor_impl_android.cc
@@ -76,6 +76,33 @@ const unsigned int kMaxDisplaySwapBuffers = 1U; +class ExternalBeginFrameSource : public cc::BeginFrameSourceBase, + public CompositorImpl::VSyncObserver { + public: + ExternalBeginFrameSource(CompositorImpl* compositor) + : compositor_(compositor) { + compositor_->AddObserver(this); + } + + ~ExternalBeginFrameSource() override { compositor_->RemoveObserver(this); } + + // cc::BeginFrameSourceBase implementation: + void OnNeedsBeginFramesChanged(bool needs_begin_frames) override { + compositor_->OnNeedsBeginFramesChange(needs_begin_frames); + } + + // CompositorImpl::VSyncObserver implementation: + void OnVSync(base::TimeTicks frame_time, + base::TimeDelta vsync_period) override { + CallOnBeginFrame(cc::BeginFrameArgs::Create( + BEGINFRAME_FROM_HERE, frame_time, base::TimeTicks::Now(), vsync_period, + cc::BeginFrameArgs::NORMAL)); + } + + private: + CompositorImpl* compositor_; +}; + // Used to override capabilities_.adjust_deadline_for_parent to false class OutputSurfaceWithoutParent : public cc::OutputSurface, public CompositorImpl::VSyncObserver { @@ -84,7 +111,8 @@ CompositorImpl* compositor, const scoped_refptr<ContextProviderCommandBuffer>& context_provider, const base::Callback<void(gpu::Capabilities)>& - populate_gpu_capabilities_callback) + populate_gpu_capabilities_callback, + std::unique_ptr<ExternalBeginFrameSource> begin_frame_source) : cc::OutputSurface(context_provider), compositor_(compositor), populate_gpu_capabilities_callback_(populate_gpu_capabilities_callback), @@ -92,7 +120,8 @@ base::Bind(&OutputSurfaceWithoutParent::OnSwapBuffersCompleted, base::Unretained(this))), overlay_candidate_validator_( - new BrowserCompositorOverlayCandidateValidatorAndroid()) { + new BrowserCompositorOverlayCandidateValidatorAndroid()), + begin_frame_source_(std::move(begin_frame_source)) { capabilities_.adjust_deadline_for_parent = false; capabilities_.max_frames_pending = kMaxDisplaySwapBuffers; } @@ -122,9 +151,16 @@ context_provider_->ContextCapabilities().gpu); compositor_->AddObserver(this); + client->SetBeginFrameSource(begin_frame_source_.get()); + return true; } + void DetachFromClient() override { + client_->SetBeginFrameSource(nullptr); + OutputSurface::DetachFromClient(); + } + cc::OverlayCandidateValidator* GetOverlayCandidateValidator() const override { return overlay_candidate_validator_.get(); } @@ -147,44 +183,17 @@ } void OnVSync(base::TimeTicks timebase, base::TimeDelta interval) override { - CommitVSyncParameters(timebase, interval); + client_->CommitVSyncParameters(timebase, interval); } + private: CompositorImpl* compositor_; base::Callback<void(gpu::Capabilities)> populate_gpu_capabilities_callback_; base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&, gfx::SwapResult)> swap_buffers_completion_callback_; std::unique_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator_; -}; - -class ExternalBeginFrameSource : public cc::BeginFrameSourceBase, - public CompositorImpl::VSyncObserver { - public: - ExternalBeginFrameSource(CompositorImpl* compositor) - : compositor_(compositor) { - compositor_->AddObserver(this); - } - - ~ExternalBeginFrameSource() override { - compositor_->RemoveObserver(this); - } - - // cc::BeginFrameSourceBase implementation: - void OnNeedsBeginFramesChanged(bool needs_begin_frames) override { - compositor_->OnNeedsBeginFramesChange(needs_begin_frames); - } - - // CompositorImpl::VSyncObserver implementation: - void OnVSync(base::TimeTicks frame_time, - base::TimeDelta vsync_period) override { - CallOnBeginFrame(cc::BeginFrameArgs::Create( - BEGINFRAME_FROM_HERE, frame_time, base::TimeTicks::Now(), vsync_period, - cc::BeginFrameArgs::NORMAL)); - } - - private: - CompositorImpl* compositor_; + std::unique_ptr<ExternalBeginFrameSource> begin_frame_source_; }; static bool g_initialized = false; @@ -336,7 +345,6 @@ settings.renderer_settings.allow_antialiasing = false; settings.renderer_settings.highp_threshold_min = 2048; settings.use_zero_copy = true; - settings.use_external_begin_frame_source = true; base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); settings.initial_debug_state.SetRecordRenderingStats( @@ -352,7 +360,6 @@ params.task_graph_runner = g_task_graph_runner.Pointer(); params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); params.settings = &settings; - params.external_begin_frame_source.reset(new ExternalBeginFrameSource(this)); host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); DCHECK(!host_->visible()); host_->SetRootLayer(root_layer_); @@ -554,15 +561,16 @@ new OutputSurfaceWithoutParent( this, context_provider, base::Bind(&CompositorImpl::PopulateGpuCapabilities, - base::Unretained(this)))); + base::Unretained(this)), + base::WrapUnique(new ExternalBeginFrameSource(this)))); cc::SurfaceManager* manager = GetSurfaceManager(); - display_client_.reset( - new cc::OnscreenDisplayClient(std::move(real_output_surface), manager, - HostSharedBitmapManager::current(), - BrowserGpuMemoryBufferManager::current(), - host_->settings().renderer_settings, - base::ThreadTaskRunnerHandle::Get())); + display_client_.reset(new cc::OnscreenDisplayClient( + std::move(real_output_surface), manager, + HostSharedBitmapManager::current(), + BrowserGpuMemoryBufferManager::current(), + host_->settings().renderer_settings, base::ThreadTaskRunnerHandle::Get(), + surface_id_allocator_->id_namespace())); std::unique_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( new cc::SurfaceDisplayOutputSurface(manager, surface_id_allocator_.get(), context_provider, nullptr));
diff --git a/content/browser/service_worker/embedded_worker_instance.cc b/content/browser/service_worker/embedded_worker_instance.cc index 49b9b913..451a612 100644 --- a/content/browser/service_worker/embedded_worker_instance.cc +++ b/content/browser/service_worker/embedded_worker_instance.cc
@@ -87,8 +87,8 @@ void SetupMojoOnUIThread( int process_id, int thread_id, - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtrInfo exposed_services) { + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtrInfo exposed_services) { RenderProcessHost* rph = RenderProcessHost::FromID(process_id); // |rph| or its ServiceRegistry may be NULL in unit tests. if (!rph || !rph->GetServiceRegistry()) @@ -595,11 +595,10 @@ thread_id_ = thread_id; FOR_EACH_OBSERVER(Listener, listener_list_, OnThreadStarted()); - mojo::shell::mojom::InterfaceProviderPtr exposed_services; + shell::mojom::InterfaceProviderPtr exposed_services; service_registry_->Bind(GetProxy(&exposed_services)); - mojo::shell::mojom::InterfaceProviderPtr services; - mojo::shell::mojom::InterfaceProviderRequest services_request = - GetProxy(&services); + shell::mojom::InterfaceProviderPtr services; + shell::mojom::InterfaceProviderRequest services_request = GetProxy(&services); BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind(SetupMojoOnUIThread, process_id(), thread_id_,
diff --git a/content/browser/service_worker/embedded_worker_test_helper.cc b/content/browser/service_worker/embedded_worker_test_helper.cc index 3be53735..cd4ab575 100644 --- a/content/browser/service_worker/embedded_worker_test_helper.cc +++ b/content/browser/service_worker/embedded_worker_test_helper.cc
@@ -61,8 +61,8 @@ void ExchangeInterfaceProviders( int32_t thread_id, - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr exposed_services) override { + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr exposed_services) override { if (!helper_) return; helper_->OnSetupMojoStub(thread_id, std::move(services), @@ -102,7 +102,7 @@ new ServiceRegistryImpl); render_process_service_registry_.ServiceRegistry::AddService( base::Bind(&MockEmbeddedWorkerSetup::Create, weak_factory_.GetWeakPtr())); - mojo::shell::mojom::InterfaceProviderPtr services; + shell::mojom::InterfaceProviderPtr services; render_process_service_registry_.Bind(mojo::GetProxy(&services)); host_service_registry->BindRemoteServiceProvider(std::move(services)); render_process_host_->SetServiceRegistry(std::move(host_service_registry)); @@ -421,8 +421,8 @@ void EmbeddedWorkerTestHelper::OnSetupMojoStub( int thread_id, - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr exposed_services) { + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr exposed_services) { std::unique_ptr<ServiceRegistryImpl> new_registry(new ServiceRegistryImpl); new_registry->Bind(std::move(services)); new_registry->BindRemoteServiceProvider(std::move(exposed_services));
diff --git a/content/browser/service_worker/embedded_worker_test_helper.h b/content/browser/service_worker/embedded_worker_test_helper.h index fe30d6c..ba45120c 100644 --- a/content/browser/service_worker/embedded_worker_test_helper.h +++ b/content/browser/service_worker/embedded_worker_test_helper.h
@@ -162,10 +162,9 @@ void OnFetchEventStub(int request_id, const ServiceWorkerFetchRequest& request); void OnPushEventStub(int request_id, const PushEventPayload& payload); - void OnSetupMojoStub( - int thread_id, - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr exposed_services); + void OnSetupMojoStub(int thread_id, + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr exposed_services); MessagePortMessageFilter* NewMessagePortMessageFilter();
diff --git a/content/child/mojo/mojo_application.cc b/content/child/mojo/mojo_application.cc index 24a720e..7aa4597 100644 --- a/content/child/mojo/mojo_application.cc +++ b/content/child/mojo/mojo_application.cc
@@ -27,8 +27,8 @@ application_setup.Bind( mojo::InterfacePtrInfo<mojom::ApplicationSetup>(std::move(handle), 0u)); - mojo::shell::mojom::InterfaceProviderPtr services; - mojo::shell::mojom::InterfaceProviderPtr exposed_services; + shell::mojom::InterfaceProviderPtr services; + shell::mojom::InterfaceProviderPtr exposed_services; service_registry_.Bind(GetProxy(&exposed_services)); application_setup->ExchangeInterfaceProviders(GetProxy(&services), std::move(exposed_services));
diff --git a/content/child/process_control_impl.cc b/content/child/process_control_impl.cc index fb0cd145..36ec78f5 100644 --- a/content/child/process_control_impl.cc +++ b/content/child/process_control_impl.cc
@@ -21,7 +21,7 @@ void ProcessControlImpl::LoadApplication( const mojo::String& name, - mojo::InterfaceRequest<mojo::shell::mojom::ShellClient> request, + mojo::InterfaceRequest<shell::mojom::ShellClient> request, const LoadApplicationCallback& callback) { // Only register loaders when we need it. if (!has_registered_loaders_) {
diff --git a/content/child/process_control_impl.h b/content/child/process_control_impl.h index 85910d3..2bf4e5f 100644 --- a/content/child/process_control_impl.h +++ b/content/child/process_control_impl.h
@@ -12,11 +12,9 @@ #include "mojo/public/cpp/bindings/interface_request.h" #include "services/shell/public/interfaces/shell_client.mojom.h" -namespace mojo { namespace shell { class Loader; } // namespace shell -} // namespace mojo namespace content { @@ -26,7 +24,7 @@ ProcessControlImpl(); ~ProcessControlImpl() override; - using NameToLoaderMap = std::map<std::string, mojo::shell::Loader*>; + using NameToLoaderMap = std::map<std::string, shell::Loader*>; // Registers Mojo loaders for names. virtual void RegisterLoaders(NameToLoaderMap* name_to_loader_map) = 0; @@ -34,7 +32,7 @@ // ProcessControl: void LoadApplication( const mojo::String& name, - mojo::InterfaceRequest<mojo::shell::mojom::ShellClient> request, + mojo::InterfaceRequest<shell::mojom::ShellClient> request, const LoadApplicationCallback& callback) override; private:
diff --git a/content/child/resource_dispatcher.cc b/content/child/resource_dispatcher.cc index 64171df0..f3f5f63 100644 --- a/content/child/resource_dispatcher.cc +++ b/content/child/resource_dispatcher.cc
@@ -687,8 +687,6 @@ case ResourceMsg_ReceivedCachedMetadata::ID: case ResourceMsg_ReceivedRedirect::ID: case ResourceMsg_SetDataBuffer::ID: - case ResourceMsg_DataReceivedDebug::ID: - case ResourceMsg_DataReceivedDebug2::ID: case ResourceMsg_InlinedDataChunkReceived::ID: case ResourceMsg_DataReceived::ID: case ResourceMsg_DataDownloaded::ID:
diff --git a/content/common/application_setup.mojom b/content/common/application_setup.mojom index 1a3847d..1a6b698 100644 --- a/content/common/application_setup.mojom +++ b/content/common/application_setup.mojom
@@ -8,6 +8,6 @@ interface ApplicationSetup { ExchangeInterfaceProviders( - mojo.shell.mojom.InterfaceProvider& remote_interfaces, - mojo.shell.mojom.InterfaceProvider local_interfaces); + shell.mojom.InterfaceProvider& remote_interfaces, + shell.mojom.InterfaceProvider local_interfaces); };
diff --git a/content/common/gpu/media/v4l2_image_processor.cc b/content/common/gpu/media/v4l2_image_processor.cc index 96838c4..1ac7029 100644 --- a/content/common/gpu/media/v4l2_image_processor.cc +++ b/content/common/gpu/media/v4l2_image_processor.cc
@@ -99,13 +99,13 @@ error_cb_.Run(); } -bool V4L2ImageProcessor::Initialize(const base::Closure& error_cb, - media::VideoPixelFormat input_format, +bool V4L2ImageProcessor::Initialize(media::VideoPixelFormat input_format, media::VideoPixelFormat output_format, - int num_buffers, gfx::Size input_visible_size, gfx::Size output_visible_size, - gfx::Size* output_allocated_size) { + gfx::Size output_allocated_size, + int num_buffers, + const base::Closure& error_cb) { DCHECK(!error_cb.is_null()); error_cb_ = error_cb; @@ -129,7 +129,7 @@ input_visible_size_ = input_visible_size; output_visible_size_ = output_visible_size; - output_allocated_size_ = *output_allocated_size; + output_allocated_size_ = output_allocated_size; input_planes_count_ = media::VideoFrame::NumPlanes(input_format); DCHECK_LE(input_planes_count_, static_cast<size_t>(VIDEO_MAX_PLANES)); @@ -149,8 +149,6 @@ if (!CreateInputBuffers() || !CreateOutputBuffers()) return false; - // CreateOutputBuffers may adjust |output_allocated_size_|. - *output_allocated_size = output_allocated_size_; if (!device_thread_.Start()) { LOG(ERROR) << "Initialize(): encoder thread failed to start";
diff --git a/content/common/gpu/media/v4l2_image_processor.h b/content/common/gpu/media/v4l2_image_processor.h index 72caf3d..3457f38d 100644 --- a/content/common/gpu/media/v4l2_image_processor.h +++ b/content/common/gpu/media/v4l2_image_processor.h
@@ -33,17 +33,16 @@ // Initializes the processor to convert from |input_format| to |output_format| // and/or scale from |input_visible_size| to |output_visible_size|. // Request the output buffers to be of at least |output_allocated_size|. The - // adjusted size will be stored back to |output_allocated_size|. The number of - // input buffers and output buffers will be |num_buffers|. Provided |error_cb| - // will be called if an error occurs. Return true if the requested + // number of input buffers and output buffers will be |num_buffers|. Provided + // |error_cb| will be called if an error occurs. Return true if the requested // configuration is supported. - bool Initialize(const base::Closure& error_cb, - media::VideoPixelFormat input_format, + bool Initialize(media::VideoPixelFormat input_format, media::VideoPixelFormat output_format, - int num_buffers, gfx::Size input_visible_size, gfx::Size output_visible_size, - gfx::Size* output_allocated_size); + gfx::Size output_allocated_size, + int num_buffers, + const base::Closure& error_cb); // Return a vector of dmabuf file descriptors, exported for V4L2 output buffer // with |index|. The size of vector will be the number of planes of the @@ -51,8 +50,11 @@ std::vector<base::ScopedFD> GetDmabufsForOutputBuffer( int output_buffer_index); - // Returns allocated size required by the processor to be fed with. - gfx::Size input_allocated_size() { return input_allocated_size_; } + // Returns input allocated size required by the processor to be fed with. + gfx::Size input_allocated_size() const { return input_allocated_size_; } + + // Returns output allocated size required by the processor. + gfx::Size output_allocated_size() const { return output_allocated_size_; } // Callback to be used to return the index of a processed image to the // client. After the client is done with the frame, call Process with the
diff --git a/content/common/gpu/media/v4l2_video_encode_accelerator.cc b/content/common/gpu/media/v4l2_video_encode_accelerator.cc index d3631483..f8b56ab 100644 --- a/content/common/gpu/media/v4l2_video_encode_accelerator.cc +++ b/content/common/gpu/media/v4l2_video_encode_accelerator.cc
@@ -154,13 +154,11 @@ // Convert from input_format to device_input_format_, keeping the size // at visible_size_ and requiring the output buffers to be of at least // input_allocated_size_. - image_processor_output_allocated_size_ = input_allocated_size_; if (!image_processor_->Initialize( + input_format, device_input_format_, visible_size_, visible_size_, + input_allocated_size_, kImageProcBufferCount, base::Bind(&V4L2VideoEncodeAccelerator::ImageProcessorError, - weak_this_), - input_format, device_input_format_, kImageProcBufferCount, - visible_size_, visible_size_, - &image_processor_output_allocated_size_)) { + weak_this_))) { LOG(ERROR) << "Failed initializing image processor"; return false; } @@ -366,7 +364,7 @@ } scoped_refptr<media::VideoFrame> output_frame = media::VideoFrame::WrapExternalDmabufs( - device_input_format_, image_processor_output_allocated_size_, + device_input_format_, image_processor_->output_allocated_size(), gfx::Rect(visible_size_), visible_size_, fds, timestamp); if (!output_frame) { NOTIFY_ERROR(kPlatformFailureError);
diff --git a/content/common/gpu/media/v4l2_video_encode_accelerator.h b/content/common/gpu/media/v4l2_video_encode_accelerator.h index a415602..f1f6a3c3 100644 --- a/content/common/gpu/media/v4l2_video_encode_accelerator.h +++ b/content/common/gpu/media/v4l2_video_encode_accelerator.h
@@ -267,8 +267,6 @@ // Indexes of free image processor output buffers. Only accessed on child // thread. std::vector<int> free_image_processor_output_buffers_; - // Output allocated size of image processor. - gfx::Size image_processor_output_allocated_size_; // Video frames ready to be processed. Only accessed on child thread. std::queue<ImageProcessorInputRecord> image_processor_input_queue_; // Mapping of int index to fds of image processor output buffer.
diff --git a/content/common/mojo/embedded_application_runner.cc b/content/common/mojo/embedded_application_runner.cc index 73b5d326..50d62a10 100644 --- a/content/common/mojo/embedded_application_runner.cc +++ b/content/common/mojo/embedded_application_runner.cc
@@ -26,14 +26,14 @@ thread_checker_.DetachFromThread(); } - void BindShellClientRequest(mojo::shell::mojom::ShellClientRequest request) { + void BindShellClientRequest(shell::mojom::ShellClientRequest request) { DCHECK(thread_checker_.CalledOnValidThread()); if (!shell_client_) shell_client_ = factory_callback_.Run(); - std::unique_ptr<mojo::ShellConnection> new_connection( - new mojo::ShellConnection(shell_client_.get(), std::move(request))); + std::unique_ptr<shell::ShellConnection> new_connection( + new shell::ShellConnection(shell_client_.get(), std::move(request))); new_connection->set_connection_lost_closure( base::Bind(&Instance::OnShellConnectionLost, base::Unretained(this), new_connection.get())); @@ -45,7 +45,7 @@ ~Instance() { DCHECK(thread_checker_.CalledOnValidThread()); } - void OnShellConnectionLost(mojo::ShellConnection* connection) { + void OnShellConnectionLost(shell::ShellConnection* connection) { DCHECK(thread_checker_.CalledOnValidThread()); for (auto it = shell_connections_.begin(); it != shell_connections_.end(); @@ -62,8 +62,8 @@ base::ThreadChecker thread_checker_; const FactoryCallback factory_callback_; - std::unique_ptr<mojo::ShellClient> shell_client_; - std::vector<std::unique_ptr<mojo::ShellConnection>> shell_connections_; + std::unique_ptr<shell::ShellClient> shell_client_; + std::vector<std::unique_ptr<shell::ShellConnection>> shell_connections_; DISALLOW_COPY_AND_ASSIGN(Instance); }; @@ -80,7 +80,7 @@ } void EmbeddedApplicationRunner::BindShellClientRequest( - mojo::shell::mojom::ShellClientRequest request) { + shell::mojom::ShellClientRequest request) { application_task_runner_->PostTask( FROM_HERE, base::Bind(&Instance::BindShellClientRequest, instance_,
diff --git a/content/common/mojo/embedded_application_runner.h b/content/common/mojo/embedded_application_runner.h index 8c5aa855..37b45897 100644 --- a/content/common/mojo/embedded_application_runner.h +++ b/content/common/mojo/embedded_application_runner.h
@@ -24,8 +24,7 @@ // EmbeddedApplicationRunner instance. class EmbeddedApplicationRunner { public: - using FactoryCallback = - base::Callback<std::unique_ptr<mojo::ShellClient>()>; + using FactoryCallback = base::Callback<std::unique_ptr<shell::ShellClient>()>; // Constructs a runner which hosts the application on |task_runner|'s thread. // If an existing instance of the app is not running when an incoming @@ -40,13 +39,14 @@ // Binds an incoming ShellClientRequest for this application. If the // application isn't already running, it's started. Otherwise the request is // bound to the running instance. - void BindShellClientRequest(mojo::shell::mojom::ShellClientRequest request); + void BindShellClientRequest(shell::mojom::ShellClientRequest request); private: class Instance; // The TaskRunner on which the factory callback will be run. The - // mojo::ShellClient it returns will live and die on this TaskRunner's thread. + // shell::ShellClient it returns will live and die on this TaskRunner's + // thread. const scoped_refptr<base::SingleThreadTaskRunner> application_task_runner_; // A reference to the application instance which may operate on the
diff --git a/content/common/mojo/mojo_shell_connection_impl.cc b/content/common/mojo/mojo_shell_connection_impl.cc index f53bfefe..cf222467 100644 --- a/content/common/mojo/mojo_shell_connection_impl.cc +++ b/content/common/mojo/mojo_shell_connection_impl.cc
@@ -65,14 +65,14 @@ } // static -void MojoShellConnection::Create(mojo::shell::mojom::ShellClientRequest request, +void MojoShellConnection::Create(shell::mojom::ShellClientRequest request, bool is_external) { DCHECK(!lazy_tls_ptr.Pointer()->Get()); MojoShellConnectionImpl* connection = new MojoShellConnectionImpl(is_external); lazy_tls_ptr.Pointer()->Set(connection); connection->shell_connection_.reset( - new mojo::ShellConnection(connection, std::move(request))); + new shell::ShellConnection(connection, std::move(request))); if (is_external) connection->WaitForShellIfNecessary(); } @@ -92,8 +92,8 @@ void MojoShellConnectionImpl::BindToRequestFromCommandLine() { DCHECK(!shell_connection_); - shell_connection_.reset(new mojo::ShellConnection( - this, mojo::shell::GetShellClientRequestFromCommandLine())); + shell_connection_.reset(new shell::ShellConnection( + this, shell::GetShellClientRequestFromCommandLine())); WaitForShellIfNecessary(); } @@ -113,19 +113,18 @@ } } -void MojoShellConnectionImpl::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, - uint32_t id) { -} +void MojoShellConnectionImpl::Initialize(shell::Connector* connector, + const shell::Identity& identity, + uint32_t id) {} -bool MojoShellConnectionImpl::AcceptConnection(mojo::Connection* connection) { +bool MojoShellConnectionImpl::AcceptConnection(shell::Connection* connection) { bool found = false; for (auto listener : listeners_) found |= listener->AcceptConnection(connection); return found; } -mojo::Connector* MojoShellConnectionImpl::GetConnector() { +shell::Connector* MojoShellConnectionImpl::GetConnector() { DCHECK(shell_connection_); return shell_connection_->connector(); }
diff --git a/content/common/mojo/mojo_shell_connection_impl.h b/content/common/mojo/mojo_shell_connection_impl.h index 2213d20..4a9f82f5 100644 --- a/content/common/mojo/mojo_shell_connection_impl.h +++ b/content/common/mojo/mojo_shell_connection_impl.h
@@ -11,7 +11,6 @@ #include "base/macros.h" #include "content/public/common/mojo_shell_connection.h" #include "mojo/public/cpp/system/message_pipe.h" -#include "services/shell/public/cpp/shell.h" #include "services/shell/public/cpp/shell_client.h" #include "services/shell/public/cpp/shell_connection.h" @@ -21,7 +20,7 @@ bool IsRunningInMojoShell(); class MojoShellConnectionImpl : public MojoShellConnection, - public mojo::ShellClient { + public shell::ShellClient { public: // Creates the MojoShellConnection using MojoShellConnection::Factory. Returns // true if a factory was set and the connection was created, false otherwise. @@ -48,21 +47,21 @@ void WaitForShellIfNecessary(); - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, - const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; // MojoShellConnection: - mojo::Connector* GetConnector() override; + shell::Connector* GetConnector() override; bool UsingExternalShell() const override; void SetConnectionLostClosure(const base::Closure& closure) override; void AddListener(Listener* listener) override; void RemoveListener(Listener* listener) override; const bool external_; - std::unique_ptr<mojo::ShellConnection> shell_connection_; + std::unique_ptr<shell::ShellConnection> shell_connection_; std::vector<Listener*> listeners_; DISALLOW_COPY_AND_ASSIGN(MojoShellConnectionImpl);
diff --git a/content/common/mojo/service_registry_impl.cc b/content/common/mojo/service_registry_impl.cc index b26c6099..fe41cf7 100644 --- a/content/common/mojo/service_registry_impl.cc +++ b/content/common/mojo/service_registry_impl.cc
@@ -20,15 +20,14 @@ } } -void ServiceRegistryImpl::Bind( - mojo::shell::mojom::InterfaceProviderRequest request) { +void ServiceRegistryImpl::Bind(shell::mojom::InterfaceProviderRequest request) { binding_.Bind(std::move(request)); binding_.set_connection_error_handler(base::Bind( &ServiceRegistryImpl::OnConnectionError, base::Unretained(this))); } void ServiceRegistryImpl::BindRemoteServiceProvider( - mojo::shell::mojom::InterfaceProviderPtr service_provider) { + shell::mojom::InterfaceProviderPtr service_provider) { CHECK(!remote_provider_); remote_provider_ = std::move(service_provider); while (!pending_connects_.empty()) {
diff --git a/content/common/mojo/service_registry_impl.h b/content/common/mojo/service_registry_impl.h index caf95b5..c53ba10 100644 --- a/content/common/mojo/service_registry_impl.h +++ b/content/common/mojo/service_registry_impl.h
@@ -22,7 +22,7 @@ class CONTENT_EXPORT ServiceRegistryImpl : public ServiceRegistry, - public NON_EXPORTED_BASE(mojo::shell::mojom::InterfaceProvider) { + public NON_EXPORTED_BASE(shell::mojom::InterfaceProvider) { public: using ServiceFactory = base::Callback<void(mojo::ScopedMessagePipeHandle)>; @@ -30,14 +30,14 @@ ~ServiceRegistryImpl() override; // Binds this ServiceProvider implementation to a message pipe endpoint. - void Bind(mojo::shell::mojom::InterfaceProviderRequest request); + void Bind(shell::mojom::InterfaceProviderRequest request); // Binds to a remote ServiceProvider. This will expose added services to the // remote ServiceProvider with the corresponding handle and enable // ConnectToRemoteService to provide access to services exposed by the remote // ServiceProvider. void BindRemoteServiceProvider( - mojo::shell::mojom::InterfaceProviderPtr service_provider); + shell::mojom::InterfaceProviderPtr service_provider); // ServiceRegistry overrides. void AddService(const std::string& service_name, @@ -61,8 +61,8 @@ void OnConnectionError(); - mojo::Binding<mojo::shell::mojom::InterfaceProvider> binding_; - mojo::shell::mojom::InterfaceProviderPtr remote_provider_; + mojo::Binding<shell::mojom::InterfaceProvider> binding_; + shell::mojom::InterfaceProviderPtr remote_provider_; std::map<std::string, ServiceFactory> service_factories_; std::queue<std::pair<std::string, mojo::MessagePipeHandle> >
diff --git a/content/common/mojo/static_loader.cc b/content/common/mojo/static_loader.cc index 16c4b42f..ad48020 100644 --- a/content/common/mojo/static_loader.cc +++ b/content/common/mojo/static_loader.cc
@@ -24,7 +24,7 @@ class RunnerThread : public base::SimpleThread { public: RunnerThread(const std::string& name, - mojo::shell::mojom::ShellClientRequest request, + shell::mojom::ShellClientRequest request, scoped_refptr<base::TaskRunner> exit_task_runner, const base::Closure& exit_callback, const StaticLoader::ApplicationFactory& factory) @@ -35,15 +35,15 @@ factory_(factory) {} void Run() override { - std::unique_ptr<mojo::ApplicationRunner> runner( - new mojo::ApplicationRunner(factory_.Run().release())); + std::unique_ptr<shell::ApplicationRunner> runner( + new shell::ApplicationRunner(factory_.Run().release())); runner->Run(request_.PassMessagePipe().release().value(), false /* init_base */); exit_task_runner_->PostTask(FROM_HERE, exit_callback_); } private: - mojo::shell::mojom::ShellClientRequest request_; + shell::mojom::ShellClientRequest request_; scoped_refptr<base::TaskRunner> exit_task_runner_; base::Closure exit_callback_; StaticLoader::ApplicationFactory factory_; @@ -68,7 +68,7 @@ } void StaticLoader::Load(const std::string& name, - mojo::shell::mojom::ShellClientRequest request) { + shell::mojom::ShellClientRequest request) { if (thread_) return;
diff --git a/content/common/mojo/static_loader.h b/content/common/mojo/static_loader.h index b281aee2..fc231940 100644 --- a/content/common/mojo/static_loader.h +++ b/content/common/mojo/static_loader.h
@@ -16,20 +16,20 @@ class SimpleThread; } -namespace mojo { +namespace shell { class ShellClient; } namespace content { // An Loader which loads a single type of app from a given -// mojo::ShellClientFactory. A Load() request is fulfilled by creating an +// shell::ShellClientFactory. A Load() request is fulfilled by creating an // instance of the app on a new thread. Only one instance of the app will run at // a time. Any Load requests received while the app is running will be dropped. -class StaticLoader : public mojo::shell::Loader { +class StaticLoader : public shell::Loader { public: using ApplicationFactory = - base::Callback<std::unique_ptr<mojo::ShellClient>()>; + base::Callback<std::unique_ptr<shell::ShellClient>()>; // Constructs a static loader for |factory|. explicit StaticLoader(const ApplicationFactory& factory); @@ -41,9 +41,9 @@ ~StaticLoader() override; - // mojo::shell::Loader: + // shell::Loader: void Load(const std::string& name, - mojo::shell::mojom::ShellClientRequest request) override; + shell::mojom::ShellClientRequest request) override; private: void StopAppThread();
diff --git a/content/common/process_control.mojom b/content/common/process_control.mojom index 58cf5f8..d872d81 100644 --- a/content/common/process_control.mojom +++ b/content/common/process_control.mojom
@@ -8,6 +8,6 @@ interface ProcessControl { LoadApplication(string url, - mojo.shell.mojom.ShellClient& request) => (bool success); + shell.mojom.ShellClient& request) => (bool success); };
diff --git a/content/common/render_frame_setup.mojom b/content/common/render_frame_setup.mojom index 320beb2..b020f42 100644 --- a/content/common/render_frame_setup.mojom +++ b/content/common/render_frame_setup.mojom
@@ -9,6 +9,6 @@ interface RenderFrameSetup { ExchangeInterfaceProviders( int32 frame_routing_id, - mojo.shell.mojom.InterfaceProvider& remote_interfaces, - mojo.shell.mojom.InterfaceProvider local_interfaces); + shell.mojom.InterfaceProvider& remote_interfaces, + shell.mojom.InterfaceProvider local_interfaces); };
diff --git a/content/common/resource_messages.h b/content/common/resource_messages.h index 9c53b36..6397eb5a 100644 --- a/content/common/resource_messages.h +++ b/content/common/resource_messages.h
@@ -372,17 +372,6 @@ int /* shm_size */, base::ProcessId /* renderer_pid */) -// A message that always precedes ResourceMsg_DataReceived. Exists to help debug -// https://code.google.com/p/chromium/issues/detail?id=527588. -IPC_MESSAGE_CONTROL2(ResourceMsg_DataReceivedDebug, - int /* request_id */, - int /* data_offset */) -IPC_MESSAGE_CONTROL4(ResourceMsg_DataReceivedDebug2, - int /* request_id */, - int /* data_offset */, - int /* data_length */, - int /* encoded_data_length */) - // Sent when a chunk of data from a resource request is ready, and the resource // is expected to be small enough to fit in the inlined buffer. // The data is sent as a part of IPC message.
diff --git a/content/common/service_worker/embedded_worker_setup.mojom b/content/common/service_worker/embedded_worker_setup.mojom index 069dbcd6..6b1dfb5 100644 --- a/content/common/service_worker/embedded_worker_setup.mojom +++ b/content/common/service_worker/embedded_worker_setup.mojom
@@ -9,6 +9,6 @@ interface EmbeddedWorkerSetup { ExchangeInterfaceProviders( int32 thread_id, - mojo.shell.mojom.InterfaceProvider& remote_interfaces, - mojo.shell.mojom.InterfaceProvider local_interfaces); + shell.mojom.InterfaceProvider& remote_interfaces, + shell.mojom.InterfaceProvider local_interfaces); };
diff --git a/content/public/browser/browser_context.h b/content/public/browser/browser_context.h index af0f332d..d973c26 100644 --- a/content/public/browser/browser_context.h +++ b/content/public/browser/browser_context.h
@@ -30,7 +30,7 @@ class Time; } -namespace mojo { +namespace shell { class Connector; } @@ -158,7 +158,7 @@ // Returns a Connector associated with this BrowserContext, which can be used // to connect to Mojo application instances bound to a specific user. - static mojo::Connector* GetMojoConnectorFor(BrowserContext* browser_context); + static shell::Connector* GetMojoConnectorFor(BrowserContext* browser_context); ~BrowserContext() override;
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h index dfff4d0..4398ba8 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h
@@ -58,7 +58,7 @@ class CdmFactory; } -namespace mojo { +namespace shell { class ShellClient; } @@ -651,7 +651,7 @@ using StaticMojoApplicationMap = std::map<std::string, - base::Callback<std::unique_ptr<mojo::ShellClient>()>>; + base::Callback<std::unique_ptr<shell::ShellClient>()>>; // Registers Mojo applications to be loaded in the browser process by the // browser's global Mojo shell.
diff --git a/content/public/common/mojo_shell_connection.h b/content/public/common/mojo_shell_connection.h index a427b4c..26f104c6 100644 --- a/content/public/common/mojo_shell_connection.h +++ b/content/public/common/mojo_shell_connection.h
@@ -9,7 +9,7 @@ #include "content/common/content_export.h" #include "services/shell/public/interfaces/shell_client.mojom.h" -namespace mojo { +namespace shell { class Connection; class Connector; } @@ -29,7 +29,7 @@ // TODO(beng): This should just be ShellClient. class Listener { public: - virtual bool AcceptConnection(mojo::Connection* connection) = 0; + virtual bool AcceptConnection(shell::Connection* connection) = 0; virtual ~Listener() {} }; @@ -50,10 +50,10 @@ // Creates the appropriate MojoShellConnection from |request|. See // UsingExternalShell() for details of |is_external|. - static void Create(mojo::shell::mojom::ShellClientRequest request, + static void Create(shell::mojom::ShellClientRequest request, bool is_external); - virtual mojo::Connector* GetConnector() = 0; + virtual shell::Connector* GetConnector() = 0; // Indicates whether the shell connection is to an external shell (true) or // a shell embedded in the browser process (false).
diff --git a/content/public/test/test_mojo_app.cc b/content/public/test/test_mojo_app.cc index ecd516f1..c3e6498 100644 --- a/content/public/test/test_mojo_app.cc +++ b/content/public/test/test_mojo_app.cc
@@ -21,14 +21,14 @@ TestMojoApp::~TestMojoApp() { } -bool TestMojoApp::AcceptConnection(mojo::Connection* connection) { +bool TestMojoApp::AcceptConnection(shell::Connection* connection) { requestor_name_ = connection->GetRemoteIdentity().name(); connection->AddInterface<mojom::TestMojoService>(this); return true; } void TestMojoApp::Create( - mojo::Connection* connection, + shell::Connection* connection, mojo::InterfaceRequest<mojom::TestMojoService> request) { DCHECK(!service_binding_.is_bound()); service_binding_.Bind(std::move(request));
diff --git a/content/public/test/test_mojo_app.h b/content/public/test/test_mojo_app.h index 1ff4ef2..de9684b1 100644 --- a/content/public/test/test_mojo_app.h +++ b/content/public/test/test_mojo_app.h
@@ -17,19 +17,19 @@ // Simple Mojo app which provides a mojom::TestMojoService impl. The app // terminates itself after its TestService fulfills a single DoSomething call. -class TestMojoApp : public mojo::ShellClient, - public mojo::InterfaceFactory<mojom::TestMojoService>, +class TestMojoApp : public shell::ShellClient, + public shell::InterfaceFactory<mojom::TestMojoService>, public mojom::TestMojoService { public: TestMojoApp(); ~TestMojoApp() override; private: - // mojo::ShellClient: - bool AcceptConnection(mojo::Connection* connection) override; + // shell::ShellClient: + bool AcceptConnection(shell::Connection* connection) override; - // mojo::InterfaceFactory<mojom::TestMojoService>: - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<mojom::TestMojoService>: + void Create(shell::Connection* connection, mojo::InterfaceRequest<mojom::TestMojoService> request) override; // TestMojoService:
diff --git a/content/public/utility/content_utility_client.h b/content/public/utility/content_utility_client.h index 3d6cb44..4210498 100644 --- a/content/public/utility/content_utility_client.h +++ b/content/public/utility/content_utility_client.h
@@ -13,7 +13,7 @@ class GURL; -namespace mojo { +namespace shell { class ShellClient; } @@ -26,7 +26,7 @@ public: using StaticMojoApplicationMap = std::map<std::string, - base::Callback<std::unique_ptr<mojo::ShellClient>()>>; + base::Callback<std::unique_ptr<shell::ShellClient>()>>; virtual ~ContentUtilityClient() {}
diff --git a/content/renderer/gpu/compositor_output_surface.cc b/content/renderer/gpu/compositor_output_surface.cc index 7d3410f..1bf5e83 100644 --- a/content/renderer/gpu/compositor_output_surface.cc +++ b/content/renderer/gpu/compositor_output_surface.cc
@@ -177,7 +177,11 @@ base::TimeTicks timebase, base::TimeDelta interval) { DCHECK(client_thread_checker_.CalledOnValidThread()); - CommitVSyncParameters(timebase, interval); + TRACE_EVENT2("cc", + "CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser", + "timebase", (timebase - base::TimeTicks()).InSecondsF(), + "interval", interval.InSecondsF()); + client_->CommitVSyncParameters(timebase, interval); } void CompositorOutputSurface::OnSwapAck(uint32_t output_surface_id,
diff --git a/content/renderer/media/media_interface_provider.cc b/content/renderer/media/media_interface_provider.cc index 44ef0e4..2391112 100644 --- a/content/renderer/media/media_interface_provider.cc +++ b/content/renderer/media/media_interface_provider.cc
@@ -48,9 +48,9 @@ DCHECK(thread_checker_.CalledOnValidThread()); if (!media_service_factory_) { - mojo::shell::mojom::InterfaceProviderPtr interface_provider = + shell::mojom::InterfaceProviderPtr interface_provider = connect_to_app_cb_.Run(GURL("mojo:media")); - mojo::GetInterface(interface_provider.get(), &media_service_factory_); + shell::GetInterface(interface_provider.get(), &media_service_factory_); media_service_factory_.set_connection_error_handler(base::Bind( &MediaInterfaceProvider::OnConnectionError, base::Unretained(this))); }
diff --git a/content/renderer/media/media_interface_provider.h b/content/renderer/media/media_interface_provider.h index c7237931..3a7e9ef 100644 --- a/content/renderer/media/media_interface_provider.h +++ b/content/renderer/media/media_interface_provider.h
@@ -19,11 +19,11 @@ // provides media related services and handles app disconnection automatically. // This class is single threaded. class CONTENT_EXPORT MediaInterfaceProvider - : public mojo::shell::mojom::InterfaceProvider { + : public shell::mojom::InterfaceProvider { public: // Callback used to connect to a mojo application. using ConnectToApplicationCB = - base::Callback<mojo::shell::mojom::InterfaceProviderPtr(const GURL& url)>; + base::Callback<shell::mojom::InterfaceProviderPtr(const GURL& url)>; explicit MediaInterfaceProvider( const ConnectToApplicationCB& connect_to_app_cb);
diff --git a/content/renderer/media/rtc_video_encoder.cc b/content/renderer/media/rtc_video_encoder.cc index 7fd656e..e01a706 100644 --- a/content/renderer/media/rtc_video_encoder.cc +++ b/content/renderer/media/rtc_video_encoder.cc
@@ -509,8 +509,9 @@ const int index = input_buffers_free_.back(); bool requires_copy = false; scoped_refptr<media::VideoFrame> frame; - if (next_frame->native_handle()) { - frame = static_cast<media::VideoFrame*>(next_frame->native_handle()); + if (next_frame->video_frame_buffer()->native_handle()) { + frame = static_cast<media::VideoFrame*>( + next_frame->video_frame_buffer()->native_handle()); requires_copy = RequiresSizeChange(frame); } else { requires_copy = true;
diff --git a/content/renderer/media/webrtc/media_stream_remote_video_source.cc b/content/renderer/media/webrtc/media_stream_remote_video_source.cc index 03b6125..8bac9d7 100644 --- a/content/renderer/media/webrtc/media_stream_remote_video_source.cc +++ b/content/renderer/media/webrtc/media_stream_remote_video_source.cc
@@ -103,7 +103,7 @@ const cricket::VideoFrame* frame = incoming_frame.GetCopyWithRotationApplied(); - gfx::Size size(frame->GetWidth(), frame->GetHeight()); + gfx::Size size(frame->width(), frame->height()); // Make a shallow copy. Both |frame| and |video_frame| will share a single // reference counted frame buffer. Const cast and hope no one will overwrite
diff --git a/content/renderer/mus/render_widget_window_tree_client_factory.cc b/content/renderer/mus/render_widget_window_tree_client_factory.cc index 584c2bde..c383e699 100644 --- a/content/renderer/mus/render_widget_window_tree_client_factory.cc +++ b/content/renderer/mus/render_widget_window_tree_client_factory.cc
@@ -25,7 +25,8 @@ // MojoShellConnection::Listener. class RenderWidgetWindowTreeClientFactoryImpl : public MojoShellConnection::Listener, - public mojo::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>, + public shell::InterfaceFactory< + mojom::RenderWidgetWindowTreeClientFactory>, public mojom::RenderWidgetWindowTreeClientFactory { public: RenderWidgetWindowTreeClientFactoryImpl() { @@ -37,13 +38,13 @@ private: // MojoShellConnection::Listener implementation: - bool AcceptConnection(mojo::Connection* connection) override { + bool AcceptConnection(shell::Connection* connection) override { connection->AddInterface<mojom::RenderWidgetWindowTreeClientFactory>(this); return true; } - // mojo::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>: - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>: + void Create(shell::Connection* connection, mojo::InterfaceRequest<mojom::RenderWidgetWindowTreeClientFactory> request) override { bindings_.AddBinding(this, std::move(request));
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index b050e8b..4a1b6f93e 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc
@@ -621,8 +621,9 @@ RenderFrameImpl::CreateRenderFrameImplFunction g_create_render_frame_impl = nullptr; -void OnGotInstanceID(mojo::shell::mojom::ConnectResult result, - const std::string& user_id, uint32_t instance_id) {} +void OnGotInstanceID(shell::mojom::ConnectResult result, + const std::string& user_id, + uint32_t instance_id) {} WebString ConvertRelativePathToHtmlAttribute(const base::FilePath& path) { DCHECK(!path.IsAbsolute()); @@ -1490,8 +1491,8 @@ } void RenderFrameImpl::BindServiceRegistry( - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr exposed_services) { + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr exposed_services) { service_registry_.Bind(std::move(services)); service_registry_.BindRemoteServiceProvider(std::move(exposed_services)); } @@ -5914,8 +5915,7 @@ } #if defined(ENABLE_MOJO_MEDIA) -mojo::shell::mojom::InterfaceProvider* -RenderFrameImpl::GetMediaInterfaceProvider() { +shell::mojom::InterfaceProvider* RenderFrameImpl::GetMediaInterfaceProvider() { if (!media_interface_provider_) { media_interface_provider_.reset(new MediaInterfaceProvider(base::Bind( &RenderFrameImpl::ConnectToApplication, base::Unretained(this)))); @@ -5982,14 +5982,14 @@ GetServiceRegistry()->ConnectToRemoteService(std::move(request)); } -mojo::shell::mojom::InterfaceProviderPtr RenderFrameImpl::ConnectToApplication( +shell::mojom::InterfaceProviderPtr RenderFrameImpl::ConnectToApplication( const GURL& url) { if (!connector_) GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&connector_)); - mojo::shell::mojom::InterfaceProviderPtr interface_provider; - mojo::shell::mojom::IdentityPtr target(mojo::shell::mojom::Identity::New()); + shell::mojom::InterfaceProviderPtr interface_provider; + shell::mojom::IdentityPtr target(shell::mojom::Identity::New()); target->name = url.spec(); - target->user_id = mojo::shell::mojom::kInheritUserID; + target->user_id = shell::mojom::kInheritUserID; target->instance = ""; connector_->Connect(std::move(target), GetProxy(&interface_provider), nullptr, nullptr, base::Bind(&OnGotInstanceID));
diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h index 907c3ce..a5db1f9 100644 --- a/content/renderer/render_frame_impl.h +++ b/content/renderer/render_frame_impl.h
@@ -636,9 +636,8 @@ override; // Binds this render frame's service registry. - void BindServiceRegistry( - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr exposed_services); + void BindServiceRegistry(shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr exposed_services); ManifestManager* manifest_manager(); @@ -960,7 +959,7 @@ bool AreSecureCodecsSupported(); #if defined(ENABLE_MOJO_MEDIA) - mojo::shell::mojom::InterfaceProvider* GetMediaInterfaceProvider(); + shell::mojom::InterfaceProvider* GetMediaInterfaceProvider(); #endif media::CdmFactory* GetCdmFactory(); @@ -974,8 +973,7 @@ // Connects to a Mojo application and returns a proxy to its exposed // ServiceProvider. - mojo::shell::mojom::InterfaceProviderPtr ConnectToApplication( - const GURL& url); + shell::mojom::InterfaceProviderPtr ConnectToApplication(const GURL& url); // Returns the media delegate for WebMediaPlayer usage. If // |media_player_delegate_| is NULL, one is created. @@ -1176,7 +1174,7 @@ BlinkServiceRegistryImpl blink_service_registry_; // The shell proxy used to connect to Mojo applications. - mojo::shell::mojom::ConnectorPtr connector_; + shell::mojom::ConnectorPtr connector_; // The screen orientation dispatcher attached to the frame, lazily // initialized.
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index 14a53601..35367aa 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc
@@ -363,9 +363,8 @@ void ExchangeInterfaceProviders( int32_t frame_routing_id, - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr exposed_services) - override { + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr exposed_services) override { // TODO(morrita): This is for investigating http://crbug.com/415059 and // should be removed once it is fixed. CHECK_LT(routing_id_highmark_, frame_routing_id); @@ -396,8 +395,8 @@ } void SetupEmbeddedWorkerOnWorkerThread( - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtrInfo exposed_services) { + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtrInfo exposed_services) { ServiceWorkerContextClient* client = ServiceWorkerContextClient::ThreadSpecificInstance(); // It is possible for client to be null if for some reason the worker died @@ -417,8 +416,8 @@ void ExchangeInterfaceProviders( int32_t thread_id, - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr exposed_services) override { + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr exposed_services) override { WorkerThreadRegistry::Instance()->GetTaskRunnerFor(thread_id)->PostTask( FROM_HERE, base::Bind(&SetupEmbeddedWorkerOnWorkerThread, base::Passed(&services), @@ -1049,9 +1048,9 @@ return; scoped_refptr<PendingRenderFrameConnect> connection(it->second); - mojo::shell::mojom::InterfaceProviderRequest services( + shell::mojom::InterfaceProviderRequest services( std::move(connection->services())); - mojo::shell::mojom::InterfaceProviderPtr exposed_services( + shell::mojom::InterfaceProviderPtr exposed_services( std::move(connection->exposed_services())); exposed_services.set_connection_error_handler(mojo::Closure()); pending_render_frame_connects_.erase(it); @@ -1082,8 +1081,8 @@ void RenderThreadImpl::RegisterPendingRenderFrameConnect( int routing_id, - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr exposed_services) { + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr exposed_services) { std::pair<PendingRenderFrameConnectMap::iterator, bool> result = pending_render_frame_connects_.insert(std::make_pair( routing_id, @@ -2127,8 +2126,8 @@ RenderThreadImpl::PendingRenderFrameConnect::PendingRenderFrameConnect( int routing_id, - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr exposed_services) + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr exposed_services) : routing_id_(routing_id), services_(std::move(services)), exposed_services_(std::move(exposed_services)) {
diff --git a/content/renderer/render_thread_impl.h b/content/renderer/render_thread_impl.h index 28379f06..2ff20c0 100644 --- a/content/renderer/render_thread_impl.h +++ b/content/renderer/render_thread_impl.h
@@ -454,8 +454,8 @@ void RegisterPendingRenderFrameConnect( int routing_id, - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr exposed_services); + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr exposed_services); mojom::StoragePartitionService* GetStoragePartitionService(); @@ -686,14 +686,12 @@ public: PendingRenderFrameConnect( int routing_id, - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr exposed_services); + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr exposed_services); - mojo::shell::mojom::InterfaceProviderRequest& services() { - return services_; - } + shell::mojom::InterfaceProviderRequest& services() { return services_; } - mojo::shell::mojom::InterfaceProviderPtr& exposed_services() { + shell::mojom::InterfaceProviderPtr& exposed_services() { return exposed_services_; } @@ -706,8 +704,8 @@ void OnConnectionError(); int routing_id_; - mojo::shell::mojom::InterfaceProviderRequest services_; - mojo::shell::mojom::InterfaceProviderPtr exposed_services_; + shell::mojom::InterfaceProviderRequest services_; + shell::mojom::InterfaceProviderPtr exposed_services_; }; typedef std::map<int, scoped_refptr<PendingRenderFrameConnect>>
diff --git a/content/renderer/service_worker/service_worker_context_client.cc b/content/renderer/service_worker/service_worker_context_client.cc index 64c72d8..f9086d41 100644 --- a/content/renderer/service_worker/service_worker_context_client.cc +++ b/content/renderer/service_worker/service_worker_context_client.cc
@@ -276,8 +276,8 @@ } void ServiceWorkerContextClient::BindServiceRegistry( - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr exposed_services) { + shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr exposed_services) { context_->service_registry.Bind(std::move(services)); context_->service_registry.BindRemoteServiceProvider( std::move(exposed_services));
diff --git a/content/renderer/service_worker/service_worker_context_client.h b/content/renderer/service_worker/service_worker_context_client.h index 6573cf5..de431ce 100644 --- a/content/renderer/service_worker/service_worker_context_client.h +++ b/content/renderer/service_worker/service_worker_context_client.h
@@ -86,9 +86,8 @@ // Called some time after the worker has started. Attempts to use the // ServiceRegistry to connect to services before this method is called are // queued up and will resolve after this method is called. - void BindServiceRegistry( - mojo::shell::mojom::InterfaceProviderRequest services, - mojo::shell::mojom::InterfaceProviderPtr exposed_services); + void BindServiceRegistry(shell::mojom::InterfaceProviderRequest services, + shell::mojom::InterfaceProviderPtr exposed_services); // WebServiceWorkerContextClient overrides. blink::WebURL scope() const override;
diff --git a/content/shell/browser/shell_mojo_test_utils_android.cc b/content/shell/browser/shell_mojo_test_utils_android.cc index 372b827..ba02290 100644 --- a/content/shell/browser/shell_mojo_test_utils_android.cc +++ b/content/shell/browser/shell_mojo_test_utils_android.cc
@@ -48,11 +48,11 @@ content::ServiceRegistryImpl* registry_b = new ServiceRegistryImpl(); test_environment->registries.push_back(registry_b); - mojo::shell::mojom::InterfaceProviderPtr exposed_services_a; + shell::mojom::InterfaceProviderPtr exposed_services_a; registry_a->Bind(GetProxy(&exposed_services_a)); registry_b->BindRemoteServiceProvider(std::move(exposed_services_a)); - mojo::shell::mojom::InterfaceProviderPtr exposed_services_b; + shell::mojom::InterfaceProviderPtr exposed_services_b; registry_b->Bind(GetProxy(&exposed_services_b)); registry_a->BindRemoteServiceProvider(std::move(exposed_services_b));
diff --git a/content/shell/utility/shell_content_utility_client.cc b/content/shell/utility/shell_content_utility_client.cc index f8dc592..ebd09fc 100644 --- a/content/shell/utility/shell_content_utility_client.cc +++ b/content/shell/utility/shell_content_utility_client.cc
@@ -14,8 +14,8 @@ namespace { -std::unique_ptr<mojo::ShellClient> CreateTestApp() { - return std::unique_ptr<mojo::ShellClient>(new TestMojoApp); +std::unique_ptr<shell::ShellClient> CreateTestApp() { + return std::unique_ptr<shell::ShellClient>(new TestMojoApp); } } // namespace
diff --git a/content/test/gpu/generate_buildbot_json.py b/content/test/gpu/generate_buildbot_json.py index 9d93c5e..3b021307 100755 --- a/content/test/gpu/generate_buildbot_json.py +++ b/content/test/gpu/generate_buildbot_json.py
@@ -670,7 +670,14 @@ 'gpu_process_launch_tests': {'target_name': 'gpu_process'}, 'gpu_rasterization': {}, 'hardware_accelerated_feature': {}, - 'maps_pixel_test': {'target_name': 'maps'}, + 'maps_pixel_test': { + 'target_name': 'maps', + 'tester_configs': [ + { + 'allow_on_mac_nvidia': True, + }, + ], + }, 'memory_test': {}, 'pixel_test': { 'target_name': 'pixel', @@ -689,7 +696,12 @@ ], 'precommit_args': [ '--download-refimg-from-cloud-storage', - ] + ], + 'tester_configs': [ + { + 'allow_on_mac_nvidia': True, + }, + ], }, 'screenshot_sync': {}, 'trace_test': {},
diff --git a/content/test/gpu/gpu_tests/screenshot_sync_expectations.py b/content/test/gpu/gpu_tests/screenshot_sync_expectations.py index 44f8e06c..eafcb8c 100644 --- a/content/test/gpu/gpu_tests/screenshot_sync_expectations.py +++ b/content/test/gpu/gpu_tests/screenshot_sync_expectations.py
@@ -11,4 +11,4 @@ super(ScreenshotSyncExpectations, self).__init__(*args, **kwargs) def SetExpectations(self): - pass + self.Flaky('ScreenshotSync.WithCanvas', ['win', 'amd'], bug=602313)
diff --git a/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py b/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py index 2ed7929..79a3e20 100644 --- a/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py +++ b/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py
@@ -55,6 +55,7 @@ self.Fail('conformance2/glsl3/forbidden-operators.html', bug=483282) self.Fail('conformance2/misc/expando-loss-2.html', bug=483282) + self.Flaky('conformance2/query/occlusion-query.html', bug=603168) self.Fail('conformance2/vertex_arrays/vertex-array-object.html', bug=483282) # Windows only. @@ -344,8 +345,6 @@ ['mac'], bug=483282) self.Fail('conformance2/textures/misc/tex-storage-compressed-formats.html', ['mac'], bug=295792) - self.Fail('conformance2/renderbuffers/invalidate-framebuffer.html', - ['mac'], bug=483282) self.Fail('conformance2/renderbuffers/framebuffer-test.html', ['mac'], bug=483282) self.Fail('conformance2/renderbuffers/readbuffer.html',
diff --git a/content/test/gpu/gpu_tests/webgl_conformance_expectations.py b/content/test/gpu/gpu_tests/webgl_conformance_expectations.py index ab49d196..c350d15 100644 --- a/content/test/gpu/gpu_tests/webgl_conformance_expectations.py +++ b/content/test/gpu/gpu_tests/webgl_conformance_expectations.py
@@ -230,10 +230,6 @@ ['android'], bug=478572) self.Fail('conformance/textures/image/tex-2d-rgb-rgb-unsigned_byte.html', ['android'], bug=586183) - self.Fail('conformance/textures/misc/texture-npot-video.html', - ['android', 'android-content-shell'], bug=601110) - self.Fail('conformance/textures/video/*', - ['android'], bug=601110) # The following tests timed out on android, so skip them for now. self.Skip('conformance/textures/image_bitmap_from_video/*', ['android'], bug=585108)
diff --git a/extensions/browser/mojo/stash_backend_unittest.cc b/extensions/browser/mojo/stash_backend_unittest.cc index 52449e6..07048ab 100644 --- a/extensions/browser/mojo/stash_backend_unittest.cc +++ b/extensions/browser/mojo/stash_backend_unittest.cc
@@ -191,7 +191,7 @@ stashed_object->id = "test type"; stashed_object->data.push_back(0); stashed_object->monitor_handles = true; - mojo::shell::mojom::InterfaceProviderPtr service_provider; + shell::mojom::InterfaceProviderPtr service_provider; // Stash the ServiceProvider request. When we make a call on // |service_provider|, the stashed handle will become readable.
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index 4d94ddf..d207979 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -3411,6 +3411,7 @@ 'InvalidateFramebuffer': { 'type': 'PUTn', 'count': 1, + 'decoder_func': 'DoInvalidateFramebuffer', 'client_test': False, 'unit_test': False, 'unsafe': True, @@ -3418,6 +3419,7 @@ 'InvalidateSubFramebuffer': { 'type': 'PUTn', 'count': 1, + 'decoder_func': 'DoInvalidateSubFramebuffer', 'client_test': False, 'unit_test': False, 'unsafe': True, @@ -7598,11 +7600,17 @@ def WriteGetDataSizeCode(self, func, f): """Overrriden from TypeHandler.""" code = """ uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "%s", "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(%s), %d, &data_size)) { return error::kOutOfBounds; } """ - f.write(code % (self.GetArrayType(func), self.GetArrayCount(func))) + f.write(code % (func.name, + self.GetArrayType(func), + self.GetArrayCount(func))) if func.IsImmediate(): f.write(" if (data_size > immediate_data_size) {\n") f.write(" return error::kOutOfBounds;\n")
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index affed33..767a7ca 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -723,6 +723,12 @@ friend class ScopedResolvedFrameBufferBinder; friend class BackFramebuffer; + enum FramebufferOperation { + kFramebufferDiscard, + kFramebufferInvalidate, + kFramebufferInvalidateSub + }; + // Initialize or re-initialize the shader translator. bool InitializeShaderTranslator(); @@ -1450,9 +1456,20 @@ // Wrapper for glDiscardFramebufferEXT, since we need to track undefined // attachments. - void DoDiscardFramebufferEXT(GLenum target, - GLsizei numAttachments, - const GLenum* attachments); + void DoDiscardFramebufferEXT( + GLenum target, GLsizei count, const GLenum* attachments); + + void DoInvalidateFramebuffer( + GLenum target, GLsizei count, const GLenum* attachments); + void DoInvalidateSubFramebuffer( + GLenum target, GLsizei count, const GLenum* attachments, + GLint x, GLint y, GLsizei width, GLsizei height); + + // Helper for DoDiscardFramebufferEXT, DoInvalidate{Sub}Framebuffer. + void InvalidateFramebufferImpl( + GLenum target, GLsizei count, const GLenum* attachments, + GLint x, GLint y, GLsizei width, GLsizei height, + const char* function_name, FramebufferOperation op); // Wrapper for glEnable void DoEnable(GLenum cap); @@ -5047,30 +5064,103 @@ } } -void GLES2DecoderImpl::DoDiscardFramebufferEXT(GLenum target, - GLsizei numAttachments, - const GLenum* attachments) { - if (workarounds().disable_discard_framebuffer) +void GLES2DecoderImpl::InvalidateFramebufferImpl( + GLenum target, GLsizei count, const GLenum* attachments, + GLint x, GLint y, GLsizei width, GLsizei height, + const char* function_name, FramebufferOperation op) { + if (!validators_->frame_buffer_target.IsValid(target)) { + LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "target"); return; + } + Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); - Framebuffer* framebuffer = - GetFramebufferInfoForTarget(GL_FRAMEBUFFER); - - // Validates the attachments. If one of them fails - // the whole command fails. - for (GLsizei i = 0; i < numAttachments; ++i) { - if ((framebuffer && - !validators_->attachment.IsValid(attachments[i])) || - (!framebuffer && - !validators_->backbuffer_attachment.IsValid(attachments[i]))) { - LOCAL_SET_GL_ERROR_INVALID_ENUM( - "glDiscardFramebufferEXT", attachments[i], "attachments"); - return; + // Validates the attachments. If one of them fails, the whole command fails. + GLenum thresh0 = GL_COLOR_ATTACHMENT0 + group_->max_color_attachments(); + GLenum thresh1 = GL_COLOR_ATTACHMENT15; + for (GLsizei i = 0; i < count; ++i) { + if (framebuffer) { + if (attachments[i] >= thresh0 && attachments[i] <= thresh1) { + LOCAL_SET_GL_ERROR( + GL_INVALID_OPERATION, function_name, "invalid attachment"); + return; + } + if (!validators_->attachment.IsValid(attachments[i])) { + LOCAL_SET_GL_ERROR_INVALID_ENUM( + function_name, attachments[i], "attachments"); + return; + } + } else { + if (!validators_->backbuffer_attachment.IsValid(attachments[i])) { + LOCAL_SET_GL_ERROR_INVALID_ENUM( + function_name, attachments[i], "attachments"); + return; + } } } - // Marks each one of them as not cleared - for (GLsizei i = 0; i < numAttachments; ++i) { + if (width < 0 || height < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "negative size"); + return; + } + + // If the default framebuffer is bound but we are still rendering to an + // FBO, translate attachment names that refer to default framebuffer + // channels to corresponding framebuffer attachments. + scoped_ptr<GLenum[]> translated_attachments(new GLenum[count]); + for (GLsizei i = 0; i < count; ++i) { + GLenum attachment = attachments[i]; + if (!framebuffer && GetBackbufferServiceId()) { + switch (attachment) { + case GL_COLOR_EXT: + attachment = GL_COLOR_ATTACHMENT0; + break; + case GL_DEPTH_EXT: + attachment = GL_DEPTH_ATTACHMENT; + break; + case GL_STENCIL_EXT: + attachment = GL_STENCIL_ATTACHMENT; + break; + default: + NOTREACHED(); + return; + } + } + translated_attachments[i] = attachment; + } + + bool dirty = false; + switch (op) { + case kFramebufferDiscard: + if (feature_info_->gl_version_info().is_es3) { + glInvalidateFramebuffer( + target, count, translated_attachments.get()); + } else { + glDiscardFramebufferEXT( + target, count, translated_attachments.get()); + } + dirty = true; + break; + case kFramebufferInvalidate: + if (feature_info_->gl_version_info().IsLowerThanGL(4, 3)) { + // no-op since the function isn't supported. + } else { + glInvalidateFramebuffer( + target, count, translated_attachments.get()); + dirty = true; + } + break; + case kFramebufferInvalidateSub: + // Make it an no-op because we don't have a mechanism to mark partial + // pixels uncleared yet. + // TODO(zmo): Revisit this. + break; + } + + if (!dirty) + return; + + // Marks each one of them as not cleared. + for (GLsizei i = 0; i < count; ++i) { if (framebuffer) { framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), texture_manager(), @@ -5093,39 +5183,36 @@ } } } +} - // If the default framebuffer is bound but we are still rendering to an - // FBO, translate attachment names that refer to default framebuffer - // channels to corresponding framebuffer attachments. - scoped_ptr<GLenum[]> translated_attachments(new GLenum[numAttachments]); - for (GLsizei i = 0; i < numAttachments; ++i) { - GLenum attachment = attachments[i]; - if (!framebuffer && GetBackbufferServiceId()) { - switch (attachment) { - case GL_COLOR_EXT: - attachment = GL_COLOR_ATTACHMENT0; - break; - case GL_DEPTH_EXT: - attachment = GL_DEPTH_ATTACHMENT; - break; - case GL_STENCIL_EXT: - attachment = GL_STENCIL_ATTACHMENT; - break; - default: - NOTREACHED(); - return; - } - } - translated_attachments[i] = attachment; - } +void GLES2DecoderImpl::DoDiscardFramebufferEXT(GLenum target, + GLsizei count, + const GLenum* attachments) { + if (workarounds().disable_discard_framebuffer) + return; - if (feature_info_->gl_version_info().is_es3) { - glInvalidateFramebuffer( - target, numAttachments, translated_attachments.get()); - } else { - glDiscardFramebufferEXT( - target, numAttachments, translated_attachments.get()); - } + const GLsizei kWidthNotUsed = 1; + const GLsizei kHeightNotUsed = 1; + InvalidateFramebufferImpl( + target, count, attachments, 0, 0, kWidthNotUsed, kHeightNotUsed, + "glDiscardFramebufferEXT", kFramebufferDiscard); +} + +void GLES2DecoderImpl::DoInvalidateFramebuffer( + GLenum target, GLsizei count, const GLenum* attachments) { + const GLsizei kWidthNotUsed = 1; + const GLsizei kHeightNotUsed = 1; + InvalidateFramebufferImpl( + target, count, attachments, 0, 0, kWidthNotUsed, kHeightNotUsed, + "glInvalidateFramebuffer", kFramebufferInvalidate); +} + +void GLES2DecoderImpl::DoInvalidateSubFramebuffer( + GLenum target, GLsizei count, const GLenum* attachments, + GLint x, GLint y, GLsizei width, GLsizei height) { + InvalidateFramebufferImpl( + target, count, attachments, x, y, width, height, + "glInvalidateSubFramebuffer", kFramebufferInvalidateSub); } void GLES2DecoderImpl::DoEnableVertexAttribArray(GLuint index) { @@ -15070,34 +15157,76 @@ LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetInternalformativ", pname, "pname"); return error::kNoError; } + typedef cmds::GetInternalformativ::Result Result; GLsizei num_values = 0; - switch (pname) { - case GL_NUM_SAMPLE_COUNTS: - num_values = 1; - break; - case GL_SAMPLES: - { - GLint value = 0; - glGetInternalformativ(target, format, GL_NUM_SAMPLE_COUNTS, 1, &value); - num_values = static_cast<GLsizei>(value); + std::vector<GLint> samples; + if (feature_info_->gl_version_info().IsLowerThanGL(4, 2)) { + if (!GLES2Util::IsIntegerFormat(format) && + !GLES2Util::IsFloatFormat(format)) { + // No multisampling for integer formats and float formats. + GLint max_samples = renderbuffer_manager()->max_samples(); + while (max_samples > 0) { + samples.push_back(max_samples); + max_samples = max_samples >> 1; } - break; - default: - NOTREACHED(); - break; + } + switch (pname) { + case GL_NUM_SAMPLE_COUNTS: + num_values = 1; + break; + case GL_SAMPLES: + num_values = static_cast<GLsizei>(samples.size()); + break; + default: + NOTREACHED(); + break; + } + } else { + switch (pname) { + case GL_NUM_SAMPLE_COUNTS: + num_values = 1; + break; + case GL_SAMPLES: + { + GLint value = 0; + glGetInternalformativ( + target, format, GL_NUM_SAMPLE_COUNTS, 1, &value); + num_values = static_cast<GLsizei>(value); + } + break; + default: + NOTREACHED(); + break; + } } Result* result = GetSharedMemoryAs<Result*>( c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); GLint* params = result ? result->GetData() : NULL; - if (params == NULL) { + if (params == nullptr) { return error::kOutOfBounds; } // Check that the client initialized the result. if (result->size != 0) { return error::kInvalidArguments; } - glGetInternalformativ(target, format, pname, num_values, params); + if (feature_info_->gl_version_info().IsLowerThanGL(4, 2)) { + switch (pname) { + case GL_NUM_SAMPLE_COUNTS: + params[0] = static_cast<GLint>(samples.size()); + break; + case GL_SAMPLES: + for (size_t ii = 0; ii < samples.size(); ++ii) { + params[ii] = samples[ii]; + } + break; + default: + NOTREACHED(); + break; + } + } else { + glGetInternalformativ(target, format, pname, num_values, params); + } result->SetNumResults(num_values); return error::kNoError; }
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h index b56ae2cd..54b8dcf 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
@@ -2088,6 +2088,11 @@ GLenum target = static_cast<GLenum>(c.target); GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "InvalidateFramebufferImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) { return error::kOutOfBounds; } @@ -2099,7 +2104,7 @@ if (attachments == NULL) { return error::kOutOfBounds; } - glInvalidateFramebuffer(target, count, attachments); + DoInvalidateFramebuffer(target, count, attachments); return error::kNoError; } @@ -2115,6 +2120,11 @@ GLenum target = static_cast<GLenum>(c.target); GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "InvalidateSubFramebufferImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) { return error::kOutOfBounds; } @@ -2130,7 +2140,7 @@ if (attachments == NULL) { return error::kOutOfBounds; } - glInvalidateSubFramebuffer(target, count, attachments, x, y, width, height); + DoInvalidateSubFramebuffer(target, count, attachments, x, y, width, height); return error::kNoError; } @@ -2960,6 +2970,11 @@ GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "Uniform1fvImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLfloat), 1, &data_size)) { return error::kOutOfBounds; } @@ -2995,6 +3010,11 @@ GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "Uniform1ivImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLint), 1, &data_size)) { return error::kOutOfBounds; } @@ -3037,6 +3057,11 @@ GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "Uniform1uivImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLuint), 1, &data_size)) { return error::kOutOfBounds; } @@ -3076,6 +3101,11 @@ GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "Uniform2fvImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLfloat), 2, &data_size)) { return error::kOutOfBounds; } @@ -3115,6 +3145,11 @@ GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "Uniform2ivImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLint), 2, &data_size)) { return error::kOutOfBounds; } @@ -3158,6 +3193,11 @@ GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "Uniform2uivImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLuint), 2, &data_size)) { return error::kOutOfBounds; } @@ -3198,6 +3238,11 @@ GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "Uniform3fvImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLfloat), 3, &data_size)) { return error::kOutOfBounds; } @@ -3238,6 +3283,11 @@ GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "Uniform3ivImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLint), 3, &data_size)) { return error::kOutOfBounds; } @@ -3282,6 +3332,11 @@ GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "Uniform3uivImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLuint), 3, &data_size)) { return error::kOutOfBounds; } @@ -3323,6 +3378,11 @@ GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "Uniform4fvImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) { return error::kOutOfBounds; } @@ -3364,6 +3424,11 @@ GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "Uniform4ivImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLint), 4, &data_size)) { return error::kOutOfBounds; } @@ -3409,6 +3474,11 @@ GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "Uniform4uivImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLuint), 4, &data_size)) { return error::kOutOfBounds; } @@ -3434,6 +3504,11 @@ GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "UniformMatrix2fvImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) { return error::kOutOfBounds; } @@ -3461,6 +3536,11 @@ GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "UniformMatrix2x3fvImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLfloat), 6, &data_size)) { return error::kOutOfBounds; } @@ -3488,6 +3568,11 @@ GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "UniformMatrix2x4fvImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLfloat), 8, &data_size)) { return error::kOutOfBounds; } @@ -3513,6 +3598,11 @@ GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "UniformMatrix3fvImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLfloat), 9, &data_size)) { return error::kOutOfBounds; } @@ -3540,6 +3630,11 @@ GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "UniformMatrix3x2fvImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLfloat), 6, &data_size)) { return error::kOutOfBounds; } @@ -3567,6 +3662,11 @@ GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "UniformMatrix3x4fvImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLfloat), 12, &data_size)) { return error::kOutOfBounds; } @@ -3592,6 +3692,11 @@ GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "UniformMatrix4fvImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLfloat), 16, &data_size)) { return error::kOutOfBounds; } @@ -3619,6 +3724,11 @@ GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "UniformMatrix4x2fvImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLfloat), 8, &data_size)) { return error::kOutOfBounds; } @@ -3646,6 +3756,11 @@ GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "UniformMatrix4x3fvImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLfloat), 12, &data_size)) { return error::kOutOfBounds; } @@ -4763,6 +4878,11 @@ GLenum target = static_cast<GLenum>(c.target); GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "DiscardFramebufferEXTImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) { return error::kOutOfBounds; } @@ -4812,6 +4932,11 @@ (void)c; GLsizei count = static_cast<GLsizei>(c.count); uint32_t data_size; + if (count < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "DrawBuffersEXTImmediate", + "negative count"); + return error::kNoError; + } if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) { return error::kOutOfBounds; }
diff --git a/ios/chrome/BUILD.gn b/ios/chrome/BUILD.gn index d13d8176..d7843da 100644 --- a/ios/chrome/BUILD.gn +++ b/ios/chrome/BUILD.gn
@@ -2,8 +2,26 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/ios/rules.gni") import("//testing/test.gni") +bundle_data("ios_chrome_unittests_bundle_data") { + testonly = true + sources = [ + "test/data/webdata/bookmarkimages/image.jpg", + "test/data/webdata/bookmarkimages/index.html", + ] + outputs = [ + "{{bundle_resources_dir}}/{{source_root_relative_dir}}/" + + "{{source_file_part}}", + ] +} + +bundle_data_xib("native_content_controller_test_xib") { + testonly = true + source = "browser/ui/native_content_controller_test.xib" +} + test("ios_chrome_unittests") { sources = [ "app/safe_mode_util_unittest.cc", @@ -44,6 +62,8 @@ ] deps = [ + ":ios_chrome_unittests_bundle_data", + ":native_content_controller_test_xib", "//base", "//base/test:test_support", "//components/bookmarks/test", @@ -73,24 +93,4 @@ "//third_party/ocmock", "//ui/gfx:test_support", ] - - # TODO(crbug.com/546283): once bundle resources are supported add code - # corresponding to the following gyp fragment: - # - # 'mac_bundle_resources': [ - # 'browser/ui/native_content_controller_test.xib' - # ], - # 'actions': [ - # { - # 'action_name': 'copy_ios_chrome_test_data', - # 'variables': { - # 'test_data_files': [ - # 'test/data/webdata/bookmarkimages', - # ], - # 'test_data_prefix': 'ios/chrome', - # }, - # 'includes': [ '../../build/copy_test_data_ios.gypi' ] - # }, - # ], - # 'includes': ['ios_chrome_resources_bundle.gypi'], }
diff --git a/ios/third_party/earl_grey/BUILD.gn b/ios/third_party/earl_grey/BUILD.gn new file mode 100644 index 0000000..bf9c18c --- /dev/null +++ b/ios/third_party/earl_grey/BUILD.gn
@@ -0,0 +1,256 @@ +# Copyright 2016 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/config/ios/ios_sdk.gni") +import("//build/config/ios/rules.gni") + +config("config") { + include_dirs = [ "src/EarlGrey" ] + + # EarlGrey and its dependencies need to link to XCTest.framework + # that is not under $ios_sdk_path. + common_flags = [ "-F$ios_sdk_path/../../Library/Frameworks" ] + cflags_objc = common_flags + cflags_objcc = common_flags + ldflags = common_flags +} + +ios_framework_bundle("earl_grey") { + output_name = "EarlGrey" + + testonly = true + sources = [ + "src/EarlGrey/Action/GREYAction.h", + "src/EarlGrey/Action/GREYActionBlock.h", + "src/EarlGrey/Action/GREYActionBlock.m", + "src/EarlGrey/Action/GREYActions.h", + "src/EarlGrey/Action/GREYActions.m", + "src/EarlGrey/Action/GREYBaseAction.h", + "src/EarlGrey/Action/GREYBaseAction.m", + "src/EarlGrey/Action/GREYChangeStepperAction.h", + "src/EarlGrey/Action/GREYChangeStepperAction.m", + "src/EarlGrey/Action/GREYPathGestureUtils.h", + "src/EarlGrey/Action/GREYPathGestureUtils.m", + "src/EarlGrey/Action/GREYPickerAction.h", + "src/EarlGrey/Action/GREYPickerAction.m", + "src/EarlGrey/Action/GREYScrollAction.h", + "src/EarlGrey/Action/GREYScrollAction.m", + "src/EarlGrey/Action/GREYScrollActionError.h", + "src/EarlGrey/Action/GREYScrollActionError.m", + "src/EarlGrey/Action/GREYScrollToContentEdgeAction.h", + "src/EarlGrey/Action/GREYScrollToContentEdgeAction.m", + "src/EarlGrey/Action/GREYSlideAction.h", + "src/EarlGrey/Action/GREYSlideAction.m", + "src/EarlGrey/Action/GREYSwipeAction.h", + "src/EarlGrey/Action/GREYSwipeAction.m", + "src/EarlGrey/Action/GREYTapAction.h", + "src/EarlGrey/Action/GREYTapAction.m", + "src/EarlGrey/Action/GREYTapper.h", + "src/EarlGrey/Action/GREYTapper.m", + "src/EarlGrey/Additions/CAAnimation+GREYAdditions.h", + "src/EarlGrey/Additions/CAAnimation+GREYAdditions.m", + "src/EarlGrey/Additions/CALayer+GREYAdditions.h", + "src/EarlGrey/Additions/CALayer+GREYAdditions.m", + "src/EarlGrey/Additions/CGGeometry+GREYAdditions.h", + "src/EarlGrey/Additions/CGGeometry+GREYAdditions.m", + "src/EarlGrey/Additions/NSError+GREYAdditions.h", + "src/EarlGrey/Additions/NSError+GREYAdditions.m", + "src/EarlGrey/Additions/NSObject+GREYAdditions.h", + "src/EarlGrey/Additions/NSObject+GREYAdditions.m", + "src/EarlGrey/Additions/NSRunLoop+GREYAdditions.h", + "src/EarlGrey/Additions/NSRunLoop+GREYAdditions.m", + "src/EarlGrey/Additions/NSString+GREYAdditions.h", + "src/EarlGrey/Additions/NSString+GREYAdditions.m", + "src/EarlGrey/Additions/NSTimer+GREYAdditions.h", + "src/EarlGrey/Additions/NSTimer+GREYAdditions.m", + "src/EarlGrey/Additions/NSURL+GREYAdditions.h", + "src/EarlGrey/Additions/NSURL+GREYAdditions.m", + "src/EarlGrey/Additions/NSURLConnection+GREYAdditions.h", + "src/EarlGrey/Additions/NSURLConnection+GREYAdditions.m", + "src/EarlGrey/Additions/UIAnimation+GREYAdditions.h", + "src/EarlGrey/Additions/UIAnimation+GREYAdditions.m", + "src/EarlGrey/Additions/UIApplication+GREYAdditions.h", + "src/EarlGrey/Additions/UIApplication+GREYAdditions.m", + "src/EarlGrey/Additions/UIScrollView+GREYAdditions.h", + "src/EarlGrey/Additions/UIScrollView+GREYAdditions.m", + "src/EarlGrey/Additions/UISwitch+GREYAdditions.h", + "src/EarlGrey/Additions/UISwitch+GREYAdditions.m", + "src/EarlGrey/Additions/UITouch+GREYAdditions.h", + "src/EarlGrey/Additions/UITouch+GREYAdditions.m", + "src/EarlGrey/Additions/UIView+GREYAdditions.h", + "src/EarlGrey/Additions/UIView+GREYAdditions.m", + "src/EarlGrey/Additions/UIViewController+GREYAdditions.h", + "src/EarlGrey/Additions/UIViewController+GREYAdditions.m", + "src/EarlGrey/Additions/UIWebView+GREYAdditions.h", + "src/EarlGrey/Additions/UIWebView+GREYAdditions.m", + "src/EarlGrey/Additions/UIWindow+GREYAdditions.h", + "src/EarlGrey/Additions/UIWindow+GREYAdditions.m", + "src/EarlGrey/Additions/XCTestCase+GREYAdditions.h", + "src/EarlGrey/Additions/XCTestCase+GREYAdditions.m", + "src/EarlGrey/Additions/_UIGestureRecognizerFailureMap_GREYAdditions.h", + "src/EarlGrey/Additions/_UIGestureRecognizerFailureMap_GREYAdditions.m", + "src/EarlGrey/Additions/_UIModalItemsPresentingViewController_GREYAdditions.h", + "src/EarlGrey/Additions/_UIModalItemsPresentingViewController_GREYAdditions.m", + "src/EarlGrey/Additions/__NSCFLocalDataTask_GREYAdditions.h", + "src/EarlGrey/Additions/__NSCFLocalDataTask_GREYAdditions.m", + "src/EarlGrey/AppSupport/GREYIdlingResource.h", + "src/EarlGrey/Assertion/GREYAssertion.h", + "src/EarlGrey/Assertion/GREYAssertionBlock.h", + "src/EarlGrey/Assertion/GREYAssertionBlock.m", + "src/EarlGrey/Assertion/GREYAssertionDefines.h", + "src/EarlGrey/Assertion/GREYAssertions.h", + "src/EarlGrey/Assertion/GREYAssertions.m", + "src/EarlGrey/Common/GREYAnalytics.h", + "src/EarlGrey/Common/GREYAnalytics.m", + "src/EarlGrey/Common/GREYConfiguration.h", + "src/EarlGrey/Common/GREYConfiguration.m", + "src/EarlGrey/Common/GREYConstants.h", + "src/EarlGrey/Common/GREYConstants.m", + "src/EarlGrey/Common/GREYDefines.h", + "src/EarlGrey/Common/GREYElementHierarchy.h", + "src/EarlGrey/Common/GREYElementHierarchy.m", + "src/EarlGrey/Common/GREYExposed.h", + "src/EarlGrey/Common/GREYPrivate.h", + "src/EarlGrey/Common/GREYScreenshotUtil.h", + "src/EarlGrey/Common/GREYScreenshotUtil.m", + "src/EarlGrey/Common/GREYSwizzler.h", + "src/EarlGrey/Common/GREYSwizzler.m", + "src/EarlGrey/Common/GREYVisibilityChecker.h", + "src/EarlGrey/Common/GREYVisibilityChecker.m", + "src/EarlGrey/Core/GREYElementFinder.h", + "src/EarlGrey/Core/GREYElementFinder.m", + "src/EarlGrey/Core/GREYElementInteraction.h", + "src/EarlGrey/Core/GREYElementInteraction.m", + "src/EarlGrey/Core/GREYInteraction.h", + "src/EarlGrey/Core/GREYInteractionDataSource.h", + "src/EarlGrey/Core/GREYKeyboard.h", + "src/EarlGrey/Core/GREYKeyboard.m", + "src/EarlGrey/Delegate/GREYCAAnimationDelegate.h", + "src/EarlGrey/Delegate/GREYCAAnimationDelegate.m", + "src/EarlGrey/Delegate/GREYNSURLConnectionDelegate.h", + "src/EarlGrey/Delegate/GREYNSURLConnectionDelegate.m", + "src/EarlGrey/Delegate/GREYSurrogateDelegate.h", + "src/EarlGrey/Delegate/GREYSurrogateDelegate.m", + "src/EarlGrey/Delegate/GREYUIWebViewDelegate.h", + "src/EarlGrey/Delegate/GREYUIWebViewDelegate.m", + "src/EarlGrey/EarlGrey.h", + "src/EarlGrey/EarlGrey.m", + "src/EarlGrey/Event/GREYSingleSequenceTouchInjector.h", + "src/EarlGrey/Event/GREYSingleSequenceTouchInjector.m", + "src/EarlGrey/Event/GREYSyntheticEvents.h", + "src/EarlGrey/Event/GREYSyntheticEvents.m", + "src/EarlGrey/Exception/GREYDefaultFailureHandler.h", + "src/EarlGrey/Exception/GREYDefaultFailureHandler.m", + "src/EarlGrey/Exception/GREYFailureHandler.h", + "src/EarlGrey/Exception/GREYFrameworkException.h", + "src/EarlGrey/Exception/GREYFrameworkException.m", + "src/EarlGrey/Matcher/GREYAllOf.h", + "src/EarlGrey/Matcher/GREYAllOf.m", + "src/EarlGrey/Matcher/GREYAnyOf.h", + "src/EarlGrey/Matcher/GREYAnyOf.m", + "src/EarlGrey/Matcher/GREYBaseMatcher.h", + "src/EarlGrey/Matcher/GREYBaseMatcher.m", + "src/EarlGrey/Matcher/GREYDescription.h", + "src/EarlGrey/Matcher/GREYElementMatcherBlock.h", + "src/EarlGrey/Matcher/GREYElementMatcherBlock.m", + "src/EarlGrey/Matcher/GREYHCMatcher.h", + "src/EarlGrey/Matcher/GREYHCMatcher.m", + "src/EarlGrey/Matcher/GREYLayoutConstraint.h", + "src/EarlGrey/Matcher/GREYLayoutConstraint.m", + "src/EarlGrey/Matcher/GREYMatcher.h", + "src/EarlGrey/Matcher/GREYMatchers.h", + "src/EarlGrey/Matcher/GREYMatchers.m", + "src/EarlGrey/Matcher/GREYNot.h", + "src/EarlGrey/Matcher/GREYNot.m", + "src/EarlGrey/Matcher/GREYStringDescription.h", + "src/EarlGrey/Matcher/GREYStringDescription.m", + "src/EarlGrey/Provider/GREYDataEnumerator.h", + "src/EarlGrey/Provider/GREYDataEnumerator.m", + "src/EarlGrey/Provider/GREYElementProvider.h", + "src/EarlGrey/Provider/GREYElementProvider.m", + "src/EarlGrey/Provider/GREYProvider.h", + "src/EarlGrey/Provider/GREYUIWindowProvider.h", + "src/EarlGrey/Provider/GREYUIWindowProvider.m", + "src/EarlGrey/Synchronization/GREYAppStateTracker.h", + "src/EarlGrey/Synchronization/GREYAppStateTracker.m", + "src/EarlGrey/Synchronization/GREYBeaconImageProtocol.h", + "src/EarlGrey/Synchronization/GREYBeaconImageProtocol.m", + "src/EarlGrey/Synchronization/GREYCondition.h", + "src/EarlGrey/Synchronization/GREYCondition.m", + "src/EarlGrey/Synchronization/GREYDispatchQueueIdlingResource.h", + "src/EarlGrey/Synchronization/GREYDispatchQueueIdlingResource.m", + "src/EarlGrey/Synchronization/GREYNSTimerIdlingResource.h", + "src/EarlGrey/Synchronization/GREYNSTimerIdlingResource.m", + "src/EarlGrey/Synchronization/GREYOperationQueueIdlingResource.h", + "src/EarlGrey/Synchronization/GREYOperationQueueIdlingResource.m", + "src/EarlGrey/Synchronization/GREYSyncAPI.h", + "src/EarlGrey/Synchronization/GREYSyncAPI.m", + "src/EarlGrey/Synchronization/GREYTimedIdlingResource.h", + "src/EarlGrey/Synchronization/GREYTimedIdlingResource.m", + "src/EarlGrey/Synchronization/GREYUIThreadExecutor.h", + "src/EarlGrey/Synchronization/GREYUIThreadExecutor.m", + "src/EarlGrey/Synchronization/GREYUIWebViewIdlingResource.h", + "src/EarlGrey/Synchronization/GREYUIWebViewIdlingResource.m", + ] + public_headers = [ + "src/EarlGrey/EarlGrey.h", + "src/EarlGrey/Action/GREYAction.h", + "src/EarlGrey/Action/GREYActionBlock.h", + "src/EarlGrey/Action/GREYActions.h", + "src/EarlGrey/Action/GREYBaseAction.h", + "src/EarlGrey/Action/GREYScrollActionError.h", + "src/EarlGrey/AppSupport/GREYIdlingResource.h", + "src/EarlGrey/Assertion/GREYAssertion.h", + "src/EarlGrey/Assertion/GREYAssertionBlock.h", + "src/EarlGrey/Assertion/GREYAssertionDefines.h", + "src/EarlGrey/Assertion/GREYAssertions.h", + "src/EarlGrey/Common/GREYConfiguration.h", + "src/EarlGrey/Common/GREYConstants.h", + "src/EarlGrey/Common/GREYDefines.h", + "src/EarlGrey/Common/GREYElementHierarchy.h", + "src/EarlGrey/Common/GREYScreenshotUtil.h", + "src/EarlGrey/Core/GREYElementFinder.h", + "src/EarlGrey/Core/GREYElementInteraction.h", + "src/EarlGrey/Core/GREYInteraction.h", + "src/EarlGrey/Exception/GREYFailureHandler.h", + "src/EarlGrey/Exception/GREYFrameworkException.h", + "src/EarlGrey/Matcher/GREYAllOf.h", + "src/EarlGrey/Matcher/GREYAnyOf.h", + "src/EarlGrey/Matcher/GREYBaseMatcher.h", + "src/EarlGrey/Matcher/GREYDescription.h", + "src/EarlGrey/Matcher/GREYElementMatcherBlock.h", + "src/EarlGrey/Matcher/GREYLayoutConstraint.h", + "src/EarlGrey/Matcher/GREYMatcher.h", + "src/EarlGrey/Matcher/GREYMatchers.h", + "src/EarlGrey/Matcher/GREYNot.h", + "src/EarlGrey/Provider/GREYDataEnumerator.h", + "src/EarlGrey/Provider/GREYProvider.h", + "src/EarlGrey/Synchronization/GREYNSTimerIdlingResource.h", + "src/EarlGrey/Synchronization/GREYOperationQueueIdlingResource.h", + "src/EarlGrey/Synchronization/GREYDispatchQueueIdlingResource.h", + "src/EarlGrey/Synchronization/GREYSyncAPI.h", + "src/EarlGrey/Synchronization/GREYCondition.h", + "src/EarlGrey/Synchronization/GREYUIThreadExecutor.h", + ] + deps = [ + "//ios/third_party/fishhook", + "//third_party/google_toolbox_for_mac", + ] + public_deps = [ + "//ios/third_party/ochamcrest", + ] + + libs = [ + "CoreGraphics.framework", + "Foundation.framework", + "IOKit.framework", + "QuartzCore.framework", + "UIKit.framework", + "XCTest.framework", + ] + + public_configs = [ ":config" ] + configs += [ "//build/config/compiler:enable_arc" ] + configs -= [ "//build/config/gcc:symbol_visibility_hidden" ] +}
diff --git a/ios/third_party/ochamcrest/BUILD.gn b/ios/third_party/ochamcrest/BUILD.gn index 4029427..754f4ff 100644 --- a/ios/third_party/ochamcrest/BUILD.gn +++ b/ios/third_party/ochamcrest/BUILD.gn
@@ -5,8 +5,9 @@ import("//build/config/ios/rules.gni") ios_framework_bundle("ochamcrest") { - testonly = true output_name = "OCHamcrest" + + testonly = true sources = [ "src/Source/Core/HCAssertThat.h", "src/Source/Core/HCAssertThat.m",
diff --git a/mash/browser_driver/browser_driver_application_delegate.cc b/mash/browser_driver/browser_driver_application_delegate.cc index ad1613d9..9038bf1 100644 --- a/mash/browser_driver/browser_driver_application_delegate.cc +++ b/mash/browser_driver/browser_driver_application_delegate.cc
@@ -55,15 +55,15 @@ BrowserDriverApplicationDelegate::~BrowserDriverApplicationDelegate() {} void BrowserDriverApplicationDelegate::Initialize( - mojo::Connector* connector, - const mojo::Identity& identity, + shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { connector_ = connector; AddAccelerators(); } bool BrowserDriverApplicationDelegate::AcceptConnection( - mojo::Connection* connection) { + shell::Connection* connection) { return true; }
diff --git a/mash/browser_driver/browser_driver_application_delegate.h b/mash/browser_driver/browser_driver_application_delegate.h index 2a251c26..73c34aad 100644 --- a/mash/browser_driver/browser_driver_application_delegate.h +++ b/mash/browser_driver/browser_driver_application_delegate.h
@@ -19,17 +19,18 @@ namespace mash { namespace browser_driver { -class BrowserDriverApplicationDelegate : public mojo::ShellClient, +class BrowserDriverApplicationDelegate : public shell::ShellClient, public mus::mojom::AcceleratorHandler { public: BrowserDriverApplicationDelegate(); ~BrowserDriverApplicationDelegate() override; private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; bool ShellConnectionLost() override; // mus::mojom::AcceleratorHandler: @@ -37,7 +38,7 @@ void AddAccelerators(); - mojo::Connector* connector_; + shell::Connector* connector_; mojo::Binding<mus::mojom::AcceleratorHandler> binding_; base::WeakPtrFactory<BrowserDriverApplicationDelegate> weak_factory_;
diff --git a/mash/browser_driver/main.cc b/mash/browser_driver/main.cc index bf94339..53244a7 100644 --- a/mash/browser_driver/main.cc +++ b/mash/browser_driver/main.cc
@@ -7,7 +7,7 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner( + shell::ApplicationRunner runner( new mash::browser_driver::BrowserDriverApplicationDelegate); return runner.Run(shell_handle); }
diff --git a/mash/example/common/mus_views_init.h b/mash/example/common/mus_views_init.h index 04a02ec..1f98392 100644 --- a/mash/example/common/mus_views_init.h +++ b/mash/example/common/mus_views_init.h
@@ -25,7 +25,7 @@ class MUSViewsInit : public views::ViewsDelegate, public mus::WindowTreeDelegate { public: - explicit MUSViewsInit(mojo::ShellConnection* app); + explicit MUSViewsInit(shell::ShellConnection* app); ~MUSViewsInit() override; private: @@ -45,7 +45,7 @@ HICON GetSmallWindowIcon() const override; #endif - mojo::ShellConnection* app_; + shell::ShellConnection* app_; std::unique_ptr<views::AuraInit> aura_init_; mus::mojom::WindowManagerPtr window_manager_;
diff --git a/mash/example/views_examples/main.cc b/mash/example/views_examples/main.cc index 04b63b5..4f30f49 100644 --- a/mash/example/views_examples/main.cc +++ b/mash/example/views_examples/main.cc
@@ -7,6 +7,6 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner(new ViewsExamplesApplicationDelegate); + shell::ApplicationRunner runner(new ViewsExamplesApplicationDelegate); return runner.Run(shell_handle); }
diff --git a/mash/example/views_examples/views_examples_application_delegate.cc b/mash/example/views_examples/views_examples_application_delegate.cc index 2bb77d3a..ef2e8c7 100644 --- a/mash/example/views_examples/views_examples_application_delegate.cc +++ b/mash/example/views_examples/views_examples_application_delegate.cc
@@ -17,8 +17,8 @@ } void ViewsExamplesApplicationDelegate::Initialize( - mojo::Connector* connector, - const mojo::Identity& identity, + shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { tracing_.Initialize(connector, identity.name()); aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); @@ -30,6 +30,6 @@ } bool ViewsExamplesApplicationDelegate::AcceptConnection( - mojo::Connection* connection) { + shell::Connection* connection) { return false; }
diff --git a/mash/example/views_examples/views_examples_application_delegate.h b/mash/example/views_examples/views_examples_application_delegate.h index 2d348a01..005dde7f89 100644 --- a/mash/example/views_examples/views_examples_application_delegate.h +++ b/mash/example/views_examples/views_examples_application_delegate.h
@@ -15,16 +15,17 @@ class AuraInit; } -class ViewsExamplesApplicationDelegate : public mojo::ShellClient { +class ViewsExamplesApplicationDelegate : public shell::ShellClient { public: ViewsExamplesApplicationDelegate(); ~ViewsExamplesApplicationDelegate() override; private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; mojo::TracingImpl tracing_;
diff --git a/mash/example/window_type_launcher/main.cc b/mash/example/window_type_launcher/main.cc index 0f2ee76..04cd24d 100644 --- a/mash/example/window_type_launcher/main.cc +++ b/mash/example/window_type_launcher/main.cc
@@ -39,8 +39,8 @@ base::AtExitManager at_exit; base::CommandLine::Init(argc, argv); - mojo::shell::InitializeLogging(); - mojo::shell::WaitForDebuggerIfNecessary(); + shell::InitializeLogging(); + shell::WaitForDebuggerIfNecessary(); #if !defined(OFFICIAL_BUILD) base::debug::EnableInProcessStackDumping(); @@ -62,8 +62,8 @@ base::MessageLoop loop; WindowTypeLauncher delegate; - mojo::ShellConnection impl( - &delegate, mojo::shell::GetShellClientRequestFromCommandLine()); + shell::ShellConnection impl(&delegate, + shell::GetShellClientRequestFromCommandLine()); loop.Run(); mojo::edk::ShutdownIPCSupport();
diff --git a/mash/example/window_type_launcher/window_type_launcher.cc b/mash/example/window_type_launcher/window_type_launcher.cc index 5cb94e5..e18b8a7 100644 --- a/mash/example/window_type_launcher/window_type_launcher.cc +++ b/mash/example/window_type_launcher/window_type_launcher.cc
@@ -165,38 +165,48 @@ public views::MenuDelegate, public views::ContextMenuController { public: - explicit WindowTypeLauncherView(mojo::Connector* connector) + explicit WindowTypeLauncherView(shell::Connector* connector) : connector_(connector), - create_button_(new views::LabelButton( - this, base::ASCIIToUTF16("Create Window"))), - panel_button_(new views::LabelButton( - this, base::ASCIIToUTF16("Create Panel"))), + create_button_( + new views::LabelButton(this, base::ASCIIToUTF16("Create Window"))), + panel_button_( + new views::LabelButton(this, base::ASCIIToUTF16("Create Panel"))), create_nonresizable_button_(new views::LabelButton( - this, base::ASCIIToUTF16("Create Non-Resizable Window"))), - bubble_button_(new views::LabelButton( - this, base::ASCIIToUTF16("Create Pointy Bubble"))), - lock_button_(new views::LabelButton( - this, base::ASCIIToUTF16("Lock Screen"))), - logout_button_(new views::LabelButton( - this, base::ASCIIToUTF16("Log Out"))), - switch_user_button_(new views::LabelButton( - this, base::ASCIIToUTF16("Switch User"))), - widgets_button_(new views::LabelButton( - this, base::ASCIIToUTF16("Show Example Widgets"))), + this, + base::ASCIIToUTF16("Create Non-Resizable Window"))), + bubble_button_( + new views::LabelButton(this, + base::ASCIIToUTF16("Create Pointy Bubble"))), + lock_button_( + new views::LabelButton(this, base::ASCIIToUTF16("Lock Screen"))), + logout_button_( + new views::LabelButton(this, base::ASCIIToUTF16("Log Out"))), + switch_user_button_( + new views::LabelButton(this, base::ASCIIToUTF16("Switch User"))), + widgets_button_( + new views::LabelButton(this, + base::ASCIIToUTF16("Show Example Widgets"))), system_modal_button_(new views::LabelButton( - this, base::ASCIIToUTF16("Open System Modal Window"))), + this, + base::ASCIIToUTF16("Open System Modal Window"))), window_modal_button_(new views::LabelButton( - this, base::ASCIIToUTF16("Open Window Modal Window"))), + this, + base::ASCIIToUTF16("Open Window Modal Window"))), child_modal_button_(new views::LabelButton( - this, base::ASCIIToUTF16("Open Child Modal Window"))), + this, + base::ASCIIToUTF16("Open Child Modal Window"))), transient_button_(new views::LabelButton( - this, base::ASCIIToUTF16("Open Non-Modal Transient Window"))), + this, + base::ASCIIToUTF16("Open Non-Modal Transient Window"))), examples_button_(new views::LabelButton( - this, base::ASCIIToUTF16("Open Views Examples Window"))), - show_hide_window_button_(new views::LabelButton( - this, base::ASCIIToUTF16("Show/Hide a Window"))), + this, + base::ASCIIToUTF16("Open Views Examples Window"))), + show_hide_window_button_( + new views::LabelButton(this, + base::ASCIIToUTF16("Show/Hide a Window"))), show_web_notification_(new views::LabelButton( - this, base::ASCIIToUTF16("Show a web/app notification"))) { + this, + base::ASCIIToUTF16("Show a web/app notification"))) { create_button_->SetStyle(views::Button::STYLE_BUTTON); panel_button_->SetStyle(views::Button::STYLE_BUTTON); create_nonresizable_button_->SetStyle(views::Button::STYLE_BUTTON); @@ -344,7 +354,7 @@ } } - mojo::Connector* connector_; + shell::Connector* connector_; views::LabelButton* create_button_; views::LabelButton* panel_button_; views::LabelButton* create_nonresizable_button_; @@ -370,8 +380,8 @@ WindowTypeLauncher::WindowTypeLauncher() {} WindowTypeLauncher::~WindowTypeLauncher() {} -void WindowTypeLauncher::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void WindowTypeLauncher::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak"));
diff --git a/mash/example/window_type_launcher/window_type_launcher.h b/mash/example/window_type_launcher/window_type_launcher.h index 9ea908b..67d32ab 100644 --- a/mash/example/window_type_launcher/window_type_launcher.h +++ b/mash/example/window_type_launcher/window_type_launcher.h
@@ -14,14 +14,15 @@ class AuraInit; } -class WindowTypeLauncher : public mojo::ShellClient { +class WindowTypeLauncher : public shell::ShellClient { public: WindowTypeLauncher(); ~WindowTypeLauncher() override; private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; bool ShellConnectionLost() override;
diff --git a/mash/init/init.cc b/mash/init/init.cc index ee5d497..b68c8661 100644 --- a/mash/init/init.cc +++ b/mash/init/init.cc
@@ -18,8 +18,8 @@ : connector_(nullptr) {} Init::~Init() {} -void Init::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void Init::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { connector_ = connector; connector_->Connect("mojo:mus"); @@ -28,7 +28,7 @@ StartLogin(); } -bool Init::AcceptConnection(mojo::Connection* connection) { +bool Init::AcceptConnection(shell::Connection* connection) { connection->AddInterface<mojom::Init>(this); return true; } @@ -36,8 +36,9 @@ void Init::StartService(const mojo::String& name, const mojo::String& user_id) { if (user_services_.find(user_id) == user_services_.end()) { - mojo::Connector::ConnectParams params(mojo::Identity(name, user_id)); - std::unique_ptr<mojo::Connection> connection = connector_->Connect(¶ms); + shell::Connector::ConnectParams params(shell::Identity(name, user_id)); + std::unique_ptr<shell::Connection> connection = + connector_->Connect(¶ms); connection->SetConnectionLostClosure( base::Bind(&Init::UserServiceQuit, base::Unretained(this), user_id)); user_services_[user_id] = std::move(connection); @@ -50,7 +51,7 @@ user_services_.erase(it); } -void Init::Create(mojo::Connection* connection, mojom::InitRequest request) { +void Init::Create(shell::Connection* connection, mojom::InitRequest request) { init_bindings_.AddBinding(this, std::move(request)); }
diff --git a/mash/init/init.h b/mash/init/init.h index 9f49662a..9c90747 100644 --- a/mash/init/init.h +++ b/mash/init/init.h
@@ -22,21 +22,22 @@ namespace mash { namespace init { -class Init : public mojo::ShellClient, - public mojo::InterfaceFactory<mojom::Init>, +class Init : public shell::ShellClient, + public shell::InterfaceFactory<mojom::Init>, public mojom::Init { public: Init(); ~Init() override; private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; - // mojo::InterfaceFactory<mojom::Login>: - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<mojom::Login>: + void Create(shell::Connection* connection, mojom::InitRequest request) override; // mojom::Init: @@ -50,10 +51,10 @@ void StartResourceProvider(); void StartLogin(); - mojo::Connector* connector_; - std::unique_ptr<mojo::Connection> login_connection_; + shell::Connector* connector_; + std::unique_ptr<shell::Connection> login_connection_; mojo::BindingSet<mojom::Init> init_bindings_; - std::map<std::string, std::unique_ptr<mojo::Connection>> user_services_; + std::map<std::string, std::unique_ptr<shell::Connection>> user_services_; DISALLOW_COPY_AND_ASSIGN(Init); };
diff --git a/mash/init/main.cc b/mash/init/main.cc index 8063dce5..7ca161e 100644 --- a/mash/init/main.cc +++ b/mash/init/main.cc
@@ -7,6 +7,6 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner(new mash::init::Init); + shell::ApplicationRunner runner(new mash::init::Init); return runner.Run(shell_handle); }
diff --git a/mash/login/login.cc b/mash/login/login.cc index 5e63ca3..93bce35 100644 --- a/mash/login/login.cc +++ b/mash/login/login.cc
@@ -36,7 +36,7 @@ class UI : public views::WidgetDelegateView, public views::ButtonListener { public: - static void Show(mojo::Connector* connector, Login* login) { + static void Show(shell::Connector* connector, Login* login) { UI* ui = new UI(login, connector); ui->StartWindowManager(); @@ -60,7 +60,7 @@ } private: - UI(Login* login, mojo::Connector* connector) + UI(Login* login, shell::Connector* connector) : login_(login), connector_(connector), user_id_1_("00000000-0000-4000-8000-000000000000"), @@ -119,18 +119,18 @@ } Login* login_; - mojo::Connector* connector_; + shell::Connector* connector_; const std::string user_id_1_; const std::string user_id_2_; views::LabelButton* login_button_1_; views::LabelButton* login_button_2_; - std::unique_ptr<mojo::Connection> window_manager_connection_; + std::unique_ptr<shell::Connection> window_manager_connection_; DISALLOW_COPY_AND_ASSIGN(UI); }; -class Login : public mojo::ShellClient, - public mojo::InterfaceFactory<mojom::Login>, +class Login : public shell::ShellClient, + public shell::InterfaceFactory<mojom::Login>, public mojom::Login { public: Login() {} @@ -144,8 +144,9 @@ } private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override { connector_ = connector; tracing_.Initialize(connector, identity.name()); @@ -155,13 +156,13 @@ connector_->ConnectToInterface("mojo:mus", &user_access_manager_); user_access_manager_->SetActiveUser(identity.user_id()); } - bool AcceptConnection(mojo::Connection* connection) override { + bool AcceptConnection(shell::Connection* connection) override { connection->AddInterface<mojom::Login>(this); return true; } - // mojo::InterfaceFactory<mojom::Login>: - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<mojom::Login>: + void Create(shell::Connection* connection, mojom::LoginRequest request) override { bindings_.AddBinding(this, std::move(request)); } @@ -176,12 +177,12 @@ void StartWindowManager(); - mojo::Connector* connector_; + shell::Connector* connector_; mojo::TracingImpl tracing_; std::unique_ptr<views::AuraInit> aura_init_; mojo::BindingSet<mojom::Login> bindings_; mus::mojom::UserAccessManagerPtr user_access_manager_; - std::unique_ptr<mojo::Connection> window_manager_connection_; + std::unique_ptr<shell::Connection> window_manager_connection_; DISALLOW_COPY_AND_ASSIGN(Login); }; @@ -200,7 +201,7 @@ } // namespace -mojo::ShellClient* CreateLogin() { +shell::ShellClient* CreateLogin() { return new Login; }
diff --git a/mash/login/login.h b/mash/login/login.h index 8f2c9f3..60ece43 100644 --- a/mash/login/login.h +++ b/mash/login/login.h
@@ -5,14 +5,14 @@ #ifndef MASH_LOGIN_LOGIN_H_ #define MASH_LOGIN_LOGIN_H_ -namespace mojo { +namespace shell { class ShellClient; } namespace mash { namespace login { -mojo::ShellClient* CreateLogin(); +shell::ShellClient* CreateLogin(); } // namespace login } // namespace mash
diff --git a/mash/login/main.cc b/mash/login/main.cc index a0e9b92..7b206f2 100644 --- a/mash/login/main.cc +++ b/mash/login/main.cc
@@ -7,6 +7,6 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner(mash::login::CreateLogin()); + shell::ApplicationRunner runner(mash::login::CreateLogin()); return runner.Run(shell_handle); }
diff --git a/mash/quick_launch/main.cc b/mash/quick_launch/main.cc index 9eec07f..d1dcd5a 100644 --- a/mash/quick_launch/main.cc +++ b/mash/quick_launch/main.cc
@@ -7,7 +7,7 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner( + shell::ApplicationRunner runner( new mash::quick_launch::QuickLaunchApplication); return runner.Run(shell_handle); }
diff --git a/mash/quick_launch/quick_launch_application.cc b/mash/quick_launch/quick_launch_application.cc index 3c36329..f4ada35 100644 --- a/mash/quick_launch/quick_launch_application.cc +++ b/mash/quick_launch/quick_launch_application.cc
@@ -32,7 +32,7 @@ class QuickLaunchUI : public views::WidgetDelegateView, public views::TextfieldController { public: - QuickLaunchUI(mojo::Connector* connector, catalog::mojom::CatalogPtr catalog) + QuickLaunchUI(shell::Connector* connector, catalog::mojom::CatalogPtr catalog) : connector_(connector), prompt_(new views::Textfield), catalog_(std::move(catalog)) { @@ -128,9 +128,9 @@ app_names_.insert(base::UTF8ToUTF16(entry.first.get())); } - mojo::Connector* connector_; + shell::Connector* connector_; views::Textfield* prompt_; - std::vector<std::unique_ptr<mojo::Connection>> connections_; + std::vector<std::unique_ptr<shell::Connection>> connections_; catalog::mojom::CatalogPtr catalog_; std::set<base::string16> app_names_; bool suggestion_rejected_ = false; @@ -141,8 +141,8 @@ QuickLaunchApplication::QuickLaunchApplication() {} QuickLaunchApplication::~QuickLaunchApplication() {} -void QuickLaunchApplication::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void QuickLaunchApplication::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { tracing_.Initialize(connector, identity.name()); @@ -158,7 +158,7 @@ window->Show(); } -bool QuickLaunchApplication::AcceptConnection(mojo::Connection* connection) { +bool QuickLaunchApplication::AcceptConnection(shell::Connection* connection) { return true; }
diff --git a/mash/quick_launch/quick_launch_application.h b/mash/quick_launch/quick_launch_application.h index 46a43fff..b11ec71e 100644 --- a/mash/quick_launch/quick_launch_application.h +++ b/mash/quick_launch/quick_launch_application.h
@@ -19,17 +19,17 @@ namespace mash { namespace quick_launch { -class QuickLaunchApplication : public mojo::ShellClient { +class QuickLaunchApplication : public shell::ShellClient { public: QuickLaunchApplication(); ~QuickLaunchApplication() override; private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, - const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; mojo::TracingImpl tracing_; std::unique_ptr<views::AuraInit> aura_init_;
diff --git a/mash/screenlock/main.cc b/mash/screenlock/main.cc index 02fdf61..c8fe171 100644 --- a/mash/screenlock/main.cc +++ b/mash/screenlock/main.cc
@@ -7,6 +7,6 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner(new mash::screenlock::Screenlock); + shell::ApplicationRunner runner(new mash::screenlock::Screenlock); return runner.Run(shell_handle); }
diff --git a/mash/screenlock/screenlock.cc b/mash/screenlock/screenlock.cc index 149dcc2..69ef2b0 100644 --- a/mash/screenlock/screenlock.cc +++ b/mash/screenlock/screenlock.cc
@@ -25,7 +25,7 @@ class ScreenlockView : public views::WidgetDelegateView, public views::ButtonListener { public: - explicit ScreenlockView(mojo::Connector* connector) + explicit ScreenlockView(shell::Connector* connector) : connector_(connector), unlock_button_( new views::LabelButton(this, base::ASCIIToUTF16("Unlock"))) { @@ -64,7 +64,7 @@ session->UnlockScreen(); } - mojo::Connector* connector_; + shell::Connector* connector_; views::LabelButton* unlock_button_; DISALLOW_COPY_AND_ASSIGN(ScreenlockView); @@ -75,8 +75,8 @@ Screenlock::Screenlock() {} Screenlock::~Screenlock() {} -void Screenlock::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void Screenlock::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { tracing_.Initialize(connector, identity.name());
diff --git a/mash/screenlock/screenlock.h b/mash/screenlock/screenlock.h index 1d770811..25838f5c 100644 --- a/mash/screenlock/screenlock.h +++ b/mash/screenlock/screenlock.h
@@ -21,16 +21,16 @@ namespace mash { namespace screenlock { -class Screenlock : public mojo::ShellClient, +class Screenlock : public shell::ShellClient, public session::mojom::ScreenlockStateListener { public: Screenlock(); ~Screenlock() override; private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, - const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; // session::mojom::ScreenlockStateListener:
diff --git a/mash/session/main.cc b/mash/session/main.cc index 317b0e8..53806c76 100644 --- a/mash/session/main.cc +++ b/mash/session/main.cc
@@ -7,6 +7,6 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner(new mash::session::Session); + shell::ApplicationRunner runner(new mash::session::Session); return runner.Run(shell_handle); }
diff --git a/mash/session/session.cc b/mash/session/session.cc index 25451dc..daae519 100644 --- a/mash/session/session.cc +++ b/mash/session/session.cc
@@ -27,8 +27,8 @@ Session::Session() : connector_(nullptr), screen_locked_(false) {} Session::~Session() {} -void Session::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void Session::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { connector_ = connector; StartBrowserDriver(); @@ -37,7 +37,7 @@ StartQuickLaunch(); } -bool Session::AcceptConnection(mojo::Connection* connection) { +bool Session::AcceptConnection(shell::Connection* connection) { connection->AddInterface<mojom::Session>(this); return true; } @@ -85,7 +85,7 @@ StopScreenlock(); } -void Session::Create(mojo::Connection* connection, +void Session::Create(shell::Connection* connection, mojom::SessionRequest request) { bindings_.AddBinding(this, std::move(request)); } @@ -135,7 +135,7 @@ const base::Closure& restart_callback) { // TODO(beng): This would be the place to insert logic that counted restarts // to avoid infinite crash-restart loops. - std::unique_ptr<mojo::Connection> connection = connector_->Connect(url); + std::unique_ptr<shell::Connection> connection = connector_->Connect(url); // Note: |connection| may be null if we've lost our connection to the shell. if (connection) { connection->SetConnectionLostClosure(
diff --git a/mash/session/session.h b/mash/session/session.h index 8128a51f0..d589db8 100644 --- a/mash/session/session.h +++ b/mash/session/session.h
@@ -23,19 +23,19 @@ namespace mash { namespace session { -class Session : public mojo::ShellClient, +class Session : public shell::ShellClient, public mojom::Session, - public mojo::InterfaceFactory<mojom::Session> { + public shell::InterfaceFactory<mojom::Session> { public: Session(); ~Session() override; private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, - const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; // mojom::Session: void Logout() override; @@ -45,8 +45,8 @@ void LockScreen() override; void UnlockScreen() override; - // mojo::InterfaceFactory<mojom::Session>: - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<mojom::Session>: + void Create(shell::Connection* connection, mojom::SessionRequest request) override; void StartWindowManager(); @@ -62,8 +62,8 @@ void StartRestartableService(const std::string& url, const base::Closure& restart_callback); - mojo::Connector* connector_; - std::map<std::string, std::unique_ptr<mojo::Connection>> connections_; + shell::Connector* connector_; + std::map<std::string, std::unique_ptr<shell::Connection>> connections_; bool screen_locked_; mojo::BindingSet<mojom::Session> bindings_; mojo::InterfacePtrSet<mojom::ScreenlockStateListener> screenlock_listeners_;
diff --git a/mash/task_viewer/main.cc b/mash/task_viewer/main.cc index 7540d5e..6e4869d6 100644 --- a/mash/task_viewer/main.cc +++ b/mash/task_viewer/main.cc
@@ -7,6 +7,6 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner(new mash::task_viewer::TaskViewer); + shell::ApplicationRunner runner(new mash::task_viewer::TaskViewer); return runner.Run(shell_handle); }
diff --git a/mash/task_viewer/task_viewer.cc b/mash/task_viewer/task_viewer.cc index eaa6a617..b1a2285 100644 --- a/mash/task_viewer/task_viewer.cc +++ b/mash/task_viewer/task_viewer.cc
@@ -34,14 +34,14 @@ namespace task_viewer { namespace { -using mojo::shell::mojom::InstanceInfoPtr; +using shell::mojom::InstanceInfoPtr; class TaskViewerContents : public views::WidgetDelegateView, public ui::TableModel, public views::ButtonListener, - public mojo::shell::mojom::InstanceListener { + public shell::mojom::InstanceListener { public: - TaskViewerContents(mojo::shell::mojom::InstanceListenerRequest request, + TaskViewerContents(shell::mojom::InstanceListenerRequest request, catalog::mojom::CatalogPtr catalog) : binding_(this, std::move(request)), catalog_(std::move(catalog)), @@ -149,7 +149,7 @@ process.Terminate(9, true); } - // Overridden from mojo::shell::mojom::InstanceListener: + // Overridden from shell::mojom::InstanceListener: void SetExistingInstances(mojo::Array<InstanceInfoPtr> instances) override { // This callback should only be called with an empty model. DCHECK(instances_.empty()); @@ -251,7 +251,7 @@ return columns; } - mojo::Binding<mojo::shell::mojom::InstanceListener> binding_; + mojo::Binding<shell::mojom::InstanceListener> binding_; catalog::mojom::CatalogPtr catalog_; views::TableView* table_view_; @@ -271,19 +271,19 @@ TaskViewer::TaskViewer() {} TaskViewer::~TaskViewer() {} -void TaskViewer::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void TaskViewer::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { tracing_.Initialize(connector, identity.name()); aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); views::WindowManagerConnection::Create(connector); - mojo::shell::mojom::ShellPtr shell; + shell::mojom::ShellPtr shell; connector->ConnectToInterface("mojo:shell", &shell); - mojo::shell::mojom::InstanceListenerPtr listener; - mojo::shell::mojom::InstanceListenerRequest request = GetProxy(&listener); + shell::mojom::InstanceListenerPtr listener; + shell::mojom::InstanceListenerRequest request = GetProxy(&listener); shell->AddInstanceListener(std::move(listener)); catalog::mojom::CatalogPtr catalog;
diff --git a/mash/task_viewer/task_viewer.h b/mash/task_viewer/task_viewer.h index d3cb636..4772f1b 100644 --- a/mash/task_viewer/task_viewer.h +++ b/mash/task_viewer/task_viewer.h
@@ -20,15 +20,15 @@ namespace mash { namespace task_viewer { -class TaskViewer : public mojo::ShellClient { +class TaskViewer : public shell::ShellClient { public: TaskViewer(); ~TaskViewer() override; private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, - const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; mojo::TracingImpl tracing_;
diff --git a/mash/wm/accelerator_registrar_unittest.cc b/mash/wm/accelerator_registrar_unittest.cc index b904714..814cbf8 100644 --- a/mash/wm/accelerator_registrar_unittest.cc +++ b/mash/wm/accelerator_registrar_unittest.cc
@@ -67,9 +67,9 @@ DISALLOW_COPY_AND_ASSIGN(TestAcceleratorHandler); }; -class AcceleratorRegistrarTest : public mojo::test::ShellTest { +class AcceleratorRegistrarTest : public shell::test::ShellTest { public: - AcceleratorRegistrarTest() : mojo::test::ShellTest("exe:mash_unittests") {} + AcceleratorRegistrarTest() : shell::test::ShellTest("exe:mash_unittests") {} ~AcceleratorRegistrarTest() override {} protected:
diff --git a/mash/wm/main.cc b/mash/wm/main.cc index ebfa0ec..72125fe 100644 --- a/mash/wm/main.cc +++ b/mash/wm/main.cc
@@ -7,6 +7,6 @@ #include "services/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner(new mash::wm::WindowManagerApplication); + shell::ApplicationRunner runner(new mash::wm::WindowManagerApplication); return runner.Run(shell_handle); }
diff --git a/mash/wm/non_client_frame_controller.cc b/mash/wm/non_client_frame_controller.cc index 81dc82b..5166177 100644 --- a/mash/wm/non_client_frame_controller.cc +++ b/mash/wm/non_client_frame_controller.cc
@@ -92,9 +92,11 @@ class WmNativeWidgetMus : public views::NativeWidgetMus { public: WmNativeWidgetMus(views::internal::NativeWidgetDelegate* delegate, - mojo::Connector* connector, + shell::Connector* connector, mus::Window* window) - : NativeWidgetMus(delegate, connector, window, + : NativeWidgetMus(delegate, + connector, + window, mus::mojom::SurfaceType::UNDERLAY) {} ~WmNativeWidgetMus() override { } @@ -177,7 +179,7 @@ // static void NonClientFrameController::Create( - mojo::Connector* connector, + shell::Connector* connector, mus::Window* window, mus::WindowManagerClient* window_manager_client) { new NonClientFrameController(connector, window, window_manager_client); @@ -194,7 +196,7 @@ } NonClientFrameController::NonClientFrameController( - mojo::Connector* connector, + shell::Connector* connector, mus::Window* window, mus::WindowManagerClient* window_manager_client) : widget_(new views::Widget), window_(window) {
diff --git a/mash/wm/non_client_frame_controller.h b/mash/wm/non_client_frame_controller.h index 292e593..02bed028 100644 --- a/mash/wm/non_client_frame_controller.h +++ b/mash/wm/non_client_frame_controller.h
@@ -16,15 +16,15 @@ class Insets; } -namespace mojo { -class Connector; -} - namespace mus { class Window; class WindowManagerClient; } +namespace shell { +class Connector; +} + namespace mash { namespace wm { @@ -33,7 +33,7 @@ public mus::WindowObserver { public: // NonClientFrameController deletes itself when |window| is destroyed. - static void Create(mojo::Connector* connector, + static void Create(shell::Connector* connector, mus::Window* window, mus::WindowManagerClient* window_manager_client); @@ -47,7 +47,7 @@ mus::Window* window() { return window_; } private: - NonClientFrameController(mojo::Connector* connector, + NonClientFrameController(shell::Connector* connector, mus::Window* window, mus::WindowManagerClient* window_manager_client); ~NonClientFrameController() override;
diff --git a/mash/wm/root_window_controller.cc b/mash/wm/root_window_controller.cc index 00dc25a..d610dc2 100644 --- a/mash/wm/root_window_controller.cc +++ b/mash/wm/root_window_controller.cc
@@ -63,7 +63,7 @@ } } -mojo::Connector* RootWindowController::GetConnector() { +shell::Connector* RootWindowController::GetConnector() { return app_->connector(); }
diff --git a/mash/wm/root_window_controller.h b/mash/wm/root_window_controller.h index 805ce4c5..d3f31421 100644 --- a/mash/wm/root_window_controller.h +++ b/mash/wm/root_window_controller.h
@@ -14,14 +14,14 @@ #include "mash/wm/public/interfaces/container.mojom.h" #include "mojo/public/cpp/bindings/binding.h" -namespace mojo { -class Connector; -} - namespace mus { class WindowManagerClient; } +namespace shell { +class Connector; +} + namespace ui { class Event; } @@ -49,7 +49,7 @@ // Deletes this. void Destroy(); - mojo::Connector* GetConnector(); + shell::Connector* GetConnector(); mus::Window* root() { return root_; }
diff --git a/mash/wm/window_manager_application.cc b/mash/wm/window_manager_application.cc index cf50eba..6562980 100644 --- a/mash/wm/window_manager_application.cc +++ b/mash/wm/window_manager_application.cc
@@ -106,8 +106,8 @@ accelerator_registrars_.erase(registrar); } -void WindowManagerApplication::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void WindowManagerApplication::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { connector_ = connector; tracing_.Initialize(connector, identity.name()); @@ -120,7 +120,7 @@ user_window_controller_.reset(new UserWindowControllerImpl()); } -bool WindowManagerApplication::AcceptConnection(mojo::Connection* connection) { +bool WindowManagerApplication::AcceptConnection(shell::Connection* connection) { connection->AddInterface<mash::wm::mojom::UserWindowController>(this); connection->AddInterface<mus::mojom::AcceleratorRegistrar>(this); if (connection->GetRemoteIdentity().name() == "mojo:mash_session") @@ -129,7 +129,7 @@ } void WindowManagerApplication::Create( - mojo::Connection* connection, + shell::Connection* connection, mojo::InterfaceRequest<mash::wm::mojom::UserWindowController> request) { if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) { user_window_controller_binding_.AddBinding(user_window_controller_.get(), @@ -142,7 +142,7 @@ } void WindowManagerApplication::Create( - mojo::Connection* connection, + shell::Connection* connection, mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) { static int accelerator_registrar_count = 0; if (accelerator_registrar_count == std::numeric_limits<int>::max()) {
diff --git a/mash/wm/window_manager_application.h b/mash/wm/window_manager_application.h index ffa0e35..a0d77dd 100644 --- a/mash/wm/window_manager_application.h +++ b/mash/wm/window_manager_application.h
@@ -47,15 +47,15 @@ class UserWindowControllerImpl; class WindowManagerApplication - : public mojo::ShellClient, + : public shell::ShellClient, public mus::mojom::WindowManagerFactory, - public mojo::InterfaceFactory<mash::wm::mojom::UserWindowController>, - public mojo::InterfaceFactory<mus::mojom::AcceleratorRegistrar> { + public shell::InterfaceFactory<mash::wm::mojom::UserWindowController>, + public shell::InterfaceFactory<mus::mojom::AcceleratorRegistrar> { public: WindowManagerApplication(); ~WindowManagerApplication() override; - mojo::Connector* connector() { return connector_; } + shell::Connector* connector() { return connector_; } // Returns the RootWindowControllers that have valid roots. // @@ -86,18 +86,19 @@ private: void OnAcceleratorRegistrarDestroyed(AcceleratorRegistrarImpl* registrar); - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; // InterfaceFactory<mash::wm::mojom::UserWindowController>: - void Create(mojo::Connection* connection, + void Create(shell::Connection* connection, mojo::InterfaceRequest<mash::wm::mojom::UserWindowController> request) override; // InterfaceFactory<mus::mojom::AcceleratorRegistrar>: - void Create(mojo::Connection* connection, + void Create(shell::Connection* connection, mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) override; @@ -106,7 +107,7 @@ mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) override; - mojo::Connector* connector_; + shell::Connector* connector_; mojo::TracingImpl tracing_;
diff --git a/mash/wm/window_manager_unittest.cc b/mash/wm/window_manager_unittest.cc index 65fc548..f3272f26 100644 --- a/mash/wm/window_manager_unittest.cc +++ b/mash/wm/window_manager_unittest.cc
@@ -31,9 +31,9 @@ DISALLOW_COPY_AND_ASSIGN(WindowTreeDelegateImpl); }; -class WindowManagerTest : public mojo::test::ShellTest { +class WindowManagerTest : public shell::test::ShellTest { public: - WindowManagerTest() : mojo::test::ShellTest("exe:mash_unittests") {} + WindowManagerTest() : shell::test::ShellTest("exe:mash_unittests") {} ~WindowManagerTest() override {} private:
diff --git a/media/BUILD.gn b/media/BUILD.gn index d738e2c..c8ebd28 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn
@@ -70,6 +70,12 @@ } } +source_set("cdm_api") { + sources = [ + "cdm/api/content_decryption_module.h", + ] +} + component("media") { sources = [ "cdm/aes_decryptor.cc", @@ -80,6 +86,7 @@ "cdm/cdm_allocator.h", "cdm/cdm_helpers.cc", "cdm/cdm_helpers.h", + "cdm/cdm_wrapper.h", "cdm/default_cdm_factory.cc", "cdm/default_cdm_factory.h", "cdm/json_web_key.cc", @@ -227,7 +234,9 @@ cflags = [] libs = [] defines = [] - deps = [] + deps = [ + ":cdm_api", + ] include_dirs = [ "." ] if (media_use_ffmpeg) {
diff --git a/media/cdm/cdm_helpers.cc b/media/cdm/cdm_helpers.cc index f413dfa..491bff9e2 100644 --- a/media/cdm/cdm_helpers.cc +++ b/media/cdm/cdm_helpers.cc
@@ -6,7 +6,7 @@ #if defined(USE_PPAPI_CDM_ADAPTER) // When building the ppapi adapter do not include any non-trivial base/ headers. -#include "ppapi/cpp/logging.h" +#include "ppapi/cpp/logging.h" // nogncheck #define PLATFORM_DCHECK PP_DCHECK #else #include "base/logging.h"
diff --git a/media/cdm/cdm_wrapper.h b/media/cdm/cdm_wrapper.h index f0ed673..20cdaad 100644 --- a/media/cdm/cdm_wrapper.h +++ b/media/cdm/cdm_wrapper.h
@@ -15,7 +15,7 @@ #if defined(USE_PPAPI_CDM_ADAPTER) // When building the ppapi adapter do not include any non-trivial base/ headers. -#include "ppapi/cpp/logging.h" +#include "ppapi/cpp/logging.h" // nogncheck #define PLATFORM_DCHECK PP_DCHECK #else #include "base/logging.h"
diff --git a/media/cdm/ppapi/BUILD.gn b/media/cdm/ppapi/BUILD.gn index b0622e12..20deaab 100644 --- a/media/cdm/ppapi/BUILD.gn +++ b/media/cdm/ppapi/BUILD.gn
@@ -65,6 +65,5 @@ ":clearkeycdm", ":clearkeycdmadapter_resources", "//base", # Required for the allocator implementation. - "//ppapi/cpp", ] }
diff --git a/media/cdm/ppapi/ppapi_cdm_adapter.gni b/media/cdm/ppapi/ppapi_cdm_adapter.gni index 120941314..bf674100 100644 --- a/media/cdm/ppapi/ppapi_cdm_adapter.gni +++ b/media/cdm/ppapi/ppapi_cdm_adapter.gni
@@ -18,8 +18,11 @@ forward_variables_from(invoker, "*") defines += [ "USE_PPAPI_CDM_ADAPTER" ] + deps += [ + "//media:cdm_api", + "//ppapi/cpp", + ] sources += [ - "//media/cdm/api/content_decryption_module.h", "//media/cdm/cdm_helpers.cc", "//media/cdm/cdm_helpers.h", "//media/cdm/cdm_wrapper.h",
diff --git a/media/filters/video_renderer_algorithm.cc b/media/filters/video_renderer_algorithm.cc index 2a98367..8bd7c5c 100644 --- a/media/filters/video_renderer_algorithm.cc +++ b/media/filters/video_renderer_algorithm.cc
@@ -86,6 +86,7 @@ if (was_time_moving_ && !have_known_duration) ++ready_frame.render_count; + UpdateEffectiveFramesQueued(); return ready_frame.frame; } @@ -239,6 +240,7 @@ first_frame_ = false; } + UpdateEffectiveFramesQueued(); DCHECK(frame_queue_.front().frame); return frame_queue_.front().frame; } @@ -249,26 +251,42 @@ if (deadline > last_deadline_max_) last_deadline_max_ = deadline; - if (frame_queue_.size() < 2) + if (frame_queue_.empty()) return 0; + // Even though we may not be able to remove anything due to having only one + // frame, correct any estimates which may have been set during EnqueueFrame(). UpdateFrameStatistics(); + + // We always leave at least one frame in the queue, so if there's only one + // frame there's nothing we can expire. + if (frame_queue_.size() == 1) { + UpdateEffectiveFramesQueued(); + return 0; + } + DCHECK_GT(average_frame_duration_, base::TimeDelta()); // Finds and removes all frames which are too old to be used; I.e., the end of // their render interval is further than |max_acceptable_drift_| from the // given |deadline|. We also always expire anything inserted before the last // rendered frame. + size_t frames_dropped_without_rendering = 0; size_t frames_to_expire = last_frame_index_; const base::TimeTicks minimum_start_time = deadline - max_acceptable_drift_ - average_frame_duration_; for (; frames_to_expire < frame_queue_.size() - 1; ++frames_to_expire) { - if (frame_queue_[frames_to_expire].start_time >= minimum_start_time) + const ReadyFrame& frame = frame_queue_[frames_to_expire]; + if (frame.start_time >= minimum_start_time) break; + if (frame.render_count == frame.drop_count) + ++frames_dropped_without_rendering; } - if (!frames_to_expire) + if (!frames_to_expire) { + UpdateEffectiveFramesQueued(); return 0; + } cadence_frame_counter_ += frames_to_expire - last_frame_index_; frame_queue_.erase(frame_queue_.begin(), @@ -277,7 +295,9 @@ last_frame_index_ = last_frame_index_ > frames_to_expire ? last_frame_index_ - frames_to_expire : 0; - return frames_to_expire; + + UpdateEffectiveFramesQueued(); + return frames_dropped_without_rendering; } void VideoRendererAlgorithm::OnLastFrameDropped() { @@ -295,18 +315,22 @@ ++frame_queue_[last_frame_index_].drop_count; DCHECK_LE(frame_queue_[last_frame_index_].drop_count, frame_queue_[last_frame_index_].render_count); + UpdateEffectiveFramesQueued(); } -void VideoRendererAlgorithm::Reset() { +void VideoRendererAlgorithm::Reset(ResetFlag reset_flag) { frames_dropped_during_enqueue_ = last_frame_index_ = 0; have_rendered_frames_ = last_render_had_glitch_ = false; - last_deadline_max_ = base::TimeTicks(); - average_frame_duration_ = render_interval_ = base::TimeDelta(); + render_interval_ = base::TimeDelta(); frame_queue_.clear(); cadence_estimator_.Reset(); - frame_duration_calculator_.Reset(); + if (reset_flag != ResetFlag::kPreserveNextFrameEstimates) { + average_frame_duration_ = base::TimeDelta(); + last_deadline_max_ = base::TimeTicks(); + frame_duration_calculator_.Reset(); + } first_frame_ = true; - cadence_frame_counter_ = 0; + effective_frames_queued_ = cadence_frame_counter_ = 0; last_render_ignored_cadence_frame_ = false; was_time_moving_ = false; @@ -315,44 +339,6 @@ max_acceptable_drift_ = base::TimeDelta::FromMilliseconds(15); } -size_t VideoRendererAlgorithm::EffectiveFramesQueued() const { - if (frame_queue_.empty() || average_frame_duration_ == base::TimeDelta() || - last_deadline_max_.is_null()) { - return frame_queue_.size(); - } - - // If we don't have cadence, subtract off any frames which are before - // the last rendered frame or are past their expected rendering time. - if (!cadence_estimator_.has_cadence()) { - size_t expired_frames = last_frame_index_; - DCHECK_LT(last_frame_index_, frame_queue_.size()); - for (; expired_frames < frame_queue_.size(); ++expired_frames) { - const ReadyFrame& frame = frame_queue_[expired_frames]; - if (frame.end_time.is_null() || frame.end_time > last_deadline_max_) - break; - } - return frame_queue_.size() - expired_frames; - } - - // Find the first usable frame to start counting from. - const int start_index = FindBestFrameByCadence(nullptr); - if (start_index < 0) - return 0; - - const base::TimeTicks minimum_start_time = - last_deadline_max_ - max_acceptable_drift_; - size_t renderable_frame_count = 0; - for (size_t i = start_index; i < frame_queue_.size(); ++i) { - const ReadyFrame& frame = frame_queue_[i]; - if (frame.render_count < frame.ideal_render_count && - (frame.end_time.is_null() || frame.end_time > minimum_start_time)) { - ++renderable_frame_count; - } - } - - return renderable_frame_count; -} - int64_t VideoRendererAlgorithm::GetMemoryUsage() const { int64_t allocation_size = 0; for (const auto& ready_frame : frame_queue_) { @@ -401,6 +387,16 @@ return; } + // Calculate an accurate start time and an estimated end time if possible for + // the new frame; this allows EffectiveFramesQueued() to be relatively correct + // immediately after a new frame is queued. + std::vector<base::TimeDelta> media_timestamps(1, frame->timestamp()); + std::vector<base::TimeTicks> wall_clock_times; + wall_clock_time_cb_.Run(media_timestamps, &wall_clock_times); + ready_frame.start_time = wall_clock_times[0]; + if (frame_duration_calculator_.count()) + ready_frame.end_time = ready_frame.start_time + average_frame_duration_; + // The vast majority of cases should always append to the back, but in rare // circumstance we get out of order timestamps, http://crbug.com/386551. frame_queue_.insert(it, ready_frame); @@ -411,6 +407,7 @@ if (cadence_estimator_.has_cadence()) UpdateCadenceForFrames(); + UpdateEffectiveFramesQueued(); #ifndef NDEBUG // Verify sorted order in debug mode. for (size_t i = 0; i < frame_queue_.size() - 1; ++i) { @@ -505,7 +502,7 @@ // If we were called via RemoveExpiredFrames() and Render() was never called, // we may not have a render interval yet. - if (render_interval_ == base::TimeDelta()) + if (render_interval_.is_zero()) return; const bool cadence_changed = cadence_estimator_.UpdateCadenceEstimate( @@ -692,4 +689,46 @@ return base::TimeDelta(); } +void VideoRendererAlgorithm::UpdateEffectiveFramesQueued() { + if (frame_queue_.empty() || average_frame_duration_.is_zero() || + last_deadline_max_.is_null()) { + effective_frames_queued_ = frame_queue_.size(); + return; + } + + // If we don't have cadence, subtract off any frames which are before + // the last rendered frame or are past their expected rendering time. + if (!cadence_estimator_.has_cadence()) { + size_t expired_frames = last_frame_index_; + DCHECK_LT(last_frame_index_, frame_queue_.size()); + for (; expired_frames < frame_queue_.size(); ++expired_frames) { + const ReadyFrame& frame = frame_queue_[expired_frames]; + if (frame.end_time.is_null() || frame.end_time > last_deadline_max_) + break; + } + effective_frames_queued_ = frame_queue_.size() - expired_frames; + return; + } + + // Find the first usable frame to start counting from. + const int start_index = FindBestFrameByCadence(nullptr); + if (start_index < 0) { + effective_frames_queued_ = 0; + return; + } + + const base::TimeTicks minimum_start_time = + last_deadline_max_ - max_acceptable_drift_; + size_t renderable_frame_count = 0; + for (size_t i = start_index; i < frame_queue_.size(); ++i) { + const ReadyFrame& frame = frame_queue_[i]; + if (frame.render_count < frame.ideal_render_count && + (frame.end_time.is_null() || frame.end_time > minimum_start_time)) { + ++renderable_frame_count; + } + } + + effective_frames_queued_ = renderable_frame_count; +} + } // namespace media
diff --git a/media/filters/video_renderer_algorithm.h b/media/filters/video_renderer_algorithm.h index 5d1169f..24e6484 100644 --- a/media/filters/video_renderer_algorithm.h +++ b/media/filters/video_renderer_algorithm.h
@@ -76,7 +76,7 @@ // // At least one frame will always remain after this call so that subsequent // Render() calls have a frame to return if no new frames are enqueued before - // then. Returns the number of frames removed. + // then. Returns the number of frames removed that were never rendered. // // Note: In cases where there is no known frame duration (i.e. perhaps a video // with only a single frame), the last frame can not be expired, regardless of @@ -97,16 +97,22 @@ // Attempting to enqueue a frame with the same timestamp as a previous frame // will result in the previous frame being replaced if it has not been // rendered yet. If it has been rendered, the new frame will be dropped. + // + // EnqueueFrame() will compute the current start time and an estimated end + // time of the frame based on previous frames so that EffectiveFramesQueued() + // is relatively accurate immediately after this call. void EnqueueFrame(const scoped_refptr<VideoFrame>& frame); // Removes all frames from the |frame_queue_| and clears predictors. The - // algorithm will be as if freshly constructed after this call. - void Reset(); + // algorithm will be as if freshly constructed after this call. By default + // everything is reset, but if kPreserveNextFrameEstimates is specified, then + // predictors for the start time of the next frame given to EnqueueFrame() + // will be kept; allowing EffectiveFramesQueued() accuracy with one frame. + enum class ResetFlag { kEverything, kPreserveNextFrameEstimates }; + void Reset(ResetFlag reset_flag = ResetFlag::kEverything); // Returns the number of frames currently buffered which could be rendered - // assuming current Render() interval trends. Before Render() is called, this - // will be the same as the number of frames given to EnqueueFrame(). After - // Render() has been called, one of two things will be returned: + // assuming current Render() interval trends. // // If a cadence has been identified, this will return the number of frames // which have a non-zero ideal render count. @@ -119,7 +125,7 @@ // // In either case, frames enqueued before the last displayed frame will not // be counted as effective. - size_t EffectiveFramesQueued() const; + size_t effective_frames_queued() const { return effective_frames_queued_; } // Returns an estimate of the amount of memory (in bytes) used for frames. int64_t GetMemoryUsage() const; @@ -249,6 +255,12 @@ base::TimeDelta CalculateAbsoluteDriftForFrame(base::TimeTicks deadline_min, int frame_index) const; + // Updates |effective_frames_queued_| which is typically called far more + // frequently (~4x) than the value changes. This must be called whenever + // frames are added or removed from the queue or when any property of a + // ReadyFrame within the queue changes. + void UpdateEffectiveFramesQueued(); + // Queue of incoming frames waiting for rendering. using VideoFrameQueue = std::deque<ReadyFrame>; VideoFrameQueue frame_queue_; @@ -320,6 +332,10 @@ // set_time_stopped(). bool was_time_moving_; + // Current number of effective frames in the |frame_queue_|. Updated by calls + // to UpdateEffectiveFramesQueued() whenever the |frame_queue_| is changed. + size_t effective_frames_queued_; + DISALLOW_COPY_AND_ASSIGN(VideoRendererAlgorithm); };
diff --git a/media/filters/video_renderer_algorithm_unittest.cc b/media/filters/video_renderer_algorithm_unittest.cc index e35aa019..1bd62bf4 100644 --- a/media/filters/video_renderer_algorithm_unittest.cc +++ b/media/filters/video_renderer_algorithm_unittest.cc
@@ -190,7 +190,7 @@ int glitch_count = 0; const base::TimeTicks start_time = tick_clock_->NowTicks(); while (tick_clock_->NowTicks() - start_time < minimum_glitch_time()) { - while (algorithm_.EffectiveFramesQueued() < 3 || + while (EffectiveFramesQueued() < 3 || frame_tg->current() - time_source_.CurrentMediaTime() < base::TimeTicks()) { algorithm_.EnqueueFrame( @@ -243,20 +243,18 @@ // within the last render interval. if (!is_using_cadence() || !frames_queued() || GetCurrentFrameDisplayCount() < GetCurrentFrameIdealDisplayCount()) { - ASSERT_NEAR(GetUsableFrameCount(deadline_max), - algorithm_.EffectiveFramesQueued(), + ASSERT_NEAR(GetUsableFrameCount(deadline_max), EffectiveFramesQueued(), fresh_algorithm ? 0 : 1); } else if (is_using_cadence() && !IsCadenceBelowOne()) { // If there was no glitch in the last render, the two queue sizes should // be off by exactly one frame; i.e., the current frame doesn't count. if (!last_render_had_glitch() && fresh_algorithm) - ASSERT_EQ(frames_queued() - 1, algorithm_.EffectiveFramesQueued()); + ASSERT_EQ(frames_queued() - 1, EffectiveFramesQueued()); } else if (IsCadenceBelowOne()) { // The frame estimate should be off by at most one frame. const size_t estimated_frames_queued = std::floor(frames_queued() * CadenceValue()); - ASSERT_NEAR(algorithm_.EffectiveFramesQueued(), estimated_frames_queued, - 1); + ASSERT_NEAR(EffectiveFramesQueued(), estimated_frames_queued, 1); } } @@ -322,6 +320,14 @@ return 0; } + size_t EffectiveFramesQueued() { + const size_t expected_frames_queued = algorithm_.effective_frames_queued(); + // These values should always be in sync. + algorithm_.UpdateEffectiveFramesQueued(); + EXPECT_EQ(expected_frames_queued, algorithm_.effective_frames_queued()); + return expected_frames_queued; + } + protected: VideoFramePool frame_pool_; scoped_ptr<base::SimpleTestTickClock> tick_clock_; @@ -350,6 +356,36 @@ algorithm_.Reset(); EXPECT_EQ(0u, frames_queued()); EXPECT_NE(base::TimeDelta(), max_acceptable_drift()); + + // Enqueue a frame and render enough such that the next frame should be + // considered ineffective. + time_source_.StartTicking(); + size_t frames_dropped = 0; + algorithm_.EnqueueFrame(CreateFrame(tg.interval(0))); + algorithm_.EnqueueFrame(CreateFrame(tg.interval(1))); + scoped_refptr<VideoFrame> frame = RenderAndStep(&tg, &frames_dropped); + ASSERT_TRUE(frame); + EXPECT_EQ(tg.interval(0), frame->timestamp()); + EXPECT_EQ(0u, frames_dropped); + EXPECT_EQ(1u, EffectiveFramesQueued()); + + for (int i = 0; i < 2; ++i) { + frame = RenderAndStep(&tg, &frames_dropped); + ASSERT_TRUE(frame); + EXPECT_EQ(tg.interval(1), frame->timestamp()); + EXPECT_EQ(0u, frames_dropped); + EXPECT_EQ(0u, EffectiveFramesQueued()); + } + time_source_.StopTicking(); + + // After reset the new frame should still be counted as ineffective. + algorithm_.Reset( + VideoRendererAlgorithm::ResetFlag::kPreserveNextFrameEstimates); + algorithm_.EnqueueFrame(CreateFrame(tg.interval(2))); + EXPECT_EQ(0u, EffectiveFramesQueued()); + algorithm_.EnqueueFrame(CreateFrame(tg.interval(3))); + ASSERT_EQ(1u, algorithm_.RemoveExpiredFrames( + tg.current() + algorithm_.average_frame_duration())); } TEST_F(VideoRendererAlgorithmTest, AccountForMissingIntervals) { @@ -522,20 +558,20 @@ // normal frame pump tests when cadence is not present. disable_cadence_hysteresis(); - EXPECT_EQ(0u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(0u, EffectiveFramesQueued()); time_source_.StartTicking(); algorithm_.EnqueueFrame(CreateFrame(frame_tg.interval(0))); - EXPECT_EQ(1u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(1u, EffectiveFramesQueued()); algorithm_.EnqueueFrame(CreateFrame(frame_tg.interval(1))); - EXPECT_EQ(2u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(2u, EffectiveFramesQueued()); algorithm_.EnqueueFrame(CreateFrame(frame_tg.interval(2))); - EXPECT_EQ(3u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(3u, EffectiveFramesQueued()); algorithm_.EnqueueFrame(CreateFrame(frame_tg.interval(3))); - EXPECT_EQ(4u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(4u, EffectiveFramesQueued()); EXPECT_EQ(4u, frames_queued()); // Render one frame which will detect cadence... @@ -547,32 +583,32 @@ // Fractional cadence should be detected and the count will decrease. ASSERT_TRUE(is_using_cadence()); - EXPECT_EQ(1u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(1u, EffectiveFramesQueued()); EXPECT_EQ(4u, frames_queued()); // Dropping the last rendered frame should do nothing, since the last frame // is already excluded from the count if it has a display count of 1. algorithm_.OnLastFrameDropped(); - EXPECT_EQ(1u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(1u, EffectiveFramesQueued()); } TEST_F(VideoRendererAlgorithmTest, EffectiveFramesQueuedWithoutCadence) { TickGenerator tg(tick_clock_->NowTicks(), 60); - EXPECT_EQ(0u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(0u, EffectiveFramesQueued()); time_source_.StartTicking(); algorithm_.EnqueueFrame(CreateFrame(tg.interval(0))); - EXPECT_EQ(1u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(1u, EffectiveFramesQueued()); algorithm_.EnqueueFrame(CreateFrame(tg.interval(1))); - EXPECT_EQ(2u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(2u, EffectiveFramesQueued()); algorithm_.EnqueueFrame(CreateFrame(tg.interval(2))); - EXPECT_EQ(3u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(3u, EffectiveFramesQueued()); algorithm_.EnqueueFrame(CreateFrame(tg.interval(3))); - EXPECT_EQ(4u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(4u, EffectiveFramesQueued()); EXPECT_EQ(4u, frames_queued()); EXPECT_EQ(384, algorithm_.GetMemoryUsage()); @@ -585,7 +621,7 @@ ASSERT_TRUE(frame); EXPECT_EQ(2u, frames_dropped); EXPECT_EQ(tg.interval(2), frame->timestamp()); - EXPECT_EQ(1u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(1u, EffectiveFramesQueued()); EXPECT_EQ(2u, frames_queued()); EXPECT_EQ(192, algorithm_.GetMemoryUsage()); @@ -595,7 +631,7 @@ ASSERT_TRUE(frame); EXPECT_EQ(0u, frames_dropped); EXPECT_EQ(tg.interval(3), frame->timestamp()); - EXPECT_EQ(0u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(0u, EffectiveFramesQueued()); EXPECT_EQ(1u, frames_queued()); EXPECT_EQ(96, algorithm_.GetMemoryUsage()); } @@ -634,7 +670,7 @@ EXPECT_EQ(tg.interval(0), frame->timestamp()); EXPECT_EQ(0u, frames_dropped); EXPECT_EQ(1u, frames_queued()); - EXPECT_EQ(1u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(1u, EffectiveFramesQueued()); // The same timestamp should be returned after time starts. tick_clock_->Advance(tg.interval(1)); @@ -644,18 +680,18 @@ EXPECT_EQ(tg.interval(0), frame->timestamp()); EXPECT_EQ(0u, frames_dropped); EXPECT_EQ(1u, frames_queued()); - EXPECT_EQ(1u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(1u, EffectiveFramesQueued()); // Ensure the next suitable frame is vended as time advances. algorithm_.EnqueueFrame(CreateFrame(tg.interval(1))); EXPECT_EQ(2u, frames_queued()); - EXPECT_EQ(2u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(2u, EffectiveFramesQueued()); frame = RenderAndStep(&tg, &frames_dropped); ASSERT_TRUE(frame); EXPECT_EQ(tg.interval(1), frame->timestamp()); EXPECT_EQ(0u, frames_dropped); EXPECT_EQ(1u, frames_queued()); - EXPECT_EQ(0u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(0u, EffectiveFramesQueued()); // Once time stops ticking, any further frames shouldn't be returned, even if // the interval requested more closely matches. @@ -666,7 +702,7 @@ EXPECT_EQ(tg.interval(1), frame->timestamp()); EXPECT_EQ(0u, frames_dropped); EXPECT_EQ(2u, frames_queued()); - EXPECT_EQ(1u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(1u, EffectiveFramesQueued()); } // Verify frames inserted out of order end up in the right spot and are rendered @@ -679,7 +715,7 @@ algorithm_.EnqueueFrame(CreateFrame(tg.interval(3))); algorithm_.EnqueueFrame(CreateFrame(tg.interval(2))); EXPECT_EQ(2u, frames_queued()); - EXPECT_EQ(2u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(2u, EffectiveFramesQueued()); time_source_.StartTicking(); @@ -689,7 +725,7 @@ EXPECT_EQ(0u, frames_dropped); EXPECT_EQ(tg.interval(2), frame->timestamp()); EXPECT_EQ(2u, frames_queued()); - EXPECT_EQ(2u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(2u, EffectiveFramesQueued()); // Since a frame has already been rendered, queuing this frame and calling // Render() should result in it being dropped; even though it's a better @@ -697,12 +733,12 @@ // it won't show up in frames_queued(). algorithm_.EnqueueFrame(CreateFrame(tg.interval(1))); EXPECT_EQ(2u, frames_queued()); - EXPECT_EQ(2u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(2u, EffectiveFramesQueued()); frame = RenderAndStep(&tg, &frames_dropped); EXPECT_EQ(1u, frames_dropped); EXPECT_EQ(tg.interval(2), frame->timestamp()); EXPECT_EQ(2u, frames_queued()); - EXPECT_EQ(2u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(2u, EffectiveFramesQueued()); } // Run through integer cadence selection for 1, 2, 3, and 4. @@ -803,7 +839,7 @@ scoped_refptr<VideoFrame> last_frame; bool have_overdisplayed_frame = false; while (!have_overdisplayed_frame) { - while (algorithm_.EffectiveFramesQueued() < 2) { + while (EffectiveFramesQueued() < 2) { algorithm_.EnqueueFrame( CreateFrame(frame_tg.current() - base::TimeTicks())); frame_tg.step(); @@ -1069,7 +1105,7 @@ algorithm_.EnqueueFrame(CreateFrame(tg.interval(0))); ASSERT_EQ(0u, algorithm_.RemoveExpiredFrames(tg.current())); - EXPECT_EQ(1u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(1u, EffectiveFramesQueued()); time_source_.StartTicking(); @@ -1083,29 +1119,61 @@ algorithm_.EnqueueFrame(CreateFrame(tg.interval(2))); algorithm_.EnqueueFrame(CreateFrame(tg.interval(3))); algorithm_.EnqueueFrame(CreateFrame(tg.interval(4))); - EXPECT_EQ(5u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(5u, EffectiveFramesQueued()); tg.step(2); - ASSERT_EQ(2u, algorithm_.RemoveExpiredFrames(tg.current())); + // Two frames are removed, one displayed frame (which should not be counted as + // dropped) and one undisplayed one. + ASSERT_EQ(1u, algorithm_.RemoveExpiredFrames(tg.current())); frame = RenderAndStep(&tg, &frames_dropped); EXPECT_EQ(1u, frames_dropped); EXPECT_EQ(2u, frames_queued()); - EXPECT_EQ(1u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(1u, EffectiveFramesQueued()); ASSERT_TRUE(frame); EXPECT_EQ(tg.interval(3), frame->timestamp()); // Advance expiry enough that one frame is removed, but one remains and is - // still counted as effective. + // still counted as effective; the expired frame was displayed so it is not + // counted as dropped. ASSERT_EQ( - 1u, algorithm_.RemoveExpiredFrames(tg.current() + tg.interval(1) * 0.9)); + 0u, algorithm_.RemoveExpiredFrames(tg.current() + tg.interval(1) * 0.9)); EXPECT_EQ(1u, frames_queued()); - EXPECT_EQ(1u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(1u, EffectiveFramesQueued()); // Advancing expiry once more should mark the frame as ineffective. tg.step(); ASSERT_EQ(0u, algorithm_.RemoveExpiredFrames(tg.current())); EXPECT_EQ(1u, frames_queued()); - EXPECT_EQ(0u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(0u, EffectiveFramesQueued()); +} + +TEST_F(VideoRendererAlgorithmTest, RemoveExpiredFramesPartialReset) { + TickGenerator tg(tick_clock_->NowTicks(), 50); + + algorithm_.EnqueueFrame(CreateFrame(tg.interval(0))); + algorithm_.EnqueueFrame(CreateFrame(tg.interval(1))); + ASSERT_EQ(0u, algorithm_.RemoveExpiredFrames(tg.current())); + EXPECT_EQ(2u, EffectiveFramesQueued()); + + time_source_.StartTicking(); + + // Render such that the next enqueued frame should be counting as expired. + for (int i = 0; i < 3; ++i) { + size_t frames_dropped = 0; + scoped_refptr<VideoFrame> frame = RenderAndStep(&tg, &frames_dropped); + ASSERT_TRUE(frame); + EXPECT_EQ(tg.interval(std::min(i, 1)), frame->timestamp()); + EXPECT_EQ(0u, frames_dropped); + } + + time_source_.StopTicking(); + algorithm_.Reset( + VideoRendererAlgorithm::ResetFlag::kPreserveNextFrameEstimates); + // Skip ahead several frames to ensure EnqueueFrame() estimates correctly. + algorithm_.EnqueueFrame(CreateFrame(tg.interval(5))); + EXPECT_EQ(1u, EffectiveFramesQueued()); + ASSERT_EQ(0u, algorithm_.RemoveExpiredFrames(tg.current())); + EXPECT_EQ(1u, EffectiveFramesQueued()); } TEST_F(VideoRendererAlgorithmTest, RemoveExpiredFramesCadence) { @@ -1117,7 +1185,7 @@ algorithm_.EnqueueFrame(CreateFrame(tg.interval(2))); ASSERT_EQ(0u, algorithm_.RemoveExpiredFrames(tg.current())); - EXPECT_EQ(3u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(3u, EffectiveFramesQueued()); time_source_.StartTicking(); @@ -1127,40 +1195,30 @@ EXPECT_EQ(tg.interval(0), frame->timestamp()); EXPECT_EQ(0u, frames_dropped); ASSERT_TRUE(is_using_cadence()); - EXPECT_EQ(2u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(2u, EffectiveFramesQueued()); // Advance expiry enough that some frames are removed, but one remains and is - // still counted as effective. - ASSERT_EQ(2u, algorithm_.RemoveExpiredFrames(tg.current() + tg.interval(1) + + // still counted as effective. 1 undisplayed and 1 displayed frame will be + // expired. + ASSERT_EQ(1u, algorithm_.RemoveExpiredFrames(tg.current() + tg.interval(1) + max_acceptable_drift() * 1.25)); EXPECT_EQ(1u, frames_queued()); - EXPECT_EQ(1u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(1u, EffectiveFramesQueued()); // Advancing expiry once more should mark the frame as ineffective. tg.step(3); ASSERT_EQ(0u, algorithm_.RemoveExpiredFrames(tg.current())); EXPECT_EQ(1u, frames_queued()); - EXPECT_EQ(0u, algorithm_.EffectiveFramesQueued()); + EXPECT_EQ(0u, EffectiveFramesQueued()); } -// TODO(crbug.com/570032): Test disabled for being flaky. -TEST_F(VideoRendererAlgorithmTest, DISABLED_CadenceBasedTest) { +// Test runs too slowly on debug builds. +#if defined(NDEBUG) +TEST_F(VideoRendererAlgorithmTest, CadenceBasedTest) { // Common display rates. const double kDisplayRates[] = { - NTSC(24), - 24, - NTSC(25), - 25, - NTSC(30), - 30, - 48, - NTSC(50), - 50, - NTSC(60), - 60, - 75, - 120, - 144, + NTSC(24), 24, NTSC(25), 25, NTSC(30), 30, 48, + NTSC(50), 50, NTSC(60), 60, 75, 120, 144, }; // List of common frame rate values. Values pulled from local test media, @@ -1183,6 +1241,7 @@ } } } +#endif // Rotate through various playback rates and ensure algorithm adapts correctly. TEST_F(VideoRendererAlgorithmTest, VariablePlaybackRateCadence) { @@ -1225,7 +1284,7 @@ bool cadence_detected = false; base::TimeDelta timestamp; for (size_t i = 0; i < arraysize(kBadTimestampsMs) * 2; ++i) { - while (algorithm_.EffectiveFramesQueued() < 3) { + while (EffectiveFramesQueued() < 3) { algorithm_.EnqueueFrame(CreateFrame(timestamp)); timestamp += base::TimeDelta::FromMilliseconds( kBadTimestampsMs[i % arraysize(kBadTimestampsMs)]); @@ -1260,7 +1319,7 @@ bool cadence_turned_off = false; base::TimeDelta timestamp; for (size_t i = 0; i < arraysize(kBadTimestampsMs);) { - while (algorithm_.EffectiveFramesQueued() < 3) { + while (EffectiveFramesQueued() < 3) { algorithm_.EnqueueFrame(CreateFrame(timestamp)); timestamp += base::TimeDelta::FromMilliseconds( kBadTimestampsMs[i % arraysize(kBadTimestampsMs)]);
diff --git a/media/mojo/services/android_mojo_media_client.cc b/media/mojo/services/android_mojo_media_client.cc index 27cb3bd..64775501 100644 --- a/media/mojo/services/android_mojo_media_client.cc +++ b/media/mojo/services/android_mojo_media_client.cc
@@ -16,9 +16,9 @@ namespace { std::unique_ptr<ProvisionFetcher> CreateProvisionFetcher( - mojo::shell::mojom::InterfaceProvider* interface_provider) { + shell::mojom::InterfaceProvider* interface_provider) { interfaces::ProvisionFetcherPtr provision_fetcher_ptr; - mojo::GetInterface(interface_provider, &provision_fetcher_ptr); + shell::GetInterface(interface_provider, &provision_fetcher_ptr); return base::WrapUnique( new MojoProvisionFetcher(std::move(provision_fetcher_ptr))); } @@ -37,7 +37,7 @@ } std::unique_ptr<CdmFactory> AndroidMojoMediaClient::CreateCdmFactory( - mojo::shell::mojom::InterfaceProvider* interface_provider) { + shell::mojom::InterfaceProvider* interface_provider) { return base::WrapUnique(new AndroidCdmFactory( base::Bind(&CreateProvisionFetcher, interface_provider))); }
diff --git a/media/mojo/services/android_mojo_media_client.h b/media/mojo/services/android_mojo_media_client.h index a158912..3ab07d8 100644 --- a/media/mojo/services/android_mojo_media_client.h +++ b/media/mojo/services/android_mojo_media_client.h
@@ -22,7 +22,7 @@ scoped_refptr<base::SingleThreadTaskRunner> task_runner) final; std::unique_ptr<CdmFactory> CreateCdmFactory( - mojo::shell::mojom::InterfaceProvider* interface_provider) final; + shell::mojom::InterfaceProvider* interface_provider) final; private: DISALLOW_COPY_AND_ASSIGN(AndroidMojoMediaClient);
diff --git a/media/mojo/services/default_mojo_media_client.cc b/media/mojo/services/default_mojo_media_client.cc index 8891e6d69..2cf9ac17 100644 --- a/media/mojo/services/default_mojo_media_client.cc +++ b/media/mojo/services/default_mojo_media_client.cc
@@ -15,7 +15,7 @@ } std::unique_ptr<CdmFactory> DefaultMojoMediaClient::CreateCdmFactory( - mojo::shell::mojom::InterfaceProvider* /* interface_provider */) { + shell::mojom::InterfaceProvider* /* interface_provider */) { DVLOG(1) << __FUNCTION__; // TODO(jrummell): Return a CdmFactory that can create CdmAdapter here. return nullptr;
diff --git a/media/mojo/services/default_mojo_media_client.h b/media/mojo/services/default_mojo_media_client.h index bbb232096..d9a491d 100644 --- a/media/mojo/services/default_mojo_media_client.h +++ b/media/mojo/services/default_mojo_media_client.h
@@ -21,7 +21,7 @@ // MojoMediaClient implementation. void Initialize() final; std::unique_ptr<CdmFactory> CreateCdmFactory( - mojo::shell::mojom::InterfaceProvider* /* interface_provider */) final; + shell::mojom::InterfaceProvider* /* interface_provider */) final; private: DISALLOW_COPY_AND_ASSIGN(DefaultMojoMediaClient);
diff --git a/media/mojo/services/main.cc b/media/mojo/services/main.cc index 990bf45..524dba66 100644 --- a/media/mojo/services/main.cc +++ b/media/mojo/services/main.cc
@@ -13,10 +13,10 @@ MojoResult MojoMain(MojoHandle mojo_handle) { // Enable logging. base::AtExitManager at_exit; - mojo::ApplicationRunner::InitBaseCommandLine(); + shell::ApplicationRunner::InitBaseCommandLine(); mojo::InitLogging(); - mojo::ApplicationRunner runner(new media::MojoMediaApplication( + shell::ApplicationRunner runner(new media::MojoMediaApplication( base::WrapUnique(new media::TestMojoMediaClient()))); return runner.Run(mojo_handle, false /* init_base */); }
diff --git a/media/mojo/services/media_apptest.cc b/media/mojo/services/media_apptest.cc index 63b44f5e..091fb244 100644 --- a/media/mojo/services/media_apptest.cc +++ b/media/mojo/services/media_apptest.cc
@@ -52,7 +52,7 @@ DISALLOW_COPY_AND_ASSIGN(MockRendererClient); }; -class MediaAppTest : public mojo::test::ApplicationTestBase { +class MediaAppTest : public shell::test::ApplicationTestBase { public: MediaAppTest() : renderer_client_binding_(&renderer_client_), @@ -128,7 +128,7 @@ StrictMock<MockDemuxerStream> video_demuxer_stream_; private: - std::unique_ptr<mojo::Connection> connection_; + std::unique_ptr<shell::Connection> connection_; DISALLOW_COPY_AND_ASSIGN(MediaAppTest); };
diff --git a/media/mojo/services/mojo_cdm_factory.cc b/media/mojo/services/mojo_cdm_factory.cc index 79704a94..0026b444 100644 --- a/media/mojo/services/mojo_cdm_factory.cc +++ b/media/mojo/services/mojo_cdm_factory.cc
@@ -17,7 +17,7 @@ namespace media { MojoCdmFactory::MojoCdmFactory( - mojo::shell::mojom::InterfaceProvider* interface_provider) + shell::mojom::InterfaceProvider* interface_provider) : interface_provider_(interface_provider) { DCHECK(interface_provider_); } @@ -53,8 +53,8 @@ } interfaces::ContentDecryptionModulePtr cdm_ptr; - mojo::GetInterface<interfaces::ContentDecryptionModule>(interface_provider_, - &cdm_ptr); + shell::GetInterface<interfaces::ContentDecryptionModule>(interface_provider_, + &cdm_ptr); MojoCdm::Create(key_system, security_origin, cdm_config, std::move(cdm_ptr), session_message_cb, session_closed_cb,
diff --git a/media/mojo/services/mojo_cdm_factory.h b/media/mojo/services/mojo_cdm_factory.h index d890d2f..9571ce8a 100644 --- a/media/mojo/services/mojo_cdm_factory.h +++ b/media/mojo/services/mojo_cdm_factory.h
@@ -8,20 +8,17 @@ #include "base/macros.h" #include "media/base/cdm_factory.h" -namespace mojo { namespace shell { namespace mojom { class InterfaceProvider; } } -} namespace media { class MojoCdmFactory : public CdmFactory { public: - explicit MojoCdmFactory( - mojo::shell::mojom::InterfaceProvider* interface_provider); + explicit MojoCdmFactory(shell::mojom::InterfaceProvider* interface_provider); ~MojoCdmFactory() final; // CdmFactory implementation. @@ -36,7 +33,7 @@ const CdmCreatedCB& cdm_created_cb) final; private: - mojo::shell::mojom::InterfaceProvider* interface_provider_; + shell::mojom::InterfaceProvider* interface_provider_; DISALLOW_COPY_AND_ASSIGN(MojoCdmFactory); };
diff --git a/media/mojo/services/mojo_decoder_factory.cc b/media/mojo/services/mojo_decoder_factory.cc index 0a1c252..5a21c212 100644 --- a/media/mojo/services/mojo_decoder_factory.cc +++ b/media/mojo/services/mojo_decoder_factory.cc
@@ -13,7 +13,7 @@ namespace media { MojoDecoderFactory::MojoDecoderFactory( - mojo::shell::mojom::InterfaceProvider* interface_provider) + shell::mojom::InterfaceProvider* interface_provider) : interface_provider_(interface_provider) { DCHECK(interface_provider_); } @@ -25,8 +25,8 @@ ScopedVector<AudioDecoder>* audio_decoders) { #if defined(ENABLE_MOJO_AUDIO_DECODER) interfaces::AudioDecoderPtr audio_decoder_ptr; - mojo::GetInterface<interfaces::AudioDecoder>(interface_provider_, - &audio_decoder_ptr); + shell::GetInterface<interfaces::AudioDecoder>(interface_provider_, + &audio_decoder_ptr); audio_decoders->push_back( new media::MojoAudioDecoder(task_runner, std::move(audio_decoder_ptr)));
diff --git a/media/mojo/services/mojo_decoder_factory.h b/media/mojo/services/mojo_decoder_factory.h index 94350a6..e834239 100644 --- a/media/mojo/services/mojo_decoder_factory.h +++ b/media/mojo/services/mojo_decoder_factory.h
@@ -14,7 +14,7 @@ class MojoDecoderFactory : public DecoderFactory { public: explicit MojoDecoderFactory( - mojo::shell::mojom::InterfaceProvider* interface_provider); + shell::mojom::InterfaceProvider* interface_provider); ~MojoDecoderFactory() final; void CreateAudioDecoders( @@ -26,7 +26,7 @@ ScopedVector<VideoDecoder>* video_decoders) final; private: - mojo::shell::mojom::InterfaceProvider* interface_provider_; + shell::mojom::InterfaceProvider* interface_provider_; DISALLOW_COPY_AND_ASSIGN(MojoDecoderFactory); };
diff --git a/media/mojo/services/mojo_media_application.cc b/media/mojo/services/mojo_media_application.cc index 7ee8e89..76fd23a6 100644 --- a/media/mojo/services/mojo_media_application.cc +++ b/media/mojo/services/mojo_media_application.cc
@@ -25,20 +25,20 @@ MojoMediaApplication::~MojoMediaApplication() {} -void MojoMediaApplication::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void MojoMediaApplication::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t /* id */) { connector_ = connector; mojo_media_client_->Initialize(); } -bool MojoMediaApplication::AcceptConnection(mojo::Connection* connection) { +bool MojoMediaApplication::AcceptConnection(shell::Connection* connection) { connection->AddInterface<interfaces::ServiceFactory>(this); return true; } void MojoMediaApplication::Create( - mojo::Connection* connection, + shell::Connection* connection, mojo::InterfaceRequest<interfaces::ServiceFactory> request) { // The created object is owned by the pipe. new ServiceFactoryImpl(std::move(request), connection->GetRemoteInterfaces(),
diff --git a/media/mojo/services/mojo_media_application.h b/media/mojo/services/mojo_media_application.h index 8775edbf..373c221 100644 --- a/media/mojo/services/mojo_media_application.h +++ b/media/mojo/services/mojo_media_application.h
@@ -23,22 +23,22 @@ class MojoMediaClient; class MojoMediaApplication - : public mojo::ShellClient, - public mojo::InterfaceFactory<interfaces::ServiceFactory> { + : public shell::ShellClient, + public shell::InterfaceFactory<interfaces::ServiceFactory> { public: explicit MojoMediaApplication( std::unique_ptr<MojoMediaClient> mojo_media_client); ~MojoMediaApplication() final; private: - // mojo::ShellClient implementation. - void Initialize(mojo::Connector* connector, - const mojo::Identity& identity, + // shell::ShellClient implementation. + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) final; - bool AcceptConnection(mojo::Connection* connection) final; + bool AcceptConnection(shell::Connection* connection) final; - // mojo::InterfaceFactory<interfaces::ServiceFactory> implementation. - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<interfaces::ServiceFactory> implementation. + void Create(shell::Connection* connection, mojo::InterfaceRequest<interfaces::ServiceFactory> request) final; // Note: Since each instance runs on a different thread, do not share a common @@ -46,9 +46,9 @@ // a unique_ptr here. std::unique_ptr<MojoMediaClient> mojo_media_client_; - mojo::Connector* connector_; + shell::Connector* connector_; scoped_refptr<MediaLog> media_log_; - mojo::MessageLoopRefFactory ref_factory_; + shell::MessageLoopRefFactory ref_factory_; }; } // namespace media
diff --git a/media/mojo/services/mojo_media_application_factory.cc b/media/mojo/services/mojo_media_application_factory.cc index 88ce7bc..aded2c67 100644 --- a/media/mojo/services/mojo_media_application_factory.cc +++ b/media/mojo/services/mojo_media_application_factory.cc
@@ -21,8 +21,8 @@ namespace media { // static -std::unique_ptr<mojo::ShellClient> CreateMojoMediaApplication() { - return std::unique_ptr<mojo::ShellClient>( +std::unique_ptr<shell::ShellClient> CreateMojoMediaApplication() { + return std::unique_ptr<shell::ShellClient>( new MojoMediaApplication(base::WrapUnique(new DefaultClient()))); }
diff --git a/media/mojo/services/mojo_media_application_factory.h b/media/mojo/services/mojo_media_application_factory.h index a05b46a..a2c6f59 100644 --- a/media/mojo/services/mojo_media_application_factory.h +++ b/media/mojo/services/mojo_media_application_factory.h
@@ -12,7 +12,7 @@ namespace media { // Creates a MojoMediaApplication instance using the default MojoMediaClient. -std::unique_ptr<mojo::ShellClient> CreateMojoMediaApplication(); +std::unique_ptr<shell::ShellClient> CreateMojoMediaApplication(); } // namespace media
diff --git a/media/mojo/services/mojo_media_client.cc b/media/mojo/services/mojo_media_client.cc index 8f30ec0f..2d81841b 100644 --- a/media/mojo/services/mojo_media_client.cc +++ b/media/mojo/services/mojo_media_client.cc
@@ -32,7 +32,7 @@ } std::unique_ptr<CdmFactory> MojoMediaClient::CreateCdmFactory( - mojo::shell::mojom::InterfaceProvider* interface_provider) { + shell::mojom::InterfaceProvider* interface_provider) { return nullptr; }
diff --git a/media/mojo/services/mojo_media_client.h b/media/mojo/services/mojo_media_client.h index 4b55c9f..eb923e2 100644 --- a/media/mojo/services/mojo_media_client.h +++ b/media/mojo/services/mojo_media_client.h
@@ -18,13 +18,11 @@ class SingleThreadTaskRunner; } -namespace mojo { namespace shell { namespace mojom { class InterfaceProvider; } } -} namespace media { @@ -55,7 +53,7 @@ // Returns the CdmFactory to be used by MojoCdmService. virtual std::unique_ptr<CdmFactory> CreateCdmFactory( - mojo::shell::mojom::InterfaceProvider* interface_provider); + shell::mojom::InterfaceProvider* interface_provider); protected: MojoMediaClient();
diff --git a/media/mojo/services/mojo_renderer_factory.cc b/media/mojo/services/mojo_renderer_factory.cc index 65580b00..ea740514 100644 --- a/media/mojo/services/mojo_renderer_factory.cc +++ b/media/mojo/services/mojo_renderer_factory.cc
@@ -12,7 +12,7 @@ namespace media { MojoRendererFactory::MojoRendererFactory( - mojo::shell::mojom::InterfaceProvider* interface_provider) + shell::mojom::InterfaceProvider* interface_provider) : interface_provider_(interface_provider) { DCHECK(interface_provider_); } @@ -27,7 +27,7 @@ VideoRendererSink* /* video_renderer_sink */, const RequestSurfaceCB& /* request_surface_cb */) { interfaces::RendererPtr renderer_ptr; - mojo::GetInterface<interfaces::Renderer>(interface_provider_, &renderer_ptr); + shell::GetInterface<interfaces::Renderer>(interface_provider_, &renderer_ptr); return std::unique_ptr<Renderer>( new MojoRendererImpl(media_task_runner, std::move(renderer_ptr)));
diff --git a/media/mojo/services/mojo_renderer_factory.h b/media/mojo/services/mojo_renderer_factory.h index 597fc99..a913e97 100644 --- a/media/mojo/services/mojo_renderer_factory.h +++ b/media/mojo/services/mojo_renderer_factory.h
@@ -11,13 +11,11 @@ #include "media/base/renderer_factory.h" #include "media/mojo/interfaces/renderer.mojom.h" -namespace mojo { namespace shell { namespace mojom { class InterfaceProvider; } } -} namespace media { @@ -25,7 +23,7 @@ class MojoRendererFactory : public RendererFactory { public: explicit MojoRendererFactory( - mojo::shell::mojom::InterfaceProvider* interface_provider); + shell::mojom::InterfaceProvider* interface_provider); ~MojoRendererFactory() final; std::unique_ptr<Renderer> CreateRenderer( @@ -36,7 +34,7 @@ const RequestSurfaceCB& request_surface_cb) final; private: - mojo::shell::mojom::InterfaceProvider* interface_provider_; + shell::mojom::InterfaceProvider* interface_provider_; DISALLOW_COPY_AND_ASSIGN(MojoRendererFactory); };
diff --git a/media/mojo/services/service_factory_impl.cc b/media/mojo/services/service_factory_impl.cc index 346761d..cb41cd4d 100644 --- a/media/mojo/services/service_factory_impl.cc +++ b/media/mojo/services/service_factory_impl.cc
@@ -27,9 +27,9 @@ ServiceFactoryImpl::ServiceFactoryImpl( mojo::InterfaceRequest<interfaces::ServiceFactory> request, - mojo::shell::mojom::InterfaceProvider* interfaces, + shell::mojom::InterfaceProvider* interfaces, scoped_refptr<MediaLog> media_log, - std::unique_ptr<mojo::MessageLoopRef> parent_app_refcount, + std::unique_ptr<shell::MessageLoopRef> parent_app_refcount, MojoMediaClient* mojo_media_client) : binding_(this, std::move(request)), interfaces_(interfaces),
diff --git a/media/mojo/services/service_factory_impl.h b/media/mojo/services/service_factory_impl.h index e40c7f1..ede1fa68 100644 --- a/media/mojo/services/service_factory_impl.h +++ b/media/mojo/services/service_factory_impl.h
@@ -33,9 +33,9 @@ class ServiceFactoryImpl : public interfaces::ServiceFactory { public: ServiceFactoryImpl(mojo::InterfaceRequest<interfaces::ServiceFactory> request, - mojo::shell::mojom::InterfaceProvider* interfaces, + shell::mojom::InterfaceProvider* interfaces, scoped_refptr<MediaLog> media_log, - std::unique_ptr<mojo::MessageLoopRef> parent_app_refcount, + std::unique_ptr<shell::MessageLoopRef> parent_app_refcount, MojoMediaClient* mojo_media_client); ~ServiceFactoryImpl() final; @@ -62,9 +62,9 @@ MojoCdmServiceContext cdm_service_context_; mojo::StrongBinding<interfaces::ServiceFactory> binding_; - mojo::shell::mojom::InterfaceProvider* interfaces_; + shell::mojom::InterfaceProvider* interfaces_; scoped_refptr<MediaLog> media_log_; - std::unique_ptr<mojo::MessageLoopRef> parent_app_refcount_; + std::unique_ptr<shell::MessageLoopRef> parent_app_refcount_; MojoMediaClient* mojo_media_client_; DISALLOW_COPY_AND_ASSIGN(ServiceFactoryImpl);
diff --git a/media/mojo/services/test_mojo_media_client.cc b/media/mojo/services/test_mojo_media_client.cc index 162a4b0..8dbd843 100644 --- a/media/mojo/services/test_mojo_media_client.cc +++ b/media/mojo/services/test_mojo_media_client.cc
@@ -65,7 +65,7 @@ } std::unique_ptr<CdmFactory> TestMojoMediaClient::CreateCdmFactory( - mojo::shell::mojom::InterfaceProvider* /* interface_provider */) { + shell::mojom::InterfaceProvider* /* interface_provider */) { DVLOG(1) << __FUNCTION__; return base::WrapUnique(new DefaultCdmFactory()); }
diff --git a/media/mojo/services/test_mojo_media_client.h b/media/mojo/services/test_mojo_media_client.h index 5542dfb..8bf795cd 100644 --- a/media/mojo/services/test_mojo_media_client.h +++ b/media/mojo/services/test_mojo_media_client.h
@@ -32,7 +32,7 @@ VideoRendererSink* CreateVideoRendererSink( const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) final; std::unique_ptr<CdmFactory> CreateCdmFactory( - mojo::shell::mojom::InterfaceProvider* /* interface_provider */) final; + shell::mojom::InterfaceProvider* /* interface_provider */) final; private: FakeAudioLogFactory fake_audio_log_factory_;
diff --git a/media/renderers/video_renderer_impl.cc b/media/renderers/video_renderer_impl.cc index ab7d0795..11caf253 100644 --- a/media/renderers/video_renderer_impl.cc +++ b/media/renderers/video_renderer_impl.cc
@@ -201,11 +201,11 @@ // If |time_progressing_| is actually true when |render_first_frame_and_stop_| // is also true, then the ended callback will be harmlessly delayed until // MaybeStopSinkAfterFirstPaint() runs and the next Render() call comes in. - const size_t effective_frames = - MaybeFireEndedCallback_Locked(!render_first_frame_and_stop_); + MaybeFireEndedCallback_Locked(!render_first_frame_and_stop_); if (buffering_state_ == BUFFERING_HAVE_ENOUGH && !received_end_of_stream_ && - !effective_frames && (!background_rendering || - (!frames_decoded_ && was_background_rendering_))) { + !algorithm_->effective_frames_queued() && + (!background_rendering || + (!frames_decoded_ && was_background_rendering_))) { // Do not set |buffering_state_| here as the lock in FrameReady() may be // held already and it fire the state changes in the wrong order. task_runner_->PostTask( @@ -339,7 +339,7 @@ pending_read_ = false; if (status == VideoFrameStream::DECODE_ERROR) { - DCHECK(!frame.get()); + DCHECK(!frame); PipelineStatus error = PIPELINE_ERROR_DECODE; task_runner_->PostTask(FROM_HERE, base::Bind(error_cb_, error)); return; @@ -354,7 +354,7 @@ DCHECK_EQ(state_, kPlaying); // Can happen when demuxers are preparing for a new Seek(). - if (!frame.get()) { + if (!frame) { DCHECK_EQ(status, VideoFrameStream::DEMUXER_READ_ABORTED); return; } @@ -575,7 +575,7 @@ // When the display rate is less than the frame rate, the effective frames // queued may be much smaller than the actual number of frames queued. Here // we ensure that frames_queued() doesn't get excessive. - return algorithm_->EffectiveFramesQueued() >= kMaxVideoFrames || + return algorithm_->effective_frames_queued() >= kMaxVideoFrames || algorithm_->frames_queued() >= 3 * kMaxVideoFrames; } @@ -595,32 +595,29 @@ was_background_rendering_ = false; } -size_t VideoRendererImpl::MaybeFireEndedCallback_Locked(bool time_progressing) { +void VideoRendererImpl::MaybeFireEndedCallback_Locked(bool time_progressing) { lock_.AssertAcquired(); // If there's only one frame in the video or Render() was never called, the // algorithm will have one frame linger indefinitely. So in cases where the // frame duration is unknown and we've received EOS, fire it once we get down // to a single frame. - const size_t effective_frames = algorithm_->EffectiveFramesQueued(); // Don't fire ended if we haven't received EOS or have already done so. if (!received_end_of_stream_ || rendered_end_of_stream_) - return effective_frames; + return; // Don't fire ended if time isn't moving and we have frames. if (!time_progressing && algorithm_->frames_queued()) - return effective_frames; + return; // Fire ended if we have no more effective frames or only ever had one frame. - if (!effective_frames || + if (!algorithm_->effective_frames_queued() || (algorithm_->frames_queued() == 1u && - algorithm_->average_frame_duration() == base::TimeDelta())) { + algorithm_->average_frame_duration().is_zero())) { rendered_end_of_stream_ = true; task_runner_->PostTask(FROM_HERE, ended_cb_); } - - return effective_frames; } base::TimeTicks VideoRendererImpl::ConvertMediaTimestamp(
diff --git a/media/renderers/video_renderer_impl.h b/media/renderers/video_renderer_impl.h index 0af253f..9f1c01c 100644 --- a/media/renderers/video_renderer_impl.h +++ b/media/renderers/video_renderer_impl.h
@@ -144,9 +144,7 @@ // value of |time_progressing_|. When called from Render() on the sink // callback thread, the inverse of |render_first_frame_and_stop_| should be // used as a proxy for |time_progressing_|. - // - // Returns algorithm_->EffectiveFramesQueued(). - size_t MaybeFireEndedCallback_Locked(bool time_progressing); + void MaybeFireEndedCallback_Locked(bool time_progressing); // Helper method for converting a single media timestamp to wall clock time. base::TimeTicks ConvertMediaTimestamp(base::TimeDelta media_timestamp);
diff --git a/media/test/pipeline_integration_test.cc b/media/test/pipeline_integration_test.cc index a88811f..5411600 100644 --- a/media/test/pipeline_integration_test.cc +++ b/media/test/pipeline_integration_test.cc
@@ -653,7 +653,7 @@ }; #if defined(MOJO_RENDERER) -class PipelineIntegrationTestHost : public mojo::test::ApplicationTestBase, +class PipelineIntegrationTestHost : public shell::test::ApplicationTestBase, public PipelineIntegrationTestBase { public: bool ShouldCreateDefaultRunLoop() override { return false; }
diff --git a/mojo/public/cpp/bindings/tests/versioning_test_service.cc b/mojo/public/cpp/bindings/tests/versioning_test_service.cc index 082178eb..43020f4 100644 --- a/mojo/public/cpp/bindings/tests/versioning_test_service.cc +++ b/mojo/public/cpp/bindings/tests/versioning_test_service.cc
@@ -95,12 +95,12 @@ }; class HumanResourceSystemServer - : public ShellClient, + : public shell::ShellClient, public InterfaceFactory<HumanResourceDatabase> { public: HumanResourceSystemServer() {} - // mojo::ShellClient implementation. + // shell::ShellClient implementation. bool AcceptConnection(Connection* connection) override { connection->AddInterface<HumanResourceDatabase>(this); return true;
diff --git a/remoting/protocol/webrtc_video_renderer_adapter.cc b/remoting/protocol/webrtc_video_renderer_adapter.cc index 264f7988..ab8ec44 100644 --- a/remoting/protocol/webrtc_video_renderer_adapter.cc +++ b/remoting/protocol/webrtc_video_renderer_adapter.cc
@@ -59,7 +59,7 @@ // BasicDesktopFrame is created directly. This will not work correctly with // all FrameConsumer implementations. Fix this somehow. std::unique_ptr<webrtc::DesktopFrame> rgb_frame(new webrtc::BasicDesktopFrame( - webrtc::DesktopSize(frame.GetWidth(), frame.GetHeight()))); + webrtc::DesktopSize(frame.width(), frame.height()))); frame.ConvertToRgbBuffer( output_format_fourcc_, rgb_frame->data(),
diff --git a/services/catalog/catalog.cc b/services/catalog/catalog.cc index 3a45f77..8ebb33c0 100644 --- a/services/catalog/catalog.cc +++ b/services/catalog/catalog.cc
@@ -24,33 +24,33 @@ base::FilePath GetManifestPath(const base::FilePath& package_dir, const std::string& name) { // TODO(beng): think more about how this should be done for exe targets. - std::string type = mojo::GetNameType(name); - std::string path = mojo::GetNamePath(name); - if (type == mojo::kNameType_Mojo) { + std::string type = shell::GetNameType(name); + std::string path = shell::GetNamePath(name); + if (type == shell::kNameType_Mojo) { return package_dir.AppendASCII("Mojo Applications").AppendASCII( path + "/manifest.json"); } - if (type == mojo::kNameType_Exe) + if (type == shell::kNameType_Exe) return package_dir.AppendASCII(path + "_manifest.json"); return base::FilePath(); } base::FilePath GetPackagePath(const base::FilePath& package_dir, const std::string& name) { - std::string type = mojo::GetNameType(name); - if (type == mojo::kNameType_Mojo) { + std::string type = shell::GetNameType(name); + if (type == shell::kNameType_Mojo) { // It's still a mojo: URL, use the default mapping scheme. - const std::string host = mojo::GetNamePath(name); + const std::string host = shell::GetNamePath(name); return package_dir.AppendASCII("Mojo Applications").AppendASCII( host + "/" + host + ".mojo"); } - if (type == mojo::kNameType_Exe) { + if (type == shell::kNameType_Exe) { #if defined OS_WIN std::string extension = ".exe"; #else std::string extension; #endif - return package_dir.AppendASCII(mojo::GetNamePath(name) + extension); + return package_dir.AppendASCII(shell::GetNamePath(name) + extension); } return base::FilePath(); } @@ -70,7 +70,7 @@ scoped_ptr<ReadManifestResult> result(new ReadManifestResult); // NOTE: This TypeConverter must run on a thread which allows IO. - result->resolve_result = mojo::shell::mojom::ResolveResult::From(*entry); + result->resolve_result = shell::mojom::ResolveResult::From(*entry); result->catalog_entry = std::move(entry); result->package_dir = system_package_dir; return result; @@ -125,8 +125,7 @@ resolver_bindings_.AddBinding(this, std::move(request)); } -void Catalog::BindShellResolver( - mojo::shell::mojom::ShellResolverRequest request) { +void Catalog::BindShellResolver(shell::mojom::ShellResolverRequest request) { shell_resolver_bindings_.AddBinding(this, std::move(request)); } @@ -154,25 +153,25 @@ } //////////////////////////////////////////////////////////////////////////////// -// Catalog, mojo::shell::mojom::ShellResolver: +// Catalog, shell::mojom::ShellResolver: void Catalog::ResolveMojoName(const mojo::String& mojo_name, const ResolveMojoNameCallback& callback) { - std::string type = mojo::GetNameType(mojo_name); + std::string type = shell::GetNameType(mojo_name); if (type != "mojo" && type != "exe") { scoped_ptr<Entry> entry(new Entry(mojo_name)); - callback.Run(mojo::shell::mojom::ResolveResult::From(*entry)); + callback.Run(shell::mojom::ResolveResult::From(*entry)); return; } auto entry = user_catalog_.find(mojo_name); if (entry != user_catalog_.end()) { - callback.Run(mojo::shell::mojom::ResolveResult::From(*entry->second)); + callback.Run(shell::mojom::ResolveResult::From(*entry->second)); return; } entry = system_catalog_->find(mojo_name); if (entry != system_catalog_->end()) { - callback.Run(mojo::shell::mojom::ResolveResult::From(*entry->second)); + callback.Run(shell::mojom::ResolveResult::From(*entry->second)); return; }
diff --git a/services/catalog/catalog.h b/services/catalog/catalog.h index 48cda4c..9301e53 100644 --- a/services/catalog/catalog.h +++ b/services/catalog/catalog.h
@@ -26,13 +26,13 @@ struct ReadManifestResult { ReadManifestResult(); ~ReadManifestResult(); - mojo::shell::mojom::ResolveResultPtr resolve_result; + shell::mojom::ResolveResultPtr resolve_result; scoped_ptr<Entry> catalog_entry; base::FilePath package_dir; }; class Catalog : public mojom::Resolver, - public mojo::shell::mojom::ShellResolver, + public shell::mojom::ShellResolver, public mojom::Catalog { public: // |manifest_provider| may be null. @@ -43,7 +43,7 @@ ~Catalog() override; void BindResolver(mojom::ResolverRequest request); - void BindShellResolver(mojo::shell::mojom::ShellResolverRequest request); + void BindShellResolver(shell::mojom::ShellResolverRequest request); void BindCatalog(mojom::CatalogRequest request); private: @@ -59,7 +59,7 @@ const mojo::String& scheme, const ResolveProtocolSchemeCallback& callback) override; - // mojo::shell::mojom::ShellResolver: + // shell::mojom::ShellResolver: void ResolveMojoName(const mojo::String& mojo_name, const ResolveMojoNameCallback& callback) override; @@ -96,7 +96,7 @@ base::TaskRunner* const file_task_runner_; mojo::BindingSet<mojom::Resolver> resolver_bindings_; - mojo::BindingSet<mojo::shell::mojom::ShellResolver> shell_resolver_bindings_; + mojo::BindingSet<shell::mojom::ShellResolver> shell_resolver_bindings_; mojo::BindingSet<mojom::Catalog> catalog_bindings_; // The current user's packages, constructed from Store/package manifests.
diff --git a/services/catalog/entry.cc b/services/catalog/entry.cc index 8d0784ba..def30aa6 100644 --- a/services/catalog/entry.cc +++ b/services/catalog/entry.cc
@@ -13,16 +13,15 @@ namespace catalog { namespace { -mojo::CapabilitySpec BuildCapabilitiesV0( - const base::DictionaryValue& value) { - mojo::CapabilitySpec capabilities; +shell::CapabilitySpec BuildCapabilitiesV0(const base::DictionaryValue& value) { + shell::CapabilitySpec capabilities; base::DictionaryValue::Iterator it(value); for (; !it.IsAtEnd(); it.Advance()) { const base::ListValue* values = nullptr; CHECK(it.value().GetAsList(&values)); - mojo::CapabilityRequest spec; + shell::CapabilityRequest spec; for (auto i = values->begin(); i != values->end(); ++i) { - mojo::Interface interface_name; + shell::Interface interface_name; const base::Value* v = *i; CHECK(v->GetAsString(&interface_name)); spec.interfaces.insert(interface_name); @@ -60,9 +59,8 @@ ReadStringSet(*list_value, string_set); } -mojo::CapabilitySpec BuildCapabilitiesV1( - const base::DictionaryValue& value) { - mojo::CapabilitySpec capabilities; +shell::CapabilitySpec BuildCapabilitiesV1(const base::DictionaryValue& value) { + shell::CapabilitySpec capabilities; const base::DictionaryValue* provided_value = nullptr; if (value.HasKey(Store::kCapabilities_ProvidedKey)) { @@ -70,10 +68,10 @@ &provided_value)); } if (provided_value) { - mojo::CapabilityRequest provided; + shell::CapabilityRequest provided; base::DictionaryValue::Iterator it(*provided_value); for(; !it.IsAtEnd(); it.Advance()) { - mojo::Interfaces interfaces; + shell::Interfaces interfaces; ReadStringSetFromValue(it.value(), &interfaces); capabilities.provided[it.key()] = interfaces; } @@ -87,7 +85,7 @@ if (required_value) { base::DictionaryValue::Iterator it(*required_value); for (; !it.IsAtEnd(); it.Advance()) { - mojo::CapabilityRequest spec; + shell::CapabilityRequest spec; const base::DictionaryValue* entry_value = nullptr; CHECK(it.value().GetAsDictionary(&entry_value)); ReadStringSetFromDictionary( @@ -104,9 +102,7 @@ Entry::Entry() {} Entry::Entry(const std::string& name) - : name_(name), - qualifier_(mojo::GetNamePath(name)), - display_name_(name) {} + : name_(name), qualifier_(shell::GetNamePath(name)), display_name_(name) {} Entry::Entry(const Entry& other) = default; Entry::~Entry() {} @@ -157,7 +153,7 @@ LOG(ERROR) << "Entry::Deserialize: dictionary has no name key"; return nullptr; } - if (!mojo::IsValidName(name_string)) { + if (!shell::IsValidName(name_string)) { LOG(WARNING) << "Entry::Deserialize: " << name_string << " is not a valid " << "Mojo name"; return nullptr; @@ -168,7 +164,7 @@ CHECK(value.GetString(Store::kQualifierKey, &qualifier)); entry->set_qualifier(qualifier); } else { - entry->set_qualifier(mojo::GetNamePath(name_string)); + entry->set_qualifier(shell::GetNamePath(name_string)); } std::string display_name; if (!value.GetString(Store::kDisplayNameKey, &display_name)) {
diff --git a/services/catalog/entry.h b/services/catalog/entry.h index 48ad1fb..6d382e6b 100644 --- a/services/catalog/entry.h +++ b/services/catalog/entry.h
@@ -46,8 +46,8 @@ void set_display_name(const std::string& display_name) { display_name_ = display_name; } - const mojo::CapabilitySpec& capabilities() const { return capabilities_; } - void set_capabilities(const mojo::CapabilitySpec& capabilities) { + const shell::CapabilitySpec& capabilities() const { return capabilities_; } + void set_capabilities(const shell::CapabilitySpec& capabilities) { capabilities_ = capabilities; } const Entry* package() const { return package_; } @@ -59,7 +59,7 @@ base::FilePath path_; std::string qualifier_; std::string display_name_; - mojo::CapabilitySpec capabilities_; + shell::CapabilitySpec capabilities_; Entry* package_ = nullptr; std::set<Entry*> applications_; };
diff --git a/services/catalog/entry_unittest.cc b/services/catalog/entry_unittest.cc index 47e286d..c1dcc33 100644 --- a/services/catalog/entry_unittest.cc +++ b/services/catalog/entry_unittest.cc
@@ -56,7 +56,7 @@ TEST_F(EntryTest, Simple) { scoped_ptr<Entry> entry = ReadEntry("simple", nullptr); EXPECT_EQ("mojo:foo", entry->name()); - EXPECT_EQ(mojo::GetNamePath(entry->name()), entry->qualifier()); + EXPECT_EQ(shell::GetNamePath(entry->name()), entry->qualifier()); EXPECT_EQ("Foo", entry->display_name()); } @@ -73,8 +73,8 @@ EXPECT_EQ("mojo:foo", entry->name()); EXPECT_EQ("bar", entry->qualifier()); EXPECT_EQ("Foo", entry->display_name()); - mojo::CapabilitySpec spec; - mojo::CapabilityRequest request; + shell::CapabilitySpec spec; + shell::CapabilityRequest request; request.interfaces.insert("mojo::Bar"); spec.required["mojo:bar"] = request; EXPECT_EQ(spec, entry->capabilities());
diff --git a/services/catalog/factory.cc b/services/catalog/factory.cc index d687b887..0d98c7f 100644 --- a/services/catalog/factory.cc +++ b/services/catalog/factory.cc
@@ -18,38 +18,38 @@ store_(std::move(store)), manifest_provider_(manifest_provider), weak_factory_(this) { - mojo::shell::mojom::ShellClientRequest request = GetProxy(&shell_client_); - shell_connection_.reset(new mojo::ShellConnection(this, std::move(request))); + shell::mojom::ShellClientRequest request = GetProxy(&shell_client_); + shell_connection_.reset(new shell::ShellConnection(this, std::move(request))); } Factory::~Factory() {} -mojo::shell::mojom::ShellClientPtr Factory::TakeShellClient() { +shell::mojom::ShellClientPtr Factory::TakeShellClient() { return std::move(shell_client_); } -bool Factory::AcceptConnection(mojo::Connection* connection) { +bool Factory::AcceptConnection(shell::Connection* connection) { connection->AddInterface<mojom::Catalog>(this); connection->AddInterface<mojom::Resolver>(this); - connection->AddInterface<mojo::shell::mojom::ShellResolver>(this); + connection->AddInterface<shell::mojom::ShellResolver>(this); return true; } -void Factory::Create(mojo::Connection* connection, +void Factory::Create(shell::Connection* connection, mojom::ResolverRequest request) { Catalog* instance = GetCatalogForUserId(connection->GetRemoteIdentity().user_id()); instance->BindResolver(std::move(request)); } -void Factory::Create(mojo::Connection* connection, - mojo::shell::mojom::ShellResolverRequest request) { +void Factory::Create(shell::Connection* connection, + shell::mojom::ShellResolverRequest request) { Catalog* instance = GetCatalogForUserId(connection->GetRemoteIdentity().user_id()); instance->BindShellResolver(std::move(request)); } -void Factory::Create(mojo::Connection* connection, +void Factory::Create(shell::Connection* connection, mojom::CatalogRequest request) { Catalog* instance = GetCatalogForUserId(connection->GetRemoteIdentity().user_id());
diff --git a/services/catalog/factory.h b/services/catalog/factory.h index 70f9221a..867b9f1860 100644 --- a/services/catalog/factory.h +++ b/services/catalog/factory.h
@@ -23,7 +23,7 @@ class TaskRunner; } -namespace mojo{ +namespace shell { class ShellConnection; } @@ -35,11 +35,10 @@ // Creates and owns an instance of the catalog. Exposes a ShellClientPtr that // can be passed to the Shell, potentially in a different process. -class Factory - : public mojo::ShellClient, - public mojo::InterfaceFactory<mojom::Catalog>, - public mojo::InterfaceFactory<mojom::Resolver>, - public mojo::InterfaceFactory<mojo::shell::mojom::ShellResolver> { +class Factory : public shell::ShellClient, + public shell::InterfaceFactory<mojom::Catalog>, + public shell::InterfaceFactory<mojom::Resolver>, + public shell::InterfaceFactory<shell::mojom::ShellResolver> { public: // |manifest_provider| may be null. Factory(base::TaskRunner* file_task_runner, @@ -47,22 +46,22 @@ ManifestProvider* manifest_provider); ~Factory() override; - mojo::shell::mojom::ShellClientPtr TakeShellClient(); + shell::mojom::ShellClientPtr TakeShellClient(); private: - // mojo::ShellClient: - bool AcceptConnection(mojo::Connection* connection) override; + // shell::ShellClient: + bool AcceptConnection(shell::Connection* connection) override; - // mojo::InterfaceFactory<mojom::Resolver>: - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<mojom::Resolver>: + void Create(shell::Connection* connection, mojom::ResolverRequest request) override; - // mojo::InterfaceFactory<mojo::shell::mojom::ShellResolver>: - void Create(mojo::Connection* connection, - mojo::shell::mojom::ShellResolverRequest request) override; + // shell::InterfaceFactory<shell::mojom::ShellResolver>: + void Create(shell::Connection* connection, + shell::mojom::ShellResolverRequest request) override; - // mojo::InterfaceFactory<mojom::Catalog>: - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<mojom::Catalog>: + void Create(shell::Connection* connection, mojom::CatalogRequest request) override; Catalog* GetCatalogForUserId(const std::string& user_id); @@ -71,8 +70,8 @@ scoped_ptr<Store> store_; ManifestProvider* const manifest_provider_; - mojo::shell::mojom::ShellClientPtr shell_client_; - scoped_ptr<mojo::ShellConnection> shell_connection_; + shell::mojom::ShellClientPtr shell_client_; + scoped_ptr<shell::ShellConnection> shell_connection_; std::map<std::string, scoped_ptr<Catalog>> catalogs_;
diff --git a/services/shell/background/background_shell.cc b/services/shell/background/background_shell.cc index 629f58c7..6ce9f8a 100644 --- a/services/shell/background/background_shell.cc +++ b/services/shell/background/background_shell.cc
@@ -8,6 +8,7 @@ #include "base/bind_helpers.h" #include "base/command_line.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "base/path_service.h" #include "base/synchronization/waitable_event.h" #include "base/threading/simple_thread.h" @@ -20,12 +21,12 @@ #include "services/shell/shell.h" #include "services/shell/standalone/context.h" -namespace mojo { namespace shell { + namespace { -scoped_ptr<base::MessagePump> CreateMessagePumpMojo() { - return make_scoped_ptr(new common::MessagePumpMojo); +std::unique_ptr<base::MessagePump> CreateMessagePumpMojo() { + return base::WrapUnique(new mojo::common::MessagePumpMojo); } // Used to obtain the ShellClientRequest for an application. When Loader::Load() @@ -70,13 +71,13 @@ // Manages the thread to startup mojo. class BackgroundShell::MojoThread : public base::SimpleThread { public: - explicit MojoThread(scoped_ptr<BackgroundShell::InitParams> init_params) + explicit MojoThread(std::unique_ptr<BackgroundShell::InitParams> init_params) : SimpleThread("mojo-background-shell"), init_params_(std::move(init_params)) {} ~MojoThread() override {} void CreateShellClientRequest(base::WaitableEvent* signal, - scoped_ptr<ConnectParams> params, + std::unique_ptr<ConnectParams> params, mojom::ShellClientRequest* request) { // Only valid to call this on the background thread. DCHECK_EQ(message_loop_, base::MessageLoop::current()); @@ -86,7 +87,7 @@ BackgroundLoader* loader = new BackgroundLoader( base::Bind(&MojoThread::OnGotApplicationRequest, base::Unretained(this), name, signal, request)); - context_->shell()->SetLoaderForName(make_scoped_ptr(loader), name); + context_->shell()->SetLoaderForName(base::WrapUnique(loader), name); context_->shell()->Connect(std::move(params)); // The request is asynchronously processed. When processed // OnGotApplicationRequest() is called and we'll signal |signal|. @@ -116,10 +117,10 @@ void Run() override { // The construction/destruction order is very finicky and has to be done // in the order here. - scoped_ptr<base::MessageLoop> message_loop(message_loop_); + std::unique_ptr<base::MessageLoop> message_loop(message_loop_); - scoped_ptr<mojo::shell::Context::InitParams> context_init_params( - new mojo::shell::Context::InitParams); + std::unique_ptr<Context::InitParams> context_init_params( + new Context::InitParams); if (init_params_) { context_init_params->catalog_store = std::move(init_params_->catalog_store); @@ -132,7 +133,7 @@ message_loop_->BindToCurrentThread(); - scoped_ptr<Context> context(new Context); + std::unique_ptr<Context> context(new Context); context_ = context.get(); context_->Init(std::move(context_init_params)); @@ -163,7 +164,7 @@ // Created in Run() on the background thread. Context* context_ = nullptr; - scoped_ptr<BackgroundShell::InitParams> init_params_; + std::unique_ptr<BackgroundShell::InitParams> init_params_; DISALLOW_COPY_AND_ASSIGN(MojoThread); }; @@ -177,7 +178,7 @@ thread_->Stop(); } -void BackgroundShell::Init(scoped_ptr<InitParams> init_params) { +void BackgroundShell::Init(std::unique_ptr<InitParams> init_params) { DCHECK(!thread_); thread_.reset(new MojoThread(std::move(init_params))); thread_->Start(); @@ -185,7 +186,7 @@ mojom::ShellClientRequest BackgroundShell::CreateShellClientRequest( const std::string& name) { - scoped_ptr<ConnectParams> params(new ConnectParams); + std::unique_ptr<ConnectParams> params(new ConnectParams); params->set_source(CreateShellIdentity()); params->set_target(Identity(name, mojom::kRootUserID)); mojom::ShellClientRequest request; @@ -206,4 +207,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/background/background_shell.h b/services/shell/background/background_shell.h index f61ab5b7..8b48dd53 100644 --- a/services/shell/background/background_shell.h +++ b/services/shell/background/background_shell.h
@@ -5,10 +5,10 @@ #ifndef SERVICES_SHELL_BACKGROUND_BACKGROUND_SHELL_H_ #define SERVICES_SHELL_BACKGROUND_BACKGROUND_SHELL_H_ +#include <memory> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "mojo/public/cpp/bindings/interface_request.h" #include "services/catalog/store.h" #include "services/shell/public/interfaces/shell_client.mojom.h" @@ -17,7 +17,6 @@ class Store; } -namespace mojo { namespace shell { class NativeRunnerDelegate; @@ -34,7 +33,7 @@ ~InitParams(); NativeRunnerDelegate* native_runner_delegate = nullptr; - scoped_ptr<catalog::Store> catalog_store; + std::unique_ptr<catalog::Store> catalog_store; // If true the edk is initialized. bool init_edk = true; }; @@ -44,7 +43,7 @@ // Starts the background shell. |command_line_switches| are additional // switches applied to any processes spawned by this call. - void Init(scoped_ptr<InitParams> init_params); + void Init(std::unique_ptr<InitParams> init_params); // Obtains an InterfaceRequest for the specified name. mojom::ShellClientRequest CreateShellClientRequest( @@ -58,12 +57,11 @@ private: class MojoThread; - scoped_ptr<MojoThread> thread_; + std::unique_ptr<MojoThread> thread_; DISALLOW_COPY_AND_ASSIGN(BackgroundShell); }; } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_BACKGROUND_BACKGROUND_SHELL_H_
diff --git a/services/shell/background/background_shell_main.cc b/services/shell/background/background_shell_main.cc index 472f012..e8d7b21 100644 --- a/services/shell/background/background_shell_main.cc +++ b/services/shell/background/background_shell_main.cc
@@ -12,7 +12,6 @@ #include "services/shell/runner/host/child_process.h" #include "services/shell/runner/init.h" -namespace mojo { namespace shell { namespace { @@ -28,13 +27,12 @@ } // namespace } // namespace shell -} // namespace mojo int main(int argc, char** argv) { base::CommandLine::Init(argc, argv); if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kChildProcess)) { - return mojo::shell::RunChildProcess(); + return shell::RunChildProcess(); } // Reset CommandLine as most likely main() is going to use CommandLine too // and expect to be able to initialize it.
diff --git a/services/shell/background/tests/background_shell_unittest.cc b/services/shell/background/tests/background_shell_unittest.cc index 28cc5e3..0e945f6 100644 --- a/services/shell/background/tests/background_shell_unittest.cc +++ b/services/shell/background/tests/background_shell_unittest.cc
@@ -4,6 +4,9 @@ #include "services/shell/background/background_shell.h" +#include <memory> + +#include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "services/shell/background/tests/test.mojom.h" #include "services/shell/background/tests/test_catalog_store.h" @@ -12,7 +15,6 @@ #include "services/shell/public/cpp/shell_connection.h" #include "testing/gtest/include/gtest/gtest.h" -namespace mojo { namespace shell { namespace { @@ -27,10 +29,10 @@ DISALLOW_COPY_AND_ASSIGN(ShellClientImpl); }; -scoped_ptr<TestCatalogStore> BuildTestCatalogStore() { - scoped_ptr<base::ListValue> apps(new base::ListValue); +std::unique_ptr<TestCatalogStore> BuildTestCatalogStore() { + std::unique_ptr<base::ListValue> apps(new base::ListValue); apps->Append(BuildPermissiveSerializedAppInfo(kTestName, "test")); - return make_scoped_ptr(new TestCatalogStore(std::move(apps))); + return base::WrapUnique(new TestCatalogStore(std::move(apps))); } } // namespace @@ -48,9 +50,9 @@ TEST(BackgroundShellTest, MAYBE_Basic) { base::MessageLoop message_loop; BackgroundShell background_shell; - scoped_ptr<BackgroundShell::InitParams> init_params( + std::unique_ptr<BackgroundShell::InitParams> init_params( new BackgroundShell::InitParams); - scoped_ptr<TestCatalogStore> store_ptr = BuildTestCatalogStore(); + std::unique_ptr<TestCatalogStore> store_ptr = BuildTestCatalogStore(); TestCatalogStore* store = store_ptr.get(); init_params->catalog_store = std::move(store_ptr); background_shell.Init(std::move(init_params)); @@ -72,4 +74,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/background/tests/test.mojom b/services/shell/background/tests/test.mojom index a021d707..18a92ec 100644 --- a/services/shell/background/tests/test.mojom +++ b/services/shell/background/tests/test.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. -module mojo.shell.mojom; +module shell.mojom; interface TestService { Test() => ();
diff --git a/services/shell/background/tests/test_catalog_store.cc b/services/shell/background/tests/test_catalog_store.cc index 902e3a5..aa2f2795 100644 --- a/services/shell/background/tests/test_catalog_store.cc +++ b/services/shell/background/tests/test_catalog_store.cc
@@ -6,10 +6,9 @@ using catalog::Store; -namespace mojo { namespace shell { -TestCatalogStore::TestCatalogStore(scoped_ptr<base::ListValue> store) +TestCatalogStore::TestCatalogStore(std::unique_ptr<base::ListValue> store) : store_(std::move(store)) {} TestCatalogStore::~TestCatalogStore() {} @@ -19,23 +18,23 @@ return store_.get(); } -void TestCatalogStore::UpdateStore( - scoped_ptr<base::ListValue> store) {} +void TestCatalogStore::UpdateStore(std::unique_ptr<base::ListValue> store) {} -scoped_ptr<base::DictionaryValue> BuildPermissiveSerializedAppInfo( +std::unique_ptr<base::DictionaryValue> BuildPermissiveSerializedAppInfo( const std::string& name, const std::string& display_name) { - scoped_ptr<base::DictionaryValue> app(new base::DictionaryValue); + std::unique_ptr<base::DictionaryValue> app(new base::DictionaryValue); app->SetString(Store::kNameKey, name); app->SetString(Store::kDisplayNameKey, display_name); app->SetInteger(Store::kManifestVersionKey, 1); - scoped_ptr<base::DictionaryValue> capabilities(new base::DictionaryValue); - scoped_ptr<base::DictionaryValue> required_capabilities( + std::unique_ptr<base::DictionaryValue> capabilities( new base::DictionaryValue); - scoped_ptr<base::DictionaryValue> interfaces_dictionary( + std::unique_ptr<base::DictionaryValue> required_capabilities( new base::DictionaryValue); - scoped_ptr<base::ListValue> interfaces_list(new base::ListValue); + std::unique_ptr<base::DictionaryValue> interfaces_dictionary( + new base::DictionaryValue); + std::unique_ptr<base::ListValue> interfaces_list(new base::ListValue); interfaces_list->AppendString("*"); interfaces_dictionary->Set("interfaces", std::move(interfaces_list)); required_capabilities->Set("*", std::move(interfaces_dictionary)); @@ -46,4 +45,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/background/tests/test_catalog_store.h b/services/shell/background/tests/test_catalog_store.h index 763fdc4e..612075f6 100644 --- a/services/shell/background/tests/test_catalog_store.h +++ b/services/shell/background/tests/test_catalog_store.h
@@ -5,42 +5,40 @@ #ifndef SERVICES_SHELL_BACKGROUND_TESTS_TEST_CATALOG_STORE_H_ #define SERVICES_SHELL_BACKGROUND_TESTS_TEST_CATALOG_STORE_H_ +#include <memory> #include <string> -#include "base/memory/scoped_ptr.h" #include "base/values.h" #include "services/catalog/store.h" -namespace mojo { namespace shell { // ApplicationCatalogStore implementation that takes the ListValue to return // as store. class TestCatalogStore : public catalog::Store { public: - explicit TestCatalogStore(scoped_ptr<base::ListValue> store); + explicit TestCatalogStore(std::unique_ptr<base::ListValue> store); ~TestCatalogStore() override; bool get_store_called() const { return get_store_called_; } // ApplicationCatalogStore: const base::ListValue* GetStore() override; - void UpdateStore(scoped_ptr<base::ListValue> store) override; + void UpdateStore(std::unique_ptr<base::ListValue> store) override; private: bool get_store_called_ = false; - scoped_ptr<base::ListValue> store_; + std::unique_ptr<base::ListValue> store_; DISALLOW_COPY_AND_ASSIGN(TestCatalogStore); }; // Returns a dictionary for an app with the specified name, display name and a // permissive filter. -scoped_ptr<base::DictionaryValue> BuildPermissiveSerializedAppInfo( +std::unique_ptr<base::DictionaryValue> BuildPermissiveSerializedAppInfo( const std::string& name, const std::string& display_name); } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_BACKGROUND_TESTS_TEST_CATALOG_STORE_H_
diff --git a/services/shell/background/tests/test_service.cc b/services/shell/background/tests/test_service.cc index d6c042b..97499339 100644 --- a/services/shell/background/tests/test_service.cc +++ b/services/shell/background/tests/test_service.cc
@@ -9,7 +9,6 @@ #include "services/shell/public/cpp/connection.h" #include "services/shell/public/cpp/shell_client.h" -namespace mojo { namespace shell { class TestClient : public ShellClient, @@ -31,7 +30,7 @@ // InterfaceFactory<mojom::TestService>: void Create(Connection* connection, - InterfaceRequest<mojom::TestService> request) override { + mojo::InterfaceRequest<mojom::TestService> request) override { bindings_.AddBinding(this, std::move(request)); } @@ -40,15 +39,14 @@ callback.Run(); } - BindingSet<mojom::TestService> bindings_; + mojo::BindingSet<mojom::TestService> bindings_; DISALLOW_COPY_AND_ASSIGN(TestClient); }; } // namespace shell -} // namespace mojo MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner(new mojo::shell::TestClient); + shell::ApplicationRunner runner(new shell::TestClient); return runner.Run(shell_handle); }
diff --git a/services/shell/connect_params.cc b/services/shell/connect_params.cc index 6e9d82f..d59ba1f 100644 --- a/services/shell/connect_params.cc +++ b/services/shell/connect_params.cc
@@ -4,11 +4,9 @@ #include "services/shell/connect_params.h" -namespace mojo { namespace shell { ConnectParams::ConnectParams() {} ConnectParams::~ConnectParams() {} } // namespace shell -} // namespace mojo \ No newline at end of file
diff --git a/services/shell/connect_params.h b/services/shell/connect_params.h index 9b9d175..7bd2ad5 100644 --- a/services/shell/connect_params.h +++ b/services/shell/connect_params.h
@@ -10,12 +10,10 @@ #include "base/callback.h" #include "base/macros.h" -#include "mojo/public/cpp/bindings/interface_request.h" #include "services/shell/public/cpp/identity.h" #include "services/shell/public/interfaces/connector.mojom.h" #include "services/shell/public/interfaces/interface_provider.mojom.h" -namespace mojo { namespace shell { // This class represents a request for the application manager to connect to an @@ -30,33 +28,32 @@ void set_target(const Identity& target) { target_ = target; } const Identity& target() const { return target_; } - void set_remote_interfaces(shell::mojom::InterfaceProviderRequest value) { + void set_remote_interfaces(mojom::InterfaceProviderRequest value) { remote_interfaces_ = std::move(value); } - shell::mojom::InterfaceProviderRequest TakeRemoteInterfaces() { + mojom::InterfaceProviderRequest TakeRemoteInterfaces() { return std::move(remote_interfaces_); } - void set_local_interfaces(shell::mojom::InterfaceProviderPtr value) { + void set_local_interfaces(mojom::InterfaceProviderPtr value) { local_interfaces_ = std::move(value); } - shell::mojom::InterfaceProviderPtr TakeLocalInterfaces() { + mojom::InterfaceProviderPtr TakeLocalInterfaces() { return std::move(local_interfaces_); } void set_client_process_connection( - shell::mojom::ClientProcessConnectionPtr client_process_connection) { + mojom::ClientProcessConnectionPtr client_process_connection) { client_process_connection_ = std::move(client_process_connection); } - shell::mojom::ClientProcessConnectionPtr TakeClientProcessConnection() { + mojom::ClientProcessConnectionPtr TakeClientProcessConnection() { return std::move(client_process_connection_); } - void set_connect_callback( - const shell::mojom::Connector::ConnectCallback& value) { + void set_connect_callback(const mojom::Connector::ConnectCallback& value) { connect_callback_ = value; } - const shell::mojom::Connector::ConnectCallback& connect_callback() const { + const mojom::Connector::ConnectCallback& connect_callback() const { return connect_callback_; } @@ -67,15 +64,14 @@ // The identity of the application being connected to. Identity target_; - shell::mojom::InterfaceProviderRequest remote_interfaces_; - shell::mojom::InterfaceProviderPtr local_interfaces_; - shell::mojom::ClientProcessConnectionPtr client_process_connection_; - shell::mojom::Connector::ConnectCallback connect_callback_; + mojom::InterfaceProviderRequest remote_interfaces_; + mojom::InterfaceProviderPtr local_interfaces_; + mojom::ClientProcessConnectionPtr client_process_connection_; + mojom::Connector::ConnectCallback connect_callback_; DISALLOW_COPY_AND_ASSIGN(ConnectParams); }; } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_CONNECT_PARAMS_H_
diff --git a/services/shell/connect_util.cc b/services/shell/connect_util.cc index cf477ac..45b468e 100644 --- a/services/shell/connect_util.cc +++ b/services/shell/connect_util.cc
@@ -4,29 +4,28 @@ #include "services/shell/connect_util.h" +#include <memory> #include <utility> #include "services/shell/connect_params.h" #include "services/shell/shell.h" -namespace mojo { namespace shell { -ScopedMessagePipeHandle ConnectToInterfaceByName( +mojo::ScopedMessagePipeHandle ConnectToInterfaceByName( Shell* shell, const Identity& source, const Identity& target, const std::string& interface_name) { - shell::mojom::InterfaceProviderPtr remote_interfaces; - scoped_ptr<ConnectParams> params(new ConnectParams); + mojom::InterfaceProviderPtr remote_interfaces; + std::unique_ptr<ConnectParams> params(new ConnectParams); params->set_source(source); params->set_target(target); - params->set_remote_interfaces(GetProxy(&remote_interfaces)); + params->set_remote_interfaces(mojo::GetProxy(&remote_interfaces)); shell->Connect(std::move(params)); - MessagePipe pipe; + mojo::MessagePipe pipe; remote_interfaces->GetInterface(interface_name, std::move(pipe.handle1)); return std::move(pipe.handle0); } } // namespace shell -} // namespace mojo
diff --git a/services/shell/connect_util.h b/services/shell/connect_util.h index 2d4f938..d560225 100644 --- a/services/shell/connect_util.h +++ b/services/shell/connect_util.h
@@ -10,12 +10,11 @@ #include "services/shell/public/cpp/identity.h" #include "services/shell/public/interfaces/connector.mojom.h" -namespace mojo { namespace shell { class Shell; -ScopedMessagePipeHandle ConnectToInterfaceByName( +mojo::ScopedMessagePipeHandle ConnectToInterfaceByName( Shell* shell, const Identity& source, const Identity& target, @@ -27,24 +26,22 @@ inline void ConnectToInterface(Shell* shell, const Identity& source, const Identity& target, - InterfacePtr<Interface>* ptr) { - ScopedMessagePipeHandle service_handle = + mojo::InterfacePtr<Interface>* ptr) { + mojo::ScopedMessagePipeHandle service_handle = ConnectToInterfaceByName(shell, source, target, Interface::Name_); - ptr->Bind(InterfacePtrInfo<Interface>(std::move(service_handle), 0u)); + ptr->Bind(mojo::InterfacePtrInfo<Interface>(std::move(service_handle), 0u)); } template <typename Interface> inline void ConnectToInterface(Shell* shell, const Identity& source, const std::string& name, - InterfacePtr<Interface>* ptr) { - ScopedMessagePipeHandle service_handle = ConnectToInterfaceByName( - shell, source, Identity(name, mojom::kInheritUserID), - Interface::Name_); - ptr->Bind(InterfacePtrInfo<Interface>(std::move(service_handle), 0u)); + mojo::InterfacePtr<Interface>* ptr) { + mojo::ScopedMessagePipeHandle service_handle = ConnectToInterfaceByName( + shell, source, Identity(name, mojom::kInheritUserID), Interface::Name_); + ptr->Bind(mojo::InterfacePtrInfo<Interface>(std::move(service_handle), 0u)); } } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_CONNECT_UTIL_H_
diff --git a/services/shell/loader.h b/services/shell/loader.h index deaf8e9..c99b628 100644 --- a/services/shell/loader.h +++ b/services/shell/loader.h
@@ -10,7 +10,6 @@ #include "services/shell/public/interfaces/connector.mojom.h" #include "services/shell/public/interfaces/shell_client.mojom.h" -namespace mojo { namespace shell { // Interface to implement special loading behavior for a particular name. @@ -23,6 +22,5 @@ }; } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_LOADER_H_
diff --git a/services/shell/native_runner.h b/services/shell/native_runner.h index 58d5fa81..c81d2ad 100644 --- a/services/shell/native_runner.h +++ b/services/shell/native_runner.h
@@ -5,8 +5,9 @@ #ifndef SERVICES_SHELL_NATIVE_RUNNER_H_ #define SERVICES_SHELL_NATIVE_RUNNER_H_ +#include <memory> + #include "base/callback_forward.h" -#include "base/memory/scoped_ptr.h" #include "base/process/process_handle.h" #include "mojo/public/cpp/bindings/interface_request.h" #include "services/shell/public/interfaces/shell_client.mojom.h" @@ -15,10 +16,8 @@ class FilePath; } -namespace mojo { -class Identity; namespace shell { - +class Identity; // Shell requires implementations of NativeRunner and NativeRunnerFactory to run // native applications. @@ -40,10 +39,10 @@ class NativeRunnerFactory { public: virtual ~NativeRunnerFactory() {} - virtual scoped_ptr<NativeRunner> Create(const base::FilePath& app_path) = 0; + virtual std::unique_ptr<NativeRunner> Create( + const base::FilePath& app_path) = 0; }; } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_NATIVE_RUNNER_H_
diff --git a/services/shell/native_runner_delegate.h b/services/shell/native_runner_delegate.h index d879c3e..8c22d5a 100644 --- a/services/shell/native_runner_delegate.h +++ b/services/shell/native_runner_delegate.h
@@ -9,9 +9,8 @@ class CommandLine; } -namespace mojo { -class Identity; namespace shell { +class Identity; class NativeRunnerDelegate { public: @@ -26,6 +25,5 @@ }; } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_NATIVE_RUNNER_DELEGATE_H_
diff --git a/services/shell/public/cpp/BUILD.gn b/services/shell/public/cpp/BUILD.gn index 73159806..5bb2bc19 100644 --- a/services/shell/public/cpp/BUILD.gn +++ b/services/shell/public/cpp/BUILD.gn
@@ -46,7 +46,6 @@ "lib/shell_connection.cc", "message_loop_ref.h", "names.h", - "shell.h", "shell_client.h", "shell_connection.h", ]
diff --git a/services/shell/public/cpp/application_runner.h b/services/shell/public/cpp/application_runner.h index 71749d8..36d79e3 100644 --- a/services/shell/public/cpp/application_runner.h +++ b/services/shell/public/cpp/application_runner.h
@@ -5,11 +5,12 @@ #ifndef SERVICES_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_H_ #define SERVICES_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_H_ -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "base/message_loop/message_loop.h" #include "mojo/public/cpp/system/core.h" -namespace mojo { +namespace shell { class ShellClient; class ShellConnection; @@ -18,7 +19,7 @@ // case is to use when writing your MojoMain: // // MojoResult MojoMain(MojoHandle shell_handle) { -// mojo::ApplicationRunner runner(new MyDelegate()); +// shell::ApplicationRunner runner(new MyDelegate()); // return runner.Run(shell_handle); // } // @@ -58,8 +59,8 @@ void Quit(); private: - scoped_ptr<ShellConnection> connection_; - scoped_ptr<ShellClient> client_; + std::unique_ptr<ShellConnection> connection_; + std::unique_ptr<ShellClient> client_; // MessageLoop type. TYPE_CUSTOM is default (MessagePumpMojo will be used as // the underlying message pump). @@ -70,6 +71,6 @@ DISALLOW_COPY_AND_ASSIGN(ApplicationRunner); }; -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_H_
diff --git a/services/shell/public/cpp/application_test_base.h b/services/shell/public/cpp/application_test_base.h index 232457ac..dc25e9f 100644 --- a/services/shell/public/cpp/application_test_base.h +++ b/services/shell/public/cpp/application_test_base.h
@@ -5,8 +5,9 @@ #ifndef SERVICES_SHELL_PUBLIC_CPP_APPLICATION_TEST_BASE_H_ #define SERVICES_SHELL_PUBLIC_CPP_APPLICATION_TEST_BASE_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "mojo/public/cpp/bindings/array.h" #include "mojo/public/cpp/bindings/string.h" #include "services/shell/public/cpp/connector.h" @@ -15,7 +16,7 @@ #include "services/shell/public/interfaces/shell_client.mojom.h" #include "testing/gtest/include/gtest/gtest.h" -namespace mojo { +namespace shell { class ShellConnection; @@ -43,7 +44,7 @@ ShellClient default_shell_client_; // The application implementation instance, reconstructed for each test. - scoped_ptr<ShellConnection> shell_connection_; + std::unique_ptr<ShellConnection> shell_connection_; std::string name_; std::string userid_; @@ -69,8 +70,8 @@ return test_helper_ ? test_helper_->test_userid() : inherit_user_id_; } uint32_t test_instance_id() const { - return test_helper_ ? test_helper_->test_instance_id() : - shell::mojom::kInvalidInstanceID; + return test_helper_ ? test_helper_->test_instance_id() + : mojom::kInvalidInstanceID; } // Get the ShellClient for the application to be tested. @@ -86,15 +87,15 @@ virtual bool ShouldCreateDefaultRunLoop(); private: - scoped_ptr<TestHelper> test_helper_; + std::unique_ptr<TestHelper> test_helper_; std::string empty_; - std::string inherit_user_id_ = shell::mojom::kInheritUserID; + std::string inherit_user_id_ = mojom::kInheritUserID; DISALLOW_COPY_AND_ASSIGN(ApplicationTestBase); }; } // namespace test -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_APPLICATION_TEST_BASE_H_
diff --git a/services/shell/public/cpp/capabilities.h b/services/shell/public/cpp/capabilities.h index 46ece61..53eaf7d2 100644 --- a/services/shell/public/cpp/capabilities.h +++ b/services/shell/public/cpp/capabilities.h
@@ -11,7 +11,8 @@ #include "services/shell/public/interfaces/shell_resolver.mojom.h" -namespace mojo { +namespace shell { + using Class = std::string; using Classes = std::set<std::string>; using Interface = std::string; @@ -41,29 +42,36 @@ std::map<Name, CapabilityRequest> required; }; +} // namespace shell + +namespace mojo { + template <> -struct TypeConverter<shell::mojom::CapabilitySpecPtr, CapabilitySpec> { +struct TypeConverter<shell::mojom::CapabilitySpecPtr, shell::CapabilitySpec> { static shell::mojom::CapabilitySpecPtr Convert( - const CapabilitySpec& input); + const shell::CapabilitySpec& input); }; + template <> -struct TypeConverter<CapabilitySpec, shell::mojom::CapabilitySpecPtr> { - static CapabilitySpec Convert( +struct TypeConverter<shell::CapabilitySpec, shell::mojom::CapabilitySpecPtr> { + static shell::CapabilitySpec Convert( const shell::mojom::CapabilitySpecPtr& input); }; template <> struct TypeConverter<shell::mojom::CapabilityRequestPtr, - CapabilityRequest> { + shell::CapabilityRequest> { static shell::mojom::CapabilityRequestPtr Convert( - const CapabilityRequest& input); + const shell::CapabilityRequest& input); }; + template <> -struct TypeConverter<CapabilityRequest, +struct TypeConverter<shell::CapabilityRequest, shell::mojom::CapabilityRequestPtr> { - static CapabilityRequest Convert( + static shell::CapabilityRequest Convert( const shell::mojom::CapabilityRequestPtr& input); }; + } // namespace mojo #endif // SERVICES_SHELL_PUBLIC_CPP_CAPABILITIES_H_
diff --git a/services/shell/public/cpp/connect.h b/services/shell/public/cpp/connect.h index 4ca4dfc..ecce18b9 100644 --- a/services/shell/public/cpp/connect.h +++ b/services/shell/public/cpp/connect.h
@@ -9,17 +9,17 @@ #include "services/shell/public/interfaces/interface_provider.mojom.h" -namespace mojo { +namespace shell { // Binds |ptr| to a remote implementation of Interface from |interfaces|. template <typename Interface> -inline void GetInterface(shell::mojom::InterfaceProvider* interfaces, - InterfacePtr<Interface>* ptr) { - MessagePipe pipe; - ptr->Bind(InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u)); +inline void GetInterface(mojom::InterfaceProvider* interfaces, + mojo::InterfacePtr<Interface>* ptr) { + mojo::MessagePipe pipe; + ptr->Bind(mojo::InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u)); interfaces->GetInterface(Interface::Name_, std::move(pipe.handle1)); } -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_CONNECT_H_
diff --git a/services/shell/public/cpp/connection.h b/services/shell/public/cpp/connection.h index 59ba9dbd..989af54 100644 --- a/services/shell/public/cpp/connection.h +++ b/services/shell/public/cpp/connection.h
@@ -17,7 +17,7 @@ #include "services/shell/public/interfaces/connector.mojom.h" #include "services/shell/public/interfaces/interface_provider.mojom.h" -namespace mojo { +namespace shell { class InterfaceBinder; @@ -46,7 +46,7 @@ PENDING, // The shell processed the connection and it was established. GetResult() - // returns mojom::shell::ConnectionResult::SUCCESS. + // returns mojom::ConnectionResult::SUCCESS. CONNECTED, // The shell processed the connection and establishment was prevented by @@ -78,8 +78,8 @@ // |ptr| can immediately be used to start sending requests to the remote // interface. template <typename Interface> - void GetInterface(InterfacePtr<Interface>* ptr) { - mojo::GetInterface(GetRemoteInterfaces(), ptr); + void GetInterface(mojo::InterfacePtr<Interface>* ptr) { + shell::GetInterface(GetRemoteInterfaces(), ptr); } // Returns true if the remote application has the specified capability class @@ -103,20 +103,20 @@ // Register a handler to receive an error notification on the pipe to the // remote application's InterfaceProvider. - virtual void SetConnectionLostClosure(const Closure& handler) = 0; + virtual void SetConnectionLostClosure(const mojo::Closure& handler) = 0; // Returns the result of the connection. This function should only be called // when the connection state is not pending. Call // AddConnectionCompletedClosure() to schedule a closure to be run when the // connection is processed by the shell. - virtual shell::mojom::ConnectResult GetResult() const = 0; + virtual mojom::ConnectResult GetResult() const = 0; // Returns true if the connection has not yet been processed by the shell. virtual bool IsPending() const = 0; // Returns the instance id of the remote application if it is known at the // time this function is called. When IsPending() returns true, this function - // will return shell::mojom::kInvalidInstanceID. Use + // will return mojom::kInvalidInstanceID. Use // AddConnectionCompletedClosure() to schedule a closure to be run when the // connection is processed by the shell and remote id is available. virtual uint32_t GetRemoteInstanceID() const = 0; @@ -125,7 +125,7 @@ // shell and remote metadata is available. Useful only for connections created // via Connector::Connect(). Once the connection is complete, metadata is // available immediately. - virtual void AddConnectionCompletedClosure(const Closure& callback) = 0; + virtual void AddConnectionCompletedClosure(const mojo::Closure& callback) = 0; // Returns true if the Shell allows |interface_name| to be exposed to the // remote application. @@ -134,7 +134,7 @@ // Returns the raw proxy to the remote application's InterfaceProvider // interface. Most applications will just use GetInterface() instead. // Caller does not take ownership. - virtual shell::mojom::InterfaceProvider* GetRemoteInterfaces() = 0; + virtual mojom::InterfaceProvider* GetRemoteInterfaces() = 0; protected: virtual InterfaceRegistry* GetLocalRegistry() = 0; @@ -142,6 +142,6 @@ virtual base::WeakPtr<Connection> GetWeakPtr() = 0; }; -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_CONNECTION_H_
diff --git a/services/shell/public/cpp/connector.h b/services/shell/public/cpp/connector.h index 8ffd433..6e40590 100644 --- a/services/shell/public/cpp/connector.h +++ b/services/shell/public/cpp/connector.h
@@ -5,13 +5,15 @@ #ifndef SERVICES_SHELL_PUBLIC_CPP_CONNECTOR_H_ #define SERVICES_SHELL_PUBLIC_CPP_CONNECTOR_H_ +#include <memory> + #include "services/shell/public/cpp/connection.h" #include "services/shell/public/cpp/identity.h" #include "services/shell/public/interfaces/connector.mojom.h" #include "services/shell/public/interfaces/shell.mojom.h" #include "services/shell/public/interfaces/shell_client.mojom.h" -namespace mojo { +namespace shell { // An interface that encapsulates the Mojo Shell's broker interface by which // connections between applications are established. Once Connect() is called, @@ -40,22 +42,22 @@ const Identity& target() { return target_; } void set_target(const Identity& target) { target_ = target; } void set_client_process_connection( - shell::mojom::ShellClientPtr shell_client, - shell::mojom::PIDReceiverRequest pid_receiver_request) { + mojom::ShellClientPtr shell_client, + mojom::PIDReceiverRequest pid_receiver_request) { shell_client_ = std::move(shell_client); pid_receiver_request_ = std::move(pid_receiver_request); } void TakeClientProcessConnection( - shell::mojom::ShellClientPtr* shell_client, - shell::mojom::PIDReceiverRequest* pid_receiver_request) { + mojom::ShellClientPtr* shell_client, + mojom::PIDReceiverRequest* pid_receiver_request) { *shell_client = std::move(shell_client_); *pid_receiver_request = std::move(pid_receiver_request_); } private: Identity target_; - shell::mojom::ShellClientPtr shell_client_; - shell::mojom::PIDReceiverRequest pid_receiver_request_; + mojom::ShellClientPtr shell_client_; + mojom::PIDReceiverRequest pid_receiver_request_; DISALLOW_COPY_AND_ASSIGN(ConnectParams); }; @@ -66,26 +68,27 @@ // Once this method is called, this object is bound to the thread on which the // call took place. To pass to another thread, call Clone() and pass the // result. - virtual scoped_ptr<Connection> Connect(const std::string& name) = 0; - virtual scoped_ptr<Connection> Connect(ConnectParams* params) = 0; + virtual std::unique_ptr<Connection> Connect(const std::string& name) = 0; + virtual std::unique_ptr<Connection> Connect(ConnectParams* params) = 0; // Connect to application identified by |request->name| and connect to the // service implementation of the interface identified by |Interface|. template <typename Interface> - void ConnectToInterface(ConnectParams* params, InterfacePtr<Interface>* ptr) { - scoped_ptr<Connection> connection = Connect(params); + void ConnectToInterface(ConnectParams* params, + mojo::InterfacePtr<Interface>* ptr) { + std::unique_ptr<Connection> connection = Connect(params); if (connection) connection->GetInterface(ptr); } template <typename Interface> void ConnectToInterface(const Identity& target, - InterfacePtr<Interface>* ptr) { + mojo::InterfacePtr<Interface>* ptr) { ConnectParams params(target); return ConnectToInterface(¶ms, ptr); } template <typename Interface> void ConnectToInterface(const std::string& name, - InterfacePtr<Interface>* ptr) { + mojo::InterfacePtr<Interface>* ptr) { ConnectParams params(name); return ConnectToInterface(¶ms, ptr); } @@ -93,9 +96,9 @@ // Creates a new instance of this class which may be passed to another thread. // The returned object may be passed multiple times until Connect() is called, // at which point this method must be called again to pass again. - virtual scoped_ptr<Connector> Clone() = 0; + virtual std::unique_ptr<Connector> Clone() = 0; }; -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_CONNECTOR_H_
diff --git a/services/shell/public/cpp/identity.h b/services/shell/public/cpp/identity.h index 01d0913c..3c2cb0b 100644 --- a/services/shell/public/cpp/identity.h +++ b/services/shell/public/cpp/identity.h
@@ -9,7 +9,7 @@ #include "services/shell/public/interfaces/connector.mojom.h" -namespace mojo { +namespace shell { // Represents the identity of an application. // |name| is the structured name of the application. @@ -41,13 +41,18 @@ std::string instance_; }; +} // namespace shell + +namespace mojo { + template <> -struct TypeConverter<shell::mojom::IdentityPtr, Identity> { - static shell::mojom::IdentityPtr Convert(const Identity& input); +struct TypeConverter<shell::mojom::IdentityPtr, shell::Identity> { + static shell::mojom::IdentityPtr Convert(const shell::Identity& input); }; + template <> -struct TypeConverter<Identity, shell::mojom::IdentityPtr> { - static Identity Convert(const shell::mojom::IdentityPtr& input); +struct TypeConverter<shell::Identity, shell::mojom::IdentityPtr> { + static shell::Identity Convert(const shell::mojom::IdentityPtr& input); }; } // namespace mojo
diff --git a/services/shell/public/cpp/initialize_base_and_icu.cc b/services/shell/public/cpp/initialize_base_and_icu.cc index 9eb49fa..4277f4f 100644 --- a/services/shell/public/cpp/initialize_base_and_icu.cc +++ b/services/shell/public/cpp/initialize_base_and_icu.cc
@@ -9,9 +9,10 @@ #include <stdint.h> +#include <memory> + #include "base/files/file.h" #include "base/i18n/icu_util.h" -#include "base/memory/scoped_ptr.h" #include "base/rand_util.h" #include "base/sys_info.h" #include "mojo/public/c/system/types.h" @@ -45,7 +46,7 @@ // Olson timezone ID by accessing the zoneinfo files on disk. After // TimeZone::createDefault is called once here, the timezone ID is // cached and there's no more need to access the file system. - scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); + std::unique_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); #endif } }
diff --git a/services/shell/public/cpp/interface_binder.h b/services/shell/public/cpp/interface_binder.h index 98ad8956..9dec4ad 100644 --- a/services/shell/public/cpp/interface_binder.h +++ b/services/shell/public/cpp/interface_binder.h
@@ -9,7 +9,7 @@ #include "mojo/public/cpp/system/message_pipe.h" -namespace mojo { +namespace shell { class Connection; @@ -22,9 +22,9 @@ // an implementation it must take ownership of the request handle. virtual void BindInterface(Connection* connection, const std::string& interface_name, - ScopedMessagePipeHandle handle) = 0; + mojo::ScopedMessagePipeHandle handle) = 0; }; -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_INTERFACE_BINDER_H_
diff --git a/services/shell/public/cpp/interface_factory.h b/services/shell/public/cpp/interface_factory.h index 60285b6..165645d 100644 --- a/services/shell/public/cpp/interface_factory.h +++ b/services/shell/public/cpp/interface_factory.h
@@ -7,11 +7,9 @@ #include "mojo/public/cpp/bindings/interface_request.h" -namespace mojo { +namespace shell { class Connection; -template <typename Interface> -class InterfaceRequest; // Implement this class to provide implementations of a given interface and // bind them to incoming requests. The implementation of this class is @@ -22,9 +20,9 @@ public: virtual ~InterfaceFactory() {} virtual void Create(Connection* connection, - InterfaceRequest<Interface> request) = 0; + mojo::InterfaceRequest<Interface> request) = 0; }; -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_INTERFACE_FACTORY_H_
diff --git a/services/shell/public/cpp/interface_factory_impl.h b/services/shell/public/cpp/interface_factory_impl.h index 88fa2a2..7510a08 100644 --- a/services/shell/public/cpp/interface_factory_impl.h +++ b/services/shell/public/cpp/interface_factory_impl.h
@@ -7,7 +7,7 @@ #include "services/shell/public/cpp/interface_factory.h" -namespace mojo { +namespace shell { // Use this class to allocate and bind instances of Impl to interface requests. // The lifetime of the constructed Impl is bound to the pipe. @@ -18,7 +18,7 @@ virtual ~InterfaceFactoryImpl() {} virtual void Create(Connection* connection, - InterfaceRequest<Interface> request) override { + mojo::InterfaceRequest<Interface> request) override { BindToRequest(new Impl(), &request); } }; @@ -36,7 +36,7 @@ virtual ~InterfaceFactoryImplWithContext() {} virtual void Create(Connection* connection, - InterfaceRequest<Interface> request) override { + mojo::InterfaceRequest<Interface> request) override { BindToRequest(new Impl(context_), &request); } @@ -44,6 +44,6 @@ Context* context_; }; -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_INTERFACE_FACTORY_IMPL_H_
diff --git a/services/shell/public/cpp/interface_registry.h b/services/shell/public/cpp/interface_registry.h index c2e9a65f..d869310b 100644 --- a/services/shell/public/cpp/interface_registry.h +++ b/services/shell/public/cpp/interface_registry.h
@@ -9,11 +9,10 @@ #include "services/shell/public/cpp/lib/interface_factory_binder.h" #include "services/shell/public/interfaces/interface_provider.mojom.h" -namespace mojo { - +namespace shell { class InterfaceBinder; -// An implementation of shell::mojom::InterfaceProvider that allows the user to +// An implementation of mojom::InterfaceProvider that allows the user to // register services to be exposed to another application. // // To use, define a class that implements your specific interface. Then @@ -35,7 +34,7 @@ // InterfaceFactory, the default InterfaceBinder supplied must outlive // InterfaceRegistry. // -class InterfaceRegistry : public shell::mojom::InterfaceProvider { +class InterfaceRegistry : public mojom::InterfaceProvider { public: class TestApi { public: @@ -46,6 +45,7 @@ const std::string& interface_name) { registry_->SetInterfaceBinderForName(binder, interface_name); } + void RemoveInterfaceBinderForName(const std::string& interface_name) { registry_->RemoveInterfaceBinderForName(interface_name); } @@ -63,13 +63,13 @@ explicit InterfaceRegistry(Connection* connection); // Construct with an InterfaceProviderRequest and a Connection (which may be // null, see note above about filtering). - InterfaceRegistry(shell::mojom::InterfaceProviderRequest request, + InterfaceRegistry(mojom::InterfaceProviderRequest request, Connection* connection); ~InterfaceRegistry() override; // Takes the client end of the InterfaceProvider pipe created in the // constructor. - shell::mojom::InterfaceProviderPtr TakeClientHandle(); + mojom::InterfaceProviderPtr TakeClientHandle(); template <typename Interface> bool AddInterface(InterfaceFactory<Interface>* factory) { @@ -83,9 +83,9 @@ private: using NameToInterfaceBinderMap = std::map<std::string, InterfaceBinder*>; - // shell::mojom::InterfaceProvider: - void GetInterface(const String& interface_name, - ScopedMessagePipeHandle handle) override; + // mojom::InterfaceProvider: + void GetInterface(const mojo::String& interface_name, + mojo::ScopedMessagePipeHandle handle) override; // Returns true if the binder was set, false if it was not set (e.g. by // some filtering policy preventing this interface from being exposed). @@ -94,8 +94,8 @@ void RemoveInterfaceBinderForName(const std::string& interface_name); - shell::mojom::InterfaceProviderPtr client_handle_; - Binding<shell::mojom::InterfaceProvider> binding_; + mojom::InterfaceProviderPtr client_handle_; + mojo::Binding<mojom::InterfaceProvider> binding_; Connection* connection_; InterfaceBinder* default_binder_; @@ -104,6 +104,6 @@ DISALLOW_COPY_AND_ASSIGN(InterfaceRegistry); }; -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_INTERFACE_REGISTRY_H_
diff --git a/services/shell/public/cpp/lib/application_runner.cc b/services/shell/public/cpp/lib/application_runner.cc index dd7a614..9f158088 100644 --- a/services/shell/public/cpp/lib/application_runner.cc +++ b/services/shell/public/cpp/lib/application_runner.cc
@@ -7,20 +7,19 @@ #include "base/at_exit.h" #include "base/bind.h" #include "base/command_line.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/process/launch.h" #include "base/run_loop.h" #include "services/shell/public/cpp/shell_client.h" #include "services/shell/public/cpp/shell_connection.h" -namespace mojo { +namespace shell { int g_application_runner_argc; const char* const* g_application_runner_argv; ApplicationRunner::ApplicationRunner(ShellClient* client) - : client_(scoped_ptr<ShellClient>(client)), + : client_(std::unique_ptr<ShellClient>(client)), message_loop_type_(base::MessageLoop::TYPE_DEFAULT), has_run_(false) {} @@ -42,20 +41,20 @@ DCHECK(!has_run_); has_run_ = true; - scoped_ptr<base::AtExitManager> at_exit; + std::unique_ptr<base::AtExitManager> at_exit; if (init_base) { InitBaseCommandLine(); at_exit.reset(new base::AtExitManager); } { - scoped_ptr<base::MessageLoop> loop; + std::unique_ptr<base::MessageLoop> loop; loop.reset(new base::MessageLoop(message_loop_type_)); connection_.reset(new ShellConnection( client_.get(), - MakeRequest<shell::mojom::ShellClient>(MakeScopedHandle( - MessagePipeHandle(shell_client_request_handle))))); + mojo::MakeRequest<mojom::ShellClient>(mojo::MakeScopedHandle( + mojo::MessagePipeHandle(shell_client_request_handle))))); base::RunLoop run_loop; connection_->set_connection_lost_closure(run_loop.QuitClosure()); run_loop.Run(); @@ -89,4 +88,4 @@ base::MessageLoop::current()->QuitWhenIdle(); } -} // namespace mojo +} // namespace shell
diff --git a/services/shell/public/cpp/lib/application_test_base.cc b/services/shell/public/cpp/lib/application_test_base.cc index 956adb8..79bc74e 100644 --- a/services/shell/public/cpp/lib/application_test_base.cc +++ b/services/shell/public/cpp/lib/application_test_base.cc
@@ -15,27 +15,27 @@ #include "services/shell/public/cpp/shell_connection.h" #include "services/shell/public/interfaces/shell_client.mojom.h" -namespace mojo { +namespace shell { namespace test { namespace { // Share the application name with multiple application tests. -shell::mojom::IdentityPtr g_identity; -uint32_t g_id = shell::mojom::kInvalidInstanceID; +mojom::IdentityPtr g_identity; +uint32_t g_id = mojom::kInvalidInstanceID; // ShellClient request handle passed from the shell in MojoMain, stored in // between SetUp()/TearDown() so we can (re-)intialize new ShellConnections. -InterfaceRequest<shell::mojom::ShellClient> g_shell_client_request; +mojom::ShellClientRequest g_shell_client_request; // Connector pointer passed in the initial mojo.ShellClient.Initialize() call, // stored in between initial setup and the first test and between SetUp/TearDown // calls so we can (re-)initialize new ShellConnections. -shell::mojom::ConnectorPtr g_connector; +mojom::ConnectorPtr g_connector; -class ShellGrabber : public shell::mojom::ShellClient { +class ShellGrabber : public mojom::ShellClient { public: - explicit ShellGrabber(InterfaceRequest<shell::mojom::ShellClient> request) + explicit ShellGrabber(mojom::ShellClientRequest request) : binding_(this, std::move(request)) { binding_.set_connection_error_handler([] { _exit(1); }); } @@ -46,8 +46,8 @@ } private: - // shell::mojom::ShellClient implementation. - void Initialize(shell::mojom::IdentityPtr identity, + // mojom::ShellClient implementation. + void Initialize(mojom::IdentityPtr identity, uint32_t id, const InitializeCallback& callback) override { callback.Run(GetProxy(&g_connector)); @@ -57,20 +57,19 @@ g_shell_client_request = binding_.Unbind(); } - void AcceptConnection( - shell::mojom::IdentityPtr source, - uint32_t source_id, - shell::mojom::InterfaceProviderRequest local_interfaces, - shell::mojom::InterfaceProviderPtr remote_interfaces, - shell::mojom::CapabilityRequestPtr capability_spec, - const String& name) override { + void AcceptConnection(mojom::IdentityPtr source, + uint32_t source_id, + mojom::InterfaceProviderRequest local_interfaces, + mojom::InterfaceProviderPtr remote_interfaces, + mojom::CapabilityRequestPtr capability_spec, + const mojo::String& name) override { CHECK(false); } - Binding<ShellClient> binding_; + mojo::Binding<ShellClient> binding_; }; -void IgnoreConnectorRequest(shell::mojom::ConnectorRequest) {} +void IgnoreConnectorRequest(mojom::ConnectorRequest) {} } // namespace @@ -81,8 +80,8 @@ // Grab the shell handle. ShellGrabber grabber( - MakeRequest<shell::mojom::ShellClient>(MakeScopedHandle( - MessagePipeHandle(shell_client_request_handle)))); + mojo::MakeRequest<mojom::ShellClient>(mojo::MakeScopedHandle( + mojo::MessagePipeHandle(shell_client_request_handle)))); grabber.WaitForInitialize(); CHECK(g_connector); CHECK(g_shell_client_request.is_pending()); @@ -125,7 +124,7 @@ shell_connection_->SetAppTestConnectorForTesting(std::move(g_connector)); // Fake ShellClient initialization. - shell::mojom::ShellClient* shell_client = shell_connection_.get(); + mojom::ShellClient* shell_client = shell_connection_.get(); shell_client->Initialize(std::move(g_identity), g_id, base::Bind(&IgnoreConnectorRequest)); } @@ -180,4 +179,4 @@ } } // namespace test -} // namespace mojo +} // namespace shell
diff --git a/services/shell/public/cpp/lib/application_test_main.cc b/services/shell/public/cpp/lib/application_test_main.cc index cc5e94d..0e0d44d 100644 --- a/services/shell/public/cpp/lib/application_test_main.cc +++ b/services/shell/public/cpp/lib/application_test_main.cc
@@ -15,9 +15,9 @@ base::AtExitManager at_exit; // Initialize the current process Commandline and test timeouts. - mojo::ApplicationRunner::InitBaseCommandLine(); + shell::ApplicationRunner::InitBaseCommandLine(); mojo::InitLogging(); TestTimeouts::Initialize(); - return mojo::test::RunAllTests(handle); + return shell::test::RunAllTests(handle); }
diff --git a/services/shell/public/cpp/lib/capabilities.cc b/services/shell/public/cpp/lib/capabilities.cc index ab3c6a059..51dcd0d 100644 --- a/services/shell/public/cpp/lib/capabilities.cc +++ b/services/shell/public/cpp/lib/capabilities.cc
@@ -4,7 +4,7 @@ #include "services/shell/public/cpp/capabilities.h" -namespace mojo { +namespace shell { CapabilityRequest::CapabilityRequest() {} CapabilityRequest::CapabilityRequest(const CapabilityRequest& other) = default; @@ -32,10 +32,14 @@ std::tie(other.provided, other.required); } +} // namespace shell + +namespace mojo { + // static shell::mojom::CapabilitySpecPtr -TypeConverter<shell::mojom::CapabilitySpecPtr, CapabilitySpec>::Convert( - const CapabilitySpec& input) { +TypeConverter<shell::mojom::CapabilitySpecPtr, shell::CapabilitySpec>::Convert( + const shell::CapabilitySpec& input) { shell::mojom::CapabilitySpecPtr spec(shell::mojom::CapabilitySpec::New()); spec->provided = mojo::Map<mojo::String, mojo::Array<mojo::String>>::From(input.provided); @@ -46,21 +50,21 @@ } // static -CapabilitySpec -TypeConverter<CapabilitySpec, shell::mojom::CapabilitySpecPtr>::Convert( +shell::CapabilitySpec +TypeConverter<shell::CapabilitySpec, shell::mojom::CapabilitySpecPtr>::Convert( const shell::mojom::CapabilitySpecPtr& input) { - CapabilitySpec spec; - spec.provided = input->provided.To<std::map<Class, Interfaces>>(); + shell::CapabilitySpec spec; + spec.provided = + input->provided.To<std::map<shell::Class, shell::Interfaces>>(); spec.required = - input->required.To<std::map<Name, CapabilityRequest>>(); + input->required.To<std::map<shell::Name, shell::CapabilityRequest>>(); return spec; } // static -shell::mojom::CapabilityRequestPtr -TypeConverter<shell::mojom::CapabilityRequestPtr, - CapabilityRequest>::Convert( - const CapabilityRequest& input) { +shell::mojom::CapabilityRequestPtr TypeConverter< + shell::mojom::CapabilityRequestPtr, + shell::CapabilityRequest>::Convert(const shell::CapabilityRequest& input) { shell::mojom::CapabilityRequestPtr request( shell::mojom::CapabilityRequest::New()); request->classes = mojo::Array<mojo::String>::From(input.classes); @@ -69,11 +73,10 @@ } // static -CapabilityRequest -TypeConverter<CapabilityRequest, - shell::mojom::CapabilityRequestPtr>::Convert( - const shell::mojom::CapabilityRequestPtr& input) { - CapabilityRequest request; +shell::CapabilityRequest +TypeConverter<shell::CapabilityRequest, shell::mojom::CapabilityRequestPtr>:: + Convert(const shell::mojom::CapabilityRequestPtr& input) { + shell::CapabilityRequest request; request.classes = input->classes.To<std::set<std::string>>(); request.interfaces = input->interfaces.To<std::set<std::string>>(); return request;
diff --git a/services/shell/public/cpp/lib/connection_impl.cc b/services/shell/public/cpp/lib/connection_impl.cc index b49cb8d..60fd988 100644 --- a/services/shell/public/cpp/lib/connection_impl.cc +++ b/services/shell/public/cpp/lib/connection_impl.cc
@@ -13,7 +13,7 @@ #include "services/shell/public/cpp/connection.h" #include "services/shell/public/cpp/interface_binder.h" -namespace mojo { +namespace shell { namespace internal { //////////////////////////////////////////////////////////////////////////////// @@ -65,7 +65,7 @@ return remote_; } -void ConnectionImpl::SetConnectionLostClosure(const Closure& handler) { +void ConnectionImpl::SetConnectionLostClosure(const mojo::Closure& handler) { remote_interfaces_.set_connection_error_handler(handler); } @@ -81,7 +81,8 @@ return remote_id_; } -void ConnectionImpl::AddConnectionCompletedClosure(const Closure& callback) { +void ConnectionImpl::AddConnectionCompletedClosure( + const mojo::Closure& callback) { if (IsPending()) connection_completed_callbacks_.push_back(callback); else @@ -118,11 +119,11 @@ State::CONNECTED : State::DISCONNECTED; remote_id_ = target_application_id; remote_.set_user_id(target_user_id); - std::vector<Closure> callbacks; + std::vector<mojo::Closure> callbacks; callbacks.swap(connection_completed_callbacks_); for (auto callback : callbacks) callback.Run(); } } // namespace internal -} // namespace mojo +} // namespace shell
diff --git a/services/shell/public/cpp/lib/connection_impl.h b/services/shell/public/cpp/lib/connection_impl.h index 6bd8927a..246cdb2 100644 --- a/services/shell/public/cpp/lib/connection_impl.h +++ b/services/shell/public/cpp/lib/connection_impl.h
@@ -17,7 +17,7 @@ #include "services/shell/public/interfaces/connector.mojom.h" #include "services/shell/public/interfaces/interface_provider.mojom.h" -namespace mojo { +namespace shell { namespace internal { // A ConnectionImpl represents each half of a connection between two @@ -45,11 +45,11 @@ bool HasCapabilityClass(const std::string& class_name) const override; const std::string& GetConnectionName() override; const Identity& GetRemoteIdentity() const override; - void SetConnectionLostClosure(const Closure& handler) override; + void SetConnectionLostClosure(const mojo::Closure& handler) override; shell::mojom::ConnectResult GetResult() const override; bool IsPending() const override; uint32_t GetRemoteInstanceID() const override; - void AddConnectionCompletedClosure(const Closure& callback) override; + void AddConnectionCompletedClosure(const mojo::Closure& callback) override; bool AllowsInterface(const std::string& interface_name) const override; shell::mojom::InterfaceProvider* GetRemoteInterfaces() override; InterfaceRegistry* GetLocalRegistry() override; @@ -65,7 +65,7 @@ State state_; shell::mojom::ConnectResult result_ = shell::mojom::ConnectResult::SUCCEEDED; - std::vector<Closure> connection_completed_callbacks_; + std::vector<mojo::Closure> connection_completed_callbacks_; InterfaceRegistry local_registry_; shell::mojom::InterfaceProviderPtr remote_interfaces_; @@ -79,6 +79,6 @@ }; } // namespace internal -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_
diff --git a/services/shell/public/cpp/lib/connector_impl.cc b/services/shell/public/cpp/lib/connector_impl.cc index a04348bf..1bd9e689 100644 --- a/services/shell/public/cpp/lib/connector_impl.cc +++ b/services/shell/public/cpp/lib/connector_impl.cc
@@ -4,31 +4,36 @@ #include "services/shell/public/cpp/lib/connector_impl.h" +#include "base/memory/ptr_util.h" #include "services/shell/public/cpp/identity.h" #include "services/shell/public/cpp/lib/connection_impl.h" -namespace mojo { +namespace shell { Connector::ConnectParams::ConnectParams(const Identity& target) : target_(target) {} + Connector::ConnectParams::ConnectParams(const std::string& name) - : target_(name, shell::mojom::kInheritUserID) {} + : target_(name, mojom::kInheritUserID) {} + Connector::ConnectParams::~ConnectParams() {} -ConnectorImpl::ConnectorImpl(shell::mojom::ConnectorPtrInfo unbound_state) +ConnectorImpl::ConnectorImpl(mojom::ConnectorPtrInfo unbound_state) : unbound_state_(std::move(unbound_state)) {} -ConnectorImpl::ConnectorImpl(shell::mojom::ConnectorPtr connector) + +ConnectorImpl::ConnectorImpl(mojom::ConnectorPtr connector) : connector_(std::move(connector)) { thread_checker_.reset(new base::ThreadChecker); } + ConnectorImpl::~ConnectorImpl() {} -scoped_ptr<Connection> ConnectorImpl::Connect(const std::string& name) { +std::unique_ptr<Connection> ConnectorImpl::Connect(const std::string& name) { ConnectParams params(name); return Connect(¶ms); } -scoped_ptr<Connection> ConnectorImpl::Connect(ConnectParams* params) { +std::unique_ptr<Connection> ConnectorImpl::Connect(ConnectParams* params) { // Bind this object to the current thread the first time it is used to // connect. if (!connector_.is_bound()) { @@ -48,23 +53,22 @@ // a position to know who we're talking to. CapabilityRequest request; request.interfaces.insert("*"); - shell::mojom::InterfaceProviderPtr local_interfaces; - shell::mojom::InterfaceProviderRequest local_request = - GetProxy(&local_interfaces); - shell::mojom::InterfaceProviderPtr remote_interfaces; - shell::mojom::InterfaceProviderRequest remote_request = - GetProxy(&remote_interfaces); - scoped_ptr<internal::ConnectionImpl> registry(new internal::ConnectionImpl( - params->target().name(), params->target(), - shell::mojom::kInvalidInstanceID, std::move(remote_interfaces), - std::move(local_request), request, Connection::State::PENDING)); + mojom::InterfaceProviderPtr local_interfaces; + mojom::InterfaceProviderRequest local_request = GetProxy(&local_interfaces); + mojom::InterfaceProviderPtr remote_interfaces; + mojom::InterfaceProviderRequest remote_request = GetProxy(&remote_interfaces); + std::unique_ptr<internal::ConnectionImpl> registry( + new internal::ConnectionImpl( + params->target().name(), params->target(), mojom::kInvalidInstanceID, + std::move(remote_interfaces), std::move(local_request), request, + Connection::State::PENDING)); - shell::mojom::ShellClientPtr shell_client; - shell::mojom::PIDReceiverRequest pid_receiver_request; + mojom::ShellClientPtr shell_client; + mojom::PIDReceiverRequest pid_receiver_request; params->TakeClientProcessConnection(&shell_client, &pid_receiver_request); - shell::mojom::ClientProcessConnectionPtr client_process_connection; + mojom::ClientProcessConnectionPtr client_process_connection; if (shell_client.is_bound() && pid_receiver_request.is_pending()) { - client_process_connection = shell::mojom::ClientProcessConnection::New(); + client_process_connection = mojom::ClientProcessConnection::New(); client_process_connection->shell_client = shell_client.PassInterface().PassHandle(); client_process_connection->pid_receiver_request = @@ -74,18 +78,17 @@ << "both must be valid."; return std::move(registry); } - connector_->Connect( - shell::mojom::Identity::From(params->target()), - std::move(remote_request), std::move(local_interfaces), - std::move(client_process_connection), registry->GetConnectCallback()); + connector_->Connect(mojom::Identity::From(params->target()), + std::move(remote_request), std::move(local_interfaces), + std::move(client_process_connection), + registry->GetConnectCallback()); return std::move(registry); } -scoped_ptr<Connector> ConnectorImpl::Clone() { - shell::mojom::ConnectorPtr connector; +std::unique_ptr<Connector> ConnectorImpl::Clone() { + mojom::ConnectorPtr connector; connector_->Clone(GetProxy(&connector)); - return make_scoped_ptr( - new ConnectorImpl(connector.PassInterface())); + return base::WrapUnique(new ConnectorImpl(connector.PassInterface())); } -} // namespace mojo +} // namespace shell
diff --git a/services/shell/public/cpp/lib/connector_impl.h b/services/shell/public/cpp/lib/connector_impl.h index 330e0e6..128469a 100644 --- a/services/shell/public/cpp/lib/connector_impl.h +++ b/services/shell/public/cpp/lib/connector_impl.h
@@ -5,33 +5,35 @@ #ifndef SERVICES_SHELL_PUBLIC_CPP_LIB_CONNECTOR_IMPL_H_ #define SERVICES_SHELL_PUBLIC_CPP_LIB_CONNECTOR_IMPL_H_ +#include <memory> + #include "base/callback.h" #include "base/threading/thread_checker.h" #include "services/shell/public/cpp/connector.h" #include "services/shell/public/interfaces/connector.mojom.h" -namespace mojo { +namespace shell { class ConnectorImpl : public Connector { public: - explicit ConnectorImpl(shell::mojom::ConnectorPtrInfo unbound_state); - explicit ConnectorImpl(shell::mojom::ConnectorPtr connector); + explicit ConnectorImpl(mojom::ConnectorPtrInfo unbound_state); + explicit ConnectorImpl(mojom::ConnectorPtr connector); ~ConnectorImpl() override; private: // Connector: - scoped_ptr<Connection> Connect(const std::string& name) override; - scoped_ptr<Connection> Connect(ConnectParams* params) override; - scoped_ptr<Connector> Clone() override; + std::unique_ptr<Connection> Connect(const std::string& name) override; + std::unique_ptr<Connection> Connect(ConnectParams* params) override; + std::unique_ptr<Connector> Clone() override; - shell::mojom::ConnectorPtrInfo unbound_state_; - shell::mojom::ConnectorPtr connector_; + mojom::ConnectorPtrInfo unbound_state_; + mojom::ConnectorPtr connector_; - scoped_ptr<base::ThreadChecker> thread_checker_; + std::unique_ptr<base::ThreadChecker> thread_checker_; DISALLOW_COPY_AND_ASSIGN(ConnectorImpl); }; -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_LIB_CONNECTOR_IMPL_H_
diff --git a/services/shell/public/cpp/lib/identity.cc b/services/shell/public/cpp/lib/identity.cc index a3f12cb..dc49424 100644 --- a/services/shell/public/cpp/lib/identity.cc +++ b/services/shell/public/cpp/lib/identity.cc
@@ -7,7 +7,7 @@ #include "base/guid.h" #include "services/shell/public/cpp/names.h" -namespace mojo { +namespace shell { Identity::Identity() {} @@ -40,10 +40,14 @@ other.user_id_ == user_id_; } +} // namespace shell + +namespace mojo { + // static shell::mojom::IdentityPtr - TypeConverter<shell::mojom::IdentityPtr, Identity>::Convert( - const Identity& input) { +TypeConverter<shell::mojom::IdentityPtr, shell::Identity>::Convert( + const shell::Identity& input) { shell::mojom::IdentityPtr identity(shell::mojom::Identity::New()); identity->name = input.name(); identity->user_id = input.user_id(); @@ -52,9 +56,10 @@ } // static -Identity TypeConverter<Identity, shell::mojom::IdentityPtr>::Convert( +shell::Identity +TypeConverter<shell::Identity, shell::mojom::IdentityPtr>::Convert( const shell::mojom::IdentityPtr& input) { - return Identity(input->name, input->user_id, input->instance); + return shell::Identity(input->name, input->user_id, input->instance); } } // namespace mojo
diff --git a/services/shell/public/cpp/lib/init_commandline.cc b/services/shell/public/cpp/lib/init_commandline.cc index a61797b..73c2011 100644 --- a/services/shell/public/cpp/lib/init_commandline.cc +++ b/services/shell/public/cpp/lib/init_commandline.cc
@@ -4,19 +4,19 @@ #include "build/build_config.h" -namespace mojo { +namespace shell { extern int g_application_runner_argc; extern const char* const* g_application_runner_argv; -} +} // namespace shell #if !defined(OS_WIN) extern "C" { __attribute__((visibility("default"))) void InitCommandLineArgs( int argc, const char* const* argv) { - mojo::g_application_runner_argc = argc; - mojo::g_application_runner_argv = argv; + shell::g_application_runner_argc = argc; + shell::g_application_runner_argv = argv; } } #endif
diff --git a/services/shell/public/cpp/lib/interface_factory_binder.h b/services/shell/public/cpp/lib/interface_factory_binder.h index 78af4c54..bd97a76 100644 --- a/services/shell/public/cpp/lib/interface_factory_binder.h +++ b/services/shell/public/cpp/lib/interface_factory_binder.h
@@ -11,7 +11,7 @@ #include "services/shell/public/cpp/interface_binder.h" #include "services/shell/public/cpp/interface_factory.h" -namespace mojo { +namespace shell { namespace internal { template <typename Interface> @@ -21,11 +21,11 @@ : factory_(factory) {} ~InterfaceFactoryBinder() override {} - void BindInterface(Connection* connection, - const std::string& interface_name, - ScopedMessagePipeHandle client_handle) override { - factory_->Create(connection, - MakeRequest<Interface>(std::move(client_handle))); + void BindInterface(Connection* connection, + const std::string& interface_name, + mojo::ScopedMessagePipeHandle client_handle) override { + factory_->Create(connection, + mojo::MakeRequest<Interface>(std::move(client_handle))); } private: @@ -34,6 +34,6 @@ }; } // namespace internal -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_LIB_INTERFACE_FACTORY_BINDER_H_
diff --git a/services/shell/public/cpp/lib/interface_registry.cc b/services/shell/public/cpp/lib/interface_registry.cc index db883ef..39e5d90 100644 --- a/services/shell/public/cpp/lib/interface_registry.cc +++ b/services/shell/public/cpp/lib/interface_registry.cc
@@ -6,17 +6,14 @@ #include "services/shell/public/cpp/connection.h" -namespace mojo { +namespace shell { InterfaceRegistry::InterfaceRegistry(Connection* connection) : InterfaceRegistry(nullptr, connection) {} -InterfaceRegistry::InterfaceRegistry( - shell::mojom::InterfaceProviderRequest request, - Connection* connection) - : binding_(this), - connection_(connection), - default_binder_(nullptr) { +InterfaceRegistry::InterfaceRegistry(mojom::InterfaceProviderRequest request, + Connection* connection) + : binding_(this), connection_(connection), default_binder_(nullptr) { if (!request.is_pending()) request = GetProxy(&client_handle_); binding_.Bind(std::move(request)); @@ -28,13 +25,13 @@ name_to_binder_.clear(); } -shell::mojom::InterfaceProviderPtr InterfaceRegistry::TakeClientHandle() { +mojom::InterfaceProviderPtr InterfaceRegistry::TakeClientHandle() { return std::move(client_handle_); } -// shell::mojom::InterfaceProvider: -void InterfaceRegistry::GetInterface(const String& interface_name, - ScopedMessagePipeHandle handle) { +// mojom::InterfaceProvider: +void InterfaceRegistry::GetInterface(const mojo::String& interface_name, + mojo::ScopedMessagePipeHandle handle) { auto iter = name_to_binder_.find(interface_name); InterfaceBinder* binder = iter != name_to_binder_.end() ? iter->second : default_binder_; @@ -67,4 +64,4 @@ name_to_binder_.erase(it); } -} // namespace mojo +} // namespace shell
diff --git a/services/shell/public/cpp/lib/message_loop_ref.cc b/services/shell/public/cpp/lib/message_loop_ref.cc index 1b65ecc..66116bb5 100644 --- a/services/shell/public/cpp/lib/message_loop_ref.cc +++ b/services/shell/public/cpp/lib/message_loop_ref.cc
@@ -5,9 +5,10 @@ #include "services/shell/public/cpp/message_loop_ref.h" #include "base/bind.h" +#include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" -namespace mojo { +namespace shell { class MessageLoopRefImpl : public MessageLoopRef { public: @@ -37,7 +38,7 @@ private: // MessageLoopRef: - scoped_ptr<MessageLoopRef> Clone() override { + std::unique_ptr<MessageLoopRef> Clone() override { if (app_task_runner_->BelongsToCurrentThread()) { factory_->AddRef(); } else { @@ -58,7 +59,7 @@ } #endif - return make_scoped_ptr(new MessageLoopRefImpl(factory_, app_task_runner_)); + return base::WrapUnique(new MessageLoopRefImpl(factory_, app_task_runner_)); } MessageLoopRefFactory* factory_; @@ -74,9 +75,9 @@ MessageLoopRefFactory::MessageLoopRefFactory() {} MessageLoopRefFactory::~MessageLoopRefFactory() {} -scoped_ptr<MessageLoopRef> MessageLoopRefFactory::CreateRef() { +std::unique_ptr<MessageLoopRef> MessageLoopRefFactory::CreateRef() { AddRef(); - return make_scoped_ptr(new MessageLoopRefImpl( + return base::WrapUnique(new MessageLoopRefImpl( this, base::MessageLoop::current()->task_runner())); } @@ -95,4 +96,4 @@ } } -} // namespace mojo +} // namespace shell
diff --git a/services/shell/public/cpp/lib/names.cc b/services/shell/public/cpp/lib/names.cc index 210a121..4912222 100644 --- a/services/shell/public/cpp/lib/names.cc +++ b/services/shell/public/cpp/lib/names.cc
@@ -7,7 +7,7 @@ #include "base/strings/string_split.h" #include "base/strings/string_util.h" -namespace mojo { +namespace shell { const char kNameType_Mojo[] = "mojo"; const char kNameType_Exe[] = "exe"; @@ -43,4 +43,4 @@ return parts.back(); } -} // namespace mojo +} // namespace shell
diff --git a/services/shell/public/cpp/lib/shell_client.cc b/services/shell/public/cpp/lib/shell_client.cc index 3619bacbb..562d6ee4 100644 --- a/services/shell/public/cpp/lib/shell_client.cc +++ b/services/shell/public/cpp/lib/shell_client.cc
@@ -4,7 +4,7 @@ #include "services/shell/public/cpp/shell_client.h" -namespace mojo { +namespace shell { ShellClient::ShellClient() {} ShellClient::~ShellClient() {} @@ -19,4 +19,4 @@ bool ShellClient::ShellConnectionLost() { return true; } -} // namespace mojo +} // namespace shell
diff --git a/services/shell/public/cpp/lib/shell_connection.cc b/services/shell/public/cpp/lib/shell_connection.cc index a302e28..ff14516 100644 --- a/services/shell/public/cpp/lib/shell_connection.cc +++ b/services/shell/public/cpp/lib/shell_connection.cc
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "services/shell/public/cpp/shell_connection.h" + #include "base/bind.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" @@ -12,17 +14,16 @@ #include "services/shell/public/cpp/lib/connection_impl.h" #include "services/shell/public/cpp/lib/connector_impl.h" #include "services/shell/public/cpp/shell_client.h" -#include "services/shell/public/cpp/shell_connection.h" -namespace mojo { +namespace shell { //////////////////////////////////////////////////////////////////////////////// // ShellConnection, public: -ShellConnection::ShellConnection(mojo::ShellClient* client, - shell::mojom::ShellClientRequest request) +ShellConnection::ShellConnection(shell::ShellClient* client, + mojom::ShellClientRequest request) : client_(client), binding_(this) { - shell::mojom::ConnectorPtr connector; + mojom::ConnectorPtr connector; pending_connector_request_ = GetProxy(&connector); connector_.reset(new ConnectorImpl(std::move(connector))); @@ -37,15 +38,15 @@ } void ShellConnection::SetAppTestConnectorForTesting( - shell::mojom::ConnectorPtr connector) { + mojom::ConnectorPtr connector) { pending_connector_request_ = nullptr; connector_.reset(new ConnectorImpl(std::move(connector))); } //////////////////////////////////////////////////////////////////////////////// -// ShellConnection, shell::mojom::ShellClient implementation: +// ShellConnection, mojom::ShellClient implementation: -void ShellConnection::Initialize(shell::mojom::IdentityPtr identity, +void ShellConnection::Initialize(mojom::IdentityPtr identity, uint32_t id, const InitializeCallback& callback) { if (!initialize_handler_.is_null()) @@ -60,16 +61,15 @@ } void ShellConnection::AcceptConnection( - shell::mojom::IdentityPtr source, + mojom::IdentityPtr source, uint32_t source_id, - shell::mojom::InterfaceProviderRequest local_interfaces, - shell::mojom::InterfaceProviderPtr remote_interfaces, - shell::mojom::CapabilityRequestPtr allowed_capabilities, - const String& name) { - scoped_ptr<Connection> registry(new internal::ConnectionImpl( + mojom::InterfaceProviderRequest local_interfaces, + mojom::InterfaceProviderPtr remote_interfaces, + mojom::CapabilityRequestPtr allowed_capabilities, + const mojo::String& name) { + std::unique_ptr<Connection> registry(new internal::ConnectionImpl( name, source.To<Identity>(), source_id, std::move(remote_interfaces), - std::move(local_interfaces), - allowed_capabilities.To<CapabilityRequest>(), + std::move(local_interfaces), allowed_capabilities.To<CapabilityRequest>(), Connection::State::CONNECTED)); if (!client_->AcceptConnection(registry.get())) return; @@ -92,4 +92,4 @@ // Connect() will return nullptr if they try to connect to anything. } -} // namespace mojo +} // namespace shell
diff --git a/services/shell/public/cpp/lib/shell_test.cc b/services/shell/public/cpp/lib/shell_test.cc index e789907..31f290f 100644 --- a/services/shell/public/cpp/lib/shell_test.cc +++ b/services/shell/public/cpp/lib/shell_test.cc
@@ -4,12 +4,13 @@ #include "services/shell/public/cpp/shell_test.h" +#include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "services/shell/background/background_shell.h" #include "services/shell/public/cpp/shell_client.h" -namespace mojo { +namespace shell { namespace test { ShellTestClient::ShellTestClient(ShellTest* test) : test_(test) {} @@ -29,12 +30,12 @@ test_name_ = test_name; } -scoped_ptr<ShellClient> ShellTest::CreateShellClient() { - return make_scoped_ptr(new ShellTestClient(this)); +std::unique_ptr<ShellClient> ShellTest::CreateShellClient() { + return base::WrapUnique(new ShellTestClient(this)); } -scoped_ptr<base::MessageLoop> ShellTest::CreateMessageLoop() { - return make_scoped_ptr(new base::MessageLoop); +std::unique_ptr<base::MessageLoop> ShellTest::CreateMessageLoop() { + return base::WrapUnique(new base::MessageLoop); } void ShellTest::InitializeCalled(Connector* connector, @@ -77,4 +78,4 @@ } } // namespace test -} // namespace mojo +} // namespace shell
diff --git a/services/shell/public/cpp/message_loop_ref.h b/services/shell/public/cpp/message_loop_ref.h index cfb8d27..8455387 100644 --- a/services/shell/public/cpp/message_loop_ref.h +++ b/services/shell/public/cpp/message_loop_ref.h
@@ -5,12 +5,13 @@ #ifndef SERVICES_SHELL_PUBLIC_CPP_MESSAGE_LOOP_REF_H_ #define SERVICES_SHELL_PUBLIC_CPP_MESSAGE_LOOP_REF_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "mojo/public/cpp/system/core.h" -namespace mojo { +namespace shell { class MessageLoopRefImpl; @@ -25,7 +26,7 @@ public: virtual ~MessageLoopRef() {} - virtual scoped_ptr<MessageLoopRef> Clone() = 0; + virtual std::unique_ptr<MessageLoopRef> Clone() = 0; }; class MessageLoopRefFactory { @@ -37,7 +38,7 @@ quit_closure_ = quit_closure; } - scoped_ptr<MessageLoopRef> CreateRef(); + std::unique_ptr<MessageLoopRef> CreateRef(); private: friend MessageLoopRefImpl; @@ -52,6 +53,6 @@ DISALLOW_COPY_AND_ASSIGN(MessageLoopRefFactory); }; -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_MESSAGE_LOOP_REF_H_
diff --git a/services/shell/public/cpp/names.h b/services/shell/public/cpp/names.h index 4da7fe5e..fe534e93 100644 --- a/services/shell/public/cpp/names.h +++ b/services/shell/public/cpp/names.h
@@ -7,7 +7,7 @@ #include <string> -namespace mojo { +namespace shell { extern const char kNameType_Mojo[]; extern const char kNameType_Exe[]; @@ -51,6 +51,6 @@ // Get the path component of the specified name. std::string GetNamePath(const std::string& name); -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_NAMES_H_
diff --git a/services/shell/public/cpp/shell.h b/services/shell/public/cpp/shell.h deleted file mode 100644 index e1ec6d28..0000000 --- a/services/shell/public/cpp/shell.h +++ /dev/null
@@ -1,16 +0,0 @@ -// Copyright 2016 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 SERVICES_SHELL_PUBLIC_CPP_SHELL_H_ -#define SERVICES_SHELL_PUBLIC_CPP_SHELL_H_ - -#include "services/shell/public/cpp/connector.h" - -namespace mojo { - -using Shell = Connector; - -} // namespace mojo - -#endif // SERVICES_SHELL_PUBLIC_CPP_SHELL_H_
diff --git a/services/shell/public/cpp/shell_client.h b/services/shell/public/cpp/shell_client.h index 1c9f4e4..d9513b76 100644 --- a/services/shell/public/cpp/shell_client.h +++ b/services/shell/public/cpp/shell_client.h
@@ -12,7 +12,7 @@ #include "services/shell/public/cpp/connection.h" #include "services/shell/public/cpp/identity.h" -namespace mojo { +namespace shell { class Connector; @@ -55,6 +55,6 @@ DISALLOW_COPY_AND_ASSIGN(ShellClient); }; -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_
diff --git a/services/shell/public/cpp/shell_connection.h b/services/shell/public/cpp/shell_connection.h index a92c930..84aae0da 100644 --- a/services/shell/public/cpp/shell_connection.h +++ b/services/shell/public/cpp/shell_connection.h
@@ -5,6 +5,7 @@ #ifndef SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ #define SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ +#include <memory> #include <utility> #include <vector> @@ -18,38 +19,37 @@ #include "services/shell/public/interfaces/connector.mojom.h" #include "services/shell/public/interfaces/shell_client.mojom.h" -namespace mojo { +namespace shell { class Connector; // Encapsulates a connection to the Mojo Shell in two parts: -// - a bound InterfacePtr to mojo::shell::mojom::Shell, the primary mechanism +// - a bound InterfacePtr to mojom::Shell, the primary mechanism // by which the instantiating application interacts with other services // brokered by the Mojo Shell. -// - a bound InterfaceRequest of mojo::shell::mojom::ShellClient, an interface +// - a bound InterfaceRequest of mojom::ShellClient, an interface // used by the Mojo Shell to inform this application of lifecycle events and // inbound connections brokered by it. // // This class should be used in two scenarios: -// - During early startup to bind the mojo::shell::mojom::ShellClientRequest -// obtained from the Mojo Shell. This is typically in response to either -// MojoMain() or main(). -// - In an implementation of mojo::shell::mojom::ContentHandler to bind the -// mojo::shell::mojom::ShellClientRequest passed via StartApplication. In this -// scenario there can be many instances of this class per process. +// - During early startup to bind the mojom::ShellClientRequest obtained from +// the Mojo Shell, typically in response to either MojoMain() or main(). +// - In an implementation of mojom::ShellClientFactory to bind the +// mojom::ShellClientRequest passed via StartApplication. In this scenario +// there can be many instances of this class per process. // // Instances of this class are constructed with an implementation of the Shell -// Client Lib's mojo::ShellClient interface. See documentation in shell_client.h +// Client Lib's ShellClient interface. See documentation in shell_client.h // for details. // -class ShellConnection : public shell::mojom::ShellClient { +class ShellConnection : public mojom::ShellClient { public: // Creates a new ShellConnection bound to |request|. This connection may be // used immediately to make outgoing connections via connector(). Does not // take ownership of |client|, which must remain valid for the lifetime of // ShellConnection. - ShellConnection(mojo::ShellClient* client, - shell::mojom::ShellClientRequest request); + ShellConnection(shell::ShellClient* client, + mojom::ShellClientRequest request); ~ShellConnection() override; @@ -59,7 +59,7 @@ void set_initialize_handler(const base::Closure& callback); // TODO(rockot): Remove this once we get rid of app tests. - void SetAppTestConnectorForTesting(shell::mojom::ConnectorPtr connector); + void SetAppTestConnectorForTesting(mojom::ConnectorPtr connector); // Specify a function to be called when the connection to the shell is lost. void set_connection_lost_closure(const base::Closure& closure) { @@ -67,39 +67,38 @@ } private: - // shell::mojom::ShellClient: - void Initialize(shell::mojom::IdentityPtr identity, - uint32_t id, - const InitializeCallback& callback) override; - void AcceptConnection( - shell::mojom::IdentityPtr source, - uint32_t source_id, - shell::mojom::InterfaceProviderRequest remote_interfaces, - shell::mojom::InterfaceProviderPtr local_interfaces, - shell::mojom::CapabilityRequestPtr allowed_capabilities, - const String& name) override; + // mojom::ShellClient: + void Initialize(mojom::IdentityPtr identity, + uint32_t id, + const InitializeCallback& callback) override; + void AcceptConnection(mojom::IdentityPtr source, + uint32_t source_id, + mojom::InterfaceProviderRequest remote_interfaces, + mojom::InterfaceProviderPtr local_interfaces, + mojom::CapabilityRequestPtr allowed_capabilities, + const mojo::String& name) override; - void OnConnectionError(); + void OnConnectionError(); - // A callback called when Initialize() is run. - base::Closure initialize_handler_; + // A callback called when Initialize() is run. + base::Closure initialize_handler_; - // We track the lifetime of incoming connection registries as it more - // convenient for the client. - ScopedVector<Connection> incoming_connections_; + // We track the lifetime of incoming connection registries as it more + // convenient for the client. + ScopedVector<Connection> incoming_connections_; - // A pending Connector request which will eventually be passed to the shell. - shell::mojom::ConnectorRequest pending_connector_request_; + // A pending Connector request which will eventually be passed to the shell. + mojom::ConnectorRequest pending_connector_request_; - mojo::ShellClient* client_; - Binding<shell::mojom::ShellClient> binding_; - scoped_ptr<Connector> connector_; + shell::ShellClient* client_; + mojo::Binding<mojom::ShellClient> binding_; + std::unique_ptr<Connector> connector_; - base::Closure connection_lost_closure_; + base::Closure connection_lost_closure_; - DISALLOW_COPY_AND_ASSIGN(ShellConnection); + DISALLOW_COPY_AND_ASSIGN(ShellConnection); }; -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_
diff --git a/services/shell/public/cpp/shell_test.h b/services/shell/public/cpp/shell_test.h index dcbd9fb..b299297 100644 --- a/services/shell/public/cpp/shell_test.h +++ b/services/shell/public/cpp/shell_test.h
@@ -5,8 +5,9 @@ #ifndef SERVICES_SHELL_PUBLIC_CPP_SHELL_TEST_H_ #define SERVICES_SHELL_PUBLIC_CPP_SHELL_TEST_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "services/shell/public/cpp/connector.h" #include "services/shell/public/cpp/shell_client.h" #include "services/shell/public/cpp/shell_connection.h" @@ -16,10 +17,10 @@ class MessageLoop; } -namespace mojo { namespace shell { + class BackgroundShell; -} + namespace test { class ShellTest; @@ -28,7 +29,7 @@ // to customize this should subclass this class instead of ShellClient, // otherwise they will have to call ShellTest::InitializeCalled() to forward // metadata from Initialize() to the test. -class ShellTestClient : public mojo::ShellClient { +class ShellTestClient : public ShellClient { public: explicit ShellTestClient(ShellTest* test); ~ShellTestClient() override; @@ -69,9 +70,9 @@ // via Initialize(). Override to customize, but custom implementations must // call InitializeCalled() to forward the metadata so test_name() etc all // work. - virtual scoped_ptr<ShellClient> CreateShellClient(); + virtual std::unique_ptr<ShellClient> CreateShellClient(); - virtual scoped_ptr<base::MessageLoop> CreateMessageLoop(); + virtual std::unique_ptr<base::MessageLoop> CreateMessageLoop(); // Call to set Initialize() metadata when GetShellClient() is overridden. void InitializeCalled(Connector* connector, @@ -86,11 +87,11 @@ private: friend ShellTestClient; - scoped_ptr<ShellClient> shell_client_; + std::unique_ptr<ShellClient> shell_client_; - scoped_ptr<base::MessageLoop> message_loop_; - scoped_ptr<shell::BackgroundShell> background_shell_; - scoped_ptr<ShellConnection> shell_connection_; + std::unique_ptr<base::MessageLoop> message_loop_; + std::unique_ptr<BackgroundShell> background_shell_; + std::unique_ptr<ShellConnection> shell_connection_; // See constructor. std::string test_name_; @@ -106,6 +107,6 @@ }; } // namespace test -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_PUBLIC_CPP_SHELL_TEST_H_
diff --git a/services/shell/public/cpp/tests/interface_registry_unittest.cc b/services/shell/public/cpp/tests/interface_registry_unittest.cc index c7719d3..614248f 100644 --- a/services/shell/public/cpp/tests/interface_registry_unittest.cc +++ b/services/shell/public/cpp/tests/interface_registry_unittest.cc
@@ -4,12 +4,11 @@ #include "services/shell/public/cpp/interface_registry.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "services/shell/public/cpp/interface_binder.h" #include "testing/gtest/include/gtest/gtest.h" -namespace mojo { +namespace shell { namespace internal { namespace { @@ -19,7 +18,7 @@ ~TestBinder() override { (*delete_count_)++; } void BindInterface(Connection* connection, const std::string& interface_name, - ScopedMessagePipeHandle client_handle) override {} + mojo::ScopedMessagePipeHandle client_handle) override {} private: int* delete_count_; @@ -39,7 +38,7 @@ // Removal. { - scoped_ptr<InterfaceRegistry> registry(new InterfaceRegistry(nullptr)); + std::unique_ptr<InterfaceRegistry> registry(new InterfaceRegistry(nullptr)); InterfaceBinder* b = new TestBinder(&delete_count); InterfaceRegistry::TestApi test_api(registry.get()); test_api.SetInterfaceBinderForName(b, "TC1"); @@ -70,4 +69,4 @@ } // namespace } // namespace internal -} // namespace mojo +} // namespace shell
diff --git a/services/shell/public/interfaces/capabilities.mojom b/services/shell/public/interfaces/capabilities.mojom index 563b88c1..dff92305 100644 --- a/services/shell/public/interfaces/capabilities.mojom +++ b/services/shell/public/interfaces/capabilities.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. -module mojo.shell.mojom; +module shell.mojom; // Mojo Capabilities ----------------------------------------------------------- //
diff --git a/services/shell/public/interfaces/connector.mojom b/services/shell/public/interfaces/connector.mojom index c114612..f419ebe 100644 --- a/services/shell/public/interfaces/connector.mojom +++ b/services/shell/public/interfaces/connector.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. -module mojo.shell.mojom; +module shell.mojom; import "services/shell/public/interfaces/interface_provider.mojom";
diff --git a/services/shell/public/interfaces/interface_provider.mojom b/services/shell/public/interfaces/interface_provider.mojom index 7011bb14..c64f52f 100644 --- a/services/shell/public/interfaces/interface_provider.mojom +++ b/services/shell/public/interfaces/interface_provider.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. -module mojo.shell.mojom; +module shell.mojom; // An interface through which a client may request interfaces from a host. // Instances of this interface are created within the context of an
diff --git a/services/shell/public/interfaces/shell.mojom b/services/shell/public/interfaces/shell.mojom index 3618b95..2ff9201 100644 --- a/services/shell/public/interfaces/shell.mojom +++ b/services/shell/public/interfaces/shell.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. -module mojo.shell.mojom; +module shell.mojom; import "services/shell/public/interfaces/connector.mojom";
diff --git a/services/shell/public/interfaces/shell_client.mojom b/services/shell/public/interfaces/shell_client.mojom index d816bac6..04618cac 100644 --- a/services/shell/public/interfaces/shell_client.mojom +++ b/services/shell/public/interfaces/shell_client.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. -module mojo.shell.mojom; +module shell.mojom; import "services/shell/public/interfaces/capabilities.mojom"; import "services/shell/public/interfaces/connector.mojom";
diff --git a/services/shell/public/interfaces/shell_client_factory.mojom b/services/shell/public/interfaces/shell_client_factory.mojom index a377cfc..a159389 100644 --- a/services/shell/public/interfaces/shell_client_factory.mojom +++ b/services/shell/public/interfaces/shell_client_factory.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. -module mojo.shell.mojom; +module shell.mojom; import "services/shell/public/interfaces/shell_client.mojom";
diff --git a/services/shell/public/interfaces/shell_resolver.mojom b/services/shell/public/interfaces/shell_resolver.mojom index 64f3134..02dbbe5be 100644 --- a/services/shell/public/interfaces/shell_resolver.mojom +++ b/services/shell/public/interfaces/shell_resolver.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. -module mojo.shell.mojom; +module shell.mojom; import "services/shell/public/interfaces/capabilities.mojom";
diff --git a/services/shell/runner/child/native_apptest.cc b/services/shell/runner/child/native_apptest.cc index 1d2c156..06bddc8c 100644 --- a/services/shell/runner/child/native_apptest.cc +++ b/services/shell/runner/child/native_apptest.cc
@@ -7,15 +7,17 @@ #include "services/shell/public/cpp/application_test_base.h" #include "services/shell/runner/child/test_native_service.mojom.h" -namespace mojo { namespace shell { + namespace { + void InvertCallback(bool* result, bool from_native) { *result = from_native; } + } // namespace -using NativeAppTest = mojo::test::ApplicationTestBase; +using NativeAppTest = test::ApplicationTestBase; TEST_F(NativeAppTest, Connect) { test::TestNativeServicePtr native_service; @@ -35,4 +37,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/runner/child/native_apptest_target.cc b/services/shell/runner/child/native_apptest_target.cc index 0e0c4b0..ab1ec4c 100644 --- a/services/shell/runner/child/native_apptest_target.cc +++ b/services/shell/runner/child/native_apptest_target.cc
@@ -18,33 +18,33 @@ namespace { class TargetApplicationDelegate - : public mojo::ShellClient, - public mojo::shell::test::TestNativeService, - public mojo::InterfaceFactory<mojo::shell::test::TestNativeService> { + : public shell::ShellClient, + public shell::test::TestNativeService, + public shell::InterfaceFactory<shell::test::TestNativeService> { public: TargetApplicationDelegate() {} ~TargetApplicationDelegate() override {} private: - // mojo::ShellClient: - bool AcceptConnection(mojo::Connection* connection) override { - connection->AddInterface<mojo::shell::test::TestNativeService>(this); + // shell::ShellClient: + bool AcceptConnection(shell::Connection* connection) override { + connection->AddInterface<shell::test::TestNativeService>(this); return true; } - // mojo::shell::test::TestNativeService: + // shell::test::TestNativeService: void Invert(bool from_driver, const InvertCallback& callback) override { callback.Run(!from_driver); } - // mojo::InterfaceFactory<mojo::shell::test::TestNativeService>: - void Create(mojo::Connection* connection, - mojo::InterfaceRequest<mojo::shell::test::TestNativeService> - request) override { + // shell::InterfaceFactory<shell::test::TestNativeService>: + void Create( + shell::Connection* connection, + mojo::InterfaceRequest<shell::test::TestNativeService> request) override { bindings_.AddBinding(this, std::move(request)); } - mojo::BindingSet<mojo::shell::test::TestNativeService> bindings_; + mojo::BindingSet<shell::test::TestNativeService> bindings_; DISALLOW_COPY_AND_ASSIGN(TargetApplicationDelegate); }; @@ -55,8 +55,8 @@ base::AtExitManager at_exit; base::CommandLine::Init(argc, argv); - mojo::shell::InitializeLogging(); + shell::InitializeLogging(); TargetApplicationDelegate delegate; - return mojo::shell::TestNativeMain(&delegate); + return shell::TestNativeMain(&delegate); }
diff --git a/services/shell/runner/child/test_native_main.cc b/services/shell/runner/child/test_native_main.cc index 50dfe5b9..ea5bd0c9 100644 --- a/services/shell/runner/child/test_native_main.cc +++ b/services/shell/runner/child/test_native_main.cc
@@ -19,7 +19,6 @@ #include "services/shell/runner/common/client_util.h" #include "services/shell/runner/init.h" -namespace mojo { namespace shell { namespace { @@ -36,8 +35,8 @@ } // namespace -int TestNativeMain(mojo::ShellClient* shell_client) { - mojo::shell::WaitForDebuggerIfNecessary(); +int TestNativeMain(shell::ShellClient* shell_client) { + shell::WaitForDebuggerIfNecessary(); #if !defined(OFFICIAL_BUILD) base::debug::EnableInProcessStackDumping(); @@ -58,8 +57,8 @@ mojo::edk::SetParentPipeHandleFromCommandLine(); base::MessageLoop loop; - mojo::ShellConnection impl( - shell_client, mojo::shell::GetShellClientRequestFromCommandLine()); + shell::ShellConnection impl(shell_client, + shell::GetShellClientRequestFromCommandLine()); loop.Run(); mojo::edk::ShutdownIPCSupport(); @@ -69,4 +68,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/runner/child/test_native_main.h b/services/shell/runner/child/test_native_main.h index 9582212..a895616 100644 --- a/services/shell/runner/child/test_native_main.h +++ b/services/shell/runner/child/test_native_main.h
@@ -5,13 +5,12 @@ #ifndef SERVICES_SHELL_RUNNER_CHILD_TEST_NATIVE_MAIN_H_ #define SERVICES_SHELL_RUNNER_CHILD_TEST_NATIVE_MAIN_H_ -namespace mojo { -class ShellClient; namespace shell { -int TestNativeMain(mojo::ShellClient* shell_client); +class ShellClient; + +int TestNativeMain(ShellClient* shell_client); } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_RUNNER_CHILD_TEST_NATIVE_MAIN_H_
diff --git a/services/shell/runner/child/test_native_service.mojom b/services/shell/runner/child/test_native_service.mojom index 1f55eed..7bd50c1 100644 --- a/services/shell/runner/child/test_native_service.mojom +++ b/services/shell/runner/child/test_native_service.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. -module mojo.shell.test; +module shell.test; interface TestNativeService { Invert(bool from_driver) => (bool from_target);
diff --git a/services/shell/runner/common/client_util.cc b/services/shell/runner/common/client_util.cc index 50e04fa1..9a79c0e 100644 --- a/services/shell/runner/common/client_util.cc +++ b/services/shell/runner/common/client_util.cc
@@ -10,17 +10,16 @@ #include "mojo/edk/embedder/embedder.h" #include "services/shell/runner/common/switches.h" -namespace mojo { namespace shell { mojom::ShellClientPtr PassShellClientRequestOnCommandLine( base::CommandLine* command_line) { - std::string token = edk::GenerateRandomToken(); + std::string token = mojo::edk::GenerateRandomToken(); command_line->AppendSwitchASCII(switches::kPrimordialPipeToken, token); mojom::ShellClientPtr client; client.Bind( - mojom::ShellClientPtrInfo(edk::CreateParentMessagePipe(token), 0)); + mojom::ShellClientPtrInfo(mojo::edk::CreateParentMessagePipe(token), 0)); return client; } @@ -30,9 +29,8 @@ switches::kPrimordialPipeToken); mojom::ShellClientRequest request; if (!token.empty()) - request.Bind(edk::CreateChildMessagePipe(token)); + request.Bind(mojo::edk::CreateChildMessagePipe(token)); return request; } } // namespace shell -} // namespace mojo
diff --git a/services/shell/runner/common/client_util.h b/services/shell/runner/common/client_util.h index c042b50..d1ff4ff 100644 --- a/services/shell/runner/common/client_util.h +++ b/services/shell/runner/common/client_util.h
@@ -11,7 +11,6 @@ class CommandLine; } -namespace mojo { namespace shell { // Creates a new ShellClient pipe and returns one end of it. The other end is @@ -27,6 +26,5 @@ mojom::ShellClientRequest GetShellClientRequestFromCommandLine(); } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_RUNNER_COMMON_CLIENT_UTIL_H_
diff --git a/services/shell/runner/host/child_process.cc b/services/shell/runner/host/child_process.cc index d092921..1cb8ce1 100644 --- a/services/shell/runner/host/child_process.cc +++ b/services/shell/runner/host/child_process.cc
@@ -6,6 +6,7 @@ #include <stdint.h> +#include <memory> #include <utility> #include "base/base_switches.h" @@ -19,7 +20,6 @@ #include "base/logging.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" @@ -48,13 +48,12 @@ #include "services/shell/runner/host/mach_broker.h" #endif -namespace mojo { namespace shell { namespace { #if defined(OS_LINUX) && !defined(OS_ANDROID) -scoped_ptr<mojo::shell::LinuxSandbox> InitializeSandbox() { +std::unique_ptr<LinuxSandbox> InitializeSandbox() { using sandbox::syscall_broker::BrokerFilePermission; // Warm parts of base in the copy of base in the mojo runner. base::RandUint64(); @@ -69,8 +68,7 @@ std::vector<BrokerFilePermission> permissions; permissions.push_back( BrokerFilePermission::ReadWriteCreateUnlinkRecursive("/dev/shm/")); - scoped_ptr<mojo::shell::LinuxSandbox> sandbox( - new mojo::shell::LinuxSandbox(permissions)); + std::unique_ptr<LinuxSandbox> sandbox(new LinuxSandbox(permissions)); sandbox->Warmup(); sandbox->EngageNamespaceSandbox(); sandbox->EngageSeccompSandbox(); @@ -79,9 +77,8 @@ } #endif -void RunNativeLibrary( - base::NativeLibrary app_library, - InterfaceRequest<mojom::ShellClient> shell_client_request) { +void RunNativeLibrary(base::NativeLibrary app_library, + mojom::ShellClientRequest shell_client_request) { if (!RunNativeApplication(app_library, std::move(shell_client_request))) { LOG(ERROR) << "Failure to RunNativeApplication()"; } @@ -95,14 +92,14 @@ *base::CommandLine::ForCurrentProcess(); #if defined(OS_LINUX) && !defined(OS_ANDROID) - scoped_ptr<mojo::shell::LinuxSandbox> sandbox; + std::unique_ptr<LinuxSandbox> sandbox; #endif base::NativeLibrary app_library = 0; // Load the application library before we engage the sandbox. base::FilePath app_library_path = command_line.GetSwitchValuePath(switches::kChildProcess); if (!app_library_path.empty()) - app_library = mojo::shell::LoadNativeApplication(app_library_path); + app_library = LoadNativeApplication(app_library_path); base::i18n::InitializeICU(); if (app_library) CallLibraryEarlyInitialization(app_library); @@ -128,4 +125,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/runner/host/child_process.h b/services/shell/runner/host/child_process.h index a7c36540..1f70c007 100644 --- a/services/shell/runner/host/child_process.h +++ b/services/shell/runner/host/child_process.h
@@ -5,13 +5,11 @@ #ifndef SERVICES_SHELL_RUNNER_HOST_CHILD_PROCESS_H_ #define SERVICES_SHELL_RUNNER_HOST_CHILD_PROCESS_H_ -namespace mojo { namespace shell { // Main method for a child process. int ChildProcessMain(); } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_RUNNER_HOST_CHILD_PROCESS_H_
diff --git a/services/shell/runner/host/child_process_base.cc b/services/shell/runner/host/child_process_base.cc index 6508551a..b3daa76b 100644 --- a/services/shell/runner/host/child_process_base.cc +++ b/services/shell/runner/host/child_process_base.cc
@@ -15,19 +15,18 @@ #include "mojo/edk/embedder/process_delegate.h" #include "services/shell/runner/common/client_util.h" -namespace mojo { namespace shell { namespace { // Should be created and initialized on the main thread and kept alive as long // a Mojo application is running in the current process. -class ScopedAppContext : public edk::ProcessDelegate { +class ScopedAppContext : public mojo::edk::ProcessDelegate { public: ScopedAppContext() : io_thread_("io_thread"), wait_for_shutdown_event_(true, false) { // Initialize Mojo before starting any threads. - edk::Init(); + mojo::edk::Init(); // Create and start our I/O thread. base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0); @@ -35,12 +34,12 @@ io_runner_ = io_thread_.task_runner().get(); CHECK(io_runner_.get()); - edk::InitIPCSupport(this, io_runner_); - edk::SetParentPipeHandleFromCommandLine(); + mojo::edk::InitIPCSupport(this, io_runner_); + mojo::edk::SetParentPipeHandleFromCommandLine(); } ~ScopedAppContext() override { - edk::ShutdownIPCSupport(); + mojo::edk::ShutdownIPCSupport(); wait_for_shutdown_event_.Wait(); } @@ -69,4 +68,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/runner/host/child_process_base.h b/services/shell/runner/host/child_process_base.h index a1600cd..367cf88c 100644 --- a/services/shell/runner/host/child_process_base.h +++ b/services/shell/runner/host/child_process_base.h
@@ -8,7 +8,6 @@ #include "base/callback.h" #include "services/shell/public/interfaces/shell_client.mojom.h" -namespace mojo { namespace shell { // Child processes call this to establish the connection to the shell and obtain @@ -18,6 +17,5 @@ void ChildProcessMain(const RunCallback& callback); } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_RUNNER_HOST_CHILD_PROCESS_BASE_H_
diff --git a/services/shell/runner/host/child_process_host.cc b/services/shell/runner/host/child_process_host.cc index e8b44779..85f5920 100644 --- a/services/shell/runner/host/child_process_host.cc +++ b/services/shell/runner/host/child_process_host.cc
@@ -38,7 +38,6 @@ #include "services/shell/runner/host/mach_broker.h" #endif -namespace mojo { namespace shell { ChildProcessHost::ChildProcessHost(base::TaskRunner* launch_process_runner, @@ -77,7 +76,7 @@ target_path = app_path_; } - scoped_ptr<base::CommandLine> child_command_line( + std::unique_ptr<base::CommandLine> child_command_line( new base::CommandLine(target_path)); child_command_line->AppendArguments(*parent_command_line, false); @@ -93,7 +92,7 @@ if (start_sandboxed_) child_command_line->AppendSwitch(switches::kEnableSandbox); - mojo_ipc_channel_.reset(new edk::PlatformChannelPair); + mojo_ipc_channel_.reset(new mojo::edk::PlatformChannelPair); mojo_ipc_channel_->PrepareToPassClientHandleToChildProcess( child_command_line.get(), &handle_passing_info_); @@ -130,7 +129,7 @@ } void ChildProcessHost::DoLaunch( - scoped_ptr<base::CommandLine> child_command_line) { + std::unique_ptr<base::CommandLine> child_command_line) { if (delegate_) { delegate_->AdjustCommandLineArgumentsForTarget(target_, child_command_line.get()); @@ -209,4 +208,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/runner/host/child_process_host.h b/services/shell/runner/host/child_process_host.h index ba9fe21ba..3234cd9 100644 --- a/services/shell/runner/host/child_process_host.h +++ b/services/shell/runner/host/child_process_host.h
@@ -7,6 +7,7 @@ #include <stdint.h> +#include <memory> #include <string> #include "base/callback.h" @@ -14,7 +15,6 @@ #include "base/files/file_path.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/process/process.h" #include "base/synchronization/lock.h" @@ -29,10 +29,9 @@ class TaskRunner; } -namespace mojo { -class Identity; namespace shell { +class Identity; class NativeRunnerDelegate; // This class represents a "child process host". Handles launching and @@ -72,7 +71,7 @@ void DidStart(const ProcessReadyCallback& callback); private: - void DoLaunch(scoped_ptr<base::CommandLine> child_command_line); + void DoLaunch(std::unique_ptr<base::CommandLine> child_command_line); scoped_refptr<base::TaskRunner> launch_process_runner_; NativeRunnerDelegate* delegate_ = nullptr; @@ -82,8 +81,8 @@ base::Process child_process_; // Used to initialize the Mojo IPC channel between parent and child. - scoped_ptr<edk::PlatformChannelPair> mojo_ipc_channel_; - edk::HandlePassingInformation handle_passing_info_; + std::unique_ptr<mojo::edk::PlatformChannelPair> mojo_ipc_channel_; + mojo::edk::HandlePassingInformation handle_passing_info_; // Since Start() calls a method on another thread, we use an event to block // the main thread if it tries to destruct |this| while launching the process. @@ -95,6 +94,5 @@ }; } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_RUNNER_HOST_CHILD_PROCESS_HOST_H_
diff --git a/services/shell/runner/host/child_process_host_unittest.cc b/services/shell/runner/host/child_process_host_unittest.cc index fce0586..3af32ef7 100644 --- a/services/shell/runner/host/child_process_host_unittest.cc +++ b/services/shell/runner/host/child_process_host_unittest.cc
@@ -6,6 +6,7 @@ #include "services/shell/runner/host/child_process_host.h" +#include <memory> #include <utility> #include "base/bind.h" @@ -23,7 +24,6 @@ #include "services/shell/native_runner_delegate.h" #include "testing/gtest/include/gtest/gtest.h" -namespace mojo { namespace shell { namespace { @@ -32,7 +32,7 @@ callback.Run(); } -class ProcessDelegate : public edk::ProcessDelegate { +class ProcessDelegate : public mojo::edk::ProcessDelegate { public: ProcessDelegate() {} ~ProcessDelegate() override {} @@ -78,7 +78,7 @@ base::FilePath shell_dir; PathService::Get(base::DIR_MODULE, &shell_dir); base::MessageLoop message_loop( - scoped_ptr<base::MessagePump>(new common::MessagePumpMojo())); + std::unique_ptr<base::MessagePump>(new mojo::common::MessagePumpMojo())); scoped_refptr<base::SequencedWorkerPool> blocking_pool( new base::SequencedWorkerPool(3, "blocking_pool")); @@ -88,7 +88,7 @@ io_thread.StartWithOptions(options); ProcessDelegate delegate; - edk::InitIPCSupport(&delegate, io_thread.task_runner()); + mojo::edk::InitIPCSupport(&delegate, io_thread.task_runner()); NativeRunnerDelegateImpl native_runner_delegate; ChildProcessHost child_process_host(blocking_pool.get(), @@ -103,10 +103,9 @@ child_process_host.Join(); blocking_pool->Shutdown(); - edk::ShutdownIPCSupport(); + mojo::edk::ShutdownIPCSupport(); EXPECT_EQ(1u, native_runner_delegate.get_and_clear_adjust_count()); } } // namespace } // namespace shell -} // namespace mojo
diff --git a/services/shell/runner/host/host_unittests.cc b/services/shell/runner/host/host_unittests.cc index 1198a3ed..37192107 100644 --- a/services/shell/runner/host/host_unittests.cc +++ b/services/shell/runner/host/host_unittests.cc
@@ -19,12 +19,12 @@ const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); - mojo::shell::WaitForDebuggerIfNecessary(); + shell::WaitForDebuggerIfNecessary(); if (command_line.HasSwitch(switches::kChildProcess)) { base::AtExitManager at_exit; - return mojo::shell::ChildProcessMain(); + return shell::ChildProcessMain(); } mojo::edk::Init();
diff --git a/services/shell/runner/host/in_process_native_runner.cc b/services/shell/runner/host/in_process_native_runner.cc index 629d44d5..5107a2e6 100644 --- a/services/shell/runner/host/in_process_native_runner.cc +++ b/services/shell/runner/host/in_process_native_runner.cc
@@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/callback_helpers.h" #include "base/location.h" +#include "base/memory/ptr_util.h" #include "base/strings/utf_string_conversions.h" #include "base/task_runner.h" #include "base/thread_task_runner_handle.h" @@ -18,7 +19,6 @@ #include "services/shell/runner/host/out_of_process_native_runner.h" #include "services/shell/runner/init.h" -namespace mojo { namespace shell { InProcessNativeRunner::InProcessNativeRunner() : app_library_(nullptr) {} @@ -81,15 +81,14 @@ app_completed_callback_runner_.Reset(); } -scoped_ptr<NativeRunner> InProcessNativeRunnerFactory::Create( +std::unique_ptr<NativeRunner> InProcessNativeRunnerFactory::Create( const base::FilePath& app_path) { // Non-Mojo apps are always run in a new process. if (!app_path.MatchesExtension(FILE_PATH_LITERAL(".mojo"))) { - return make_scoped_ptr( + return base::WrapUnique( new OutOfProcessNativeRunner(launch_process_runner_, nullptr)); } - return make_scoped_ptr(new InProcessNativeRunner); + return base::WrapUnique(new InProcessNativeRunner); } } // namespace shell -} // namespace mojo
diff --git a/services/shell/runner/host/in_process_native_runner.h b/services/shell/runner/host/in_process_native_runner.h index 13b59fe..8b1af263 100644 --- a/services/shell/runner/host/in_process_native_runner.h +++ b/services/shell/runner/host/in_process_native_runner.h
@@ -5,10 +5,11 @@ #ifndef SERVICES_SHELL_RUNNER_HOST_IN_PROCESS_NATIVE_RUNNER_H_ #define SERVICES_SHELL_RUNNER_HOST_IN_PROCESS_NATIVE_RUNNER_H_ +#include <memory> + #include "base/callback.h" #include "base/files/file_path.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/scoped_native_library.h" #include "base/threading/simple_thread.h" #include "services/shell/native_runner.h" @@ -18,7 +19,6 @@ class TaskRunner; } -namespace mojo { namespace shell { // An implementation of |NativeRunner| that loads/runs the given app (from the @@ -42,11 +42,11 @@ void Run() override; base::FilePath app_path_; - InterfaceRequest<mojom::ShellClient> request_; + mojom::ShellClientRequest request_; base::Callback<bool(void)> app_completed_callback_runner_; base::ScopedNativeLibrary app_library_; - scoped_ptr<base::DelegateSimpleThread> thread_; + std::unique_ptr<base::DelegateSimpleThread> thread_; DISALLOW_COPY_AND_ASSIGN(InProcessNativeRunner); }; @@ -57,7 +57,7 @@ : launch_process_runner_(launch_process_runner) {} ~InProcessNativeRunnerFactory() override {} - scoped_ptr<NativeRunner> Create(const base::FilePath& app_path) override; + std::unique_ptr<NativeRunner> Create(const base::FilePath& app_path) override; private: base::TaskRunner* const launch_process_runner_; @@ -66,6 +66,5 @@ }; } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_RUNNER_HOST_IN_PROCESS_NATIVE_RUNNER_H_
diff --git a/services/shell/runner/host/in_process_native_runner_unittest.cc b/services/shell/runner/host/in_process_native_runner_unittest.cc index 2191d9b..8f67967 100644 --- a/services/shell/runner/host/in_process_native_runner_unittest.cc +++ b/services/shell/runner/host/in_process_native_runner_unittest.cc
@@ -6,7 +6,6 @@ #include "testing/gtest/include/gtest/gtest.h" -namespace mojo { namespace shell { TEST(InProcessNativeRunnerTest, NotStarted) { @@ -15,4 +14,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/runner/host/linux_sandbox.cc b/services/shell/runner/host/linux_sandbox.cc index f9e549e..24461a5 100644 --- a/services/shell/runner/host/linux_sandbox.cc +++ b/services/shell/runner/host/linux_sandbox.cc
@@ -28,7 +28,6 @@ using sandbox::syscall_broker::BrokerFilePermission; -namespace mojo { namespace shell { namespace { @@ -166,4 +165,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/runner/host/linux_sandbox.h b/services/shell/runner/host/linux_sandbox.h index 11f878a..bd1880a5 100644 --- a/services/shell/runner/host/linux_sandbox.h +++ b/services/shell/runner/host/linux_sandbox.h
@@ -13,7 +13,6 @@ #include "sandbox/linux/bpf_dsl/policy.h" #include "sandbox/linux/syscall_broker/broker_process.h" -namespace mojo { namespace shell { // Encapsulates all tasks related to raising the sandbox for mojo runner. @@ -48,6 +47,5 @@ }; } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_RUNNER_HOST_LINUX_SANDBOX_H_
diff --git a/services/shell/runner/host/mach_broker.cc b/services/shell/runner/host/mach_broker.cc index fd3f0fb..7f1cd45 100644 --- a/services/shell/runner/host/mach_broker.cc +++ b/services/shell/runner/host/mach_broker.cc
@@ -7,7 +7,6 @@ #include "base/logging.h" #include "base/memory/singleton.h" -namespace mojo { namespace shell { namespace { @@ -42,4 +41,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/runner/host/mach_broker.h b/services/shell/runner/host/mach_broker.h index 7ae5cd4..64fa63a 100644 --- a/services/shell/runner/host/mach_broker.h +++ b/services/shell/runner/host/mach_broker.h
@@ -11,7 +11,6 @@ template <typename T> struct DefaultSingletonTraits; } -namespace mojo { namespace shell { // A global singleton |MachBroker| is used by the shell to provide access to @@ -49,6 +48,5 @@ }; } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_RUNNER_HOST_MACH_BROKER_H_
diff --git a/services/shell/runner/host/native_application_support.cc b/services/shell/runner/host/native_application_support.cc index c9ab6fd5..cb21374 100644 --- a/services/shell/runner/host/native_application_support.cc +++ b/services/shell/runner/host/native_application_support.cc
@@ -13,7 +13,6 @@ #include "mojo/platform_handle/platform_handle_private_thunks.h" #include "mojo/public/platform/native/system_thunks.h" -namespace mojo { namespace shell { namespace { @@ -49,9 +48,8 @@ return app_library; } -bool RunNativeApplication( - base::NativeLibrary app_library, - InterfaceRequest<mojom::ShellClient> request) { +bool RunNativeApplication(base::NativeLibrary app_library, + mojom::ShellClientRequest request) { // Tolerate |app_library| being null, to make life easier for callers. if (!app_library) return false; @@ -106,4 +104,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/runner/host/native_application_support.h b/services/shell/runner/host/native_application_support.h index 9d41f34..2f8df699 100644 --- a/services/shell/runner/host/native_application_support.h +++ b/services/shell/runner/host/native_application_support.h
@@ -13,8 +13,6 @@ class FilePath; } -namespace mojo { -class Application; namespace shell { // Loads the native Mojo application from the DSO specified by |app_path|. @@ -33,9 +31,8 @@ // true if |MojoMain()| was called (even if it returns an error), and false // otherwise. bool RunNativeApplication(base::NativeLibrary app_library, - InterfaceRequest<mojom::ShellClient> request); + mojom::ShellClientRequest request); } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_RUNNER_HOST_NATIVE_APPLICATION_SUPPORT_H_
diff --git a/services/shell/runner/host/out_of_process_native_runner.cc b/services/shell/runner/host/out_of_process_native_runner.cc index 95196f6..eeeb234 100644 --- a/services/shell/runner/host/out_of_process_native_runner.cc +++ b/services/shell/runner/host/out_of_process_native_runner.cc
@@ -12,12 +12,12 @@ #include "base/callback_helpers.h" #include "base/files/file_util.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "base/task_runner.h" #include "services/shell/runner/common/client_util.h" #include "services/shell/runner/host/child_process_host.h" #include "services/shell/runner/host/in_process_native_runner.h" -namespace mojo { namespace shell { OutOfProcessNativeRunner::OutOfProcessNativeRunner( @@ -66,11 +66,10 @@ : launch_process_runner_(launch_process_runner), delegate_(delegate) {} OutOfProcessNativeRunnerFactory::~OutOfProcessNativeRunnerFactory() {} -scoped_ptr<shell::NativeRunner> OutOfProcessNativeRunnerFactory::Create( +std::unique_ptr<NativeRunner> OutOfProcessNativeRunnerFactory::Create( const base::FilePath& app_path) { - return make_scoped_ptr( + return base::WrapUnique( new OutOfProcessNativeRunner(launch_process_runner_, delegate_)); } } // namespace shell -} // namespace mojo
diff --git a/services/shell/runner/host/out_of_process_native_runner.h b/services/shell/runner/host/out_of_process_native_runner.h index b4754e6..d141c90 100644 --- a/services/shell/runner/host/out_of_process_native_runner.h +++ b/services/shell/runner/host/out_of_process_native_runner.h
@@ -7,19 +7,18 @@ #include <stdint.h> +#include <memory> #include <string> #include "base/callback.h" #include "base/files/file_path.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "services/shell/native_runner.h" namespace base { class TaskRunner; } -namespace mojo { namespace shell { class ChildProcessHost; @@ -50,7 +49,7 @@ base::FilePath app_path_; base::Closure app_completed_callback_; - scoped_ptr<ChildProcessHost> child_process_host_; + std::unique_ptr<ChildProcessHost> child_process_host_; DISALLOW_COPY_AND_ASSIGN(OutOfProcessNativeRunner); }; @@ -61,7 +60,7 @@ NativeRunnerDelegate* delegate); ~OutOfProcessNativeRunnerFactory() override; - scoped_ptr<NativeRunner> Create(const base::FilePath& app_path) override; + std::unique_ptr<NativeRunner> Create(const base::FilePath& app_path) override; private: base::TaskRunner* const launch_process_runner_; @@ -71,6 +70,5 @@ }; } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_
diff --git a/services/shell/runner/init.cc b/services/shell/runner/init.cc index cf89033..7283997 100644 --- a/services/shell/runner/init.cc +++ b/services/shell/runner/init.cc
@@ -24,7 +24,6 @@ #include <unistd.h> #endif -namespace mojo { namespace shell { void InitializeLogging() { @@ -85,4 +84,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/runner/init.h b/services/shell/runner/init.h index 4ce8528..dced60d 100644 --- a/services/shell/runner/init.h +++ b/services/shell/runner/init.h
@@ -7,7 +7,6 @@ #include "base/native_library.h" -namespace mojo { namespace shell { // Initialization routines shared by desktop and Android main functions. @@ -20,6 +19,5 @@ void CallLibraryEarlyInitialization(base::NativeLibrary app_library); } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_RUNNER_INIT_H_
diff --git a/services/shell/shell.cc b/services/shell/shell.cc index 25db56b4..35049dd 100644 --- a/services/shell/shell.cc +++ b/services/shell/shell.cc
@@ -31,9 +31,10 @@ #include "services/shell/public/interfaces/shell_client.mojom.h" #include "url/gurl.h" -namespace mojo { namespace shell { + namespace { + const char kCatalogName[] = "mojo:catalog"; const char kShellName[] = "mojo:shell"; const char kCapabilityClass_UserID[] = "user_id"; @@ -43,7 +44,7 @@ void EmptyResolverCallback(mojom::ResolveResultPtr result) {} -} +} // namespace Identity CreateShellIdentity() { return Identity(kShellName, mojom::kRootUserID); @@ -136,10 +137,12 @@ } Instance* parent() { return parent_; } + void AddChild(Instance* child) { children_.insert(child); child->parent_ = this; } + void RemoveChild(Instance* child) { auto it = children_.find(child); DCHECK(it != children_.end()); @@ -147,7 +150,7 @@ child->parent_ = nullptr; } - void ConnectToClient(scoped_ptr<ConnectParams> params) { + void ConnectToClient(std::unique_ptr<ConnectParams> params) { CHECK(shell_client_.is_bound()); params->connect_callback().Run(mojom::ConnectResult::SUCCEEDED, identity_.user_id(), id_); @@ -189,7 +192,7 @@ void StartWithFilePath(const base::FilePath& path) { CHECK(!shell_client_); - scoped_ptr<NativeRunner> runner = + std::unique_ptr<NativeRunner> runner = shell_->native_runner_factory_->Create(path); bool start_sandboxed = false; mojom::ShellClientPtr client = runner->Start( @@ -241,7 +244,7 @@ if (!ValidateCapabilities(target, callback)) return; - scoped_ptr<ConnectParams> params(new ConnectParams); + std::unique_ptr<ConnectParams> params(new ConnectParams); params->set_source(identity_); params->set_target(target); params->set_remote_interfaces(std::move(remote_interfaces)); @@ -412,9 +415,9 @@ const CapabilitySpec capability_spec_; const bool allow_any_application_; mojom::ShellClientPtr shell_client_; - Binding<mojom::PIDReceiver> pid_receiver_binding_; - BindingSet<mojom::Connector> connectors_; - BindingSet<mojom::Shell> shell_bindings_; + mojo::Binding<mojom::PIDReceiver> pid_receiver_binding_; + mojo::BindingSet<mojom::Connector> connectors_; + mojo::BindingSet<mojom::Shell> shell_bindings_; NativeRunner* runner_ = nullptr; base::ProcessId pid_ = base::kNullProcessId; Instance* parent_ = nullptr; @@ -439,12 +442,12 @@ //////////////////////////////////////////////////////////////////////////////// // Shell, public: -Shell::Shell(scoped_ptr<NativeRunnerFactory> native_runner_factory, +Shell::Shell(std::unique_ptr<NativeRunnerFactory> native_runner_factory, mojom::ShellClientPtr catalog) : native_runner_factory_(std::move(native_runner_factory)), weak_ptr_factory_(this) { mojom::ShellClientPtr client; - mojom::ShellClientRequest request = GetProxy(&client); + mojom::ShellClientRequest request = mojo::GetProxy(&client); Instance* instance = CreateInstance(Identity(), CreateShellIdentity(), GetPermissiveCapabilities()); instance->StartWithClient(std::move(client)); @@ -467,26 +470,26 @@ instance_quit_callback_ = callback; } -void Shell::Connect(scoped_ptr<ConnectParams> params) { +void Shell::Connect(std::unique_ptr<ConnectParams> params) { Connect(std::move(params), nullptr); } mojom::ShellClientRequest Shell::InitInstanceForEmbedder( const std::string& name) { - scoped_ptr<ConnectParams> params(new ConnectParams); + std::unique_ptr<ConnectParams> params(new ConnectParams); Identity embedder_identity(name, mojom::kRootUserID); params->set_source(embedder_identity); params->set_target(embedder_identity); mojom::ShellClientPtr client; - mojom::ShellClientRequest request = GetProxy(&client); + mojom::ShellClientRequest request = mojo::GetProxy(&client); Connect(std::move(params), std::move(client)); return request; } -void Shell::SetLoaderForName(scoped_ptr<Loader> loader, +void Shell::SetLoaderForName(std::unique_ptr<Loader> loader, const std::string& name) { auto it = name_to_loader_.find(name); if (it != name_to_loader_.end()) @@ -525,7 +528,7 @@ // TODO(beng): this doesn't work anymore. // Seed the catalog with manifest info for the shell & catalog. - shell::mojom::ShellResolverPtr resolver; + mojom::ShellResolverPtr resolver; shell_connection_->connector()->ConnectToInterface(kCatalogName, &resolver); resolver->ResolveMojoName(kCatalogName, base::Bind(&EmptyResolverCallback)); resolver->ResolveMojoName(kShellName, base::Bind(&EmptyResolverCallback)); @@ -552,7 +555,7 @@ instance_quit_callback_.Run(identity); } -void Shell::Connect(scoped_ptr<ConnectParams> params, +void Shell::Connect(std::unique_ptr<ConnectParams> params, mojom::ShellClientPtr client) { TRACE_EVENT_INSTANT1("mojo_shell", "Shell::Connect", TRACE_EVENT_SCOPE_THREAD, "original_name", @@ -577,10 +580,10 @@ std::string name = params->target().name(); mojom::ShellResolver* resolver_raw = resolver.get(); resolver_raw->ResolveMojoName( - name, - base::Bind(&Shell::OnGotResolvedName, weak_ptr_factory_.GetWeakPtr(), - base::Passed(std::move(resolver)), base::Passed(¶ms), - base::Passed(&client))); + name, base::Bind(&shell::Shell::OnGotResolvedName, + weak_ptr_factory_.GetWeakPtr(), + base::Passed(std::move(resolver)), base::Passed(¶ms), + base::Passed(&client))); } Shell::Instance* Shell::GetExistingInstance(const Identity& identity) const { @@ -606,7 +609,7 @@ }); } -bool Shell::ConnectToExistingInstance(scoped_ptr<ConnectParams>* params) { +bool Shell::ConnectToExistingInstance(std::unique_ptr<ConnectParams>* params) { Instance* instance = GetExistingInstance((*params)->target()); if (instance) instance->ConnectToClient(std::move(*params)); @@ -634,7 +637,7 @@ void Shell::AddInstanceListener(mojom::InstanceListenerPtr listener) { // TODO(beng): filter instances provided by those visible to this client. - Array<mojom::InstanceInfoPtr> instances; + mojo::Array<mojom::InstanceInfoPtr> instances; for (auto& instance : identity_to_instance_) instances.push_back(instance.second->CreateInstanceInfo()); listener->SetExistingInstances(std::move(instances)); @@ -661,10 +664,9 @@ ConnectToInterface(this, source_identity, shell_client_factory_identity, &factory); mojom::ShellClientFactory* factory_interface = factory.get(); - factory.set_connection_error_handler( - base::Bind(&Shell::OnShellClientFactoryLost, - weak_ptr_factory_.GetWeakPtr(), - shell_client_factory_identity)); + factory.set_connection_error_handler(base::Bind( + &shell::Shell::OnShellClientFactoryLost, weak_ptr_factory_.GetWeakPtr(), + shell_client_factory_identity)); shell_client_factories_[shell_client_factory_identity] = std::move(factory); return factory_interface; } @@ -677,7 +679,7 @@ } void Shell::OnGotResolvedName(mojom::ShellResolverPtr resolver, - scoped_ptr<ConnectParams> params, + std::unique_ptr<ConnectParams> params, mojom::ShellClientPtr client, mojom::ResolveResultPtr result) { std::string instance_name = params->target().instance(); @@ -748,7 +750,7 @@ std::move(request)); } else { instance->StartWithFilePath( - util::UrlToFilePath(result->package_url.To<GURL>())); + mojo::util::UrlToFilePath(result->package_url.To<GURL>())); } } } @@ -787,4 +789,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/shell.gyp b/services/shell/shell.gyp index 778ebbe..e738bef 100644 --- a/services/shell/shell.gyp +++ b/services/shell/shell.gyp
@@ -53,7 +53,6 @@ 'public/cpp/lib/shell_connection.cc', 'public/cpp/message_loop_ref.h', 'public/cpp/names.h', - 'public/cpp/shell.h', 'public/cpp/shell_client.h', 'public/cpp/shell_connection.h', ],
diff --git a/services/shell/shell.h b/services/shell/shell.h index 85379b7..fc17adf 100644 --- a/services/shell/shell.h +++ b/services/shell/shell.h
@@ -6,10 +6,10 @@ #define SERVICES_SHELL_SHELL_H_ #include <map> +#include <memory> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/interface_ptr_set.h" @@ -27,9 +27,8 @@ #include "services/shell/public/interfaces/shell_client_factory.mojom.h" #include "services/shell/public/interfaces/shell_resolver.mojom.h" -namespace mojo { -class ShellConnection; namespace shell { +class ShellConnection; // Creates an identity for the Shell, used when the Shell connects to // applications. @@ -57,7 +56,7 @@ // |file_task_runner| provides access to a thread to perform file copy // operations on. This may be null only in testing environments where // applications are loaded via Loader implementations. - Shell(scoped_ptr<NativeRunnerFactory> native_runner_factory, + Shell(std::unique_ptr<NativeRunnerFactory> native_runner_factory, mojom::ShellClientPtr catalog); ~Shell() override; @@ -69,7 +68,7 @@ // Completes a connection between a source and target application as defined // by |params|, exchanging InterfaceProviders between them. If no existing // instance of the target application is running, one will be loaded. - void Connect(scoped_ptr<ConnectParams> params); + void Connect(std::unique_ptr<ConnectParams> params); // Creates a new Instance identified as |name|. This is intended for use by // the Shell's embedder to register itself with the shell. This must only be @@ -77,12 +76,13 @@ mojom::ShellClientRequest InitInstanceForEmbedder(const std::string& name); // Sets the default Loader to be used if not overridden by SetLoaderForName(). - void set_default_loader(scoped_ptr<Loader> loader) { + void set_default_loader(std::unique_ptr<Loader> loader) { default_loader_ = std::move(loader); } // Sets a Loader to be used for a specific name. - void SetLoaderForName(scoped_ptr<Loader> loader, const std::string& name); + void SetLoaderForName(std::unique_ptr<Loader> loader, + const std::string& name); private: class Instance; @@ -107,7 +107,8 @@ // If |client| is not null, there must not be an instance of the target // application already running. The shell will create a new instance and use // |client| to control it. - void Connect(scoped_ptr<ConnectParams> params, mojom::ShellClientPtr client); + void Connect(std::unique_ptr<ConnectParams> params, + mojom::ShellClientPtr client); // Returns a running instance matching |identity|. This might be an instance // running as a different user if one is available that services all users. @@ -118,7 +119,7 @@ // Attempt to complete the connection requested by |params| by connecting to // an existing instance. If there is an existing instance, |params| is taken, // and this function returns true. - bool ConnectToExistingInstance(scoped_ptr<ConnectParams>* params); + bool ConnectToExistingInstance(std::unique_ptr<ConnectParams>* params); Instance* CreateInstance(const Identity& source, const Identity& target, @@ -142,7 +143,7 @@ // new application instance. This may be null. // |result| contains the result of the resolve operation. void OnGotResolvedName(mojom::ShellResolverPtr resolver, - scoped_ptr<ConnectParams> params, + std::unique_ptr<ConnectParams> params, mojom::ShellClientPtr client, mojom::ResolveResultPtr result); @@ -162,7 +163,7 @@ // Loader management. // Loaders are chosen in the order they are listed here. std::map<std::string, Loader*> name_to_loader_; - scoped_ptr<Loader> default_loader_; + std::unique_ptr<Loader> default_loader_; std::map<Identity, Instance*> identity_to_instance_; @@ -174,12 +175,12 @@ // Counter used to assign ids to client factories. uint32_t shell_client_factory_id_counter_; - InterfacePtrSet<mojom::InstanceListener> instance_listeners_; + mojo::InterfacePtrSet<mojom::InstanceListener> instance_listeners_; base::Callback<void(const Identity&)> instance_quit_callback_; - scoped_ptr<NativeRunnerFactory> native_runner_factory_; - std::vector<scoped_ptr<NativeRunner>> native_runners_; - scoped_ptr<ShellConnection> shell_connection_; + std::unique_ptr<NativeRunnerFactory> native_runner_factory_; + std::vector<std::unique_ptr<NativeRunner>> native_runners_; + std::unique_ptr<ShellConnection> shell_connection_; base::WeakPtrFactory<Shell> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(Shell); @@ -188,6 +189,5 @@ mojom::Connector::ConnectCallback EmptyConnectCallback(); } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_SHELL_H_
diff --git a/services/shell/standalone/context.cc b/services/shell/standalone/context.cc index 0588726..e144b3c8 100644 --- a/services/shell/standalone/context.cc +++ b/services/shell/standalone/context.cc
@@ -15,7 +15,6 @@ #include "base/files/file_path.h" #include "base/lazy_instance.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/path_service.h" #include "base/process/process_info.h" #include "base/run_loop.h" @@ -47,14 +46,13 @@ #include "services/shell/runner/host/mach_broker.h" #endif -namespace mojo { namespace shell { namespace { // Used to ensure we only init once. class Setup { public: - Setup() { edk::Init(); } + Setup() { mojo::edk::Init(); } ~Setup() {} @@ -62,33 +60,33 @@ DISALLOW_COPY_AND_ASSIGN(Setup); }; -class TracingInterfaceProvider : public shell::mojom::InterfaceProvider { +class TracingInterfaceProvider : public mojom::InterfaceProvider { public: TracingInterfaceProvider(Tracer* tracer, - shell::mojom::InterfaceProviderRequest request) + mojom::InterfaceProviderRequest request) : tracer_(tracer), binding_(this, std::move(request)) {} ~TracingInterfaceProvider() override {} - // shell::mojom::InterfaceProvider: + // mojom::InterfaceProvider: void GetInterface(const mojo::String& interface_name, - ScopedMessagePipeHandle client_handle) override { + mojo::ScopedMessagePipeHandle client_handle) override { if (tracer_ && interface_name == tracing::TraceProvider::Name_) { tracer_->ConnectToProvider( - MakeRequest<tracing::TraceProvider>(std::move(client_handle))); + mojo::MakeRequest<tracing::TraceProvider>(std::move(client_handle))); } } private: Tracer* tracer_; - StrongBinding<shell::mojom::InterfaceProvider> binding_; + mojo::StrongBinding<mojom::InterfaceProvider> binding_; DISALLOW_COPY_AND_ASSIGN(TracingInterfaceProvider); }; const size_t kMaxBlockingPoolThreads = 3; -scoped_ptr<base::Thread> CreateIOThread(const char* name) { - scoped_ptr<base::Thread> thread(new base::Thread(name)); +std::unique_ptr<base::Thread> CreateIOThread(const char* name) { + std::unique_ptr<base::Thread> thread(new base::Thread(name)); base::Thread::Options options; options.message_loop_type = base::MessageLoop::TYPE_IO; thread->StartWithOptions(options); @@ -120,7 +118,7 @@ setup.Get(); } -void Context::Init(scoped_ptr<InitParams> init_params) { +void Context::Init(std::unique_ptr<InitParams> init_params) { TRACE_EVENT0("mojo_shell", "Context::Init"); const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); @@ -142,13 +140,13 @@ init_edk_ = !init_params || init_params->init_edk; if (init_edk_) { - edk::InitIPCSupport(this, io_thread_->task_runner().get()); + mojo::edk::InitIPCSupport(this, io_thread_->task_runner().get()); #if defined(OS_MACOSX) - edk::SetMachPortProvider(MachBroker::GetInstance()->port_provider()); + mojo::edk::SetMachPortProvider(MachBroker::GetInstance()->port_provider()); #endif } - scoped_ptr<NativeRunnerFactory> runner_factory; + std::unique_ptr<NativeRunnerFactory> runner_factory; if (command_line.HasSwitch(switches::kSingleProcess)) { #if defined(COMPONENT_BUILD) LOG(ERROR) << "Running Mojo in single process component build, which isn't " @@ -163,7 +161,7 @@ runner_factory.reset(new OutOfProcessNativeRunnerFactory( blocking_pool_.get(), native_runner_delegate)); } - scoped_ptr<catalog::Store> store; + std::unique_ptr<catalog::Store> store; if (init_params) store = std::move(init_params->catalog_store); catalog_.reset( @@ -171,14 +169,14 @@ shell_.reset(new Shell(std::move(runner_factory), catalog_->TakeShellClient())); - shell::mojom::InterfaceProviderPtr tracing_remote_interfaces; - shell::mojom::InterfaceProviderPtr tracing_local_interfaces; + mojom::InterfaceProviderPtr tracing_remote_interfaces; + mojom::InterfaceProviderPtr tracing_local_interfaces; new TracingInterfaceProvider(&tracer_, GetProxy(&tracing_local_interfaces)); - scoped_ptr<ConnectParams> params(new ConnectParams); + std::unique_ptr<ConnectParams> params(new ConnectParams); params->set_source(CreateShellIdentity()); params->set_target(Identity("mojo:tracing", mojom::kRootUserID)); - params->set_remote_interfaces(GetProxy(&tracing_remote_interfaces)); + params->set_remote_interfaces(mojo::GetProxy(&tracing_remote_interfaces)); params->set_local_interfaces(std::move(tracing_local_interfaces)); shell_->Connect(std::move(params)); @@ -196,7 +194,7 @@ tracing::StartupPerformanceDataCollectorPtr collector; tracing_remote_interfaces->GetInterface( tracing::StartupPerformanceDataCollector::Name_, - GetProxy(&collector).PassMessagePipe()); + mojo::GetProxy(&collector).PassMessagePipe()); #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) // CurrentProcessInfo::CreationTime is only defined on some platforms. const base::Time creation_time = base::CurrentProcessInfo::CreationTime(); @@ -220,8 +218,8 @@ TRACE_EVENT0("mojo_shell", "Context::Shutdown"); // Post a task in case OnShutdownComplete is called synchronously. - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(edk::ShutdownIPCSupport)); + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(mojo::edk::ShutdownIPCSupport)); // We'll quit when we get OnShutdownComplete(). base::MessageLoop::current()->Run(); } @@ -250,16 +248,15 @@ void Context::Run(const std::string& name) { shell_->SetInstanceQuitCallback(base::Bind(&OnInstanceQuit, name)); - shell::mojom::InterfaceProviderPtr remote_interfaces; - shell::mojom::InterfaceProviderPtr local_interfaces; + mojom::InterfaceProviderPtr remote_interfaces; + mojom::InterfaceProviderPtr local_interfaces; - scoped_ptr<ConnectParams> params(new ConnectParams); + std::unique_ptr<ConnectParams> params(new ConnectParams); params->set_source(CreateShellIdentity()); params->set_target(Identity(name, mojom::kRootUserID)); - params->set_remote_interfaces(GetProxy(&remote_interfaces)); + params->set_remote_interfaces(mojo::GetProxy(&remote_interfaces)); params->set_local_interfaces(std::move(local_interfaces)); shell_->Connect(std::move(params)); } } // namespace shell -} // namespace mojo
diff --git a/services/shell/standalone/context.h b/services/shell/standalone/context.h index eba6233..9db0b424 100644 --- a/services/shell/standalone/context.h +++ b/services/shell/standalone/context.h
@@ -5,10 +5,11 @@ #ifndef SERVICES_SHELL_STANDALONE_CONTEXT_H_ #define SERVICES_SHELL_STANDALONE_CONTEXT_H_ +#include <memory> + #include "base/callback_forward.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/threading/thread.h" #include "base/time/time.h" #include "mojo/edk/embedder/process_delegate.h" @@ -24,19 +25,18 @@ class Store; } -namespace mojo { namespace shell { class NativeRunnerDelegate; // The "global" context for the shell's main process. -class Context : public edk::ProcessDelegate { +class Context : public mojo::edk::ProcessDelegate { public: struct InitParams { InitParams(); ~InitParams(); NativeRunnerDelegate* native_runner_delegate = nullptr; - scoped_ptr<catalog::Store> catalog_store; + std::unique_ptr<catalog::Store> catalog_store; // If true the edk is initialized. bool init_edk = true; }; @@ -48,7 +48,7 @@ // This must be called with a message loop set up for the current thread, // which must remain alive until after Shutdown() is called. - void Init(scoped_ptr<InitParams> init_params); + void Init(std::unique_ptr<InitParams> init_params); // If Init() was called and succeeded, this must be called before destruction. void Shutdown(); @@ -59,21 +59,21 @@ Shell* shell() { return shell_.get(); } private: - // edk::ProcessDelegate: + // mojo::edk::ProcessDelegate: void OnShutdownComplete() override; // Runs the app specified by |name|. void Run(const std::string& name); scoped_refptr<base::SingleThreadTaskRunner> shell_runner_; - scoped_ptr<base::Thread> io_thread_; + std::unique_ptr<base::Thread> io_thread_; scoped_refptr<base::SequencedWorkerPool> blocking_pool_; // Ensure this is destructed before task_runners_ since it owns a message pipe // that needs the IO thread to destruct cleanly. Tracer tracer_; - scoped_ptr<catalog::Factory> catalog_; - scoped_ptr<Shell> shell_; + std::unique_ptr<catalog::Factory> catalog_; + std::unique_ptr<Shell> shell_; base::Time main_entry_time_; bool init_edk_ = false; @@ -81,6 +81,5 @@ }; } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_STANDALONE_CONTEXT_H_
diff --git a/services/shell/standalone/desktop/launcher_process.cc b/services/shell/standalone/desktop/launcher_process.cc index 7da7176..4403b227 100644 --- a/services/shell/standalone/desktop/launcher_process.cc +++ b/services/shell/standalone/desktop/launcher_process.cc
@@ -20,7 +20,6 @@ #include "services/shell/standalone/context.h" #include "services/shell/switches.h" -namespace mojo { namespace shell { int LauncherProcessMain() { @@ -56,4 +55,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/standalone/desktop/launcher_process.h b/services/shell/standalone/desktop/launcher_process.h index 5c7288a..13cdf51 100644 --- a/services/shell/standalone/desktop/launcher_process.h +++ b/services/shell/standalone/desktop/launcher_process.h
@@ -7,13 +7,11 @@ #include "base/callback_forward.h" -namespace mojo { namespace shell { // Main method for the launcher process. int LauncherProcessMain(); } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_STANDALONE_LAUNCHER_PROCESS_H_
diff --git a/services/shell/standalone/desktop/main.cc b/services/shell/standalone/desktop/main.cc index 31404c8..9a27ab2 100644 --- a/services/shell/standalone/desktop/main.cc +++ b/services/shell/standalone/desktop/main.cc
@@ -5,5 +5,5 @@ #include "services/shell/standalone/desktop/main_helper.h" int main(int argc, char** argv) { - return mojo::shell::StandaloneShellMain(argc, argv); + return shell::StandaloneShellMain(argc, argv); }
diff --git a/services/shell/standalone/desktop/main_helper.cc b/services/shell/standalone/desktop/main_helper.cc index ac58fd0..d51f421 100644 --- a/services/shell/standalone/desktop/main_helper.cc +++ b/services/shell/standalone/desktop/main_helper.cc
@@ -25,7 +25,6 @@ #include <unistd.h> #endif -namespace mojo { namespace shell { int StandaloneShellMain(int argc, char** argv) { @@ -48,4 +47,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/standalone/desktop/main_helper.h b/services/shell/standalone/desktop/main_helper.h index 2070ab7..f326957 100644 --- a/services/shell/standalone/desktop/main_helper.h +++ b/services/shell/standalone/desktop/main_helper.h
@@ -5,13 +5,11 @@ #ifndef SERVICES_SHELL_STANDALONE_DESKTOP_MAIN_HELPER_H #define SERVICES_SHELL_STANDALONE_DESKTOP_MAIN_HELPER_H -namespace mojo { namespace shell { // Helper method to start Mojo standalone shell code. int StandaloneShellMain(int argc, char** argv); } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_STANDALONE_DESKTOP_MAIN_HELPER_H
diff --git a/services/shell/standalone/tracer.cc b/services/shell/standalone/tracer.cc index fb34d01..cffcfe0 100644 --- a/services/shell/standalone/tracer.cc +++ b/services/shell/standalone/tracer.cc
@@ -16,7 +16,6 @@ #include "base/trace_event/trace_config.h" #include "base/trace_event/trace_event.h" -namespace mojo { namespace shell { Tracer::Tracer() @@ -161,4 +160,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/standalone/tracer.h b/services/shell/standalone/tracer.h index 18e27f5..173f3ab 100644 --- a/services/shell/standalone/tracer.h +++ b/services/shell/standalone/tracer.h
@@ -8,6 +8,7 @@ #include <stddef.h> #include <stdio.h> +#include <memory> #include <string> #include "base/callback.h" @@ -17,7 +18,6 @@ #include "services/tracing/public/cpp/trace_provider_impl.h" #include "services/tracing/public/interfaces/tracing.mojom.h" -namespace mojo { namespace shell { // Tracer collects tracing data from base/trace_event and from externally @@ -77,7 +77,7 @@ // Set when connected to the tracing service. tracing::TraceCollectorPtr coordinator_; - scoped_ptr<mojo::common::DataPipeDrainer> drainer_; + std::unique_ptr<mojo::common::DataPipeDrainer> drainer_; mojo::TraceProviderImpl trace_provider_impl_; // Whether we're currently tracing. @@ -97,6 +97,5 @@ }; } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_STANDALONE_TRACER_H_
diff --git a/services/shell/switches.cc b/services/shell/switches.cc index 7547ea2..10dc430 100644 --- a/services/shell/switches.cc +++ b/services/shell/switches.cc
@@ -4,7 +4,7 @@ #include "services/shell/switches.h" -namespace mojo { +namespace shell { namespace switches { // Disables the sandbox for debugging. @@ -14,4 +14,4 @@ const char kSingleProcess[] = "single-process"; } // namespace switches -} // namespace mojo +} // namespace shell
diff --git a/services/shell/switches.h b/services/shell/switches.h index 5fc0ce66..1a442e1 100644 --- a/services/shell/switches.h +++ b/services/shell/switches.h
@@ -8,7 +8,7 @@ #include <set> #include <string> -namespace mojo { +namespace shell { namespace switches { // All switches in alphabetical order. The switches should be documented @@ -17,6 +17,6 @@ extern const char kSingleProcess[]; } // namespace switches -} // namespace mojo +} // namespace shell #endif // SERVICES_SHELL_SWITCHES_H_
diff --git a/services/shell/tests/connect/connect_test.mojom b/services/shell/tests/connect/connect_test.mojom index 949fe429..5a9efcda 100644 --- a/services/shell/tests/connect/connect_test.mojom +++ b/services/shell/tests/connect/connect_test.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. -module mojo.shell.test.mojom; +module shell.test.mojom; import "services/shell/public/interfaces/connector.mojom"; @@ -36,8 +36,8 @@ // Attempts to connect to mojo:connect_test_class_app as |user_id|. // The callback takes the connection response result, and the identity // mojo:connect_test_class_app was run as, which should match |user_id|. - ConnectToClassAppAsDifferentUser(mojo.shell.mojom.Identity target) => - (int32 connection_result, mojo.shell.mojom.Identity target); + ConnectToClassAppAsDifferentUser(shell.mojom.Identity target) => + (int32 connection_result, shell.mojom.Identity target); }; interface ClientProcessTest { @@ -46,7 +46,7 @@ // the result of the connection, and the identity of the app that the caller // can use to connect to this app as well. LaunchAndConnectToProcess() => - (int32 connection_result, mojo.shell.mojom.Identity target); + (int32 connection_result, shell.mojom.Identity target); }; struct ConnectionState {
diff --git a/services/shell/tests/connect/connect_test_app.cc b/services/shell/tests/connect/connect_test_app.cc index 39b01dc..66e9f3a 100644 --- a/services/shell/tests/connect/connect_test_app.cc +++ b/services/shell/tests/connect/connect_test_app.cc
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <memory> + #include "base/bind.h" #include "base/guid.h" #include "base/macros.h" @@ -16,9 +18,10 @@ #include "services/shell/public/interfaces/connector.mojom.h" #include "services/shell/tests/connect/connect_test.mojom.h" -namespace mojo { namespace shell { + namespace { + void QuitLoop(base::RunLoop* loop) { loop->Quit(); } @@ -28,7 +31,8 @@ *string = response; loop->Quit(); } -} + +} // namespace using GetTitleCallback = test::mojom::ConnectTestService::GetTitleCallback; @@ -46,7 +50,7 @@ ~ConnectTestApp() override {} private: - // mojo::ShellClient: + // shell::ShellClient: void Initialize(Connector* connector, const Identity& identity, uint32_t id) override { connector_ = connector; @@ -116,7 +120,7 @@ void ConnectToAllowedAppInBlockedPackage( const ConnectToAllowedAppInBlockedPackageCallback& callback) override { base::RunLoop run_loop; - scoped_ptr<Connection> connection = + std::unique_ptr<Connection> connection = connector_->Connect("mojo:connect_test_a"); connection->SetConnectionLostClosure( base::Bind(&ConnectTestApp::OnConnectionBlocked, @@ -136,7 +140,7 @@ } void ConnectToClassInterface( const ConnectToClassInterfaceCallback& callback) override { - scoped_ptr<Connection> connection = + std::unique_ptr<Connection> connection = connector_->Connect("mojo:connect_test_class_app"); test::mojom::ClassInterfacePtr class_interface; connection->GetInterface(&class_interface); @@ -171,7 +175,7 @@ mojom::IdentityPtr target, const ConnectToClassAppAsDifferentUserCallback& callback) override { Connector::ConnectParams params(target.To<Identity>()); - scoped_ptr<Connection> connection = connector_->Connect(¶ms); + std::unique_ptr<Connection> connection = connector_->Connect(¶ms); { base::RunLoop loop; connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop)); @@ -205,22 +209,20 @@ Connector* connector_ = nullptr; Identity identity_; - uint32_t id_ = shell::mojom::kInvalidInstanceID; - BindingSet<test::mojom::ConnectTestService> bindings_; - BindingSet<test::mojom::StandaloneApp> standalone_bindings_; - BindingSet<test::mojom::BlockedInterface> blocked_bindings_; - BindingSet<test::mojom::UserIdTest> user_id_test_bindings_; + uint32_t id_ = mojom::kInvalidInstanceID; + mojo::BindingSet<test::mojom::ConnectTestService> bindings_; + mojo::BindingSet<test::mojom::StandaloneApp> standalone_bindings_; + mojo::BindingSet<test::mojom::BlockedInterface> blocked_bindings_; + mojo::BindingSet<test::mojom::UserIdTest> user_id_test_bindings_; test::mojom::ExposedInterfacePtr caller_; DISALLOW_COPY_AND_ASSIGN(ConnectTestApp); }; } // namespace shell -} // namespace mojo - MojoResult MojoMain(MojoHandle shell_handle) { - MojoResult rv = mojo::ApplicationRunner( - new mojo::shell::ConnectTestApp).Run(shell_handle); + MojoResult rv = + shell::ApplicationRunner(new shell::ConnectTestApp).Run(shell_handle); return rv; }
diff --git a/services/shell/tests/connect/connect_test_app_manifest.json b/services/shell/tests/connect/connect_test_app_manifest.json index 7c459227..bae4bf9 100644 --- a/services/shell/tests/connect/connect_test_app_manifest.json +++ b/services/shell/tests/connect/connect_test_app_manifest.json
@@ -7,7 +7,7 @@ "mojo:connect_test_a": { "interfaces": ["*"] }, "mojo:connect_test_class_app": { "classes": [ "class" ], - "interfaces": ["mojo::shell::test::mojom::ConnectTestService"] + "interfaces": ["shell::test::mojom::ConnectTestService"] }, "mojo:shell": { "classes": [ "user_id" ] } }
diff --git a/services/shell/tests/connect/connect_test_class_app.cc b/services/shell/tests/connect/connect_test_class_app.cc index fe75a63..d64d38b 100644 --- a/services/shell/tests/connect/connect_test_class_app.cc +++ b/services/shell/tests/connect/connect_test_class_app.cc
@@ -15,7 +15,6 @@ #include "services/shell/public/interfaces/connector.mojom.h" #include "services/shell/tests/connect/connect_test.mojom.h" -namespace mojo { namespace shell { using GetTitleCallback = test::mojom::ConnectTestService::GetTitleCallback; @@ -31,7 +30,7 @@ ~ConnectTestClassApp() override {} private: - // mojo::ShellClient: + // shell::ShellClient: void Initialize(Connector* connector, const Identity& identity, uint32_t id) override { connector_ = connector; @@ -84,18 +83,17 @@ Connector* connector_ = nullptr; Identity identity_; std::set<Connection*> inbound_connections_; - BindingSet<test::mojom::ConnectTestService> bindings_; - BindingSet<test::mojom::ClassInterface> class_interface_bindings_; + mojo::BindingSet<test::mojom::ConnectTestService> bindings_; + mojo::BindingSet<test::mojom::ClassInterface> class_interface_bindings_; DISALLOW_COPY_AND_ASSIGN(ConnectTestClassApp); }; } // namespace shell -} // namespace mojo MojoResult MojoMain(MojoHandle shell_handle) { - MojoResult rv = mojo::ApplicationRunner( - new mojo::shell::ConnectTestClassApp).Run(shell_handle); + MojoResult rv = shell::ApplicationRunner(new shell::ConnectTestClassApp) + .Run(shell_handle); return rv; }
diff --git a/services/shell/tests/connect/connect_test_class_app_manifest.json b/services/shell/tests/connect/connect_test_class_app_manifest.json index 9bb7bb8f..3f40e1ad 100644 --- a/services/shell/tests/connect/connect_test_class_app_manifest.json +++ b/services/shell/tests/connect/connect_test_class_app_manifest.json
@@ -4,7 +4,7 @@ "display_name": "Connect Test Class App", "capabilities": { "provided": { - "class": ["mojo::shell::test::mojom::ClassInterface"] + "class": ["shell::test::mojom::ClassInterface"] } } }
diff --git a/services/shell/tests/connect/connect_test_driver.cc b/services/shell/tests/connect/connect_test_driver.cc index 3c3fcebe..55329928 100644 --- a/services/shell/tests/connect/connect_test_driver.cc +++ b/services/shell/tests/connect/connect_test_driver.cc
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <memory> + #include "base/at_exit.h" #include "base/command_line.h" #include "base/macros.h" @@ -15,25 +17,26 @@ #include "services/shell/tests/connect/connect_test.mojom.h" #include "services/shell/tests/util.h" -using mojo::shell::test::mojom::ClientProcessTest; -using mojo::shell::test::mojom::ClientProcessTestRequest; +using shell::test::mojom::ClientProcessTest; +using shell::test::mojom::ClientProcessTestRequest; namespace { -class Driver : public mojo::ShellClient, - public mojo::InterfaceFactory<ClientProcessTest>, +class Driver : public shell::ShellClient, + public shell::InterfaceFactory<ClientProcessTest>, public ClientProcessTest { public: Driver() {} ~Driver() override {} private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override { connector_ = connector; } - bool AcceptConnection(mojo::Connection* connection) override { + bool AcceptConnection(shell::Connection* connection) override { connection->AddInterface<ClientProcessTest>(this); return true; } @@ -43,8 +46,8 @@ _exit(1); } - // mojo::InterfaceFactory<ConnectTestService>: - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<ConnectTestService>: + void Create(shell::Connection* connection, ClientProcessTestRequest request) override { bindings_.AddBinding(this, std::move(request)); } @@ -53,23 +56,21 @@ void LaunchAndConnectToProcess( const LaunchAndConnectToProcessCallback& callback) override { base::Process process; - scoped_ptr<mojo::Connection> connection = - mojo::shell::test::LaunchAndConnectToProcess( + std::unique_ptr<shell::Connection> connection = + shell::test::LaunchAndConnectToProcess( #if defined(OS_WIN) "connect_test_exe.exe", #else "connect_test_exe", #endif - mojo::Identity("exe:connect_test_exe", - mojo::shell::mojom::kInheritUserID), - connector_, - &process); + shell::Identity("exe:connect_test_exe", + shell::mojom::kInheritUserID), + connector_, &process); callback.Run(static_cast<int32_t>(connection->GetResult()), - mojo::shell::mojom::Identity::From( - connection->GetRemoteIdentity())); + shell::mojom::Identity::From(connection->GetRemoteIdentity())); } - mojo::Connector* connector_ = nullptr; + shell::Connector* connector_ = nullptr; mojo::BindingSet<ClientProcessTest> bindings_; DISALLOW_COPY_AND_ASSIGN(Driver); @@ -81,8 +82,8 @@ base::AtExitManager at_exit; base::CommandLine::Init(argc, argv); - mojo::shell::InitializeLogging(); + shell::InitializeLogging(); Driver driver; - return mojo::shell::TestNativeMain(&driver); + return shell::TestNativeMain(&driver); }
diff --git a/services/shell/tests/connect/connect_test_exe.cc b/services/shell/tests/connect/connect_test_exe.cc index 4bf6fd5..460b518e 100644 --- a/services/shell/tests/connect/connect_test_exe.cc +++ b/services/shell/tests/connect/connect_test_exe.cc
@@ -13,31 +13,32 @@ #include "services/shell/runner/init.h" #include "services/shell/tests/connect/connect_test.mojom.h" -using mojo::shell::test::mojom::ConnectTestService; -using mojo::shell::test::mojom::ConnectTestServiceRequest; +using shell::test::mojom::ConnectTestService; +using shell::test::mojom::ConnectTestServiceRequest; namespace { -class Target : public mojo::ShellClient, - public mojo::InterfaceFactory<ConnectTestService>, +class Target : public shell::ShellClient, + public shell::InterfaceFactory<ConnectTestService>, public ConnectTestService { public: Target() {} ~Target() override {} private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override { identity_ = identity; } - bool AcceptConnection(mojo::Connection* connection) override { + bool AcceptConnection(shell::Connection* connection) override { connection->AddInterface<ConnectTestService>(this); return true; } - // mojo::InterfaceFactory<ConnectTestService>: - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<ConnectTestService>: + void Create(shell::Connection* connection, ConnectTestServiceRequest request) override { bindings_.AddBinding(this, std::move(request)); } @@ -50,7 +51,7 @@ callback.Run(identity_.instance()); } - mojo::Identity identity_; + shell::Identity identity_; mojo::BindingSet<ConnectTestService> bindings_; DISALLOW_COPY_AND_ASSIGN(Target); @@ -62,8 +63,8 @@ base::AtExitManager at_exit; base::CommandLine::Init(argc, argv); - mojo::shell::InitializeLogging(); + shell::InitializeLogging(); Target target; - return mojo::shell::TestNativeMain(&target); + return shell::TestNativeMain(&target); }
diff --git a/services/shell/tests/connect/connect_test_package.cc b/services/shell/tests/connect/connect_test_package.cc index 5e3d083..356b392c 100644 --- a/services/shell/tests/connect/connect_test_package.cc +++ b/services/shell/tests/connect/connect_test_package.cc
@@ -5,6 +5,7 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <utility> #include "base/bind.h" @@ -25,13 +26,15 @@ // implementing ShellClientFactory; that these applications can be specified by // the package's manifest and are thus registered with the PackageManager. -namespace mojo { namespace shell { + namespace { + void QuitLoop(base::RunLoop* loop) { loop->Quit(); } -} + +} // namespace using GetTitleCallback = test::mojom::ConnectTestService::GetTitleCallback; @@ -57,7 +60,7 @@ } private: - // mojo::ShellClient: + // shell::ShellClient: void Initialize(Connector* connector, const Identity& identity, uint32_t id) override { connector_ = connector; @@ -123,7 +126,7 @@ mojom::IdentityPtr target, const ConnectToClassAppAsDifferentUserCallback& callback) override { Connector::ConnectParams params(target.To<Identity>()); - scoped_ptr<Connection> connection = connector_->Connect(¶ms); + std::unique_ptr<Connection> connection = connector_->Connect(¶ms); { base::RunLoop loop; connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop)); @@ -153,9 +156,9 @@ const std::string title_; mojom::ShellClientRequest request_; test::mojom::ExposedInterfacePtr caller_; - BindingSet<test::mojom::ConnectTestService> bindings_; - BindingSet<test::mojom::BlockedInterface> blocked_bindings_; - BindingSet<test::mojom::UserIdTest> user_id_test_bindings_; + mojo::BindingSet<test::mojom::ConnectTestService> bindings_; + mojo::BindingSet<test::mojom::BlockedInterface> blocked_bindings_; + mojo::BindingSet<test::mojom::UserIdTest> user_id_test_bindings_; DISALLOW_COPY_AND_ASSIGN(ProvidedShellClient); }; @@ -171,7 +174,7 @@ ~ConnectTestShellClient() override {} private: - // mojo::ShellClient: + // shell::ShellClient: void Initialize(Connector* connector, const Identity& identity, uint32_t id) override { identity_ = identity; @@ -199,7 +202,7 @@ // mojom::ShellClientFactory: void CreateShellClient(mojom::ShellClientRequest request, - const String& name) override { + const mojo::String& name) override { if (name == "mojo:connect_test_a") new ProvidedShellClient("A", std::move(request)); else if (name == "mojo:connect_test_b") @@ -220,19 +223,17 @@ } Identity identity_; - std::vector<scoped_ptr<ShellClient>> delegates_; - BindingSet<mojom::ShellClientFactory> shell_client_factory_bindings_; - BindingSet<test::mojom::ConnectTestService> bindings_; + std::vector<std::unique_ptr<ShellClient>> delegates_; + mojo::BindingSet<mojom::ShellClientFactory> shell_client_factory_bindings_; + mojo::BindingSet<test::mojom::ConnectTestService> bindings_; DISALLOW_COPY_AND_ASSIGN(ConnectTestShellClient); }; } // namespace shell -} // namespace mojo - MojoResult MojoMain(MojoHandle shell_handle) { - MojoResult rv = mojo::ApplicationRunner( - new mojo::shell::ConnectTestShellClient).Run(shell_handle); + MojoResult rv = shell::ApplicationRunner(new shell::ConnectTestShellClient) + .Run(shell_handle); return rv; }
diff --git a/services/shell/tests/connect/connect_test_singleton_app.cc b/services/shell/tests/connect/connect_test_singleton_app.cc index ff23fdc..51a2a3e 100644 --- a/services/shell/tests/connect/connect_test_singleton_app.cc +++ b/services/shell/tests/connect/connect_test_singleton_app.cc
@@ -7,7 +7,6 @@ #include "services/shell/public/cpp/application_runner.h" #include "services/shell/public/cpp/shell_client.h" -namespace mojo { namespace shell { class ConnectTestSingletonApp : public ShellClient { @@ -16,7 +15,7 @@ ~ConnectTestSingletonApp() override {} private: - // mojo::ShellClient: + // shell::ShellClient: void Initialize(Connector* connector, const Identity& identity, uint32_t id) override {} bool AcceptConnection(Connection* connection) override { @@ -27,10 +26,9 @@ }; } // namespace shell -} // namespace mojo MojoResult MojoMain(MojoHandle shell_handle) { - return mojo::ApplicationRunner( - new mojo::shell::ConnectTestSingletonApp).Run(shell_handle); + return shell::ApplicationRunner(new shell::ConnectTestSingletonApp) + .Run(shell_handle); }
diff --git a/services/shell/tests/connect/connect_unittest.cc b/services/shell/tests/connect/connect_unittest.cc index e94da0e5e..b144468 100644 --- a/services/shell/tests/connect/connect_unittest.cc +++ b/services/shell/tests/connect/connect_unittest.cc
@@ -5,6 +5,7 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <utility> #include "base/bind.h" @@ -22,9 +23,10 @@ // implementing ShellClientFactory; that these applications can be specified by // the package's manifest and are thus registered with the PackageManager. -namespace mojo { namespace shell { + namespace { + const char kTestPackageName[] = "mojo:connect_test_package"; const char kTestAppName[] = "mojo:connect_test_app"; const char kTestAppAName[] = "mojo:connect_test_a"; @@ -35,14 +37,16 @@ void ReceiveOneString(std::string* out_string, base::RunLoop* loop, - const String& in_string) { + const mojo::String& in_string) { *out_string = in_string; loop->Quit(); } -void ReceiveTwoStrings(std::string* out_string_1, std::string* out_string_2, +void ReceiveTwoStrings(std::string* out_string_1, + std::string* out_string_2, base::RunLoop* loop, - const String& in_string_1, const String& in_string_2) { + const mojo::String& in_string_1, + const mojo::String& in_string_2) { *out_string_1 = in_string_1; *out_string_2 = in_string_2; loop->Quit(); @@ -53,7 +57,7 @@ base::RunLoop* loop, int32_t in_result, mojom::IdentityPtr in_identity) { - *out_result = static_cast<shell::mojom::ConnectResult>(in_result); + *out_result = static_cast<mojom::ConnectResult>(in_result); *out_target = in_identity.To<Identity>(); loop->Quit(); } @@ -64,7 +68,7 @@ } // namespace -class ConnectTest : public mojo::test::ShellTest, +class ConnectTest : public test::ShellTest, public InterfaceFactory<test::mojom::ExposedInterface>, public test::mojom::ExposedInterface { public: @@ -72,8 +76,8 @@ ~ConnectTest() override {} protected: - scoped_ptr<Connection> ConnectTo(Connector::ConnectParams* params) { - scoped_ptr<Connection> connection = connector()->Connect(params); + std::unique_ptr<Connection> ConnectTo(Connector::ConnectParams* params) { + std::unique_ptr<Connection> connection = connector()->Connect(params); base::RunLoop loop; connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop)); loop.Run(); @@ -104,14 +108,15 @@ } private: - // mojo::test::ShellTest: + // test::ShellTest: void SetUp() override { - mojo::test::ShellTest::SetUp(); + test::ShellTest::SetUp(); // We need to connect to the package first to force the shell to read the // package app's manifest and register aliases for the applications it // provides. test::mojom::ConnectTestServicePtr root_service; - scoped_ptr<Connection> connection = connector()->Connect(kTestPackageName); + std::unique_ptr<Connection> connection = + connector()->Connect(kTestPackageName); connection->GetInterface(&root_service); base::RunLoop run_loop; std::string root_name; @@ -125,6 +130,7 @@ test::mojom::ExposedInterfaceRequest request) override { bindings_.AddBinding(this, std::move(request)); } + void ConnectionAccepted(test::mojom::ConnectionStatePtr state) override { connection_state_ = std::move(state); ping_callback_.Run(); @@ -133,7 +139,7 @@ base::Closure ping_callback_; test::mojom::ConnectionStatePtr connection_state_; - BindingSet<test::mojom::ExposedInterface> bindings_; + mojo::BindingSet<test::mojom::ExposedInterface> bindings_; DISALLOW_COPY_AND_ASSIGN(ConnectTest); }; @@ -141,7 +147,7 @@ // Ensure the connection was properly established and that a round trip // method call/response is completed. TEST_F(ConnectTest, Connect) { - scoped_ptr<Connection> connection = connector()->Connect(kTestAppName); + std::unique_ptr<Connection> connection = connector()->Connect(kTestAppName); test::mojom::ConnectTestServicePtr service; connection->GetInterface(&service); base::RunLoop run_loop; @@ -157,8 +163,8 @@ TEST_F(ConnectTest, Instances) { Connector::ConnectParams params_a( Identity(kTestAppName, mojom::kInheritUserID, "A")); - scoped_ptr<Connection> connection_a1 = ConnectTo(¶ms_a); - scoped_ptr<Connection> connection_a2 = ConnectTo(¶ms_a); + std::unique_ptr<Connection> connection_a1 = ConnectTo(¶ms_a); + std::unique_ptr<Connection> connection_a2 = ConnectTo(¶ms_a); std::string instance_a1, instance_a2; test::mojom::ConnectTestServicePtr service_a1; { @@ -178,7 +184,7 @@ Connector::ConnectParams params_b( Identity(kTestAppName, mojom::kInheritUserID, "B")); - scoped_ptr<Connection> connection_b = ConnectTo(¶ms_b); + std::unique_ptr<Connection> connection_b = ConnectTo(¶ms_b); std::string instance_b; test::mojom::ConnectTestServicePtr service_b; { @@ -199,7 +205,7 @@ // Connect to an app with no manifest-supplied instance name provided by a // package, the instance name must be derived from the application instance // name, not the package. - scoped_ptr<Connection> connection = connector()->Connect(kTestAppName); + std::unique_ptr<Connection> connection = connector()->Connect(kTestAppName); { base::RunLoop loop; connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop)); @@ -220,7 +226,7 @@ // BlockedInterface should not be exposed to this application because it is not // in our CapabilityFilter whitelist. TEST_F(ConnectTest, BlockedInterface) { - scoped_ptr<Connection> connection = connector()->Connect(kTestAppName); + std::unique_ptr<Connection> connection = connector()->Connect(kTestAppName); base::RunLoop run_loop; test::mojom::BlockedInterfacePtr blocked; connection->GetInterface(&blocked); @@ -233,7 +239,7 @@ // Connects to an app provided by a package. TEST_F(ConnectTest, PackagedApp) { - scoped_ptr<Connection> connection = connector()->Connect(kTestAppAName); + std::unique_ptr<Connection> connection = connector()->Connect(kTestAppAName); test::mojom::ConnectTestServicePtr service_a; connection->GetInterface(&service_a); base::RunLoop run_loop; @@ -252,7 +258,7 @@ // allowed regardless of the target's CapabilityFilter with respect to the // package. TEST_F(ConnectTest, BlockedPackage) { - scoped_ptr<Connection> connection = connector()->Connect(kTestAppName); + std::unique_ptr<Connection> connection = connector()->Connect(kTestAppName); test::mojom::StandaloneAppPtr standalone_app; connection->GetInterface(&standalone_app); base::RunLoop run_loop; @@ -266,7 +272,7 @@ // BlockedInterface should not be exposed to this application because it is not // in our CapabilityFilter whitelist. TEST_F(ConnectTest, PackagedApp_BlockedInterface) { - scoped_ptr<Connection> connection = connector()->Connect(kTestAppAName); + std::unique_ptr<Connection> connection = connector()->Connect(kTestAppAName); base::RunLoop run_loop; test::mojom::BlockedInterfacePtr blocked; connection->GetInterface(&blocked); @@ -277,7 +283,7 @@ // Connection to another application provided by the same package, blocked // because it's not in the capability filter whitelist. TEST_F(ConnectTest, BlockedPackagedApplication) { - scoped_ptr<Connection> connection = connector()->Connect(kTestAppBName); + std::unique_ptr<Connection> connection = connector()->Connect(kTestAppBName); test::mojom::ConnectTestServicePtr service_b; connection->GetInterface(&service_b); base::RunLoop run_loop; @@ -289,7 +295,7 @@ } TEST_F(ConnectTest, CapabilityClasses) { - scoped_ptr<Connection> connection = connector()->Connect(kTestAppName); + std::unique_ptr<Connection> connection = connector()->Connect(kTestAppName); test::mojom::StandaloneAppPtr standalone_app; connection->GetInterface(&standalone_app); std::string string1, string2; @@ -302,10 +308,10 @@ } TEST_F(ConnectTest, ConnectAsDifferentUser_Allowed) { - scoped_ptr<Connection> connection = connector()->Connect(kTestAppName); + std::unique_ptr<Connection> connection = connector()->Connect(kTestAppName); test::mojom::UserIdTestPtr user_id_test; connection->GetInterface(&user_id_test); - shell::mojom::ConnectResult result; + mojom::ConnectResult result; Identity target(kTestClassAppName, base::GenerateGUID()); Identity result_identity; { @@ -315,15 +321,15 @@ base::Bind(&ReceiveConnectionResult, &result, &result_identity, &loop)); loop.Run(); } - EXPECT_EQ(result, shell::mojom::ConnectResult::SUCCEEDED); + EXPECT_EQ(result, mojom::ConnectResult::SUCCEEDED); EXPECT_EQ(target, result_identity); } TEST_F(ConnectTest, ConnectAsDifferentUser_Blocked) { - scoped_ptr<Connection> connection = connector()->Connect(kTestAppAName); + std::unique_ptr<Connection> connection = connector()->Connect(kTestAppAName); test::mojom::UserIdTestPtr user_id_test; connection->GetInterface(&user_id_test); - shell::mojom::ConnectResult result; + mojom::ConnectResult result; Identity target(kTestClassAppName, base::GenerateGUID()); Identity result_identity; { @@ -333,17 +339,18 @@ base::Bind(&ReceiveConnectionResult, &result, &result_identity, &loop)); loop.Run(); } - EXPECT_EQ(shell::mojom::ConnectResult::ACCESS_DENIED, result); + EXPECT_EQ(mojom::ConnectResult::ACCESS_DENIED, result); EXPECT_FALSE(target == result_identity); } // There are various other tests (shell, lifecycle) that test valid client // process specifications. This is the only one for blocking. TEST_F(ConnectTest, ConnectToClientProcess_Blocked) { - scoped_ptr<Connection> connection = connector()->Connect(kTestDriverName); + std::unique_ptr<Connection> connection = + connector()->Connect(kTestDriverName); test::mojom::ClientProcessTestPtr client_process_test; connection->GetInterface(&client_process_test); - shell::mojom::ConnectResult result; + mojom::ConnectResult result; Identity result_identity; { base::RunLoop loop; @@ -351,7 +358,7 @@ base::Bind(&ReceiveConnectionResult, &result, &result_identity, &loop)); loop.Run(); } - EXPECT_EQ(shell::mojom::ConnectResult::ACCESS_DENIED, result); + EXPECT_EQ(mojom::ConnectResult::ACCESS_DENIED, result); } // Verifies that a client with the "all_users" capability class can receive @@ -363,7 +370,7 @@ const std::string singleton_userid = base::GenerateGUID(); Connector::ConnectParams params( Identity(kTestSingletonAppName, singleton_userid)); - scoped_ptr<Connection> connection = connector()->Connect(¶ms); + std::unique_ptr<Connection> connection = connector()->Connect(¶ms); { base::RunLoop loop; connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop)); @@ -372,7 +379,7 @@ } // This connects using the current client's user_id. It should be bound to the // same service started above, with the same shell-generated user id. - scoped_ptr<Connection> inherit_connection = + std::unique_ptr<Connection> inherit_connection = connector()->Connect(kTestSingletonAppName); { base::RunLoop loop; @@ -389,11 +396,11 @@ // Connect to a standalone application. { test::mojom::ConnectTestServicePtr service; - scoped_ptr<Connection> connection = connector()->Connect(kTestAppName); + std::unique_ptr<Connection> connection = connector()->Connect(kTestAppName); connection->GetInterface(&service); connection->AddInterface<test::mojom::ExposedInterface>(this); - uint32_t remote_id = shell::mojom::kInvalidInstanceID; + uint32_t remote_id = mojom::kInvalidInstanceID; { base::RunLoop run_loop; EXPECT_TRUE(connection->IsPending()); @@ -419,11 +426,12 @@ // Connect to an application provided by a package. { test::mojom::ConnectTestServicePtr service_a; - scoped_ptr<Connection> connection = connector()->Connect(kTestAppAName); + std::unique_ptr<Connection> connection = + connector()->Connect(kTestAppAName); connection->GetInterface(&service_a); connection->AddInterface<test::mojom::ExposedInterface>(this); - uint32_t remote_id = shell::mojom::kInvalidInstanceID; + uint32_t remote_id = mojom::kInvalidInstanceID; { base::RunLoop run_loop; EXPECT_TRUE(connection->IsPending()); @@ -449,4 +457,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/tests/connect/connect_unittests_manifest.json b/services/shell/tests/connect/connect_unittests_manifest.json index ea650b1..8e171d2 100644 --- a/services/shell/tests/connect/connect_unittests_manifest.json +++ b/services/shell/tests/connect/connect_unittests_manifest.json
@@ -7,19 +7,19 @@ "mojo:connect_test_package": { "interfaces": [ "*" ] }, "mojo:connect_test_app": { "interfaces": [ - "mojo::shell::test::mojom::ConnectTestService", - "mojo::shell::test::mojom::StandaloneApp", - "mojo::shell::test::mojom::UserIdTest" + "shell::test::mojom::ConnectTestService", + "shell::test::mojom::StandaloneApp", + "shell::test::mojom::UserIdTest" ] }, - "exe:connect_test_driver": { - "interfaces": [ "mojo::shell::test::mojom::ClientProcessTest" ] + "exe:connect_test_driver": { + "interfaces": [ "shell::test::mojom::ClientProcessTest" ] }, "mojo:connect_test_a": { "interfaces": [ - "mojo::shell::test::mojom::ConnectTestService", - "mojo::shell::test::mojom::StandaloneApp", - "mojo::shell::test::mojom::UserIdTest" + "shell::test::mojom::ConnectTestService", + "shell::test::mojom::StandaloneApp", + "shell::test::mojom::UserIdTest" ] }, "mojo:shell": { "classes": [ "instance_name", "user_id" ] }
diff --git a/services/shell/tests/lifecycle/app.cc b/services/shell/tests/lifecycle/app.cc index d16357e20..7bcf044 100644 --- a/services/shell/tests/lifecycle/app.cc +++ b/services/shell/tests/lifecycle/app.cc
@@ -7,8 +7,8 @@ #include "services/shell/tests/lifecycle/app_client.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::shell::test::AppClient* app = new mojo::shell::test::AppClient; - mojo::ApplicationRunner runner(app); + shell::test::AppClient* app = new shell::test::AppClient; + shell::ApplicationRunner runner(app); app->set_runner(&runner); return runner.Run(shell_handle); }
diff --git a/services/shell/tests/lifecycle/app_client.cc b/services/shell/tests/lifecycle/app_client.cc index 256ef16..14d0c3a 100644 --- a/services/shell/tests/lifecycle/app_client.cc +++ b/services/shell/tests/lifecycle/app_client.cc
@@ -6,7 +6,6 @@ #include "services/shell/public/cpp/shell_connection.h" -namespace mojo { namespace shell { namespace test { @@ -15,12 +14,12 @@ : connection_(new ShellConnection(this, std::move(request))) {} AppClient::~AppClient() {} -bool AppClient::AcceptConnection(mojo::Connection* connection) { +bool AppClient::AcceptConnection(Connection* connection) { connection->AddInterface<LifecycleControl>(this); return true; } -void AppClient::Create(mojo::Connection* connection, +void AppClient::Create(Connection* connection, LifecycleControlRequest request) { bindings_.AddBinding(this, std::move(request)); } @@ -55,6 +54,5 @@ } // namespace test } // namespace shell -} // namespace mojo
diff --git a/services/shell/tests/lifecycle/app_client.h b/services/shell/tests/lifecycle/app_client.h index f461dc9..efeb3c7 100644 --- a/services/shell/tests/lifecycle/app_client.h +++ b/services/shell/tests/lifecycle/app_client.h
@@ -5,6 +5,8 @@ #ifndef SERVICES_SHELL_TESTS_LIFECYCLE_APP_CLIENT_H_ #define SERVICES_SHELL_TESTS_LIFECYCLE_APP_CLIENT_H_ +#include <memory> + #include "base/bind.h" #include "base/macros.h" #include "mojo/public/cpp/bindings/binding_set.h" @@ -14,13 +16,12 @@ #include "services/shell/public/interfaces/shell_client.mojom.h" #include "services/shell/tests/lifecycle/lifecycle_unittest.mojom.h" -using LifecycleControl = mojo::shell::test::mojom::LifecycleControl; -using LifecycleControlRequest = - mojo::shell::test::mojom::LifecycleControlRequest; +using LifecycleControl = shell::test::mojom::LifecycleControl; +using LifecycleControlRequest = shell::test::mojom::LifecycleControlRequest; -namespace mojo { -class ShellConnection; namespace shell { +class ShellConnection; + namespace test { class AppClient : public ShellClient, @@ -51,14 +52,13 @@ void BindingLost(); ApplicationRunner* runner_ = nullptr; - BindingSet<LifecycleControl> bindings_; - scoped_ptr<ShellConnection> connection_; + mojo::BindingSet<LifecycleControl> bindings_; + std::unique_ptr<ShellConnection> connection_; DISALLOW_COPY_AND_ASSIGN(AppClient); }; } // namespace test } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_TESTS_LIFECYCLE_APP_CLIENT_H_
diff --git a/services/shell/tests/lifecycle/lifecycle_exe.cc b/services/shell/tests/lifecycle/lifecycle_exe.cc index f4d56ea..4ce73d4d 100644 --- a/services/shell/tests/lifecycle/lifecycle_exe.cc +++ b/services/shell/tests/lifecycle/lifecycle_exe.cc
@@ -16,8 +16,8 @@ base::AtExitManager at_exit; base::CommandLine::Init(argc, argv); - mojo::shell::InitializeLogging(); + shell::InitializeLogging(); - mojo::shell::test::AppClient client; - return mojo::shell::TestNativeMain(&client); + shell::test::AppClient client; + return shell::TestNativeMain(&client); }
diff --git a/services/shell/tests/lifecycle/lifecycle_unittest.cc b/services/shell/tests/lifecycle/lifecycle_unittest.cc index ca8f03f..d702ee8 100644 --- a/services/shell/tests/lifecycle/lifecycle_unittest.cc +++ b/services/shell/tests/lifecycle/lifecycle_unittest.cc
@@ -2,9 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <memory> + #include "base/bind.h" #include "base/command_line.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/process/process.h" #include "base/run_loop.h" #include "services/shell/public/cpp/identity.h" @@ -13,8 +16,8 @@ #include "services/shell/tests/lifecycle/lifecycle_unittest.mojom.h" #include "services/shell/tests/util.h" -namespace mojo { namespace shell { + namespace { const char kTestAppName[] = "mojo:lifecycle_unittest_app"; @@ -35,7 +38,7 @@ } struct Instance { - Instance() : id(shell::mojom::kInvalidInstanceID), pid(0) {} + Instance() : id(mojom::kInvalidInstanceID), pid(0) {} Instance(const Identity& identity, uint32_t id, uint32_t pid) : identity(identity), id(id), pid(pid) {} @@ -66,7 +69,8 @@ private: // mojom::InstanceListener: - void SetExistingInstances(Array<mojom::InstanceInfoPtr> instances) override { + void SetExistingInstances( + mojo::Array<mojom::InstanceInfoPtr> instances) override { for (const auto& instance : instances) { Instance i(instance->identity.To<Identity>(), instance->id, instance->pid); @@ -110,7 +114,7 @@ // The initial set of instances. std::map<std::string, Instance> initial_instances_; - Binding<mojom::InstanceListener> binding_; + mojo::Binding<mojom::InstanceListener> binding_; base::RunLoop* loop_; // Set when the client wants to wait for this object to track the destruction @@ -120,23 +124,23 @@ DISALLOW_COPY_AND_ASSIGN(InstanceState); }; -} +} // namespace -class LifecycleTest : public mojo::test::ShellTest { +class LifecycleTest : public test::ShellTest { public: LifecycleTest() : ShellTest(kTestName) {} ~LifecycleTest() override {} protected: - // mojo::test::ShellTest: + // test::ShellTest: void SetUp() override { - mojo::test::ShellTest::SetUp(); + test::ShellTest::SetUp(); InitPackage(); instances_ = TrackInstances(); } void TearDown() override { instances_.reset(); - mojo::test::ShellTest::TearDown(); + test::ShellTest::TearDown(); } bool CanRunCrashTest() { @@ -187,7 +191,7 @@ } private: - scoped_ptr<InstanceState> TrackInstances() { + std::unique_ptr<InstanceState> TrackInstances() { mojom::ShellPtr shell; connector()->ConnectToInterface("mojo:shell", &shell); mojom::InstanceListenerPtr listener; @@ -195,10 +199,10 @@ InstanceState* state = new InstanceState(GetProxy(&listener), &loop); shell->AddInstanceListener(std::move(listener)); loop.Run(); - return make_scoped_ptr(state); + return base::WrapUnique(state); } - scoped_ptr<InstanceState> instances_; + std::unique_ptr<InstanceState> instances_; DISALLOW_COPY_AND_ASSIGN(LifecycleTest); }; @@ -441,7 +445,7 @@ TEST_F(LifecycleTest, ShutdownTree) { // Verifies that Instances are destroyed when their creator is. - scoped_ptr<Connection> parent_connection = + std::unique_ptr<Connection> parent_connection = connector()->Connect(kTestParentName); test::mojom::ParentPtr parent; parent_connection->GetInterface(&parent); @@ -469,4 +473,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/tests/lifecycle/lifecycle_unittest.mojom b/services/shell/tests/lifecycle/lifecycle_unittest.mojom index 2197e3b..212398c 100644 --- a/services/shell/tests/lifecycle/lifecycle_unittest.mojom +++ b/services/shell/tests/lifecycle/lifecycle_unittest.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. -module mojo.shell.test.mojom; +module shell.test.mojom; // An interface implemented by an application exposing different ways for the // application to "shut down" from the caller and shell's perspective.
diff --git a/services/shell/tests/lifecycle/package.cc b/services/shell/tests/lifecycle/package.cc index 3d6b011..8e0c28e 100644 --- a/services/shell/tests/lifecycle/package.cc +++ b/services/shell/tests/lifecycle/package.cc
@@ -3,6 +3,7 @@ // found in the LICENSE file. #include <algorithm> +#include <memory> #include "base/bind.h" #include "base/macros.h" @@ -16,16 +17,16 @@ namespace { -class PackagedApp : public mojo::ShellClient, - public mojo::InterfaceFactory<LifecycleControl>, +class PackagedApp : public shell::ShellClient, + public shell::InterfaceFactory<LifecycleControl>, public LifecycleControl { public: using DestructCallback = base::Callback<void(PackagedApp*)>; - PackagedApp(mojo::shell::mojom::ShellClientRequest request, + PackagedApp(shell::mojom::ShellClientRequest request, const DestructCallback& shell_connection_closed_callback, const DestructCallback& destruct_callback) - : connection_(new mojo::ShellConnection(this, std::move(request))), + : connection_(new shell::ShellConnection(this, std::move(request))), shell_connection_closed_callback_(shell_connection_closed_callback), destruct_callback_(destruct_callback) { bindings_.set_connection_error_handler(base::Bind(&PackagedApp::BindingLost, @@ -36,14 +37,14 @@ } private: - // mojo::ShellClient: - bool AcceptConnection(mojo::Connection* connection) override { + // shell::ShellClient: + bool AcceptConnection(shell::Connection* connection) override { connection->AddInterface<LifecycleControl>(this); return true; } - // mojo::InterfaceFactory<LifecycleControl> - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<LifecycleControl> + void Create(shell::Connection* connection, LifecycleControlRequest request) override { bindings_.AddBinding(this, std::move(request)); } @@ -74,7 +75,7 @@ delete this; } - scoped_ptr<mojo::ShellConnection> connection_; + std::unique_ptr<shell::ShellConnection> connection_; mojo::BindingSet<LifecycleControl> bindings_; // Run when this object's connection to the shell is closed. DestructCallback shell_connection_closed_callback_; @@ -85,32 +86,32 @@ }; class Package - : public mojo::ShellClient, - public mojo::InterfaceFactory<mojo::shell::mojom::ShellClientFactory>, - public mojo::shell::mojom::ShellClientFactory { + : public shell::ShellClient, + public shell::InterfaceFactory<shell::mojom::ShellClientFactory>, + public shell::mojom::ShellClientFactory { public: Package() {} ~Package() override {} - void set_runner(mojo::ApplicationRunner* runner) { + void set_runner(shell::ApplicationRunner* runner) { app_client_.set_runner(runner); } private: - // mojo::shell::test::AppClient: - bool AcceptConnection(mojo::Connection* connection) override { - connection->AddInterface<mojo::shell::mojom::ShellClientFactory>(this); + // shell::test::AppClient: + bool AcceptConnection(shell::Connection* connection) override { + connection->AddInterface<shell::mojom::ShellClientFactory>(this); return app_client_.AcceptConnection(connection); } - // mojo::InterfaceFactory<mojo::shell::mojom::ShellClientFactory>: - void Create(mojo::Connection* connection, - mojo::shell::mojom::ShellClientFactoryRequest request) override { + // shell::InterfaceFactory<shell::mojom::ShellClientFactory>: + void Create(shell::Connection* connection, + shell::mojom::ShellClientFactoryRequest request) override { bindings_.AddBinding(this, std::move(request)); } - // mojo::shell::mojom::ShellClientFactory: - void CreateShellClient(mojo::shell::mojom::ShellClientRequest request, + // shell::mojom::ShellClientFactory: + void CreateShellClient(shell::mojom::ShellClientRequest request, const mojo::String& name) override { ++shell_connection_refcount_; apps_.push_back( @@ -134,9 +135,9 @@ base::MessageLoop::current()->QuitWhenIdle(); } - mojo::shell::test::AppClient app_client_; + shell::test::AppClient app_client_; int shell_connection_refcount_ = 0; - mojo::BindingSet<mojo::shell::mojom::ShellClientFactory> bindings_; + mojo::BindingSet<shell::mojom::ShellClientFactory> bindings_; std::vector<PackagedApp*> apps_; DISALLOW_COPY_AND_ASSIGN(Package); @@ -146,7 +147,7 @@ MojoResult MojoMain(MojoHandle shell_handle) { Package* package = new Package; - mojo::ApplicationRunner runner(package); + shell::ApplicationRunner runner(package); package->set_runner(&runner); return runner.Run(shell_handle); }
diff --git a/services/shell/tests/lifecycle/parent.cc b/services/shell/tests/lifecycle/parent.cc index d302e02..814a752 100644 --- a/services/shell/tests/lifecycle/parent.cc +++ b/services/shell/tests/lifecycle/parent.cc
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <memory> + #include "base/bind.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" @@ -18,10 +20,9 @@ loop->Quit(); } -class Parent - : public mojo::ShellClient, - public mojo::InterfaceFactory<mojo::shell::test::mojom::Parent>, - public mojo::shell::test::mojom::Parent { +class Parent : public shell::ShellClient, + public shell::InterfaceFactory<shell::test::mojom::Parent>, + public shell::test::mojom::Parent { public: Parent() {} ~Parent() override { @@ -32,25 +33,26 @@ private: // ShellClient: - void Initialize(mojo::Connector* connector, const mojo::Identity& identity, + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override { connector_ = connector; } - bool AcceptConnection(mojo::Connection* connection) override { - connection->AddInterface<mojo::shell::test::mojom::Parent>(this); + bool AcceptConnection(shell::Connection* connection) override { + connection->AddInterface<shell::test::mojom::Parent>(this); return true; } - // InterfaceFactory<mojo::shell::test::mojom::Parent>: - void Create(mojo::Connection* connection, - mojo::shell::test::mojom::ParentRequest request) override { + // InterfaceFactory<shell::test::mojom::Parent>: + void Create(shell::Connection* connection, + shell::test::mojom::ParentRequest request) override { parent_bindings_.AddBinding(this, std::move(request)); } // Parent: void ConnectToChild(const ConnectToChildCallback& callback) override { child_connection_ = connector_->Connect("mojo:lifecycle_unittest_app"); - mojo::shell::test::mojom::LifecycleControlPtr lifecycle; + shell::test::mojom::LifecycleControlPtr lifecycle; child_connection_->GetInterface(&lifecycle); { base::RunLoop loop; @@ -65,9 +67,9 @@ base::MessageLoop::current()->QuitWhenIdle(); } - mojo::Connector* connector_; - scoped_ptr<mojo::Connection> child_connection_; - mojo::BindingSet<mojo::shell::test::mojom::Parent> parent_bindings_; + shell::Connector* connector_; + std::unique_ptr<shell::Connection> child_connection_; + mojo::BindingSet<shell::test::mojom::Parent> parent_bindings_; DISALLOW_COPY_AND_ASSIGN(Parent); }; @@ -76,5 +78,5 @@ MojoResult MojoMain(MojoHandle shell_handle) { Parent* parent = new Parent; - return mojo::ApplicationRunner(parent).Run(shell_handle); + return shell::ApplicationRunner(parent).Run(shell_handle); }
diff --git a/services/shell/tests/lifecycle/parent_manifest.json b/services/shell/tests/lifecycle/parent_manifest.json index 25191c8..29975a7 100644 --- a/services/shell/tests/lifecycle/parent_manifest.json +++ b/services/shell/tests/lifecycle/parent_manifest.json
@@ -5,7 +5,7 @@ "capabilities": { "required": { "mojo:lifecycle_unittest_app": { - "interfaces": [ "mojo::shell::test::mojom::LifecycleControl" ] + "interfaces": [ "shell::test::mojom::LifecycleControl" ] } } }
diff --git a/services/shell/tests/loader_unittest.cc b/services/shell/tests/loader_unittest.cc index f9c5954..533ccf6 100644 --- a/services/shell/tests/loader_unittest.cc +++ b/services/shell/tests/loader_unittest.cc
@@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <memory> #include <utility> #include "base/at_exit.h" #include "base/bind.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/memory/scoped_vector.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" @@ -24,7 +26,6 @@ #include "services/shell/tests/test.mojom.h" #include "testing/gtest/include/gtest/gtest.h" -namespace mojo { namespace shell { namespace test { @@ -50,7 +51,7 @@ class TestServiceImpl : public TestService { public: - TestServiceImpl(TestContext* context, InterfaceRequest<TestService> request) + TestServiceImpl(TestContext* context, TestServiceRequest request) : context_(context), binding_(this, std::move(request)) { ++context_->num_impls; } @@ -63,15 +64,15 @@ } // TestService implementation: - void Test(const String& test_string, - const Callback<void()>& callback) override { + void Test(const mojo::String& test_string, + const mojo::Closure& callback) override { context_->last_test_string = test_string; callback.Run(); } private: TestContext* context_; - StrongBinding<TestService> binding_; + mojo::StrongBinding<TestService> binding_; }; class TestClient { @@ -121,7 +122,7 @@ shell_connection_.reset(new ShellConnection(this, std::move(request))); } - // mojo::ShellClient implementation. + // ShellClient implementation. bool AcceptConnection(Connection* connection) override { connection->AddInterface<TestService>(this); last_requestor_name_ = connection->GetRemoteIdentity().name(); @@ -129,12 +130,11 @@ } // InterfaceFactory<TestService> implementation. - void Create(Connection* connection, - InterfaceRequest<TestService> request) override { + void Create(Connection* connection, TestServiceRequest request) override { new TestServiceImpl(context_, std::move(request)); } - scoped_ptr<ShellConnection> shell_connection_; + std::unique_ptr<ShellConnection> shell_connection_; TestContext* context_; int num_loads_; std::string last_requestor_name_; @@ -250,7 +250,7 @@ public: TestAImpl(Connector* connector, TesterContext* test_context, - InterfaceRequest<TestA> request, + TestARequest request, InterfaceFactory<TestC>* factory) : test_context_(test_context), binding_(this, std::move(request)) { connection_ = connector->Connect(kTestBURLString); @@ -279,17 +279,17 @@ test_context_->QuitSoon(); } - scoped_ptr<Connection> connection_; + std::unique_ptr<Connection> connection_; TesterContext* test_context_; TestBPtr b_; - StrongBinding<TestA> binding_; + mojo::StrongBinding<TestA> binding_; }; class TestBImpl : public TestB { public: TestBImpl(Connection* connection, TesterContext* test_context, - InterfaceRequest<TestB> request) + TestBRequest request) : test_context_(test_context), binding_(this, std::move(request)) { connection->GetInterface(&c_); } @@ -302,38 +302,38 @@ } private: - void B(const Callback<void()>& callback) override { + void B(const mojo::Closure& callback) override { test_context_->IncrementNumBCalls(); callback.Run(); } - void CallC(const Callback<void()>& callback) override { + void CallC(const mojo::Closure& callback) override { test_context_->IncrementNumBCalls(); c_->C(callback); } TesterContext* test_context_; TestCPtr c_; - StrongBinding<TestB> binding_; + mojo::StrongBinding<TestB> binding_; }; class TestCImpl : public TestC { public: TestCImpl(Connection* connection, TesterContext* test_context, - InterfaceRequest<TestC> request) + TestCRequest request) : test_context_(test_context), binding_(this, std::move(request)) {} ~TestCImpl() override { test_context_->IncrementNumCDeletes(); } private: - void C(const Callback<void()>& callback) override { + void C(const mojo::Closure& callback) override { test_context_->IncrementNumCCalls(); callback.Run(); } TesterContext* test_context_; - StrongBinding<TestC> binding_; + mojo::StrongBinding<TestC> binding_; }; class Tester : public ShellClient, @@ -348,7 +348,7 @@ private: void Load(const std::string& name, - InterfaceRequest<mojom::ShellClient> request) override { + mojom::ShellClientRequest request) override { app_.reset(new ShellConnection(this, std::move(request))); } @@ -368,30 +368,29 @@ return true; } - void Create(Connection* connection, - InterfaceRequest<TestA> request) override { + void Create(Connection* connection, TestARequest request) override { a_bindings_.push_back( new TestAImpl(app_->connector(), context_, std::move(request), this)); } - void Create(Connection* connection, - InterfaceRequest<TestB> request) override { + void Create(Connection* connection, TestBRequest request) override { new TestBImpl(connection, context_, std::move(request)); } - void Create(Connection* connection, - InterfaceRequest<TestC> request) override { + void Create(Connection* connection, TestCRequest request) override { new TestCImpl(connection, context_, std::move(request)); } TesterContext* context_; - scoped_ptr<ShellConnection> app_; + std::unique_ptr<ShellConnection> app_; std::string requestor_name_; ScopedVector<TestAImpl> a_bindings_; }; -void OnConnect(base::RunLoop* loop, mojom::ConnectResult result, - const String& user_id, uint32_t instance_id) { +void OnConnect(base::RunLoop* loop, + mojom::ConnectResult result, + const mojo::String& user_id, + uint32_t instance_id) { loop->Quit(); } @@ -406,7 +405,7 @@ new catalog::Factory(blocking_pool_.get(), nullptr, nullptr)); shell_.reset(new Shell(nullptr, catalog_->TakeShellClient())); test_loader_ = new TestLoader(&context_); - shell_->set_default_loader(scoped_ptr<Loader>(test_loader_)); + shell_->set_default_loader(std::unique_ptr<Loader>(test_loader_)); TestServicePtr service_proxy; ConnectToInterface(kTestURLString, &service_proxy); @@ -422,7 +421,7 @@ void AddLoaderForName(const std::string& name, const std::string& requestor_name) { shell_->SetLoaderForName( - make_scoped_ptr(new Tester(&tester_context_, requestor_name)), name); + base::WrapUnique(new Tester(&tester_context_, requestor_name)), name); } bool HasRunningInstanceForName(const std::string& name) { @@ -433,19 +432,19 @@ protected: template <typename Interface> void ConnectToInterface(const std::string& name, - InterfacePtr<Interface>* ptr) { + mojo::InterfacePtr<Interface>* ptr) { base::RunLoop loop; mojom::InterfaceProviderPtr remote_interfaces; - scoped_ptr<ConnectParams> params(new ConnectParams); + std::unique_ptr<ConnectParams> params(new ConnectParams); params->set_source(CreateShellIdentity()); params->set_target(Identity(name, mojom::kRootUserID)); - params->set_remote_interfaces(GetProxy(&remote_interfaces)); + params->set_remote_interfaces(mojo::GetProxy(&remote_interfaces)); params->set_connect_callback( base::Bind(&OnConnect, base::Unretained(&loop))); shell_->Connect(std::move(params)); loop.Run(); - mojo::GetInterface(remote_interfaces.get(), ptr); + GetInterface(remote_interfaces.get(), ptr); } base::ShadowingAtExitManager at_exit_; @@ -453,10 +452,11 @@ TesterContext tester_context_; TestContext context_; base::MessageLoop loop_; - scoped_ptr<TestClient> test_client_; - scoped_ptr<catalog::Factory> catalog_; + std::unique_ptr<TestClient> test_client_; + std::unique_ptr<catalog::Factory> catalog_; scoped_refptr<base::SequencedWorkerPool> blocking_pool_; - scoped_ptr<Shell> shell_; + std::unique_ptr<Shell> shell_; + DISALLOW_COPY_AND_ASSIGN(LoaderTest); }; @@ -484,9 +484,9 @@ TestLoader* default_loader = new TestLoader(&context_); TestLoader* name_loader1 = new TestLoader(&context_); TestLoader* name_loader2 = new TestLoader(&context_); - shell.set_default_loader(scoped_ptr<Loader>(default_loader)); - shell.SetLoaderForName(scoped_ptr<Loader>(name_loader1), "test:test1"); - shell.SetLoaderForName(scoped_ptr<Loader>(name_loader2), "test:test1"); + shell.set_default_loader(std::unique_ptr<Loader>(default_loader)); + shell.SetLoaderForName(std::unique_ptr<Loader>(name_loader1), "test:test1"); + shell.SetLoaderForName(std::unique_ptr<Loader>(name_loader2), "test:test1"); } EXPECT_EQ(3, context_.num_loader_deletes); } @@ -495,8 +495,8 @@ TEST_F(LoaderTest, SetLoaders) { TestLoader* default_loader = new TestLoader(&context_); TestLoader* name_loader = new TestLoader(&context_); - shell_->set_default_loader(scoped_ptr<Loader>(default_loader)); - shell_->SetLoaderForName(scoped_ptr<Loader>(name_loader), "test:test1"); + shell_->set_default_loader(std::unique_ptr<Loader>(default_loader)); + shell_->SetLoaderForName(std::unique_ptr<Loader>(name_loader), "test:test1"); // test::test1 should go to name_loader. TestServicePtr test_service; @@ -526,10 +526,10 @@ TEST_F(LoaderTest, TestEndApplicationClosure) { ClosingLoader* loader = new ClosingLoader(); - shell_->SetLoaderForName(scoped_ptr<Loader>(loader), "test:test"); + shell_->SetLoaderForName(std::unique_ptr<Loader>(loader), "test:test"); bool called = false; - scoped_ptr<ConnectParams> params(new ConnectParams); + std::unique_ptr<ConnectParams> params(new ConnectParams); params->set_source(CreateShellIdentity()); params->set_target(Identity("test:test", mojom::kRootUserID)); shell_->SetInstanceQuitCallback( @@ -558,4 +558,3 @@ } // namespace test } // namespace shell -} // namespace mojo
diff --git a/services/shell/tests/shell/driver.cc b/services/shell/tests/shell/driver.cc index 380497d..04ee30f 100644 --- a/services/shell/tests/shell/driver.cc +++ b/services/shell/tests/shell/driver.cc
@@ -4,6 +4,7 @@ #include <stdint.h> +#include <memory> #include <utility> #include "base/at_exit.h" @@ -12,7 +13,6 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" #include "base/path_service.h" @@ -36,16 +36,17 @@ namespace { -class Driver : public mojo::ShellClient, - public mojo::InterfaceFactory<mojo::shell::test::mojom::Driver>, - public mojo::shell::test::mojom::Driver { +class Driver : public shell::ShellClient, + public shell::InterfaceFactory<shell::test::mojom::Driver>, + public shell::test::mojom::Driver { public: Driver() : weak_factory_(this) {} ~Driver() override {} private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override { base::FilePath target_path; CHECK(base::PathService::Get(base::DIR_EXE, &target_path)); @@ -72,16 +73,16 @@ platform_channel_pair.PrepareToPassClientHandleToChildProcess( &child_command_line, &handle_passing_info); - mojo::shell::mojom::ShellClientPtr client = - mojo::shell::PassShellClientRequestOnCommandLine(&child_command_line); - mojo::shell::mojom::PIDReceiverPtr receiver; + shell::mojom::ShellClientPtr client = + shell::PassShellClientRequestOnCommandLine(&child_command_line); + shell::mojom::PIDReceiverPtr receiver; - mojo::Identity target("exe:shell_unittest_target", - mojo::shell::mojom::kInheritUserID); - mojo::Connector::ConnectParams params(target); + shell::Identity target("exe:shell_unittest_target", + shell::mojom::kInheritUserID); + shell::Connector::ConnectParams params(target); params.set_client_process_connection(std::move(client), GetProxy(&receiver)); - scoped_ptr<mojo::Connection> connection = connector->Connect(¶ms); + std::unique_ptr<shell::Connection> connection = connector->Connect(¶ms); connection->AddConnectionCompletedClosure( base::Bind(&Driver::OnConnectionCompleted, base::Unretained(this))); @@ -98,14 +99,14 @@ platform_channel_pair.PassServerHandle()); } - bool AcceptConnection(mojo::Connection* connection) override { - connection->AddInterface<mojo::shell::test::mojom::Driver>(this); + bool AcceptConnection(shell::Connection* connection) override { + connection->AddInterface<shell::test::mojom::Driver>(this); return true; } - // mojo::InterfaceFactory<Driver>: - void Create(mojo::Connection* connection, - mojo::shell::test::mojom::DriverRequest request) override { + // shell::InterfaceFactory<Driver>: + void Create(shell::Connection* connection, + shell::test::mojom::DriverRequest request) override { bindings_.AddBinding(this, std::move(request)); } @@ -118,7 +119,7 @@ void OnConnectionCompleted() {} base::Process target_; - mojo::BindingSet<mojo::shell::test::mojom::Driver> bindings_; + mojo::BindingSet<shell::test::mojom::Driver> bindings_; base::WeakPtrFactory<Driver> weak_factory_; DISALLOW_COPY_AND_ASSIGN(Driver); @@ -130,8 +131,8 @@ base::AtExitManager at_exit; base::CommandLine::Init(argc, argv); - mojo::shell::InitializeLogging(); + shell::InitializeLogging(); Driver driver; - return mojo::shell::TestNativeMain(&driver); + return shell::TestNativeMain(&driver); }
diff --git a/services/shell/tests/shell/shell_unittest.cc b/services/shell/tests/shell/shell_unittest.cc index 30c9b464..d751b16c 100644 --- a/services/shell/tests/shell/shell_unittest.cc +++ b/services/shell/tests/shell/shell_unittest.cc
@@ -5,10 +5,12 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <utility> #include "base/bind.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" #include "base/process/process_handle.h" #include "base/run_loop.h" @@ -19,17 +21,17 @@ #include "services/shell/public/interfaces/shell.mojom.h" #include "services/shell/tests/shell/shell_unittest.mojom.h" -namespace mojo { namespace shell { + namespace { class ShellTestClient - : public mojo::test::ShellTestClient, + : public test::ShellTestClient, public InterfaceFactory<test::mojom::CreateInstanceTest>, public test::mojom::CreateInstanceTest { public: - explicit ShellTestClient(mojo::test::ShellTest* test) - : mojo::test::ShellTestClient(test), + explicit ShellTestClient(test::ShellTest* test) + : test::ShellTestClient(test), target_id_(shell::mojom::kInvalidInstanceID), binding_(this) {} ~ShellTestClient() override {} @@ -37,7 +39,7 @@ uint32_t target_id() const { return target_id_; } private: - // mojo::ShellClient: + // test::ShellTestClient: bool AcceptConnection(Connection* connection) override { connection->AddInterface<test::mojom::CreateInstanceTest>(this); return true; @@ -58,18 +60,17 @@ uint32_t target_id_; - Binding<test::mojom::CreateInstanceTest> binding_; + mojo::Binding<test::mojom::CreateInstanceTest> binding_; DISALLOW_COPY_AND_ASSIGN(ShellTestClient); }; } // namespace -class ShellTest : public mojo::test::ShellTest, - public mojom::InstanceListener { +class ShellTest : public test::ShellTest, public mojom::InstanceListener { public: ShellTest() - : mojo::test::ShellTest("mojo:shell_unittest"), + : test::ShellTest("mojo:shell_unittest"), shell_client_(nullptr), binding_(this) {} ~ShellTest() override {} @@ -121,13 +122,14 @@ private: // test::ShellTest: - scoped_ptr<ShellClient> CreateShellClient() override { + std::unique_ptr<ShellClient> CreateShellClient() override { shell_client_ = new ShellTestClient(this); - return make_scoped_ptr(shell_client_); + return base::WrapUnique(shell_client_); } // mojom::InstanceListener: - void SetExistingInstances(Array<mojom::InstanceInfoPtr> instances) override { + void SetExistingInstances( + mojo::Array<mojom::InstanceInfoPtr> instances) override { for (size_t i = 0; i < instances.size(); ++i) { initial_instances_.push_back(InstanceInfo(instances[i]->id, instances[i]->identity->name)); @@ -161,10 +163,10 @@ } ShellTestClient* shell_client_; - Binding<mojom::InstanceListener> binding_; + mojo::Binding<mojom::InstanceListener> binding_; std::vector<InstanceInfo> instances_; std::vector<InstanceInfo> initial_instances_; - scoped_ptr<base::RunLoop> wait_for_instances_loop_; + std::unique_ptr<base::RunLoop> wait_for_instances_loop_; DISALLOW_COPY_AND_ASSIGN(ShellTest); }; @@ -174,8 +176,8 @@ // 1. Launch a process. (Actually, have the runner launch a process that // launches a process.) - mojo::shell::test::mojom::DriverPtr driver; - scoped_ptr<Connection> connection = + test::mojom::DriverPtr driver; + std::unique_ptr<Connection> connection = connector()->Connect("exe:shell_unittest_driver"); connection->GetInterface(&driver); @@ -185,7 +187,7 @@ EXPECT_FALSE(connection->IsPending()); uint32_t remote_id = connection->GetRemoteInstanceID(); - EXPECT_NE(shell::mojom::kInvalidInstanceID, remote_id); + EXPECT_NE(mojom::kInvalidInstanceID, remote_id); // 3. Validate that this test suite's name was received from the application // manager. @@ -217,4 +219,3 @@ } } // namespace shell -} // namespace mojo
diff --git a/services/shell/tests/shell/shell_unittest.mojom b/services/shell/tests/shell/shell_unittest.mojom index bee0368..5b51418 100644 --- a/services/shell/tests/shell/shell_unittest.mojom +++ b/services/shell/tests/shell/shell_unittest.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. -module mojo.shell.test.mojom; +module shell.test.mojom; interface CreateInstanceTest { SetTargetID(uint32 target_id);
diff --git a/services/shell/tests/shell/target.cc b/services/shell/tests/shell/target.cc index 1b24123..68a2bb5 100644 --- a/services/shell/tests/shell/target.cc +++ b/services/shell/tests/shell/target.cc
@@ -12,18 +12,19 @@ #include "services/shell/runner/init.h" #include "services/shell/tests/shell/shell_unittest.mojom.h" -using mojo::shell::test::mojom::CreateInstanceTestPtr; +using shell::test::mojom::CreateInstanceTestPtr; namespace { -class Target : public mojo::ShellClient { +class Target : public shell::ShellClient { public: Target() {} ~Target() override {} private: - // mojo::ShellClient: - void Initialize(mojo::Connector* connector, const mojo::Identity& identity, + // shell::ShellClient: + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override { CreateInstanceTestPtr service; connector->ConnectToInterface("mojo:shell_unittest", &service); @@ -39,8 +40,8 @@ base::AtExitManager at_exit; base::CommandLine::Init(argc, argv); - mojo::shell::InitializeLogging(); + shell::InitializeLogging(); Target target; - return mojo::shell::TestNativeMain(&target); + return shell::TestNativeMain(&target); }
diff --git a/services/shell/tests/shell/target_manifest.json b/services/shell/tests/shell/target_manifest.json index 68ddc21..0216a962 100644 --- a/services/shell/tests/shell/target_manifest.json +++ b/services/shell/tests/shell/target_manifest.json
@@ -1,5 +1,5 @@ { "name": "exe:shell_unittest_target", "display_name": "Shell Unittest: Target", - "capabilities": { "mojo:shell_unittest": [ "mojo::shell::test::mojom::CreateInstanceTest" ] } + "capabilities": { "mojo:shell_unittest": [ "shell::test::mojom::CreateInstanceTest" ] } }
diff --git a/services/shell/tests/test.mojom b/services/shell/tests/test.mojom index 25700b59..f5a45a8 100644 --- a/services/shell/tests/test.mojom +++ b/services/shell/tests/test.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. -module mojo.shell; +module shell; interface TestService { Test(string test_string) => ();
diff --git a/services/shell/tests/util.cc b/services/shell/tests/util.cc index bebda4e..6449cc3 100644 --- a/services/shell/tests/util.cc +++ b/services/shell/tests/util.cc
@@ -23,19 +23,21 @@ #include "services/shell/public/interfaces/shell_client_factory.mojom.h" #include "services/shell/runner/common/switches.h" -namespace mojo { namespace shell { namespace test { + namespace { + void QuitLoop(base::RunLoop* loop) { loop->Quit(); } + } // namespace -scoped_ptr<Connection> LaunchAndConnectToProcess( +std::unique_ptr<Connection> LaunchAndConnectToProcess( const std::string& target_exe_name, const Identity target, - mojo::Connector* connector, + shell::Connector* connector, base::Process* process) { base::FilePath target_path; CHECK(base::PathService::Get(base::DIR_EXE, &target_path)); @@ -66,14 +68,14 @@ mojo::ScopedMessagePipeHandle pipe = mojo::edk::CreateParentMessagePipe(primordial_pipe_token); - mojo::shell::mojom::ShellClientPtr client; - client.Bind(mojo::InterfacePtrInfo<mojo::shell::mojom::ShellClient>( - std::move(pipe), 0u)); - mojo::shell::mojom::PIDReceiverPtr receiver; + shell::mojom::ShellClientPtr client; + client.Bind( + mojo::InterfacePtrInfo<shell::mojom::ShellClient>(std::move(pipe), 0u)); + shell::mojom::PIDReceiverPtr receiver; - mojo::Connector::ConnectParams params(target); + shell::Connector::ConnectParams params(target); params.set_client_process_connection(std::move(client), GetProxy(&receiver)); - scoped_ptr<mojo::Connection> connection = connector->Connect(¶ms); + std::unique_ptr<shell::Connection> connection = connector->Connect(¶ms); { base::RunLoop loop; connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop)); @@ -98,4 +100,3 @@ } // namespace test } // namespace shell -} // namespace mojo
diff --git a/services/shell/tests/util.h b/services/shell/tests/util.h index 50603dc..cad8831 100644 --- a/services/shell/tests/util.h +++ b/services/shell/tests/util.h
@@ -5,32 +5,30 @@ #ifndef SERVICES_SHELL_TESTS_UTIL_H_ #define SERVICES_SHELL_TESTS_UTIL_H_ +#include <memory> #include <string> -#include "base/memory/scoped_ptr.h" - namespace base { class Process; } -namespace mojo { +namespace shell { class Connection; class Connector; class Identity; -namespace shell { + namespace test { // Starts the process @ |target_exe_name| and connects to it as |target| using // |connector|, returning the connection & the process. // This blocks until the connection is established/rejected by the shell. -scoped_ptr<Connection> LaunchAndConnectToProcess( +std::unique_ptr<Connection> LaunchAndConnectToProcess( const std::string& target_exe_name, const Identity target, - mojo::Connector* connector, + shell::Connector* connector, base::Process* process); } // namespace test } // namespace shell -} // namespace mojo #endif // SERVICES_SHELL_TESTS_UTIL_H_
diff --git a/services/tracing/main.cc b/services/tracing/main.cc index 9142263..758efedf 100644 --- a/services/tracing/main.cc +++ b/services/tracing/main.cc
@@ -7,6 +7,6 @@ #include "services/tracing/tracing_app.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner(new tracing::TracingApp); + shell::ApplicationRunner runner(new tracing::TracingApp); return runner.Run(shell_handle); }
diff --git a/services/tracing/public/cpp/tracing_impl.cc b/services/tracing/public/cpp/tracing_impl.cc index 349ccb5..6b6f68fb 100644 --- a/services/tracing/public/cpp/tracing_impl.cc +++ b/services/tracing/public/cpp/tracing_impl.cc
@@ -41,7 +41,8 @@ TracingImpl::~TracingImpl() { } -void TracingImpl::Initialize(Connector* connector, const std::string& url) { +void TracingImpl::Initialize(shell::Connector* connector, + const std::string& url) { { base::AutoLock lock(g_singleton_lock.Get()); if (g_tracing_singleton_created) @@ -66,7 +67,7 @@ #endif } -void TracingImpl::Create(Connection* connection, +void TracingImpl::Create(shell::Connection* connection, InterfaceRequest<tracing::TraceProvider> request) { provider_impl_.Bind(std::move(request)); }
diff --git a/services/tracing/public/cpp/tracing_impl.h b/services/tracing/public/cpp/tracing_impl.h index f3f034c..fa68304 100644 --- a/services/tracing/public/cpp/tracing_impl.h +++ b/services/tracing/public/cpp/tracing_impl.h
@@ -10,10 +10,12 @@ #include "services/tracing/public/cpp/trace_provider_impl.h" #include "services/tracing/public/interfaces/tracing.mojom.h" -namespace mojo { - +namespace shell { class Connection; class Connector; +} + +namespace mojo { // Connects to mojo:tracing during your Application's Initialize() call once // per process. @@ -25,21 +27,21 @@ // // Have your bundle ContentHandler own a TracingImpl, and each Application own // a TracingImpl. In bundles, the second TracingImpl will be a no-op. -class TracingImpl : public InterfaceFactory<tracing::TraceProvider> { +class TracingImpl : public shell::InterfaceFactory<tracing::TraceProvider> { public: TracingImpl(); ~TracingImpl() override; // This connects to the tracing service and registers ourselves to provide // tracing data on demand. - void Initialize(Connector* connector, const std::string& url); + void Initialize(shell::Connector* connector, const std::string& url); private: // InterfaceFactory<tracing::TraceProvider> implementation. - void Create(Connection* connection, + void Create(shell::Connection* connection, InterfaceRequest<tracing::TraceProvider> request) override; - scoped_ptr<Connection> connection_; + scoped_ptr<shell::Connection> connection_; TraceProviderImpl provider_impl_; DISALLOW_COPY_AND_ASSIGN(TracingImpl);
diff --git a/services/tracing/tracing_app.cc b/services/tracing/tracing_app.cc index 845f6ba1..2dff1177 100644 --- a/services/tracing/tracing_app.cc +++ b/services/tracing/tracing_app.cc
@@ -21,7 +21,7 @@ TracingApp::~TracingApp() { } -bool TracingApp::AcceptConnection(mojo::Connection* connection) { +bool TracingApp::AcceptConnection(shell::Connection* connection) { connection->AddInterface<TraceCollector>(this); connection->AddInterface<StartupPerformanceDataCollector>(this); @@ -50,13 +50,13 @@ return false; } -void TracingApp::Create(mojo::Connection* connection, +void TracingApp::Create(shell::Connection* connection, mojo::InterfaceRequest<TraceCollector> request) { collector_binding_.Bind(std::move(request)); } void TracingApp::Create( - mojo::Connection* connection, + shell::Connection* connection, mojo::InterfaceRequest<StartupPerformanceDataCollector> request) { startup_performance_data_collector_bindings_.AddBinding(this, std::move(request));
diff --git a/services/tracing/tracing_app.h b/services/tracing/tracing_app.h index 48b67e4..b1dcd9f3 100644 --- a/services/tracing/tracing_app.h +++ b/services/tracing/tracing_app.h
@@ -22,27 +22,27 @@ namespace tracing { class TracingApp - : public mojo::ShellClient, - public mojo::InterfaceFactory<TraceCollector>, + : public shell::ShellClient, + public shell::InterfaceFactory<TraceCollector>, public TraceCollector, - public mojo::InterfaceFactory<StartupPerformanceDataCollector>, + public shell::InterfaceFactory<StartupPerformanceDataCollector>, public StartupPerformanceDataCollector { public: TracingApp(); ~TracingApp() override; private: - // mojo::ShellClient implementation. - bool AcceptConnection(mojo::Connection* connection) override; + // shell::ShellClient implementation. + bool AcceptConnection(shell::Connection* connection) override; bool ShellConnectionLost() override; - // mojo::InterfaceFactory<TraceCollector> implementation. - void Create(mojo::Connection* connection, + // shell::InterfaceFactory<TraceCollector> implementation. + void Create(shell::Connection* connection, mojo::InterfaceRequest<TraceCollector> request) override; - // mojo::InterfaceFactory<StartupPerformanceDataCollector> implementation. + // shell::InterfaceFactory<StartupPerformanceDataCollector> implementation. void Create( - mojo::Connection* connection, + shell::Connection* connection, mojo::InterfaceRequest<StartupPerformanceDataCollector> request) override; // tracing::TraceCollector implementation.
diff --git a/services/user/user_service.h b/services/user/user_service.h index b5e4f8d6..9682cc2 100644 --- a/services/user/user_service.h +++ b/services/user/user_service.h
@@ -16,7 +16,7 @@ class LockTable; } -namespace mojo { +namespace shell { class MessageLoopRef; }
diff --git a/services/user/user_shell_client.cc b/services/user/user_shell_client.cc index 06bb96bb..13efc60 100644 --- a/services/user/user_shell_client.cc +++ b/services/user/user_shell_client.cc
@@ -25,7 +25,7 @@ ~UserServiceObjects() {} // Called on the |user_service_runner_|. - void OnUserServiceRequest(mojo::Connection* connection, + void OnUserServiceRequest(shell::Connection* connection, mojom::UserServiceRequest request) { if (!lock_table_) lock_table_ = new filesystem::LockTable; @@ -52,7 +52,7 @@ ~LevelDBServiceObjects() {} // Called on the |leveldb_service_runner_|. - void OnLevelDBServiceRequest(mojo::Connection* connection, + void OnLevelDBServiceRequest(shell::Connection* connection, leveldb::LevelDBServiceRequest request) { if (!leveldb_service_) leveldb_service_.reset(new leveldb::LevelDBServiceImpl(task_runner_)); @@ -69,7 +69,7 @@ DISALLOW_COPY_AND_ASSIGN(LevelDBServiceObjects); }; -scoped_ptr<mojo::ShellClient> CreateUserShellClient( +scoped_ptr<shell::ShellClient> CreateUserShellClient( scoped_refptr<base::SingleThreadTaskRunner> user_service_runner, scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner) { return make_scoped_ptr(new UserShellClient(std::move(user_service_runner), @@ -87,8 +87,8 @@ leveldb_service_runner_->DeleteSoon(FROM_HERE, leveldb_objects_.release()); } -void UserShellClient::Initialize(mojo::Connector* connector, - const mojo::Identity& identity, +void UserShellClient::Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) { tracing_.Initialize(connector, identity.name()); user_objects_.reset(new UserShellClient::UserServiceObjects( @@ -97,13 +97,13 @@ new UserShellClient::LevelDBServiceObjects(leveldb_service_runner_)); } -bool UserShellClient::AcceptConnection(mojo::Connection* connection) { +bool UserShellClient::AcceptConnection(shell::Connection* connection) { connection->AddInterface<leveldb::LevelDBService>(this); connection->AddInterface<mojom::UserService>(this); return true; } -void UserShellClient::Create(mojo::Connection* connection, +void UserShellClient::Create(shell::Connection* connection, mojom::UserServiceRequest request) { user_service_runner_->PostTask( FROM_HERE, @@ -112,7 +112,7 @@ base::Passed(&request))); } -void UserShellClient::Create(mojo::Connection* connection, +void UserShellClient::Create(shell::Connection* connection, leveldb::LevelDBServiceRequest request) { leveldb_service_runner_->PostTask( FROM_HERE,
diff --git a/services/user/user_shell_client.h b/services/user/user_shell_client.h index de52157..f9c5dda4 100644 --- a/services/user/user_shell_client.h +++ b/services/user/user_shell_client.h
@@ -16,13 +16,14 @@ namespace user_service { -scoped_ptr<mojo::ShellClient> CreateUserShellClient( +scoped_ptr<shell::ShellClient> CreateUserShellClient( scoped_refptr<base::SingleThreadTaskRunner> user_service_runner, scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner); -class UserShellClient : public mojo::ShellClient, - public mojo::InterfaceFactory<mojom::UserService>, - public mojo::InterfaceFactory<leveldb::LevelDBService> { +class UserShellClient + : public shell::ShellClient, + public shell::InterfaceFactory<mojom::UserService>, + public shell::InterfaceFactory<leveldb::LevelDBService> { public: UserShellClient( scoped_refptr<base::SingleThreadTaskRunner> user_service_runner, @@ -31,20 +32,20 @@ private: // |ShellClient| override: - void Initialize(mojo::Connector* connector, - const mojo::Identity& identity, + void Initialize(shell::Connector* connector, + const shell::Identity& identity, uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; + bool AcceptConnection(shell::Connection* connection) override; // |InterfaceFactory<mojom::UserService>| implementation: - void Create(mojo::Connection* connection, + void Create(shell::Connection* connection, mojom::UserServiceRequest request) override; // |InterfaceFactory<LevelDBService>| implementation: - void Create(mojo::Connection* connection, + void Create(shell::Connection* connection, leveldb::LevelDBServiceRequest request) override; - void OnLevelDBServiceRequest(mojo::Connection* connection, + void OnLevelDBServiceRequest(shell::Connection* connection, leveldb::LevelDBServiceRequest request); void OnLevelDBServiceError();
diff --git a/testing/buildbot/chromium.gpu.fyi.json b/testing/buildbot/chromium.gpu.fyi.json index 8b5d5c7..cdefee1 100644 --- a/testing/buildbot/chromium.gpu.fyi.json +++ b/testing/buildbot/chromium.gpu.fyi.json
@@ -5395,6 +5395,68 @@ "isolated_scripts": [ { "args": [ + "maps", + "--show-stdout", + "--browser=release", + "-v", + "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc" + ], + "isolate_name": "telemetry_gpu_test", + "name": "maps_pixel_test", + "override_compile_targets": [ + "telemetry_gpu_test_run" + ], + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "10de:0fe9", + "hidpi": "1", + "os": "Mac" + } + ] + } + }, + { + "args": [ + "pixel", + "--show-stdout", + "--browser=release", + "-v", + "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc", + "--refimg-cloud-storage-bucket", + "chromium-gpu-archive/reference-images", + "--os-type", + "mac", + "--build-revision", + "${got_revision}", + "--test-machine-name", + "${buildername}" + ], + "isolate_name": "telemetry_gpu_test", + "name": "pixel_test", + "non_precommit_args": [ + "--upload-refimg-to-cloud-storage" + ], + "override_compile_targets": [ + "telemetry_gpu_test_run" + ], + "precommit_args": [ + "--download-refimg-from-cloud-storage" + ], + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "10de:0fe9", + "hidpi": "1", + "os": "Mac" + } + ] + } + }, + { + "args": [ "webgl_conformance", "--show-stdout", "--browser=release",
diff --git a/testing/buildbot/chromium.gpu.json b/testing/buildbot/chromium.gpu.json index 3e5eb2b..8a69b08ee 100644 --- a/testing/buildbot/chromium.gpu.json +++ b/testing/buildbot/chromium.gpu.json
@@ -1977,6 +1977,68 @@ "isolated_scripts": [ { "args": [ + "maps", + "--show-stdout", + "--browser=release", + "-v", + "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc" + ], + "isolate_name": "telemetry_gpu_test", + "name": "maps_pixel_test", + "override_compile_targets": [ + "telemetry_gpu_test_run" + ], + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "10de:0fe9", + "hidpi": "1", + "os": "Mac" + } + ] + } + }, + { + "args": [ + "pixel", + "--show-stdout", + "--browser=release", + "-v", + "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc", + "--refimg-cloud-storage-bucket", + "chromium-gpu-archive/reference-images", + "--os-type", + "mac", + "--build-revision", + "${got_revision}", + "--test-machine-name", + "${buildername}" + ], + "isolate_name": "telemetry_gpu_test", + "name": "pixel_test", + "non_precommit_args": [ + "--upload-refimg-to-cloud-storage" + ], + "override_compile_targets": [ + "telemetry_gpu_test_run" + ], + "precommit_args": [ + "--download-refimg-from-cloud-storage" + ], + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "10de:0fe9", + "hidpi": "1", + "os": "Mac" + } + ] + } + }, + { + "args": [ "webgl_conformance", "--show-stdout", "--browser=release",
diff --git a/testing/buildbot/filters/browser-side-navigation.linux.content_browsertests.filter b/testing/buildbot/filters/browser-side-navigation.linux.content_browsertests.filter index f59da93..21c1dd89 100644 --- a/testing/buildbot/filters/browser-side-navigation.linux.content_browsertests.filter +++ b/testing/buildbot/filters/browser-side-navigation.linux.content_browsertests.filter
@@ -1,5 +1,6 @@ -NavigationControllerBrowserTest.FrameNavigationEntry_SubframeHistoryFallback -RenderFrameHostManagerTest.RestoreSubframeFileAccessForHistoryNavigation +-RenderFrameHostManagerTest.SameOriginFramesInDifferentProcesses -RenderViewImplTest.GetCompositionCharacterBoundsTest -RenderViewImplTest.OnNavigationHttpPost -ServiceWorkerBrowserTest.FetchPageWithSaveData
diff --git a/third_party/WebKit/LayoutTests/FlagExpectations/enable-browser-side-navigation b/third_party/WebKit/LayoutTests/FlagExpectations/enable-browser-side-navigation index 62898f4..c34d93b 100644 --- a/third_party/WebKit/LayoutTests/FlagExpectations/enable-browser-side-navigation +++ b/third_party/WebKit/LayoutTests/FlagExpectations/enable-browser-side-navigation
@@ -353,3 +353,10 @@ # Regressions: Unexpected text-only failures (3) imported/web-platform-tests/web-animations/keyframe-effect/getComputedTiming-currentIteration.html [ Failure ] imported/web-platform-tests/web-animations/keyframe-effect/getComputedTiming-progress.html [ Failure ] + +# Update on 16-4-14 + +# Regressions: Unexpected text-only failures (2) + http/tests/security/mixedContent/insecure-prefetch-in-main-frame.html [ Failure ] + imported/web-platform-tests/web-animations/animation-timeline/document-timeline.html [ Failure ] +
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations index bf3b6062..67b86f7 100644 --- a/third_party/WebKit/LayoutTests/TestExpectations +++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -52,6 +52,10 @@ # TODO(wangxianzhu): verify this after rebaseline for crbug.com/602483 # crbug.com/584211 [ Mac ] svg/transforms/animated-path-inside-transformed-html.xhtml [ Pass Failure ] +# This test violates lifecycle assertions. +# Timeout because of crbug.com/603231 +crbug.com/372245 media/track/track-word-breaking.html [ Crash Timeout ] + # ====== Oilpan-only failures until here ====== # Run these tests with under virtual/spv2 only.
diff --git a/third_party/WebKit/LayoutTests/animations/animation-properties-in-keyframe-are-ignored-expected.txt b/third_party/WebKit/LayoutTests/animations/animation-properties-in-keyframe-are-ignored-expected.txt index bd0be774..94089d9d 100644 --- a/third_party/WebKit/LayoutTests/animations/animation-properties-in-keyframe-are-ignored-expected.txt +++ b/third_party/WebKit/LayoutTests/animations/animation-properties-in-keyframe-are-ignored-expected.txt
@@ -2,6 +2,6 @@ PASS - "left" property for "target" element at 1s saw something close to: 50 PASS - "left" property for "target" element at 2s saw something close to: 100 PASS - "left" property for "target" element at 3s saw something close to: 150 -PASS - "left" property for "target" element at 4s saw something close to: auto -PASS - "left" property for "target" element at 5s saw something close to: auto +PASS - "left" property for "target" element at 4s saw something close to: 0px +PASS - "left" property for "target" element at 5s saw something close to: 0px
diff --git a/third_party/WebKit/LayoutTests/animations/animation-properties-in-keyframe-are-ignored.html b/third_party/WebKit/LayoutTests/animations/animation-properties-in-keyframe-are-ignored.html index 779e17c..fdd965d 100644 --- a/third_party/WebKit/LayoutTests/animations/animation-properties-in-keyframe-are-ignored.html +++ b/third_party/WebKit/LayoutTests/animations/animation-properties-in-keyframe-are-ignored.html
@@ -45,8 +45,8 @@ [1, "target", "left", 50, 5], [2, "target", "left", 100, 5], [3, "target", "left", 150, 5], - [4, "target", "left", "auto", 0], - [5, "target", "left", "auto", 0], + [4, "target", "left", "0px", 0], + [5, "target", "left", "0px", 0], ]; runAnimationTest(expectedValues); @@ -57,4 +57,4 @@ <div id="target"></div> <div id="result"></div> </body> -</html> \ No newline at end of file +</html>
diff --git a/third_party/WebKit/LayoutTests/animations/change-keyframes.html b/third_party/WebKit/LayoutTests/animations/change-keyframes.html index 97fda5a4..fc0bef4 100644 --- a/third_party/WebKit/LayoutTests/animations/change-keyframes.html +++ b/third_party/WebKit/LayoutTests/animations/change-keyframes.html
@@ -43,7 +43,7 @@ // A forced style-recalc aborts the previous animation. box.style.animationName = "none"; - assert_equals(getComputedStyle(box).left, 'auto', 'left'); + assert_equals(getComputedStyle(box).left, '0px', 'left'); // Change keyframes. var keyframes = findKeyframesRule("anim"); @@ -53,8 +53,8 @@ keyframes.appendRule("100% { top: 150px; }"); box.style.webkitAnimationName = "anim"; - // The left property should reset to auto and top should be animating. - assert_equals(getComputedStyle(box).left, 'auto', 'left'); + // The left property should reset and top should be animating. + assert_equals(getComputedStyle(box).left, '0px', 'left'); assert_equals(getComputedStyle(box).top, '100px', 'top'); }, "Check that changes to keyframe rules take effect"); </script>
diff --git a/third_party/WebKit/LayoutTests/animations/function-easing-use-counters-linear.html b/third_party/WebKit/LayoutTests/animations/function-easing-use-counters-linear.html index 769a70c..29c5667 100644 --- a/third_party/WebKit/LayoutTests/animations/function-easing-use-counters-linear.html +++ b/third_party/WebKit/LayoutTests/animations/function-easing-use-counters-linear.html
@@ -11,12 +11,19 @@ document.documentElement.animate([], { }); document.documentElement.animate([], { easing: 'linear' }); document.documentElement.animate([], { easing: 'step-start' }); - document.documentElement.animate([], { easing: 'invalid' }); assert_false(internals.isUseCounted(document, WebAnimationsEasingAsFunctionLinear)); assert_false(internals.isUseCounted(document, WebAnimationsEasingAsFunctionOther)); }, 'Non-function values for easing are not use-counted.'); test(() => { + assert_throws( + {name: 'TypeError'}, + function() { document.documentElement.animate([], { easing: 'invalid' }) }); + assert_false(internals.isUseCounted(document, WebAnimationsEasingAsFunctionLinear)); + assert_false(internals.isUseCounted(document, WebAnimationsEasingAsFunctionOther)); +}, 'Invalid non-function values for easing are not use-counted.'); + +test(() => { // This linear function value is the one expected from uses of the unpatched // Web Animations polyfill (i.e. old versions lacking // https://github.com/web-animations/web-animations-next/pull/423).
diff --git a/third_party/WebKit/LayoutTests/animations/function-easing-use-counters-other1.html b/third_party/WebKit/LayoutTests/animations/function-easing-use-counters-other1.html index 72ae7c6..7670d69e 100644 --- a/third_party/WebKit/LayoutTests/animations/function-easing-use-counters-other1.html +++ b/third_party/WebKit/LayoutTests/animations/function-easing-use-counters-other1.html
@@ -8,7 +8,9 @@ var WebAnimationsEasingAsFunctionOther = 1296; test(() => { - document.documentElement.animate([], { easing: 'function (x){return x}' }); + assert_throws( + {name: 'TypeError'}, + function() { document.documentElement.animate([], { easing: 'function (x){return x}' }) }); assert_false(internals.isUseCounted(document, WebAnimationsEasingAsFunctionLinear)); assert_true(internals.isUseCounted(document, WebAnimationsEasingAsFunctionOther)); }, 'Any linear function for easing other than "function (a){return a}" is counted in WebAnimationsEasingAsFunctionOther.');
diff --git a/third_party/WebKit/LayoutTests/animations/function-easing-use-counters-other2.html b/third_party/WebKit/LayoutTests/animations/function-easing-use-counters-other2.html index 8cac23d2..b02fd1e 100644 --- a/third_party/WebKit/LayoutTests/animations/function-easing-use-counters-other2.html +++ b/third_party/WebKit/LayoutTests/animations/function-easing-use-counters-other2.html
@@ -8,7 +8,9 @@ var WebAnimationsEasingAsFunctionOther = 1296; test(() => { - document.documentElement.animate([], { easing: 'function(x, y){return 0.3}' }); + assert_throws( + {name: 'TypeError'}, + function() { document.documentElement.animate([], { easing: 'function(x, y){return 0.3}' }) }); assert_false(internals.isUseCounted(document, WebAnimationsEasingAsFunctionLinear)); assert_true(internals.isUseCounted(document, WebAnimationsEasingAsFunctionOther)); }, 'Arbitrary functions for easing are counted in WebAnimationsEasingAsFunctionOther.');
diff --git a/third_party/WebKit/LayoutTests/animations/play-state.html b/third_party/WebKit/LayoutTests/animations/play-state.html index 17dcba0..98e8f46 100644 --- a/third_party/WebKit/LayoutTests/animations/play-state.html +++ b/third_party/WebKit/LayoutTests/animations/play-state.html
@@ -77,7 +77,7 @@ function end() { logPassFail('none', getComputedStyle(document.getElementById('translate')).webkitTransform, 'translate', 'at end'); - logPassFail('auto', getComputedStyle(document.getElementById('left')).left, 'left', 'at end'); + logPassFail('0px', getComputedStyle(document.getElementById('left')).left, 'left', 'at end'); if (window.testRunner) { testRunner.notifyDone(); }
diff --git a/third_party/WebKit/LayoutTests/fast/css-grid-layout/explicit-grid-size.html b/third_party/WebKit/LayoutTests/fast/css-grid-layout/explicit-grid-size.html new file mode 100644 index 0000000..4df0525 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/css-grid-layout/explicit-grid-size.html
@@ -0,0 +1,172 @@ +<!DOCTYPE html> +<link href="resources/grid.css" rel="stylesheet"> +<style> + +.grid { + grid-auto-columns: 10px; + grid-auto-rows: 10px; + position: relative; +} + +.oneColumnOneRow { + grid-template-columns: 50px; + grid-template-rows: 50px; +} + +.twoColumnsOneRow { + grid-template-columns: 50px 50px; + grid-template-rows: 50px; +} + +.oneColumnTwoRows { + grid-template-columns: 50px; + grid-template-rows: 50px 50px; +} + +.twoColumnsTwoRows { + grid-template-columns: 50px 50px; + grid-template-rows: 50px 50px; +} + +.oneColumnOneRowAreas { + grid-template-areas: "a"; +} + +.twoColumnsOneRowAreas { + grid-template-areas: "a b"; +} + +.oneColumnTwoRowsAreas { + grid-template-areas: "a" + "b"; +} + +.twoColumnsTwoRowsAreas { + grid-template-areas: "a b" + "c d"; +} + +</style> +<script src="../../resources/testharness.js"></script> +<script src="../../resources/testharnessreport.js"></script> +<script src="../../resources/check-layout-th.js"></script> +<body onload="checkLayout('.grid')"> +<div id="log"></div> + +<p>Checks that the explicit grid size is set by the maximum of the grid-template-columns|rows properties and grid-template-areas.</p> + +<div class="grid"> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="0" data-expected-width="10" data-expected-height="10"> + </div> +</div> + +<div class="grid oneColumnOneRow"> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="0" data-expected-width="50" data-expected-height="50"> + </div> +</div> + +<div class="grid oneColumnOneRowAreas"> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="0" data-expected-width="10" data-expected-height="10"> + </div> +</div> + +<div class="grid oneColumnTwoRows"> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="0" data-expected-width="50" data-expected-height="50"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="50" data-expected-width="50" data-expected-height="50"> + </div> +</div> + +<div class="grid oneColumnTwoRowsAreas"> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="0" data-expected-width="10" data-expected-height="10"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="10" data-expected-width="10" data-expected-height="10"> + </div> +</div> + +<div class="grid twoColumnsOneRow"> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="0" data-expected-width="50" data-expected-height="50"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="50" data-offset-y="0" data-expected-width="50" data-expected-height="50"> + </div> +</div> + +<div class="grid twoColumnsOneRowAreas"> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="0" data-expected-width="10" data-expected-height="10"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="10" data-offset-y="0" data-expected-width="10" data-expected-height="10"> + </div> +</div> + +<div class="grid twoColumnsTwoRows"> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="0" data-expected-width="50" data-expected-height="50"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="50" data-offset-y="0" data-expected-width="50" data-expected-height="50"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="50" data-expected-width="50" data-expected-height="50"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="50" data-offset-y="50" data-expected-width="50" data-expected-height="50"> + </div> +</div> + +<div class="grid twoColumnsTwoRowsAreas"> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="0" data-expected-width="10" data-expected-height="10"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="10" data-offset-y="0" data-expected-width="10" data-expected-height="10"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="10" data-expected-width="10" data-expected-height="10"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="10" data-offset-y="10" data-expected-width="10" data-expected-height="10"> + </div> +</div> + +<div class="grid oneColumnOneRow twoColumnsTwoRowsAreas"> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="0" data-expected-width="50" data-expected-height="50"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="50" data-offset-y="0" data-expected-width="10" data-expected-height="50"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="50" data-expected-width="50" data-expected-height="10"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="50" data-offset-y="50" data-expected-width="10" data-expected-height="10"> + </div> +</div> + +<div class="grid twoColumnsTwoRows oneColumnOneRowAreas"> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="0" data-expected-width="50" data-expected-height="50"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="50" data-offset-y="0" data-expected-width="50" data-expected-height="50"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="0" data-offset-y="50" data-expected-width="50" data-expected-height="50"> + </div> + <div class="autoRowAutoColumn" + data-offset-x="50" data-offset-y="50" data-expected-width="50" data-expected-height="50"> + </div> +</div> + +</body>
diff --git a/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-container-change-explicit-grid-recompute-child-expected.txt b/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-container-change-explicit-grid-recompute-child-expected.txt index 3584a61..51b904eb 100644 --- a/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-container-change-explicit-grid-recompute-child-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-container-change-explicit-grid-recompute-child-expected.txt
@@ -3,3 +3,5 @@ PASS PASS PASS +PASS +PASS
diff --git a/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-container-change-explicit-grid-recompute-child.html b/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-container-change-explicit-grid-recompute-child.html index a1305f5..e9eb8bc 100644 --- a/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-container-change-explicit-grid-recompute-child.html +++ b/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-container-change-explicit-grid-recompute-child.html
@@ -5,6 +5,8 @@ <style> .grid { grid-auto-flow: row dense; + grid-auto-rows: 5px; + grid-auto-columns: 5px; } #firstGridItem { grid-row: auto; @@ -22,11 +24,12 @@ } </style> <script> -function testGridDefinitions(gridTemplateRows, gridTemplateColumns, firstGridItemData, secondGridItemData, thirdGridItemData) +function testGridDefinitions(gridTemplateRows, gridTemplateColumns, gridTemplateAreas, firstGridItemData, secondGridItemData, thirdGridItemData) { var gridElement = document.getElementsByClassName("grid")[0]; gridElement.style.gridTemplateRows = gridTemplateRows; gridElement.style.gridTemplateColumns = gridTemplateColumns; + gridElement.style.gridTemplateAreas = gridTemplateAreas; var firstGridItem = document.getElementById("firstGridItem"); firstGridItem.setAttribute("data-expected-width", firstGridItemData.width); @@ -51,10 +54,12 @@ function testChangingGridDefinitions() { - testGridDefinitions('10px 20px', '10px', { 'width': '10', 'height': '20', 'x': '0', 'y': '10' }, { 'width': '10', 'height': '10', 'x': '0', 'y': '0' }, { 'width': '10', 'height': '0', 'x': '0', 'y': '30' }); - testGridDefinitions('50px', '30px 40px', { 'width': '30', 'height': '0', 'x': '0', 'y': '50' }, { 'width': '30', 'height': '50', 'x': '0', 'y': '0' }, { 'width': '40', 'height': '50', 'x': '30', 'y': '0' }); - testGridDefinitions('50px', '60px', { 'width': '60', 'height': '0', 'x': '0', 'y': '50' }, { 'width': '60', 'height': '50', 'x': '0', 'y': '0' }, { 'width': '60', 'height': '0', 'x': '0', 'y': '50' }); - testGridDefinitions('50px 100px 150px', '60px', { 'width': '60', 'height': '100', 'x': '0', 'y': '50' }, { 'width': '60', 'height': '50', 'x': '0', 'y': '0' }, { 'width': '60', 'height': '150', 'x': '0', 'y': '150' }); + testGridDefinitions('10px 20px', '10px', '', { 'width': '10', 'height': '20', 'x': '0', 'y': '10' }, { 'width': '10', 'height': '10', 'x': '0', 'y': '0' }, { 'width': '10', 'height': '5', 'x': '0', 'y': '30' }); + testGridDefinitions('10px', '10px', '"a"', { 'width': '10', 'height': '5', 'x': '0', 'y': '10' }, { 'width': '10', 'height': '10', 'x': '0', 'y': '0' }, { 'width': '10', 'height': '5', 'x': '0', 'y': '15' }); + testGridDefinitions('10px', '10px', '"a ."', { 'width': '10', 'height': '5', 'x': '0', 'y': '10' }, { 'width': '10', 'height': '10', 'x': '0', 'y': '0' }, { 'width': '5', 'height': '10', 'x': '10', 'y': '0' }); + testGridDefinitions('50px', '30px 40px', '', { 'width': '30', 'height': '5', 'x': '0', 'y': '50' }, { 'width': '30', 'height': '50', 'x': '0', 'y': '0' }, { 'width': '40', 'height': '50', 'x': '30', 'y': '0' }); + testGridDefinitions('50px', '60px', '', { 'width': '60', 'height': '5', 'x': '0', 'y': '50' }, { 'width': '60', 'height': '50', 'x': '0', 'y': '0' }, { 'width': '60', 'height': '5', 'x': '0', 'y': '55' }); + testGridDefinitions('50px 100px 150px', '60px', '', { 'width': '60', 'height': '100', 'x': '0', 'y': '50' }, { 'width': '60', 'height': '50', 'x': '0', 'y': '0' }, { 'width': '60', 'height': '150', 'x': '0', 'y': '150' }); } window.addEventListener("load", testChangingGridDefinitions, false);
diff --git a/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-template-shorthand-get-set-expected.txt b/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-template-shorthand-get-set-expected.txt index 7f3205a..31186731 100644 --- a/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-template-shorthand-get-set-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-template-shorthand-get-set-expected.txt
@@ -28,10 +28,10 @@ PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesWithoutRowSize, '').getPropertyValue('grid-template-columns') is "10px" PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesWithoutRowSize, '').getPropertyValue('grid-template-rows') is "[head] 0px [tail]" PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesWithoutRowSize, '').getPropertyValue('grid-template-areas') is "\"a\"" -PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleColumns, '').getPropertyValue('grid-template-columns') is "10px" +PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleColumns, '').getPropertyValue('grid-template-columns') is "10px 20px" PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleColumns, '').getPropertyValue('grid-template-rows') is "[head] 15px [tail]" PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleColumns, '').getPropertyValue('grid-template-areas') is "\"a b\"" -PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleColumnsWithoutRowSize, '').getPropertyValue('grid-template-columns') is "10px" +PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleColumnsWithoutRowSize, '').getPropertyValue('grid-template-columns') is "10px 20px" PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleColumnsWithoutRowSize, '').getPropertyValue('grid-template-rows') is "[head] 0px [tail]" PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleColumnsWithoutRowSize, '').getPropertyValue('grid-template-areas') is "\"a b\"" PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleRows, '').getPropertyValue('grid-template-columns') is "10px"
diff --git a/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-template-shorthand-get-set.html b/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-template-shorthand-get-set.html index 907705c..b2109380 100644 --- a/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-template-shorthand-get-set.html +++ b/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-template-shorthand-get-set.html
@@ -28,10 +28,10 @@ grid-template: [head] "a" [tail] / 10px; } #gridTemplateComplexFormWithLineNamesMultipleColumns { - grid-template: [head] "a b" 15px [tail] / 10px; + grid-template: [head] "a b" 15px [tail] / 10px 20px; } #gridTemplateComplexFormWithLineNamesMultipleColumnsWithoutRowSize { - grid-template: [head] "a b" [tail] / 10px; + grid-template: [head] "a b" [tail] / 10px 20px; } #gridTemplateComplexFormWithLineNamesMultipleRows { grid-template: [head1] "a" 15px [tail1] @@ -202,8 +202,8 @@ testGridDefinitionsValues(document.getElementById("gridTemplateComplexForm"), "10px", "15px", '"a"'); testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithLineNames"), "10px", "[head] 15px [tail]", '"a"'); testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithLineNamesWithoutRowSize"), "10px", "[head] 0px [tail]", '"a"'); - testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithLineNamesMultipleColumns"), "10px", "[head] 15px [tail]", '"a b"'); - testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithLineNamesMultipleColumnsWithoutRowSize"), "10px", "[head] 0px [tail]", '"a b"'); + testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithLineNamesMultipleColumns"), "10px 20px", "[head] 15px [tail]", '"a b"'); + testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithLineNamesMultipleColumnsWithoutRowSize"), "10px 20px", "[head] 0px [tail]", '"a b"'); testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithLineNamesMultipleRows"), "10px", "[head1] 15px [tail1 head2] 20px [tail2]", '"a" "b"'); testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithLineNamesMultipleRowsWithoutRowsSizes"), "10px", "[head1] 0px [tail1 head2] 0px [tail2]", '"a" "b"'); testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithLineNamesMultipleRowsAndColumns"), "[first] 10px [nav nav2] 15px [nav nav2] 15px", "100px [nav nav2] 25px [nav nav2] 25px [last]", '"a b c" "d e f" "g h i"');
diff --git a/third_party/WebKit/LayoutTests/fast/css/getComputedStyle/getComputedStyle-resolved-values-expected.txt b/third_party/WebKit/LayoutTests/fast/css/getComputedStyle/getComputedStyle-resolved-values-expected.txt index 051be33a6..f35339b 100644 --- a/third_party/WebKit/LayoutTests/fast/css/getComputedStyle/getComputedStyle-resolved-values-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/css/getComputedStyle/getComputedStyle-resolved-values-expected.txt
@@ -5,6 +5,10 @@ line-height: 30px width: 150px height: 100px +top: auto +right: auto +bottom: auto +left: auto margin-top: 15px margin-right: 30px margin-bottom: 20px @@ -18,6 +22,10 @@ line-height: 30px width: auto height: auto +top: auto +right: auto +bottom: auto +left: auto margin-top: 15px margin-right: 30px margin-bottom: 20px @@ -31,6 +39,10 @@ line-height: 30px width: 150px height: 100px +top: auto +right: auto +bottom: auto +left: auto margin-top: 15px margin-right: 30px margin-bottom: 20px @@ -44,6 +56,10 @@ line-height: 30px width: 150px height: 100px +top: auto +right: auto +bottom: auto +left: auto margin-top: 15px margin-right: 30px margin-bottom: 20px @@ -58,6 +74,10 @@ line-height: 36px width: 250px height: 75px +top: auto +right: auto +bottom: auto +left: auto margin-top: 50px margin-right: 25px margin-bottom: 50px @@ -71,6 +91,10 @@ line-height: 36px width: auto height: auto +top: auto +right: auto +bottom: auto +left: auto margin-top: 10% margin-right: 5% margin-bottom: 10% @@ -84,6 +108,10 @@ line-height: 36px width: 250px height: 75px +top: auto +right: auto +bottom: auto +left: auto margin-top: 50px margin-right: 25px margin-bottom: 50px @@ -97,6 +125,10 @@ line-height: 36px width: 50% height: 25% +top: auto +right: auto +bottom: auto +left: auto margin-top: 10% margin-right: 5% margin-bottom: 10% @@ -111,6 +143,10 @@ line-height: 24px width: 240px height: 120px +top: auto +right: auto +bottom: auto +left: auto margin-top: 24px margin-right: 12px margin-bottom: 36px @@ -124,6 +160,10 @@ line-height: 24px width: auto height: auto +top: auto +right: auto +bottom: auto +left: auto margin-top: 24px margin-right: 12px margin-bottom: 36px @@ -137,6 +177,10 @@ line-height: 24px width: 240px height: 120px +top: auto +right: auto +bottom: auto +left: auto margin-top: 24px margin-right: 12px margin-bottom: 36px @@ -150,6 +194,10 @@ line-height: 24px width: 240px height: 120px +top: auto +right: auto +bottom: auto +left: auto margin-top: 24px margin-right: 12px margin-bottom: 36px @@ -164,6 +212,10 @@ line-height: 30px width: 200px height: 30px +top: auto +right: auto +bottom: auto +left: auto margin-top: 0px margin-right: 126px margin-bottom: 0px @@ -177,6 +229,10 @@ line-height: 30px width: auto height: auto +top: auto +right: auto +bottom: auto +left: auto margin-top: 0px margin-right: auto margin-bottom: 0px @@ -190,6 +246,10 @@ line-height: 30px width: 200px height: 30px +top: auto +right: auto +bottom: auto +left: auto margin-top: 0px margin-right: 0px margin-bottom: 0px @@ -203,6 +263,10 @@ line-height: 30px width: 200px height: auto +top: auto +right: auto +bottom: auto +left: auto margin-top: 0px margin-right: auto margin-bottom: 0px @@ -217,6 +281,10 @@ line-height: 48px width: 150px height: 60px +top: auto +right: auto +bottom: auto +left: auto margin-top: 72px margin-right: 0px margin-bottom: 0px @@ -230,6 +298,10 @@ line-height: 48px width: auto height: auto +top: auto +right: auto +bottom: auto +left: auto margin-top: 72px margin-right: 0px margin-bottom: 0px @@ -243,6 +315,10 @@ line-height: 48px width: 150px height: 60px +top: auto +right: auto +bottom: auto +left: auto margin-top: 72px margin-right: 0px margin-bottom: 0px @@ -256,6 +332,10 @@ line-height: 48px width: 30% height: 20% +top: auto +right: auto +bottom: auto +left: auto margin-top: 72px margin-right: 0px margin-bottom: 0px @@ -266,8 +346,148 @@ padding-left: 0px +Resolved values for element "rel_positioned" with display "block": +line-height: 30px +width: 150px +height: 100px +top: 15px +right: -10px +bottom: -15px +left: 10px +margin-top: 15px +margin-right: 30px +margin-bottom: 20px +margin-left: 10px +padding-top: 20px +padding-right: 20px +padding-bottom: 20px +padding-left: 20px + +Resolved values for element "rel_positioned" with display "inline": +line-height: 30px +width: auto +height: auto +top: 15px +right: -10px +bottom: -15px +left: 10px +margin-top: 15px +margin-right: 30px +margin-bottom: 20px +margin-left: 10px +padding-top: 20px +padding-right: 20px +padding-bottom: 20px +padding-left: 20px + +Resolved values for element "rel_positioned" with display "inline-block": +line-height: 30px +width: 150px +height: 100px +top: 15px +right: -10px +bottom: -15px +left: 10px +margin-top: 15px +margin-right: 30px +margin-bottom: 20px +margin-left: 10px +padding-top: 20px +padding-right: 20px +padding-bottom: 20px +padding-left: 20px + +Resolved values for element "rel_positioned" with display "none": +line-height: 30px +width: 150px +height: 100px +top: 15px +right: auto +bottom: auto +left: 10px +margin-top: 15px +margin-right: 30px +margin-bottom: 20px +margin-left: 10px +padding-top: 20px +padding-right: 20px +padding-bottom: 20px +padding-left: 20px + + +Resolved values for element "abs_positioned" with display "block": +line-height: 30px +width: 150px +height: 100px +top: 62px +right: 10px +bottom: 15px +left: 212px +margin-top: 15px +margin-right: 30px +margin-bottom: 20px +margin-left: 10px +padding-top: 20px +padding-right: 20px +padding-bottom: 20px +padding-left: 20px + +Resolved values for element "abs_positioned" with display "inline": +line-height: 30px +width: 150px +height: 100px +top: 62px +right: 10px +bottom: 15px +left: 212px +margin-top: 15px +margin-right: 30px +margin-bottom: 20px +margin-left: 10px +padding-top: 20px +padding-right: 20px +padding-bottom: 20px +padding-left: 20px + +Resolved values for element "abs_positioned" with display "inline-block": +line-height: 30px +width: 150px +height: 100px +top: 62px +right: 10px +bottom: 15px +left: 212px +margin-top: 15px +margin-right: 30px +margin-bottom: 20px +margin-left: 10px +padding-top: 20px +padding-right: 20px +padding-bottom: 20px +padding-left: 20px + +Resolved values for element "abs_positioned" with display "none": +line-height: 30px +width: 150px +height: 100px +top: auto +right: 10px +bottom: 15px +left: auto +margin-top: 15px +margin-right: 30px +margin-bottom: 20px +margin-left: 10px +padding-top: 20px +padding-right: 20px +padding-bottom: 20px +padding-left: 20px + + Fixed Percents EMs Auto Mixed +Relative Positioned +Absolute Positioned
diff --git a/third_party/WebKit/LayoutTests/fast/css/getComputedStyle/getComputedStyle-resolved-values.html b/third_party/WebKit/LayoutTests/fast/css/getComputedStyle/getComputedStyle-resolved-values.html index 4295409..806dc5d 100644 --- a/third_party/WebKit/LayoutTests/fast/css/getComputedStyle/getComputedStyle-resolved-values.html +++ b/third_party/WebKit/LayoutTests/fast/css/getComputedStyle/getComputedStyle-resolved-values.html
@@ -8,6 +8,10 @@ border: 1px solid black; } + #abs_container { + position: relative; + } + .testbox { color: white; font: 24px 'Lucida Grande'; @@ -68,6 +72,35 @@ padding-bottom: 1em; padding-left: auto; } + + #rel_positioned { + position: relative; + line-height: 30px; + width: 150px; + height: 100px; + left: 10px; + top: 15px; + margin-top: 15px; + margin-right: 30px; + margin-bottom: 20px; + margin-left: 10px; + padding: 20px; + } + + #abs_positioned { + position: absolute; + line-height: 30px; + width: 150px; + height: 100px; + right: 10px; + bottom: 15px; + margin-top: 15px; + margin-right: 30px; + margin-bottom: 20px; + margin-left: 10px; + padding: 20px; + } + </style> <script> @@ -75,6 +108,10 @@ 'line-height', 'width', 'height', + 'top', + 'right', + 'bottom', + 'left', 'margin-top', 'margin-right', 'margin-bottom', @@ -124,6 +161,8 @@ test('ems'); test('auto'); test('mixed'); + test('rel_positioned'); + test('abs_positioned'); } </script> </head> @@ -150,5 +189,11 @@ <div class="outer"> <div class="testbox" id="mixed">Mixed</div> </div> + <div class="outer"> + <div class="testbox" id="rel_positioned">Relative Positioned</div> + </div> + <div class="outer" id="abs_container"> + <div class="testbox" id="abs_positioned">Absolute Positioned</div> + </div> </body> </html>
diff --git a/third_party/WebKit/LayoutTests/fast/css/hover-affects-child.html b/third_party/WebKit/LayoutTests/fast/css/hover-affects-child.html index b8cb8aa..cd9e9c3 100644 --- a/third_party/WebKit/LayoutTests/fast/css/hover-affects-child.html +++ b/third_party/WebKit/LayoutTests/fast/css/hover-affects-child.html
@@ -32,10 +32,10 @@ var innerElem = document.getElementById('innerElem'); var calculatedStyle = window.getComputedStyle(innerElem); - if (calculatedStyle.getPropertyValue('left') == "auto") + if (calculatedStyle.getPropertyValue('left') == "8px") log("PASSED: Calculated style of inner element is correct"); else - log("FAILED: Calculated style of inner element is wrong, should be 'left: auto'"); + log("FAILED: Calculated style of inner element is wrong, should be 'left: 8px'"); } function runTest() {
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/abspos-dialog-layout-expected.txt b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/abspos-dialog-layout-expected.txt index 02101c9c..a6ee007 100644 --- a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/abspos-dialog-layout-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/abspos-dialog-layout-expected.txt
@@ -7,9 +7,9 @@ showModal() should center in the viewport. PASS dialog.getBoundingClientRect().top is centeredTop -The computed top and bottom of a centered dialog should still have position auto. -PASS window.getComputedStyle(dialog).top is "auto" -PASS window.getComputedStyle(dialog).bottom is "auto" +The dialog is a positioned element, so the top and bottom should not have style auto. +PASS window.getComputedStyle(dialog).top is "790px" +PASS window.getComputedStyle(dialog).bottom is "-210px" Dialog should be recentered if showModal() is called after close(). PASS dialog.getBoundingClientRect().top is centeredTop
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/abspos-dialog-layout.html b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/abspos-dialog-layout.html index 957197b..e88d8f3 100644 --- a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/abspos-dialog-layout.html +++ b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/abspos-dialog-layout.html
@@ -35,11 +35,14 @@ }()); (function() { - debug('<br>The computed top and bottom of a centered dialog should still have position auto.'); + debug('<br>The dialog is a positioned element, so the top and bottom should not have style auto.'); + dialog.style.height = '20px'; dialog.showModal(); - shouldBeEqualToString('window.getComputedStyle(dialog).top', 'auto'); - shouldBeEqualToString('window.getComputedStyle(dialog).bottom', 'auto'); + shouldBeEqualToString('window.getComputedStyle(dialog).top', '790px'); + shouldBeEqualToString('window.getComputedStyle(dialog).bottom', '-210px'); + + dialog.style.height = 'auto'; reset(); }());
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/fixpos-dialog-layout-expected.txt b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/fixpos-dialog-layout-expected.txt index 981152c2..414acbb5 100644 --- a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/fixpos-dialog-layout-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/fixpos-dialog-layout-expected.txt
@@ -7,9 +7,9 @@ showModal() should center in the viewport. PASS dialog.getBoundingClientRect().top is centeredTop -The computed top and bottom of a centered dialog should still have position auto. -PASS window.getComputedStyle(dialog).top is "auto" -PASS window.getComputedStyle(dialog).bottom is "auto" +The dialog is a positioned element, so the top and bottom should not have style auto. +PASS window.getComputedStyle(dialog).top is "290px" +PASS window.getComputedStyle(dialog).bottom is "290px" The dialog shold stay centered on scroll. PASS dialog.getBoundingClientRect().top is centeredTop
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/fixpos-dialog-layout.html b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/fixpos-dialog-layout.html index bab9fe3..b05e74a 100644 --- a/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/fixpos-dialog-layout.html +++ b/third_party/WebKit/LayoutTests/fast/dom/HTMLDialogElement/fixpos-dialog-layout.html
@@ -40,11 +40,14 @@ }()); (function() { - debug('<br>The computed top and bottom of a centered dialog should still have position auto.'); + debug('<br>The dialog is a positioned element, so the top and bottom should not have style auto.'); + dialog.style.height = '20px'; dialog.showModal(); - shouldBeEqualToString('window.getComputedStyle(dialog).top', 'auto'); - shouldBeEqualToString('window.getComputedStyle(dialog).bottom', 'auto'); + shouldBeEqualToString('window.getComputedStyle(dialog).top', '290px'); + shouldBeEqualToString('window.getComputedStyle(dialog).bottom', '290px'); + + dialog.style.height = 'auto'; reset(); }());
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/multiple-host-pseudos-in-compound-expected.txt b/third_party/WebKit/LayoutTests/fast/dom/shadow/multiple-host-pseudos-in-compound-expected.txt new file mode 100644 index 0000000..6dd084ac --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/multiple-host-pseudos-in-compound-expected.txt
@@ -0,0 +1,19 @@ +Multiple :host(-context) pseudos in same compound. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS getComputedStyle(host).color is "rgb(0, 128, 0)" +PASS getComputedStyle(host, '::before').color is "rgb(0, 128, 0)" +PASS getComputedStyle(host).color is "rgb(0, 128, 0)" +PASS getComputedStyle(host, '::before').color is "rgb(0, 128, 0)" +PASS getComputedStyle(host).color is "rgb(0, 128, 0)" +PASS getComputedStyle(host, '::before').color is "rgb(0, 128, 0)" +PASS getComputedStyle(host).color is "rgb(0, 128, 0)" +PASS getComputedStyle(host, '::before').color is "rgb(0, 128, 0)" +PASS getComputedStyle(host).color is "rgb(0, 128, 0)" +PASS getComputedStyle(host, '::before').color is "rgb(0, 128, 0)" +PASS successfullyParsed is true + +TEST COMPLETE +Should be green
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/multiple-host-pseudos-in-compound.html b/third_party/WebKit/LayoutTests/fast/dom/shadow/multiple-host-pseudos-in-compound.html new file mode 100644 index 0000000..5de532b --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/multiple-host-pseudos-in-compound.html
@@ -0,0 +1,23 @@ +<!DOCTYPE html> +<script src="../../../resources/js-test.js"></script> +<div id="host">Should be green</div> +<script> + description("Multiple :host(-context) pseudos in same compound."); + + host.createShadowRoot(); + + [ + ":host:host-context(body)", + ":host-context(:not(.nomatch)):host", + ":host:host:host", + ":host-context(body):host-context(html)", + ":host(:not(.nomatch)):host" + ].forEach((selector) => { + host.shadowRoot.innerHTML = "<style>" + selector + "{color:green}</style><content/>"; + shouldBeEqualToString("getComputedStyle(host).color", "rgb(0, 128, 0)"); + + host.shadowRoot.innerHTML = "<style>" + selector + "::before" + "{color:green;content:'green'}</style><content/>"; + shouldBeEqualToString("getComputedStyle(host, '::before').color", "rgb(0, 128, 0)"); + }); + +</script>
diff --git a/third_party/WebKit/LayoutTests/fast/encoding/unlabelled-non-ascii-utf8-expected.html b/third_party/WebKit/LayoutTests/fast/encoding/unlabelled-non-ascii-utf8-expected.html new file mode 100644 index 0000000..511c0fbc --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/encoding/unlabelled-non-ascii-utf8-expected.html
@@ -0,0 +1,48 @@ +<!DOCTYPE html> +<html> +<head> +<title>Unlabelled UTF-8</title> +<meta charset="utf-8"> +</head> +<body> + <p>UTF-8 page without a proper label. UTF-8 encoding detector + should come into action to detect the right encoding, hence + all the non-ASCII chars should be rendered as expected without + being garbled.</p> + <pre> + För var vers, jag gör, + Lovar du en kyss mig giva; + Arket fullt jag borde skriva, + Mindre har jag skrivit för. + Men man måste hålla måtta, + Jag med vers, med kyssar du. + Låt mig räkna: Där är sju! + En därtill det gör mig åtta. + + Numro åtta är fatal, + Greklands sångmör voro nio, + Och en svensk därtill gör tio. — + Elva var apostelns tal, + Ty jag räknar icke Judas, + Honom, som i vänners lag + Kysste falskt; det gör ej jag, + Helst när vackra läppar bjudas. + + Huru står min räkning här? + Aderton; det är dock något. + Nitton — rimmet gör besvär, + Därföre jag fyller tjoget. + Strofen är ej full som jag, + In i hamnen vill jag styra, + Därföre till godo tag + Denna gång med tjugofyra. + + 'Kyssarna' ('The kisses'), Esaias Tegnér, 1782-1846 + + int main(void) + { + return 0; + } + </pre> +</body> +</html>
diff --git a/third_party/WebKit/LayoutTests/fast/encoding/unlabelled-non-ascii-utf8.html b/third_party/WebKit/LayoutTests/fast/encoding/unlabelled-non-ascii-utf8.html new file mode 100644 index 0000000..aeddfef --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/encoding/unlabelled-non-ascii-utf8.html
@@ -0,0 +1,47 @@ +<!DOCTYPE html> +<html> +<head> +<title>Unlabelled UTF-8</title> +</head> +<body> + <p>UTF-8 page without a proper label. UTF-8 encoding detector + should come into action to detect the right encoding, hence + all the non-ASCII chars should be rendered as expected without + being garbled.</p> + <pre> + För var vers, jag gör, + Lovar du en kyss mig giva; + Arket fullt jag borde skriva, + Mindre har jag skrivit för. + Men man måste hålla måtta, + Jag med vers, med kyssar du. + Låt mig räkna: Där är sju! + En därtill det gör mig åtta. + + Numro åtta är fatal, + Greklands sångmör voro nio, + Och en svensk därtill gör tio. — + Elva var apostelns tal, + Ty jag räknar icke Judas, + Honom, som i vänners lag + Kysste falskt; det gör ej jag, + Helst när vackra läppar bjudas. + + Huru står min räkning här? + Aderton; det är dock något. + Nitton — rimmet gör besvär, + Därföre jag fyller tjoget. + Strofen är ej full som jag, + In i hamnen vill jag styra, + Därföre till godo tag + Denna gång med tjugofyra. + + 'Kyssarna' ('The kisses'), Esaias Tegnér, 1782-1846 + + int main(void) + { + return 0; + } + </pre> +</body> +</html>
diff --git a/third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-observer-iterate-no-crash-expected.txt b/third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-observer-iterate-no-crash-expected.txt new file mode 100644 index 0000000..d7c8c995 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-observer-iterate-no-crash-expected.txt
@@ -0,0 +1,10 @@ +Verify that MediaStreamTracks created while dispatching MediaStreamSource events do not crash. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS Test did not crash. +PASS successfullyParsed is true + +TEST COMPLETE +
diff --git a/third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-observer-iterate-no-crash.html b/third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-observer-iterate-no-crash.html new file mode 100644 index 0000000..f91618b --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-observer-iterate-no-crash.html
@@ -0,0 +1,41 @@ +<!DOCTYPE html> +<html> +<head> +<script src="../../resources/js-test.js"></script> +</head> +<body> +<script> +description("Verify that MediaStreamTracks created while dispatching MediaStreamSource events do not crash."); + +if (window.testRunner) { + testRunner.dumpAsText(); + testRunner.waitUntilDone(); +} + +var jsTestIsAsync = true; + +function getUserMedia(constraints, callback) { + try { + navigator.webkitGetUserMedia(constraints, callback, function () { }); + } catch (e) { + testFailed("Unexpected exception: " + e.toString()); + finishJSTest(); + } +} + +getUserMedia({audio: true,video: true}, function (stream) { + var track = stream.getTracks()[0]; + track.onmute = function () { + track.clone(); + track.stop(); + }; + track.onended = function () { + track.clone(undefined); + testPassed("Test did not crash."); + finishJSTest(); + }; + track.enabled = false; +}); +</script> +</body> +</html>
diff --git a/third_party/WebKit/LayoutTests/harness-tests/mojo-helpers.html b/third_party/WebKit/LayoutTests/harness-tests/mojo-helpers.html index 7e96946..17aa2607 100644 --- a/third_party/WebKit/LayoutTests/harness-tests/mojo-helpers.html +++ b/third_party/WebKit/LayoutTests/harness-tests/mojo-helpers.html
@@ -97,7 +97,7 @@ ['services/shell/public/interfaces/interface_provider.mojom']).then(mojo => { let interfaceProvider = mojo.modules[0]; assert_equals(interfaceProvider.InterfaceProvider.name, - 'mojo::shell::mojom::InterfaceProvider'); + 'shell::mojom::InterfaceProvider'); }); }, 'Generated mojo bindings can be loaded in tests');
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/console-cd-completions-expected.txt b/third_party/WebKit/LayoutTests/http/tests/inspector/console-cd-completions-expected.txt index 346f390a..3d663b22 100644 --- a/third_party/WebKit/LayoutTests/http/tests/inspector/console-cd-completions-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/inspector/console-cd-completions-expected.txt
@@ -3,4 +3,8 @@ myGlobalVar myGlobalFunction +myIFrame completions: +self +top +window
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/console-cd-completions.html b/third_party/WebKit/LayoutTests/http/tests/inspector/console-cd-completions.html index c5bd91f..ee68b97 100644 --- a/third_party/WebKit/LayoutTests/http/tests/inspector/console-cd-completions.html +++ b/third_party/WebKit/LayoutTests/http/tests/inspector/console-cd-completions.html
@@ -18,6 +18,26 @@ else InspectorTest.addResult("NOT FOUND: " + expected[i]); } + requestIFrameCompletions(); + } + + function requestIFrameCompletions() + { + InspectorTest.changeExecutionContext("top"); + WebInspector.context.flavor(WebInspector.ExecutionContext).completionsForExpression("myIFrame.", "myIFrame.", 0, "", false, checkIframeCompletions.bind(this)); + } + + function checkIframeCompletions(completions) + { + var completionSet = new Set(completions); + var expected = ["self", "top", "window"]; + InspectorTest.addResult("myIFrame completions:") + for (var completion of expected) { + if (completionSet.has(completion)) + InspectorTest.addResult(completion); + else + InspectorTest.addResult("NOT FOUND: " + completion); + } InspectorTest.dumpConsoleMessages(); InspectorTest.completeTest(); }
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/html/semantics/selectors/pseudo-classes/inrange-outofrange-expected.txt b/third_party/WebKit/LayoutTests/imported/web-platform-tests/html/semantics/selectors/pseudo-classes/inrange-outofrange-expected.txt deleted file mode 100644 index ceb660b..0000000 --- a/third_party/WebKit/LayoutTests/imported/web-platform-tests/html/semantics/selectors/pseudo-classes/inrange-outofrange-expected.txt +++ /dev/null
@@ -1,9 +0,0 @@ -This is a testharness.js-based test. -FAIL ':in-range' matches all elements that are candidates for constraint validation, have range limitations, and that are neither suffering from an underflow nor suffering from an overflow assert_array_equals: lengths differ, expected 1 got 2 -PASS ':out-of-range' matches all elements that are candidates for constraint validation, have range limitations, and that are either suffering from an underflow or suffering from an overflow -FAIL ':in-range' update number1's value < min assert_array_equals: lengths differ, expected 0 got 1 -PASS ':out-of-range' update number1's value < min -FAIL ':in-range' update number3's min < value assert_array_equals: lengths differ, expected 1 got 2 -PASS ':out-of-range' update number3's min < value -Harness: the test ran to completion. -
diff --git a/third_party/WebKit/LayoutTests/inspector/animation/animation-timeline-expected.txt b/third_party/WebKit/LayoutTests/inspector/animation/animation-timeline-expected.txt index 662f3e7e..c86523a9 100644 --- a/third_party/WebKit/LayoutTests/inspector/animation/animation-timeline-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/animation/animation-timeline-expected.txt
@@ -11,7 +11,7 @@ >>>> Animation with step timing function WebAnimation -<g style="cursor: -webkit-grab; transform: translateX(0px);"><g style="transform: translateX(0px);"><line class="animation-line" x1="7" y1="26" y2="26" x2="407.00" style="stroke: black;"></line><path class="animation-keyframe" d="M 0 26 L 0 5 L 400.00 5 L 400.00 26 Z" style="transform: translateX(7px); fill: black;"></path><circle class="animation-endpoint" cx="7.00" cy="26" r="3.5" style="stroke: black; fill: black; cursor: ew-resize;"></circle><circle class="animation-endpoint" cx="407.00" cy="26" r="3.5" style="stroke: black; fill: black; cursor: ew-resize;"></circle></g><g class="animation-tail-iterations"></g></g><line class="animation-delay-line" x1="7" y1="26" y2="26" x2="7.00" style="stroke: black;"></line><line class="animation-delay-line" x1="7" y1="26" y2="26" x2="7.00" style="stroke: black; transform: translateX(400px);"></line> +<g style="cursor: -webkit-grab; transform: translateX(0px);"><g style="transform: translateX(0px);"><line class="animation-line" x1="7" y1="26" y2="26" x2="407.00" style="stroke: black;"></line><g class="animation-keyframe-step" style="transform: translateX(7px);"><line x1="80" x2="80" y1="7" y2="26" style="stroke: black;"></line><line x1="160" x2="160" y1="7" y2="26" style="stroke: black;"></line><line x1="240" x2="240" y1="7" y2="26" style="stroke: black;"></line><line x1="320" x2="320" y1="7" y2="26" style="stroke: black;"></line><line x1="400" x2="400" y1="7" y2="26" style="stroke: black;"></line></g><circle class="animation-endpoint" cx="7.00" cy="26" r="3.5" style="stroke: black; fill: black; cursor: ew-resize;"></circle><circle class="animation-endpoint" cx="407.00" cy="26" r="3.5" style="stroke: black; fill: black; cursor: ew-resize;"></circle></g><g class="animation-tail-iterations"></g></g><line class="animation-delay-line" x1="7" y1="26" y2="26" x2="7.00" style="stroke: black;"></line><line class="animation-delay-line" x1="7" y1="26" y2="26" x2="7.00" style="stroke: black; transform: translateX(400px);"></line> >>>> CSS animation started CSSAnimation anim
diff --git a/third_party/WebKit/LayoutTests/inspector/animation/animation-timeline.html b/third_party/WebKit/LayoutTests/inspector/animation/animation-timeline.html index 363acbe..d23c5e63 100644 --- a/third_party/WebKit/LayoutTests/inspector/animation/animation-timeline.html +++ b/third_party/WebKit/LayoutTests/inspector/animation/animation-timeline.html
@@ -35,7 +35,7 @@ function startAnimationWithStepTiming() { - player = node.animate([{ width: "100px", easing: "step(5, end)" }, { width: "200px", easing: "step-start" }], 200); + player = node.animate([{ width: "100px", easing: "steps(5, end)" }, { width: "200px", easing: "step-start" }], 200); } function startCSSAnimation()
diff --git a/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-bottom-up-times-expected.txt b/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-bottom-up-times-expected.txt index f63785a7..b970ba8 100644 --- a/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-bottom-up-times-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-bottom-up-times-expected.txt
@@ -1,10 +1,10 @@ Tests bottom-up view self and total time calculation in CPU profiler. -2: (idle) 300 300 300.0 ms30.00 %300.0 ms30.00 %(idle) -1001: A 250 370 250.0 ms25.00 %370.0 ms37.00 %A -2000: C 200 250 200.0 ms20.00 %250.0 ms25.00 %C -1002: B 150 280 150.0 ms15.00 %280.0 ms28.00 %B -3000: D 50 50 50.0 ms5.00 %50.0 ms5.00 %D +2: (idle) 500 500 500.0 ms500.0 ms(idle) +1001: A 125 185 125.0 ms25.00 %185.0 ms37.00 %A +2000: C 100 125 100.0 ms20.00 %125.0 ms25.00 %C +1002: B 75 140 75.0 ms15.00 %140.0 ms28.00 %B +3000: D 25 25 25.0 ms5.00 %25.0 ms5.00 %D Profiler was disabled.
diff --git a/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-bottom-up-times.html b/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-bottom-up-times.html index 1baecd5..68dde35a 100644 --- a/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-bottom-up-times.html +++ b/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-bottom-up-times.html
@@ -17,7 +17,7 @@ "scriptId": "0", "url": "a.js", "lineNumber": 0, - "hitCount": 50, + "hitCount": 350, "callUID": 1000, "children": [ { @@ -25,7 +25,7 @@ "scriptId": "0", "url": "a.js", "lineNumber": 1, - "hitCount": 300, + "hitCount": 1000, "callUID": 2, "children": [] }, @@ -89,7 +89,6 @@ } ] }, - "idleTime": 0.300, "startTime": 0, "endTime": 1.000 }
diff --git a/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-calculate-time.html b/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-calculate-time.html index eb45c3a..82d8916 100644 --- a/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-calculate-time.html +++ b/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-calculate-time.html
@@ -93,7 +93,7 @@ "endTime": 1375445601.070847, "samples": [ 1, 2 ] }; - WebInspector.CPUProfileDataModel.prototype._calculateTimes(profileAndExpectations); + WebInspector.ProfileTreeModel.prototype._calculateTotals(profileAndExpectations.head); function checkExpectations(node) { if (Math.abs(node.selfTime - node.expectedSelfTime) > 0.0001) {
diff --git a/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-flame-chart-overview.html b/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-flame-chart-overview.html index afe26e4..545558d 100644 --- a/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-flame-chart-overview.html +++ b/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-flame-chart-overview.html
@@ -809,6 +809,8 @@ var profile = profileAndExpectations._profile; var startTime = profile.startTime * 1000; var endTime = profile.endTime * 1000; + profile.startTime /= 1000; + profile.endTime /= 1000; var samplingInterval = (endTime - startTime) / (profile.samples.length - 1); profile.timestamps = []; for (var i = 0; i < profile.samples.length; ++i)
diff --git a/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-native-nodes-filter-expected.txt b/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-native-nodes-filter-expected.txt index 87ca284..f6756c0 100644 --- a/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-native-nodes-filter-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-native-nodes-filter-expected.txt
@@ -1,10 +1,10 @@ Tests filtering of native nodes. -(root) id:1 hits:100000 depth:-1 - holder id:10 hits:11110 depth:0 - Aaaaaa id:5 hits:20 depth:1 - Bbb id:6 hits:200 depth:1 - C id:7 hits:22000 depth:0 - Ccc id:9 hits:1000 depth:1 +(root) id:1 total:134330 self:100000 depth:-1 + holder id:10 total:11330 self:11110 depth:0 + Aaaaaa id:5 total:20 self:20 depth:1 + Bbb id:6 total:200 self:200 depth:1 + C id:7 total:23000 self:22000 depth:0 + Ccc id:9 total:1000 self:1000 depth:1 1, 10, 10, 10, 5, 6, 7, 7, 9, 10
diff --git a/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-native-nodes-filter.html b/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-native-nodes-filter.html index 1955179..0356a4d 100644 --- a/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-native-nodes-filter.html +++ b/third_party/WebKit/LayoutTests/inspector/profiler/cpu-profiler-native-nodes-filter.html
@@ -104,15 +104,15 @@ ] }, "idleTime": 202.88199791684747, - "startTime": 1375445600.000847, - "endTime": 1375445601.070847, + "startTime": 100000, + "endTime": 100000 + 111.110 + 22.220 + 1.000, "samples": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] }; var model = new WebInspector.CPUProfileDataModel(profile); printTree("", model.profileHead); function printTree(padding, node) { - InspectorTest.addResult(padding + node.functionName + " id:" + node.id + " hits:" + node.hitCount + " depth:" + node.depth); + InspectorTest.addResult(`${padding}${node.functionName} id:${node.id} total:${node.total} self:${node.self} depth:${node.depth}`); node.children.forEach(printTree.bind(null, padding + " ")); } InspectorTest.addResult(model.samples.join(", "));
diff --git a/third_party/WebKit/LayoutTests/typedcssom/styleValue-parse-basic.html b/third_party/WebKit/LayoutTests/typedcssom/styleValue-parse-basic.html new file mode 100644 index 0000000..1b3754b --- /dev/null +++ b/third_party/WebKit/LayoutTests/typedcssom/styleValue-parse-basic.html
@@ -0,0 +1,39 @@ +<!DOCTYPE html> +<script src='../resources/testharness.js'></script> +<script src='../resources/testharnessreport.js'></script> +<script> + +test(function() { + var result = StyleValue.parse('width', '10px'); + + assert_not_equals(result, null); + assert_true(result instanceof SimpleLength); + assert_equals(result.value, 10); + assert_equals(result.type, 'px'); +}, 'Parsing 10px results in a SimpleLength'); + +test(function() { + assert_equals(StyleValue.parse('width', 'hello'), null); + assert_equals(StyleValue.parse('width', ''), null); + assert_equals(StyleValue.parse('width', null), null); +}, 'Parsing returns null on failure'); + +test(function() { + assert_throws(new TypeError(), function() { + StyleValue.parse('', '10px'); + }); +}, 'Passing in empty string to parse for the property name throws'); + +test(function() { + assert_throws(new TypeError(), function() { + StyleValue.parse('hello', '5px'); + }); +}, 'Passing in an invalid property name throws'); + +test(function() { + assert_throws(new TypeError(), function() { + StyleValue.parse('border', '10px'); + }); +}, 'Attempting to parse a value for a shorthand property throws'); + +</script>
diff --git a/third_party/WebKit/LayoutTests/web-animations-api/animation-effect-timing-easing.html b/third_party/WebKit/LayoutTests/web-animations-api/animation-effect-timing-easing.html new file mode 100644 index 0000000..71b6b486 --- /dev/null +++ b/third_party/WebKit/LayoutTests/web-animations-api/animation-effect-timing-easing.html
@@ -0,0 +1,63 @@ +<!DOCTYPE html> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> +<script> +var animate_with_easing = function(inputEasing) { + return document.documentElement.animate([], { easing : inputEasing }); +}; + +var assert_animate_with_easing_succeeds = function(inputEasing, expectedEasing) { + var animation = animate_with_easing(inputEasing); + assert_equals(animation.effect.timing.easing, expectedEasing); +}; + +var assert_animate_with_easing_roundtrips = function(inputEasing) { + assert_animate_with_easing_succeeds(inputEasing, inputEasing); +}; + +var assert_animate_with_easing_throws = function(inputEasing) { + assert_throws( + {name: 'TypeError'}, + function() { animate_with_easing(inputEasing); }, + 'with inputEasing=\'' + inputEasing + '\''); +}; + +test(function() { + assert_animate_with_easing_roundtrips('ease'); + assert_animate_with_easing_roundtrips('linear'); + assert_animate_with_easing_roundtrips('ease-in'); + assert_animate_with_easing_roundtrips('ease-out'); + assert_animate_with_easing_roundtrips('ease-in-out'); + assert_animate_with_easing_roundtrips('step-start'); + assert_animate_with_easing_roundtrips('step-middle'); + assert_animate_with_easing_roundtrips('step-end'); + assert_animate_with_easing_roundtrips('steps(3, start)'); + assert_animate_with_easing_roundtrips('steps(3, middle)'); + assert_animate_with_easing_roundtrips('steps(3, end)'); + assert_animate_with_easing_roundtrips('cubic-bezier(0.1, 5, 0.23, 0)'); +}, 'Valid easing functions should come out the same as they went in'); + +test(function() { + assert_animate_with_easing_succeeds('steps(3)', 'steps(3, end)'); +}, 'steps easing second parameter defaults to end'); + +test(function() { + assert_animate_with_easing_succeeds('eAse\\2d iN-ouT', 'ease-in-out'); +}, 'Should accept arbitrary casing and escape chararcters'); + +test(function() { + assert_animate_with_easing_throws(''); + assert_animate_with_easing_throws('initial'); + assert_animate_with_easing_throws('inherit'); + assert_animate_with_easing_throws('unset'); + assert_animate_with_easing_throws('steps(3, nowhere)'); + assert_animate_with_easing_throws('steps(-3, end)'); + assert_animate_with_easing_throws('cubic-bezier(0.1, 0, 4, 0.4)'); +}, 'Invalid easing values should throw a TypeError'); + +test(function() { + assert_animate_with_easing_succeeds('function (a){return a}', 'linear'); + assert_animate_with_easing_throws('function (x){return x}'); + assert_animate_with_easing_throws('function(x, y){return 0.3}'); +}, 'Function values for easing should throw a TypeError, except for one special linear case, which is deprecated for now and returns the default'); +</script>
diff --git a/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp b/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp index 62ee2276..82d8d0d 100644 --- a/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp
@@ -85,7 +85,6 @@ }; unsigned DOMWrapperWorld::isolatedWorldCount = 0; -DOMWrapperWorld* DOMWrapperWorld::worldOfInitializingWindow = 0; PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::create(v8::Isolate* isolate, int worldId, int extensionGroup) {
diff --git a/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h b/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h index c782ba0..317ce4b 100644 --- a/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h +++ b/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h
@@ -77,13 +77,6 @@ static DOMWrapperWorld& current(v8::Isolate* isolate) { - if (isMainThread() && worldOfInitializingWindow) { - // It's possible that current() is being called while window is being initialized. - // In order to make current() workable during the initialization phase, - // we cache the world of the initializing window on worldOfInitializingWindow. - // If there is no initiazing window, worldOfInitializingWindow is 0. - return *worldOfInitializingWindow; - } return world(isolate->GetCurrentContext()); } @@ -119,12 +112,6 @@ int extensionGroup() const { return m_extensionGroup; } DOMDataStore& domDataStore() const { return *m_domDataStore; } - static void setWorldOfInitializingWindow(DOMWrapperWorld* world) - { - ASSERT(isMainThread()); - worldOfInitializingWindow = world; - } - public: template<typename T> void registerDOMObjectHolder(v8::Isolate*, T*, v8::Local<v8::Value>); @@ -137,7 +124,6 @@ void unregisterDOMObjectHolder(DOMObjectHolderBase*); static unsigned isolatedWorldCount; - static DOMWrapperWorld* worldOfInitializingWindow; const int m_worldId; const int m_extensionGroup;
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8Binding.h b/third_party/WebKit/Source/bindings/core/v8/V8Binding.h index 10b13dc..6a452c6 100644 --- a/third_party/WebKit/Source/bindings/core/v8/V8Binding.h +++ b/third_party/WebKit/Source/bindings/core/v8/V8Binding.h
@@ -597,63 +597,7 @@ bool toV8Sequence(v8::Local<v8::Value>, uint32_t& length, v8::Isolate*, ExceptionState&); -// Converts a JavaScript value to an array as per the Web IDL specification: -// http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array -template <typename T, typename V8T> -Vector<RefPtr<T>> toRefPtrNativeArrayUnchecked(v8::Local<v8::Value> v8Value, uint32_t length, v8::Isolate* isolate, ExceptionState& exceptionState) -{ - Vector<RefPtr<T>> result; - result.reserveInitialCapacity(length); - v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); - v8::TryCatch block(isolate); - for (uint32_t i = 0; i < length; ++i) { - v8::Local<v8::Value> element; - if (!v8Call(object->Get(isolate->GetCurrentContext(), i), element, block)) { - exceptionState.rethrowV8Exception(block.Exception()); - return Vector<RefPtr<T>>(); - } - if (V8T::hasInstance(element, isolate)) { - v8::Local<v8::Object> elementObject = v8::Local<v8::Object>::Cast(element); - result.uncheckedAppend(V8T::toImpl(elementObject)); - } else { - exceptionState.throwTypeError("Invalid Array element type"); - return Vector<RefPtr<T>>(); - } - } - return result; -} - -template <typename T, typename V8T> -Vector<RefPtr<T>> toRefPtrNativeArray(v8::Local<v8::Value> value, int argumentIndex, v8::Isolate* isolate, ExceptionState& exceptionState) -{ - v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); - uint32_t length = 0; - if (value->IsArray()) { - length = v8::Local<v8::Array>::Cast(v8Value)->Length(); - } else if (!toV8Sequence(value, length, isolate, exceptionState)) { - if (!exceptionState.hadException()) - exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argumentIndex)); - return Vector<RefPtr<T>>(); - } - return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, exceptionState); -} - -template <typename T, typename V8T> -Vector<RefPtr<T>> toRefPtrNativeArray(v8::Local<v8::Value> value, const String& propertyName, v8::Isolate* isolate, ExceptionState& exceptionState) -{ - v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); - uint32_t length = 0; - if (value->IsArray()) { - length = v8::Local<v8::Array>::Cast(v8Value)->Length(); - } else if (!toV8Sequence(value, length, isolate, exceptionState)) { - if (!exceptionState.hadException()) - exceptionState.throwTypeError(ExceptionMessages::notASequenceTypeProperty(propertyName)); - return Vector<RefPtr<T>>(); - } - return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, exceptionState); -} - -template <typename T, typename V8T> +template <typename T> HeapVector<Member<T>> toMemberNativeArray(v8::Local<v8::Value> value, int argumentIndex, v8::Isolate* isolate, ExceptionState& exceptionState) { v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); @@ -676,9 +620,9 @@ exceptionState.rethrowV8Exception(block.Exception()); return HeapVector<Member<T>>(); } - if (V8T::hasInstance(element, isolate)) { + if (V8TypeOf<T>::Type::hasInstance(element, isolate)) { v8::Local<v8::Object> elementObject = v8::Local<v8::Object>::Cast(element); - result.uncheckedAppend(V8T::toImpl(elementObject)); + result.uncheckedAppend(V8TypeOf<T>::Type::toImpl(elementObject)); } else { exceptionState.throwTypeError("Invalid Array element type"); return HeapVector<Member<T>>(); @@ -687,7 +631,7 @@ return result; } -template <typename T, typename V8T> +template <typename T> HeapVector<Member<T>> toMemberNativeArray(v8::Local<v8::Value> value, const String& propertyName, v8::Isolate* isolate, ExceptionState& exceptionState) { v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); @@ -710,9 +654,9 @@ exceptionState.rethrowV8Exception(block.Exception()); return HeapVector<Member<T>>(); } - if (V8T::hasInstance(element, isolate)) { + if (V8TypeOf<T>::Type::hasInstance(element, isolate)) { v8::Local<v8::Object> elementObject = v8::Local<v8::Object>::Cast(element); - result.uncheckedAppend(V8T::toImpl(elementObject)); + result.uncheckedAppend(V8TypeOf<T>::Type::toImpl(elementObject)); } else { exceptionState.throwTypeError("Invalid Array element type"); return HeapVector<Member<T>>();
diff --git a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp index 33e5bfd..fb18985 100644 --- a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp
@@ -218,10 +218,7 @@ if (isContextInitialized()) return true; - DOMWrapperWorld::setWorldOfInitializingWindow(m_world.get()); - bool result = initialize(); - DOMWrapperWorld::setWorldOfInitializingWindow(0); - return result; + return initialize(); } bool WindowProxy::initialize()
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp index 65f7cb0..48ea91a 100644 --- a/third_party/WebKit/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp
@@ -114,7 +114,7 @@ const int portArrayIndex = 7; if (!isUndefinedOrNull(info[portArrayIndex])) { portArray = new MessagePortArray; - *portArray = toMemberNativeArray<MessagePort, V8MessagePort>(info[portArrayIndex], portArrayIndex + 1, info.GetIsolate(), exceptionState); + *portArray = toMemberNativeArray<MessagePort>(info[portArrayIndex], portArrayIndex + 1, info.GetIsolate(), exceptionState); if (exceptionState.throwIfNeeded()) return; }
diff --git a/third_party/WebKit/Source/bindings/scripts/v8_types.py b/third_party/WebKit/Source/bindings/scripts/v8_types.py index d52e835a..dc18cf24 100644 --- a/third_party/WebKit/Source/bindings/scripts/v8_types.py +++ b/third_party/WebKit/Source/bindings/scripts/v8_types.py
@@ -588,7 +588,7 @@ native_array_element_type.name != 'Dictionary'): this_cpp_type = None ref_ptr_type = 'Member' - expression_format = '(to{ref_ptr_type}NativeArray<{native_array_element_type}, V8{native_array_element_type}>({v8_value}, {index}, {isolate}, exceptionState))' + expression_format = '(to{ref_ptr_type}NativeArray<{native_array_element_type}>({v8_value}, {index}, {isolate}, exceptionState))' else: ref_ptr_type = None this_cpp_type = native_array_element_type.cpp_type
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.cpp index 28fc889b..b372236 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.cpp
@@ -509,7 +509,7 @@ if (testInterfaceGarbageCollectedSequenceMemberValue.IsEmpty() || testInterfaceGarbageCollectedSequenceMemberValue->IsUndefined()) { // Do nothing. } else { - HeapVector<Member<TestInterfaceGarbageCollected>> testInterfaceGarbageCollectedSequenceMember = (toMemberNativeArray<TestInterfaceGarbageCollected, V8TestInterfaceGarbageCollected>(testInterfaceGarbageCollectedSequenceMemberValue, 0, isolate, exceptionState)); + HeapVector<Member<TestInterfaceGarbageCollected>> testInterfaceGarbageCollectedSequenceMember = (toMemberNativeArray<TestInterfaceGarbageCollected>(testInterfaceGarbageCollectedSequenceMemberValue, 0, isolate, exceptionState)); if (exceptionState.hadException()) return; impl.setTestInterfaceGarbageCollectedSequenceMember(testInterfaceGarbageCollectedSequenceMember); @@ -563,7 +563,7 @@ if (testInterfaceSequenceMemberValue.IsEmpty() || testInterfaceSequenceMemberValue->IsUndefined()) { // Do nothing. } else { - HeapVector<Member<TestInterfaceImplementation>> testInterfaceSequenceMember = (toMemberNativeArray<TestInterface, V8TestInterface>(testInterfaceSequenceMemberValue, 0, isolate, exceptionState)); + HeapVector<Member<TestInterfaceImplementation>> testInterfaceSequenceMember = (toMemberNativeArray<TestInterface>(testInterfaceSequenceMemberValue, 0, isolate, exceptionState)); if (exceptionState.hadException()) return; impl.setTestInterfaceSequenceMember(testInterfaceSequenceMember);
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp index b728892..2f8ff43a 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp
@@ -1549,7 +1549,7 @@ v8::Local<v8::Object> holder = info.Holder(); ExceptionState exceptionState(ExceptionState::SetterContext, "testInterfaceEmptyArrayAttribute", "TestObject", holder, info.GetIsolate()); TestObject* impl = V8TestObject::toImpl(holder); - HeapVector<Member<TestInterfaceEmpty>> cppValue = (toMemberNativeArray<TestInterfaceEmpty, V8TestInterfaceEmpty>(v8Value, 0, info.GetIsolate(), exceptionState)); + HeapVector<Member<TestInterfaceEmpty>> cppValue = (toMemberNativeArray<TestInterfaceEmpty>(v8Value, 0, info.GetIsolate(), exceptionState)); if (exceptionState.throwIfNeeded()) return; impl->setTestInterfaceEmptyArrayAttribute(cppValue); @@ -6138,7 +6138,7 @@ TestObject* impl = V8TestObject::toImpl(info.Holder()); HeapVector<Member<TestInterfaceEmpty>> arrayTestInterfaceEmptyArg; { - arrayTestInterfaceEmptyArg = (toMemberNativeArray<TestInterfaceEmpty, V8TestInterfaceEmpty>(info[0], 1, info.GetIsolate(), exceptionState)); + arrayTestInterfaceEmptyArg = (toMemberNativeArray<TestInterfaceEmpty>(info[0], 1, info.GetIsolate(), exceptionState)); if (exceptionState.throwIfNeeded()) return; } @@ -6265,7 +6265,7 @@ TestObject* impl = V8TestObject::toImpl(info.Holder()); HeapVector<Member<TestInterfaceEmpty>> testInterfaceEmptySequenceArg; { - testInterfaceEmptySequenceArg = (toMemberNativeArray<TestInterfaceEmpty, V8TestInterfaceEmpty>(info[0], 1, info.GetIsolate(), exceptionState)); + testInterfaceEmptySequenceArg = (toMemberNativeArray<TestInterfaceEmpty>(info[0], 1, info.GetIsolate(), exceptionState)); if (exceptionState.throwIfNeeded()) return; } @@ -10707,7 +10707,7 @@ TestObject* impl = V8TestObject::toImpl(info.Holder()); HeapVector<Member<TestInterfaceGarbageCollected>> testInterfaceGarbageCollectedSequenceArg; { - testInterfaceGarbageCollectedSequenceArg = (toMemberNativeArray<TestInterfaceGarbageCollected, V8TestInterfaceGarbageCollected>(info[0], 1, info.GetIsolate(), exceptionState)); + testInterfaceGarbageCollectedSequenceArg = (toMemberNativeArray<TestInterfaceGarbageCollected>(info[0], 1, info.GetIsolate(), exceptionState)); if (exceptionState.throwIfNeeded()) return; } @@ -10730,7 +10730,7 @@ TestObject* impl = V8TestObject::toImpl(info.Holder()); HeapVector<Member<TestInterfaceGarbageCollected>> testInterfaceGarbageCollectedArrayArg; { - testInterfaceGarbageCollectedArrayArg = (toMemberNativeArray<TestInterfaceGarbageCollected, V8TestInterfaceGarbageCollected>(info[0], 1, info.GetIsolate(), exceptionState)); + testInterfaceGarbageCollectedArrayArg = (toMemberNativeArray<TestInterfaceGarbageCollected>(info[0], 1, info.GetIsolate(), exceptionState)); if (exceptionState.throwIfNeeded()) return; }
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp index 7ffd9f2a..599323b 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp
@@ -188,7 +188,7 @@ TestTypedefs* impl = V8TestTypedefs::toImpl(info.Holder()); HeapVector<Member<TestInterfaceEmpty>> testInterfaceEmptyTypeSequenceArg; { - testInterfaceEmptyTypeSequenceArg = (toMemberNativeArray<TestInterfaceEmpty, V8TestInterfaceEmpty>(info[0], 1, info.GetIsolate(), exceptionState)); + testInterfaceEmptyTypeSequenceArg = (toMemberNativeArray<TestInterfaceEmpty>(info[0], 1, info.GetIsolate(), exceptionState)); if (exceptionState.throwIfNeeded()) return; }
diff --git a/third_party/WebKit/Source/core/animation/AnimationEffectTiming.cpp b/third_party/WebKit/Source/core/animation/AnimationEffectTiming.cpp index 8d784c0..9135e0c 100644 --- a/third_party/WebKit/Source/core/animation/AnimationEffectTiming.cpp +++ b/third_party/WebKit/Source/core/animation/AnimationEffectTiming.cpp
@@ -4,6 +4,7 @@ #include "core/animation/AnimationEffectTiming.h" +#include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/UnionTypesCore.h" #include "core/animation/AnimationEffect.h" #include "core/animation/KeyframeEffect.h" @@ -127,7 +128,7 @@ m_parent->updateSpecifiedTiming(timing); } -void AnimationEffectTiming::setEasing(String easing) +void AnimationEffectTiming::setEasing(String easing, ExceptionState& exceptionState) { Timing timing = m_parent->specifiedTiming(); // The AnimationEffectTiming might not be attached to a document at this @@ -135,8 +136,8 @@ // calls are not considered in the WebAnimationsEasingAsFunction* // UseCounters, but the bug we are tracking there does not come through // this interface. - TimingInput::setTimingFunction(timing, easing, nullptr); - m_parent->updateSpecifiedTiming(timing); + if (TimingInput::setTimingFunction(timing, easing, nullptr, exceptionState)) + m_parent->updateSpecifiedTiming(timing); } DEFINE_TRACE(AnimationEffectTiming)
diff --git a/third_party/WebKit/Source/core/animation/AnimationEffectTiming.h b/third_party/WebKit/Source/core/animation/AnimationEffectTiming.h index 7983293..22d33d2 100644 --- a/third_party/WebKit/Source/core/animation/AnimationEffectTiming.h +++ b/third_party/WebKit/Source/core/animation/AnimationEffectTiming.h
@@ -12,6 +12,7 @@ namespace blink { +class ExceptionState; class UnrestrictedDoubleOrString; class CORE_EXPORT AnimationEffectTiming : public GarbageCollected<AnimationEffectTiming>, public ScriptWrappable { @@ -36,7 +37,7 @@ void setDuration(const UnrestrictedDoubleOrString&); void setPlaybackRate(double); void setDirection(String); - void setEasing(String); + void setEasing(String, ExceptionState&); DECLARE_TRACE();
diff --git a/third_party/WebKit/Source/core/animation/AnimationEffectTiming.idl b/third_party/WebKit/Source/core/animation/AnimationEffectTiming.idl index 3518bfa..def85d1 100644 --- a/third_party/WebKit/Source/core/animation/AnimationEffectTiming.idl +++ b/third_party/WebKit/Source/core/animation/AnimationEffectTiming.idl
@@ -17,5 +17,5 @@ // TODO(dstockwell): playbackRate has been removed from level 1. attribute double playbackRate; attribute DOMString direction; - attribute DOMString easing; + [RaisesException=Setter] attribute DOMString easing; };
diff --git a/third_party/WebKit/Source/core/animation/AnimationInputHelpers.cpp b/third_party/WebKit/Source/core/animation/AnimationInputHelpers.cpp index 21ad87c..4713937 100644 --- a/third_party/WebKit/Source/core/animation/AnimationInputHelpers.cpp +++ b/third_party/WebKit/Source/core/animation/AnimationInputHelpers.cpp
@@ -4,6 +4,7 @@ #include "core/animation/AnimationInputHelpers.h" +#include "bindings/core/v8/ExceptionState.h" #include "core/SVGNames.h" #include "core/css/CSSValueList.h" #include "core/css/parser/CSSParser.h" @@ -202,14 +203,17 @@ return iter->value; } -PassRefPtr<TimingFunction> AnimationInputHelpers::parseTimingFunction(const String& string, Document* document) +PassRefPtr<TimingFunction> AnimationInputHelpers::parseTimingFunction(const String& string, Document* document, ExceptionState& exceptionState) { - if (string.isEmpty()) + if (string.isEmpty()) { + exceptionState.throwTypeError("Easing may not be the empty string"); return nullptr; + } CSSValue* value = CSSParser::parseSingleValue(CSSPropertyTransitionTimingFunction, string); if (!value || !value->isValueList()) { ASSERT(!value || value->isCSSWideKeyword()); + bool throwTypeError = true; if (document) { if (string.startsWith("function")) { // Due to a bug in old versions of the web-animations-next @@ -221,18 +225,33 @@ // https://github.com/web-animations/web-animations-next/pull/423 // and we want to track how often it is still being hit. The // linear case is special because 'linear' is the default value - // for easing. - if (string == "function (a){return a}") - UseCounter::count(*document, UseCounter::WebAnimationsEasingAsFunctionLinear); - else + // for easing. See http://crbug.com/601672 + if (string == "function (a){return a}") { + Deprecation::countDeprecation(*document, UseCounter::WebAnimationsEasingAsFunctionLinear); + throwTypeError = false; + } else { UseCounter::count(*document, UseCounter::WebAnimationsEasingAsFunctionOther); + } } } + + // TODO(suzyh): This return clause exists so that the special linear + // function case above is exempted from causing TypeErrors. The + // throwTypeError bool and this if-statement should be removed after the + // M53 branch point in July 2016, so that this case will also throw + // TypeErrors from M54 onward. + if (!throwTypeError) { + return Timing::defaults().timingFunction; + } + + exceptionState.throwTypeError("'" + string + "' is not a valid value for easing"); return nullptr; } CSSValueList* valueList = toCSSValueList(value); - if (valueList->length() > 1) + if (valueList->length() > 1) { + exceptionState.throwTypeError("Easing may not be set to a list of values"); return nullptr; + } return CSSToStyleMap::mapAnimationTimingFunction(*valueList->item(0), true); }
diff --git a/third_party/WebKit/Source/core/animation/AnimationInputHelpers.h b/third_party/WebKit/Source/core/animation/AnimationInputHelpers.h index 7237abc..1fbbc14 100644 --- a/third_party/WebKit/Source/core/animation/AnimationInputHelpers.h +++ b/third_party/WebKit/Source/core/animation/AnimationInputHelpers.h
@@ -12,6 +12,7 @@ namespace blink { class Element; +class ExceptionState; class TimingFunction; class QualifiedName; @@ -21,7 +22,7 @@ static CSSPropertyID keyframeAttributeToCSSProperty(const String&, const Document&); static CSSPropertyID keyframeAttributeToPresentationAttribute(const String&, const Element&); static const QualifiedName* keyframeAttributeToSVGAttribute(const String&, Element&); - static PassRefPtr<TimingFunction> parseTimingFunction(const String&, Document*); + static PassRefPtr<TimingFunction> parseTimingFunction(const String&, Document*, ExceptionState&); }; } // namespace blink
diff --git a/third_party/WebKit/Source/core/animation/AnimationInputHelpersTest.cpp b/third_party/WebKit/Source/core/animation/AnimationInputHelpersTest.cpp index b4240a7..f659d4e 100644 --- a/third_party/WebKit/Source/core/animation/AnimationInputHelpersTest.cpp +++ b/third_party/WebKit/Source/core/animation/AnimationInputHelpersTest.cpp
@@ -5,6 +5,7 @@ #include "core/animation/AnimationInputHelpers.h" #include "core/dom/Element.h" +#include "core/dom/ExceptionCode.h" #include "core/testing/DummyPageHolder.h" #include "platform/animation/TimingFunction.h" #include "testing/gtest/include/gtest/gtest.h" @@ -18,17 +19,26 @@ return AnimationInputHelpers::keyframeAttributeToCSSProperty(property, *document); } - PassRefPtr<TimingFunction> parseTimingFunction(const String& string) + PassRefPtr<TimingFunction> parseTimingFunction(const String& string, ExceptionState& exceptionState) { - return AnimationInputHelpers::parseTimingFunction(string, document); + return AnimationInputHelpers::parseTimingFunction(string, document, exceptionState); } - bool timingFunctionRoundTrips(const String& string) + void timingFunctionRoundTrips(const String& string, ExceptionState& exceptionState) { - RefPtr<TimingFunction> timingFunction = parseTimingFunction(string); - return timingFunction && string == timingFunction->toString(); + RefPtr<TimingFunction> timingFunction = parseTimingFunction(string, exceptionState); + EXPECT_NE(nullptr, timingFunction); + EXPECT_EQ(string, timingFunction->toString()); } + void timingFunctionThrows(const String& string, ExceptionState& exceptionState) + { + RefPtr<TimingFunction> timingFunction = parseTimingFunction(string, exceptionState); + EXPECT_TRUE(exceptionState.hadException()); + EXPECT_EQ(V8TypeError, exceptionState.code()); + } + + protected: void SetUp() override { @@ -44,6 +54,7 @@ OwnPtr<DummyPageHolder> pageHolder; Persistent<Document> document; + TrackExceptionState exceptionState; }; TEST_F(AnimationAnimationInputHelpersTest, ParseKeyframePropertyAttributes) @@ -69,28 +80,29 @@ TEST_F(AnimationAnimationInputHelpersTest, ParseAnimationTimingFunction) { - EXPECT_EQ(nullptr, parseTimingFunction("initial")); - EXPECT_EQ(nullptr, parseTimingFunction("inherit")); - EXPECT_EQ(nullptr, parseTimingFunction("unset")); + timingFunctionThrows("", exceptionState); + timingFunctionThrows("initial", exceptionState); + timingFunctionThrows("inherit", exceptionState); + timingFunctionThrows("unset", exceptionState); - EXPECT_TRUE(timingFunctionRoundTrips("ease")); - EXPECT_TRUE(timingFunctionRoundTrips("linear")); - EXPECT_TRUE(timingFunctionRoundTrips("ease-in")); - EXPECT_TRUE(timingFunctionRoundTrips("ease-out")); - EXPECT_TRUE(timingFunctionRoundTrips("ease-in-out")); - EXPECT_TRUE(timingFunctionRoundTrips("step-start")); - EXPECT_TRUE(timingFunctionRoundTrips("step-middle")); - EXPECT_TRUE(timingFunctionRoundTrips("step-end")); - EXPECT_TRUE(timingFunctionRoundTrips("steps(3, start)")); - EXPECT_TRUE(timingFunctionRoundTrips("steps(3, middle)")); - EXPECT_TRUE(timingFunctionRoundTrips("steps(3, end)")); - EXPECT_TRUE(timingFunctionRoundTrips("cubic-bezier(0.1, 5, 0.23, 0)")); + timingFunctionRoundTrips("ease", exceptionState); + timingFunctionRoundTrips("linear", exceptionState); + timingFunctionRoundTrips("ease-in", exceptionState); + timingFunctionRoundTrips("ease-out", exceptionState); + timingFunctionRoundTrips("ease-in-out", exceptionState); + timingFunctionRoundTrips("step-start", exceptionState); + timingFunctionRoundTrips("step-middle", exceptionState); + timingFunctionRoundTrips("step-end", exceptionState); + timingFunctionRoundTrips("steps(3, start)", exceptionState); + timingFunctionRoundTrips("steps(3, middle)", exceptionState); + timingFunctionRoundTrips("steps(3, end)", exceptionState); + timingFunctionRoundTrips("cubic-bezier(0.1, 5, 0.23, 0)", exceptionState); - EXPECT_EQ("steps(3, end)", parseTimingFunction("steps(3)")->toString()); + EXPECT_EQ("steps(3, end)", parseTimingFunction("steps(3)", exceptionState)->toString()); - EXPECT_EQ(nullptr, parseTimingFunction("steps(3, nowhere)")); - EXPECT_EQ(nullptr, parseTimingFunction("steps(-3, end)")); - EXPECT_EQ(nullptr, parseTimingFunction("cubic-bezier(0.1, 0, 4, 0.4)")); + timingFunctionThrows("steps(3, nowhere)", exceptionState); + timingFunctionThrows("steps(-3, end)", exceptionState); + timingFunctionThrows("cubic-bezier(0.1, 0, 4, 0.4)", exceptionState); } } // namespace blink
diff --git a/third_party/WebKit/Source/core/animation/EffectInput.cpp b/third_party/WebKit/Source/core/animation/EffectInput.cpp index 49038de..4d60a9b2 100644 --- a/third_party/WebKit/Source/core/animation/EffectInput.cpp +++ b/third_party/WebKit/Source/core/animation/EffectInput.cpp
@@ -125,6 +125,7 @@ } keyframeEffectModel->forceConversionsToAnimatableValues(element, element.computedStyle()); + ASSERT(!exceptionState.hadException()); return keyframeEffectModel; } @@ -196,8 +197,10 @@ String timingFunctionString; if (DictionaryHelper::get(keyframeDictionary, "easing", timingFunctionString)) { - if (RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::parseTimingFunction(timingFunctionString, &element.document())) - keyframe->setEasing(timingFunction); + RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::parseTimingFunction(timingFunctionString, &element.document(), exceptionState); + if (!timingFunction) + return nullptr; + keyframe->setEasing(timingFunction); } Vector<String> keyframeProperties; @@ -223,8 +226,7 @@ keyframes.append(keyframe); } - if (exceptionState.hadException()) - return nullptr; + ASSERT(!exceptionState.hadException()); return createEffectModelFromKeyframes(element, keyframes, encounteredCompositableProperty, exceptionState); } @@ -236,8 +238,11 @@ String timingFunctionString; RefPtr<TimingFunction> timingFunction = nullptr; - if (DictionaryHelper::get(keyframeDictionary, "easing", timingFunctionString)) - timingFunction = AnimationInputHelpers::parseTimingFunction(timingFunctionString, &element.document()); + if (DictionaryHelper::get(keyframeDictionary, "easing", timingFunctionString)) { + timingFunction = AnimationInputHelpers::parseTimingFunction(timingFunctionString, &element.document(), exceptionState); + if (!timingFunction) + return nullptr; + } ScriptValue scriptValue; bool frameHasOffset = DictionaryHelper::get(keyframeDictionary, "offset", scriptValue) && !scriptValue.isNull(); @@ -290,6 +295,8 @@ std::sort(keyframes.begin(), keyframes.end(), compareKeyframes); + ASSERT(!exceptionState.hadException()); + return createEffectModelFromKeyframes(element, keyframes, encounteredCompositableProperty, exceptionState); }
diff --git a/third_party/WebKit/Source/core/animation/ElementAnimation.h b/third_party/WebKit/Source/core/animation/ElementAnimation.h index eda33d9..b1375fdc 100644 --- a/third_party/WebKit/Source/core/animation/ElementAnimation.h +++ b/third_party/WebKit/Source/core/animation/ElementAnimation.h
@@ -61,10 +61,12 @@ static Animation* animate(ExecutionContext* executionContext, Element& element, const EffectModelOrDictionarySequenceOrDictionary& effectInput, const KeyframeEffectOptions& options, ExceptionState& exceptionState) { EffectModel* effect = EffectInput::convert(&element, effectInput, executionContext, exceptionState); - if (exceptionState.hadException()) + Timing timing; + bool success = TimingInput::convert(options, timing, &element.document(), exceptionState); + if (!success || exceptionState.hadException()) return 0; - Animation* animation = animateInternal(element, effect, TimingInput::convert(options, &element.document())); + Animation* animation = animateInternal(element, effect, timing); animation->setId(options.id()); return animation; }
diff --git a/third_party/WebKit/Source/core/animation/KeyframeEffect.cpp b/third_party/WebKit/Source/core/animation/KeyframeEffect.cpp index 2a74232..4d989e7f 100644 --- a/third_party/WebKit/Source/core/animation/KeyframeEffect.cpp +++ b/third_party/WebKit/Source/core/animation/KeyframeEffect.cpp
@@ -60,13 +60,20 @@ UseCounter::count(element->document(), UseCounter::AnimationConstructorKeyframeListEffectObjectTiming); return create(element, EffectInput::convert(element, effectInput, executionContext, exceptionState), TimingInput::convert(duration)); } + KeyframeEffect* KeyframeEffect::create(ExecutionContext* executionContext, Element* element, const EffectModelOrDictionarySequenceOrDictionary& effectInput, const KeyframeEffectOptions& timingInput, ExceptionState& exceptionState) { ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); if (element) UseCounter::count(element->document(), UseCounter::AnimationConstructorKeyframeListEffectObjectTiming); - return create(element, EffectInput::convert(element, effectInput, executionContext, exceptionState), TimingInput::convert(timingInput, &element->document())); + Timing timing; + bool success = TimingInput::convert(timingInput, timing, &element->document(), exceptionState); + if (!success || exceptionState.hadException()) + return nullptr; + + return create(element, EffectInput::convert(element, effectInput, executionContext, exceptionState), timing); } + KeyframeEffect* KeyframeEffect::create(ExecutionContext* executionContext, Element* element, const EffectModelOrDictionarySequenceOrDictionary& effectInput, ExceptionState& exceptionState) { ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled());
diff --git a/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp b/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp index 5704309..e5ecb34 100644 --- a/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp +++ b/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp
@@ -236,7 +236,8 @@ EXPECT_EQ("reverse", specified->direction()); EXPECT_EQ("linear", specified->easing()); - specified->setEasing("step-start"); + specified->setEasing("step-start", exceptionState); + ASSERT_FALSE(exceptionState.hadException()); EXPECT_EQ("step-start", specified->easing()); }
diff --git a/third_party/WebKit/Source/core/animation/TimingInput.cpp b/third_party/WebKit/Source/core/animation/TimingInput.cpp index 2f5eea1..84f837f 100644 --- a/third_party/WebKit/Source/core/animation/TimingInput.cpp +++ b/third_party/WebKit/Source/core/animation/TimingInput.cpp
@@ -4,6 +4,7 @@ #include "core/animation/TimingInput.h" +#include "bindings/core/v8/ExceptionState.h" #include "core/animation/AnimationInputHelpers.h" #include "core/animation/KeyframeEffectOptions.h" @@ -85,34 +86,34 @@ } } -void TimingInput::setTimingFunction(Timing& timing, const String& timingFunctionString, Document* document) +bool TimingInput::setTimingFunction(Timing& timing, const String& timingFunctionString, Document* document, ExceptionState& exceptionState) { - if (RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::parseTimingFunction(timingFunctionString, document)) + if (RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::parseTimingFunction(timingFunctionString, document, exceptionState)) { timing.timingFunction = timingFunction; - else - timing.timingFunction = Timing::defaults().timingFunction; + return true; + } + return false; } -Timing TimingInput::convert(const KeyframeEffectOptions& timingInput, Document* document) +bool TimingInput::convert(const KeyframeEffectOptions& timingInput, Timing& timingOutput, Document* document, ExceptionState& exceptionState) { - Timing result; - - setStartDelay(result, timingInput.delay()); - setEndDelay(result, timingInput.endDelay()); - setFillMode(result, timingInput.fill()); - setIterationStart(result, timingInput.iterationStart()); - setIterationCount(result, timingInput.iterations()); + setStartDelay(timingOutput, timingInput.delay()); + setEndDelay(timingOutput, timingInput.endDelay()); + setFillMode(timingOutput, timingInput.fill()); + setIterationStart(timingOutput, timingInput.iterationStart()); + setIterationCount(timingOutput, timingInput.iterations()); if (timingInput.duration().isUnrestrictedDouble()) - setIterationDuration(result, timingInput.duration().getAsUnrestrictedDouble()); + setIterationDuration(timingOutput, timingInput.duration().getAsUnrestrictedDouble()); else - setIterationDuration(result, -1); - setPlaybackRate(result, timingInput.playbackRate()); - setPlaybackDirection(result, timingInput.direction()); - setTimingFunction(result, timingInput.easing(), document); + setIterationDuration(timingOutput, -1); + setPlaybackRate(timingOutput, timingInput.playbackRate()); + setPlaybackDirection(timingOutput, timingInput.direction()); + if (!setTimingFunction(timingOutput, timingInput.easing(), document, exceptionState)) + return false; - result.assertValid(); + timingOutput.assertValid(); - return result; + return true; } Timing TimingInput::convert(double duration)
diff --git a/third_party/WebKit/Source/core/animation/TimingInput.h b/third_party/WebKit/Source/core/animation/TimingInput.h index 073f180..2611357d 100644 --- a/third_party/WebKit/Source/core/animation/TimingInput.h +++ b/third_party/WebKit/Source/core/animation/TimingInput.h
@@ -13,12 +13,13 @@ class Dictionary; class Document; +class ExceptionState; class KeyframeEffectOptions; class CORE_EXPORT TimingInput { STATIC_ONLY(TimingInput); public: - static Timing convert(const KeyframeEffectOptions& timingInput, Document*); + static bool convert(const KeyframeEffectOptions& timingInput, Timing& timingOutput, Document*, ExceptionState&); static Timing convert(double duration); static void setStartDelay(Timing&, double startDelay); @@ -29,7 +30,7 @@ static void setIterationDuration(Timing&, double iterationDuration); static void setPlaybackRate(Timing&, double playbackRate); static void setPlaybackDirection(Timing&, const String& direction); - static void setTimingFunction(Timing&, const String& timingFunctionString, Document*); + static bool setTimingFunction(Timing&, const String& timingFunctionString, Document*, ExceptionState&); }; } // namespace blink
diff --git a/third_party/WebKit/Source/core/animation/TimingInputTest.cpp b/third_party/WebKit/Source/core/animation/TimingInputTest.cpp index d68ebf365..f351c4a0 100644 --- a/third_party/WebKit/Source/core/animation/TimingInputTest.cpp +++ b/third_party/WebKit/Source/core/animation/TimingInputTest.cpp
@@ -22,22 +22,26 @@ { } - Timing applyTimingInputNumber(String timingProperty, double timingPropertyValue) + Timing applyTimingInputNumber(String timingProperty, double timingPropertyValue, bool& timingConversionSuccess) { v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate); setV8ObjectPropertyAsNumber(m_isolate, timingInput, timingProperty, timingPropertyValue); KeyframeEffectOptions timingInputDictionary; V8KeyframeEffectOptions::toImpl(m_isolate, timingInput, timingInputDictionary, exceptionState); - return TimingInput::convert(timingInputDictionary, nullptr); + Timing result; + timingConversionSuccess = TimingInput::convert(timingInputDictionary, result, nullptr, exceptionState); + return result; } - Timing applyTimingInputString(String timingProperty, String timingPropertyValue) + Timing applyTimingInputString(String timingProperty, String timingPropertyValue, bool& timingConversionSuccess) { v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate); setV8ObjectPropertyAsString(m_isolate, timingInput, timingProperty, timingPropertyValue); KeyframeEffectOptions timingInputDictionary; V8KeyframeEffectOptions::toImpl(m_isolate, timingInput, timingInputDictionary, exceptionState); - return TimingInput::convert(timingInputDictionary, nullptr); + Timing result; + timingConversionSuccess = TimingInput::convert(timingInputDictionary, result, nullptr, exceptionState); + return result; } v8::Isolate* m_isolate; @@ -49,125 +53,156 @@ TEST_F(AnimationTimingInputTest, TimingInputStartDelay) { - EXPECT_EQ(1.1, applyTimingInputNumber("delay", 1100).startDelay); - EXPECT_EQ(-1, applyTimingInputNumber("delay", -1000).startDelay); - EXPECT_EQ(1, applyTimingInputString("delay", "1000").startDelay); - EXPECT_EQ(0, applyTimingInputString("delay", "1s").startDelay); - EXPECT_EQ(0, applyTimingInputString("delay", "Infinity").startDelay); - EXPECT_EQ(0, applyTimingInputString("delay", "-Infinity").startDelay); - EXPECT_EQ(0, applyTimingInputString("delay", "NaN").startDelay); - EXPECT_EQ(0, applyTimingInputString("delay", "rubbish").startDelay); + bool ignoredSuccess; + EXPECT_EQ(1.1, applyTimingInputNumber("delay", 1100, ignoredSuccess).startDelay); + EXPECT_EQ(-1, applyTimingInputNumber("delay", -1000, ignoredSuccess).startDelay); + EXPECT_EQ(1, applyTimingInputString("delay", "1000", ignoredSuccess).startDelay); + EXPECT_EQ(0, applyTimingInputString("delay", "1s", ignoredSuccess).startDelay); + EXPECT_EQ(0, applyTimingInputString("delay", "Infinity", ignoredSuccess).startDelay); + EXPECT_EQ(0, applyTimingInputString("delay", "-Infinity", ignoredSuccess).startDelay); + EXPECT_EQ(0, applyTimingInputString("delay", "NaN", ignoredSuccess).startDelay); + EXPECT_EQ(0, applyTimingInputString("delay", "rubbish", ignoredSuccess).startDelay); } TEST_F(AnimationTimingInputTest, TimingInputEndDelay) { - EXPECT_EQ(10, applyTimingInputNumber("endDelay", 10000).endDelay); - EXPECT_EQ(-2.5, applyTimingInputNumber("endDelay", -2500).endDelay); + bool ignoredSuccess; + EXPECT_EQ(10, applyTimingInputNumber("endDelay", 10000, ignoredSuccess).endDelay); + EXPECT_EQ(-2.5, applyTimingInputNumber("endDelay", -2500, ignoredSuccess).endDelay); } TEST_F(AnimationTimingInputTest, TimingInputFillMode) { Timing::FillMode defaultFillMode = Timing::FillModeAuto; + bool ignoredSuccess; - EXPECT_EQ(Timing::FillModeAuto, applyTimingInputString("fill", "auto").fillMode); - EXPECT_EQ(Timing::FillModeForwards, applyTimingInputString("fill", "forwards").fillMode); - EXPECT_EQ(Timing::FillModeNone, applyTimingInputString("fill", "none").fillMode); - EXPECT_EQ(Timing::FillModeBackwards, applyTimingInputString("fill", "backwards").fillMode); - EXPECT_EQ(Timing::FillModeBoth, applyTimingInputString("fill", "both").fillMode); - EXPECT_EQ(defaultFillMode, applyTimingInputString("fill", "everything!").fillMode); - EXPECT_EQ(defaultFillMode, applyTimingInputString("fill", "backwardsandforwards").fillMode); - EXPECT_EQ(defaultFillMode, applyTimingInputNumber("fill", 2).fillMode); + EXPECT_EQ(Timing::FillModeAuto, applyTimingInputString("fill", "auto", ignoredSuccess).fillMode); + EXPECT_EQ(Timing::FillModeForwards, applyTimingInputString("fill", "forwards", ignoredSuccess).fillMode); + EXPECT_EQ(Timing::FillModeNone, applyTimingInputString("fill", "none", ignoredSuccess).fillMode); + EXPECT_EQ(Timing::FillModeBackwards, applyTimingInputString("fill", "backwards", ignoredSuccess).fillMode); + EXPECT_EQ(Timing::FillModeBoth, applyTimingInputString("fill", "both", ignoredSuccess).fillMode); + EXPECT_EQ(defaultFillMode, applyTimingInputString("fill", "everything!", ignoredSuccess).fillMode); + EXPECT_EQ(defaultFillMode, applyTimingInputString("fill", "backwardsandforwards", ignoredSuccess).fillMode); + EXPECT_EQ(defaultFillMode, applyTimingInputNumber("fill", 2, ignoredSuccess).fillMode); } TEST_F(AnimationTimingInputTest, TimingInputIterationStart) { - EXPECT_EQ(1.1, applyTimingInputNumber("iterationStart", 1.1).iterationStart); - EXPECT_EQ(0, applyTimingInputNumber("iterationStart", -1).iterationStart); - EXPECT_EQ(0, applyTimingInputString("iterationStart", "Infinity").iterationStart); - EXPECT_EQ(0, applyTimingInputString("iterationStart", "-Infinity").iterationStart); - EXPECT_EQ(0, applyTimingInputString("iterationStart", "NaN").iterationStart); - EXPECT_EQ(0, applyTimingInputString("iterationStart", "rubbish").iterationStart); + bool ignoredSuccess; + EXPECT_EQ(1.1, applyTimingInputNumber("iterationStart", 1.1, ignoredSuccess).iterationStart); + EXPECT_EQ(0, applyTimingInputNumber("iterationStart", -1, ignoredSuccess).iterationStart); + EXPECT_EQ(0, applyTimingInputString("iterationStart", "Infinity", ignoredSuccess).iterationStart); + EXPECT_EQ(0, applyTimingInputString("iterationStart", "-Infinity", ignoredSuccess).iterationStart); + EXPECT_EQ(0, applyTimingInputString("iterationStart", "NaN", ignoredSuccess).iterationStart); + EXPECT_EQ(0, applyTimingInputString("iterationStart", "rubbish", ignoredSuccess).iterationStart); } TEST_F(AnimationTimingInputTest, TimingInputIterationCount) { - EXPECT_EQ(2.1, applyTimingInputNumber("iterations", 2.1).iterationCount); - EXPECT_EQ(0, applyTimingInputNumber("iterations", -1).iterationCount); + bool ignoredSuccess; + EXPECT_EQ(2.1, applyTimingInputNumber("iterations", 2.1, ignoredSuccess).iterationCount); + EXPECT_EQ(0, applyTimingInputNumber("iterations", -1, ignoredSuccess).iterationCount); - Timing timing = applyTimingInputString("iterations", "Infinity"); + Timing timing = applyTimingInputString("iterations", "Infinity", ignoredSuccess); EXPECT_TRUE(std::isinf(timing.iterationCount)); EXPECT_GT(timing.iterationCount, 0); - EXPECT_EQ(0, applyTimingInputString("iterations", "-Infinity").iterationCount); - EXPECT_EQ(1, applyTimingInputString("iterations", "NaN").iterationCount); - EXPECT_EQ(1, applyTimingInputString("iterations", "rubbish").iterationCount); + EXPECT_EQ(0, applyTimingInputString("iterations", "-Infinity", ignoredSuccess).iterationCount); + EXPECT_EQ(1, applyTimingInputString("iterations", "NaN", ignoredSuccess).iterationCount); + EXPECT_EQ(1, applyTimingInputString("iterations", "rubbish", ignoredSuccess).iterationCount); } TEST_F(AnimationTimingInputTest, TimingInputIterationDuration) { - EXPECT_EQ(1.1, applyTimingInputNumber("duration", 1100).iterationDuration); - EXPECT_TRUE(std::isnan(applyTimingInputNumber("duration", -1000).iterationDuration)); - EXPECT_TRUE(std::isnan(applyTimingInputString("duration", "1000").iterationDuration)); + bool ignoredSuccess; + EXPECT_EQ(1.1, applyTimingInputNumber("duration", 1100, ignoredSuccess).iterationDuration); + EXPECT_TRUE(std::isnan(applyTimingInputNumber("duration", -1000, ignoredSuccess).iterationDuration)); + EXPECT_TRUE(std::isnan(applyTimingInputString("duration", "1000", ignoredSuccess).iterationDuration)); - Timing timing = applyTimingInputNumber("duration", std::numeric_limits<double>::infinity()); + Timing timing = applyTimingInputNumber("duration", std::numeric_limits<double>::infinity(), ignoredSuccess); EXPECT_TRUE(std::isinf(timing.iterationDuration)); EXPECT_GT(timing.iterationDuration, 0); - EXPECT_TRUE(std::isnan(applyTimingInputString("duration", "-Infinity").iterationDuration)); - EXPECT_TRUE(std::isnan(applyTimingInputString("duration", "NaN").iterationDuration)); - EXPECT_TRUE(std::isnan(applyTimingInputString("duration", "auto").iterationDuration)); - EXPECT_TRUE(std::isnan(applyTimingInputString("duration", "rubbish").iterationDuration)); + EXPECT_TRUE(std::isnan(applyTimingInputString("duration", "-Infinity", ignoredSuccess).iterationDuration)); + EXPECT_TRUE(std::isnan(applyTimingInputString("duration", "NaN", ignoredSuccess).iterationDuration)); + EXPECT_TRUE(std::isnan(applyTimingInputString("duration", "auto", ignoredSuccess).iterationDuration)); + EXPECT_TRUE(std::isnan(applyTimingInputString("duration", "rubbish", ignoredSuccess).iterationDuration)); } TEST_F(AnimationTimingInputTest, TimingInputPlaybackRate) { - EXPECT_EQ(2.1, applyTimingInputNumber("playbackRate", 2.1).playbackRate); - EXPECT_EQ(-1, applyTimingInputNumber("playbackRate", -1).playbackRate); - EXPECT_EQ(1, applyTimingInputString("playbackRate", "Infinity").playbackRate); - EXPECT_EQ(1, applyTimingInputString("playbackRate", "-Infinity").playbackRate); - EXPECT_EQ(1, applyTimingInputString("playbackRate", "NaN").playbackRate); - EXPECT_EQ(1, applyTimingInputString("playbackRate", "rubbish").playbackRate); + bool ignoredSuccess; + EXPECT_EQ(2.1, applyTimingInputNumber("playbackRate", 2.1, ignoredSuccess).playbackRate); + EXPECT_EQ(-1, applyTimingInputNumber("playbackRate", -1, ignoredSuccess).playbackRate); + EXPECT_EQ(1, applyTimingInputString("playbackRate", "Infinity", ignoredSuccess).playbackRate); + EXPECT_EQ(1, applyTimingInputString("playbackRate", "-Infinity", ignoredSuccess).playbackRate); + EXPECT_EQ(1, applyTimingInputString("playbackRate", "NaN", ignoredSuccess).playbackRate); + EXPECT_EQ(1, applyTimingInputString("playbackRate", "rubbish", ignoredSuccess).playbackRate); } TEST_F(AnimationTimingInputTest, TimingInputDirection) { Timing::PlaybackDirection defaultPlaybackDirection = Timing::PlaybackDirectionNormal; + bool ignoredSuccess; - EXPECT_EQ(Timing::PlaybackDirectionNormal, applyTimingInputString("direction", "normal").direction); - EXPECT_EQ(Timing::PlaybackDirectionReverse, applyTimingInputString("direction", "reverse").direction); - EXPECT_EQ(Timing::PlaybackDirectionAlternate, applyTimingInputString("direction", "alternate").direction); - EXPECT_EQ(Timing::PlaybackDirectionAlternateReverse, applyTimingInputString("direction", "alternate-reverse").direction); - EXPECT_EQ(defaultPlaybackDirection, applyTimingInputString("direction", "rubbish").direction); - EXPECT_EQ(defaultPlaybackDirection, applyTimingInputNumber("direction", 2).direction); + EXPECT_EQ(Timing::PlaybackDirectionNormal, applyTimingInputString("direction", "normal", ignoredSuccess).direction); + EXPECT_EQ(Timing::PlaybackDirectionReverse, applyTimingInputString("direction", "reverse", ignoredSuccess).direction); + EXPECT_EQ(Timing::PlaybackDirectionAlternate, applyTimingInputString("direction", "alternate", ignoredSuccess).direction); + EXPECT_EQ(Timing::PlaybackDirectionAlternateReverse, applyTimingInputString("direction", "alternate-reverse", ignoredSuccess).direction); + EXPECT_EQ(defaultPlaybackDirection, applyTimingInputString("direction", "rubbish", ignoredSuccess).direction); + EXPECT_EQ(defaultPlaybackDirection, applyTimingInputNumber("direction", 2, ignoredSuccess).direction); } TEST_F(AnimationTimingInputTest, TimingInputTimingFunction) { const RefPtr<TimingFunction> defaultTimingFunction = LinearTimingFunction::shared(); + bool success; - EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease), *applyTimingInputString("easing", "ease").timingFunction); - EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseIn), *applyTimingInputString("easing", "ease-in").timingFunction); - EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseOut), *applyTimingInputString("easing", "ease-out").timingFunction); - EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseInOut), *applyTimingInputString("easing", "ease-in-out").timingFunction); - EXPECT_EQ(*LinearTimingFunction::shared(), *applyTimingInputString("easing", "linear").timingFunction); - EXPECT_EQ(*StepsTimingFunction::preset(StepsTimingFunction::Start), *applyTimingInputString("easing", "step-start").timingFunction); - EXPECT_EQ(*StepsTimingFunction::preset(StepsTimingFunction::Middle), *applyTimingInputString("easing", "step-middle").timingFunction); - EXPECT_EQ(*StepsTimingFunction::preset(StepsTimingFunction::End), *applyTimingInputString("easing", "step-end").timingFunction); - EXPECT_EQ(*CubicBezierTimingFunction::create(1, 1, 0.3, 0.3), *applyTimingInputString("easing", "cubic-bezier(1, 1, 0.3, 0.3)").timingFunction); - EXPECT_EQ(*StepsTimingFunction::create(3, StepsTimingFunction::Start), *applyTimingInputString("easing", "steps(3, start)").timingFunction); - EXPECT_EQ(*StepsTimingFunction::create(5, StepsTimingFunction::Middle), *applyTimingInputString("easing", "steps(5, middle)").timingFunction); - EXPECT_EQ(*StepsTimingFunction::create(5, StepsTimingFunction::End), *applyTimingInputString("easing", "steps(5, end)").timingFunction); - EXPECT_EQ(*defaultTimingFunction, *applyTimingInputString("easing", "steps(5.6, end)").timingFunction); - EXPECT_EQ(*defaultTimingFunction, *applyTimingInputString("easing", "cubic-bezier(2, 2, 0.3, 0.3)").timingFunction); - EXPECT_EQ(*defaultTimingFunction, *applyTimingInputString("easing", "rubbish").timingFunction); - EXPECT_EQ(*defaultTimingFunction, *applyTimingInputNumber("easing", 2).timingFunction); - EXPECT_EQ(*defaultTimingFunction, *applyTimingInputString("easing", "initial").timingFunction); + EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease), *applyTimingInputString("easing", "ease", success).timingFunction); + EXPECT_TRUE(success); + EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseIn), *applyTimingInputString("easing", "ease-in", success).timingFunction); + EXPECT_TRUE(success); + EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseOut), *applyTimingInputString("easing", "ease-out", success).timingFunction); + EXPECT_TRUE(success); + EXPECT_EQ(*CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseInOut), *applyTimingInputString("easing", "ease-in-out", success).timingFunction); + EXPECT_TRUE(success); + EXPECT_EQ(*LinearTimingFunction::shared(), *applyTimingInputString("easing", "linear", success).timingFunction); + EXPECT_TRUE(success); + EXPECT_EQ(*StepsTimingFunction::preset(StepsTimingFunction::Start), *applyTimingInputString("easing", "step-start", success).timingFunction); + EXPECT_TRUE(success); + EXPECT_EQ(*StepsTimingFunction::preset(StepsTimingFunction::Middle), *applyTimingInputString("easing", "step-middle", success).timingFunction); + EXPECT_TRUE(success); + EXPECT_EQ(*StepsTimingFunction::preset(StepsTimingFunction::End), *applyTimingInputString("easing", "step-end", success).timingFunction); + EXPECT_TRUE(success); + EXPECT_EQ(*CubicBezierTimingFunction::create(1, 1, 0.3, 0.3), *applyTimingInputString("easing", "cubic-bezier(1, 1, 0.3, 0.3)", success).timingFunction); + EXPECT_TRUE(success); + EXPECT_EQ(*StepsTimingFunction::create(3, StepsTimingFunction::Start), *applyTimingInputString("easing", "steps(3, start)", success).timingFunction); + EXPECT_TRUE(success); + EXPECT_EQ(*StepsTimingFunction::create(5, StepsTimingFunction::Middle), *applyTimingInputString("easing", "steps(5, middle)", success).timingFunction); + EXPECT_TRUE(success); + EXPECT_EQ(*StepsTimingFunction::create(5, StepsTimingFunction::End), *applyTimingInputString("easing", "steps(5, end)", success).timingFunction); + EXPECT_TRUE(success); + + applyTimingInputString("easing", "", success); + EXPECT_FALSE(success); + applyTimingInputString("easing", "steps(5.6, end)", success); + EXPECT_FALSE(success); + applyTimingInputString("easing", "cubic-bezier(2, 2, 0.3, 0.3)", success); + EXPECT_FALSE(success); + applyTimingInputString("easing", "rubbish", success); + EXPECT_FALSE(success); + applyTimingInputNumber("easing", 2, success); + EXPECT_FALSE(success); + applyTimingInputString("easing", "initial", success); + EXPECT_FALSE(success); } TEST_F(AnimationTimingInputTest, TimingInputEmpty) { Timing controlTiming; - Timing updatedTiming = TimingInput::convert(KeyframeEffectOptions(), nullptr); + Timing updatedTiming; + bool success = TimingInput::convert(KeyframeEffectOptions(), updatedTiming, nullptr, exceptionState); + EXPECT_TRUE(success); EXPECT_EQ(controlTiming.startDelay, updatedTiming.startDelay); EXPECT_EQ(controlTiming.fillMode, updatedTiming.fillMode);
diff --git a/third_party/WebKit/Source/core/core.gypi b/third_party/WebKit/Source/core/core.gypi index b83d898..02e9778 100644 --- a/third_party/WebKit/Source/core/core.gypi +++ b/third_party/WebKit/Source/core/core.gypi
@@ -1391,7 +1391,6 @@ 'css/parser/CSSTokenizerInputStream.cpp', 'css/parser/CSSVariableParser.cpp', 'css/parser/CSSVariableParser.h', - 'css/parser/LegacyCSSPropertyParser.cpp', 'css/parser/MediaQueryBlockWatcher.cpp', 'css/parser/MediaQueryParser.cpp', 'css/parser/SizesAttributeParser.cpp', @@ -2009,6 +2008,8 @@ 'page/scrolling/ScrollStateCallback.h', 'page/scrolling/StickyPositionScrollingConstraints.cpp', 'page/scrolling/StickyPositionScrollingConstraints.h', + 'page/scrolling/ViewportScrollCallback.cpp', + 'page/scrolling/ViewportScrollCallback.h', 'paint/BackgroundImageGeometry.cpp', 'paint/BackgroundImageGeometry.h', 'paint/BlockFlowPainter.cpp',
diff --git a/third_party/WebKit/Source/core/css/CSSFontSelector.cpp b/third_party/WebKit/Source/core/css/CSSFontSelector.cpp index 5f3c79d..eced738 100644 --- a/third_party/WebKit/Source/core/css/CSSFontSelector.cpp +++ b/third_party/WebKit/Source/core/css/CSSFontSelector.cpp
@@ -65,6 +65,11 @@ m_clients.add(client); } +void CSSFontSelector::unregisterForInvalidationCallbacks(CSSFontSelectorClient* client) +{ + m_clients.remove(client); +} + void CSSFontSelector::dispatchInvalidationCallbacks() { m_fontFaceCache.incrementVersion();
diff --git a/third_party/WebKit/Source/core/css/CSSFontSelector.h b/third_party/WebKit/Source/core/css/CSSFontSelector.h index 29f1e68..4e3ae52 100644 --- a/third_party/WebKit/Source/core/css/CSSFontSelector.h +++ b/third_party/WebKit/Source/core/css/CSSFontSelector.h
@@ -62,6 +62,7 @@ void fontCacheInvalidated() override; void registerForInvalidationCallbacks(CSSFontSelectorClient*); + void unregisterForInvalidationCallbacks(CSSFontSelectorClient*); Document* document() const { return m_document; } FontFaceCache* fontFaceCache() { return &m_fontFaceCache; }
diff --git a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp index 76fa72d..9ec10b7 100644 --- a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp +++ b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
@@ -162,19 +162,23 @@ static CSSValue* valueForPositionOffset(const ComputedStyle& style, CSSPropertyID propertyID, const LayoutObject* layoutObject) { - Length offset; + Length offset, opposite; switch (propertyID) { case CSSPropertyLeft: offset = style.left(); + opposite = style.right(); break; case CSSPropertyRight: offset = style.right(); + opposite = style.left(); break; case CSSPropertyTop: offset = style.top(); + opposite = style.bottom(); break; case CSSPropertyBottom: offset = style.bottom(); + opposite = style.top(); break; default: return nullptr; @@ -186,13 +190,63 @@ toLayoutBox(layoutObject)->containingBlockLogicalHeightForGetComputedStyle(); return zoomAdjustedPixelValue(valueForLength(offset, containingBlockSize), style); } - if (offset.isAuto()) { - // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined. - // In other words if left is auto and right is not auto, then left's computed value is negative right(). - // So we should get the opposite length unit and see if it is auto. - return cssValuePool().createIdentifierValue(CSSValueAuto); + + if (offset.isAuto() && layoutObject) { + // If the property applies to a positioned element and the resolved value of the display + // property is not none, the resolved value is the used value. + if (layoutObject->isInFlowPositioned()) { + // If e.g. left is auto and right is not auto, then left's computed value is negative right. + // So we get the opposite length unit and see if it is auto. + if (opposite.isAuto()) + return cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Pixels); + + if (opposite.hasPercent()) { + LayoutUnit containingBlockSize = + (propertyID == CSSPropertyLeft || propertyID == CSSPropertyRight) ? + toLayoutBox(layoutObject)->containingBlockLogicalWidthForContent() : + toLayoutBox(layoutObject)->containingBlockLogicalHeightForGetComputedStyle(); + return zoomAdjustedPixelValue(-floatValueForLength(opposite, containingBlockSize), style); + } + return zoomAdjustedPixelValue(-opposite.pixels(), style); + } + + if (layoutObject->isOutOfFlowPositioned()) { + // For fixed and absolute positioned elements, the top, left, bottom, and right + // are defined relative to the corresponding sides of the containing block. + LayoutBlock* container = layoutObject->containingBlock(); + const LayoutBox* layoutBox = toLayoutBox(layoutObject); + + // clientOffset is the distance from this object's border edge to the container's + // padding edge. Thus it includes margins which we subtract below. + const LayoutSize clientOffset = + layoutBox->locationOffset() - LayoutSize(container->clientLeft(), container->clientTop()); + LayoutUnit position; + + switch (propertyID) { + case CSSPropertyLeft: + position = clientOffset.width() - layoutBox->marginLeft(); + break; + case CSSPropertyTop: + position = clientOffset.height() - layoutBox->marginTop(); + break; + case CSSPropertyRight: + position = container->clientWidth() - layoutBox->marginRight() - + (layoutBox->offsetWidth() + clientOffset.width()); + break; + case CSSPropertyBottom: + position = container->clientHeight() - layoutBox->marginBottom() - + (layoutBox->offsetHeight() + clientOffset.height()); + break; + default: + ASSERT_NOT_REACHED(); + } + return zoomAdjustedPixelValue(position, style); + } } + if (offset.isAuto()) + return cssValuePool().createIdentifierValue(CSSValueAuto); + return zoomAdjustedPixelValueForLength(offset, style); }
diff --git a/third_party/WebKit/Source/core/css/RuleFeature.cpp b/third_party/WebKit/Source/core/css/RuleFeature.cpp index 7d665f6..d3aaa9ba 100644 --- a/third_party/WebKit/Source/core/css/RuleFeature.cpp +++ b/third_party/WebKit/Source/core/css/RuleFeature.cpp
@@ -610,10 +610,13 @@ break; case CSSSelector::PseudoHost: case CSSSelector::PseudoHostContext: - if (relation == CSSSelector::SubSelector) + if (!foundHostPseudo && relation == CSSSelector::SubSelector) return SelectorNeverMatches; - if (!current->isLastInTagHistory() && current->tagHistory()->match() != CSSSelector::PseudoElement) + if (!current->isLastInTagHistory() + && current->tagHistory()->match() != CSSSelector::PseudoElement + && !current->tagHistory()->isHostPseudoClass()) { return SelectorNeverMatches; + } foundHostPseudo = true; // fall through. default:
diff --git a/third_party/WebKit/Source/core/css/RuleSet.cpp b/third_party/WebKit/Source/core/css/RuleSet.cpp index 6d91eeb..d3ba8d9 100644 --- a/third_party/WebKit/Source/core/css/RuleSet.cpp +++ b/third_party/WebKit/Source/core/css/RuleSet.cpp
@@ -205,7 +205,6 @@ } if (component.isHostPseudoClass()) { - ASSERT(component.isLastInTagHistory() || (component.relation() == CSSSelector::SubSelector && component.tagHistory()->match() == CSSSelector::PseudoElement)); m_shadowHostRules.append(ruleData); return true; }
diff --git a/third_party/WebKit/Source/core/css/cssom/StyleValue.cpp b/third_party/WebKit/Source/core/css/cssom/StyleValue.cpp index 4b168d60..b862a39d 100644 --- a/third_party/WebKit/Source/core/css/cssom/StyleValue.cpp +++ b/third_party/WebKit/Source/core/css/cssom/StyleValue.cpp
@@ -4,15 +4,42 @@ #include "core/css/cssom/StyleValue.h" +#include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/ScriptValue.h" -#include "core/css/cssom/SimpleLength.h" +#include "bindings/core/v8/ToV8.h" +#include "core/StylePropertyShorthand.h" +#include "core/css/cssom/StyleValueFactory.h" +#include "core/css/parser/CSSParser.h" namespace blink { -ScriptValue StyleValue::parse(ScriptState* state, const String& property, const String& cssText) +ScriptValue StyleValue::parse(ScriptState* scriptState, const String& propertyName, const String& value, ExceptionState& exceptionState) { - // TODO: implement. - return ScriptValue(); + if (propertyName.isEmpty()) { + exceptionState.throwTypeError("Property name cannot be empty"); + return ScriptValue::createNull(scriptState); + } + + CSSPropertyID propertyID = cssPropertyID(propertyName); + if (propertyID == CSSPropertyInvalid) { + exceptionState.throwTypeError("Invalid property name"); + return ScriptValue::createNull(scriptState); + } + if (isShorthandProperty(propertyID)) { + exceptionState.throwTypeError("Parsing shorthand properties is not supported"); + return ScriptValue::createNull(scriptState); + } + + CSSValue* cssValue = CSSParser::parseSingleValue(propertyID, value, strictCSSParserContext()); + if (!cssValue) + return ScriptValue::createNull(scriptState); + + StyleValue* styleValue = StyleValueFactory::create(propertyID, *cssValue); + if (!styleValue) + return ScriptValue::createNull(scriptState); + + v8::Local<v8::Value> wrappedValue = toV8(styleValue, scriptState->context()->Global(), scriptState->isolate()); + return ScriptValue(scriptState, wrappedValue); } } // namespace blink
diff --git a/third_party/WebKit/Source/core/css/cssom/StyleValue.h b/third_party/WebKit/Source/core/css/cssom/StyleValue.h index 214dd9e..53ddb90 100644 --- a/third_party/WebKit/Source/core/css/cssom/StyleValue.h +++ b/third_party/WebKit/Source/core/css/cssom/StyleValue.h
@@ -12,6 +12,7 @@ namespace blink { +class ExceptionState; class ScriptState; class ScriptValue; @@ -27,7 +28,7 @@ virtual StyleValueType type() const = 0; - static ScriptValue parse(ScriptState*, const String& property, const String& cssText); + static ScriptValue parse(ScriptState*, const String& propertyName, const String& value, ExceptionState&); virtual CSSValue* toCSSValue() const = 0; virtual String cssString() const
diff --git a/third_party/WebKit/Source/core/css/cssom/StyleValue.idl b/third_party/WebKit/Source/core/css/cssom/StyleValue.idl index 7a8211bd..b5ea708 100644 --- a/third_party/WebKit/Source/core/css/cssom/StyleValue.idl +++ b/third_party/WebKit/Source/core/css/cssom/StyleValue.idl
@@ -6,6 +6,6 @@ RuntimeEnabled=CSSTypedOM, ] interface StyleValue { readonly attribute DOMString cssString; - // static (StyleValue or sequence<StyleValue>)? parse(DOMString property, DOMString cssText); - [CallWith=ScriptState] static object? parse(DOMString property, DOMString cssText); + // TODO(meade): Should be (StyleValue or sequence<StyleValue>)? instead of object?. Fix when the code generator supports this. + [RaisesException, CallWith=ScriptState] static object? parse(DOMString property, DOMString cssText); };
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp index 419adc0..eab4066 100644 --- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp +++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
@@ -18,6 +18,7 @@ #include "core/css/CSSGradientValue.h" #include "core/css/CSSGridAutoRepeatValue.h" #include "core/css/CSSGridLineNamesValue.h" +#include "core/css/CSSGridTemplateAreasValue.h" #include "core/css/CSSImageSetValue.h" #include "core/css/CSSPaintValue.h" #include "core/css/CSSPathValue.h" @@ -59,6 +60,39 @@ m_range.consumeWhitespace(); } +void CSSPropertyParser::addProperty(CSSPropertyID property, CSSValue* value, bool important, bool implicit) +{ + ASSERT(!isPropertyAlias(property)); + + int shorthandIndex = 0; + bool setFromShorthand = false; + + if (m_currentShorthand) { + Vector<StylePropertyShorthand, 4> shorthands; + getMatchingShorthandsForLonghand(property, &shorthands); + setFromShorthand = true; + if (shorthands.size() > 1) + shorthandIndex = indexOfShorthandForLonghand(m_currentShorthand, shorthands); + } + + m_parsedProperties->append(CSSProperty(property, value, important, setFromShorthand, shorthandIndex, implicit)); +} + +void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID property, CSSValue* value, bool important) +{ + const StylePropertyShorthand& shorthand = shorthandForProperty(property); + unsigned shorthandLength = shorthand.length(); + if (!shorthandLength) { + addProperty(property, value, important); + return; + } + + ShorthandScope scope(this, property); + const CSSPropertyID* longhands = shorthand.properties(); + for (unsigned i = 0; i < shorthandLength; ++i) + addProperty(longhands[i], value, important); +} + static bool hasInvalidNumericValues(const CSSParserTokenRange& range) { for (const CSSParserToken& token : range) { @@ -620,7 +654,7 @@ return list; } -static CSSValueList* consumeScale(CSSParserTokenRange& range, CSSParserMode cssParserMode) +static CSSValueList* consumeScale(CSSParserTokenRange& range) { ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled()); @@ -659,7 +693,7 @@ return list; } -static CSSValue* consumeCounter(CSSParserTokenRange& range, CSSParserMode cssParserMode, int defaultValue) +static CSSValue* consumeCounter(CSSParserTokenRange& range, int defaultValue) { if (range.peek().id() == CSSValueNone) return consumeIdent(range); @@ -938,7 +972,7 @@ return consumeLength(range, cssParserMode, ValueRangeNonNegative); } -static CSSValue* consumeColumnSpan(CSSParserTokenRange& range, CSSParserMode cssParserMode) +static CSSValue* consumeColumnSpan(CSSParserTokenRange& range) { return consumeIdent<CSSValueAll, CSSValueNone>(range); } @@ -2699,7 +2733,7 @@ return CSSValuePair::create(horizontal, vertical, CSSValuePair::DropIdenticalValues); } -static CSSValue* consumeBorderImageSlice(CSSPropertyID property, CSSParserTokenRange& range, CSSParserMode cssParserMode) +static CSSValue* consumeBorderImageSlice(CSSPropertyID property, CSSParserTokenRange& range) { bool fill = consumeIdent<CSSValueFill>(range); CSSPrimitiveValue* slices[4] = { 0 }; @@ -2782,7 +2816,7 @@ continue; } if (!slice) { - slice = consumeBorderImageSlice(property, range, context.mode()); + slice = consumeBorderImageSlice(property, range); if (slice) { ASSERT(!width && !outset); if (consumeSlashIncludingWhitespace(range)) { @@ -2899,21 +2933,21 @@ return nullptr; } -static CSSValue* consumeBackgroundSize(CSSPropertyID unresolvedProperty, CSSParserTokenRange& range, CSSParserMode mode) +static CSSValue* consumeBackgroundSize(CSSPropertyID unresolvedProperty, CSSParserTokenRange& range, CSSParserMode cssParserMode) { if (identMatches<CSSValueContain, CSSValueCover>(range.peek().id())) return consumeIdent(range); CSSPrimitiveValue* horizontal = consumeIdent<CSSValueAuto>(range); if (!horizontal) - horizontal = consumeLengthOrPercent(range, mode, ValueRangeAll, UnitlessQuirk::Forbid); + horizontal = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, UnitlessQuirk::Forbid); CSSPrimitiveValue* vertical = nullptr; if (!range.atEnd()) { if (range.peek().id() == CSSValueAuto) // `auto' is the default range.consumeIncludingWhitespace(); else - vertical = consumeLengthOrPercent(range, mode, ValueRangeAll, UnitlessQuirk::Forbid); + vertical = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, UnitlessQuirk::Forbid); } else if (unresolvedProperty == CSSPropertyAliasWebkitBackgroundSize) { // Legacy syntax: "-webkit-background-size: 10px" is equivalent to "background-size: 10px 10px". vertical = horizontal; @@ -2923,7 +2957,7 @@ return CSSValuePair::create(horizontal, vertical, CSSValuePair::KeepIdenticalValues); } -CSSValueList* consumeGridAutoFlow(CSSParserTokenRange& range) +static CSSValueList* consumeGridAutoFlow(CSSParserTokenRange& range) { CSSPrimitiveValue* rowOrColumnValue = consumeIdent<CSSValueRow, CSSValueColumn>(range); CSSPrimitiveValue* denseAlgorithm = consumeIdent<CSSValueDense>(range); @@ -3102,6 +3136,124 @@ return values; } +static bool allTracksAreFixedSized(CSSValueList& valueList) +{ + for (CSSValue* value : valueList) { + if (value->isGridLineNamesValue()) + continue; + // The auto-repeat value holds a <fixed-size> = <fixed-breadth> | minmax( <fixed-breadth>, <track-breadth> ) + if (value->isGridAutoRepeatValue()) { + if (!allTracksAreFixedSized(toCSSValueList(*value))) + return false; + continue; + } + const CSSPrimitiveValue& primitiveValue = value->isPrimitiveValue() + ? toCSSPrimitiveValue(*value) + : toCSSPrimitiveValue(*toCSSFunctionValue(*value).item(0)); + CSSValueID valueID = primitiveValue.getValueID(); + if (valueID == CSSValueMinContent || valueID == CSSValueMaxContent || valueID == CSSValueAuto || primitiveValue.isFlex()) + return false; + } + return true; +} + +static Vector<String> parseGridTemplateAreasColumnNames(const String& gridRowNames) +{ + ASSERT(!gridRowNames.isEmpty()); + Vector<String> columnNames; + // Using StringImpl to avoid checks and indirection in every call to String::operator[]. + StringImpl& text = *gridRowNames.impl(); + + StringBuilder areaName; + for (unsigned i = 0; i < text.length(); ++i) { + // TODO(rob.buis): this whitespace check misses \n and \t. + // https://drafts.csswg.org/css-grid/#valdef-grid-template-areas-string + // https://drafts.csswg.org/css-syntax-3/#whitespace + if (text[i] == ' ') { + if (!areaName.isEmpty()) { + columnNames.append(areaName.toString()); + areaName.clear(); + } + continue; + } + if (text[i] == '.') { + if (areaName == ".") + continue; + if (!areaName.isEmpty()) { + columnNames.append(areaName.toString()); + areaName.clear(); + } + } else { + // TODO(rob.buis): only allow name code points here. + if (areaName == ".") { + columnNames.append(areaName.toString()); + areaName.clear(); + } + } + + areaName.append(text[i]); + } + + if (!areaName.isEmpty()) + columnNames.append(areaName.toString()); + + return columnNames; +} + +static bool parseGridTemplateAreasRow(const String& gridRowNames, NamedGridAreaMap& gridAreaMap, const size_t rowCount, size_t& columnCount) +{ + if (gridRowNames.isEmpty() || gridRowNames.containsOnlyWhitespace()) + return false; + + Vector<String> columnNames = parseGridTemplateAreasColumnNames(gridRowNames); + if (rowCount == 0) { + columnCount = columnNames.size(); + ASSERT(columnCount); + } else if (columnCount != columnNames.size()) { + // The declaration is invalid if all the rows don't have the number of columns. + return false; + } + + for (size_t currentColumn = 0; currentColumn < columnCount; ++currentColumn) { + const String& gridAreaName = columnNames[currentColumn]; + + // Unamed areas are always valid (we consider them to be 1x1). + if (gridAreaName == ".") + continue; + + size_t lookAheadColumn = currentColumn + 1; + while (lookAheadColumn < columnCount && columnNames[lookAheadColumn] == gridAreaName) + lookAheadColumn++; + + NamedGridAreaMap::iterator gridAreaIt = gridAreaMap.find(gridAreaName); + if (gridAreaIt == gridAreaMap.end()) { + gridAreaMap.add(gridAreaName, GridArea(GridSpan::translatedDefiniteGridSpan(rowCount, rowCount + 1), GridSpan::translatedDefiniteGridSpan(currentColumn, lookAheadColumn))); + } else { + GridArea& gridArea = gridAreaIt->value; + + // The following checks test that the grid area is a single filled-in rectangle. + // 1. The new row is adjacent to the previously parsed row. + if (rowCount != gridArea.rows.endLine()) + return false; + + // 2. The new area starts at the same position as the previously parsed area. + if (currentColumn != gridArea.columns.startLine()) + return false; + + // 3. The new area ends at the same position as the previously parsed area. + if (lookAheadColumn != gridArea.columns.endLine()) + return false; + + gridArea.rows = GridSpan::translatedDefiniteGridSpan(gridArea.rows.startLine(), gridArea.rows.endLine() + 1); + } + currentColumn = lookAheadColumn - 1; + } + + return true; +} + +enum TrackSizeRestriction { FixedSizeOnly, AllowAll }; + static CSSPrimitiveValue* consumeGridBreadth(CSSParserTokenRange& range, CSSParserMode cssParserMode, TrackSizeRestriction restriction = AllowAll) { if (restriction == AllowAll) { @@ -3118,7 +3270,7 @@ } // TODO(rob.buis): This needs a bool parameter so we can disallow <auto-track-list> for the grid shorthand. -CSSValue* consumeGridTrackSize(CSSParserTokenRange& range, CSSParserMode cssParserMode, TrackSizeRestriction restriction) +static CSSValue* consumeGridTrackSize(CSSParserTokenRange& range, CSSParserMode cssParserMode, TrackSizeRestriction restriction = AllowAll) { const CSSParserToken& token = range.peek(); if (restriction == AllowAll && identMatches<CSSValueAuto>(token.id())) @@ -3313,7 +3465,7 @@ case CSSPropertyRotate: return consumeRotation(m_range); case CSSPropertyScale: - return consumeScale(m_range, m_context.mode()); + return consumeScale(m_range); case CSSPropertyTranslate: return consumeTranslate(m_range, m_context.mode()); case CSSPropertyWebkitBorderHorizontalSpacing: @@ -3321,7 +3473,7 @@ return consumeLength(m_range, m_context.mode(), ValueRangeNonNegative); case CSSPropertyCounterIncrement: case CSSPropertyCounterReset: - return consumeCounter(m_range, m_context.mode(), property == CSSPropertyCounterIncrement ? 1 : 0); + return consumeCounter(m_range, property == CSSPropertyCounterIncrement ? 1 : 0); case CSSPropertySize: return consumeSize(m_range, m_context.mode()); case CSSPropertySnapHeight: @@ -3390,7 +3542,7 @@ case CSSPropertyColumnGap: return consumeColumnGap(m_range, m_context.mode()); case CSSPropertyColumnSpan: - return consumeColumnSpan(m_range, m_context.mode()); + return consumeColumnSpan(m_range); case CSSPropertyZoom: return consumeZoom(m_range, m_context); case CSSPropertyAnimationDelay: @@ -3589,7 +3741,7 @@ return consumeBorderImageRepeat(m_range); case CSSPropertyBorderImageSlice: case CSSPropertyWebkitMaskBoxImageSlice: - return consumeBorderImageSlice(property, m_range, m_context.mode()); + return consumeBorderImageSlice(property, m_range); case CSSPropertyBorderImageOutset: case CSSPropertyWebkitMaskBoxImageOutset: return consumeBorderImageOutset(m_range); @@ -3982,7 +4134,7 @@ } } -static bool consumeColumnWidthOrCount(CSSParserTokenRange& range, CSSParserMode cssParserMode, CSSValue*& columnWidth, CSSValue*& columnCount) +static bool consumeColumnWidthOrCount(CSSParserTokenRange& range, CSSValue*& columnWidth, CSSValue*& columnCount) { if (range.peek().id() == CSSValueAuto) { consumeIdent(range); @@ -4002,9 +4154,9 @@ { CSSValue* columnWidth = nullptr; CSSValue* columnCount = nullptr; - if (!consumeColumnWidthOrCount(m_range, m_context.mode(), columnWidth, columnCount)) + if (!consumeColumnWidthOrCount(m_range, columnWidth, columnCount)) return false; - consumeColumnWidthOrCount(m_range, m_context.mode(), columnWidth, columnCount); + consumeColumnWidthOrCount(m_range, columnWidth, columnCount); if (!m_range.atEnd()) return false; if (!columnWidth) @@ -4563,6 +4715,70 @@ return consumeGridTemplateRowsAndAreasAndColumns(important); } +bool CSSPropertyParser::consumeGridShorthand(bool important) +{ + ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); + ASSERT(shorthandForProperty(CSSPropertyGrid).length() == 8); + + CSSParserTokenRange rangeCopy = m_range; + + // 1- <grid-template> + if (consumeGridTemplateShorthand(important)) { + // It can only be specified the explicit or the implicit grid properties in a single grid declaration. + // The sub-properties not specified are set to their initial value, as normal for shorthands. + addProperty(CSSPropertyGridAutoFlow, cssValuePool().createImplicitInitialValue(), important); + addProperty(CSSPropertyGridAutoColumns, cssValuePool().createImplicitInitialValue(), important); + addProperty(CSSPropertyGridAutoRows, cssValuePool().createImplicitInitialValue(), important); + addProperty(CSSPropertyGridColumnGap, cssValuePool().createImplicitInitialValue(), important); + addProperty(CSSPropertyGridRowGap, cssValuePool().createImplicitInitialValue(), important); + return true; + } + + m_range = rangeCopy; + + // 2- <grid-auto-flow> [ <grid-auto-rows> [ / <grid-auto-columns> ]? ] + CSSValueList* gridAutoFlow = consumeGridAutoFlow(m_range); + if (!gridAutoFlow) + return false; + + CSSValue* autoColumnsValue = nullptr; + CSSValue* autoRowsValue = nullptr; + + if (!m_range.atEnd()) { + autoRowsValue = consumeGridTrackSize(m_range, m_context.mode()); + if (!autoRowsValue) + return false; + if (consumeSlashIncludingWhitespace(m_range)) { + autoColumnsValue = consumeGridTrackSize(m_range, m_context.mode()); + if (!autoColumnsValue) + return false; + } + if (!m_range.atEnd()) + return false; + } else { + // Other omitted values are set to their initial values. + autoColumnsValue = cssValuePool().createImplicitInitialValue(); + autoRowsValue = cssValuePool().createImplicitInitialValue(); + } + + // if <grid-auto-columns> value is omitted, it is set to the value specified for grid-auto-rows. + if (!autoColumnsValue) + autoColumnsValue = autoRowsValue; + + // It can only be specified the explicit or the implicit grid properties in a single grid declaration. + // The sub-properties not specified are set to their initial value, as normal for shorthands. + addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createImplicitInitialValue(), important); + addProperty(CSSPropertyGridTemplateRows, cssValuePool().createImplicitInitialValue(), important); + addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createImplicitInitialValue(), important); + addProperty(CSSPropertyGridAutoFlow, gridAutoFlow, important); + addProperty(CSSPropertyGridAutoColumns, autoColumnsValue, important); + addProperty(CSSPropertyGridAutoRows, autoRowsValue, important); + addProperty(CSSPropertyGridColumnGap, cssValuePool().createImplicitInitialValue(), important); + addProperty(CSSPropertyGridRowGap, cssValuePool().createImplicitInitialValue(), important); + + return true; +} + bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool important) { CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); @@ -4747,13 +4963,11 @@ return consumeGridAreaShorthand(important); case CSSPropertyGridTemplate: return consumeGridTemplateShorthand(important); + case CSSPropertyGrid: + return consumeGridShorthand(important); default: m_currentShorthand = oldShorthand; - CSSParserValueList valueList(m_range); - if (!valueList.size()) - return false; - m_valueList = &valueList; - return legacyParseShorthand(unresolvedProperty, important); + return false; } }
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h index 4c5a5c5..e74f778 100644 --- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h +++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h
@@ -23,30 +23,17 @@ #ifndef CSSPropertyParser_h #define CSSPropertyParser_h -#include "core/css/CSSGridTemplateAreasValue.h" #include "core/css/StyleRule.h" #include "core/css/parser/CSSParserTokenRange.h" -#include "platform/Length.h" namespace blink { -class CSSCustomIdentValue; -class CSSFunctionValue; -class CSSGradientValue; -class CSSGridLineNamesValue; struct CSSParserString; -struct CSSParserValue; -class CSSParserValueList; -class CSSPrimitiveValue; class CSSProperty; class CSSValue; -class CSSValueList; class StylePropertyShorthand; -// TODO(rob.buis) to move to cpp file once legacy parser is removed. -enum TrackSizeRestriction { FixedSizeOnly, AllowAll }; - -// Inputs: PropertyID, isImportant bool, CSSParserValueList. +// Inputs: PropertyID, isImportant bool, CSSParserTokenRange. // Outputs: Vector of CSSProperties class CSSPropertyParser { @@ -73,9 +60,6 @@ bool consumeCSSWideKeyword(CSSPropertyID unresolvedProperty, bool important); CSSValue* parseSingleValue(CSSPropertyID); - bool legacyParseShorthand(CSSPropertyID, bool important); - - bool inShorthand() const { return m_inParseShorthand; } bool inQuirksMode() const { return isQuirksModeBehavior(m_context.mode()); } bool parseViewportDescriptor(CSSPropertyID propId, bool important); @@ -99,9 +83,8 @@ bool consumeGridItemPositionShorthand(CSSPropertyID, bool important); bool consumeGridTemplateRowsAndAreasAndColumns(bool important); bool consumeGridTemplateShorthand(bool important); - bool parseGridShorthand(bool important); + bool consumeGridShorthand(bool important); bool consumeGridAreaShorthand(bool important); - bool parseGridLineNames(CSSParserValueList&, CSSValueList&, CSSGridLineNamesValue* = nullptr); bool consumeFont(bool important); bool consumeSystemFont(bool important); @@ -135,7 +118,6 @@ private: // Inputs: - CSSParserValueList* m_valueList; CSSParserTokenRange m_range; const CSSParserContext& m_context; @@ -145,15 +127,8 @@ // Locals during parsing: int m_inParseShorthand; CSSPropertyID m_currentShorthand; - Member<CSSCalcValue> m_parsedCalculation; }; -// TODO(rob.buis): should move to CSSPropertyParser after conversion. -bool allTracksAreFixedSized(CSSValueList&); -bool parseGridTemplateAreasRow(const String&, NamedGridAreaMap&, const size_t, size_t&); -CSSValueList* consumeGridAutoFlow(CSSParserTokenRange&); -CSSValue* consumeGridTrackSize(CSSParserTokenRange&, CSSParserMode, TrackSizeRestriction = AllowAll); - CSSPropertyID unresolvedCSSPropertyID(const CSSParserString&); CSSValueID cssValueKeywordID(const CSSParserString&);
diff --git a/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp deleted file mode 100644 index cdf953f..0000000 --- a/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp +++ /dev/null
@@ -1,273 +0,0 @@ -/* - * Copyright (C) 2003 Lars Knoll (knoll@kde.org) - * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) - * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. - * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> - * Copyright (C) 2008 Eric Seidel <eric@webkit.org> - * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) - * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. - * Copyright (C) 2012 Intel Corporation. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "core/css/parser/CSSPropertyParser.h" - -#include "core/StylePropertyShorthand.h" -#include "core/css/CSSCustomIdentValue.h" -#include "core/css/CSSFunctionValue.h" -#include "core/css/CSSGridAutoRepeatValue.h" -#include "core/css/CSSGridLineNamesValue.h" -#include "core/css/CSSPrimitiveValueMappings.h" -#include "core/css/CSSValuePair.h" -#include "core/css/CSSValuePool.h" -#include "core/css/parser/CSSParserValues.h" -#include "core/css/parser/CSSPropertyParserHelpers.h" -#include "core/style/GridArea.h" -#include "platform/RuntimeEnabledFeatures.h" - -namespace blink { - -using namespace CSSPropertyParserHelpers; - -void CSSPropertyParser::addProperty(CSSPropertyID propId, CSSValue* value, bool important, bool implicit) -{ - ASSERT(!isPropertyAlias(propId)); - - int shorthandIndex = 0; - bool setFromShorthand = false; - - if (m_currentShorthand) { - Vector<StylePropertyShorthand, 4> shorthands; - getMatchingShorthandsForLonghand(propId, &shorthands); - setFromShorthand = true; - if (shorthands.size() > 1) - shorthandIndex = indexOfShorthandForLonghand(m_currentShorthand, shorthands); - } - - m_parsedProperties->append(CSSProperty(propId, value, important, setFromShorthand, shorthandIndex, implicit)); -} - -void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, CSSValue* value, bool important) -{ - const StylePropertyShorthand& shorthand = shorthandForProperty(propId); - unsigned shorthandLength = shorthand.length(); - if (!shorthandLength) { - addProperty(propId, value, important); - return; - } - - ShorthandScope scope(this, propId); - const CSSPropertyID* longhands = shorthand.properties(); - for (unsigned i = 0; i < shorthandLength; ++i) - addProperty(longhands[i], value, important); -} - -bool CSSPropertyParser::legacyParseShorthand(CSSPropertyID propertyID, bool important) -{ - switch (propertyID) { - case CSSPropertyGrid: - ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); - return parseGridShorthand(important); - - // The remaining shorthands are handled in CSSPropertyParser.cpp - default: - return false; - } -} - -bool CSSPropertyParser::parseGridShorthand(bool important) -{ - ShorthandScope scope(this, CSSPropertyGrid); - ASSERT(shorthandForProperty(CSSPropertyGrid).length() == 8); - - CSSParserTokenRange rangeCopy = m_range; - - // 1- <grid-template> - if (consumeGridTemplateShorthand(important)) { - // It can only be specified the explicit or the implicit grid properties in a single grid declaration. - // The sub-properties not specified are set to their initial value, as normal for shorthands. - addProperty(CSSPropertyGridAutoFlow, cssValuePool().createImplicitInitialValue(), important); - addProperty(CSSPropertyGridAutoColumns, cssValuePool().createImplicitInitialValue(), important); - addProperty(CSSPropertyGridAutoRows, cssValuePool().createImplicitInitialValue(), important); - addProperty(CSSPropertyGridColumnGap, cssValuePool().createImplicitInitialValue(), important); - addProperty(CSSPropertyGridRowGap, cssValuePool().createImplicitInitialValue(), important); - return true; - } - - m_range = rangeCopy; - - // 2- <grid-auto-flow> [ <grid-auto-rows> [ / <grid-auto-columns> ]? ] - CSSValueList* gridAutoFlow = consumeGridAutoFlow(m_range); - if (!gridAutoFlow) - return false; - - CSSValue* autoColumnsValue = nullptr; - CSSValue* autoRowsValue = nullptr; - - if (!m_range.atEnd()) { - autoRowsValue = consumeGridTrackSize(m_range, m_context.mode()); - if (!autoRowsValue) - return false; - if (consumeSlashIncludingWhitespace(m_range)) { - autoColumnsValue = consumeGridTrackSize(m_range, m_context.mode()); - if (!autoColumnsValue) - return false; - } - if (!m_range.atEnd()) - return false; - } else { - // Other omitted values are set to their initial values. - autoColumnsValue = cssValuePool().createImplicitInitialValue(); - autoRowsValue = cssValuePool().createImplicitInitialValue(); - } - - // if <grid-auto-columns> value is omitted, it is set to the value specified for grid-auto-rows. - if (!autoColumnsValue) - autoColumnsValue = autoRowsValue; - - addProperty(CSSPropertyGridAutoFlow, gridAutoFlow, important); - addProperty(CSSPropertyGridAutoColumns, autoColumnsValue, important); - addProperty(CSSPropertyGridAutoRows, autoRowsValue, important); - - // It can only be specified the explicit or the implicit grid properties in a single grid declaration. - // The sub-properties not specified are set to their initial value, as normal for shorthands. - addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createImplicitInitialValue(), important); - addProperty(CSSPropertyGridTemplateRows, cssValuePool().createImplicitInitialValue(), important); - addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createImplicitInitialValue(), important); - addProperty(CSSPropertyGridColumnGap, cssValuePool().createImplicitInitialValue(), important); - addProperty(CSSPropertyGridRowGap, cssValuePool().createImplicitInitialValue(), important); - - return true; -} - -bool allTracksAreFixedSized(CSSValueList& valueList) -{ - for (auto value : valueList) { - if (value->isGridLineNamesValue()) - continue; - // The auto-repeat value holds a <fixed-size> = <fixed-breadth> | minmax( <fixed-breadth>, <track-breadth> ) - if (value->isGridAutoRepeatValue()) { - if (!allTracksAreFixedSized(toCSSValueList(*value))) - return false; - continue; - } - ASSERT(value->isPrimitiveValue() || (value->isFunctionValue() && toCSSFunctionValue(*value).item(0))); - const CSSPrimitiveValue& primitiveValue = value->isPrimitiveValue() - ? toCSSPrimitiveValue(*value) - : toCSSPrimitiveValue(*toCSSFunctionValue(*value).item(0)); - CSSValueID valueID = primitiveValue.getValueID(); - if (valueID == CSSValueMinContent || valueID == CSSValueMaxContent || valueID == CSSValueAuto || primitiveValue.isFlex()) - return false; - } - return true; -} - -static Vector<String> parseGridTemplateAreasColumnNames(const String& gridRowNames) -{ - ASSERT(!gridRowNames.isEmpty()); - Vector<String> columnNames; - // Using StringImpl to avoid checks and indirection in every call to String::operator[]. - StringImpl& text = *gridRowNames.impl(); - - StringBuilder areaName; - for (unsigned i = 0; i < text.length(); ++i) { - if (text[i] == ' ') { - if (!areaName.isEmpty()) { - columnNames.append(areaName.toString()); - areaName.clear(); - } - continue; - } - if (text[i] == '.') { - if (areaName == ".") - continue; - if (!areaName.isEmpty()) { - columnNames.append(areaName.toString()); - areaName.clear(); - } - } else { - if (areaName == ".") { - columnNames.append(areaName.toString()); - areaName.clear(); - } - } - - areaName.append(text[i]); - } - - if (!areaName.isEmpty()) - columnNames.append(areaName.toString()); - - return columnNames; -} - -bool parseGridTemplateAreasRow(const String& gridRowNames, NamedGridAreaMap& gridAreaMap, const size_t rowCount, size_t& columnCount) -{ - if (gridRowNames.isEmpty() || gridRowNames.containsOnlyWhitespace()) - return false; - - Vector<String> columnNames = parseGridTemplateAreasColumnNames(gridRowNames); - if (!columnCount) { - columnCount = columnNames.size(); - ASSERT(columnCount); - } else if (columnCount != columnNames.size()) { - // The declaration is invalid is all the rows don't have the number of columns. - return false; - } - - for (size_t currentCol = 0; currentCol < columnCount; ++currentCol) { - const String& gridAreaName = columnNames[currentCol]; - - // Unamed areas are always valid (we consider them to be 1x1). - if (gridAreaName == ".") - continue; - - // We handle several grid areas with the same name at once to simplify the validation code. - size_t lookAheadCol; - for (lookAheadCol = currentCol + 1; lookAheadCol < columnCount; ++lookAheadCol) { - if (columnNames[lookAheadCol] != gridAreaName) - break; - } - - NamedGridAreaMap::iterator gridAreaIt = gridAreaMap.find(gridAreaName); - if (gridAreaIt == gridAreaMap.end()) { - gridAreaMap.add(gridAreaName, GridArea(GridSpan::translatedDefiniteGridSpan(rowCount, rowCount + 1), GridSpan::translatedDefiniteGridSpan(currentCol, lookAheadCol))); - } else { - GridArea& gridArea = gridAreaIt->value; - - // The following checks test that the grid area is a single filled-in rectangle. - // 1. The new row is adjacent to the previously parsed row. - if (rowCount != gridArea.rows.endLine()) - return false; - - // 2. The new area starts at the same position as the previously parsed area. - if (currentCol != gridArea.columns.startLine()) - return false; - - // 3. The new area ends at the same position as the previously parsed area. - if (lookAheadCol != gridArea.columns.endLine()) - return false; - - gridArea.rows = GridSpan::translatedDefiniteGridSpan(gridArea.rows.startLine(), gridArea.rows.endLine() + 1); - } - currentCol = lookAheadCol - 1; - } - - return true; -} - -} // namespace blink
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp index 3a08cfb..0ab698f 100644 --- a/third_party/WebKit/Source/core/dom/Document.cpp +++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -194,6 +194,7 @@ #include "core/page/Page.h" #include "core/page/PointerLockController.h" #include "core/page/scrolling/ScrollingCoordinator.h" +#include "core/page/scrolling/ViewportScrollCallback.h" #include "core/svg/SVGDocumentExtensions.h" #include "core/svg/SVGTitleElement.h" #include "core/svg/SVGUseElement.h" @@ -701,6 +702,47 @@ m_documentElement = ElementTraversal::firstWithin(*this); } +void Document::updateViewportApplyScroll() +{ + if (!m_documentElement + || !m_documentElement->isHTMLElement() + || ownerElement()) + return; + + Element* newScrollingElement = scrollingElement(); + + // If there is no scrolling element (in QuirksMode and body is scrollable), + // install the viewport scroll callback on the <HTML> element. + if (!newScrollingElement) + newScrollingElement = m_documentElement; + + if (newScrollingElement == m_oldScrollingElement) + return; + + ScrollStateCallback* applyScroll = nullptr; + + // If the scrolling element changed, remove the apply scroll from the + // old one and keep it to put on the new scrolling element. + if (m_oldScrollingElement) { + applyScroll = m_oldScrollingElement->getApplyScroll(); + m_oldScrollingElement->removeApplyScroll(); + } + + if (newScrollingElement) { + if (!applyScroll) + applyScroll = new ViewportScrollCallback(*this, *frameHost()); + + // Use disable-native-scroll since the ViewportScrollCallback needs to + // apply scroll actions before (TopControls) and after (overscroll) + // scrolling the element so it applies scroll to the element itself. + newScrollingElement->setApplyScroll( + applyScroll, + "disable-native-scroll"); + } + + m_oldScrollingElement = newScrollingElement; +} + AtomicString Document::convertLocalName(const AtomicString& name) { return isHTMLDocument() ? name.lower() : name; @@ -1979,6 +2021,8 @@ void Document::layoutUpdated() { + updateViewportApplyScroll(); + // Plugins can run script inside layout which can detach the page. // TODO(esprehn): Can this still happen now that all plugins are out of // process? @@ -5990,6 +6034,7 @@ visitor->trace(m_contextFeatures); visitor->trace(m_styleSheetList); visitor->trace(m_documentTiming); + visitor->trace(m_oldScrollingElement); visitor->trace(m_mediaQueryMatcher); visitor->trace(m_scriptedAnimationController); visitor->trace(m_scriptedIdleTaskController);
diff --git a/third_party/WebKit/Source/core/dom/Document.h b/third_party/WebKit/Source/core/dom/Document.h index f130ef0e..ddc19640e 100644 --- a/third_party/WebKit/Source/core/dom/Document.h +++ b/third_party/WebKit/Source/core/dom/Document.h
@@ -1171,6 +1171,13 @@ const OriginAccessEntry& accessEntryFromURL(); + // Installs the viewport scrolling callback (the "applyScroll" in Scroll + // Customization lingo) on the root scrollingElement. This callback is + // responsible for viewport related scroll actions like top controls + // movement and overscroll glow as well as actually scrolling the root + // viewport. + void updateViewportApplyScroll(); + DocumentLifecycle m_lifecycle; bool m_hasNodesWithPlaceholderStyle; @@ -1277,6 +1284,10 @@ Member<Element> m_cssTarget; + // Not a WeakMember since we want to keep the scrollingElement around until + // we move its ApplyScroll onto the new scrollingElement. + Member<Element> m_oldScrollingElement; + LoadEventProgress m_loadEventProgress; double m_startTime;
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp index 7c0ce54..90aaf5d 100644 --- a/third_party/WebKit/Source/core/dom/Element.cpp +++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -149,7 +149,6 @@ // FrameHosts when elements are moved around. ScrollCustomizationCallbacks& scrollCustomizationCallbacks() { - DCHECK(RuntimeEnabledFeatures::scrollCustomizationEnabled()); DEFINE_STATIC_LOCAL(ScrollCustomizationCallbacks, scrollCustomizationCallbacks, (new ScrollCustomizationCallbacks)); return scrollCustomizationCallbacks; } @@ -506,9 +505,18 @@ scrollCustomizationCallbacks().setApplyScroll(this, scrollStateCallback); } +void Element::removeApplyScroll() +{ + scrollCustomizationCallbacks().removeApplyScroll(this); +} + +ScrollStateCallback* Element::getApplyScroll() +{ + return scrollCustomizationCallbacks().getApplyScroll(this); +} + void Element::nativeDistributeScroll(ScrollState& scrollState) { - DCHECK(RuntimeEnabledFeatures::scrollCustomizationEnabled()); if (scrollState.fullyConsumed()) return; @@ -550,44 +558,44 @@ void Element::nativeApplyScroll(ScrollState& scrollState) { DCHECK(RuntimeEnabledFeatures::scrollCustomizationEnabled()); + + // All elements in the scroll chain should be boxes. + DCHECK(!layoutObject() || layoutObject()->isBox()); + if (scrollState.fullyConsumed()) return; - const double deltaX = scrollState.deltaX(); - const double deltaY = scrollState.deltaY(); - bool scrolled = false; + FloatSize delta(scrollState.deltaX(), scrollState.deltaY()); + + if (delta.isZero()) + return; // TODO(esprehn): This should use updateLayoutIgnorePendingStylesheetsForNode. - if (deltaY || deltaX) - document().updateLayoutIgnorePendingStylesheets(); + document().updateLayoutIgnorePendingStylesheets(); - // Handle the scrollingElement separately, as it scrolls the viewport. - if (this == document().scrollingElement()) { - FloatSize delta(deltaX, deltaY); - if (document().frame()->applyScrollDelta(ScrollByPrecisePixel, delta, scrollState.isBeginning()).didScroll()) { - scrolled = true; - scrollState.consumeDeltaNative(scrollState.deltaX(), scrollState.deltaY()); - } - } else { - if (!layoutObject()) - return; - LayoutBoxItem curBox = LayoutBoxItem(toLayoutBox(layoutObject())).enclosingBox(); - // FIXME: Native scrollers should only consume the scroll they - // apply. See crbug.com/457765. - if (deltaX && curBox.scroll(ScrollByPrecisePixel, FloatSize(deltaX, 0)).didScrollX) { - scrollState.consumeDeltaNative(scrollState.deltaX(), 0); - scrolled = true; - } + LayoutBox* boxToScroll = nullptr; - if (deltaY && curBox.scroll(ScrollByPrecisePixel, FloatSize(0, deltaY)).didScrollY) { - scrollState.consumeDeltaNative(0, scrollState.deltaY()); - scrolled = true; - } - } + // Handle the scrollingElement separately, as it should scroll the viewport. + if (this == document().scrollingElement()) + boxToScroll = document().layoutView(); + else if (layoutObject()) + boxToScroll = toLayoutBox(layoutObject()); - if (!scrolled) + if (!boxToScroll) return; + ScrollResult result = + LayoutBoxItem(boxToScroll).enclosingBox().scroll( + ScrollByPrecisePixel, + delta); + + if (!result.didScroll()) + return; + + // FIXME: Native scrollers should only consume the scroll they + // apply. See crbug.com/457765. + scrollState.consumeDeltaNative(delta.width(), delta.height()); + // We need to setCurrentNativeScrollingElement in both the // distributeScroll and applyScroll default implementations so // that if JS overrides one of these methods, but not the
diff --git a/third_party/WebKit/Source/core/dom/Element.h b/third_party/WebKit/Source/core/dom/Element.h index 34029e6..dfa90ec 100644 --- a/third_party/WebKit/Source/core/dom/Element.h +++ b/third_party/WebKit/Source/core/dom/Element.h
@@ -404,11 +404,14 @@ void setDistributeScroll(ScrollStateCallback*, String nativeScrollBehavior); void nativeDistributeScroll(ScrollState&); void setApplyScroll(ScrollStateCallback*, String nativeScrollBehavior); + void removeApplyScroll(); void nativeApplyScroll(ScrollState&); void callDistributeScroll(ScrollState&); void callApplyScroll(ScrollState&); + ScrollStateCallback* getApplyScroll(); + // Whether this element can receive focus at all. Most elements are not // focusable but some elements, such as form controls and links, are. Unlike // layoutObjectIsFocusable(), this method may be called when layout is not up to
diff --git a/third_party/WebKit/Source/core/dom/Node.cpp b/third_party/WebKit/Source/core/dom/Node.cpp index 0066cfd6..dcb18417 100644 --- a/third_party/WebKit/Source/core/dom/Node.cpp +++ b/third_party/WebKit/Source/core/dom/Node.cpp
@@ -2320,20 +2320,20 @@ #if DCHECK_IS_ON() DCHECK(!needsDistributionRecalc()); #endif - if (ElementShadow* shadow = parentElementShadow()) { - if (shadow->isV1()) - return shadow->assignedSlotFor(*this); - } + Element* parent = parentElement(); + ShadowRoot* root = parent ? parent->youngestShadowRoot() : nullptr; + if (root && root->isV1()) + return root->assignedSlotFor(*this); return nullptr; } HTMLSlotElement* Node::assignedSlotForBinding() { updateDistribution(); - if (ElementShadow* shadow = parentElementShadow()) { - if (shadow->isV1() && shadow->isOpenOrV0()) - return shadow->assignedSlotFor(*this); - } + Element* parent = parentElement(); + ShadowRoot* root = parent ? parent->youngestShadowRoot() : nullptr; + if (root && root->type() == ShadowRootType::Open) + return root->assignedSlotFor(*this); return nullptr; }
diff --git a/third_party/WebKit/Source/core/dom/StyleEngine.cpp b/third_party/WebKit/Source/core/dom/StyleEngine.cpp index 819ad3d..83f3d4c 100644 --- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp +++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
@@ -605,10 +605,8 @@ void StyleEngine::setFontSelector(CSSFontSelector* fontSelector) { -#if !ENABLE(OILPAN) if (m_fontSelector) m_fontSelector->unregisterForInvalidationCallbacks(this); -#endif m_fontSelector = fontSelector; if (m_fontSelector) m_fontSelector->registerForInvalidationCallbacks(this);
diff --git a/third_party/WebKit/Source/core/dom/shadow/ElementShadow.cpp b/third_party/WebKit/Source/core/dom/shadow/ElementShadow.cpp index 7ab19206..5326524 100644 --- a/third_party/WebKit/Source/core/dom/shadow/ElementShadow.cpp +++ b/third_party/WebKit/Source/core/dom/shadow/ElementShadow.cpp
@@ -287,7 +287,7 @@ void ElementShadow::distribute() { if (isV1()) - distributeV1(); + youngestShadowRoot().distributeV1(); else distributeV0(); } @@ -335,13 +335,6 @@ InspectorInstrumentation::didPerformElementShadowDistribution(host()); } -void ElementShadow::distributeV1() -{ - if (!m_slotAssignment) - m_slotAssignment = SlotAssignment::create(); - m_slotAssignment->resolveAssignment(youngestShadowRoot()); -} - void ElementShadow::didDistributeNode(const Node* node, InsertionPoint* insertionPoint) { #if ENABLE(OILPAN) @@ -408,7 +401,6 @@ // It is therefore enough to trace one of the shadow roots here and the // rest will be traced from there. visitor->trace(m_shadowRoots.head()); - visitor->trace(m_slotAssignment); } } // namespace blink
diff --git a/third_party/WebKit/Source/core/dom/shadow/ElementShadow.h b/third_party/WebKit/Source/core/dom/shadow/ElementShadow.h index 08832128..c263887 100644 --- a/third_party/WebKit/Source/core/dom/shadow/ElementShadow.h +++ b/third_party/WebKit/Source/core/dom/shadow/ElementShadow.h
@@ -31,7 +31,6 @@ #include "core/dom/shadow/InsertionPoint.h" #include "core/dom/shadow/SelectRuleFeatureSet.h" #include "core/dom/shadow/ShadowRoot.h" -#include "core/dom/shadow/SlotAssignment.h" #include "platform/heap/Handle.h" #include "wtf/DoublyLinkedList.h" #include "wtf/HashMap.h" @@ -50,19 +49,6 @@ ShadowRoot* oldestShadowRoot() const { return m_shadowRoots.tail(); } ElementShadow* containingShadow() const; - ShadowRoot* shadowRootIfV1() const - { - if (isV1()) - return &youngestShadowRoot(); - return nullptr; - } - - HTMLSlotElement* assignedSlotFor(const Node& node) const - { - DCHECK(m_slotAssignment); - return m_slotAssignment->assignedSlotFor(node); - } - ShadowRoot& addShadowRoot(Element& shadowHost, ShadowRootType); bool hasSameStyles(const ElementShadow*) const; @@ -120,9 +106,6 @@ DoublyLinkedList<ShadowRoot> m_shadowRoots; bool m_needsDistributionRecalc; bool m_needsSelectFeatureSet; - - // TODO(hayato): ShadowRoot should be an owner of SlotAssigment - Member<SlotAssignment> m_slotAssignment; }; inline Element* ElementShadow::host() const @@ -145,13 +128,6 @@ return 0; } -inline ShadowRoot* Element::shadowRootIfV1() const -{ - if (ElementShadow* shadow = this->shadow()) - return shadow->shadowRootIfV1(); - return nullptr; -} - inline ElementShadow* ElementShadow::containingShadow() const { if (ShadowRoot* parentRoot = host()->containingShadowRoot())
diff --git a/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp b/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp index 2ce8428..012b1ad 100644 --- a/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp +++ b/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp
@@ -46,7 +46,7 @@ #if ENABLE(OILPAN) char emptyClassFieldsDueToGCMixinMarker[1]; #endif - Member<void*> willbeMember[3]; + Member<void*> willbeMember[4]; unsigned countersAndFlags[1]; }; @@ -57,6 +57,7 @@ , TreeScope(*this, document) , m_prev(nullptr) , m_next(nullptr) + , m_slotAssignment(nullptr) , m_numberOfStyles(0) , m_type(static_cast<unsigned>(type)) , m_registeredWithParentShadowRoot(false) @@ -367,11 +368,19 @@ return m_shadowRootRareData->descendantSlots(); } +void ShadowRoot::distributeV1() +{ + if (!m_slotAssignment) + m_slotAssignment = SlotAssignment::create(); + m_slotAssignment->resolveAssignment(*this); +} + DEFINE_TRACE(ShadowRoot) { visitor->trace(m_prev); visitor->trace(m_next); visitor->trace(m_shadowRootRareData); + visitor->trace(m_slotAssignment); TreeScope::trace(visitor); DocumentFragment::trace(visitor); }
diff --git a/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h b/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h index 3f3e7fe1..e9f0a86 100644 --- a/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h +++ b/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h
@@ -32,6 +32,7 @@ #include "core/dom/DocumentFragment.h" #include "core/dom/Element.h" #include "core/dom/TreeScope.h" +#include "core/dom/shadow/SlotAssignment.h" #include "wtf/DoublyLinkedList.h" namespace blink { @@ -120,6 +121,14 @@ void didRemoveSlot(); const HeapVector<Member<HTMLSlotElement>>& descendantSlots(); + void distributeV1(); + + HTMLSlotElement* assignedSlotFor(const Node& node) const + { + DCHECK(m_slotAssignment); + return m_slotAssignment->assignedSlotFor(node); + } + // Make protected methods from base class public here. using TreeScope::setDocument; using TreeScope::setParentTreeScope; @@ -169,6 +178,7 @@ Member<ShadowRoot> m_prev; Member<ShadowRoot> m_next; Member<ShadowRootRareData> m_shadowRootRareData; + Member<SlotAssignment> m_slotAssignment; unsigned m_numberOfStyles : 26; unsigned m_type : 2; unsigned m_registeredWithParentShadowRoot : 1; @@ -182,6 +192,14 @@ return adjustedFocusedElement(); } +inline ShadowRoot* Element::shadowRootIfV1() const +{ + ShadowRoot* root = this->shadowRoot(); + if (root && root->isV1()) + return root; + return nullptr; +} + DEFINE_NODE_TYPE_CASTS(ShadowRoot, isShadowRoot()); DEFINE_TYPE_CASTS(ShadowRoot, TreeScope, treeScope, treeScope->rootNode().isShadowRoot(), treeScope.rootNode().isShadowRoot()); DEFINE_TYPE_CASTS(TreeScope, ShadowRoot, shadowRoot, true, true);
diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.h b/third_party/WebKit/Source/core/editing/EditingUtilities.h index 98dcdd9..18f4cb3 100644 --- a/third_party/WebKit/Source/core/editing/EditingUtilities.h +++ b/third_party/WebKit/Source/core/editing/EditingUtilities.h
@@ -217,6 +217,8 @@ // positions don't have common ancestor. int comparePositionsInDOMTree(Node* containerA, int offsetA, Node* containerB, int offsetB, bool* disconnected = nullptr); int comparePositionsInFlatTree(Node* containerA, int offsetA, Node* containerB, int offsetB, bool* disconnected = nullptr); +// TODO(yosin): We replace |comparePositions()| by |Position::opeator<()| to +// utilize |DCHECK_XX()|. int comparePositions(const Position&, const Position&); int comparePositions(const PositionWithAffinity&, const PositionWithAffinity&);
diff --git a/third_party/WebKit/Source/core/editing/Position.cpp b/third_party/WebKit/Source/core/editing/Position.cpp index a7b62df..d024f8ed 100644 --- a/third_party/WebKit/Source/core/editing/Position.cpp +++ b/third_party/WebKit/Source/core/editing/Position.cpp
@@ -309,6 +309,30 @@ } template <typename Strategy> +bool PositionTemplate<Strategy>::operator<(const PositionTemplate<Strategy>& other) const +{ + return comparePositions(*this, other) < 0; +} + +template <typename Strategy> +bool PositionTemplate<Strategy>::operator<=(const PositionTemplate<Strategy>& other) const +{ + return comparePositions(*this, other) <= 0; +} + +template <typename Strategy> +bool PositionTemplate<Strategy>::operator>(const PositionTemplate<Strategy>& other) const +{ + return comparePositions(*this, other) > 0; +} + +template <typename Strategy> +bool PositionTemplate<Strategy>::operator>=(const PositionTemplate<Strategy>& other) const +{ + return comparePositions(*this, other) >= 0; +} + +template <typename Strategy> bool PositionTemplate<Strategy>::atFirstEditingPositionForNode() const { if (isNull())
diff --git a/third_party/WebKit/Source/core/editing/Position.h b/third_party/WebKit/Source/core/editing/Position.h index fb9843e..8c6d909 100644 --- a/third_party/WebKit/Source/core/editing/Position.h +++ b/third_party/WebKit/Source/core/editing/Position.h
@@ -143,7 +143,15 @@ bool isNotNull() const { return m_anchorNode; } bool isOrphan() const { return m_anchorNode && !m_anchorNode->inShadowIncludingDocument(); } + // Note: Comparison of positions require both parameters are non-null. You + // should check null-position before comparing them. + // TODO(yosin): We should use |Position::operator<()| instead of + // |Position::comapreTo()| to utilize |DHCECK_XX()|. int compareTo(const PositionTemplate<Strategy>&) const; + bool operator<(const PositionTemplate<Strategy>&) const; + bool operator<=(const PositionTemplate<Strategy>&) const; + bool operator>(const PositionTemplate<Strategy>&) const; + bool operator>=(const PositionTemplate<Strategy>&) const; // These can be either inside or just before/after the node, depending on // if the node is ignored by editing or not.
diff --git a/third_party/WebKit/Source/core/editing/VisiblePosition.cpp b/third_party/WebKit/Source/core/editing/VisiblePosition.cpp index 3df66fa..aec7d2e 100644 --- a/third_party/WebKit/Source/core/editing/VisiblePosition.cpp +++ b/third_party/WebKit/Source/core/editing/VisiblePosition.cpp
@@ -39,10 +39,7 @@ #include "core/layout/line/RootInlineBox.h" #include "platform/geometry/FloatQuad.h" #include "wtf/text/CString.h" - -#ifndef NDEBUG -#include <stdio.h> -#endif +#include <ostream> // NOLINT namespace blink { @@ -65,6 +62,7 @@ const PositionTemplate<Strategy> deepPosition = canonicalPositionOf(positionWithAffinity.position()); if (deepPosition.isNull()) return VisiblePositionTemplate<Strategy>(); + DCHECK(positionWithAffinity.position().inShadowIncludingDocument()) << positionWithAffinity; const PositionWithAffinityTemplate<Strategy> downstreamPosition(deepPosition); if (positionWithAffinity.affinity() == TextAffinity::Downstream) return VisiblePositionTemplate<Strategy>(downstreamPosition); @@ -142,10 +140,11 @@ void showTree(const blink::VisiblePosition* vpos) { - if (vpos) + if (vpos) { vpos->showTreeForThis(); - else - fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); + return; + } + DVLOG(0) << "Cannot showTree for (nil) VisiblePosition."; } void showTree(const blink::VisiblePosition& vpos)
diff --git a/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp index 8606b01..fd87f70b 100644 --- a/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp
@@ -1183,7 +1183,7 @@ ASSERT(start.inShadowIncludingDocument()); ASSERT(end.inShadowIncludingDocument()); ASSERT(Position::commonAncestorTreeScope(start, end)); - ASSERT(comparePositions(start, end) <= 0); + DCHECK_LE(start, end); // FIXME: We should assert that start/end are not in the middle of a text node. Position pushDownStart = mostForwardCaretPosition(start);
diff --git a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp index a3331d8..85e6a046 100644 --- a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
@@ -1054,7 +1054,7 @@ void CompositeEditCommand::cloneParagraphUnderNewElement(const Position& start, const Position& end, Node* passedOuterNode, Element* blockElement, EditingState* editingState) { - ASSERT(comparePositions(start, end) <= 0); + DCHECK_LE(start, end); ASSERT(passedOuterNode); ASSERT(blockElement);
diff --git a/third_party/WebKit/Source/core/frame/Deprecation.cpp b/third_party/WebKit/Source/core/frame/Deprecation.cpp index 05736fc..e868e5a4f 100644 --- a/third_party/WebKit/Source/core/frame/Deprecation.cpp +++ b/third_party/WebKit/Source/core/frame/Deprecation.cpp
@@ -367,6 +367,9 @@ case UseCounter::TouchDragUserGestureUsedCrossOrigin: return willBeRemoved("Performing sensitive operations in iframes on touch events which don't represent a tap gesture", 52, "https://www.chromestatus.com/features/5649871251963904"); + case UseCounter::WebAnimationsEasingAsFunctionLinear: + return String::format("Specifying animation easing as a function is deprecated and all support will be removed in %s, at which point this will throw a TypeError. This warning may have been triggered by the Web Animations or Polymer polyfills. See http://crbug.com/601672 for details.", milestoneString(54)); + // Features that aren't deprecated don't have a deprecation message. default: return String();
diff --git a/third_party/WebKit/Source/core/frame/LocalFrame.cpp b/third_party/WebKit/Source/core/frame/LocalFrame.cpp index 9350b3b..6924697b 100644 --- a/third_party/WebKit/Source/core/frame/LocalFrame.cpp +++ b/third_party/WebKit/Source/core/frame/LocalFrame.cpp
@@ -757,50 +757,6 @@ spellChecker().removeSpellingMarkersUnderWords(words); } -ScrollResult LocalFrame::applyScrollDelta(ScrollGranularity granularity, const FloatSize& delta, bool isScrollBegin) -{ - if (isScrollBegin) - host()->topControls().scrollBegin(); - - if (!view() || delta.isZero()) - return ScrollResult(false, false, delta.width(), delta.height()); - - FloatSize remainingDelta = delta; - - // If this is main frame, allow top controls to scroll first. - if (shouldScrollTopControls(granularity, delta)) - remainingDelta = host()->topControls().scrollBy(remainingDelta); - - if (remainingDelta.isZero()) - return ScrollResult(delta.width(), delta.height(), 0.0f, 0.0f); - - ScrollResult result = view()->getScrollableArea()->userScroll(granularity, remainingDelta); - result.didScrollX = result.didScrollX || (remainingDelta.width() != delta.width()); - result.didScrollY = result.didScrollY || (remainingDelta.height() != delta.height()); - - return result; -} - -bool LocalFrame::shouldScrollTopControls(ScrollGranularity granularity, const FloatSize& delta) const -{ - if (!isMainFrame()) - return false; - - if (granularity != ScrollByPixel && granularity != ScrollByPrecisePixel) - return false; - - // Always give the delta to the top controls if the scroll is in - // the direction to show the top controls. If it's in the - // direction to hide the top controls, only give the delta to the - // top controls when the frame can scroll. - DoublePoint maximumScrollPosition = - host()->visualViewport().maximumScrollPositionDouble() + - toDoubleSize(view()->maximumScrollPositionDouble()); - DoublePoint scrollPosition = host()->visualViewport() - .visibleRectInDocument().location(); - return delta.height() < 0 || scrollPosition.y() < maximumScrollPosition.y(); -} - String LocalFrame::localLayerTreeAsText(unsigned flags) const { if (!contentLayoutObject())
diff --git a/third_party/WebKit/Source/core/frame/LocalFrame.h b/third_party/WebKit/Source/core/frame/LocalFrame.h index ad9debd..3dd0a74 100644 --- a/third_party/WebKit/Source/core/frame/LocalFrame.h +++ b/third_party/WebKit/Source/core/frame/LocalFrame.h
@@ -171,10 +171,6 @@ bool shouldReuseDefaultView(const KURL&) const; void removeSpellingMarkersUnderWords(const Vector<String>& words); - // FIXME: once scroll customization is enabled everywhere - // (crbug.com/416862), this should take a ScrollState object. - ScrollResult applyScrollDelta(ScrollGranularity, const FloatSize& delta, bool isScrollBegin); - // DisplayItemClient methods String debugName() const final { return "LocalFrame"; } // TODO(chrishtr): fix this. @@ -195,8 +191,6 @@ LocalFrame(FrameLoaderClient*, FrameHost*, FrameOwner*, ServiceRegistry*); - bool shouldScrollTopControls(ScrollGranularity, const FloatSize& delta) const; - // Internal Frame helper overrides: WindowProxyManager* getWindowProxyManager() const override;
diff --git a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp index 9f0381e..b370767 100644 --- a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
@@ -1457,12 +1457,12 @@ bool HTMLInputElement::isInRange() const { - return m_inputType->isInRange(value()); + return willValidate() && m_inputType->isInRange(value()); } bool HTMLInputElement::isOutOfRange() const { - return m_inputType->isOutOfRange(value()); + return willValidate() && m_inputType->isOutOfRange(value()); } bool HTMLInputElement::isRequiredFormControl() const
diff --git a/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp b/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp index 7cf1fdaf..6d7c97bc 100644 --- a/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp +++ b/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp
@@ -2,12 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "CanvasAsyncBlobCreator.h" +#include "core/html/canvas/CanvasAsyncBlobCreator.h" #include "core/fileapi/Blob.h" #include "platform/ThreadSafeFunctional.h" #include "platform/graphics/ImageBuffer.h" -#include "platform/heap/Handle.h" #include "platform/image-encoders/skia/JPEGImageEncoder.h" #include "platform/image-encoders/skia/PNGImageEncoder.h" #include "platform/threading/BackgroundTaskRunner.h" @@ -60,9 +59,6 @@ // TODO: async blob creation should be supported in worker_pool threads as well. but right now blink does not have that ASSERT(isMainThread()); - // Make self-reference to keep this object alive until the final task completes - m_keepAlive = this; - // At the time being, progressive encoding is only applicable to png image format, // and thus idle tasks scheduling can only be applied to png image format. // TODO(xlai): Progressive encoding on jpeg and webp image formats (crbug.com/571398, crbug.com/571399) @@ -82,7 +78,6 @@ m_jpegEncoderState = JPEGImageEncoderState::create(m_size, quality, m_encodedImage.get()); if (!m_jpegEncoderState) { Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, bind(&BlobCallback::handleEvent, m_callback, nullptr)); - m_keepAlive.clear(); return; } BackgroundTaskRunner::TaskSize taskSize = (m_size.height() * m_size.width() >= LongTaskImageSizeThreshold) ? BackgroundTaskRunner::TaskSizeLongRunningTask : BackgroundTaskRunner::TaskSizeShortRunningTask; @@ -95,7 +90,6 @@ m_pngEncoderState = PNGImageEncoderState::create(m_size, m_encodedImage.get()); if (!m_pngEncoderState) { Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, bind(&BlobCallback::handleEvent, m_callback, nullptr)); - m_keepAlive.clear(); return; } @@ -124,11 +118,10 @@ m_numRowsCompleted = m_size.height(); PNGImageEncoder::finalizePng(m_pngEncoderState.get()); - if (isDeadlineNearOrPassed(deadlineSeconds)) { + if (isDeadlineNearOrPassed(deadlineSeconds)) Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, bind(&CanvasAsyncBlobCreator::createBlobAndCall, this)); - } else { + else this->createBlobAndCall(); - } } void CanvasAsyncBlobCreator::createBlobAndCall() @@ -136,7 +129,6 @@ ASSERT(isMainThread()); Blob* resultBlob = Blob::create(m_encodedImage->data(), m_encodedImage->size(), m_mimeType); Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, bind(&BlobCallback::handleEvent, m_callback, resultBlob)); - clearSelfReference(); // self-destruct once job is done. } void CanvasAsyncBlobCreator::encodeImageOnEncoderThread(double quality) @@ -144,39 +136,17 @@ ASSERT(!isMainThread()); bool success; - if (m_mimeType == "image/jpeg") { + if (m_mimeType == "image/jpeg") success = JPEGImageEncoder::encodeWithPreInitializedState(m_jpegEncoderState.release(), m_data->data()); - } else { + else success = ImageDataBuffer(m_size, m_data->data()).encodeImage(m_mimeType, quality, m_encodedImage.get()); - } if (!success) { - scheduleCreateNullptrAndCallOnMainThread(); + Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&BlobCallback::handleEvent, m_callback.get(), nullptr)); return; } - scheduleCreateBlobAndCallOnMainThread(); -} - -void CanvasAsyncBlobCreator::clearSelfReference() -{ - // Some persistent members in CanvasAsyncBlobCreator can only be destroyed - // on the thread that creates them. In this case, it's the main thread. - ASSERT(isMainThread()); - m_keepAlive.clear(); -} - -void CanvasAsyncBlobCreator::scheduleCreateBlobAndCallOnMainThread() -{ - ASSERT(!isMainThread()); Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&CanvasAsyncBlobCreator::createBlobAndCall, AllowCrossThreadAccess(this))); } -void CanvasAsyncBlobCreator::scheduleCreateNullptrAndCallOnMainThread() -{ - ASSERT(!isMainThread()); - Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&BlobCallback::handleEvent, m_callback.get(), nullptr)); - Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&CanvasAsyncBlobCreator::clearSelfReference, AllowCrossThreadAccess(this))); -} - } // namespace blink
diff --git a/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h b/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h index cae95f3..24c682a9 100644 --- a/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h +++ b/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h
@@ -8,7 +8,6 @@ #include "platform/geometry/IntSize.h" #include "platform/heap/Handle.h" #include "wtf/OwnPtr.h" -#include "wtf/PassOwnPtr.h" #include "wtf/Vector.h" #include "wtf/text/WTFString.h" @@ -30,8 +29,6 @@ private: CanvasAsyncBlobCreator(DOMUint8ClampedArray* data, const String& mimeType, const IntSize&, BlobCallback*); - void scheduleCreateBlobAndCallOnMainThread(); - void scheduleCreateNullptrAndCallOnMainThread(); OwnPtr<PNGImageEncoderState> m_pngEncoderState; OwnPtr<JPEGImageEncoderState> m_jpegEncoderState; @@ -44,9 +41,6 @@ const String m_mimeType; CrossThreadPersistent<BlobCallback> m_callback; - SelfKeepAlive<CanvasAsyncBlobCreator> m_keepAlive; - void clearSelfReference(); - void initiatePngEncoding(double deadlineSeconds); void scheduleIdleEncodeRowsPng(); void idleEncodeRowsPng(double deadlineSeconds);
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp index 671f8da4..2e89a88 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp +++ b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
@@ -161,21 +161,10 @@ HTMLDocumentParser::~HTMLDocumentParser() { -#if ENABLE(OILPAN) - if (m_haveBackgroundParser) - stopBackgroundParser(); // In Oilpan, HTMLDocumentParser can die together with Document, and // detach() is not called in this case. -#else - ASSERT(!m_parserScheduler); - ASSERT(!m_pumpSessionNestingLevel); - ASSERT(!m_preloadScanner); - ASSERT(!m_insertionPreloadScanner); - ASSERT(!m_haveBackgroundParser); - // FIXME: We should be able to ASSERT(m_speculations.isEmpty()), - // but there are cases where that's not true currently. For example, - // we we're told to stop parsing before we've consumed all the input. -#endif + if (m_haveBackgroundParser) + stopBackgroundParser(); } DEFINE_TRACE(HTMLDocumentParser) @@ -444,10 +433,6 @@ ASSERT(!isParsingFragment()); ASSERT(!isWaitingForScripts()); ASSERT(!isStopped()); -#if !ENABLE(OILPAN) - // ASSERT that this object is both attached to the Document and protected. - ASSERT(refCount() >= 2); -#endif ASSERT(shouldUseThreading()); ASSERT(!m_tokenizer); ASSERT(!m_token); @@ -535,10 +520,6 @@ void HTMLDocumentParser::pumpPendingSpeculations() { -#if !ENABLE(OILPAN) - // ASSERT that this object is both attached to the Document and protected. - ASSERT(refCount() >= 2); -#endif // If this assert fails, you need to call validateSpeculations to make sure // m_tokenizer and m_token don't have state that invalidates m_speculations. ASSERT(!m_tokenizer); @@ -602,10 +583,6 @@ void HTMLDocumentParser::pumpTokenizer() { ASSERT(!isStopped()); -#if !ENABLE(OILPAN) - // ASSERT that this object is both attached to the Document and protected. - ASSERT(refCount() >= 2); -#endif ASSERT(m_tokenizer); ASSERT(m_token); @@ -641,12 +618,6 @@ ASSERT(isStopped() || token().isUninitialized()); } -#if !ENABLE(OILPAN) - // Ensure we haven't been totally deref'ed after pumping. Any caller of this - // function should be holding a RefPtr to this to ensure we weren't deleted. - ASSERT(refCount() >= 1); -#endif - if (isStopped()) return;
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLElementStack.cpp b/third_party/WebKit/Source/core/html/parser/HTMLElementStack.cpp index c76dd53..36293ca8 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLElementStack.cpp +++ b/third_party/WebKit/Source/core/html/parser/HTMLElementStack.cpp
@@ -125,12 +125,6 @@ ASSERT(m_item); } -#if !ENABLE(OILPAN) -HTMLElementStack::ElementRecord::~ElementRecord() -{ -} -#endif - void HTMLElementStack::ElementRecord::replaceElement(HTMLStackItem* item) { ASSERT(item);
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLElementStack.h b/third_party/WebKit/Source/core/html/parser/HTMLElementStack.h index 20470771..4bb7331 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLElementStack.h +++ b/third_party/WebKit/Source/core/html/parser/HTMLElementStack.h
@@ -52,10 +52,6 @@ class ElementRecord final : public GarbageCollected<ElementRecord> { WTF_MAKE_NONCOPYABLE(ElementRecord); public: -#if !ENABLE(OILPAN) - ~ElementRecord(); // Public for ~PassOwnPtr() -#endif - Element* element() const { return m_item->element(); } ContainerNode* node() const { return m_item->node(); } const AtomicString& namespaceURI() const { return m_item->namespaceURI(); }
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp b/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp index 288843b..f89f9ab 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp +++ b/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp
@@ -139,9 +139,7 @@ , m_hasScriptsWaitingForResources(false) { ASSERT(m_host); -#if ENABLE(OILPAN) ThreadState::current()->registerPreFinalizer(this); -#endif } HTMLScriptRunner::~HTMLScriptRunner()
diff --git a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp index 49897d7c..7705bf88 100644 --- a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp +++ b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp
@@ -28,6 +28,7 @@ #include "wtf/StringExtras.h" #include "wtf/text/TextCodec.h" #include "wtf/text/TextEncodingRegistry.h" +#include "wtf/text/UTF8.h" using namespace WTF; @@ -349,23 +350,6 @@ return; } -// We use the encoding detector in two cases: -// 1. Encoding detector is turned ON and no other encoding source is -// available (that is, it's DefaultEncoding). -// 2. Encoding detector is turned ON and the encoding is set to -// the encoding of the parent frame, which is also auto-detected. -// Note that condition #2 is NOT satisfied unless parent-child frame -// relationship is compliant to the same-origin policy. If they're from -// different domains, |m_source| would not be set to EncodingFromParentFrame -// in the first place. -bool TextResourceDecoder::shouldAutoDetect() const -{ - // Just checking m_hintEncoding suffices here because it's only set - // in setHintEncoding when the source is AutoDetectedEncoding. - return m_encodingDetectionOption == UseAllAutoDetection - && (m_source == DefaultEncoding || (m_source == EncodingFromParentFrame && m_hintEncoding)); -} - String TextResourceDecoder::decode(const char* data, size_t len) { size_t lengthOfBOM = 0; @@ -402,11 +386,7 @@ if (m_contentType == HTMLContent && !m_checkedForMetaCharset) checkForMetaCharset(dataForDecode, lengthForDecode); - if (shouldAutoDetect()) { - WTF::TextEncoding detectedEncoding; - if (detectTextEncoding(data, len, m_hintEncoding, &detectedEncoding)) - setEncoding(detectedEncoding, EncodingFromContentSniffing); - } + detectTextEncoding(data, len); ASSERT(m_encoding.isValid()); @@ -419,16 +399,46 @@ return result; } +// We use the encoding detector in following cases: +// 1. Encoding detector is turned ON and no other encoding source is +// available (that is, it's DefaultEncoding). +// 2. Encoding detector is turned ON and the encoding is set to +// the encoding of the parent frame, which is also auto-detected. +// Note that condition #2 is NOT satisfied unless parent-child frame +// relationship is compliant to the same-origin policy. If they're from +// different domains, |m_source| would not be set to EncodingFromParentFrame +// in the first place. +void TextResourceDecoder::detectTextEncoding(const char* data, size_t len) +{ + if (!shouldDetectEncoding()) + return; + + if (WTF::Unicode::isUTF8andNotASCII(data, len)) { + setEncoding(UTF8Encoding(), EncodingFromContentSniffing); + return; + } + if (m_encodingDetectionOption == UseAllAutoDetection) { + WTF::TextEncoding detectedEncoding; + if (detectTextEncodingUniversal(data, len, m_hintEncoding, &detectedEncoding)) + setEncoding(detectedEncoding, EncodingFromContentSniffing); + } +} + +bool TextResourceDecoder::shouldDetectEncoding() const +{ + // Just checking m_hintEncoding suffices here because it's only set + // in setHintEncoding when the source is AutoDetectedEncoding. + return m_source == DefaultEncoding || (m_source == EncodingFromParentFrame && m_hintEncoding); +} + String TextResourceDecoder::flush() { // If we can not identify the encoding even after a document is completely // loaded, we need to detect the encoding if other conditions for // autodetection is satisfied. - if (m_buffer.size() && shouldAutoDetect() + if (m_buffer.size() && ((!m_checkedForXMLCharset && (m_contentType == HTMLContent || m_contentType == XMLContent)) || (!m_checkedForCSSCharset && (m_contentType == CSSContent)))) { - WTF::TextEncoding detectedEncoding; - if (detectTextEncoding(m_buffer.data(), m_buffer.size(), m_hintEncoding, &detectedEncoding)) - setEncoding(detectedEncoding, EncodingFromContentSniffing); + detectTextEncoding(m_buffer.data(), m_buffer.size()); } if (!m_codec)
diff --git a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h index 82411a7..bdfa0d6 100644 --- a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h +++ b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h
@@ -79,16 +79,18 @@ private: - // TextResourceDecoder does three kind of encoding detection: + // TextResourceDecoder does four kinds of encoding detection: // 1. By BOM, // 2. By Content if |m_contentType| is not |PlainTextContext| - // (e.g. <meta> tag for HTML), and - // 3. By detectTextEncoding(). + // (e.g. <meta> tag for HTML), + // 3. By isUTF8Encoded() to detect if the document + // is of UTF-8, and + // 4. By detectTextEncodingUniversal(). enum EncodingDetectionOption { - // Use 1. + 2. + 3. + // Use 1. + 2. + 4. UseAllAutoDetection, - // Use 1. + 2. + // Use 1. + 2. + 3. UseContentAndBOMBasedDetection, // Use None of them. @@ -108,7 +110,8 @@ bool checkForCSSCharset(const char*, size_t, bool& movedDataToBuffer); bool checkForXMLCharset(const char*, size_t, bool& movedDataToBuffer); void checkForMetaCharset(const char*, size_t); - bool shouldAutoDetect() const; + void detectTextEncoding(const char*, size_t); + bool shouldDetectEncoding() const; ContentType m_contentType; WTF::TextEncoding m_encoding;
diff --git a/third_party/WebKit/Source/core/input/EventHandler.cpp b/third_party/WebKit/Source/core/input/EventHandler.cpp index e142c701..c84317b 100644 --- a/third_party/WebKit/Source/core/input/EventHandler.cpp +++ b/third_party/WebKit/Source/core/input/EventHandler.cpp
@@ -164,6 +164,47 @@ return targetNode->isShadowRoot() && isHTMLInputElement(*toShadowRoot(targetNode)->host()); } +// TODO(bokan): This method can go away once all scrolls happen through the +// scroll customization path. +void computeScrollChainForSingleNode(Node& node, std::deque<int>& scrollChain) +{ + scrollChain.clear(); + + ASSERT(node.layoutObject()); + Element* element = toElement(&node); + + scrollChain.push_front(DOMNodeIds::idForNode(element)); +} + +void recomputeScrollChain(const LocalFrame& frame, const Node& startNode, + std::deque<int>& scrollChain) +{ + scrollChain.clear(); + + ASSERT(startNode.layoutObject()); + LayoutBox* curBox = startNode.layoutObject()->enclosingBox(); + + // Scrolling propagates along the containing block chain. + while (curBox && !curBox->isLayoutView()) { + Node* curNode = curBox->node(); + // FIXME: this should reject more elements, as part of crbug.com/410974. + if (curNode && curNode->isElementNode()) { + Element* curElement = toElement(curNode); + if (curElement == frame.document()->scrollingElement()) + break; + scrollChain.push_front(DOMNodeIds::idForNode(curElement)); + } + curBox = curBox->containingBlock(); + } + // TODO(tdresser): this should sometimes be excluded, as part of crbug.com/410974. + // We need to ensure that the scrollingElement is always part of + // the scroll chain. In quirks mode, when the scrollingElement is + // the body, some elements may use the documentElement as their + // containingBlock, so we ensure the scrollingElement is added + // here. + scrollChain.push_front(DOMNodeIds::idForNode(frame.document()->scrollingElement())); +} + } // namespace using namespace HTMLNames; @@ -222,35 +263,6 @@ Cursor m_cursor; }; -void recomputeScrollChain(const LocalFrame& frame, const Node& startNode, - std::deque<int>& scrollChain) -{ - scrollChain.clear(); - - ASSERT(startNode.layoutObject()); - LayoutBox* curBox = startNode.layoutObject()->enclosingBox(); - - // Scrolling propagates along the containing block chain. - while (curBox && !curBox->isLayoutView()) { - Node* curNode = curBox->node(); - // FIXME: this should reject more elements, as part of crbug.com/410974. - if (curNode && curNode->isElementNode()) { - Element* curElement = toElement(curNode); - if (curElement == frame.document()->scrollingElement()) - break; - scrollChain.push_front(DOMNodeIds::idForNode(curElement)); - } - curBox = curBox->containingBlock(); - } - // TODO(tdresser): this should sometimes be excluded, as part of crbug.com/410974. - // We need to ensure that the scrollingElement is always part of - // the scroll chain. In quirks mode, when the scrollingElement is - // the body, some elements may use the documentElement as their - // containingBlock, so we ensure the scrollingElement is added - // here. - scrollChain.push_front(DOMNodeIds::idForNode(frame.document()->scrollingElement())); -} - EventHandler::EventHandler(LocalFrame* frame) : m_frame(frame) , m_mousePressed(false) @@ -611,7 +623,83 @@ controller->stopAutoscroll(); } -ScrollResult EventHandler::physicalScroll(ScrollGranularity granularity, const FloatSize& delta, Node* startNode, Node** stopNode, bool* consumed) +ScrollResult EventHandler::scrollBox(LayoutBox* box, + ScrollGranularity granularity, const FloatSize& delta, + const FloatPoint& position, const FloatSize& velocity, + bool* wasRootScroller) +{ + ASSERT(box); + Node* node = box->node(); + Document* document = m_frame->document(); + Element* scrollingElement = document->scrollingElement(); + + bool isRootFrame = !document->ownerElement(); + + // TODO(bokan): If the ViewportScrollCallback is installed on the body, we + // can still hit the HTML element for scrolling in which case it'll bubble + // up to the document node and try to scroll the LayoutView directly. Make + // sure we never scroll the LayoutView like this by manually resetting the + // scroll to happen on the scrolling element. This can also happen in + // QuirksMode when the body is scrollable and scrollingElement == nullptr. + if (node && node->isDocumentNode() && isRootFrame) { + node = scrollingElement + ? scrollingElement + : document->documentElement(); + } + + // If there's no ApplyScroll callback on the element, scroll as usuall in + // the non-scroll-customization case. + if (!node || !node->isElementNode() || !toElement(node)->getApplyScroll()) { + ASSERT(!isRootFrame + || node != scrollingElement + || (!scrollingElement && node != document->documentElement())); + *wasRootScroller = false; + return box->scroll(granularity, delta); + } + + ASSERT(isRootFrame); + + // If there is an ApplyScroll callback, its because we placed one on the + // root scroller to control top controls and overscroll. Invoke a scroll + // using parts of the scroll customization framework on just this element. + computeScrollChainForSingleNode(*node, m_currentScrollChain); + + OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateData()); + scrollStateData->delta_x = delta.width(); + scrollStateData->delta_y = delta.height(); + scrollStateData->position_x = position.x(); + scrollStateData->position_y = position.y(); + // TODO(bokan): delta_granularity is meant to be the number of pixels per + // unit of delta but we can't determine that until we get to the area we'll + // scroll. This is a hack, we stuff the enum into the double value for + // now. + scrollStateData->delta_granularity = static_cast<double>(granularity); + scrollStateData->velocity_x = velocity.width(); + scrollStateData->velocity_y = velocity.height(); + scrollStateData->should_propagate = false; + scrollStateData->is_in_inertial_phase = false; + scrollStateData->from_user_input = true; + scrollStateData->delta_consumed_for_scroll_sequence = false; + ScrollState* scrollState = + ScrollState::create(scrollStateData.release()); + + customizedScroll(*node, *scrollState); + + ScrollResult result( + scrollState->deltaX() != delta.width(), + scrollState->deltaY() != delta.height(), + scrollState->deltaX(), + scrollState->deltaY()); + + *wasRootScroller = true; + m_currentScrollChain.clear(); + + return result; +} + +ScrollResult EventHandler::physicalScroll(ScrollGranularity granularity, + const FloatSize& delta, const FloatPoint& position, + const FloatSize& velocity, Node* startNode, Node** stopNode, bool* consumed) { if (consumed) *consumed = false; @@ -631,7 +719,15 @@ // chain past it. bool shouldStopChaining = stopNode && *stopNode && curBox->node() == *stopNode; - result = curBox->scroll(granularity, delta); + bool wasRootScroller = false; + + result = scrollBox( + curBox, + granularity, + delta, + position, + velocity, + &wasRootScroller); if (result.didScroll() && stopNode) *stopNode = curBox->node(); @@ -641,6 +737,10 @@ if (consumed) *consumed = true; return result; + } else if (wasRootScroller) { + // Don't try to chain past the root scroller, even if there's + // eligible ancestors. + break; } curBox = curBox->containingBlock(); @@ -1894,13 +1994,18 @@ // FIXME: enable scroll customization in this case. See crbug.com/410974. bool consumed = false; - ScrollResult result = physicalScroll(granularity, delta, startNode, &node, &consumed); + + physicalScroll( + granularity, + delta, + FloatPoint(), + FloatSize(), + startNode, + &node, + &consumed); if (consumed) wheelEvent->setDefaultHandled(); - - if (m_frame->isMainFrame()) - handleOverscroll(result); } WebInputEventResult EventHandler::handleGestureShowPress() @@ -2393,6 +2498,20 @@ } } +bool EventHandler::isRootScroller(const Node& node) const +{ + // The root scroller is the one Element on the page designated to perform + // "viewport actions" like top controls movement and overscroll glow. + + if (!node.isElementNode() || node.document().ownerElement()) + return false; + + Element* scrollingElement = node.document().scrollingElement(); + return scrollingElement + ? toElement(&node) == node.document().scrollingElement() + : toElement(&node) == node.document().documentElement(); +} + WebInputEventResult EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gestureEvent) { ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); @@ -2435,6 +2554,7 @@ OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateData()); scrollStateData->delta_x = delta.width(); scrollStateData->delta_y = delta.height(); + scrollStateData->delta_granularity = ScrollByPrecisePixel; scrollStateData->velocity_x = velocity.width(); scrollStateData->velocity_y = velocity.height(); scrollStateData->should_propagate = !gestureEvent.preventPropagation(); @@ -2464,17 +2584,20 @@ stopNode = m_previousGestureScrolledNode.get(); bool consumed = false; - ScrollResult result = physicalScroll(granularity, delta, node, &stopNode, &consumed); + ScrollResult result = physicalScroll( + granularity, + delta, + FloatPoint(gestureEvent.position()), + velocity, + node, + &stopNode, + &consumed); if (gestureEvent.preventPropagation()) m_previousGestureScrolledNode = stopNode; - if (m_frame->isMainFrame() && (!stopNode || stopNode->layoutObject() == m_frame->view()->layoutView())) { - FloatPoint positionInRootFrame = FloatPoint(gestureEvent.position().x(), gestureEvent.position().y()); - handleOverscroll(result, positionInRootFrame, velocity); - } else { + if (!stopNode || !isRootScroller(*stopNode)) resetOverscroll(result.didScrollX, result.didScrollY); - } if (consumed) return WebInputEventResult::HandledSystem;
diff --git a/third_party/WebKit/Source/core/input/EventHandler.h b/third_party/WebKit/Source/core/input/EventHandler.h index c95179c..e609398 100644 --- a/third_party/WebKit/Source/core/input/EventHandler.h +++ b/third_party/WebKit/Source/core/input/EventHandler.h
@@ -240,6 +240,9 @@ String region; }; + // TODO(bokan): This seems like it no longer belongs here. + void handleOverscroll(const ScrollResult&, const FloatPoint& positionInRootFrame = FloatPoint(), const FloatSize& velocity = FloatSize()); + private: static DragState& dragState(); @@ -284,6 +287,8 @@ // delta - The delta to scroll by, in the units of the granularity param // (e.g. pixels, lines, pages, etc.). These are in a physical // direction. i.e. Positive is down and right. + // position - Where the scroll originated from (e.g. touch location). + // velocity - The velocity of the scroll in the case of fling gestures. // startNode - The node to start the scroll chaining from. // stopNode - On input, if non-null, the node at which we should stop // chaining. On output, if provided and a node was scrolled, @@ -292,7 +297,14 @@ // ScrollResult.didScroll since we might not have scrolled but // have reached the stopNode and thus don't want to continue // chaining the scroll. - ScrollResult physicalScroll(ScrollGranularity, const FloatSize& delta, Node* startNode, Node** stopNode, bool* consumed); + ScrollResult physicalScroll( + ScrollGranularity, + const FloatSize& delta, + const FloatPoint& position, + const FloatSize& velocity, + Node* startNode, + Node** stopNode, + bool* consumed); // Performs a chaining logical scroll, within a *single* frame, starting // from either a provided starting node or a default based on the focused or @@ -307,8 +319,16 @@ bool logicalScroll(ScrollDirection, ScrollGranularity, Node* startNode = nullptr); void resetOverscroll(bool didScrollX, bool didScrollY); - void handleOverscroll(const ScrollResult&, const FloatPoint& positionInRootFrame = FloatPoint(), const FloatSize& velocity = FloatSize()); + ScrollResult scrollBox( + LayoutBox*, + ScrollGranularity, + const FloatSize& delta, + const FloatPoint& position, + const FloatSize& velocity, + bool* wasRootScroller); + + bool isRootScroller(const Node&) const; void customizedScroll(const Node& startNode, ScrollState&); HitTestResult hitTestResultInFrame(LocalFrame*, const LayoutPoint&, HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active);
diff --git a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp index 97bbdfaf..cfde1c7 100644 --- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
@@ -308,7 +308,9 @@ bool LayoutGrid::explicitGridDidResize(const ComputedStyle& oldStyle) const { return oldStyle.gridTemplateColumns().size() != styleRef().gridTemplateColumns().size() - || oldStyle.gridTemplateRows().size() != styleRef().gridTemplateRows().size(); + || oldStyle.gridTemplateRows().size() != styleRef().gridTemplateRows().size() + || oldStyle.namedGridAreaColumnCount() != styleRef().namedGridAreaColumnCount() + || oldStyle.namedGridAreaRowCount() != styleRef().namedGridAreaRowCount(); } bool LayoutGrid::namedGridLinesDefinitionDidChange(const ComputedStyle& oldStyle) const
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp index f2faa0ae..6b52046 100644 --- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
@@ -3635,10 +3635,13 @@ return objectPaintPropertiesMap().get(this); } -void LayoutObject::setObjectPaintProperties(PassOwnPtr<ObjectPaintProperties> paintProperties) +ObjectPaintProperties& LayoutObject::ensureObjectPaintProperties() { ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); - objectPaintPropertiesMap().set(this, paintProperties); + if (ObjectPaintProperties* properties = objectPaintPropertiesMap().get(this)) + return *properties; + objectPaintPropertiesMap().set(this, ObjectPaintProperties::create()); + return *objectPaintPropertiesMap().get(this); } void LayoutObject::clearObjectPaintProperties()
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.h b/third_party/WebKit/Source/core/layout/LayoutObject.h index fbbb1ee..4eff15d 100644 --- a/third_party/WebKit/Source/core/layout/LayoutObject.h +++ b/third_party/WebKit/Source/core/layout/LayoutObject.h
@@ -403,7 +403,7 @@ // The property nodes are only updated during InUpdatePaintProperties phase // of the document lifecycle and shall remain immutable during other phases. ObjectPaintProperties* objectPaintProperties() const; - void setObjectPaintProperties(PassOwnPtr<ObjectPaintProperties>); + ObjectPaintProperties& ensureObjectPaintProperties(); void clearObjectPaintProperties(); private:
diff --git a/third_party/WebKit/Source/core/layout/LayoutView.cpp b/third_party/WebKit/Source/core/layout/LayoutView.cpp index 6134b5c..b39d631 100644 --- a/third_party/WebKit/Source/core/layout/LayoutView.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutView.cpp
@@ -1032,10 +1032,16 @@ ScrollResult LayoutView::scroll(ScrollGranularity granularity, const FloatSize& delta) { - if (!frameView()) - return ScrollResult(); + // TODO(bokan): This should never get called on the main frame but it + // currently does via the Windows pan scrolling path. That should go through + // a more normalized EventHandler-like scrolling path and we should + // ASSERT(!frame()->isMainFrame()) here. All main frame scrolling should + // be handled by the ViewportScrollCallback. - return frame()->applyScrollDelta(granularity, delta, false); + if (!frameView()) + return ScrollResult(false, false, delta.width(), delta.height()); + + return frameView()->getScrollableArea()->userScroll(granularity, delta); } } // namespace blink
diff --git a/third_party/WebKit/Source/core/page/scrolling/ScrollCustomizationCallbacks.cpp b/third_party/WebKit/Source/core/page/scrolling/ScrollCustomizationCallbacks.cpp index a1b2701..6500fc8f 100644 --- a/third_party/WebKit/Source/core/page/scrolling/ScrollCustomizationCallbacks.cpp +++ b/third_party/WebKit/Source/core/page/scrolling/ScrollCustomizationCallbacks.cpp
@@ -26,6 +26,11 @@ m_applyScrollCallbacks.set(element, scrollStateCallback); } +void ScrollCustomizationCallbacks::removeApplyScroll(Element* element) +{ + m_applyScrollCallbacks.remove(element); +} + ScrollStateCallback* ScrollCustomizationCallbacks::getApplyScroll(Element* element) { auto it = m_applyScrollCallbacks.find(element);
diff --git a/third_party/WebKit/Source/core/page/scrolling/ScrollCustomizationCallbacks.h b/third_party/WebKit/Source/core/page/scrolling/ScrollCustomizationCallbacks.h index 24dfb2a..371bc9e9 100644 --- a/third_party/WebKit/Source/core/page/scrolling/ScrollCustomizationCallbacks.h +++ b/third_party/WebKit/Source/core/page/scrolling/ScrollCustomizationCallbacks.h
@@ -22,6 +22,7 @@ void setDistributeScroll(Element*, ScrollStateCallback*); ScrollStateCallback* getDistributeScroll(Element*); void setApplyScroll(Element*, ScrollStateCallback*); + void removeApplyScroll(Element*); ScrollStateCallback* getApplyScroll(Element*); DEFINE_INLINE_TRACE()
diff --git a/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.cpp b/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.cpp new file mode 100644 index 0000000..f6a6902 --- /dev/null +++ b/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.cpp
@@ -0,0 +1,121 @@ +// Copyright 2016 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 "core/page/scrolling/ViewportScrollCallback.h" + +#include "core/dom/Document.h" +#include "core/frame/FrameHost.h" +#include "core/frame/FrameView.h" +#include "core/frame/Settings.h" +#include "core/frame/TopControls.h" +#include "core/frame/VisualViewport.h" +#include "core/input/EventHandler.h" +#include "core/layout/LayoutView.h" +#include "core/page/scrolling/ScrollState.h" +#include "platform/geometry/FloatSize.h" +#include "platform/scroll/ScrollableArea.h" + +namespace blink { + +ViewportScrollCallback::ViewportScrollCallback(Document& document, + FrameHost& frameHost) + : m_document(&document) + , m_frameHost(&frameHost) +{ + // Only the root document can have a viewport scroll callback for now. + ASSERT(!document.ownerElement()); +} + +ViewportScrollCallback::~ViewportScrollCallback() +{ +} + +DEFINE_TRACE(ViewportScrollCallback) +{ + visitor->trace(m_frameHost); + visitor->trace(m_document); + ScrollStateCallback::trace(visitor); +} + +bool ViewportScrollCallback::shouldScrollTopControls(const FloatSize& delta, + ScrollGranularity granularity) const +{ + if (granularity != ScrollByPixel && granularity != ScrollByPrecisePixel) + return false; + + ScrollableArea* rootFrameViewport = getRootFrameViewport(); + if (!rootFrameViewport) + return false; + + DoublePoint maxScroll = rootFrameViewport->maximumScrollPositionDouble(); + DoublePoint scrollPosition = rootFrameViewport->scrollPositionDouble(); + + // Always give the delta to the top controls if the scroll is in + // the direction to show the top controls. If it's in the + // direction to hide the top controls, only give the delta to the + // top controls when the frame can scroll. + return delta.height() < 0 || scrollPosition.y() < maxScroll.y(); +} + +void ViewportScrollCallback::handleEvent(ScrollState* state) +{ + if (!m_frameHost || !m_document) + return; + + TopControls& topControls = m_frameHost->topControls(); + + // Scroll top controls. + if (state->isBeginning()) + topControls.scrollBegin(); + + FloatSize delta(state->deltaX(), state->deltaY()); + ScrollGranularity granularity = + ScrollGranularity(static_cast<int>(state->deltaGranularity())); + FloatSize remainingDelta = delta; + + if (shouldScrollTopControls(delta, granularity)) + remainingDelta = topControls.scrollBy(delta); + + bool topControlsConsumedScroll = remainingDelta.height() != delta.height(); + + // Do the native scroll. + ScrollableArea* rootFrameViewport = getRootFrameViewport(); + if (!rootFrameViewport) + return; + + ScrollResult result = + rootFrameViewport->userScroll(granularity, remainingDelta); + + // We consider top controls movement to be scrolling. + result.didScrollY |= topControlsConsumedScroll; + + // Handle Overscroll. + FloatPoint position(state->positionX(), state->positionY()); + FloatSize velocity(state->velocityX(), state->velocityY()); + + m_document->frame()->eventHandler().handleOverscroll( + result, position, velocity); + + // The viewport consumes everything. + state->consumeDeltaNative( + state->deltaX() - result.unusedScrollDeltaX, + state->deltaY() - result.unusedScrollDeltaY); +} + +ScrollableArea* ViewportScrollCallback::getRootFrameViewport() const +{ + if (!m_document->layoutView()) + return nullptr; + + FrameView* frameView = m_document->layoutView()->frameView(); + if (!frameView) + return nullptr; + + ScrollableArea* rootFrameViewport = frameView->getScrollableArea(); + ASSERT(rootFrameViewport); + + return rootFrameViewport; +} + +} // namespace blink
diff --git a/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.h b/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.h new file mode 100644 index 0000000..979da5f --- /dev/null +++ b/third_party/WebKit/Source/core/page/scrolling/ViewportScrollCallback.h
@@ -0,0 +1,41 @@ +// Copyright 2016 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 ViewportScrollCallback_h +#define ViewportScrollCallback_h + +#include "core/page/scrolling/ScrollStateCallback.h" +#include "platform/heap/Handle.h" +#include "platform/scroll/ScrollTypes.h" + +namespace blink { + +class Document; +class FloatSize; +class FrameHost; +class Element; +class ScrollableArea; +class ScrollState; + +class ViewportScrollCallback : public ScrollStateCallback { +public: + ViewportScrollCallback(Document&, FrameHost&); + ~ViewportScrollCallback(); + + void handleEvent(ScrollState*) override; + + DECLARE_VIRTUAL_TRACE(); + +private: + bool shouldScrollTopControls(const FloatSize&, ScrollGranularity) const; + ScrollableArea* getRootFrameViewport() const; + + WeakMember<Document> m_document; + WeakMember<FrameHost> m_frameHost; + +}; + +} // namespace blink + +#endif // ViewportScrollCallback_h
diff --git a/third_party/WebKit/Source/core/paint/ObjectPaintProperties.h b/third_party/WebKit/Source/core/paint/ObjectPaintProperties.h index c6c7830..2977ae8 100644 --- a/third_party/WebKit/Source/core/paint/ObjectPaintProperties.h +++ b/third_party/WebKit/Source/core/paint/ObjectPaintProperties.h
@@ -27,25 +27,9 @@ public: struct LocalBorderBoxProperties; - // TODO(pdr): This should be refactored to not pass 11 arguments because it - // is hard to follow here and at the callsites. - static PassOwnPtr<ObjectPaintProperties> create( - PassRefPtr<TransformPaintPropertyNode> paintOffsetTranslation, - PassRefPtr<TransformPaintPropertyNode> transform, - PassRefPtr<EffectPaintPropertyNode> effect, - PassRefPtr<ClipPaintPropertyNode> cssClip, - PassRefPtr<ClipPaintPropertyNode> cssClipFixedPosition, - PassRefPtr<ClipPaintPropertyNode> overflowClip, - PassRefPtr<TransformPaintPropertyNode> perspective, - PassRefPtr<TransformPaintPropertyNode> svgLocalTransform, - PassRefPtr<TransformPaintPropertyNode> scrollTranslation, - PassRefPtr<TransformPaintPropertyNode> scrollbarPaintOffset, - PassOwnPtr<LocalBorderBoxProperties> localBorderBoxProperties) + static PassOwnPtr<ObjectPaintProperties> create() { - return adoptPtr(new ObjectPaintProperties(paintOffsetTranslation, - transform, effect, cssClip, cssClipFixedPosition, overflowClip, - perspective, svgLocalTransform, scrollTranslation, - scrollbarPaintOffset, localBorderBoxProperties)); + return adoptPtr(new ObjectPaintProperties()); } // The hierarchy of transform subtree created by a LayoutObject. @@ -90,29 +74,29 @@ LocalBorderBoxProperties* localBorderBoxProperties() const { return m_localBorderBoxProperties.get(); } private: - ObjectPaintProperties( - PassRefPtr<TransformPaintPropertyNode> paintOffsetTranslation, - PassRefPtr<TransformPaintPropertyNode> transform, - PassRefPtr<EffectPaintPropertyNode> effect, - PassRefPtr<ClipPaintPropertyNode> cssClip, - PassRefPtr<ClipPaintPropertyNode> cssClipFixedPosition, - PassRefPtr<ClipPaintPropertyNode> overflowClip, - PassRefPtr<TransformPaintPropertyNode> perspective, - PassRefPtr<TransformPaintPropertyNode> svgLocalTransform, - PassRefPtr<TransformPaintPropertyNode> scrollTranslation, - PassRefPtr<TransformPaintPropertyNode> scrollbarPaintOffset, - PassOwnPtr<LocalBorderBoxProperties> localBorderBoxProperties) - : m_paintOffsetTranslation(paintOffsetTranslation) - , m_transform(transform) - , m_effect(effect) - , m_cssClip(cssClip) - , m_cssClipFixedPosition(cssClipFixedPosition) - , m_overflowClip(overflowClip) - , m_perspective(perspective) - , m_svgLocalTransform(svgLocalTransform) - , m_scrollTranslation(scrollTranslation) - , m_scrollbarPaintOffset(scrollbarPaintOffset) - , m_localBorderBoxProperties(localBorderBoxProperties) { } + ObjectPaintProperties() { } + + friend class PaintPropertyTreeBuilder; + // These setters should only be used by PaintPropertyTreeBuilder. + void setPaintOffsetTranslation(PassRefPtr<TransformPaintPropertyNode> paintOffset) { m_paintOffsetTranslation = paintOffset; } + void setTransform(PassRefPtr<TransformPaintPropertyNode> transform) { m_transform = transform; } + void setEffect(PassRefPtr<EffectPaintPropertyNode> effect) { m_effect = effect; } + void setCssClip(PassRefPtr<ClipPaintPropertyNode> clip) { m_cssClip = clip; } + void setCssClipFixedPosition(PassRefPtr<ClipPaintPropertyNode> clip) { m_cssClipFixedPosition = clip; } + void setOverflowClip(PassRefPtr<ClipPaintPropertyNode> clip) { m_overflowClip = clip; } + void setPerspective(PassRefPtr<TransformPaintPropertyNode> perspective) { m_perspective = perspective; } + void setSvgLocalTransform(PassRefPtr<TransformPaintPropertyNode> transform) + { + DCHECK(!scrollTranslation()) << "SVG elements cannot scroll so there should never be both a scroll translation and an SVG local transform."; + m_svgLocalTransform = transform; + } + void setScrollTranslation(PassRefPtr<TransformPaintPropertyNode> translation) + { + DCHECK(!svgLocalTransform()) << "SVG elements cannot scroll so there should never be both a scroll translation and an SVG local transform."; + m_scrollTranslation = translation; + } + void setScrollbarPaintOffset(PassRefPtr<TransformPaintPropertyNode> paintOffset) { m_scrollbarPaintOffset = paintOffset; } + void setLocalBorderBoxProperties(PassOwnPtr<LocalBorderBoxProperties> properties) { m_localBorderBoxProperties = properties; } RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation; RefPtr<TransformPaintPropertyNode> m_transform;
diff --git a/third_party/WebKit/Source/core/paint/PaintLayer.cpp b/third_party/WebKit/Source/core/paint/PaintLayer.cpp index 832ee11..9b9a868 100644 --- a/third_party/WebKit/Source/core/paint/PaintLayer.cpp +++ b/third_party/WebKit/Source/core/paint/PaintLayer.cpp
@@ -422,6 +422,9 @@ if (had3DTransform != has3DTransform()) dirty3DTransformedDescendantStatus(); + + if (FrameView* frameView = layoutObject()->document().view()) + frameView->setNeedsUpdateWidgetGeometries(); } static PaintLayer* enclosingLayerForContainingBlock(PaintLayer* layer)
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp index 39ca334..ec8a78e 100644 --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
@@ -100,6 +100,249 @@ walk(*layoutView, localContext); } +void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(LayoutObject& object, PaintPropertyTreeBuilderContext& context) +{ + bool shouldCreatePaintOffsetTranslationNode = false; + if (object.isSVGRoot()) { + // SVG doesn't use paint offset internally so emit a paint offset at the html->svg boundary. + shouldCreatePaintOffsetTranslationNode = true; + } else if (object.isBoxModelObject()) { + // TODO(trchen): Eliminate PaintLayer dependency. + PaintLayer* layer = toLayoutBoxModelObject(object).layer(); + shouldCreatePaintOffsetTranslationNode = layer && layer->paintsWithTransform(GlobalPaintNormalPhase); + } + + if (context.paintOffset == LayoutPoint() || !shouldCreatePaintOffsetTranslationNode) + return; + + RefPtr<TransformPaintPropertyNode> paintOffsetTranslation = TransformPaintPropertyNode::create( + TransformationMatrix().translate(context.paintOffset.x(), context.paintOffset.y()), + FloatPoint3D(), context.currentTransform); + context.currentTransform = paintOffsetTranslation.get(); + context.paintOffset = LayoutPoint(); + object.ensureObjectPaintProperties().setPaintOffsetTranslation(paintOffsetTranslation.release()); +} + +static FloatPoint3D transformOrigin(const LayoutBox& box) +{ + const ComputedStyle& style = box.styleRef(); + FloatSize borderBoxSize(box.size()); + return FloatPoint3D( + floatValueForLength(style.transformOriginX(), borderBoxSize.width()), + floatValueForLength(style.transformOriginY(), borderBoxSize.height()), + style.transformOriginZ()); +} + +void PaintPropertyTreeBuilder::updateTransform(LayoutObject& object, PaintPropertyTreeBuilderContext& context) +{ + const ComputedStyle& style = object.styleRef(); + if (!object.isBox() || !style.hasTransform()) + return; + ASSERT(context.paintOffset == LayoutPoint()); + + TransformationMatrix matrix; + style.applyTransform(matrix, toLayoutBox(object).size(), ComputedStyle::ExcludeTransformOrigin, + ComputedStyle::IncludeMotionPath, ComputedStyle::IncludeIndependentTransformProperties); + RefPtr<TransformPaintPropertyNode> transformNode = TransformPaintPropertyNode::create( + matrix, transformOrigin(toLayoutBox(object)), context.currentTransform); + context.currentTransform = transformNode.get(); + object.ensureObjectPaintProperties().setTransform(transformNode.release()); +} + +void PaintPropertyTreeBuilder::updateEffect(LayoutObject& object, PaintPropertyTreeBuilderContext& context) +{ + if (!object.styleRef().hasOpacity()) + return; + RefPtr<EffectPaintPropertyNode> effectNode = EffectPaintPropertyNode::create(object.styleRef().opacity(), context.currentEffect); + context.currentEffect = effectNode.get(); + object.ensureObjectPaintProperties().setEffect(effectNode.release()); +} + +void PaintPropertyTreeBuilder::updateCssClip(LayoutObject& object, PaintPropertyTreeBuilderContext& context) +{ + if (!object.hasClip()) + return; + ASSERT(object.canContainAbsolutePositionObjects()); + + // Create clip node for descendants that are not fixed position. + // We don't have to setup context.clipForAbsolutePosition here because this object must be + // a container for absolute position descendants, and will copy from in-flow context later + // at updateOutOfFlowContext() step. + LayoutRect clipRect = toLayoutBox(object).clipRect(context.paintOffset); + RefPtr<ClipPaintPropertyNode> clipNode = ClipPaintPropertyNode::create( + context.currentTransform, + FloatRoundedRect(FloatRect(clipRect)), + context.currentClip); + context.currentClip = clipNode.get(); + object.ensureObjectPaintProperties().setCssClip(clipNode.release()); +} + +void PaintPropertyTreeBuilder::updateLocalBorderBoxContext(LayoutObject& object, const PaintPropertyTreeBuilderContext& context) +{ + // Note: Currently only layer painter makes use of the pre-computed context. + // This condition may be loosened with no adverse effects beside memory use. + if (!object.hasLayer()) + return; + + OwnPtr<ObjectPaintProperties::LocalBorderBoxProperties> borderBoxContext = + adoptPtr(new ObjectPaintProperties::LocalBorderBoxProperties); + borderBoxContext->paintOffset = context.paintOffset; + borderBoxContext->transform = context.currentTransform; + borderBoxContext->clip = context.currentClip; + borderBoxContext->effect = context.currentEffect; + object.ensureObjectPaintProperties().setLocalBorderBoxProperties(borderBoxContext.release()); +} + +// TODO(trchen): Remove this once we bake the paint offset into frameRect. +void PaintPropertyTreeBuilder::updateScrollbarPaintOffset(LayoutObject& object, const PaintPropertyTreeBuilderContext& context) +{ + IntPoint roundedPaintOffset = roundedIntPoint(context.paintOffset); + if (roundedPaintOffset == IntPoint()) + return; + + if (!object.isBoxModelObject()) + return; + PaintLayerScrollableArea* scrollableArea = toLayoutBoxModelObject(object).getScrollableArea(); + if (!scrollableArea) + return; + if (!scrollableArea->horizontalScrollbar() && !scrollableArea->verticalScrollbar()) + return; + + auto paintOffset = TransformationMatrix().translate(roundedPaintOffset.x(), roundedPaintOffset.y()); + object.ensureObjectPaintProperties().setScrollbarPaintOffset( + TransformPaintPropertyNode::create(paintOffset, FloatPoint3D(), context.currentTransform)); +} + +void PaintPropertyTreeBuilder::updateOverflowClip(LayoutObject& object, PaintPropertyTreeBuilderContext& context) +{ + if (!object.isBox()) + return; + const LayoutBox& box = toLayoutBox(object); + + // The <input> elements can't have contents thus CSS overflow property doesn't apply. + // However for layout purposes we do generate child layout objects for them, e.g. button label. + // We should clip the overflow from those children. This is called control clip and we + // technically treat them like overflow clip. + LayoutRect clipRect; + if (box.hasControlClip()) + clipRect = box.controlClipRect(context.paintOffset); + else if (box.hasOverflowClip()) + clipRect = box.overflowClipRect(context.paintOffset); + else + return; + + RefPtr<ClipPaintPropertyNode> borderRadiusClip; + if (box.styleRef().hasBorderRadius()) { + auto innerBorder = box.styleRef().getRoundedInnerBorderFor( + LayoutRect(context.paintOffset, box.size())); + borderRadiusClip = ClipPaintPropertyNode::create( + context.currentTransform, innerBorder, context.currentClip); + } + + RefPtr<ClipPaintPropertyNode> overflowClip = ClipPaintPropertyNode::create( + context.currentTransform, + FloatRoundedRect(FloatRect(clipRect)), + borderRadiusClip ? borderRadiusClip.release() : context.currentClip); + context.currentClip = overflowClip.get(); + object.ensureObjectPaintProperties().setOverflowClip(overflowClip.release()); +} + +static FloatPoint perspectiveOrigin(const LayoutBox& box) +{ + const ComputedStyle& style = box.styleRef(); + FloatSize borderBoxSize(box.size()); + return FloatPoint( + floatValueForLength(style.perspectiveOriginX(), borderBoxSize.width()), + floatValueForLength(style.perspectiveOriginY(), borderBoxSize.height())); +} + +void PaintPropertyTreeBuilder::updatePerspective(LayoutObject& object, PaintPropertyTreeBuilderContext& context) +{ + const ComputedStyle& style = object.styleRef(); + if (!object.isBox() || !style.hasPerspective()) + return; + + RefPtr<TransformPaintPropertyNode> perspective = TransformPaintPropertyNode::create( + TransformationMatrix().applyPerspective(style.perspective()), + perspectiveOrigin(toLayoutBox(object)) + toLayoutSize(context.paintOffset), + context.currentTransform); + context.currentTransform = perspective.get(); + object.ensureObjectPaintProperties().setPerspective(perspective.release()); +} + +void PaintPropertyTreeBuilder::updateSvgLocalTransform(LayoutObject& object, PaintPropertyTreeBuilderContext& context) +{ + if (!object.isSVG()) + return; + + const AffineTransform& transform = object.localToSVGParentTransform(); + if (transform.isIdentity()) + return; + + // The origin is included in the local transform, so use an empty origin. + RefPtr<TransformPaintPropertyNode> svgLocalTransform = TransformPaintPropertyNode::create( + transform, FloatPoint3D(0, 0, 0), context.currentTransform); + context.currentTransform = svgLocalTransform.get(); + object.ensureObjectPaintProperties().setSvgLocalTransform(svgLocalTransform.release()); +} + +void PaintPropertyTreeBuilder::updateScrollTranslation(LayoutObject& object, PaintPropertyTreeBuilderContext& context) +{ + if (!object.isBoxModelObject() || !object.hasOverflowClip()) + return; + + PaintLayer* layer = toLayoutBoxModelObject(object).layer(); + ASSERT(layer); + DoubleSize scrollOffset = layer->getScrollableArea()->scrollOffset(); + if (scrollOffset.isZero() && !layer->scrollsOverflow()) + return; + + RefPtr<TransformPaintPropertyNode> scrollTranslation = TransformPaintPropertyNode::create( + TransformationMatrix().translate(-scrollOffset.width(), -scrollOffset.height()), + FloatPoint3D(), + context.currentTransform); + context.currentTransform = scrollTranslation.get(); + object.ensureObjectPaintProperties().setScrollTranslation(scrollTranslation.release()); +} + +void PaintPropertyTreeBuilder::updateOutOfFlowContext(LayoutObject& object, PaintPropertyTreeBuilderContext& context) +{ + if (object.canContainAbsolutePositionObjects()) { + context.transformForAbsolutePosition = context.currentTransform; + context.paintOffsetForAbsolutePosition = context.paintOffset; + context.clipForAbsolutePosition = context.currentClip; + } + + // TODO(pdr): Remove the !object.isLayoutView() condition when removing FrameView + // paint properties for rootLayerScrolls. + if (!object.isLayoutView() && object.canContainFixedPositionObjects()) { + context.transformForFixedPosition = context.currentTransform; + context.paintOffsetForFixedPosition = context.paintOffset; + context.clipForFixedPosition = context.currentClip; + } else if (object.objectPaintProperties() && object.objectPaintProperties()->cssClip()) { + // CSS clip applies to all descendants, even if this object is not a containing block + // ancestor of the descendant. It is okay for absolute-position descendants because + // having CSS clip implies being absolute position container. However for fixed-position + // descendants we need to insert the clip here if we are not a containing block ancestor + // of them. + auto* cssClip = object.objectPaintProperties()->cssClip(); + + // Before we actually create anything, check whether in-flow context and fixed-position + // context has exactly the same clip. Reuse if possible. + if (context.clipForFixedPosition == cssClip->parent()) { + context.clipForFixedPosition = cssClip; + return; + } + + RefPtr<ClipPaintPropertyNode> clipFixedPosition = ClipPaintPropertyNode::create( + const_cast<TransformPaintPropertyNode*>(cssClip->localTransformSpace()), + cssClip->clipRect(), + context.clipForFixedPosition); + context.clipForFixedPosition = clipFixedPosition.get(); + object.ensureObjectPaintProperties().setCssClipFixedPosition(clipFixedPosition.release()); + } +} + static void deriveBorderBoxFromContainerContext(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) { if (!object.isBoxModelObject()) @@ -142,295 +385,26 @@ } } -static PassRefPtr<TransformPaintPropertyNode> createPaintOffsetTranslationIfNeeded(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) -{ - bool shouldCreatePaintOffsetTranslationNode = false; - if (object.isSVGRoot()) { - // SVG doesn't use paint offset internally so emit a paint offset at the html->svg boundary. - shouldCreatePaintOffsetTranslationNode = true; - } else if (object.isBoxModelObject()) { - // TODO(trchen): Eliminate PaintLayer dependency. - PaintLayer* layer = toLayoutBoxModelObject(object).layer(); - shouldCreatePaintOffsetTranslationNode = layer && layer->paintsWithTransform(GlobalPaintNormalPhase); - } - - if (context.paintOffset == LayoutPoint() || !shouldCreatePaintOffsetTranslationNode) - return nullptr; - - RefPtr<TransformPaintPropertyNode> newTransformNodeForPaintOffsetTranslation = TransformPaintPropertyNode::create( - TransformationMatrix().translate(context.paintOffset.x(), context.paintOffset.y()), - FloatPoint3D(), context.currentTransform); - context.currentTransform = newTransformNodeForPaintOffsetTranslation.get(); - context.paintOffset = LayoutPoint(); - return newTransformNodeForPaintOffsetTranslation.release(); -} - -static FloatPoint3D transformOrigin(const LayoutBox& box) -{ - const ComputedStyle& style = box.styleRef(); - FloatSize borderBoxSize(box.size()); - return FloatPoint3D( - floatValueForLength(style.transformOriginX(), borderBoxSize.width()), - floatValueForLength(style.transformOriginY(), borderBoxSize.height()), - style.transformOriginZ()); -} - -static PassRefPtr<TransformPaintPropertyNode> createTransformIfNeeded(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) -{ - const ComputedStyle& style = object.styleRef(); - if (!object.isBox() || !style.hasTransform()) - return nullptr; - - ASSERT(context.paintOffset == LayoutPoint()); - - TransformationMatrix matrix; - style.applyTransform(matrix, toLayoutBox(object).size(), ComputedStyle::ExcludeTransformOrigin, - ComputedStyle::IncludeMotionPath, ComputedStyle::IncludeIndependentTransformProperties); - RefPtr<TransformPaintPropertyNode> newTransformNodeForTransform = TransformPaintPropertyNode::create( - matrix, transformOrigin(toLayoutBox(object)), context.currentTransform); - context.currentTransform = newTransformNodeForTransform.get(); - return newTransformNodeForTransform.release(); -} - -static PassRefPtr<TransformPaintPropertyNode> createSvgLocalTransformIfNeeded(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) -{ - if (!object.isSVG()) - return nullptr; - - const AffineTransform& transform = object.localToSVGParentTransform(); - if (transform.isIdentity()) - return nullptr; - - // SVG's transform origin is baked into the localToSVGParentTransform so we use 0's for the origin. - RefPtr<TransformPaintPropertyNode> newTransformNodeForTransform = TransformPaintPropertyNode::create( - transform, FloatPoint3D(0, 0, 0), context.currentTransform); - context.currentTransform = newTransformNodeForTransform.get(); - return newTransformNodeForTransform.release(); -} - -static PassRefPtr<EffectPaintPropertyNode> createEffectIfNeeded(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) -{ - const ComputedStyle& style = object.styleRef(); - if (!style.hasOpacity()) - return nullptr; - RefPtr<EffectPaintPropertyNode> newEffectNode = EffectPaintPropertyNode::create(style.opacity(), context.currentEffect); - context.currentEffect = newEffectNode.get(); - return newEffectNode.release(); -} - -static PassRefPtr<ClipPaintPropertyNode> createCSSClipIfNeeded(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) -{ - if (!object.hasClip()) - return nullptr; - ASSERT(object.canContainAbsolutePositionObjects()); - - // Create clip node for descendants that are not fixed position. - // We don't have to setup context.clipForAbsolutePosition here because this object must be - // a container for absolute position descendants, and will copy from in-flow context later - // at updateOutOfFlowContext() step. - LayoutRect clipRect = toLayoutBox(object).clipRect(context.paintOffset); - RefPtr<ClipPaintPropertyNode> newClipNodeForCSSClip = ClipPaintPropertyNode::create( - context.currentTransform, - FloatRoundedRect(FloatRect(clipRect)), - context.currentClip); - context.currentClip = newClipNodeForCSSClip.get(); - - return newClipNodeForCSSClip.release(); -} - -// TODO(trchen): Remove this once we bake the paint offset into frameRect. -static PassRefPtr<TransformPaintPropertyNode> createScrollbarPaintOffsetIfNeeded(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) -{ - IntPoint roundedPaintOffset = roundedIntPoint(context.paintOffset); - if (roundedPaintOffset == IntPoint()) - return nullptr; - - if (!object.isBoxModelObject()) - return nullptr; - PaintLayerScrollableArea* scrollableArea = toLayoutBoxModelObject(object).getScrollableArea(); - if (!scrollableArea) - return nullptr; - if (!scrollableArea->horizontalScrollbar() && !scrollableArea->verticalScrollbar()) - return nullptr; - - return TransformPaintPropertyNode::create( - TransformationMatrix().translate(roundedPaintOffset.x(), roundedPaintOffset.y()), - FloatPoint3D(), context.currentTransform); -} - -static PassRefPtr<ClipPaintPropertyNode> createOverflowClipIfNeeded(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) -{ - if (!object.isBox()) - return nullptr; - const LayoutBox& box = toLayoutBox(object); - - // The <input> elements can't have contents thus CSS overflow property doesn't apply. - // However for layout purposes we do generate child layout objects for them, e.g. button label. - // We should clip the overflow from those children. This is called control clip and we - // technically treat them like overflow clip. - LayoutRect clipRect; - if (box.hasControlClip()) - clipRect = box.controlClipRect(context.paintOffset); - else if (box.hasOverflowClip()) - clipRect = box.overflowClipRect(context.paintOffset); - else - return nullptr; - - RefPtr<ClipPaintPropertyNode> newClipNodeForBorderRadiusClip; - const ComputedStyle& style = box.styleRef(); - if (style.hasBorderRadius()) { - newClipNodeForBorderRadiusClip = ClipPaintPropertyNode::create( - context.currentTransform, - style.getRoundedInnerBorderFor(LayoutRect(context.paintOffset, box.size())), - context.currentClip); - } - - RefPtr<ClipPaintPropertyNode> newClipNodeForOverflowClip = ClipPaintPropertyNode::create( - context.currentTransform, - FloatRoundedRect(FloatRect(clipRect)), - newClipNodeForBorderRadiusClip ? newClipNodeForBorderRadiusClip.release() : context.currentClip); - context.currentClip = newClipNodeForOverflowClip.get(); - return newClipNodeForOverflowClip.release(); -} - -static FloatPoint perspectiveOrigin(const LayoutBox& box) -{ - const ComputedStyle& style = box.styleRef(); - FloatSize borderBoxSize(box.size()); - return FloatPoint( - floatValueForLength(style.perspectiveOriginX(), borderBoxSize.width()), - floatValueForLength(style.perspectiveOriginY(), borderBoxSize.height())); -} - -static PassRefPtr<TransformPaintPropertyNode> createPerspectiveIfNeeded(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) -{ - const ComputedStyle& style = object.styleRef(); - if (!object.isBox() || !style.hasPerspective()) - return nullptr; - - RefPtr<TransformPaintPropertyNode> newTransformNodeForPerspective = TransformPaintPropertyNode::create( - TransformationMatrix().applyPerspective(style.perspective()), - perspectiveOrigin(toLayoutBox(object)) + toLayoutSize(context.paintOffset), context.currentTransform); - context.currentTransform = newTransformNodeForPerspective.get(); - return newTransformNodeForPerspective.release(); -} - -static PassRefPtr<TransformPaintPropertyNode> createScrollTranslationIfNeeded(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) -{ - if (!object.isBoxModelObject() || !object.hasOverflowClip()) - return nullptr; - - PaintLayer* layer = toLayoutBoxModelObject(object).layer(); - ASSERT(layer); - DoubleSize scrollOffset = layer->getScrollableArea()->scrollOffset(); - if (scrollOffset.isZero() && !layer->scrollsOverflow()) - return nullptr; - - RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = TransformPaintPropertyNode::create( - TransformationMatrix().translate(-scrollOffset.width(), -scrollOffset.height()), - FloatPoint3D(), context.currentTransform); - context.currentTransform = newTransformNodeForScrollTranslation.get(); - return newTransformNodeForScrollTranslation.release(); -} - -static void updateOutOfFlowContext(const LayoutObject& object, PaintPropertyTreeBuilderContext& context, ClipPaintPropertyNode* newClipNodeForCSSClip, RefPtr<ClipPaintPropertyNode>& newClipNodeForCSSClipFixedPosition) -{ - // TODO(pdr): Always create an SVG transform for the root and remove this paint offset quirk. - // At the html->svg boundary (see: createPaintOffsetTranslationIfNeeded) the currentTransform is - // up-to-date for all children of the svg root element. Additionally, inside SVG, all positioning - // uses transforms. Therefore, we only need to check createdNewTransform and isSVGRoot() to - // ensure out-of-flow and fixed positioning is correct at the svg->html boundary. - - if (object.canContainAbsolutePositionObjects()) { - context.transformForAbsolutePosition = context.currentTransform; - context.paintOffsetForAbsolutePosition = context.paintOffset; - context.clipForAbsolutePosition = context.currentClip; - } - - // TODO(pdr): Remove the !object.isLayoutView() condition when removing FrameView - // paint properties for rootLayerScrolls. - if (!object.isLayoutView() && object.canContainFixedPositionObjects()) { - context.transformForFixedPosition = context.currentTransform; - context.paintOffsetForFixedPosition = context.paintOffset; - context.clipForFixedPosition = context.currentClip; - } else if (newClipNodeForCSSClip) { - // CSS clip applies to all descendants, even if this object is not a containing block - // ancestor of the descendant. It is okay for absolute-position descendants because - // having CSS clip implies being absolute position container. However for fixed-position - // descendants we need to insert the clip here if we are not a containing block ancestor - // of them. - - // Before we actually create anything, check whether in-flow context and fixed-position - // context has exactly the same clip. Reuse if possible. - if (context.clipForFixedPosition == newClipNodeForCSSClip->parent()) { - context.clipForFixedPosition = newClipNodeForCSSClip; - return; - } - - newClipNodeForCSSClipFixedPosition = ClipPaintPropertyNode::create( - const_cast<TransformPaintPropertyNode*>(newClipNodeForCSSClip->localTransformSpace()), - newClipNodeForCSSClip->clipRect(), - context.clipForFixedPosition); - context.clipForFixedPosition = newClipNodeForCSSClipFixedPosition.get(); - } -} - -static PassOwnPtr<ObjectPaintProperties::LocalBorderBoxProperties> recordTreeContextIfNeeded(LayoutObject& object, const PaintPropertyTreeBuilderContext& context) -{ - // Note: Currently only layer painter makes use of the pre-computed context. - // This condition may be loosened with no adverse effects beside memory use. - if (!object.hasLayer()) - return nullptr; - - OwnPtr<ObjectPaintProperties::LocalBorderBoxProperties> recordedContext = adoptPtr(new ObjectPaintProperties::LocalBorderBoxProperties); - recordedContext->paintOffset = context.paintOffset; - recordedContext->transform = context.currentTransform; - recordedContext->clip = context.currentClip; - recordedContext->effect = context.currentEffect; - return recordedContext.release(); -} - void PaintPropertyTreeBuilder::walk(LayoutObject& object, const PaintPropertyTreeBuilderContext& context) { PaintPropertyTreeBuilderContext localContext(context); + object.clearObjectPaintProperties(); deriveBorderBoxFromContainerContext(object, localContext); - RefPtr<TransformPaintPropertyNode> newTransformNodeForPaintOffsetTranslation = createPaintOffsetTranslationIfNeeded(object, localContext); - RefPtr<TransformPaintPropertyNode> newTransformNodeForTransform = createTransformIfNeeded(object, localContext); - RefPtr<EffectPaintPropertyNode> newEffectNode = createEffectIfNeeded(object, localContext); - RefPtr<ClipPaintPropertyNode> newClipNodeForCSSClip = createCSSClipIfNeeded(object, localContext); - OwnPtr<ObjectPaintProperties::LocalBorderBoxProperties> newRecordedContext = recordTreeContextIfNeeded(object, localContext); - RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollbarPaintOffset = createScrollbarPaintOffsetIfNeeded(object, localContext); - RefPtr<ClipPaintPropertyNode> newClipNodeForOverflowClip = createOverflowClipIfNeeded(object, localContext); + + updatePaintOffsetTranslation(object, localContext); + updateTransform(object, localContext); + updateEffect(object, localContext); + updateCssClip(object, localContext); + updateLocalBorderBoxContext(object, localContext); + updateScrollbarPaintOffset(object, localContext); + updateOverflowClip(object, localContext); // TODO(trchen): Insert flattening transform here, as specified by // http://www.w3.org/TR/css3-transforms/#transform-style-property - RefPtr<TransformPaintPropertyNode> newTransformNodeForPerspective = createPerspectiveIfNeeded(object, localContext); - RefPtr<TransformPaintPropertyNode> newTransformNodeForSvgLocalTransform = createSvgLocalTransformIfNeeded(object, localContext); - RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = createScrollTranslationIfNeeded(object, localContext); - RefPtr<ClipPaintPropertyNode> newClipNodeForCSSClipFixedPosition; - updateOutOfFlowContext(object, localContext, newClipNodeForCSSClip.get(), newClipNodeForCSSClipFixedPosition); - - DCHECK(!newTransformNodeForSvgLocalTransform || !newTransformNodeForScrollTranslation) - << "SVG elements cannot have scroll translation"; - - // TODO(pdr): Refactor this to use a less massive if statement. - if (newTransformNodeForPaintOffsetTranslation || newTransformNodeForTransform || newEffectNode || newClipNodeForCSSClip || newClipNodeForCSSClipFixedPosition || newClipNodeForOverflowClip || newTransformNodeForPerspective || newTransformNodeForSvgLocalTransform || newTransformNodeForScrollTranslation || newTransformNodeForScrollbarPaintOffset || newRecordedContext) { - OwnPtr<ObjectPaintProperties> updatedPaintProperties = ObjectPaintProperties::create( - newTransformNodeForPaintOffsetTranslation.release(), - newTransformNodeForTransform.release(), - newEffectNode.release(), - newClipNodeForCSSClip.release(), - newClipNodeForCSSClipFixedPosition.release(), - newClipNodeForOverflowClip.release(), - newTransformNodeForPerspective.release(), - newTransformNodeForSvgLocalTransform.release(), - newTransformNodeForScrollTranslation.release(), - newTransformNodeForScrollbarPaintOffset.release(), - newRecordedContext.release()); - object.setObjectPaintProperties(updatedPaintProperties.release()); - } else { - object.clearObjectPaintProperties(); - } + updatePerspective(object, localContext); + updateSvgLocalTransform(object, localContext); + updateScrollTranslation(object, localContext); + updateOutOfFlowContext(object, localContext); for (LayoutObject* child = object.slowFirstChild(); child; child = child->nextSibling()) { if (child->isBoxModelObject() || child->isSVG())
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.h b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.h index cdfacad..e716410 100644 --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.h +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.h
@@ -22,6 +22,19 @@ private: void walk(FrameView&, const PaintPropertyTreeBuilderContext&); + + static void updatePaintOffsetTranslation(LayoutObject&, PaintPropertyTreeBuilderContext&); + static void updateTransform(LayoutObject&, PaintPropertyTreeBuilderContext&); + static void updateEffect(LayoutObject&, PaintPropertyTreeBuilderContext&); + static void updateCssClip(LayoutObject&, PaintPropertyTreeBuilderContext&); + static void updateLocalBorderBoxContext(LayoutObject&, const PaintPropertyTreeBuilderContext&); + static void updateScrollbarPaintOffset(LayoutObject&, const PaintPropertyTreeBuilderContext&); + static void updateOverflowClip(LayoutObject&, PaintPropertyTreeBuilderContext&); + static void updatePerspective(LayoutObject&, PaintPropertyTreeBuilderContext&); + static void updateSvgLocalTransform(LayoutObject&, PaintPropertyTreeBuilderContext&); + static void updateScrollTranslation(LayoutObject&, PaintPropertyTreeBuilderContext&); + static void updateOutOfFlowContext(LayoutObject&, PaintPropertyTreeBuilderContext&); + void walk(LayoutObject&, const PaintPropertyTreeBuilderContext&); };
diff --git a/third_party/WebKit/Source/core/style/GridPositionsResolver.cpp b/third_party/WebKit/Source/core/style/GridPositionsResolver.cpp index e401dbfd..23cb2441 100644 --- a/third_party/WebKit/Source/core/style/GridPositionsResolver.cpp +++ b/third_party/WebKit/Source/core/style/GridPositionsResolver.cpp
@@ -207,12 +207,12 @@ size_t GridPositionsResolver::explicitGridColumnCount(const ComputedStyle& gridContainerStyle, size_t autoRepeatTracksCount) { - return std::min<size_t>(gridContainerStyle.gridTemplateColumns().size() + autoRepeatTracksCount, kGridMaxTracks); + return std::min<size_t>(std::max(gridContainerStyle.gridTemplateColumns().size() + autoRepeatTracksCount, gridContainerStyle.namedGridAreaColumnCount()), kGridMaxTracks); } size_t GridPositionsResolver::explicitGridRowCount(const ComputedStyle& gridContainerStyle, size_t autoRepeatTracksCount) { - return std::min<size_t>(gridContainerStyle.gridTemplateRows().size() + autoRepeatTracksCount, kGridMaxTracks); + return std::min<size_t>(std::max(gridContainerStyle.gridTemplateRows().size() + autoRepeatTracksCount, gridContainerStyle.namedGridAreaRowCount()), kGridMaxTracks); } static size_t explicitGridSizeForSide(const ComputedStyle& gridContainerStyle, GridPositionSide side, size_t autoRepeatTracksCount)
diff --git a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp index 9de6192..bd4b897 100644 --- a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp +++ b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
@@ -1544,8 +1544,11 @@ if (m_responseTypeCode == ResponseTypeJSON) return TextResourceDecoder::create("application/json", "UTF-8"); - if (!m_finalResponseCharset.isEmpty()) - return TextResourceDecoder::create("text/plain", m_finalResponseCharset); + if (!m_finalResponseCharset.isEmpty()) { + OwnPtr<TextResourceDecoder> decoder(TextResourceDecoder::create("text/plain")); + decoder->setEncoding(WTF::TextEncoding(m_finalResponseCharset), TextResourceDecoder::EncodingFromHTTPHeader); + return decoder.release(); + } // allow TextResourceDecoder to look inside the m_response if it's XML or HTML if (responseIsXML()) {
diff --git a/third_party/WebKit/Source/devtools/devtools.gypi b/third_party/WebKit/Source/devtools/devtools.gypi index cd6a22c..6dc78d6 100644 --- a/third_party/WebKit/Source/devtools/devtools.gypi +++ b/third_party/WebKit/Source/devtools/devtools.gypi
@@ -156,6 +156,7 @@ 'front_end/sdk/NetworkManager.js', 'front_end/sdk/NetworkRequest.js', 'front_end/sdk/PaintProfiler.js', + 'front_end/sdk/ProfileTreeModel.js', 'front_end/sdk/RemoteObject.js', 'front_end/sdk/Resource.js', 'front_end/sdk/ResourceTreeModel.js',
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js index d51f72d5..878b2e59 100644 --- a/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js +++ b/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js
@@ -2,72 +2,82 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +/** + * @constructor + * @extends {WebInspector.ProfileNode} + * @param {!ProfilerAgent.CPUProfileNode} sourceNode + * @param {number} sampleTime + */ +WebInspector.CPUProfileNode = function(sourceNode, sampleTime) +{ + WebInspector.ProfileNode.call(this, sourceNode.functionName, sourceNode.scriptId, sourceNode.url, sourceNode.lineNumber, sourceNode.columnNumber); + this.id = sourceNode.id; + this.self = sourceNode.hitCount * sampleTime; + this.callUID = sourceNode.callUID; + this.positionTicks = sourceNode.positionTicks; + this.deoptReason = sourceNode.deoptReason; + // TODO: Remove the following field in favor of this.self + this.selfTime = this.self; +} + +WebInspector.CPUProfileNode.prototype = { + __proto__: WebInspector.ProfileNode.prototype +} /** * @constructor + * @extends {WebInspector.ProfileTreeModel} * @param {!ProfilerAgent.CPUProfile} profile */ WebInspector.CPUProfileDataModel = function(profile) { - this.profileHead = profile.head; this.samples = profile.samples; this.timestamps = profile.timestamps; + // Convert times from sec to msec. this.profileStartTime = profile.startTime * 1000; this.profileEndTime = profile.endTime * 1000; - this._assignParentsInProfile(); + this.totalHitCount = 0; + if (!WebInspector.moduleSetting("showNativeFunctionsInJSProfile").get()) + this._filterNativeFrames(profile.head); + this.profileHead = this._translateProfileTree(profile.head); + WebInspector.ProfileTreeModel.call(this, this.profileHead, this.profileStartTime, this.profileEndTime); + this._extractMetaNodes(); if (this.samples) { + this._buildIdToNodeMap(); this._sortSamples(); this._normalizeTimestamps(); - this._buildIdToNodeMap(); this._fixMissingSamples(); } - if (!WebInspector.moduleSetting("showNativeFunctionsInJSProfile").get()) - this._filterNativeFrames(); - this._assignDepthsInProfile(); - this._calculateTimes(profile); + this._assignTotalTimes(this.profileHead); } WebInspector.CPUProfileDataModel.prototype = { /** - * @param {!ProfilerAgent.CPUProfile} profile + * @param {!ProfilerAgent.CPUProfileNode} root */ - _calculateTimes: function(profile) + _filterNativeFrames: function(root) { - function totalHitCount(node) { - var result = node.hitCount; - for (var i = 0; i < node.children.length; i++) - result += totalHitCount(node.children[i]); - return result; - } - profile.totalHitCount = totalHitCount(profile.head); - this.totalHitCount = profile.totalHitCount; - - var duration = this.profileEndTime - this.profileStartTime; - var samplingInterval = duration / profile.totalHitCount; - this.samplingInterval = samplingInterval; - - function calculateTimesForNode(node) { - node.selfTime = node.hitCount * samplingInterval; - var totalHitCount = node.hitCount; - for (var i = 0; i < node.children.length; i++) - totalHitCount += calculateTimesForNode(node.children[i]); - node.totalTime = totalHitCount * samplingInterval; - return totalHitCount; - } - calculateTimesForNode(profile.head); - }, - - _filterNativeFrames: function() - { + // TODO: get rid of this function and do the filtering while _translateProfileTree if (this.samples) { + /** @type {!Map<number, !ProfilerAgent.CPUProfileNode>} */ + var idToNode = new Map(); + var stack = [root]; + while (stack.length) { + var node = stack.pop(); + idToNode.set(node.id, node); + for (var i = 0; i < node.children.length; i++) { + node.children[i].parent = node; + stack.push(node.children[i]); + } + } for (var i = 0; i < this.samples.length; ++i) { - var node = this.nodeByIndex(i); + var node = idToNode.get(this.samples[i]); while (isNativeNode(node)) node = node.parent; this.samples[i] = node.id; } } - processSubtree(this.profileHead); + processSubtree(root); /** * @param {!ProfilerAgent.CPUProfileNode} node @@ -118,44 +128,43 @@ } }, - _assignParentsInProfile: function() + /** + * @param {!ProfilerAgent.CPUProfileNode} root + * @return {!WebInspector.CPUProfileNode} + */ + _translateProfileTree: function(root) { - var head = this.profileHead; - head.parent = null; - var nodesToTraverse = [ head ]; - while (nodesToTraverse.length) { - var parent = nodesToTraverse.pop(); - var children = parent.children; - var length = children.length; - for (var i = 0; i < length; ++i) { - var child = children[i]; - child.parent = parent; - if (child.children.length) - nodesToTraverse.push(child); - } + /** + * @param {!ProfilerAgent.CPUProfileNode} node + * @return {number} + */ + function computeHitCountForSubtree(node) + { + return node.children.reduce((acc, node) => acc + computeHitCountForSubtree(node), node.hitCount); } + this.totalHitCount = computeHitCountForSubtree(root); + var sampleTime = (this.profileEndTime - this.profileStartTime) / this.totalHitCount; + var resultRoot = new WebInspector.CPUProfileNode(root, sampleTime); + var targetNodeStack = [resultRoot]; + var sourceNodeStack = [root]; + while (sourceNodeStack.length) { + var sourceNode = sourceNodeStack.pop(); + var parentNode = targetNodeStack.pop(); + parentNode.children = sourceNode.children.map(child => new WebInspector.CPUProfileNode(child, sampleTime)); + sourceNodeStack.push.apply(sourceNodeStack, sourceNode.children); + targetNodeStack.push.apply(targetNodeStack, parentNode.children); + } + return resultRoot; }, - _assignDepthsInProfile: function() + /** + * @param {!WebInspector.ProfileNode} node + */ + _assignTotalTimes: function(node) { - var head = this.profileHead; - head.depth = -1; - this.maxDepth = 0; - var nodesToTraverse = [ head ]; - while (nodesToTraverse.length) { - var parent = nodesToTraverse.pop(); - var depth = parent.depth + 1; - if (depth > this.maxDepth) - this.maxDepth = depth; - var children = parent.children; - var length = children.length; - for (var i = 0; i < length; ++i) { - var child = children[i]; - child.depth = depth; - if (child.children.length) - nodesToTraverse.push(child); - } - } + // TODO: get rid of this field in favor of this.total + node.totalTime = node.total; + node.children.forEach(this._assignTotalTimes, this); }, _sortSamples: function() @@ -213,7 +222,7 @@ _buildIdToNodeMap: function() { - /** @type {!Object.<number, !ProfilerAgent.CPUProfileNode>} */ + /** @type {!Object<number, !WebInspector.CPUProfileNode>} */ this._idToNode = {}; var idToNode = this._idToNode; var stack = [this.profileHead]; @@ -223,7 +232,10 @@ for (var i = 0; i < node.children.length; i++) stack.push(node.children[i]); } + }, + _extractMetaNodes: function() + { var topLevelNodes = this.profileHead.children; for (var i = 0; i < topLevelNodes.length && !(this.gcNode && this.programNode && this.idleNode); i++) { var node = topLevelNodes[i]; @@ -265,8 +277,8 @@ } /** - * @param {!ProfilerAgent.CPUProfileNode} node - * @return {!ProfilerAgent.CPUProfileNode} + * @param {!WebInspector.ProfileNode} node + * @return {!WebInspector.ProfileNode} */ function bottomNode(node) { @@ -286,8 +298,8 @@ }, /** - * @param {function(number, !ProfilerAgent.CPUProfileNode, number)} openFrameCallback - * @param {function(number, !ProfilerAgent.CPUProfileNode, number, number, number)} closeFrameCallback + * @param {function(number, !WebInspector.CPUProfileNode, number)} openFrameCallback + * @param {function(number, !WebInspector.CPUProfileNode, number, number, number)} closeFrameCallback * @param {number=} startTime * @param {number=} stopTime */ @@ -358,7 +370,7 @@ var start = stackStartTimes[stackTop]; var duration = sampleTime - start; stackChildrenDuration[stackTop - 1] += duration; - closeFrameCallback(prevNode.depth, prevNode, start, duration, duration - stackChildrenDuration[stackTop]); + closeFrameCallback(prevNode.depth, /** @type {!WebInspector.CPUProfileNode} */(prevNode), start, duration, duration - stackChildrenDuration[stackTop]); --stackTop; if (node.depth === prevNode.depth) { stackNodes.push(node); @@ -390,18 +402,19 @@ var start = stackStartTimes[stackTop]; var duration = sampleTime - start; stackChildrenDuration[stackTop - 1] += duration; - closeFrameCallback(node.depth, node, start, duration, duration - stackChildrenDuration[stackTop]); + closeFrameCallback(node.depth, /** @type {!WebInspector.CPUProfileNode} */(node), start, duration, duration - stackChildrenDuration[stackTop]); --stackTop; } }, /** * @param {number} index - * @return {!ProfilerAgent.CPUProfileNode} + * @return {!WebInspector.CPUProfileNode} */ nodeByIndex: function(index) { return this._idToNode[this.samples[index]]; - } + }, + __proto__: WebInspector.ProfileTreeModel.prototype }
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/CSSMetadata.js b/third_party/WebKit/Source/devtools/front_end/sdk/CSSMetadata.js index 5070d7a2..1fd86ce 100644 --- a/third_party/WebKit/Source/devtools/front_end/sdk/CSSMetadata.js +++ b/third_party/WebKit/Source/devtools/front_end/sdk/CSSMetadata.js
@@ -601,6 +601,12 @@ "-webkit-line-break": { values: [ "auto", "loose", "normal", "strict" ] }, + "-webkit-user-select": { values: [ + "none", "text", "all" + ] }, + "-webkit-user-modify": { values: [ + "read-only", "read-write", "read-write-plaintext-only" + ] }, "text-align-last": { values: [ "auto", "start", "end", "left", "right", "center", "justify" ] },
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/ProfileTreeModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/ProfileTreeModel.js new file mode 100644 index 0000000..49b4fac --- /dev/null +++ b/third_party/WebKit/Source/devtools/front_end/sdk/ProfileTreeModel.js
@@ -0,0 +1,123 @@ +// Copyright 2016 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. + +/** + * @constructor + */ +WebInspector.ProfileNode = function(functionName, scriptId, url, lineNumber, columnNumber) +{ + /** @type {!RuntimeAgent.CallFrame} */ + this.frame = { + functionName: functionName, + scriptId: scriptId, + url: url, + lineNumber: lineNumber, + columnNumber: columnNumber + }; + /** @type {number} */ + this.callUID; + /** @type {number} */ + this.self = 0; + /** @type {number} */ + this.total = 0; + /** @type {number} */ + this.id = 0; + /** @type {?WebInspector.ProfileNode} */ + this.parent = null; + /** @type {!Array<!WebInspector.ProfileNode>} */ + this.children = []; +} + +WebInspector.ProfileNode.prototype = { + /** + * @return {string} + */ + get functionName() + { + return this.frame.functionName; + }, + + /** + * @return {string} + */ + get scriptId() + { + return this.frame.scriptId; + }, + + /** + * @return {string} + */ + get url() + { + return this.frame.url; + }, + + /** + * @return {number} + */ + get lineNumber() + { + return this.frame.lineNumber; + }, + + /** + * @return {number} + */ + get columnNumber() + { + return this.frame.columnNumber; + } +} + +/** + * @constructor + * @param {!WebInspector.ProfileNode} root + * @param {number} begin + * @param {number} end + */ +WebInspector.ProfileTreeModel = function(root, begin, end) +{ + this.root = root; + this.begin = begin; + this.end = end; + this._assignDepthsAndParents(); + this._calculateTotals(this.root); +} + +WebInspector.ProfileTreeModel.prototype = { + _assignDepthsAndParents: function() + { + var root = this.root; + root.depth = -1; + root.parent = null; + this.maxDepth = 0; + var nodesToTraverse = [root]; + while (nodesToTraverse.length) { + var parent = nodesToTraverse.pop(); + var depth = parent.depth + 1; + if (depth > this.maxDepth) + this.maxDepth = depth; + var children = parent.children; + var length = children.length; + for (var i = 0; i < length; ++i) { + var child = children[i]; + child.depth = depth; + child.parent = parent; + if (child.children.length) + nodesToTraverse.push(child); + } + } + }, + + /** + * @param {!WebInspector.ProfileNode} node + * @return {number} + */ + _calculateTotals: function(node) + { + node.total = node.children.reduce((acc, child) => acc + this._calculateTotals(child), node.self); + return node.total; + } +}
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js index bd8c6cb..45f1aebd 100644 --- a/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js +++ b/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js
@@ -495,8 +495,8 @@ object = this; var resultSet = {}; - for (var o = object; o; o = o.__proto__) { - try { + try { + for (var o = object; o; o = o.__proto__) { if (type === "array" && o === object && ArrayBuffer.isView(o) && o.length > 9999) continue; var names = Object.getOwnPropertyNames(o); @@ -507,8 +507,8 @@ continue; resultSet[names[i]] = true; } - } catch (e) { } + } catch (e) { } return resultSet; }
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/module.json b/third_party/WebKit/Source/devtools/front_end/sdk/module.json index dd2f07e..cb90918b 100644 --- a/third_party/WebKit/Source/devtools/front_end/sdk/module.json +++ b/third_party/WebKit/Source/devtools/front_end/sdk/module.json
@@ -68,6 +68,7 @@ "ConsoleModel.js", "ContentProviders.js", "CookieParser.js", + "ProfileTreeModel.js", "CPUProfileDataModel.js", "CPUProfilerModel.js", "CSSMatchedStyles.js",
diff --git a/third_party/WebKit/Source/modules/cachestorage/Cache.cpp b/third_party/WebKit/Source/modules/cachestorage/Cache.cpp index 30973127..e1f85c3 100644 --- a/third_party/WebKit/Source/modules/cachestorage/Cache.cpp +++ b/third_party/WebKit/Source/modules/cachestorage/Cache.cpp
@@ -231,7 +231,7 @@ ScriptValue call(ScriptValue value) override { NonThrowableExceptionState exceptionState; - HeapVector<Member<Response>> responses = toMemberNativeArray<Response, V8Response>(value.v8Value(), m_requests.size(), getScriptState()->isolate(), exceptionState); + HeapVector<Member<Response>> responses = toMemberNativeArray<Response>(value.v8Value(), m_requests.size(), getScriptState()->isolate(), exceptionState); for (const auto& response : responses) { if (!response->ok()) {
diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp index 66ff5e9..dbbdd31c 100644 --- a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp +++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
@@ -201,7 +201,7 @@ ExecutionContext* PaymentRequest::getExecutionContext() const { - return m_scriptState->getExecutionContext(); + return ContextLifecycleObserver::getExecutionContext(); } ScriptPromise PaymentRequest::complete(ScriptState* scriptState, bool success) @@ -223,10 +223,11 @@ visitor->trace(m_showResolver); visitor->trace(m_completeResolver); EventTargetWithInlineData::trace(visitor); + ContextLifecycleObserver::trace(visitor); } PaymentRequest::PaymentRequest(ScriptState* scriptState, const Vector<String>& supportedMethods, const PaymentDetails& details, const PaymentOptions& options, const ScriptValue& data, ExceptionState& exceptionState) - : m_scriptState(scriptState) + : ContextLifecycleObserver(scriptState->getExecutionContext()) , m_supportedMethods(supportedMethods) , m_details(details) , m_options(options) @@ -297,6 +298,11 @@ m_shippingOption = details.shippingOptions().begin()->id(); } +void PaymentRequest::contextDestroyed() +{ + cleanUp(); +} + void PaymentRequest::OnShippingAddressChange(mojom::wtf::ShippingAddressPtr address) { DCHECK(m_showResolver); @@ -360,7 +366,8 @@ { m_completeResolver.clear(); m_showResolver.clear(); - m_clientBinding.Close(); + if (m_clientBinding.is_bound()) + m_clientBinding.Close(); m_paymentProvider.reset(); }
diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequest.h b/third_party/WebKit/Source/modules/payments/PaymentRequest.h index 7b7e9b1..fcf72aa 100644 --- a/third_party/WebKit/Source/modules/payments/PaymentRequest.h +++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.h
@@ -8,6 +8,7 @@ #include "bindings/core/v8/ScriptPromise.h" #include "bindings/core/v8/ScriptValue.h" #include "bindings/core/v8/ScriptWrappable.h" +#include "core/dom/ContextLifecycleObserver.h" #include "core/events/EventTarget.h" #include "modules/ModulesExport.h" #include "modules/payments/PaymentCompleter.h" @@ -29,7 +30,7 @@ class ScriptState; class ShippingAddress; -class MODULES_EXPORT PaymentRequest final : public EventTargetWithInlineData, WTF_NON_EXPORTED_BASE(public mojom::wtf::PaymentRequestClient), public PaymentCompleter { +class MODULES_EXPORT PaymentRequest final : public EventTargetWithInlineData, WTF_NON_EXPORTED_BASE(public mojom::wtf::PaymentRequestClient), public PaymentCompleter, public ContextLifecycleObserver { DEFINE_WRAPPERTYPEINFO(); USING_GARBAGE_COLLECTED_MIXIN(PaymentRequest) WTF_MAKE_NONCOPYABLE(PaymentRequest); @@ -62,6 +63,9 @@ private: PaymentRequest(ScriptState*, const Vector<String>& supportedMethods, const PaymentDetails&, const PaymentOptions&, const ScriptValue& data, ExceptionState&); + // LifecycleObserver: + void contextDestroyed() override; + // mojom::wtf::PaymentRequestClient: void OnShippingAddressChange(mojom::wtf::ShippingAddressPtr) override; void OnShippingOptionChange(const String& shippingOptionId) override; @@ -72,7 +76,6 @@ // Clears the promise resolvers and closes the Mojo connection. void cleanUp(); - RefPtr<ScriptState> m_scriptState; Vector<String> m_supportedMethods; PaymentDetails m_details; PaymentOptions m_options;
diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp index 8bd2343..7923895 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
@@ -430,52 +430,34 @@ } } -bool WebGL2RenderingContextBase::checkAndTranslateAttachments(const char* functionName, GLenum target, const Vector<GLenum>& attachments, Vector<GLenum>& translatedAttachments) +bool WebGL2RenderingContextBase::checkAndTranslateAttachments(const char* functionName, GLenum target, Vector<GLenum>& attachments) { - GLsizei size = attachments.size(); - translatedAttachments.resize(size); + if (!validateFramebufferTarget(target)) { + synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); + return false; + } WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); ASSERT(framebufferBinding || drawingBuffer()); if (!framebufferBinding) { // For the default framebuffer // Translate GL_COLOR/GL_DEPTH/GL_STENCIL, because the default framebuffer of WebGL is not fb 0, it is an internal fbo - for (GLsizei i = 0; i < size; ++i) { + for (size_t i = 0; i < attachments.size(); ++i) { switch (attachments[i]) { case GL_COLOR: - translatedAttachments[i] = GL_COLOR_ATTACHMENT0; + attachments[i] = GL_COLOR_ATTACHMENT0; break; case GL_DEPTH: - translatedAttachments[i] = GL_DEPTH_ATTACHMENT; + attachments[i] = GL_DEPTH_ATTACHMENT; break; case GL_STENCIL: - translatedAttachments[i] = GL_STENCIL_ATTACHMENT; + attachments[i] = GL_STENCIL_ATTACHMENT; break; default: synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid attachment"); return false; } } - } else { - // For the FBO - for (GLsizei i = 0; i < size; ++i) { - switch (attachments[i]) { - case GL_COLOR_ATTACHMENT0: - case GL_DEPTH_ATTACHMENT: - case GL_STENCIL_ATTACHMENT: - case GL_DEPTH_STENCIL_ATTACHMENT: - translatedAttachments[i] = attachments[i]; - break; - default: - if (attachments[i] > GL_COLOR_ATTACHMENT0 - && attachments[i] < static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + maxColorAttachments())) { - translatedAttachments[i] = attachments[i]; - break; - } - synthesizeGLError(GL_INVALID_OPERATION, functionName, "invalid attachment"); - return false; - } - } } return true; } @@ -485,15 +467,9 @@ if (isContextLost()) return; - if (!validateFramebufferTarget(target)) { - synthesizeGLError(GL_INVALID_ENUM, "invalidateFramebuffer", "invalid target"); + Vector<GLenum> translatedAttachments = attachments; + if (!checkAndTranslateAttachments("invalidateFramebuffer", target, translatedAttachments)) return; - } - - Vector<GLenum> translatedAttachments; - if (!checkAndTranslateAttachments("invalidateFramebuffer", target, attachments, translatedAttachments)) - return; - contextGL()->InvalidateFramebuffer(target, translatedAttachments.size(), translatedAttachments.data()); } @@ -502,20 +478,9 @@ if (isContextLost()) return; - if (!validateFramebufferTarget(target)) { - synthesizeGLError(GL_INVALID_ENUM, "invalidateFramebuffer", "invalid target"); + Vector<GLenum> translatedAttachments = attachments; + if (!checkAndTranslateAttachments("invalidateSubFramebuffer", target, translatedAttachments)) return; - } - - if (width < 0 || height < 0) { - synthesizeGLError(GL_INVALID_VALUE, "invalidateSubFramebuffer", "invalid width or height"); - return; - } - - Vector<GLenum> translatedAttachments; - if (!checkAndTranslateAttachments("invalidateSubFramebuffer", target, attachments, translatedAttachments)) - return; - contextGL()->InvalidateSubFramebuffer(target, translatedAttachments.size(), translatedAttachments.data(), x, y, width, height); }
diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h index 2d5b681..e688ca6 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h +++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h
@@ -248,7 +248,7 @@ WebGLImageConversion::PixelStoreParams getPackPixelStoreParams() override; WebGLImageConversion::PixelStoreParams getUnpackPixelStoreParams(TexImageDimension) override; - bool checkAndTranslateAttachments(const char* functionName, GLenum, const Vector<GLenum>&, Vector<GLenum>&); + bool checkAndTranslateAttachments(const char* functionName, GLenum, Vector<GLenum>&); /* WebGLRenderingContextBase overrides */ unsigned getMaxWebGLLocationLength() const override { return 1024; };
diff --git a/third_party/WebKit/Source/platform/blink_platform.gypi b/third_party/WebKit/Source/platform/blink_platform.gypi index db7e83b..7d3a46f 100644 --- a/third_party/WebKit/Source/platform/blink_platform.gypi +++ b/third_party/WebKit/Source/platform/blink_platform.gypi
@@ -455,6 +455,9 @@ 'fonts/mac/FontFamilyMatcherMac.mm', 'fonts/mac/FontCacheMac.mm', 'fonts/mac/FontPlatformDataMac.mm', + 'fonts/opentype/OpenTypeCapsSupport.h', + 'fonts/opentype/OpenTypeCapsSupport.cpp', + 'fonts/opentype/OpenTypeCapsSupportMPL.cpp', 'fonts/opentype/OpenTypeSanitizer.cpp', 'fonts/opentype/OpenTypeSanitizer.h', 'fonts/opentype/OpenTypeTypes.h', @@ -1156,6 +1159,7 @@ 'fonts/android/FontCacheAndroidTest.cpp', 'fonts/mac/FontFamilyMatcherMacTest.mm', 'fonts/opentype/OpenTypeVerticalDataTest.cpp', + 'fonts/opentype/OpenTypeCapsSupportTest.cpp', 'fonts/shaping/CachingWordShaperTest.cpp', 'fonts/shaping/HarfBuzzShaperTest.cpp', 'fonts/shaping/RunSegmenterTest.cpp',
diff --git a/third_party/WebKit/Source/platform/blink_platform_unittests.isolate b/third_party/WebKit/Source/platform/blink_platform_unittests.isolate index 2e344787..873a72550 100644 --- a/third_party/WebKit/Source/platform/blink_platform_unittests.isolate +++ b/third_party/WebKit/Source/platform/blink_platform_unittests.isolate
@@ -6,6 +6,8 @@ 'files': [ # Required by some font tests. 'testing/data/', + '../../LayoutTests/third_party/Libertine/', + '../../LayoutTests/third_party/MEgalopolis/', # Required by some image decoder tests. 'image-decoders/testing/', '../../LayoutTests/fast/images/resources/',
diff --git a/third_party/WebKit/Source/platform/fonts/FontDescription.h b/third_party/WebKit/Source/platform/fonts/FontDescription.h index 88faa3a..0232c312 100644 --- a/third_party/WebKit/Source/platform/fonts/FontDescription.h +++ b/third_party/WebKit/Source/platform/fonts/FontDescription.h
@@ -57,6 +57,8 @@ enum LigaturesState { NormalLigaturesState, DisabledLigaturesState, EnabledLigaturesState }; + enum FontVariantCaps { CapsNormal, SmallCaps, AllSmallCaps, PetiteCaps, AllPetiteCaps, Unicase, TitlingCaps }; + FontDescription() : m_specifiedSize(0) , m_computedSize(0)
diff --git a/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupport.cpp b/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupport.cpp new file mode 100644 index 0000000..bba64a5 --- /dev/null +++ b/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupport.cpp
@@ -0,0 +1,173 @@ +// Copyright 2015 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 "platform/fonts/opentype/OpenTypeCapsSupport.h" + +namespace blink { + +OpenTypeCapsSupport::OpenTypeCapsSupport() + : m_harfBuzzFace(nullptr) + , m_requestedCaps(FontDescription::CapsNormal) + , m_fontSupport(FontSupport::Full) + , m_capsSynthesis(CapsSynthesis::None) +{ +} + +OpenTypeCapsSupport::OpenTypeCapsSupport(const HarfBuzzFace* harfBuzzFace, + FontDescription::FontVariantCaps requestedCaps, + hb_script_t script) + : m_harfBuzzFace(harfBuzzFace) + , m_requestedCaps(requestedCaps) + , m_fontSupport(FontSupport::Full) + , m_capsSynthesis(CapsSynthesis::None) +{ + if (requestedCaps != FontDescription::CapsNormal) + determineFontSupport(script); +} + +FontDescription::FontVariantCaps OpenTypeCapsSupport::fontFeatureToUse( + SmallCapsIterator::SmallCapsBehavior sourceTextCase) +{ + if (m_fontSupport == FontSupport::Full) + return m_requestedCaps; + + if (m_fontSupport == FontSupport::Fallback) { + if (m_requestedCaps == FontDescription::FontVariantCaps::AllPetiteCaps) + return FontDescription::FontVariantCaps::AllSmallCaps; + + if (m_requestedCaps == FontDescription::FontVariantCaps::PetiteCaps + || (m_requestedCaps == FontDescription::FontVariantCaps::Unicase + && sourceTextCase == SmallCapsIterator::SmallCapsSameCase)) + return FontDescription::FontVariantCaps::SmallCaps; + } + + return FontDescription::FontVariantCaps::CapsNormal; +} + +bool OpenTypeCapsSupport::needsRunCaseSplitting() +{ + // Lack of titling case support is ignored, titling case is not synthesized. + return m_fontSupport != FontSupport::Full + && m_requestedCaps != FontDescription::TitlingCaps; +} + +bool OpenTypeCapsSupport::needsSyntheticFont( + SmallCapsIterator::SmallCapsBehavior runCase) +{ + if (m_fontSupport == FontSupport::Full) + return false; + + if (m_requestedCaps == FontDescription::TitlingCaps) + return false; + + if (m_fontSupport == FontSupport::None) { + if (runCase == SmallCapsIterator::SmallCapsUppercaseNeeded + && (m_capsSynthesis == CapsSynthesis::LowerToSmallCaps + || m_capsSynthesis == CapsSynthesis::BothToSmallCaps)) + return true; + + if (runCase == SmallCapsIterator::SmallCapsSameCase + && (m_capsSynthesis == CapsSynthesis::UpperToSmallCaps + || m_capsSynthesis == CapsSynthesis::BothToSmallCaps)) { + return true; + } + } + + return false; +} + +CaseMapIntend OpenTypeCapsSupport::needsCaseChange( + SmallCapsIterator::SmallCapsBehavior runCase) +{ + CaseMapIntend caseMapIntend = CaseMapIntend::KeepSameCase; + + if (m_fontSupport == FontSupport::Full) + return caseMapIntend; + + switch (runCase) { + case SmallCapsIterator::SmallCapsSameCase: + caseMapIntend = m_fontSupport == FontSupport::Fallback + && (m_capsSynthesis == CapsSynthesis::BothToSmallCaps + || m_capsSynthesis == CapsSynthesis::UpperToSmallCaps) + ? CaseMapIntend::LowerCase + : CaseMapIntend::KeepSameCase; + break; + case SmallCapsIterator::SmallCapsUppercaseNeeded: + caseMapIntend = m_fontSupport != FontSupport::Fallback + && (m_capsSynthesis == CapsSynthesis::LowerToSmallCaps + || m_capsSynthesis == CapsSynthesis::BothToSmallCaps) + ? CaseMapIntend::UpperCase + : CaseMapIntend::KeepSameCase; + break; + default: + break; + } + return caseMapIntend; +} + +void OpenTypeCapsSupport::determineFontSupport(hb_script_t script) +{ + switch (m_requestedCaps) { + case FontDescription::SmallCaps: + if (!supportsOpenTypeFeature(script, HB_TAG('s', 'm', 'c', 'p'))) { + m_fontSupport = FontSupport::None; + m_capsSynthesis = CapsSynthesis::LowerToSmallCaps; + } + break; + case FontDescription::AllSmallCaps: + if (!(supportsOpenTypeFeature(script, HB_TAG('s', 'm', 'c', 'p')) + && supportsOpenTypeFeature( + script, + HB_TAG('c', '2', 's', 'c')))) { + m_fontSupport = FontSupport::None; + m_capsSynthesis = CapsSynthesis::BothToSmallCaps; + } + break; + case FontDescription::PetiteCaps: + if (!supportsOpenTypeFeature(script, HB_TAG('p', 'c', 'a', 'p'))) { + if (supportsOpenTypeFeature(script, HB_TAG('s', 'm', 'c', 'p'))) { + m_fontSupport = FontSupport::Fallback; + } else { + m_fontSupport = FontSupport::None; + m_capsSynthesis = CapsSynthesis::LowerToSmallCaps; + } + } + break; + case FontDescription::AllPetiteCaps: + if (!(supportsOpenTypeFeature(script, HB_TAG('p', 'c', 'a', 'p')) + && supportsOpenTypeFeature( + script, + HB_TAG('c', '2', 'p', 'c')))) { + if (supportsOpenTypeFeature(script, HB_TAG('s', 'm', 'c', 'p')) + && supportsOpenTypeFeature( + script, + HB_TAG('c', '2', 's', 'c'))) { + m_fontSupport = FontSupport::Fallback; + } else { + m_fontSupport = FontSupport::None; + m_capsSynthesis = CapsSynthesis::BothToSmallCaps; + } + } + break; + case FontDescription::Unicase: + if (!supportsOpenTypeFeature(script, HB_TAG('u', 'n', 'i', 'c'))) { + m_capsSynthesis = CapsSynthesis::UpperToSmallCaps; + if (supportsOpenTypeFeature(script, HB_TAG('s', 'm', 'c', 'p'))) { + m_fontSupport = FontSupport::Fallback; + } else { + m_fontSupport = FontSupport::None; + } + } + break; + case FontDescription::TitlingCaps: + if (!supportsOpenTypeFeature(script, HB_TAG('t', 'i', 't', 'l'))) { + m_fontSupport = FontSupport::None; + } + break; + default: + ASSERT_NOT_REACHED(); + } +} + +} // namespace blink
diff --git a/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupport.h b/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupport.h new file mode 100644 index 0000000..7015c2a --- /dev/null +++ b/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupport.h
@@ -0,0 +1,57 @@ +// Copyright 2016 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 OpenTypeCapsSupport_h +#define OpenTypeCapsSupport_h + +#include "platform/fonts/FontDescription.h" +#include "platform/fonts/SmallCapsIterator.h" +#include "platform/fonts/opentype/OpenTypeCapsSupport.h" +#include "platform/fonts/shaping/CaseMappingHarfBuzzBufferFiller.h" +#include "platform/fonts/shaping/HarfBuzzFace.h" + +#include <hb.h> + +namespace blink { + +class PLATFORM_EXPORT OpenTypeCapsSupport { +public: + OpenTypeCapsSupport(); + OpenTypeCapsSupport(const HarfBuzzFace*, + FontDescription::FontVariantCaps requestedCaps, + hb_script_t); + + bool needsRunCaseSplitting(); + bool needsSyntheticFont(SmallCapsIterator::SmallCapsBehavior runCase); + FontDescription::FontVariantCaps fontFeatureToUse(SmallCapsIterator::SmallCapsBehavior runCase); + CaseMapIntend needsCaseChange(SmallCapsIterator::SmallCapsBehavior runCase); + +private: + void determineFontSupport(hb_script_t); + bool supportsOpenTypeFeature(hb_script_t, uint32_t tag) const; + + const HarfBuzzFace* m_harfBuzzFace; + FontDescription::FontVariantCaps m_requestedCaps; + SmallCapsIterator::SmallCapsBehavior m_runCase; + + enum class FontSupport { + Full, + Fallback, // Fall back to 'smcp' or 'smcp' + 'c2sc' + None + }; + + enum class CapsSynthesis { + None, + LowerToSmallCaps, + UpperToSmallCaps, + BothToSmallCaps + }; + + FontSupport m_fontSupport; + CapsSynthesis m_capsSynthesis; +}; + +}; // namespace blink + +#endif
diff --git a/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportMPL.cpp b/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportMPL.cpp new file mode 100644 index 0000000..ad979fc0 --- /dev/null +++ b/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportMPL.cpp
@@ -0,0 +1,81 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * ***** END LICENSE BLOCK ***** */ + +#include "platform/fonts/opentype/OpenTypeCapsSupport.h" + +#include <hb-ot.h> + +namespace blink { + +bool OpenTypeCapsSupport::supportsOpenTypeFeature( + hb_script_t script, + uint32_t tag) const +{ + + hb_face_t* face = m_harfBuzzFace->face(); + ASSERT(face); + + ASSERT((tag == HB_TAG('s', 'm', 'c', 'p') + || tag == HB_TAG('c', '2', 's', 'c') + || tag == HB_TAG('p', 'c', 'a', 'p') + || tag == HB_TAG('c', '2', 'p', 'c') + || tag == HB_TAG('s', 'u', 'p', 's') + || tag == HB_TAG('s', 'u', 'b', 's') + || tag == HB_TAG('t', 'i', 't', 'l') + || tag == HB_TAG('u', 'n', 'i', 'c') + || tag == HB_TAG('v', 'e', 'r', 't'))); + + bool result = false; + + if (!hb_ot_layout_has_substitution(face)) + return false; + + // Get the OpenType tag(s) that match this script code + const size_t kMaxScriptTags = 4; + hb_tag_t scriptTags[kMaxScriptTags] = { + HB_TAG_NONE, + HB_TAG_NONE, + HB_TAG_NONE, + HB_TAG_NONE + }; + hb_ot_tags_from_script(static_cast<hb_script_t>(script), + &scriptTags[0], + &scriptTags[1]); + + // Replace the first remaining NONE with DEFAULT + for (size_t i = 0; i < kMaxScriptTags; ++i) { + if (scriptTags[i] == HB_TAG_NONE) { + scriptTags[i] = HB_OT_TAG_DEFAULT_SCRIPT; + break; + } + } + + // Now check for 'smcp' under the first of those scripts that is present + const hb_tag_t kGSUB = HB_TAG('G', 'S', 'U', 'B'); + for (size_t j = 0; j < kMaxScriptTags; ++j) { + if (scriptTags[j] == HB_TAG_NONE) + break; + + unsigned scriptIndex; + if (hb_ot_layout_table_find_script(face, + kGSUB, + scriptTags[j], + &scriptIndex)) { + if (hb_ot_layout_language_find_feature(face, kGSUB, + scriptIndex, + HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX, + tag, nullptr)) { + result = true; + } + break; + } + } + return result; +} + +} // namespace blink
diff --git a/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportTest.cpp b/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportTest.cpp new file mode 100644 index 0000000..5cfa615 --- /dev/null +++ b/third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportTest.cpp
@@ -0,0 +1,113 @@ +// Copyright 2015 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 "platform/fonts/opentype/OpenTypeCapsSupport.h" + +#include "platform/fonts/Font.h" +#include "platform/testing/FontTestHelpers.h" +#include "platform/testing/UnitTestHelpers.h" +#include "testing/gtest/include/gtest/gtest.h" + +using blink::testing::createTestFont; + +namespace blink { + +static inline String layoutTestsFontPath(String relativePath) +{ + return testing::blinkRootDir() + + String("/LayoutTests/third_party/") + + relativePath; +} + +TEST(OpenTypeCapsSupportTest, LibertineSmcpC2scSupported) +{ + Font font = createTestFont("Libertine", layoutTestsFontPath("Libertine/LinLibertine_R.woff"), 16); + const FontPlatformData& platformData = font.primaryFont()->platformData(); + + OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription::SmallCaps, HB_SCRIPT_LATIN); + EXPECT_FALSE(capsSupport.needsRunCaseSplitting()); + EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppercaseNeeded)); + EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsUppercaseNeeded)); + EXPECT_EQ(FontDescription::SmallCaps, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_EQ(FontDescription::SmallCaps, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsUppercaseNeeded)); +} + +TEST(OpenTypeCapsSupportTest, LibertineIgnoreMissingTitling) +{ + Font font = createTestFont("Libertine", layoutTestsFontPath("Libertine/LinLibertine_R.woff"), 16); + const FontPlatformData& platformData = font.primaryFont()->platformData(); + + OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription::TitlingCaps, HB_SCRIPT_LATIN); + EXPECT_FALSE(capsSupport.needsRunCaseSplitting()); + EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppercaseNeeded)); + EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsUppercaseNeeded)); + EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsUppercaseNeeded)); +} + +TEST(OpenTypeCapsSupportTest, LibertineAllPetiteSynthesis) +{ + Font font = createTestFont("Libertine", layoutTestsFontPath("Libertine/LinLibertine_R.woff"), 16); + const FontPlatformData& platformData = font.primaryFont()->platformData(); + + OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription::AllPetiteCaps, HB_SCRIPT_LATIN); + EXPECT_TRUE(capsSupport.needsRunCaseSplitting()); + EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppercaseNeeded)); + EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsUppercaseNeeded)); + EXPECT_EQ(FontDescription::AllSmallCaps, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_EQ(FontDescription::AllSmallCaps, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsUppercaseNeeded)); +} + +TEST(OpenTypeCapsSupportTest, MEgalopolisSmallCapsSynthetic) +{ + Font font = createTestFont("MEgalopolis", layoutTestsFontPath("MEgalopolis/MEgalopolisExtra.woff"), 16); + const FontPlatformData& platformData = font.primaryFont()->platformData(); + + OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription::SmallCaps, HB_SCRIPT_LATIN); + EXPECT_TRUE(capsSupport.needsRunCaseSplitting()); + EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_TRUE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppercaseNeeded)); + EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_EQ(CaseMapIntend::UpperCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsUppercaseNeeded)); + EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsUppercaseNeeded)); +} + +TEST(OpenTypeCapsSupportTest, MEgalopolisUnicaseSynthetic) +{ + Font font = createTestFont("MEgalopolis", layoutTestsFontPath("MEgalopolis/MEgalopolisExtra.woff"), 16); + const FontPlatformData& platformData = font.primaryFont()->platformData(); + + OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription::Unicase, HB_SCRIPT_LATIN); + EXPECT_TRUE(capsSupport.needsRunCaseSplitting()); + EXPECT_TRUE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppercaseNeeded)); + EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsUppercaseNeeded)); + EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsUppercaseNeeded)); +} + +TEST(OpenTypeCapsSupportTest, LibertineUnicaseFallback) +{ + Font font = createTestFont("Libertine", layoutTestsFontPath("Libertine/LinLibertine_R.woff"), 16); + const FontPlatformData& platformData = font.primaryFont()->platformData(); + + OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription::Unicase, HB_SCRIPT_LATIN); + EXPECT_TRUE(capsSupport.needsRunCaseSplitting()); + EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppercaseNeeded)); + EXPECT_EQ(CaseMapIntend::LowerCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCapsIterator::SmallCapsUppercaseNeeded)); + EXPECT_EQ(FontDescription::SmallCaps, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsSameCase)); + EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCapsIterator::SmallCapsUppercaseNeeded)); +} + +} // namespace blink
diff --git a/third_party/WebKit/Source/platform/mediastream/MediaStreamSource.cpp b/third_party/WebKit/Source/platform/mediastream/MediaStreamSource.cpp index 5819964..62d5a02 100644 --- a/third_party/WebKit/Source/platform/mediastream/MediaStreamSource.cpp +++ b/third_party/WebKit/Source/platform/mediastream/MediaStreamSource.cpp
@@ -53,8 +53,13 @@ { if (m_readyState != ReadyStateEnded && m_readyState != readyState) { m_readyState = readyState; - for (auto i = m_observers.begin(); i != m_observers.end(); ++i) - (*i)->sourceChangedState(); + + // Observers may dispatch events which create and add new Observers; + // take a snapshot so as to safely iterate. + HeapVector<Member<Observer>> observers; + copyToVector(m_observers, observers); + for (auto observer : observers) + observer->sourceChangedState(); } }
diff --git a/third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp b/third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp index 616aac0..476d992 100644 --- a/third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp +++ b/third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp
@@ -36,7 +36,7 @@ namespace blink { -bool detectTextEncoding(const char* data, size_t length, +bool detectTextEncodingUniversal(const char* data, size_t length, const char* hintEncodingName, WTF::TextEncoding* detectedEncoding) { *detectedEncoding = WTF::TextEncoding();
diff --git a/third_party/WebKit/Source/platform/text/TextEncodingDetector.h b/third_party/WebKit/Source/platform/text/TextEncodingDetector.h index 12f4890..dd6b774a 100644 --- a/third_party/WebKit/Source/platform/text/TextEncodingDetector.h +++ b/third_party/WebKit/Source/platform/text/TextEncodingDetector.h
@@ -44,9 +44,9 @@ // hintEncodingName, detect the most likely character encoding. // The way hintEncodingName is used is up to an implementation. // Currently, the only caller sets it to the parent frame encoding. -PLATFORM_EXPORT bool detectTextEncoding(const char* data, size_t length, - const char* hintEncodingName, WTF::TextEncoding* detectedEncoding); - +PLATFORM_EXPORT bool detectTextEncodingUniversal(const char* data, + size_t length, const char* hintEncodingName, + WTF::TextEncoding* detectedEncoding); } // namespace blink #endif
diff --git a/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp b/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp index 942c1c7..31482ba 100644 --- a/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp +++ b/third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp
@@ -477,4 +477,30 @@ EXPECT_TRUE(document().view()->shouldScrollOnMainThread()); } +TEST_F(FrameThrottlingTest, UnthrottleByTransformingWithoutLayout) +{ + webView().settings()->setAcceleratedCompositingEnabled(true); + + // Create a hidden frame which is throttled. + SimRequest mainResource("https://example.com/", "text/html"); + SimRequest frameResource("https://example.com/iframe.html", "text/html"); + + loadURL("https://example.com/"); + mainResource.complete("<iframe id=frame sandbox src=iframe.html></iframe>"); + frameResource.complete(""); + + // Move the frame offscreen to throttle it. + auto* frameElement = toHTMLIFrameElement(document().getElementById("frame")); + frameElement->setAttribute(styleAttr, "transform: translateY(480px)"); + EXPECT_FALSE(frameElement->contentDocument()->view()->canThrottleRendering()); + compositeFrame(); + EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering()); + + // Make the frame visible by changing its transform. This doesn't cause a + // layout, but should still unthrottle the frame. + frameElement->setAttribute(styleAttr, "transform: translateY(0px)"); + compositeFrame(); + EXPECT_FALSE(frameElement->contentDocument()->view()->canThrottleRendering()); +} + } // namespace blink
diff --git a/third_party/WebKit/Source/wtf/text/UTF8.cpp b/third_party/WebKit/Source/wtf/text/UTF8.cpp index 0beca10..a258db8 100644 --- a/third_party/WebKit/Source/wtf/text/UTF8.cpp +++ b/third_party/WebKit/Source/wtf/text/UTF8.cpp
@@ -442,5 +442,23 @@ return equalWithUTF8Internal(a, aEnd, b, bEnd); } +bool isUTF8andNotASCII(const char* data, size_t length) +{ + // This cast is necessary because U8_NEXT uses int32_ts. + int32_t srcLen = static_cast<int32_t>(length); + int32_t charIndex = 0; + bool isASCIIOnly = true; + + while (charIndex < srcLen) { + int32_t codePoint; + if (static_cast<uint8_t>(data[charIndex]) >= 0x80) + isASCIIOnly = false; + U8_NEXT(data, charIndex, srcLen, codePoint); + if (!U_IS_UNICODE_CHAR(codePoint)) + return false; + } + return !isASCIIOnly; +} + } // namespace Unicode } // namespace WTF
diff --git a/third_party/WebKit/Source/wtf/text/UTF8.h b/third_party/WebKit/Source/wtf/text/UTF8.h index eda26334..b0ba7dbd 100644 --- a/third_party/WebKit/Source/wtf/text/UTF8.h +++ b/third_party/WebKit/Source/wtf/text/UTF8.h
@@ -70,6 +70,12 @@ WTF_EXPORT bool equalUTF16WithUTF8(const UChar* a, const UChar* aEnd, const char* b, const char* bEnd); WTF_EXPORT bool equalLatin1WithUTF8(const LChar* a, const LChar* aEnd, const char* b, const char* bEnd); + +// Given a sequence of bytes in |data| of length |len|, check if the content is +// encoded in UTF-8. Pure ASCII text is not regarded as UTF-8 in order to +// respect the default encoding since it can be of any encoding. +WTF_EXPORT bool isUTF8andNotASCII(const char* data, size_t length); + } // namespace Unicode } // namespace WTF
diff --git a/third_party/WebKit/Source/wtf/text/UTF8Test.cpp b/third_party/WebKit/Source/wtf/text/UTF8Test.cpp new file mode 100644 index 0000000..65c27ee --- /dev/null +++ b/third_party/WebKit/Source/wtf/text/UTF8Test.cpp
@@ -0,0 +1,63 @@ +// Copyright 2016 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 "wtf/text/UTF8.h" + +#include "testing/gtest/include/gtest/gtest.h" + +namespace WTF { +namespace Unicode { + +TEST(UTF8Test, IsUTF8andNotASCII) +{ + EXPECT_TRUE(isUTF8andNotASCII("\xc2\x81", 2)); + EXPECT_TRUE(isUTF8andNotASCII("\xe1\x80\xbf", 3)); + EXPECT_TRUE(isUTF8andNotASCII("\xf1\x80\xa0\xbf", 4)); + EXPECT_TRUE(isUTF8andNotASCII("a\xc2\x81\xe1\x80\xbf\xf1\x80\xa0\xbf", 10)); + + // Surrogate code points + EXPECT_FALSE(isUTF8andNotASCII("\xed\xa0\x80\xed\xbf\xbf", 6)); + EXPECT_FALSE(isUTF8andNotASCII("\xed\xa0\x8f", 3)); + EXPECT_FALSE(isUTF8andNotASCII("\xed\xbf\xbf", 3)); + + // Overlong sequences + EXPECT_FALSE(isUTF8andNotASCII("\xc0\x80", 2)); // U+0000 + EXPECT_FALSE(isUTF8andNotASCII("\xc1\x80\xc1\x81", 4)); // "AB" + EXPECT_FALSE(isUTF8andNotASCII("\xe0\x80\x80", 3)); // U+0000 + EXPECT_FALSE(isUTF8andNotASCII("\xe0\x82\x80", 3)); // U+0080 + EXPECT_FALSE(isUTF8andNotASCII("\xe0\x9f\xbf", 3)); // U+07ff + EXPECT_FALSE(isUTF8andNotASCII("\xf0\x80\x80\x8D", 4)); // U+000D + EXPECT_FALSE(isUTF8andNotASCII("\xf0\x80\x82\x91", 4)); // U+0091 + EXPECT_FALSE(isUTF8andNotASCII("\xf0\x80\xa0\x80", 4)); // U+0800 + EXPECT_FALSE(isUTF8andNotASCII("\xf0\x8f\xbb\xbf", 4)); // U+FEFF (BOM) + EXPECT_FALSE(isUTF8andNotASCII("\xf8\x80\x80\x80\xbf", 5)); // U+003F + EXPECT_FALSE(isUTF8andNotASCII("\xfc\x80\x80\x80\xa0\xa5", 6)); // U+00A5 + + // Beyond U+10FFFF (the upper limit of Unicode codespace) + EXPECT_FALSE(isUTF8andNotASCII("\xf4\x90\x80\x80", 4)); // U+110000 + EXPECT_FALSE(isUTF8andNotASCII("\xf8\xa0\xbf\x80\xbf", 5)); // 5 bytes + EXPECT_FALSE(isUTF8andNotASCII("\xfc\x9c\xbf\x80\xbf\x80", 6)); // 6 bytes + + // Non-characters : U+xxFFF[EF] where xx is 0x00 through 0x10 and <FDD0,FDEF> + EXPECT_FALSE(isUTF8andNotASCII("\xef\xbf\xbe", 3)); // U+FFFE + EXPECT_FALSE(isUTF8andNotASCII("\xf0\x8f\xbf\xbe", 4)); // U+1FFFE + EXPECT_FALSE(isUTF8andNotASCII("\xf3\xbf\xbf\xbf", 4)); // U+10FFFF + EXPECT_FALSE(isUTF8andNotASCII("\xef\xb7\x90", 3)); // U+FDD0 + EXPECT_FALSE(isUTF8andNotASCII("\xef\xb7\xaf", 3)); // U+FDEF + + // Strings in legacy encodings. + EXPECT_FALSE(isUTF8andNotASCII("caf\xe9", 4)); // cafe with U+00E9 in ISO-8859-1 + EXPECT_FALSE(isUTF8andNotASCII("\xb0\xa1\xb0\xa2", 4)); // U+AC00, U+AC001 in EUC-KR + EXPECT_FALSE(isUTF8andNotASCII("\xa7\x41\xa6\x6e", 4)); // U+4F60 U+597D in Big5 + // "abc" with U+201[CD] in windows-125[0-8] + EXPECT_FALSE(isUTF8andNotASCII("\x93" "abc\x94", 4)); + // U+0639 U+064E U+0644 U+064E in ISO-8859-6 + EXPECT_FALSE(isUTF8andNotASCII("\xd9\xee\xe4\xee", 4)); + // U+03B3 U+03B5 U+03B9 U+03AC in ISO-8859-7 + EXPECT_FALSE(isUTF8andNotASCII("\xe3\xe5\xe9\xdC", 4)); + EXPECT_FALSE(isUTF8andNotASCII("abc", 3)); // plain ASCII +} + +} // namespace Unicode +} // namespace WTF
diff --git a/third_party/WebKit/Source/wtf/wtf.gypi b/third_party/WebKit/Source/wtf/wtf.gypi index fe778a0..1a65dfe 100644 --- a/third_party/WebKit/Source/wtf/wtf.gypi +++ b/third_party/WebKit/Source/wtf/wtf.gypi
@@ -225,6 +225,7 @@ 'text/StringOperatorsTest.cpp', 'text/TextCodecReplacementTest.cpp', 'text/TextCodecUTF8Test.cpp', + "text/UTF8Test.cpp", 'text/WTFStringTest.cpp', 'typed_arrays/ArrayBufferBuilderTest.cpp', ],
diff --git a/third_party/widevine/cdm/BUILD.gn b/third_party/widevine/cdm/BUILD.gn index af0dd6c..e2093a58 100644 --- a/third_party/widevine/cdm/BUILD.gn +++ b/third_party/widevine/cdm/BUILD.gn
@@ -128,7 +128,6 @@ ":version_h", ":widevinecdm", ":widevinecdmadapter_resources", - "//ppapi/cpp", ] if (is_linux) {
diff --git a/tools/mb/mb.py b/tools/mb/mb.py index cdf1cc3..ae7de3f2 100755 --- a/tools/mb/mb.py +++ b/tools/mb/mb.py
@@ -317,9 +317,13 @@ for config in self.masters[master].values(): all_configs[config] = master - # Check that every referenced config actually exists. + # Check that every referenced args file or config actually exists. for config, loc in all_configs.items(): - if not config in self.configs: + if config.startswith('//'): + if not self.Exists(self.ToAbsPath(config)): + errs.append('Unknown args file "%s" referenced from "%s".' % + (config, loc)) + elif not config in self.configs: errs.append('Unknown config "%s" referenced from "%s".' % (config, loc)) @@ -550,11 +554,19 @@ if not vals: self.ReadConfigFile() config = self.ConfigFromArgs() - if not config in self.configs: - raise MBErr('Config "%s" not found in %s' % - (config, self.args.config_file)) - - vals = self.FlattenConfig(config) + if config.startswith('//'): + if not self.Exists(self.ToAbsPath(config)): + raise MBErr('args file "%s" not found' % config) + vals = { + 'type': 'gn', + 'args_file': config, + 'gn_args': '', + } + else: + if not config in self.configs: + raise MBErr('Config "%s" not found in %s' % + (config, self.args.config_file)) + vals = self.FlattenConfig(config) # Do some basic sanity checking on the config so that we # don't have to do this in every caller. @@ -873,6 +885,9 @@ # the last instance of each arg is listed. gn_args = gn_helpers.ToGNString(gn_helpers.FromGNArgs(gn_args)) + args_file = vals.get('args_file', None) + if args_file: + gn_args = ('import("%s")\n' % vals['args_file']) + gn_args return gn_args def RunGYPGen(self, vals):
diff --git a/tools/mb/mb_config.pyl b/tools/mb/mb_config.pyl index f83ebb3..eb23a45 100644 --- a/tools/mb/mb_config.pyl +++ b/tools/mb/mb_config.pyl
@@ -563,7 +563,7 @@ }, 'official.desktop': { - 'blimp-engine': 'gn_blimp_debug', + 'blimp-engine': '//build/args/bots/official.desktop/blimp-engine.gn', 'mac64': 'gyp_official', 'precise64': 'gn_official', @@ -1016,13 +1016,6 @@ 'error', ], - # This is the "deployment" config for the blimp builds. Currently - # we want them to be debug, non-optimized builds (and we don't need any - # chrome branding), so we don't use the "official" mixin. - 'gn_blimp_debug': [ - 'gn', 'blimp', 'debug', - ], - 'gn_cfi_release_bot': [ 'gn', 'cfi', 'release_bot', ], @@ -1564,19 +1557,6 @@ 'gyp_defines': 'asan=1', }, - # Removes dependencies on X11 and audio libraries for a containerized - # build. - 'blimp': { - # This list must be kept in sync with the list in - # //build/args/blimp_engine.gn. - 'gn_args': ('use_aura=true use_ozone=true ozone_auto_platforms=false ' - 'ozone_platform="headless" ozone_platform_headless=true ' - 'metrics_use_blimp=true ' - 'use_low_quality_image_interpolation=true use_alsa=false ' - 'use_pulseaudio=false use_cups=false use_glib=false'), - 'gyp_defines': 'target_arch=unknown', - }, - 'cast': { 'gn_args': 'is_chromecast=true', 'gyp_defines': 'chromecast=1',
diff --git a/tools/mb/mb_unittest.py b/tools/mb/mb_unittest.py index 6d54bf72..63b81d5 100755 --- a/tools/mb/mb_unittest.py +++ b/tools/mb/mb_unittest.py
@@ -118,6 +118,7 @@ 'fake_gyp_crosscompile_builder': 'gyp_crosscompile', 'fake_gn_debug_builder': 'gn_debug_goma', 'fake_gyp_builder': 'gyp_debug', + 'fake_gn_args_bot': '//build/args/bots/fake_master/fake_gn_args_bot.gn', }, }, 'mixins': { @@ -176,6 +177,9 @@ def fake_mbw(self, files=None, win32=False): mbw = FakeMBW(win32=win32) mbw.files.setdefault(mbw.default_config, TEST_CONFIG) + mbw.files.setdefault( + mbw.ToAbsPath('//build/args/bots/fake_master/fake_gn_args_bot.gn'), + 'is_debug = false\n') if files: for path, contents in files.items(): mbw.files[path] = contents @@ -319,6 +323,14 @@ 'is_debug = true\n' 'use_goma = true\n')) + mbw = self.fake_mbw() + self.check(['gen', '-m', 'fake_master', '-b', 'fake_gn_args_bot', + '//out/Debug'], + mbw=mbw, ret=0) + self.assertEqual( + mbw.files['/fake_src/out/Debug/args.gn'], + 'import("//build/args/bots/fake_master/fake_gn_args_bot.gn")\n') + def test_gn_gen_fails(self): mbw = self.fake_mbw() @@ -448,7 +460,6 @@ def test_validate(self): mbw = self.fake_mbw() - mbw.files[mbw.default_config] = TEST_CONFIG self.check(['validate'], mbw=mbw, ret=0) def test_bad_validate(self):
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc index 85871cc9..862b5fb 100644 --- a/ui/compositor/compositor.cc +++ b/ui/compositor/compositor.cc
@@ -175,6 +175,8 @@ // thread. settings.image_decode_tasks_enabled = false; + settings.use_output_surface_begin_frame_source = true; + #if !defined(OS_ANDROID) // TODO(sohanjg): Revisit this memory usage in tile manager. cc::ManagedMemoryPolicy policy(
diff --git a/ui/compositor/test/in_process_context_factory.cc b/ui/compositor/test/in_process_context_factory.cc index 52faf2b..f6faff08 100644 --- a/ui/compositor/test/in_process_context_factory.cc +++ b/ui/compositor/test/in_process_context_factory.cc
@@ -47,13 +47,22 @@ public: DirectOutputSurface( const scoped_refptr<cc::ContextProvider>& context_provider, - const scoped_refptr<cc::ContextProvider>& worker_context_provider) + const scoped_refptr<cc::ContextProvider>& worker_context_provider, + std::unique_ptr<cc::BeginFrameSource> begin_frame_source) : cc::OutputSurface(context_provider, worker_context_provider), + begin_frame_source_(std::move(begin_frame_source)), weak_ptr_factory_(this) {} ~DirectOutputSurface() override {} // cc::OutputSurface implementation + bool BindToClient(cc::OutputSurfaceClient* client) override { + if (!OutputSurface::BindToClient(client)) + return false; + + client->SetBeginFrameSource(begin_frame_source_.get()); + return true; + } void SwapBuffers(cc::CompositorFrame* frame) override { DCHECK(context_provider_.get()); DCHECK(frame->gl_frame_data); @@ -78,6 +87,8 @@ } private: + std::unique_ptr<cc::BeginFrameSource> begin_frame_source_; + base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(DirectOutputSurface); @@ -141,15 +152,19 @@ "UICompositor"); std::unique_ptr<cc::OutputSurface> real_output_surface; + std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source( + new cc::SyntheticBeginFrameSource(compositor->task_runner().get(), + cc::BeginFrameArgs::DefaultInterval())); if (use_test_surface_) { bool flipped_output_surface = false; real_output_surface = base::WrapUnique(new cc::PixelTestOutputSurface( context_provider, shared_worker_context_provider_, - flipped_output_surface)); + flipped_output_surface, std::move(begin_frame_source))); } else { real_output_surface = base::WrapUnique(new DirectOutputSurface( - context_provider, shared_worker_context_provider_)); + context_provider, shared_worker_context_provider_, + std::move(begin_frame_source))); } if (surface_manager_) { @@ -157,7 +172,8 @@ new cc::OnscreenDisplayClient( std::move(real_output_surface), surface_manager_, GetSharedBitmapManager(), GetGpuMemoryBufferManager(), - compositor->GetRendererSettings(), compositor->task_runner())); + compositor->GetRendererSettings(), compositor->task_runner(), + compositor->surface_id_allocator()->id_namespace())); std::unique_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( new cc::SurfaceDisplayOutputSurface( surface_manager_, compositor->surface_id_allocator(),
diff --git a/ui/file_manager/audio_player/elements/control_panel.js b/ui/file_manager/audio_player/elements/control_panel.js index 98c4374..a07a136 100644 --- a/ui/file_manager/audio_player/elements/control_panel.js +++ b/ui/file_manager/audio_player/elements/control_panel.js
@@ -139,10 +139,6 @@ if (!this.dragging) this.dragging = true; }.bind(this)); - timeSlider.addEventListener('keydown', - this.onProgressKeyDownOrKeyPress_.bind(this)); - timeSlider.addEventListener('keypress', - this.onProgressKeyDownOrKeyPress_.bind(this)); // Update volume on user inputs for volume slider. // During a drag operation, the volume should be updated immediately. @@ -190,6 +186,40 @@ }, /** + * Skips min(5 seconds, 10% of duration). + * @param {boolean} forward Whether to skip forward/backword. + */ + smallSkip: function(forward) { + var millisecondsToSkip = Math.min(5000, this.duration / 10); + if (!forward) { + millisecondsToSkip *= -1; + } + this.skip_(millisecondsToSkip); + }, + + /** + * Skips min(10 seconds, 20% of duration). + * @param {boolean} forward Whether to skip forward/backword. + */ + bigSkip: function(forward) { + var millisecondsToSkip = Math.min(10000, this.duration / 5); + if (!forward) { + millisecondsToSkip *= -1; + } + this.skip_(millisecondsToSkip); + }, + + /** + * Skips forward/backword. + * @param {number} sec Seconds to skip. Set negative value to skip backword. + * @private + */ + skip_: function(millis) { + if (this.duration > 0) + this.time = Math.max(Math.min(this.time + millis, this.duration), 0); + }, + + /** * Converts the time into human friendly string. * @param {number} time Time to be converted. * @return {string} String representation of the given time @@ -274,29 +304,5 @@ this.volume !== 0 ? ariaLabels.mute : ariaLabels.unmute); this.$.volumeSlider.setAttribute('aria-label', ariaLabels.volumeSlider); }, - - /** - * Handles arrow keys on time slider to skip forward/backword. - * @param {!Event} event - * @private - */ - onProgressKeyDownOrKeyPress_: function(event) { - if (event.code !== 'ArrowRight' && event.code !== 'ArrowLeft' && - event.code !== 'ArrowUp' && event.code !== 'ArrowDown') { - return; - } - - event.preventDefault(); - - if (this.duration > 0) { - // Skip 5 seconds or 10% of duration, whichever is smaller. - var millisecondsToSkip = Math.min(5000, this.duration / 10); - if (event.code === 'ArrowRight' || event.code === 'ArrowUp') { - this.time = Math.min(this.time + millisecondsToSkip, this.duration); - } else { - this.time = Math.max(this.time - millisecondsToSkip, 0); - } - } - } }); })(); // Anonymous closure
diff --git a/ui/file_manager/audio_player/js/audio_player.js b/ui/file_manager/audio_player/js/audio_player.js index 8241903..2397eda 100644 --- a/ui/file_manager/audio_player/js/audio_player.js +++ b/ui/file_manager/audio_player/js/audio_player.js
@@ -368,6 +368,27 @@ case 'Ctrl-Shift-U+0042': // Ctrl+Shift+B chrome.fileManagerPrivate.openInspector('background'); break; + + case 'U+0020': // Space + case 'U+004B': // K + this.player_.$.audioController.playClick(); + break; + case 'Up': + case 'Right': + if (event.target.id !== 'volumeSlider') + this.player_.$.audioController.smallSkip(true); + break; + case 'Down': + case 'Left': + if (event.target.id !== 'volumeSlider') + this.player_.$.audioController.smallSkip(false); + break; + case 'U+004C': // L + this.player_.$.audioController.bigSkip(true); + break; + case 'U+004A': // J + this.player_.$.audioController.bigSkip(false); + break; } };
diff --git a/ui/file_manager/file_manager/foreground/elements/files_ripple.js b/ui/file_manager/file_manager/foreground/elements/files_ripple.js index 672a5fbc..5972bb9 100644 --- a/ui/file_manager/file_manager/foreground/elements/files_ripple.js +++ b/ui/file_manager/file_manager/foreground/elements/files_ripple.js
@@ -56,7 +56,7 @@ height: '2%', opacity: 0, offset: 0, - easing: 'liner' + easing: 'linear' }, { width: '50%',
diff --git a/ui/file_manager/file_manager/foreground/js/toolbar_controller.js b/ui/file_manager/file_manager/foreground/js/toolbar_controller.js index f25f7cfd..b3e61f03 100644 --- a/ui/file_manager/file_manager/foreground/js/toolbar_controller.js +++ b/ui/file_manager/file_manager/foreground/js/toolbar_controller.js
@@ -125,18 +125,23 @@ var selection = this.selectionHandler_.selection; // Update the label "x files selected." on the header. + var text; if (selection.totalCount === 0) { - this.filesSelectedLabel_.textContent = ''; + text = ''; + } else if (selection.totalCount === 1) { + if (selection.directoryCount == 0) + text = str('ONE_FILE_SELECTED'); + else if (selection.fileCount == 0) + text = str('ONE_DIRECTORY_SELECTED'); } else { - var text; if (selection.directoryCount == 0) text = strf('MANY_FILES_SELECTED', selection.fileCount); else if (selection.fileCount == 0) text = strf('MANY_DIRECTORIES_SELECTED', selection.directoryCount); else text = strf('MANY_ENTRIES_SELECTED', selection.totalCount); - this.filesSelectedLabel_.textContent = text; } + this.filesSelectedLabel_.textContent = text; // Update visibility of the delete button. this.deleteButton_.hidden =
diff --git a/ui/file_manager/video_player/js/media_controls.js b/ui/file_manager/video_player/js/media_controls.js index aad1db0..0866696 100644 --- a/ui/file_manager/video_player/js/media_controls.js +++ b/ui/file_manager/video_player/js/media_controls.js
@@ -257,15 +257,26 @@ MediaControls.PROGRESS_RANGE = 5000; /** - * 5 seconds should be skipped when left/right key is pressed on progress bar. + * 5 seconds should be skipped when left/right key is pressed. */ -MediaControls.PROGRESS_MAX_SECONDS_TO_SKIP = 5; +MediaControls.PROGRESS_MAX_SECONDS_TO_SMALL_SKIP = 5; + +/** + * 10 seconds should be skipped when J/L key is pressed. + */ +MediaControls.PROGRESS_MAX_SECONDS_TO_BIG_SKIP = 10; /** * 10% of duration should be skipped when the video is too short to skip 5 * seconds. */ -MediaControls.PROGRESS_MAX_RATIO_TO_SKIP = 0.1; +MediaControls.PROGRESS_MAX_RATIO_TO_SMALL_SKIP = 0.1; + +/** + * 20% of duration should be skipped when the video is too short to skip 10 + * seconds. + */ +MediaControls.PROGRESS_MAX_RATIO_TO_BIG_SKIP = 0.2; /** * @param {HTMLElement=} opt_parent Parent container. @@ -294,10 +305,6 @@ function(event) { this.onProgressDrag_(); }.bind(this)); - this.progressSlider_.addEventListener('keydown', - this.onProgressKeyDownOrKeyPress_.bind(this)); - this.progressSlider_.addEventListener('keypress', - this.onProgressKeyDownOrKeyPress_.bind(this)); timeControls.appendChild(this.progressSlider_); }; @@ -351,39 +358,48 @@ }; /** - * Handles arrow keys on progress slider to skip forward/backword. - * @param {!Event} event + * Skips forward/backword. + * @param {number} sec Seconds to skip. Set negative value to skip backword. * @private */ -MediaControls.prototype.onProgressKeyDownOrKeyPress_ = function(event) { - if (event.code !== 'ArrowRight' && event.code !== 'ArrowLeft' && - event.code !== 'ArrowUp' && event.code !== 'ArrowDown') { - return; - } - - event.preventDefault(); - +MediaControls.prototype.skip_ = function(sec) { if (this.media_ && this.media_.duration > 0) { - // Skip 5 seconds or 10% of duration, whichever is smaller. - var secondsToSkip = Math.min( - MediaControls.PROGRESS_MAX_SECONDS_TO_SKIP, - this.media_.duration * MediaControls.PROGRESS_MAX_RATIO_TO_SKIP); var stepsToSkip = MediaControls.PROGRESS_RANGE * - (secondsToSkip / this.media_.duration); - - if (event.code === 'ArrowRight' || event.code === 'ArrowUp') { - this.progressSlider_.value = Math.min( - this.progressSlider_.value + stepsToSkip, - this.progressSlider_.max); - } else { - this.progressSlider_.value = Math.max( - this.progressSlider_.value - stepsToSkip, 0); - } + (sec / this.media_.duration); + this.progressSlider_.value = Math.max(Math.min( + this.progressSlider_.value + stepsToSkip, + this.progressSlider_.max), 0); this.onProgressChange_(this.progressSlider_.ratio); } }; /** + * Invokes small skip. + * @param {boolean} forward Whether to skip forward or backword. + */ +MediaControls.prototype.smallSkip = function(forward) { + var secondsToSkip = Math.min( + MediaControls.PROGRESS_MAX_SECONDS_TO_SMALL_SKIP, + this.media_.duration * MediaControls.PROGRESS_MAX_RATIO_TO_SMALL_SKIP); + if (!forward) + secondsToSkip *= -1; + this.skip_(secondsToSkip); +}; + +/** + * Invokes big skip. + * @param {boolean} forward Whether to skip forward or backword. + */ +MediaControls.prototype.bigSkip = function(forward) { + var secondsToSkip = Math.min( + MediaControls.PROGRESS_MAX_SECONDS_TO_BIG_SKIP, + this.media_.duration * MediaControls.PROGRESS_MAX_RATIO_TO_BIG_SKIP); + if (!forward) + secondsToSkip *= -1; + this.skip_(secondsToSkip); +}; + +/** * Handles 'seeking' state, which starts by dragging slider knob and finishes by * releasing it. While seeking, we pause the video when seeking starts and * resume the last play state when seeking ends.
diff --git a/ui/file_manager/video_player/js/video_player.js b/ui/file_manager/video_player/js/video_player.js index 1d0b23d..fadab6e6 100644 --- a/ui/file_manager/video_player/js/video_player.js +++ b/ui/file_manager/video_player/js/video_player.js
@@ -46,6 +46,7 @@ break; case 'U+0020': // Space + case 'U+004B': // K case 'MediaPlayPause': if (!e.target.classList.contains('menu-button')) this.togglePlayStateWithFeedback(); @@ -55,14 +56,26 @@ chrome.app.window.current(), false); // Leave the full screen mode. break; - case 'Right': case 'MediaNextTrack': player.advance_(1); break; - case 'Left': case 'MediaPreviousTrack': player.advance_(0); break; + case 'Right': + if (!e.target.classList.contains('volume')) + this.smallSkip(true); + break; + case 'Left': + if (!e.target.classList.contains('volume')) + this.smallSkip(false); + break; + case 'U+004C': // L + this.bigSkip(true); + break; + case 'U+004A': // J + this.bigSkip(false); + break; case 'MediaStop': // TODO: Define "Stop" behavior. break;
diff --git a/ui/gl/sync_control_vsync_provider.cc b/ui/gl/sync_control_vsync_provider.cc index 836ec21..c3ecb95 100644 --- a/ui/gl/sync_control_vsync_provider.cc +++ b/ui/gl/sync_control_vsync_provider.cc
@@ -108,7 +108,7 @@ last_computed_intervals_.pop(); int32_t numerator, denominator; - if (GetMscRate(&numerator, &denominator)) { + if (GetMscRate(&numerator, &denominator) && numerator) { last_computed_intervals_.push(base::TimeDelta::FromSeconds(denominator) / numerator); } else if (!last_timebase_.is_null()) {
diff --git a/ui/views/mus/aura_init.cc b/ui/views/mus/aura_init.cc index 6a98706..0b44e720 100644 --- a/ui/views/mus/aura_init.cc +++ b/ui/views/mus/aura_init.cc
@@ -50,7 +50,8 @@ } // namespace -AuraInit::AuraInit(mojo::Connector* connector, const std::string& resource_file) +AuraInit::AuraInit(shell::Connector* connector, + const std::string& resource_file) : resource_file_(resource_file), env_(aura::Env::CreateInstance()), views_delegate_(new MusViewsDelegate) { @@ -71,7 +72,7 @@ #endif } -void AuraInit::InitializeResources(mojo::Connector* connector) { +void AuraInit::InitializeResources(shell::Connector* connector) { if (ui::ResourceBundle::HasSharedInstance()) return; resource_provider::ResourceLoader resource_loader(
diff --git a/ui/views/mus/aura_init.h b/ui/views/mus/aura_init.h index 911c44a..de09d8e 100644 --- a/ui/views/mus/aura_init.h +++ b/ui/views/mus/aura_init.h
@@ -21,7 +21,7 @@ class FontLoader; } -namespace mojo { +namespace shell { class Connector; } @@ -32,11 +32,11 @@ // |resource_file| is the path to the apk file containing the resources. class VIEWS_MUS_EXPORT AuraInit { public: - AuraInit(mojo::Connector* connector, const std::string& resource_file); + AuraInit(shell::Connector* connector, const std::string& resource_file); ~AuraInit(); private: - void InitializeResources(mojo::Connector* connector); + void InitializeResources(shell::Connector* connector); #if defined(OS_LINUX) && !defined(OS_ANDROID) skia::RefPtr<font_service::FontLoader> font_loader_;
diff --git a/ui/views/mus/native_widget_mus.cc b/ui/views/mus/native_widget_mus.cc index 70dd986..c47066b8 100644 --- a/ui/views/mus/native_widget_mus.cc +++ b/ui/views/mus/native_widget_mus.cc
@@ -238,7 +238,7 @@ // NativeWidgetMus, public: NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, - mojo::Connector* connector, + shell::Connector* connector, mus::Window* window, mus::mojom::SurfaceType surface_type) : window_(window),
diff --git a/ui/views/mus/native_widget_mus.h b/ui/views/mus/native_widget_mus.h index 60a2d234..8a7ed8c 100644 --- a/ui/views/mus/native_widget_mus.h +++ b/ui/views/mus/native_widget_mus.h
@@ -29,15 +29,15 @@ class Window; } -namespace mojo { -class Connector; -} - namespace mus { class Window; class WindowTreeConnection; } +namespace shell { +class Connector; +} + namespace wm { class FocusController; } @@ -58,7 +58,7 @@ public aura::WindowTreeHostObserver { public: NativeWidgetMus(internal::NativeWidgetDelegate* delegate, - mojo::Connector* connector, + shell::Connector* connector, mus::Window* window, mus::mojom::SurfaceType surface_type); ~NativeWidgetMus() override;
diff --git a/ui/views/mus/platform_test_helper_mus.cc b/ui/views/mus/platform_test_helper_mus.cc index c2592320..023c530 100644 --- a/ui/views/mus/platform_test_helper_mus.cc +++ b/ui/views/mus/platform_test_helper_mus.cc
@@ -15,14 +15,14 @@ #include "ui/views/test/platform_test_helper.h" #include "ui/views/views_delegate.h" -using mojo::shell::BackgroundShell; +using shell::BackgroundShell; namespace views { namespace { const char kTestName[] = "mojo:test-app"; -class DefaultShellClient : public mojo::ShellClient { +class DefaultShellClient : public shell::ShellClient { public: DefaultShellClient() {} ~DefaultShellClient() override {} @@ -31,11 +31,10 @@ DISALLOW_COPY_AND_ASSIGN(DefaultShellClient); }; -std::unique_ptr<mojo::shell::TestCatalogStore> BuildTestCatalogStore() { +std::unique_ptr<shell::TestCatalogStore> BuildTestCatalogStore() { std::unique_ptr<base::ListValue> apps(new base::ListValue); - apps->Append( - mojo::shell::BuildPermissiveSerializedAppInfo(kTestName, "test")); - return base::WrapUnique(new mojo::shell::TestCatalogStore(std::move(apps))); + apps->Append(shell::BuildPermissiveSerializedAppInfo(kTestName, "test")); + return base::WrapUnique(new shell::TestCatalogStore(std::move(apps))); } class PlatformTestHelperMus : public PlatformTestHelper { @@ -47,7 +46,7 @@ init_params->catalog_store = BuildTestCatalogStore(); background_shell_->Init(std::move(init_params)); shell_client_.reset(new DefaultShellClient); - shell_connection_.reset(new mojo::ShellConnection( + shell_connection_.reset(new shell::ShellConnection( shell_client_.get(), background_shell_->CreateShellClientRequest(kTestName))); @@ -58,7 +57,7 @@ // ui/views/mus requires a WindowManager running, for now use the desktop // one. - mojo::Connector* connector = shell_connection_->connector(); + shell::Connector* connector = shell_connection_->connector(); connector->Connect("mojo:desktop_wm"); WindowManagerConnection::Create(connector); @@ -93,7 +92,7 @@ } std::unique_ptr<BackgroundShell> background_shell_; - std::unique_ptr<mojo::ShellConnection> shell_connection_; + std::unique_ptr<shell::ShellConnection> shell_connection_; std::unique_ptr<DefaultShellClient> shell_client_; DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus);
diff --git a/ui/views/mus/platform_window_mus.cc b/ui/views/mus/platform_window_mus.cc index 14a85e1..1ae09d1 100644 --- a/ui/views/mus/platform_window_mus.cc +++ b/ui/views/mus/platform_window_mus.cc
@@ -22,7 +22,7 @@ } // namespace PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate, - mojo::Connector* connector, + shell::Connector* connector, mus::Window* mus_window) : delegate_(delegate), mus_window_(mus_window),
diff --git a/ui/views/mus/platform_window_mus.h b/ui/views/mus/platform_window_mus.h index 100cf908..7e9caa0 100644 --- a/ui/views/mus/platform_window_mus.h +++ b/ui/views/mus/platform_window_mus.h
@@ -20,7 +20,7 @@ class BitmapUploader; } -namespace mojo { +namespace shell { class Connector; } @@ -37,7 +37,7 @@ public NON_EXPORTED_BASE(mus::InputEventHandler) { public: PlatformWindowMus(ui::PlatformWindowDelegate* delegate, - mojo::Connector* connector, + shell::Connector* connector, mus::Window* mus_window); ~PlatformWindowMus() override;
diff --git a/ui/views/mus/screen_mus.cc b/ui/views/mus/screen_mus.cc index 67d0e661..d22499c 100644 --- a/ui/views/mus/screen_mus.cc +++ b/ui/views/mus/screen_mus.cc
@@ -74,7 +74,7 @@ ScreenMus::~ScreenMus() {} -void ScreenMus::Init(mojo::Connector* connector) { +void ScreenMus::Init(shell::Connector* connector) { gfx::Screen::SetScreenInstance(this); connector->ConnectToInterface("mojo:mus", &display_manager_);
diff --git a/ui/views/mus/screen_mus.h b/ui/views/mus/screen_mus.h index a6800af..620fd911 100644 --- a/ui/views/mus/screen_mus.h +++ b/ui/views/mus/screen_mus.h
@@ -15,7 +15,7 @@ #include "ui/gfx/screen.h" #include "ui/views/mus/mus_export.h" -namespace mojo { +namespace shell { class Connector; } @@ -31,7 +31,7 @@ explicit ScreenMus(ScreenMusDelegate* delegate); ~ScreenMus() override; - void Init(mojo::Connector* connector); + void Init(shell::Connector* connector); private: int FindDisplayIndexById(int64_t id) const;
diff --git a/ui/views/mus/surface_binding.cc b/ui/views/mus/surface_binding.cc index 808165fa4..4161811c4 100644 --- a/ui/views/mus/surface_binding.cc +++ b/ui/views/mus/surface_binding.cc
@@ -42,7 +42,7 @@ class SurfaceBinding::PerConnectionState : public base::RefCounted<PerConnectionState> { public: - static PerConnectionState* Get(mojo::Connector* connector, + static PerConnectionState* Get(shell::Connector* connector, mus::WindowTreeConnection* connection); std::unique_ptr<cc::OutputSurface> CreateOutputSurface( @@ -55,7 +55,7 @@ friend class base::RefCounted<PerConnectionState>; - PerConnectionState(mojo::Connector* connector, + PerConnectionState(shell::Connector* connector, mus::WindowTreeConnection* connection); ~PerConnectionState(); @@ -64,7 +64,7 @@ static base::LazyInstance< base::ThreadLocalPointer<ConnectionToStateMap>>::Leaky window_states; - mojo::Connector* connector_; + shell::Connector* connector_; mus::WindowTreeConnection* connection_; // Set of state needed to create an OutputSurface. @@ -80,7 +80,7 @@ // static SurfaceBinding::PerConnectionState* SurfaceBinding::PerConnectionState::Get( - mojo::Connector* connector, + shell::Connector* connector, mus::WindowTreeConnection* connection) { ConnectionToStateMap* window_map = window_states.Pointer()->Get(); if (!window_map) { @@ -110,7 +110,7 @@ } SurfaceBinding::PerConnectionState::PerConnectionState( - mojo::Connector* connector, + shell::Connector* connector, mus::WindowTreeConnection* connection) : connector_(connector), connection_(connection) {} @@ -131,7 +131,7 @@ // SurfaceBinding -------------------------------------------------------------- -SurfaceBinding::SurfaceBinding(mojo::Connector* connector, +SurfaceBinding::SurfaceBinding(shell::Connector* connector, mus::Window* window, mus::mojom::SurfaceType surface_type) : window_(window),
diff --git a/ui/views/mus/surface_binding.h b/ui/views/mus/surface_binding.h index 34a1088..2e04c3d4 100644 --- a/ui/views/mus/surface_binding.h +++ b/ui/views/mus/surface_binding.h
@@ -16,14 +16,14 @@ class OutputSurface; } -namespace mojo { -class Connector; -} - namespace mus { class Window; } +namespace shell { +class Connector; +} + namespace views { // SurfaceBinding is responsible for managing the connections necessary to @@ -33,7 +33,7 @@ // connection. class VIEWS_MUS_EXPORT SurfaceBinding { public: - SurfaceBinding(mojo::Connector* connector, + SurfaceBinding(shell::Connector* connector, mus::Window* window, mus::mojom::SurfaceType surface_type); ~SurfaceBinding();
diff --git a/ui/views/mus/surface_context_factory.cc b/ui/views/mus/surface_context_factory.cc index 37f569b..b62a656 100644 --- a/ui/views/mus/surface_context_factory.cc +++ b/ui/views/mus/surface_context_factory.cc
@@ -28,7 +28,7 @@ } // namespace SurfaceContextFactory::SurfaceContextFactory( - mojo::Connector* connector, + shell::Connector* connector, mus::Window* window, mus::mojom::SurfaceType surface_type) : surface_binding_(connector, window, surface_type),
diff --git a/ui/views/mus/surface_context_factory.h b/ui/views/mus/surface_context_factory.h index 087fc03..4932fd3 100644 --- a/ui/views/mus/surface_context_factory.h +++ b/ui/views/mus/surface_context_factory.h
@@ -27,7 +27,7 @@ class VIEWS_MUS_EXPORT SurfaceContextFactory : public ui::ContextFactory { public: - SurfaceContextFactory(mojo::Connector* connector, + SurfaceContextFactory(shell::Connector* connector, mus::Window* window, mus::mojom::SurfaceType surface_type); ~SurfaceContextFactory() override;
diff --git a/ui/views/mus/window_manager_connection.cc b/ui/views/mus/window_manager_connection.cc index 96d65a1..d08b5268 100644 --- a/ui/views/mus/window_manager_connection.cc +++ b/ui/views/mus/window_manager_connection.cc
@@ -31,7 +31,7 @@ } // namespace // static -void WindowManagerConnection::Create(mojo::Connector* connector) { +void WindowManagerConnection::Create(shell::Connector* connector) { DCHECK(!lazy_tls_ptr.Pointer()->Get()); lazy_tls_ptr.Pointer()->Set(new WindowManagerConnection(connector)); } @@ -69,7 +69,7 @@ mus::mojom::SurfaceType::DEFAULT); } -WindowManagerConnection::WindowManagerConnection(mojo::Connector* connector) +WindowManagerConnection::WindowManagerConnection(shell::Connector* connector) : connector_(connector), window_tree_connection_(nullptr) { window_tree_connection_.reset( mus::WindowTreeConnection::Create(this, connector_));
diff --git a/ui/views/mus/window_manager_connection.h b/ui/views/mus/window_manager_connection.h index 2716919..469f7e68 100644 --- a/ui/views/mus/window_manager_connection.h +++ b/ui/views/mus/window_manager_connection.h
@@ -15,7 +15,7 @@ #include "ui/views/mus/screen_mus_delegate.h" #include "ui/views/widget/widget.h" -namespace mojo { +namespace shell { class Connector; } @@ -38,14 +38,14 @@ : public NON_EXPORTED_BASE(mus::WindowTreeDelegate), public ScreenMusDelegate { public: - static void Create(mojo::Connector* connector); + static void Create(shell::Connector* connector); static WindowManagerConnection* Get(); static bool Exists(); // Destroys the singleton instance. static void Reset(); - mojo::Connector* connector() { return connector_; } + shell::Connector* connector() { return connector_; } mus::Window* NewWindow(const std::map<std::string, std::vector<uint8_t>>& properties); @@ -56,7 +56,7 @@ internal::NativeWidgetDelegate* delegate); private: - explicit WindowManagerConnection(mojo::Connector* connector); + explicit WindowManagerConnection(shell::Connector* connector); ~WindowManagerConnection() override; // mus::WindowTreeDelegate: @@ -66,7 +66,7 @@ // ScreenMusDelegate: void OnWindowManagerFrameValuesChanged() override; - mojo::Connector* connector_; + shell::Connector* connector_; std::unique_ptr<ScreenMus> screen_; std::unique_ptr<mus::WindowTreeConnection> window_tree_connection_;
diff --git a/ui/views/mus/window_tree_host_mus.cc b/ui/views/mus/window_tree_host_mus.cc index 185434f..c388453 100644 --- a/ui/views/mus/window_tree_host_mus.cc +++ b/ui/views/mus/window_tree_host_mus.cc
@@ -17,7 +17,7 @@ //////////////////////////////////////////////////////////////////////////////// // WindowTreeHostMus, public: -WindowTreeHostMus::WindowTreeHostMus(mojo::Connector* connector, +WindowTreeHostMus::WindowTreeHostMus(shell::Connector* connector, NativeWidgetMus* native_widget, mus::Window* window) : native_widget_(native_widget),
diff --git a/ui/views/mus/window_tree_host_mus.h b/ui/views/mus/window_tree_host_mus.h index 546a3ac..bc678752 100644 --- a/ui/views/mus/window_tree_host_mus.h +++ b/ui/views/mus/window_tree_host_mus.h
@@ -11,14 +11,14 @@ class SkBitmap; -namespace mojo { -class Connector; -} - namespace mus { class Window; } +namespace shell { +class Connector; +} + namespace views { class InputMethodMUS; @@ -27,7 +27,7 @@ class VIEWS_MUS_EXPORT WindowTreeHostMus : public aura::WindowTreeHostPlatform { public: - WindowTreeHostMus(mojo::Connector* connector, + WindowTreeHostMus(shell::Connector* connector, NativeWidgetMus* native_widget, mus::Window* window); ~WindowTreeHostMus() override;