diff --git a/DEPS b/DEPS index f6b2c31..8cc5b5f 100644 --- a/DEPS +++ b/DEPS
@@ -43,7 +43,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. - 'v8_revision': '617a02498272ca4336f30278c4477c4f90005fb6', + 'v8_revision': 'ed58de7aa22d94ea31d306bdf2d9d119e4dd2e7d', # 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. @@ -67,7 +67,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling BoringSSL # and whatever else without interference from each other. - 'boringssl_revision': 'afe57cb14d36f70ad4a109fc5e7765d1adc67035', + 'boringssl_revision': '6c22f542f42eccb0de7f43edf27aa1255c7be7e2', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling nss # and whatever else without interference from each other.
diff --git a/android_webview/browser/aw_permission_manager.cc b/android_webview/browser/aw_permission_manager.cc index 5d9e7368..c7fe04db2 100644 --- a/android_webview/browser/aw_permission_manager.cc +++ b/android_webview/browser/aw_permission_manager.cc
@@ -28,8 +28,8 @@ const GURL& requesting_origin, const GURL& embedding_origin, PermissionStatus status) { - DCHECK(status == content::PERMISSION_STATUS_GRANTED || - status == content::PERMISSION_STATUS_DENIED); + DCHECK(status == content::PermissionStatus::GRANTED || + status == content::PermissionStatus::DENIED); // TODO(ddorwin): We should be denying empty origins at a higher level. if (requesting_origin.is_empty() || embedding_origin.is_empty()) { @@ -66,7 +66,7 @@ const GURL& embedding_origin) const { // TODO(ddorwin): We should be denying empty origins at a higher level. if (requesting_origin.is_empty() || embedding_origin.is_empty()) { - return content::PERMISSION_STATUS_ASK; + return content::PermissionStatus::ASK; } DCHECK(requesting_origin.is_valid()) @@ -76,14 +76,14 @@ if (permission != PermissionType::PROTECTED_MEDIA_IDENTIFIER) { NOTREACHED() << "Results are only cached for PROTECTED_MEDIA_IDENTIFIER"; - return content::PERMISSION_STATUS_ASK; + return content::PermissionStatus::ASK; } std::string key = GetCacheKey(requesting_origin, embedding_origin); StatusMap::const_iterator it = pmi_result_cache_.find(key); if (it == pmi_result_cache_.end()) { DLOG(WARNING) << "GetResult() called for uncached origins: " << key; - return content::PERMISSION_STATUS_ASK; + return content::PermissionStatus::ASK; } DCHECK(!key.empty()); @@ -179,7 +179,7 @@ if (!delegate) { DVLOG(0) << "Dropping permission request for " << static_cast<int>(permission); - callback.Run(content::PERMISSION_STATUS_DENIED); + callback.Run(content::PermissionStatus::DENIED); return kNoPendingOperation; } @@ -245,14 +245,14 @@ case PermissionType::DURABLE_STORAGE: NOTIMPLEMENTED() << "RequestPermission is not implemented for " << static_cast<int>(permission); - callback.Run(content::PERMISSION_STATUS_DENIED); + callback.Run(content::PermissionStatus::DENIED); break; case PermissionType::MIDI: - callback.Run(content::PERMISSION_STATUS_GRANTED); + callback.Run(content::PermissionStatus::GRANTED); break; case PermissionType::NUM: NOTREACHED() << "PermissionType::NUM was not expected here."; - callback.Run(content::PERMISSION_STATUS_DENIED); + callback.Run(content::PermissionStatus::DENIED); break; } return request_id; @@ -287,8 +287,8 @@ int request_id, const base::Callback<void(PermissionStatus)>& callback, bool allowed) { - PermissionStatus status = allowed ? content::PERMISSION_STATUS_GRANTED - : content::PERMISSION_STATUS_DENIED; + PermissionStatus status = allowed ? content::PermissionStatus::GRANTED + : content::PermissionStatus::DENIED; if (manager.get()) { PendingRequest* pending_request = manager->pending_requests_.Lookup(request_id); @@ -391,10 +391,10 @@ return result_cache_->GetResult(permission, requesting_origin, embedding_origin); } else if (permission == PermissionType::MIDI) { - return content::PERMISSION_STATUS_GRANTED; + return content::PermissionStatus::GRANTED; } - return content::PERMISSION_STATUS_DENIED; + return content::PermissionStatus::DENIED; } void AwPermissionManager::RegisterPermissionUsage(
diff --git a/blimp/engine/browser/blimp_permission_manager.cc b/blimp/engine/browser/blimp_permission_manager.cc index a2cf9e9..0e2aad65 100644 --- a/blimp/engine/browser/blimp_permission_manager.cc +++ b/blimp/engine/browser/blimp_permission_manager.cc
@@ -23,7 +23,7 @@ const GURL& origin, bool user_gesture, const base::Callback<void(content::PermissionStatus)>& callback) { - callback.Run(content::PermissionStatus::PERMISSION_STATUS_DENIED); + callback.Run(content::PermissionStatus::DENIED); return kNoPendingOperation; } @@ -35,7 +35,7 @@ const base::Callback<void(const std::vector<content::PermissionStatus>&)>& callback) { callback.Run(std::vector<content::PermissionStatus>( - permission.size(), content::PermissionStatus::PERMISSION_STATUS_DENIED)); + permission.size(), content::PermissionStatus::DENIED)); return kNoPendingOperation; } @@ -49,7 +49,7 @@ content::PermissionType permission, const GURL& requesting_origin, const GURL& embedding_origin) { - return content::PermissionStatus::PERMISSION_STATUS_DENIED; + return content::PermissionStatus::DENIED; } void BlimpPermissionManager::RegisterPermissionUsage(
diff --git a/cc/output/ca_layer_overlay.cc b/cc/output/ca_layer_overlay.cc index 8704a06..2a0d84c 100644 --- a/cc/output/ca_layer_overlay.cc +++ b/cc/output/ca_layer_overlay.cc
@@ -89,7 +89,7 @@ // frame is the composition of a vertical flip about the anchor point, and a // translation by the height of the layer. ca_layer_overlay->transform.preTranslate( - 0, ca_layer_overlay->bounds_size.height(), 0); + 0, ca_layer_overlay->bounds_rect.height(), 0); ca_layer_overlay->transform.preScale(1, -1, 1); } ca_layer_overlay->contents_resource_id = resource_id; @@ -125,10 +125,6 @@ if (quad->shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode) return CA_LAYER_FAILED_QUAD_BLEND_MODE; - // TODO(ccameron): Handle 3D transforms. - if (!quad->shared_quad_state->quad_to_target_transform.IsFlat()) - return CA_LAYER_FAILED_QUAD_TRANSFORM; - // Early-out for invisible quads. if (quad->shared_quad_state->opacity == 0.f) { *skip = true; @@ -146,31 +142,16 @@ if (quad->IsTopEdge()) ca_layer_overlay->edge_aa_mask |= GL_CA_LAYER_EDGE_TOP_CHROMIUM; - // Check rect clipping. - gfx::RectF quad_rect(quad->rect); - if (quad->shared_quad_state->is_clipped) { - gfx::RectF clip_rect = gfx::RectF(quad->shared_quad_state->clip_rect); - gfx::RectF quad_rect_in_clip_space = gfx::RectF(quad->rect); - quad->shared_quad_state->quad_to_target_transform.TransformRect( - &quad_rect_in_clip_space); - quad_rect_in_clip_space.Intersect(display_rect); - // Skip quads that are entirely clipped. - if (!quad_rect_in_clip_space.Intersects(clip_rect)) { - *skip = true; - return CA_LAYER_SUCCESS; - } - // Fall back if the clip rect actually has an effect. - // TODO(ccameron): Handle more clip rects. - if (!clip_rect.Contains(quad_rect_in_clip_space)) { - return CA_LAYER_FAILED_QUAD_CLIPPING; - } - } + // Set rect clipping and sorting context ID. + ca_layer_overlay->sorting_context_id = + quad->shared_quad_state->sorting_context_id; + ca_layer_overlay->is_clipped = quad->shared_quad_state->is_clipped; + ca_layer_overlay->clip_rect = gfx::RectF(quad->shared_quad_state->clip_rect); ca_layer_overlay->opacity = quad->shared_quad_state->opacity; - ca_layer_overlay->bounds_size = gfx::SizeF(quad->rect.size()); - ca_layer_overlay->transform.setTranslate(quad->rect.x(), quad->rect.y(), 0); - ca_layer_overlay->transform.postConcat( - quad->shared_quad_state->quad_to_target_transform.matrix()); + ca_layer_overlay->bounds_rect = gfx::RectF(quad->rect); + ca_layer_overlay->transform = + quad->shared_quad_state->quad_to_target_transform.matrix(); switch (quad->material) { case DrawQuad::IO_SURFACE_CONTENT: @@ -202,7 +183,6 @@ case DrawQuad::YUV_VIDEO_CONTENT: return CA_LAYER_FAILED_YUV_VIDEO_CONTENT; default: - return CA_LAYER_FAILED_UNKNOWN; break; } @@ -220,18 +200,37 @@ const QuadList& quad_list, CALayerOverlayList* ca_layer_overlays) { CALayerResult result = CA_LAYER_SUCCESS; + ca_layer_overlays->reserve(quad_list.size()); + for (auto it = quad_list.BackToFrontBegin(); it != quad_list.BackToFrontEnd(); ++it) { const DrawQuad* quad = *it; - CALayerOverlay ca_layer_overlay; + CALayerOverlay ca_layer; bool skip = false; - result = FromDrawQuad(resource_provider, display_rect, quad, - &ca_layer_overlay, &skip); + result = + FromDrawQuad(resource_provider, display_rect, quad, &ca_layer, &skip); if (result != CA_LAYER_SUCCESS) break; + if (skip) continue; - ca_layer_overlays->push_back(ca_layer_overlay); + + // It is not possible to correctly represent two different clipping settings + // within one sorting context. + if (!ca_layer_overlays->empty()) { + const CALayerOverlay& previous_ca_layer = ca_layer_overlays->back(); + if (ca_layer.sorting_context_id && + previous_ca_layer.sorting_context_id == ca_layer.sorting_context_id) { + if (previous_ca_layer.is_clipped != ca_layer.is_clipped || + previous_ca_layer.clip_rect != ca_layer.clip_rect) { + // TODO(ccameron): Add a histogram value for this. + result = CA_LAYER_FAILED_UNKNOWN; + break; + } + } + } + + ca_layer_overlays->push_back(ca_layer); } UMA_HISTOGRAM_ENUMERATION("Compositing.Renderer.CALayerResult", result,
diff --git a/cc/output/ca_layer_overlay.h b/cc/output/ca_layer_overlay.h index ab234f4..f0b7c2234 100644 --- a/cc/output/ca_layer_overlay.h +++ b/cc/output/ca_layer_overlay.h
@@ -20,6 +20,12 @@ CALayerOverlay(); ~CALayerOverlay(); + // If |is_clipped| is true, then clip to |clip_rect| in the target space. + bool is_clipped = false; + gfx::RectF clip_rect; + // Layers in a non-zero sorting context exist in the same 3D space and should + // intersect. + unsigned sorting_context_id = 0; // Texture that corresponds to an IOSurface to set as the content of the // CALayer. If this is 0 then the CALayer is a solid color. unsigned contents_resource_id = 0; @@ -32,7 +38,7 @@ // The edge anti-aliasing mask property for the CALayer. unsigned edge_aa_mask = 0; // The bounds for the CALayer in pixels. - gfx::SizeF bounds_size; + gfx::RectF bounds_rect; // The transform to apply to the CALayer. SkMatrix44 transform = SkMatrix44(SkMatrix44::kIdentity_Constructor); };
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index b2502d9..4dd3bde 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc
@@ -3587,14 +3587,16 @@ ca_layer_overlay.contents_rect.height(), }; GLfloat bounds_rect[4] = { - 0, 0, ca_layer_overlay.bounds_size.width(), - ca_layer_overlay.bounds_size.height(), + ca_layer_overlay.bounds_rect.x(), ca_layer_overlay.bounds_rect.y(), + ca_layer_overlay.bounds_rect.width(), + ca_layer_overlay.bounds_rect.height(), }; - GLboolean is_clipped = GL_FALSE; - GLfloat clip_rect[4] = { - 0, 0, 0, 0, - }; - GLint sorting_context_id = 0; + GLboolean is_clipped = ca_layer_overlay.is_clipped; + GLfloat clip_rect[4] = {ca_layer_overlay.clip_rect.x(), + ca_layer_overlay.clip_rect.y(), + ca_layer_overlay.clip_rect.width(), + ca_layer_overlay.clip_rect.height()}; + GLint sorting_context_id = ca_layer_overlay.sorting_context_id; GLfloat transform[16]; ca_layer_overlay.transform.asColMajorf(transform); gl_->ScheduleCALayerCHROMIUM(
diff --git a/cc/output/overlay_unittest.cc b/cc/output/overlay_unittest.cc index 140935c5..c9c3017c0 100644 --- a/cc/output/overlay_unittest.cc +++ b/cc/output/overlay_unittest.cc
@@ -1516,7 +1516,7 @@ EXPECT_EQ(1U, ca_layer_list.size()); } -TEST_F(CALayerOverlayTest, Disallow3DTransform) { +TEST_F(CALayerOverlayTest, ThreeDTransform) { scoped_ptr<RenderPass> pass = CreateRenderPass(); CreateFullscreenCandidateQuad(resource_provider_.get(), pass->shared_quad_state_list.back(), @@ -1534,9 +1534,13 @@ &overlay_list, &ca_layer_list, &damage_rect); ASSERT_EQ(1U, pass_list.size()); - EXPECT_EQ(1U, pass_list.back()->quad_list.size()); - EXPECT_EQ(1U, overlay_list.size()); - EXPECT_EQ(0U, ca_layer_list.size()); + EXPECT_EQ(0U, pass_list.back()->quad_list.size()); + EXPECT_EQ(0U, overlay_list.size()); + EXPECT_EQ(1U, ca_layer_list.size()); + gfx::Transform expected_transform; + expected_transform.RotateAboutXAxis(45.f); + gfx::Transform actual_transform(ca_layer_list.back().transform); + EXPECT_EQ(expected_transform.ToString(), actual_transform.ToString()); } TEST_F(CALayerOverlayTest, AllowContainingClip) { @@ -1562,31 +1566,7 @@ EXPECT_EQ(1U, ca_layer_list.size()); } -TEST_F(CALayerOverlayTest, SkipDisjointClip) { - scoped_ptr<RenderPass> pass = CreateRenderPass(); - CreateFullscreenCandidateQuad(resource_provider_.get(), - pass->shared_quad_state_list.back(), - pass.get()); - pass->shared_quad_state_list.back()->is_clipped = true; - pass->shared_quad_state_list.back()->clip_rect = - gfx::Rect(128, 128, 128, 128); - - gfx::Rect damage_rect; - RenderPassList pass_list; - pass_list.push_back(std::move(pass)); - CALayerOverlayList ca_layer_list; - OverlayCandidateList overlay_list( - BackbufferOverlayList(pass_list.back().get())); - overlay_processor_->ProcessForOverlays(resource_provider_.get(), &pass_list, - &overlay_list, &ca_layer_list, - &damage_rect); - ASSERT_EQ(1U, pass_list.size()); - EXPECT_EQ(0U, pass_list.back()->quad_list.size()); - EXPECT_EQ(0U, overlay_list.size()); - EXPECT_EQ(0U, ca_layer_list.size()); -} - -TEST_F(CALayerOverlayTest, DisallowNontrivialClip) { +TEST_F(CALayerOverlayTest, NontrivialClip) { scoped_ptr<RenderPass> pass = CreateRenderPass(); CreateFullscreenCandidateQuad(resource_provider_.get(), pass->shared_quad_state_list.back(), @@ -1605,9 +1585,11 @@ &damage_rect); ASSERT_EQ(1U, pass_list.size()); - EXPECT_EQ(1U, pass_list.back()->quad_list.size()); - EXPECT_EQ(1U, overlay_list.size()); - EXPECT_EQ(0U, ca_layer_list.size()); + EXPECT_EQ(0U, pass_list.back()->quad_list.size()); + EXPECT_EQ(0U, overlay_list.size()); + EXPECT_EQ(1U, ca_layer_list.size()); + EXPECT_TRUE(ca_layer_list.back().is_clipped); + EXPECT_EQ(gfx::RectF(64, 64, 128, 128), ca_layer_list.back().clip_rect); } TEST_F(CALayerOverlayTest, SkipTransparent) {
diff --git a/chrome/VERSION b/chrome/VERSION index ebe78155..2eb368d 100644 --- a/chrome/VERSION +++ b/chrome/VERSION
@@ -1,4 +1,4 @@ MAJOR=50 MINOR=0 -BUILD=2627 +BUILD=2628 PATCH=0
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/remote/NotificationTransportControl.java b/chrome/android/java/src/org/chromium/chrome/browser/media/remote/NotificationTransportControl.java index d52b561e..055ec4a 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/media/remote/NotificationTransportControl.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/media/remote/NotificationTransportControl.java
@@ -337,7 +337,7 @@ new RemoteVideoInfo(null, 0, RemoteVideoInfo.PlayerState.STOPPED, 0, null)); } - sInstance.setMediaRouteController(mrc); + sInstance.setRouteController(mrc); return sInstance; } } @@ -454,7 +454,9 @@ @Override public void setRouteController(MediaRouteController controller) { - setMediaRouteController(controller); + if (mMediaRouteController != null) mMediaRouteController.removeUiListener(this); + mMediaRouteController = controller; + if (controller != null) controller.addUiListener(this); } @Override @@ -514,15 +516,4 @@ return scaleBitmap(bitmap, (int) maxWidth, (int) maxHeight); } - /** - * Sets the MediaRouteController the notification should be using to get the data from. - * - * @param mrc the MediaRouteController object to use. - */ - private void setMediaRouteController(@Nullable MediaRouteController mrc) { - if (mMediaRouteController != null) mMediaRouteController.removeUiListener(this); - mMediaRouteController = mrc; - if (mrc != null) mrc.addUiListener(this); - } - }
diff --git a/chrome/browser/chromeos/input_method/input_method_engine.h b/chrome/browser/chromeos/input_method/input_method_engine.h index 9991a02..9420a48 100644 --- a/chrome/browser/chromeos/input_method/input_method_engine.h +++ b/chrome/browser/chromeos/input_method/input_method_engine.h
@@ -12,7 +12,7 @@ #include <string> #include <vector> #include "base/time/time.h" -#include "chrome/browser/input_method/input_method_engine_base.h" +#include "chrome/browser/ui/input_method/input_method_engine_base.h" #include "ui/base/ime/chromeos/input_method_descriptor.h" #include "ui/base/ime/ime_engine_handler_interface.h" #include "url/gurl.h"
diff --git a/chrome/browser/chromeos/input_method/input_method_engine_unittest.cc b/chrome/browser/chromeos/input_method/input_method_engine_unittest.cc index 71a3fff..c503a3f4 100644 --- a/chrome/browser/chromeos/input_method/input_method_engine_unittest.cc +++ b/chrome/browser/chromeos/input_method/input_method_engine_unittest.cc
@@ -14,8 +14,8 @@ #include "base/test/histogram_tester.h" #include "chrome/browser/chromeos/input_method/input_method_configuration.h" #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" -#include "chrome/browser/input_method/input_method_engine_base.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/ui/input_method/input_method_engine_base.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/ime/chromeos/extension_ime_util.h" #include "ui/base/ime/chromeos/mock_component_extension_ime_manager_delegate.h"
diff --git a/chrome/browser/extensions/api/input_ime/input_ime_api.h b/chrome/browser/extensions/api/input_ime/input_ime_api.h index 738aaed0..bf9f69bb 100644 --- a/chrome/browser/extensions/api/input_ime/input_ime_api.h +++ b/chrome/browser/extensions/api/input_ime/input_ime_api.h
@@ -14,8 +14,8 @@ #include "base/scoped_observer.h" #include "base/values.h" #include "build/build_config.h" -#include "chrome/browser/input_method/input_method_engine_base.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/input_method/input_method_engine_base.h" #include "components/keyed_service/core/keyed_service.h" #include "extensions/browser/browser_context_keyed_api_factory.h" #include "extensions/browser/event_router.h"
diff --git a/chrome/browser/extensions/api/input_ime/input_ime_api_nonchromeos.cc b/chrome/browser/extensions/api/input_ime/input_ime_api_nonchromeos.cc index 98be0cc3..f9816326 100644 --- a/chrome/browser/extensions/api/input_ime/input_ime_api_nonchromeos.cc +++ b/chrome/browser/extensions/api/input_ime/input_ime_api_nonchromeos.cc
@@ -12,14 +12,24 @@ #include "base/command_line.h" #include "base/macros.h" +#include "chrome/browser/ui/input_method/input_method_engine.h" #include "chrome/common/chrome_switches.h" +#include "ui/base/ime/ime_bridge.h" + +using ui::IMEEngineHandlerInterface; +using input_method::InputMethodEngine; +using input_method::InputMethodEngineBase; namespace { +const char kErrorAPIDisabled[] = + "The chrome.input.ime API is not supported on the current platform"; + bool IsInputImeEnabled() { return base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableInputImeAPI); -} + +} // namespace class ImeObserverNonChromeOS : public ui::ImeObserver { public: @@ -45,9 +55,7 @@ ->DispatchEventToExtension(extension_id_, std::move(event)); } - std::string GetCurrentScreenType() override { - return "normal"; - } + std::string GetCurrentScreenType() override { return "normal"; } DISALLOW_COPY_AND_ASSIGN(ImeObserverNonChromeOS); }; @@ -56,20 +64,103 @@ namespace extensions { -InputImeEventRouter::InputImeEventRouter(Profile* profile) - : InputImeEventRouterBase(profile) {} - -InputImeEventRouter::~InputImeEventRouter() {} - void InputImeAPI::OnExtensionLoaded(content::BrowserContext* browser_context, - const Extension* extension) {} + const Extension* extension) { + // No-op if called multiple times. + ui::IMEBridge::Initialize(); +} void InputImeAPI::OnExtensionUnloaded(content::BrowserContext* browser_context, const Extension* extension, - UnloadedExtensionInfo::Reason reason) {} + UnloadedExtensionInfo::Reason reason) { + GetInputImeEventRouter(Profile::FromBrowserContext(browser_context)) + ->UnregisterImeExtension(extension->id()); +} void InputImeAPI::OnListenerAdded(const EventListenerInfo& details) {} +InputImeEventRouter::InputImeEventRouter(Profile* profile) + : InputImeEventRouterBase(profile), active_engine_(nullptr) {} + +InputImeEventRouter::~InputImeEventRouter() { + DeleteInputMethodEngine(); +} + +bool InputImeEventRouter::RegisterImeExtension( + const std::string& extension_id) { + // Check if the IME extension is already registered. + if (std::find(extension_ids_.begin(), extension_ids_.end(), extension_id) != + extension_ids_.end()) + return false; + + extension_ids_.push_back(extension_id); + return true; +} + +void InputImeEventRouter::UnregisterImeExtension( + const std::string& extension_id) { + std::vector<std::string>::iterator it = + std::find(extension_ids_.begin(), extension_ids_.end(), extension_id); + if (it != extension_ids_.end()) { + if (GetActiveEngine(extension_id)) + DeleteInputMethodEngine(); + extension_ids_.erase(it); + } +} + +InputMethodEngine* InputImeEventRouter::GetActiveEngine( + const std::string& extension_id) { + return (active_engine_ && active_engine_->GetExtensionId() == extension_id) + ? active_engine_ + : nullptr; +} + +void InputImeEventRouter::SetActiveEngine(const std::string& extension_id) { + if (active_engine_) { + if (active_engine_->GetExtensionId() == extension_id) + return; + DeleteInputMethodEngine(); + } + + RegisterImeExtension(extension_id); + scoped_ptr<input_method::InputMethodEngine> engine( + new input_method::InputMethodEngine()); + scoped_ptr<InputMethodEngineBase::Observer> observer( + new ImeObserverNonChromeOS(extension_id, profile())); + engine->Initialize(std::move(observer), extension_id.c_str(), profile()); + engine->Enable(""); + active_engine_ = engine.release(); + ui::IMEBridge::Get()->SetCurrentEngineHandler(active_engine_); +} + +void InputImeEventRouter::DeleteInputMethodEngine() { + if (active_engine_) { + ui::IMEBridge::Get()->SetCurrentEngineHandler(nullptr); + delete active_engine_; + active_engine_ = nullptr; + } +} + +ExtensionFunction::ResponseAction InputImeActivateFunction::Run() { + if (!IsInputImeEnabled()) + return RespondNow(Error(kErrorAPIDisabled)); + + InputImeEventRouter* event_router = + GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); + event_router->SetActiveEngine(extension_id()); + return RespondNow(NoArguments()); +} + +ExtensionFunction::ResponseAction InputImeDeactivateFunction::Run() { + if (!IsInputImeEnabled()) + return RespondNow(Error(kErrorAPIDisabled)); + + InputImeEventRouter* event_router = + GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); + event_router->UnregisterImeExtension(extension_id()); + return RespondNow(NoArguments()); +} + ExtensionFunction::ResponseAction InputImeCreateWindowFunction::Run() { // TODO(shuchen): Implement this API. return RespondNow(NoArguments());
diff --git a/chrome/browser/extensions/api/input_ime/input_ime_api_nonchromeos.h b/chrome/browser/extensions/api/input_ime/input_ime_api_nonchromeos.h index 2378297..d577c573 100644 --- a/chrome/browser/extensions/api/input_ime/input_ime_api_nonchromeos.h +++ b/chrome/browser/extensions/api/input_ime/input_ime_api_nonchromeos.h
@@ -11,6 +11,10 @@ class Profile; +namespace input_method { +class InputMethodEngine; +} // namespace input_method + namespace extensions { class InputImeEventRouterBase; @@ -20,6 +24,32 @@ explicit InputImeEventRouter(Profile* profile); ~InputImeEventRouter() override; + // Registers the extension as an IME extension, allowing it to be the active + // engine. + bool RegisterImeExtension(const std::string& extension_id); + + // Unregisters the extension as an IME extension and deactivates the IME + // engine for it, if it was active. + void UnregisterImeExtension(const std::string& extension_id); + + // Gets the input method engine if the extension is active. + input_method::InputMethodEngine* GetActiveEngine( + const std::string& extension_id); + + // Actives the extension with new input method engine, and deletes the + // previous engine if another extension was active. + void SetActiveEngine(const std::string& extension_id); + + private: + // Deletes the current input method engine. + void DeleteInputMethodEngine(); + + // The active input method engine. + input_method::InputMethodEngine* active_engine_; + + // The id of the all registered extensions. + std::vector<std::string> extension_ids_; + DISALLOW_COPY_AND_ASSIGN(InputImeEventRouter); }; @@ -34,6 +64,28 @@ ExtensionFunction::ResponseAction Run() override; }; +class InputImeActivateFunction : public UIThreadExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("input.ime.activate", INPUT_IME_ACTIVATE) + + protected: + ~InputImeActivateFunction() override {} + + // UIThreadExtensionFunction: + ResponseAction Run() override; +}; + +class InputImeDeactivateFunction : public UIThreadExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("input.ime.deactivate", INPUT_IME_DEACTIVATE) + + protected: + ~InputImeDeactivateFunction() override {} + + // UIThreadExtensionFunction: + ResponseAction Run() override; +}; + } // namespace extensions #endif // CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_NONCHROMEOS_H_
diff --git a/chrome/browser/extensions/api/management/management_apitest.cc b/chrome/browser/extensions/api/management/management_apitest.cc index 402003a..85fc4e27 100644 --- a/chrome/browser/extensions/api/management/management_apitest.cc +++ b/chrome/browser/extensions/api/management/management_apitest.cc
@@ -111,6 +111,7 @@ Manifest::EXTERNAL_PREF); InstallNamedExtension(basedir, "admin_extension", Manifest::EXTERNAL_POLICY_DOWNLOAD); + InstallNamedExtension(basedir, "version_name", Manifest::INTERNAL); ASSERT_TRUE(RunExtensionSubtest("management/test", "basics.html")); }
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc index ad2a792..a1176106 100644 --- a/chrome/browser/extensions/api/tabs/tabs_api.cc +++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -1641,10 +1641,6 @@ : chrome_details_(this) { } -bool TabsCaptureVisibleTabFunction::HasPermission() { - return true; -} - bool TabsCaptureVisibleTabFunction::IsScreenshotEnabled() { PrefService* service = chrome_details_.GetProfile()->GetPrefs(); if (service->GetBoolean(prefs::kDisableScreenshots)) { @@ -1672,40 +1668,6 @@ return contents; } -bool TabsCaptureVisibleTabFunction::RunAsync() { - using api::extension_types::ImageDetails; - - EXTENSION_FUNCTION_VALIDATE(args_); - - int context_id = extension_misc::kCurrentWindowId; - args_->GetInteger(0, &context_id); - - scoped_ptr<ImageDetails> image_details; - if (args_->GetSize() > 1) { - base::Value* spec = NULL; - EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &spec) && spec); - image_details = ImageDetails::FromValue(*spec); - } - - WebContents* contents = GetWebContentsForID(context_id); - - return CaptureAsync( - contents, image_details.get(), - base::Bind(&TabsCaptureVisibleTabFunction::CopyFromBackingStoreComplete, - this)); -} - -void TabsCaptureVisibleTabFunction::OnCaptureSuccess(const SkBitmap& bitmap) { - std::string base64_result; - if (!EncodeBitmap(bitmap, &base64_result)) { - OnCaptureFailure(FAILURE_REASON_ENCODING_FAILED); - return; - } - - SetResult(new base::StringValue(base64_result)); - SendResponse(true); -} - void TabsCaptureVisibleTabFunction::OnCaptureFailure(FailureReason reason) { const char* reason_description = "internal error"; switch (reason) {
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.h b/chrome/browser/extensions/api/tabs/tabs_api.h index e0a5f241..b398e70c 100644 --- a/chrome/browser/extensions/api/tabs/tabs_api.h +++ b/chrome/browser/extensions/api/tabs/tabs_api.h
@@ -15,8 +15,8 @@ #include "components/ui/zoom/zoom_controller.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" +#include "extensions/browser/api/capture_web_contents_function.h" #include "extensions/browser/api/execute_code_function.h" -#include "extensions/browser/api/web_contents_capture_client.h" #include "extensions/common/extension_resource.h" #include "extensions/common/user_script.h" #include "url/gurl.h" @@ -195,29 +195,21 @@ content::NotificationRegistrar registrar_; DECLARE_EXTENSION_FUNCTION("tabs.detectLanguage", TABS_DETECTLANGUAGE) }; - class TabsCaptureVisibleTabFunction - : public extensions::WebContentsCaptureClient, - public AsyncExtensionFunction { + : public extensions::CaptureWebContentsFunction { public: TabsCaptureVisibleTabFunction(); static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); - // ExtensionFunction implementation. - bool HasPermission() override; - bool RunAsync() override; - protected: ~TabsCaptureVisibleTabFunction() override {} private: ChromeExtensionFunctionDetails chrome_details_; - content::WebContents* GetWebContentsForID(int window_id); - - // extensions::WebContentsCaptureClient: + // extensions::CaptureWebContentsFunction: bool IsScreenshotEnabled() override; - void OnCaptureSuccess(const SkBitmap& bitmap) override; + content::WebContents* GetWebContentsForID(int id) override; void OnCaptureFailure(FailureReason reason) override; DECLARE_EXTENSION_FUNCTION("tabs.captureVisibleTab", TABS_CAPTUREVISIBLETAB)
diff --git a/chrome/browser/extensions/browser_context_keyed_service_factories.cc b/chrome/browser/extensions/browser_context_keyed_service_factories.cc index 96cf3ee..1dcfe76 100644 --- a/chrome/browser/extensions/browser_context_keyed_service_factories.cc +++ b/chrome/browser/extensions/browser_context_keyed_service_factories.cc
@@ -65,6 +65,8 @@ #include "chrome/browser/chromeos/extensions/media_player_api.h" #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" #include "chrome/browser/extensions/api/log_private/log_private_api.h" +#elif defined(OS_LINUX) || defined(OS_WIN) +#include "chrome/browser/extensions/api/input_ime/input_ime_api.h" #endif #if defined(ENABLE_SPELLCHECK) @@ -104,6 +106,8 @@ #if defined(OS_CHROMEOS) extensions::InputImeAPI::GetFactoryInstance(); extensions::InputMethodAPI::GetFactoryInstance(); +#elif defined(OS_LINUX) || defined(OS_WIN) + extensions::InputImeAPI::GetFactoryInstance(); #endif extensions::LanguageSettingsPrivateDelegateFactory::GetInstance(); extensions::LocationManager::GetFactoryInstance();
diff --git a/chrome/browser/media/router/media_router_mojo_impl.cc b/chrome/browser/media/router/media_router_mojo_impl.cc index 8233dff6f..bd9f6aca 100644 --- a/chrome/browser/media/router/media_router_mojo_impl.cc +++ b/chrome/browser/media/router/media_router_mojo_impl.cc
@@ -41,7 +41,7 @@ DCHECK(!input.is_null()); scoped_ptr<content::PresentationSessionMessage> output; switch (input->type) { - case interfaces::RouteMessage::Type::TYPE_TEXT: { + case interfaces::RouteMessage::Type::TEXT: { DCHECK(!input->message.is_null()); DCHECK(input->data.is_null()); output.reset(new content::PresentationSessionMessage( @@ -49,7 +49,7 @@ input->message.Swap(&output->message); return output; } - case interfaces::RouteMessage::Type::TYPE_BINARY: { + case interfaces::RouteMessage::Type::BINARY: { DCHECK(!input->data.is_null()); DCHECK(input->message.is_null()); output.reset(new content::PresentationSessionMessage( @@ -105,7 +105,7 @@ : event_page_tracker_(event_page_tracker), instance_id_(base::GenerateGUID()), has_local_display_route_(false), - availability_(interfaces::MediaRouter::SINK_AVAILABILITY_UNAVAILABLE), + availability_(interfaces::MediaRouter::SinkAvailability::UNAVAILABLE), wakeup_attempt_count_(0), current_wake_reason_(MediaRouteProviderWakeReason::TOTAL_COUNT), weak_factory_(this) { @@ -430,7 +430,7 @@ // If sink availability is UNAVAILABLE, then there is no need to call MRPM. // |observer| can be immediately notified with an empty list. sinks_query->observers.AddObserver(observer); - if (availability_ == interfaces::MediaRouter::SINK_AVAILABILITY_UNAVAILABLE) { + if (availability_ == interfaces::MediaRouter::SinkAvailability::UNAVAILABLE) { observer->OnSinksReceived(std::vector<MediaSink>()); } else { // Need to call MRPM to start observing sinks if the query is new. @@ -465,7 +465,7 @@ // UNAVAILABLE. // Otherwise, the MRPM would have discarded the queries already. if (availability_ != - interfaces::MediaRouter::SINK_AVAILABILITY_UNAVAILABLE) { + interfaces::MediaRouter::SinkAvailability::UNAVAILABLE) { SetWakeReason(MediaRouteProviderWakeReason::STOP_OBSERVING_MEDIA_SINKS); // The |sinks_queries_| entry will be removed in the immediate or deferred // |DoStopObservingMediaSinks| call. @@ -739,7 +739,7 @@ return; availability_ = availability; - if (availability_ == interfaces::MediaRouter::SINK_AVAILABILITY_UNAVAILABLE) { + if (availability_ == interfaces::MediaRouter::SinkAvailability::UNAVAILABLE) { // Sinks are no longer available. MRPM has already removed all sink queries. for (auto& source_and_query : sinks_queries_) { auto* query = source_and_query.second; @@ -777,7 +777,7 @@ const MediaSource::Id& source_id) { DVLOG_WITH_INSTANCE(1) << "DoStartObservingMediaSinks: " << source_id; // No need to call MRPM if there are no sinks available. - if (availability_ == interfaces::MediaRouter::SINK_AVAILABILITY_UNAVAILABLE) + if (availability_ == interfaces::MediaRouter::SinkAvailability::UNAVAILABLE) return; // No need to call MRPM if all observers have been removed in the meantime.
diff --git a/chrome/browser/media/router/media_router_mojo_impl_unittest.cc b/chrome/browser/media/router/media_router_mojo_impl_unittest.cc index 6965b272..fe521ca1b 100644 --- a/chrome/browser/media/router/media_router_mojo_impl_unittest.cc +++ b/chrome/browser/media/router/media_router_mojo_impl_unittest.cc
@@ -83,11 +83,10 @@ mojoIssue->title = title; mojoIssue->message = "msg"; mojoIssue->route_id = ""; - mojoIssue->default_action = - interfaces::Issue::ActionType::ACTION_TYPE_DISMISS; + mojoIssue->default_action = interfaces::Issue::ActionType::DISMISS; mojoIssue->secondary_actions = mojo::Array<interfaces::Issue::ActionType>::New(0); - mojoIssue->severity = interfaces::Issue::Severity::SEVERITY_WARNING; + mojoIssue->severity = interfaces::Issue::Severity::WARNING; mojoIssue->is_blocking = false; mojoIssue->help_url = ""; return mojoIssue; @@ -467,7 +466,7 @@ TEST_F(MediaRouterMojoImplTest, RegisterAndUnregisterMediaSinksObserver) { router()->OnSinkAvailabilityUpdated( - interfaces::MediaRouter::SINK_AVAILABILITY_AVAILABLE); + interfaces::MediaRouter::SinkAvailability::AVAILABLE); MediaSource media_source(kSource); // These should only be called once even if there is more than one observer @@ -499,12 +498,12 @@ mojo_sinks[0]->sink_id = kSinkId; mojo_sinks[0]->name = kSinkName; mojo_sinks[0]->icon_type = - media_router::interfaces::MediaSink::IconType::ICON_TYPE_CAST; + media_router::interfaces::MediaSink::IconType::CAST; mojo_sinks[1] = interfaces::MediaSink::New(); mojo_sinks[1]->sink_id = kSinkId2; mojo_sinks[1]->name = kSinkName; mojo_sinks[1]->icon_type = - media_router::interfaces::MediaSink::IconType::ICON_TYPE_CAST; + media_router::interfaces::MediaSink::IconType::CAST; base::RunLoop run_loop; EXPECT_CALL(*sinks_observer, OnSinksReceived(SequenceEquals(expected_sinks))); @@ -543,7 +542,7 @@ RegisterMediaSinksObserverWithAvailabilityChange) { // When availability is UNAVAILABLE, no calls should be made to MRPM. router()->OnSinkAvailabilityUpdated( - interfaces::MediaRouter::SINK_AVAILABILITY_UNAVAILABLE); + interfaces::MediaRouter::SinkAvailability::UNAVAILABLE); MediaSource media_source(kSource); scoped_ptr<MockMediaSinksObserver> sinks_observer( new MockMediaSinksObserver(router(), media_source)); @@ -566,7 +565,7 @@ // When availability transitions AVAILABLE, existing sink queries should be // sent to MRPM. router()->OnSinkAvailabilityUpdated( - interfaces::MediaRouter::SINK_AVAILABILITY_AVAILABLE); + interfaces::MediaRouter::SinkAvailability::AVAILABLE); EXPECT_CALL(mock_media_route_provider_, StartObservingMediaSinks(mojo::String(kSource))) .Times(1); @@ -578,7 +577,7 @@ // No change in availability status; no calls should be made to MRPM. router()->OnSinkAvailabilityUpdated( - interfaces::MediaRouter::SINK_AVAILABILITY_AVAILABLE); + interfaces::MediaRouter::SinkAvailability::AVAILABLE); EXPECT_CALL(mock_media_route_provider_, StartObservingMediaSinks(mojo::String(kSource))) .Times(0); @@ -591,7 +590,7 @@ // When availability is UNAVAILABLE, queries are already removed from MRPM. // Unregistering observer won't result in call to MRPM to remove query. router()->OnSinkAvailabilityUpdated( - interfaces::MediaRouter::SINK_AVAILABILITY_UNAVAILABLE); + interfaces::MediaRouter::SinkAvailability::UNAVAILABLE); EXPECT_CALL(mock_media_route_provider_, StopObservingMediaSinks(mojo::String(kSource))) .Times(0); @@ -602,7 +601,7 @@ // When availability is AVAILABLE, call is made to MRPM to remove query when // observer is unregistered. router()->OnSinkAvailabilityUpdated( - interfaces::MediaRouter::SINK_AVAILABILITY_AVAILABLE); + interfaces::MediaRouter::SinkAvailability::AVAILABLE); EXPECT_CALL(mock_media_route_provider_, StopObservingMediaSinks(mojo::String(kSource2))); sinks_observer2.reset(); @@ -746,10 +745,10 @@ TEST_F(MediaRouterMojoImplTest, PresentationSessionMessagesSingleObserver) { mojo::Array<interfaces::RouteMessagePtr> mojo_messages(2); mojo_messages[0] = interfaces::RouteMessage::New(); - mojo_messages[0]->type = interfaces::RouteMessage::Type::TYPE_TEXT; + mojo_messages[0]->type = interfaces::RouteMessage::Type::TEXT; mojo_messages[0]->message = "text"; mojo_messages[1] = interfaces::RouteMessage::New(); - mojo_messages[1]->type = interfaces::RouteMessage::Type::TYPE_BINARY; + mojo_messages[1]->type = interfaces::RouteMessage::Type::BINARY; mojo_messages[1]->data.push_back(1); ScopedVector<content::PresentationSessionMessage> expected_messages; @@ -806,7 +805,7 @@ // call ListenForRouteMessages again when it sees there are no more observers. mojo::Array<interfaces::RouteMessagePtr> mojo_messages_2(1); mojo_messages_2[0] = interfaces::RouteMessage::New(); - mojo_messages_2[0]->type = interfaces::RouteMessage::Type::TYPE_TEXT; + mojo_messages_2[0]->type = interfaces::RouteMessage::Type::TEXT; mojo_messages_2[0]->message = "foo"; observer.reset(); mojo_callback_2.Run(std::move(mojo_messages_2), false); @@ -820,10 +819,10 @@ TEST_F(MediaRouterMojoImplTest, PresentationSessionMessagesMultipleObservers) { mojo::Array<interfaces::RouteMessagePtr> mojo_messages(2); mojo_messages[0] = interfaces::RouteMessage::New(); - mojo_messages[0]->type = interfaces::RouteMessage::Type::TYPE_TEXT; + mojo_messages[0]->type = interfaces::RouteMessage::Type::TEXT; mojo_messages[0]->message = "text"; mojo_messages[1] = interfaces::RouteMessage::New(); - mojo_messages[1]->type = interfaces::RouteMessage::Type::TYPE_BINARY; + mojo_messages[1]->type = interfaces::RouteMessage::Type::BINARY; mojo_messages[1]->data.push_back(1); ScopedVector<content::PresentationSessionMessage> expected_messages; @@ -886,7 +885,7 @@ // call ListenForRouteMessages again when it sees there are no more observers. mojo::Array<interfaces::RouteMessagePtr> mojo_messages_2(1); mojo_messages_2[0] = interfaces::RouteMessage::New(); - mojo_messages_2[0]->type = interfaces::RouteMessage::Type::TYPE_TEXT; + mojo_messages_2[0]->type = interfaces::RouteMessage::Type::TEXT; mojo_messages_2[0]->message = "foo"; observer1.reset(); observer2.reset(); @@ -947,8 +946,7 @@ run_loop.Quit(); })); media_router_proxy_->OnPresentationConnectionStateChanged( - route_id, - PresentationConnectionState::PRESENTATION_CONNECTION_STATE_CLOSED); + route_id, PresentationConnectionState::CLOSED); run_loop.Run(); EXPECT_TRUE(Mock::VerifyAndClearExpectations(&callback)); @@ -961,8 +959,7 @@ run_loop2.Quit(); })); media_router_proxy_->OnPresentationConnectionStateChanged( - route_id, - PresentationConnectionState::PRESENTATION_CONNECTION_STATE_CLOSED); + route_id, PresentationConnectionState::CLOSED); run_loop2.Run(); // Callback has been removed, so we don't expect it to be called anymore. @@ -972,8 +969,7 @@ EXPECT_CALL(callback, Run(content::PRESENTATION_CONNECTION_STATE_CLOSED)) .Times(0); media_router_proxy_->OnPresentationConnectionStateChanged( - route_id, - PresentationConnectionState::PRESENTATION_CONNECTION_STATE_CLOSED); + route_id, PresentationConnectionState::CLOSED); ProcessEventLoop(); }
diff --git a/chrome/browser/media/router/media_router_type_converters.cc b/chrome/browser/media/router/media_router_type_converters.cc index 5ec515c..7542f24a 100644 --- a/chrome/browser/media/router/media_router_type_converters.cc +++ b/chrome/browser/media/router/media_router_type_converters.cc
@@ -18,16 +18,15 @@ media_router::MediaSink::IconType SinkIconTypeFromMojo( media_router::interfaces::MediaSink::IconType type) { switch (type) { - case media_router::interfaces::MediaSink::IconType::ICON_TYPE_CAST: + case media_router::interfaces::MediaSink::IconType::CAST: return media_router::MediaSink::CAST; - case media_router::interfaces::MediaSink::IconType::ICON_TYPE_CAST_AUDIO: + case media_router::interfaces::MediaSink::IconType::CAST_AUDIO: return media_router::MediaSink::CAST_AUDIO; - case media_router::interfaces::MediaSink:: - IconType::ICON_TYPE_CAST_AUDIO_GROUP: + case media_router::interfaces::MediaSink::IconType::CAST_AUDIO_GROUP: return media_router::MediaSink::CAST_AUDIO_GROUP; - case media_router::interfaces::MediaSink::IconType::ICON_TYPE_HANGOUT: + case media_router::interfaces::MediaSink::IconType::HANGOUT: return media_router::MediaSink::HANGOUT; - case media_router::interfaces::MediaSink::IconType::ICON_TYPE_GENERIC: + case media_router::interfaces::MediaSink::IconType::GENERIC: return media_router::MediaSink::GENERIC; default: NOTREACHED() << "Unknown sink icon type " << type; @@ -39,21 +38,18 @@ media_router::MediaSink::IconType type) { switch (type) { case media_router::MediaSink::CAST: - return media_router::interfaces::MediaSink::IconType::ICON_TYPE_CAST; + return media_router::interfaces::MediaSink::IconType::CAST; case media_router::MediaSink::CAST_AUDIO: - return - media_router::interfaces::MediaSink::IconType::ICON_TYPE_CAST_AUDIO; + return media_router::interfaces::MediaSink::IconType::CAST_AUDIO; case media_router::MediaSink::CAST_AUDIO_GROUP: - return - media_router::interfaces::MediaSink:: - IconType::ICON_TYPE_CAST_AUDIO_GROUP; + return media_router::interfaces::MediaSink::IconType::CAST_AUDIO_GROUP; case media_router::MediaSink::HANGOUT: - return media_router::interfaces::MediaSink::IconType::ICON_TYPE_HANGOUT; + return media_router::interfaces::MediaSink::IconType::HANGOUT; case media_router::MediaSink::GENERIC: - return media_router::interfaces::MediaSink::IconType::ICON_TYPE_GENERIC; + return media_router::interfaces::MediaSink::IconType::GENERIC; default: NOTREACHED() << "Unknown sink icon type " << type; - return media_router::interfaces::MediaSink::ICON_TYPE_GENERIC; + return media_router::interfaces::MediaSink::IconType::GENERIC; } } @@ -94,11 +90,11 @@ media_router::Issue::Severity IssueSeverityFromMojo( media_router::interfaces::Issue::Severity severity) { switch (severity) { - case media_router::interfaces::Issue::Severity::SEVERITY_FATAL: + case media_router::interfaces::Issue::Severity::FATAL: return media_router::Issue::FATAL; - case media_router::interfaces::Issue::Severity::SEVERITY_WARNING: + case media_router::interfaces::Issue::Severity::WARNING: return media_router::Issue::WARNING; - case media_router::interfaces::Issue::Severity::SEVERITY_NOTIFICATION: + case media_router::interfaces::Issue::Severity::NOTIFICATION: return media_router::Issue::NOTIFICATION; default: NOTREACHED() << "Unknown issue severity " << severity; @@ -109,9 +105,9 @@ media_router::IssueAction::Type IssueActionTypeFromMojo( media_router::interfaces::Issue::ActionType action_type) { switch (action_type) { - case media_router::interfaces::Issue::ActionType::ACTION_TYPE_DISMISS: + case media_router::interfaces::Issue::ActionType::DISMISS: return media_router::IssueAction::TYPE_DISMISS; - case media_router::interfaces::Issue::ActionType::ACTION_TYPE_LEARN_MORE: + case media_router::interfaces::Issue::ActionType::LEARN_MORE: return media_router::IssueAction::TYPE_LEARN_MORE; default: NOTREACHED() << "Unknown issue action type " << action_type; @@ -140,13 +136,13 @@ content::PresentationConnectionState PresentationConnectionStateFromMojo( PresentationConnectionState state) { switch (state) { - case PresentationConnectionState::PRESENTATION_CONNECTION_STATE_CONNECTING: + case PresentationConnectionState::CONNECTING: return content::PRESENTATION_CONNECTION_STATE_CONNECTING; - case PresentationConnectionState::PRESENTATION_CONNECTION_STATE_CONNECTED: + case PresentationConnectionState::CONNECTED: return content::PRESENTATION_CONNECTION_STATE_CONNECTED; - case PresentationConnectionState::PRESENTATION_CONNECTION_STATE_CLOSED: + case PresentationConnectionState::CLOSED: return content::PRESENTATION_CONNECTION_STATE_CLOSED; - case PresentationConnectionState::PRESENTATION_CONNECTION_STATE_TERMINATED: + case PresentationConnectionState::TERMINATED: return content::PRESENTATION_CONNECTION_STATE_TERMINATED; default: NOTREACHED() << "Unknown PresentationConnectionState " << state;
diff --git a/chrome/browser/media/router/media_router_type_converters_unittest.cc b/chrome/browser/media/router/media_router_type_converters_unittest.cc index 152c83e..0f29c65 100644 --- a/chrome/browser/media/router/media_router_type_converters_unittest.cc +++ b/chrome/browser/media/router/media_router_type_converters_unittest.cc
@@ -22,8 +22,7 @@ mojo_sink->name = "Sink 1"; mojo_sink->description = "description"; mojo_sink->domain = "domain"; - mojo_sink->icon_type = - media_router::interfaces::MediaSink::IconType::ICON_TYPE_CAST; + mojo_sink->icon_type = media_router::interfaces::MediaSink::IconType::CAST; MediaSink media_sink = mojo::TypeConverter< media_router::MediaSink, @@ -43,34 +42,34 @@ TEST(MediaRouterTypeConvertersTest, ConvertMediaSinkIconType) { // Convert from Mojo to Media Router. EXPECT_EQ(media_router::MediaSink::CAST, - mojo::SinkIconTypeFromMojo( - media_router::interfaces::MediaSink::IconType::ICON_TYPE_CAST)); + mojo::SinkIconTypeFromMojo( + media_router::interfaces::MediaSink::IconType::CAST)); EXPECT_EQ(media_router::MediaSink::CAST_AUDIO, + mojo::SinkIconTypeFromMojo( + media_router::interfaces::MediaSink::IconType::CAST_AUDIO)); + EXPECT_EQ( + media_router::MediaSink::CAST_AUDIO_GROUP, mojo::SinkIconTypeFromMojo( - media_router::interfaces::MediaSink::IconType::ICON_TYPE_CAST_AUDIO)); - EXPECT_EQ(media_router::MediaSink::CAST_AUDIO_GROUP, - mojo::SinkIconTypeFromMojo( - media_router::interfaces::MediaSink:: - IconType::ICON_TYPE_CAST_AUDIO_GROUP)); + media_router::interfaces::MediaSink::IconType::CAST_AUDIO_GROUP)); EXPECT_EQ(media_router::MediaSink::GENERIC, - mojo::SinkIconTypeFromMojo( - media_router::interfaces::MediaSink::IconType::ICON_TYPE_GENERIC)); + mojo::SinkIconTypeFromMojo( + media_router::interfaces::MediaSink::IconType::GENERIC)); EXPECT_EQ(media_router::MediaSink::HANGOUT, - mojo::SinkIconTypeFromMojo( - media_router::interfaces::MediaSink::IconType::ICON_TYPE_HANGOUT)); + mojo::SinkIconTypeFromMojo( + media_router::interfaces::MediaSink::IconType::HANGOUT)); // Convert from Media Router to Mojo. - EXPECT_EQ(media_router::interfaces::MediaSink::IconType::ICON_TYPE_CAST, - mojo::SinkIconTypeToMojo(media_router::MediaSink::CAST)); - EXPECT_EQ(media_router::interfaces::MediaSink::IconType::ICON_TYPE_CAST_AUDIO, - mojo::SinkIconTypeToMojo(media_router::MediaSink::CAST_AUDIO)); - EXPECT_EQ(media_router::interfaces::MediaSink:: - IconType::ICON_TYPE_CAST_AUDIO_GROUP, + EXPECT_EQ(media_router::interfaces::MediaSink::IconType::CAST, + mojo::SinkIconTypeToMojo(media_router::MediaSink::CAST)); + EXPECT_EQ(media_router::interfaces::MediaSink::IconType::CAST_AUDIO, + mojo::SinkIconTypeToMojo(media_router::MediaSink::CAST_AUDIO)); + EXPECT_EQ( + media_router::interfaces::MediaSink::IconType::CAST_AUDIO_GROUP, mojo::SinkIconTypeToMojo(media_router::MediaSink::CAST_AUDIO_GROUP)); - EXPECT_EQ(media_router::interfaces::MediaSink::IconType::ICON_TYPE_GENERIC, - mojo::SinkIconTypeToMojo(media_router::MediaSink::GENERIC)); - EXPECT_EQ(media_router::interfaces::MediaSink::IconType::ICON_TYPE_HANGOUT, - mojo::SinkIconTypeToMojo(media_router::MediaSink::HANGOUT)); + EXPECT_EQ(media_router::interfaces::MediaSink::IconType::GENERIC, + mojo::SinkIconTypeToMojo(media_router::MediaSink::GENERIC)); + EXPECT_EQ(media_router::interfaces::MediaSink::IconType::HANGOUT, + mojo::SinkIconTypeToMojo(media_router::MediaSink::HANGOUT)); } TEST(MediaRouterTypeConvertersTest, ConvertMediaRoute) { @@ -121,13 +120,11 @@ mojoIssue->title = "title"; mojoIssue->message = "msg"; mojoIssue->route_id = "routeId"; - mojoIssue->default_action = - interfaces::Issue::ActionType::ACTION_TYPE_LEARN_MORE; + mojoIssue->default_action = interfaces::Issue::ActionType::LEARN_MORE; mojoIssue->secondary_actions = mojo::Array<interfaces::Issue::ActionType>::New(1); - mojoIssue->secondary_actions[0] = - interfaces::Issue::ActionType::ACTION_TYPE_DISMISS; - mojoIssue->severity = interfaces::Issue::Severity::SEVERITY_WARNING; + mojoIssue->secondary_actions[0] = interfaces::Issue::ActionType::DISMISS; + mojoIssue->severity = interfaces::Issue::Severity::WARNING; mojoIssue->is_blocking = true; mojoIssue->help_url = "help_url"; @@ -165,9 +162,8 @@ interfaces::IssuePtr mojoIssue; mojoIssue = interfaces::Issue::New(); mojoIssue->title = "title"; - mojoIssue->default_action = - interfaces::Issue::ActionType::ACTION_TYPE_DISMISS; - mojoIssue->severity = interfaces::Issue::Severity::SEVERITY_WARNING; + mojoIssue->default_action = interfaces::Issue::ActionType::DISMISS; + mojoIssue->severity = interfaces::Issue::Severity::WARNING; mojoIssue->is_blocking = true; Issue expected_issue("title", "", IssueAction(IssueAction::TYPE_DISMISS),
diff --git a/chrome/browser/permissions/permission_manager.cc b/chrome/browser/permissions/permission_manager.cc index 44d97af..7a8652e 100644 --- a/chrome/browser/permissions/permission_manager.cc +++ b/chrome/browser/permissions/permission_manager.cc
@@ -34,11 +34,11 @@ switch (setting) { case CONTENT_SETTING_ALLOW: case CONTENT_SETTING_SESSION_ONLY: - return content::PERMISSION_STATUS_GRANTED; + return content::PermissionStatus::GRANTED; case CONTENT_SETTING_BLOCK: - return content::PERMISSION_STATUS_DENIED; + return content::PermissionStatus::DENIED; case CONTENT_SETTING_ASK: - return content::PERMISSION_STATUS_ASK; + return content::PermissionStatus::ASK; case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT: case CONTENT_SETTING_DEFAULT: case CONTENT_SETTING_NUM_SETTINGS: @@ -46,7 +46,7 @@ } NOTREACHED(); - return content::PERMISSION_STATUS_DENIED; + return content::PermissionStatus::DENIED; } // Wrap a callback taking a PermissionStatus to pass it as a callback taking a @@ -140,15 +140,14 @@ public: PendingRequest(content::RenderFrameHost* render_frame_host, const std::vector<PermissionType> permissions, - const base::Callback<void( - const std::vector<PermissionStatus>&)>& callback) - : render_process_id_(render_frame_host->GetProcess()->GetID()), - render_frame_id_(render_frame_host->GetRoutingID()), - callback_(callback), - permissions_(permissions), - results_(permissions.size(), content::PERMISSION_STATUS_DENIED), - remaining_results_(permissions.size()) { - } + const base::Callback< + void(const std::vector<PermissionStatus>&)>& callback) + : render_process_id_(render_frame_host->GetProcess()->GetID()), + render_frame_id_(render_frame_host->GetRoutingID()), + callback_(callback), + permissions_(permissions), + results_(permissions.size(), content::PermissionStatus::DENIED), + remaining_results_(permissions.size()) {} void SetPermissionStatus(int permission_id, PermissionStatus status) { DCHECK(!IsComplete()); @@ -328,7 +327,7 @@ PermissionContextBase* context = PermissionContext::Get(profile_, permission); if (!context) - return content::PERMISSION_STATUS_DENIED; + return content::PermissionStatus::DENIED; return ContentSettingToPermissionStatus(context->GetPermissionStatus( requesting_origin.GetOrigin(), embedding_origin.GetOrigin()));
diff --git a/chrome/browser/permissions/permission_manager_unittest.cc b/chrome/browser/permissions/permission_manager_unittest.cc index 8144f4f..cd3926f 100644 --- a/chrome/browser/permissions/permission_manager_unittest.cc +++ b/chrome/browser/permissions/permission_manager_unittest.cc
@@ -45,8 +45,7 @@ : url_("https://example.com"), other_url_("https://foo.com"), callback_called_(false), - callback_result_(content::PERMISSION_STATUS_ASK) { - } + callback_result_(content::PermissionStatus::ASK) {} PermissionManager* GetPermissionManager() { return profile_.GetPermissionManager(); @@ -85,7 +84,7 @@ void Reset() { callback_called_ = false; - callback_result_ = content::PERMISSION_STATUS_ASK; + callback_result_ = content::PermissionStatus::ASK; } private: @@ -99,41 +98,41 @@ TEST_F(PermissionManagerTest, GetPermissionStatusDefault) { CheckPermissionStatus(PermissionType::MIDI_SYSEX, - content::PERMISSION_STATUS_ASK); + content::PermissionStatus::ASK); CheckPermissionStatus(PermissionType::PUSH_MESSAGING, - content::PERMISSION_STATUS_ASK); + content::PermissionStatus::ASK); CheckPermissionStatus(PermissionType::NOTIFICATIONS, - content::PERMISSION_STATUS_ASK); + content::PermissionStatus::ASK); CheckPermissionStatus(PermissionType::GEOLOCATION, - content::PERMISSION_STATUS_ASK); + content::PermissionStatus::ASK); #if defined(OS_ANDROID) CheckPermissionStatus(PermissionType::PROTECTED_MEDIA_IDENTIFIER, - content::PERMISSION_STATUS_ASK); + content::PermissionStatus::ASK); #endif } TEST_F(PermissionManagerTest, GetPermissionStatusAfterSet) { SetPermission(CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW); CheckPermissionStatus(PermissionType::GEOLOCATION, - content::PERMISSION_STATUS_GRANTED); + content::PermissionStatus::GRANTED); SetPermission(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_ALLOW); CheckPermissionStatus(PermissionType::NOTIFICATIONS, - content::PERMISSION_STATUS_GRANTED); + content::PermissionStatus::GRANTED); SetPermission(CONTENT_SETTINGS_TYPE_MIDI_SYSEX, CONTENT_SETTING_ALLOW); CheckPermissionStatus(PermissionType::MIDI_SYSEX, - content::PERMISSION_STATUS_GRANTED); + content::PermissionStatus::GRANTED); SetPermission(CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, CONTENT_SETTING_ALLOW); CheckPermissionStatus(PermissionType::PUSH_MESSAGING, - content::PERMISSION_STATUS_GRANTED); + content::PermissionStatus::GRANTED); #if defined(OS_ANDROID) SetPermission(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, CONTENT_SETTING_ALLOW); CheckPermissionStatus(PermissionType::PROTECTED_MEDIA_IDENTIFIER, - content::PERMISSION_STATUS_GRANTED); + content::PermissionStatus::GRANTED); #endif } @@ -151,7 +150,7 @@ CONTENT_SETTING_ALLOW); EXPECT_TRUE(callback_called()); - EXPECT_EQ(content::PERMISSION_STATUS_GRANTED, callback_result()); + EXPECT_EQ(content::PermissionStatus::GRANTED, callback_result()); GetPermissionManager()->UnsubscribePermissionStatusChange(subscription_id); } @@ -242,7 +241,7 @@ CONTENT_SETTING_ALLOW); EXPECT_TRUE(callback_called()); - EXPECT_EQ(content::PERMISSION_STATUS_GRANTED, callback_result()); + EXPECT_EQ(content::PermissionStatus::GRANTED, callback_result()); GetPermissionManager()->UnsubscribePermissionStatusChange(subscription_id); } @@ -264,7 +263,7 @@ CONTENT_SETTINGS_TYPE_GEOLOCATION); EXPECT_TRUE(callback_called()); - EXPECT_EQ(content::PERMISSION_STATUS_ASK, callback_result()); + EXPECT_EQ(content::PermissionStatus::ASK, callback_result()); GetPermissionManager()->UnsubscribePermissionStatusChange(subscription_id); } @@ -283,7 +282,7 @@ CONTENT_SETTING_BLOCK); EXPECT_TRUE(callback_called()); - EXPECT_EQ(content::PERMISSION_STATUS_DENIED, callback_result()); + EXPECT_EQ(content::PermissionStatus::DENIED, callback_result()); GetPermissionManager()->UnsubscribePermissionStatusChange(subscription_id); } @@ -334,7 +333,7 @@ CONTENT_SETTING_ALLOW); EXPECT_TRUE(callback_called()); - EXPECT_EQ(content::PERMISSION_STATUS_GRANTED, callback_result()); + EXPECT_EQ(content::PermissionStatus::GRANTED, callback_result()); Reset(); @@ -346,7 +345,7 @@ CONTENT_SETTING_ASK); EXPECT_TRUE(callback_called()); - EXPECT_EQ(content::PERMISSION_STATUS_ASK, callback_result()); + EXPECT_EQ(content::PermissionStatus::ASK, callback_result()); GetPermissionManager()->UnsubscribePermissionStatusChange(subscription_id); }
diff --git a/chrome/browser/permissions/permission_uma_util.cc b/chrome/browser/permissions/permission_uma_util.cc index 133904df..651ecfe 100644 --- a/chrome/browser/permissions/permission_uma_util.cc +++ b/chrome/browser/permissions/permission_uma_util.cc
@@ -233,9 +233,10 @@ base::HistogramBase* histogram = base::LinearHistogram::FactoryGet( "Permissions.Requested.CrossOrigin_" + PermissionUtil::GetPermissionString(permission), - 1, content::PERMISSION_STATUS_LAST, content::PERMISSION_STATUS_LAST + 1, + 1, static_cast<int>(content::PermissionStatus::LAST), + static_cast<int>(content::PermissionStatus::LAST) + 1, base::HistogramBase::kUmaTargetedHistogramFlag); - histogram->Add(embedding_permission_status); + histogram->Add(static_cast<int>(embedding_permission_status)); } else { UMA_HISTOGRAM_ENUMERATION( "Permissions.Requested.SameOrigin",
diff --git a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc index b891a614..953b9f4 100644 --- a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc +++ b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
@@ -239,7 +239,7 @@ const base::FilePath& profile_path, const base::string16& new_profile_name) { const size_t profile_index = - profile_info_cache_->GetIndexOfProfileWithPath(profile_2_path_); + profile_info_cache_->GetIndexOfProfileWithPath(profile_path); ASSERT_NE(std::string::npos, profile_index); ASSERT_NE(profile_info_cache_->GetNameOfProfileAtIndex(profile_index), new_profile_name); @@ -878,3 +878,146 @@ EXPECT_TRUE(base::ReadFileToString(icon_path_1, &unbadged_icon_1_a)); EXPECT_EQ(unbadged_icon_1, unbadged_icon_1_a); } + +TEST_F(ProfileShortcutManagerTest, ShortcutFilenameUniquified) { + const auto suffix = + GetDistribution()->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME); + std::set<base::FilePath> excludes; + + auto shortcut_filename = + profiles::internal::GetUniqueShortcutFilenameForProfile( + L"Carrie", excludes, GetDistribution()); + EXPECT_EQ(L"Carrie - " + suffix + L".lnk", shortcut_filename); + excludes.insert(GetUserShortcutsDirectory().Append(shortcut_filename)); + + shortcut_filename = profiles::internal::GetUniqueShortcutFilenameForProfile( + L"Carrie", excludes, GetDistribution()); + EXPECT_EQ(L"Carrie - " + suffix + L" (1).lnk", shortcut_filename); + excludes.insert(GetUserShortcutsDirectory().Append(shortcut_filename)); + + shortcut_filename = profiles::internal::GetUniqueShortcutFilenameForProfile( + L"Carrie", excludes, GetDistribution()); + EXPECT_EQ(L"Carrie - " + suffix + L" (2).lnk", shortcut_filename); + excludes.insert(GetUserShortcutsDirectory().Append(shortcut_filename)); + + shortcut_filename = profiles::internal::GetUniqueShortcutFilenameForProfile( + L"Steven", excludes, GetDistribution()); + EXPECT_EQ(L"Steven - " + suffix + L".lnk", shortcut_filename); + excludes.insert(GetUserShortcutsDirectory().Append(shortcut_filename)); + + shortcut_filename = profiles::internal::GetUniqueShortcutFilenameForProfile( + L"Steven", excludes, GetDistribution()); + EXPECT_EQ(L"Steven - " + suffix + L" (1).lnk", shortcut_filename); + excludes.insert(GetUserShortcutsDirectory().Append(shortcut_filename)); + + shortcut_filename = profiles::internal::GetUniqueShortcutFilenameForProfile( + L"Carrie", excludes, GetDistribution()); + EXPECT_EQ(L"Carrie - " + suffix + L" (3).lnk", shortcut_filename); + excludes.insert(GetUserShortcutsDirectory().Append(shortcut_filename)); + + excludes.erase( + GetUserShortcutsDirectory().Append(L"Carrie - " + suffix + L".lnk")); + shortcut_filename = profiles::internal::GetUniqueShortcutFilenameForProfile( + L"Carrie", excludes, GetDistribution()); + EXPECT_EQ(L"Carrie - " + suffix + L".lnk", shortcut_filename); +} + +TEST_F(ProfileShortcutManagerTest, ShortcutFilenameMatcher) { + profiles::internal::ShortcutFilenameMatcher matcher(L"Carrie", + GetDistribution()); + const auto suffix = + GetDistribution()->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME); + EXPECT_TRUE(matcher.IsCanonical(L"Carrie - " + suffix + L" (2).lnk")); + EXPECT_FALSE(matcher.IsCanonical(L"Carrie - " + suffix + L"(2).lnk")); + EXPECT_FALSE(matcher.IsCanonical(L"Carrie - " + suffix + L" 2.lnk")); + EXPECT_FALSE(matcher.IsCanonical(L"Carrie - " + suffix + L"2.lnk")); + EXPECT_FALSE(matcher.IsCanonical(L"Carrie - " + suffix + L" - 2.lnk")); + EXPECT_FALSE(matcher.IsCanonical(L"Carrie - " + suffix + L" (a).lnk")); + EXPECT_TRUE(matcher.IsCanonical(L"Carrie - " + suffix + L" (11).lnk")); + EXPECT_TRUE(matcher.IsCanonical(L"Carrie - " + suffix + L" (03).lnk")); + EXPECT_TRUE(matcher.IsCanonical(L"Carrie - " + suffix + L" (999).lnk")); + EXPECT_FALSE(matcher.IsCanonical(L"Carrie - " + suffix + L" (999).lin")); + EXPECT_FALSE(matcher.IsCanonical(L"ABC Carrie - " + suffix + L" DEF.lnk")); + EXPECT_FALSE(matcher.IsCanonical(L"ABC Carrie DEF.lnk")); + EXPECT_FALSE(matcher.IsCanonical(L"Carrie.lnk")); +} + +TEST_F(ProfileShortcutManagerTest, ShortcutsForProfilesWithIdenticalNames) { + SetupDefaultProfileShortcut(FROM_HERE); + + // Create new profile - profile2. + CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); + // Check that nothing is changed for profile1. + ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); + + // Give to profile1 the same name as profile2. + base::string16 new_profile_1_name = profile_2_name_; + RenameProfile(FROM_HERE, profile_1_path_, new_profile_1_name); + const auto profile_1_shortcut_name = new_profile_1_name + L" - " + + GetDistribution()->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + + L" (1)"; + const auto profile_1_shortcut_path = GetUserShortcutsDirectory() + .Append(profile_1_shortcut_name + installer::kLnkExt); + ValidateProfileShortcutAtPath(FROM_HERE, + profile_1_shortcut_path, + profile_1_path_); + // Check that nothing is changed for profile2. + ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_); + + // Create new profile - profile3. + CreateProfileWithShortcut(FROM_HERE, profile_3_name_, profile_3_path_); + // Check that nothing is changed for profile1 and profile2. + ValidateProfileShortcutAtPath(FROM_HERE, + profile_1_shortcut_path, + profile_1_path_); + ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_); + + // Give to profile3 the same name as profile2. + const base::string16 new_profile_3_name = profile_2_name_; + RenameProfile(FROM_HERE, profile_3_path_, new_profile_3_name); + const auto profile_3_shortcut_name = new_profile_3_name + L" - " + + GetDistribution()->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + + L" (2)"; + const auto profile_3_shortcut_path = GetUserShortcutsDirectory() + .Append(profile_3_shortcut_name + installer::kLnkExt); + ValidateProfileShortcutAtPath(FROM_HERE, + profile_3_shortcut_path, + profile_3_path_); + // Check that nothing is changed for profile1 and profile2. + ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_); + ValidateProfileShortcutAtPath(FROM_HERE, + profile_1_shortcut_path, + profile_1_path_); + + // Rename profile1 again. + new_profile_1_name = L"Carrie"; + RenameProfile(FROM_HERE, profile_1_path_, new_profile_1_name); + ValidateProfileShortcut(FROM_HERE, new_profile_1_name, profile_1_path_); + // Check that nothing is changed for profile2 and profile3. + ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_); + ValidateProfileShortcutAtPath(FROM_HERE, + profile_3_shortcut_path, + profile_3_path_); + + // Delete profile1. + profile_info_cache_->DeleteProfileFromCache(profile_1_path_); + RunPendingTasks(); + EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(new_profile_1_name)); + // Check that nothing is changed for profile2 and profile3. + ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_); + ValidateProfileShortcutAtPath(FROM_HERE, + profile_3_shortcut_path, + profile_3_path_); + + // Delete profile2. + EXPECT_TRUE(base::PathExists( + GetDefaultShortcutPathForProfile(profile_2_name_))); + EXPECT_TRUE(base::PathExists(profile_3_shortcut_path)); + profile_info_cache_->DeleteProfileFromCache(profile_2_path_); + RunPendingTasks(); + EXPECT_FALSE(base::PathExists( + GetDefaultShortcutPathForProfile(profile_2_name_))); + // Only profile3 exists. There should be non-profile shortcut only. + EXPECT_FALSE(base::PathExists(profile_3_shortcut_path)); + ValidateNonProfileShortcut(FROM_HERE); +}
diff --git a/chrome/browser/profiles/profile_shortcut_manager_win.cc b/chrome/browser/profiles/profile_shortcut_manager_win.cc index 8877ed6e..f00150bb 100644 --- a/chrome/browser/profiles/profile_shortcut_manager_win.cc +++ b/chrome/browser/profiles/profile_shortcut_manager_win.cc
@@ -7,6 +7,8 @@ #include <shlobj.h> // For SHChangeNotify(). #include <stddef.h> +#include <algorithm> +#include <set> #include <string> #include <vector> @@ -291,33 +293,56 @@ return ConvertToLongPath(target_path) == ConvertToLongPath(chrome_exe); } -// Populates |paths| with the file paths of Chrome desktop shortcuts that have -// the specified |command_line|. If |include_empty_command_lines| is true, -// Chrome desktop shortcuts with empty command lines will also be included. -void ListDesktopShortcutsWithCommandLine(const base::FilePath& chrome_exe, - const base::string16& command_line, - bool include_empty_command_lines, - std::vector<base::FilePath>* paths) { - base::FilePath user_shortcuts_directory; - if (!GetDesktopShortcutsDirectories(&user_shortcuts_directory, NULL)) - return; +// A functor checks if |path| is the Chrome desktop shortcut (|chrome_exe|) +// that have the specified |command_line|. If |include_empty_command_lines| is +// true Chrome desktop shortcuts with empty command lines will also be included. +struct ChromeCommandLineFilter { + const base::FilePath& chrome_exe; + const base::string16& command_line; + bool include_empty_command_lines; - base::FileEnumerator enumerator(user_shortcuts_directory, false, - base::FileEnumerator::FILES); - for (base::FilePath path = enumerator.Next(); !path.empty(); - path = enumerator.Next()) { + ChromeCommandLineFilter(const base::FilePath& chrome_exe, + const base::string16& command_line, + bool include_empty_command_lines) + : chrome_exe(chrome_exe), + command_line(command_line), + include_empty_command_lines(include_empty_command_lines) {} + + bool operator()(const base::FilePath& path) const { base::string16 shortcut_command_line; if (!IsChromeShortcut(path, chrome_exe, &shortcut_command_line)) - continue; + return false; // TODO(asvitkine): Change this to build a CommandLine object and ensure all // args from |command_line| are present in the shortcut's CommandLine. This // will be more robust when |command_line| contains multiple args. if ((shortcut_command_line.empty() && include_empty_command_lines) || (shortcut_command_line.find(command_line) != base::string16::npos)) { - paths->push_back(path); + return true; } + return false; } +}; + +// Get the file paths of desktop files and folders optionally filtered +// by |filter|. +std::set<base::FilePath> ListUserDesktopContents( + const ChromeCommandLineFilter* filter) { + std::set<base::FilePath> result; + + base::FilePath user_shortcuts_directory; + if (!GetDesktopShortcutsDirectories(&user_shortcuts_directory, nullptr)) + return result; + + base::FileEnumerator enumerator( + user_shortcuts_directory, false, + base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); + for (base::FilePath path = enumerator.Next(); !path.empty(); + path = enumerator.Next()) { + if (!filter || (*filter)(path)) + result.insert(path); + } + return result; } // Renames the given desktop shortcut and informs the shell of this change. @@ -337,9 +362,20 @@ // Renames an existing Chrome desktop profile shortcut. Must be called on the // FILE thread. +// |profile_shortcuts| are Chrome desktop shortcuts for the profile (there can +// be several). +// |desktop_contents| is the collection of all user desktop shortcuts +// (not only Chrome). It is used to make an unique shortcut for the +// |new_profile_name| among all shortcuts. +// This function updates |profile_shortcuts| and |desktop_contents| respectively +// when renaming occurs. void RenameChromeDesktopShortcutForProfile( - const base::string16& old_shortcut_filename, - const base::string16& new_shortcut_filename) { + const base::string16& old_profile_name, + const base::string16& new_profile_name, + std::set<base::FilePath>* profile_shortcuts, + std::set<base::FilePath>* desktop_contents) { + DCHECK(profile_shortcuts); + DCHECK(desktop_contents); DCHECK_CURRENTLY_ON(BrowserThread::FILE); base::FilePath user_shortcuts_directory; @@ -349,32 +385,70 @@ return; } - const base::FilePath old_shortcut_path = - user_shortcuts_directory.Append(old_shortcut_filename); + BrowserDistribution* distribution = BrowserDistribution::GetDistribution(); + + // Get a new unique shortcut name. + const base::string16 new_shortcut_filename = + profiles::internal::GetUniqueShortcutFilenameForProfile( + new_profile_name, *desktop_contents, distribution); const base::FilePath new_shortcut_path = user_shortcuts_directory.Append(new_shortcut_filename); - if (base::PathExists(old_shortcut_path)) { + if (!profile_shortcuts->empty()) { + // From all profile_shortcuts choose the one with a known (canonical) name. + profiles::internal::ShortcutFilenameMatcher matcher(old_profile_name, + distribution); + auto it = std::find_if(profile_shortcuts->begin(), profile_shortcuts->end(), + [&matcher](const base::FilePath& p) { + return matcher.IsCanonical(p.BaseName().value()); + }); + // If all profile_shortcuts were renamed by user, respect it and do not + // rename. + if (it == profile_shortcuts->end()) + return; + const base::FilePath old_shortcut_path = *it; + // Rename the old shortcut unless a system-level shortcut exists at the // destination, in which case the old shortcut is simply deleted. const base::FilePath possible_new_system_shortcut = system_shortcuts_directory.Append(new_shortcut_filename); - if (base::PathExists(possible_new_system_shortcut)) - base::DeleteFile(old_shortcut_path, false); - else if (!RenameDesktopShortcut(old_shortcut_path, new_shortcut_path)) - DLOG(ERROR) << "Could not rename Windows profile desktop shortcut."; + if (base::PathExists(possible_new_system_shortcut)) { + if (base::DeleteFile(old_shortcut_path, false)) { + profile_shortcuts->erase(old_shortcut_path); + desktop_contents->erase(old_shortcut_path); + } else { + DLOG(ERROR) << "Could not delete Windows profile desktop shortcut."; + } + } else { + if (RenameDesktopShortcut(old_shortcut_path, new_shortcut_path)) { + profile_shortcuts->erase(old_shortcut_path); + desktop_contents->erase(old_shortcut_path); + profile_shortcuts->insert(new_shortcut_path); + desktop_contents->insert(new_shortcut_path); + } else { + DLOG(ERROR) << "Could not rename Windows profile desktop shortcut."; + } + } } else { - // If the shortcut does not exist, it may have been renamed by the user. In - // that case, its name should not be changed. + // If the shortcut does not exist, it may have been deleted by the user. // It's also possible that a system-level shortcut exists instead - this // should only be the case for the original Chrome shortcut from an // installation. If that's the case, copy that one over - it will get its // properties updated by // |CreateOrUpdateDesktopShortcutsAndIconForProfile()|. + const auto old_shortcut_filename = + profiles::internal::GetShortcutFilenameForProfile(old_profile_name, + distribution); const base::FilePath possible_old_system_shortcut = system_shortcuts_directory.Append(old_shortcut_filename); - if (base::PathExists(possible_old_system_shortcut)) - base::CopyFile(possible_old_system_shortcut, new_shortcut_path); + if (base::PathExists(possible_old_system_shortcut)) { + if (base::CopyFile(possible_old_system_shortcut, new_shortcut_path)) { + profile_shortcuts->insert(new_shortcut_path); + desktop_contents->insert(new_shortcut_path); + } else { + DLOG(ERROR) << "Could not copy Windows profile desktop shortcut."; + } + } } } @@ -430,24 +504,31 @@ // the following code may result in NOTREACHED() being hit. DCHECK(distribution->CanCreateDesktopShortcuts()); + std::set<base::FilePath> desktop_contents = ListUserDesktopContents(nullptr); + + const base::string16 command_line = + profiles::internal::CreateProfileShortcutFlags(params.profile_path); + ChromeCommandLineFilter filter( + chrome_exe, command_line, + params.action == ProfileShortcutManagerWin::UPDATE_NON_PROFILE_SHORTCUTS); + + std::set<base::FilePath> shortcuts; + // Do not call ListUserDesktopContents again (but with filter) to avoid + // excess work inside it. Just reuse non-filtered desktop_contents. + // We need both of them (desktop_contents and shortcuts) later. + std::copy_if(desktop_contents.begin(), desktop_contents.end(), + std::inserter(shortcuts, shortcuts.begin()), filter); + if (params.old_profile_name != params.profile_name) { - const base::string16 old_shortcut_filename = - profiles::internal::GetShortcutFilenameForProfile( - params.old_profile_name, - distribution); - const base::string16 new_shortcut_filename = - profiles::internal::GetShortcutFilenameForProfile(params.profile_name, - distribution); - RenameChromeDesktopShortcutForProfile(old_shortcut_filename, - new_shortcut_filename); + RenameChromeDesktopShortcutForProfile(params.old_profile_name, + params.profile_name, &shortcuts, + &desktop_contents); } ShellUtil::ShortcutProperties properties(ShellUtil::CURRENT_USER); installer::Product product(distribution); product.AddDefaultShortcutProperties(chrome_exe, &properties); - const base::string16 command_line = - profiles::internal::CreateProfileShortcutFlags(params.profile_path); // Only set the profile-specific properties when |profile_name| is non empty. // If it is empty, it means the shortcut being created should be a regular, @@ -467,22 +548,17 @@ ShellUtil::ShortcutOperation operation = ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING; - std::vector<base::FilePath> shortcuts; - ListDesktopShortcutsWithCommandLine(chrome_exe, command_line, - params.action == ProfileShortcutManagerWin::UPDATE_NON_PROFILE_SHORTCUTS, - &shortcuts); if (params.create_mode == ProfileShortcutManagerWin::CREATE_WHEN_NONE_FOUND && shortcuts.empty()) { const base::string16 shortcut_name = - profiles::internal::GetShortcutFilenameForProfile(params.profile_name, - distribution); - shortcuts.push_back(base::FilePath(shortcut_name)); + profiles::internal::GetUniqueShortcutFilenameForProfile( + params.profile_name, desktop_contents, distribution); + shortcuts.insert(base::FilePath(shortcut_name)); operation = ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL; } - for (size_t i = 0; i < shortcuts.size(); ++i) { - const base::FilePath shortcut_name = - shortcuts[i].BaseName().RemoveExtension(); + for (const auto& shortcut : shortcuts) { + const base::FilePath shortcut_name = shortcut.BaseName().RemoveExtension(); properties.set_shortcut_name(shortcut_name.value()); ShellUtil::CreateOrUpdateShortcut(ShellUtil::SHORTCUT_LOCATION_DESKTOP, distribution, properties, operation); @@ -523,20 +599,18 @@ const base::string16 command_line = profiles::internal::CreateProfileShortcutFlags(profile_path); - std::vector<base::FilePath> shortcuts; - ListDesktopShortcutsWithCommandLine(chrome_exe, command_line, false, - &shortcuts); + ChromeCommandLineFilter filter(chrome_exe, command_line, false); + const std::set<base::FilePath> shortcuts = ListUserDesktopContents(&filter); - for (size_t i = 0; i < shortcuts.size(); ++i) { + for (const auto& shortcut : shortcuts) { // Use base::DeleteFile() instead of ShellUtil::RemoveShortcuts(), as the // latter causes non-profile taskbar shortcuts to be removed since it // doesn't consider the command-line of the shortcuts it deletes. // TODO(huangs): Refactor with ShellUtil::RemoveShortcuts(). - base::win::UnpinShortcutFromTaskbar(shortcuts[i]); - base::DeleteFile(shortcuts[i], false); + base::win::UnpinShortcutFromTaskbar(shortcut); + base::DeleteFile(shortcut, false); // Notify the shell that the shortcut was deleted to ensure desktop refresh. - SHChangeNotify(SHCNE_DELETE, SHCNF_PATH, shortcuts[i].value().c_str(), - NULL); + SHChangeNotify(SHCNE_DELETE, SHCNF_PATH, shortcut.value().c_str(), nullptr); } // If |ensure_shortcuts_remain| is true and deleting this profile caused the @@ -574,10 +648,8 @@ const base::string16 command_line = profiles::internal::CreateProfileShortcutFlags(profile_path); - std::vector<base::FilePath> shortcuts; - ListDesktopShortcutsWithCommandLine(chrome_exe, command_line, false, - &shortcuts); - return !shortcuts.empty(); + ChromeCommandLineFilter filter(chrome_exe, command_line, false); + return !ListUserDesktopContents(&filter).empty(); } // Replaces any reserved characters with spaces, and trims the resulting string @@ -645,6 +717,60 @@ return shortcut_name + installer::kLnkExt; } +base::string16 GetUniqueShortcutFilenameForProfile( + const base::string16& profile_name, + const std::set<base::FilePath>& excludes, + BrowserDistribution* distribution) { + std::set<base::string16> excludes_names; + std::transform(excludes.begin(), excludes.end(), + std::inserter(excludes_names, excludes_names.begin()), + [](const base::FilePath& e) { return e.BaseName().value(); }); + + const auto base_name = + GetShortcutFilenameForProfile(profile_name, distribution); + auto name = base_name; + const base::FilePath base_path(base_name); + for (int uniquifier = 1; excludes_names.count(name) > 0; ++uniquifier) { + const auto suffix = base::StringPrintf(" (%d)", uniquifier); + name = base_path.InsertBeforeExtensionASCII(suffix).value(); + } + return name; +} + +// Corresponds to GetUniqueShortcutFilenameForProfile. +ShortcutFilenameMatcher::ShortcutFilenameMatcher( + const base::string16& profile_name, + BrowserDistribution* distribution) + : profile_shortcut_filename_( + GetShortcutFilenameForProfile(profile_name, distribution)), + lnk_ext_(installer::kLnkExt), + profile_shortcut_name_(profile_shortcut_filename_) { + DCHECK(profile_shortcut_name_.ends_with(lnk_ext_)); + profile_shortcut_name_.remove_suffix(lnk_ext_.size()); +} + +bool ShortcutFilenameMatcher::IsCanonical( + const base::string16& filename) const { + if (filename == profile_shortcut_filename_) + return true; + + base::StringPiece16 shortcut_suffix(filename); + if (!shortcut_suffix.starts_with(profile_shortcut_name_)) + return false; + shortcut_suffix.remove_prefix(profile_shortcut_name_.size()); + + if (!shortcut_suffix.ends_with(lnk_ext_)) + return false; + shortcut_suffix.remove_suffix(lnk_ext_.size()); + + if (shortcut_suffix.size() < 4 || !shortcut_suffix.starts_with(L" (") || + !shortcut_suffix.ends_with(L")")) { + return false; + } + return std::all_of(shortcut_suffix.begin() + 2, shortcut_suffix.end() - 1, + iswdigit); +} + base::string16 CreateProfileShortcutFlags(const base::FilePath& profile_path) { return base::StringPrintf(L"--%ls=\"%ls\"", base::ASCIIToUTF16(
diff --git a/chrome/browser/profiles/profile_shortcut_manager_win.h b/chrome/browser/profiles/profile_shortcut_manager_win.h index a7ed610..9bd93d696 100644 --- a/chrome/browser/profiles/profile_shortcut_manager_win.h +++ b/chrome/browser/profiles/profile_shortcut_manager_win.h
@@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_ #define CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_ +#include <set> + #include "base/callback.h" #include "base/macros.h" #include "chrome/browser/profiles/profile_shortcut_manager.h" @@ -26,6 +28,31 @@ base::string16 GetShortcutFilenameForProfile(const base::string16& profile_name, BrowserDistribution* distribution); +// The same as GetShortcutFilenameForProfile but uniqueness is guaranteed. +// Makes an unique filename among |excludes|. +base::string16 GetUniqueShortcutFilenameForProfile( + const base::string16& profile_name, + const std::set<base::FilePath>& excludes, + BrowserDistribution* distribution); + +// This class checks that shortcut filename matches certain profile. +class ShortcutFilenameMatcher { + public: + ShortcutFilenameMatcher(const base::string16& profile_name, + BrowserDistribution* distribution); + + // Check that shortcut filename has a name given by us (by + // GetShortcutFilenameForProfile or GetUniqueShortcutFilenameForProfile). + bool IsCanonical(const base::string16& filename) const; + + private: + const base::string16 profile_shortcut_filename_; + const base::StringPiece16 lnk_ext_; + base::StringPiece16 profile_shortcut_name_; + + DISALLOW_COPY_AND_ASSIGN(ShortcutFilenameMatcher); +}; + // Returns the command-line flags to launch Chrome with the given profile. base::string16 CreateProfileShortcutFlags(const base::FilePath& profile_path);
diff --git a/chrome/browser/push_messaging/push_messaging_service_impl.cc b/chrome/browser/push_messaging/push_messaging_service_impl.cc index 014a95c8..b490beb 100644 --- a/chrome/browser/push_messaging/push_messaging_service_impl.cc +++ b/chrome/browser/push_messaging/push_messaging_service_impl.cc
@@ -68,11 +68,11 @@ blink::WebPushPermissionStatus ToPushPermission( content::PermissionStatus permission_status) { switch (permission_status) { - case content::PERMISSION_STATUS_GRANTED: + case content::PermissionStatus::GRANTED: return blink::WebPushPermissionStatusGranted; - case content::PERMISSION_STATUS_DENIED: + case content::PermissionStatus::DENIED: return blink::WebPushPermissionStatusDenied; - case content::PERMISSION_STATUS_ASK: + case content::PermissionStatus::ASK: return blink::WebPushPermissionStatusPrompt; default: NOTREACHED(); @@ -523,7 +523,7 @@ const std::string& sender_id, const content::PushMessagingService::RegisterCallback& register_callback, content::PermissionStatus permission_status) { - if (permission_status != content::PERMISSION_STATUS_GRANTED) { + if (permission_status != content::PermissionStatus::GRANTED) { SubscribeEndWithError(register_callback, content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED); return;
diff --git a/chrome/browser/resources/md_downloads/crisper.js b/chrome/browser/resources/md_downloads/crisper.js index 9ed789aa..4741e55 100644 --- a/chrome/browser/resources/md_downloads/crisper.js +++ b/chrome/browser/resources/md_downloads/crisper.js
@@ -13040,7 +13040,8 @@ observeIsDangerous_: function() { if (this.data && !this.isDangerous_) { var filePath = encodeURIComponent(this.data.file_path); - this.$['file-icon'].src = 'chrome://fileicon/' + filePath; + var scaleFactor = '?scale=' + window.devicePixelRatio + 'x'; + this.$['file-icon'].src = 'chrome://fileicon/' + filePath + scaleFactor; } },
diff --git a/chrome/browser/resources/md_downloads/item.js b/chrome/browser/resources/md_downloads/item.js index 5dfba3b..2838b0c 100644 --- a/chrome/browser/resources/md_downloads/item.js +++ b/chrome/browser/resources/md_downloads/item.js
@@ -265,7 +265,8 @@ observeIsDangerous_: function() { if (this.data && !this.isDangerous_) { var filePath = encodeURIComponent(this.data.file_path); - this.$['file-icon'].src = 'chrome://fileicon/' + filePath; + var scaleFactor = '?scale=' + window.devicePixelRatio + 'x'; + this.$['file-icon'].src = 'chrome://fileicon/' + filePath + scaleFactor; } },
diff --git a/chrome/browser/resources/options/chromeos/display_options.js b/chrome/browser/resources/options/chromeos/display_options.js index 462b84f..9b48940 100644 --- a/chrome/browser/resources/options/chromeos/display_options.js +++ b/chrome/browser/resources/options/chromeos/display_options.js
@@ -6,20 +6,50 @@ /** * @typedef {{ - * availableColorProfiles: Array<{profileId: number, name: string}>, - * colorProfile: number, + * left: number, + * top: number, + * width: number, + * height: number + * }} + */ +options.DisplayBounds; + +/** + * @typedef {{ + * width: number, * height: number, + * originalWidth: number, + * originalHeight: number, + * deviceScaleFactor: number, + * scale: number, + * refreshRate: number, + * isBest: boolean, + * selected: boolean + * }} + */ +options.DisplayMode; + +/** + * @typedef {{ + * profileId: number, + * name: string + * }} + */ +options.ColorProfile; + +/** + * @typedef {{ + * availableColorProfiles: !Array<!options.ColorProfile>, + * bounds: options.DisplayBounds, + * colorProfileId: number, + * div: ?Element, * id: string, * isInternal: boolean, * isPrimary: boolean, - * resolutions: Array<{width: number, height: number, originalWidth: number, - * originalHeight: number, deviceScaleFactor: number, scale: number, - * refreshRate: number, isBest: boolean, selected: boolean}>, + * resolutions: !Array<!options.DisplayMode>, * name: string, - * orientation: number, - * width: number, - * x: number, - * y: number + * rotation: number, + * originalPosition: ?{x: number, y: number} * }} */ options.DisplayInfo; @@ -148,7 +178,7 @@ /** * The array of current output displays. It also contains the display * rectangles currently rendered on screen. - * @type {Array<options.DisplayInfo>} + * @type {!Array<!options.DisplayInfo>} * @private */ displays_: [], @@ -161,13 +191,15 @@ focusedIndex_: null, /** - * The primary display. + * The primary display edit info. + * @type {?options.DisplayInfo} * @private */ primaryDisplay_: null, /** - * The secondary display. + * The secondary display edit info. + * @type {?options.DisplayInfo} * @private */ secondaryDisplay_: null, @@ -226,8 +258,8 @@ $('display-options-orientation-selection').onchange = (function(ev) { var displayIndex = (this.focusedIndex_ === null) ? 0 : this.focusedIndex_; - chrome.send('setOrientation', [this.displays_[displayIndex].id, - ev.target.value]); + var rotation = parseInt(ev.target.value, 10); + chrome.send('setRotation', [this.displays_[displayIndex].id, rotation]); }).bind(this); $('display-options-color-profile-selection').onchange = (function(ev) { chrome.send('setColorProfile', [this.displays_[this.focusedIndex_].id, @@ -647,13 +679,14 @@ var orientation = $('display-options-orientation-selection'); orientation.disabled = false; var orientationOptions = orientation.getElementsByTagName('option'); - orientationOptions[display.orientation].selected = true; + var orientationIndex = Math.floor(display.rotation / 90); + orientationOptions[orientationIndex].selected = true; $('selected-display-name').textContent = loadTimeData.getString('mirroringDisplay'); var resolution = $('display-options-resolution-selection'); var option = document.createElement('option'); option.value = 'default'; - option.textContent = display.width + 'x' + display.height; + option.textContent = display.bounds.width + 'x' + display.bounds.height; resolution.appendChild(option); resolution.disabled = true; }, @@ -701,7 +734,8 @@ orientation.disabled = this.unifiedDesktopEnabled_; var orientationOptions = orientation.getElementsByTagName('option'); - orientationOptions[display.orientation].selected = true; + var orientationIndex = Math.floor(display.rotation / 90); + orientationOptions[orientationIndex].selected = true; $('selected-display-name').textContent = display.name; @@ -709,7 +743,7 @@ if (display.resolutions.length <= 1) { var option = document.createElement('option'); option.value = 'default'; - option.textContent = display.width + 'x' + display.height; + option.textContent = display.bounds.width + 'x' + display.bounds.height; option.selected = true; resolution.appendChild(option); resolution.disabled = true; @@ -750,8 +784,7 @@ var colorProfile = display.availableColorProfiles[i]; option.value = colorProfile.profileId; option.textContent = colorProfile.name; - option.selected = ( - display.colorProfile == colorProfile.profileId); + option.selected = (display.colorProfileId == colorProfile.profileId); profiles.appendChild(option); } } @@ -807,8 +840,9 @@ /** @const */ var MIRRORING_VERTICAL_MARGIN = 20; // The width/height should be same as the first display: - var width = Math.ceil(this.displays_[0].width * this.visualScale_); - var height = Math.ceil(this.displays_[0].height * this.visualScale_); + var width = Math.ceil(this.displays_[0].bounds.width * this.visualScale_); + var height = + Math.ceil(this.displays_[0].bounds.height * this.visualScale_); var numDisplays = Math.max(MIN_NUM_DISPLAYS, this.displays_.length); @@ -838,7 +872,7 @@ /** * Creates a div element representing the specified display. - * @param {Object} display The display object. + * @param {!options.DisplayInfo} display The display object. * @param {boolean} focused True if it's focused. * @private */ @@ -856,8 +890,9 @@ var nameContainer = document.createElement('div'); nameContainer.textContent = display.name; div.appendChild(nameContainer); - div.style.width = Math.floor(display.width * this.visualScale_) + 'px'; - var newHeight = Math.floor(display.height * this.visualScale_); + div.style.width = + Math.floor(display.bounds.width * this.visualScale_) + 'px'; + var newHeight = Math.floor(display.bounds.height * this.visualScale_); div.style.height = newHeight + 'px'; nameContainer.style.marginTop = (newHeight - nameContainer.offsetHeight) / 2 + 'px'; @@ -887,14 +922,15 @@ if (i == this.focusedIndex_) focusedDisplay = display; - boundingBox.left = Math.min(boundingBox.left, display.x); - boundingBox.right = Math.max( - boundingBox.right, display.x + display.width); - boundingBox.top = Math.min(boundingBox.top, display.y); - boundingBox.bottom = Math.max( - boundingBox.bottom, display.y + display.height); - maxWidth = Math.max(maxWidth, display.width); - maxHeight = Math.max(maxHeight, display.height); + var bounds = display.bounds; + boundingBox.left = Math.min(boundingBox.left, bounds.left); + boundingBox.right = + Math.max(boundingBox.right, bounds.left + bounds.width); + boundingBox.top = Math.min(boundingBox.top, bounds.top); + boundingBox.bottom = + Math.max(boundingBox.bottom, bounds.top + bounds.height); + maxWidth = Math.max(maxWidth, bounds.width); + maxHeight = Math.max(maxHeight, bounds.height); } if (!this.primaryDisplay_) return; @@ -914,9 +950,11 @@ // Centering the bounding box of the display rectangles. var offset = { - x: Math.floor(this.displaysView_.offsetWidth / 2 - + x: Math.floor( + this.displaysView_.offsetWidth / 2 - (boundingBox.right + boundingBox.left) * this.visualScale_ / 2), - y: Math.floor(this.displaysView_.offsetHeight / 2 - + y: Math.floor( + this.displaysView_.offsetHeight / 2 - (boundingBox.bottom + boundingBox.top) * this.visualScale_ / 2) }; @@ -925,13 +963,15 @@ var primaryDiv = this.createDisplayRectangle_( this.primaryDisplay_, this.primaryDisplay_ == focusedDisplay); primaryDiv.style.left = - Math.floor(this.primaryDisplay_.x * this.visualScale_) + - offset.x + 'px'; + Math.floor(this.primaryDisplay_.bounds.left * this.visualScale_) + + offset.x + 'px'; primaryDiv.style.top = - Math.floor(this.primaryDisplay_.y * this.visualScale_) + - offset.y + 'px'; + Math.floor(this.primaryDisplay_.bounds.top * this.visualScale_) + + offset.y + 'px'; this.primaryDisplay_.originalPosition = { - x: primaryDiv.offsetLeft, y: primaryDiv.offsetTop}; + x: primaryDiv.offsetLeft, + y: primaryDiv.offsetTop + }; if (this.secondaryDisplay_) { var secondaryDiv = this.createDisplayRectangle_( @@ -939,38 +979,37 @@ // Don't trust the secondary display's x or y, because it may cause a // 1px gap due to rounding, which will create a fake update on end // dragging. See crbug.com/386401 + var bounds = this.secondaryDisplay_.bounds; switch (this.layout_) { - case options.SecondaryDisplayLayout.TOP: - secondaryDiv.style.left = - Math.floor(this.secondaryDisplay_.x * this.visualScale_) + - offset.x + 'px'; - secondaryDiv.style.top = - primaryDiv.offsetTop - secondaryDiv.offsetHeight + 'px'; - break; - case options.SecondaryDisplayLayout.RIGHT: - secondaryDiv.style.left = - primaryDiv.offsetLeft + primaryDiv.offsetWidth + 'px'; - secondaryDiv.style.top = - Math.floor(this.secondaryDisplay_.y * this.visualScale_) + - offset.y + 'px'; - break; - case options.SecondaryDisplayLayout.BOTTOM: - secondaryDiv.style.left = - Math.floor(this.secondaryDisplay_.x * this.visualScale_) + - offset.x + 'px'; - secondaryDiv.style.top = - primaryDiv.offsetTop + primaryDiv.offsetHeight + 'px'; - break; - case options.SecondaryDisplayLayout.LEFT: - secondaryDiv.style.left = - primaryDiv.offsetLeft - secondaryDiv.offsetWidth + 'px'; - secondaryDiv.style.top = - Math.floor(this.secondaryDisplay_.y * this.visualScale_) + - offset.y + 'px'; - break; + case options.SecondaryDisplayLayout.TOP: + secondaryDiv.style.left = + Math.floor(bounds.left * this.visualScale_) + offset.x + 'px'; + secondaryDiv.style.top = + primaryDiv.offsetTop - secondaryDiv.offsetHeight + 'px'; + break; + case options.SecondaryDisplayLayout.RIGHT: + secondaryDiv.style.left = + primaryDiv.offsetLeft + primaryDiv.offsetWidth + 'px'; + secondaryDiv.style.top = + Math.floor(bounds.top * this.visualScale_) + offset.y + 'px'; + break; + case options.SecondaryDisplayLayout.BOTTOM: + secondaryDiv.style.left = + Math.floor(bounds.left * this.visualScale_) + offset.x + 'px'; + secondaryDiv.style.top = + primaryDiv.offsetTop + primaryDiv.offsetHeight + 'px'; + break; + case options.SecondaryDisplayLayout.LEFT: + secondaryDiv.style.left = + primaryDiv.offsetLeft - secondaryDiv.offsetWidth + 'px'; + secondaryDiv.style.top = + Math.floor(bounds.top * this.visualScale_) + offset.y + 'px'; + break; } this.secondaryDisplay_.originalPosition = { - x: secondaryDiv.offsetLeft, y: secondaryDiv.offsetTop}; + x: secondaryDiv.offsetLeft, + y: secondaryDiv.offsetTop + }; } },
diff --git a/chrome/browser/sync/profile_sync_service_startup_unittest.cc b/chrome/browser/sync/profile_sync_service_startup_unittest.cc index 2876157..c37ffeb 100644 --- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
@@ -16,7 +16,6 @@ #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/sync/chrome_sync_client.h" #include "chrome/browser/sync/profile_sync_service_factory.h" -#include "chrome/browser/sync/profile_sync_test_util.h" #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" #include "chrome/common/channel_info.h" #include "chrome/common/pref_names.h" @@ -24,6 +23,7 @@ #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile_manager.h" #include "components/browser_sync/browser/profile_sync_service.h" +#include "components/browser_sync/browser/profile_sync_test_util.h" #include "components/signin/core/browser/account_tracker_service.h" #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" #include "components/signin/core/browser/profile_oauth2_token_service.h" @@ -75,7 +75,7 @@ init_params.start_behavior = start_behavior; init_params.sync_client = std::move(sync_client); init_params.network_time_update_callback = - base::Bind(&EmptyNetworkTimeUpdate); + base::Bind(&browser_sync::EmptyNetworkTimeUpdate); init_params.base_directory = profile->GetPath(); init_params.url_request_context = profile->GetRequestContext(); init_params.debug_identifier = profile->GetDebugName(); @@ -243,7 +243,7 @@ TestingProfileManager profile_manager_; TestingProfile* profile_; ProfileSyncService* sync_; - SyncServiceObserverMock observer_; + browser_sync::SyncServiceObserverMock observer_; sync_driver::DataTypeStatusTable data_type_status_table_; };
diff --git a/chrome/browser/sync/profile_sync_test_util.cc b/chrome/browser/sync/profile_sync_test_util.cc index 143ca63..5ace716 100644 --- a/chrome/browser/sync/profile_sync_test_util.cc +++ b/chrome/browser/sync/profile_sync_test_util.cc
@@ -15,6 +15,7 @@ #include "chrome/common/channel_info.h" #include "chrome/test/base/testing_profile.h" #include "components/browser_sync/browser/profile_sync_service.h" +#include "components/browser_sync/browser/profile_sync_test_util.h" #include "components/signin/core/browser/signin_manager.h" #include "components/sync_driver/signin_manager_wrapper.h" #include "components/sync_driver/startup_controller.h" @@ -22,16 +23,6 @@ using content::BrowserThread; -void EmptyNetworkTimeUpdate(const base::Time&, - const base::TimeDelta&, - const base::TimeDelta&) {} - -SyncServiceObserverMock::SyncServiceObserverMock() { -} - -SyncServiceObserverMock::~SyncServiceObserverMock() { -} - ThreadNotifier::ThreadNotifier(base::Thread* notify_thread) : done_event_(false, false), notify_thread_(notify_thread) {} @@ -86,7 +77,7 @@ init_params.start_behavior = browser_sync::MANUAL_START; init_params.sync_client = std::move(sync_client); init_params.network_time_update_callback = - base::Bind(&EmptyNetworkTimeUpdate); + base::Bind(&browser_sync::EmptyNetworkTimeUpdate); init_params.base_directory = profile->GetPath(); init_params.url_request_context = profile->GetRequestContext(); init_params.debug_identifier = profile->GetDebugName();
diff --git a/chrome/browser/sync/profile_sync_test_util.h b/chrome/browser/sync/profile_sync_test_util.h index db21a95..928ced7 100644 --- a/chrome/browser/sync/profile_sync_test_util.h +++ b/chrome/browser/sync/profile_sync_test_util.h
@@ -12,19 +12,12 @@ #include "base/message_loop/message_loop.h" #include "base/synchronization/waitable_event.h" #include "components/browser_sync/browser/profile_sync_service_mock.h" -#include "components/sync_driver/sync_service_observer.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" #include "testing/gmock/include/gmock/gmock.h" -namespace base { -class Thread; -class Time; -class TimeDelta; -} - namespace content { class BrowserContext; } @@ -38,12 +31,6 @@ class ProfileSyncServiceMock; class TestingProfile; -// An empty syncer::NetworkTimeUpdateCallback. Used in various tests to -// instantiate ProfileSyncService. -void EmptyNetworkTimeUpdate(const base::Time&, - const base::TimeDelta&, - const base::TimeDelta&); - ACTION_P(Notify, type) { content::NotificationService::current()->Notify( type, @@ -56,14 +43,6 @@ base::MessageLoop::current()->QuitWhenIdle(); } -class SyncServiceObserverMock : public sync_driver::SyncServiceObserver { - public: - SyncServiceObserverMock(); - virtual ~SyncServiceObserverMock(); - - MOCK_METHOD0(OnStateChanged, void()); -}; - class ThreadNotifier : // NOLINT public base::RefCountedThreadSafe<ThreadNotifier> { public:
diff --git a/chrome/browser/sync/test_profile_sync_service.cc b/chrome/browser/sync/test_profile_sync_service.cc index 1d2c8282..6c3b9d4 100644 --- a/chrome/browser/sync/test_profile_sync_service.cc +++ b/chrome/browser/sync/test_profile_sync_service.cc
@@ -17,9 +17,9 @@ #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/sync/chrome_sync_client.h" #include "chrome/browser/sync/profile_sync_service_factory.h" -#include "chrome/browser/sync/profile_sync_test_util.h" #include "chrome/browser/sync/test/test_http_bridge_factory.h" #include "chrome/common/channel_info.h" +#include "components/browser_sync/browser/profile_sync_test_util.h" #include "components/invalidation/impl/profile_invalidation_provider.h" #include "components/signin/core/browser/signin_manager.h" #include "components/sync_driver/glue/sync_backend_host.h" @@ -46,13 +46,26 @@ SigninManagerBase* signin, ProfileOAuth2TokenService* oauth2_token_service, browser_sync::ProfileSyncServiceStartBehavior behavior) { - ProfileSyncService::InitParams init_params = - CreateProfileSyncServiceParamsForTest(profile); + ProfileSyncService::InitParams init_params; init_params.signin_wrapper = make_scoped_ptr(new SigninManagerWrapper(signin)); init_params.oauth2_token_service = oauth2_token_service; init_params.start_behavior = behavior; + init_params.sync_client = + make_scoped_ptr(new browser_sync::ChromeSyncClient(profile)); + init_params.network_time_update_callback = + base::Bind(&browser_sync::EmptyNetworkTimeUpdate); + init_params.base_directory = profile->GetPath(); + init_params.url_request_context = profile->GetRequestContext(); + init_params.debug_identifier = profile->GetDebugName(); + init_params.channel = chrome::GetChannel(); + init_params.db_thread = content::BrowserThread::GetMessageLoopProxyForThread( + content::BrowserThread::DB); + init_params.file_thread = + content::BrowserThread::GetMessageLoopProxyForThread( + content::BrowserThread::FILE); + init_params.blocking_pool = content::BrowserThread::GetBlockingPool(); return init_params; }
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index 4ac1c60..33afb5f 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -201,6 +201,7 @@ deps += [ "//chrome/browser/chromeos", "//components/arc", + "//ui/base/ime", ] } else { defines += [ "FRAME_AVATAR_BUTTON=1" ] @@ -397,6 +398,8 @@ "//third_party/isimpledom", "//third_party/wtl", "//ui/app_list", + "//ui/base/ime", + "//ui/events:dom_keycode_converter", ] if (!is_chrome_branded) { deps -= [ "//google_update" ] @@ -418,6 +421,10 @@ sources += rebase_path(gypi_values.chrome_browser_ui_desktop_linux_sources, ".", "//chrome") + deps += [ + "//ui/base/ime", + "//ui/events:dom_keycode_converter", + ] } if (is_linux) { # Both desktop Linux and ChromeOS. sources += rebase_path(gypi_values.chrome_browser_ui_linux_sources,
diff --git a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc index b754f50..0eff178 100644 --- a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc +++ b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc
@@ -411,8 +411,7 @@ mojo::Array<uint8_t> icon_png_data) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_NE(0u, icon_png_data.size()); - DCHECK(scale_factor >= arc::SCALE_FACTOR_SCALE_FACTOR_100P && - scale_factor < arc::SCALE_FACTOR_NUM_SCALE_FACTORS); + DCHECK(arc::ScaleFactor_IsValidValue(scale_factor)); std::string app_id = GetAppId(package, activity); if (!IsRegistered(app_id)) {
diff --git a/chrome/browser/input_method/OWNERS b/chrome/browser/ui/input_method/OWNERS similarity index 100% rename from chrome/browser/input_method/OWNERS rename to chrome/browser/ui/input_method/OWNERS
diff --git a/chrome/browser/ui/input_method/input_method_engine.cc b/chrome/browser/ui/input_method/input_method_engine.cc new file mode 100644 index 0000000..a03580c9 --- /dev/null +++ b/chrome/browser/ui/input_method/input_method_engine.cc
@@ -0,0 +1,28 @@ +// 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 "chrome/browser/ui/input_method/input_method_engine.h" + +namespace input_method { + +InputMethodEngine::InputMethodEngine() {} + +InputMethodEngine::~InputMethodEngine() {} + +bool InputMethodEngine::SendKeyEvents( + int context_id, + const std::vector<KeyboardEvent>& events) { + // TODO(azurewei) Implement SendKeyEvents funciton + return false; +} + +bool InputMethodEngine::IsActive() const { + return true; +} + +std::string InputMethodEngine::GetExtensionId() const { + return extension_id_; +} + +} // namespace input_method
diff --git a/chrome/browser/ui/input_method/input_method_engine.h b/chrome/browser/ui/input_method/input_method_engine.h new file mode 100644 index 0000000..273213d --- /dev/null +++ b/chrome/browser/ui/input_method/input_method_engine.h
@@ -0,0 +1,32 @@ +// 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 CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ +#define CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ + +#include <string> +#include <vector> + +#include "chrome/browser/ui/input_method/input_method_engine_base.h" + +namespace input_method { +class InputMethodEngine : public InputMethodEngineBase { + public: + InputMethodEngine(); + + ~InputMethodEngine() override; + + // ui::IMEEngineHandlerInterface: + bool SendKeyEvents(int context_id, + const std::vector<KeyboardEvent>& events) override; + bool IsActive() const override; + std::string GetExtensionId() const override; + + private: + DISALLOW_COPY_AND_ASSIGN(InputMethodEngine); +}; + +} // namespace input_method + +#endif // CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_H_
diff --git a/chrome/browser/input_method/input_method_engine_base.cc b/chrome/browser/ui/input_method/input_method_engine_base.cc similarity index 99% rename from chrome/browser/input_method/input_method_engine_base.cc rename to chrome/browser/ui/input_method/input_method_engine_base.cc index f74f376f..6cd3a64 100644 --- a/chrome/browser/input_method/input_method_engine_base.cc +++ b/chrome/browser/ui/input_method/input_method_engine_base.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/input_method/input_method_engine_base.h" +#include "chrome/browser/ui/input_method/input_method_engine_base.h" #undef FocusIn #undef FocusOut
diff --git a/chrome/browser/input_method/input_method_engine_base.h b/chrome/browser/ui/input_method/input_method_engine_base.h similarity index 96% rename from chrome/browser/input_method/input_method_engine_base.h rename to chrome/browser/ui/input_method/input_method_engine_base.h index 406bb6d..28ef642 100644 --- a/chrome/browser/input_method/input_method_engine_base.h +++ b/chrome/browser/ui/input_method/input_method_engine_base.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_ -#define CHROME_BROWSER_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_ +#ifndef CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_ +#define CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_ #include <map> #include <string> @@ -196,4 +196,4 @@ } // namespace input_method -#endif // CHROME_BROWSER_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_ +#endif // CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_
diff --git a/chrome/browser/ui/views/frame/browser_frame_mus.cc b/chrome/browser/ui/views/frame/browser_frame_mus.cc index b3ff9f6..28ec7df 100644 --- a/chrome/browser/ui/views/frame/browser_frame_mus.cc +++ b/chrome/browser/ui/views/frame/browser_frame_mus.cc
@@ -38,7 +38,7 @@ browser_frame, views::WindowManagerConnection::Get()->app()->shell(), CreateMusWindow(browser_view), - mus::mojom::SURFACE_TYPE_DEFAULT), + mus::mojom::SurfaceType::DEFAULT), browser_view_(browser_view) {} BrowserFrameMus::~BrowserFrameMus() {}
diff --git a/chrome/browser/ui/views/tabs/tab_strip_unittest.cc b/chrome/browser/ui/views/tabs/tab_strip_unittest.cc index d5354bc..20835d2 100644 --- a/chrome/browser/ui/views/tabs/tab_strip_unittest.cc +++ b/chrome/browser/ui/views/tabs/tab_strip_unittest.cc
@@ -13,6 +13,7 @@ #include "chrome/browser/ui/views/tabs/tab_strip_observer.h" #include "chrome/test/base/testing_profile.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/base/material_design/material_design_controller.h" #include "ui/gfx/canvas.h" #include "ui/gfx/geometry/rect_conversions.h" #include "ui/gfx/path.h" @@ -323,6 +324,13 @@ // of hit tests against the visible/occluded regions of a tab and the tab // close button of the active tab. TEST_F(TabStripTest, TabHitTestMaskWhenStacked) { + // TODO(varkha,pkasting): Update the test for Material Design layout. + // crbug.com/575327 + if (ui::MaterialDesignController::IsModeMaterial()) { + VLOG(1) << "Test is DISABLED for material design layouts."; + return; + } + tab_strip_->SetBounds(0, 0, 300, 20); controller_->AddTab(0, false);
diff --git a/chrome/browser/ui/views/tabs/tab_unittest.cc b/chrome/browser/ui/views/tabs/tab_unittest.cc index 5929b33..f001038 100644 --- a/chrome/browser/ui/views/tabs/tab_unittest.cc +++ b/chrome/browser/ui/views/tabs/tab_unittest.cc
@@ -6,7 +6,6 @@ #include <stddef.h> -#include "base/i18n/rtl.h" #include "base/macros.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/ui/layout_constants.h" @@ -86,27 +85,10 @@ DISALLOW_COPY_AND_ASSIGN(FakeTabController); }; -class TabTest : public views::ViewsTestBase, - public ::testing::WithParamInterface<bool> { +class TabTest : public views::ViewsTestBase { public: TabTest() {} - virtual ~TabTest() {} - - bool testing_for_rtl_locale() const { return GetParam(); } - - void SetUp() override { - if (testing_for_rtl_locale()) { - original_locale_ = base::i18n::GetConfiguredLocale(); - base::i18n::SetICUDefaultLocale("he"); - } - views::ViewsTestBase::SetUp(); - } - - void TearDown() override { - views::ViewsTestBase::TearDown(); - if (testing_for_rtl_locale()) - base::i18n::SetICUDefaultLocale(original_locale_); - } + ~TabTest() override {} static views::ImageButton* GetCloseButton(const Tab& tab) { return tab.close_button_; @@ -264,12 +246,7 @@ std::string original_locale_; }; -TEST_P(TabTest, HitTestTopPixel) { - if (testing_for_rtl_locale() && !base::i18n::IsRTL()) { - LOG(WARNING) << "Testing of RTL locale not supported on current platform."; - return; - } - +TEST_F(TabTest, HitTestTopPixel) { Widget widget; InitWidget(&widget); @@ -299,12 +276,7 @@ EXPECT_FALSE(tab.HitTestPoint(gfx::Point(tab.width() - 1, 0))); } -TEST_P(TabTest, LayoutAndVisibilityOfElements) { - if (testing_for_rtl_locale() && !base::i18n::IsRTL()) { - LOG(WARNING) << "Testing of RTL locale not supported on current platform."; - return; - } - +TEST_F(TabTest, LayoutAndVisibilityOfElements) { static const TabMediaState kMediaStatesToTest[] = { TAB_MEDIA_STATE_NONE, TAB_MEDIA_STATE_CAPTURING, TAB_MEDIA_STATE_AUDIO_PLAYING, TAB_MEDIA_STATE_AUDIO_MUTING @@ -364,12 +336,7 @@ // Regression test for http://crbug.com/420313: Confirms that any child Views of // Tab do not attempt to provide their own tooltip behavior/text. It also tests // that Tab provides the expected tooltip text (according to tab_utils). -TEST_P(TabTest, TooltipProvidedByTab) { - if (testing_for_rtl_locale() && !base::i18n::IsRTL()) { - LOG(WARNING) << "Testing of RTL locale not supported on current platform."; - return; - } - +TEST_F(TabTest, TooltipProvidedByTab) { Widget widget; InitWidget(&widget); @@ -422,12 +389,7 @@ // Regression test for http://crbug.com/226253. Calling Layout() more than once // shouldn't change the insets of the close button. -TEST_P(TabTest, CloseButtonLayout) { - if (testing_for_rtl_locale() && !base::i18n::IsRTL()) { - LOG(WARNING) << "Testing of RTL locale not supported on current platform."; - return; - } - +TEST_F(TabTest, CloseButtonLayout) { FakeTabController tab_controller; Tab tab(&tab_controller); tab.SetBounds(0, 0, 100, 50); @@ -446,12 +408,7 @@ // Tests expected changes to the ThrobberView state when the WebContents loading // state changes or the animation timer (usually in BrowserView) triggers. -TEST_P(TabTest, LayeredThrobber) { - if (testing_for_rtl_locale() && !base::i18n::IsRTL()) { - LOG(WARNING) << "Testing of RTL locale not supported on current platform."; - return; - } - +TEST_F(TabTest, LayeredThrobber) { Widget widget; InitWidget(&widget); @@ -505,13 +462,7 @@ EXPECT_FALSE(throbber->visible()); } -TEST_P(TabTest, TitleHiddenWhenSmall) { - // TODO(sky): figure out if needed. - if (testing_for_rtl_locale() && !base::i18n::IsRTL()) { - LOG(WARNING) << "Testing of RTL locale not supported on current platform."; - return; - } - +TEST_F(TabTest, TitleHiddenWhenSmall) { FakeTabController tab_controller; Tab tab(&tab_controller); tab.SetBounds(0, 0, 100, 50); @@ -519,11 +470,3 @@ tab.SetBounds(0, 0, 0, 50); EXPECT_EQ(0, GetTitleWidth(tab)); } - -// Test in both a LTR and a RTL locale. Note: The fact that the UI code is -// configured for an RTL locale does *not* change how the coordinates are -// examined in the tests above because views::View and friends are supposed to -// auto-mirror the widgets when painting. Thus, what we're testing here is that -// there's no code in Tab that will erroneously subvert this automatic -// coordinate translation. http://crbug.com/384179 -INSTANTIATE_TEST_CASE_P(, TabTest, ::testing::Values(false, true));
diff --git a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc index 0d534428..6b08ae3 100644 --- a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
@@ -148,6 +148,15 @@ return result; } +base::DictionaryValue* ConvertBoundsToValue(const gfx::Rect& bounds) { + base::DictionaryValue* result = new base::DictionaryValue(); + result->SetInteger("left", bounds.x()); + result->SetInteger("top", bounds.y()); + result->SetInteger("width", bounds.width()); + result->SetInteger("height", bounds.height()); + return result; +} + } // namespace DisplayOptionsHandler::DisplayOptionsHandler() { @@ -239,8 +248,8 @@ base::Bind(&DisplayOptionsHandler::HandleSetDisplayMode, base::Unretained(this))); web_ui()->RegisterMessageCallback( - "setOrientation", - base::Bind(&DisplayOptionsHandler::HandleSetOrientation, + "setRotation", + base::Bind(&DisplayOptionsHandler::HandleSetRotation, base::Unretained(this))); web_ui()->RegisterMessageCallback( "setColorProfile", @@ -285,19 +294,16 @@ for (const gfx::Display& display : displays) { const ash::DisplayInfo& display_info = display_manager->GetDisplayInfo(display.id()); - const gfx::Rect& bounds = display.bounds(); base::DictionaryValue* js_display = new base::DictionaryValue(); js_display->SetString("id", base::Int64ToString(display.id())); - js_display->SetInteger("x", bounds.x()); - js_display->SetInteger("y", bounds.y()); - js_display->SetInteger("width", bounds.width()); - js_display->SetInteger("height", bounds.height()); js_display->SetString("name", display_manager->GetDisplayNameForId(display.id())); + base::DictionaryValue* display_bounds = + ConvertBoundsToValue(display.bounds()); + js_display->Set("bounds", display_bounds); js_display->SetBoolean("isPrimary", display.id() == primary_id); js_display->SetBoolean("isInternal", display.IsInternal()); - js_display->SetInteger("orientation", - static_cast<int>(display_info.GetActiveRotation())); + js_display->SetInteger("rotation", display.RotationAsDegree()); base::ListValue* js_resolutions = new base::ListValue(); for (const ash::DisplayMode& display_mode : display_info.display_modes()) { @@ -306,7 +312,7 @@ } js_display->Set("resolutions", js_resolutions); - js_display->SetInteger("colorProfile", display_info.color_profile()); + js_display->SetInteger("colorProfileId", display_info.color_profile()); base::ListValue* available_color_profiles = new base::ListValue(); for (const auto& color_profile : display_info.available_color_profiles()) { const base::string16 profile_name = GetColorProfileName(color_profile); @@ -425,26 +431,26 @@ base::Bind(&chromeos::StoreDisplayPrefs)); } -void DisplayOptionsHandler::HandleSetOrientation(const base::ListValue* args) { +void DisplayOptionsHandler::HandleSetRotation(const base::ListValue* args) { DCHECK(!args->empty()); int64_t display_id = GetDisplayId(args); if (display_id == gfx::Display::kInvalidDisplayID) return; - std::string rotation_value; - gfx::Display::Rotation new_rotation = gfx::Display::ROTATE_0; - if (!args->GetString(1, &rotation_value)) { - LOG(ERROR) << "Can't find new orientation"; + int rotation_value = 0; + if (!args->GetInteger(1, &rotation_value)) { + LOG(ERROR) << "Can't parse rotation: " << args; return; } - if (rotation_value == "90") + gfx::Display::Rotation new_rotation = gfx::Display::ROTATE_0; + if (rotation_value == 90) new_rotation = gfx::Display::ROTATE_90; - else if (rotation_value == "180") + else if (rotation_value == 180) new_rotation = gfx::Display::ROTATE_180; - else if (rotation_value == "270") + else if (rotation_value == 270) new_rotation = gfx::Display::ROTATE_270; - else if (rotation_value != "0") + else if (rotation_value != 0) LOG(ERROR) << "Invalid rotation: " << rotation_value << " Falls back to 0"; content::RecordAction(
diff --git a/chrome/browser/ui/webui/options/chromeos/display_options_handler.h b/chrome/browser/ui/webui/options/chromeos/display_options_handler.h index 031c476..de6b832 100644 --- a/chrome/browser/ui/webui/options/chromeos/display_options_handler.h +++ b/chrome/browser/ui/webui/options/chromeos/display_options_handler.h
@@ -53,7 +53,7 @@ void HandleSetPrimary(const base::ListValue* args); void HandleSetDisplayLayout(const base::ListValue* args); void HandleSetDisplayMode(const base::ListValue* args); - void HandleSetOrientation(const base::ListValue* args); + void HandleSetRotation(const base::ListValue* args); void HandleSetColorProfile(const base::ListValue* args); void HandleSetUnifiedDesktopEnabled(const base::ListValue* args);
diff --git a/chrome/browser/ui/webui/options/content_settings_exception_area_browsertest.js b/chrome/browser/ui/webui/options/content_settings_exception_area_browsertest.js index 4112ed6..243d653 100644 --- a/chrome/browser/ui/webui/options/content_settings_exception_area_browsertest.js +++ b/chrome/browser/ui/webui/options/content_settings_exception_area_browsertest.js
@@ -18,13 +18,14 @@ browsePreload: 'chrome://settings-frame/contentExceptions', }; -GEN('#if defined(OS_CHROMEOS)'); +// See crbug.com/579666 for OS_LINUX +GEN('#if defined(OS_CHROMEOS) || defined(OS_LINUX)'); GEN('#define MAYBE_testOpenContentSettingsExceptionArea ' + 'DISABLED_testOpenContentSettingsExceptionArea'); GEN('#else'); GEN('#define MAYBE_testOpenContentSettingsExceptionArea ' + 'testOpenContentSettingsExceptionArea'); -GEN('#endif // defined(OS_CHROMEOS)'); +GEN('#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)'); // Test opening the content settings exception area has correct location. TEST_F('ContentSettingsExceptionAreaWebUITest', 'MAYBE_testOpenContentSettingsExceptionArea', function() {
diff --git a/chrome/browser/ui/webui/options/content_settings_handler.cc b/chrome/browser/ui/webui/options/content_settings_handler.cc index f3c697cd..cff82e59 100644 --- a/chrome/browser/ui/webui/options/content_settings_handler.cc +++ b/chrome/browser/ui/webui/options/content_settings_handler.cc
@@ -821,6 +821,7 @@ Profile* profile = content::Source<Profile>(source).ptr(); if (profile->IsOffTheRecord()) { UpdateAllOTRExceptionsViewsFromModel(); + UpdateAllOTRChooserExceptionsViewsFromModel(); observer_.Add(HostContentSettingsMapFactory::GetForProfile(profile)); } break; @@ -1118,91 +1119,32 @@ UpdateChooserExceptionsViewFromModel(chooser_type); } +void ContentSettingsHandler::UpdateAllOTRChooserExceptionsViewsFromModel() { + for (const ChooserTypeNameEntry& chooser_type : kChooserTypeGroupNames) + UpdateOTRChooserExceptionsViewFromModel(chooser_type); +} + void ContentSettingsHandler::UpdateChooserExceptionsViewFromModel( const ChooserTypeNameEntry& chooser_type) { - ChooserContextBase* chooser_context = - chooser_type.get_context(Profile::FromWebUI(web_ui())); - std::vector<scoped_ptr<ChooserContextBase::Object>> objects = - chooser_context->GetAllGrantedObjects(); - AllOriginObjects all_origin_objects; - for (const auto& object : objects) { - std::string name; - bool found = object->object.GetString(chooser_type.ui_name_key, &name); - DCHECK(found); - // It is safe for this structure to hold references into |objects| because - // they are both destroyed at the end of this function. - all_origin_objects[make_pair(object->requesting_origin, - object->source)][object->embedding_origin] - .insert(make_pair(name, &object->object)); - } - - // Keep the exceptions sorted by provider so they will be displayed in - // precedence order. - std::vector<scoped_ptr<base::DictionaryValue>> - all_provider_exceptions[HostContentSettingsMap::NUM_PROVIDER_TYPES]; - - for (const auto& all_origin_objects_entry : all_origin_objects) { - const GURL& requesting_origin = all_origin_objects_entry.first.first; - const std::string& source = all_origin_objects_entry.first.second; - const OneOriginObjects& one_origin_objects = - all_origin_objects_entry.second; - - auto& this_provider_exceptions = all_provider_exceptions - [HostContentSettingsMap::GetProviderTypeFromSource(source)]; - - // Add entries for any non-embedded origins. - bool has_embedded_entries = false; - for (const auto& one_origin_objects_entry : one_origin_objects) { - const GURL& embedding_origin = one_origin_objects_entry.first; - const SortedObjects& sorted_objects = one_origin_objects_entry.second; - - // Skip the embedded settings which will be added below. - if (requesting_origin != embedding_origin) { - has_embedded_entries = true; - continue; - } - - for (const auto& sorted_objects_entry : sorted_objects) { - this_provider_exceptions.push_back(GetChooserExceptionForPage( - requesting_origin, embedding_origin, source, - sorted_objects_entry.first, sorted_objects_entry.second)); - } - } - - if (has_embedded_entries) { - // Add a "parent" entry that simply acts as a heading for all entries - // where |requesting_origin| has been embedded. - this_provider_exceptions.push_back( - GetChooserExceptionForPage(requesting_origin, requesting_origin, - source, std::string(), nullptr)); - - // Add the "children" for any embedded settings. - for (const auto& one_origin_objects_entry : one_origin_objects) { - const GURL& embedding_origin = one_origin_objects_entry.first; - const SortedObjects& sorted_objects = one_origin_objects_entry.second; - - // Skip the non-embedded setting which we already added above. - if (requesting_origin == embedding_origin) - continue; - - for (const auto& sorted_objects_entry : sorted_objects) { - this_provider_exceptions.push_back(GetChooserExceptionForPage( - requesting_origin, embedding_origin, source, - sorted_objects_entry.first, sorted_objects_entry.second)); - } - } - } - } - base::ListValue exceptions; - for (auto& one_provider_exceptions : all_provider_exceptions) { - for (auto& exception : one_provider_exceptions) - exceptions.Append(std::move(exception)); - } - + GetChooserExceptionsFromProfile(false, chooser_type, &exceptions); base::StringValue type_string(chooser_type.name); web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", type_string, exceptions); + + UpdateOTRChooserExceptionsViewFromModel(chooser_type); +} + +void ContentSettingsHandler::UpdateOTRChooserExceptionsViewFromModel( + const ChooserTypeNameEntry& chooser_type) { + if (!Profile::FromWebUI(web_ui())->HasOffTheRecordProfile()) + return; + + base::ListValue exceptions; + GetChooserExceptionsFromProfile(true, chooser_type, &exceptions); + base::StringValue type_string(chooser_type.name); + web_ui()->CallJavascriptFunction("ContentSettings.setOTRExceptions", + type_string, exceptions); } void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { @@ -1441,6 +1383,97 @@ } } +void ContentSettingsHandler::GetChooserExceptionsFromProfile( + bool incognito, + const ChooserTypeNameEntry& chooser_type, + base::ListValue* exceptions) { + Profile* profile = Profile::FromWebUI(web_ui()); + if (incognito) { + if (profile->HasOffTheRecordProfile()) + profile = profile->GetOffTheRecordProfile(); + else + return; + } + + ChooserContextBase* chooser_context = chooser_type.get_context(profile); + std::vector<scoped_ptr<ChooserContextBase::Object>> objects = + chooser_context->GetAllGrantedObjects(); + AllOriginObjects all_origin_objects; + for (const auto& object : objects) { + std::string name; + bool found = object->object.GetString(chooser_type.ui_name_key, &name); + DCHECK(found); + // It is safe for this structure to hold references into |objects| because + // they are both destroyed at the end of this function. + all_origin_objects[make_pair(object->requesting_origin, + object->source)][object->embedding_origin] + .insert(make_pair(name, &object->object)); + } + + // Keep the exceptions sorted by provider so they will be displayed in + // precedence order. + std::vector<scoped_ptr<base::DictionaryValue>> + all_provider_exceptions[HostContentSettingsMap::NUM_PROVIDER_TYPES]; + + for (const auto& all_origin_objects_entry : all_origin_objects) { + const GURL& requesting_origin = all_origin_objects_entry.first.first; + const std::string& source = all_origin_objects_entry.first.second; + const OneOriginObjects& one_origin_objects = + all_origin_objects_entry.second; + + auto& this_provider_exceptions = all_provider_exceptions + [HostContentSettingsMap::GetProviderTypeFromSource(source)]; + + // Add entries for any non-embedded origins. + bool has_embedded_entries = false; + for (const auto& one_origin_objects_entry : one_origin_objects) { + const GURL& embedding_origin = one_origin_objects_entry.first; + const SortedObjects& sorted_objects = one_origin_objects_entry.second; + + // Skip the embedded settings which will be added below. + if (requesting_origin != embedding_origin) { + has_embedded_entries = true; + continue; + } + + for (const auto& sorted_objects_entry : sorted_objects) { + this_provider_exceptions.push_back(GetChooserExceptionForPage( + requesting_origin, embedding_origin, source, + sorted_objects_entry.first, sorted_objects_entry.second)); + } + } + + if (has_embedded_entries) { + // Add a "parent" entry that simply acts as a heading for all entries + // where |requesting_origin| has been embedded. + this_provider_exceptions.push_back( + GetChooserExceptionForPage(requesting_origin, requesting_origin, + source, std::string(), nullptr)); + + // Add the "children" for any embedded settings. + for (const auto& one_origin_objects_entry : one_origin_objects) { + const GURL& embedding_origin = one_origin_objects_entry.first; + const SortedObjects& sorted_objects = one_origin_objects_entry.second; + + // Skip the non-embedded setting which we already added above. + if (requesting_origin == embedding_origin) + continue; + + for (const auto& sorted_objects_entry : sorted_objects) { + this_provider_exceptions.push_back(GetChooserExceptionForPage( + requesting_origin, embedding_origin, source, + sorted_objects_entry.first, sorted_objects_entry.second)); + } + } + } + } + + for (auto& one_provider_exceptions : all_provider_exceptions) { + for (auto& exception : one_provider_exceptions) + exceptions->Append(std::move(exception)); + } +} + void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap( const base::ListValue* args, ContentSettingsType type) {
diff --git a/chrome/browser/ui/webui/options/content_settings_handler.h b/chrome/browser/ui/webui/options/content_settings_handler.h index 01ae9d78..8ac7cad 100644 --- a/chrome/browser/ui/webui/options/content_settings_handler.h +++ b/chrome/browser/ui/webui/options/content_settings_handler.h
@@ -157,11 +157,18 @@ // Clobbers and rebuilds all chooser-based exception tables. void UpdateAllChooserExceptionsViewsFromModel(); + // As above, but only OTR tables. + void UpdateAllOTRChooserExceptionsViewsFromModel(); + // Clobbers and rebuilds the exception table for a particular chooser-based // permission. void UpdateChooserExceptionsViewFromModel( const ChooserTypeNameEntry& chooser_type); + // As above, but only OTR tables. + void UpdateOTRChooserExceptionsViewFromModel( + const ChooserTypeNameEntry& chooser_type); + // Modifies the zoom level exceptions list to display correct chrome // signin page entry. When the legacy (non-WebView-based) signin page // goes away, this function can be removed. @@ -255,6 +262,11 @@ ContentSettingsType type, base::ListValue* exceptions); + // Fills in |exceptions| with Values for the given |type| from |map|. + void GetChooserExceptionsFromProfile(bool incognito, + const ChooserTypeNameEntry& type, + base::ListValue* exceptions); + void OnPepperFlashPrefChanged(); // content::HostZoomMap subscription.
diff --git a/chrome/browser/ui/webui/options/search_engine_manager_browsertest.js b/chrome/browser/ui/webui/options/search_engine_manager_browsertest.js index 9e9a1a2..f0b7ddb2 100644 --- a/chrome/browser/ui/webui/options/search_engine_manager_browsertest.js +++ b/chrome/browser/ui/webui/options/search_engine_manager_browsertest.js
@@ -18,13 +18,14 @@ browsePreload: 'chrome://settings-frame/searchEngines', }; -// See crosbug.com/22673 -GEN('#if defined(OS_CHROMEOS)'); +// See crosbug.com/22673 for OS_CHROMEOS +// See crbug.com/579666 for OS_LINUX +GEN('#if defined(OS_CHROMEOS) || defined(OS_LINUX)'); GEN('#define MAYBE_testOpenSearchEngineManager ' + 'DISABLED_testOpenSearchEngineManager'); GEN('#else'); GEN('#define MAYBE_testOpenSearchEngineManager testOpenSearchEngineManager'); -GEN('#endif // defined(OS_CHROMEOS)'); +GEN('#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)'); // Test opening the search engine manager has correct location. TEST_F('SearchEngineManagerWebUITest', 'MAYBE_testOpenSearchEngineManager',
diff --git a/chrome/browser/ui/webui/options/settings_app_browsertest.js b/chrome/browser/ui/webui/options/settings_app_browsertest.js index 2920183..43b5b46e 100644 --- a/chrome/browser/ui/webui/options/settings_app_browsertest.js +++ b/chrome/browser/ui/webui/options/settings_app_browsertest.js
@@ -20,8 +20,14 @@ GEN('#if defined(ENABLE_SETTINGS_APP)'); +// This test is flaky on Linux bot. See crbug.com/579666 +GEN('#if defined(OS_LINUX)'); +GEN('#define MAYBE_testOpenSettingsApp DISABLED_testOpenSettingsApp'); +GEN('#else'); +GEN('#define MAYBE_testOpenSettingsApp testOpenSettingsApp'); +GEN('#endif // defined(OS_LINUX)'); // Test opening Settings App, and do some checks on section visibility. -TEST_F('SettingsAppWebUITest', 'testOpenSettingsApp', function() { +TEST_F('SettingsAppWebUITest', 'MAYBE_testOpenSettingsApp', function() { // Note there is no location bar in the Settings App. // Some things are hidden via a parent, so make a helper function. @@ -41,10 +47,16 @@ assertFalse(isVisible('startup-section')); }); +// This test is flaky on Linux bot. See crbug.com/579666 +GEN('#if defined(OS_LINUX)'); +GEN('#define MAYBE_testStrings DISABLED_testStrings'); +GEN('#else'); +GEN('#define MAYBE_testStrings testStrings'); +GEN('#endif // defined(OS_LINUX)'); // Check functionality of LoadTimeData.overrideValues(), which the Settings App // uses. Do spot checks, so the test is not too fragile. Some of the content // strings rely on waiting for sync sign-in status, or platform-specifics. -TEST_F('SettingsAppWebUITest', 'testStrings', function() { +TEST_F('SettingsAppWebUITest', 'MAYBE_testStrings', function() { // Ensure we check against the override values. assertTrue(!!loadTimeData.getValue('settingsApp'));
diff --git a/chrome/browser/ui/webui/sync_setup_browsertest.js b/chrome/browser/ui/webui/sync_setup_browsertest.js index 528c2fe..b0000a2 100644 --- a/chrome/browser/ui/webui/sync_setup_browsertest.js +++ b/chrome/browser/ui/webui/sync_setup_browsertest.js
@@ -81,7 +81,13 @@ }, }; -TEST_F('SyncSetupWebUITestAsync', 'VerifySignIn', function() { +// This test is flaky on Linux bot. See crbug.com/579666 +GEN('#if defined(OS_LINUX)'); +GEN('#define MAYBE_VerifySignIn DISABLED_VerifySignIn'); +GEN('#else'); +GEN('#define MAYBE_VerifySignIn VerifySignIn'); +GEN('#endif // defined(OS_LINUX)'); +TEST_F('SyncSetupWebUITestAsync', 'MAYBE_VerifySignIn', function() { // Handle SyncSetupStartSignIn by displaying the sync setup dialog, verifying // that a confirmation dialog appears, and clicking OK to dismiss the dialog. // Note that this test doesn't actually do a gaia sign in. @@ -101,8 +107,14 @@ this.startSyncing(); }); +// This test is flaky on Linux bot. See crbug.com/579666 +GEN('#if defined(OS_LINUX)'); +GEN('#define MAYBE_RestoreSyncDataTypes DISABLED_RestoreSyncDataTypes'); +GEN('#else'); +GEN('#define MAYBE_RestoreSyncDataTypes RestoreSyncDataTypes'); +GEN('#endif // defined(OS_LINUX)'); // Test that switching to and from "Sync everything" saves and restores types. -TEST_F('SyncSetupWebUITestAsync', 'RestoreSyncDataTypes', function() { +TEST_F('SyncSetupWebUITestAsync', 'MAYBE_RestoreSyncDataTypes', function() { this.mockHandler.expects(once()).SyncSetupStartSignIn( 'access-point-settings').will(callFunction(function() { SyncSetupOverlay.showSyncSetupPage('configure', {});
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index ca0677c..4b38309e 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi
@@ -984,8 +984,6 @@ 'browser/download/notification/download_notification.h', 'browser/download/notification/download_notification_manager.cc', 'browser/download/notification/download_notification_manager.h', - 'browser/input_method/input_method_engine_base.cc', - 'browser/input_method/input_method_engine_base.h', 'browser/media/protected_media_identifier_permission_context.cc', 'browser/media/protected_media_identifier_permission_context.h', 'browser/media/protected_media_identifier_permission_context_factory.cc', @@ -3601,13 +3599,9 @@ '<(SHARED_INTERMEDIATE_DIR)/ui/chromeos/resources/grit/ui_chromeos_resources_map.cc', ], 'dependencies': [ - '../base/base.gyp:base', 'browser_chromeos', '../components/components.gyp:user_manager', '../ui/chromeos/ui_chromeos.gyp:ui_chromeos_resources', - '../ui/base/ime/ui_base_ime.gyp:ui_base_ime', - '../ui/base/ui_base.gyp:ui_base', - '../ui/events/events.gyp:dom_keycode_converter', ], }], ['use_cups==1', {
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 1d5dd4572..3ea4ae5 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi
@@ -694,6 +694,8 @@ 'browser/ui/app_list/search/launcher_search/launcher_search_provider.h', 'browser/ui/app_list/search/launcher_search/launcher_search_result.cc', 'browser/ui/app_list/search/launcher_search/launcher_search_result.h', + 'browser/ui/input_method/input_method_engine_base.cc', + 'browser/ui/input_method/input_method_engine_base.h', 'browser/ui/views/apps/chrome_native_app_window_views_aura_ash.cc', 'browser/ui/views/apps/chrome_native_app_window_views_aura_ash.h', # On chromeos, file manager extension handles the file open/save dialog. @@ -1321,6 +1323,10 @@ ], # Desktop Linux. Assume aura/ash/views/x11. 'chrome_browser_ui_desktop_linux_sources': [ + 'browser/ui/input_method/input_method_engine.cc', + 'browser/ui/input_method/input_method_engine.h', + 'browser/ui/input_method/input_method_engine_base.cc', + 'browser/ui/input_method/input_method_engine_base.h', 'browser/ui/views/app_list/linux/app_list_linux.cc', 'browser/ui/views/app_list/linux/app_list_linux.h', 'browser/ui/views/app_list/linux/app_list_service_linux.cc', @@ -2517,6 +2523,10 @@ ], # Windows-only. Assume ash/aura/views. 'chrome_browser_ui_win_sources': [ + 'browser/ui/input_method/input_method_engine.cc', + 'browser/ui/input_method/input_method_engine.h', + 'browser/ui/input_method/input_method_engine_base.cc', + 'browser/ui/input_method/input_method_engine_base.h', 'browser/ui/network_profile_bubble.cc', 'browser/ui/network_profile_bubble.h', 'browser/ui/views/color_chooser_dialog.cc', @@ -2973,8 +2983,10 @@ 'browser_chromeos', '../components/components.gyp:proximity_auth_webui', '../device/nfc/nfc.gyp:device_nfc', + '../ui/base/ime/ui_base_ime.gyp:ui_base_ime', '../ui/chromeos/ui_chromeos.gyp:ui_chromeos', '../ui/chromeos/ui_chromeos.gyp:ui_chromeos_resources', + '../ui/events/events.gyp:dom_keycode_converter', ], }], ['enable_app_list==1 and chromeos==1', { @@ -3162,6 +3174,8 @@ '../third_party/iaccessible2/iaccessible2.gyp:iaccessible2', '../third_party/isimpledom/isimpledom.gyp:isimpledom', '../ui/app_list/app_list.gyp:app_list', + '../ui/base/ime/ui_base_ime.gyp:ui_base_ime', + '../ui/events/events.gyp:dom_keycode_converter', '../ui/views/controls/webview/webview.gyp:webview', '../ui/views/views.gyp:views', ], @@ -3208,6 +3222,10 @@ ], }], ['desktop_linux==1', { + 'dependencies': [ + '../ui/base/ime/ui_base_ime.gyp:ui_base_ime', + '../ui/events/events.gyp:dom_keycode_converter', + ], 'sources': [ '<@(chrome_browser_ui_desktop_linux_sources)' ], }], ['OS=="linux"', { # Both desktop Linux and ChromeOS.
diff --git a/chrome/common/extensions/api/input_ime.json b/chrome/common/extensions/api/input_ime.json index b8379add..a4a2db7b 100644 --- a/chrome/common/extensions/api/input_ime.json +++ b/chrome/common/extensions/api/input_ime.json
@@ -596,6 +596,36 @@ "description": "The JavaScript 'window' object of the newly created IME window." } ] + } + ] + }, + { + "name": "activate", + "type": "function", + "description": "Activates the IME extension so that it can receive events.", + "platforms": ["win", "linux"], + "parameters": [ + { + "type": "function", + "name": "callback", + "optional": true, + "description": "Called when the operation completes.", + "parameters": [] + } + ] + }, + { + "name": "deactivate", + "type": "function", + "description": "Deactivates the IME extension so that it cannot receive events.", + "platforms": ["win", "linux"], + "parameters": [ + { + "type": "function", + "name": "callback", + "optional": true, + "description": "Called when the operation completes.", + "parameters": [] } ] }
diff --git a/chrome/common/extensions/api/webview_tag.json b/chrome/common/extensions/api/webview_tag.json index 0263954..8828eb3 100644 --- a/chrome/common/extensions/api/webview_tag.json +++ b/chrome/common/extensions/api/webview_tag.json
@@ -676,28 +676,6 @@ ], "functions": [ { - "name": "captureVisibleRegion", - "type": "function", - "description": "Captures the visible region of the webview.", - "parameters": [ - { - "$ref": "extensionTypes.ImageDetails", - "name": "options", - "optional": true - }, - { - "type": "function", - "name": "callback", - "parameters": [ - {"type": "string", - "name": "dataUrl", - "description": "A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display." - } - ] - } - ] - }, - { "name": "addContentScripts", "type": "function", "description": "<p>Adds content script injection rules to the <code>webview</code>. When the <code>webview</code> navigates to a page matching one or more rules, the associated scripts will be injected. You can programmatically add rules or update existing rules.</p><p>The following example adds two rules to the <code>webview</code>: 'myRule' and 'anotherRule'.</p><pre>webview.addContentScripts([\r {\r name: 'myRule',\r matches: ['http://www.foo.com/*'],\r css: { files: ['mystyles.css'] },\r js: { files: ['jquery.js', 'myscript.js'] },\r run_at: 'document_start'\r },\r {\r name: 'anotherRule',\r matches: ['http://www.bar.com/*'],\r js: { code: \"document.body.style.backgroundColor = 'red';\" },\r run_at: 'document_end'\r }]);\r ...\r\r// Navigates webview.\rwebview.src = 'http://www.foo.com';</pre><p>You can defer addContentScripts call until you needs to inject scripts.</p><p>The following example shows how to overwrite an existing rule.</p><pre>webview.addContentScripts([{\r name: 'rule',\r matches: ['http://www.foo.com/*'],\r js: { files: ['scriptA.js'] },\r run_at: 'document_start'}]);\r\r// Do something.\rwebview.src = 'http://www.foo.com/*';\r ...\r// Overwrite 'rule' defined before.\rwebview.addContentScripts([{\r name: 'rule',\r matches: ['http://www.bar.com/*'],\r js: { files: ['scriptB.js'] },\r run_at: 'document_end'}]);</pre><p>If <code>webview</code> has been naviagted to the origin (e.g., foo.com) and calls <code>webview.addContentScripts</code> to add 'myRule', you need to wait for next navigation to make the scripts injected. If you want immediate injection, <code>executeScript</code> will do the right thing.</p><p>Rules are preserved even if the guest process crashes or is killed or even if the <code>webview</code> is reparented.</p><p>Refer to the <a href='/extensions/content_scripts'>content scripts</a> documentation for more details.</p>",
diff --git a/chrome/test/data/extensions/api_test/management/test/basics.js b/chrome/test/data/extensions/api_test/management/test/basics.js index d9ccf31d..a9cf6c0 100644 --- a/chrome/test/data/extensions/api_test/management/test/basics.js +++ b/chrome/test/data/extensions/api_test/management/test/basics.js
@@ -45,7 +45,7 @@ var tests = [ function simple() { chrome.management.getAll(callback(function(items) { - chrome.test.assertEq(11, items.length); + chrome.test.assertEq(12, items.length); checkItemInList(items, "Extension Management API Test", true, "extension"); @@ -72,6 +72,8 @@ { "installType": "sideload" }); checkItemInList(items, "admin_extension", true, "extension", { "installType": "admin" }); + checkItemInList(items, "version_name", true, "extension", + { "versionName": "0.1 beta" }); // Check that we got the icons correctly var extension = getItemNamed(items, "enabled_extension");
diff --git a/chrome/test/data/extensions/api_test/management/version_name/manifest.json b/chrome/test/data/extensions/api_test/management/version_name/manifest.json new file mode 100644 index 0000000..27a66d9 --- /dev/null +++ b/chrome/test/data/extensions/api_test/management/version_name/manifest.json
@@ -0,0 +1,6 @@ +{ + "name": "version_name", + "version": "0.1", + "manifest_version": 2, + "version_name" : "0.1 beta" +}
diff --git a/chrome/test/media_router/media_router_integration_ui_browsertest.cc b/chrome/test/media_router/media_router_integration_ui_browsertest.cc index f200d09..9193327 100644 --- a/chrome/test/media_router/media_router_integration_ui_browsertest.cc +++ b/chrome/test/media_router/media_router_integration_ui_browsertest.cc
@@ -32,8 +32,16 @@ ASSERT_EQ(2, ExecuteScriptAndExtractInt(dialog_contents, sink_length_script)); ChooseSink(web_contents, kTestSinkName); - WaitUntilRouteCreated(); +// Linux bots run browser tests without a physical display, which is causing +// flaky event dispatching of mouseenter and mouseleave events. This causes +// the dialog to sometimes close prematurely even though a mouseenter event +// is explicitly dispatched in the test. +// Here, we still dispatch the mouseenter event for OSX and Windows, but close +// the dialog and reopen it on Linux. +// The test succeeds fine when run with a physical display. +// http://crbug.com/577943 +#if defined(OS_MACOSX) || defined(OS_WIN) // Simulate keeping the mouse on the dialog to prevent it from automatically // closing after the route has been created. Then, check that the dialog // remains open. @@ -42,7 +50,17 @@ "window.document.getElementById('media-router-container').dispatchEvent(" "new Event('mouseenter')))"); ASSERT_TRUE(content::ExecuteScript(dialog_contents, mouse_enter_script)); +#endif + WaitUntilRouteCreated(); + +#if defined(OS_MACOSX) || defined(OS_WIN) CheckDialogRemainsOpen(web_contents); +#elif defined(OS_LINUX) + Wait(base::TimeDelta::FromSeconds(5)); + WaitUntilDialogClosed(web_contents); + dialog_contents = OpenMRDialog(web_contents); + ChooseSink(web_contents, kTestSinkName); +#endif // Verify the route details page. std::string route_info_script = base::StringPrintf(
diff --git a/chromecast/browser/cast_permission_manager.cc b/chromecast/browser/cast_permission_manager.cc index d8cf3cb7..0595f35 100644 --- a/chromecast/browser/cast_permission_manager.cc +++ b/chromecast/browser/cast_permission_manager.cc
@@ -25,7 +25,7 @@ bool user_gesture, const base::Callback<void(content::PermissionStatus)>& callback) { LOG(INFO) << __FUNCTION__ << ": " << static_cast<int>(permission); - callback.Run(content::PermissionStatus::PERMISSION_STATUS_GRANTED); + callback.Run(content::PermissionStatus::GRANTED); return kNoPendingOperation; } @@ -36,8 +36,8 @@ bool user_gesture, const base::Callback<void( const std::vector<content::PermissionStatus>&)>& callback) { - callback.Run(std::vector<content::PermissionStatus>(permissions.size(), - content::PermissionStatus::PERMISSION_STATUS_GRANTED)); + callback.Run(std::vector<content::PermissionStatus>( + permissions.size(), content::PermissionStatus::GRANTED)); return kNoPendingOperation; } @@ -55,7 +55,7 @@ const GURL& requesting_origin, const GURL& embedding_origin) { LOG(INFO) << __FUNCTION__ << ": " << static_cast<int>(permission); - return content::PermissionStatus::PERMISSION_STATUS_GRANTED; + return content::PermissionStatus::GRANTED; } void CastPermissionManager::RegisterPermissionUsage(
diff --git a/chromecast/media/cma/base/buffering_defs.cc b/chromecast/media/cma/base/buffering_defs.cc index 3afd0f80..b799c04a 100644 --- a/chromecast/media/cma/base/buffering_defs.cc +++ b/chromecast/media/cma/base/buffering_defs.cc
@@ -7,7 +7,16 @@ namespace chromecast { namespace media { -const size_t kAppAudioBufferSize = 64 * 1024; +// TODO(servolk): Find a way to compute those values dynamically, based on +// input stream parameters. These sizes need to allow enough data to be buffered +// to reach high memory threshold of the buffering controller (see +// kHighBufferThresholdMediaSource/kHighBufferThresholdURL being used in media +// pipeline initialization in MediaPipelineImpl::Initialize). Otherwise CMA IPC +// might deadlock (playback is kept paused by buffering_controller since we have +// less than |high_threshold| of data buffered, media DecoderBuffers are kept +// alive holding on to the IPC shared memory and CMA IPC is stuck since it +// reached the buffer limit and can't send more data to the browser process). +const size_t kAppAudioBufferSize = 256 * 1024; const size_t kAppVideoBufferSize = 4 * 1024 * 1024; } // namespace media
diff --git a/components/arc/ime/arc_ime_ipc_host_impl.cc b/components/arc/ime/arc_ime_ipc_host_impl.cc index cd36ece..e601384 100644 --- a/components/arc/ime/arc_ime_ipc_host_impl.cc +++ b/components/arc/ime/arc_ime_ipc_host_impl.cc
@@ -24,27 +24,27 @@ // That's why we need a lengthy switch statement instead of static_cast // guarded by a static assert on the two enums to be in sync. switch (ipc_type) { - case arc::TEXT_INPUT_TYPE_NONE: + case arc::TextInputType::NONE: return ui::TEXT_INPUT_TYPE_NONE; - case arc::TEXT_INPUT_TYPE_TEXT: + case arc::TextInputType::TEXT: return ui::TEXT_INPUT_TYPE_TEXT; - case arc::TEXT_INPUT_TYPE_PASSWORD: + case arc::TextInputType::PASSWORD: return ui::TEXT_INPUT_TYPE_PASSWORD; - case arc::TEXT_INPUT_TYPE_SEARCH: + case arc::TextInputType::SEARCH: return ui::TEXT_INPUT_TYPE_SEARCH; - case arc::TEXT_INPUT_TYPE_EMAIL: + case arc::TextInputType::EMAIL: return ui::TEXT_INPUT_TYPE_EMAIL; - case arc::TEXT_INPUT_TYPE_NUMBER: + case arc::TextInputType::NUMBER: return ui::TEXT_INPUT_TYPE_NUMBER; - case arc::TEXT_INPUT_TYPE_TELEPHONE: + case arc::TextInputType::TELEPHONE: return ui::TEXT_INPUT_TYPE_TELEPHONE; - case arc::TEXT_INPUT_TYPE_URL: + case arc::TextInputType::URL: return ui::TEXT_INPUT_TYPE_URL; - case arc::TEXT_INPUT_TYPE_DATE: + case arc::TextInputType::DATE: return ui::TEXT_INPUT_TYPE_DATE; - case arc::TEXT_INPUT_TYPE_TIME: + case arc::TextInputType::TIME: return ui::TEXT_INPUT_TYPE_TIME; - case arc::TEXT_INPUT_TYPE_DATETIME: + case arc::TextInputType::DATETIME: return ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL; default: return ui::TEXT_INPUT_TYPE_TEXT;
diff --git a/components/arc/power/arc_power_bridge.cc b/components/arc/power/arc_power_bridge.cc index b918147..172d8fe 100644 --- a/components/arc/power/arc_power_bridge.cc +++ b/components/arc/power/arc_power_bridge.cc
@@ -53,11 +53,11 @@ int wake_lock_id = -1; switch (type) { - case DISPLAY_WAKE_LOCK_TYPE_BRIGHT: + case DisplayWakeLockType::BRIGHT: wake_lock_id = controller->AddScreenWakeLock( chromeos::PowerPolicyController::REASON_OTHER, "ARC"); break; - case DISPLAY_WAKE_LOCK_TYPE_DIM: + case DisplayWakeLockType::DIM: wake_lock_id = controller->AddDimWakeLock( chromeos::PowerPolicyController::REASON_OTHER, "ARC"); break;
diff --git a/components/arc/test/fake_app_instance.cc b/components/arc/test/fake_app_instance.cc index 2ea1ff0..2b3041b89 100644 --- a/components/arc/test/fake_app_instance.cc +++ b/components/arc/test/fake_app_instance.cc
@@ -57,31 +57,31 @@ CHECK(png_data_as_string != nullptr); std::string icon_file_name; switch (scale_factor) { - case SCALE_FACTOR_SCALE_FACTOR_100P: + case ScaleFactor::SCALE_FACTOR_100P: icon_file_name = "icon_100p.png"; break; - case SCALE_FACTOR_SCALE_FACTOR_125P: + case ScaleFactor::SCALE_FACTOR_125P: icon_file_name = "icon_125p.png"; break; - case SCALE_FACTOR_SCALE_FACTOR_133P: + case ScaleFactor::SCALE_FACTOR_133P: icon_file_name = "icon_133p.png"; break; - case SCALE_FACTOR_SCALE_FACTOR_140P: + case ScaleFactor::SCALE_FACTOR_140P: icon_file_name = "icon_140p.png"; break; - case SCALE_FACTOR_SCALE_FACTOR_150P: + case ScaleFactor::SCALE_FACTOR_150P: icon_file_name = "icon_150p.png"; break; - case SCALE_FACTOR_SCALE_FACTOR_180P: + case ScaleFactor::SCALE_FACTOR_180P: icon_file_name = "icon_180p.png"; break; - case SCALE_FACTOR_SCALE_FACTOR_200P: + case ScaleFactor::SCALE_FACTOR_200P: icon_file_name = "icon_200p.png"; break; - case SCALE_FACTOR_SCALE_FACTOR_250P: + case ScaleFactor::SCALE_FACTOR_250P: icon_file_name = "icon_250p.png"; break; - case SCALE_FACTOR_SCALE_FACTOR_300P: + case ScaleFactor::SCALE_FACTOR_300P: icon_file_name = "icon_300p.png"; break; default:
diff --git a/components/arc/test/fake_app_instance.h b/components/arc/test/fake_app_instance.h index 509c451..a078ea7 100644 --- a/components/arc/test/fake_app_instance.h +++ b/components/arc/test/fake_app_instance.h
@@ -43,7 +43,8 @@ IconRequest(const std::string& package, const std::string& activity, ScaleFactor scale_factor) - : Request(package, activity), scale_factor_(scale_factor) {} + : Request(package, activity), + scale_factor_(static_cast<int>(scale_factor)) {} ~IconRequest() {} int scale_factor() const { return scale_factor_; }
diff --git a/components/bitmap_uploader/bitmap_uploader.cc b/components/bitmap_uploader/bitmap_uploader.cc index 46a4515a..f618763 100644 --- a/components/bitmap_uploader/bitmap_uploader.cc +++ b/components/bitmap_uploader/bitmap_uploader.cc
@@ -52,7 +52,7 @@ } void BitmapUploader::Init(mojo::Shell* shell) { - surface_ = window_->RequestSurface(mus::mojom::SURFACE_TYPE_DEFAULT); + surface_ = window_->RequestSurface(mus::mojom::SurfaceType::DEFAULT); surface_->BindToThread(); mojo::ServiceProviderPtr gpu_service_provider; @@ -142,7 +142,7 @@ mus::mojom::TransferableResource::New(); resource->id = next_resource_id_++; resource_to_texture_id_map_[resource->id] = texture_id; - resource->format = mus::mojom::RESOURCE_FORMAT_RGBA_8888; + resource->format = mus::mojom::ResourceFormat::RGBA_8888; resource->filter = GL_LINEAR; resource->size = bitmap_size.Clone(); mus::mojom::MailboxHolderPtr mailbox_holder = @@ -159,7 +159,7 @@ resource->is_overlay_candidate = false; mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); - quad->material = mus::mojom::MATERIAL_TEXTURE_CONTENT; + quad->material = mus::mojom::Material::TEXTURE_CONTENT; mojo::RectPtr rect = mojo::Rect::New(); if (width_ <= bounds.width() && height_ <= bounds.height()) { @@ -205,7 +205,7 @@ if (color_ != g_transparent_color) { mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); - quad->material = mus::mojom::MATERIAL_SOLID_COLOR; + quad->material = mus::mojom::Material::SOLID_COLOR; quad->rect = mojo::Rect::From(bounds); quad->opaque_rect = mojo::Rect::New(); quad->visible_rect = mojo::Rect::From(bounds);
diff --git a/components/browser_sync.gypi b/components/browser_sync.gypi index 828814ae..f9d4b4c 100644 --- a/components/browser_sync.gypi +++ b/components/browser_sync.gypi
@@ -74,6 +74,7 @@ '../google_apis/google_apis.gyp:google_apis', '../sync/sync.gyp:sync', '../testing/gmock.gyp:gmock', + 'sync_driver', 'sync_driver_test_support', ], 'include_dirs': [ @@ -83,6 +84,8 @@ # Note: file list duplicated in GN build. 'browser_sync/browser/profile_sync_service_mock.cc', 'browser_sync/browser/profile_sync_service_mock.h', + 'browser_sync/browser/profile_sync_test_util.cc', + 'browser_sync/browser/profile_sync_test_util.h', ], } ],
diff --git a/components/browser_sync/browser/BUILD.gn b/components/browser_sync/browser/BUILD.gn index 3ad2405..38ef95fb 100644 --- a/components/browser_sync/browser/BUILD.gn +++ b/components/browser_sync/browser/BUILD.gn
@@ -83,11 +83,14 @@ sources = [ "profile_sync_service_mock.cc", "profile_sync_service_mock.h", + "profile_sync_test_util.cc", + "profile_sync_test_util.h", ] deps = [ ":browser", "//base", + "//components/sync_driver", "//components/sync_driver:test_support", "//google_apis", "//testing/gmock",
diff --git a/components/browser_sync/browser/profile_sync_test_util.cc b/components/browser_sync/browser/profile_sync_test_util.cc new file mode 100644 index 0000000..b941c32 --- /dev/null +++ b/components/browser_sync/browser/profile_sync_test_util.cc
@@ -0,0 +1,17 @@ +// 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 "components/browser_sync/browser/profile_sync_test_util.h" + +namespace browser_sync { + +void EmptyNetworkTimeUpdate(const base::Time&, + const base::TimeDelta&, + const base::TimeDelta&) {} + +SyncServiceObserverMock::SyncServiceObserverMock() {} + +SyncServiceObserverMock::~SyncServiceObserverMock() {} + +} // namespace browser_sync
diff --git a/components/browser_sync/browser/profile_sync_test_util.h b/components/browser_sync/browser/profile_sync_test_util.h new file mode 100644 index 0000000..d0b7007 --- /dev/null +++ b/components/browser_sync/browser/profile_sync_test_util.h
@@ -0,0 +1,35 @@ +// 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 COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_TEST_UTIL_H_ +#define COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_TEST_UTIL_H_ + +#include "base/time/time.h" +#include "components/sync_driver/sync_service_observer.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace base { +class Time; +class TimeDelta; +} + +namespace browser_sync { + +// An empty syncer::NetworkTimeUpdateCallback. Used in various tests to +// instantiate ProfileSyncService. +void EmptyNetworkTimeUpdate(const base::Time&, + const base::TimeDelta&, + const base::TimeDelta&); + +class SyncServiceObserverMock : public sync_driver::SyncServiceObserver { + public: + SyncServiceObserverMock(); + virtual ~SyncServiceObserverMock(); + + MOCK_METHOD0(OnStateChanged, void()); +}; + +} // namespace browser_sync + +#endif // COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_TEST_UTIL_H_
diff --git a/components/clipboard/clipboard_apptest.cc b/components/clipboard/clipboard_apptest.cc index 92808c0..c06b28d 100644 --- a/components/clipboard/clipboard_apptest.cc +++ b/components/clipboard/clipboard_apptest.cc
@@ -65,7 +65,7 @@ base::RunLoop run_loop; uint64_t sequence_num = 999999; clipboard_->GetSequenceNumber( - Clipboard::TYPE_COPY_PASTE, + Clipboard::Type::COPY_PASTE, base::Bind(&CopyUint64AndEndRunloop, &sequence_num, &run_loop)); run_loop.Run(); return sequence_num; @@ -76,7 +76,7 @@ std::vector<std::string> types; types.push_back(kUninitialized); clipboard_->GetAvailableMimeTypes( - Clipboard::TYPE_COPY_PASTE, + Clipboard::Type::COPY_PASTE, base::Bind(&CopyVectorStringAndEndRunloop, &types, &run_loop)); run_loop.Run(); return types; @@ -86,7 +86,7 @@ base::RunLoop run_loop; bool is_null = false; clipboard_->ReadMimeType( - Clipboard::TYPE_COPY_PASTE, mime_type, + Clipboard::Type::COPY_PASTE, mime_type, base::Bind(&CopyStringAndEndRunloop, data, &is_null, &run_loop)); run_loop.Run(); return !is_null; @@ -95,7 +95,7 @@ void SetStringText(const std::string& data) { Map<String, Array<uint8_t>> mime_data; mime_data[Clipboard::MIME_TYPE_TEXT] = Array<uint8_t>::From(data); - clipboard_->WriteClipboardData(Clipboard::TYPE_COPY_PASTE, + clipboard_->WriteClipboardData(Clipboard::Type::COPY_PASTE, std::move(mime_data)); } @@ -131,7 +131,7 @@ mime_data[Clipboard::MIME_TYPE_HTML] = Array<uint8_t>::From(std::string(kHtmlData)); - clipboard_->WriteClipboardData(Clipboard::TYPE_COPY_PASTE, + clipboard_->WriteClipboardData(Clipboard::Type::COPY_PASTE, std::move(mime_data)); EXPECT_EQ(1ul, GetSequenceNumber()); @@ -152,7 +152,7 @@ EXPECT_EQ(kPlainTextData, data); Map<String, Array<uint8_t>> mime_data; - clipboard_->WriteClipboardData(Clipboard::TYPE_COPY_PASTE, + clipboard_->WriteClipboardData(Clipboard::Type::COPY_PASTE, std::move(mime_data)); EXPECT_EQ(2ul, GetSequenceNumber());
diff --git a/components/clipboard/clipboard_standalone_impl.cc b/components/clipboard/clipboard_standalone_impl.cc index 1a852f72..1a5d3b3 100644 --- a/components/clipboard/clipboard_standalone_impl.cc +++ b/components/clipboard/clipboard_standalone_impl.cc
@@ -65,13 +65,14 @@ void ClipboardStandaloneImpl::GetSequenceNumber( Clipboard::Type clipboard_type, const mojo::Callback<void(uint64_t)>& callback) { - callback.Run(sequence_number_[clipboard_type]); + callback.Run(sequence_number_[static_cast<int>(clipboard_type)]); } void ClipboardStandaloneImpl::GetAvailableMimeTypes( Clipboard::Type clipboard_type, const mojo::Callback<void(Array<String>)>& callback) { - callback.Run(clipboard_state_[clipboard_type]->GetMimeTypes()); + callback.Run( + clipboard_state_[static_cast<int>(clipboard_type)]->GetMimeTypes()); } void ClipboardStandaloneImpl::ReadMimeType( @@ -79,15 +80,16 @@ const String& mime_type, const mojo::Callback<void(Array<uint8_t>)>& callback) { Array<uint8_t> mime_data; - clipboard_state_[clipboard_type]->GetData(mime_type, &mime_data); + clipboard_state_[static_cast<int>(clipboard_type)]->GetData(mime_type, + &mime_data); callback.Run(std::move(mime_data)); } void ClipboardStandaloneImpl::WriteClipboardData( Clipboard::Type clipboard_type, Map<String, Array<uint8_t>> data) { - sequence_number_[clipboard_type]++; - clipboard_state_[clipboard_type]->SetData(std::move(data)); + sequence_number_[static_cast<int>(clipboard_type)]++; + clipboard_state_[static_cast<int>(clipboard_type)]->SetData(std::move(data)); } } // namespace clipboard
diff --git a/components/devtools_service/devtools_http_server.cc b/components/devtools_service/devtools_http_server.cc index 3ab27d9..33bae37c 100644 --- a/components/devtools_service/devtools_http_server.cc +++ b/components/devtools_service/devtools_http_server.cc
@@ -251,7 +251,7 @@ pending_send_count_--; if (web_socket_ && buffer) - web_socket_->Send(true, mojo::WebSocket::MESSAGE_TYPE_TEXT, num_bytes); + web_socket_->Send(true, mojo::WebSocket::MessageType::TEXT, num_bytes); if (ShouldSelfDestruct()) delete this; @@ -341,7 +341,7 @@ &network_service); mojo::NetAddressPtr local_address(mojo::NetAddress::New()); - local_address->family = mojo::NET_ADDRESS_FAMILY_IPV4; + local_address->family = mojo::NetAddressFamily::IPV4; local_address->ipv4 = mojo::NetAddressIPv4::New(); local_address->ipv4->port = remote_debugging_port; local_address->ipv4->addr.resize(4);
diff --git a/components/filesystem/directory_impl.cc b/components/filesystem/directory_impl.cc index d61c2fe8..715c31f 100644 --- a/components/filesystem/directory_impl.cc +++ b/components/filesystem/directory_impl.cc
@@ -37,13 +37,13 @@ name = directory_enumerator.Next()) { base::FileEnumerator::FileInfo info = directory_enumerator.GetInfo(); DirectoryEntryPtr entry = DirectoryEntry::New(); - entry->type = info.IsDirectory() - ? FS_FILE_TYPE_DIRECTORY : FS_FILE_TYPE_REGULAR_FILE; + entry->type = + info.IsDirectory() ? FsFileType::DIRECTORY : FsFileType::REGULAR_FILE; entry->name = info.GetName().AsUTF8Unsafe(); entries.push_back(std::move(entry)); } - callback.Run(FILE_ERROR_OK, std::move(entries)); + callback.Run(FileError::OK, std::move(entries)); } // TODO(erg): Consider adding an implementation of Stat()/Touch() to the @@ -56,7 +56,8 @@ uint32_t open_flags, const OpenFileCallback& callback) { base::FilePath path; - if (FileError error = ValidatePath(raw_path, directory_path_, &path)) { + FileError error = ValidatePath(raw_path, directory_path_, &path); + if (error != FileError::OK) { callback.Run(error); return; } @@ -69,13 +70,13 @@ base::File base_file(path, open_flags); if (!base_file.IsValid()) { - callback.Run(FILE_ERROR_FAILED); + callback.Run(FileError::FAILED); return; } base::File::Info info; if (!base_file.GetInfo(&info)) { - callback.Run(FILE_ERROR_FAILED); + callback.Run(FileError::FAILED); return; } @@ -83,14 +84,14 @@ // We must not return directories as files. In the file abstraction, we can // fetch raw file descriptors over mojo pipes, and passing a file // descriptor to a directory is a sandbox escape on Windows. - callback.Run(FILE_ERROR_NOT_A_FILE); + callback.Run(FileError::NOT_A_FILE); return; } if (file.is_pending()) { new FileImpl(std::move(file), std::move(base_file)); } - callback.Run(FILE_ERROR_OK); + callback.Run(FileError::OK); } void DirectoryImpl::OpenDirectory(const mojo::String& raw_path, @@ -98,21 +99,22 @@ uint32_t open_flags, const OpenDirectoryCallback& callback) { base::FilePath path; - if (FileError error = ValidatePath(raw_path, directory_path_, &path)) { + FileError error = ValidatePath(raw_path, directory_path_, &path); + if (error != FileError::OK) { callback.Run(error); return; } if (!base::DirectoryExists(path)) { if (base::PathExists(path)) { - callback.Run(FILE_ERROR_NOT_A_DIRECTORY); + callback.Run(FileError::NOT_A_DIRECTORY); return; } if (!(open_flags & kFlagOpenAlways || open_flags & kFlagCreate)) { // The directory doesn't exist, and we weren't passed parameters to // create it. - callback.Run(FILE_ERROR_NOT_FOUND); + callback.Run(FileError::NOT_FOUND); return; } @@ -126,88 +128,91 @@ if (directory.is_pending()) new DirectoryImpl(std::move(directory), path, scoped_ptr<base::ScopedTempDir>()); - callback.Run(FILE_ERROR_OK); + callback.Run(FileError::OK); } void DirectoryImpl::Rename(const mojo::String& raw_old_path, const mojo::String& raw_new_path, const RenameCallback& callback) { base::FilePath old_path; - if (FileError error = - ValidatePath(raw_old_path, directory_path_, &old_path)) { + FileError error = ValidatePath(raw_old_path, directory_path_, &old_path); + if (error != FileError::OK) { callback.Run(error); return; } base::FilePath new_path; - if (FileError error = - ValidatePath(raw_new_path, directory_path_, &new_path)) { + error = ValidatePath(raw_new_path, directory_path_, &new_path); + if (error != FileError::OK) { callback.Run(error); return; } if (!base::Move(old_path, new_path)) { - callback.Run(FILE_ERROR_FAILED); + callback.Run(FileError::FAILED); return; } - callback.Run(FILE_ERROR_OK); + callback.Run(FileError::OK); } void DirectoryImpl::Delete(const mojo::String& raw_path, uint32_t delete_flags, const DeleteCallback& callback) { base::FilePath path; - if (FileError error = ValidatePath(raw_path, directory_path_, &path)) { + FileError error = ValidatePath(raw_path, directory_path_, &path); + if (error != FileError::OK) { callback.Run(error); return; } bool recursive = delete_flags & kDeleteFlagRecursive; if (!base::DeleteFile(path, recursive)) { - callback.Run(FILE_ERROR_FAILED); + callback.Run(FileError::FAILED); return; } - callback.Run(FILE_ERROR_OK); + callback.Run(FileError::OK); } void DirectoryImpl::Exists(const mojo::String& raw_path, const ExistsCallback& callback) { base::FilePath path; - if (FileError error = ValidatePath(raw_path, directory_path_, &path)) { + FileError error = ValidatePath(raw_path, directory_path_, &path); + if (error != FileError::OK) { callback.Run(error, false); return; } bool exists = base::PathExists(path); - callback.Run(FILE_ERROR_OK, exists); + callback.Run(FileError::OK, exists); } void DirectoryImpl::IsWritable(const mojo::String& raw_path, const IsWritableCallback& callback) { base::FilePath path; - if (FileError error = ValidatePath(raw_path, directory_path_, &path)) { + FileError error = ValidatePath(raw_path, directory_path_, &path); + if (error != FileError::OK) { callback.Run(error, false); return; } - callback.Run(FILE_ERROR_OK, base::PathIsWritable(path)); + callback.Run(FileError::OK, base::PathIsWritable(path)); } void DirectoryImpl::Flush(const FlushCallback& callback) { base::File file(directory_path_, base::File::FLAG_READ); if (!file.IsValid()) { - callback.Run(FILE_ERROR_FAILED); + callback.Run(FileError::FAILED); return; } if (!file.Flush()) { - callback.Run(FILE_ERROR_FAILED); + callback.Run(FileError::FAILED); return; } - callback.Run(FILE_ERROR_OK); + callback.Run(FileError::OK); } } // namespace filesystem
diff --git a/components/filesystem/directory_impl_unittest.cc b/components/filesystem/directory_impl_unittest.cc index 53fc2b7..a5638b7 100644 --- a/components/filesystem/directory_impl_unittest.cc +++ b/components/filesystem/directory_impl_unittest.cc
@@ -33,31 +33,31 @@ {"my_file2", kFlagWrite | kFlagCreate}, {"my_file3", kFlagAppend | kFlagCreate }}; for (size_t i = 0; i < arraysize(files_to_create); i++) { - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile(files_to_create[i].name, nullptr, files_to_create[i].open_flags, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); } // Make a directory. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenDirectory( "my_dir", nullptr, kFlagRead | kFlagWrite | kFlagCreate, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); - error = FILE_ERROR_FAILED; + error = FileError::FAILED; mojo::Array<DirectoryEntryPtr> directory_contents; directory->Read(Capture(&error, &directory_contents)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Expected contents of the directory. std::map<std::string, FsFileType> expected_contents; - expected_contents["my_file1"] = FS_FILE_TYPE_REGULAR_FILE; - expected_contents["my_file2"] = FS_FILE_TYPE_REGULAR_FILE; - expected_contents["my_file3"] = FS_FILE_TYPE_REGULAR_FILE; - expected_contents["my_dir"] = FS_FILE_TYPE_DIRECTORY; + expected_contents["my_file1"] = FsFileType::REGULAR_FILE; + expected_contents["my_file2"] = FsFileType::REGULAR_FILE; + expected_contents["my_file3"] = FsFileType::REGULAR_FILE; + expected_contents["my_dir"] = FsFileType::DIRECTORY; // Note: We don't expose ".." or ".". EXPECT_EQ(expected_contents.size(), directory_contents.size()); @@ -79,50 +79,50 @@ FileError error; // Create my_file. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", nullptr, kFlagWrite | kFlagCreate, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Opening my_file should succeed. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", nullptr, kFlagRead | kFlagOpen, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Rename my_file to my_new_file. directory->Rename("my_file", "my_new_file", Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Opening my_file should fail. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", nullptr, kFlagRead | kFlagOpen, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_FAILED, error); + EXPECT_EQ(FileError::FAILED, error); // Opening my_new_file should succeed. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_new_file", nullptr, kFlagRead | kFlagOpen, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Delete my_new_file (no flags). directory->Delete("my_new_file", 0, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Opening my_new_file should fail. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_new_file", nullptr, kFlagRead | kFlagOpen, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_FAILED, error); + EXPECT_EQ(FileError::FAILED, error); } TEST_F(DirectoryImplTest, CantOpenDirectoriesAsFiles) { @@ -133,23 +133,23 @@ { // Create a directory called 'my_file' DirectoryPtr my_file_directory; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenDirectory( "my_file", GetProxy(&my_file_directory), kFlagRead | kFlagWrite | kFlagCreate, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); } { // Attempt to open that directory as a file. This must fail! FilePtr file; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file), kFlagRead | kFlagOpen, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_NOT_A_FILE, error); + EXPECT_EQ(FileError::NOT_A_FILE, error); } }
diff --git a/components/filesystem/file_impl.cc b/components/filesystem/file_impl.cc index 9ba2c45..1d6b7e2 100644 --- a/components/filesystem/file_impl.cc +++ b/components/filesystem/file_impl.cc
@@ -48,7 +48,7 @@ } file_.Close(); - callback.Run(FILE_ERROR_OK); + callback.Run(FileError::OK); } // TODO(vtl): Move the implementation to a thread pool. @@ -61,20 +61,22 @@ return; } if (num_bytes_to_read > kMaxReadSize) { - callback.Run(FILE_ERROR_INVALID_OPERATION, mojo::Array<uint8_t>()); + callback.Run(FileError::INVALID_OPERATION, mojo::Array<uint8_t>()); return; } - if (FileError error = IsOffsetValid(offset)) { + FileError error = IsOffsetValid(offset); + if (error != FileError::OK) { callback.Run(error, mojo::Array<uint8_t>()); return; } - if (FileError error = IsWhenceValid(whence)) { + error = IsWhenceValid(whence); + if (error != FileError::OK) { callback.Run(error, mojo::Array<uint8_t>()); return; } if (file_.Seek(static_cast<base::File::Whence>(whence), offset) == -1) { - callback.Run(FILE_ERROR_FAILED, mojo::Array<uint8_t>()); + callback.Run(FileError::FAILED, mojo::Array<uint8_t>()); return; } @@ -82,13 +84,13 @@ int num_bytes_read = file_.ReadAtCurrentPos( reinterpret_cast<char*>(&bytes_read.front()), num_bytes_to_read); if (num_bytes_read < 0) { - callback.Run(FILE_ERROR_FAILED, mojo::Array<uint8_t>()); + callback.Run(FileError::FAILED, mojo::Array<uint8_t>()); return; } DCHECK_LE(static_cast<size_t>(num_bytes_read), num_bytes_to_read); bytes_read.resize(static_cast<size_t>(num_bytes_read)); - callback.Run(FILE_ERROR_OK, std::move(bytes_read)); + callback.Run(FileError::OK, std::move(bytes_read)); } // TODO(vtl): Move the implementation to a thread pool. @@ -109,20 +111,22 @@ #else static_cast<size_t>(std::numeric_limits<ssize_t>::max())) { #endif - callback.Run(FILE_ERROR_INVALID_OPERATION, 0); + callback.Run(FileError::INVALID_OPERATION, 0); return; } - if (FileError error = IsOffsetValid(offset)) { + FileError error = IsOffsetValid(offset); + if (error != FileError::OK) { callback.Run(error, 0); return; } - if (FileError error = IsWhenceValid(whence)) { + error = IsWhenceValid(whence); + if (error != FileError::OK) { callback.Run(error, 0); return; } if (file_.Seek(static_cast<base::File::Whence>(whence), offset) == -1) { - callback.Run(FILE_ERROR_FAILED, 0); + callback.Run(FileError::FAILED, 0); return; } @@ -132,17 +136,17 @@ int num_bytes_written = file_.WriteAtCurrentPos( buf, static_cast<int>(bytes_to_write.size())); if (num_bytes_written < 0) { - callback.Run(FILE_ERROR_FAILED, 0); + callback.Run(FileError::FAILED, 0); return; } DCHECK_LE(static_cast<size_t>(num_bytes_written), std::numeric_limits<uint32_t>::max()); - callback.Run(FILE_ERROR_OK, static_cast<uint32_t>(num_bytes_written)); + callback.Run(FileError::OK, static_cast<uint32_t>(num_bytes_written)); } void FileImpl::Tell(const TellCallback& callback) { - Seek(0, WHENCE_FROM_CURRENT, callback); + Seek(0, Whence::FROM_CURRENT, callback); } void FileImpl::Seek(int64_t offset, @@ -152,11 +156,13 @@ callback.Run(GetError(file_), 0); return; } - if (FileError error = IsOffsetValid(offset)) { + FileError error = IsOffsetValid(offset); + if (error != FileError::OK) { callback.Run(error, 0); return; } - if (FileError error = IsWhenceValid(whence)) { + error = IsWhenceValid(whence); + if (error != FileError::OK) { callback.Run(error, 0); return; } @@ -164,11 +170,11 @@ int64_t position = file_.Seek(static_cast<base::File::Whence>(whence), offset); if (position < 0) { - callback.Run(FILE_ERROR_FAILED, 0); + callback.Run(FileError::FAILED, 0); return; } - callback.Run(FILE_ERROR_OK, static_cast<int64_t>(position)); + callback.Run(FileError::OK, static_cast<int64_t>(position)); } void FileImpl::Stat(const StatCallback& callback) { @@ -179,11 +185,11 @@ base::File::Info info; if (!file_.GetInfo(&info)) { - callback.Run(FILE_ERROR_FAILED, nullptr); + callback.Run(FileError::FAILED, nullptr); return; } - callback.Run(FILE_ERROR_OK, MakeFileInformation(info)); + callback.Run(FileError::OK, MakeFileInformation(info)); } void FileImpl::Truncate(int64_t size, const TruncateCallback& callback) { @@ -192,20 +198,21 @@ return; } if (size < 0) { - callback.Run(FILE_ERROR_INVALID_OPERATION); + callback.Run(FileError::INVALID_OPERATION); return; } - if (FileError error = IsOffsetValid(size)) { + FileError error = IsOffsetValid(size); + if (error != FileError::OK) { callback.Run(error); return; } if (!file_.SetLength(size)) { - callback.Run(FILE_ERROR_NOT_FOUND); + callback.Run(FileError::NOT_FOUND); return; } - callback.Run(FILE_ERROR_OK); + callback.Run(FileError::OK); } void FileImpl::Touch(TimespecOrNowPtr atime, @@ -220,7 +227,7 @@ if (!atime) { base::File::Info info; if (!file_.GetInfo(&info)) { - callback.Run(FILE_ERROR_FAILED); + callback.Run(FileError::FAILED); return; } @@ -233,7 +240,7 @@ if (!mtime) { base::File::Info info; if (!file_.GetInfo(&info)) { - callback.Run(FILE_ERROR_FAILED); + callback.Run(FileError::FAILED); return; } @@ -243,7 +250,7 @@ } file_.SetTimes(base_atime, base_mtime); - callback.Run(FILE_ERROR_OK); + callback.Run(FileError::OK); } void FileImpl::Dup(mojo::InterfaceRequest<File> file, @@ -261,7 +268,7 @@ if (file.is_pending()) new FileImpl(std::move(file), std::move(new_file)); - callback.Run(FILE_ERROR_OK); + callback.Run(FileError::OK); } void FileImpl::Flush(const FlushCallback& callback) { @@ -271,7 +278,7 @@ } bool ret = file_.Flush(); - callback.Run(ret ? FILE_ERROR_OK : FILE_ERROR_FAILED); + callback.Run(ret ? FileError::OK : FileError::FAILED); } void FileImpl::AsHandle(const AsHandleCallback& callback) { @@ -288,7 +295,7 @@ base::File::Info info; if (!new_file.GetInfo(&info)) { - callback.Run(FILE_ERROR_FAILED, ScopedHandle()); + callback.Run(FileError::FAILED, ScopedHandle()); return; } @@ -297,7 +304,7 @@ // passing a file descriptor to a directory is a sandbox escape on Windows, // we should be absolutely paranoid. if (info.is_directory) { - callback.Run(FILE_ERROR_NOT_A_FILE, ScopedHandle()); + callback.Run(FileError::NOT_A_FILE, ScopedHandle()); return; } @@ -305,11 +312,11 @@ MojoResult create_result = MojoCreatePlatformHandleWrapper( new_file.TakePlatformFile(), &mojo_handle); if (create_result != MOJO_RESULT_OK) { - callback.Run(FILE_ERROR_FAILED, ScopedHandle()); + callback.Run(FileError::FAILED, ScopedHandle()); return; } - callback.Run(FILE_ERROR_OK, ScopedHandle(mojo::Handle(mojo_handle))); + callback.Run(FileError::OK, ScopedHandle(mojo::Handle(mojo_handle))); } } // namespace filesystem
diff --git a/components/filesystem/file_impl_unittest.cc b/components/filesystem/file_impl_unittest.cc index e56a3bf..1396799 100644 --- a/components/filesystem/file_impl_unittest.cc +++ b/components/filesystem/file_impl_unittest.cc
@@ -29,11 +29,11 @@ { // Create my_file. FilePtr file; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file), kFlagWrite | kFlagCreate, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Write to it. std::vector<uint8_t> bytes_to_write; @@ -42,42 +42,42 @@ bytes_to_write.push_back(static_cast<uint8_t>('l')); bytes_to_write.push_back(static_cast<uint8_t>('l')); bytes_to_write.push_back(static_cast<uint8_t>('o')); - error = FILE_ERROR_FAILED; + error = FileError::FAILED; uint32_t num_bytes_written = 0; file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - WHENCE_FROM_CURRENT, Capture(&error, &num_bytes_written)); + Whence::FROM_CURRENT, Capture(&error, &num_bytes_written)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); // Close it. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; file->Close(Capture(&error)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); } // Rename it. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->Rename("my_file", "your_file", Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); { // Open my_file again. FilePtr file; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("your_file", GetProxy(&file), kFlagRead | kFlagOpen, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Read from it. mojo::Array<uint8_t> bytes_read; - error = FILE_ERROR_FAILED; - file->Read(3, 1, WHENCE_FROM_BEGIN, Capture(&error, &bytes_read)); + error = FileError::FAILED; + file->Read(3, 1, Whence::FROM_BEGIN, Capture(&error, &bytes_read)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); ASSERT_EQ(3u, bytes_read.size()); EXPECT_EQ(static_cast<uint8_t>('e'), bytes_read[0]); EXPECT_EQ(static_cast<uint8_t>('l'), bytes_read[1]); @@ -102,52 +102,52 @@ { // Create my_file. FilePtr file; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file), kFlagWrite | kFlagCreate, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Write to it. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; uint32_t num_bytes_written = 0; file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - WHENCE_FROM_CURRENT, Capture(&error, &num_bytes_written)); + Whence::FROM_CURRENT, Capture(&error, &num_bytes_written)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); // Close it. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; file->Close(Capture(&error)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); } { // Open my_file again, this time with read only mode. FilePtr file; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file), kFlagRead | kFlagOpen, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Try to write in read mode; it should fail. - error = FILE_ERROR_OK; + error = FileError::OK; uint32_t num_bytes_written = 0; file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - WHENCE_FROM_CURRENT, Capture(&error, &num_bytes_written)); + Whence::FROM_CURRENT, Capture(&error, &num_bytes_written)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_FAILED, error); + EXPECT_EQ(FileError::FAILED, error); EXPECT_EQ(0u, num_bytes_written); // Close it. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; file->Close(Capture(&error)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); } } @@ -159,11 +159,11 @@ { // Create my_file. FilePtr file; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file), kFlagWrite | kFlagCreate, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Write to it. std::vector<uint8_t> bytes_to_write; @@ -172,29 +172,29 @@ bytes_to_write.push_back(static_cast<uint8_t>('l')); bytes_to_write.push_back(static_cast<uint8_t>('l')); bytes_to_write.push_back(static_cast<uint8_t>('o')); - error = FILE_ERROR_FAILED; + error = FileError::FAILED; uint32_t num_bytes_written = 0; file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - WHENCE_FROM_CURRENT, Capture(&error, &num_bytes_written)); + Whence::FROM_CURRENT, Capture(&error, &num_bytes_written)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); // Close it. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; file->Close(Capture(&error)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); } { // Append to my_file. FilePtr file; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file), kFlagAppend | kFlagOpen, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Write to it. std::vector<uint8_t> bytes_to_write; @@ -205,36 +205,36 @@ bytes_to_write.push_back(static_cast<uint8_t>('b')); bytes_to_write.push_back(static_cast<uint8_t>('y')); bytes_to_write.push_back(static_cast<uint8_t>('e')); - error = FILE_ERROR_FAILED; + error = FileError::FAILED; uint32_t num_bytes_written = 0; file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - WHENCE_FROM_CURRENT, Capture(&error, &num_bytes_written)); + Whence::FROM_CURRENT, Capture(&error, &num_bytes_written)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); // Close it. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; file->Close(Capture(&error)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); } { // Open my_file again. FilePtr file; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file), kFlagRead | kFlagOpen, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Read from it. mojo::Array<uint8_t> bytes_read; - error = FILE_ERROR_FAILED; - file->Read(12, 0, WHENCE_FROM_BEGIN, Capture(&error, &bytes_read)); + error = FileError::FAILED; + file->Read(12, 0, Whence::FROM_BEGIN, Capture(&error, &bytes_read)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); ASSERT_EQ(12u, bytes_read.size()); EXPECT_EQ(static_cast<uint8_t>('l'), bytes_read[3]); EXPECT_EQ(static_cast<uint8_t>('o'), bytes_read[4]); @@ -251,11 +251,11 @@ { // Create my_file. FilePtr file; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file), kFlagWrite | kFlagCreate, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Write to it. std::vector<uint8_t> bytes_to_write; @@ -264,29 +264,29 @@ bytes_to_write.push_back(static_cast<uint8_t>('l')); bytes_to_write.push_back(static_cast<uint8_t>('l')); bytes_to_write.push_back(static_cast<uint8_t>('o')); - error = FILE_ERROR_FAILED; + error = FileError::FAILED; uint32_t num_bytes_written = 0; file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - WHENCE_FROM_CURRENT, Capture(&error, &num_bytes_written)); + Whence::FROM_CURRENT, Capture(&error, &num_bytes_written)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); // Close it. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; file->Close(Capture(&error)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); } { // Append to my_file. FilePtr file; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file), kFlagWrite | kFlagOpenTruncated, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Write to it. std::vector<uint8_t> bytes_to_write; @@ -297,36 +297,36 @@ bytes_to_write.push_back(static_cast<uint8_t>('b')); bytes_to_write.push_back(static_cast<uint8_t>('y')); bytes_to_write.push_back(static_cast<uint8_t>('e')); - error = FILE_ERROR_FAILED; + error = FileError::FAILED; uint32_t num_bytes_written = 0; file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - WHENCE_FROM_CURRENT, Capture(&error, &num_bytes_written)); + Whence::FROM_CURRENT, Capture(&error, &num_bytes_written)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); // Close it. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; file->Close(Capture(&error)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); } { // Open my_file again. FilePtr file; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file), kFlagRead | kFlagOpen, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Read from it. mojo::Array<uint8_t> bytes_read; - error = FILE_ERROR_FAILED; - file->Read(7, 0, WHENCE_FROM_BEGIN, Capture(&error, &bytes_read)); + error = FileError::FAILED; + file->Read(7, 0, Whence::FROM_BEGIN, Capture(&error, &bytes_read)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); ASSERT_EQ(7u, bytes_read.size()); EXPECT_EQ(static_cast<uint8_t>('g'), bytes_read[0]); EXPECT_EQ(static_cast<uint8_t>('o'), bytes_read[1]); @@ -344,41 +344,41 @@ // Create my_file. FilePtr file; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file), kFlagWrite | kFlagCreate, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Stat it. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; FileInformationPtr file_info; file->Stat(Capture(&error, &file_info)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); ASSERT_FALSE(file_info.is_null()); - EXPECT_EQ(FS_FILE_TYPE_REGULAR_FILE, file_info->type); + EXPECT_EQ(FsFileType::REGULAR_FILE, file_info->type); EXPECT_EQ(0, file_info->size); EXPECT_GT(file_info->atime, 0); // Expect that it's not 1970-01-01. EXPECT_GT(file_info->mtime, 0); double first_mtime = file_info->mtime; // Touch only the atime. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; TimespecOrNowPtr t(TimespecOrNow::New()); t->now = false; const int64_t kPartyTime1 = 1234567890; // Party like it's 2009-02-13. t->seconds = kPartyTime1; file->Touch(std::move(t), nullptr, Capture(&error)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Stat again. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; file_info.reset(); file->Stat(Capture(&error, &file_info)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); ASSERT_FALSE(file_info.is_null()); EXPECT_EQ(kPartyTime1, file_info->atime); EXPECT_EQ(first_mtime, file_info->mtime); @@ -390,14 +390,14 @@ t->seconds = kPartyTime2; file->Touch(nullptr, std::move(t), Capture(&error)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Stat again. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; file_info.reset(); file->Stat(Capture(&error, &file_info)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); ASSERT_FALSE(file_info.is_null()); EXPECT_EQ(kPartyTime1, file_info->atime); EXPECT_EQ(kPartyTime2, file_info->mtime); @@ -414,78 +414,78 @@ // Create my_file. FilePtr file; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file), kFlagWrite | kFlagCreate, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Write to it. std::vector<uint8_t> bytes_to_write(1000, '!'); - error = FILE_ERROR_FAILED; + error = FileError::FAILED; uint32_t num_bytes_written = 0; file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - WHENCE_FROM_CURRENT, Capture(&error, &num_bytes_written)); + Whence::FROM_CURRENT, Capture(&error, &num_bytes_written)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); const int size = static_cast<int>(num_bytes_written); // Tell. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; int64_t position = -1; file->Tell(Capture(&error, &position)); ASSERT_TRUE(file.WaitForIncomingResponse()); // Should be at the end. - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(size, position); // Seek back 100. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; position = -1; - file->Seek(-100, WHENCE_FROM_CURRENT, Capture(&error, &position)); + file->Seek(-100, Whence::FROM_CURRENT, Capture(&error, &position)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(size - 100, position); // Tell. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; position = -1; file->Tell(Capture(&error, &position)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(size - 100, position); // Seek to 123 from start. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; position = -1; - file->Seek(123, WHENCE_FROM_BEGIN, Capture(&error, &position)); + file->Seek(123, Whence::FROM_BEGIN, Capture(&error, &position)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(123, position); // Tell. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; position = -1; file->Tell(Capture(&error, &position)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(123, position); // Seek to 123 back from end. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; position = -1; - file->Seek(-123, WHENCE_FROM_END, Capture(&error, &position)); + file->Seek(-123, Whence::FROM_END, Capture(&error, &position)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(size - 123, position); // Tell. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; position = -1; file->Tell(Capture(&error, &position)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(size - 123, position); // TODO(vtl): Check that seeking actually affects reading/writing. @@ -499,11 +499,11 @@ // Create my_file. FilePtr file1; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file1), kFlagRead | kFlagWrite | kFlagCreate, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Write to it. std::vector<uint8_t> bytes_to_write; @@ -512,28 +512,28 @@ bytes_to_write.push_back(static_cast<uint8_t>('l')); bytes_to_write.push_back(static_cast<uint8_t>('l')); bytes_to_write.push_back(static_cast<uint8_t>('o')); - error = FILE_ERROR_FAILED; + error = FileError::FAILED; uint32_t num_bytes_written = 0; file1->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - WHENCE_FROM_CURRENT, Capture(&error, &num_bytes_written)); + Whence::FROM_CURRENT, Capture(&error, &num_bytes_written)); ASSERT_TRUE(file1.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); const int end_hello_pos = static_cast<int>(num_bytes_written); // Dup it. FilePtr file2; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; file1->Dup(GetProxy(&file2), Capture(&error)); ASSERT_TRUE(file1.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // |file2| should have the same position. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; int64_t position = -1; file2->Tell(Capture(&error, &position)); ASSERT_TRUE(file2.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(end_hello_pos, position); // Write using |file2|. @@ -543,35 +543,35 @@ more_bytes_to_write.push_back(static_cast<uint8_t>('r')); more_bytes_to_write.push_back(static_cast<uint8_t>('l')); more_bytes_to_write.push_back(static_cast<uint8_t>('d')); - error = FILE_ERROR_FAILED; + error = FileError::FAILED; num_bytes_written = 0; file2->Write(mojo::Array<uint8_t>::From(more_bytes_to_write), 0, - WHENCE_FROM_CURRENT, Capture(&error, &num_bytes_written)); + Whence::FROM_CURRENT, Capture(&error, &num_bytes_written)); ASSERT_TRUE(file2.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(more_bytes_to_write.size(), num_bytes_written); const int end_world_pos = end_hello_pos + static_cast<int>(num_bytes_written); // |file1| should have the same position. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; position = -1; file1->Tell(Capture(&error, &position)); ASSERT_TRUE(file1.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(end_world_pos, position); // Close |file1|. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; file1->Close(Capture(&error)); ASSERT_TRUE(file1.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Read everything using |file2|. mojo::Array<uint8_t> bytes_read; - error = FILE_ERROR_FAILED; - file2->Read(1000, 0, WHENCE_FROM_BEGIN, Capture(&error, &bytes_read)); + error = FileError::FAILED; + file2->Read(1000, 0, Whence::FROM_BEGIN, Capture(&error, &bytes_read)); ASSERT_TRUE(file2.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); ASSERT_EQ(static_cast<size_t>(end_world_pos), bytes_read.size()); // Just check the first and last bytes. EXPECT_EQ(static_cast<uint8_t>('h'), bytes_read[0]); @@ -590,43 +590,43 @@ // Create my_file. FilePtr file; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file), kFlagWrite | kFlagCreate, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Write to it. std::vector<uint8_t> bytes_to_write(kInitialSize, '!'); - error = FILE_ERROR_FAILED; + error = FileError::FAILED; uint32_t num_bytes_written = 0; file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - WHENCE_FROM_CURRENT, Capture(&error, &num_bytes_written)); + Whence::FROM_CURRENT, Capture(&error, &num_bytes_written)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); EXPECT_EQ(kInitialSize, num_bytes_written); // Stat it. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; FileInformationPtr file_info; file->Stat(Capture(&error, &file_info)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); ASSERT_FALSE(file_info.is_null()); EXPECT_EQ(kInitialSize, file_info->size); // Truncate it. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; file->Truncate(kTruncatedSize, Capture(&error)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Stat again. - error = FILE_ERROR_FAILED; + error = FileError::FAILED; file_info.reset(); file->Stat(Capture(&error, &file_info)); ASSERT_TRUE(file.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); ASSERT_FALSE(file_info.is_null()); EXPECT_EQ(kTruncatedSize, file_info->size); } @@ -639,18 +639,18 @@ { // Create my_file. FilePtr file1; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file1), kFlagRead | kFlagWrite | kFlagCreate, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Fetch the handle - error = FILE_ERROR_FAILED; + error = FileError::FAILED; mojo::ScopedHandle handle; file1->AsHandle(Capture(&error, &handle)); ASSERT_TRUE(file1.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Pull a file descriptor out of the scoped handle. MojoPlatformHandle platform_handle; @@ -667,18 +667,18 @@ { // Reopen my_file. FilePtr file2; - error = FILE_ERROR_FAILED; + error = FileError::FAILED; directory->OpenFile("my_file", GetProxy(&file2), kFlagRead | kFlagOpen, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); // Verify that we wrote data raw on the file descriptor. mojo::Array<uint8_t> bytes_read; - error = FILE_ERROR_FAILED; - file2->Read(5, 0, WHENCE_FROM_BEGIN, Capture(&error, &bytes_read)); + error = FileError::FAILED; + file2->Read(5, 0, Whence::FROM_BEGIN, Capture(&error, &bytes_read)); ASSERT_TRUE(file2.WaitForIncomingResponse()); - EXPECT_EQ(FILE_ERROR_OK, error); + EXPECT_EQ(FileError::OK, error); ASSERT_EQ(5u, bytes_read.size()); EXPECT_EQ(static_cast<uint8_t>('h'), bytes_read[0]); EXPECT_EQ(static_cast<uint8_t>('e'), bytes_read[1]);
diff --git a/components/filesystem/file_system_impl.cc b/components/filesystem/file_system_impl.cc index 90497764..88de84c 100644 --- a/components/filesystem/file_system_impl.cc +++ b/components/filesystem/file_system_impl.cc
@@ -90,9 +90,9 @@ DirectoryImpl* dir_impl = new DirectoryImpl(std::move(directory), path, std::move(temp_dir)); app_->RegisterDirectoryToClient(dir_impl, std::move(client)); - callback.Run(FILE_ERROR_OK); + callback.Run(FileError::OK); } else { - callback.Run(FILE_ERROR_FAILED); + callback.Run(FileError::FAILED); } }
diff --git a/components/filesystem/files_test_base.cc b/components/filesystem/files_test_base.cc index d57acf24..6b73a37 100644 --- a/components/filesystem/files_test_base.cc +++ b/components/filesystem/files_test_base.cc
@@ -31,11 +31,11 @@ filesystem::FileSystemClientPtr client; binding_.Bind(GetProxy(&client)); - FileError error = FILE_ERROR_FAILED; + FileError error = FileError::FAILED; files()->OpenFileSystem("temp", GetProxy(directory), std::move(client), mojo::Capture(&error)); ASSERT_TRUE(files().WaitForIncomingResponse()); - ASSERT_EQ(FILE_ERROR_OK, error); + ASSERT_EQ(FileError::OK, error); } } // namespace filesystem
diff --git a/components/filesystem/util.cc b/components/filesystem/util.cc index c1c9e36..16bef00 100644 --- a/components/filesystem/util.cc +++ b/components/filesystem/util.cc
@@ -48,83 +48,83 @@ ""); // filesystem.Error in types.mojom must be the same as base::File::Error. -static_assert(static_cast<int>(filesystem::FILE_ERROR_OK) == +static_assert(static_cast<int>(filesystem::FileError::OK) == static_cast<int>(base::File::FILE_OK), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_FAILED) == +static_assert(static_cast<int>(filesystem::FileError::FAILED) == static_cast<int>(base::File::FILE_ERROR_FAILED), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_IN_USE) == +static_assert(static_cast<int>(filesystem::FileError::IN_USE) == static_cast<int>(base::File::FILE_ERROR_IN_USE), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_EXISTS) == +static_assert(static_cast<int>(filesystem::FileError::EXISTS) == static_cast<int>(base::File::FILE_ERROR_EXISTS), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_NOT_FOUND) == +static_assert(static_cast<int>(filesystem::FileError::NOT_FOUND) == static_cast<int>(base::File::FILE_ERROR_NOT_FOUND), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_ACCESS_DENIED) == +static_assert(static_cast<int>(filesystem::FileError::ACCESS_DENIED) == static_cast<int>(base::File::FILE_ERROR_ACCESS_DENIED), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_TOO_MANY_OPENED) == +static_assert(static_cast<int>(filesystem::FileError::TOO_MANY_OPENED) == static_cast<int>(base::File::FILE_ERROR_TOO_MANY_OPENED), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_NO_MEMORY) == +static_assert(static_cast<int>(filesystem::FileError::NO_MEMORY) == static_cast<int>(base::File::FILE_ERROR_NO_MEMORY), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_NO_SPACE) == +static_assert(static_cast<int>(filesystem::FileError::NO_SPACE) == static_cast<int>(base::File::FILE_ERROR_NO_SPACE), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_NOT_A_DIRECTORY) == +static_assert(static_cast<int>(filesystem::FileError::NOT_A_DIRECTORY) == static_cast<int>(base::File::FILE_ERROR_NOT_A_DIRECTORY), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_INVALID_OPERATION) == +static_assert(static_cast<int>(filesystem::FileError::INVALID_OPERATION) == static_cast<int>(base::File::FILE_ERROR_INVALID_OPERATION), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_SECURITY) == +static_assert(static_cast<int>(filesystem::FileError::SECURITY) == static_cast<int>(base::File::FILE_ERROR_SECURITY), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_ABORT) == +static_assert(static_cast<int>(filesystem::FileError::ABORT) == static_cast<int>(base::File::FILE_ERROR_ABORT), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_NOT_A_FILE) == +static_assert(static_cast<int>(filesystem::FileError::NOT_A_FILE) == static_cast<int>(base::File::FILE_ERROR_NOT_A_FILE), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_NOT_EMPTY) == +static_assert(static_cast<int>(filesystem::FileError::NOT_EMPTY) == static_cast<int>(base::File::FILE_ERROR_NOT_EMPTY), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_INVALID_URL) == +static_assert(static_cast<int>(filesystem::FileError::INVALID_URL) == static_cast<int>(base::File::FILE_ERROR_INVALID_URL), ""); -static_assert(static_cast<int>(filesystem::FILE_ERROR_IO) == +static_assert(static_cast<int>(filesystem::FileError::IO) == static_cast<int>(base::File::FILE_ERROR_IO), ""); // filesystem.Whence in types.mojom must be the same as base::File::Whence. -static_assert(static_cast<int>(filesystem::WHENCE_FROM_BEGIN) == +static_assert(static_cast<int>(filesystem::Whence::FROM_BEGIN) == static_cast<int>(base::File::FROM_BEGIN), ""); -static_assert(static_cast<int>(filesystem::WHENCE_FROM_CURRENT) == +static_assert(static_cast<int>(filesystem::Whence::FROM_CURRENT) == static_cast<int>(base::File::FROM_CURRENT), ""); -static_assert(static_cast<int>(filesystem::WHENCE_FROM_END) == +static_assert(static_cast<int>(filesystem::Whence::FROM_END) == static_cast<int>(base::File::FROM_END), ""); namespace filesystem { FileError IsWhenceValid(Whence whence) { - return (whence == WHENCE_FROM_CURRENT || whence == WHENCE_FROM_BEGIN || - whence == WHENCE_FROM_END) - ? FILE_ERROR_OK - : FILE_ERROR_INVALID_OPERATION; + return (whence == Whence::FROM_CURRENT || whence == Whence::FROM_BEGIN || + whence == Whence::FROM_END) + ? FileError::OK + : FileError::INVALID_OPERATION; } FileError IsOffsetValid(int64_t offset) { return (offset >= std::numeric_limits<off_t>::min() && offset <= std::numeric_limits<off_t>::max()) - ? FILE_ERROR_OK - : FILE_ERROR_INVALID_OPERATION; + ? FileError::OK + : FileError::INVALID_OPERATION; } FileError GetError(const base::File& file) { @@ -134,7 +134,7 @@ FileInformationPtr MakeFileInformation(const base::File::Info& info) { FileInformationPtr file_info(FileInformation::New()); file_info->type = - info.is_directory ? FS_FILE_TYPE_DIRECTORY : FS_FILE_TYPE_REGULAR_FILE; + info.is_directory ? FsFileType::DIRECTORY : FsFileType::REGULAR_FILE; file_info->size = info.size; file_info->atime = info.last_accessed.ToDoubleT(); @@ -149,7 +149,7 @@ base::FilePath* out) { DCHECK(!raw_path.is_null()); if (!base::IsStringUTF8(raw_path.get())) - return FILE_ERROR_INVALID_OPERATION; + return FileError::INVALID_OPERATION; #if defined(OS_POSIX) base::FilePath::StringType path = raw_path; @@ -164,11 +164,11 @@ base::FilePath full_path = filesystem_base.Append(path); if (full_path.ReferencesParent()) { // TODO(erg): For now, if it references a parent, we'll consider this bad. - return FILE_ERROR_ACCESS_DENIED; + return FileError::ACCESS_DENIED; } *out = full_path; - return FILE_ERROR_OK; + return FileError::OK; } } // namespace filesystem
diff --git a/components/font_service/font_service_app.cc b/components/font_service/font_service_app.cc index 21c688f..74768a1 100644 --- a/components/font_service/font_service_app.cc +++ b/components/font_service/font_service_app.cc
@@ -12,17 +12,17 @@ #include "mojo/shell/public/cpp/application_connection.h" static_assert(static_cast<uint32_t>(SkTypeface::kNormal) == - static_cast<uint32_t>(font_service::TYPEFACE_STYLE_NORMAL), + static_cast<uint32_t>(font_service::TypefaceStyle::NORMAL), "Skia and font service flags must match"); static_assert(static_cast<uint32_t>(SkTypeface::kBold) == - static_cast<uint32_t>(font_service::TYPEFACE_STYLE_BOLD), + static_cast<uint32_t>(font_service::TypefaceStyle::BOLD), "Skia and font service flags must match"); static_assert(static_cast<uint32_t>(SkTypeface::kItalic) == - static_cast<uint32_t>(font_service::TYPEFACE_STYLE_ITALIC), + static_cast<uint32_t>(font_service::TypefaceStyle::ITALIC), "Skia and font service flags must match"); static_assert( static_cast<uint32_t>(SkTypeface::kBoldItalic) == - static_cast<uint32_t>(font_service::TYPEFACE_STYLE_BOLD_ITALIC), + static_cast<uint32_t>(font_service::TypefaceStyle::BOLD_ITALIC), "Skia and font service flags must match"); namespace { @@ -86,7 +86,7 @@ &result_identity, &result_family, &result_style); if (!r) { - callback.Run(nullptr, "", TYPEFACE_STYLE_NORMAL); + callback.Run(nullptr, "", TypefaceStyle::NORMAL); return; }
diff --git a/components/html_viewer/ax_provider_apptest.cc b/components/html_viewer/ax_provider_apptest.cc index 44ce4d64..87b57a6 100644 --- a/components/html_viewer/ax_provider_apptest.cc +++ b/components/html_viewer/ax_provider_apptest.cc
@@ -107,7 +107,7 @@ connection->ConnectToService(&frame_client); frame_client->OnConnect( std::move(frame_ptr), 1u, embed_window->id(), - web_view::mojom::WINDOW_CONNECT_TYPE_USE_NEW, std::move(array), + web_view::mojom::WindowConnectType::USE_NEW, std::move(array), base::TimeTicks::Now().ToInternalValue(), base::Closure()); // Connect to the AxProvider of the HTML document and get the AxTree.
diff --git a/components/html_viewer/blink_text_input_type_converters.cc b/components/html_viewer/blink_text_input_type_converters.cc index 959660eb..26bd20b 100644 --- a/components/html_viewer/blink_text_input_type_converters.cc +++ b/components/html_viewer/blink_text_input_type_converters.cc
@@ -11,7 +11,7 @@ namespace mojo { #define TEXT_INPUT_TYPE_ASSERT(NAME, Name) \ - static_assert(static_cast<int32_t>(TEXT_INPUT_TYPE_##NAME) == \ + static_assert(static_cast<int32_t>(TextInputType::NAME) == \ static_cast<int32_t>(blink::WebTextInputType##Name), \ "text_input_type should match") TEXT_INPUT_TYPE_ASSERT(NONE, None); @@ -31,7 +31,7 @@ TEXT_INPUT_TYPE_ASSERT(TEXT_AREA, TextArea); #define TEXT_INPUT_FLAG_ASSERT(NAME, Name) \ - static_assert(static_cast<int32_t>(TEXT_INPUT_FLAG_##NAME) == \ + static_assert(static_cast<int32_t>(TextInputFlag::NAME) == \ static_cast<int32_t>(blink::WebTextInputFlag##Name), \ "text_input_flag should match") TEXT_INPUT_FLAG_ASSERT(NONE, None);
diff --git a/components/html_viewer/document_resource_waiter.cc b/components/html_viewer/document_resource_waiter.cc index a9c3a0f..c7bbece 100644 --- a/components/html_viewer/document_resource_waiter.cc +++ b/components/html_viewer/document_resource_waiter.cc
@@ -24,7 +24,7 @@ root_(nullptr), change_id_(0u), window_id_(0u), - window_connect_type_(web_view::mojom::WINDOW_CONNECT_TYPE_USE_NEW), + window_connect_type_(web_view::mojom::WindowConnectType::USE_NEW), frame_client_binding_(this), is_ready_(false), waiting_for_change_id_(false), @@ -100,7 +100,7 @@ bool is_ready = (!frame_data_.is_null() && ((window_connect_type_ == - web_view::mojom::WINDOW_CONNECT_TYPE_USE_EXISTING) || + web_view::mojom::WindowConnectType::USE_EXISTING) || (root_ && root_->viewport_metrics().device_pixel_ratio != 0.0f))); if (is_ready) { HTMLFrameTreeManager* frame_tree =
diff --git a/components/html_viewer/html_frame.cc b/components/html_viewer/html_frame.cc index 22f3ca98..3da5aeba 100644 --- a/components/html_viewer/html_frame.cc +++ b/components/html_viewer/html_frame.cc
@@ -84,14 +84,14 @@ blink::WebNavigationPolicy policy) { switch (policy) { case blink::WebNavigationPolicyCurrentTab: - return web_view::mojom::NAVIGATION_TARGET_TYPE_EXISTING_FRAME; + return web_view::mojom::NavigationTargetType::EXISTING_FRAME; case blink::WebNavigationPolicyNewBackgroundTab: case blink::WebNavigationPolicyNewForegroundTab: case blink::WebNavigationPolicyNewWindow: case blink::WebNavigationPolicyNewPopup: - return web_view::mojom::NAVIGATION_TARGET_TYPE_NEW_FRAME; + return web_view::mojom::NavigationTargetType::NEW_FRAME; default: - return web_view::mojom::NAVIGATION_TARGET_TYPE_NO_PREFERENCE; + return web_view::mojom::NavigationTargetType::NO_PREFERENCE; } } @@ -788,12 +788,12 @@ touch_handler_.reset(new TouchHandler(web_widget)); if (touch_handler_ && - (event->action == mus::mojom::EVENT_TYPE_POINTER_DOWN || - event->action == mus::mojom::EVENT_TYPE_POINTER_UP || - event->action == mus::mojom::EVENT_TYPE_POINTER_CANCEL || - event->action == mus::mojom::EVENT_TYPE_POINTER_MOVE) && + (event->action == mus::mojom::EventType::POINTER_DOWN || + event->action == mus::mojom::EventType::POINTER_UP || + event->action == mus::mojom::EventType::POINTER_CANCEL || + event->action == mus::mojom::EventType::POINTER_MOVE) && event->pointer_data && - event->pointer_data->kind == mus::mojom::POINTER_KIND_TOUCH) { + event->pointer_data->kind == mus::mojom::PointerKind::TOUCH) { touch_handler_->OnTouchEvent(*event); return; } @@ -1018,7 +1018,7 @@ NOTIMPLEMENTED(); // for |should_replace_current_entry mojo::URLRequestPtr url_request = mojo::URLRequest::From(request); GetServerFrame()->RequestNavigate( - web_view::mojom::NAVIGATION_TARGET_TYPE_EXISTING_FRAME, id_, + web_view::mojom::NavigationTargetType::EXISTING_FRAME, id_, std::move(url_request)); }
diff --git a/components/html_viewer/html_frame_tree_manager.cc b/components/html_viewer/html_frame_tree_manager.cc index 58d7122..1323b5ff 100644 --- a/components/html_viewer/html_frame_tree_manager.cc +++ b/components/html_viewer/html_frame_tree_manager.cc
@@ -100,10 +100,9 @@ DVLOG(2) << "HTMLFrameTreeManager::CreateFrameAndAttachToTree " << " frame_tree=" << frame_tree << " use_existing=" << (window_connect_type == - web_view::mojom::WINDOW_CONNECT_TYPE_USE_EXISTING) + web_view::mojom::WindowConnectType::USE_EXISTING) << " frame_id=" << window_id; - if (window_connect_type == - web_view::mojom::WINDOW_CONNECT_TYPE_USE_EXISTING && + if (window_connect_type == web_view::mojom::WindowConnectType::USE_EXISTING && !frame_tree) { DVLOG(1) << "was told to use existing window but do not have frame tree"; return nullptr; @@ -114,7 +113,7 @@ frame_tree->Init(delegate, window, frame_data, change_id); (*instances_)[frame_data[0]->frame_id] = frame_tree; } else if (window_connect_type == - web_view::mojom::WINDOW_CONNECT_TYPE_USE_EXISTING) { + web_view::mojom::WindowConnectType::USE_EXISTING) { HTMLFrame* existing_frame = frame_tree->root_->FindFrame(window_id); if (!existing_frame) { DVLOG(1) << "was told to use existing window but could not find window";
diff --git a/components/html_viewer/input_events_unittest.cc b/components/html_viewer/input_events_unittest.cc index 4a28bbec..f5c16ca5 100644 --- a/components/html_viewer/input_events_unittest.cc +++ b/components/html_viewer/input_events_unittest.cc
@@ -26,8 +26,8 @@ mus::mojom::EventPtr mojo_event(mus::mojom::Event::From(*mouseev)); - EXPECT_EQ(mus::mojom::EVENT_TYPE_POINTER_DOWN, mojo_event->action); - EXPECT_EQ(mus::mojom::POINTER_KIND_MOUSE, mojo_event->pointer_data->kind); + EXPECT_EQ(mus::mojom::EventType::POINTER_DOWN, mojo_event->action); + EXPECT_EQ(mus::mojom::PointerKind::MOUSE, mojo_event->pointer_data->kind); scoped_ptr<blink::WebInputEvent> webevent = mojo_event.To<scoped_ptr<blink::WebInputEvent>>(); @@ -52,7 +52,7 @@ mus::mojom::EventPtr mojo_event(mus::mojom::Event::From(*original_wheel)); - EXPECT_EQ(mus::mojom::EVENT_TYPE_WHEEL, mojo_event->action); + EXPECT_EQ(mus::mojom::EventType::WHEEL, mojo_event->action); // Exercise the blink converter. scoped_ptr<blink::WebInputEvent> webevent =
diff --git a/components/html_viewer/touch_handler.cc b/components/html_viewer/touch_handler.cc index 88a0d5df..ff1253f 100644 --- a/components/html_viewer/touch_handler.cc +++ b/components/html_viewer/touch_handler.cc
@@ -30,8 +30,8 @@ } if (event.pointer_data && event.pointer_data->brush_data && - (event.pointer_data->kind == mus::mojom::POINTER_KIND_TOUCH || - event.pointer_data->kind == mus::mojom::POINTER_KIND_PEN)) { + (event.pointer_data->kind == mus::mojom::PointerKind::TOUCH || + event.pointer_data->kind == mus::mojom::PointerKind::PEN)) { properties->pressure = event.pointer_data->brush_data->pressure; // TODO(rjkroege): vary orientation for width, height. @@ -39,9 +39,9 @@ event.pointer_data->brush_data->height, 0.0); } else { - if (event.flags & mus::mojom::EVENT_FLAGS_LEFT_MOUSE_BUTTON || - event.flags & mus::mojom::EVENT_FLAGS_MIDDLE_MOUSE_BUTTON || - event.flags & mus::mojom::EVENT_FLAGS_MIDDLE_MOUSE_BUTTON) { + if (event.flags & mus::mojom::kEventFlagLeftMouseButton || + event.flags & mus::mojom::kEventFlagMiddleMouseButton || + event.flags & mus::mojom::kEventFlagMiddleMouseButton) { properties->pressure = 0.5; } else { properties->pressure = 0.0; @@ -97,7 +97,7 @@ } switch (event.action) { - case mus::mojom::EVENT_TYPE_POINTER_DOWN: + case mus::mojom::EventType::POINTER_DOWN: if (!current_motion_event_.get()) { current_motion_event_.reset(new ui::MotionEventGeneric( ui::MotionEvent::ACTION_DOWN, timestamp, properties)); @@ -115,7 +115,7 @@ } return true; - case mus::mojom::EVENT_TYPE_POINTER_UP: { + case mus::mojom::EventType::POINTER_UP: { if (!current_motion_event_.get()) { DVLOG(1) << "pointer up with no event, id=" << properties.id; return false; @@ -135,7 +135,7 @@ return true; } - case mus::mojom::EVENT_TYPE_POINTER_MOVE: { + case mus::mojom::EventType::POINTER_MOVE: { if (!current_motion_event_.get()) { DVLOG(1) << "pointer move with no event, id=" << properties.id; return false; @@ -152,7 +152,7 @@ return true; } - case mus::mojom::EVENT_TYPE_POINTER_CANCEL: { + case mus::mojom::EventType::POINTER_CANCEL: { if (!current_motion_event_.get()) { DVLOG(1) << "canel with no event, id=" << properties.id; return false; @@ -190,7 +190,7 @@ void TouchHandler::PostProcessMotionEvent(const mus::mojom::Event& event) { switch (event.action) { - case mus::mojom::EVENT_TYPE_POINTER_UP: { + case mus::mojom::EventType::POINTER_UP: { if (event.pointer_data) { const int index = current_motion_event_->FindPointerIndexOfId( event.pointer_data->pointer_id); @@ -201,7 +201,7 @@ break; } - case mus::mojom::EVENT_TYPE_POINTER_CANCEL: + case mus::mojom::EventType::POINTER_CANCEL: current_motion_event_.reset(); break;
diff --git a/components/html_viewer/web_clipboard_impl.cc b/components/html_viewer/web_clipboard_impl.cc index 33053cfb..35b3153 100644 --- a/components/html_viewer/web_clipboard_impl.cc +++ b/components/html_viewer/web_clipboard_impl.cc
@@ -176,7 +176,7 @@ Map<String, Array<uint8_t>> data; data[Clipboard::MIME_TYPE_TEXT] = Array<uint8_t>::From(plain_text); - clipboard_->WriteClipboardData(Clipboard::TYPE_COPY_PASTE, std::move(data)); + clipboard_->WriteClipboardData(Clipboard::Type::COPY_PASTE, std::move(data)); } void WebClipboardImpl::writeHTML(const blink::WebString& html_text, @@ -191,19 +191,19 @@ if (writeSmartPaste) data[kMimeTypeWebkitSmartPaste] = Array<uint8_t>::From(blink::WebString()); - clipboard_->WriteClipboardData(Clipboard::TYPE_COPY_PASTE, std::move(data)); + clipboard_->WriteClipboardData(Clipboard::Type::COPY_PASTE, std::move(data)); } Clipboard::Type WebClipboardImpl::ConvertBufferType(Buffer buffer) { switch (buffer) { case BufferStandard: - return Clipboard::TYPE_COPY_PASTE; + return Clipboard::Type::COPY_PASTE; case BufferSelection: - return Clipboard::TYPE_SELECTION; + return Clipboard::Type::SELECTION; } NOTREACHED(); - return Clipboard::TYPE_COPY_PASTE; + return Clipboard::Type::COPY_PASTE; } } // namespace html_viewer
diff --git a/components/html_viewer/web_layer_tree_view_impl.cc b/components/html_viewer/web_layer_tree_view_impl.cc index 90e8103..72e2985 100644 --- a/components/html_viewer/web_layer_tree_view_impl.cc +++ b/components/html_viewer/web_layer_tree_view_impl.cc
@@ -76,7 +76,7 @@ new mus::ContextProvider(cb.PassInterface().PassHandle())); output_surface_.reset(new mus::OutputSurface( context_provider, - window_->RequestSurface(mus::mojom::SURFACE_TYPE_DEFAULT))); + window_->RequestSurface(mus::mojom::SurfaceType::DEFAULT))); } layer_tree_host_->SetVisible(window_->visible()); }
diff --git a/components/html_viewer/web_socket_handle_impl.cc b/components/html_viewer/web_socket_handle_impl.cc index e33aeaf4..e2520d2 100644 --- a/components/html_viewer/web_socket_handle_impl.cc +++ b/components/html_viewer/web_socket_handle_impl.cc
@@ -43,14 +43,14 @@ typedef WebSocket::MessageType MessageType; static_assert( static_cast<MessageType>(WebSocketHandle::MessageTypeContinuation) == - WebSocket::MESSAGE_TYPE_CONTINUATION, + WebSocket::MessageType::CONTINUATION, "WebSocket and WebSocketHandle enum values must match"); static_assert(static_cast<MessageType>(WebSocketHandle::MessageTypeText) == - WebSocket::MESSAGE_TYPE_TEXT, + WebSocket::MessageType::TEXT, "WebSocket and WebSocketHandle enum values must match"); static_assert( static_cast<MessageType>(WebSocketHandle::MessageTypeBinary) == - WebSocket::MESSAGE_TYPE_BINARY, + WebSocket::MessageType::BINARY, "WebSocket and WebSocketHandle enum values must match"); return static_cast<WebSocket::MessageType>(type); } @@ -59,9 +59,9 @@ template<> struct TypeConverter<WebSocketHandle::MessageType, WebSocket::MessageType> { static WebSocketHandle::MessageType Convert(WebSocket::MessageType type) { - DCHECK(type == WebSocket::MESSAGE_TYPE_CONTINUATION || - type == WebSocket::MESSAGE_TYPE_TEXT || - type == WebSocket::MESSAGE_TYPE_BINARY); + DCHECK(type == WebSocket::MessageType::CONTINUATION || + type == WebSocket::MessageType::TEXT || + type == WebSocket::MessageType::BINARY); return static_cast<WebSocketHandle::MessageType>(type); } };
diff --git a/components/mus/common/transient_window_utils.h b/components/mus/common/transient_window_utils.h index 042e11dd..17eedc63a 100644 --- a/components/mus/common/transient_window_utils.h +++ b/components/mus/common/transient_window_utils.h
@@ -78,7 +78,7 @@ FindCommonTransientAncestor(child, target); // When stacking above skip to the topmost transient descendant of the target. - if (*direction == mojom::ORDER_DIRECTION_ABOVE && + if (*direction == mojom::OrderDirection::ABOVE && !HasTransientAncestor(*child, *target)) { const std::vector<T*>& siblings((*child)->parent()->children()); size_t target_i = @@ -116,7 +116,7 @@ if ((*it) != window && HasTransientAncestor(*it, window)) { T* old_stacking_target = *GetStackingTarget(*it); *GetStackingTarget(*it) = window; - Reorder(*it, window, mojom::ORDER_DIRECTION_ABOVE); + Reorder(*it, window, mojom::OrderDirection::ABOVE); *GetStackingTarget(*it) = old_stacking_target; } }
diff --git a/components/mus/gles2/command_buffer_impl.cc b/components/mus/gles2/command_buffer_impl.cc index 06ca0c5..3666522 100644 --- a/components/mus/gles2/command_buffer_impl.cc +++ b/components/mus/gles2/command_buffer_impl.cc
@@ -130,24 +130,6 @@ base::Unretained(this), id)); } -void CommandBufferImpl::InsertSyncPoint( - bool retire, - const mojom::CommandBuffer::InsertSyncPointCallback& callback) { - uint32_t sync_point = gpu_state_->sync_point_manager()->GenerateSyncPoint(); - sync_points_.push_back(sync_point); - callback.Run(sync_point); - if (retire) - RetireSyncPoint(sync_point); -} - -void CommandBufferImpl::RetireSyncPoint(uint32_t sync_point) { - DCHECK(!sync_points_.empty() && sync_points_.front() == sync_point); - sync_points_.pop_front(); - gpu_state_->command_buffer_task_runner()->PostTask( - driver_.get(), base::Bind(&CommandBufferImpl::RetireSyncPointOnGpuThread, - base::Unretained(this), sync_point)); -} - void CommandBufferImpl::CreateImage(int32_t id, mojo::ScopedHandle memory_handle, int32_t type, @@ -245,12 +227,6 @@ return true; } -bool CommandBufferImpl::RetireSyncPointOnGpuThread(uint32_t sync_point) { - DCHECK(driver_->IsScheduled()); - gpu_state_->sync_point_manager()->RetireSyncPoint(sync_point); - return true; -} - bool CommandBufferImpl::CreateImageOnGpuThread(int32_t id, mojo::ScopedHandle memory_handle, int32_t type,
diff --git a/components/mus/gles2/command_buffer_impl.h b/components/mus/gles2/command_buffer_impl.h index 6cb84f8..e4ea15b 100644 --- a/components/mus/gles2/command_buffer_impl.h +++ b/components/mus/gles2/command_buffer_impl.h
@@ -54,10 +54,6 @@ mojo::ScopedSharedBufferHandle transfer_buffer, uint32_t size) override; void DestroyTransferBuffer(int32_t id) override; - void InsertSyncPoint( - bool retire, - const mojom::CommandBuffer::InsertSyncPointCallback& callback) override; - void RetireSyncPoint(uint32_t sync_point) override; void CreateImage(int32_t id, mojo::ScopedHandle memory_handle, int32_t type, @@ -82,7 +78,6 @@ mojo::ScopedSharedBufferHandle transfer_buffer, uint32_t size); bool DestroyTransferBufferOnGpuThread(int32_t id); - bool RetireSyncPointOnGpuThread(uint32_t sync_point); bool CreateImageOnGpuThread(int32_t id, mojo::ScopedHandle memory_handle, int32_t type,
diff --git a/components/mus/gles2/command_buffer_local.cc b/components/mus/gles2/command_buffer_local.cc index 834722c..0615e76 100644 --- a/components/mus/gles2/command_buffer_local.cc +++ b/components/mus/gles2/command_buffer_local.cc
@@ -62,12 +62,6 @@ return true; } -void PostTask( - const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, - const base::Closure& callback) { - task_runner->PostTask(FROM_HERE, callback); -} - } const unsigned int GL_READ_WRITE_CHROMIUM = 0x78F2; @@ -296,34 +290,22 @@ } uint32_t CommandBufferLocal::InsertSyncPoint() { - DCHECK(CalledOnValidThread()); - uint32_t sync_point = gpu_state_->sync_point_manager()->GenerateSyncPoint(); - sync_points_.push_back(sync_point); - RetireSyncPoint(sync_point); - return sync_point; + NOTREACHED(); + return 0; } uint32_t CommandBufferLocal::InsertFutureSyncPoint() { - DCHECK(CalledOnValidThread()); - uint32_t sync_point = gpu_state_->sync_point_manager()->GenerateSyncPoint(); - sync_points_.push_back(sync_point); - return sync_point; + NOTREACHED(); + return 0; } void CommandBufferLocal::RetireSyncPoint(uint32_t sync_point) { - DCHECK(CalledOnValidThread()); - DCHECK(!sync_points_.empty() && sync_points_.front() == sync_point); - sync_points_.pop_front(); - gpu_state_->command_buffer_task_runner()->PostTask( - driver_.get(), base::Bind(&CommandBufferLocal::RetireSyncPointOnGpuThread, - base::Unretained(this), sync_point)); + NOTREACHED(); } void CommandBufferLocal::SignalSyncPoint(uint32_t sync_point, const base::Closure& callback) { - DCHECK(CalledOnValidThread()); - gpu_state_->sync_point_manager()->AddSyncPointCallback(sync_point, - base::Bind(&PostTask, client_thread_task_runner_, callback)); + NOTREACHED(); } void CommandBufferLocal::SignalQuery(uint32_t query, @@ -428,10 +410,7 @@ } } -CommandBufferLocal::~CommandBufferLocal() { - for (uint32_t sync_point : sync_points_) - gpu_state_->sync_point_manager()->RetireSyncPoint(sync_point); -} +CommandBufferLocal::~CommandBufferLocal() {} void CommandBufferLocal::TryUpdateState() { if (last_state_.error == gpu::error::kNoError) @@ -512,12 +491,6 @@ return true; } -bool CommandBufferLocal::RetireSyncPointOnGpuThread(uint32_t sync_point) { - DCHECK(driver_->IsScheduled()); - gpu_state_->sync_point_manager()->RetireSyncPoint(sync_point); - return true; -} - bool CommandBufferLocal::CreateImageOnGpuThread( int32_t id, mojo::ScopedHandle memory_handle,
diff --git a/components/mus/gles2/command_buffer_local.h b/components/mus/gles2/command_buffer_local.h index f234c86..d3f5401 100644 --- a/components/mus/gles2/command_buffer_local.h +++ b/components/mus/gles2/command_buffer_local.h
@@ -123,7 +123,6 @@ mojo::ScopedSharedBufferHandle transfer_buffer, uint32_t size); bool DestroyTransferBufferOnGpuThread(int32_t id); - bool RetireSyncPointOnGpuThread(uint32_t sync_point); bool CreateImageOnGpuThread(int32_t id, mojo::ScopedHandle memory_handle, int32_t type, @@ -144,7 +143,6 @@ scoped_ptr<CommandBufferDriver> driver_; CommandBufferLocalClient* client_; scoped_refptr<base::SingleThreadTaskRunner> client_thread_task_runner_; - std::deque<uint32_t> sync_points_; // Members accessed on the client thread: gpu::CommandBuffer::State last_state_;
diff --git a/components/mus/public/cpp/event_matcher.h b/components/mus/public/cpp/event_matcher.h index d25dc38..d6e25cb 100644 --- a/components/mus/public/cpp/event_matcher.h +++ b/components/mus/public/cpp/event_matcher.h
@@ -11,8 +11,9 @@ namespace mus { -mojom::EventMatcherPtr CreateKeyMatcher(mojom::KeyboardCode code, - mojom::EventFlags flags); +// |flags| is a bitfield of kEventFlag* and kMouseEventFlag* values in +// input_event_constants.mojom. +mojom::EventMatcherPtr CreateKeyMatcher(mojom::KeyboardCode code, int flags); } // namespace mus
diff --git a/components/mus/public/cpp/lib/event_matcher.cc b/components/mus/public/cpp/lib/event_matcher.cc index 0c39714..eeafcac 100644 --- a/components/mus/public/cpp/lib/event_matcher.cc +++ b/components/mus/public/cpp/lib/event_matcher.cc
@@ -6,21 +6,19 @@ namespace mus { -mojom::EventMatcherPtr CreateKeyMatcher(mojom::KeyboardCode code, - mojom::EventFlags flags) { +mojom::EventMatcherPtr CreateKeyMatcher(mojom::KeyboardCode code, int flags) { mojom::EventMatcherPtr matcher(mojom::EventMatcher::New()); matcher->type_matcher = mojom::EventTypeMatcher::New(); matcher->flags_matcher = mojom::EventFlagsMatcher::New(); matcher->ignore_flags_matcher = mojom::EventFlagsMatcher::New(); // Ignoring these makes most accelerator scenarios more straight forward. Code // that needs to check them can override this setting. - matcher->ignore_flags_matcher->flags = - static_cast<mojom::EventFlags>(mojom::EVENT_FLAGS_NUM_LOCK_ON | - mojom::EVENT_FLAGS_CAPS_LOCK_ON | - mojom::EVENT_FLAGS_SCROLL_LOCK_ON); + matcher->ignore_flags_matcher->flags = mojom::kEventFlagCapsLockOn | + mojom::kEventFlagScrollLockOn | + mojom::kEventFlagNumLockOn; matcher->key_matcher = mojom::KeyEventMatcher::New(); - matcher->type_matcher->type = mus::mojom::EVENT_TYPE_KEY_PRESSED; + matcher->type_matcher->type = mus::mojom::EventType::KEY_PRESSED; matcher->flags_matcher->flags = flags; matcher->key_matcher->keyboard_code = code; return matcher;
diff --git a/components/mus/public/cpp/lib/in_flight_change.h b/components/mus/public/cpp/lib/in_flight_change.h index 2773ef6..d92c300 100644 --- a/components/mus/public/cpp/lib/in_flight_change.h +++ b/components/mus/public/cpp/lib/in_flight_change.h
@@ -19,7 +19,7 @@ namespace mus { namespace mojom { -enum Cursor : int32_t; +enum class Cursor : int32_t; } class Window;
diff --git a/components/mus/public/cpp/lib/window.cc b/components/mus/public/cpp/lib/window.cc index 4885537b..ba6b77f7 100644 --- a/components/mus/public/cpp/lib/window.cc +++ b/components/mus/public/cpp/lib/window.cc
@@ -308,13 +308,13 @@ void Window::MoveToFront() { if (!parent_ || parent_->children_.back() == this) return; - Reorder(parent_->children_.back(), mojom::ORDER_DIRECTION_ABOVE); + Reorder(parent_->children_.back(), mojom::OrderDirection::ABOVE); } void Window::MoveToBack() { if (!parent_ || parent_->children_.front() == this) return; - Reorder(parent_->children_.front(), mojom::ORDER_DIRECTION_BELOW); + Reorder(parent_->children_.front(), mojom::OrderDirection::BELOW); } bool Window::Contains(Window* child) const { @@ -368,7 +368,7 @@ void Window::SetImeVisibility(bool visible, mojo::TextInputStatePtr state) { // SetImeVisibility() shouldn't be used if the window is not editable. - DCHECK(state.is_null() || state->type != mojo::TEXT_INPUT_TYPE_NONE); + DCHECK(state.is_null() || state->type != mojo::TextInputType::NONE); if (connection_) tree_client()->SetImeVisibility(id_, visible, std::move(state)); } @@ -388,7 +388,7 @@ } void Window::Embed(mus::mojom::WindowTreeClientPtr client) { - Embed(std::move(client), mus::mojom::WindowTree::ACCESS_POLICY_DEFAULT, + Embed(std::move(client), mus::mojom::WindowTree::kAccessPolicyDefault, base::Bind(&EmptyEmbedCallback)); } @@ -483,7 +483,7 @@ input_event_handler_(nullptr), viewport_metrics_(CreateEmptyViewportMetrics()), visible_(false), - cursor_id_(mojom::CURSOR_NULL), + cursor_id_(mojom::Cursor::CURSOR_NULL), drawn_(false) {} WindowTreeClientImpl* Window::tree_client() { @@ -791,15 +791,15 @@ std::find(window->parent_->children_.begin(), window->parent_->children_.end(), relative) - window->parent_->children_.begin(); - if ((direction == mojom::ORDER_DIRECTION_ABOVE && child_i == target_i + 1) || - (direction == mojom::ORDER_DIRECTION_BELOW && child_i + 1 == target_i)) { + if ((direction == mojom::OrderDirection::ABOVE && child_i == target_i + 1) || + (direction == mojom::OrderDirection::BELOW && child_i + 1 == target_i)) { return false; } if (notifier) notifier->NotifyWindowReordering(); - const size_t dest_i = direction == mojom::ORDER_DIRECTION_ABOVE + const size_t dest_i = direction == mojom::OrderDirection::ABOVE ? (child_i < target_i ? target_i : target_i + 1) : (child_i < target_i ? target_i - 1 : target_i); window->parent_->children_.erase(window->parent_->children_.begin() +
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 d647587..5b02c73 100644 --- a/components/mus/public/cpp/lib/window_tree_client_impl.cc +++ b/components/mus/public/cpp/lib/window_tree_client_impl.cc
@@ -424,7 +424,7 @@ tree_ = window_tree; connection_id_ = connection_id; is_embed_root_ = - (access_policy & mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT) != 0; + (access_policy & mojom::WindowTree::kAccessPolicyEmbedRoot) != 0; DCHECK(roots_.empty()); Window* root = AddWindowToConnection(this, nullptr, root_data);
diff --git a/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc b/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc index 0845442b..669baf9c 100644 --- a/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc +++ b/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc
@@ -83,7 +83,7 @@ public: WindowTreeSetup() : tree_client_(&window_tree_delegate_, nullptr, nullptr) { WindowTreeClientImplPrivate(&tree_client_) - .Init(&window_tree_, mojom::WindowTree::ACCESS_POLICY_DEFAULT); + .Init(&window_tree_, mojom::WindowTree::kAccessPolicyDefault); window_tree_.GetAndClearChangeId(nullptr); }
diff --git a/components/mus/public/cpp/tests/window_unittest.cc b/components/mus/public/cpp/tests/window_unittest.cc index 5b706582..09172c6 100644 --- a/components/mus/public/cpp/tests/window_unittest.cc +++ b/components/mus/public/cpp/tests/window_unittest.cc
@@ -516,11 +516,11 @@ ASSERT_EQ(2U, changes.size()); EXPECT_EQ(&w11, changes[0].window); EXPECT_EQ(&w13, changes[0].relative_window); - EXPECT_EQ(mojom::ORDER_DIRECTION_ABOVE, changes[0].direction); + EXPECT_EQ(mojom::OrderDirection::ABOVE, changes[0].direction); EXPECT_EQ(&w11, changes[1].window); EXPECT_EQ(&w13, changes[1].relative_window); - EXPECT_EQ(mojom::ORDER_DIRECTION_ABOVE, changes[1].direction); + EXPECT_EQ(mojom::OrderDirection::ABOVE, changes[1].direction); } { @@ -536,11 +536,11 @@ ASSERT_EQ(2U, changes.size()); EXPECT_EQ(&w11, changes[0].window); EXPECT_EQ(&w12, changes[0].relative_window); - EXPECT_EQ(mojom::ORDER_DIRECTION_BELOW, changes[0].direction); + EXPECT_EQ(mojom::OrderDirection::BELOW, changes[0].direction); EXPECT_EQ(&w11, changes[1].window); EXPECT_EQ(&w12, changes[1].relative_window); - EXPECT_EQ(mojom::ORDER_DIRECTION_BELOW, changes[1].direction); + EXPECT_EQ(mojom::OrderDirection::BELOW, changes[1].direction); } { @@ -548,7 +548,7 @@ // Move w11 above w12. // Resulting order: w12. w11, w13 - w11.Reorder(&w12, mojom::ORDER_DIRECTION_ABOVE); + w11.Reorder(&w12, mojom::OrderDirection::ABOVE); EXPECT_EQ(&w12, w1.children().front()); EXPECT_EQ(&w13, w1.children().back()); @@ -556,11 +556,11 @@ ASSERT_EQ(2U, changes.size()); EXPECT_EQ(&w11, changes[0].window); EXPECT_EQ(&w12, changes[0].relative_window); - EXPECT_EQ(mojom::ORDER_DIRECTION_ABOVE, changes[0].direction); + EXPECT_EQ(mojom::OrderDirection::ABOVE, changes[0].direction); EXPECT_EQ(&w11, changes[1].window); EXPECT_EQ(&w12, changes[1].relative_window); - EXPECT_EQ(mojom::ORDER_DIRECTION_ABOVE, changes[1].direction); + EXPECT_EQ(mojom::OrderDirection::ABOVE, changes[1].direction); } { @@ -568,7 +568,7 @@ // Move w11 below w12. // Resulting order: w11, w12, w13 - w11.Reorder(&w12, mojom::ORDER_DIRECTION_BELOW); + w11.Reorder(&w12, mojom::OrderDirection::BELOW); EXPECT_EQ(&w11, w1.children().front()); EXPECT_EQ(&w13, w1.children().back()); @@ -576,11 +576,11 @@ ASSERT_EQ(2U, changes.size()); EXPECT_EQ(&w11, changes[0].window); EXPECT_EQ(&w12, changes[0].relative_window); - EXPECT_EQ(mojom::ORDER_DIRECTION_BELOW, changes[0].direction); + EXPECT_EQ(mojom::OrderDirection::BELOW, changes[0].direction); EXPECT_EQ(&w11, changes[1].window); EXPECT_EQ(&w12, changes[1].relative_window); - EXPECT_EQ(mojom::ORDER_DIRECTION_BELOW, changes[1].direction); + EXPECT_EQ(mojom::OrderDirection::BELOW, changes[1].direction); } } @@ -985,39 +985,39 @@ EXPECT_EQ(w22, parent->children().back()); EXPECT_EQ("1 11 2 21 211 212 213 22", ChildWindowIDsAsString(parent.get())); - w11->Reorder(w2.get(), mojom::ORDER_DIRECTION_ABOVE); + w11->Reorder(w2.get(), mojom::OrderDirection::ABOVE); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 21 211 212 213 22 1 11", ChildWindowIDsAsString(parent.get())); - w21->Reorder(w1.get(), mojom::ORDER_DIRECTION_ABOVE); + w21->Reorder(w1.get(), mojom::OrderDirection::ABOVE); EXPECT_EQ(w22, parent->children().back()); EXPECT_EQ("1 11 2 21 211 212 213 22", ChildWindowIDsAsString(parent.get())); - w21->Reorder(w22, mojom::ORDER_DIRECTION_ABOVE); + w21->Reorder(w22, mojom::OrderDirection::ABOVE); EXPECT_EQ(w213, parent->children().back()); EXPECT_EQ("1 11 2 22 21 211 212 213", ChildWindowIDsAsString(parent.get())); - w11->Reorder(w21, mojom::ORDER_DIRECTION_ABOVE); + w11->Reorder(w21, mojom::OrderDirection::ABOVE); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 211 212 213 1 11", ChildWindowIDsAsString(parent.get())); - w213->Reorder(w21, mojom::ORDER_DIRECTION_ABOVE); + w213->Reorder(w21, mojom::OrderDirection::ABOVE); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 213 211 212 1 11", ChildWindowIDsAsString(parent.get())); // No change when stacking a transient parent above its transient child. - w21->Reorder(w211, mojom::ORDER_DIRECTION_ABOVE); + w21->Reorder(w211, mojom::OrderDirection::ABOVE); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 213 211 212 1 11", ChildWindowIDsAsString(parent.get())); // This tests that the order in children_ array rather than in // transient_children_ array is used when reinserting transient children. // If transient_children_ array was used '22' would be following '21'. - w2->Reorder(w1.get(), mojom::ORDER_DIRECTION_ABOVE); + w2->Reorder(w1.get(), mojom::OrderDirection::ABOVE); EXPECT_EQ(w212, parent->children().back()); EXPECT_EQ("1 11 2 22 21 213 211 212", ChildWindowIDsAsString(parent.get())); - w11->Reorder(w213, mojom::ORDER_DIRECTION_ABOVE); + w11->Reorder(w213, mojom::OrderDirection::ABOVE); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 213 211 212 1 11", ChildWindowIDsAsString(parent.get())); } @@ -1063,36 +1063,36 @@ EXPECT_EQ(w22, parent->children().back()); EXPECT_EQ("1 11 2 21 211 212 213 22", ChildWindowIDsAsString(parent.get())); - w21->Reorder(w1.get(), mojom::ORDER_DIRECTION_BELOW); + w21->Reorder(w1.get(), mojom::OrderDirection::BELOW); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 21 211 212 213 22 1 11", ChildWindowIDsAsString(parent.get())); - w11->Reorder(w2.get(), mojom::ORDER_DIRECTION_BELOW); + w11->Reorder(w2.get(), mojom::OrderDirection::BELOW); EXPECT_EQ(w22, parent->children().back()); EXPECT_EQ("1 11 2 21 211 212 213 22", ChildWindowIDsAsString(parent.get())); - w22->Reorder(w21, mojom::ORDER_DIRECTION_BELOW); + w22->Reorder(w21, mojom::OrderDirection::BELOW); EXPECT_EQ(w213, parent->children().back()); EXPECT_EQ("1 11 2 22 21 211 212 213", ChildWindowIDsAsString(parent.get())); - w21->Reorder(w11, mojom::ORDER_DIRECTION_BELOW); + w21->Reorder(w11, mojom::OrderDirection::BELOW); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 211 212 213 1 11", ChildWindowIDsAsString(parent.get())); - w213->Reorder(w211, mojom::ORDER_DIRECTION_BELOW); + w213->Reorder(w211, mojom::OrderDirection::BELOW); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 213 211 212 1 11", ChildWindowIDsAsString(parent.get())); // No change when stacking a transient parent below its transient child. - w21->Reorder(w211, mojom::ORDER_DIRECTION_BELOW); + w21->Reorder(w211, mojom::OrderDirection::BELOW); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 213 211 212 1 11", ChildWindowIDsAsString(parent.get())); - w1->Reorder(w2.get(), mojom::ORDER_DIRECTION_BELOW); + w1->Reorder(w2.get(), mojom::OrderDirection::BELOW); EXPECT_EQ(w212, parent->children().back()); EXPECT_EQ("1 11 2 22 21 213 211 212", ChildWindowIDsAsString(parent.get())); - w213->Reorder(w11, mojom::ORDER_DIRECTION_BELOW); + w213->Reorder(w11, mojom::OrderDirection::BELOW); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 213 211 212 1 11", ChildWindowIDsAsString(parent.get())); }
diff --git a/components/mus/public/interfaces/command_buffer.mojom b/components/mus/public/interfaces/command_buffer.mojom index e61882f..dd0c9fa 100644 --- a/components/mus/public/interfaces/command_buffer.mojom +++ b/components/mus/public/interfaces/command_buffer.mojom
@@ -43,11 +43,6 @@ int32 id, handle<shared_buffer> transfer_buffer, uint32 size); DestroyTransferBuffer(int32 id); - // If |retire| is true, the sync point is retired on insertion. Otherwise, - // explicitly call RetireSyncPoint to retire it. - InsertSyncPoint(bool retire) => (uint32 sync_point); - RetireSyncPoint(uint32 sync_point); - CreateImage(int32 id, handle memory_handle, int32 type,
diff --git a/components/mus/public/interfaces/cursor.mojom b/components/mus/public/interfaces/cursor.mojom index c92aef2..878cd01 100644 --- a/components/mus/public/interfaces/cursor.mojom +++ b/components/mus/public/interfaces/cursor.mojom
@@ -9,7 +9,7 @@ enum Cursor { // NULL is kept for compatibility with chrome declarations. In chrome code, it // is treated exactly like POINTER, the default pointer. - NULL = 0, + CURSOR_NULL = 0, POINTER, CROSS, HAND,
diff --git a/components/mus/public/interfaces/input_event_constants.mojom b/components/mus/public/interfaces/input_event_constants.mojom index 85cde70..03bd80bd 100644 --- a/components/mus/public/interfaces/input_event_constants.mojom +++ b/components/mus/public/interfaces/input_event_constants.mojom
@@ -18,32 +18,28 @@ // This mirrors ui::EventFlags // TODO(morrita): Use shift operator once it is available. -enum EventFlags { - NONE = 0, - IS_SYNTHESIZED = 1, - SHIFT_DOWN = 2, - CONTROL_DOWN = 4, - ALT_DOWN = 8, - COMMAND_DOWN = 16, - ALTGR_DOWN = 32, - MOD3_DOWN = 64, - NUM_LOCK_ON = 128, - CAPS_LOCK_ON = 256, - SCROLL_LOCK_ON = 512, - LEFT_MOUSE_BUTTON = 1024, - MIDDLE_MOUSE_BUTTON = 2048, - RIGHT_MOUSE_BUTTON = 4096, - BACK_MOUSE_BUTTON = 8192, - FORWARD_MOUSE_BUTTON = 16384, -}; +const int32 kEventFlagNone = 0x00000; +const int32 kEventFlagIsSynthesized = 0x00001; +const int32 kEventFlagShiftDown = 0x00002; +const int32 kEventFlagControlDown = 0x00004; +const int32 kEventFlagAltDown = 0x00008; +const int32 kEventFlagCommandDown = 0x00010; +const int32 kEventFlagAltgrDown = 0x00020; +const int32 kEventFlagMod3Down = 0x00040; +const int32 kEventFlagNumLockOn = 0x00080; +const int32 kEventFlagCapsLockOn = 0x00100; +const int32 kEventFlagScrollLockOn = 0x00200; +const int32 kEventFlagLeftMouseButton = 0x00400; +const int32 kEventFlagMiddleMouseButton = 0x00800; +const int32 kEventFlagRightMouseButton = 0x01000; +const int32 kEventFlagBackMouseButton = 0x02000; +const int32 kEventFlagForwardMouseButton = 0x04000; -enum MouseEventFlags { - IS_DOUBLE_CLICK = 32768, - IS_TRIPLE_CLICK = 65536, - IS_NON_CLIENT = 131072, +const int32 kMouseEventFlagIsDoubleClick = 0x08000; +const int32 kMouseEventFlagIsTripleClick = 0x10000; +const int32 kMouseEventFlagIsNonClient = 0x20000; - // TODO(erg): Move accessibility flags and maybe synthetic touch events here. -}; +// TODO(erg): Move accessibility flags and maybe synthetic touch events here. enum PointerKind { MOUSE,
diff --git a/components/mus/public/interfaces/input_event_matcher.mojom b/components/mus/public/interfaces/input_event_matcher.mojom index ec223e65..3e0929da 100644 --- a/components/mus/public/interfaces/input_event_matcher.mojom +++ b/components/mus/public/interfaces/input_event_matcher.mojom
@@ -25,7 +25,9 @@ }; struct EventFlagsMatcher { - EventFlags flags; + // A bitfield of kEventFlag* and kMouseEventFlag* values in + // input_event_constants.mojom. + int32 flags; }; // If a specific matcher is missing, then an Event will match this EventMatcher @@ -33,12 +35,12 @@ // types will match this EventMatcher. Similarly, if |key_matcher| is missing, // then all key-events will match. // An example matcher to match the Ctrl+A accelerator would be: -// - |type_matcher.type| = mojo::EVENT_TYPE_KEY_PRESSED -// - |flags_matcher.flags| = mojo::EVENT_FLAGS_CONTROL_DOWN -// - |key_matcher.keyboard_code| = mojo::KEYBOARD_CODE_A +// - |type_matcher.type| = mus::mojom::EventType::KEY_PRESSED +// - |flags_matcher.flags| = mus::mojom::kEventVlagControlDown +// - |key_matcher.keyboard_code| = mus::mojom::KeyboardCode::A // // A matcher to match any key-press event would be: -// - |type_matcher.type| = mojo::EVENT_TYPE_KEY_PRESSED +// - |type_matcher.type| = mus::mojom::EventType::KEY_PRESSED struct EventMatcher { EventTypeMatcher? type_matcher; EventFlagsMatcher? flags_matcher;
diff --git a/components/mus/public/interfaces/input_events.mojom b/components/mus/public/interfaces/input_events.mojom index 3647b66..2ea63d0 100644 --- a/components/mus/public/interfaces/input_events.mojom +++ b/components/mus/public/interfaces/input_events.mojom
@@ -104,8 +104,11 @@ struct Event { // TODO(sky): rename to type. EventType action; + // A bitfield of kEventFlag* and kMouseEventFlag* values in + // input_event_constants.mojom. + // // TODO(sky): parts of this should move to PointerData. - EventFlags flags; + int32 flags; // Time in microseconds from when the platform was started. // This value accurately orders events w.r.t. to each other but // does not position them at an absolute time.
diff --git a/components/mus/public/interfaces/input_key_codes.mojom b/components/mus/public/interfaces/input_key_codes.mojom index ba3497f..48eb2000 100644 --- a/components/mus/public/interfaces/input_key_codes.mojom +++ b/components/mus/public/interfaces/input_key_codes.mojom
@@ -42,7 +42,7 @@ EXECUTE = 0x2B, SNAPSHOT = 0x2C, INSERT = 0x2D, - DELETE = 0x2E, + KEY_DELETE = 0x2E, HELP = 0x2F, NUM_0 = 0x30, NUM_1 = 0x31,
diff --git a/components/mus/public/interfaces/window_manager_constants.mojom b/components/mus/public/interfaces/window_manager_constants.mojom index ff66f0c..010b2a6f 100644 --- a/components/mus/public/interfaces/window_manager_constants.mojom +++ b/components/mus/public/interfaces/window_manager_constants.mojom
@@ -8,7 +8,7 @@ enum WindowManagerErrorCode { SUCCESS, - ERROR_ACCESS_DENIED + ACCESS_DENIED }; enum ShowState { @@ -26,12 +26,10 @@ VALUE_270, }; -enum ResizeBehavior { - NONE = 0, - CAN_RESIZE = 1, - CAN_MAXIMIZE = 2, - CAN_MINIMIZE = 4, -}; +const int32 kResizeBehaviorNone = 0; +const int32 kResizeBehaviorCanResize = 1; +const int32 kResizeBehaviorCanMaximize = 2; +const int32 kResizeBehaviorCanMinimize = 4; struct Display { int64 id;
diff --git a/components/mus/public/interfaces/window_tree.mojom b/components/mus/public/interfaces/window_tree.mojom index a1e8152c..f6126e4 100644 --- a/components/mus/public/interfaces/window_tree.mojom +++ b/components/mus/public/interfaces/window_tree.mojom
@@ -68,18 +68,16 @@ // change id in anyway, it is up to the client to assign a value and use it. // Generally the change id is an ever increasing integer. interface WindowTree { - enum AccessPolicy { - DEFAULT = 0, + const int32 kAccessPolicyDefault = 0; - // An embed root has the following abilities: - // . The app sees all the descendants of the window the app is ebmedded at, - // even those from separate connections. - // . The app is able to Embed() in all the descendants of the window the app - // is embedded at, even those from separate connections. - // Only connections originating from the WindowTreeHostFactory can grant - // this policy. - EMBED_ROOT = 1, - }; + // An embed root has the following abilities: + // . The app sees all the descendants of the window the app is ebmedded at, + // even those from separate connections. + // . The app is able to Embed() in all the descendants of the window the app + // is embedded at, even those from separate connections. + // Only connections originating from the WindowTreeHostFactory can grant + // this policy. + const int32 kAccessPolicyEmbedRoot = 1; // Creates a new window with the specified id. It is up to the client to // ensure the id is unique to the connection (the id need not be globally @@ -195,7 +193,7 @@ // longer has privileges to access or see any of the children of the window. // If the window had existing children the children are removed. The one // exception is the root connection and any connections with the policy - // ACCESS_POLICY_EMBED_ROOT. + // kAccessPolicyEmbedRoot. // // A window may only have one embedding in it at a time. Subsequent calls to // Embed() for the same window result in the currently embedded
diff --git a/components/mus/ws/default_access_policy.cc b/components/mus/ws/default_access_policy.cc index 8948462..f8efadb 100644 --- a/components/mus/ws/default_access_policy.cc +++ b/components/mus/ws/default_access_policy.cc
@@ -79,7 +79,7 @@ bool DefaultAccessPolicy::CanEmbed(const ServerWindow* window, uint32_t policy_bitmask) const { - if (policy_bitmask != mojom::WindowTree::ACCESS_POLICY_DEFAULT) + if (policy_bitmask != mojom::WindowTree::kAccessPolicyDefault) return false; return WasCreatedByThisConnection(window) || (delegate_->IsWindowKnownForAccessPolicy(window) && @@ -96,7 +96,7 @@ bool DefaultAccessPolicy::CanSetWindowSurface( const ServerWindow* window, mojom::SurfaceType surface_type) const { - if (surface_type == mojom::SURFACE_TYPE_UNDERLAY) + if (surface_type == mojom::SurfaceType::UNDERLAY) return WasCreatedByThisConnection(window); // Once a window embeds another app, the embedder app is no longer able to
diff --git a/components/mus/ws/event_dispatcher.cc b/components/mus/ws/event_dispatcher.cc index e35451415..24f9680 100644 --- a/components/mus/ws/event_dispatcher.cc +++ b/components/mus/ws/event_dispatcher.cc
@@ -22,14 +22,14 @@ namespace ws { namespace { -bool IsOnlyOneMouseButtonDown(mojom::EventFlags flags) { +bool IsOnlyOneMouseButtonDown(int flags) { const uint32_t mouse_only_flags = - flags & (mojom::EVENT_FLAGS_LEFT_MOUSE_BUTTON | - mojom::EVENT_FLAGS_MIDDLE_MOUSE_BUTTON | - mojom::EVENT_FLAGS_RIGHT_MOUSE_BUTTON); - return mouse_only_flags == mojom::EVENT_FLAGS_LEFT_MOUSE_BUTTON || - mouse_only_flags == mojom::EVENT_FLAGS_MIDDLE_MOUSE_BUTTON || - mouse_only_flags == mojom::EVENT_FLAGS_RIGHT_MOUSE_BUTTON; + flags & + (mojom::kEventFlagLeftMouseButton | mojom::kEventFlagMiddleMouseButton | + mojom::kEventFlagRightMouseButton); + return mouse_only_flags == mojom::kEventFlagLeftMouseButton || + mouse_only_flags == mojom::kEventFlagMiddleMouseButton || + mouse_only_flags == mojom::kEventFlagRightMouseButton; } bool IsLocationInNonclientArea(const ServerWindow* target, @@ -61,11 +61,11 @@ public: explicit EventMatcher(const mojom::EventMatcher& matcher) : fields_to_match_(NONE), - event_type_(mojom::EVENT_TYPE_UNKNOWN), - event_flags_(mojom::EVENT_FLAGS_NONE), - ignore_event_flags_(mojom::EVENT_FLAGS_NONE), - keyboard_code_(mojom::KEYBOARD_CODE_UNKNOWN), - pointer_kind_(mojom::POINTER_KIND_MOUSE) { + event_type_(mojom::EventType::UNKNOWN), + event_flags_(mojom::kEventFlagNone), + ignore_event_flags_(mojom::kEventFlagNone), + keyboard_code_(mojom::KeyboardCode::UNKNOWN), + pointer_kind_(mojom::PointerKind::MOUSE) { if (matcher.type_matcher) { fields_to_match_ |= TYPE; event_type_ = matcher.type_matcher->type; @@ -96,14 +96,13 @@ bool MatchesEvent(const mojom::Event& event) const { if ((fields_to_match_ & TYPE) && event.action != event_type_) return false; - mojom::EventFlags flags = - static_cast<mojom::EventFlags>(event.flags & ~ignore_event_flags_); + int flags = event.flags & ~ignore_event_flags_; if ((fields_to_match_ & FLAGS) && flags != event_flags_) return false; if (fields_to_match_ & KEYBOARD_CODE) { if (!event.key_data) return false; - if (keyboard_code_ != event.key_data->key_code) + if (static_cast<int32_t>(keyboard_code_) != event.key_data->key_code) return false; } if (fields_to_match_ & POINTER_KIND) { @@ -144,8 +143,10 @@ uint32_t fields_to_match_; mojom::EventType event_type_; - mojom::EventFlags event_flags_; - mojom::EventFlags ignore_event_flags_; + // Bitfields of kEventFlag* and kMouseEventFlag* values in + // input_event_constants.mojom. + int event_flags_; + int ignore_event_flags_; mojom::KeyboardCode keyboard_code_; mojom::PointerKind pointer_kind_; gfx::RectF pointer_region_; @@ -199,7 +200,7 @@ if (!root_) return; - if (event->action == mojom::EVENT_TYPE_KEY_PRESSED && + if (event->action == mojom::EventType::KEY_PRESSED && !event->key_data->is_char) { uint32_t accelerator = 0u; if (FindAccelerator(*event, &accelerator)) { @@ -230,9 +231,8 @@ } void EventDispatcher::ProcessPointerEvent(mojom::EventPtr event) { - const bool is_mouse_event = - event->pointer_data && - event->pointer_data->kind == mojom::PointerKind::POINTER_KIND_MOUSE; + const bool is_mouse_event = event->pointer_data && + event->pointer_data->kind == mojom::PointerKind::MOUSE; if (is_mouse_event) mouse_pointer_last_location_ = EventLocationToPoint(*event); @@ -259,9 +259,9 @@ // Release capture on pointer up. For mouse we only release if there are // no buttons down. const bool is_pointer_going_up = - (event->action == mojom::EVENT_TYPE_POINTER_UP || - event->action == mojom::EVENT_TYPE_POINTER_CANCEL) && - (event->pointer_data->kind != mojom::POINTER_KIND_MOUSE || + (event->action == mojom::EventType::POINTER_UP || + event->action == mojom::EventType::POINTER_CANCEL) && + (event->pointer_data->kind != mojom::PointerKind::MOUSE || IsOnlyOneMouseButtonDown(event->flags)); if (is_pointer_going_up && is_mouse_event) { @@ -322,11 +322,11 @@ } // The targets are changing. Send an exit if appropriate. - if (event.pointer_data->kind == mojom::POINTER_KIND_MOUSE) { + if (event.pointer_data->kind == mojom::PointerKind::MOUSE) { mojom::EventPtr exit_event = mojom::Event::New(); - exit_event->action = mojom::EVENT_TYPE_MOUSE_EXIT; + exit_event->action = mojom::EventType::MOUSE_EXIT; // TODO(sky): copy flags from existing event? - exit_event->flags = mojom::EVENT_FLAGS_NONE; + exit_event->flags = mojom::kEventFlagNone; exit_event->time_stamp = event.time_stamp; exit_event->pointer_data = mojom::PointerData::New(); exit_event->pointer_data->pointer_id = event.pointer_data->pointer_id; @@ -351,7 +351,7 @@ pointer_target.in_nonclient_area = IsLocationInNonclientArea(pointer_target.window, location); pointer_target.is_pointer_down = - event.action == mojom::EVENT_TYPE_POINTER_DOWN; + event.action == mojom::EventType::POINTER_DOWN; return pointer_target; }
diff --git a/components/mus/ws/event_dispatcher_unittest.cc b/components/mus/ws/event_dispatcher_unittest.cc index ef5d06f..04255ab7 100644 --- a/components/mus/ws/event_dispatcher_unittest.cc +++ b/components/mus/ws/event_dispatcher_unittest.cc
@@ -204,34 +204,34 @@ EventDispatcher dispatcher(&event_dispatcher_delegate); uint32_t accelerator_1 = 1; mojom::EventMatcherPtr matcher = mus::CreateKeyMatcher( - mus::mojom::KEYBOARD_CODE_W, mus::mojom::EVENT_FLAGS_CONTROL_DOWN); + mus::mojom::KeyboardCode::W, mus::mojom::kEventFlagControlDown); EXPECT_TRUE(dispatcher.AddAccelerator(accelerator_1, std::move(matcher))); uint32_t accelerator_2 = 2; - matcher = mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, - mus::mojom::EVENT_FLAGS_NONE); + matcher = mus::CreateKeyMatcher(mus::mojom::KeyboardCode::N, + mus::mojom::kEventFlagNone); EXPECT_TRUE(dispatcher.AddAccelerator(accelerator_2, std::move(matcher))); // Attempting to add a new accelerator with the same id should fail. - matcher = mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_T, - mus::mojom::EVENT_FLAGS_NONE); + matcher = mus::CreateKeyMatcher(mus::mojom::KeyboardCode::T, + mus::mojom::kEventFlagNone); EXPECT_FALSE(dispatcher.AddAccelerator(accelerator_2, std::move(matcher))); // Adding the accelerator with the same id should succeed once the existing // accelerator is removed. dispatcher.RemoveAccelerator(accelerator_2); - matcher = mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_T, - mus::mojom::EVENT_FLAGS_NONE); + matcher = mus::CreateKeyMatcher(mus::mojom::KeyboardCode::T, + mus::mojom::kEventFlagNone); EXPECT_TRUE(dispatcher.AddAccelerator(accelerator_2, std::move(matcher))); // Attempting to add an accelerator with the same matcher should fail. uint32_t accelerator_3 = 3; - matcher = mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_T, - mus::mojom::EVENT_FLAGS_NONE); + matcher = mus::CreateKeyMatcher(mus::mojom::KeyboardCode::T, + mus::mojom::kEventFlagNone); EXPECT_FALSE(dispatcher.AddAccelerator(accelerator_3, std::move(matcher))); - matcher = mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_T, - mus::mojom::EVENT_FLAGS_CONTROL_DOWN); + matcher = mus::CreateKeyMatcher(mus::mojom::KeyboardCode::T, + mus::mojom::kEventFlagControlDown); EXPECT_TRUE(dispatcher.AddAccelerator(accelerator_3, std::move(matcher))); } @@ -243,7 +243,7 @@ dispatcher.set_root(&root); mojom::EventMatcherPtr matcher = mus::CreateKeyMatcher( - mus::mojom::KEYBOARD_CODE_W, mus::mojom::EVENT_FLAGS_CONTROL_DOWN); + mus::mojom::KeyboardCode::W, mus::mojom::kEventFlagControlDown); uint32_t accelerator_1 = 1; dispatcher.AddAccelerator(accelerator_1, std::move(matcher)); @@ -265,8 +265,8 @@ EXPECT_EQ(0u, event_dispatcher_delegate.GetAndClearLastAccelerator()); uint32_t accelerator_2 = 2; - matcher = mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_W, - mus::mojom::EVENT_FLAGS_NONE); + matcher = mus::CreateKeyMatcher(mus::mojom::KeyboardCode::W, + mus::mojom::kEventFlagNone); dispatcher.AddAccelerator(accelerator_2, std::move(matcher)); dispatcher.ProcessEvent(mojom::Event::From(key)); EXPECT_EQ(accelerator_2, @@ -458,13 +458,13 @@ EXPECT_TRUE(event_dispatcher_delegate.has_queued_events()); ASSERT_EQ(&child, details->window); EXPECT_TRUE(details->in_nonclient_area); - EXPECT_EQ(mojom::EVENT_TYPE_MOUSE_EXIT, details->event->action); + EXPECT_EQ(mojom::EventType::MOUSE_EXIT, details->event->action); details = event_dispatcher_delegate.GetAndAdvanceDispatchedEventDetails(); EXPECT_FALSE(event_dispatcher_delegate.has_queued_events()); ASSERT_EQ(&child, details->window); EXPECT_FALSE(details->in_nonclient_area); - EXPECT_EQ(mojom::EVENT_TYPE_POINTER_DOWN, details->event->action); + EXPECT_EQ(mojom::EventType::POINTER_DOWN, details->event->action); } TEST(EventDispatcherTest, AdditionalClientArea) { @@ -716,14 +716,14 @@ mojom::Event::From(static_cast<const ui::Event&>(ui_event))); details = event_dispatcher_delegate.GetAndAdvanceDispatchedEventDetails(); EXPECT_EQ(&root, details->window); - EXPECT_EQ(mojom::EVENT_TYPE_MOUSE_EXIT, details->event->action); + EXPECT_EQ(mojom::EventType::MOUSE_EXIT, details->event->action); details = event_dispatcher_delegate.GetAndAdvanceDispatchedEventDetails(); ASSERT_TRUE(details); EXPECT_FALSE(event_dispatcher_delegate.has_queued_events()); EXPECT_TRUE(details->in_nonclient_area); ASSERT_EQ(&child, details->window); - EXPECT_EQ(mojom::EVENT_TYPE_POINTER_DOWN, details->event->action); + EXPECT_EQ(mojom::EventType::POINTER_DOWN, details->event->action); scoped_ptr<ui::Event> dispatched_event( details->event.To<scoped_ptr<ui::Event>>()); ASSERT_TRUE(dispatched_event.get());
diff --git a/components/mus/ws/focus_controller.cc b/components/mus/ws/focus_controller.cc index 6b01883..1415c193 100644 --- a/components/mus/ws/focus_controller.cc +++ b/components/mus/ws/focus_controller.cc
@@ -184,7 +184,7 @@ if (props.count(mojom::WindowManager::kShowState_Property)) { is_minimized = props.find(mojom::WindowManager::kShowState_Property)->second[0] == - mus::mojom::SHOW_STATE_MINIMIZED; + static_cast<int>(mus::mojom::ShowState::MINIMIZED); } if (!is_minimized) return false;
diff --git a/components/mus/ws/server_window.cc b/components/mus/ws/server_window.cc index 41e0126..518c0640 100644 --- a/components/mus/ws/server_window.cc +++ b/components/mus/ws/server_window.cc
@@ -30,7 +30,7 @@ stacking_target_(nullptr), transient_parent_(nullptr), visible_(false), - cursor_id_(mojom::CURSOR_NULL), + cursor_id_(mojom::Cursor::CURSOR_NULL), opacity_(1), can_focus_(true), properties_(properties), @@ -87,7 +87,7 @@ if (child->parent() == this) { if (children_.size() == 1) return; // Already in the right position. - child->Reorder(children_.back(), mojom::ORDER_DIRECTION_ABOVE); + child->Reorder(children_.back(), mojom::OrderDirection::ABOVE); return; } @@ -138,14 +138,14 @@ // There's nothing to do if the child is already at the bottom. if (children_.size() <= 1 || child == children_.front()) return; - child->Reorder(children_.front(), mojom::ORDER_DIRECTION_BELOW); + child->Reorder(children_.front(), mojom::OrderDirection::BELOW); } void ServerWindow::StackChildAtTop(ServerWindow* child) { // There's nothing to do if the child is already at the top. if (children_.size() <= 1 || child == children_.back()) return; - child->Reorder(children_.back(), mojom::ORDER_DIRECTION_ABOVE); + child->Reorder(children_.back(), mojom::OrderDirection::ABOVE); } void ServerWindow::SetBounds(const gfx::Rect& bounds) { @@ -408,10 +408,10 @@ window)); Windows::iterator i = std::find(window->parent_->children_.begin(), window->parent_->children_.end(), relative); - if (direction == mojom::ORDER_DIRECTION_ABOVE) { + if (direction == mojom::OrderDirection::ABOVE) { DCHECK(i != window->parent_->children_.end()); window->parent_->children_.insert(++i, window); - } else if (direction == mojom::ORDER_DIRECTION_BELOW) { + } else if (direction == mojom::OrderDirection::BELOW) { DCHECK(i != window->parent_->children_.end()); window->parent_->children_.insert(i, window); }
diff --git a/components/mus/ws/server_window.h b/components/mus/ws/server_window.h index a821aff..46a1b21b 100644 --- a/components/mus/ws/server_window.h +++ b/components/mus/ws/server_window.h
@@ -80,7 +80,7 @@ void SetClientArea(const gfx::Insets& insets, const std::vector<gfx::Rect>& additional_client_areas); - int32_t cursor() const { return cursor_id_; } + int32_t cursor() const { return static_cast<int32_t>(cursor_id_); } const ServerWindow* parent() const { return parent_; } ServerWindow* parent() { return parent_; }
diff --git a/components/mus/ws/server_window_surface_manager.cc b/components/mus/ws/server_window_surface_manager.cc index 0661209..1699de4 100644 --- a/components/mus/ws/server_window_surface_manager.cc +++ b/components/mus/ws/server_window_surface_manager.cc
@@ -25,8 +25,8 @@ return true; waiting_for_initial_frames_ = - !IsSurfaceReadyAndNonEmpty(mojom::SURFACE_TYPE_DEFAULT) || - !IsSurfaceReadyAndNonEmpty(mojom::SURFACE_TYPE_UNDERLAY); + !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::DEFAULT) || + !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::UNDERLAY); return !waiting_for_initial_frames_; } @@ -39,11 +39,11 @@ } ServerWindowSurface* ServerWindowSurfaceManager::GetDefaultSurface() { - return GetSurfaceByType(mojom::SURFACE_TYPE_DEFAULT); + return GetSurfaceByType(mojom::SurfaceType::DEFAULT); } ServerWindowSurface* ServerWindowSurfaceManager::GetUnderlaySurface() { - return GetSurfaceByType(mojom::SURFACE_TYPE_UNDERLAY); + return GetSurfaceByType(mojom::SurfaceType::UNDERLAY); } ServerWindowSurface* ServerWindowSurfaceManager::GetSurfaceByType(
diff --git a/components/mus/ws/server_window_surface_manager_test_api.cc b/components/mus/ws/server_window_surface_manager_test_api.cc index 606e556..38aba12 100644 --- a/components/mus/ws/server_window_surface_manager_test_api.cc +++ b/components/mus/ws/server_window_surface_manager_test_api.cc
@@ -16,7 +16,7 @@ ServerWindowSurfaceManagerTestApi::~ServerWindowSurfaceManagerTestApi() {} void ServerWindowSurfaceManagerTestApi::CreateEmptyDefaultSurface() { - manager_->type_to_surface_map_[mojom::SURFACE_TYPE_DEFAULT] = nullptr; + manager_->type_to_surface_map_[mojom::SurfaceType::DEFAULT] = nullptr; } void EnableHitTest(ServerWindow* window) {
diff --git a/components/mus/ws/test_change_tracker.cc b/components/mus/ws/test_change_tracker.cc index a08f923d..2ea6796 100644 --- a/components/mus/ws/test_change_tracker.cc +++ b/components/mus/ws/test_change_tracker.cc
@@ -31,7 +31,7 @@ } std::string DirectionToString(mojom::OrderDirection direction) { - return direction == mojom::ORDER_DIRECTION_ABOVE ? "above" : "below"; + return direction == mojom::OrderDirection::ABOVE ? "above" : "below"; } std::string ChangeToDescription1(const Change& change) { @@ -187,7 +187,7 @@ window_id2(0), window_id3(0), event_action(0), - direction(mojom::ORDER_DIRECTION_ABOVE), + direction(mojom::OrderDirection::ABOVE), bool_value(false), change_id(0u) {} @@ -317,7 +317,7 @@ Change change; change.type = CHANGE_TYPE_INPUT_EVENT; change.window_id = window_id; - change.event_action = event->action; + change.event_action = static_cast<int32_t>(event->action); AddChange(change); } @@ -348,7 +348,7 @@ Change change; change.type = CHANGE_TYPE_CURSOR_CHANGED; change.window_id = window_id; - change.cursor_id = cursor_id; + change.cursor_id = static_cast<int32_t>(cursor_id); AddChange(change); }
diff --git a/components/mus/ws/transient_windows_unittest.cc b/components/mus/ws/transient_windows_unittest.cc index 0c679dc..258c4f00 100644 --- a/components/mus/ws/transient_windows_unittest.cc +++ b/components/mus/ws/transient_windows_unittest.cc
@@ -153,39 +153,39 @@ EXPECT_EQ(w22, parent->children().back()); EXPECT_EQ("1 11 2 21 211 212 213 22", ChildWindowIDsAsString(parent.get())); - w11->Reorder(w2.get(), mojom::ORDER_DIRECTION_ABOVE); + w11->Reorder(w2.get(), mojom::OrderDirection::ABOVE); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 21 211 212 213 22 1 11", ChildWindowIDsAsString(parent.get())); - w21->Reorder(w1.get(), mojom::ORDER_DIRECTION_ABOVE); + w21->Reorder(w1.get(), mojom::OrderDirection::ABOVE); EXPECT_EQ(w22, parent->children().back()); EXPECT_EQ("1 11 2 21 211 212 213 22", ChildWindowIDsAsString(parent.get())); - w21->Reorder(w22, mojom::ORDER_DIRECTION_ABOVE); + w21->Reorder(w22, mojom::OrderDirection::ABOVE); EXPECT_EQ(w213, parent->children().back()); EXPECT_EQ("1 11 2 22 21 211 212 213", ChildWindowIDsAsString(parent.get())); - w11->Reorder(w21, mojom::ORDER_DIRECTION_ABOVE); + w11->Reorder(w21, mojom::OrderDirection::ABOVE); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 211 212 213 1 11", ChildWindowIDsAsString(parent.get())); - w213->Reorder(w21, mojom::ORDER_DIRECTION_ABOVE); + w213->Reorder(w21, mojom::OrderDirection::ABOVE); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 213 211 212 1 11", ChildWindowIDsAsString(parent.get())); // No change when stacking a transient parent above its transient child. - w21->Reorder(w211, mojom::ORDER_DIRECTION_ABOVE); + w21->Reorder(w211, mojom::OrderDirection::ABOVE); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 213 211 212 1 11", ChildWindowIDsAsString(parent.get())); // This tests that the order in children_ array rather than in // transient_children_ array is used when reinserting transient children. // If transient_children_ array was used '22' would be following '21'. - w2->Reorder(w1.get(), mojom::ORDER_DIRECTION_ABOVE); + w2->Reorder(w1.get(), mojom::OrderDirection::ABOVE); EXPECT_EQ(w212, parent->children().back()); EXPECT_EQ("1 11 2 22 21 213 211 212", ChildWindowIDsAsString(parent.get())); - w11->Reorder(w213, mojom::ORDER_DIRECTION_ABOVE); + w11->Reorder(w213, mojom::OrderDirection::ABOVE); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 213 211 212 1 11", ChildWindowIDsAsString(parent.get())); } @@ -241,36 +241,36 @@ EXPECT_EQ(w22, parent->children().back()); EXPECT_EQ("1 11 2 21 211 212 213 22", ChildWindowIDsAsString(parent.get())); - w21->Reorder(w1.get(), mojom::ORDER_DIRECTION_BELOW); + w21->Reorder(w1.get(), mojom::OrderDirection::BELOW); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 21 211 212 213 22 1 11", ChildWindowIDsAsString(parent.get())); - w11->Reorder(w2.get(), mojom::ORDER_DIRECTION_BELOW); + w11->Reorder(w2.get(), mojom::OrderDirection::BELOW); EXPECT_EQ(w22, parent->children().back()); EXPECT_EQ("1 11 2 21 211 212 213 22", ChildWindowIDsAsString(parent.get())); - w22->Reorder(w21, mojom::ORDER_DIRECTION_BELOW); + w22->Reorder(w21, mojom::OrderDirection::BELOW); EXPECT_EQ(w213, parent->children().back()); EXPECT_EQ("1 11 2 22 21 211 212 213", ChildWindowIDsAsString(parent.get())); - w21->Reorder(w11, mojom::ORDER_DIRECTION_BELOW); + w21->Reorder(w11, mojom::OrderDirection::BELOW); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 211 212 213 1 11", ChildWindowIDsAsString(parent.get())); - w213->Reorder(w211, mojom::ORDER_DIRECTION_BELOW); + w213->Reorder(w211, mojom::OrderDirection::BELOW); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 213 211 212 1 11", ChildWindowIDsAsString(parent.get())); // No change when stacking a transient parent below its transient child. - w21->Reorder(w211, mojom::ORDER_DIRECTION_BELOW); + w21->Reorder(w211, mojom::OrderDirection::BELOW); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 213 211 212 1 11", ChildWindowIDsAsString(parent.get())); - w1->Reorder(w2.get(), mojom::ORDER_DIRECTION_BELOW); + w1->Reorder(w2.get(), mojom::OrderDirection::BELOW); EXPECT_EQ(w212, parent->children().back()); EXPECT_EQ("1 11 2 22 21 213 211 212", ChildWindowIDsAsString(parent.get())); - w213->Reorder(w11, mojom::ORDER_DIRECTION_BELOW); + w213->Reorder(w11, mojom::OrderDirection::BELOW); EXPECT_EQ(w11, parent->children().back()); EXPECT_EQ("2 22 21 213 211 212 1 11", ChildWindowIDsAsString(parent.get())); }
diff --git a/components/mus/ws/window_finder.cc b/components/mus/ws/window_finder.cc index 6596a3e..592d753 100644 --- a/components/mus/ws/window_finder.cc +++ b/components/mus/ws/window_finder.cc
@@ -22,7 +22,7 @@ bool IsValidWindowForEvents(ServerWindow* window) { ServerWindowSurfaceManager* surface_manager = window->surface_manager(); return surface_manager && - surface_manager->HasSurfaceOfType(mojom::SURFACE_TYPE_DEFAULT); + surface_manager->HasSurfaceOfType(mojom::SurfaceType::DEFAULT); } ServerWindow* FindDeepestVisibleWindowNonSurface(ServerWindow* window, @@ -114,9 +114,9 @@ if (!display_surface_id.is_null()) { gfx::Transform transform; if (HitTestSurfaceOfType(display_surface_id, window, - mus::mojom::SURFACE_TYPE_DEFAULT, &transform) || + mus::mojom::SurfaceType::DEFAULT, &transform) || HitTestSurfaceOfType(display_surface_id, window, - mus::mojom::SURFACE_TYPE_UNDERLAY, &transform)) { + mus::mojom::SurfaceType::UNDERLAY, &transform)) { return transform; } }
diff --git a/components/mus/ws/window_manager_access_policy.cc b/components/mus/ws/window_manager_access_policy.cc index 65ac9c1..a6293ae 100644 --- a/components/mus/ws/window_manager_access_policy.cc +++ b/components/mus/ws/window_manager_access_policy.cc
@@ -79,7 +79,7 @@ bool WindowManagerAccessPolicy::CanSetWindowSurface( const ServerWindow* window, mus::mojom::SurfaceType surface_type) const { - if (surface_type == mojom::SURFACE_TYPE_UNDERLAY) + if (surface_type == mojom::SurfaceType::UNDERLAY) return window->id().connection_id == connection_id_; if (delegate_->IsWindowRootOfAnotherConnectionForAccessPolicy(window))
diff --git a/components/mus/ws/window_manager_client_apptest.cc b/components/mus/ws/window_manager_client_apptest.cc index abf575f..82f73102 100644 --- a/components/mus/ws/window_manager_client_apptest.cc +++ b/components/mus/ws/window_manager_client_apptest.cc
@@ -229,7 +229,7 @@ // a response is received, or a timeout. On success the new WindowServer is // returned. EmbedResult Embed(Window* window) { - return Embed(window, mus::mojom::WindowTree::ACCESS_POLICY_DEFAULT); + return Embed(window, mus::mojom::WindowTree::kAccessPolicyDefault); } EmbedResult Embed(Window* window, uint32_t access_policy_bitmask) { @@ -995,7 +995,7 @@ GetFirstWMRoot()->AddChild(embed_window); WindowTreeConnection* vm2 = - Embed(embed_window, mus::mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT) + Embed(embed_window, mus::mojom::WindowTree::kAccessPolicyEmbedRoot) .connection; Window* vm2_v1 = vm2->NewWindow(); GetFirstRoot(vm2)->AddChild(vm2_v1); @@ -1014,7 +1014,7 @@ // Give the connection embedded at |embed_window| embed root powers. const EmbedResult result1 = - Embed(embed_window, mus::mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT); + Embed(embed_window, mus::mojom::WindowTree::kAccessPolicyEmbedRoot); WindowTreeConnection* vm2 = result1.connection; EXPECT_EQ(result1.connection_id, vm2->GetConnectionId()); Window* vm2_v1 = vm2->NewWindow();
diff --git a/components/mus/ws/window_tree_apptest.cc b/components/mus/ws/window_tree_apptest.cc index da25034..340aa41 100644 --- a/components/mus/ws/window_tree_apptest.cc +++ b/components/mus/ws/window_tree_apptest.cc
@@ -26,7 +26,6 @@ using mojo::InterfaceRequest; using mojo::RectPtr; using mojo::String; -using mus::mojom::ERROR_CODE_NONE; using mus::mojom::ErrorCode; using mus::mojom::EventPtr; using mus::mojom::ViewportMetricsPtr; @@ -75,7 +74,7 @@ mojom::WindowTreeClientPtr client; app->ConnectToService(url.get(), &client); ws->Embed(root_id, std::move(client), - mojom::WindowTree::ACCESS_POLICY_DEFAULT, + mojom::WindowTree::kAccessPolicyDefault, base::Bind(&EmbedCallbackImpl, &run_loop, &result)); } run_loop.Run(); @@ -87,7 +86,7 @@ base::RunLoop run_loop; { ws->Embed(root_id, std::move(client), - mojom::WindowTree::ACCESS_POLICY_DEFAULT, + mojom::WindowTree::kAccessPolicyDefault, base::Bind(&EmbedCallbackImpl, &run_loop, &result)); } run_loop.Run(); @@ -495,8 +494,7 @@ Id root_id, int* connection_id) { return EstablishConnectionViaEmbedWithPolicyBitmask( - owner, root_id, mojom::WindowTree::ACCESS_POLICY_DEFAULT, - connection_id); + owner, root_id, mojom::WindowTree::kAccessPolicyDefault, connection_id); } scoped_ptr<TestWindowTreeClientImpl> @@ -943,7 +941,7 @@ { changes1()->clear(); ASSERT_TRUE(ws_client2()->ReorderWindow(window_2_2, window_2_3, - mojom::ORDER_DIRECTION_ABOVE)); + mojom::OrderDirection::ABOVE)); ws_client1_->WaitForChangeCount(1); EXPECT_EQ("Reordered window=" + IdToString(window_2_2) + " relative=" + @@ -954,7 +952,7 @@ { changes1()->clear(); ASSERT_TRUE(ws_client2()->ReorderWindow(window_2_2, window_2_3, - mojom::ORDER_DIRECTION_BELOW)); + mojom::OrderDirection::BELOW)); ws_client1_->WaitForChangeCount(1); EXPECT_EQ("Reordered window=" + IdToString(window_2_2) + " relative=" + @@ -964,24 +962,24 @@ // view2 is already below view3. EXPECT_FALSE(ws_client2()->ReorderWindow(window_2_2, window_2_3, - mojom::ORDER_DIRECTION_BELOW)); + mojom::OrderDirection::BELOW)); // view4 & 5 are unknown to connection2_. EXPECT_FALSE(ws_client2()->ReorderWindow(window_1_4, window_1_5, - mojom::ORDER_DIRECTION_ABOVE)); + mojom::OrderDirection::ABOVE)); // view6 & view3 have different parents. EXPECT_FALSE(ws_client1()->ReorderWindow(window_2_3, window_2_6, - mojom::ORDER_DIRECTION_ABOVE)); + mojom::OrderDirection::ABOVE)); // Non-existent window-ids EXPECT_FALSE(ws_client1()->ReorderWindow(BuildWindowId(connection_id_1(), 27), BuildWindowId(connection_id_1(), 28), - mojom::ORDER_DIRECTION_ABOVE)); + mojom::OrderDirection::ABOVE)); // view7 & view8 are un-parented. EXPECT_FALSE(ws_client1()->ReorderWindow(window_2_7, window_2_8, - mojom::ORDER_DIRECTION_ABOVE)); + mojom::OrderDirection::ABOVE)); } // Verifies DeleteWindow works. @@ -1420,8 +1418,8 @@ Id window_1_1 = BuildWindowId(connection_id_1(), 1); changes2()->clear(); - ASSERT_TRUE(ws_client1()->SetPredefinedCursor(window_1_1, - mojom::Cursor::CURSOR_IBEAM)); + ASSERT_TRUE( + ws_client1()->SetPredefinedCursor(window_1_1, mojom::Cursor::IBEAM)); ws_client2_->WaitForChangeCount(1u); EXPECT_EQ("CursorChanged id=" + IdToString(window_1_1) + " cursor_id=4", @@ -1711,7 +1709,7 @@ ws_client1()->AddWindow(BuildWindowId(connection_id_1(), 1), window_1_2)); ASSERT_TRUE(ws_client3_.get() == nullptr); ws_client3_ = EstablishConnectionViaEmbedWithPolicyBitmask( - ws1(), window_1_2, mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT, nullptr); + ws1(), window_1_2, mojom::WindowTree::kAccessPolicyEmbedRoot, nullptr); ASSERT_TRUE(ws_client3_.get() != nullptr); ws_client3_->set_root_window(root_window_id());
diff --git a/components/mus/ws/window_tree_host_connection.cc b/components/mus/ws/window_tree_host_connection.cc index 31691034..656b2c8 100644 --- a/components/mus/ws/window_tree_host_connection.cc +++ b/components/mus/ws/window_tree_host_connection.cc
@@ -63,7 +63,7 @@ connection_manager()->AddHost(this); set_window_tree(connection_manager()->EmbedAtWindow( window_tree_host()->root_window(), - mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT, std::move(client_))); + mojom::WindowTree::kAccessPolicyEmbedRoot, std::move(client_))); } } // namespace ws
diff --git a/components/mus/ws/window_tree_host_impl.cc b/components/mus/ws/window_tree_host_impl.cc index 446b32b..ef921381 100644 --- a/components/mus/ws/window_tree_host_impl.cc +++ b/components/mus/ws/window_tree_host_impl.cc
@@ -33,7 +33,7 @@ if (one.action != two.action || one.flags != two.flags) return false; // TODO(sad): wheel events can also be merged. - if (one.action != mojom::EVENT_TYPE_POINTER_MOVE) + if (one.action != mojom::EventType::POINTER_MOVE) return false; DCHECK(one.pointer_data); DCHECK(two.pointer_data); @@ -45,7 +45,7 @@ } mojom::EventPtr CoalesceEvents(mojom::EventPtr first, mojom::EventPtr second) { - DCHECK_EQ(first->action, mojom::EVENT_TYPE_POINTER_MOVE) + DCHECK_EQ(first->action, mojom::EventType::POINTER_MOVE) << " Non-move events cannot be merged yet."; // For mouse moves, the new event just replaces the old event. return second; @@ -328,7 +328,7 @@ bool in_nonclient_area, mojom::EventPtr event) { if (event->pointer_data && - event->pointer_data->kind == mojom::PointerKind::POINTER_KIND_MOUSE) { + event->pointer_data->kind == mojom::PointerKind::MOUSE) { DCHECK(event_dispatcher_.mouse_cursor_source_window()); UpdateNativeCursor( event_dispatcher_.mouse_cursor_source_window()->cursor());
diff --git a/components/mus/ws/window_tree_impl.cc b/components/mus/ws/window_tree_impl.cc index 121c7ced..b01e650 100644 --- a/components/mus/ws/window_tree_impl.cc +++ b/components/mus/ws/window_tree_impl.cc
@@ -79,8 +79,7 @@ is_embed_root_ = true; } else { access_policy_.reset(new DefaultAccessPolicy(id_, this)); - is_embed_root_ = - (policy_bitmask & WindowTree::ACCESS_POLICY_EMBED_ROOT) != 0; + is_embed_root_ = (policy_bitmask & WindowTree::kAccessPolicyEmbedRoot) != 0; } } @@ -105,8 +104,8 @@ client->OnEmbed(id_, WindowToWindowData(to_send.front()), std::move(tree), focused_window_transport_id, - is_embed_root_ ? WindowTree::ACCESS_POLICY_EMBED_ROOT - : WindowTree::ACCESS_POLICY_DEFAULT); + is_embed_root_ ? WindowTree::kAccessPolicyEmbedRoot + : WindowTree::kAccessPolicyDefault); } const ServerWindow* WindowTreeImpl::GetWindow(const WindowId& id) const { @@ -151,7 +150,7 @@ uint32_t change_id, mojom::WindowManagerErrorCode error_code) { client_->OnChangeCompleted( - change_id, error_code == mojom::WINDOW_MANAGER_ERROR_CODE_SUCCESS); + change_id, error_code == mojom::WindowManagerErrorCode::SUCCESS); } bool WindowTreeImpl::NewWindow( @@ -577,8 +576,8 @@ const size_t target_i = std::find(children.begin(), children.end(), relative_window) - children.begin(); - if ((direction == mojom::ORDER_DIRECTION_ABOVE && child_i == target_i + 1) || - (direction == mojom::ORDER_DIRECTION_BELOW && child_i + 1 == target_i)) { + if ((direction == mojom::OrderDirection::ABOVE && child_i == target_i + 1) || + (direction == mojom::OrderDirection::BELOW && child_i + 1 == target_i)) { return false; }
diff --git a/components/mus/ws/window_tree_unittest.cc b/components/mus/ws/window_tree_unittest.cc index 61701737..1a8f84b0 100644 --- a/components/mus/ws/window_tree_unittest.cc +++ b/components/mus/ws/window_tree_unittest.cc
@@ -36,7 +36,6 @@ using mojo::Array; using mojo::InterfaceRequest; using mojo::String; -using mus::mojom::ERROR_CODE_NONE; using mus::mojom::Event; using mus::mojom::EventPtr; using mus::mojom::LocationData; @@ -284,7 +283,7 @@ connection_manager()->AddHost(this); set_window_tree(connection_manager()->EmbedAtWindow( window_tree_host()->root_window(), - mus::mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT, + mus::mojom::WindowTree::kAccessPolicyEmbedRoot, mus::mojom::WindowTreeClientPtr())); } DISALLOW_COPY_AND_ASSIGN(TestWindowTreeHostConnection); @@ -411,7 +410,9 @@ } TestWindowTreeClient* wm_client() { return wm_client_; } - int32_t cursor_id() { return cursor_id_; } + mus::mojom::Cursor cursor_id() { + return static_cast<mus::mojom::Cursor>(cursor_id_); + } TestWindowTreeHostConnection* host_connection() { return host_connection_; } @@ -494,7 +495,7 @@ wm_client()->Bind(std::move(client_request)); ConnectionSpecificId connection_id = 0; wm_connection()->Embed(embed_window_id, std::move(client), - mojom::WindowTree::ACCESS_POLICY_DEFAULT, + mojom::WindowTree::kAccessPolicyDefault, &connection_id); WindowTreeImpl* connection1 = connection_manager()->GetConnectionWithRoot( GetWindowById(embed_window_id)); @@ -542,7 +543,7 @@ wm_client()->Bind(std::move(client_request)); ConnectionSpecificId connection_id = 0; wm_connection()->Embed(embed_window_id, std::move(client), - mojom::WindowTree::ACCESS_POLICY_DEFAULT, + mojom::WindowTree::kAccessPolicyDefault, &connection_id); WindowTreeImpl* connection1 = connection_manager()->GetConnectionWithRoot( GetWindowById(embed_window_id)); @@ -644,11 +645,11 @@ // dispatched. This is only to place the mouse cursor over that window though. DispatchEventAndAckImmediately(CreateMouseMoveEvent(21, 22)); - window->SetPredefinedCursor(mojom::Cursor::CURSOR_IBEAM); + window->SetPredefinedCursor(mojom::Cursor::IBEAM); // Because the cursor is over the window when SetCursor was called, we should // have immediately changed the cursor. - EXPECT_EQ(mojom::Cursor::CURSOR_IBEAM, cursor_id()); + EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); } TEST_F(WindowTreeTest, CursorChangesWhenEnteringWindowWithDifferentCursor) { @@ -661,11 +662,11 @@ // Let's create a pointer event outside the window and then move the pointer // inside. DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5)); - window->SetPredefinedCursor(mojom::Cursor::CURSOR_IBEAM); + window->SetPredefinedCursor(mojom::Cursor::IBEAM); EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); DispatchEventAndAckImmediately(CreateMouseMoveEvent(21, 22)); - EXPECT_EQ(mojom::Cursor::CURSOR_IBEAM, cursor_id()); + EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); } TEST_F(WindowTreeTest, TouchesDontChangeCursor) { @@ -678,7 +679,7 @@ // Let's create a pointer event outside the window and then move the pointer // inside. DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5)); - window->SetPredefinedCursor(mojom::Cursor::CURSOR_IBEAM); + window->SetPredefinedCursor(mojom::Cursor::IBEAM); EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); // With a touch event, we shouldn't update the cursor. @@ -696,20 +697,20 @@ // Start with the cursor outside the window. Setting the cursor shouldn't // change the cursor. DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5)); - window->SetPredefinedCursor(mojom::Cursor::CURSOR_IBEAM); + window->SetPredefinedCursor(mojom::Cursor::IBEAM); EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); // Move the pointer to the inside of the window DispatchEventAndAckImmediately(CreateMouseMoveEvent(21, 22)); - EXPECT_EQ(mojom::Cursor::CURSOR_IBEAM, cursor_id()); + EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); // Start the drag. DispatchEventAndAckImmediately(CreateMouseDownEvent(21, 22)); - EXPECT_EQ(mojom::Cursor::CURSOR_IBEAM, cursor_id()); + EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); // Move the cursor (mouse is still down) outside the window. DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5)); - EXPECT_EQ(mojom::Cursor::CURSOR_IBEAM, cursor_id()); + EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); // Release the cursor. We should now adapt the cursor of the window // underneath the pointer. @@ -726,13 +727,13 @@ // Put the cursor just outside the bounds of the window. DispatchEventAndAckImmediately(CreateMouseMoveEvent(41, 41)); - window->SetPredefinedCursor(mojom::Cursor::CURSOR_IBEAM); + window->SetPredefinedCursor(mojom::Cursor::IBEAM); EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id()); // Expand the bounds of the window so they now include where the cursor now // is. window->SetBounds(gfx::Rect(20, 20, 25, 25)); - EXPECT_EQ(mojom::Cursor::CURSOR_IBEAM, cursor_id()); + EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); // Contract the bounds again. window->SetBounds(gfx::Rect(20, 20, 20, 20)); @@ -761,16 +762,16 @@ EnableHitTest(window2); // Give each window a different cursor. - window1->SetPredefinedCursor(mojom::Cursor::CURSOR_IBEAM); - window2->SetPredefinedCursor(mojom::Cursor::CURSOR_HAND); + window1->SetPredefinedCursor(mojom::Cursor::IBEAM); + window2->SetPredefinedCursor(mojom::Cursor::HAND); // We expect window2 to be over window1 now. DispatchEventAndAckImmediately(CreateMouseMoveEvent(22, 22)); - EXPECT_EQ(mojom::Cursor::CURSOR_HAND, cursor_id()); + EXPECT_EQ(mojom::Cursor::HAND, cursor_id()); // But when we put window2 at the bottom, we should adapt window1's cursor. window2->parent()->StackChildAtBottom(window2); - EXPECT_EQ(mojom::Cursor::CURSOR_IBEAM, cursor_id()); + EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id()); } TEST_F(WindowTreeTest, EventAck) {
diff --git a/components/pdf_viewer/pdf_viewer.cc b/components/pdf_viewer/pdf_viewer.cc index 5897ecc..b21c459 100644 --- a/components/pdf_viewer/pdf_viewer.cc +++ b/components/pdf_viewer/pdf_viewer.cc
@@ -142,7 +142,7 @@ mus::mojom::EventPtr event, scoped_ptr<base::Closure>* ack_callback) override { if (event->key_data && - (event->action != mus::mojom::EVENT_TYPE_KEY_PRESSED || + (event->action != mus::mojom::EventType::KEY_PRESSED || event->key_data->is_char)) { return; } @@ -150,7 +150,7 @@ // TODO(rjkroege): Make panning and scrolling more performant and // responsive to gesture events. if ((event->key_data && - event->key_data->windows_key_code == mus::mojom::KEYBOARD_CODE_DOWN) || + event->key_data->windows_key_code == mus::mojom::KeyboardCode::DOWN) || (event->pointer_data && event->pointer_data->wheel_data && event->pointer_data->wheel_data->delta_y < 0)) { if (current_page_ < (page_count_ - 1)) { @@ -159,7 +159,7 @@ } } else if ((event->key_data && event->key_data->windows_key_code == - mus::mojom::KEYBOARD_CODE_UP) || + mus::mojom::KeyboardCode::UP) || (event->pointer_data && event->pointer_data->wheel_data && event->pointer_data->wheel_data->delta_y > 0)) { if (current_page_ > 0) {
diff --git a/components/web_view/frame.cc b/components/web_view/frame.cc index 453382b..4581c80 100644 --- a/components/web_view/frame.cc +++ b/components/web_view/frame.cc
@@ -201,7 +201,7 @@ embed_weak_ptr_factory_.InvalidateWeakPtrs(); window_->Embed( std::move(window_tree_client), - mus::mojom::WindowTree::ACCESS_POLICY_DEFAULT, + mus::mojom::WindowTree::kAccessPolicyDefault, base::Bind(&Frame::OnEmbedAck, embed_weak_ptr_factory_.GetWeakPtr())); } @@ -213,7 +213,7 @@ frame_binding_.reset( new mojo::Binding<mojom::Frame>(this, std::move(frame_request))); frame_client_->OnConnect( - nullptr, tree_->change_id(), id_, mojom::WINDOW_CONNECT_TYPE_USE_NEW, + nullptr, tree_->change_id(), id_, mojom::WindowConnectType::USE_NEW, mojo::Array<mojom::FrameDataPtr>(), navigation_start_time.ToInternalValue(), base::Bind(&OnConnectAck, base::Passed(&data_and_binding))); @@ -233,8 +233,8 @@ frame_client_->OnConnect( std::move(frame_ptr), tree_->change_id(), id_, client_type == ClientType::EXISTING_FRAME_SAME_APP - ? mojom::WINDOW_CONNECT_TYPE_USE_EXISTING - : mojom::WINDOW_CONNECT_TYPE_USE_NEW, + ? mojom::WindowConnectType::USE_EXISTING + : mojom::WindowConnectType::USE_NEW, std::move(array), navigation_start_time.ToInternalValue(), base::Bind(&OnConnectAck, base::Passed(&data_and_binding))); tree_->delegate_->DidStartNavigation(this); @@ -563,7 +563,7 @@ void Frame::RequestNavigate(mojom::NavigationTargetType target_type, uint32_t target_frame_id, mojo::URLRequestPtr request) { - if (target_type == mojom::NAVIGATION_TARGET_TYPE_EXISTING_FRAME) { + if (target_type == mojom::NavigationTargetType::EXISTING_FRAME) { // |target_frame| is allowed to come from another connection. Frame* target_frame = tree_->root()->FindFrame(target_frame_id); if (!target_frame) {
diff --git a/components/web_view/frame_apptest.cc b/components/web_view/frame_apptest.cc index 4ff7dc0..2d8fd71 100644 --- a/components/web_view/frame_apptest.cc +++ b/components/web_view/frame_apptest.cc
@@ -316,7 +316,7 @@ request->url = mojo::String::From(application_impl()->url()); request->originating_time_ticks = navigation_start_time.ToInternalValue(); window_and_frame->server_frame()->RequestNavigate( - mojom::NAVIGATION_TARGET_TYPE_EXISTING_FRAME, + mojom::NavigationTargetType::EXISTING_FRAME, window_and_frame->window()->id(), std::move(request)); return WaitForViewAndFrame(); }
diff --git a/components/web_view/public/cpp/web_view.cc b/components/web_view/public/cpp/web_view.cc index 7f66c695..85af0f4 100644 --- a/components/web_view/public/cpp/web_view.cc +++ b/components/web_view/public/cpp/web_view.cc
@@ -36,7 +36,7 @@ mus::mojom::WindowTreeClientPtr window_tree_client; web_view_->GetWindowTreeClient(GetProxy(&window_tree_client)); window->Embed(std::move(window_tree_client), - mus::mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT, + mus::mojom::WindowTree::kAccessPolicyEmbedRoot, base::Bind(&OnEmbed)); }
diff --git a/components/web_view/web_view_apptest.cc b/components/web_view/web_view_apptest.cc index eebd2d90..1b14430 100644 --- a/components/web_view/web_view_apptest.cc +++ b/components/web_view/web_view_apptest.cc
@@ -187,35 +187,29 @@ // the stack. EXPECT_EQ(GetTestFileURL(kTestOneFile).spec(), navigation_url()); EXPECT_EQ(kTestOneTitle, last_title()); - EXPECT_EQ(mojom::ButtonState::BUTTON_STATE_DISABLED, - last_back_button_state()); - EXPECT_EQ(mojom::ButtonState::BUTTON_STATE_DISABLED, - last_forward_button_state()); + EXPECT_EQ(mojom::ButtonState::DISABLED, last_back_button_state()); + EXPECT_EQ(mojom::ButtonState::DISABLED, last_forward_button_state()); ASSERT_NO_FATAL_FAILURE(NavigateTo(kTestTwoFile)); EXPECT_EQ(kTestTwoTitle, last_title()); - EXPECT_EQ(mojom::ButtonState::BUTTON_STATE_ENABLED, last_back_button_state()); - EXPECT_EQ(mojom::ButtonState::BUTTON_STATE_DISABLED, - last_forward_button_state()); + EXPECT_EQ(mojom::ButtonState::ENABLED, last_back_button_state()); + EXPECT_EQ(mojom::ButtonState::DISABLED, last_forward_button_state()); web_view()->GoBack(); StartNestedRunLoopUntil(LOADING_DONE); EXPECT_EQ(GetTestFileURL(kTestOneFile).spec(), navigation_url()); EXPECT_EQ(kTestOneTitle, last_title()); - EXPECT_EQ(mojom::ButtonState::BUTTON_STATE_DISABLED, - last_back_button_state()); - EXPECT_EQ(mojom::ButtonState::BUTTON_STATE_ENABLED, - last_forward_button_state()); + EXPECT_EQ(mojom::ButtonState::DISABLED, last_back_button_state()); + EXPECT_EQ(mojom::ButtonState::ENABLED, last_forward_button_state()); web_view()->GoForward(); StartNestedRunLoopUntil(LOADING_DONE); EXPECT_EQ(GetTestFileURL(kTestTwoFile).spec(), navigation_url()); EXPECT_EQ(kTestTwoTitle, last_title()); - EXPECT_EQ(mojom::ButtonState::BUTTON_STATE_ENABLED, last_back_button_state()); - EXPECT_EQ(mojom::ButtonState::BUTTON_STATE_DISABLED, - last_forward_button_state()); + EXPECT_EQ(mojom::ButtonState::ENABLED, last_back_button_state()); + EXPECT_EQ(mojom::ButtonState::DISABLED, last_forward_button_state()); } TEST_F(WebViewTest, NavigationClearsForward) { @@ -229,19 +223,16 @@ EXPECT_EQ(GetTestFileURL(kTestOneFile).spec(), navigation_url()); EXPECT_EQ(kTestOneTitle, last_title()); - EXPECT_EQ(mojom::ButtonState::BUTTON_STATE_DISABLED, - last_back_button_state()); - EXPECT_EQ(mojom::ButtonState::BUTTON_STATE_ENABLED, - last_forward_button_state()); + EXPECT_EQ(mojom::ButtonState::DISABLED, last_back_button_state()); + EXPECT_EQ(mojom::ButtonState::ENABLED, last_forward_button_state()); // Now navigate to a third file. This should clear the forward stack. ASSERT_NO_FATAL_FAILURE(NavigateTo(kTestThreeFile)); EXPECT_EQ(GetTestFileURL(kTestThreeFile).spec(), navigation_url()); EXPECT_EQ(kTestThreeTitle, last_title()); - EXPECT_EQ(mojom::ButtonState::BUTTON_STATE_ENABLED, last_back_button_state()); - EXPECT_EQ(mojom::ButtonState::BUTTON_STATE_DISABLED, - last_forward_button_state()); + EXPECT_EQ(mojom::ButtonState::ENABLED, last_back_button_state()); + EXPECT_EQ(mojom::ButtonState::DISABLED, last_forward_button_state()); } TEST_F(WebViewTest, Find) {
diff --git a/components/web_view/web_view_impl.cc b/components/web_view/web_view_impl.cc index e07f3cf5..e4ee5cf 100644 --- a/components/web_view/web_view_impl.cc +++ b/components/web_view/web_view_impl.cc
@@ -255,12 +255,11 @@ } void WebViewImpl::OnDidNavigate() { - client_->BackForwardChanged(navigation_controller_.CanGoBack() - ? ButtonState::BUTTON_STATE_ENABLED - : ButtonState::BUTTON_STATE_DISABLED, - navigation_controller_.CanGoForward() - ? ButtonState::BUTTON_STATE_ENABLED - : ButtonState::BUTTON_STATE_DISABLED); + client_->BackForwardChanged( + navigation_controller_.CanGoBack() ? ButtonState::ENABLED + : ButtonState::DISABLED, + navigation_controller_.CanGoForward() ? ButtonState::ENABLED + : ButtonState::DISABLED); } ////////////////////////////////////////////////////////////////////////////////
diff --git a/content/browser/background_sync/background_sync_browsertest.cc b/content/browser/background_sync/background_sync_browsertest.cc index 60d517e..3205c75b 100644 --- a/content/browser/background_sync/background_sync_browsertest.cc +++ b/content/browser/background_sync/background_sync_browsertest.cc
@@ -72,7 +72,7 @@ scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle) { ASSERT_EQ(BACKGROUND_SYNC_STATUS_OK, error_type); callback.Run(registration_handle->sync_state() == - BACKGROUND_SYNC_STATE_PENDING); + BackgroundSyncState::PENDING); } void OneShotPendingDidGetSWRegistration(
diff --git a/content/browser/background_sync/background_sync_manager.cc b/content/browser/background_sync/background_sync_manager.cc index 9a8aa4c..0f7fbcb 100644 --- a/content/browser/background_sync/background_sync_manager.cc +++ b/content/browser/background_sync/background_sync_manager.cc
@@ -528,7 +528,7 @@ if (existing_registration->IsFiring()) { existing_registration->set_sync_state( - BACKGROUND_SYNC_STATE_REREGISTERED_WHILE_FIRING); + BackgroundSyncState::REREGISTERED_WHILE_FIRING); } base::ThreadTaskRunnerHandle::Get()->PostTask( @@ -965,7 +965,7 @@ if (disabled_) { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, BACKGROUND_SYNC_STATUS_STORAGE_ERROR, - BACKGROUND_SYNC_STATE_FAILED)); + BackgroundSyncState::FAILED)); return; } @@ -987,7 +987,7 @@ if (disabled_) { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, BACKGROUND_SYNC_STATUS_STORAGE_ERROR, - BACKGROUND_SYNC_STATE_FAILED)); + BackgroundSyncState::FAILED)); return; } @@ -1087,7 +1087,7 @@ if (registration.options()->periodicity == SYNC_PERIODIC) return false; - if (registration.sync_state() != BACKGROUND_SYNC_STATE_PENDING) + if (registration.sync_state() != BackgroundSyncState::PENDING) return false; if (clock_->Now() < registration.delay_until()) @@ -1107,7 +1107,7 @@ sw_id_and_registrations.second.registration_map) { const BackgroundSyncRegistration& registration = *key_and_registration.second->value(); - if (registration.sync_state() == BACKGROUND_SYNC_STATE_PENDING) { + if (registration.sync_state() == BackgroundSyncState::PENDING) { if (registration.options()->periodicity == SYNC_ONE_SHOT) { if (clock_->Now() >= registration.delay_until()) { soonest_wakeup_delta = base::TimeDelta(); @@ -1185,7 +1185,7 @@ // The state change is not saved to persistent storage because // if the sync event is killed mid-sync then it should return to // SYNC_STATE_PENDING. - registration->set_sync_state(BACKGROUND_SYNC_STATE_FIRING); + registration->set_sync_state(BackgroundSyncState::FIRING); } } } @@ -1261,8 +1261,8 @@ BackgroundSyncEventLastChance last_chance = registration->value()->num_attempts() == parameters_->max_sync_attempts - 1 - ? BACKGROUND_SYNC_EVENT_LAST_CHANCE_IS_LAST_CHANCE - : BACKGROUND_SYNC_EVENT_LAST_CHANCE_IS_NOT_LAST_CHANCE; + ? BackgroundSyncEventLastChance::IS_LAST_CHANCE + : BackgroundSyncEventLastChance::IS_NOT_LAST_CHANCE; HasMainFrameProviderHost( service_worker_registration->pattern().GetOrigin(), @@ -1338,31 +1338,31 @@ if (registration->options()->periodicity == SYNC_ONE_SHOT) { if (registration->sync_state() == - BACKGROUND_SYNC_STATE_REREGISTERED_WHILE_FIRING) { - registration->set_sync_state(BACKGROUND_SYNC_STATE_PENDING); + BackgroundSyncState::REREGISTERED_WHILE_FIRING) { + registration->set_sync_state(BackgroundSyncState::PENDING); registration->set_num_attempts(0); } else if (status_code != SERVICE_WORKER_OK) { // Sync failed bool can_retry = registration->num_attempts() < parameters_->max_sync_attempts; if (registration->sync_state() == - BACKGROUND_SYNC_STATE_UNREGISTERED_WHILE_FIRING) { + BackgroundSyncState::UNREGISTERED_WHILE_FIRING) { registration->set_sync_state(can_retry - ? BACKGROUND_SYNC_STATE_UNREGISTERED - : BACKGROUND_SYNC_STATE_FAILED); + ? BackgroundSyncState::UNREGISTERED + : BackgroundSyncState::FAILED); registration->RunFinishedCallbacks(); } else if (can_retry) { - registration->set_sync_state(BACKGROUND_SYNC_STATE_PENDING); + registration->set_sync_state(BackgroundSyncState::PENDING); registration->set_delay_until( clock_->Now() + parameters_->initial_retry_delay * pow(parameters_->retry_delay_factor, registration->num_attempts() - 1)); } else { - registration->set_sync_state(BACKGROUND_SYNC_STATE_FAILED); + registration->set_sync_state(BackgroundSyncState::FAILED); registration->RunFinishedCallbacks(); } } else { // Sync succeeded - registration->set_sync_state(BACKGROUND_SYNC_STATE_SUCCESS); + registration->set_sync_state(BackgroundSyncState::SUCCESS); registration->RunFinishedCallbacks(); }
diff --git a/content/browser/background_sync/background_sync_manager_unittest.cc b/content/browser/background_sync/background_sync_manager_unittest.cc index bf0670df..58d2d0c 100644 --- a/content/browser/background_sync/background_sync_manager_unittest.cc +++ b/content/browser/background_sync/background_sync_manager_unittest.cc
@@ -289,7 +289,7 @@ bool delay_backend_ = false; bool has_main_frame_provider_host_ = true; BackgroundSyncEventLastChance last_chance_ = - BACKGROUND_SYNC_EVENT_LAST_CHANCE_IS_NOT_LAST_CHANCE; + BackgroundSyncEventLastChance::IS_NOT_LAST_CHANCE; base::Closure continuation_; OneShotCallback one_shot_callback_; base::Closure delayed_task_; @@ -533,7 +533,7 @@ BackgroundSyncRegistrationHandle* registration_handle) { callback_finished_called_ = false; callback_finished_status_ = BACKGROUND_SYNC_STATUS_NOT_FOUND; - callback_finished_state_ = BACKGROUND_SYNC_STATE_FAILED; + callback_finished_state_ = BackgroundSyncState::FAILED; registration_handle->NotifyWhenFinished( base::Bind(&NotifyWhenFinishedCallback, &callback_finished_called_, @@ -691,7 +691,7 @@ bool callback_finished_called_ = false; BackgroundSyncStatus callback_finished_status_ = BACKGROUND_SYNC_STATUS_NOT_FOUND; - BackgroundSyncState callback_finished_state_ = BACKGROUND_SYNC_STATE_FAILED; + BackgroundSyncState callback_finished_state_ = BackgroundSyncState::FAILED; int sync_events_called_ = 0; ServiceWorkerVersion::StatusCallback sync_fired_callback_; }; @@ -1190,7 +1190,7 @@ EXPECT_EQ(1, sync_events_called_); EXPECT_TRUE(NotifyWhenFinished(callback_registration_handle_.get())); - EXPECT_EQ(BACKGROUND_SYNC_STATE_SUCCESS, FinishedState()); + EXPECT_EQ(BackgroundSyncState::SUCCESS, FinishedState()); } TEST_F(BackgroundSyncManagerTest, NotifyWhenFinishedBeforeEventSuccess) { @@ -1204,7 +1204,7 @@ sync_fired_callback_.Run(SERVICE_WORKER_OK); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1, sync_events_called_); - EXPECT_EQ(BACKGROUND_SYNC_STATE_SUCCESS, FinishedState()); + EXPECT_EQ(BackgroundSyncState::SUCCESS, FinishedState()); } TEST_F(BackgroundSyncManagerTest, @@ -1223,7 +1223,7 @@ // Finish firing the event. sync_fired_callback_.Run(SERVICE_WORKER_OK); base::RunLoop().RunUntilIdle(); - EXPECT_EQ(BACKGROUND_SYNC_STATE_SUCCESS, FinishedState()); + EXPECT_EQ(BackgroundSyncState::SUCCESS, FinishedState()); } TEST_F(BackgroundSyncManagerTest, @@ -1243,7 +1243,7 @@ sync_fired_callback_.Run(SERVICE_WORKER_ERROR_FAILED); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1, sync_events_called_); - EXPECT_EQ(BACKGROUND_SYNC_STATE_FAILED, FinishedState()); + EXPECT_EQ(BackgroundSyncState::FAILED, FinishedState()); } TEST_F(BackgroundSyncManagerTest, @@ -1254,7 +1254,7 @@ EXPECT_TRUE(Register(sync_options_1_)); EXPECT_TRUE(Unregister(callback_registration_handle_.get())); EXPECT_TRUE(NotifyWhenFinished(callback_registration_handle_.get())); - EXPECT_EQ(BACKGROUND_SYNC_STATE_UNREGISTERED, FinishedState()); + EXPECT_EQ(BackgroundSyncState::UNREGISTERED, FinishedState()); } TEST_F(BackgroundSyncManagerTest, @@ -1272,7 +1272,7 @@ sync_fired_callback_.Run(SERVICE_WORKER_OK); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1, sync_events_called_); - EXPECT_EQ(BACKGROUND_SYNC_STATE_SUCCESS, FinishedState()); + EXPECT_EQ(BackgroundSyncState::SUCCESS, FinishedState()); } TEST_F(BackgroundSyncManagerTest, NotifyWhenFinishedAfterEventFailure) { @@ -1282,7 +1282,7 @@ EXPECT_EQ(1, sync_events_called_); EXPECT_TRUE(NotifyWhenFinished(callback_registration_handle_.get())); - EXPECT_EQ(BACKGROUND_SYNC_STATE_FAILED, FinishedState()); + EXPECT_EQ(BackgroundSyncState::FAILED, FinishedState()); } TEST_F(BackgroundSyncManagerTest, NotifyWhenFinishedBeforeEventFailure) { @@ -1294,7 +1294,7 @@ // Finish firing the event. sync_fired_callback_.Run(SERVICE_WORKER_ERROR_FAILED); base::RunLoop().RunUntilIdle(); - EXPECT_EQ(BACKGROUND_SYNC_STATE_FAILED, FinishedState()); + EXPECT_EQ(BackgroundSyncState::FAILED, FinishedState()); } TEST_F(BackgroundSyncManagerTest, NotifyWhenFinishedAfterUnregistered) { @@ -1302,14 +1302,14 @@ EXPECT_TRUE(Unregister(callback_registration_handle_.get())); EXPECT_TRUE(NotifyWhenFinished(callback_registration_handle_.get())); - EXPECT_EQ(BACKGROUND_SYNC_STATE_UNREGISTERED, FinishedState()); + EXPECT_EQ(BackgroundSyncState::UNREGISTERED, FinishedState()); } TEST_F(BackgroundSyncManagerTest, NotifyWhenFinishedBeforeUnregistered) { Register(sync_options_1_); EXPECT_FALSE(NotifyWhenFinished(callback_registration_handle_.get())); EXPECT_TRUE(Unregister(callback_registration_handle_.get())); - EXPECT_EQ(BACKGROUND_SYNC_STATE_UNREGISTERED, FinishedState()); + EXPECT_EQ(BackgroundSyncState::UNREGISTERED, FinishedState()); } TEST_F(BackgroundSyncManagerTest, ReregisterMidSyncFirstAttemptFails) { @@ -1329,7 +1329,7 @@ EXPECT_TRUE(GetRegistration(sync_options_1_)); sync_fired_callback_.Run(SERVICE_WORKER_OK); EXPECT_FALSE(GetRegistration(sync_options_1_)); - EXPECT_EQ(BACKGROUND_SYNC_STATE_SUCCESS, FinishedState()); + EXPECT_EQ(BackgroundSyncState::SUCCESS, FinishedState()); } TEST_F(BackgroundSyncManagerTest, ReregisterMidSyncFirstAttemptSucceeds) { @@ -1349,7 +1349,7 @@ EXPECT_TRUE(GetRegistration(sync_options_1_)); sync_fired_callback_.Run(SERVICE_WORKER_OK); EXPECT_FALSE(GetRegistration(sync_options_1_)); - EXPECT_EQ(BACKGROUND_SYNC_STATE_SUCCESS, FinishedState()); + EXPECT_EQ(BackgroundSyncState::SUCCESS, FinishedState()); } TEST_F(BackgroundSyncManagerTest, @@ -1367,7 +1367,7 @@ base::RunLoop().RunUntilIdle(); // Since there were no retry attempts left, the sync ultimately failed. - EXPECT_EQ(BACKGROUND_SYNC_STATE_FAILED, FinishedState()); + EXPECT_EQ(BackgroundSyncState::FAILED, FinishedState()); } TEST_F(BackgroundSyncManagerTest, @@ -1386,12 +1386,12 @@ base::RunLoop().RunUntilIdle(); // Since there was one retry attempt left, the sync didn't completely fail // before it was unregistered. - EXPECT_EQ(BACKGROUND_SYNC_STATE_UNREGISTERED, FinishedState()); + EXPECT_EQ(BackgroundSyncState::UNREGISTERED, FinishedState()); } TEST_F(BackgroundSyncManagerTest, OverwritePendingRegistration) { // An overwritten pending registration should complete with - // BACKGROUND_SYNC_STATE_UNREGISTERED. + // BackgroundSyncState::UNREGISTERED. sync_options_1_.power_state = POWER_STATE_AVOID_DRAINING; EXPECT_TRUE(Register(sync_options_1_)); EXPECT_TRUE(GetRegistration(sync_options_1_)); @@ -1408,13 +1408,13 @@ callback_registration_handle_->options()->power_state); EXPECT_TRUE(NotifyWhenFinished(original_handle.get())); - EXPECT_EQ(BACKGROUND_SYNC_STATE_UNREGISTERED, FinishedState()); + EXPECT_EQ(BackgroundSyncState::UNREGISTERED, FinishedState()); EXPECT_EQ(0, sync_events_called_); } TEST_F(BackgroundSyncManagerTest, OverwriteFiringRegistrationWhichSucceeds) { // An overwritten pending registration should complete with - // BACKGROUND_SYNC_STATE_SUCCESS if firing completes successfully. + // BackgroundSyncState::SUCCESS if firing completes successfully. InitDelayedSyncEventTest(); sync_options_1_.power_state = POWER_STATE_AVOID_DRAINING; @@ -1433,12 +1433,12 @@ // Successfully finish the first event. sync_fired_callback_.Run(SERVICE_WORKER_OK); base::RunLoop().RunUntilIdle(); - EXPECT_EQ(BACKGROUND_SYNC_STATE_SUCCESS, FinishedState()); + EXPECT_EQ(BackgroundSyncState::SUCCESS, FinishedState()); } TEST_F(BackgroundSyncManagerTest, OverwriteFiringRegistrationWhichFails) { // An overwritten pending registration should complete with - // BACKGROUND_SYNC_STATE_FAILED if firing fails. + // BackgroundSyncState::FAILED if firing fails. InitDelayedSyncEventTest(); sync_options_1_.power_state = POWER_STATE_AVOID_DRAINING; @@ -1457,7 +1457,7 @@ // Fail the first event. sync_fired_callback_.Run(SERVICE_WORKER_ERROR_FAILED); base::RunLoop().RunUntilIdle(); - EXPECT_EQ(BACKGROUND_SYNC_STATE_FAILED, FinishedState()); + EXPECT_EQ(BackgroundSyncState::FAILED, FinishedState()); } TEST_F(BackgroundSyncManagerTest, DisableWhilePendingNotifiesFinished) { @@ -1474,7 +1474,7 @@ // registrations. test_background_sync_manager_->set_corrupt_backend(true); EXPECT_FALSE(Register(sync_options_2_)); - EXPECT_EQ(BACKGROUND_SYNC_STATE_UNREGISTERED, FinishedState()); + EXPECT_EQ(BackgroundSyncState::UNREGISTERED, FinishedState()); } TEST_F(BackgroundSyncManagerTest, DisableWhileFiringNotifiesFinished) { @@ -1495,7 +1495,7 @@ // Successfully complete the firing event. sync_fired_callback_.Run(SERVICE_WORKER_OK); base::RunLoop().RunUntilIdle(); - EXPECT_EQ(BACKGROUND_SYNC_STATE_SUCCESS, FinishedState()); + EXPECT_EQ(BackgroundSyncState::SUCCESS, FinishedState()); } // TODO(jkarlin): Change this to a periodic test as one-shots can't be power @@ -2022,7 +2022,7 @@ InitFailedSyncEventTest(); EXPECT_TRUE(Register(sync_options_1_)); - EXPECT_EQ(BACKGROUND_SYNC_EVENT_LAST_CHANCE_IS_NOT_LAST_CHANCE, + EXPECT_EQ(BackgroundSyncEventLastChance::IS_NOT_LAST_CHANCE, test_background_sync_manager_->last_chance()); EXPECT_TRUE(GetRegistration(sync_options_1_)); @@ -2031,7 +2031,7 @@ test_background_sync_manager_->delayed_task().Run(); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(GetRegistration(sync_options_1_)); - EXPECT_EQ(BACKGROUND_SYNC_EVENT_LAST_CHANCE_IS_LAST_CHANCE, + EXPECT_EQ(BackgroundSyncEventLastChance::IS_LAST_CHANCE, test_background_sync_manager_->last_chance()); }
diff --git a/content/browser/background_sync/background_sync_registration.cc b/content/browser/background_sync/background_sync_registration.cc index b20e2ef7..5625696 100644 --- a/content/browser/background_sync/background_sync_registration.cc +++ b/content/browser/background_sync/background_sync_registration.cc
@@ -49,14 +49,14 @@ bool BackgroundSyncRegistration::HasCompleted() const { switch (sync_state_) { - case BACKGROUND_SYNC_STATE_PENDING: - case BACKGROUND_SYNC_STATE_FIRING: - case BACKGROUND_SYNC_STATE_REREGISTERED_WHILE_FIRING: - case BACKGROUND_SYNC_STATE_UNREGISTERED_WHILE_FIRING: + case BackgroundSyncState::PENDING: + case BackgroundSyncState::FIRING: + case BackgroundSyncState::REREGISTERED_WHILE_FIRING: + case BackgroundSyncState::UNREGISTERED_WHILE_FIRING: return false; - case BACKGROUND_SYNC_STATE_FAILED: - case BACKGROUND_SYNC_STATE_SUCCESS: - case BACKGROUND_SYNC_STATE_UNREGISTERED: + case BackgroundSyncState::FAILED: + case BackgroundSyncState::SUCCESS: + case BackgroundSyncState::UNREGISTERED: return true; } NOTREACHED(); @@ -65,14 +65,14 @@ bool BackgroundSyncRegistration::IsFiring() const { switch (sync_state_) { - case BACKGROUND_SYNC_STATE_FIRING: - case BACKGROUND_SYNC_STATE_REREGISTERED_WHILE_FIRING: - case BACKGROUND_SYNC_STATE_UNREGISTERED_WHILE_FIRING: + case BackgroundSyncState::FIRING: + case BackgroundSyncState::REREGISTERED_WHILE_FIRING: + case BackgroundSyncState::UNREGISTERED_WHILE_FIRING: return true; - case BACKGROUND_SYNC_STATE_PENDING: - case BACKGROUND_SYNC_STATE_FAILED: - case BACKGROUND_SYNC_STATE_SUCCESS: - case BACKGROUND_SYNC_STATE_UNREGISTERED: + case BackgroundSyncState::PENDING: + case BackgroundSyncState::FAILED: + case BackgroundSyncState::SUCCESS: + case BackgroundSyncState::UNREGISTERED: return false; } NOTREACHED(); @@ -84,8 +84,8 @@ bool is_firing = IsFiring(); - sync_state_ = is_firing ? BACKGROUND_SYNC_STATE_UNREGISTERED_WHILE_FIRING - : BACKGROUND_SYNC_STATE_UNREGISTERED; + sync_state_ = is_firing ? BackgroundSyncState::UNREGISTERED_WHILE_FIRING + : BackgroundSyncState::UNREGISTERED; if (!is_firing) { // If the registration is currently firing then wait to run
diff --git a/content/browser/background_sync/background_sync_registration.h b/content/browser/background_sync/background_sync_registration.h index 4e4f1cd3f..5c0e56c 100644 --- a/content/browser/background_sync/background_sync_registration.h +++ b/content/browser/background_sync/background_sync_registration.h
@@ -39,8 +39,8 @@ bool IsFiring() const; // If the registration is currently firing, sets its state to - // BACKGROUND_SYNC_STATE_UNREGISTERED_WHILE_FIRING. If it is firing, it sets - // the state to BACKGROUND_SYNC_STATE_UNREGISTERED and calls + // BackgroundSyncState::UNREGISTERED_WHILE_FIRING. If it is firing, it sets + // the state to BackgroundSyncState::UNREGISTERED and calls // RunFinishedCallbacks. void SetUnregisteredState(); @@ -64,7 +64,7 @@ BackgroundSyncRegistrationOptions options_; RegistrationId id_ = kInvalidRegistrationId; - BackgroundSyncState sync_state_ = BACKGROUND_SYNC_STATE_PENDING; + BackgroundSyncState sync_state_ = BackgroundSyncState::PENDING; int num_attempts_ = 0; base::Time delay_until_;
diff --git a/content/browser/background_sync/background_sync_registration_handle.h b/content/browser/background_sync/background_sync_registration_handle.h index 8b2b5a9..22cfdaa 100644 --- a/content/browser/background_sync/background_sync_registration_handle.h +++ b/content/browser/background_sync/background_sync_registration_handle.h
@@ -50,9 +50,9 @@ // Runs |callback| when the registration associated with |handle_id| // completes.The provided status is BACKGROUND_SYNC_STATUS_OK if the operation - // succeeded. The provided state is BACKGROUND_SYNC_STATE_SUCCESS on success, + // succeeded. The provided state is BackgroundSyncState::SUCCESS on success, // BACKGRUOND_SYNC_STATE_FAILED on final failure, and - // BACKGROUND_SYNC_STATE_UNREGISTERED if the registration was unregistered + // BackgroundSyncState::UNREGISTERED if the registration was unregistered // before it could complete. NotifyWhenFinished should only be called for // SYNC_ONE_SHOT registrations. void NotifyWhenFinished(const StatusAndStateCallback& callback);
diff --git a/content/browser/background_sync/background_sync_service_impl.cc b/content/browser/background_sync/background_sync_service_impl.cc index ffab6ab..f91def0 100644 --- a/content/browser/background_sync/background_sync_service_impl.cc +++ b/content/browser/background_sync/background_sync_service_impl.cc
@@ -54,40 +54,40 @@ "mojo and manager enums must match") // TODO(iclelland): Move these tests somewhere else -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_ERROR_NONE, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncError::NONE, BACKGROUND_SYNC_STATUS_OK); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_ERROR_STORAGE, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncError::STORAGE, BACKGROUND_SYNC_STATUS_STORAGE_ERROR); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_ERROR_NOT_FOUND, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncError::NOT_FOUND, BACKGROUND_SYNC_STATUS_NOT_FOUND); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_ERROR_NO_SERVICE_WORKER, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncError::NO_SERVICE_WORKER, BACKGROUND_SYNC_STATUS_NO_SERVICE_WORKER); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_ERROR_NOT_ALLOWED, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncError::NOT_ALLOWED, BACKGROUND_SYNC_STATUS_NOT_ALLOWED); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_ERROR_MAX, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncError::MAX, BACKGROUND_SYNC_STATUS_NOT_ALLOWED); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_NETWORK_STATE_ANY, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncNetworkState::ANY, SyncNetworkState::NETWORK_STATE_ANY); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_NETWORK_STATE_AVOID_CELLULAR, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncNetworkState::AVOID_CELLULAR, SyncNetworkState::NETWORK_STATE_AVOID_CELLULAR); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_NETWORK_STATE_ONLINE, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncNetworkState::ONLINE, SyncNetworkState::NETWORK_STATE_ONLINE); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_NETWORK_STATE_MAX, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncNetworkState::MAX, SyncNetworkState::NETWORK_STATE_ONLINE); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_POWER_STATE_AUTO, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPowerState::AUTO, SyncPowerState::POWER_STATE_AUTO); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_POWER_STATE_AVOID_DRAINING, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPowerState::AVOID_DRAINING, SyncPowerState::POWER_STATE_AVOID_DRAINING); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_POWER_STATE_MAX, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPowerState::MAX, SyncPowerState::POWER_STATE_AVOID_DRAINING); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_PERIODICITY_PERIODIC, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPeriodicity::PERIODIC, SyncPeriodicity::SYNC_PERIODIC); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_PERIODICITY_ONE_SHOT, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPeriodicity::ONE_SHOT, SyncPeriodicity::SYNC_ONE_SHOT); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_PERIODICITY_MAX, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPeriodicity::MAX, SyncPeriodicity::SYNC_ONE_SHOT); BackgroundSyncServiceImpl::~BackgroundSyncServiceImpl() { @@ -141,7 +141,7 @@ BackgroundSyncRegistrationHandle* registration = active_handles_.Lookup(handle_id); if (!registration) { - callback.Run(BACKGROUND_SYNC_ERROR_NOT_ALLOWED); + callback.Run(BackgroundSyncError::NOT_ALLOWED); return; } @@ -189,7 +189,7 @@ // TODO(iclelland): Implement a real policy. This is a stub implementation. // OneShot: crbug.com/482091 // Periodic: crbug.com/482093 - callback.Run(BACKGROUND_SYNC_ERROR_NONE, PERMISSION_STATUS_GRANTED); + callback.Run(BackgroundSyncError::NONE, PermissionStatus::GRANTED); } void BackgroundSyncServiceImpl::DuplicateRegistrationHandle( @@ -206,7 +206,7 @@ BackgroundSyncRegistrationHandle* handle_ptr = registration_handle.get(); if (!registration_handle) { - callback.Run(BACKGROUND_SYNC_ERROR_NOT_FOUND, + callback.Run(BackgroundSyncError::NOT_FOUND, SyncRegistrationPtr(content::SyncRegistration::New())); return; } @@ -214,7 +214,7 @@ active_handles_.AddWithID(registration_handle.release(), handle_ptr->handle_id()); SyncRegistrationPtr mojoResult = ToMojoRegistration(*handle_ptr); - callback.Run(BACKGROUND_SYNC_ERROR_NONE, std::move(mojoResult)); + callback.Run(BackgroundSyncError::NONE, std::move(mojoResult)); } void BackgroundSyncServiceImpl::ReleaseRegistration( @@ -235,8 +235,7 @@ BackgroundSyncRegistrationHandle* registration = active_handles_.Lookup(handle_id); if (!registration) { - callback.Run(BACKGROUND_SYNC_ERROR_NOT_ALLOWED, - BACKGROUND_SYNC_STATE_FAILED); + callback.Run(BackgroundSyncError::NOT_ALLOWED, BackgroundSyncState::FAILED); return; }
diff --git a/content/browser/background_sync/background_sync_service_impl_unittest.cc b/content/browser/background_sync/background_sync_service_impl_unittest.cc index a9f8307..650c6570 100644 --- a/content/browser/background_sync/background_sync_service_impl_unittest.cc +++ b/content/browser/background_sync/background_sync_service_impl_unittest.cc
@@ -89,7 +89,7 @@ mojo::Array<content::SyncRegistrationPtr> registrations) { *called = true; *out_error = error; - if (error == BackgroundSyncError::BACKGROUND_SYNC_ERROR_NONE) + if (error == BackgroundSyncError::NONE) *out_array_size = registrations.size(); } @@ -222,17 +222,15 @@ void GetRegistrationOneShot( const mojo::String& tag, const BackgroundSyncService::RegisterCallback& callback) { - service_impl_->GetRegistration( - BackgroundSyncPeriodicity::BACKGROUND_SYNC_PERIODICITY_ONE_SHOT, tag, - sw_registration_id_, callback); + service_impl_->GetRegistration(BackgroundSyncPeriodicity::ONE_SHOT, tag, + sw_registration_id_, callback); base::RunLoop().RunUntilIdle(); } void GetRegistrationsOneShot( const BackgroundSyncService::GetRegistrationsCallback& callback) { - service_impl_->GetRegistrations( - BackgroundSyncPeriodicity::BACKGROUND_SYNC_PERIODICITY_ONE_SHOT, - sw_registration_id_, callback); + service_impl_->GetRegistrations(BackgroundSyncPeriodicity::ONE_SHOT, + sw_registration_id_, callback); base::RunLoop().RunUntilIdle(); } @@ -267,7 +265,7 @@ default_sync_registration_.Clone(), base::Bind(&ErrorAndRegistrationCallback, &called, &error, ®)); EXPECT_TRUE(called); - EXPECT_EQ(BackgroundSyncError::BACKGROUND_SYNC_ERROR_NONE, error); + EXPECT_EQ(BackgroundSyncError::NONE, error); EXPECT_EQ("", reg->tag); } @@ -279,8 +277,7 @@ default_sync_registration_->handle_id, base::Bind(&ErrorCallback, &unregister_called, &unregister_error)); EXPECT_TRUE(unregister_called); - EXPECT_EQ(BackgroundSyncError::BACKGROUND_SYNC_ERROR_NOT_ALLOWED, - unregister_error); + EXPECT_EQ(BackgroundSyncError::NOT_ALLOWED, unregister_error); } TEST_F(BackgroundSyncServiceImplTest, UnregisterWithRegisteredSync) { @@ -293,12 +290,12 @@ base::Bind(&ErrorAndRegistrationCallback, ®ister_called, ®ister_error, ®)); EXPECT_TRUE(register_called); - EXPECT_EQ(BackgroundSyncError::BACKGROUND_SYNC_ERROR_NONE, register_error); + EXPECT_EQ(BackgroundSyncError::NONE, register_error); UnregisterOneShot( reg->handle_id, base::Bind(&ErrorCallback, &unregister_called, &unregister_error)); EXPECT_TRUE(unregister_called); - EXPECT_EQ(BackgroundSyncError::BACKGROUND_SYNC_ERROR_NONE, unregister_error); + EXPECT_EQ(BackgroundSyncError::NONE, unregister_error); } TEST_F(BackgroundSyncServiceImplTest, GetRegistration) { @@ -308,7 +305,7 @@ GetRegistrationOneShot( "", base::Bind(&ErrorAndRegistrationCallback, &called, &error, ®)); EXPECT_TRUE(called); - EXPECT_EQ(BackgroundSyncError::BACKGROUND_SYNC_ERROR_NOT_FOUND, error); + EXPECT_EQ(BackgroundSyncError::NOT_FOUND, error); } TEST_F(BackgroundSyncServiceImplTest, GetRegistrationWithRegisteredSync) { @@ -322,14 +319,13 @@ base::Bind(&ErrorAndRegistrationCallback, ®ister_called, ®ister_error, ®ister_reg)); EXPECT_TRUE(register_called); - EXPECT_EQ(BackgroundSyncError::BACKGROUND_SYNC_ERROR_NONE, register_error); + EXPECT_EQ(BackgroundSyncError::NONE, register_error); GetRegistrationOneShot( register_reg->tag, base::Bind(&ErrorAndRegistrationCallback, &getregistration_called, &getregistration_error, &getregistration_reg)); EXPECT_TRUE(getregistration_called); - EXPECT_EQ(BackgroundSyncError::BACKGROUND_SYNC_ERROR_NONE, - getregistration_error); + EXPECT_EQ(BackgroundSyncError::NONE, getregistration_error); } TEST_F(BackgroundSyncServiceImplTest, GetRegistrations) { @@ -339,7 +335,7 @@ GetRegistrationsOneShot(base::Bind(&ErrorAndRegistrationListCallback, &called, &error, &array_size)); EXPECT_TRUE(called); - EXPECT_EQ(BackgroundSyncError::BACKGROUND_SYNC_ERROR_NONE, error); + EXPECT_EQ(BackgroundSyncError::NONE, error); EXPECT_EQ(0UL, array_size); } @@ -354,13 +350,12 @@ base::Bind(&ErrorAndRegistrationCallback, ®ister_called, ®ister_error, ®ister_reg)); EXPECT_TRUE(register_called); - EXPECT_EQ(BackgroundSyncError::BACKGROUND_SYNC_ERROR_NONE, register_error); + EXPECT_EQ(BackgroundSyncError::NONE, register_error); GetRegistrationsOneShot(base::Bind(&ErrorAndRegistrationListCallback, &getregistrations_called, &getregistrations_error, &array_size)); EXPECT_TRUE(getregistrations_called); - EXPECT_EQ(BackgroundSyncError::BACKGROUND_SYNC_ERROR_NONE, - getregistrations_error); + EXPECT_EQ(BackgroundSyncError::NONE, getregistrations_error); EXPECT_EQ(1UL, array_size); } @@ -373,7 +368,7 @@ base::Bind(&ErrorAndRegistrationCallback, ®ister_called, ®ister_error, ®)); EXPECT_TRUE(register_called); - EXPECT_EQ(BACKGROUND_SYNC_ERROR_NONE, register_error); + EXPECT_EQ(BackgroundSyncError::NONE, register_error); // Unregister it. bool unregister_called = false; @@ -382,19 +377,19 @@ reg->handle_id, base::Bind(&ErrorCallback, &unregister_called, &unregister_error)); EXPECT_TRUE(unregister_called); - EXPECT_EQ(BACKGROUND_SYNC_ERROR_NONE, unregister_error); + EXPECT_EQ(BackgroundSyncError::NONE, unregister_error); // Call NotifyWhenDone and verify that it calls back with unregistered. bool notify_done_called = false; - BackgroundSyncError notify_done_error = BACKGROUND_SYNC_ERROR_NONE; - BackgroundSyncState notify_done_sync_state = BACKGROUND_SYNC_STATE_SUCCESS; + BackgroundSyncError notify_done_error = BackgroundSyncError::NONE; + BackgroundSyncState notify_done_sync_state = BackgroundSyncState::SUCCESS; NotifyWhenDone(reg->handle_id, base::Bind(&ErrorAndStateCallback, ¬ify_done_called, ¬ify_done_error, ¬ify_done_sync_state)); EXPECT_TRUE(notify_done_called); - EXPECT_EQ(BACKGROUND_SYNC_ERROR_NONE, notify_done_error); - EXPECT_EQ(BACKGROUND_SYNC_STATE_UNREGISTERED, notify_done_sync_state); + EXPECT_EQ(BackgroundSyncError::NONE, notify_done_error); + EXPECT_EQ(BackgroundSyncState::UNREGISTERED, notify_done_sync_state); } } // namespace content
diff --git a/content/browser/compositor/browser_compositor_overlay_candidate_validator_mac.mm b/content/browser/compositor/browser_compositor_overlay_candidate_validator_mac.mm index 9c12c7e..2b1c3ec 100644 --- a/content/browser/compositor/browser_compositor_overlay_candidate_validator_mac.mm +++ b/content/browser/compositor/browser_compositor_overlay_candidate_validator_mac.mm
@@ -28,7 +28,6 @@ void BrowserCompositorOverlayCandidateValidatorMac::GetStrategies( cc::OverlayProcessor::StrategyList* strategies) { - strategies->push_back(make_scoped_ptr(new cc::OverlayStrategySandwich(this))); } bool BrowserCompositorOverlayCandidateValidatorMac::AllowCALayerOverlays() {
diff --git a/content/browser/compositor/delegated_frame_host.cc b/content/browser/compositor/delegated_frame_host.cc index 3125dd5..f381da0 100644 --- a/content/browser/compositor/delegated_frame_host.cc +++ b/content/browser/compositor/delegated_frame_host.cc
@@ -151,7 +151,7 @@ scoped_ptr<cc::CopyOutputRequest> request = cc::CopyOutputRequest::CreateRequest( - base::Bind(&CopyFromCompositingSurfaceHasResult, + base::Bind(&DelegatedFrameHost::CopyFromCompositingSurfaceHasResult, output_size, preferred_color_type, callback)); if (!src_subrect.IsEmpty()) request->set_area(src_subrect); @@ -593,6 +593,155 @@ } // static +void DelegatedFrameHost::CopyFromCompositingSurfaceHasResult( + const gfx::Size& dst_size_in_pixel, + const SkColorType color_type, + const ReadbackRequestCallback& callback, + scoped_ptr<cc::CopyOutputResult> result) { + if (result->IsEmpty() || result->size().IsEmpty()) { + callback.Run(SkBitmap(), content::READBACK_FAILED); + return; + } + + gfx::Size output_size_in_pixel; + if (dst_size_in_pixel.IsEmpty()) + output_size_in_pixel = result->size(); + else + output_size_in_pixel = dst_size_in_pixel; + + if (result->HasTexture()) { + // GPU-accelerated path + PrepareTextureCopyOutputResult(output_size_in_pixel, color_type, callback, + std::move(result)); + return; + } + + DCHECK(result->HasBitmap()); + // Software path + PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback, + std::move(result)); +} + +static void CopyFromCompositingSurfaceFinished( + const ReadbackRequestCallback& callback, + scoped_ptr<cc::SingleReleaseCallback> release_callback, + scoped_ptr<SkBitmap> bitmap, + scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, + bool result) { + bitmap_pixels_lock.reset(); + + gpu::SyncToken sync_token; + if (result) { + GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); + if (gl_helper) + gl_helper->GenerateSyncToken(&sync_token); + } + const bool lost_resource = !sync_token.HasData(); + release_callback->Run(sync_token, lost_resource); + + callback.Run(*bitmap, + result ? content::READBACK_SUCCESS : content::READBACK_FAILED); +} + +// static +void DelegatedFrameHost::PrepareTextureCopyOutputResult( + const gfx::Size& dst_size_in_pixel, + const SkColorType color_type, + const ReadbackRequestCallback& callback, + scoped_ptr<cc::CopyOutputResult> result) { + DCHECK(result->HasTexture()); + base::ScopedClosureRunner scoped_callback_runner( + base::Bind(callback, SkBitmap(), content::READBACK_FAILED)); + + // TODO(siva.gunturi): We should be able to validate the format here using + // GLHelper::IsReadbackConfigSupported before we processs the result. + // See crbug.com/415682 and crbug.com/415131. + scoped_ptr<SkBitmap> bitmap(new SkBitmap); + if (!bitmap->tryAllocPixels(SkImageInfo::Make( + dst_size_in_pixel.width(), dst_size_in_pixel.height(), color_type, + kOpaque_SkAlphaType))) { + scoped_callback_runner.Reset(base::Bind( + callback, SkBitmap(), content::READBACK_BITMAP_ALLOCATION_FAILURE)); + return; + } + + ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); + GLHelper* gl_helper = factory->GetGLHelper(); + if (!gl_helper) + return; + + scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( + new SkAutoLockPixels(*bitmap)); + uint8_t* pixels = static_cast<uint8_t*>(bitmap->getPixels()); + + cc::TextureMailbox texture_mailbox; + scoped_ptr<cc::SingleReleaseCallback> release_callback; + result->TakeTexture(&texture_mailbox, &release_callback); + DCHECK(texture_mailbox.IsTexture()); + + ignore_result(scoped_callback_runner.Release()); + + gl_helper->CropScaleReadbackAndCleanMailbox( + texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(), + gfx::Rect(result->size()), dst_size_in_pixel, pixels, color_type, + base::Bind(&CopyFromCompositingSurfaceFinished, callback, + base::Passed(&release_callback), base::Passed(&bitmap), + base::Passed(&bitmap_pixels_lock)), + GLHelper::SCALER_QUALITY_GOOD); +} + +// static +void DelegatedFrameHost::PrepareBitmapCopyOutputResult( + const gfx::Size& dst_size_in_pixel, + const SkColorType preferred_color_type, + const ReadbackRequestCallback& callback, + scoped_ptr<cc::CopyOutputResult> result) { + SkColorType color_type = preferred_color_type; + if (color_type != kN32_SkColorType && color_type != kAlpha_8_SkColorType) { + // Switch back to default colortype if format not supported. + color_type = kN32_SkColorType; + } + DCHECK(result->HasBitmap()); + scoped_ptr<SkBitmap> source = result->TakeBitmap(); + DCHECK(source); + SkBitmap scaled_bitmap; + if (source->width() != dst_size_in_pixel.width() || + source->height() != dst_size_in_pixel.height()) { + scaled_bitmap = + skia::ImageOperations::Resize(*source, + skia::ImageOperations::RESIZE_BEST, + dst_size_in_pixel.width(), + dst_size_in_pixel.height()); + } else { + scaled_bitmap = *source; + } + if (color_type == kN32_SkColorType) { + DCHECK_EQ(scaled_bitmap.colorType(), kN32_SkColorType); + callback.Run(scaled_bitmap, READBACK_SUCCESS); + return; + } + DCHECK_EQ(color_type, kAlpha_8_SkColorType); + // The software path currently always returns N32 bitmap regardless of the + // |color_type| we ask for. + DCHECK_EQ(scaled_bitmap.colorType(), kN32_SkColorType); + // Paint |scaledBitmap| to alpha-only |grayscale_bitmap|. + SkBitmap grayscale_bitmap; + bool success = grayscale_bitmap.tryAllocPixels( + SkImageInfo::MakeA8(scaled_bitmap.width(), scaled_bitmap.height())); + if (!success) { + callback.Run(SkBitmap(), content::READBACK_BITMAP_ALLOCATION_FAILURE); + return; + } + SkCanvas canvas(grayscale_bitmap); + SkPaint paint; + skia::RefPtr<SkColorFilter> filter = + skia::AdoptRef(SkLumaColorFilter::Create()); + paint.setColorFilter(filter.get()); + canvas.drawBitmap(scaled_bitmap, SkIntToScalar(0), SkIntToScalar(0), &paint); + callback.Run(grayscale_bitmap, READBACK_SUCCESS); +} + +// static void DelegatedFrameHost::ReturnSubscriberTexture( base::WeakPtr<DelegatedFrameHost> dfh, scoped_refptr<OwnedMailbox> subscriber_texture, @@ -898,12 +1047,11 @@ void DelegatedFrameHost::RequestCopyOfOutput( scoped_ptr<cc::CopyOutputRequest> request) { - if (!request_copy_of_output_callback_for_testing_.is_null()) { + if (!request_copy_of_output_callback_for_testing_.is_null()) request_copy_of_output_callback_for_testing_.Run(std::move(request)); - } else { + else client_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput( std::move(request)); - } } void DelegatedFrameHost::UnlockResources() {
diff --git a/content/browser/compositor/delegated_frame_host.h b/content/browser/compositor/delegated_frame_host.h index b937c76a..d1237afa 100644 --- a/content/browser/compositor/delegated_frame_host.h +++ b/content/browser/compositor/delegated_frame_host.h
@@ -219,6 +219,21 @@ // Called after async thumbnailer task completes. Scales and crops the result // of the copy. + static void CopyFromCompositingSurfaceHasResult( + const gfx::Size& dst_size_in_pixel, + const SkColorType color_type, + const ReadbackRequestCallback& callback, + scoped_ptr<cc::CopyOutputResult> result); + static void PrepareTextureCopyOutputResult( + const gfx::Size& dst_size_in_pixel, + const SkColorType color_type, + const ReadbackRequestCallback& callback, + scoped_ptr<cc::CopyOutputResult> result); + static void PrepareBitmapCopyOutputResult( + const gfx::Size& dst_size_in_pixel, + const SkColorType color_type, + const ReadbackRequestCallback& callback, + scoped_ptr<cc::CopyOutputResult> result); static void CopyFromCompositingSurfaceHasResultForVideo( base::WeakPtr<DelegatedFrameHost> rwhva, scoped_refptr<OwnedMailbox> subscriber_texture,
diff --git a/content/browser/compositor/surface_utils.cc b/content/browser/compositor/surface_utils.cc index 83d55f5..7ae0591 100644 --- a/content/browser/compositor/surface_utils.cc +++ b/content/browser/compositor/surface_utils.cc
@@ -4,21 +4,8 @@ #include "content/browser/compositor/surface_utils.h" -#include "base/callback_helpers.h" -#include "base/memory/ref_counted.h" #include "build/build_config.h" -#include "cc/output/copy_output_result.h" -#include "cc/resources/single_release_callback.h" #include "cc/surfaces/surface_id_allocator.h" -#include "content/common/gpu/client/gl_helper.h" -#include "skia/ext/image_operations.h" -#include "skia/ext/refptr.h" -#include "third_party/skia/include/core/SkCanvas.h" -#include "third_party/skia/include/core/SkColorFilter.h" -#include "third_party/skia/include/core/SkPaint.h" -#include "third_party/skia/include/effects/SkLumaColorFilter.h" -#include "ui/gfx/geometry/rect.h" - #if defined(OS_ANDROID) && !defined(USE_AURA) #include "content/browser/renderer_host/compositor_impl_android.h" @@ -27,135 +14,6 @@ #include "ui/compositor/compositor.h" #endif -namespace { - -#if !defined(OS_ANDROID) || defined(USE_AURA) -void CopyFromCompositingSurfaceFinished( - const content::ReadbackRequestCallback& callback, - scoped_ptr<cc::SingleReleaseCallback> release_callback, - scoped_ptr<SkBitmap> bitmap, - scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, - bool result) { - bitmap_pixels_lock.reset(); - - gpu::SyncToken sync_token; - if (result) { - content::GLHelper* gl_helper = - content::ImageTransportFactory::GetInstance()->GetGLHelper(); - if (gl_helper) - gl_helper->GenerateSyncToken(&sync_token); - } - const bool lost_resource = !sync_token.HasData(); - release_callback->Run(sync_token, lost_resource); - - callback.Run(*bitmap, - result ? content::READBACK_SUCCESS : content::READBACK_FAILED); -} -#endif - -void PrepareTextureCopyOutputResult( - const gfx::Size& dst_size_in_pixel, - const SkColorType color_type, - const content::ReadbackRequestCallback& callback, - scoped_ptr<cc::CopyOutputResult> result) { -#if defined(OS_ANDROID) && !defined(USE_AURA) - //TODO(wjmaclean): See if there's an equivalent pathway for Android and - // implement it here. - callback.Run(SkBitmap(), content::READBACK_FAILED); -#else - DCHECK(result->HasTexture()); - base::ScopedClosureRunner scoped_callback_runner( - base::Bind(callback, SkBitmap(), content::READBACK_FAILED)); - - // TODO(siva.gunturi): We should be able to validate the format here using - // GLHelper::IsReadbackConfigSupported before we processs the result. - // See crbug.com/415682 and crbug.com/415131. - scoped_ptr<SkBitmap> bitmap(new SkBitmap); - if (!bitmap->tryAllocPixels(SkImageInfo::Make( - dst_size_in_pixel.width(), dst_size_in_pixel.height(), color_type, - kOpaque_SkAlphaType))) { - scoped_callback_runner.Reset(base::Bind( - callback, SkBitmap(), content::READBACK_BITMAP_ALLOCATION_FAILURE)); - return; - } - - content::ImageTransportFactory* factory = - content::ImageTransportFactory::GetInstance(); - content::GLHelper* gl_helper = factory->GetGLHelper(); - if (!gl_helper) - return; - - scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( - new SkAutoLockPixels(*bitmap)); - uint8_t* pixels = static_cast<uint8_t*>(bitmap->getPixels()); - - cc::TextureMailbox texture_mailbox; - scoped_ptr<cc::SingleReleaseCallback> release_callback; - result->TakeTexture(&texture_mailbox, &release_callback); - DCHECK(texture_mailbox.IsTexture()); - - ignore_result(scoped_callback_runner.Release()); - - gl_helper->CropScaleReadbackAndCleanMailbox( - texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(), - gfx::Rect(result->size()), dst_size_in_pixel, pixels, color_type, - base::Bind(&CopyFromCompositingSurfaceFinished, callback, - base::Passed(&release_callback), base::Passed(&bitmap), - base::Passed(&bitmap_pixels_lock)), - content::GLHelper::SCALER_QUALITY_GOOD); -#endif -} - -void PrepareBitmapCopyOutputResult( - const gfx::Size& dst_size_in_pixel, - const SkColorType preferred_color_type, - const content::ReadbackRequestCallback& callback, - scoped_ptr<cc::CopyOutputResult> result) { - SkColorType color_type = preferred_color_type; - if (color_type != kN32_SkColorType && color_type != kAlpha_8_SkColorType) { - // Switch back to default colortype if format not supported. - color_type = kN32_SkColorType; - } - DCHECK(result->HasBitmap()); - scoped_ptr<SkBitmap> source = result->TakeBitmap(); - DCHECK(source); - SkBitmap scaled_bitmap; - if (source->width() != dst_size_in_pixel.width() || - source->height() != dst_size_in_pixel.height()) { - scaled_bitmap = skia::ImageOperations::Resize( - *source, skia::ImageOperations::RESIZE_BEST, dst_size_in_pixel.width(), - dst_size_in_pixel.height()); - } else { - scaled_bitmap = *source; - } - if (color_type == kN32_SkColorType) { - DCHECK_EQ(scaled_bitmap.colorType(), kN32_SkColorType); - callback.Run(scaled_bitmap, content::READBACK_SUCCESS); - return; - } - DCHECK_EQ(color_type, kAlpha_8_SkColorType); - // The software path currently always returns N32 bitmap regardless of the - // |color_type| we ask for. - DCHECK_EQ(scaled_bitmap.colorType(), kN32_SkColorType); - // Paint |scaledBitmap| to alpha-only |grayscale_bitmap|. - SkBitmap grayscale_bitmap; - bool success = grayscale_bitmap.tryAllocPixels( - SkImageInfo::MakeA8(scaled_bitmap.width(), scaled_bitmap.height())); - if (!success) { - callback.Run(SkBitmap(), content::READBACK_BITMAP_ALLOCATION_FAILURE); - return; - } - SkCanvas canvas(grayscale_bitmap); - SkPaint paint; - skia::RefPtr<SkColorFilter> filter = - skia::AdoptRef(SkLumaColorFilter::Create()); - paint.setColorFilter(filter.get()); - canvas.drawBitmap(scaled_bitmap, SkIntToScalar(0), SkIntToScalar(0), &paint); - callback.Run(grayscale_bitmap, content::READBACK_SUCCESS); -} - -} // namespace - namespace content { scoped_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator() { @@ -176,33 +34,4 @@ #endif } -void CopyFromCompositingSurfaceHasResult( - const gfx::Size& dst_size_in_pixel, - const SkColorType color_type, - const ReadbackRequestCallback& callback, - scoped_ptr<cc::CopyOutputResult> result) { - if (result->IsEmpty() || result->size().IsEmpty()) { - callback.Run(SkBitmap(), READBACK_FAILED); - return; - } - - gfx::Size output_size_in_pixel; - if (dst_size_in_pixel.IsEmpty()) - output_size_in_pixel = result->size(); - else - output_size_in_pixel = dst_size_in_pixel; - - if (result->HasTexture()) { - // GPU-accelerated path - PrepareTextureCopyOutputResult(output_size_in_pixel, color_type, callback, - std::move(result)); - return; - } - - DCHECK(result->HasBitmap()); - // Software path - PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback, - std::move(result)); -} - } // namespace content
diff --git a/content/browser/compositor/surface_utils.h b/content/browser/compositor/surface_utils.h index 00d0fd7..b56fef27 100644 --- a/content/browser/compositor/surface_utils.h +++ b/content/browser/compositor/surface_utils.h
@@ -6,12 +6,8 @@ #define CONTENT_BROWSER_COMPOSITOR_SURFACE_UTILS_H_ #include "base/memory/scoped_ptr.h" -#include "content/public/browser/readback_types.h" -#include "third_party/skia/include/core/SkImageInfo.h" -#include "ui/gfx/geometry/size.h" namespace cc { -class CopyOutputResult; class SurfaceIdAllocator; class SurfaceManager; } // namespace cc @@ -22,12 +18,6 @@ cc::SurfaceManager* GetSurfaceManager(); -void CopyFromCompositingSurfaceHasResult( - const gfx::Size& dst_size_in_pixel, - const SkColorType color_type, - const ReadbackRequestCallback& callback, - scoped_ptr<cc::CopyOutputResult> result); - } // namespace content #endif // CONTENT_BROWSER_COMPOSITOR_SURFACE_UTILS_H_
diff --git a/content/browser/frame_host/render_widget_host_view_child_frame.cc b/content/browser/frame_host/render_widget_host_view_child_frame.cc index 62b1d6e9a..e8d384e7 100644 --- a/content/browser/frame_host/render_widget_host_view_child_frame.cc +++ b/content/browser/frame_host/render_widget_host_view_child_frame.cc
@@ -9,8 +9,6 @@ #include <vector> #include "build/build_config.h" -#include "cc/output/copy_output_request.h" -#include "cc/output/copy_output_result.h" #include "cc/surfaces/surface.h" #include "cc/surfaces/surface_factory.h" #include "cc/surfaces/surface_manager.h" @@ -428,21 +426,11 @@ #endif // defined(OS_MACOSX) void RenderWidgetHostViewChildFrame::CopyFromCompositingSurface( - const gfx::Rect& src_subrect, - const gfx::Size& output_size, + const gfx::Rect& /* src_subrect */, + const gfx::Size& /* dst_size */, const ReadbackRequestCallback& callback, - const SkColorType preferred_color_type) { - if (!surface_factory_ || surface_id_.is_null()) - callback.Run(SkBitmap(), READBACK_FAILED); - - scoped_ptr<cc::CopyOutputRequest> request = - cc::CopyOutputRequest::CreateRequest( - base::Bind(&CopyFromCompositingSurfaceHasResult, output_size, - preferred_color_type, callback)); - if (!src_subrect.IsEmpty()) - request->set_area(src_subrect); - - surface_factory_->RequestCopyOfSurface(surface_id_, std::move(request)); + const SkColorType /* preferred_color_type */) { + callback.Run(SkBitmap(), READBACK_FAILED); } void RenderWidgetHostViewChildFrame::CopyFromCompositingSurfaceToVideoFrame(
diff --git a/content/browser/media/cdm/browser_cdm_manager.cc b/content/browser/media/cdm/browser_cdm_manager.cc index 2f997d07..c83bdd2 100644 --- a/content/browser/media/cdm/browser_cdm_manager.cc +++ b/content/browser/media/cdm/browser_cdm_manager.cc
@@ -670,7 +670,7 @@ PermissionType::PROTECTED_MEDIA_IDENTIFIER, security_origin, web_contents->GetLastCommittedURL().GetOrigin()); - bool allowed = (permission_status == PERMISSION_STATUS_GRANTED); + bool allowed = (permission_status == PermissionStatus::GRANTED); if (!task_runner_->RunsTasksOnCurrentThread()) { task_runner_->PostTask(FROM_HERE, base::Bind(permission_status_cb, allowed));
diff --git a/content/browser/navigator_connect/navigator_connect_context_impl.cc b/content/browser/navigator_connect/navigator_connect_context_impl.cc index f571b9f..02459122 100644 --- a/content/browser/navigator_connect/navigator_connect_context_impl.cc +++ b/content/browser/navigator_connect/navigator_connect_context_impl.cc
@@ -226,7 +226,7 @@ if (!worker->FinishRequest(request_id)) return; - if (result != SERVICE_PORT_CONNECT_RESULT_ACCEPT) { + if (result != ServicePortConnectResult::ACCEPT) { OnConnectError(callback, client_port_id, service_port_id, SERVICE_WORKER_ERROR_FAILED); return;
diff --git a/content/browser/navigator_connect/service_port_service_impl.cc b/content/browser/navigator_connect/service_port_service_impl.cc index 73ea2793..16065c18 100644 --- a/content/browser/navigator_connect/service_port_service_impl.cc +++ b/content/browser/navigator_connect/service_port_service_impl.cc
@@ -124,8 +124,8 @@ void ServicePortServiceImpl::OnConnectResult(const ConnectCallback& callback, int message_port_id, bool success) { - callback.Run(success ? SERVICE_PORT_CONNECT_RESULT_ACCEPT - : SERVICE_PORT_CONNECT_RESULT_REJECT, + callback.Run(success ? ServicePortConnectResult::ACCEPT + : ServicePortConnectResult::REJECT, message_port_id); }
diff --git a/content/browser/permissions/permission_service_impl.cc b/content/browser/permissions/permission_service_impl.cc index e8efb28..51e75ad 100644 --- a/content/browser/permissions/permission_service_impl.cc +++ b/content/browser/permissions/permission_service_impl.cc
@@ -18,23 +18,23 @@ PermissionType PermissionNameToPermissionType(PermissionName name) { switch(name) { - case PERMISSION_NAME_GEOLOCATION: + case PermissionName::GEOLOCATION: return PermissionType::GEOLOCATION; - case PERMISSION_NAME_NOTIFICATIONS: + case PermissionName::NOTIFICATIONS: return PermissionType::NOTIFICATIONS; - case PERMISSION_NAME_PUSH_NOTIFICATIONS: + case PermissionName::PUSH_NOTIFICATIONS: return PermissionType::PUSH_MESSAGING; - case PERMISSION_NAME_MIDI: + case PermissionName::MIDI: return PermissionType::MIDI; - case PERMISSION_NAME_MIDI_SYSEX: + case PermissionName::MIDI_SYSEX: return PermissionType::MIDI_SYSEX; - case PERMISSION_NAME_PROTECTED_MEDIA_IDENTIFIER: + case PermissionName::PROTECTED_MEDIA_IDENTIFIER: return PermissionType::PROTECTED_MEDIA_IDENTIFIER; - case PERMISSION_NAME_DURABLE_STORAGE: + case PermissionName::DURABLE_STORAGE: return PermissionType::DURABLE_STORAGE; - case PERMISSION_NAME_AUDIO_CAPTURE: + case PermissionName::AUDIO_CAPTURE: return PermissionType::AUDIO_CAPTURE; - case PERMISSION_NAME_VIDEO_CAPTURE: + case PermissionName::VIDEO_CAPTURE: return PermissionType::VIDEO_CAPTURE; } @@ -67,7 +67,7 @@ mojo::Array<PermissionStatus> result = mojo::Array<PermissionStatus>::New(request_count); for (int i = 0; i < request_count; ++i) - result[i] = PERMISSION_STATUS_DENIED; + result[i] = PermissionStatus::DENIED; callback.Run(std::move(result)); } @@ -83,7 +83,7 @@ PermissionServiceImpl::PendingSubscription::~PendingSubscription() { if (!callback.is_null()) - callback.Run(PERMISSION_STATUS_ASK); + callback.Run(PermissionStatus::ASK); } PermissionServiceImpl::PermissionServiceImpl( @@ -263,7 +263,7 @@ // Resetting the permission should only be possible if the permission is // already granted. - if (status != PERMISSION_STATUS_GRANTED) { + if (status != PermissionStatus::GRANTED) { callback.Run(status); return; } @@ -325,7 +325,7 @@ BrowserContext* browser_context = context_->GetBrowserContext(); DCHECK(browser_context); if (!browser_context->GetPermissionManager()) - return PERMISSION_STATUS_DENIED; + return PermissionStatus::DENIED; // If the embedding_origin is empty we'll use |origin| instead. GURL embedding_origin = context_->GetEmbeddingOrigin();
diff --git a/content/browser/presentation/presentation_service_impl.cc b/content/browser/presentation/presentation_service_impl.cc index 07644589..26947c2a 100644 --- a/content/browser/presentation/presentation_service_impl.cc +++ b/content/browser/presentation/presentation_service_impl.cc
@@ -47,8 +47,7 @@ if (input->is_binary()) { // binary data DCHECK(input->data); - output->type = presentation::PresentationMessageType:: - PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER; + output->type = presentation::PresentationMessageType::ARRAY_BUFFER; if (pass_ownership) { output->data.Swap(input->data.get()); } else { @@ -56,8 +55,7 @@ } } else { // string message - output->type = - presentation::PresentationMessageType::PRESENTATION_MESSAGE_TYPE_TEXT; + output->type = presentation::PresentationMessageType::TEXT; if (pass_ownership) { output->message.Swap(&input->message); } else { @@ -72,7 +70,7 @@ DCHECK(!input.is_null()); scoped_ptr<content::PresentationSessionMessage> output; switch (input->type) { - case presentation::PRESENTATION_MESSAGE_TYPE_TEXT: { + case presentation::PresentationMessageType::TEXT: { DCHECK(!input->message.is_null()); DCHECK(input->data.is_null()); // Return null PresentationSessionMessage if size exceeds. @@ -84,7 +82,7 @@ input->message.Swap(&output->message); return output; } - case presentation::PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER: { + case presentation::PresentationMessageType::ARRAY_BUFFER: { DCHECK(!input->data.is_null()); DCHECK(input->message.is_null()); if (input->data.size() > content::kMaxPresentationSessionMessageSize) @@ -96,7 +94,7 @@ input->data.Swap(output->data.get()); return output; } - case presentation::PRESENTATION_MESSAGE_TYPE_BLOB: { + case presentation::PresentationMessageType::BLOB: { DCHECK(!input->data.is_null()); DCHECK(input->message.is_null()); if (input->data.size() > content::kMaxPresentationSessionMessageSize)
diff --git a/content/browser/presentation/presentation_service_impl_unittest.cc b/content/browser/presentation/presentation_service_impl_unittest.cc index cc98878..80e7952 100644 --- a/content/browser/presentation/presentation_service_impl_unittest.cc +++ b/content/browser/presentation/presentation_service_impl_unittest.cc
@@ -308,12 +308,11 @@ bool pass_ownership) { mojo::Array<presentation::SessionMessagePtr> expected_msgs(2); expected_msgs[0] = presentation::SessionMessage::New(); - expected_msgs[0]->type = - presentation::PresentationMessageType::PRESENTATION_MESSAGE_TYPE_TEXT; + expected_msgs[0]->type = presentation::PresentationMessageType::TEXT; expected_msgs[0]->message = text_msg; expected_msgs[1] = presentation::SessionMessage::New(); - expected_msgs[1]->type = presentation::PresentationMessageType:: - PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER; + expected_msgs[1]->type = + presentation::PresentationMessageType::ARRAY_BUFFER; expected_msgs[1]->data = mojo::Array<uint8_t>::From(binary_data); presentation::PresentationSessionInfoPtr session( @@ -477,9 +476,9 @@ EXPECT_CALL(mock_client_, OnConnectionStateChanged( Equals(presentation_connection), - presentation::PRESENTATION_CONNECTION_STATE_CLOSED)) + presentation::PresentationConnectionState::CLOSED)) .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); - state_changed_cb.Run(content::PRESENTATION_CONNECTION_STATE_CLOSED); + state_changed_cb.Run(PRESENTATION_CONNECTION_STATE_CLOSED); run_loop.Run(); } @@ -636,8 +635,7 @@ session->id = kPresentationId; presentation::SessionMessagePtr message_request( presentation::SessionMessage::New()); - message_request->type = presentation::PresentationMessageType:: - PRESENTATION_MESSAGE_TYPE_TEXT; + message_request->type = presentation::PresentationMessageType::TEXT; message_request->message = message; service_ptr_->SendSessionMessage( std::move(session), std::move(message_request), @@ -675,8 +673,7 @@ session->id = kPresentationId; presentation::SessionMessagePtr message_request( presentation::SessionMessage::New()); - message_request->type = presentation::PresentationMessageType:: - PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER; + message_request->type = presentation::PresentationMessageType::ARRAY_BUFFER; message_request->data = mojo::Array<uint8_t>::From(data); service_ptr_->SendSessionMessage( std::move(session), std::move(message_request), @@ -720,8 +717,7 @@ session->id = kPresentationId; presentation::SessionMessagePtr message_request( presentation::SessionMessage::New()); - message_request->type = presentation::PresentationMessageType:: - PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER; + message_request->type = presentation::PresentationMessageType::ARRAY_BUFFER; message_request->data = mojo::Array<uint8_t>::From(data); service_ptr_->SendSessionMessage( std::move(session), std::move(message_request), @@ -752,8 +748,7 @@ session->id = kPresentationId; presentation::SessionMessagePtr message_request( presentation::SessionMessage::New()); - message_request->type = - presentation::PresentationMessageType::PRESENTATION_MESSAGE_TYPE_BLOB; + message_request->type = presentation::PresentationMessageType::BLOB; message_request->data = mojo::Array<uint8_t>::From(data); service_ptr_->SendSessionMessage( std::move(session), std::move(message_request),
diff --git a/content/browser/presentation/presentation_type_converters.cc b/content/browser/presentation/presentation_type_converters.cc index cd64997..6068950 100644 --- a/content/browser/presentation/presentation_type_converters.cc +++ b/content/browser/presentation/presentation_type_converters.cc
@@ -12,32 +12,32 @@ content::PresentationErrorType input) { switch (input) { case content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS: - return presentation::PRESENTATION_ERROR_TYPE_NO_AVAILABLE_SCREENS; + return presentation::PresentationErrorType::NO_AVAILABLE_SCREENS; case content::PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED: - return presentation::PRESENTATION_ERROR_TYPE_SESSION_REQUEST_CANCELLED; + return presentation::PresentationErrorType::SESSION_REQUEST_CANCELLED; case content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND: - return presentation::PRESENTATION_ERROR_TYPE_NO_PRESENTATION_FOUND; + return presentation::PresentationErrorType::NO_PRESENTATION_FOUND; case content::PRESENTATION_ERROR_UNKNOWN: - return presentation::PRESENTATION_ERROR_TYPE_UNKNOWN; + return presentation::PresentationErrorType::UNKNOWN; } NOTREACHED(); - return presentation::PRESENTATION_ERROR_TYPE_UNKNOWN; + return presentation::PresentationErrorType::UNKNOWN; } presentation::PresentationConnectionState PresentationConnectionStateToMojo( content::PresentationConnectionState state) { switch (state) { case content::PRESENTATION_CONNECTION_STATE_CONNECTING: - return presentation::PRESENTATION_CONNECTION_STATE_CONNECTING; + return presentation::PresentationConnectionState::CONNECTING; case content::PRESENTATION_CONNECTION_STATE_CONNECTED: - return presentation::PRESENTATION_CONNECTION_STATE_CONNECTED; + return presentation::PresentationConnectionState::CONNECTED; case content::PRESENTATION_CONNECTION_STATE_CLOSED: - return presentation::PRESENTATION_CONNECTION_STATE_CLOSED; + return presentation::PresentationConnectionState::CLOSED; case content::PRESENTATION_CONNECTION_STATE_TERMINATED: - return presentation::PRESENTATION_CONNECTION_STATE_TERMINATED; + return presentation::PresentationConnectionState::TERMINATED; } NOTREACHED(); - return presentation::PRESENTATION_CONNECTION_STATE_TERMINATED; + return presentation::PresentationConnectionState::TERMINATED; } } // namespace content
diff --git a/content/browser/presentation/presentation_type_converters_unittest.cc b/content/browser/presentation/presentation_type_converters_unittest.cc index 3107aff3..61c91f9 100644 --- a/content/browser/presentation/presentation_type_converters_unittest.cc +++ b/content/browser/presentation/presentation_type_converters_unittest.cc
@@ -26,7 +26,7 @@ presentation::PresentationErrorPtr error_mojo( presentation::PresentationError::From(error)); EXPECT_FALSE(error_mojo.is_null()); - EXPECT_EQ(presentation::PRESENTATION_ERROR_TYPE_NO_AVAILABLE_SCREENS, + EXPECT_EQ(presentation::PresentationErrorType::NO_AVAILABLE_SCREENS, error_mojo->error_type); EXPECT_EQ(message, error_mojo->message); }
diff --git a/content/browser/push_messaging/push_messaging_message_filter.cc b/content/browser/push_messaging/push_messaging_message_filter.cc index 41668e3..1efbc68 100644 --- a/content/browser/push_messaging/push_messaging_message_filter.cc +++ b/content/browser/push_messaging/push_messaging_message_filter.cc
@@ -457,7 +457,7 @@ PermissionStatus status) { DCHECK_CURRENTLY_ON(BrowserThread::UI); // Notification permission should always be denied in incognito. - DCHECK_EQ(PERMISSION_STATUS_DENIED, status); + DCHECK_EQ(PermissionStatus::DENIED, status); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&PushMessagingMessageFilter::SendSubscriptionError, io_parent_,
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 06fd27cb..1d19e40 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc
@@ -413,13 +413,12 @@ rwh_input_event_router_.reset(); - // Delete all RFH pending shutdown, which will lead the corresponding RVH to - // shutdown and be deleted as well. - for (FrameTreeNode* node : frame_tree_.Nodes()) + for (FrameTreeNode* node : frame_tree_.Nodes()) { + // Delete all RFHs pending shutdown, which will lead the corresponding RVHs + // to be shutdown and be deleted as well. node->render_manager()->ClearRFHsPendingShutdown(); - - for (FrameTreeNode* node : frame_tree_.Nodes()) node->render_manager()->ClearWebUIInstances(); + } for (RenderWidgetHostImpl* widget : created_widgets_) widget->DetachDelegate();
diff --git a/content/child/background_sync/background_sync_provider.cc b/content/child/background_sync/background_sync_provider.cc index d29a40f..9895820 100644 --- a/content/child/background_sync/background_sync_provider.cc +++ b/content/child/background_sync/background_sync_provider.cc
@@ -227,27 +227,27 @@ // TODO(iclelland): Determine the correct error message to return in each case scoped_ptr<blink::WebSyncRegistration> result; switch (error) { - case BACKGROUND_SYNC_ERROR_NONE: + case BackgroundSyncError::NONE: if (!options.is_null()) result = mojo::ConvertTo<scoped_ptr<blink::WebSyncRegistration>>(options); callbacks->onSuccess(blink::adoptWebPtr(result.release())); break; - case BACKGROUND_SYNC_ERROR_NOT_FOUND: + case BackgroundSyncError::NOT_FOUND: NOTREACHED(); break; - case BACKGROUND_SYNC_ERROR_STORAGE: + case BackgroundSyncError::STORAGE: callbacks->onError( blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, "Background Sync is disabled.")); break; - case BACKGROUND_SYNC_ERROR_NOT_ALLOWED: + case BackgroundSyncError::NOT_ALLOWED: callbacks->onError( blink::WebSyncError(blink::WebSyncError::ErrorTypeNoPermission, "Attempted to register a sync event without a " "window or registration tag too long.")); break; - case BACKGROUND_SYNC_ERROR_NO_SERVICE_WORKER: + case BackgroundSyncError::NO_SERVICE_WORKER: callbacks->onError( blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, "No service worker is active.")); @@ -260,23 +260,23 @@ BackgroundSyncError error) { // TODO(iclelland): Determine the correct error message to return in each case switch (error) { - case BACKGROUND_SYNC_ERROR_NONE: + case BackgroundSyncError::NONE: callbacks->onSuccess(true); break; - case BACKGROUND_SYNC_ERROR_NOT_FOUND: + case BackgroundSyncError::NOT_FOUND: callbacks->onSuccess(false); break; - case BACKGROUND_SYNC_ERROR_STORAGE: + case BackgroundSyncError::STORAGE: callbacks->onError( blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, "Background Sync is disabled.")); break; - case BACKGROUND_SYNC_ERROR_NOT_ALLOWED: + case BackgroundSyncError::NOT_ALLOWED: // This error should never be returned from // BackgroundSyncManager::Unregister NOTREACHED(); break; - case BACKGROUND_SYNC_ERROR_NO_SERVICE_WORKER: + case BackgroundSyncError::NO_SERVICE_WORKER: callbacks->onError( blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, "No service worker is active.")); @@ -291,26 +291,26 @@ // TODO(iclelland): Determine the correct error message to return in each case scoped_ptr<blink::WebSyncRegistration> result; switch (error) { - case BACKGROUND_SYNC_ERROR_NONE: + case BackgroundSyncError::NONE: if (!options.is_null()) result = mojo::ConvertTo<scoped_ptr<blink::WebSyncRegistration>>(options); callbacks->onSuccess(blink::adoptWebPtr(result.release())); break; - case BACKGROUND_SYNC_ERROR_NOT_FOUND: + case BackgroundSyncError::NOT_FOUND: callbacks->onSuccess(nullptr); break; - case BACKGROUND_SYNC_ERROR_STORAGE: + case BackgroundSyncError::STORAGE: callbacks->onError( blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, "Background Sync is disabled.")); break; - case BACKGROUND_SYNC_ERROR_NOT_ALLOWED: + case BackgroundSyncError::NOT_ALLOWED: // This error should never be returned from // BackgroundSyncManager::GetRegistration NOTREACHED(); break; - case BACKGROUND_SYNC_ERROR_NO_SERVICE_WORKER: + case BackgroundSyncError::NO_SERVICE_WORKER: callbacks->onError( blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, "No service worker is active.")); @@ -324,7 +324,7 @@ const mojo::Array<SyncRegistrationPtr>& registrations) { // TODO(iclelland): Determine the correct error message to return in each case switch (error) { - case BACKGROUND_SYNC_ERROR_NONE: { + case BackgroundSyncError::NONE: { blink::WebVector<blink::WebSyncRegistration*> results( registrations.size()); for (size_t i = 0; i < registrations.size(); ++i) { @@ -335,18 +335,18 @@ callbacks->onSuccess(results); break; } - case BACKGROUND_SYNC_ERROR_NOT_FOUND: - case BACKGROUND_SYNC_ERROR_NOT_ALLOWED: + case BackgroundSyncError::NOT_FOUND: + case BackgroundSyncError::NOT_ALLOWED: // These errors should never be returned from // BackgroundSyncManager::GetRegistrations NOTREACHED(); break; - case BACKGROUND_SYNC_ERROR_STORAGE: + case BackgroundSyncError::STORAGE: callbacks->onError( blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, "Background Sync is disabled.")); break; - case BACKGROUND_SYNC_ERROR_NO_SERVICE_WORKER: + case BackgroundSyncError::NO_SERVICE_WORKER: callbacks->onError( blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, "No service worker is active.")); @@ -360,31 +360,31 @@ PermissionStatus status) { // TODO(iclelland): Determine the correct error message to return in each case switch (error) { - case BACKGROUND_SYNC_ERROR_NONE: + case BackgroundSyncError::NONE: switch (status) { - case PERMISSION_STATUS_GRANTED: + case PermissionStatus::GRANTED: callbacks->onSuccess(blink::WebSyncPermissionStatusGranted); break; - case PERMISSION_STATUS_DENIED: + case PermissionStatus::DENIED: callbacks->onSuccess(blink::WebSyncPermissionStatusDenied); break; - case PERMISSION_STATUS_ASK: + case PermissionStatus::ASK: callbacks->onSuccess(blink::WebSyncPermissionStatusPrompt); break; } break; - case BACKGROUND_SYNC_ERROR_NOT_FOUND: - case BACKGROUND_SYNC_ERROR_NOT_ALLOWED: + case BackgroundSyncError::NOT_FOUND: + case BackgroundSyncError::NOT_ALLOWED: // These errors should never be returned from // BackgroundSyncManager::GetPermissionStatus NOTREACHED(); break; - case BACKGROUND_SYNC_ERROR_STORAGE: + case BackgroundSyncError::STORAGE: callbacks->onError( blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, "Background Sync is disabled.")); break; - case BACKGROUND_SYNC_ERROR_NO_SERVICE_WORKER: + case BackgroundSyncError::NO_SERVICE_WORKER: callbacks->onError( blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, "No service worker is active.")); @@ -397,35 +397,35 @@ BackgroundSyncError error, BackgroundSyncState state) { switch (error) { - case BACKGROUND_SYNC_ERROR_NONE: + case BackgroundSyncError::NONE: switch (state) { - case BACKGROUND_SYNC_STATE_PENDING: - case BACKGROUND_SYNC_STATE_FIRING: - case BACKGROUND_SYNC_STATE_REREGISTERED_WHILE_FIRING: - case BACKGROUND_SYNC_STATE_UNREGISTERED_WHILE_FIRING: + case BackgroundSyncState::PENDING: + case BackgroundSyncState::FIRING: + case BackgroundSyncState::REREGISTERED_WHILE_FIRING: + case BackgroundSyncState::UNREGISTERED_WHILE_FIRING: NOTREACHED(); break; - case BACKGROUND_SYNC_STATE_SUCCESS: + case BackgroundSyncState::SUCCESS: callbacks->onSuccess(); break; - case BACKGROUND_SYNC_STATE_FAILED: - case BACKGROUND_SYNC_STATE_UNREGISTERED: + case BackgroundSyncState::FAILED: + case BackgroundSyncState::UNREGISTERED: callbacks->onError(blink::WebSyncError( blink::WebSyncError::ErrorTypeAbort, "Sync failed, unregistered, or overwritten.")); break; } break; - case BACKGROUND_SYNC_ERROR_NOT_FOUND: - case BACKGROUND_SYNC_ERROR_NOT_ALLOWED: + case BackgroundSyncError::NOT_FOUND: + case BackgroundSyncError::NOT_ALLOWED: NOTREACHED(); break; - case BACKGROUND_SYNC_ERROR_STORAGE: + case BackgroundSyncError::STORAGE: callbacks->onError( blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, "Background Sync is disabled.")); break; - case BACKGROUND_SYNC_ERROR_NO_SERVICE_WORKER: + case BackgroundSyncError::NO_SERVICE_WORKER: callbacks->onError( blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, "No service worker is active."));
diff --git a/content/child/background_sync/background_sync_type_converters.cc b/content/child/background_sync/background_sync_type_converters.cc index de459d2..1be501d 100644 --- a/content/child/background_sync/background_sync_type_converters.cc +++ b/content/child/background_sync/background_sync_type_converters.cc
@@ -13,36 +13,35 @@ static_cast<int>(blink::blink_name), \ "mojo and blink enums must match") -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_PERIODICITY_PERIODIC, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPeriodicity::PERIODIC, WebSyncRegistration::PeriodicityPeriodic); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_PERIODICITY_ONE_SHOT, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPeriodicity::ONE_SHOT, WebSyncRegistration::PeriodicityOneShot); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_PERIODICITY_MAX, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPeriodicity::MAX, WebSyncRegistration::PeriodicityOneShot); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_PERIODICITY_MAX, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPeriodicity::MAX, WebSyncRegistration::PeriodicityLast); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_NETWORK_STATE_ANY, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncNetworkState::ANY, WebSyncRegistration::NetworkStateAny); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_NETWORK_STATE_AVOID_CELLULAR, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncNetworkState::AVOID_CELLULAR, WebSyncRegistration::NetworkStateAvoidCellular); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_NETWORK_STATE_ONLINE, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncNetworkState::ONLINE, WebSyncRegistration::NetworkStateOnline); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_NETWORK_STATE_MAX, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncNetworkState::MAX, WebSyncRegistration::NetworkStateOnline); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_NETWORK_STATE_MAX, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncNetworkState::MAX, WebSyncRegistration::NetworkStateLast); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_POWER_STATE_AUTO, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPowerState::AUTO, WebSyncRegistration::PowerStateAuto); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_POWER_STATE_AVOID_DRAINING, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPowerState::AVOID_DRAINING, WebSyncRegistration::PowerStateAvoidDraining); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_POWER_STATE_MAX, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPowerState::MAX, WebSyncRegistration::PowerStateAvoidDraining); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_POWER_STATE_MAX, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPowerState::MAX, WebSyncRegistration::PowerStateLast); -COMPILE_ASSERT_MATCHING_ENUM( - BACKGROUND_SYNC_EVENT_LAST_CHANCE_IS_NOT_LAST_CHANCE, - WebServiceWorkerContextProxy::IsNotLastChance); -COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_EVENT_LAST_CHANCE_IS_LAST_CHANCE, +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncEventLastChance::IS_NOT_LAST_CHANCE, + WebServiceWorkerContextProxy::IsNotLastChance); +COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncEventLastChance::IS_LAST_CHANCE, WebServiceWorkerContextProxy::IsLastChance); // static
diff --git a/content/child/background_sync/background_sync_type_converters_unittest.cc b/content/child/background_sync/background_sync_type_converters_unittest.cc index 89b1925..e769bab8 100644 --- a/content/child/background_sync/background_sync_type_converters_unittest.cc +++ b/content/child/background_sync/background_sync_type_converters_unittest.cc
@@ -11,62 +11,62 @@ TEST(BackgroundSyncTypeConverterTest, TestBlinkToMojoPeriodicityConversions) { ASSERT_EQ(blink::WebSyncRegistration::PeriodicityPeriodic, - ConvertTo<blink::WebSyncRegistration::Periodicity>( - content::BACKGROUND_SYNC_PERIODICITY_PERIODIC)); + ConvertTo<blink::WebSyncRegistration::Periodicity>( + content::BackgroundSyncPeriodicity::PERIODIC)); ASSERT_EQ(blink::WebSyncRegistration::PeriodicityOneShot, - ConvertTo<blink::WebSyncRegistration::Periodicity>( - content::BACKGROUND_SYNC_PERIODICITY_ONE_SHOT)); + ConvertTo<blink::WebSyncRegistration::Periodicity>( + content::BackgroundSyncPeriodicity::ONE_SHOT)); } TEST(BackgroundSyncTypeConverterTest, TestMojoToBlinkPeriodicityConversions) { - ASSERT_EQ(content::BACKGROUND_SYNC_PERIODICITY_PERIODIC, - ConvertTo<content::BackgroundSyncPeriodicity>( - blink::WebSyncRegistration::PeriodicityPeriodic)); - ASSERT_EQ(content::BACKGROUND_SYNC_PERIODICITY_ONE_SHOT, - ConvertTo<content::BackgroundSyncPeriodicity>( - blink::WebSyncRegistration::PeriodicityOneShot)); + ASSERT_EQ(content::BackgroundSyncPeriodicity::PERIODIC, + ConvertTo<content::BackgroundSyncPeriodicity>( + blink::WebSyncRegistration::PeriodicityPeriodic)); + ASSERT_EQ(content::BackgroundSyncPeriodicity::ONE_SHOT, + ConvertTo<content::BackgroundSyncPeriodicity>( + blink::WebSyncRegistration::PeriodicityOneShot)); } TEST(BackgroundSyncTypeConverterTest, TestBlinkToMojoNetworkStateConversions) { ASSERT_EQ(blink::WebSyncRegistration::NetworkStateAny, - ConvertTo<blink::WebSyncRegistration::NetworkState>( - content::BACKGROUND_SYNC_NETWORK_STATE_ANY)); + ConvertTo<blink::WebSyncRegistration::NetworkState>( + content::BackgroundSyncNetworkState::ANY)); ASSERT_EQ(blink::WebSyncRegistration::NetworkStateAvoidCellular, - ConvertTo<blink::WebSyncRegistration::NetworkState>( - content::BACKGROUND_SYNC_NETWORK_STATE_AVOID_CELLULAR)); + ConvertTo<blink::WebSyncRegistration::NetworkState>( + content::BackgroundSyncNetworkState::AVOID_CELLULAR)); ASSERT_EQ(blink::WebSyncRegistration::NetworkStateOnline, - ConvertTo<blink::WebSyncRegistration::NetworkState>( - content::BACKGROUND_SYNC_NETWORK_STATE_ONLINE)); + ConvertTo<blink::WebSyncRegistration::NetworkState>( + content::BackgroundSyncNetworkState::ONLINE)); } TEST(BackgroundSyncTypeConverterTest, TestMojoToBlinkNetworkStateConversions) { - ASSERT_EQ(content::BACKGROUND_SYNC_NETWORK_STATE_ANY, - ConvertTo<content::BackgroundSyncNetworkState>( - blink::WebSyncRegistration::NetworkStateAny)); - ASSERT_EQ(content::BACKGROUND_SYNC_NETWORK_STATE_AVOID_CELLULAR, - ConvertTo<content::BackgroundSyncNetworkState>( - blink::WebSyncRegistration::NetworkStateAvoidCellular)); - ASSERT_EQ(content::BACKGROUND_SYNC_NETWORK_STATE_ONLINE, - ConvertTo<content::BackgroundSyncNetworkState>( - blink::WebSyncRegistration::NetworkStateOnline)); + ASSERT_EQ(content::BackgroundSyncNetworkState::ANY, + ConvertTo<content::BackgroundSyncNetworkState>( + blink::WebSyncRegistration::NetworkStateAny)); + ASSERT_EQ(content::BackgroundSyncNetworkState::AVOID_CELLULAR, + ConvertTo<content::BackgroundSyncNetworkState>( + blink::WebSyncRegistration::NetworkStateAvoidCellular)); + ASSERT_EQ(content::BackgroundSyncNetworkState::ONLINE, + ConvertTo<content::BackgroundSyncNetworkState>( + blink::WebSyncRegistration::NetworkStateOnline)); } TEST(BackgroundSyncTypeConverterTest, TestBlinkToMojoPowerStateConversions) { ASSERT_EQ(blink::WebSyncRegistration::PowerStateAuto, - ConvertTo<blink::WebSyncRegistration::PowerState>( - content::BACKGROUND_SYNC_POWER_STATE_AUTO)); + ConvertTo<blink::WebSyncRegistration::PowerState>( + content::BackgroundSyncPowerState::AUTO)); ASSERT_EQ(blink::WebSyncRegistration::PowerStateAvoidDraining, - ConvertTo<blink::WebSyncRegistration::PowerState>( - content::BACKGROUND_SYNC_POWER_STATE_AVOID_DRAINING)); + ConvertTo<blink::WebSyncRegistration::PowerState>( + content::BackgroundSyncPowerState::AVOID_DRAINING)); } TEST(BackgroundSyncTypeConverterTest, TestMojoToBlinkPowerStateConversions) { - ASSERT_EQ(content::BACKGROUND_SYNC_POWER_STATE_AUTO, - ConvertTo<content::BackgroundSyncPowerState>( - blink::WebSyncRegistration::PowerStateAuto)); - ASSERT_EQ(content::BACKGROUND_SYNC_POWER_STATE_AVOID_DRAINING, - ConvertTo<content::BackgroundSyncPowerState>( - blink::WebSyncRegistration::PowerStateAvoidDraining)); + ASSERT_EQ(content::BackgroundSyncPowerState::AUTO, + ConvertTo<content::BackgroundSyncPowerState>( + blink::WebSyncRegistration::PowerStateAuto)); + ASSERT_EQ(content::BackgroundSyncPowerState::AVOID_DRAINING, + ConvertTo<content::BackgroundSyncPowerState>( + blink::WebSyncRegistration::PowerStateAvoidDraining)); } TEST(BackgroundSyncTypeConverterTest, TestDefaultBlinkToMojoConversion) { @@ -75,11 +75,11 @@ ConvertTo<content::SyncRegistrationPtr>(in); ASSERT_EQ(blink::WebSyncRegistration::UNREGISTERED_SYNC_ID, out->handle_id); - ASSERT_EQ(content::BACKGROUND_SYNC_PERIODICITY_ONE_SHOT, out->periodicity); + ASSERT_EQ(content::BackgroundSyncPeriodicity::ONE_SHOT, out->periodicity); ASSERT_EQ("", out->tag); ASSERT_EQ(0UL, out->min_period_ms); - ASSERT_EQ(content::BACKGROUND_SYNC_NETWORK_STATE_ONLINE, out->network_state); - ASSERT_EQ(content::BACKGROUND_SYNC_POWER_STATE_AUTO, out->power_state); + ASSERT_EQ(content::BackgroundSyncNetworkState::ONLINE, out->network_state); + ASSERT_EQ(content::BackgroundSyncPowerState::AUTO, out->power_state); } TEST(BackgroundSyncTypeConverterTest, TestFullPeriodicBlinkToMojoConversion) { @@ -91,12 +91,12 @@ ConvertTo<content::SyncRegistrationPtr>(in); ASSERT_EQ(7, out->handle_id); - ASSERT_EQ(content::BACKGROUND_SYNC_PERIODICITY_PERIODIC, out->periodicity); + ASSERT_EQ(content::BackgroundSyncPeriodicity::PERIODIC, out->periodicity); ASSERT_EQ("BlinkToMojo", out->tag); ASSERT_EQ(12340000UL, out->min_period_ms); - ASSERT_EQ(content::BACKGROUND_SYNC_NETWORK_STATE_AVOID_CELLULAR, + ASSERT_EQ(content::BackgroundSyncNetworkState::AVOID_CELLULAR, out->network_state); - ASSERT_EQ(content::BACKGROUND_SYNC_POWER_STATE_AVOID_DRAINING, + ASSERT_EQ(content::BackgroundSyncPowerState::AVOID_DRAINING, out->power_state); } @@ -109,12 +109,12 @@ ConvertTo<content::SyncRegistrationPtr>(in); ASSERT_EQ(7, out->handle_id); - ASSERT_EQ(content::BACKGROUND_SYNC_PERIODICITY_ONE_SHOT, out->periodicity); + ASSERT_EQ(content::BackgroundSyncPeriodicity::ONE_SHOT, out->periodicity); ASSERT_EQ("BlinkToMojo", out->tag); ASSERT_EQ(12340000UL, out->min_period_ms); - ASSERT_EQ(content::BACKGROUND_SYNC_NETWORK_STATE_AVOID_CELLULAR, + ASSERT_EQ(content::BackgroundSyncNetworkState::AVOID_CELLULAR, out->network_state); - ASSERT_EQ(content::BACKGROUND_SYNC_POWER_STATE_AVOID_DRAINING, + ASSERT_EQ(content::BackgroundSyncPowerState::AVOID_DRAINING, out->power_state); } @@ -136,11 +136,11 @@ content::SyncRegistrationPtr in( content::SyncRegistration::New()); in->handle_id = 41; - in->periodicity = content::BACKGROUND_SYNC_PERIODICITY_PERIODIC; + in->periodicity = content::BackgroundSyncPeriodicity::PERIODIC; in->tag = mojo::String("MojoToBlink"); in->min_period_ms = 43210000; - in->network_state = content::BACKGROUND_SYNC_NETWORK_STATE_AVOID_CELLULAR; - in->power_state = content::BACKGROUND_SYNC_POWER_STATE_AVOID_DRAINING; + in->network_state = content::BackgroundSyncNetworkState::AVOID_CELLULAR; + in->power_state = content::BackgroundSyncPowerState::AVOID_DRAINING; scoped_ptr<blink::WebSyncRegistration> out = ConvertTo<scoped_ptr<blink::WebSyncRegistration>>(in); @@ -158,11 +158,11 @@ content::SyncRegistrationPtr in( content::SyncRegistration::New()); in->handle_id = 41; - in->periodicity = content::BACKGROUND_SYNC_PERIODICITY_ONE_SHOT; + in->periodicity = content::BackgroundSyncPeriodicity::ONE_SHOT; in->tag = mojo::String("MojoToBlink"); in->min_period_ms = 43210000; - in->network_state = content::BACKGROUND_SYNC_NETWORK_STATE_AVOID_CELLULAR; - in->power_state = content::BACKGROUND_SYNC_POWER_STATE_AVOID_DRAINING; + in->network_state = content::BackgroundSyncNetworkState::AVOID_CELLULAR; + in->power_state = content::BackgroundSyncPowerState::AVOID_DRAINING; scoped_ptr<blink::WebSyncRegistration> out = ConvertTo<scoped_ptr<blink::WebSyncRegistration>>(in);
diff --git a/content/child/navigator_connect/service_port_dispatcher_impl.cc b/content/child/navigator_connect/service_port_dispatcher_impl.cc index bc002a9..8a63fd2 100644 --- a/content/child/navigator_connect/service_port_dispatcher_impl.cc +++ b/content/child/navigator_connect/service_port_dispatcher_impl.cc
@@ -25,13 +25,13 @@ ~WebConnectCallbacksImpl() override {} void onSuccess(const blink::WebServicePort& port) override { - callback_.Run(SERVICE_PORT_CONNECT_RESULT_ACCEPT, + callback_.Run(ServicePortConnectResult::ACCEPT, mojo::String::From<base::string16>(port.name), mojo::String::From<base::string16>(port.data)); } void onError() override { - callback_.Run(SERVICE_PORT_CONNECT_RESULT_REJECT, mojo::String(""), + callback_.Run(ServicePortConnectResult::REJECT, mojo::String(""), mojo::String("")); } @@ -67,7 +67,7 @@ int32_t port_id, const ConnectCallback& callback) { if (!proxy_) { - callback.Run(SERVICE_PORT_CONNECT_RESULT_REJECT, mojo::String(""), + callback.Run(ServicePortConnectResult::REJECT, mojo::String(""), mojo::String("")); return; }
diff --git a/content/child/navigator_connect/service_port_provider.cc b/content/child/navigator_connect/service_port_provider.cc index 79bf8a5..5082665 100644 --- a/content/child/navigator_connect/service_port_provider.cc +++ b/content/child/navigator_connect/service_port_provider.cc
@@ -109,7 +109,7 @@ scoped_ptr<blink::WebServicePortConnectCallbacks> callbacks, ServicePortConnectResult result, int32_t port_id) { - if (result == SERVICE_PORT_CONNECT_RESULT_ACCEPT) { + if (result == ServicePortConnectResult::ACCEPT) { callbacks->onSuccess(port_id); } else { callbacks->onError();
diff --git a/content/child/permissions/permission_dispatcher.cc b/content/child/permissions/permission_dispatcher.cc index 2efb9a6..62ce59e 100644 --- a/content/child/permissions/permission_dispatcher.cc +++ b/content/child/permissions/permission_dispatcher.cc
@@ -23,46 +23,46 @@ PermissionName GetPermissionName(blink::WebPermissionType type) { switch (type) { case blink::WebPermissionTypeGeolocation: - return PERMISSION_NAME_GEOLOCATION; + return PermissionName::GEOLOCATION; case blink::WebPermissionTypeNotifications: - return PERMISSION_NAME_NOTIFICATIONS; + return PermissionName::NOTIFICATIONS; case blink::WebPermissionTypePushNotifications: - return PERMISSION_NAME_PUSH_NOTIFICATIONS; + return PermissionName::PUSH_NOTIFICATIONS; case blink::WebPermissionTypeMidiSysEx: - return PERMISSION_NAME_MIDI_SYSEX; + return PermissionName::MIDI_SYSEX; case blink::WebPermissionTypeDurableStorage: - return PERMISSION_NAME_DURABLE_STORAGE; + return PermissionName::DURABLE_STORAGE; case blink::WebPermissionTypeMidi: - return PERMISSION_NAME_MIDI; + return PermissionName::MIDI; default: // The default statement is only there to prevent compilation failures if // WebPermissionType enum gets extended. NOTREACHED(); - return PERMISSION_NAME_GEOLOCATION; + return PermissionName::GEOLOCATION; } } PermissionStatus GetPermissionStatus(blink::WebPermissionStatus status) { switch (status) { case blink::WebPermissionStatusGranted: - return PERMISSION_STATUS_GRANTED; + return PermissionStatus::GRANTED; case blink::WebPermissionStatusDenied: - return PERMISSION_STATUS_DENIED; + return PermissionStatus::DENIED; case blink::WebPermissionStatusPrompt: - return PERMISSION_STATUS_ASK; + return PermissionStatus::ASK; } NOTREACHED(); - return PERMISSION_STATUS_DENIED; + return PermissionStatus::DENIED; } blink::WebPermissionStatus GetWebPermissionStatus(PermissionStatus status) { switch (status) { - case PERMISSION_STATUS_GRANTED: + case PermissionStatus::GRANTED: return blink::WebPermissionStatusGranted; - case PERMISSION_STATUS_DENIED: + case PermissionStatus::DENIED: return blink::WebPermissionStatusDenied; - case PERMISSION_STATUS_ASK: + case PermissionStatus::ASK: return blink::WebPermissionStatusPrompt; } @@ -130,16 +130,14 @@ RegisterObserver(observer); - GetNextPermissionChange(type, - origin.string().utf8(), - observer, + GetNextPermissionChange(type, origin.string().utf8(), observer, // We initialize with an arbitrary value because the // mojo service wants a value. Worst case, the // observer will get notified about a non-change which // should be a no-op. After the first notification, // GetNextPermissionChange will be called with the // latest known value. - PERMISSION_STATUS_ASK); + PermissionStatus::ASK); } void PermissionDispatcher::stopListening(WebPermissionObserver* observer) { @@ -184,17 +182,14 @@ int worker_thread_id, const base::Callback<void(blink::WebPermissionStatus)>& callback) { GetPermissionServicePtr()->GetNextPermissionChange( - GetPermissionName(type), - origin, + GetPermissionName(type), origin, // We initialize with an arbitrary value because the mojo service wants a // value. Worst case, the observer will get notified about a non-change // which should be a no-op. After the first notification, // GetNextPermissionChange will be called with the latest known value. - PERMISSION_STATUS_ASK, + PermissionStatus::ASK, base::Bind(&PermissionDispatcher::OnPermissionChangedForWorker, - base::Unretained(this), - worker_thread_id, - callback)); + base::Unretained(this), worker_thread_id, callback)); } void PermissionDispatcher::GetNextPermissionChangeForWorker(
diff --git a/content/common/gpu/ca_layer_tree_mac.h b/content/common/gpu/ca_layer_tree_mac.h new file mode 100644 index 0000000..b6c7271 --- /dev/null +++ b/content/common/gpu/ca_layer_tree_mac.h
@@ -0,0 +1,188 @@ +// 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 CONTENT_COMMON_GPU_CA_LAYER_TREE_MAC_H_ +#define CONTENT_COMMON_GPU_CA_LAYER_TREE_MAC_H_ + +#include <IOSurface/IOSurface.h> +#include <QuartzCore/QuartzCore.h> +#include <deque> +#include <vector> + +#include "base/mac/scoped_cftyperef.h" +#include "base/mac/scoped_nsobject.h" +#include "base/memory/scoped_ptr.h" +#include "ui/gfx/geometry/rect.h" +#include "ui/gfx/geometry/rect_f.h" +#include "ui/gfx/transform.h" + +namespace content { + +// The CALayerTree will construct a hierarchy of CALayers from a linear list, +// using the algorithm and structure referenced described in +// https://docs.google.com/document/d/1DtSN9zzvCF44_FQPM7ie01UxGHagQ66zfF5L9HnigQY/edit?usp=sharing +class CALayerTree { + public: + CALayerTree(); + + // This will remove all CALayers from this tree from their superlayer. + ~CALayerTree(); + + // Append the description of a new CALayer to the tree. This will not + // create any new CALayers until CommitScheduledCALayers is called. This + // cannot be called anymore after CommitScheduledCALayers has been called. + bool ScheduleCALayer(bool is_clipped, + const gfx::Rect& clip_rect, + unsigned sorting_context_id, + const gfx::Transform& transform, + base::ScopedCFTypeRef<IOSurfaceRef> io_surface, + const gfx::RectF& contents_rect, + const gfx::Rect& rect, + unsigned background_color, + unsigned edge_aa_mask, + float opacity); + + // Create a CALayer tree for the scheduled layers, and set |superlayer| to + // have only this tree as its sublayers. If |old_tree| is non-null, then try + // to re-use the CALayers of |old_tree| as much as possible. |old_tree| will + // be destroyed at the end of the function, and any CALayers in it which were + // not re-used by |this| will be removed from the CALayer hierarchy. + void CommitScheduledCALayers(CALayer* superlayer, + scoped_ptr<CALayerTree> old_tree, + float scale_factor); + + private: + struct RootLayer; + struct ClipAndSortingLayer; + struct TransformLayer; + struct ContentLayer; + + struct RootLayer { + RootLayer(); + + // This will remove |ca_layer| from its superlayer, if |ca_layer| is + // non-nil. + ~RootLayer(); + + // Append a new content layer, without modifying the actual CALayer + // structure. + bool AddContentLayer(bool is_clipped, + const gfx::Rect& clip_rect, + unsigned sorting_context_id, + const gfx::Transform& transform, + base::ScopedCFTypeRef<IOSurfaceRef> io_surface, + const gfx::RectF& contents_rect, + const gfx::Rect& rect, + unsigned background_color, + unsigned edge_aa_mask, + float opacity); + + // Allocate CALayers for this layer and its children, and set their + // properties appropriately. Re-use the CALayers from |old_layer| if + // possible. If re-using a CALayer from |old_layer|, reset its |ca_layer| + // to nil, so that its destructor will not remove an active CALayer. + void CommitToCA(CALayer* superlayer, + RootLayer* old_layer, + float scale_factor); + + std::vector<ClipAndSortingLayer> clip_and_sorting_layers; + base::scoped_nsobject<CALayer> ca_layer; + + private: + DISALLOW_COPY_AND_ASSIGN(RootLayer); + }; + struct ClipAndSortingLayer { + ClipAndSortingLayer(bool is_clipped, + gfx::Rect clip_rect, + unsigned sorting_context_id, + bool is_singleton_sorting_context); + ClipAndSortingLayer(ClipAndSortingLayer&& layer); + + // See the behavior of RootLayer for the effects of these functions on the + // |ca_layer| member and |old_layer| argument. + ~ClipAndSortingLayer(); + void AddContentLayer(const gfx::Transform& transform, + base::ScopedCFTypeRef<IOSurfaceRef> io_surface, + const gfx::RectF& contents_rect, + const gfx::Rect& rect, + unsigned background_color, + unsigned edge_aa_mask, + float opacity); + void CommitToCA(CALayer* superlayer, + ClipAndSortingLayer* old_layer, + float scale_factor); + + std::vector<TransformLayer> transform_layers; + bool is_clipped = false; + gfx::Rect clip_rect; + unsigned sorting_context_id = 0; + bool is_singleton_sorting_context = false; + base::scoped_nsobject<CALayer> ca_layer; + + private: + DISALLOW_COPY_AND_ASSIGN(ClipAndSortingLayer); + }; + struct TransformLayer { + TransformLayer(const gfx::Transform& transform); + TransformLayer(TransformLayer&& layer); + + // See the behavior of RootLayer for the effects of these functions on the + // |ca_layer| member and |old_layer| argument. + ~TransformLayer(); + void AddContentLayer(base::ScopedCFTypeRef<IOSurfaceRef> io_surface, + const gfx::RectF& contents_rect, + const gfx::Rect& rect, + unsigned background_color, + unsigned edge_aa_mask, + float opacity); + void CommitToCA(CALayer* superlayer, + TransformLayer* old_layer, + float scale_factor); + + gfx::Transform transform; + std::vector<ContentLayer> content_layers; + base::scoped_nsobject<CALayer> ca_layer; + + private: + DISALLOW_COPY_AND_ASSIGN(TransformLayer); + }; + struct ContentLayer { + ContentLayer(base::ScopedCFTypeRef<IOSurfaceRef> io_surface, + const gfx::RectF& contents_rect, + const gfx::Rect& rect, + unsigned background_color, + unsigned edge_aa_mask, + float opacity); + ContentLayer(ContentLayer&& layer); + + // See the behavior of RootLayer for the effects of these functions on the + // |ca_layer| member and |old_layer| argument. + ~ContentLayer(); + void CommitToCA(CALayer* parent, + ContentLayer* old_layer, + float scale_factor); + + const base::ScopedCFTypeRef<IOSurfaceRef> io_surface; + gfx::RectF contents_rect; + gfx::Rect rect; + unsigned background_color = 0; + unsigned edge_aa_mask = 0; + float opacity = 1; + base::scoped_nsobject<CALayer> ca_layer; + + private: + DISALLOW_COPY_AND_ASSIGN(ContentLayer); + }; + + RootLayer root_layer_; + float scale_factor_ = 1; + bool has_committed_ = false; + + private: + DISALLOW_COPY_AND_ASSIGN(CALayerTree); +}; + +} // namespace content + +#endif // CONTENT_COMMON_GPU_CA_LAYER_TREE_MAC_H_
diff --git a/content/common/gpu/ca_layer_tree_mac.mm b/content/common/gpu/ca_layer_tree_mac.mm new file mode 100644 index 0000000..3a6d34b --- /dev/null +++ b/content/common/gpu/ca_layer_tree_mac.mm
@@ -0,0 +1,416 @@ +// 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 "content/common/gpu/ca_layer_tree_mac.h" + +#include "base/command_line.h" +#include "base/mac/sdk_forward_declarations.h" +#include "third_party/skia/include/core/SkColor.h" +#include "ui/base/cocoa/animation_utils.h" +#include "ui/base/ui_base_switches.h" +#include "ui/gfx/geometry/dip_util.h" + +namespace content { + +CALayerTree::CALayerTree() {} +CALayerTree::~CALayerTree() {} + +bool CALayerTree::ScheduleCALayer( + bool is_clipped, + const gfx::Rect& clip_rect, + unsigned sorting_context_id, + const gfx::Transform& transform, + base::ScopedCFTypeRef<IOSurfaceRef> io_surface, + const gfx::RectF& contents_rect, + const gfx::Rect& rect, + unsigned background_color, + unsigned edge_aa_mask, + float opacity) { + if (has_committed_) { + DLOG(ERROR) << "ScheduleCALayer called after CommitScheduledCALayers."; + return false; + } + return root_layer_.AddContentLayer(is_clipped, clip_rect, sorting_context_id, + transform, io_surface, contents_rect, rect, + background_color, edge_aa_mask, opacity); +} + +void CALayerTree::CommitScheduledCALayers(CALayer* superlayer, + scoped_ptr<CALayerTree> old_tree, + float scale_factor) { + RootLayer* old_root_layer = nullptr; + if (old_tree) { + DCHECK(old_tree->has_committed_); + if (old_tree->scale_factor_ == scale_factor) + old_root_layer = &old_tree->root_layer_; + } + + root_layer_.CommitToCA(superlayer, old_root_layer, scale_factor); + // If there are any extra CALayers in |old_tree| that were not stolen by this + // tree, they will be removed from the CALayer tree in this deallocation. + old_tree.reset(); + has_committed_ = true; + scale_factor_ = scale_factor; +} + +CALayerTree::RootLayer::RootLayer() {} + +// Note that for all destructors, the the CALayer will have been reset to nil if +// another layer has taken it. +CALayerTree::RootLayer::~RootLayer() { + [ca_layer removeFromSuperlayer]; +} + +CALayerTree::ClipAndSortingLayer::ClipAndSortingLayer( + bool is_clipped, + gfx::Rect clip_rect, + unsigned sorting_context_id, + bool is_singleton_sorting_context) + : is_clipped(is_clipped), + clip_rect(clip_rect), + sorting_context_id(sorting_context_id), + is_singleton_sorting_context(is_singleton_sorting_context) {} + +CALayerTree::ClipAndSortingLayer::ClipAndSortingLayer( + ClipAndSortingLayer&& layer) + : transform_layers(std::move(layer.transform_layers)), + is_clipped(layer.is_clipped), + clip_rect(layer.clip_rect), + sorting_context_id(layer.sorting_context_id), + is_singleton_sorting_context( + layer.is_singleton_sorting_context), + ca_layer(layer.ca_layer) { + // Ensure that the ca_layer be reset, so that when the destructor is called, + // the layer hierarchy is unaffected. + // TODO(ccameron): Add a move constructor for scoped_nsobject to do this + // automatically. + layer.ca_layer.reset(); +} + +CALayerTree::ClipAndSortingLayer::~ClipAndSortingLayer() { + [ca_layer removeFromSuperlayer]; +} + +CALayerTree::TransformLayer::TransformLayer(const gfx::Transform& transform) + : transform(transform) {} + +CALayerTree::TransformLayer::TransformLayer(TransformLayer&& layer) + : transform(layer.transform), + content_layers(std::move(layer.content_layers)), + ca_layer(layer.ca_layer) { + layer.ca_layer.reset(); +} + +CALayerTree::TransformLayer::~TransformLayer() { + [ca_layer removeFromSuperlayer]; +} + +CALayerTree::ContentLayer::ContentLayer( + base::ScopedCFTypeRef<IOSurfaceRef> io_surface, + const gfx::RectF& contents_rect, + const gfx::Rect& rect, + unsigned background_color, + unsigned edge_aa_mask, + float opacity) + : io_surface(io_surface), + contents_rect(contents_rect), + rect(rect), + background_color(background_color), + edge_aa_mask(edge_aa_mask), + opacity(opacity) { + // Ensure that the IOSurface be in use as soon as it is added to a + // ContentLayer, so that, by the time that the call to SwapBuffers completes, + // all IOSurfaces that can be used as CALayer contents in the future will be + // marked as InUse. + if (io_surface) + IOSurfaceIncrementUseCount(io_surface); +} + +CALayerTree::ContentLayer::ContentLayer(ContentLayer&& layer) + : io_surface(layer.io_surface), + contents_rect(layer.contents_rect), + rect(layer.rect), + background_color(layer.background_color), + edge_aa_mask(layer.edge_aa_mask), + opacity(layer.opacity), + ca_layer(layer.ca_layer) { + DCHECK(!layer.ca_layer); + layer.ca_layer.reset(); + // See remarks in the non-move constructor. + if (io_surface) + IOSurfaceIncrementUseCount(io_surface); +} + +CALayerTree::ContentLayer::~ContentLayer() { + [ca_layer removeFromSuperlayer]; + // By the time the destructor is called, the IOSurface will have been passed + // to the WindowServer, and will remain InUse by the WindowServer as long as + // is needed to avoid recycling bugs. + if (io_surface) + IOSurfaceDecrementUseCount(io_surface); +} + +bool CALayerTree::RootLayer::AddContentLayer( + bool is_clipped, + const gfx::Rect& clip_rect, + unsigned sorting_context_id, + const gfx::Transform& transform, + base::ScopedCFTypeRef<IOSurfaceRef> io_surface, + const gfx::RectF& contents_rect, + const gfx::Rect& rect, + unsigned background_color, + unsigned edge_aa_mask, + float opacity) { + bool needs_new_clip_and_sorting_layer = true; + + // In sorting_context_id 0, all quads are listed in back-to-front order. + // This is accomplished by having the CALayers be siblings of each other. + // If a quad has a 3D transform, it is necessary to put it in its own sorting + // context, so that it will not intersect with quads before and after it. + bool is_singleton_sorting_context = + !sorting_context_id && !transform.IsFlat(); + + if (!clip_and_sorting_layers.empty()) { + ClipAndSortingLayer& current_layer = clip_and_sorting_layers.back(); + // It is in error to change the clipping settings within a non-zero sorting + // context. The result will be incorrect layering and intersection. + if (sorting_context_id && + current_layer.sorting_context_id == sorting_context_id && + (current_layer.is_clipped != is_clipped || + current_layer.clip_rect != clip_rect)) { + DLOG(ERROR) << "CALayer changed clip inside non-zero sorting context."; + return false; + } + if (!is_singleton_sorting_context && + !current_layer.is_singleton_sorting_context && + current_layer.is_clipped == is_clipped && + current_layer.clip_rect == clip_rect && + current_layer.sorting_context_id == sorting_context_id) { + needs_new_clip_and_sorting_layer = false; + } + } + if (needs_new_clip_and_sorting_layer) { + clip_and_sorting_layers.push_back( + ClipAndSortingLayer(is_clipped, clip_rect, sorting_context_id, + is_singleton_sorting_context)); + } + clip_and_sorting_layers.back().AddContentLayer( + transform, io_surface, contents_rect, rect, background_color, + edge_aa_mask, opacity); + return true; +} + +void CALayerTree::ClipAndSortingLayer::AddContentLayer( + const gfx::Transform& transform, + base::ScopedCFTypeRef<IOSurfaceRef> io_surface, + const gfx::RectF& contents_rect, + const gfx::Rect& rect, + unsigned background_color, + unsigned edge_aa_mask, + float opacity) { + bool needs_new_transform_layer = true; + if (!transform_layers.empty()) { + const TransformLayer& current_layer = transform_layers.back(); + if (current_layer.transform == transform) + needs_new_transform_layer = false; + } + if (needs_new_transform_layer) + transform_layers.push_back(TransformLayer(transform)); + transform_layers.back().AddContentLayer( + io_surface, contents_rect, rect, background_color, edge_aa_mask, opacity); +} + +void CALayerTree::TransformLayer::AddContentLayer( + base::ScopedCFTypeRef<IOSurfaceRef> io_surface, + const gfx::RectF& contents_rect, + const gfx::Rect& rect, + unsigned background_color, + unsigned edge_aa_mask, + float opacity) { + content_layers.push_back(ContentLayer(io_surface, contents_rect, rect, + background_color, edge_aa_mask, + opacity)); +} + +void CALayerTree::RootLayer::CommitToCA(CALayer* superlayer, + RootLayer* old_layer, + float scale_factor) { + if (old_layer) { + DCHECK(old_layer->ca_layer); + std::swap(ca_layer, old_layer->ca_layer); + } else { + ca_layer.reset([[CALayer alloc] init]); + [ca_layer setAnchorPoint:CGPointZero]; + [superlayer setSublayers:nil]; + [superlayer addSublayer:ca_layer]; + [superlayer setBorderWidth:0]; + } + DCHECK_EQ([ca_layer superlayer], superlayer); + + for (size_t i = 0; i < clip_and_sorting_layers.size(); ++i) { + ClipAndSortingLayer* old_clip_and_sorting_layer = nullptr; + if (old_layer && i < old_layer->clip_and_sorting_layers.size()) { + old_clip_and_sorting_layer = &old_layer->clip_and_sorting_layers[i]; + } + clip_and_sorting_layers[i].CommitToCA( + ca_layer.get(), old_clip_and_sorting_layer, scale_factor); + } +} + +void CALayerTree::ClipAndSortingLayer::CommitToCA( + CALayer* superlayer, + ClipAndSortingLayer* old_layer, + float scale_factor) { + bool update_is_clipped = true; + bool update_clip_rect = true; + if (old_layer) { + DCHECK(old_layer->ca_layer); + std::swap(ca_layer, old_layer->ca_layer); + update_is_clipped = old_layer->is_clipped != is_clipped; + update_clip_rect = old_layer->clip_rect != clip_rect; + } else { + ca_layer.reset([[CALayer alloc] init]); + [ca_layer setAnchorPoint:CGPointZero]; + [superlayer addSublayer:ca_layer]; + } + DCHECK_EQ([ca_layer superlayer], superlayer); + + if (update_is_clipped) + [ca_layer setMasksToBounds:is_clipped]; + + if (update_clip_rect) { + if (is_clipped) { + gfx::RectF dip_clip_rect = gfx::RectF(clip_rect); + dip_clip_rect.Scale(1 / scale_factor); + [ca_layer setPosition:CGPointMake(dip_clip_rect.x(), dip_clip_rect.y())]; + [ca_layer setBounds:CGRectMake(0, 0, dip_clip_rect.width(), + dip_clip_rect.height())]; + [ca_layer + setSublayerTransform:CATransform3DMakeTranslation( + -dip_clip_rect.x(), -dip_clip_rect.y(), 0)]; + } else { + [ca_layer setPosition:CGPointZero]; + [ca_layer setBounds:CGRectZero]; + [ca_layer setSublayerTransform:CATransform3DIdentity]; + } + } + + for (size_t i = 0; i < transform_layers.size(); ++i) { + TransformLayer* old_transform_layer = nullptr; + if (old_layer && i < old_layer->transform_layers.size()) + old_transform_layer = &old_layer->transform_layers[i]; + transform_layers[i].CommitToCA(ca_layer.get(), old_transform_layer, + scale_factor); + } +} + +void CALayerTree::TransformLayer::CommitToCA(CALayer* superlayer, + TransformLayer* old_layer, + float scale_factor) { + bool update_transform = true; + if (old_layer) { + DCHECK(old_layer->ca_layer); + std::swap(ca_layer, old_layer->ca_layer); + update_transform = old_layer->transform != transform; + } else { + ca_layer.reset([[CATransformLayer alloc] init]); + [superlayer addSublayer:ca_layer]; + } + DCHECK_EQ([ca_layer superlayer], superlayer); + + if (update_transform) { + gfx::Transform pre_scale; + gfx::Transform post_scale; + pre_scale.Scale(1 / scale_factor, 1 / scale_factor); + post_scale.Scale(scale_factor, scale_factor); + gfx::Transform conjugated_transform = pre_scale * transform * post_scale; + + CATransform3D ca_transform; + conjugated_transform.matrix().asColMajord(&ca_transform.m11); + [ca_layer setTransform:ca_transform]; + } + + for (size_t i = 0; i < content_layers.size(); ++i) { + ContentLayer* old_content_layer = nullptr; + if (old_layer && i < old_layer->content_layers.size()) + old_content_layer = &old_layer->content_layers[i]; + content_layers[i].CommitToCA(ca_layer.get(), old_content_layer, + scale_factor); + } +} + +void CALayerTree::ContentLayer::CommitToCA(CALayer* superlayer, + ContentLayer* old_layer, + float scale_factor) { + bool update_contents = true; + bool update_contents_rect = true; + bool update_rect = true; + bool update_background_color = true; + bool update_edge_aa_mask = true; + bool update_opacity = true; + if (old_layer) { + DCHECK(old_layer->ca_layer); + std::swap(ca_layer, old_layer->ca_layer); + update_contents = old_layer->io_surface != io_surface; + update_contents_rect = old_layer->contents_rect != contents_rect; + update_rect = old_layer->rect != rect; + update_background_color = old_layer->background_color != background_color; + update_edge_aa_mask = old_layer->edge_aa_mask != edge_aa_mask; + update_opacity = old_layer->opacity != opacity; + } else { + ca_layer.reset([[CALayer alloc] init]); + [ca_layer setAnchorPoint:CGPointZero]; + [superlayer addSublayer:ca_layer]; + } + DCHECK_EQ([ca_layer superlayer], superlayer); + bool update_anything = update_contents || update_contents_rect || + update_rect || update_background_color || + update_edge_aa_mask || update_opacity; + + if (update_contents) { + [ca_layer setContents:static_cast<id>(io_surface.get())]; + if ([ca_layer respondsToSelector:(@selector(setContentsScale:))]) + [ca_layer setContentsScale:scale_factor]; + } + if (update_contents_rect) + [ca_layer setContentsRect:contents_rect.ToCGRect()]; + if (update_rect) { + gfx::RectF dip_rect = gfx::RectF(rect); + dip_rect.Scale(1 / scale_factor); + [ca_layer setPosition:CGPointMake(dip_rect.x(), dip_rect.y())]; + [ca_layer setBounds:CGRectMake(0, 0, dip_rect.width(), dip_rect.height())]; + } + if (update_background_color) { + CGFloat rgba_color_components[4] = { + SkColorGetR(background_color) / 255., + SkColorGetG(background_color) / 255., + SkColorGetB(background_color) / 255., + SkColorGetA(background_color) / 255., + }; + base::ScopedCFTypeRef<CGColorRef> srgb_background_color(CGColorCreate( + CGColorSpaceCreateWithName(kCGColorSpaceSRGB), rgba_color_components)); + [ca_layer setBackgroundColor:srgb_background_color]; + } + if (update_edge_aa_mask) + [ca_layer setEdgeAntialiasingMask:edge_aa_mask]; + if (update_opacity) + [ca_layer setOpacity:opacity]; + + static bool show_borders = base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kShowMacOverlayBorders); + if (show_borders) { + base::ScopedCFTypeRef<CGColorRef> color; + if (update_anything) { + // Pink represents a CALayer that changed this frame. + color.reset(CGColorCreateGenericRGB(1, 0, 1, 1)); + } else { + // Grey represents a CALayer that has not changed. + color.reset(CGColorCreateGenericRGB(0, 0, 0, 0.1)); + } + [ca_layer setBorderWidth:1]; + [ca_layer setBorderColor:color]; + } +} + +} // namespace content
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.cc b/content/common/gpu/client/command_buffer_proxy_impl.cc index 0c95666..1b5d14b 100644 --- a/content/common/gpu/client/command_buffer_proxy_impl.cc +++ b/content/common/gpu/client/command_buffer_proxy_impl.cc
@@ -530,7 +530,8 @@ } void CommandBufferProxyImpl::EnsureWorkVisible() { - channel_->ValidateFlushIDReachedServer(stream_id_, true); + if (channel_) + channel_->ValidateFlushIDReachedServer(stream_id_, true); } gpu::CommandBufferNamespace CommandBufferProxyImpl::GetNamespaceID() const {
diff --git a/content/common/gpu/image_transport_surface_overlay_mac.h b/content/common/gpu/image_transport_surface_overlay_mac.h index 5f6d8caf..3e3dca5e 100644 --- a/content/common/gpu/image_transport_surface_overlay_mac.h +++ b/content/common/gpu/image_transport_surface_overlay_mac.h
@@ -21,6 +21,8 @@ namespace content { +class CALayerTree; + class ImageTransportSurfaceOverlayMac : public gfx::GLSurface, public ImageTransportSurface, public ui::GpuSwitchingObserver { @@ -53,10 +55,11 @@ float opacity, unsigned background_color, unsigned edge_aa_mask, - const gfx::RectF& bounds_rect, + const gfx::RectF& rect, bool is_clipped, const gfx::RectF& clip_rect, - const gfx::Transform& transform) override; + const gfx::Transform& transform, + int sorting_context_id) override; bool IsSurfaceless() const override; // ImageTransportSurface implementation @@ -78,9 +81,9 @@ void UpdateRootAndPartialDamagePlanes( const linked_ptr<OverlayPlane>& new_root_plane, const gfx::RectF& pixel_damage_rect); - void UpdateOverlayPlanes( - const std::vector<linked_ptr<OverlayPlane>>& new_overlay_planes); - void UpdateCALayerTree(); + void UpdateRootAndPartialDamageCALayers(float scale_factor); + void UpdateCALayerTree(scoped_ptr<CALayerTree> ca_layer_tree, + float scale_factor); // Returns true if the front of |pending_swaps_| has completed, or has timed // out by |now|. @@ -123,7 +126,7 @@ // Planes that have been scheduled, but have not had a subsequent SwapBuffers // call made yet. linked_ptr<OverlayPlane> pending_root_plane_; - std::vector<linked_ptr<OverlayPlane>> pending_overlay_planes_; + scoped_ptr<CALayerTree> pending_ca_layer_tree_; // A queue of all frames that have been created by SwapBuffersInternal but // have not yet been displayed. This queue is checked at the beginning of @@ -133,7 +136,7 @@ // The planes that are currently being displayed on the screen. linked_ptr<OverlayPlane> current_root_plane_; std::list<linked_ptr<OverlayPlane>> current_partial_damage_planes_; - std::list<linked_ptr<OverlayPlane>> current_overlay_planes_; + scoped_ptr<CALayerTree> current_ca_layer_tree_; // The time of the last swap was issued. If this is more than two vsyncs, then // use the simpler non-smooth animation path.
diff --git a/content/common/gpu/image_transport_surface_overlay_mac.mm b/content/common/gpu/image_transport_surface_overlay_mac.mm index fff98a3..311e60fd 100644 --- a/content/common/gpu/image_transport_surface_overlay_mac.mm +++ b/content/common/gpu/image_transport_surface_overlay_mac.mm
@@ -22,12 +22,14 @@ #include "base/command_line.h" #include "base/mac/scoped_cftyperef.h" +#include "base/mac/sdk_forward_declarations.h" +#include "content/common/gpu/ca_layer_tree_mac.h" #include "content/common/gpu/gpu_messages.h" #include "ui/accelerated_widget_mac/io_surface_context.h" #include "ui/base/cocoa/animation_utils.h" #include "ui/base/cocoa/remote_layer_api.h" #include "ui/base/ui_base_switches.h" -#include "ui/gfx/geometry/dip_util.h" +#include "ui/gfx/geometry/rect_conversions.h" #include "ui/gfx/transform.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_fence.h" @@ -96,89 +98,53 @@ public: static linked_ptr<OverlayPlane> CreateWithFrameRect( int z_order, - int io_surface_id, base::ScopedCFTypeRef<IOSurfaceRef> io_surface, const gfx::RectF& pixel_frame_rect, const gfx::RectF& contents_rect) { gfx::Transform transform; transform.Translate(pixel_frame_rect.x(), pixel_frame_rect.y()); return linked_ptr<OverlayPlane>( - new OverlayPlane(z_order, io_surface_id, io_surface, contents_rect, 1.f, - base::ScopedCFTypeRef<CGColorRef>(), 0, - pixel_frame_rect.size(), transform, pixel_frame_rect)); + new OverlayPlane(z_order, io_surface, contents_rect, pixel_frame_rect)); } - static linked_ptr<OverlayPlane> CreateWithTransform( - int z_order, - int io_surface_id, - base::ScopedCFTypeRef<IOSurfaceRef> io_surface, - const gfx::RectF& contents_rect, - float opacity, - base::ScopedCFTypeRef<CGColorRef> background_color, - unsigned int edge_aa_mask, - const gfx::SizeF& bounds_size, - const gfx::Transform& transform) { - gfx::RectF pixel_frame_rect = gfx::RectF(bounds_size); - transform.TransformRect(&pixel_frame_rect); - return linked_ptr<OverlayPlane>(new OverlayPlane( - z_order, io_surface_id, io_surface, contents_rect, opacity, - background_color, edge_aa_mask, bounds_size, transform, - pixel_frame_rect)); + ~OverlayPlane() { + [ca_layer setContents:nil]; + [ca_layer removeFromSuperlayer]; + ca_layer.reset(); } - ~OverlayPlane() { DCHECK(!ca_layer); } - const int z_order; - base::scoped_nsobject<CALayer> ca_layer; - - // The IOSurface to set the CALayer's contents to. - const int io_surface_id; const base::ScopedCFTypeRef<IOSurfaceRef> io_surface; const gfx::RectF contents_rect; - float opacity; - const base::ScopedCFTypeRef<CGColorRef> background_color; - unsigned int edge_aa_mask; - const gfx::SizeF bounds_size; - const gfx::Transform transform; - const gfx::RectF pixel_frame_rect; - bool layer_needs_update; - - static bool Compare(const linked_ptr<OverlayPlane>& a, - const linked_ptr<OverlayPlane>& b) { - return (a->z_order < b->z_order); - } + base::scoped_nsobject<CALayer> ca_layer; void TakeCALayerFrom(OverlayPlane* other_plane) { ca_layer.swap(other_plane->ca_layer); } - void UpdateProperties() { + void UpdateProperties(float scale_factor) { if (layer_needs_update) { [ca_layer setOpaque:YES]; id new_contents = static_cast<id>(io_surface.get()); - if ([ca_layer contents] == new_contents && z_order == 0) { + if ([ca_layer contents] == new_contents && z_order == 0) [ca_layer setContentsChanged]; - } else { + else [ca_layer setContents:new_contents]; - } [ca_layer setContentsRect:contents_rect.ToCGRect()]; - [ca_layer setOpacity:opacity]; - if (background_color) { - [ca_layer setBackgroundColor:background_color]; - } else { - [ca_layer setBackgroundColor:CGColorGetConstantColor(kCGColorClear)]; - } - [ca_layer setEdgeAntialiasingMask:edge_aa_mask]; - [ca_layer setAnchorPoint:CGPointZero]; - [ca_layer setBounds:gfx::RectF(bounds_size).ToCGRect()]; - CATransform3D ca_transform; - transform.matrix().asColMajord(&ca_transform.m11); - [ca_layer setTransform:ca_transform]; + + if ([ca_layer respondsToSelector:(@selector(setContentsScale:))]) + [ca_layer setContentsScale:scale_factor]; + gfx::RectF dip_frame_rect = gfx::RectF(pixel_frame_rect); + dip_frame_rect.Scale(1 / scale_factor); + [ca_layer setBounds:CGRectMake(0, 0, dip_frame_rect.width(), + dip_frame_rect.height())]; + [ca_layer + setPosition:CGPointMake(dip_frame_rect.x(), dip_frame_rect.y())]; } static bool show_borders = base::CommandLine::ForCurrentProcess()->HasSwitch( @@ -188,9 +154,6 @@ if (!layer_needs_update) { // Green represents contents that are unchanged across frames. color.reset(CGColorCreateGenericRGB(0, 1, 0, 1)); - } else if (z_order != 0) { - // Pink represents overlay planes - color.reset(CGColorCreateGenericRGB(1, 0, 1, 1)); } else { // Red represents damaged contents. color.reset(CGColorCreateGenericRGB(1, 0, 0, 1)); @@ -201,34 +164,14 @@ layer_needs_update = false; } - void Destroy() { - if (!ca_layer) - return; - [ca_layer setContents:nil]; - [ca_layer removeFromSuperlayer]; - ca_layer.reset(); - } - private: OverlayPlane(int z_order, - int io_surface_id, base::ScopedCFTypeRef<IOSurfaceRef> io_surface, const gfx::RectF& contents_rect, - float opacity, - base::ScopedCFTypeRef<CGColorRef> background_color, - unsigned edge_aa_mask, - const gfx::SizeF& bounds_size, - const gfx::Transform& transform, const gfx::RectF& pixel_frame_rect) : z_order(z_order), - io_surface_id(io_surface_id), io_surface(io_surface), contents_rect(contents_rect), - opacity(opacity), - background_color(background_color), - edge_aa_mask(edge_aa_mask), - bounds_size(bounds_size), - transform(transform), pixel_frame_rect(pixel_frame_rect), layer_needs_update(true) {} }; @@ -243,7 +186,7 @@ gfx::Rect pixel_damage_rect; linked_ptr<OverlayPlane> root_plane; - std::vector<linked_ptr<OverlayPlane>> overlay_planes; + scoped_ptr<CALayerTree> ca_layer_tree; std::vector<ui::LatencyInfo> latency_info; // A fence object, and the CGL context it was issued in. @@ -301,16 +244,8 @@ void ImageTransportSurfaceOverlayMac::Destroy() { DisplayAndClearAllPendingSwaps(); - - if (current_root_plane_.get()) - current_root_plane_->Destroy(); - current_root_plane_.reset(); - for (auto& plane : current_partial_damage_planes_) - plane->Destroy(); current_partial_damage_planes_.clear(); - for (auto& plane : current_overlay_planes_) - plane->Destroy(); - current_overlay_planes_.clear(); + current_root_plane_.reset(); } bool ImageTransportSurfaceOverlayMac::IsOffscreen() { @@ -353,7 +288,7 @@ new_swap->pixel_damage_rect = pixel_damage_rect; new_swap->root_plane = pending_root_plane_; pending_root_plane_ = linked_ptr<OverlayPlane>(); - new_swap->overlay_planes.swap(pending_overlay_planes_); + new_swap->ca_layer_tree.swap(pending_ca_layer_tree_); new_swap->latency_info.swap(latency_info_); // A flush is required to ensure that all content appears in the layer. @@ -437,16 +372,10 @@ // Sort the input planes by z-index, and remove any overlays from the // damage rect. gfx::RectF pixel_damage_rect = gfx::RectF(swap->pixel_damage_rect); - std::sort(swap->overlay_planes.begin(), swap->overlay_planes.end(), - OverlayPlane::Compare); - for (auto& plane : swap->overlay_planes) - pixel_damage_rect.Subtract(plane->pixel_frame_rect); - ScopedCAActionDisabler disabler; UpdateRootAndPartialDamagePlanes(swap->root_plane, pixel_damage_rect); - UpdateOverlayPlanes(swap->overlay_planes); - UpdateCALayerTree(); - swap->overlay_planes.clear(); + UpdateRootAndPartialDamageCALayers(swap->scale_factor); + UpdateCALayerTree(std::move(swap->ca_layer_tree), swap->scale_factor); } // Update the latency info to reflect the swap time. @@ -476,27 +405,6 @@ pending_swaps_.pop_front(); } -void ImageTransportSurfaceOverlayMac::UpdateOverlayPlanes( - const std::vector<linked_ptr<OverlayPlane>>& new_overlay_planes) { - std::list<linked_ptr<OverlayPlane>> old_overlay_planes; - old_overlay_planes.swap(current_overlay_planes_); - - // Move the new overlay planes into the |current_overlay_planes_| list, - // cannibalizing from the old |current_overlay_planes_| as much as possible. - for (auto& new_plane : new_overlay_planes) { - if (!old_overlay_planes.empty()) { - new_plane->TakeCALayerFrom(old_overlay_planes.front().get()); - old_overlay_planes.pop_front(); - } - current_overlay_planes_.push_back(new_plane); - } - - // Destroy any of the previous |current_overlay_planes_| that we couldn't - // cannibalize. - for (auto& old_plane : old_overlay_planes) - old_plane->Destroy(); -} - void ImageTransportSurfaceOverlayMac::UpdateRootAndPartialDamagePlanes( const linked_ptr<OverlayPlane>& new_root_plane, const gfx::RectF& pixel_damage_rect) { @@ -504,12 +412,9 @@ old_partial_damage_planes.swap(current_partial_damage_planes_); linked_ptr<OverlayPlane> plane_for_swap; - // If there is no new root plane, destroy the old one. + // If there is no new root plane, remove everything. if (!new_root_plane.get()) { - for (auto& old_plane : old_partial_damage_planes) - old_plane->Destroy(); - if (current_root_plane_.get()) - current_root_plane_->Destroy(); + old_partial_damage_planes.clear(); current_root_plane_.reset(); return; } @@ -555,8 +460,8 @@ 1. / new_root_plane->pixel_frame_rect.height()); plane_for_swap = OverlayPlane::CreateWithFrameRect( - 0, new_root_plane->io_surface_id, new_root_plane->io_surface, - plane_to_reuse_dip_enlarged_rect, enlarged_contents_rect); + 0, new_root_plane->io_surface, plane_to_reuse_dip_enlarged_rect, + enlarged_contents_rect); plane_for_swap->TakeCALayerFrom(plane_to_reuse.get()); if (plane_to_reuse != old_partial_damage_planes.back()) @@ -572,8 +477,7 @@ contents_rect.Scale(1. / new_root_plane->pixel_frame_rect.width(), 1. / new_root_plane->pixel_frame_rect.height()); plane_for_swap = OverlayPlane::CreateWithFrameRect( - 0, new_root_plane->io_surface_id, new_root_plane->io_surface, - pixel_damage_rect, contents_rect); + 0, new_root_plane->io_surface, pixel_damage_rect, contents_rect); } // And if we still don't have a layer, use the root layer. @@ -589,10 +493,12 @@ gfx::RectF old_plane_frame_rect = old_plane->pixel_frame_rect; old_plane_frame_rect.Intersect(new_root_plane->pixel_frame_rect); + bool old_plane_covered_by_swap = false; if (plane_for_swap.get() && plane_for_swap->pixel_frame_rect.Contains(old_plane_frame_rect)) { - old_plane->Destroy(); - } else { + old_plane_covered_by_swap = true; + } + if (!old_plane_covered_by_swap) { DCHECK(old_plane->ca_layer); current_partial_damage_planes_.push_back(old_plane); } @@ -600,36 +506,27 @@ // Finally, add the new swap's plane at the back of the list, if it exists. if (plane_for_swap == new_root_plane) { - if (current_root_plane_.get()) { - plane_for_swap->TakeCALayerFrom(current_root_plane_.get()); - } else { - plane_for_swap->ca_layer = ca_root_layer_; - } current_root_plane_ = new_root_plane; } else if (plane_for_swap.get()) { current_partial_damage_planes_.push_back(plane_for_swap); } } -void ImageTransportSurfaceOverlayMac::UpdateCALayerTree() { +void ImageTransportSurfaceOverlayMac::UpdateRootAndPartialDamageCALayers( + float scale_factor) { if (!use_remote_layer_api_) { - DCHECK(current_overlay_planes_.empty()); DCHECK(current_partial_damage_planes_.empty()); return; } - // Allocate new CALayers as needed. Overlay layers are always added to the - // back of the list. - CALayer* first_overlay_ca_layer = nil; - for (auto& plane : current_overlay_planes_) { - if (!plane->ca_layer) { - plane->ca_layer.reset([[CALayer alloc] init]); - [ca_root_layer_ addSublayer:plane->ca_layer]; + // Allocate and update CALayers for the backbuffer and partial damage layers. + if (current_root_plane_.get()) { + if (!current_root_plane_->ca_layer) { + current_root_plane_->ca_layer.reset([[CALayer alloc] init]); + [ca_root_layer_ setSublayers:nil]; + [ca_root_layer_ addSublayer:current_root_plane_->ca_layer]; } - if (!first_overlay_ca_layer) - first_overlay_ca_layer = plane->ca_layer; } - // Partial damage layers are inserted below the overlay layers. for (auto& plane : current_partial_damage_planes_) { if (!plane->ca_layer) { DCHECK(plane == current_partial_damage_planes_.back()); @@ -637,28 +534,26 @@ } if (![plane->ca_layer superlayer]) { DCHECK(plane == current_partial_damage_planes_.back()); - if (first_overlay_ca_layer) { - [ca_root_layer_ insertSublayer:plane->ca_layer - below:first_overlay_ca_layer]; - } else { - [ca_root_layer_ addSublayer:plane->ca_layer]; - } + [ca_root_layer_ addSublayer:plane->ca_layer]; } } - - // Update CALayer contents, frames, and borders. if (current_root_plane_.get()) - current_root_plane_->UpdateProperties(); + current_root_plane_->UpdateProperties(scale_factor); for (auto& plane : current_partial_damage_planes_) - plane->UpdateProperties(); - for (auto& plane : current_overlay_planes_) - plane->UpdateProperties(); - [ca_root_layer_ setTransform:CATransform3DMakeScale(1 / scale_factor_, - 1 / scale_factor_, 1)]; + plane->UpdateProperties(scale_factor); +} - DCHECK_EQ( - static_cast<size_t>([[ca_root_layer_ sublayers] count]), - current_partial_damage_planes_.size() + current_overlay_planes_.size()); +void ImageTransportSurfaceOverlayMac::UpdateCALayerTree( + scoped_ptr<CALayerTree> ca_layer_tree, + float scale_factor) { + if (ca_layer_tree) { + ca_layer_tree->CommitScheduledCALayers( + ca_root_layer_.get(), std::move(current_ca_layer_tree_), scale_factor); + current_ca_layer_tree_.swap(ca_layer_tree); + ca_layer_tree.reset(); + } else { + current_ca_layer_tree_.reset(); + } } void ImageTransportSurfaceOverlayMac::DisplayAndClearAllPendingSwaps() { @@ -743,19 +638,18 @@ gl::GLImage* image, const gfx::Rect& pixel_frame_rect, const gfx::RectF& crop_rect) { - DCHECK_EQ(transform, gfx::OVERLAY_TRANSFORM_NONE); - if (transform != gfx::OVERLAY_TRANSFORM_NONE) + if (transform != gfx::OVERLAY_TRANSFORM_NONE) { + DLOG(ERROR) << "Invalid overlay plane transform."; return false; + } + if (z_order) { + DLOG(ERROR) << "Invalid non-zero Z order."; + return false; + } - linked_ptr<OverlayPlane> plane = OverlayPlane::CreateWithFrameRect( - z_order, static_cast<gl::GLImageIOSurface*>(image)->io_surface_id().id, - static_cast<gl::GLImageIOSurface*>(image)->io_surface(), + pending_root_plane_ = OverlayPlane::CreateWithFrameRect( + z_order, static_cast<gl::GLImageIOSurface*>(image)->io_surface(), gfx::RectF(pixel_frame_rect), crop_rect); - if (z_order == 0) - pending_root_plane_ = plane; - else - pending_overlay_planes_.push_back(plane); - return true; } @@ -765,35 +659,22 @@ float opacity, unsigned background_color, unsigned edge_aa_mask, - const gfx::RectF& bounds_rect, + const gfx::RectF& rect, bool is_clipped, const gfx::RectF& clip_rect, - const gfx::Transform& transform) { - // Extract the IOSurface, if this layer is not just a solid color. - int io_surface_id = 0; + const gfx::Transform& transform, + int sorting_context_id) { base::ScopedCFTypeRef<IOSurfaceRef> io_surface; if (contents_image) { - io_surface_id = - static_cast<gl::GLImageIOSurface*>(contents_image)->io_surface_id().id; io_surface = static_cast<gl::GLImageIOSurface*>(contents_image)->io_surface(); } - - // Convert the RGBA SkColor to an sRGB CGColorRef. - CGFloat rgba_color_components[4] = { - SkColorGetR(background_color) / 255., - SkColorGetG(background_color) / 255., - SkColorGetB(background_color) / 255., - SkColorGetA(background_color) / 255., - }; - base::ScopedCFTypeRef<CGColorRef> srgb_background_color(CGColorCreate( - CGColorSpaceCreateWithName(kCGColorSpaceSRGB), rgba_color_components)); - - pending_overlay_planes_.push_back(OverlayPlane::CreateWithTransform( - next_ca_layer_z_order_++, io_surface_id, io_surface, contents_rect, - opacity, srgb_background_color, edge_aa_mask, bounds_rect.size(), - transform)); - return true; + if (!pending_ca_layer_tree_) + pending_ca_layer_tree_.reset(new CALayerTree); + return pending_ca_layer_tree_->ScheduleCALayer( + is_clipped, gfx::ToEnclosingRect(clip_rect), sorting_context_id, + transform, io_surface, contents_rect, gfx::ToEnclosingRect(rect), + background_color, edge_aa_mask, opacity); } bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const {
diff --git a/content/common/service_worker/service_worker_type_converters.cc b/content/common/service_worker/service_worker_type_converters.cc index 735f529..cffec739 100644 --- a/content/common/service_worker/service_worker_type_converters.cc +++ b/content/common/service_worker/service_worker_type_converters.cc
@@ -15,11 +15,11 @@ content::ServiceWorkerEventStatus>:: Convert(content::ServiceWorkerEventStatus status) { content::ServiceWorkerStatusCode status_code; - if (status == content::SERVICE_WORKER_EVENT_STATUS_COMPLETED) { + if (status == content::ServiceWorkerEventStatus::COMPLETED) { status_code = content::SERVICE_WORKER_OK; - } else if (status == content::SERVICE_WORKER_EVENT_STATUS_REJECTED) { + } else if (status == content::ServiceWorkerEventStatus::REJECTED) { status_code = content::SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED; - } else if (status == content::SERVICE_WORKER_EVENT_STATUS_ABORTED) { + } else if (status == content::ServiceWorkerEventStatus::ABORTED) { status_code = content::SERVICE_WORKER_ERROR_ABORT; } else { // We received an unexpected value back. This can theoretically happen as
diff --git a/content/content_common.gypi b/content/content_common.gypi index 1c686bf..e4d0884 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi
@@ -321,6 +321,8 @@ 'common/gpu/client/grcontext_for_webgraphicscontext3d.h', 'common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc', 'common/gpu/client/webgraphicscontext3d_command_buffer_impl.h', + 'common/gpu/ca_layer_tree_mac.h', + 'common/gpu/ca_layer_tree_mac.mm', 'common/gpu/child_window_surface_win.cc', 'common/gpu/child_window_surface_win.h', 'common/gpu/gpu_channel.cc',
diff --git a/content/public/common/mojo_geoposition.mojom b/content/public/common/mojo_geoposition.mojom index 852f2a9..b88ffc2 100644 --- a/content/public/common/mojo_geoposition.mojom +++ b/content/public/common/mojo_geoposition.mojom
@@ -14,11 +14,11 @@ // These values follow the W3C geolocation specification and can be returned // to JavaScript without the need for a conversion. enum ErrorCode { - ERROR_CODE_NONE = 0, // Chrome addition. - ERROR_CODE_PERMISSION_DENIED = 1, - ERROR_CODE_POSITION_UNAVAILABLE = 2, - ERROR_CODE_TIMEOUT = 3, - ERROR_CODE_LAST = ERROR_CODE_TIMEOUT + NONE = 0, // Chrome addition. + PERMISSION_DENIED = 1, + POSITION_UNAVAILABLE = 2, + TIMEOUT = 3, + LAST = TIMEOUT }; // Whether this geoposition is valid.
diff --git a/content/renderer/background_sync/background_sync_client_impl.cc b/content/renderer/background_sync/background_sync_client_impl.cc index 4b1c928c..bd420c0 100644 --- a/content/renderer/background_sync/background_sync_client_impl.cc +++ b/content/renderer/background_sync/background_sync_client_impl.cc
@@ -70,15 +70,15 @@ callback = it->second; sync_callbacks_.erase(it); - if (error != BACKGROUND_SYNC_ERROR_NONE) { - callback.Run(SERVICE_WORKER_EVENT_STATUS_ABORTED); + if (error != BackgroundSyncError::NONE) { + callback.Run(ServiceWorkerEventStatus::ABORTED); return; } ServiceWorkerContextClient* client = ServiceWorkerContextClient::ThreadSpecificInstance(); if (!client) { - callback.Run(SERVICE_WORKER_EVENT_STATUS_ABORTED); + callback.Run(ServiceWorkerEventStatus::ABORTED); return; }
diff --git a/content/renderer/child_frame_compositing_helper.cc b/content/renderer/child_frame_compositing_helper.cc index 408fc08..ef85384 100644 --- a/content/renderer/child_frame_compositing_helper.cc +++ b/content/renderer/child_frame_compositing_helper.cc
@@ -315,6 +315,7 @@ cc::SurfaceLayer::Create(cc_blink::WebLayerImpl::LayerSettings(), satisfy_callback, require_callback); surface_layer->SetSurfaceId(surface_id, scale_factor, frame_size); + surface_layer->SetMasksToBounds(true); blink::WebLayer* layer = new cc_blink::WebLayerImpl(surface_layer); UpdateWebLayer(layer);
diff --git a/content/renderer/geolocation_dispatcher.cc b/content/renderer/geolocation_dispatcher.cc index 9f544736..20d3add2 100644 --- a/content/renderer/geolocation_dispatcher.cc +++ b/content/renderer/geolocation_dispatcher.cc
@@ -81,12 +81,11 @@ int permission_request_id = pending_permissions_->add(permissionRequest); permission_service_->RequestPermission( - PERMISSION_NAME_GEOLOCATION, + PermissionName::GEOLOCATION, permissionRequest.securityOrigin().toString().utf8(), blink::WebUserGestureIndicator::isProcessingUserGesture(), base::Bind(&GeolocationDispatcher::OnPermissionSet, - base::Unretained(this), - permission_request_id)); + base::Unretained(this), permission_request_id)); } void GeolocationDispatcher::cancelPermissionRequest( @@ -103,7 +102,7 @@ if (!pending_permissions_->remove(permission_request_id, permissionRequest)) return; - permissionRequest.setIsAllowed(status == PERMISSION_STATUS_GRANTED); + permissionRequest.setIsAllowed(status == PermissionStatus::GRANTED); } void GeolocationDispatcher::QueryNextPosition() { @@ -134,10 +133,10 @@ } else { WebGeolocationError::Error code; switch (geoposition->error_code) { - case Geoposition::ERROR_CODE_PERMISSION_DENIED: + case MojoGeoposition::ErrorCode::PERMISSION_DENIED: code = WebGeolocationError::ErrorPermissionDenied; break; - case Geoposition::ERROR_CODE_POSITION_UNAVAILABLE: + case MojoGeoposition::ErrorCode::POSITION_UNAVAILABLE: code = WebGeolocationError::ErrorPositionUnavailable; break; default:
diff --git a/content/renderer/media/media_permission_dispatcher_impl.cc b/content/renderer/media/media_permission_dispatcher_impl.cc index a1daf8c..64515fb44 100644 --- a/content/renderer/media/media_permission_dispatcher_impl.cc +++ b/content/renderer/media/media_permission_dispatcher_impl.cc
@@ -20,14 +20,14 @@ content::PermissionName MediaPermissionTypeToPermissionName(Type type) { switch (type) { case Type::PROTECTED_MEDIA_IDENTIFIER: - return content::PERMISSION_NAME_PROTECTED_MEDIA_IDENTIFIER; + return content::PermissionName::PROTECTED_MEDIA_IDENTIFIER; case Type::AUDIO_CAPTURE: - return content::PERMISSION_NAME_AUDIO_CAPTURE; + return content::PermissionName::AUDIO_CAPTURE; case Type::VIDEO_CAPTURE: - return content::PERMISSION_NAME_VIDEO_CAPTURE; + return content::PermissionName::VIDEO_CAPTURE; } NOTREACHED(); - return content::PERMISSION_NAME_PROTECTED_MEDIA_IDENTIFIER; + return content::PermissionName::PROTECTED_MEDIA_IDENTIFIER; } } // namespace @@ -93,7 +93,7 @@ uint32_t request_id, PermissionStatus status) { DCHECK(thread_checker().CalledOnValidThread()); - DeliverResult(request_id, status == PERMISSION_STATUS_GRANTED); + DeliverResult(request_id, status == PermissionStatus::GRANTED); } } // namespace content
diff --git a/content/renderer/media/midi_dispatcher.cc b/content/renderer/media/midi_dispatcher.cc index 40fca847..dc322eb 100644 --- a/content/renderer/media/midi_dispatcher.cc +++ b/content/renderer/media/midi_dispatcher.cc
@@ -34,11 +34,9 @@ requests_.Add(new WebMIDIPermissionRequest(request)); permission_service_->RequestPermission( - PERMISSION_NAME_MIDI_SYSEX, - request.securityOrigin().toString().utf8(), + PermissionName::MIDI_SYSEX, request.securityOrigin().toString().utf8(), blink::WebUserGestureIndicator::isProcessingUserGesture(), - base::Bind(&MidiDispatcher::OnSysExPermissionSet, - base::Unretained(this), + base::Bind(&MidiDispatcher::OnSysExPermissionSet, base::Unretained(this), permission_request_id)); } @@ -59,7 +57,7 @@ WebMIDIPermissionRequest* request = requests_.Lookup(request_id); if (!request) return; - request->setIsAllowed(status == PERMISSION_STATUS_GRANTED); + request->setIsAllowed(status == PermissionStatus::GRANTED); requests_.Remove(request_id); }
diff --git a/content/renderer/mus/compositor_mus_connection.cc b/content/renderer/mus/compositor_mus_connection.cc index 00b9e49..6973de6f 100644 --- a/content/renderer/mus/compositor_mus_connection.cc +++ b/content/renderer/mus/compositor_mus_connection.cc
@@ -47,7 +47,7 @@ DCHECK(compositor_task_runner_->BelongsToCurrentThread()); window_surface_binding_ = std::move(surface_binding); if (root_) { - root_->AttachSurface(mus::mojom::SURFACE_TYPE_DEFAULT, + root_->AttachSurface(mus::mojom::SurfaceType::DEFAULT, std::move(window_surface_binding_)); } } @@ -101,7 +101,7 @@ root_ = root; root_->set_input_event_handler(this); if (window_surface_binding_) { - root->AttachSurface(mus::mojom::SURFACE_TYPE_DEFAULT, + root->AttachSurface(mus::mojom::SurfaceType::DEFAULT, std::move(window_surface_binding_)); } }
diff --git a/content/renderer/notification_permission_dispatcher.cc b/content/renderer/notification_permission_dispatcher.cc index 9c2f767d..cd71c03 100644 --- a/content/renderer/notification_permission_dispatcher.cc +++ b/content/renderer/notification_permission_dispatcher.cc
@@ -37,7 +37,7 @@ // base::Unretained is safe here because the Mojo channel, with associated // callbacks, will be deleted before the "this" instance is deleted. permission_service_->RequestPermission( - PERMISSION_NAME_NOTIFICATIONS, origin.toString().utf8(), + PermissionName::NOTIFICATIONS, origin.toString().utf8(), blink::WebUserGestureIndicator::isProcessingUserGesture(), base::Bind(&NotificationPermissionDispatcher::OnPermissionRequestComplete, base::Unretained(this), @@ -52,13 +52,13 @@ blink::WebNotificationPermission permission = blink::WebNotificationPermissionDefault; switch (status) { - case PERMISSION_STATUS_GRANTED: + case PermissionStatus::GRANTED: permission = blink::WebNotificationPermissionAllowed; break; - case PERMISSION_STATUS_DENIED: + case PermissionStatus::DENIED: permission = blink::WebNotificationPermissionDenied; break; - case PERMISSION_STATUS_ASK: + case PermissionStatus::ASK: permission = blink::WebNotificationPermissionDefault; break; }
diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc index bfe9a49..bf5a4a64 100644 --- a/content/renderer/presentation/presentation_dispatcher.cc +++ b/content/renderer/presentation/presentation_dispatcher.cc
@@ -27,13 +27,13 @@ blink::WebPresentationError::ErrorType GetWebPresentationErrorTypeFromMojo( presentation::PresentationErrorType mojoErrorType) { switch (mojoErrorType) { - case presentation::PRESENTATION_ERROR_TYPE_NO_AVAILABLE_SCREENS: + case presentation::PresentationErrorType::NO_AVAILABLE_SCREENS: return blink::WebPresentationError::ErrorTypeNoAvailableScreens; - case presentation::PRESENTATION_ERROR_TYPE_SESSION_REQUEST_CANCELLED: + case presentation::PresentationErrorType::SESSION_REQUEST_CANCELLED: return blink::WebPresentationError::ErrorTypeSessionRequestCancelled; - case presentation::PRESENTATION_ERROR_TYPE_NO_PRESENTATION_FOUND: + case presentation::PresentationErrorType::NO_PRESENTATION_FOUND: return blink::WebPresentationError::ErrorTypeNoPresentationFound; - case presentation::PRESENTATION_ERROR_TYPE_UNKNOWN: + case presentation::PresentationErrorType::UNKNOWN: default: return blink::WebPresentationError::ErrorTypeUnknown; } @@ -43,11 +43,11 @@ presentation::PresentationConnectionState mojoSessionState) { switch (mojoSessionState) { // TODO(imcheng): Add Connecting state to Blink (crbug.com/575351). - case presentation::PRESENTATION_CONNECTION_STATE_CONNECTED: + case presentation::PresentationConnectionState::CONNECTED: return blink::WebPresentationConnectionState::Connected; - case presentation::PRESENTATION_CONNECTION_STATE_CLOSED: + case presentation::PresentationConnectionState::CLOSED: return blink::WebPresentationConnectionState::Closed; - case presentation::PRESENTATION_CONNECTION_STATE_TERMINATED: + case presentation::PresentationConnectionState::TERMINATED: return blink::WebPresentationConnectionState::Terminated; default: NOTREACHED(); @@ -146,11 +146,9 @@ return; } - message_request_queue_.push(make_scoped_ptr( - CreateSendBinaryMessageRequest(presentationUrl, presentationId, - presentation::PresentationMessageType:: - PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER, - data, length))); + message_request_queue_.push(make_scoped_ptr(CreateSendBinaryMessageRequest( + presentationUrl, presentationId, + presentation::PresentationMessageType::ARRAY_BUFFER, data, length))); // Start processing request if only one in the queue. if (message_request_queue_.size() == 1) DoSendMessage(message_request_queue_.front().get()); @@ -170,8 +168,7 @@ message_request_queue_.push(make_scoped_ptr(CreateSendBinaryMessageRequest( presentationUrl, presentationId, - presentation::PresentationMessageType::PRESENTATION_MESSAGE_TYPE_BLOB, - data, length))); + presentation::PresentationMessageType::BLOB, data, length))); // Start processing request if only one in the queue. if (message_request_queue_.size() == 1) DoSendMessage(message_request_queue_.front().get()); @@ -397,17 +394,14 @@ scoped_ptr<PresentationConnectionClient> session_client( new PresentationConnectionClient(session_info->url, session_info->id)); switch (messages[i]->type) { - case presentation::PresentationMessageType:: - PRESENTATION_MESSAGE_TYPE_TEXT: { + case presentation::PresentationMessageType::TEXT: { controller_->didReceiveSessionTextMessage( session_client.release(), blink::WebString::fromUTF8(messages[i]->message)); break; } - case presentation::PresentationMessageType:: - PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER: - case presentation::PresentationMessageType:: - PRESENTATION_MESSAGE_TYPE_BLOB: { + case presentation::PresentationMessageType::ARRAY_BUFFER: + case presentation::PresentationMessageType::BLOB: { controller_->didReceiveSessionBinaryMessage( session_client.release(), &(messages[i]->data.front()), messages[i]->data.size()); @@ -470,8 +464,7 @@ presentation::SessionMessagePtr session_message = presentation::SessionMessage::New(); - session_message->type = - presentation::PresentationMessageType::PRESENTATION_MESSAGE_TYPE_TEXT; + session_message->type = presentation::PresentationMessageType::TEXT; session_message->message = message.utf8(); return new SendMessageRequest(std::move(session_info), std::move(session_message));
diff --git a/content/renderer/service_worker/service_worker_context_client.cc b/content/renderer/service_worker/service_worker_context_client.cc index ecf84b84..348e809 100644 --- a/content/renderer/service_worker/service_worker_context_client.cc +++ b/content/renderer/service_worker/service_worker_context_client.cc
@@ -539,9 +539,9 @@ if (!callback) return; if (result == blink::WebServiceWorkerEventResultCompleted) { - callback->Run(SERVICE_WORKER_EVENT_STATUS_COMPLETED); + callback->Run(ServiceWorkerEventStatus::COMPLETED); } else { - callback->Run(SERVICE_WORKER_EVENT_STATUS_REJECTED); + callback->Run(ServiceWorkerEventStatus::REJECTED); } context_->sync_event_callbacks.Remove(request_id); }
diff --git a/content/renderer/usb/type_converters.cc b/content/renderer/usb/type_converters.cc index 62c9aab..acddfaf 100644 --- a/content/renderer/usb/type_converters.cc +++ b/content/renderer/usb/type_converters.cc
@@ -16,9 +16,9 @@ device::usb::TransferDirection>:: Convert(const device::usb::TransferDirection& direction) { switch (direction) { - case device::usb::TRANSFER_DIRECTION_IN: + case device::usb::TransferDirection::INBOUND: return blink::WebUSBDevice::TransferDirection::In; - case device::usb::TRANSFER_DIRECTION_OUT: + case device::usb::TransferDirection::OUTBOUND: return blink::WebUSBDevice::TransferDirection::Out; default: NOTREACHED(); @@ -33,12 +33,12 @@ Convert(const blink::WebUSBDevice::TransferDirection& direction) { switch (direction) { case blink::WebUSBDevice::TransferDirection::In: - return device::usb::TRANSFER_DIRECTION_IN; + return device::usb::TransferDirection::INBOUND; case blink::WebUSBDevice::TransferDirection::Out: - return device::usb::TRANSFER_DIRECTION_OUT; + return device::usb::TransferDirection::OUTBOUND; default: NOTREACHED(); - return device::usb::TRANSFER_DIRECTION_IN; + return device::usb::TransferDirection::INBOUND; } } @@ -49,14 +49,14 @@ Convert(const blink::WebUSBDevice::RequestType& direction) { switch (direction) { case blink::WebUSBDevice::RequestType::Standard: - return device::usb::CONTROL_TRANSFER_TYPE_STANDARD; + return device::usb::ControlTransferType::STANDARD; case blink::WebUSBDevice::RequestType::Class: - return device::usb::CONTROL_TRANSFER_TYPE_CLASS; + return device::usb::ControlTransferType::CLASS; case blink::WebUSBDevice::RequestType::Vendor: - return device::usb::CONTROL_TRANSFER_TYPE_VENDOR; + return device::usb::ControlTransferType::VENDOR; default: NOTREACHED(); - return device::usb::CONTROL_TRANSFER_TYPE_STANDARD; + return device::usb::ControlTransferType::STANDARD; } } @@ -67,16 +67,16 @@ Convert(const blink::WebUSBDevice::RequestRecipient& direction) { switch (direction) { case blink::WebUSBDevice::RequestRecipient::Device: - return device::usb::CONTROL_TRANSFER_RECIPIENT_DEVICE; + return device::usb::ControlTransferRecipient::DEVICE; case blink::WebUSBDevice::RequestRecipient::Interface: - return device::usb::CONTROL_TRANSFER_RECIPIENT_INTERFACE; + return device::usb::ControlTransferRecipient::INTERFACE; case blink::WebUSBDevice::RequestRecipient::Endpoint: - return device::usb::CONTROL_TRANSFER_RECIPIENT_ENDPOINT; + return device::usb::ControlTransferRecipient::ENDPOINT; case blink::WebUSBDevice::RequestRecipient::Other: - return device::usb::CONTROL_TRANSFER_RECIPIENT_OTHER; + return device::usb::ControlTransferRecipient::OTHER; default: NOTREACHED(); - return device::usb::CONTROL_TRANSFER_RECIPIENT_DEVICE; + return device::usb::ControlTransferRecipient::DEVICE; } } @@ -103,11 +103,11 @@ device::usb::EndpointType>::Convert(const device::usb::EndpointType& endpoint_type) { switch (endpoint_type) { - case device::usb::ENDPOINT_TYPE_BULK: + case device::usb::EndpointType::BULK: return blink::WebUSBDeviceInfo::Endpoint::Type::Bulk; - case device::usb::ENDPOINT_TYPE_INTERRUPT: + case device::usb::EndpointType::INTERRUPT: return blink::WebUSBDeviceInfo::Endpoint::Type::Interrupt; - case device::usb::ENDPOINT_TYPE_ISOCHRONOUS: + case device::usb::EndpointType::ISOCHRONOUS: return blink::WebUSBDeviceInfo::Endpoint::Type::Isochronous; default: NOTREACHED();
diff --git a/content/renderer/usb/web_usb_device_impl.cc b/content/renderer/usb/web_usb_device_impl.cc index d1db890..6c76838 100644 --- a/content/renderer/usb/web_usb_device_impl.cc +++ b/content/renderer/usb/web_usb_device_impl.cc
@@ -66,10 +66,10 @@ device::usb::OpenDeviceError error) { auto scoped_callbacks = callbacks.PassCallbacks(); switch(error) { - case device::usb::OPEN_DEVICE_ERROR_OK: + case device::usb::OpenDeviceError::OK: scoped_callbacks->onSuccess(); break; - case device::usb::OPEN_DEVICE_ERROR_ACCESS_DENIED: + case device::usb::OpenDeviceError::ACCESS_DENIED: scoped_callbacks->onError(blink::WebUSBError( blink::WebUSBError::Error::Security, base::ASCIIToUTF16(kDeviceNoAccess))); @@ -117,7 +117,7 @@ device::usb::TransferStatus status, mojo::Array<uint8_t> data) { auto scoped_callbacks = callbacks.PassCallbacks(); - if (status != device::usb::TRANSFER_STATUS_COMPLETED) { + if (status != device::usb::TransferStatus::COMPLETED) { RejectWithTransferError(std::move(scoped_callbacks)); return; } @@ -134,13 +134,13 @@ auto scoped_callbacks = callbacks.PassCallbacks(); scoped_ptr<blink::WebUSBTransferInfo> info(new blink::WebUSBTransferInfo()); switch (status) { - case device::usb::TRANSFER_STATUS_COMPLETED: + case device::usb::TransferStatus::COMPLETED: info->status = blink::WebUSBTransferInfo::Status::Ok; break; - case device::usb::TRANSFER_STATUS_STALLED: + case device::usb::TransferStatus::STALLED: info->status = blink::WebUSBTransferInfo::Status::Stall; break; - case device::usb::TRANSFER_STATUS_BABBLE: + case device::usb::TransferStatus::BABBLE: info->status = blink::WebUSBTransferInfo::Status::Babble; break; default:
diff --git a/content/shell/browser/layout_test/layout_test_notification_manager.cc b/content/shell/browser/layout_test/layout_test_notification_manager.cc index 82cc07d..9380238 100644 --- a/content/shell/browser/layout_test/layout_test_notification_manager.cc +++ b/content/shell/browser/layout_test/layout_test_notification_manager.cc
@@ -26,11 +26,11 @@ blink::WebNotificationPermission ToWebNotificationPermission( PermissionStatus status) { switch (status) { - case PERMISSION_STATUS_GRANTED: + case PermissionStatus::GRANTED: return blink::WebNotificationPermissionAllowed; - case PERMISSION_STATUS_DENIED: + case PermissionStatus::DENIED: return blink::WebNotificationPermissionDenied; - case PERMISSION_STATUS_ASK: + case PermissionStatus::ASK: return blink::WebNotificationPermissionDefault; }
diff --git a/content/shell/browser/layout_test/layout_test_permission_manager.cc b/content/shell/browser/layout_test/layout_test_permission_manager.cc index 55e788f8..df6f87b9 100644 --- a/content/shell/browser/layout_test/layout_test_permission_manager.cc +++ b/content/shell/browser/layout_test/layout_test_permission_manager.cc
@@ -129,7 +129,7 @@ auto it = permissions_.find( PermissionDescription(permission, requesting_origin, embedding_origin)); if (it == permissions_.end()) - return PERMISSION_STATUS_DENIED; + return PermissionStatus::DENIED; return it->second; }
diff --git a/content/shell/browser/layout_test/layout_test_push_messaging_service.cc b/content/shell/browser/layout_test/layout_test_push_messaging_service.cc index 9b83add..e4a9e680 100644 --- a/content/shell/browser/layout_test/layout_test_push_messaging_service.cc +++ b/content/shell/browser/layout_test/layout_test_push_messaging_service.cc
@@ -40,11 +40,11 @@ blink::WebPushPermissionStatus ToWebPushPermissionStatus( PermissionStatus status) { switch (status) { - case PERMISSION_STATUS_GRANTED: + case PermissionStatus::GRANTED: return blink::WebPushPermissionStatusGranted; - case PERMISSION_STATUS_DENIED: + case PermissionStatus::DENIED: return blink::WebPushPermissionStatusDenied; - case PERMISSION_STATUS_ASK: + case PermissionStatus::ASK: return blink::WebPushPermissionStatusPrompt; }
diff --git a/content/shell/browser/shell_permission_manager.cc b/content/shell/browser/shell_permission_manager.cc index fb537b02..5d666467 100644 --- a/content/shell/browser/shell_permission_manager.cc +++ b/content/shell/browser/shell_permission_manager.cc
@@ -26,7 +26,8 @@ bool user_gesture, const base::Callback<void(PermissionStatus)>& callback) { callback.Run(permission == PermissionType::GEOLOCATION - ? PERMISSION_STATUS_GRANTED : PERMISSION_STATUS_DENIED); + ? PermissionStatus::GRANTED + : PermissionStatus::DENIED); return kNoPendingOperation; } @@ -40,7 +41,8 @@ std::vector<PermissionStatus> result(permissions.size()); for (const auto& permission : permissions) { result.push_back(permission == PermissionType::GEOLOCATION - ? PERMISSION_STATUS_GRANTED : PERMISSION_STATUS_DENIED); + ? PermissionStatus::GRANTED + : PermissionStatus::DENIED); } callback.Run(result); return kNoPendingOperation; @@ -64,9 +66,9 @@ permission == PermissionType::VIDEO_CAPTURE) && command_line->HasSwitch(switches::kUseFakeDeviceForMediaStream) && command_line->HasSwitch(switches::kUseFakeUIForMediaStream)) { - return PERMISSION_STATUS_GRANTED; + return PermissionStatus::GRANTED; } - return PERMISSION_STATUS_DENIED; + return PermissionStatus::DENIED; } void ShellPermissionManager::RegisterPermissionUsage(
diff --git a/content/shell/common/layout_test/layout_test_messages.h b/content/shell/common/layout_test/layout_test_messages.h index 97b30738..a67b872 100644 --- a/content/shell/common/layout_test/layout_test_messages.h +++ b/content/shell/common/layout_test/layout_test_messages.h
@@ -15,8 +15,8 @@ #define IPC_MESSAGE_START LayoutTestMsgStart IPC_ENUM_TRAITS_MIN_MAX_VALUE(content::PermissionStatus, - content::PERMISSION_STATUS_GRANTED, - content::PERMISSION_STATUS_ASK) + content::PermissionStatus::GRANTED, + content::PermissionStatus::ASK) IPC_SYNC_MESSAGE_ROUTED1_1(LayoutTestHostMsg_ReadFileToString, base::FilePath /* local path */,
diff --git a/content/shell/renderer/layout_test/blink_test_runner.cc b/content/shell/renderer/layout_test/blink_test_runner.cc index 15fee62..f6f74c58 100644 --- a/content/shell/renderer/layout_test/blink_test_runner.cc +++ b/content/shell/renderer/layout_test/blink_test_runner.cc
@@ -705,14 +705,14 @@ const GURL& embedding_origin) { content::PermissionStatus status; if (value == "granted") - status = PERMISSION_STATUS_GRANTED; + status = PermissionStatus::GRANTED; else if (value == "prompt") - status = PERMISSION_STATUS_ASK; + status = PermissionStatus::ASK; else if (value == "denied") - status = PERMISSION_STATUS_DENIED; + status = PermissionStatus::DENIED; else { NOTREACHED(); - status = PERMISSION_STATUS_DENIED; + status = PermissionStatus::DENIED; } Send(new LayoutTestHostMsg_SetPermission(
diff --git a/content/test/gpu/gpu_tests/pixel_expectations.py b/content/test/gpu/gpu_tests/pixel_expectations.py index 0ce1f6d..e4875a48 100644 --- a/content/test/gpu/gpu_tests/pixel_expectations.py +++ b/content/test/gpu/gpu_tests/pixel_expectations.py
@@ -19,3 +19,7 @@ ['mac'], bug=540039) self.Fail('Pixel.WebGLGreenTriangleES3', ['mac', ('intel', 0x116)], bug=540531) + + # TODO(ccameron): Remove suppression after rebaseline. + self.Fail('Pixel.CSS3DBlueBox', ['mac'], bug=533690) + self.Fail('Pixel.CSS3DBlueBoxES3', ['mac'], bug=533690)
diff --git a/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py b/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py index 0f286c87..5cb7036 100644 --- a/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py +++ b/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py
@@ -336,6 +336,8 @@ ['linux'], bug=483282) self.Fail('conformance2/rendering/draw-buffers.html', ['linux'], bug=483282) + self.Fail('conformance2/textures/misc/tex-mipmap-levels.html', + ['linux'], bug=483282) # Linux AMD only. # It looks like AMD shader compiler rejects many valid ES3 semantics.
diff --git a/device/bluetooth/bluetooth_adapter_bluez.cc b/device/bluetooth/bluetooth_adapter_bluez.cc index e3971997..89abe8e 100644 --- a/device/bluetooth/bluetooth_adapter_bluez.cc +++ b/device/bluetooth/bluetooth_adapter_bluez.cc
@@ -495,9 +495,12 @@ // PlayStation joystick tries to reconnect after disconnection from USB. // If it is still not trusted, set it, so it becomes available on the // list of known devices. - if (properties->connected.value() && device_bluez->IsTrustable() && - !properties->trusted.value()) - device_bluez->SetTrusted(); + if (properties->connected.value()) { + if (device_bluez->IsTrustable() && !properties->trusted.value()) + device_bluez->SetTrusted(); + } else { + device_bluez->SetGattServicesDiscoveryComplete(false); + } int count = 0;
diff --git a/device/bluetooth/bluetooth_gatt_bluez_unittest.cc b/device/bluetooth/bluetooth_gatt_bluez_unittest.cc index 575c867b..8641c35 100644 --- a/device/bluetooth/bluetooth_gatt_bluez_unittest.cc +++ b/device/bluetooth/bluetooth_gatt_bluez_unittest.cc
@@ -377,10 +377,41 @@ properties->gatt_services.ReplaceValue( fake_bluetooth_gatt_service_client_->GetServices()); + EXPECT_TRUE(device->IsGattServicesDiscoveryComplete()); + EXPECT_EQ(1u, device->GetGattServices().size()); EXPECT_EQ(1, observer.gatt_services_discovered_count()); EXPECT_EQ(device, observer.last_device()); EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress, observer.last_device_address()); + + // Disconnect from the device: + device->Disconnect(base::Bind(&BluetoothGattBlueZTest::SuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothGattBlueZTest::ErrorCallback, + base::Unretained(this))); + fake_bluetooth_gatt_service_client_->HideHeartRateService(); + properties->connected.ReplaceValue(false); + + EXPECT_FALSE(device->IsConnected()); + EXPECT_FALSE(device->IsGattServicesDiscoveryComplete()); + EXPECT_EQ(0u, device->GetGattServices().size()); + + // Verify that the device can be connected to again: + device->CreateGattConnection( + base::Bind(&BluetoothGattBlueZTest::GattConnectionCallback, + base::Unretained(this)), + base::Bind(&BluetoothGattBlueZTest::ConnectErrorCallback, + base::Unretained(this))); + properties->connected.ReplaceValue(true); + EXPECT_TRUE(device->IsConnected()); + + // Verify that service discovery can be done again: + fake_bluetooth_gatt_service_client_->ExposeHeartRateService( + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); + properties->gatt_services.ReplaceValue( + fake_bluetooth_gatt_service_client_->GetServices()); + EXPECT_TRUE(device->IsGattServicesDiscoveryComplete()); + EXPECT_EQ(1u, device->GetGattServices().size()); } TEST_F(BluetoothGattBlueZTest, GattCharacteristicAddedAndRemoved) {
diff --git a/device/devices_app/usb/device_impl.cc b/device/devices_app/usb/device_impl.cc index bc1cf17..fd2f0ff 100644 --- a/device/devices_app/usb/device_impl.cc +++ b/device/devices_app/usb/device_impl.cc
@@ -95,7 +95,7 @@ base::Bind(&OnTransferIn, base::Passed(&callback))); } else { mojo::Array<uint8_t> data; - callback->Run(TRANSFER_STATUS_PERMISSION_DENIED, std::move(data)); + callback->Run(TransferStatus::PERMISSION_DENIED, std::move(data)); } } @@ -124,7 +124,7 @@ params->request, params->value, params->index, buffer, data.size(), timeout, base::Bind(&OnTransferOut, base::Passed(&callback))); } else { - callback->Run(TRANSFER_STATUS_PERMISSION_DENIED); + callback->Run(TransferStatus::PERMISSION_DENIED); } } @@ -189,15 +189,15 @@ DCHECK(device_handle_); const UsbConfigDescriptor* config = device_->GetActiveConfiguration(); - if (recipient == CONTROL_TRANSFER_RECIPIENT_INTERFACE || - recipient == CONTROL_TRANSFER_RECIPIENT_ENDPOINT) { + if (recipient == ControlTransferRecipient::INTERFACE || + recipient == ControlTransferRecipient::ENDPOINT) { if (!config) { callback.Run(false); return; } uint8_t interface_number = index & 0xff; - if (recipient == CONTROL_TRANSFER_RECIPIENT_ENDPOINT) { + if (recipient == ControlTransferRecipient::ENDPOINT) { if (!device_handle_->FindInterfaceByEndpoint(index & 0xff, &interface_number)) { callback.Run(false); @@ -220,7 +220,7 @@ void DeviceImpl::OnOpen(const OpenCallback& callback, scoped_refptr<UsbDeviceHandle> handle) { device_handle_ = handle; - callback.Run(handle ? OPEN_DEVICE_ERROR_OK : OPEN_DEVICE_ERROR_ACCESS_DENIED); + callback.Run(handle ? OpenDeviceError::OK : OpenDeviceError::ACCESS_DENIED); } void DeviceImpl::GetDeviceInfo(const GetDeviceInfoCallback& callback) { @@ -325,7 +325,7 @@ uint32_t timeout, const ControlTransferInCallback& callback) { if (!device_handle_) { - callback.Run(TRANSFER_STATUS_ERROR, mojo::Array<uint8_t>()); + callback.Run(TransferStatus::TRANSFER_ERROR, mojo::Array<uint8_t>()); return; } @@ -345,7 +345,7 @@ uint32_t timeout, const ControlTransferOutCallback& callback) { if (!device_handle_) { - callback.Run(TRANSFER_STATUS_ERROR); + callback.Run(TransferStatus::TRANSFER_ERROR); return; } @@ -364,7 +364,7 @@ uint32_t timeout, const GenericTransferInCallback& callback) { if (!device_handle_) { - callback.Run(TRANSFER_STATUS_ERROR, mojo::Array<uint8_t>()); + callback.Run(TransferStatus::TRANSFER_ERROR, mojo::Array<uint8_t>()); return; } @@ -382,7 +382,7 @@ uint32_t timeout, const GenericTransferOutCallback& callback) { if (!device_handle_) { - callback.Run(TRANSFER_STATUS_ERROR); + callback.Run(TransferStatus::TRANSFER_ERROR); return; } @@ -403,7 +403,8 @@ uint32_t timeout, const IsochronousTransferInCallback& callback) { if (!device_handle_) { - callback.Run(TRANSFER_STATUS_ERROR, mojo::Array<mojo::Array<uint8_t>>()); + callback.Run(TransferStatus::TRANSFER_ERROR, + mojo::Array<mojo::Array<uint8_t>>()); return; } @@ -425,7 +426,7 @@ uint32_t timeout, const IsochronousTransferOutCallback& callback) { if (!device_handle_) { - callback.Run(TRANSFER_STATUS_ERROR); + callback.Run(TransferStatus::TRANSFER_ERROR); return; }
diff --git a/device/devices_app/usb/device_impl_unittest.cc b/device/devices_app/usb/device_impl_unittest.cc index 3fbc702..f6ad171 100644 --- a/device/devices_app/usb/device_impl_unittest.cc +++ b/device/devices_app/usb/device_impl_unittest.cc
@@ -379,7 +379,7 @@ base::RunLoop loop; device->Open( - base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK, loop.QuitClosure())); + base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK, loop.QuitClosure())); loop.Run(); EXPECT_CALL(mock_handle(), Close()); @@ -394,7 +394,7 @@ { base::RunLoop loop; - device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK, + device->Open(base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK, loop.QuitClosure())); loop.Run(); } @@ -430,7 +430,7 @@ { base::RunLoop loop; - device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK, + device->Open(base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK, loop.QuitClosure())); loop.Run(); } @@ -456,7 +456,7 @@ { base::RunLoop loop; - device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK, + device->Open(base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK, loop.QuitClosure())); loop.Run(); } @@ -485,7 +485,7 @@ { base::RunLoop loop; - device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK, + device->Open(base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK, loop.QuitClosure())); loop.Run(); } @@ -520,7 +520,7 @@ { base::RunLoop loop; - device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK, + device->Open(base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK, loop.QuitClosure())); loop.Run(); } @@ -588,7 +588,7 @@ { base::RunLoop loop; - device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK, + device->Open(base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK, loop.QuitClosure())); loop.Run(); } @@ -626,7 +626,7 @@ { base::RunLoop loop; - device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK, + device->Open(base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK, loop.QuitClosure())); loop.Run(); } @@ -656,15 +656,15 @@ { auto params = ControlTransferParams::New(); - params->type = CONTROL_TRANSFER_TYPE_STANDARD; - params->recipient = CONTROL_TRANSFER_RECIPIENT_DEVICE; + params->type = ControlTransferType::STANDARD; + params->recipient = ControlTransferRecipient::DEVICE; params->request = 5; params->value = 6; params->index = 7; base::RunLoop loop; device->ControlTransferIn( std::move(params), static_cast<uint32_t>(fake_data.size()), 0, - base::Bind(&ExpectTransferInAndThen, TRANSFER_STATUS_COMPLETED, + base::Bind(&ExpectTransferInAndThen, TransferStatus::COMPLETED, fake_data, loop.QuitClosure())); loop.Run(); } @@ -678,15 +678,15 @@ { auto params = ControlTransferParams::New(); - params->type = CONTROL_TRANSFER_TYPE_STANDARD; - params->recipient = CONTROL_TRANSFER_RECIPIENT_INTERFACE; + params->type = ControlTransferType::STANDARD; + params->recipient = ControlTransferRecipient::INTERFACE; params->request = 5; params->value = 6; params->index = 7; base::RunLoop loop; device->ControlTransferOut( std::move(params), mojo::Array<uint8_t>::From(fake_data), 0, - base::Bind(&ExpectTransferStatusAndThen, TRANSFER_STATUS_COMPLETED, + base::Bind(&ExpectTransferStatusAndThen, TransferStatus::COMPLETED, loop.QuitClosure())); loop.Run(); } @@ -701,7 +701,7 @@ { base::RunLoop loop; - device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK, + device->Open(base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK, loop.QuitClosure())); loop.Run(); } @@ -725,7 +725,7 @@ base::RunLoop loop; device->GenericTransferOut( 1, mojo::Array<uint8_t>::From(fake_outbound_data), 0, - base::Bind(&ExpectTransferStatusAndThen, TRANSFER_STATUS_COMPLETED, + base::Bind(&ExpectTransferStatusAndThen, TransferStatus::COMPLETED, loop.QuitClosure())); loop.Run(); } @@ -737,7 +737,7 @@ base::RunLoop loop; device->GenericTransferIn( 1, static_cast<uint32_t>(fake_inbound_data.size()), 0, - base::Bind(&ExpectTransferInAndThen, TRANSFER_STATUS_COMPLETED, + base::Bind(&ExpectTransferInAndThen, TransferStatus::COMPLETED, fake_inbound_data, loop.QuitClosure())); loop.Run(); } @@ -752,7 +752,7 @@ { base::RunLoop loop; - device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK, + device->Open(base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK, loop.QuitClosure())); loop.Run(); } @@ -787,7 +787,7 @@ } device->IsochronousTransferOut( 1, std::move(packets), 0, - base::Bind(&ExpectTransferStatusAndThen, TRANSFER_STATUS_COMPLETED, + base::Bind(&ExpectTransferStatusAndThen, TransferStatus::COMPLETED, loop.QuitClosure())); loop.Run(); } @@ -805,7 +805,7 @@ inbound_packet_data.begin() + i * 8 + 8, packets[i].begin()); } device->IsochronousTransferIn( - 1, 4, 8, 0, base::Bind(&ExpectPacketsAndThen, TRANSFER_STATUS_COMPLETED, + 1, 4, 8, 0, base::Bind(&ExpectPacketsAndThen, TransferStatus::COMPLETED, packets, loop.QuitClosure())); loop.Run(); }
diff --git a/device/devices_app/usb/public/interfaces/device.mojom b/device/devices_app/usb/public/interfaces/device.mojom index 5382ce37..438aed1 100644 --- a/device/devices_app/usb/public/interfaces/device.mojom +++ b/device/devices_app/usb/public/interfaces/device.mojom
@@ -13,8 +13,8 @@ }; enum TransferDirection { - IN, - OUT, + INBOUND, + OUTBOUND, }; enum ControlTransferType { @@ -113,7 +113,7 @@ COMPLETED, // The transfer failed due to a non-specific error. - ERROR, + TRANSFER_ERROR, // The transfer was not allowed. PERMISSION_DENIED,
diff --git a/device/devices_app/usb/type_converters.cc b/device/devices_app/usb/type_converters.cc index 7152d450..cadf9cf9 100644 --- a/device/devices_app/usb/type_converters.cc +++ b/device/devices_app/usb/type_converters.cc
@@ -41,9 +41,9 @@ TypeConverter<device::usb::TransferDirection, device::UsbEndpointDirection>:: Convert(const device::UsbEndpointDirection& direction) { if (direction == device::USB_DIRECTION_INBOUND) - return device::usb::TRANSFER_DIRECTION_IN; + return device::usb::TransferDirection::INBOUND; DCHECK(direction == device::USB_DIRECTION_OUTBOUND); - return device::usb::TRANSFER_DIRECTION_OUT; + return device::usb::TransferDirection::OUTBOUND; } // static @@ -52,24 +52,24 @@ const device::UsbTransferStatus& status) { switch (status) { case device::USB_TRANSFER_COMPLETED: - return device::usb::TRANSFER_STATUS_COMPLETED; + return device::usb::TransferStatus::COMPLETED; case device::USB_TRANSFER_ERROR: - return device::usb::TRANSFER_STATUS_ERROR; + return device::usb::TransferStatus::TRANSFER_ERROR; case device::USB_TRANSFER_TIMEOUT: - return device::usb::TRANSFER_STATUS_TIMEOUT; + return device::usb::TransferStatus::TIMEOUT; case device::USB_TRANSFER_CANCELLED: - return device::usb::TRANSFER_STATUS_CANCELLED; + return device::usb::TransferStatus::CANCELLED; case device::USB_TRANSFER_STALLED: - return device::usb::TRANSFER_STATUS_STALLED; + return device::usb::TransferStatus::STALLED; case device::USB_TRANSFER_DISCONNECT: - return device::usb::TRANSFER_STATUS_DISCONNECT; + return device::usb::TransferStatus::DISCONNECT; case device::USB_TRANSFER_OVERFLOW: - return device::usb::TRANSFER_STATUS_BABBLE; + return device::usb::TransferStatus::BABBLE; case device::USB_TRANSFER_LENGTH_SHORT: - return device::usb::TRANSFER_STATUS_SHORT_PACKET; + return device::usb::TransferStatus::SHORT_PACKET; default: NOTREACHED(); - return device::usb::TRANSFER_STATUS_ERROR; + return device::usb::TransferStatus::TRANSFER_ERROR; } } @@ -79,13 +79,13 @@ device::usb::ControlTransferType>:: Convert(const device::usb::ControlTransferType& type) { switch (type) { - case device::usb::CONTROL_TRANSFER_TYPE_STANDARD: + case device::usb::ControlTransferType::STANDARD: return device::UsbDeviceHandle::STANDARD; - case device::usb::CONTROL_TRANSFER_TYPE_CLASS: + case device::usb::ControlTransferType::CLASS: return device::UsbDeviceHandle::CLASS; - case device::usb::CONTROL_TRANSFER_TYPE_VENDOR: + case device::usb::ControlTransferType::VENDOR: return device::UsbDeviceHandle::VENDOR; - case device::usb::CONTROL_TRANSFER_TYPE_RESERVED: + case device::usb::ControlTransferType::RESERVED: return device::UsbDeviceHandle::RESERVED; default: NOTREACHED(); @@ -99,13 +99,13 @@ device::usb::ControlTransferRecipient>:: Convert(const device::usb::ControlTransferRecipient& recipient) { switch (recipient) { - case device::usb::CONTROL_TRANSFER_RECIPIENT_DEVICE: + case device::usb::ControlTransferRecipient::DEVICE: return device::UsbDeviceHandle::DEVICE; - case device::usb::CONTROL_TRANSFER_RECIPIENT_INTERFACE: + case device::usb::ControlTransferRecipient::INTERFACE: return device::UsbDeviceHandle::INTERFACE; - case device::usb::CONTROL_TRANSFER_RECIPIENT_ENDPOINT: + case device::usb::ControlTransferRecipient::ENDPOINT: return device::UsbDeviceHandle::ENDPOINT; - case device::usb::CONTROL_TRANSFER_RECIPIENT_OTHER: + case device::usb::ControlTransferRecipient::OTHER: return device::UsbDeviceHandle::OTHER; default: NOTREACHED(); @@ -119,17 +119,17 @@ const device::UsbTransferType& type) { switch (type) { case device::USB_TRANSFER_ISOCHRONOUS: - return device::usb::ENDPOINT_TYPE_ISOCHRONOUS; + return device::usb::EndpointType::ISOCHRONOUS; case device::USB_TRANSFER_BULK: - return device::usb::ENDPOINT_TYPE_BULK; + return device::usb::EndpointType::BULK; case device::USB_TRANSFER_INTERRUPT: - return device::usb::ENDPOINT_TYPE_INTERRUPT; + return device::usb::EndpointType::INTERRUPT; // Note that we do not expose control transfer in the public interface // because control endpoints are implied rather than explicitly enumerated // there. default: NOTREACHED(); - return device::usb::ENDPOINT_TYPE_BULK; + return device::usb::EndpointType::BULK; } }
diff --git a/device/nfc/nfc.mojom b/device/nfc/nfc.mojom index 72b3e9e..6ba8b7a1a 100644 --- a/device/nfc/nfc.mojom +++ b/device/nfc/nfc.mojom
@@ -21,7 +21,7 @@ TEXT, URL, JSON, - OPAQUE + OPAQUE_RECORD }; enum NFCPushTarget {
diff --git a/device/serial/buffer.cc b/device/serial/buffer.cc index 2475e016..c6eeea2 100644 --- a/device/serial/buffer.cc +++ b/device/serial/buffer.cc
@@ -30,7 +30,7 @@ } void SendBuffer::Done(uint32_t bytes_read) { - callback_.Run(bytes_read, device::serial::SEND_ERROR_NONE); + callback_.Run(bytes_read, device::serial::SendError::NONE); } void SendBuffer::DoneWithError(uint32_t bytes_read, int32_t error) { @@ -54,7 +54,7 @@ } void ReceiveBuffer::Done(uint32_t bytes_written) { - callback_.Run(bytes_written, device::serial::RECEIVE_ERROR_NONE); + callback_.Run(bytes_written, device::serial::ReceiveError::NONE); } void ReceiveBuffer::DoneWithError(uint32_t bytes_written, int32_t error) {
diff --git a/device/serial/serial_connection.cc b/device/serial/serial_connection.cc index 249b892..9b88c9d0 100644 --- a/device/serial/serial_connection.cc +++ b/device/serial/serial_connection.cc
@@ -35,8 +35,8 @@ SerialConnection::~SerialConnection() { receiver_->ShutDown(); sender_->ShutDown(); - io_handler_->CancelRead(serial::RECEIVE_ERROR_DISCONNECTED); - io_handler_->CancelWrite(serial::SEND_ERROR_DISCONNECTED); + io_handler_->CancelRead(serial::ReceiveError::DISCONNECTED); + io_handler_->CancelWrite(serial::SendError::DISCONNECTED); } void SerialConnection::GetInfo( @@ -47,7 +47,7 @@ void SerialConnection::SetOptions(serial::ConnectionOptionsPtr options, const mojo::Callback<void(bool)>& callback) { callback.Run(io_handler_->ConfigurePort(*options)); - io_handler_->CancelRead(device::serial::RECEIVE_ERROR_NONE); + io_handler_->CancelRead(device::serial::ReceiveError::NONE); } void SerialConnection::SetControlSignals(
diff --git a/device/serial/serial_connection_factory.cc b/device/serial/serial_connection_factory.cc index d167a78..8088a7e 100644 --- a/device/serial/serial_connection_factory.cc +++ b/device/serial/serial_connection_factory.cc
@@ -18,12 +18,12 @@ void FillDefaultConnectionOptions(serial::ConnectionOptions* options) { if (!options->bitrate) options->bitrate = 9600; - if (options->data_bits == serial::DATA_BITS_NONE) - options->data_bits = serial::DATA_BITS_EIGHT; - if (options->stop_bits == serial::STOP_BITS_NONE) - options->stop_bits = serial::STOP_BITS_ONE; - if (options->parity_bit == serial::PARITY_BIT_NONE) - options->parity_bit = serial::PARITY_BIT_NO; + if (options->data_bits == serial::DataBits::NONE) + options->data_bits = serial::DataBits::EIGHT; + if (options->stop_bits == serial::StopBits::NONE) + options->stop_bits = serial::StopBits::ONE; + if (options->parity_bit == serial::ParityBit::NONE) + options->parity_bit = serial::ParityBit::NO; if (!options->has_cts_flow_control) { options->has_cts_flow_control = true; options->cts_flow_control = false;
diff --git a/device/serial/serial_connection_unittest.cc b/device/serial/serial_connection_unittest.cc index c310755..3d5f51e 100644 --- a/device/serial/serial_connection_unittest.cc +++ b/device/serial/serial_connection_unittest.cc
@@ -61,8 +61,8 @@ : connected_(false), success_(false), bytes_sent_(0), - send_error_(serial::SEND_ERROR_NONE), - receive_error_(serial::RECEIVE_ERROR_NONE), + send_error_(serial::SendError::NONE), + receive_error_(serial::ReceiveError::NONE), expected_event_(EVENT_NONE) {} void SetUp() override { @@ -85,11 +85,12 @@ service->Connect("device", serial::ConnectionOptions::New(), mojo::GetProxy(&connection_), mojo::GetProxy(&sink), mojo::GetProxy(&source), std::move(source_client)); - sender_.reset(new DataSender(std::move(sink), kBufferSize, - serial::SEND_ERROR_DISCONNECTED)); - receiver_ = - new DataReceiver(std::move(source), std::move(source_client_request), - kBufferSize, serial::RECEIVE_ERROR_DISCONNECTED); + sender_.reset( + new DataSender(std::move(sink), kBufferSize, + static_cast<int32_t>(serial::SendError::DISCONNECTED))); + receiver_ = new DataReceiver( + std::move(source), std::move(source_client_request), kBufferSize, + static_cast<int32_t>(serial::ReceiveError::DISCONNECTED)); connection_.set_connection_error_handler(base::Bind( &SerialConnectionTest::OnConnectionError, base::Unretained(this))); connection_->GetInfo( @@ -152,7 +153,7 @@ void OnDataSent(uint32_t bytes_sent) { bytes_sent_ += bytes_sent; - send_error_ = serial::SEND_ERROR_NONE; + send_error_ = serial::SendError::NONE; EventReceived(EVENT_DATA_SENT); } @@ -165,7 +166,7 @@ void OnDataReceived(scoped_ptr<ReadOnlyBuffer> buffer) { data_received_ += std::string(buffer->GetData(), buffer->GetSize()); buffer->Done(buffer->GetSize()); - receive_error_ = serial::RECEIVE_ERROR_NONE; + receive_error_ = serial::ReceiveError::NONE; EventReceived(EVENT_DATA_RECEIVED); } @@ -207,16 +208,16 @@ // |info_| is filled in during SetUp(). ASSERT_TRUE(info_); EXPECT_EQ(9600u, info_->bitrate); - EXPECT_EQ(serial::DATA_BITS_EIGHT, info_->data_bits); - EXPECT_EQ(serial::PARITY_BIT_NO, info_->parity_bit); - EXPECT_EQ(serial::STOP_BITS_ONE, info_->stop_bits); + EXPECT_EQ(serial::DataBits::EIGHT, info_->data_bits); + EXPECT_EQ(serial::ParityBit::NO, info_->parity_bit); + EXPECT_EQ(serial::StopBits::ONE, info_->stop_bits); EXPECT_FALSE(info_->cts_flow_control); } TEST_F(SerialConnectionTest, SetOptions) { serial::ConnectionOptionsPtr options(serial::ConnectionOptions::New()); options->bitrate = 12345; - options->data_bits = serial::DATA_BITS_SEVEN; + options->data_bits = serial::DataBits::SEVEN; options->has_cts_flow_control = true; options->cts_flow_control = true; connection_->SetOptions( @@ -227,9 +228,9 @@ ASSERT_TRUE(success_); serial::ConnectionInfo* info = io_handler_->connection_info(); EXPECT_EQ(12345u, info->bitrate); - EXPECT_EQ(serial::DATA_BITS_SEVEN, info->data_bits); - EXPECT_EQ(serial::PARITY_BIT_NO, info->parity_bit); - EXPECT_EQ(serial::STOP_BITS_ONE, info->stop_bits); + EXPECT_EQ(serial::DataBits::SEVEN, info->data_bits); + EXPECT_EQ(serial::ParityBit::NO, info->parity_bit); + EXPECT_EQ(serial::StopBits::ONE, info->stop_bits); EXPECT_TRUE(info->cts_flow_control); } @@ -280,7 +281,7 @@ io_handler_->set_send_callback(base::Bind(base::DoNothing)); ASSERT_NO_FATAL_FAILURE(Send("data")); WaitForEvent(EVENT_SEND_ERROR); - EXPECT_EQ(serial::SEND_ERROR_DISCONNECTED, send_error_); + EXPECT_EQ(serial::SendError::DISCONNECTED, send_error_); EXPECT_EQ(0, bytes_sent_); EXPECT_TRUE(io_handler_->HasOneRef()); } @@ -289,7 +290,7 @@ connection_.reset(); ASSERT_NO_FATAL_FAILURE(Receive()); WaitForEvent(EVENT_RECEIVE_ERROR); - EXPECT_EQ(serial::RECEIVE_ERROR_DISCONNECTED, receive_error_); + EXPECT_EQ(serial::ReceiveError::DISCONNECTED, receive_error_); EXPECT_EQ("", data_received_); EXPECT_TRUE(io_handler_->HasOneRef()); } @@ -297,12 +298,12 @@ TEST_F(SerialConnectionTest, Echo) { ASSERT_NO_FATAL_FAILURE(Send("data")); WaitForEvent(EVENT_DATA_SENT); - EXPECT_EQ(serial::SEND_ERROR_NONE, send_error_); + EXPECT_EQ(serial::SendError::NONE, send_error_); EXPECT_EQ(4, bytes_sent_); ASSERT_NO_FATAL_FAILURE(Receive()); WaitForEvent(EVENT_DATA_RECEIVED); EXPECT_EQ("data", data_received_); - EXPECT_EQ(serial::RECEIVE_ERROR_NONE, receive_error_); + EXPECT_EQ(serial::ReceiveError::NONE, receive_error_); } TEST_F(SerialConnectionTest, Cancel) { @@ -317,22 +318,22 @@ WaitForEvent(EVENT_DATA_AT_IO_HANDLER); EXPECT_EQ(0, bytes_sent_); - ASSERT_TRUE(sender_->Cancel(serial::SEND_ERROR_TIMEOUT, - base::Bind(&SerialConnectionTest::EventReceived, - base::Unretained(this), - EVENT_CANCEL_COMPLETE))); + ASSERT_TRUE(sender_->Cancel( + static_cast<int32_t>(serial::SendError::TIMEOUT), + base::Bind(&SerialConnectionTest::EventReceived, base::Unretained(this), + EVENT_CANCEL_COMPLETE))); WaitForEvent(EVENT_CANCEL_COMPLETE); - EXPECT_EQ(serial::SEND_ERROR_TIMEOUT, send_error_); + EXPECT_EQ(serial::SendError::TIMEOUT, send_error_); ASSERT_NO_FATAL_FAILURE(Send("data")); WaitForEvent(EVENT_DATA_SENT); - EXPECT_EQ(serial::SEND_ERROR_NONE, send_error_); + EXPECT_EQ(serial::SendError::NONE, send_error_); EXPECT_EQ(4, bytes_sent_); ASSERT_NO_FATAL_FAILURE(Receive()); WaitForEvent(EVENT_DATA_RECEIVED); EXPECT_EQ("data", data_received_); - EXPECT_EQ(serial::RECEIVE_ERROR_NONE, receive_error_); + EXPECT_EQ(serial::ReceiveError::NONE, receive_error_); } } // namespace device
diff --git a/device/serial/serial_io_handler.cc b/device/serial/serial_io_handler.cc index ae63dab..35b41f7f 100644 --- a/device/serial/serial_io_handler.cc +++ b/device/serial/serial_io_handler.cc
@@ -26,9 +26,9 @@ : file_thread_task_runner_(file_thread_task_runner), ui_thread_task_runner_(ui_thread_task_runner) { options_.bitrate = 9600; - options_.data_bits = serial::DATA_BITS_EIGHT; - options_.parity_bit = serial::PARITY_BIT_NO; - options_.stop_bits = serial::STOP_BITS_ONE; + options_.data_bits = serial::DataBits::EIGHT; + options_.parity_bit = serial::ParityBit::NO; + options_.stop_bits = serial::StopBits::ONE; options_.cts_flow_control = false; options_.has_cts_flow_control = true; } @@ -100,13 +100,13 @@ if (options.bitrate) { options_.bitrate = options.bitrate; } - if (options.data_bits != serial::DATA_BITS_NONE) { + if (options.data_bits != serial::DataBits::NONE) { options_.data_bits = options.data_bits; } - if (options.parity_bit != serial::PARITY_BIT_NONE) { + if (options.parity_bit != serial::ParityBit::NONE) { options_.parity_bit = options.parity_bit; } - if (options.stop_bits != serial::STOP_BITS_NONE) { + if (options.stop_bits != serial::StopBits::NONE) { options_.stop_bits = options.stop_bits; } if (options.has_cts_flow_control) { @@ -200,10 +200,10 @@ DCHECK(IsReadPending()); scoped_ptr<WritableBuffer> pending_read_buffer = std::move(pending_read_buffer_); - if (error == serial::RECEIVE_ERROR_NONE) { + if (error == serial::ReceiveError::NONE) { pending_read_buffer->Done(bytes_read); } else { - pending_read_buffer->DoneWithError(bytes_read, error); + pending_read_buffer->DoneWithError(bytes_read, static_cast<int32_t>(error)); } Release(); } @@ -214,10 +214,11 @@ DCHECK(IsWritePending()); scoped_ptr<ReadOnlyBuffer> pending_write_buffer = std::move(pending_write_buffer_); - if (error == serial::SEND_ERROR_NONE) { + if (error == serial::SendError::NONE) { pending_write_buffer->Done(bytes_written); } else { - pending_write_buffer->DoneWithError(bytes_written, error); + pending_write_buffer->DoneWithError(bytes_written, + static_cast<int32_t>(error)); } Release(); }
diff --git a/device/serial/serial_io_handler_posix.cc b/device/serial/serial_io_handler_posix.cc index 45385e9..158c374 100644 --- a/device/serial/serial_io_handler_posix.cc +++ b/device/serial/serial_io_handler_posix.cc
@@ -199,28 +199,28 @@ #endif } - DCHECK(options().data_bits != serial::DATA_BITS_NONE); + DCHECK(options().data_bits != serial::DataBits::NONE); config.c_cflag &= ~CSIZE; switch (options().data_bits) { - case serial::DATA_BITS_SEVEN: + case serial::DataBits::SEVEN: config.c_cflag |= CS7; break; - case serial::DATA_BITS_EIGHT: + case serial::DataBits::EIGHT: default: config.c_cflag |= CS8; break; } - DCHECK(options().parity_bit != serial::PARITY_BIT_NONE); + DCHECK(options().parity_bit != serial::ParityBit::NONE); switch (options().parity_bit) { - case serial::PARITY_BIT_EVEN: + case serial::ParityBit::EVEN: config.c_cflag |= PARENB; config.c_cflag &= ~PARODD; break; - case serial::PARITY_BIT_ODD: + case serial::ParityBit::ODD: config.c_cflag |= (PARODD | PARENB); break; - case serial::PARITY_BIT_NO: + case serial::ParityBit::NO: default: config.c_cflag &= ~(PARODD | PARENB); break; @@ -239,12 +239,12 @@ parity_check_enabled_ = false; } - DCHECK(options().stop_bits != serial::STOP_BITS_NONE); + DCHECK(options().stop_bits != serial::StopBits::NONE); switch (options().stop_bits) { - case serial::STOP_BITS_TWO: + case serial::StopBits::TWO: config.c_cflag |= CSTOPB; break; - case serial::STOP_BITS_ONE: + case serial::StopBits::ONE: default: config.c_cflag &= ~CSTOPB; break; @@ -300,12 +300,12 @@ pending_read_buffer_len())); if (bytes_read < 0) { if (errno == ENXIO) { - ReadCompleted(0, serial::RECEIVE_ERROR_DEVICE_LOST); + ReadCompleted(0, serial::ReceiveError::DEVICE_LOST); } else { - ReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR); + ReadCompleted(0, serial::ReceiveError::SYSTEM_ERROR); } } else if (bytes_read == 0) { - ReadCompleted(0, serial::RECEIVE_ERROR_DEVICE_LOST); + ReadCompleted(0, serial::ReceiveError::DEVICE_LOST); } else { bool break_detected = false; bool parity_error_detected = false; @@ -314,11 +314,11 @@ bytes_read, break_detected, parity_error_detected); if (break_detected) { - ReadCompleted(new_bytes_read, serial::RECEIVE_ERROR_BREAK); + ReadCompleted(new_bytes_read, serial::ReceiveError::BREAK); } else if (parity_error_detected) { - ReadCompleted(new_bytes_read, serial::RECEIVE_ERROR_PARITY_ERROR); + ReadCompleted(new_bytes_read, serial::ReceiveError::PARITY_ERROR); } else { - ReadCompleted(new_bytes_read, serial::RECEIVE_ERROR_NONE); + ReadCompleted(new_bytes_read, serial::ReceiveError::NONE); } } } else { @@ -338,9 +338,9 @@ pending_write_buffer(), pending_write_buffer_len())); if (bytes_written < 0) { - WriteCompleted(0, serial::SEND_ERROR_SYSTEM_ERROR); + WriteCompleted(0, serial::SendError::SYSTEM_ERROR); } else { - WriteCompleted(bytes_written, serial::SEND_ERROR_NONE); + WriteCompleted(bytes_written, serial::SendError::NONE); } } else { // Stop watching the fd if we get notifications with no pending @@ -463,20 +463,20 @@ #endif if ((config.c_cflag & CSIZE) == CS7) { - info->data_bits = serial::DATA_BITS_SEVEN; + info->data_bits = serial::DataBits::SEVEN; } else if ((config.c_cflag & CSIZE) == CS8) { - info->data_bits = serial::DATA_BITS_EIGHT; + info->data_bits = serial::DataBits::EIGHT; } else { - info->data_bits = serial::DATA_BITS_NONE; + info->data_bits = serial::DataBits::NONE; } if (config.c_cflag & PARENB) { - info->parity_bit = (config.c_cflag & PARODD) ? serial::PARITY_BIT_ODD - : serial::PARITY_BIT_EVEN; + info->parity_bit = (config.c_cflag & PARODD) ? serial::ParityBit::ODD + : serial::ParityBit::EVEN; } else { - info->parity_bit = serial::PARITY_BIT_NO; + info->parity_bit = serial::ParityBit::NO; } info->stop_bits = - (config.c_cflag & CSTOPB) ? serial::STOP_BITS_TWO : serial::STOP_BITS_ONE; + (config.c_cflag & CSTOPB) ? serial::StopBits::TWO : serial::StopBits::ONE; info->cts_flow_control = (config.c_cflag & CRTSCTS) != 0; return info; }
diff --git a/device/serial/serial_io_handler_win.cc b/device/serial/serial_io_handler_win.cc index dec9450..4c1010f 100644 --- a/device/serial/serial_io_handler_win.cc +++ b/device/serial/serial_io_handler_win.cc
@@ -49,9 +49,9 @@ int DataBitsEnumToConstant(serial::DataBits data_bits) { switch (data_bits) { - case serial::DATA_BITS_SEVEN: + case serial::DataBits::SEVEN: return 7; - case serial::DATA_BITS_EIGHT: + case serial::DataBits::EIGHT: default: return 8; } @@ -59,11 +59,11 @@ int ParityBitEnumToConstant(serial::ParityBit parity_bit) { switch (parity_bit) { - case serial::PARITY_BIT_EVEN: + case serial::ParityBit::EVEN: return EVENPARITY; - case serial::PARITY_BIT_ODD: + case serial::ParityBit::ODD: return ODDPARITY; - case serial::PARITY_BIT_NO: + case serial::ParityBit::NO: default: return NOPARITY; } @@ -71,9 +71,9 @@ int StopBitsEnumToConstant(serial::StopBits stop_bits) { switch (stop_bits) { - case serial::STOP_BITS_TWO: + case serial::StopBits::TWO: return TWOSTOPBITS; - case serial::STOP_BITS_ONE: + case serial::StopBits::ONE: default: return ONESTOPBIT; } @@ -110,32 +110,32 @@ serial::DataBits DataBitsConstantToEnum(int data_bits) { switch (data_bits) { case 7: - return serial::DATA_BITS_SEVEN; + return serial::DataBits::SEVEN; case 8: default: - return serial::DATA_BITS_EIGHT; + return serial::DataBits::EIGHT; } } serial::ParityBit ParityBitConstantToEnum(int parity_bit) { switch (parity_bit) { case EVENPARITY: - return serial::PARITY_BIT_EVEN; + return serial::ParityBit::EVEN; case ODDPARITY: - return serial::PARITY_BIT_ODD; + return serial::ParityBit::ODD; case NOPARITY: default: - return serial::PARITY_BIT_NO; + return serial::ParityBit::NO; } } serial::StopBits StopBitsConstantToEnum(int stop_bits) { switch (stop_bits) { case TWOSTOPBITS: - return serial::STOP_BITS_TWO; + return serial::StopBits::TWO; case ONESTOPBIT: default: - return serial::STOP_BITS_ONE; + return serial::StopBits::ONE; } } @@ -227,7 +227,7 @@ } if (port() == com_port) - CancelRead(serial::RECEIVE_ERROR_DEVICE_LOST); + CancelRead(serial::ReceiveError::DEVICE_LOST); } bool SerialIoHandlerWin::PostOpen() { @@ -285,7 +285,7 @@ file().GetPlatformFile(), &event_mask_, &comm_context_->overlapped); if (!ok && GetLastError() != ERROR_IO_PENDING) { VPLOG(1) << "Failed to receive serial event"; - QueueReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR); + QueueReadCompleted(0, serial::ReceiveError::SYSTEM_ERROR); } is_comm_pending_ = true; } @@ -302,7 +302,7 @@ &write_context_->overlapped); if (!ok && GetLastError() != ERROR_IO_PENDING) { VPLOG(1) << "Write failed"; - QueueWriteCompleted(0, serial::SEND_ERROR_SYSTEM_ERROR); + QueueWriteCompleted(0, serial::SendError::SYSTEM_ERROR); } } @@ -339,13 +339,13 @@ DCHECK(options().bitrate); config.BaudRate = BitrateToSpeedConstant(options().bitrate); - DCHECK(options().data_bits != serial::DATA_BITS_NONE); + DCHECK(options().data_bits != serial::DataBits::NONE); config.ByteSize = DataBitsEnumToConstant(options().data_bits); - DCHECK(options().parity_bit != serial::PARITY_BIT_NONE); + DCHECK(options().parity_bit != serial::ParityBit::NONE); config.Parity = ParityBitEnumToConstant(options().parity_bit); - DCHECK(options().stop_bits != serial::STOP_BITS_NONE); + DCHECK(options().stop_bits != serial::StopBits::NONE); config.StopBits = StopBitsEnumToConstant(options().stop_bits); DCHECK(options().has_cts_flow_control); @@ -388,17 +388,17 @@ if (!ClearCommError(file().GetPlatformFile(), &errors, &status) || errors != 0) { if (errors & CE_BREAK) { - ReadCompleted(0, serial::RECEIVE_ERROR_BREAK); + ReadCompleted(0, serial::ReceiveError::BREAK); } else if (errors & CE_FRAME) { - ReadCompleted(0, serial::RECEIVE_ERROR_FRAME_ERROR); + ReadCompleted(0, serial::ReceiveError::FRAME_ERROR); } else if (errors & CE_OVERRUN) { - ReadCompleted(0, serial::RECEIVE_ERROR_OVERRUN); + ReadCompleted(0, serial::ReceiveError::OVERRUN); } else if (errors & CE_RXOVER) { - ReadCompleted(0, serial::RECEIVE_ERROR_BUFFER_OVERFLOW); + ReadCompleted(0, serial::ReceiveError::BUFFER_OVERFLOW); } else if (errors & CE_RXPARITY) { - ReadCompleted(0, serial::RECEIVE_ERROR_PARITY_ERROR); + ReadCompleted(0, serial::ReceiveError::PARITY_ERROR); } else { - ReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR); + ReadCompleted(0, serial::ReceiveError::SYSTEM_ERROR); } return; } @@ -406,7 +406,7 @@ if (read_canceled()) { ReadCompleted(bytes_transferred, read_cancel_reason()); } else if (error != ERROR_SUCCESS && error != ERROR_OPERATION_ABORTED) { - ReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR); + ReadCompleted(0, serial::ReceiveError::SYSTEM_ERROR); } else if (pending_read_buffer()) { BOOL ok = ::ReadFile(file().GetPlatformFile(), pending_read_buffer(), @@ -415,26 +415,26 @@ &read_context_->overlapped); if (!ok && GetLastError() != ERROR_IO_PENDING) { VPLOG(1) << "Read failed"; - ReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR); + ReadCompleted(0, serial::ReceiveError::SYSTEM_ERROR); } } } else if (context == read_context_.get()) { if (read_canceled()) { ReadCompleted(bytes_transferred, read_cancel_reason()); } else if (error != ERROR_SUCCESS && error != ERROR_OPERATION_ABORTED) { - ReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR); + ReadCompleted(0, serial::ReceiveError::SYSTEM_ERROR); } else { ReadCompleted(bytes_transferred, error == ERROR_SUCCESS - ? serial::RECEIVE_ERROR_NONE - : serial::RECEIVE_ERROR_SYSTEM_ERROR); + ? serial::ReceiveError::NONE + : serial::ReceiveError::SYSTEM_ERROR); } } else if (context == write_context_.get()) { DCHECK(pending_write_buffer()); if (write_canceled()) { WriteCompleted(0, write_cancel_reason()); } else if (error != ERROR_SUCCESS && error != ERROR_OPERATION_ABORTED) { - WriteCompleted(0, serial::SEND_ERROR_SYSTEM_ERROR); + WriteCompleted(0, serial::SendError::SYSTEM_ERROR); if (error == ERROR_GEN_FAILURE && IsReadPending()) { // For devices using drivers such as FTDI, CP2xxx, when device is // disconnected, the context is comm_context_ and the error is @@ -445,12 +445,12 @@ // signal, also need to generate a read error signal // serial::OnReceiveError which will notify the app about the // disconnection. - CancelRead(serial::RECEIVE_ERROR_SYSTEM_ERROR); + CancelRead(serial::ReceiveError::SYSTEM_ERROR); } } else { - WriteCompleted(bytes_transferred, - error == ERROR_SUCCESS ? serial::SEND_ERROR_NONE - : serial::SEND_ERROR_SYSTEM_ERROR); + WriteCompleted(bytes_transferred, error == ERROR_SUCCESS + ? serial::SendError::NONE + : serial::SendError::SYSTEM_ERROR); } } else { NOTREACHED() << "Invalid IOContext";
diff --git a/device/serial/test_serial_io_handler.cc b/device/serial/test_serial_io_handler.cc index b112462b4..d0b4ee6 100644 --- a/device/serial/test_serial_io_handler.cc +++ b/device/serial/test_serial_io_handler.cc
@@ -45,7 +45,7 @@ std::min(buffer_.size(), static_cast<size_t>(pending_read_buffer_len())); memcpy(pending_read_buffer(), buffer_.c_str(), num_bytes); buffer_ = buffer_.substr(num_bytes); - ReadCompleted(static_cast<uint32_t>(num_bytes), serial::RECEIVE_ERROR_NONE); + ReadCompleted(static_cast<uint32_t>(num_bytes), serial::ReceiveError::NONE); } void TestSerialIoHandler::CancelReadImpl() { @@ -60,7 +60,7 @@ return; } buffer_ += std::string(pending_write_buffer(), pending_write_buffer_len()); - WriteCompleted(pending_write_buffer_len(), serial::SEND_ERROR_NONE); + WriteCompleted(pending_write_buffer_len(), serial::SendError::NONE); if (pending_read_buffer()) ReadImpl(); }
diff --git a/extensions/browser/api/web_contents_capture_client.cc b/extensions/browser/api/capture_web_contents_function.cc similarity index 70% rename from extensions/browser/api/web_contents_capture_client.cc rename to extensions/browser/api/capture_web_contents_function.cc index 7a38202..e10842d 100644 --- a/extensions/browser/api/web_contents_capture_client.cc +++ b/extensions/browser/api/capture_web_contents_function.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "extensions/browser/api/web_contents_capture_client.h" +#include "extensions/browser/api/capture_web_contents_function.h" #include "base/base64.h" #include "base/strings/stringprintf.h" @@ -25,16 +25,30 @@ using api::extension_types::ImageDetails; -bool WebContentsCaptureClient::CaptureAsync( - WebContents* web_contents, - const ImageDetails* image_details, - const content::ReadbackRequestCallback callback) { - if (!web_contents) - return false; +bool CaptureWebContentsFunction::HasPermission() { + return true; +} + +bool CaptureWebContentsFunction::RunAsync() { + EXTENSION_FUNCTION_VALIDATE(args_); + + context_id_ = extension_misc::kCurrentWindowId; + args_->GetInteger(0, &context_id_); + + scoped_ptr<ImageDetails> image_details; + if (args_->GetSize() > 1) { + base::Value* spec = NULL; + EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &spec) && spec); + image_details = ImageDetails::FromValue(*spec); + } if (!IsScreenshotEnabled()) return false; + WebContents* contents = GetWebContentsForID(context_id_); + if (!contents) + return false; + // The default format and quality setting used when encoding jpegs. const api::extension_types::ImageFormat kDefaultFormat = api::extension_types::IMAGE_FORMAT_JPEG; @@ -51,7 +65,7 @@ } // TODO(miu): Account for fullscreen render widget? http://crbug.com/419878 - RenderWidgetHostView* const view = web_contents->GetRenderWidgetHostView(); + RenderWidgetHostView* const view = contents->GetRenderWidgetHostView(); RenderWidgetHost* const host = view ? view->GetRenderWidgetHost() : nullptr; if (!view || !host) { OnCaptureFailure(FAILURE_REASON_VIEW_INVISIBLE); @@ -70,27 +84,26 @@ if (scale > 1.0f) bitmap_size = gfx::ScaleToCeiledSize(view_size, scale); - host->CopyFromBackingStore(gfx::Rect(view_size), bitmap_size, callback, - kN32_SkColorType); + host->CopyFromBackingStore( + gfx::Rect(view_size), + bitmap_size, + base::Bind(&CaptureWebContentsFunction::CopyFromBackingStoreComplete, + this), + kN32_SkColorType); return true; } -void WebContentsCaptureClient::CopyFromBackingStoreComplete( +void CaptureWebContentsFunction::CopyFromBackingStoreComplete( const SkBitmap& bitmap, content::ReadbackResponse response) { if (response == content::READBACK_SUCCESS) { OnCaptureSuccess(bitmap); return; } - // TODO(wjmaclean): Improve error reporting. Why aren't we passing more - // information here? OnCaptureFailure(FAILURE_REASON_UNKNOWN); } -// TODO(wjmaclean) can this be static? -bool WebContentsCaptureClient::EncodeBitmap(const SkBitmap& bitmap, - std::string* base64_result) { - DCHECK(base64_result); +void CaptureWebContentsFunction::OnCaptureSuccess(const SkBitmap& bitmap) { std::vector<unsigned char> data; SkAutoLockPixels screen_capture_lock(bitmap); bool encoded = false; @@ -99,8 +112,12 @@ case api::extension_types::IMAGE_FORMAT_JPEG: encoded = gfx::JPEGCodec::Encode( reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), - gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(), - static_cast<int>(bitmap.rowBytes()), image_quality_, &data); + gfx::JPEGCodec::FORMAT_SkBitmap, + bitmap.width(), + bitmap.height(), + static_cast<int>(bitmap.rowBytes()), + image_quality_, + &data); mime_type = kMimeTypeJpeg; break; case api::extension_types::IMAGE_FORMAT_PNG: @@ -114,17 +131,20 @@ NOTREACHED() << "Invalid image format."; } - if (!encoded) - return false; + if (!encoded) { + OnCaptureFailure(FAILURE_REASON_ENCODING_FAILED); + return; + } + std::string base64_result; base::StringPiece stream_as_string(reinterpret_cast<const char*>(data.data()), data.size()); - base::Base64Encode(stream_as_string, base64_result); - base64_result->insert( + base::Base64Encode(stream_as_string, &base64_result); + base64_result.insert( 0, base::StringPrintf("data:%s;base64,", mime_type.c_str())); - - return true; + SetResult(new base::StringValue(base64_result)); + SendResponse(true); } } // namespace extensions
diff --git a/extensions/browser/api/capture_web_contents_function.h b/extensions/browser/api/capture_web_contents_function.h new file mode 100644 index 0000000..53f78f7 --- /dev/null +++ b/extensions/browser/api/capture_web_contents_function.h
@@ -0,0 +1,67 @@ +// Copyright 2013 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 EXTENSIONS_BROWSER_API_CAPTURE_WEB_CONTENTS_FUNCTION_H_ +#define EXTENSIONS_BROWSER_API_CAPTURE_WEB_CONTENTS_FUNCTION_H_ + +#include "base/macros.h" +#include "content/public/browser/readback_types.h" +#include "extensions/browser/extension_function.h" +#include "extensions/common/api/extension_types.h" + +class SkBitmap; + +namespace content { +class WebContents; +} + +namespace extensions { + +// Base class for capturing visibile area of a WebContents. +// This is used by both webview.captureVisibleRegion and tabs.captureVisibleTab. +class CaptureWebContentsFunction : public AsyncExtensionFunction { + public: + CaptureWebContentsFunction() {} + + protected: + ~CaptureWebContentsFunction() override {} + + // ExtensionFunction implementation. + bool HasPermission() override; + bool RunAsync() override; + + virtual bool IsScreenshotEnabled() = 0; + virtual content::WebContents* GetWebContentsForID(int context_id) = 0; + + enum FailureReason { + FAILURE_REASON_UNKNOWN, + FAILURE_REASON_ENCODING_FAILED, + FAILURE_REASON_VIEW_INVISIBLE + }; + virtual void OnCaptureFailure(FailureReason reason) = 0; + + private: + + void CopyFromBackingStoreComplete(const SkBitmap& bitmap, + content::ReadbackResponse response); + void OnCaptureSuccess(const SkBitmap& bitmap); + + // |context_id_| is the ID used to find the relevant WebContents. In the + // |tabs.captureVisibleTab()| api, this represents the window-id, and in the + // |webview.captureVisibleRegion()| api, this represents the instance-id of + // the guest. + int context_id_; + + // The format (JPEG vs PNG) of the resulting image. Set in RunAsync(). + api::extension_types::ImageFormat image_format_; + + // Quality setting to use when encoding jpegs. Set in RunAsync(). + int image_quality_; + + DISALLOW_COPY_AND_ASSIGN(CaptureWebContentsFunction); +}; + +} // namespace extensions + +#endif // EXTENSIONS_BROWSER_API_CAPTURE_WEB_CONTENTS_FUNCTION_H_
diff --git a/extensions/browser/api/display_source/display_source_apitest.cc b/extensions/browser/api/display_source/display_source_apitest.cc index 6a949a5..dc7e9ef 100644 --- a/extensions/browser/api/display_source/display_source_apitest.cc +++ b/extensions/browser/api/display_source/display_source_apitest.cc
@@ -36,14 +36,14 @@ DisplaySourceSinkInfoList last_found_sinks() const override { return sinks_; } const Connection* connection() const override { return nullptr; } void GetAvailableSinks(const SinkInfoListCallback& sinks_callback, - const FailureCallback& failure_callback) override { + const StringCallback& failure_callback) override { AddSink(CreateSinkInfoPtr(1, "sink 1", SINK_STATE_DISCONNECTED)); sinks_callback.Run(sinks_); } void RequestAuthentication(int sink_id, const AuthInfoCallback& auth_info_callback, - const FailureCallback& failure_callback) override { + const StringCallback& failure_callback) override { DisplaySourceAuthInfo info; info.method = AUTHENTICATION_METHOD_PBC; auth_info_callback.Run(info); @@ -51,9 +51,9 @@ void Connect(int sink_id, const DisplaySourceAuthInfo& auth_info, - const FailureCallback& failure_callback) override {} + const StringCallback& failure_callback) override {} - void Disconnect(const FailureCallback& failure_callback) override {} + void Disconnect(const StringCallback& failure_callback) override {} void StartWatchingAvailableSinks() override { AddSink(CreateSinkInfoPtr(2, "sink 2", SINK_STATE_DISCONNECTED));
diff --git a/extensions/browser/api/display_source/display_source_connection_delegate.h b/extensions/browser/api/display_source/display_source_connection_delegate.h index dbd4553..1133cdf 100644 --- a/extensions/browser/api/display_source/display_source_connection_delegate.h +++ b/extensions/browser/api/display_source/display_source_connection_delegate.h
@@ -15,25 +15,45 @@ using DisplaySourceSinkInfoPtr = linked_ptr<api::display_source::SinkInfo>; using DisplaySourceSinkInfoList = std::vector<DisplaySourceSinkInfoPtr>; using DisplaySourceAuthInfo = api::display_source::AuthenticationInfo; - +using DisplaySourceErrorType = api::display_source::ErrorType; // The DisplaySourceConnectionDelegate interface should be implemented // to provide sinks search and connection functionality for // 'chrome.displaySource' API. class DisplaySourceConnectionDelegate : public KeyedService { public: using AuthInfoCallback = base::Callback<void(const DisplaySourceAuthInfo&)>; - using FailureCallback = base::Callback<void(const std::string&)>; + using StringCallback = base::Callback<void(const std::string&)>; using SinkInfoListCallback = base::Callback<void(const DisplaySourceSinkInfoList&)>; const static int kInvalidSinkId = -1; - struct Connection { + class Connection { + public: + // Returns a pointer to the connected sink object. The result is + // guaranteed not to be NULL. + virtual DisplaySourceSinkInfoPtr GetConnectedSink() const = 0; + + // Returns the local address of the source. + virtual std::string GetLocalAddress() const = 0; + + // Returns the address of the connected sink. + virtual std::string GetSinkAddress() const = 0; + + // Sends a control message to the connected sink. + // If an error occurs 'Observer::OnConnectionError' is invoked. + virtual void SendMessage(const std::string& message) const = 0; + + // Sets a callback to receive control messages from the connected sink. + // This method should only be called once in the lifetime of each + // Connection object. + // If an error occurs 'Observer::OnConnectionError' is invoked. + virtual void SetMessageReceivedCallback( + const StringCallback& callback) const = 0; + + protected: Connection(); - ~Connection(); - DisplaySourceSinkInfoPtr connected_sink; - std::string local_ip; - std::string sink_ip; + virtual ~Connection(); }; class Observer { @@ -45,6 +65,13 @@ // Also this method is called to reflect current connection updates. virtual void OnSinksUpdated(const DisplaySourceSinkInfoList& sinks) = 0; + // This method is called during the established connection to report + // a transport layer fatal error (which implies that the connection + // becomes broken/disconnected). + virtual void OnConnectionError(int sink_id, + DisplaySourceErrorType type, + const std::string& description) = 0; + protected: virtual ~Observer() {} }; @@ -68,7 +95,7 @@ // Queries the list of currently available sinks. virtual void GetAvailableSinks(const SinkInfoListCallback& sinks_callback, - const FailureCallback& failure_callback) = 0; + const StringCallback& failure_callback) = 0; // Queries the authentication method required by the sink for connection. // If the used authentication method requires authentication data to be @@ -77,17 +104,17 @@ virtual void RequestAuthentication( int sink_id, const AuthInfoCallback& auth_info_callback, - const FailureCallback& failure_callback) = 0; + const StringCallback& failure_callback) = 0; // Connects to a sink by given id and auth info. virtual void Connect(int sink_id, const DisplaySourceAuthInfo& auth_info, - const FailureCallback& failure_callback) = 0; + const StringCallback& failure_callback) = 0; // Disconnects the current connection to sink, the 'failure_callback' // is called if an error has occurred or if there is no established // connection. - virtual void Disconnect(const FailureCallback& failure_callback) = 0; + virtual void Disconnect(const StringCallback& failure_callback) = 0; // Implementation should start watching the available sinks updates. virtual void StartWatchingAvailableSinks() = 0;
diff --git a/extensions/browser/api/display_source/display_source_event_router.h b/extensions/browser/api/display_source/display_source_event_router.h index 6697fe8..97e2e6f 100644 --- a/extensions/browser/api/display_source/display_source_event_router.h +++ b/extensions/browser/api/display_source/display_source_event_router.h
@@ -17,6 +17,9 @@ namespace extensions { // Observe listeners to 'onSinksUpdated' events. +// This class initiates/stops listening for the available sinks +// by the DisplaySourceConnectionDelegate, depending on whether +// there are existing listeners to 'onSinksUpdated' event. class DisplaySourceEventRouter : public KeyedService, public EventRouter::Observer, @@ -39,6 +42,9 @@ // DisplaySourceConnectionDelegate::Observer overrides: void OnSinksUpdated(const DisplaySourceSinkInfoList& sinks) override; + void OnConnectionError(int sink_id, + DisplaySourceErrorType type, + const std::string& description) override {} private: void StartOrStopListeningForSinksChanges();
diff --git a/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.cc b/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.cc index ae3713d..59dfda10 100644 --- a/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.cc +++ b/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.cc
@@ -30,7 +30,7 @@ auto connection = delegate_->connection(); if (connection) - last_connected_sink_ = connection->connected_sink->id; + last_connected_sink_ = connection->GetConnectedSink()->id; } WiFiDisplaySessionServiceImpl::~WiFiDisplaySessionServiceImpl() { @@ -100,13 +100,29 @@ return; } DCHECK(delegate_->connection()); - DCHECK_EQ(own_sink_, delegate_->connection()->connected_sink->id); + DCHECK_EQ(own_sink_, delegate_->connection()->GetConnectedSink()->id); auto on_error = base::Bind(&WiFiDisplaySessionServiceImpl::OnDisconnectFailed, weak_factory_.GetWeakPtr(), own_sink_); delegate_->Disconnect(on_error); } -void WiFiDisplaySessionServiceImpl::SendMessage(const mojo::String& message) {} +void WiFiDisplaySessionServiceImpl::SendMessage(const mojo::String& message) { + if (own_sink_ == DisplaySourceConnectionDelegate::kInvalidSinkId) { + // The connection might drop before this call has arrived. + return; + } + auto connection = delegate_->connection(); + DCHECK(connection); + DCHECK_EQ(own_sink_, connection->GetConnectedSink()->id); + connection->SendMessage(message); +} + +void WiFiDisplaySessionServiceImpl::OnSinkMessage(const std::string& message) { + DCHECK(delegate_->connection()); + DCHECK_NE(own_sink_, DisplaySourceConnectionDelegate::kInvalidSinkId); + DCHECK(client_); + client_->OnMessage(message); +} void WiFiDisplaySessionServiceImpl::OnSinksUpdated( const DisplaySourceSinkInfoList& sinks) { @@ -119,13 +135,28 @@ client_->OnDisconnected(last_connected_sink_); last_connected_sink_ = DisplaySourceConnectionDelegate::kInvalidSinkId; } - if (connection && last_connected_sink_ != connection->connected_sink->id) { - last_connected_sink_ = connection->connected_sink->id; + if (connection && + last_connected_sink_ != connection->GetConnectedSink()->id) { + last_connected_sink_ = connection->GetConnectedSink()->id; if (client_) - client_->OnConnected(last_connected_sink_, connection->local_ip); + client_->OnConnected(last_connected_sink_, connection->GetLocalAddress()); + if (last_connected_sink_ == own_sink_) { + auto on_message = + base::Bind(&WiFiDisplaySessionServiceImpl::OnSinkMessage, + weak_factory_.GetWeakPtr()); + connection->SetMessageReceivedCallback(on_message); + } } } +void WiFiDisplaySessionServiceImpl::OnConnectionError( + int sink_id, + DisplaySourceErrorType type, + const std::string& description) { + DCHECK(client_); + client_->OnError(sink_id, type, description); +} + void WiFiDisplaySessionServiceImpl::OnConnectFailed( int sink_id, const std::string& message) {
diff --git a/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.h b/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.h index 6348b12..e50237c 100644 --- a/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.h +++ b/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.h
@@ -39,14 +39,22 @@ // DisplaySourceConnectionDelegate::Observer overrides. void OnSinksUpdated(const DisplaySourceSinkInfoList& sinks) override; + void OnConnectionError(int sink_id, + DisplaySourceErrorType type, + const std::string& description) override; explicit WiFiDisplaySessionServiceImpl( DisplaySourceConnectionDelegate* delegate, mojo::InterfaceRequest<WiFiDisplaySessionService> request); - void OnConnectFailed(int sink_id, const std::string& message); - void OnDisconnectFailed(int sink_id, const std::string& message); + // Called if a message is received from the connected sink. + void OnSinkMessage(const std::string& message); + // Failure callbacks for Connect and Disconnect methods. + void OnConnectFailed(int sink_id, const std::string& reason); + void OnDisconnectFailed(int sink_id, const std::string& reason); + + // Mojo error callback. void OnClientConnectionError(); mojo::StrongBinding<WiFiDisplaySessionService> binding_;
diff --git a/extensions/browser/api/guest_view/extension_view/extension_view_internal_api.h b/extensions/browser/api/guest_view/extension_view/extension_view_internal_api.h index 1899d42..9e77cbd 100644 --- a/extensions/browser/api/guest_view/extension_view/extension_view_internal_api.h +++ b/extensions/browser/api/guest_view/extension_view/extension_view_internal_api.h
@@ -6,6 +6,7 @@ #define EXTENSIONS_BROWSER_API_EXTENSION_VIEW_EXTENSION_VIEW_INTERNAL_API_H_ #include "base/macros.h" +#include "extensions/browser/api/capture_web_contents_function.h" #include "extensions/browser/api/execute_code_function.h" #include "extensions/browser/extension_function.h" #include "extensions/browser/guest_view/extension_view/extension_view_guest.h"
diff --git a/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc b/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc index 3e3a8ed..bba531d 100644 --- a/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc +++ b/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc
@@ -259,62 +259,6 @@ return RunAsyncSafe(guest); } -bool WebViewInternalCaptureVisibleRegionFunction::RunAsyncSafe( - WebViewGuest* guest) { - using api::extension_types::ImageDetails; - - scoped_ptr<web_view_internal::CaptureVisibleRegion::Params> params( - web_view_internal::CaptureVisibleRegion::Params::Create(*args_)); - EXTENSION_FUNCTION_VALIDATE(params.get()); - - scoped_ptr<ImageDetails> image_details; - if (args_->GetSize() > 1) { - base::Value* spec = NULL; - EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &spec) && spec); - image_details = ImageDetails::FromValue(*spec); - } - - return CaptureAsync(guest->web_contents(), image_details.get(), - base::Bind(&WebViewInternalCaptureVisibleRegionFunction:: - CopyFromBackingStoreComplete, - this)); -} -bool WebViewInternalCaptureVisibleRegionFunction::IsScreenshotEnabled() { - // TODO(wjmaclean): Is it ok to always return true here? - return true; -} - -void WebViewInternalCaptureVisibleRegionFunction::OnCaptureSuccess( - const SkBitmap& bitmap) { - std::string base64_result; - if (!EncodeBitmap(bitmap, &base64_result)) { - OnCaptureFailure(FAILURE_REASON_ENCODING_FAILED); - return; - } - - SetResult(new base::StringValue(base64_result)); - SendResponse(true); -} - -void WebViewInternalCaptureVisibleRegionFunction::OnCaptureFailure( - FailureReason reason) { - const char* reason_description = "internal error"; - switch (reason) { - case FAILURE_REASON_UNKNOWN: - reason_description = "unknown error"; - break; - case FAILURE_REASON_ENCODING_FAILED: - reason_description = "encoding failed"; - break; - case FAILURE_REASON_VIEW_INVISIBLE: - reason_description = "view is invisible"; - break; - } - error_ = ErrorUtils::FormatErrorMessage("Failed to capture webview: *", - reason_description); - SendResponse(false); -} - bool WebViewInternalNavigateFunction::RunAsyncSafe(WebViewGuest* guest) { scoped_ptr<web_view_internal::Navigate::Params> params( web_view_internal::Navigate::Params::Create(*args_));
diff --git a/extensions/browser/api/guest_view/web_view/web_view_internal_api.h b/extensions/browser/api/guest_view/web_view/web_view_internal_api.h index 388491ea..dcdb828 100644 --- a/extensions/browser/api/guest_view/web_view/web_view_internal_api.h +++ b/extensions/browser/api/guest_view/web_view/web_view_internal_api.h
@@ -8,8 +8,8 @@ #include <stdint.h> #include "base/macros.h" +#include "extensions/browser/api/capture_web_contents_function.h" #include "extensions/browser/api/execute_code_function.h" -#include "extensions/browser/api/web_contents_capture_client.h" #include "extensions/browser/extension_function.h" #include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h" #include "extensions/browser/guest_view/web_view/web_view_guest.h" @@ -37,29 +37,6 @@ virtual bool RunAsyncSafe(WebViewGuest* guest) = 0; }; -class WebViewInternalCaptureVisibleRegionFunction - : public WebViewInternalExtensionFunction, - public WebContentsCaptureClient { - public: - DECLARE_EXTENSION_FUNCTION("webViewInternal.captureVisibleRegion", - WEBVIEWINTERNAL_CAPTUREVISIBLEREGION); - WebViewInternalCaptureVisibleRegionFunction() {} - - protected: - ~WebViewInternalCaptureVisibleRegionFunction() override {} - - private: - // WebViewInternalExtensionFunction implementation. - bool RunAsyncSafe(WebViewGuest* guest) override; - - // extensions::WebContentsCaptureClient: - bool IsScreenshotEnabled() override; - void OnCaptureSuccess(const SkBitmap& bitmap) override; - void OnCaptureFailure(FailureReason reason) override; - - DISALLOW_COPY_AND_ASSIGN(WebViewInternalCaptureVisibleRegionFunction); -}; - class WebViewInternalNavigateFunction : public WebViewInternalExtensionFunction { public:
diff --git a/extensions/browser/api/management/management_api.cc b/extensions/browser/api/management/management_api.cc index 2511aee5..e1e72af 100644 --- a/extensions/browser/api/management/management_api.cc +++ b/extensions/browser/api/management/management_api.cc
@@ -107,6 +107,8 @@ info->enabled = registry->enabled_extensions().Contains(info->id); info->offline_enabled = OfflineEnabledInfo::IsOfflineEnabled(&extension); info->version = extension.VersionString(); + if (!extension.version_name().empty()) + info->version_name.reset(new std::string(extension.version_name())); info->description = extension.description(); info->options_url = OptionsPageInfo::GetOptionsPage(&extension).spec(); info->homepage_url.reset(
diff --git a/extensions/browser/api/serial/serial_connection.cc b/extensions/browser/api/serial/serial_connection.cc index cc46b12..6e4cde90 100644 --- a/extensions/browser/api/serial/serial_connection.cc +++ b/extensions/browser/api/serial/serial_connection.cc
@@ -23,15 +23,15 @@ api::serial::SendError ConvertSendErrorFromMojo( device::serial::SendError input) { switch (input) { - case device::serial::SEND_ERROR_NONE: + case device::serial::SendError::NONE: return api::serial::SEND_ERROR_NONE; - case device::serial::SEND_ERROR_DISCONNECTED: + case device::serial::SendError::DISCONNECTED: return api::serial::SEND_ERROR_DISCONNECTED; - case device::serial::SEND_ERROR_PENDING: + case device::serial::SendError::PENDING: return api::serial::SEND_ERROR_PENDING; - case device::serial::SEND_ERROR_TIMEOUT: + case device::serial::SendError::TIMEOUT: return api::serial::SEND_ERROR_TIMEOUT; - case device::serial::SEND_ERROR_SYSTEM_ERROR: + case device::serial::SendError::SYSTEM_ERROR: return api::serial::SEND_ERROR_SYSTEM_ERROR; } return api::serial::SEND_ERROR_NONE; @@ -40,25 +40,25 @@ api::serial::ReceiveError ConvertReceiveErrorFromMojo( device::serial::ReceiveError input) { switch (input) { - case device::serial::RECEIVE_ERROR_NONE: + case device::serial::ReceiveError::NONE: return api::serial::RECEIVE_ERROR_NONE; - case device::serial::RECEIVE_ERROR_DISCONNECTED: + case device::serial::ReceiveError::DISCONNECTED: return api::serial::RECEIVE_ERROR_DISCONNECTED; - case device::serial::RECEIVE_ERROR_TIMEOUT: + case device::serial::ReceiveError::TIMEOUT: return api::serial::RECEIVE_ERROR_TIMEOUT; - case device::serial::RECEIVE_ERROR_DEVICE_LOST: + case device::serial::ReceiveError::DEVICE_LOST: return api::serial::RECEIVE_ERROR_DEVICE_LOST; - case device::serial::RECEIVE_ERROR_BREAK: + case device::serial::ReceiveError::BREAK: return api::serial::RECEIVE_ERROR_BREAK; - case device::serial::RECEIVE_ERROR_FRAME_ERROR: + case device::serial::ReceiveError::FRAME_ERROR: return api::serial::RECEIVE_ERROR_FRAME_ERROR; - case device::serial::RECEIVE_ERROR_OVERRUN: + case device::serial::ReceiveError::OVERRUN: return api::serial::RECEIVE_ERROR_OVERRUN; - case device::serial::RECEIVE_ERROR_BUFFER_OVERFLOW: + case device::serial::ReceiveError::BUFFER_OVERFLOW: return api::serial::RECEIVE_ERROR_BUFFER_OVERFLOW; - case device::serial::RECEIVE_ERROR_PARITY_ERROR: + case device::serial::ReceiveError::PARITY_ERROR: return api::serial::RECEIVE_ERROR_PARITY_ERROR; - case device::serial::RECEIVE_ERROR_SYSTEM_ERROR: + case device::serial::ReceiveError::SYSTEM_ERROR: return api::serial::RECEIVE_ERROR_SYSTEM_ERROR; } return api::serial::RECEIVE_ERROR_NONE; @@ -66,11 +66,11 @@ api::serial::DataBits ConvertDataBitsFromMojo(device::serial::DataBits input) { switch (input) { - case device::serial::DATA_BITS_NONE: + case device::serial::DataBits::NONE: return api::serial::DATA_BITS_NONE; - case device::serial::DATA_BITS_SEVEN: + case device::serial::DataBits::SEVEN: return api::serial::DATA_BITS_SEVEN; - case device::serial::DATA_BITS_EIGHT: + case device::serial::DataBits::EIGHT: return api::serial::DATA_BITS_EIGHT; } return api::serial::DATA_BITS_NONE; @@ -79,25 +79,25 @@ device::serial::DataBits ConvertDataBitsToMojo(api::serial::DataBits input) { switch (input) { case api::serial::DATA_BITS_NONE: - return device::serial::DATA_BITS_NONE; + return device::serial::DataBits::NONE; case api::serial::DATA_BITS_SEVEN: - return device::serial::DATA_BITS_SEVEN; + return device::serial::DataBits::SEVEN; case api::serial::DATA_BITS_EIGHT: - return device::serial::DATA_BITS_EIGHT; + return device::serial::DataBits::EIGHT; } - return device::serial::DATA_BITS_NONE; + return device::serial::DataBits::NONE; } api::serial::ParityBit ConvertParityBitFromMojo( device::serial::ParityBit input) { switch (input) { - case device::serial::PARITY_BIT_NONE: + case device::serial::ParityBit::NONE: return api::serial::PARITY_BIT_NONE; - case device::serial::PARITY_BIT_ODD: + case device::serial::ParityBit::ODD: return api::serial::PARITY_BIT_ODD; - case device::serial::PARITY_BIT_NO: + case device::serial::ParityBit::NO: return api::serial::PARITY_BIT_NO; - case device::serial::PARITY_BIT_EVEN: + case device::serial::ParityBit::EVEN: return api::serial::PARITY_BIT_EVEN; } return api::serial::PARITY_BIT_NONE; @@ -106,24 +106,24 @@ device::serial::ParityBit ConvertParityBitToMojo(api::serial::ParityBit input) { switch (input) { case api::serial::PARITY_BIT_NONE: - return device::serial::PARITY_BIT_NONE; + return device::serial::ParityBit::NONE; case api::serial::PARITY_BIT_NO: - return device::serial::PARITY_BIT_NO; + return device::serial::ParityBit::NO; case api::serial::PARITY_BIT_ODD: - return device::serial::PARITY_BIT_ODD; + return device::serial::ParityBit::ODD; case api::serial::PARITY_BIT_EVEN: - return device::serial::PARITY_BIT_EVEN; + return device::serial::ParityBit::EVEN; } - return device::serial::PARITY_BIT_NONE; + return device::serial::ParityBit::NONE; } api::serial::StopBits ConvertStopBitsFromMojo(device::serial::StopBits input) { switch (input) { - case device::serial::STOP_BITS_NONE: + case device::serial::StopBits::NONE: return api::serial::STOP_BITS_NONE; - case device::serial::STOP_BITS_ONE: + case device::serial::StopBits::ONE: return api::serial::STOP_BITS_ONE; - case device::serial::STOP_BITS_TWO: + case device::serial::StopBits::TWO: return api::serial::STOP_BITS_TWO; } return api::serial::STOP_BITS_NONE; @@ -132,13 +132,13 @@ device::serial::StopBits ConvertStopBitsToMojo(api::serial::StopBits input) { switch (input) { case api::serial::STOP_BITS_NONE: - return device::serial::STOP_BITS_NONE; + return device::serial::StopBits::NONE; case api::serial::STOP_BITS_ONE: - return device::serial::STOP_BITS_ONE; + return device::serial::StopBits::ONE; case api::serial::STOP_BITS_TWO: - return device::serial::STOP_BITS_TWO; + return device::serial::StopBits::TWO; } - return device::serial::STOP_BITS_NONE; + return device::serial::StopBits::NONE; } } // namespace @@ -172,8 +172,8 @@ } SerialConnection::~SerialConnection() { - io_handler_->CancelRead(device::serial::RECEIVE_ERROR_DISCONNECTED); - io_handler_->CancelWrite(device::serial::SEND_ERROR_DISCONNECTED); + io_handler_->CancelRead(device::serial::ReceiveError::DISCONNECTED); + io_handler_->CancelWrite(device::serial::SendError::DISCONNECTED); } bool SerialConnection::IsPersistent() const { @@ -195,7 +195,7 @@ void SerialConnection::set_paused(bool paused) { paused_ = paused; if (paused) { - io_handler_->CancelRead(device::serial::RECEIVE_ERROR_NONE); + io_handler_->CancelRead(device::serial::ReceiveError::NONE); } } @@ -266,7 +266,7 @@ set_send_timeout(*options.send_timeout); bool success = io_handler_->ConfigurePort( *device::serial::ConnectionOptions::From(options)); - io_handler_->CancelRead(device::serial::RECEIVE_ERROR_NONE); + io_handler_->CancelRead(device::serial::ReceiveError::NONE); return success; } @@ -329,12 +329,12 @@ void SerialConnection::OnReceiveTimeout() { DCHECK_CURRENTLY_ON(BrowserThread::IO); - io_handler_->CancelRead(device::serial::RECEIVE_ERROR_TIMEOUT); + io_handler_->CancelRead(device::serial::ReceiveError::TIMEOUT); } void SerialConnection::OnSendTimeout() { DCHECK_CURRENTLY_ON(BrowserThread::IO); - io_handler_->CancelWrite(device::serial::SEND_ERROR_TIMEOUT); + io_handler_->CancelWrite(device::serial::SendError::TIMEOUT); } void SerialConnection::OnAsyncReadComplete(int bytes_read,
diff --git a/extensions/browser/api/web_contents_capture_client.h b/extensions/browser/api/web_contents_capture_client.h deleted file mode 100644 index 4107ee4e..0000000 --- a/extensions/browser/api/web_contents_capture_client.h +++ /dev/null
@@ -1,58 +0,0 @@ -// Copyright 2013 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 EXTENSIONS_BROWSER_API_WEB_CONTENTS_CAPTURE_CLIENT_H_ -#define EXTENSIONS_BROWSER_API_WEB_CONTENTS_CAPTURE_CLIENT_H_ - -#include "base/macros.h" -#include "content/public/browser/readback_types.h" -#include "extensions/browser/extension_function.h" -#include "extensions/common/api/extension_types.h" - -class SkBitmap; - -namespace content { -class WebContents; -} - -namespace extensions { - -// Base class for capturing visible area of a WebContents. -// This is used by both webview.captureVisibleRegion and tabs.captureVisibleTab. -class WebContentsCaptureClient { - public: - WebContentsCaptureClient() {} - - protected: - virtual ~WebContentsCaptureClient() {} - - virtual bool IsScreenshotEnabled() = 0; - - enum FailureReason { - FAILURE_REASON_UNKNOWN, - FAILURE_REASON_ENCODING_FAILED, - FAILURE_REASON_VIEW_INVISIBLE - }; - bool CaptureAsync(content::WebContents* web_contents, - const api::extension_types::ImageDetails* image_detail, - const content::ReadbackRequestCallback callback); - bool EncodeBitmap(const SkBitmap& bitmap, std::string* base64_result); - virtual void OnCaptureFailure(FailureReason reason) = 0; - virtual void OnCaptureSuccess(const SkBitmap& bitmap) = 0; - void CopyFromBackingStoreComplete(const SkBitmap& bitmap, - content::ReadbackResponse response); - - private: - // The format (JPEG vs PNG) of the resulting image. Set in RunAsync(). - api::extension_types::ImageFormat image_format_; - - // Quality setting to use when encoding jpegs. Set in RunAsync(). - int image_quality_; - - DISALLOW_COPY_AND_ASSIGN(WebContentsCaptureClient); -}; - -} // namespace extensions - -#endif // EXTENSIONS_BROWSER_API_WEB_CONTENTS_CAPTURE_CLIENT_H_
diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h index 57ecb3e5..da49571 100644 --- a/extensions/browser/extension_function_histogram_value.h +++ b/extensions/browser/extension_function_histogram_value.h
@@ -1164,6 +1164,8 @@ INPUT_IME_CREATEWINDOW, INPUTMETHODPRIVATE_SETXKBLAYOUT, ACCESSIBILITY_PRIVATE_SETKEYBOARDLISTENER, + INPUT_IME_ACTIVATE, + INPUT_IME_DEACTIVATE, // Last entry: Add new entries above, then run: // python tools/metrics/histograms/update_extension_histograms.py ENUM_BOUNDARY
diff --git a/extensions/browser/guest_view/web_view/web_view_apitest.cc b/extensions/browser/guest_view/web_view/web_view_apitest.cc index 89bbf05..9896e13 100644 --- a/extensions/browser/guest_view/web_view/web_view_apitest.cc +++ b/extensions/browser/guest_view/web_view/web_view_apitest.cc
@@ -736,8 +736,5 @@ LaunchApp("web_view/inside_iframe"); } -IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestCaptureVisibleRegion) { - RunTest("testCaptureVisibleRegion", "web_view/apitest"); -} } // namespace extensions
diff --git a/extensions/common/api/_api_features.json b/extensions/common/api/_api_features.json index 5e07269..b30775f 100644 --- a/extensions/common/api/_api_features.json +++ b/extensions/common/api/_api_features.json
@@ -460,12 +460,6 @@ "chrome://oobe/*" ] }], - "webViewExperimentalInternal": [{ - "internal": true, - "channel": "dev", - "dependencies": ["permission:webview"], - "contexts": ["blessed_extension"] - }], "webViewRequest": [{ "dependencies": ["permission:webview"], "contexts": ["blessed_extension"]
diff --git a/extensions/common/api/management.json b/extensions/common/api/management.json index 93f1f1f..8d126a77 100644 --- a/extensions/common/api/management.json +++ b/extensions/common/api/management.json
@@ -65,6 +65,11 @@ "description": "The <a href='manifest/version'>version</a> of this extension, app, or theme.", "type": "string" }, + "versionName": { + "description": "The <a href='manifest/version#version_name'>version name</a> of this extension, app, or theme if the manifest specified one.", + "type": "string", + "optional": true + }, "mayDisable": { "description": "Whether this extension can be disabled or uninstalled by the user.", "type": "boolean"
diff --git a/extensions/common/api/web_view_internal.json b/extensions/common/api/web_view_internal.json index 94a6eb9..a33f500 100644 --- a/extensions/common/api/web_view_internal.json +++ b/extensions/common/api/web_view_internal.json
@@ -670,33 +670,6 @@ ] }, { - "name": "captureVisibleRegion", - "type": "function", - "description": "foo", - "parameters": [ - { - "type": "integer", - "name": "instanceId", - "description": "The instance ID of the guest <webview> process." - }, - { - "$ref": "extensionTypes.ImageDetails", - "name": "options", - "optional": true - }, - { - "type": "function", - "name": "callback", - "parameters": [ - {"type": "string", - "name": "dataUrl", - "description": "A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display." - } - ] - } - ] - }, - { "name": "clearData", "type": "function", "description": "Clears various types of browsing data stored in a storage partition of a <webview>.",
diff --git a/extensions/common/extension.h b/extensions/common/extension.h index 25035ee..df06d0f 100644 --- a/extensions/common/extension.h +++ b/extensions/common/extension.h
@@ -290,6 +290,7 @@ Manifest::Location location() const; const ExtensionId& id() const; const base::Version* version() const { return version_.get(); } + const std::string& version_name() const { return version_name_; } const std::string VersionString() const; const std::string GetVersionForDisplay() const; const std::string& name() const { return name_; }
diff --git a/extensions/extensions.gypi b/extensions/extensions.gypi index 8a0fb29..27b1033 100644 --- a/extensions/extensions.gypi +++ b/extensions/extensions.gypi
@@ -273,6 +273,8 @@ 'browser/api/bluetooth_socket/bluetooth_socket_api.h', 'browser/api/bluetooth_socket/bluetooth_socket_event_dispatcher.cc', 'browser/api/bluetooth_socket/bluetooth_socket_event_dispatcher.h', + 'browser/api/capture_web_contents_function.cc', + 'browser/api/capture_web_contents_function.h', 'browser/api/cast_channel/cast_auth_ica.cc', 'browser/api/cast_channel/cast_auth_ica.h', 'browser/api/cast_channel/cast_auth_util.cc', @@ -489,8 +491,6 @@ 'browser/api/virtual_keyboard_private/virtual_keyboard_delegate.h', 'browser/api/virtual_keyboard_private/virtual_keyboard_private_api.cc', 'browser/api/virtual_keyboard_private/virtual_keyboard_private_api.h', - 'browser/api/web_contents_capture_client.cc', - 'browser/api/web_contents_capture_client.h', 'browser/api/web_request/form_data_parser.cc', 'browser/api/web_request/form_data_parser.h', 'browser/api/web_request/upload_data_presenter.cc',
diff --git a/extensions/renderer/api/serial/serial_api_unittest.cc b/extensions/renderer/api/serial/serial_api_unittest.cc index 0e30cfb..b8c9e42 100644 --- a/extensions/renderer/api/serial/serial_api_unittest.cc +++ b/extensions/renderer/api/serial/serial_api_unittest.cc
@@ -189,60 +189,51 @@ // Each JavaScript call to chrome.serial.update only modifies a single // property of the connection however this function can only check the // final value of all options. The modified option is marked with "set". - GenerateConnectionOptions(9600, - device::serial::DATA_BITS_EIGHT, - device::serial::PARITY_BIT_NO, - device::serial::STOP_BITS_ONE, + GenerateConnectionOptions(9600, device::serial::DataBits::EIGHT, + device::serial::ParityBit::NO, + device::serial::StopBits::ONE, OPTIONAL_VALUE_FALSE), - GenerateConnectionOptions(57600, // set - device::serial::DATA_BITS_EIGHT, - device::serial::PARITY_BIT_NO, - device::serial::STOP_BITS_ONE, + GenerateConnectionOptions( + 57600, // set + device::serial::DataBits::EIGHT, device::serial::ParityBit::NO, + device::serial::StopBits::ONE, OPTIONAL_VALUE_FALSE), + GenerateConnectionOptions(57600, + device::serial::DataBits::SEVEN, // set + device::serial::ParityBit::NO, + device::serial::StopBits::ONE, OPTIONAL_VALUE_FALSE), GenerateConnectionOptions(57600, - device::serial::DATA_BITS_SEVEN, // set - device::serial::PARITY_BIT_NO, - device::serial::STOP_BITS_ONE, + device::serial::DataBits::EIGHT, // set + device::serial::ParityBit::NO, + device::serial::StopBits::ONE, OPTIONAL_VALUE_FALSE), - GenerateConnectionOptions(57600, - device::serial::DATA_BITS_EIGHT, // set - device::serial::PARITY_BIT_NO, - device::serial::STOP_BITS_ONE, + GenerateConnectionOptions(57600, device::serial::DataBits::EIGHT, + device::serial::ParityBit::NO, // set + device::serial::StopBits::ONE, OPTIONAL_VALUE_FALSE), - GenerateConnectionOptions(57600, - device::serial::DATA_BITS_EIGHT, - device::serial::PARITY_BIT_NO, // set - device::serial::STOP_BITS_ONE, + GenerateConnectionOptions(57600, device::serial::DataBits::EIGHT, + device::serial::ParityBit::ODD, // set + device::serial::StopBits::ONE, OPTIONAL_VALUE_FALSE), - GenerateConnectionOptions(57600, - device::serial::DATA_BITS_EIGHT, - device::serial::PARITY_BIT_ODD, // set - device::serial::STOP_BITS_ONE, + GenerateConnectionOptions(57600, device::serial::DataBits::EIGHT, + device::serial::ParityBit::EVEN, // set + device::serial::StopBits::ONE, OPTIONAL_VALUE_FALSE), - GenerateConnectionOptions(57600, - device::serial::DATA_BITS_EIGHT, - device::serial::PARITY_BIT_EVEN, // set - device::serial::STOP_BITS_ONE, + GenerateConnectionOptions(57600, device::serial::DataBits::EIGHT, + device::serial::ParityBit::EVEN, + device::serial::StopBits::ONE, // set OPTIONAL_VALUE_FALSE), - GenerateConnectionOptions(57600, - device::serial::DATA_BITS_EIGHT, - device::serial::PARITY_BIT_EVEN, - device::serial::STOP_BITS_ONE, // set + GenerateConnectionOptions(57600, device::serial::DataBits::EIGHT, + device::serial::ParityBit::EVEN, + device::serial::StopBits::TWO, // set OPTIONAL_VALUE_FALSE), - GenerateConnectionOptions(57600, - device::serial::DATA_BITS_EIGHT, - device::serial::PARITY_BIT_EVEN, - device::serial::STOP_BITS_TWO, // set - OPTIONAL_VALUE_FALSE), - GenerateConnectionOptions(57600, - device::serial::DATA_BITS_EIGHT, - device::serial::PARITY_BIT_EVEN, - device::serial::STOP_BITS_TWO, + GenerateConnectionOptions(57600, device::serial::DataBits::EIGHT, + device::serial::ParityBit::EVEN, + device::serial::StopBits::TWO, OPTIONAL_VALUE_FALSE), // set - GenerateConnectionOptions(57600, - device::serial::DATA_BITS_EIGHT, - device::serial::PARITY_BIT_EVEN, - device::serial::STOP_BITS_TWO, + GenerateConnectionOptions(57600, device::serial::DataBits::EIGHT, + device::serial::ParityBit::EVEN, + device::serial::StopBits::TWO, OPTIONAL_VALUE_TRUE), // set }; @@ -346,7 +337,7 @@ return; memcpy(pending_read_buffer(), data_.c_str(), data_.size()); QueueReadCompleted(static_cast<uint32_t>(data_.size()), - device::serial::RECEIVE_ERROR_NONE); + device::serial::ReceiveError::NONE); } private: @@ -378,13 +369,13 @@ void WriteImpl() override { if (sent_error_) { WriteCompleted(pending_write_buffer_len(), - device::serial::SEND_ERROR_NONE); + device::serial::SendError::NONE); return; } sent_error_ = true; // We expect the JS test code to send a 4 byte buffer. ASSERT_LT(2u, pending_write_buffer_len()); - WriteCompleted(2, device::serial::SEND_ERROR_SYSTEM_ERROR); + WriteCompleted(2, device::serial::SendError::SYSTEM_ERROR); } private: @@ -580,7 +571,7 @@ TEST_F(SerialApiTest, PausedReceiveError) { io_handler_ = - new ReceiveErrorTestIoHandler(device::serial::RECEIVE_ERROR_DEVICE_LOST); + new ReceiveErrorTestIoHandler(device::serial::ReceiveError::DEVICE_LOST); RunTest("serial_unittest.js", "testPausedReceiveError"); } @@ -598,61 +589,61 @@ TEST_F(SerialApiTest, ReceiveErrorDisconnected) { io_handler_ = - new ReceiveErrorTestIoHandler(device::serial::RECEIVE_ERROR_DISCONNECTED); + new ReceiveErrorTestIoHandler(device::serial::ReceiveError::DISCONNECTED); RunTest("serial_unittest.js", "testReceiveErrorDisconnected"); } TEST_F(SerialApiTest, ReceiveErrorDeviceLost) { io_handler_ = - new ReceiveErrorTestIoHandler(device::serial::RECEIVE_ERROR_DEVICE_LOST); + new ReceiveErrorTestIoHandler(device::serial::ReceiveError::DEVICE_LOST); RunTest("serial_unittest.js", "testReceiveErrorDeviceLost"); } TEST_F(SerialApiTest, ReceiveErrorBreak) { io_handler_ = - new ReceiveErrorTestIoHandler(device::serial::RECEIVE_ERROR_BREAK); + new ReceiveErrorTestIoHandler(device::serial::ReceiveError::BREAK); RunTest("serial_unittest.js", "testReceiveErrorBreak"); } TEST_F(SerialApiTest, ReceiveErrorFrameError) { io_handler_ = - new ReceiveErrorTestIoHandler(device::serial::RECEIVE_ERROR_FRAME_ERROR); + new ReceiveErrorTestIoHandler(device::serial::ReceiveError::FRAME_ERROR); RunTest("serial_unittest.js", "testReceiveErrorFrameError"); } TEST_F(SerialApiTest, ReceiveErrorOverrun) { io_handler_ = - new ReceiveErrorTestIoHandler(device::serial::RECEIVE_ERROR_OVERRUN); + new ReceiveErrorTestIoHandler(device::serial::ReceiveError::OVERRUN); RunTest("serial_unittest.js", "testReceiveErrorOverrun"); } TEST_F(SerialApiTest, ReceiveErrorBufferOverflow) { io_handler_ = new ReceiveErrorTestIoHandler( - device::serial::RECEIVE_ERROR_BUFFER_OVERFLOW); + device::serial::ReceiveError::BUFFER_OVERFLOW); RunTest("serial_unittest.js", "testReceiveErrorBufferOverflow"); } TEST_F(SerialApiTest, ReceiveErrorParityError) { io_handler_ = - new ReceiveErrorTestIoHandler(device::serial::RECEIVE_ERROR_PARITY_ERROR); + new ReceiveErrorTestIoHandler(device::serial::ReceiveError::PARITY_ERROR); RunTest("serial_unittest.js", "testReceiveErrorParityError"); } TEST_F(SerialApiTest, ReceiveErrorSystemError) { io_handler_ = - new ReceiveErrorTestIoHandler(device::serial::RECEIVE_ERROR_SYSTEM_ERROR); + new ReceiveErrorTestIoHandler(device::serial::ReceiveError::SYSTEM_ERROR); RunTest("serial_unittest.js", "testReceiveErrorSystemError"); } TEST_F(SerialApiTest, SendErrorDisconnected) { io_handler_ = - new SendErrorTestIoHandler(device::serial::SEND_ERROR_DISCONNECTED); + new SendErrorTestIoHandler(device::serial::SendError::DISCONNECTED); RunTest("serial_unittest.js", "testSendErrorDisconnected"); } TEST_F(SerialApiTest, SendErrorSystemError) { io_handler_ = - new SendErrorTestIoHandler(device::serial::SEND_ERROR_SYSTEM_ERROR); + new SendErrorTestIoHandler(device::serial::SendError::SYSTEM_ERROR); RunTest("serial_unittest.js", "testSendErrorSystemError"); } @@ -701,7 +692,7 @@ TEST_F(SerialApiTest, DISABLED_StashAndRestoreDuringEchoError) { io_handler_ = - new ReceiveErrorTestIoHandler(device::serial::RECEIVE_ERROR_DEVICE_LOST); + new ReceiveErrorTestIoHandler(device::serial::ReceiveError::DEVICE_LOST); ASSERT_NO_FATAL_FAILURE( RunTest("serial_unittest.js", "testRestoreAndReceiveErrorSetUp")); scoped_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment());
diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc index bdfa298b..7ec76ad 100644 --- a/extensions/renderer/dispatcher.cc +++ b/extensions/renderer/dispatcher.cc
@@ -644,8 +644,6 @@ resources.push_back(std::make_pair("webViewEvents", IDR_WEB_VIEW_EVENTS_JS)); resources.push_back(std::make_pair("webViewInternal", IDR_WEB_VIEW_INTERNAL_CUSTOM_BINDINGS_JS)); - resources.push_back(std::make_pair("webViewExperimental", - IDR_WEB_VIEW_EXPERIMENTAL_JS)); if (content::BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { resources.push_back(std::make_pair("webViewIframe", IDR_WEB_VIEW_IFRAME_JS)); @@ -1599,10 +1597,6 @@ module_system->Require("webView"); module_system->Require("webViewApiMethods"); module_system->Require("webViewAttributes"); - if (context->GetAvailability("webViewExperimentalInternal") - .is_available()) { - module_system->Require("webViewExperimental"); - } if (content::BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { module_system->Require("webViewIframe");
diff --git a/extensions/renderer/extension_helper.cc b/extensions/renderer/extension_helper.cc index 8eb0cc8e..728ea13 100644 --- a/extensions/renderer/extension_helper.cc +++ b/extensions/renderer/extension_helper.cc
@@ -47,6 +47,7 @@ std::vector<DraggableRegion> regions; for (size_t i = 0; i < webregions.size(); ++i) { DraggableRegion region; + render_view()->convertViewportToWindow(&webregions[i].bounds); region.bounds = webregions[i].bounds; region.draggable = webregions[i].draggable; regions.push_back(region);
diff --git a/extensions/renderer/resources/extensions_renderer_resources.grd b/extensions/renderer/resources/extensions_renderer_resources.grd index b4f5dad..bad8e29 100644 --- a/extensions/renderer/resources/extensions_renderer_resources.grd +++ b/extensions/renderer/resources/extensions_renderer_resources.grd
@@ -61,7 +61,6 @@ <include name="IDR_WEB_VIEW_ATTRIBUTES_JS" file="guest_view/web_view/web_view_attributes.js" type="BINDATA" /> <include name="IDR_WEB_VIEW_CONSTANTS_JS" file="guest_view/web_view/web_view_constants.js" type="BINDATA" /> <include name="IDR_WEB_VIEW_EVENTS_JS" file="guest_view/web_view/web_view_events.js" type="BINDATA" /> - <include name="IDR_WEB_VIEW_EXPERIMENTAL_JS" file="guest_view/web_view/web_view_experimental.js" type="BINDATA" /> <include name="IDR_WEB_VIEW_IFRAME_JS" file="guest_view/web_view/web_view_iframe.js" type="BINDATA" /> <include name="IDR_WEB_VIEW_INTERNAL_CUSTOM_BINDINGS_JS" file="guest_view/web_view/web_view_internal.js" type="BINDATA" /> <include name="IDR_WEB_VIEW_JS" file="guest_view/web_view/web_view.js" type="BINDATA" />
diff --git a/extensions/renderer/resources/guest_view/web_view/web_view.js b/extensions/renderer/resources/guest_view/web_view/web_view.js index d55249f2..6dd4fae 100644 --- a/extensions/renderer/resources/guest_view/web_view/web_view.js +++ b/extensions/renderer/resources/guest_view/web_view/web_view.js
@@ -31,11 +31,6 @@ // Public-facing API methods. var apiMethods = WebViewImpl.getApiMethods(); - // Add the experimental API methods, if available. - var experimentalApiMethods = - WebViewImpl.maybeGetExperimentalApiMethods(); - apiMethods = $Array.concat(apiMethods, experimentalApiMethods); - // Create default implementations for undefined API methods. var createDefaultApiMethod = function(m) { return function(var_args) { @@ -225,9 +220,6 @@ // Implemented when the ChromeWebView API is available. WebViewImpl.prototype.maybeSetupContextMenus = function() {}; -// Implemented when the experimental WebView API is available. -WebViewImpl.maybeGetExperimentalApiMethods = function() { return []; }; - GuestViewContainer.registerElement(WebViewImpl); // Exports.
diff --git a/extensions/renderer/resources/guest_view/web_view/web_view_experimental.js b/extensions/renderer/resources/guest_view/web_view/web_view_experimental.js deleted file mode 100644 index 96331df..0000000 --- a/extensions/renderer/resources/guest_view/web_view/web_view_experimental.js +++ /dev/null
@@ -1,24 +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. - -// This module implements experimental API for <webview>. -// See web_view.js and web_view_api_methods.js for details. -// -// <webview> Experimental API is only available on canary and channels of -// Chrome. - -var WebViewImpl = require('webView').WebViewImpl; -var WebViewInternal = require('webViewInternal').WebViewInternal; - -// An array of <webview>'s experimental API methods. See |WEB_VIEW_API_METHODS| -// in web_view_api_methods.js for more details. -var WEB_VIEW_EXPERIMENTAL_API_METHODS = [ - // Captures the visible region of the WebView contents into a bitmap. - 'captureVisibleRegion' -]; - -// Registers the experimantal WebVIew API when available. -WebViewImpl.maybeGetExperimentalApiMethods = function() { - return WEB_VIEW_EXPERIMENTAL_API_METHODS; -};
diff --git a/extensions/test/data/web_view/apitest/main.js b/extensions/test/data/web_view/apitest/main.js index b203025..983212c 100644 --- a/extensions/test/data/web_view/apitest/main.js +++ b/extensions/test/data/web_view/apitest/main.js
@@ -1685,28 +1685,6 @@ document.body.appendChild(webview); } -// This is a basic test to verify that image data is returned by -// captureVisibleRegion(). -function testCaptureVisibleRegion() { - var webview = document.createElement('webview'); - webview.setAttribute('src', 'data:text/html,webview test'); - - webview.addEventListener('loadstop', function(e) { - webview.captureVisibleRegion({}, function(imgdata) { - if (chrome.runtime.lastError) { - console.log('webview.apitest.testCaptureVisibleRegion: ' + - chrome.runtime.lastError.message); - embedder.test.fail(); - } else { - embedder.test.assertTrue( - imgdata.indexOf('data:image/jpeg;base64') == 0); - embedder.test.succeed(); - } - }); - }); - document.body.appendChild(webview); -} - // Tests end. embedder.test.testList = { @@ -1774,8 +1752,7 @@ 'testWebRequestAPI': testWebRequestAPI, 'testWebRequestAPIWithHeaders': testWebRequestAPIWithHeaders, 'testWebRequestAPIExistence': testWebRequestAPIExistence, - 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty, - 'testCaptureVisibleRegion' : testCaptureVisibleRegion + 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty }; onload = function() {
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index 9794fc25..efdd2963 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -1933,74 +1933,6 @@ 'GL_BGR', ], }, - 'TextureUnsizedInternalFormat': { - 'type': 'GLenum', - 'valid': [ - 'GL_ALPHA', - 'GL_LUMINANCE', - 'GL_LUMINANCE_ALPHA', - 'GL_RGB', - 'GL_RGBA', - ], - }, - 'TextureSizedColorRenderableInternalFormat': { - 'type': 'GLenum', - 'valid': [ - 'GL_R8', - 'GL_R8UI', - 'GL_R8I', - 'GL_R16UI', - 'GL_R16I', - 'GL_R32UI', - 'GL_R32I', - 'GL_RG8', - 'GL_RG8UI', - 'GL_RG8I', - 'GL_RG16UI', - 'GL_RG16I', - 'GL_RG32UI', - 'GL_RG32I', - 'GL_RGB8', - 'GL_RGB565', - 'GL_RGBA8', - 'GL_SRGB8_ALPHA8', - 'GL_RGB5_A1', - 'GL_RGBA4', - 'GL_RGB10_A2', - 'GL_RGBA8UI', - 'GL_RGBA8I', - 'GL_RGB10_A2UI', - 'GL_RGBA16UI', - 'GL_RGBA16I', - 'GL_RGBA32UI', - 'GL_RGBA32I', - ], - }, - 'TextureSizedTextureFilterableInternalFormat': { - 'type': 'GLenum', - 'valid': [ - 'GL_R8', - 'GL_R8_SNORM', - 'GL_R16F', - 'GL_RG8', - 'GL_RG8_SNORM', - 'GL_RG16F', - 'GL_RGB8', - 'GL_SRGB8', - 'GL_RGB565', - 'GL_RGB8_SNORM', - 'GL_R11F_G11F_B10F', - 'GL_RGB9_E5', - 'GL_RGB16F', - 'GL_RGBA8', - 'GL_SRGB8_ALPHA8', - 'GL_RGBA8_SNORM', - 'GL_RGB5_A1', - 'GL_RGBA4', - 'GL_RGB10_A2', - 'GL_RGBA16F', - ], - }, 'TextureInternalFormatStorage': { 'type': 'GLenum', 'valid': [
diff --git a/gpu/command_buffer/common/gles2_cmd_utils_autogen.h b/gpu/command_buffer/common/gles2_cmd_utils_autogen.h index f68b352..a7167cff 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_utils_autogen.h
@@ -89,12 +89,7 @@ static std::string GetStringTextureMagFilterMode(uint32_t value); static std::string GetStringTextureMinFilterMode(uint32_t value); static std::string GetStringTextureParameter(uint32_t value); -static std::string GetStringTextureSizedColorRenderableInternalFormat( - uint32_t value); -static std::string GetStringTextureSizedTextureFilterableInternalFormat( - uint32_t value); static std::string GetStringTextureTarget(uint32_t value); -static std::string GetStringTextureUnsizedInternalFormat(uint32_t value); static std::string GetStringTextureUsage(uint32_t value); static std::string GetStringTextureWrapMode(uint32_t value); static std::string GetStringTransformFeedbackBindTarget(uint32_t value);
diff --git a/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h b/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h index b501a188..dcf3983 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h
@@ -4771,70 +4771,6 @@ arraysize(string_table), value); } -std::string GLES2Util::GetStringTextureSizedColorRenderableInternalFormat( - uint32_t value) { - static const EnumToString string_table[] = { - {GL_R8, "GL_R8"}, - {GL_R8UI, "GL_R8UI"}, - {GL_R8I, "GL_R8I"}, - {GL_R16UI, "GL_R16UI"}, - {GL_R16I, "GL_R16I"}, - {GL_R32UI, "GL_R32UI"}, - {GL_R32I, "GL_R32I"}, - {GL_RG8, "GL_RG8"}, - {GL_RG8UI, "GL_RG8UI"}, - {GL_RG8I, "GL_RG8I"}, - {GL_RG16UI, "GL_RG16UI"}, - {GL_RG16I, "GL_RG16I"}, - {GL_RG32UI, "GL_RG32UI"}, - {GL_RG32I, "GL_RG32I"}, - {GL_RGB8, "GL_RGB8"}, - {GL_RGB565, "GL_RGB565"}, - {GL_RGBA8, "GL_RGBA8"}, - {GL_SRGB8_ALPHA8, "GL_SRGB8_ALPHA8"}, - {GL_RGB5_A1, "GL_RGB5_A1"}, - {GL_RGBA4, "GL_RGBA4"}, - {GL_RGB10_A2, "GL_RGB10_A2"}, - {GL_RGBA8UI, "GL_RGBA8UI"}, - {GL_RGBA8I, "GL_RGBA8I"}, - {GL_RGB10_A2UI, "GL_RGB10_A2UI"}, - {GL_RGBA16UI, "GL_RGBA16UI"}, - {GL_RGBA16I, "GL_RGBA16I"}, - {GL_RGBA32UI, "GL_RGBA32UI"}, - {GL_RGBA32I, "GL_RGBA32I"}, - }; - return GLES2Util::GetQualifiedEnumString(string_table, - arraysize(string_table), value); -} - -std::string GLES2Util::GetStringTextureSizedTextureFilterableInternalFormat( - uint32_t value) { - static const EnumToString string_table[] = { - {GL_R8, "GL_R8"}, - {GL_R8_SNORM, "GL_R8_SNORM"}, - {GL_R16F, "GL_R16F"}, - {GL_RG8, "GL_RG8"}, - {GL_RG8_SNORM, "GL_RG8_SNORM"}, - {GL_RG16F, "GL_RG16F"}, - {GL_RGB8, "GL_RGB8"}, - {GL_SRGB8, "GL_SRGB8"}, - {GL_RGB565, "GL_RGB565"}, - {GL_RGB8_SNORM, "GL_RGB8_SNORM"}, - {GL_R11F_G11F_B10F, "GL_R11F_G11F_B10F"}, - {GL_RGB9_E5, "GL_RGB9_E5"}, - {GL_RGB16F, "GL_RGB16F"}, - {GL_RGBA8, "GL_RGBA8"}, - {GL_SRGB8_ALPHA8, "GL_SRGB8_ALPHA8"}, - {GL_RGBA8_SNORM, "GL_RGBA8_SNORM"}, - {GL_RGB5_A1, "GL_RGB5_A1"}, - {GL_RGBA4, "GL_RGBA4"}, - {GL_RGB10_A2, "GL_RGB10_A2"}, - {GL_RGBA16F, "GL_RGBA16F"}, - }; - return GLES2Util::GetQualifiedEnumString(string_table, - arraysize(string_table), value); -} - std::string GLES2Util::GetStringTextureTarget(uint32_t value) { static const EnumToString string_table[] = { {GL_TEXTURE_2D, "GL_TEXTURE_2D"}, @@ -4849,18 +4785,6 @@ arraysize(string_table), value); } -std::string GLES2Util::GetStringTextureUnsizedInternalFormat(uint32_t value) { - static const EnumToString string_table[] = { - {GL_ALPHA, "GL_ALPHA"}, - {GL_LUMINANCE, "GL_LUMINANCE"}, - {GL_LUMINANCE_ALPHA, "GL_LUMINANCE_ALPHA"}, - {GL_RGB, "GL_RGB"}, - {GL_RGBA, "GL_RGBA"}, - }; - return GLES2Util::GetQualifiedEnumString(string_table, - arraysize(string_table), value); -} - std::string GLES2Util::GetStringTextureUsage(uint32_t value) { static const EnumToString string_table[] = { {GL_NONE, "GL_NONE"},
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 8ec9cfd..34601eb6 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -9668,7 +9668,7 @@ if (!surface_->ScheduleCALayer(image, contents_rect, c.opacity, c.background_color, c.edge_aa_mask, bounds_rect, c.is_clipped ? true : false, - clip_rect, transform)) { + clip_rect, transform, c.sorting_context_id)) { LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glScheduleCALayerCHROMIUM", "failed to schedule CALayer"); }
diff --git a/gpu/command_buffer/service/gles2_cmd_validation_autogen.h b/gpu/command_buffer/service/gles2_cmd_validation_autogen.h index c3a7b39..e98aa2c 100644 --- a/gpu/command_buffer/service/gles2_cmd_validation_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_validation_autogen.h
@@ -346,10 +346,7 @@ TextureMinFilterModeValidator texture_min_filter_mode; ValueValidator<GLenum> texture_parameter; -ValueValidator<GLenum> texture_sized_color_renderable_internal_format; -ValueValidator<GLenum> texture_sized_texture_filterable_internal_format; ValueValidator<GLenum> texture_target; -ValueValidator<GLenum> texture_unsized_internal_format; class TextureUsageValidator { public: bool IsValid(const GLenum value) const;
diff --git a/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h b/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h index 2d0091f..aeaecd0 100644 --- a/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h
@@ -1192,25 +1192,6 @@ GL_TEXTURE_WRAP_R, }; -static const GLenum - valid_texture_sized_color_renderable_internal_format_table[] = { - GL_R8, GL_R8UI, GL_R8I, GL_R16UI, GL_R16I, - GL_R32UI, GL_R32I, GL_RG8, GL_RG8UI, GL_RG8I, - GL_RG16UI, GL_RG16I, GL_RG32UI, GL_RG32I, GL_RGB8, - GL_RGB565, GL_RGBA8, GL_SRGB8_ALPHA8, GL_RGB5_A1, GL_RGBA4, - GL_RGB10_A2, GL_RGBA8UI, GL_RGBA8I, GL_RGB10_A2UI, GL_RGBA16UI, - GL_RGBA16I, GL_RGBA32UI, GL_RGBA32I, -}; - -static const GLenum - valid_texture_sized_texture_filterable_internal_format_table[] = { - GL_R8, GL_R8_SNORM, GL_R16F, GL_RG8, - GL_RG8_SNORM, GL_RG16F, GL_RGB8, GL_SRGB8, - GL_RGB565, GL_RGB8_SNORM, GL_R11F_G11F_B10F, GL_RGB9_E5, - GL_RGB16F, GL_RGBA8, GL_SRGB8_ALPHA8, GL_RGBA8_SNORM, - GL_RGB5_A1, GL_RGBA4, GL_RGB10_A2, GL_RGBA16F, -}; - static const GLenum valid_texture_target_table[] = { GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP_POSITIVE_X, @@ -1221,10 +1202,6 @@ GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, }; -static const GLenum valid_texture_unsized_internal_format_table[] = { - GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA, -}; - bool Validators::TextureUsageValidator::IsValid(const GLenum value) const { switch (value) { case GL_NONE: @@ -1389,19 +1366,8 @@ arraysize(valid_texture_internal_format_storage_table)), texture_parameter(valid_texture_parameter_table, arraysize(valid_texture_parameter_table)), - texture_sized_color_renderable_internal_format( - valid_texture_sized_color_renderable_internal_format_table, - arraysize( - valid_texture_sized_color_renderable_internal_format_table)), - texture_sized_texture_filterable_internal_format( - valid_texture_sized_texture_filterable_internal_format_table, - arraysize( - valid_texture_sized_texture_filterable_internal_format_table)), texture_target(valid_texture_target_table, arraysize(valid_texture_target_table)), - texture_unsized_internal_format( - valid_texture_unsized_internal_format_table, - arraysize(valid_texture_unsized_internal_format_table)), transform_feedback_bind_target( valid_transform_feedback_bind_target_table, arraysize(valid_transform_feedback_bind_target_table)),
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc index d428c376..212daf3 100644 --- a/gpu/command_buffer/service/texture_manager.cc +++ b/gpu/command_buffer/service/texture_manager.cc
@@ -529,9 +529,11 @@ mailbox_manager_ = mailbox_manager; } -void Texture::MarkMipmapsGenerated( +bool Texture::MarkMipmapsGenerated( const FeatureInfo* feature_info) { - DCHECK(CanGenerateMipmaps(feature_info)); + if (!CanGenerateMipmaps(feature_info)) { + return false; + } for (size_t ii = 0; ii < face_infos_.size(); ++ii) { const Texture::FaceInfo& face_info = face_infos_[ii]; const Texture::LevelInfo& level0_info = face_info.level_infos[base_level_]; @@ -552,6 +554,8 @@ level0_info.type, gfx::Rect(width, height)); } } + + return true; } void Texture::SetTarget( @@ -596,33 +600,20 @@ return false; } - bool valid_internal_format = false; - if (feature_info->validators()->texture_unsized_internal_format.IsValid( - base.internal_format)) { - valid_internal_format = true; - } else if (feature_info->validators()-> - texture_sized_color_renderable_internal_format.IsValid( - base.internal_format) && feature_info->validators()-> - texture_sized_texture_filterable_internal_format.IsValid( - base.internal_format)) { - valid_internal_format = true; - } - if (!valid_internal_format) { - return false; - } - + // TODO(gman): Check internal_format, format and type. for (size_t ii = 0; ii < face_infos_.size(); ++ii) { const LevelInfo& info = face_infos_[ii].level_infos[base_level_]; - if ((info.target == 0) || + if ((info.target == 0) || (info.width != base.width) || + (info.height != base.height) || (info.depth != base.depth) || + (info.format != base.format) || + (info.internal_format != base.internal_format) || + (info.type != base.type) || feature_info->validators()->compressed_texture_format.IsValid( info.internal_format) || info.image.get()) { return false; } } - if (face_infos_.size() == 6 && !cube_complete_) { - return false; - } return true; } @@ -1121,8 +1112,7 @@ texture_complete_ = max_level_set_ >= (levels_needed - 1) && max_level_set_ >= 0; cube_complete_ = (face_infos_.size() == 6) && - (first_level.width == first_level.height) && - (first_level.width > 0); + (first_level.width == first_level.height); if (first_level.width == 0 || first_level.height == 0) { texture_complete_ = false; @@ -1705,12 +1695,13 @@ } } -void TextureManager::MarkMipmapsGenerated(TextureRef* ref) { +bool TextureManager::MarkMipmapsGenerated(TextureRef* ref) { DCHECK(ref); Texture* texture = ref->texture(); texture->GetMemTracker()->TrackMemFree(texture->estimated_size()); - texture->MarkMipmapsGenerated(feature_info_.get()); + bool result = texture->MarkMipmapsGenerated(feature_info_.get()); texture->GetMemTracker()->TrackMemAlloc(texture->estimated_size()); + return result; } TextureRef* TextureManager::CreateTexture(
diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h index e33df330..e106b73 100644 --- a/gpu/command_buffer/service/texture_manager.h +++ b/gpu/command_buffer/service/texture_manager.h
@@ -344,7 +344,7 @@ const FeatureInfo* feature_info, GLenum pname, GLfloat param); // Makes each of the mip levels as though they were generated. - void MarkMipmapsGenerated(const FeatureInfo* feature_info); + bool MarkMipmapsGenerated(const FeatureInfo* feature_info); bool NeedsMips() const { return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR; @@ -756,7 +756,8 @@ TextureRef* ref, GLenum pname, GLfloat param); // Makes each of the mip levels as though they were generated. - void MarkMipmapsGenerated(TextureRef* ref); + // Returns false if that's not allowed for the given texture. + bool MarkMipmapsGenerated(TextureRef* ref); // Clears any uncleared renderable levels. bool ClearRenderableLevels(GLES2Decoder* decoder, TextureRef* ref);
diff --git a/gpu/command_buffer/service/texture_manager_unittest.cc b/gpu/command_buffer/service/texture_manager_unittest.cc index c8eeddc..e1ed65646 100644 --- a/gpu/command_buffer/service/texture_manager_unittest.cc +++ b/gpu/command_buffer/service/texture_manager_unittest.cc
@@ -710,7 +710,7 @@ EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get())); // Make mips. - manager_->MarkMipmapsGenerated(texture_ref_.get()); + EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get())); EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); EXPECT_TRUE(manager_->CanRender(texture_ref_.get())); EXPECT_FALSE(manager_->HaveUnrenderableTextures()); @@ -727,7 +727,7 @@ 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(4, 4)); EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get())); // Make mips. - manager_->MarkMipmapsGenerated(texture_ref_.get()); + EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get())); EXPECT_TRUE(manager_->CanRender(texture_ref_.get())); EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); EXPECT_FALSE(manager_->HaveUnrenderableTextures()); @@ -789,8 +789,7 @@ 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(4, 4)); EXPECT_MEMORY_ALLOCATION_CHANGE(64, 0); EXPECT_MEMORY_ALLOCATION_CHANGE(0, 84); - EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get())); - manager_->MarkMipmapsGenerated(texture_ref_.get()); + EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get())); EXPECT_MEMORY_ALLOCATION_CHANGE(84, 0); EXPECT_MEMORY_ALLOCATION_CHANGE(0, 0); } @@ -802,8 +801,7 @@ // Set level zero to large size. manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(4, 4)); - EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get())); - manager_->MarkMipmapsGenerated(texture_ref_.get()); + EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get())); EXPECT_FALSE(TextureTestHelper::IsNPOT(texture)); EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); EXPECT_TRUE(manager_->CanRender(texture_ref_.get())); @@ -811,8 +809,7 @@ // Set level zero to large smaller (levels unused mips) manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(2, 2)); - EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get())); - manager_->MarkMipmapsGenerated(texture_ref_.get()); + EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get())); EXPECT_FALSE(TextureTestHelper::IsNPOT(texture)); EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); EXPECT_TRUE(manager_->CanRender(texture_ref_.get())); @@ -886,7 +883,7 @@ EXPECT_TRUE(manager.CanGenerateMipmaps(texture_ref)); EXPECT_FALSE(manager.CanRender(texture_ref)); EXPECT_TRUE(manager.HaveUnrenderableTextures()); - manager.MarkMipmapsGenerated(texture_ref); + EXPECT_TRUE(manager.MarkMipmapsGenerated(texture_ref)); EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); EXPECT_TRUE(manager.CanRender(texture_ref)); EXPECT_FALSE(manager.HaveUnrenderableTextures()); @@ -954,7 +951,7 @@ EXPECT_TRUE(manager_->HaveUnrenderableTextures()); // Make mips. - manager_->MarkMipmapsGenerated(texture_ref_.get()); + EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get())); EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); EXPECT_TRUE(TextureTestHelper::IsCubeComplete(texture)); EXPECT_TRUE(manager_->CanRender(texture_ref_.get())); @@ -974,7 +971,7 @@ gfx::Rect(4, 4)); EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get())); // Make mips. - manager_->MarkMipmapsGenerated(texture_ref_.get()); + EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get())); EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); EXPECT_TRUE(TextureTestHelper::IsCubeComplete(texture)); } @@ -1340,7 +1337,6 @@ EXPECT_TRUE(manager_->HaveUnsafeTextures()); EXPECT_TRUE(manager_->HaveUnclearedMips()); EXPECT_EQ(1, texture->num_uncleared_mips()); - EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get())); manager_->MarkMipmapsGenerated(texture_ref_.get()); EXPECT_TRUE(texture->SafeToRenderFrom()); EXPECT_FALSE(manager_->HaveUnsafeTextures()); @@ -1751,8 +1747,7 @@ LevelInfo level0(GL_TEXTURE_2D, GL_RGBA, 4, 4, 1, 0, GL_UNSIGNED_BYTE, gfx::Rect(4, 4)); SetLevelInfo(texture_ref_.get(), 0, level0); - EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get())); - manager_->MarkMipmapsGenerated(texture_ref_.get()); + EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get())); EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); LevelInfo level1 = GetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1); LevelInfo level2 = GetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 2); @@ -1764,8 +1759,7 @@ manager_->SetTarget(texture2_.get(), GL_TEXTURE_2D); SetLevelInfo(texture2_.get(), 0, LevelInfo(GL_TEXTURE_2D, GL_RGBA, 16, 16, 1, 0, GL_UNSIGNED_BYTE, gfx::Rect())); - EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get())); - manager_->MarkMipmapsGenerated(texture2_.get()); + EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture2_.get())); texture = texture2_->texture(); EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); EXPECT_EQ(1024U + 256U + 64U + 16U + 4U, texture->estimated_size());
diff --git a/ios/chrome/browser/sync/ios_chrome_profile_sync_test_util.cc b/ios/chrome/browser/sync/ios_chrome_profile_sync_test_util.cc index 556651f..624e578 100644 --- a/ios/chrome/browser/sync/ios_chrome_profile_sync_test_util.cc +++ b/ios/chrome/browser/sync/ios_chrome_profile_sync_test_util.cc
@@ -5,8 +5,8 @@ #include "ios/chrome/browser/sync/ios_chrome_profile_sync_test_util.h" #include "base/bind.h" -#include "base/time/time.h" #include "components/browser_sync/browser/profile_sync_service_mock.h" +#include "components/browser_sync/browser/profile_sync_test_util.h" #include "components/signin/core/browser/profile_oauth2_token_service.h" #include "components/signin/core/browser/signin_manager.h" #include "components/sync_driver/signin_manager_wrapper.h" @@ -17,14 +17,6 @@ #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/web/public/web_thread.h" -namespace { - -void EmptyNetworkTimeUpdate(const base::Time&, - const base::TimeDelta&, - const base::TimeDelta&) {} - -} // namespace - ProfileSyncService::InitParams CreateProfileSyncServiceParamsForTest( scoped_ptr<sync_driver::SyncClient> sync_client, ios::ChromeBrowserState* browser_state) { @@ -39,7 +31,7 @@ sync_client ? std::move(sync_client) : make_scoped_ptr(new IOSChromeSyncClient(browser_state)); init_params.network_time_update_callback = - base::Bind(&EmptyNetworkTimeUpdate); + base::Bind(&browser_sync::EmptyNetworkTimeUpdate); init_params.base_directory = browser_state->GetStatePath(); init_params.url_request_context = browser_state->GetRequestContext(); init_params.debug_identifier = browser_state->GetDebugName();
diff --git a/ios/net/cookies/cookie_store_ios_unittest.mm b/ios/net/cookies/cookie_store_ios_unittest.mm index 9bb977f6..7271abd 100644 --- a/ios/net/cookies/cookie_store_ios_unittest.mm +++ b/ios/net/cookies/cookie_store_ios_unittest.mm
@@ -208,8 +208,11 @@ std::vector<net::CanonicalCookie*> cookies; net::CookieOptions options; options.set_include_httponly(); - cookies.push_back(net::CanonicalCookie::Create(kTestCookieURL, "a=b", - base::Time::Now(), options)); + + scoped_ptr<net::CanonicalCookie> cookie(net::CanonicalCookie::Create( + kTestCookieURL, "a=b", base::Time::Now(), options)); + cookies.push_back(cookie.release()); + // Some canonical cookies cannot be converted into System cookies, for // example if value is not valid utf8. Such cookies are ignored. net::CanonicalCookie* bad_canonical_cookie = new net::CanonicalCookie(
diff --git a/ios/web/app/web_main_loop.mm b/ios/web/app/web_main_loop.mm index 05b3ee28..be504e0d 100644 --- a/ios/web/app/web_main_loop.mm +++ b/ios/web/app/web_main_loop.mm
@@ -24,6 +24,7 @@ #include "ios/web/public/app/web_main_parts.h" #include "ios/web/public/web_client.h" #include "ios/web/web_thread_impl.h" +#include "ios/web/webui/url_data_manager_ios.h" #include "net/base/network_change_notifier.h" namespace web { @@ -252,6 +253,8 @@ // more head start for those operations to finish. WebThreadImpl::ShutdownThreadPool(); + URLDataManagerIOS::DeleteDataSources(); + if (parts_) { parts_->PostDestroyThreads(); }
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm index f89ae845..32d2ec65 100644 --- a/ios/web/web_state/ui/crw_web_controller.mm +++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -2795,7 +2795,7 @@ // that errors reported following the 'NO' reply can be safely ignored. if ([self shouldClosePageOnNativeApplicationLoad]) [_delegate webPageOrderedClose]; - [self abortLoad]; + [self stopLoading]; [_openedApplicationURL addObject:request.URL]; return NO; }
diff --git a/mandoline/ui/desktop_ui/browser_window.cc b/mandoline/ui/desktop_ui/browser_window.cc index eba87b61..0285ec8 100644 --- a/mandoline/ui/desktop_ui/browser_window.cc +++ b/mandoline/ui/desktop_ui/browser_window.cc
@@ -212,31 +212,31 @@ host_->AddAccelerator( static_cast<uint32_t>(BrowserCommand::CLOSE), - mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_W, - mus::mojom::EVENT_FLAGS_CONTROL_DOWN), + mus::CreateKeyMatcher(mus::mojom::KeyboardCode::W, + mus::mojom::kEventFlagControlDown), mus::mojom::WindowTreeHost::AddAcceleratorCallback()); host_->AddAccelerator( static_cast<uint32_t>(BrowserCommand::FOCUS_OMNIBOX), - mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_L, - mus::mojom::EVENT_FLAGS_CONTROL_DOWN), + mus::CreateKeyMatcher(mus::mojom::KeyboardCode::L, + mus::mojom::kEventFlagControlDown), mus::mojom::WindowTreeHost::AddAcceleratorCallback()); host_->AddAccelerator( static_cast<uint32_t>(BrowserCommand::NEW_WINDOW), - mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, - mus::mojom::EVENT_FLAGS_CONTROL_DOWN), + mus::CreateKeyMatcher(mus::mojom::KeyboardCode::N, + mus::mojom::kEventFlagControlDown), mus::mojom::WindowTreeHost::AddAcceleratorCallback()); host_->AddAccelerator( static_cast<uint32_t>(BrowserCommand::SHOW_FIND), - mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_F, - mus::mojom::EVENT_FLAGS_CONTROL_DOWN), + mus::CreateKeyMatcher(mus::mojom::KeyboardCode::F, + mus::mojom::kEventFlagControlDown), mus::mojom::WindowTreeHost::AddAcceleratorCallback()); host_->AddAccelerator(static_cast<uint32_t>(BrowserCommand::GO_BACK), - mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_LEFT, - mus::mojom::EVENT_FLAGS_ALT_DOWN), + mus::CreateKeyMatcher(mus::mojom::KeyboardCode::LEFT, + mus::mojom::kEventFlagAltDown), mus::mojom::WindowTreeHost::AddAcceleratorCallback()); host_->AddAccelerator(static_cast<uint32_t>(BrowserCommand::GO_FORWARD), - mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_RIGHT, - mus::mojom::EVENT_FLAGS_ALT_DOWN), + mus::CreateKeyMatcher(mus::mojom::KeyboardCode::RIGHT, + mus::mojom::kEventFlagAltDown), mus::mojom::WindowTreeHost::AddAcceleratorCallback()); // Now that we're ready, load the default url. LoadURL(default_url_); @@ -319,8 +319,8 @@ web_view::mojom::ButtonState back_button, web_view::mojom::ButtonState forward_button) { toolbar_view_->SetBackForwardEnabled( - back_button == web_view::mojom::ButtonState::BUTTON_STATE_ENABLED, - forward_button == web_view::mojom::ButtonState::BUTTON_STATE_ENABLED); + back_button == web_view::mojom::ButtonState::ENABLED, + forward_button == web_view::mojom::ButtonState::ENABLED); } void BrowserWindow::TitleChanged(const mojo::String& title) { @@ -408,7 +408,7 @@ views::Widget::InitParams params( views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); params.native_widget = new views::NativeWidgetMus( - widget, app_->shell(), root, mus::mojom::SURFACE_TYPE_DEFAULT); + widget, app_->shell(), root, mus::mojom::SurfaceType::DEFAULT); params.delegate = widget_delegate; params.bounds = root_->bounds(); widget->Init(params);
diff --git a/mandoline/ui/omnibox/omnibox_application.cc b/mandoline/ui/omnibox/omnibox_application.cc index dec5c76..0479f4a 100644 --- a/mandoline/ui/omnibox/omnibox_application.cc +++ b/mandoline/ui/omnibox/omnibox_application.cc
@@ -144,7 +144,7 @@ views::Widget::InitParams params( views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); params.native_widget = new views::NativeWidgetMus( - widget, app_->shell(), root, mus::mojom::SURFACE_TYPE_DEFAULT); + widget, app_->shell(), root, mus::mojom::SurfaceType::DEFAULT); params.delegate = widget_delegate; params.bounds = root->bounds(); params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
diff --git a/mash/browser_driver/browser_driver_application_delegate.cc b/mash/browser_driver/browser_driver_application_delegate.cc index ebd41dc..62fdccf 100644 --- a/mash/browser_driver/browser_driver_application_delegate.cc +++ b/mash/browser_driver/browser_driver_application_delegate.cc
@@ -24,20 +24,18 @@ struct AcceleratorSpec { Accelerator id; mus::mojom::KeyboardCode keyboard_code; - mus::mojom::EventFlags event_flags; + // A bitfield of kEventFlag* and kMouseEventFlag* values in + // input_event_constants.mojom. + int event_flags; }; AcceleratorSpec g_spec[] = { - { Accelerator::NewWindow, - mus::mojom::KEYBOARD_CODE_N, - mus::mojom::EVENT_FLAGS_CONTROL_DOWN }, - { Accelerator::NewTab, - mus::mojom::KEYBOARD_CODE_T, - mus::mojom::EVENT_FLAGS_CONTROL_DOWN }, - { Accelerator::NewIncognitoWindow, - mus::mojom::KEYBOARD_CODE_N, - static_cast<mus::mojom::EventFlags>(mus::mojom::EVENT_FLAGS_CONTROL_DOWN | - mus::mojom::EVENT_FLAGS_SHIFT_DOWN) }, + {Accelerator::NewWindow, mus::mojom::KeyboardCode::N, + mus::mojom::kEventFlagControlDown}, + {Accelerator::NewTab, mus::mojom::KeyboardCode::T, + mus::mojom::kEventFlagControlDown}, + {Accelerator::NewIncognitoWindow, mus::mojom::KeyboardCode::N, + mus::mojom::kEventFlagControlDown | mus::mojom::kEventFlagShiftDown}, }; void AssertTrue(bool success) {
diff --git a/mash/shelf/shelf_application.cc b/mash/shelf/shelf_application.cc index 4656978..cb829fe 100644 --- a/mash/shelf/shelf_application.cc +++ b/mash/shelf/shelf_application.cc
@@ -35,11 +35,11 @@ std::map<std::string, std::vector<uint8_t>> properties; properties[mash::wm::mojom::kWindowContainer_Property] = mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert( - mash::wm::mojom::CONTAINER_USER_SHELF); + static_cast<int32_t>(mash::wm::mojom::Container::USER_SHELF)); mus::Window* window = views::WindowManagerConnection::Get()->NewWindow(properties); params.native_widget = new views::NativeWidgetMus( - widget, app->shell(), window, mus::mojom::SURFACE_TYPE_DEFAULT); + widget, app->shell(), window, mus::mojom::SurfaceType::DEFAULT); widget->Init(params); widget->Show(); }
diff --git a/mash/wallpaper/wallpaper.cc b/mash/wallpaper/wallpaper.cc index 07e35718..fa86f6db 100644 --- a/mash/wallpaper/wallpaper.cc +++ b/mash/wallpaper/wallpaper.cc
@@ -58,11 +58,11 @@ std::map<std::string, std::vector<uint8_t>> properties; properties[mash::wm::mojom::kWindowContainer_Property] = mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert( - mash::wm::mojom::CONTAINER_USER_BACKGROUND); + static_cast<int32_t>(mash::wm::mojom::Container::USER_BACKGROUND)); mus::Window* window = views::WindowManagerConnection::Get()->NewWindow(properties); params.native_widget = new views::NativeWidgetMus( - widget, app->shell(), window, mus::mojom::SURFACE_TYPE_DEFAULT); + widget, app->shell(), window, mus::mojom::SurfaceType::DEFAULT); widget->Init(params); widget->Show(); }
diff --git a/mash/wm/accelerator_registrar_apptest.cc b/mash/wm/accelerator_registrar_apptest.cc index eaccd5b2..083f8c8 100644 --- a/mash/wm/accelerator_registrar_apptest.cc +++ b/mash/wm/accelerator_registrar_apptest.cc
@@ -88,13 +88,13 @@ ConnectToRegistrar(®istrar_first); TestAcceleratorHandler handler_first(std::move(registrar_first)); EXPECT_TRUE(handler_first.AttemptToInstallAccelerator( - 1, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_T, - mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); + 1, mus::CreateKeyMatcher(mus::mojom::KeyboardCode::T, + mus::mojom::kEventFlagShiftDown))); // Attempting to add an accelerator with the same accelerator id from the same // registrar should fail. EXPECT_FALSE(handler_first.AttemptToInstallAccelerator( - 1, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, - mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); + 1, mus::CreateKeyMatcher(mus::mojom::KeyboardCode::N, + mus::mojom::kEventFlagShiftDown))); // Attempting to add an accelerator with the same id from a different // registrar should be OK. @@ -102,16 +102,16 @@ ConnectToRegistrar(®istrar_second); TestAcceleratorHandler handler_second(std::move(registrar_second)); EXPECT_TRUE(handler_second.AttemptToInstallAccelerator( - 1, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, - mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); + 1, mus::CreateKeyMatcher(mus::mojom::KeyboardCode::N, + mus::mojom::kEventFlagShiftDown))); // But attempting to add an accelerator with the same matcher should fail. EXPECT_FALSE(handler_first.AttemptToInstallAccelerator( - 3, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, - mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); + 3, mus::CreateKeyMatcher(mus::mojom::KeyboardCode::N, + mus::mojom::kEventFlagShiftDown))); EXPECT_FALSE(handler_second.AttemptToInstallAccelerator( - 3, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, - mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); + 3, mus::CreateKeyMatcher(mus::mojom::KeyboardCode::N, + mus::mojom::kEventFlagShiftDown))); } } // namespace wm
diff --git a/mash/wm/frame/move_event_handler.cc b/mash/wm/frame/move_event_handler.cc index 7b6393d..448e51ad 100644 --- a/mash/wm/frame/move_event_handler.cc +++ b/mash/wm/frame/move_event_handler.cc
@@ -20,21 +20,21 @@ mus::mojom::Cursor CursorForWindowComponent(int window_component) { switch (window_component) { case HTBOTTOM: - return mus::mojom::Cursor::CURSOR_SOUTH_RESIZE; + return mus::mojom::Cursor::SOUTH_RESIZE; case HTBOTTOMLEFT: - return mus::mojom::Cursor::CURSOR_SOUTH_WEST_RESIZE; + return mus::mojom::Cursor::SOUTH_WEST_RESIZE; case HTBOTTOMRIGHT: - return mus::mojom::Cursor::CURSOR_SOUTH_EAST_RESIZE; + return mus::mojom::Cursor::SOUTH_EAST_RESIZE; case HTLEFT: - return mus::mojom::Cursor::CURSOR_WEST_RESIZE; + return mus::mojom::Cursor::WEST_RESIZE; case HTRIGHT: - return mus::mojom::Cursor::CURSOR_EAST_RESIZE; + return mus::mojom::Cursor::EAST_RESIZE; case HTTOP: - return mus::mojom::Cursor::CURSOR_NORTH_RESIZE; + return mus::mojom::Cursor::NORTH_RESIZE; case HTTOPLEFT: - return mus::mojom::Cursor::CURSOR_NORTH_WEST_RESIZE; + return mus::mojom::Cursor::NORTH_WEST_RESIZE; case HTTOPRIGHT: - return mus::mojom::Cursor::CURSOR_NORTH_EAST_RESIZE; + return mus::mojom::Cursor::NORTH_EAST_RESIZE; default: return mus::mojom::Cursor::CURSOR_NULL; }
diff --git a/mash/wm/frame/move_loop.cc b/mash/wm/frame/move_loop.cc index ca37b08..1aac3ce 100644 --- a/mash/wm/frame/move_loop.cc +++ b/mash/wm/frame/move_loop.cc
@@ -23,11 +23,10 @@ event.pointer_data->location->screen_y)); } -mus::mojom::EventFlags MouseOnlyEventFlags(mus::mojom::EventFlags flags) { - return static_cast<mus::mojom::EventFlags>( - flags & (mus::mojom::EVENT_FLAGS_LEFT_MOUSE_BUTTON | - mus::mojom::EVENT_FLAGS_MIDDLE_MOUSE_BUTTON | - mus::mojom::EVENT_FLAGS_RIGHT_MOUSE_BUTTON)); +int MouseOnlyEventFlags(int flags) { + return flags & (mus::mojom::kEventFlagLeftMouseButton | + mus::mojom::kEventFlagMiddleMouseButton | + mus::mojom::kEventFlagRightMouseButton); } } // namespace @@ -41,11 +40,11 @@ scoped_ptr<MoveLoop> MoveLoop::Create(mus::Window* target, int ht_location, const mus::mojom::Event& event) { - DCHECK_EQ(event.action, mus::mojom::EVENT_TYPE_POINTER_DOWN); + DCHECK_EQ(event.action, mus::mojom::EventType::POINTER_DOWN); // Start a move on left mouse, or any other type of pointer. - if (event.pointer_data->kind == mus::mojom::POINTER_KIND_MOUSE && + if (event.pointer_data->kind == mus::mojom::PointerKind::MOUSE && MouseOnlyEventFlags(event.flags) != - mus::mojom::EVENT_FLAGS_LEFT_MOUSE_BUTTON) { + mus::mojom::kEventFlagLeftMouseButton) { return nullptr; } @@ -60,7 +59,7 @@ MoveLoop::MoveResult MoveLoop::Move(const mus::mojom::Event& event) { switch (event.action) { - case mus::mojom::EVENT_TYPE_POINTER_CANCEL: + case mus::mojom::EventType::POINTER_CANCEL: if (event.pointer_data->pointer_id == pointer_id_) { if (target_) Revert(); @@ -68,12 +67,12 @@ } return MoveResult::CONTINUE; - case mus::mojom::EVENT_TYPE_POINTER_MOVE: + case mus::mojom::EventType::POINTER_MOVE: if (target_ && event.pointer_data->pointer_id == pointer_id_) MoveImpl(event); return MoveResult::CONTINUE; - case mus::mojom::EVENT_TYPE_POINTER_UP: + case mus::mojom::EventType::POINTER_UP: if (event.pointer_data->pointer_id == pointer_id_) { // TODO(sky): need to support changed_flags. if (target_)
diff --git a/mash/wm/non_client_frame_controller.cc b/mash/wm/non_client_frame_controller.cc index 1db0627..9857676c 100644 --- a/mash/wm/non_client_frame_controller.cc +++ b/mash/wm/non_client_frame_controller.cc
@@ -93,7 +93,7 @@ : NativeWidgetMus(delegate, shell, window, - mus::mojom::SURFACE_TYPE_UNDERLAY) {} + mus::mojom::SurfaceType::UNDERLAY) {} ~WmNativeWidgetMus() override { } @@ -221,20 +221,20 @@ bool NonClientFrameController::CanResize() const { return window_ && - (GetResizeBehavior(window_) & - mus::mojom::RESIZE_BEHAVIOR_CAN_RESIZE) != 0; + (GetResizeBehavior(window_) & mus::mojom::kResizeBehaviorCanResize) != + 0; } bool NonClientFrameController::CanMaximize() const { return window_ && (GetResizeBehavior(window_) & - mus::mojom::RESIZE_BEHAVIOR_CAN_MAXIMIZE) != 0; + mus::mojom::kResizeBehaviorCanMaximize) != 0; } bool NonClientFrameController::CanMinimize() const { return window_ && (GetResizeBehavior(window_) & - mus::mojom::RESIZE_BEHAVIOR_CAN_MINIMIZE) != 0; + mus::mojom::kResizeBehaviorCanMinimize) != 0; } views::ClientView* NonClientFrameController::CreateClientView(
diff --git a/mash/wm/property_util.cc b/mash/wm/property_util.cc index 67b11b6..5fa4931 100644 --- a/mash/wm/property_util.cc +++ b/mash/wm/property_util.cc
@@ -27,7 +27,7 @@ window->GetSharedProperty<int32_t>( mus::mojom::WindowManager::kShowState_Property)); } - return mus::mojom::SHOW_STATE_RESTORED; + return mus::mojom::ShowState::RESTORED; } void SetWindowUserSetBounds(mus::Window* window, const gfx::Rect& bounds) { @@ -68,17 +68,16 @@ return static_cast<mojom::Container>( window->GetSharedProperty<int32_t>(mojom::kWindowContainer_Property)); } - return mojom::CONTAINER_USER_WINDOWS; + return mojom::Container::USER_WINDOWS; } -mus::mojom::ResizeBehavior GetResizeBehavior(const mus::Window* window) { +int32_t GetResizeBehavior(const mus::Window* window) { if (window->HasSharedProperty( mus::mojom::WindowManager::kResizeBehavior_Property)) { - return static_cast<mus::mojom::ResizeBehavior>( - window->GetSharedProperty<int32_t>( - mus::mojom::WindowManager::kResizeBehavior_Property)); + return window->GetSharedProperty<int32_t>( + mus::mojom::WindowManager::kResizeBehavior_Property); } - return mus::mojom::RESIZE_BEHAVIOR_NONE; + return mus::mojom::kResizeBehaviorNone; } void SetRestoreBounds(mus::Window* window, const gfx::Rect& bounds) { @@ -116,7 +115,7 @@ mojo::TypeConverter<int32_t, const std::vector<uint8_t>>::Convert( iter->second)); } - return mus::mojom::WINDOW_TYPE_POPUP; + return mus::mojom::WindowType::POPUP; } } // namespace wm
diff --git a/mash/wm/property_util.h b/mash/wm/property_util.h index 04b540a..54b21c7 100644 --- a/mash/wm/property_util.h +++ b/mash/wm/property_util.h
@@ -37,7 +37,9 @@ mojom::Container GetRequestedContainer(const mus::Window* window); -mus::mojom::ResizeBehavior GetResizeBehavior(const mus::Window* window); +// Returns a bitfield of kResizeBehavior* values from +// window_manager_constants.mojom. +int32_t GetResizeBehavior(const mus::Window* window); void SetRestoreBounds(mus::Window* window, const gfx::Rect& bounds); gfx::Rect GetRestoreBounds(const mus::Window* window);
diff --git a/mash/wm/public/interfaces/user_window_controller.mojom b/mash/wm/public/interfaces/user_window_controller.mojom index 6753ceb..1fd7cb0 100644 --- a/mash/wm/public/interfaces/user_window_controller.mojom +++ b/mash/wm/public/interfaces/user_window_controller.mojom
@@ -9,7 +9,7 @@ string window_title; }; -// An observer of user windows within mojom::CONTAINER_USER_WINDOWS. +// An observer of user windows within mojom::Container::USER_WINDOWS. // TODO(msw): Observe focus changes, title/icon changes, etc. interface UserWindowObserver { // Called when the observer is first added to supply the initial state. @@ -25,4 +25,4 @@ interface UserWindowController { AddUserWindowObserver(UserWindowObserver observer); FocusUserWindow(uint32 window_id); -}; \ No newline at end of file +};
diff --git a/mash/wm/user_window_controller_impl.cc b/mash/wm/user_window_controller_impl.cc index 8e29814..eaecadd 100644 --- a/mash/wm/user_window_controller_impl.cc +++ b/mash/wm/user_window_controller_impl.cc
@@ -80,7 +80,7 @@ } mus::Window* UserWindowControllerImpl::GetUserWindowContainer() const { - return state_->GetWindowForContainer(mojom::CONTAINER_USER_WINDOWS); + return state_->GetWindowForContainer(mojom::Container::USER_WINDOWS); } void UserWindowControllerImpl::OnTreeChanging(const TreeChangeParams& params) {
diff --git a/mash/wm/window_layout.cc b/mash/wm/window_layout.cc index 1a590f5..3cd6807 100644 --- a/mash/wm/window_layout.cc +++ b/mash/wm/window_layout.cc
@@ -35,12 +35,12 @@ // Transient windows should be opened centered within their parent. switch (show_state) { - case mus::mojom::SHOW_STATE_MAXIMIZED: - case mus::mojom::SHOW_STATE_IMMERSIVE: - case mus::mojom::SHOW_STATE_PRESENTATION: + case mus::mojom::ShowState::MAXIMIZED: + case mus::mojom::ShowState::IMMERSIVE: + case mus::mojom::ShowState::PRESENTATION: FitToContainer(window); break; - case mus::mojom::SHOW_STATE_RESTORED: { + case mus::mojom::ShowState::RESTORED: { if (!user_set_bounds.IsEmpty()) { // If the bounds are unchanged, this will do nothing. window->SetBounds(user_set_bounds); @@ -48,7 +48,7 @@ CenterWindow(window, preferred_size); } } - case mus::mojom::SHOW_STATE_MINIMIZED: + case mus::mojom::ShowState::MINIMIZED: break; default: NOTREACHED(); @@ -64,7 +64,7 @@ // TODO(sky): this feels like the wrong place for this logic. Find a better // place. if (name == mus::mojom::WindowManager::kShowState_Property && - GetWindowShowState(window) == mus::mojom::SHOW_STATE_MAXIMIZED) { + GetWindowShowState(window) == mus::mojom::ShowState::MAXIMIZED) { SetRestoreBounds(window, window->bounds()); } LayoutManager::OnWindowSharedPropertyChanged(window, name, old_data,
diff --git a/mash/wm/window_manager_application.cc b/mash/wm/window_manager_application.cc index 4436e2e7..1d5da1614 100644 --- a/mash/wm/window_manager_application.cc +++ b/mash/wm/window_manager_application.cc
@@ -64,8 +64,8 @@ void WindowManagerApplication::AddAccelerators() { window_tree_host_->AddAccelerator( kWindowSwitchCmd, - mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_TAB, - mus::mojom::EVENT_FLAGS_CONTROL_DOWN), + mus::CreateKeyMatcher(mus::mojom::KeyboardCode::TAB, + mus::mojom::kEventFlagControlDown), base::Bind(&AssertTrue)); } @@ -120,13 +120,13 @@ root_->AddObserver(this); CreateContainers(); background_layout_.reset(new BackgroundLayout( - GetWindowForContainer(mojom::CONTAINER_USER_BACKGROUND))); + GetWindowForContainer(mojom::Container::USER_BACKGROUND))); shelf_layout_.reset( - new ShelfLayout(GetWindowForContainer(mojom::CONTAINER_USER_SHELF))); + new ShelfLayout(GetWindowForContainer(mojom::Container::USER_SHELF))); - mus::Window* window = GetWindowForContainer(mojom::CONTAINER_USER_WINDOWS); + mus::Window* window = GetWindowForContainer(mojom::Container::USER_WINDOWS); window_layout_.reset( - new WindowLayout(GetWindowForContainer(mojom::CONTAINER_USER_WINDOWS))); + new WindowLayout(GetWindowForContainer(mojom::Container::USER_WINDOWS))); window_tree_host_->AddActivationParent(window->id()); window_tree_host_->SetTitle("Mash"); @@ -213,8 +213,9 @@ void WindowManagerApplication::CreateContainers() { for (uint16_t container = - static_cast<uint16_t>(mojom::CONTAINER_ALL_USER_BACKGROUND); - container < static_cast<uint16_t>(mojom::CONTAINER_COUNT); ++container) { + static_cast<uint16_t>(mojom::Container::ALL_USER_BACKGROUND); + container < static_cast<uint16_t>(mojom::Container::COUNT); + ++container) { mus::Window* window = root_->connection()->NewWindow(); DCHECK_EQ(mus::LoWord(window->id()), container) << "Containers must be created before other windows!";
diff --git a/mash/wm/window_manager_impl.cc b/mash/wm/window_manager_impl.cc index 5195c1f..dd649c5 100644 --- a/mash/wm/window_manager_impl.cc +++ b/mash/wm/window_manager_impl.cc
@@ -92,7 +92,7 @@ DCHECK(root); const bool provide_non_client_frame = - GetWindowType(*properties) == mus::mojom::WINDOW_TYPE_WINDOW; + GetWindowType(*properties) == mus::mojom::WindowType::WINDOW; if (provide_non_client_frame) (*properties)[mus::mojom::kWaitForUnderlay_Property].clear();
diff --git a/media/blink/webmediaplayer_cast_android.cc b/media/blink/webmediaplayer_cast_android.cc index 1b74b7af..fc3de1c 100644 --- a/media/blink/webmediaplayer_cast_android.cc +++ b/media/blink/webmediaplayer_cast_android.cc
@@ -249,7 +249,7 @@ is_remote_ = true; initializing_ = true; paused_ = false; - if (delegate_ && is_remote_) + if (delegate_) delegate_->DidPlay(webmediaplayer_); client_->playbackStateChanged(); @@ -273,13 +273,11 @@ player_manager_->Start(player_id_); remote_time_at_ = base::TimeTicks::Now(); paused_ = false; - if (delegate_ && is_remote_) + if (delegate_) delegate_->DidPlay(webmediaplayer_); } void WebMediaPlayerCast::pause() { - if (paused_) - return; player_manager_->Pause(player_id_, true); } @@ -292,7 +290,7 @@ DVLOG(1) << __FUNCTION__; if (!paused_) { paused_ = true; - if (delegate_ && is_remote_) + if (delegate_) delegate_->DidPause(webmediaplayer_); } is_remote_ = false; @@ -310,13 +308,10 @@ void WebMediaPlayerCast::OnMediaPlayerPlay() { DVLOG(1) << __FUNCTION__ << " is_remote_ = " << is_remote_; initializing_ = false; - if (paused_) { + if (is_remote_ && paused_) { paused_ = false; - if (delegate_ && paused_ && is_remote_) + if (paused_) delegate_->DidPlay(webmediaplayer_); - if (!is_remote_) - webmediaplayer_->play(); - remote_time_at_ = base::TimeTicks::Now(); client_->playbackStateChanged(); } @@ -327,12 +322,10 @@ void WebMediaPlayerCast::OnMediaPlayerPause() { DVLOG(1) << __FUNCTION__ << " is_remote_ = " << is_remote_; - if (!paused_) { + if (is_remote_ && !paused_) { paused_ = true; - if (delegate_ && is_remote_) + if (delegate_) delegate_->DidPause(webmediaplayer_); - if (!is_remote_) - webmediaplayer_->pause(); client_->playbackStateChanged(); } }
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc index 463a61cb..e56b4bb 100644 --- a/media/blink/webmediaplayer_impl.cc +++ b/media/blink/webmediaplayer_impl.cc
@@ -318,8 +318,8 @@ DCHECK(main_task_runner_->BelongsToCurrentThread()); #if defined(OS_ANDROID) // WMPI_CAST - cast_impl_.play(); if (isRemote()) { + cast_impl_.play(); return; } #endif @@ -344,8 +344,8 @@ paused_ = true; #if defined(OS_ANDROID) // WMPI_CAST - cast_impl_.pause(); if (isRemote()) { + cast_impl_.pause(); return; } #endif
diff --git a/media/mojo/interfaces/decryptor.mojom b/media/mojo/interfaces/decryptor.mojom index 64e1b63..d063e6b 100644 --- a/media/mojo/interfaces/decryptor.mojom +++ b/media/mojo/interfaces/decryptor.mojom
@@ -16,7 +16,8 @@ SUCCESS, // Successfully completed. Decrypted buffer ready. NO_KEY, // No key is available to decrypt. NEED_MORE_DATA, // Decoder needs more data to produce an output. - ERROR // Key is available but an error occurred during decryption. + // Key is available but an error occurred during decryption. + DECRYPTION_ERROR }; // Pass the two data pipes used to transfer DecoderBuffer contents to and
diff --git a/media/mojo/interfaces/media_types.mojom b/media/mojo/interfaces/media_types.mojom index 3890b2a0..91f1619 100644 --- a/media/mojo/interfaces/media_types.mojom +++ b/media/mojo/interfaces/media_types.mojom
@@ -38,8 +38,6 @@ // See media/base/channel_layout.h for descriptions. // Kept in sync with media::ChannelLayout via static_asserts. -// TODO(tim): The bindings generators will always prepend the enum name, should -// mojom therefore allow enum values starting with numbers? enum ChannelLayout { k_NONE = 0, k_UNSUPPORTED = 1,
diff --git a/media/mojo/services/media_type_converters.cc b/media/mojo/services/media_type_converters.cc index 2c854fc..a498710 100644 --- a/media/mojo/services/media_type_converters.cc +++ b/media/mojo/services/media_type_converters.cc
@@ -25,12 +25,12 @@ namespace mojo { -#define ASSERT_ENUM_EQ(media_enum, media_prefix, mojo_prefix, value) \ - static_assert(media::media_prefix##value == \ - static_cast<media::media_enum>( \ - media::interfaces::mojo_prefix##value), \ - "Mismatched enum: " #media_prefix #value \ - " != " #mojo_prefix #value) +#define ASSERT_ENUM_EQ(media_enum, media_prefix, mojo_prefix, value) \ + static_assert(media::media_prefix##value == \ + static_cast<media::media_enum>( \ + media::interfaces::media_enum::mojo_prefix##value), \ + "Mismatched enum: " #media_prefix #value " != " #media_enum \ + "::" #mojo_prefix #value) #define ASSERT_ENUM_EQ_RAW(media_enum, media_enum_value, mojo_enum_value) \ static_assert( \ @@ -39,220 +39,188 @@ "Mismatched enum: " #media_enum_value " != " #mojo_enum_value) // BufferingState. -ASSERT_ENUM_EQ(BufferingState, BUFFERING_, BUFFERING_STATE_, HAVE_NOTHING); -ASSERT_ENUM_EQ(BufferingState, BUFFERING_, BUFFERING_STATE_, HAVE_ENOUGH); +ASSERT_ENUM_EQ(BufferingState, BUFFERING_, , HAVE_NOTHING); +ASSERT_ENUM_EQ(BufferingState, BUFFERING_, , HAVE_ENOUGH); // AudioCodec. -ASSERT_ENUM_EQ_RAW(AudioCodec, kUnknownAudioCodec, AUDIO_CODEC_UNKNOWN); -ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, AAC); -ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, MP3); -ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, PCM); -ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, Vorbis); -ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, FLAC); -ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, AMR_NB); -ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, PCM_MULAW); -ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, GSM_MS); -ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, PCM_S16BE); -ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, PCM_S24BE); -ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, Opus); -ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, EAC3); -ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, PCM_ALAW); -ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, ALAC); -ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, AC3); -ASSERT_ENUM_EQ_RAW(AudioCodec, kAudioCodecMax, AUDIO_CODEC_MAX); +ASSERT_ENUM_EQ_RAW(AudioCodec, kUnknownAudioCodec, AudioCodec::UNKNOWN); +ASSERT_ENUM_EQ(AudioCodec, kCodec, , AAC); +ASSERT_ENUM_EQ(AudioCodec, kCodec, , MP3); +ASSERT_ENUM_EQ(AudioCodec, kCodec, , PCM); +ASSERT_ENUM_EQ(AudioCodec, kCodec, , Vorbis); +ASSERT_ENUM_EQ(AudioCodec, kCodec, , FLAC); +ASSERT_ENUM_EQ(AudioCodec, kCodec, , AMR_NB); +ASSERT_ENUM_EQ(AudioCodec, kCodec, , PCM_MULAW); +ASSERT_ENUM_EQ(AudioCodec, kCodec, , GSM_MS); +ASSERT_ENUM_EQ(AudioCodec, kCodec, , PCM_S16BE); +ASSERT_ENUM_EQ(AudioCodec, kCodec, , PCM_S24BE); +ASSERT_ENUM_EQ(AudioCodec, kCodec, , Opus); +ASSERT_ENUM_EQ(AudioCodec, kCodec, , EAC3); +ASSERT_ENUM_EQ(AudioCodec, kCodec, , PCM_ALAW); +ASSERT_ENUM_EQ(AudioCodec, kCodec, , ALAC); +ASSERT_ENUM_EQ(AudioCodec, kCodec, , AC3); +ASSERT_ENUM_EQ_RAW(AudioCodec, kAudioCodecMax, AudioCodec::MAX); // ChannelLayout. -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _NONE); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _UNSUPPORTED); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _MONO); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _STEREO); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _2_1); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _SURROUND); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _4_0); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _2_2); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _QUAD); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _5_0); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _5_1); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _5_0_BACK); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _5_1_BACK); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _7_0); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _7_1); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _7_1_WIDE); -ASSERT_ENUM_EQ(ChannelLayout, - CHANNEL_LAYOUT, - CHANNEL_LAYOUT_k, - _STEREO_DOWNMIX); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _2POINT1); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _3_1); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _4_1); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _6_0); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _6_0_FRONT); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _HEXAGONAL); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _6_1); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _6_1_BACK); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _6_1_FRONT); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _7_0_FRONT); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _7_1_WIDE_BACK); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _OCTAGONAL); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _DISCRETE); -ASSERT_ENUM_EQ(ChannelLayout, - CHANNEL_LAYOUT, - CHANNEL_LAYOUT_k, - _STEREO_AND_KEYBOARD_MIC); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _4_1_QUAD_SIDE); -ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, CHANNEL_LAYOUT_k, _MAX); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _NONE); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _UNSUPPORTED); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _MONO); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _STEREO); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _2_1); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _SURROUND); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _4_0); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _2_2); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _QUAD); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _5_0); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _5_1); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _5_0_BACK); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _5_1_BACK); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _7_0); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _7_1); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _7_1_WIDE); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _STEREO_DOWNMIX); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _2POINT1); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _3_1); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _4_1); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _6_0); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _6_0_FRONT); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _HEXAGONAL); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _6_1); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _6_1_BACK); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _6_1_FRONT); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _7_0_FRONT); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _7_1_WIDE_BACK); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _OCTAGONAL); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _DISCRETE); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _STEREO_AND_KEYBOARD_MIC); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _4_1_QUAD_SIDE); +ASSERT_ENUM_EQ(ChannelLayout, CHANNEL_LAYOUT, k, _MAX); // SampleFormat. -ASSERT_ENUM_EQ_RAW(SampleFormat, kUnknownSampleFormat, SAMPLE_FORMAT_UNKNOWN); -ASSERT_ENUM_EQ(SampleFormat, kSampleFormat, SAMPLE_FORMAT_, U8); -ASSERT_ENUM_EQ(SampleFormat, kSampleFormat, SAMPLE_FORMAT_, S16); -ASSERT_ENUM_EQ(SampleFormat, kSampleFormat, SAMPLE_FORMAT_, S32); -ASSERT_ENUM_EQ(SampleFormat, kSampleFormat, SAMPLE_FORMAT_, F32); -ASSERT_ENUM_EQ(SampleFormat, kSampleFormat, SAMPLE_FORMAT_, PlanarS16); -ASSERT_ENUM_EQ(SampleFormat, kSampleFormat, SAMPLE_FORMAT_, PlanarF32); -ASSERT_ENUM_EQ(SampleFormat, kSampleFormat, SAMPLE_FORMAT_, Max); +ASSERT_ENUM_EQ_RAW(SampleFormat, kUnknownSampleFormat, SampleFormat::UNKNOWN); +ASSERT_ENUM_EQ(SampleFormat, kSampleFormat, , U8); +ASSERT_ENUM_EQ(SampleFormat, kSampleFormat, , S16); +ASSERT_ENUM_EQ(SampleFormat, kSampleFormat, , S32); +ASSERT_ENUM_EQ(SampleFormat, kSampleFormat, , F32); +ASSERT_ENUM_EQ(SampleFormat, kSampleFormat, , PlanarS16); +ASSERT_ENUM_EQ(SampleFormat, kSampleFormat, , PlanarF32); +ASSERT_ENUM_EQ(SampleFormat, kSampleFormat, , Max); // DemuxerStream Type. Note: Mojo DemuxerStream's don't have the TEXT type. ASSERT_ENUM_EQ_RAW(DemuxerStream::Type, DemuxerStream::UNKNOWN, - DemuxerStream::TYPE_UNKNOWN); + DemuxerStream::Type::UNKNOWN); ASSERT_ENUM_EQ_RAW(DemuxerStream::Type, DemuxerStream::AUDIO, - DemuxerStream::TYPE_AUDIO); + DemuxerStream::Type::AUDIO); ASSERT_ENUM_EQ_RAW(DemuxerStream::Type, DemuxerStream::VIDEO, - DemuxerStream::TYPE_VIDEO); -ASSERT_ENUM_EQ_RAW(DemuxerStream::Type, - DemuxerStream::NUM_TYPES, - DemuxerStream::TYPE_LAST_TYPE + 2); + DemuxerStream::Type::VIDEO); +static_assert(media::DemuxerStream::NUM_TYPES == + static_cast<media::DemuxerStream::Type>( + static_cast<int>( + media::interfaces::DemuxerStream::Type::LAST_TYPE) + + 2), + "Mismatched enum: media::DemuxerStream::NUM_TYPES != " + "media::interfaces::DemuxerStream::Type::LAST_TYPE + 2"); // DemuxerStream Status. ASSERT_ENUM_EQ_RAW(DemuxerStream::Status, DemuxerStream::kOk, - DemuxerStream::STATUS_OK); + DemuxerStream::Status::OK); ASSERT_ENUM_EQ_RAW(DemuxerStream::Status, DemuxerStream::kAborted, - DemuxerStream::STATUS_ABORTED); + DemuxerStream::Status::ABORTED); ASSERT_ENUM_EQ_RAW(DemuxerStream::Status, DemuxerStream::kConfigChanged, - DemuxerStream::STATUS_CONFIG_CHANGED); + DemuxerStream::Status::CONFIG_CHANGED); // VideoFormat. ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_UNKNOWN, - VIDEO_FORMAT_UNKNOWN); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_I420, VIDEO_FORMAT_I420); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_YV12, VIDEO_FORMAT_YV12); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_YV16, VIDEO_FORMAT_YV16); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_YV12A, VIDEO_FORMAT_YV12A); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_YV24, VIDEO_FORMAT_YV24); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_NV12, VIDEO_FORMAT_NV12); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_NV21, VIDEO_FORMAT_NV21); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_UYVY, VIDEO_FORMAT_UYVY); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_YUY2, VIDEO_FORMAT_YUY2); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_ARGB, VIDEO_FORMAT_ARGB); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_XRGB, VIDEO_FORMAT_XRGB); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_RGB24, VIDEO_FORMAT_RGB24); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_RGB32, VIDEO_FORMAT_RGB32); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_MJPEG, VIDEO_FORMAT_MJPEG); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_MT21, VIDEO_FORMAT_MT21); -ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_MAX, VIDEO_FORMAT_FORMAT_MAX); + VideoFormat::UNKNOWN); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_I420, VideoFormat::I420); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_YV12, VideoFormat::YV12); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_YV16, VideoFormat::YV16); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_YV12A, VideoFormat::YV12A); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_YV24, VideoFormat::YV24); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_NV12, VideoFormat::NV12); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_NV21, VideoFormat::NV21); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_UYVY, VideoFormat::UYVY); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_YUY2, VideoFormat::YUY2); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_ARGB, VideoFormat::ARGB); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_XRGB, VideoFormat::XRGB); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_RGB24, VideoFormat::RGB24); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_RGB32, VideoFormat::RGB32); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_MJPEG, VideoFormat::MJPEG); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_MT21, VideoFormat::MT21); +ASSERT_ENUM_EQ_RAW(VideoPixelFormat, PIXEL_FORMAT_MAX, VideoFormat::FORMAT_MAX); // ColorSpace. ASSERT_ENUM_EQ_RAW(ColorSpace, COLOR_SPACE_UNSPECIFIED, - COLOR_SPACE_UNSPECIFIED); -ASSERT_ENUM_EQ_RAW(ColorSpace, COLOR_SPACE_JPEG, COLOR_SPACE_JPEG); -ASSERT_ENUM_EQ_RAW(ColorSpace, COLOR_SPACE_HD_REC709, COLOR_SPACE_HD_REC709); -ASSERT_ENUM_EQ_RAW(ColorSpace, COLOR_SPACE_SD_REC601, COLOR_SPACE_SD_REC601); -ASSERT_ENUM_EQ_RAW(ColorSpace, COLOR_SPACE_MAX, COLOR_SPACE_MAX); + ColorSpace::UNSPECIFIED); +ASSERT_ENUM_EQ_RAW(ColorSpace, COLOR_SPACE_JPEG, ColorSpace::JPEG); +ASSERT_ENUM_EQ_RAW(ColorSpace, COLOR_SPACE_HD_REC709, ColorSpace::HD_REC709); +ASSERT_ENUM_EQ_RAW(ColorSpace, COLOR_SPACE_SD_REC601, ColorSpace::SD_REC601); +ASSERT_ENUM_EQ_RAW(ColorSpace, COLOR_SPACE_MAX, ColorSpace::MAX); // VideoCodec -ASSERT_ENUM_EQ_RAW(VideoCodec, kUnknownVideoCodec, VIDEO_CODEC_UNKNOWN); -ASSERT_ENUM_EQ(VideoCodec, kCodec, VIDEO_CODEC_, H264); -ASSERT_ENUM_EQ(VideoCodec, kCodec, VIDEO_CODEC_, HEVC); -ASSERT_ENUM_EQ(VideoCodec, kCodec, VIDEO_CODEC_, VC1); -ASSERT_ENUM_EQ(VideoCodec, kCodec, VIDEO_CODEC_, MPEG2); -ASSERT_ENUM_EQ(VideoCodec, kCodec, VIDEO_CODEC_, MPEG4); -ASSERT_ENUM_EQ(VideoCodec, kCodec, VIDEO_CODEC_, Theora); -ASSERT_ENUM_EQ(VideoCodec, kCodec, VIDEO_CODEC_, VP8); -ASSERT_ENUM_EQ(VideoCodec, kCodec, VIDEO_CODEC_, VP9); -ASSERT_ENUM_EQ_RAW(VideoCodec, kVideoCodecMax, VIDEO_CODEC_Max); +ASSERT_ENUM_EQ_RAW(VideoCodec, kUnknownVideoCodec, VideoCodec::UNKNOWN); +ASSERT_ENUM_EQ(VideoCodec, kCodec, , H264); +ASSERT_ENUM_EQ(VideoCodec, kCodec, , HEVC); +ASSERT_ENUM_EQ(VideoCodec, kCodec, , VC1); +ASSERT_ENUM_EQ(VideoCodec, kCodec, , MPEG2); +ASSERT_ENUM_EQ(VideoCodec, kCodec, , MPEG4); +ASSERT_ENUM_EQ(VideoCodec, kCodec, , Theora); +ASSERT_ENUM_EQ(VideoCodec, kCodec, , VP8); +ASSERT_ENUM_EQ(VideoCodec, kCodec, , VP9); +ASSERT_ENUM_EQ_RAW(VideoCodec, kVideoCodecMax, VideoCodec::Max); // VideoCodecProfile -ASSERT_ENUM_EQ(VideoCodecProfile, - , - VIDEO_CODEC_PROFILE_, - VIDEO_CODEC_PROFILE_UNKNOWN); -ASSERT_ENUM_EQ(VideoCodecProfile, - , - VIDEO_CODEC_PROFILE_, - VIDEO_CODEC_PROFILE_MIN); -ASSERT_ENUM_EQ(VideoCodecProfile, , VIDEO_CODEC_PROFILE_, H264PROFILE_MIN); -ASSERT_ENUM_EQ(VideoCodecProfile, , VIDEO_CODEC_PROFILE_, H264PROFILE_BASELINE); -ASSERT_ENUM_EQ(VideoCodecProfile, , VIDEO_CODEC_PROFILE_, H264PROFILE_MAIN); -ASSERT_ENUM_EQ(VideoCodecProfile, , VIDEO_CODEC_PROFILE_, H264PROFILE_EXTENDED); -ASSERT_ENUM_EQ(VideoCodecProfile, , VIDEO_CODEC_PROFILE_, H264PROFILE_HIGH); -ASSERT_ENUM_EQ(VideoCodecProfile, - , - VIDEO_CODEC_PROFILE_, - H264PROFILE_HIGH10PROFILE); -ASSERT_ENUM_EQ(VideoCodecProfile, - , - VIDEO_CODEC_PROFILE_, - H264PROFILE_HIGH422PROFILE); -ASSERT_ENUM_EQ(VideoCodecProfile, - , - VIDEO_CODEC_PROFILE_, - H264PROFILE_HIGH444PREDICTIVEPROFILE); -ASSERT_ENUM_EQ(VideoCodecProfile, - , - VIDEO_CODEC_PROFILE_, - H264PROFILE_SCALABLEBASELINE); -ASSERT_ENUM_EQ(VideoCodecProfile, - , - VIDEO_CODEC_PROFILE_, - H264PROFILE_SCALABLEHIGH); -ASSERT_ENUM_EQ(VideoCodecProfile, - , - VIDEO_CODEC_PROFILE_, - H264PROFILE_STEREOHIGH); -ASSERT_ENUM_EQ(VideoCodecProfile, - , - VIDEO_CODEC_PROFILE_, - H264PROFILE_MULTIVIEWHIGH); -ASSERT_ENUM_EQ(VideoCodecProfile, , VIDEO_CODEC_PROFILE_, H264PROFILE_MAX); -ASSERT_ENUM_EQ(VideoCodecProfile, , VIDEO_CODEC_PROFILE_, VP8PROFILE_MIN); -ASSERT_ENUM_EQ(VideoCodecProfile, , VIDEO_CODEC_PROFILE_, VP8PROFILE_ANY); -ASSERT_ENUM_EQ(VideoCodecProfile, , VIDEO_CODEC_PROFILE_, VP8PROFILE_MAX); -ASSERT_ENUM_EQ(VideoCodecProfile, , VIDEO_CODEC_PROFILE_, VP9PROFILE_MIN); -ASSERT_ENUM_EQ(VideoCodecProfile, , VIDEO_CODEC_PROFILE_, VP9PROFILE_ANY); -ASSERT_ENUM_EQ(VideoCodecProfile, , VIDEO_CODEC_PROFILE_, VP9PROFILE_MAX); -ASSERT_ENUM_EQ(VideoCodecProfile, - , - VIDEO_CODEC_PROFILE_, - VIDEO_CODEC_PROFILE_MAX); +ASSERT_ENUM_EQ(VideoCodecProfile, , , VIDEO_CODEC_PROFILE_UNKNOWN); +ASSERT_ENUM_EQ(VideoCodecProfile, , , VIDEO_CODEC_PROFILE_MIN); +ASSERT_ENUM_EQ(VideoCodecProfile, , , H264PROFILE_MIN); +ASSERT_ENUM_EQ(VideoCodecProfile, , , H264PROFILE_BASELINE); +ASSERT_ENUM_EQ(VideoCodecProfile, , , H264PROFILE_MAIN); +ASSERT_ENUM_EQ(VideoCodecProfile, , , H264PROFILE_EXTENDED); +ASSERT_ENUM_EQ(VideoCodecProfile, , , H264PROFILE_HIGH); +ASSERT_ENUM_EQ(VideoCodecProfile, , , H264PROFILE_HIGH10PROFILE); +ASSERT_ENUM_EQ(VideoCodecProfile, , , H264PROFILE_HIGH422PROFILE); +ASSERT_ENUM_EQ(VideoCodecProfile, , , H264PROFILE_HIGH444PREDICTIVEPROFILE); +ASSERT_ENUM_EQ(VideoCodecProfile, , , H264PROFILE_SCALABLEBASELINE); +ASSERT_ENUM_EQ(VideoCodecProfile, , , H264PROFILE_SCALABLEHIGH); +ASSERT_ENUM_EQ(VideoCodecProfile, , , H264PROFILE_STEREOHIGH); +ASSERT_ENUM_EQ(VideoCodecProfile, , , H264PROFILE_MULTIVIEWHIGH); +ASSERT_ENUM_EQ(VideoCodecProfile, , , H264PROFILE_MAX); +ASSERT_ENUM_EQ(VideoCodecProfile, , , VP8PROFILE_MIN); +ASSERT_ENUM_EQ(VideoCodecProfile, , , VP8PROFILE_ANY); +ASSERT_ENUM_EQ(VideoCodecProfile, , , VP8PROFILE_MAX); +ASSERT_ENUM_EQ(VideoCodecProfile, , , VP9PROFILE_MIN); +ASSERT_ENUM_EQ(VideoCodecProfile, , , VP9PROFILE_ANY); +ASSERT_ENUM_EQ(VideoCodecProfile, , , VP9PROFILE_MAX); +ASSERT_ENUM_EQ(VideoCodecProfile, , , VIDEO_CODEC_PROFILE_MAX); // Decryptor Status ASSERT_ENUM_EQ_RAW(Decryptor::Status, Decryptor::kSuccess, - Decryptor::STATUS_SUCCESS); + Decryptor::Status::SUCCESS); ASSERT_ENUM_EQ_RAW(Decryptor::Status, Decryptor::kNoKey, - Decryptor::STATUS_NO_KEY); + Decryptor::Status::NO_KEY); ASSERT_ENUM_EQ_RAW(Decryptor::Status, Decryptor::kNeedMoreData, - Decryptor::STATUS_NEED_MORE_DATA); + Decryptor::Status::NEED_MORE_DATA); ASSERT_ENUM_EQ_RAW(Decryptor::Status, Decryptor::kError, - Decryptor::STATUS_ERROR); + Decryptor::Status::DECRYPTION_ERROR); // CdmException -#define ASSERT_CDM_EXCEPTION(value) \ - static_assert(media::MediaKeys::value == \ - static_cast<media::MediaKeys::Exception>( \ - media::interfaces::CDM_EXCEPTION_##value), \ - "Mismatched CDM Exception") +#define ASSERT_CDM_EXCEPTION(value) \ + static_assert( \ + media::MediaKeys::value == static_cast<media::MediaKeys::Exception>( \ + media::interfaces::CdmException::value), \ + "Mismatched CDM Exception") ASSERT_CDM_EXCEPTION(NOT_SUPPORTED_ERROR); ASSERT_CDM_EXCEPTION(INVALID_STATE_ERROR); ASSERT_CDM_EXCEPTION(INVALID_ACCESS_ERROR); @@ -262,12 +230,12 @@ ASSERT_CDM_EXCEPTION(OUTPUT_ERROR); // CDM Session Type -#define ASSERT_CDM_SESSION_TYPE(value) \ - static_assert(media::MediaKeys::value == \ - static_cast<media::MediaKeys::SessionType>( \ - media::interfaces::ContentDecryptionModule:: \ - SESSION_TYPE_##value), \ - "Mismatched CDM Session Type") +#define ASSERT_CDM_SESSION_TYPE(value) \ + static_assert( \ + media::MediaKeys::value == \ + static_cast<media::MediaKeys::SessionType>( \ + media::interfaces::ContentDecryptionModule::SessionType::value), \ + "Mismatched CDM Session Type") ASSERT_CDM_SESSION_TYPE(TEMPORARY_SESSION); ASSERT_CDM_SESSION_TYPE(PERSISTENT_LICENSE_SESSION); ASSERT_CDM_SESSION_TYPE(PERSISTENT_RELEASE_MESSAGE_SESSION); @@ -277,7 +245,7 @@ static_assert(media::EmeInitDataType::value == \ static_cast<media::EmeInitDataType>( \ media::interfaces::ContentDecryptionModule:: \ - INIT_DATA_TYPE_##value), \ + InitDataType::value), \ "Mismatched CDM Init Data Type") ASSERT_CDM_INIT_DATA_TYPE(UNKNOWN); ASSERT_CDM_INIT_DATA_TYPE(WEBM); @@ -288,7 +256,7 @@ #define ASSERT_CDM_KEY_STATUS(value) \ static_assert(media::CdmKeyInformation::value == \ static_cast<media::CdmKeyInformation::KeyStatus>( \ - media::interfaces::CDM_KEY_STATUS_##value), \ + media::interfaces::CdmKeyStatus::value), \ "Mismatched CDM Key Status") ASSERT_CDM_KEY_STATUS(USABLE); ASSERT_CDM_KEY_STATUS(INTERNAL_ERROR); @@ -298,10 +266,10 @@ ASSERT_CDM_KEY_STATUS(KEY_STATUS_PENDING); // CDM Message Type -#define ASSERT_CDM_MESSAGE_TYPE(value) \ - static_assert(media::MediaKeys::value == \ - static_cast<media::MediaKeys::MessageType>( \ - media::interfaces::CDM_MESSAGE_TYPE_##value), \ +#define ASSERT_CDM_MESSAGE_TYPE(value) \ + static_assert(media::MediaKeys::value == \ + static_cast<media::MediaKeys::MessageType>( \ + media::interfaces::CdmMessageType::value), \ "Mismatched CDM Message Type") ASSERT_CDM_MESSAGE_TYPE(LICENSE_REQUEST); ASSERT_CDM_MESSAGE_TYPE(LICENSE_RENEWAL);
diff --git a/media/mojo/services/mojo_cdm_service.cc b/media/mojo/services/mojo_cdm_service.cc index 52bfee2..9a8f270 100644 --- a/media/mojo/services/mojo_cdm_service.cc +++ b/media/mojo/services/mojo_cdm_service.cc
@@ -194,7 +194,7 @@ if (!cdm || !context_) { cdm_promise_result->success = false; cdm_promise_result->exception = - interfaces::CDM_EXCEPTION_NOT_SUPPORTED_ERROR; + interfaces::CdmException::NOT_SUPPORTED_ERROR; cdm_promise_result->system_code = 0; cdm_promise_result->error_message = error_message; callback.Run(std::move(cdm_promise_result), 0, nullptr);
diff --git a/media/mojo/services/mojo_decryptor.cc b/media/mojo/services/mojo_decryptor.cc index 99d9acfa..7ce3888 100644 --- a/media/mojo/services/mojo_decryptor.cc +++ b/media/mojo/services/mojo_decryptor.cc
@@ -116,9 +116,9 @@ void MojoDecryptor::OnBufferDecrypted(const DecryptCB& decrypt_cb, interfaces::Decryptor::Status status, interfaces::DecoderBufferPtr buffer) { - DVLOG_IF(1, status != interfaces::Decryptor::STATUS_SUCCESS) + DVLOG_IF(1, status != interfaces::Decryptor::Status::SUCCESS) << __FUNCTION__ << "(" << status << ")"; - DVLOG_IF(3, status == interfaces::Decryptor::STATUS_SUCCESS) << __FUNCTION__; + DVLOG_IF(3, status == interfaces::Decryptor::Status::SUCCESS) << __FUNCTION__; if (buffer.is_null()) { decrypt_cb.Run(static_cast<Decryptor::Status>(status), nullptr); @@ -133,9 +133,9 @@ const AudioDecodeCB& audio_decode_cb, interfaces::Decryptor::Status status, mojo::Array<interfaces::AudioBufferPtr> audio_buffers) { - DVLOG_IF(1, status != interfaces::Decryptor::STATUS_SUCCESS) + DVLOG_IF(1, status != interfaces::Decryptor::Status::SUCCESS) << __FUNCTION__ << "(" << status << ")"; - DVLOG_IF(3, status == interfaces::Decryptor::STATUS_SUCCESS) << __FUNCTION__; + DVLOG_IF(3, status == interfaces::Decryptor::Status::SUCCESS) << __FUNCTION__; Decryptor::AudioFrames audio_frames; for (size_t i = 0; i < audio_buffers.size(); ++i) @@ -147,9 +147,9 @@ void MojoDecryptor::OnVideoDecoded(const VideoDecodeCB& video_decode_cb, interfaces::Decryptor::Status status, interfaces::VideoFramePtr video_frame) { - DVLOG_IF(1, status != interfaces::Decryptor::STATUS_SUCCESS) + DVLOG_IF(1, status != interfaces::Decryptor::Status::SUCCESS) << __FUNCTION__ << "(" << status << ")"; - DVLOG_IF(3, status == interfaces::Decryptor::STATUS_SUCCESS) << __FUNCTION__; + DVLOG_IF(3, status == interfaces::Decryptor::Status::SUCCESS) << __FUNCTION__; if (video_frame.is_null()) { video_decode_cb.Run(static_cast<Decryptor::Status>(status), nullptr); return;
diff --git a/media/mojo/services/mojo_demuxer_stream_adapter.cc b/media/mojo/services/mojo_demuxer_stream_adapter.cc index d510c0c..c8506c6e 100644 --- a/media/mojo/services/mojo_demuxer_stream_adapter.cc +++ b/media/mojo/services/mojo_demuxer_stream_adapter.cc
@@ -97,18 +97,18 @@ DCHECK_NE(type_, DemuxerStream::UNKNOWN); DCHECK(stream_pipe_.is_valid()); - if (status == interfaces::DemuxerStream::STATUS_CONFIG_CHANGED) { + if (status == interfaces::DemuxerStream::Status::CONFIG_CHANGED) { UpdateConfig(std::move(audio_config), std::move(video_config)); base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kConfigChanged, nullptr); return; } - if (status == interfaces::DemuxerStream::STATUS_ABORTED) { + if (status == interfaces::DemuxerStream::Status::ABORTED) { base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kAborted, nullptr); return; } - DCHECK_EQ(status, interfaces::DemuxerStream::STATUS_OK); + DCHECK_EQ(status, interfaces::DemuxerStream::Status::OK); scoped_refptr<DecoderBuffer> media_buffer( buffer.To<scoped_refptr<DecoderBuffer>>());
diff --git a/media/mojo/services/mojo_demuxer_stream_impl.cc b/media/mojo/services/mojo_demuxer_stream_impl.cc index f201fe7..a443897 100644 --- a/media/mojo/services/mojo_demuxer_stream_impl.cc +++ b/media/mojo/services/mojo_demuxer_stream_impl.cc
@@ -97,14 +97,14 @@ << stream_->type(); } - callback.Run(interfaces::DemuxerStream::STATUS_CONFIG_CHANGED, + callback.Run(interfaces::DemuxerStream::Status::CONFIG_CHANGED, interfaces::DecoderBufferPtr(), std::move(audio_config), std::move(video_config)); return; } if (status == media::DemuxerStream::kAborted) { - callback.Run(interfaces::DemuxerStream::STATUS_ABORTED, + callback.Run(interfaces::DemuxerStream::Status::ABORTED, interfaces::DecoderBufferPtr(), std::move(audio_config), std::move(video_config)); return;
diff --git a/mojo/converters/blink/blink_input_events_type_converters.cc b/mojo/converters/blink/blink_input_events_type_converters.cc index d11b3dc..48a2143 100644 --- a/mojo/converters/blink/blink_input_events_type_converters.cc +++ b/mojo/converters/blink/blink_input_events_type_converters.cc
@@ -22,43 +22,42 @@ int EventFlagsToWebEventModifiers(int flags) { int modifiers = 0; - if (flags & mus::mojom::EVENT_FLAGS_SHIFT_DOWN) + if (flags & mus::mojom::kEventFlagShiftDown) modifiers |= blink::WebInputEvent::ShiftKey; - if (flags & mus::mojom::EVENT_FLAGS_CONTROL_DOWN) + if (flags & mus::mojom::kEventFlagControlDown) modifiers |= blink::WebInputEvent::ControlKey; - if (flags & mus::mojom::EVENT_FLAGS_ALT_DOWN) + if (flags & mus::mojom::kEventFlagAltDown) modifiers |= blink::WebInputEvent::AltKey; // TODO(beng): MetaKey/META_MASK - if (flags & mus::mojom::EVENT_FLAGS_LEFT_MOUSE_BUTTON) + if (flags & mus::mojom::kEventFlagLeftMouseButton) modifiers |= blink::WebInputEvent::LeftButtonDown; - if (flags & mus::mojom::EVENT_FLAGS_MIDDLE_MOUSE_BUTTON) + if (flags & mus::mojom::kEventFlagMiddleMouseButton) modifiers |= blink::WebInputEvent::MiddleButtonDown; - if (flags & mus::mojom::EVENT_FLAGS_RIGHT_MOUSE_BUTTON) + if (flags & mus::mojom::kEventFlagRightMouseButton) modifiers |= blink::WebInputEvent::RightButtonDown; - if (flags & mus::mojom::EVENT_FLAGS_CAPS_LOCK_ON) + if (flags & mus::mojom::kEventFlagCapsLockOn) modifiers |= blink::WebInputEvent::CapsLockOn; return modifiers; } int EventFlagsToWebInputEventModifiers(int flags) { - return (flags & mus::mojom::EVENT_FLAGS_SHIFT_DOWN + return (flags & mus::mojom::kEventFlagShiftDown ? blink::WebInputEvent::ShiftKey : 0) | - (flags & mus::mojom::EVENT_FLAGS_CONTROL_DOWN + (flags & mus::mojom::kEventFlagControlDown ? blink::WebInputEvent::ControlKey : 0) | - (flags & mus::mojom::EVENT_FLAGS_ALT_DOWN - ? blink::WebInputEvent::AltKey - : 0) | - (flags & mus::mojom::EVENT_FLAGS_CAPS_LOCK_ON + (flags & mus::mojom::kEventFlagCapsLockOn ? blink::WebInputEvent::CapsLockOn - : 0); + : 0) | + (flags & mus::mojom::kEventFlagAltDown ? blink::WebInputEvent::AltKey + : 0); } int GetClickCount(int flags) { - if (flags & mus::mojom::MOUSE_EVENT_FLAGS_IS_TRIPLE_CLICK) + if (flags & mus::mojom::kMouseEventFlagIsTripleClick) return 3; - else if (flags & mus::mojom::MOUSE_EVENT_FLAGS_IS_DOUBLE_CLICK) + else if (flags & mus::mojom::kMouseEventFlagIsDoubleClick) return 2; return 1; @@ -83,24 +82,24 @@ web_event->timeStampSeconds = EventTimeToWebEventTime(event); web_event->button = blink::WebMouseEvent::ButtonNone; - if (event->flags & mus::mojom::EVENT_FLAGS_LEFT_MOUSE_BUTTON) + if (event->flags & mus::mojom::kEventFlagLeftMouseButton) web_event->button = blink::WebMouseEvent::ButtonLeft; - if (event->flags & mus::mojom::EVENT_FLAGS_MIDDLE_MOUSE_BUTTON) + if (event->flags & mus::mojom::kEventFlagMiddleMouseButton) web_event->button = blink::WebMouseEvent::ButtonMiddle; - if (event->flags & mus::mojom::EVENT_FLAGS_RIGHT_MOUSE_BUTTON) + if (event->flags & mus::mojom::kEventFlagRightMouseButton) web_event->button = blink::WebMouseEvent::ButtonRight; switch (event->action) { - case mus::mojom::EVENT_TYPE_POINTER_DOWN: + case mus::mojom::EventType::POINTER_DOWN: web_event->type = blink::WebInputEvent::MouseDown; break; - case mus::mojom::EVENT_TYPE_POINTER_UP: + case mus::mojom::EventType::POINTER_UP: web_event->type = blink::WebInputEvent::MouseUp; break; - case mus::mojom::EVENT_TYPE_POINTER_MOVE: + case mus::mojom::EventType::POINTER_MOVE: web_event->type = blink::WebInputEvent::MouseMove; break; - case mus::mojom::EVENT_TYPE_MOUSE_EXIT: + case mus::mojom::EventType::MOUSE_EXIT: web_event->type = blink::WebInputEvent::MouseLeave; break; default: @@ -121,12 +120,12 @@ web_event->timeStampSeconds = EventTimeToWebEventTime(event); switch (event->action) { - case mus::mojom::EVENT_TYPE_KEY_PRESSED: + case mus::mojom::EventType::KEY_PRESSED: web_event->type = event->key_data->is_char ? blink::WebInputEvent::Char : blink::WebInputEvent::RawKeyDown; break; - case mus::mojom::EVENT_TYPE_KEY_RELEASED: + case mus::mojom::EventType::KEY_RELEASED: web_event->type = blink::WebInputEvent::KeyUp; break; default: @@ -136,7 +135,8 @@ if (web_event->modifiers & blink::WebInputEvent::AltKey) web_event->isSystemKey = true; - web_event->windowsKeyCode = event->key_data->windows_key_code; + web_event->windowsKeyCode = + static_cast<int>(event->key_data->windows_key_code); web_event->nativeKeyCode = event->key_data->native_key_code; web_event->text[0] = event->key_data->text; web_event->unmodifiedText[0] = event->key_data->unmodified_text; @@ -171,22 +171,22 @@ // wheel events so the other modes are not yet tested. Verify that // the implementation is correct. switch (wheel_data.mode) { - case mus::mojom::WHEEL_MODE_PIXEL: + case mus::mojom::WheelMode::PIXEL: web_event->hasPreciseScrollingDeltas = true; web_event->scrollByPage = false; web_event->canScroll = true; break; - case mus::mojom::WHEEL_MODE_LINE: + case mus::mojom::WheelMode::LINE: web_event->hasPreciseScrollingDeltas = false; web_event->scrollByPage = false; web_event->canScroll = true; break; - case mus::mojom::WHEEL_MODE_PAGE: + case mus::mojom::WheelMode::PAGE: web_event->hasPreciseScrollingDeltas = false; web_event->scrollByPage = true; web_event->canScroll = true; break; - case mus::mojom::WHEEL_MODE_SCALING: + case mus::mojom::WheelMode::SCALING: web_event->hasPreciseScrollingDeltas = false; web_event->scrollByPage = false; web_event->canScroll = false; @@ -203,22 +203,22 @@ TypeConverter<scoped_ptr<blink::WebInputEvent>, mus::mojom::EventPtr>::Convert( const mus::mojom::EventPtr& event) { switch (event->action) { - case mus::mojom::EVENT_TYPE_POINTER_DOWN: - case mus::mojom::EVENT_TYPE_POINTER_UP: - case mus::mojom::EVENT_TYPE_POINTER_CANCEL: - case mus::mojom::EVENT_TYPE_POINTER_MOVE: - case mus::mojom::EVENT_TYPE_MOUSE_EXIT: + case mus::mojom::EventType::POINTER_DOWN: + case mus::mojom::EventType::POINTER_UP: + case mus::mojom::EventType::POINTER_CANCEL: + case mus::mojom::EventType::POINTER_MOVE: + case mus::mojom::EventType::MOUSE_EXIT: if (event->pointer_data && - event->pointer_data->kind == mus::mojom::POINTER_KIND_MOUSE) { + event->pointer_data->kind == mus::mojom::PointerKind::MOUSE) { return BuildWebMouseEventFrom(event); } return nullptr; - case mus::mojom::EVENT_TYPE_WHEEL: + case mus::mojom::EventType::WHEEL: return BuildWebMouseWheelEventFrom(event); - case mus::mojom::EVENT_TYPE_KEY_PRESSED: - case mus::mojom::EVENT_TYPE_KEY_RELEASED: + case mus::mojom::EventType::KEY_PRESSED: + case mus::mojom::EventType::KEY_RELEASED: return BuildWebKeyboardEvent(event); - case mus::mojom::EVENT_TYPE_UNKNOWN: + case mus::mojom::EventType::UNKNOWN: return nullptr; } return nullptr;
diff --git a/mojo/converters/ime/ime_type_converters.cc b/mojo/converters/ime/ime_type_converters.cc index 55a5757..6d95937e 100644 --- a/mojo/converters/ime/ime_type_converters.cc +++ b/mojo/converters/ime/ime_type_converters.cc
@@ -11,7 +11,7 @@ namespace mojo { #define TEXT_INPUT_TYPE_ASSERT(NAME) \ - static_assert(static_cast<int32_t>(TEXT_INPUT_TYPE_##NAME) == \ + static_assert(static_cast<int32_t>(TextInputType::NAME) == \ static_cast<int32_t>(ui::TEXT_INPUT_TYPE_##NAME), \ "TEXT_INPUT_TYPE must match") TEXT_INPUT_TYPE_ASSERT(NONE); @@ -31,7 +31,7 @@ TEXT_INPUT_TYPE_ASSERT(TEXT_AREA); #define TEXT_INPUT_FLAG_ASSERT(NAME) \ - static_assert(static_cast<int32_t>(TEXT_INPUT_FLAG_##NAME) == \ + static_assert(static_cast<int32_t>(TextInputFlag::NAME) == \ static_cast<int32_t>(ui::TEXT_INPUT_FLAG_##NAME), \ "TEXT_INPUT_FLAG must match") TEXT_INPUT_FLAG_ASSERT(NONE);
diff --git a/mojo/converters/input_events/input_events_type_converters.cc b/mojo/converters/input_events/input_events_type_converters.cc index 3d68be7..1751a6e 100644 --- a/mojo/converters/input_events/input_events_type_converters.cc +++ b/mojo/converters/input_events/input_events_type_converters.cc
@@ -25,24 +25,24 @@ ui::EventType MojoMouseEventTypeToUIEvent(const mus::mojom::EventPtr& event) { DCHECK(event->pointer_data); - DCHECK_EQ(mus::mojom::POINTER_KIND_MOUSE, event->pointer_data->kind); + DCHECK_EQ(mus::mojom::PointerKind::MOUSE, event->pointer_data->kind); switch (event->action) { - case mus::mojom::EVENT_TYPE_POINTER_DOWN: + case mus::mojom::EventType::POINTER_DOWN: return ui::ET_MOUSE_PRESSED; - case mus::mojom::EVENT_TYPE_POINTER_UP: + case mus::mojom::EventType::POINTER_UP: return ui::ET_MOUSE_RELEASED; - case mus::mojom::EVENT_TYPE_POINTER_MOVE: + case mus::mojom::EventType::POINTER_MOVE: DCHECK(event->pointer_data); - if (event->flags & (mus::mojom::EVENT_FLAGS_LEFT_MOUSE_BUTTON | - mus::mojom::EVENT_FLAGS_MIDDLE_MOUSE_BUTTON | - mus::mojom::EVENT_FLAGS_RIGHT_MOUSE_BUTTON)) { + if (event->flags & (mus::mojom::kEventFlagLeftMouseButton | + mus::mojom::kEventFlagMiddleMouseButton | + mus::mojom::kEventFlagRightMouseButton)) { return ui::ET_MOUSE_DRAGGED; } return ui::ET_MOUSE_MOVED; - case mus::mojom::EVENT_TYPE_MOUSE_EXIT: + case mus::mojom::EventType::MOUSE_EXIT: return ui::ET_MOUSE_EXITED; default: @@ -54,18 +54,18 @@ ui::EventType MojoTouchEventTypeToUIEvent(const mus::mojom::EventPtr& event) { DCHECK(event->pointer_data); - DCHECK_EQ(mus::mojom::POINTER_KIND_TOUCH, event->pointer_data->kind); + DCHECK_EQ(mus::mojom::PointerKind::TOUCH, event->pointer_data->kind); switch (event->action) { - case mus::mojom::EVENT_TYPE_POINTER_DOWN: + case mus::mojom::EventType::POINTER_DOWN: return ui::ET_TOUCH_PRESSED; - case mus::mojom::EVENT_TYPE_POINTER_UP: + case mus::mojom::EventType::POINTER_UP: return ui::ET_TOUCH_RELEASED; - case mus::mojom::EVENT_TYPE_POINTER_MOVE: + case mus::mojom::EventType::POINTER_MOVE: return ui::ET_TOUCH_MOVED; - case mus::mojom::EVENT_TYPE_POINTER_CANCEL: + case mus::mojom::EventType::POINTER_CANCEL: return ui::ET_TOUCH_CANCELLED; default: @@ -90,57 +90,53 @@ } // namespace -static_assert(static_cast<int32_t>(mus::mojom::EVENT_FLAGS_NONE) == - static_cast<int32_t>(ui::EF_NONE), +static_assert(mus::mojom::kEventFlagNone == static_cast<int32_t>(ui::EF_NONE), "EVENT_FLAGS must match"); -static_assert(static_cast<int32_t>(mus::mojom::EVENT_FLAGS_IS_SYNTHESIZED) == +static_assert(mus::mojom::kEventFlagIsSynthesized == static_cast<int32_t>(ui::EF_IS_SYNTHESIZED), "EVENT_FLAGS must match"); -static_assert(static_cast<int32_t>(mus::mojom::EVENT_FLAGS_SHIFT_DOWN) == +static_assert(mus::mojom::kEventFlagShiftDown == static_cast<int32_t>(ui::EF_SHIFT_DOWN), "EVENT_FLAGS must match"); -static_assert(static_cast<int32_t>(mus::mojom::EVENT_FLAGS_CONTROL_DOWN) == +static_assert(mus::mojom::kEventFlagControlDown == static_cast<int32_t>(ui::EF_CONTROL_DOWN), "EVENT_FLAGS must match"); -static_assert(static_cast<int32_t>(mus::mojom::EVENT_FLAGS_ALT_DOWN) == +static_assert(mus::mojom::kEventFlagAltDown == static_cast<int32_t>(ui::EF_ALT_DOWN), "EVENT_FLAGS must match"); -static_assert(static_cast<int32_t>(mus::mojom::EVENT_FLAGS_COMMAND_DOWN) == +static_assert(mus::mojom::kEventFlagCommandDown == static_cast<int32_t>(ui::EF_COMMAND_DOWN), "EVENT_FLAGS must match"); -static_assert(static_cast<int32_t>(mus::mojom::EVENT_FLAGS_ALTGR_DOWN) == +static_assert(mus::mojom::kEventFlagAltgrDown == static_cast<int32_t>(ui::EF_ALTGR_DOWN), "EVENT_FLAGS must match"); -static_assert(static_cast<int32_t>(mus::mojom::EVENT_FLAGS_MOD3_DOWN) == +static_assert(mus::mojom::kEventFlagMod3Down == static_cast<int32_t>(ui::EF_MOD3_DOWN), "EVENT_FLAGS must match"); -static_assert(static_cast<int32_t>(mus::mojom::EVENT_FLAGS_NUM_LOCK_ON) == +static_assert(mus::mojom::kEventFlagNumLockOn == static_cast<int32_t>(ui::EF_NUM_LOCK_ON), "EVENT_FLAGS must match"); -static_assert(static_cast<int32_t>(mus::mojom::EVENT_FLAGS_CAPS_LOCK_ON) == +static_assert(mus::mojom::kEventFlagCapsLockOn == static_cast<int32_t>(ui::EF_CAPS_LOCK_ON), "EVENT_FLAGS must match"); -static_assert(static_cast<int32_t>(mus::mojom::EVENT_FLAGS_SCROLL_LOCK_ON) == +static_assert(mus::mojom::kEventFlagScrollLockOn == static_cast<int32_t>(ui::EF_SCROLL_LOCK_ON), "EVENT_FLAGS must match"); -static_assert(static_cast<int32_t>(mus::mojom::EVENT_FLAGS_LEFT_MOUSE_BUTTON) == +static_assert(mus::mojom::kEventFlagLeftMouseButton == static_cast<int32_t>(ui::EF_LEFT_MOUSE_BUTTON), "EVENT_FLAGS must match"); -static_assert( - static_cast<int32_t>(mus::mojom::EVENT_FLAGS_MIDDLE_MOUSE_BUTTON) == - static_cast<int32_t>(ui::EF_MIDDLE_MOUSE_BUTTON), - "EVENT_FLAGS must match"); -static_assert( - static_cast<int32_t>(mus::mojom::EVENT_FLAGS_RIGHT_MOUSE_BUTTON) == - static_cast<int32_t>(ui::EF_RIGHT_MOUSE_BUTTON), - "EVENT_FLAGS must match"); -static_assert(static_cast<int32_t>(mus::mojom::EVENT_FLAGS_BACK_MOUSE_BUTTON) == +static_assert(mus::mojom::kEventFlagMiddleMouseButton == + static_cast<int32_t>(ui::EF_MIDDLE_MOUSE_BUTTON), + "EVENT_FLAGS must match"); +static_assert(mus::mojom::kEventFlagRightMouseButton == + static_cast<int32_t>(ui::EF_RIGHT_MOUSE_BUTTON), + "EVENT_FLAGS must match"); +static_assert(mus::mojom::kEventFlagBackMouseButton == static_cast<int32_t>(ui::EF_BACK_MOUSE_BUTTON), "EVENT_FLAGS must match"); -static_assert( - static_cast<int32_t>(mus::mojom::EVENT_FLAGS_FORWARD_MOUSE_BUTTON) == - static_cast<int32_t>(ui::EF_FORWARD_MOUSE_BUTTON), - "EVENT_FLAGS must match"); +static_assert(mus::mojom::kEventFlagForwardMouseButton == + static_cast<int32_t>(ui::EF_FORWARD_MOUSE_BUTTON), + "EVENT_FLAGS must match"); // static mus::mojom::EventType @@ -149,49 +145,49 @@ switch (type) { case ui::ET_MOUSE_PRESSED: case ui::ET_TOUCH_PRESSED: - return mus::mojom::EVENT_TYPE_POINTER_DOWN; + return mus::mojom::EventType::POINTER_DOWN; case ui::ET_MOUSE_DRAGGED: case ui::ET_MOUSE_MOVED: case ui::ET_MOUSE_ENTERED: case ui::ET_TOUCH_MOVED: - return mus::mojom::EVENT_TYPE_POINTER_MOVE; + return mus::mojom::EventType::POINTER_MOVE; case ui::ET_MOUSE_EXITED: - return mus::mojom::EVENT_TYPE_MOUSE_EXIT; + return mus::mojom::EventType::MOUSE_EXIT; case ui::ET_MOUSEWHEEL: - return mus::mojom::EVENT_TYPE_WHEEL; + return mus::mojom::EventType::WHEEL; case ui::ET_MOUSE_RELEASED: case ui::ET_TOUCH_RELEASED: - return mus::mojom::EVENT_TYPE_POINTER_UP; + return mus::mojom::EventType::POINTER_UP; case ui::ET_TOUCH_CANCELLED: - return mus::mojom::EVENT_TYPE_POINTER_CANCEL; + return mus::mojom::EventType::POINTER_CANCEL; case ui::ET_KEY_PRESSED: - return mus::mojom::EVENT_TYPE_KEY_PRESSED; + return mus::mojom::EventType::KEY_PRESSED; case ui::ET_KEY_RELEASED: - return mus::mojom::EVENT_TYPE_KEY_RELEASED; + return mus::mojom::EventType::KEY_RELEASED; default: break; } - return mus::mojom::EVENT_TYPE_UNKNOWN; + return mus::mojom::EventType::UNKNOWN; } mus::mojom::EventPtr TypeConverter<mus::mojom::EventPtr, ui::Event>::Convert( const ui::Event& input) { const mus::mojom::EventType type = ConvertTo<mus::mojom::EventType>(input.type()); - if (type == mus::mojom::EVENT_TYPE_UNKNOWN) + if (type == mus::mojom::EventType::UNKNOWN) return nullptr; mus::mojom::EventPtr event = mus::mojom::Event::New(); event->action = type; - event->flags = mus::mojom::EventFlags(input.flags()); + event->flags = input.flags(); event->time_stamp = input.time_stamp().ToInternalValue(); if (input.IsMouseEvent()) { @@ -200,7 +196,7 @@ mus::mojom::PointerDataPtr pointer_data(mus::mojom::PointerData::New()); // TODO(sky): come up with a better way to handle this. pointer_data->pointer_id = std::numeric_limits<int32_t>::max(); - pointer_data->kind = mus::mojom::POINTER_KIND_MOUSE; + pointer_data->kind = mus::mojom::PointerKind::MOUSE; mus::mojom::LocationDataPtr location_data(mus::mojom::LocationData::New()); SetPointerDataLocationFromEvent(*located_event, location_data.get()); pointer_data->location = std::move(location_data); @@ -213,7 +209,7 @@ // TODO(rjkroege): Support page scrolling on windows by directly // cracking into a mojo event when the native event is available. - wheel_data->mode = mus::mojom::WHEEL_MODE_LINE; + wheel_data->mode = mus::mojom::WheelMode::LINE; // TODO(rjkroege): Support precise scrolling deltas. if ((input.flags() & ui::EF_SHIFT_DOWN) != 0 && @@ -236,7 +232,7 @@ mus::mojom::PointerDataPtr pointer_data(mus::mojom::PointerData::New()); pointer_data->pointer_id = touch_event->touch_id(); - pointer_data->kind = mus::mojom::POINTER_KIND_TOUCH; + pointer_data->kind = mus::mojom::PointerKind::TOUCH; mus::mojom::LocationDataPtr location_data(mus::mojom::LocationData::New()); SetPointerDataLocationFromEvent(*touch_event, location_data.get()); pointer_data->location = std::move(location_data); @@ -304,18 +300,17 @@ } switch (input->action) { - case mus::mojom::EVENT_TYPE_KEY_PRESSED: - case mus::mojom::EVENT_TYPE_KEY_RELEASED: { + case mus::mojom::EventType::KEY_PRESSED: + case mus::mojom::EventType::KEY_RELEASED: { scoped_ptr<ui::KeyEvent> key_event; if (input->key_data->is_char) { key_event.reset(new ui::KeyEvent( static_cast<base::char16>(input->key_data->character), - static_cast<ui::KeyboardCode>( - input->key_data->key_code), + static_cast<ui::KeyboardCode>(input->key_data->key_code), input->flags)); } else { key_event.reset(new ui::KeyEvent( - input->action == mus::mojom::EVENT_TYPE_KEY_PRESSED + input->action == mus::mojom::EventType::KEY_PRESSED ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED, @@ -329,13 +324,13 @@ input->key_data->unmodified_text))); return std::move(key_event); } - case mus::mojom::EVENT_TYPE_POINTER_DOWN: - case mus::mojom::EVENT_TYPE_POINTER_UP: - case mus::mojom::EVENT_TYPE_POINTER_MOVE: - case mus::mojom::EVENT_TYPE_POINTER_CANCEL: - case mus::mojom::EVENT_TYPE_MOUSE_EXIT: { + case mus::mojom::EventType::POINTER_DOWN: + case mus::mojom::EventType::POINTER_UP: + case mus::mojom::EventType::POINTER_MOVE: + case mus::mojom::EventType::POINTER_CANCEL: + case mus::mojom::EventType::MOUSE_EXIT: { switch (input->pointer_data->kind) { - case mus::mojom::POINTER_KIND_MOUSE: { + case mus::mojom::PointerKind::MOUSE: { // TODO: last flags isn't right. Need to send changed_flags. scoped_ptr<ui::MouseEvent> event(new ui::MouseEvent( MojoMouseEventTypeToUIEvent(input), gfx::Point(), gfx::Point(), @@ -345,7 +340,7 @@ event->set_root_location_f(screen_location); return std::move(event); } break; - case mus::mojom::POINTER_KIND_TOUCH: { + case mus::mojom::PointerKind::TOUCH: { DCHECK(input->pointer_data->brush_data); scoped_ptr<ui::TouchEvent> touch_event(new ui::TouchEvent( MojoTouchEventTypeToUIEvent(input), gfx::Point(), @@ -358,12 +353,12 @@ touch_event->set_root_location_f(screen_location); return std::move(touch_event); } break; - case mus::mojom::POINTER_KIND_PEN: + case mus::mojom::PointerKind::PEN: NOTIMPLEMENTED(); break; } } break; - case mus::mojom::EVENT_TYPE_WHEEL: { + case mus::mojom::EventType::WHEEL: { DCHECK(input->pointer_data && input->pointer_data->wheel_data); scoped_ptr<ui::MouseEvent> pre_wheel_event(new ui::MouseEvent( MojoWheelEventTypeToUIEvent(input), gfx::Point(), gfx::Point(),
diff --git a/mojo/converters/surfaces/surfaces_type_converters.cc b/mojo/converters/surfaces/surfaces_type_converters.cc index ab77a5a..bff1f701 100644 --- a/mojo/converters/surfaces/surfaces_type_converters.cc +++ b/mojo/converters/surfaces/surfaces_type_converters.cc
@@ -76,7 +76,7 @@ #define ASSERT_ENUM_VALUES_EQUAL(value) \ static_assert(cc::DrawQuad::value == static_cast<cc::DrawQuad::Material>( \ - mus::mojom::MATERIAL_##value), \ + mus::mojom::Material::value), \ #value " enum value must match") ASSERT_ENUM_VALUES_EQUAL(DEBUG_BORDER); @@ -92,7 +92,7 @@ static_assert(cc::YUVVideoDrawQuad::REC_601 == static_cast<cc::YUVVideoDrawQuad::ColorSpace>( - mus::mojom::YUV_COLOR_SPACE_REC_601), + mus::mojom::YUVColorSpace::REC_601), "REC_601 enum value must match"); // TODO(jamesr): Add REC_709 and JPEG to the YUVColorSpace enum upstream in // mojo. @@ -119,7 +119,7 @@ cc::RenderPass* render_pass, CustomSurfaceConverter* custom_converter) { switch (input->material) { - case mus::mojom::MATERIAL_DEBUG_BORDER: { + case mus::mojom::Material::DEBUG_BORDER: { cc::DebugBorderDrawQuad* debug_border_quad = render_pass->CreateAndAppendDrawQuad<cc::DebugBorderDrawQuad>(); debug_border_quad->SetAll( @@ -132,7 +132,7 @@ input->debug_border_quad_state->width); break; } - case mus::mojom::MATERIAL_RENDER_PASS: { + case mus::mojom::Material::RENDER_PASS: { cc::RenderPassDrawQuad* render_pass_quad = render_pass->CreateAndAppendDrawQuad<cc::RenderPassDrawQuad>(); RenderPassQuadState* render_pass_quad_state = @@ -156,7 +156,7 @@ cc::FilterOperations()); // TODO(jamesr): background_filters break; } - case mus::mojom::MATERIAL_SOLID_COLOR: { + case mus::mojom::Material::SOLID_COLOR: { if (input->solid_color_quad_state.is_null()) return false; cc::SolidColorDrawQuad* color_quad = @@ -171,7 +171,7 @@ input->solid_color_quad_state->force_anti_aliasing_off); break; } - case mus::mojom::MATERIAL_SURFACE_CONTENT: { + case mus::mojom::Material::SURFACE_CONTENT: { if (input->surface_quad_state.is_null()) return false; @@ -190,7 +190,7 @@ input->surface_quad_state->surface.To<cc::SurfaceId>()); break; } - case mus::mojom::MATERIAL_TEXTURE_CONTENT: { + case mus::mojom::Material::TEXTURE_CONTENT: { TextureQuadStatePtr& texture_quad_state = input->texture_quad_state; if (texture_quad_state.is_null() || @@ -211,7 +211,7 @@ texture_quad_state->y_flipped, texture_quad_state->nearest_neighbor); break; } - case mus::mojom::MATERIAL_TILED_CONTENT: { + case mus::mojom::Material::TILED_CONTENT: { TileQuadStatePtr& tile_state = input->tile_quad_state; if (tile_state.is_null()) return false; @@ -229,7 +229,7 @@ tile_state->nearest_neighbor); break; } - case mus::mojom::MATERIAL_YUV_VIDEO_CONTENT: { + case mus::mojom::Material::YUV_VIDEO_CONTENT: { YUVVideoQuadStatePtr& yuv_state = input->yuv_video_quad_state; if (yuv_state.is_null()) return false;
diff --git a/mojo/converters/surfaces/surfaces_utils.cc b/mojo/converters/surfaces/surfaces_utils.cc index d0793afe..239263f 100644 --- a/mojo/converters/surfaces/surfaces_utils.cc +++ b/mojo/converters/surfaces/surfaces_utils.cc
@@ -26,7 +26,7 @@ sqs->clip_rect = Rect::From(gfx::Rect(size)); sqs->is_clipped = false; sqs->opacity = 1.f; - sqs->blend_mode = mus::mojom::SK_XFERMODE_kSrc_Mode; + sqs->blend_mode = mus::mojom::SkXfermode::kSrc_Mode; sqs->sorting_context_id = 0; return sqs; }
diff --git a/mojo/converters/surfaces/tests/surface_unittest.cc b/mojo/converters/surfaces/tests/surface_unittest.cc index 114cd15..f43b4269 100644 --- a/mojo/converters/surfaces/tests/surface_unittest.cc +++ b/mojo/converters/surfaces/tests/surface_unittest.cc
@@ -120,7 +120,7 @@ QuadPtr mus_quad = Quad::From<cc::DrawQuad>(*color_quad); ASSERT_FALSE(mus_quad.is_null()); - EXPECT_EQ(mus::mojom::MATERIAL_SOLID_COLOR, mus_quad->material); + EXPECT_EQ(mus::mojom::Material::SOLID_COLOR, mus_quad->material); EXPECT_TRUE(Rect::From(rect).Equals(mus_quad->rect)); EXPECT_TRUE(Rect::From(opaque_rect).Equals(mus_quad->opaque_rect)); EXPECT_TRUE(Rect::From(visible_rect).Equals(mus_quad->visible_rect)); @@ -140,7 +140,7 @@ QuadPtr mus_quad = Quad::From<cc::DrawQuad>(*surface_quad); ASSERT_FALSE(mus_quad.is_null()); - EXPECT_EQ(mus::mojom::MATERIAL_SURFACE_CONTENT, mus_quad->material); + EXPECT_EQ(mus::mojom::Material::SURFACE_CONTENT, mus_quad->material); ASSERT_TRUE(mus_quad->surface_quad_state); SurfaceQuadStatePtr& mus_surface_state = mus_quad->surface_quad_state; EXPECT_TRUE(SurfaceId::From(arbitrary_id).Equals(mus_surface_state->surface)); @@ -164,7 +164,7 @@ QuadPtr mus_quad = Quad::From<cc::DrawQuad>(*texture_quad); ASSERT_FALSE(mus_quad.is_null()); - EXPECT_EQ(mus::mojom::MATERIAL_TEXTURE_CONTENT, mus_quad->material); + EXPECT_EQ(mus::mojom::Material::TEXTURE_CONTENT, mus_quad->material); ASSERT_TRUE(mus_quad->texture_quad_state); TextureQuadStatePtr& mus_texture_state = mus_quad->texture_quad_state; EXPECT_EQ(resource_id, mus_texture_state->resource_id); @@ -182,7 +182,7 @@ TEST_F(SurfaceLibQuadTest, TextureQuadEmptyVertexOpacity) { QuadPtr mus_texture_quad = Quad::New(); - mus_texture_quad->material = mus::mojom::MATERIAL_TEXTURE_CONTENT; + mus_texture_quad->material = mus::mojom::Material::TEXTURE_CONTENT; TextureQuadStatePtr mus_texture_state = TextureQuadState::New(); mus_texture_state->background_color = Color::New(); mus_texture_quad->texture_quad_state = std::move(mus_texture_state); @@ -201,7 +201,7 @@ TEST_F(SurfaceLibQuadTest, TextureQuadEmptyBackgroundColor) { QuadPtr mus_texture_quad = Quad::New(); - mus_texture_quad->material = mus::mojom::MATERIAL_TEXTURE_CONTENT; + mus_texture_quad->material = mus::mojom::Material::TEXTURE_CONTENT; TextureQuadStatePtr mus_texture_state = TextureQuadState::New(); mus_texture_state->vertex_opacity = mojo::Array<float>::New(4); mus_texture_quad->texture_quad_state = std::move(mus_texture_state); @@ -407,7 +407,8 @@ gpu::Mailbox mailbox; mailbox.Generate(); uint32_t texture_target = GL_TEXTURE_2D; - gpu::SyncToken sync_token(7u); + gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 1, 7u); + sync_token.SetVerifyFlush(); gpu::MailboxHolder holder(mailbox, sync_token, texture_target); MailboxHolderPtr mus_holder = MailboxHolder::From(holder); @@ -458,7 +459,8 @@ TEST(SurfaceLibTest, ReturnedResource) { uint32_t id = 5u; - gpu::SyncToken sync_token(24u); + gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 1, 24u); + sync_token.SetVerifyFlush(); int count = 2; bool lost = false; cc::ReturnedResource resource; @@ -496,7 +498,7 @@ QuadPtr mus_quad = Quad::From<cc::DrawQuad>(*debug_border_quad); ASSERT_FALSE(mus_quad.is_null()); - EXPECT_EQ(mus::mojom::MATERIAL_DEBUG_BORDER, mus_quad->material); + EXPECT_EQ(mus::mojom::Material::DEBUG_BORDER, mus_quad->material); EXPECT_TRUE(Rect::From(rect).Equals(mus_quad->rect)); EXPECT_TRUE(Rect::From(opaque_rect).Equals(mus_quad->opaque_rect)); EXPECT_TRUE(Rect::From(visible_rect).Equals(mus_quad->visible_rect));
diff --git a/mojo/gles2/command_buffer_client_impl.cc b/mojo/gles2/command_buffer_client_impl.cc index 80e37046..a4ece0c 100644 --- a/mojo/gles2/command_buffer_client_impl.cc +++ b/mojo/gles2/command_buffer_client_impl.cc
@@ -272,31 +272,17 @@ } uint32_t CommandBufferClientImpl::InsertSyncPoint() { - uint32_t sync_point = 0; - command_buffer_->InsertSyncPoint(true, - base::Bind(&Copy<uint32_t>, &sync_point)); - - base::ThreadRestrictions::ScopedAllowWait wait; - if (!command_buffer_.WaitForIncomingResponse()) { - VLOG(1) << "Channel encountered error while creating command buffer."; - } - return sync_point; + NOTREACHED(); + return 0; } uint32_t CommandBufferClientImpl::InsertFutureSyncPoint() { - uint32_t sync_point = 0; - command_buffer_->InsertSyncPoint(false, - base::Bind(&Copy<uint32_t>, &sync_point)); - - base::ThreadRestrictions::ScopedAllowWait wait; - if (!command_buffer_.WaitForIncomingResponse()) { - VLOG(1) << "Channel encountered error while creating command buffer."; - } - return sync_point; + NOTREACHED(); + return 0; } void CommandBufferClientImpl::RetireSyncPoint(uint32_t sync_point) { - command_buffer_->RetireSyncPoint(sync_point); + NOTREACHED(); } void CommandBufferClientImpl::SignalSyncPoint(uint32_t sync_point,
diff --git a/mojo/public/cpp/bindings/tests/binding_unittest.cc b/mojo/public/cpp/bindings/tests/binding_unittest.cc index e3741bb0..1949c21d8 100644 --- a/mojo/public/cpp/bindings/tests/binding_unittest.cc +++ b/mojo/public/cpp/bindings/tests/binding_unittest.cc
@@ -101,7 +101,7 @@ }; { Binding<sample::Service> binding(&impl, std::move(request)); - ptr->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr, + ptr->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr, called_cb); run_loop2.Run(); EXPECT_TRUE(called); @@ -114,7 +114,7 @@ // And calls should fail. called = false; - ptr->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr, + ptr->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr, called_cb); loop().RunUntilIdle(); EXPECT_FALSE(called); @@ -210,7 +210,7 @@ called = true; run_loop.Quit(); }; - ptr->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr, + ptr->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr, called_cb); run_loop.Run(); EXPECT_TRUE(called); @@ -219,7 +219,7 @@ auto request = binding.Unbind(); EXPECT_FALSE(binding.is_bound()); // All calls should fail when not bound... - ptr->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr, + ptr->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr, called_cb); loop().RunUntilIdle(); EXPECT_FALSE(called); @@ -233,7 +233,7 @@ called = true; run_loop2.Quit(); }; - ptr->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr, + ptr->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr, called_cb2); run_loop2.Run(); EXPECT_TRUE(called); @@ -247,7 +247,7 @@ private: // sample::IntegerAccessor implementation. void GetInteger(const GetIntegerCallback& callback) override { - callback.Run(1, sample::ENUM_VALUE); + callback.Run(1, sample::Enum::VALUE); } void SetInteger(int64_t data, sample::Enum type) override {} @@ -273,7 +273,7 @@ ServiceImpl impl; Binding<sample::Service> binding(&impl, std::move(request)); binding.PauseIncomingMethodCallProcessing(); - ptr->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr, + ptr->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr, called_cb); EXPECT_FALSE(called); loop().RunUntilIdle(); @@ -337,7 +337,7 @@ }; { StrongBinding<sample::Service> binding(&impl, std::move(request)); - ptr->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr, + ptr->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr, called_cb); run_loop2.Run(); EXPECT_TRUE(called);
diff --git a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc index aac1cb4..d63b542d 100644 --- a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc +++ b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
@@ -198,7 +198,7 @@ private: // sample::IntegerAccessor implementation. void GetInteger(const GetIntegerCallback& callback) override { - callback.Run(integer_, sample::ENUM_VALUE); + callback.Run(integer_, sample::Enum::VALUE); } void SetInteger(int64_t data, sample::Enum type) override { integer_ = data; @@ -421,9 +421,9 @@ base::RunLoop run_loop, run_loop2; auto called_cb = [&run_loop](int32_t result) { run_loop.Quit(); }; auto called_cb2 = [&run_loop2](int32_t result) { run_loop2.Quit(); }; - proxy->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr, + proxy->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr, called_cb); - proxy->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr, + proxy->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr, called_cb2); run_loop.Run(); @@ -462,7 +462,7 @@ EXPECT_EQ(1u, ptr.version()); base::RunLoop run_loop; impl.set_closure(run_loop.QuitClosure()); - ptr->SetInteger(123, sample::ENUM_VALUE); + ptr->SetInteger(123, sample::Enum::VALUE); run_loop.Run(); EXPECT_FALSE(ptr.encountered_error()); EXPECT_EQ(123, impl.integer()); @@ -471,7 +471,7 @@ EXPECT_EQ(3u, ptr.version()); base::RunLoop run_loop2; impl.set_closure(run_loop2.QuitClosure()); - ptr->SetInteger(456, sample::ENUM_VALUE); + ptr->SetInteger(456, sample::Enum::VALUE); run_loop2.Run(); EXPECT_FALSE(ptr.encountered_error()); EXPECT_EQ(456, impl.integer()); @@ -482,7 +482,7 @@ EXPECT_EQ(4u, ptr.version()); base::RunLoop run_loop3; ptr.set_connection_error_handler(run_loop3.QuitClosure()); - ptr->SetInteger(789, sample::ENUM_VALUE); + ptr->SetInteger(789, sample::Enum::VALUE); run_loop3.Run(); EXPECT_TRUE(ptr.encountered_error()); // The call to SetInteger() after RequireVersion(4u) is ignored.
diff --git a/mojo/public/cpp/bindings/tests/request_response_unittest.cc b/mojo/public/cpp/bindings/tests/request_response_unittest.cc index 85d2fd4..cbc6515 100644 --- a/mojo/public/cpp/bindings/tests/request_response_unittest.cc +++ b/mojo/public/cpp/bindings/tests/request_response_unittest.cc
@@ -165,12 +165,12 @@ sample::Enum value; base::RunLoop run_loop; - provider->EchoEnum(sample::ENUM_VALUE, + provider->EchoEnum(sample::Enum::VALUE, EnumRecorder(&value, run_loop.QuitClosure())); run_loop.Run(); - EXPECT_EQ(sample::ENUM_VALUE, value); + EXPECT_EQ(sample::Enum::VALUE, value); } } // namespace
diff --git a/mojo/public/cpp/bindings/tests/sample_service_unittest.cc b/mojo/public/cpp/bindings/tests/sample_service_unittest.cc index 741ea8f..609a1dd1 100644 --- a/mojo/public/cpp/bindings/tests/sample_service_unittest.cc +++ b/mojo/public/cpp/bindings/tests/sample_service_unittest.cc
@@ -42,11 +42,11 @@ bar->alpha = 20; bar->beta = 40; bar->gamma = 60; - bar->type = Bar::TYPE_VERTICAL; + bar->type = Bar::Type::VERTICAL; mojo::Array<BarPtr> extra_bars(3); for (size_t i = 0; i < extra_bars.size(); ++i) { - Bar::Type type = i % 2 == 0 ? Bar::TYPE_VERTICAL : Bar::TYPE_HORIZONTAL; + Bar::Type type = i % 2 == 0 ? Bar::Type::VERTICAL : Bar::Type::HORIZONTAL; BarPtr bar(Bar::New()); uint8_t base = static_cast<uint8_t>(i * 100); bar->alpha = base; @@ -123,12 +123,12 @@ EXPECT_EQ(20, foo.bar->alpha); EXPECT_EQ(40, foo.bar->beta); EXPECT_EQ(60, foo.bar->gamma); - EXPECT_EQ(Bar::TYPE_VERTICAL, foo.bar->type); + EXPECT_EQ(Bar::Type::VERTICAL, foo.bar->type); EXPECT_EQ(3u, foo.extra_bars.size()); for (size_t i = 0; i < foo.extra_bars.size(); i++) { uint8_t base = static_cast<uint8_t>(i * 100); - Bar::Type type = i % 2 == 0 ? Bar::TYPE_VERTICAL : Bar::TYPE_HORIZONTAL; + Bar::Type type = i % 2 == 0 ? Bar::Type::VERTICAL : Bar::Type::HORIZONTAL; EXPECT_EQ(base, foo.extra_bars[i]->alpha) << i; EXPECT_EQ(base + 20, foo.extra_bars[i]->beta) << i; EXPECT_EQ(base + 40, foo.extra_bars[i]->gamma) << i; @@ -267,14 +267,14 @@ EXPECT_FALSE(foo.is_null()); if (!foo.is_null()) CheckFoo(*foo); - EXPECT_EQ(BAZ_OPTIONS_EXTRA, baz); + EXPECT_EQ(BazOptions::EXTRA, baz); if (g_dump_message_as_text) { // Also dump the Foo structure and all of its members. std::cout << "Frobinate:" << std::endl; int depth = 1; Print(depth, "foo", foo); - Print(depth, "baz", baz); + Print(depth, "baz", static_cast<int32_t>(baz)); Print(depth, "port", port.get()); } callback.Run(5); @@ -332,7 +332,7 @@ CheckFoo(*foo); PortPtr port; - service->Frobinate(std::move(foo), Service::BAZ_OPTIONS_EXTRA, + service->Frobinate(std::move(foo), Service::BazOptions::EXTRA, std::move(port), Service::FrobinateCallback()); delete service; @@ -360,11 +360,11 @@ EXPECT_DOUBLE_EQ(1.23E-20, defaults->a17); EXPECT_TRUE(defaults->a18.is_null()); EXPECT_TRUE(defaults->a19.is_null()); - EXPECT_EQ(Bar::TYPE_BOTH, defaults->a20); + EXPECT_EQ(Bar::Type::BOTH, defaults->a20); EXPECT_TRUE(defaults->a21.is_null()); ASSERT_FALSE(defaults->a22.is_null()); - EXPECT_EQ(imported::SHAPE_RECTANGLE, defaults->a22->shape); - EXPECT_EQ(imported::COLOR_BLACK, defaults->a22->color); + EXPECT_EQ(imported::Shape::RECTANGLE, defaults->a22->shape); + EXPECT_EQ(imported::Color::BLACK, defaults->a22->color); EXPECT_EQ(0xFFFFFFFFFFFFFFFFULL, defaults->a23); EXPECT_EQ(0x123456789, defaults->a24); EXPECT_EQ(-0x123456789, defaults->a25);
diff --git a/mojo/public/cpp/bindings/tests/union_unittest.cc b/mojo/public/cpp/bindings/tests/union_unittest.cc index 461e204..60bde4b 100644 --- a/mojo/public/cpp/bindings/tests/union_unittest.cc +++ b/mojo/public/cpp/bindings/tests/union_unittest.cc
@@ -87,8 +87,8 @@ EXPECT_TRUE(pod->is_f_bool()); EXPECT_EQ(pod->which(), PodUnion::Tag::F_BOOL); - pod->set_f_enum(AN_ENUM_SECOND); - EXPECT_EQ(AN_ENUM_SECOND, pod->get_f_enum()); + pod->set_f_enum(AnEnum::SECOND); + EXPECT_EQ(AnEnum::SECOND, pod->get_f_enum()); EXPECT_TRUE(pod->is_f_enum()); EXPECT_EQ(pod->which(), PodUnion::Tag::F_ENUM); } @@ -139,7 +139,7 @@ TEST(UnionTest, EnumSerialization) { PodUnionPtr pod1(PodUnion::New()); - pod1->set_f_enum(AN_ENUM_SECOND); + pod1->set_f_enum(AnEnum::SECOND); size_t size = GetSerializedSize_(pod1, false); EXPECT_EQ(16U, size); @@ -151,7 +151,7 @@ PodUnionPtr pod2; Deserialize_(data, &pod2, nullptr); - EXPECT_EQ(AN_ENUM_SECOND, pod2->get_f_enum()); + EXPECT_EQ(AnEnum::SECOND, pod2->get_f_enum()); EXPECT_TRUE(pod2->is_f_enum()); EXPECT_EQ(pod2->which(), PodUnion::Tag::F_ENUM); }
diff --git a/mojo/public/interfaces/bindings/tests/sample_import2.mojom b/mojo/public/interfaces/bindings/tests/sample_import2.mojom index 29065fc..ca4e81c0 100644 --- a/mojo/public/interfaces/bindings/tests/sample_import2.mojom +++ b/mojo/public/interfaces/bindings/tests/sample_import2.mojom
@@ -22,7 +22,7 @@ struct Thing { imported.Shape shape = RECTANGLE; - int32 color = Color.BLACK; + imported.Color color = Color.BLACK; Point location; Size size; };
diff --git a/mojo/public/interfaces/bindings/tests/test_structs.mojom b/mojo/public/interfaces/bindings/tests/test_structs.mojom index b62df5b..49b4fe8 100644 --- a/mojo/public/interfaces/bindings/tests/test_structs.mojom +++ b/mojo/public/interfaces/bindings/tests/test_structs.mojom
@@ -97,7 +97,6 @@ E3 = E2, E4, }; - const int32 TEN_TOO = EType.E2; EType f0 = E0; // 0 EType f1 = E1; // 1 EType f2 = E2; // 10
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl index 0e44acd..d11b198 100644 --- a/mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl +++ b/mojo/public/tools/bindings/generators/cpp_templates/enum_macros.tmpl
@@ -4,12 +4,12 @@ which case associated functions need to be static. ---#} {%- macro enum_decl(enum, is_static=false) %} -enum {{enum.name}} : int32_t { +enum class {{enum.name}} : int32_t { {%- for field in enum.fields %} {%- if field.value %} - {{enum.name|to_all_caps}}_{{field.name}} = {{field.value|expression_to_text}}, + {{field.name}} = {{field.value|expression_to_text}}, {%- else %} - {{enum.name|to_all_caps}}_{{field.name}}, + {{field.name}}, {%- endif %} {%- endfor %} }; @@ -27,6 +27,27 @@ bool {{enum.name}}_IsValidValue({{enum.name}} value); {%- endmacro %} +{%- macro enum_stream_operator(enum) %} +inline std::ostream& operator<<(std::ostream& os, {{enum|get_name_for_kind}} value) { + switch(value) { +{%- for _, values in enum.fields|groupby('numeric_value') %} + case {{enum|get_name_for_kind}}::{{values[0].name}}: + return os << "{{enum|get_name_for_kind}}:: +{%- if values|length > 1 -%} + {{'{'}} +{%- endif -%} + {{values|map(attribute='name')|join(', ')}} +{%- if values|length > 1 -%} + {{'}'}} +{%- endif -%} + "; +{%- endfor %} + default: + return os << "Unknown {{enum|get_name_for_kind}} value: " << static_cast<int32_t>(value); + } +} +{%- endmacro %} + {%- macro is_valid_enum_def(enum, class_name = '') %} {% if class_name != '' -%} // static
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl index f29d3d8a..5ef35a28 100644 --- a/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl +++ b/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl
@@ -16,6 +16,7 @@ #define {{header_guard}} #include <stdint.h> +#include <ostream> #include "mojo/public/cpp/bindings/array.h" #include "mojo/public/cpp/bindings/associated_interface_ptr.h" @@ -49,8 +50,10 @@ {#--- Enums #} {% from "enum_macros.tmpl" import enum_decl -%} +{% from "enum_macros.tmpl" import enum_stream_operator -%} {% for enum in enums %} {{enum_decl(enum)}} + {{enum_stream_operator(enum)}} {%- endfor %} {#--- Constants #} @@ -158,6 +161,18 @@ {%- endfor %} {%- endif %} +{% for struct in structs %} +{% for enum in struct.enums %} +{{enum_stream_operator(enum)}} +{%- endfor %} +{%- endfor %} + +{% for interface in interfaces %} +{% for enum in interface.enums %} +{{enum_stream_operator(enum)}} +{%- endfor %} +{%- endfor %} + {%- if variant %} } // namespace {{variant}} {%- endif %}
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl index 47068c53..ebc6048c 100644 --- a/mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl +++ b/mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl
@@ -110,6 +110,8 @@ {%- else %} {{output}}->{{name}} = mojo::internal::AssociatedInterfaceRequestHelper::PassHandle(&{{input_field}}).release(); {%- endif %} +{%- elif kind|is_enum_kind %} + {{output}}->{{name}} = static_cast<int32_t>({{input_field}}); {%- else %} {{output}}->{{name}} = {{input_field}}; {%- endif %}
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl index 5321d29f..f067e64 100644 --- a/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl +++ b/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl
@@ -78,6 +78,8 @@ std::move(*input_acc.data()->{{field.name}}), {{field.name}}); {%- elif field.kind|is_associated_kind %} // TODO(yzshen): add seralization logic for associated kinds. +{% elif field.kind|is_enum_kind %} + result->data.f_{{field.name}} = static_cast<int32_t>(input_acc.data()->{{field.name}}); {% else %} result->data.f_{{field.name}} = input_acc.data()->{{field.name}}; {%- endif %}
diff --git a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py index 45d74760e..eb2f03b 100644 --- a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py +++ b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
@@ -334,8 +334,7 @@ if token.parent_kind: name.append(token.parent_kind.name) if isinstance(token, mojom.EnumValue): - name.append( - "%s_%s" % (generator.CamelCaseToAllCaps(token.enum.name), token.name)) + name.extend([token.enum.name, token.name]) else: name.append(token.name) return "::".join(name) @@ -463,7 +462,6 @@ "passes_associated_kinds": mojom.PassesAssociatedKinds, "struct_size": lambda ps: ps.GetTotalSize() + _HEADER_SIZE, "stylize_method": generator.StudlyCapsToCamel, - "to_all_caps": generator.CamelCaseToAllCaps, "under_to_camel": generator.UnderToCamel, }
diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/generator.py b/mojo/public/tools/bindings/pylib/mojom/generate/generator.py index 9c225b4..0ecc615 100644 --- a/mojo/public/tools/bindings/pylib/mojom/generate/generator.py +++ b/mojo/public/tools/bindings/pylib/mojom/generate/generator.py
@@ -20,10 +20,6 @@ def StudlyCapsToCamel(studly): return studly[0].lower() + studly[1:] -def CamelCaseToAllCaps(camel_case): - return '_'.join( - word for word in re.split(r'([A-Z][^A-Z]+)', camel_case) if word).upper() - def UnderToCamel(under): """Converts underscore_separated strings to CamelCase strings.""" return ''.join(word.capitalize() for word in under.split('_'))
diff --git a/mojo/services/network/http_connection_impl.cc b/mojo/services/network/http_connection_impl.cc index 21c2f37..b2c7fd1 100644 --- a/mojo/services/network/http_connection_impl.cc +++ b/mojo/services/network/http_connection_impl.cc
@@ -156,7 +156,7 @@ } void Send(bool fin, MessageType type, uint32_t num_bytes) override { - if (!fin || type != MESSAGE_TYPE_TEXT) { + if (!fin || type != MessageType::TEXT) { NOTIMPLEMENTED(); Close(); } @@ -196,7 +196,7 @@ return; if (buffer) - client_->DidReceiveData(true, MESSAGE_TYPE_TEXT, num_bytes); + client_->DidReceiveData(true, MessageType::TEXT, num_bytes); } // Checks whether Close() has been called.
diff --git a/mojo/services/network/http_server_apptest.cc b/mojo/services/network/http_server_apptest.cc index f630f761..4fda6c0 100644 --- a/mojo/services/network/http_server_apptest.cc +++ b/mojo/services/network/http_server_apptest.cc
@@ -44,7 +44,7 @@ NetAddressPtr GetLocalHostWithAnyPort() { NetAddressPtr addr(NetAddress::New()); - addr->family = NET_ADDRESS_FAMILY_IPV4; + addr->family = NetAddressFamily::IPV4; addr->ipv4 = NetAddressIPv4::New(); addr->ipv4->port = 0; addr->ipv4->addr.resize(4); @@ -379,7 +379,7 @@ void OnFinishedWritingSendStream(uint32_t num_bytes, const char* buffer) { EXPECT_TRUE(buffer); - web_socket_->Send(true, WebSocket::MESSAGE_TYPE_TEXT, num_bytes); + web_socket_->Send(true, WebSocket::MessageType::TEXT, num_bytes); } void OnFinishedReadingReceiveStream(uint32_t num_bytes, const char* data) {
diff --git a/mojo/services/network/net_address_type_converters.cc b/mojo/services/network/net_address_type_converters.cc index a0102104..72eeb691 100644 --- a/mojo/services/network/net_address_type_converters.cc +++ b/mojo/services/network/net_address_type_converters.cc
@@ -15,12 +15,12 @@ return net::IPEndPoint(); switch (obj->family) { - case NET_ADDRESS_FAMILY_IPV4: + case NetAddressFamily::IPV4: if (!obj->ipv4) break; return net::IPEndPoint(obj->ipv4->addr.storage(), obj->ipv4->port); - case NET_ADDRESS_FAMILY_IPV6: + case NetAddressFamily::IPV6: if (!obj->ipv6) break; return net::IPEndPoint(obj->ipv6->addr.storage(), obj->ipv6->port); @@ -39,14 +39,14 @@ switch (obj.GetFamily()) { case net::ADDRESS_FAMILY_IPV4: - net_address->family = NET_ADDRESS_FAMILY_IPV4; + net_address->family = NetAddressFamily::IPV4; net_address->ipv4 = NetAddressIPv4::New(); net_address->ipv4->port = static_cast<uint16_t>(obj.port()); net_address->ipv4->addr = Array<uint8_t>::From(obj.address()); break; - case NET_ADDRESS_FAMILY_IPV6: + case net::ADDRESS_FAMILY_IPV6: net_address->ipv6 = NetAddressIPv6::New(); - net_address->family = NET_ADDRESS_FAMILY_IPV6; + net_address->family = NetAddressFamily::IPV6; net_address->ipv6->port = static_cast<uint16_t>(obj.port()); net_address->ipv6->addr = Array<uint8_t>::From(obj.address()); break;
diff --git a/mojo/services/network/network_service_delegate.cc b/mojo/services/network/network_service_delegate.cc index fff5950..74388f1 100644 --- a/mojo/services/network/network_service_delegate.cc +++ b/mojo/services/network/network_service_delegate.cc
@@ -101,7 +101,7 @@ filesystem::FileSystemClientPtr client; binding_.Bind(GetProxy(&client)); - filesystem::FileError error = filesystem::FILE_ERROR_FAILED; + filesystem::FileError error = filesystem::FileError::FAILED; filesystem::DirectoryPtr directory; files_->OpenFileSystem("origin", GetProxy(&directory), std::move(client), Capture(&error));
diff --git a/mojo/services/network/udp_socket_apptest.cc b/mojo/services/network/udp_socket_apptest.cc index 17388a4..66e0a12 100644 --- a/mojo/services/network/udp_socket_apptest.cc +++ b/mojo/services/network/udp_socket_apptest.cc
@@ -26,7 +26,7 @@ NetAddressPtr GetLocalHostWithAnyPort() { NetAddressPtr addr(NetAddress::New()); - addr->family = NET_ADDRESS_FAMILY_IPV4; + addr->family = NetAddressFamily::IPV4; addr->ipv4 = NetAddressIPv4::New(); addr->ipv4->port = 0; addr->ipv4->addr.resize(4);
diff --git a/mojo/services/network/web_socket_impl.cc b/mojo/services/network/web_socket_impl.cc index 9b2e8f7..459b531 100644 --- a/mojo/services/network/web_socket_impl.cc +++ b/mojo/services/network/web_socket_impl.cc
@@ -30,19 +30,19 @@ WebSocket::MessageType> { static net::WebSocketFrameHeader::OpCode Convert( WebSocket::MessageType type) { - DCHECK(type == WebSocket::MESSAGE_TYPE_CONTINUATION || - type == WebSocket::MESSAGE_TYPE_TEXT || - type == WebSocket::MESSAGE_TYPE_BINARY); + DCHECK(type == WebSocket::MessageType::CONTINUATION || + type == WebSocket::MessageType::TEXT || + type == WebSocket::MessageType::BINARY); typedef net::WebSocketFrameHeader::OpCode OpCode; // These compile asserts verify that the same underlying values are used for // both types, so we can simply cast between them. - static_assert(static_cast<OpCode>(WebSocket::MESSAGE_TYPE_CONTINUATION) == + static_assert(static_cast<OpCode>(WebSocket::MessageType::CONTINUATION) == net::WebSocketFrameHeader::kOpCodeContinuation, "enum values must match for opcode continuation"); - static_assert(static_cast<OpCode>(WebSocket::MESSAGE_TYPE_TEXT) == + static_assert(static_cast<OpCode>(WebSocket::MessageType::TEXT) == net::WebSocketFrameHeader::kOpCodeText, "enum values must match for opcode text"); - static_assert(static_cast<OpCode>(WebSocket::MESSAGE_TYPE_BINARY) == + static_assert(static_cast<OpCode>(WebSocket::MessageType::BINARY) == net::WebSocketFrameHeader::kOpCodeBinary, "enum values must match for opcode binary"); return static_cast<OpCode>(type);
diff --git a/net/cookies/canonical_cookie.cc b/net/cookies/canonical_cookie.cc index 15287e0..4491873 100644 --- a/net/cookies/canonical_cookie.cc +++ b/net/cookies/canonical_cookie.cc
@@ -217,26 +217,27 @@ } // static -CanonicalCookie* CanonicalCookie::Create(const GURL& url, - const std::string& cookie_line, - const base::Time& creation_time, - const CookieOptions& options) { +scoped_ptr<CanonicalCookie> CanonicalCookie::Create( + const GURL& url, + const std::string& cookie_line, + const base::Time& creation_time, + const CookieOptions& options) { ParsedCookie parsed_cookie(cookie_line); if (!parsed_cookie.IsValid()) { VLOG(kVlogSetCookies) << "WARNING: Couldn't parse cookie"; - return NULL; + return nullptr; } if (options.exclude_httponly() && parsed_cookie.IsHttpOnly()) { VLOG(kVlogSetCookies) << "Create() is not creating a httponly cookie"; - return NULL; + return nullptr; } std::string cookie_domain; if (!GetCookieDomain(url, parsed_cookie, &cookie_domain)) { VLOG(kVlogSetCookies) << "Create() failed to get a cookie domain"; - return NULL; + return nullptr; } // Per 3.2.1 of "Deprecate modification of 'secure' cookies from non-secure @@ -247,7 +248,7 @@ !url.SchemeIsCryptographic()) { VLOG(kVlogSetCookies) << "Create() is trying to create a secure cookie from an insecure URL"; - return NULL; + return nullptr; } std::string cookie_path = CanonicalCookie::CanonPath(url, parsed_cookie); @@ -269,54 +270,56 @@ return nullptr; } - return new CanonicalCookie( + return make_scoped_ptr(new CanonicalCookie( url, parsed_cookie.Name(), parsed_cookie.Value(), cookie_domain, cookie_path, creation_time, cookie_expires, creation_time, parsed_cookie.IsSecure(), parsed_cookie.IsHttpOnly(), - parsed_cookie.IsFirstPartyOnly(), parsed_cookie.Priority()); + parsed_cookie.IsFirstPartyOnly(), parsed_cookie.Priority())); } -CanonicalCookie* CanonicalCookie::Create(const GURL& url, - const std::string& name, - const std::string& value, - const std::string& domain, - const std::string& path, - const base::Time& creation, - const base::Time& expiration, - bool secure, - bool http_only, - bool first_party_only, - bool enforce_strict_secure, - CookiePriority priority) { +// static +scoped_ptr<CanonicalCookie> CanonicalCookie::Create( + const GURL& url, + const std::string& name, + const std::string& value, + const std::string& domain, + const std::string& path, + const base::Time& creation, + const base::Time& expiration, + bool secure, + bool http_only, + bool first_party_only, + bool enforce_strict_secure, + CookiePriority priority) { // Expect valid attribute tokens and values, as defined by the ParsedCookie // logic, otherwise don't create the cookie. std::string parsed_name = ParsedCookie::ParseTokenString(name); if (parsed_name != name) - return NULL; + return nullptr; std::string parsed_value = ParsedCookie::ParseValueString(value); if (parsed_value != value) - return NULL; + return nullptr; std::string parsed_domain = ParsedCookie::ParseValueString(domain); if (parsed_domain != domain) - return NULL; + return nullptr; std::string cookie_domain; if (!cookie_util::GetCookieDomainWithString(url, parsed_domain, &cookie_domain)) { - return NULL; + return nullptr; } if (enforce_strict_secure && secure && !url.SchemeIsCryptographic()) - return NULL; + return nullptr; std::string parsed_path = ParsedCookie::ParseValueString(path); if (parsed_path != path) - return NULL; + return nullptr; std::string cookie_path = CanonPathWithString(url, parsed_path); // Expect that the path was either not specified (empty), or is valid. if (!parsed_path.empty() && cookie_path != parsed_path) - return NULL; + return nullptr; // Canonicalize path again to make sure it escapes characters as needed. url::Component path_component(0, cookie_path.length()); url::RawCanonOutputT<char> canon_path; @@ -326,9 +329,9 @@ cookie_path = std::string(canon_path.data() + canon_path_component.begin, canon_path_component.len); - return new CanonicalCookie(url, parsed_name, parsed_value, cookie_domain, - cookie_path, creation, expiration, creation, - secure, http_only, first_party_only, priority); + return make_scoped_ptr(new CanonicalCookie( + url, parsed_name, parsed_value, cookie_domain, cookie_path, creation, + expiration, creation, secure, http_only, first_party_only, priority)); } bool CanonicalCookie::IsOnPath(const std::string& url_path) const {
diff --git a/net/cookies/canonical_cookie.h b/net/cookies/canonical_cookie.h index 9c3a1c9c..da836b2b 100644 --- a/net/cookies/canonical_cookie.h +++ b/net/cookies/canonical_cookie.h
@@ -9,6 +9,7 @@ #include <vector> #include "base/gtest_prod_util.h" +#include "base/memory/scoped_ptr.h" #include "base/time/time.h" #include "net/base/net_export.h" #include "net/cookies/cookie_constants.h" @@ -52,26 +53,26 @@ // Creates a new |CanonicalCookie| from the |cookie_line| and the // |creation_time|. Canonicalizes and validates inputs. May return NULL if // an attribute value is invalid. - static CanonicalCookie* Create(const GURL& url, - const std::string& cookie_line, - const base::Time& creation_time, - const CookieOptions& options); + static scoped_ptr<CanonicalCookie> Create(const GURL& url, + const std::string& cookie_line, + const base::Time& creation_time, + const CookieOptions& options); // Creates a canonical cookie from unparsed attribute values. // Canonicalizes and validates inputs. May return NULL if an attribute // value is invalid. - static CanonicalCookie* Create(const GURL& url, - const std::string& name, - const std::string& value, - const std::string& domain, - const std::string& path, - const base::Time& creation, - const base::Time& expiration, - bool secure, - bool http_only, - bool first_party_only, - bool enforce_strict_secure, - CookiePriority priority); + static scoped_ptr<CanonicalCookie> Create(const GURL& url, + const std::string& name, + const std::string& value, + const std::string& domain, + const std::string& path, + const base::Time& creation, + const base::Time& expiration, + bool secure, + bool http_only, + bool first_party_only, + bool enforce_strict_secure, + CookiePriority priority); const GURL& Source() const { return source_; } const std::string& Name() const { return name_; }
diff --git a/net/cookies/canonical_cookie_unittest.cc b/net/cookies/canonical_cookie_unittest.cc index 2a01d974..8b519b3 100644 --- a/net/cookies/canonical_cookie_unittest.cc +++ b/net/cookies/canonical_cookie_unittest.cc
@@ -58,7 +58,7 @@ EXPECT_FALSE(cookie->IsSecure()); GURL url2("http://www.foo.com"); - cookie.reset(CanonicalCookie::Create(url2, "B=1", creation_time, options)); + cookie = CanonicalCookie::Create(url2, "B=1", creation_time, options); EXPECT_EQ(url2.GetOrigin(), cookie->Source()); EXPECT_EQ("B", cookie->Name()); EXPECT_EQ("1", cookie->Value()); @@ -68,34 +68,33 @@ // Test creating secure cookies. RFC 6265 allows insecure urls to set secure // cookies. - cookie.reset( - CanonicalCookie::Create(url, "A=2; Secure", creation_time, options)); + cookie = CanonicalCookie::Create(url, "A=2; Secure", creation_time, options); EXPECT_TRUE(cookie.get()); EXPECT_TRUE(cookie->IsSecure()); // Test creating http only cookies. - cookie.reset( - CanonicalCookie::Create(url, "A=2; HttpOnly", creation_time, options)); + cookie = + CanonicalCookie::Create(url, "A=2; HttpOnly", creation_time, options); EXPECT_FALSE(cookie.get()); CookieOptions httponly_options; httponly_options.set_include_httponly(); - cookie.reset(CanonicalCookie::Create(url, "A=2; HttpOnly", creation_time, - httponly_options)); + cookie = CanonicalCookie::Create(url, "A=2; HttpOnly", creation_time, + httponly_options); EXPECT_TRUE(cookie->IsHttpOnly()); // Test creating http only cookies. CookieOptions first_party_options; first_party_options.set_include_first_party_only_cookies(); - cookie.reset(CanonicalCookie::Create(url, "A=2; First-Party-Only", - creation_time, httponly_options)); + cookie = CanonicalCookie::Create(url, "A=2; First-Party-Only", creation_time, + httponly_options); EXPECT_TRUE(cookie.get()); EXPECT_TRUE(cookie->IsFirstPartyOnly()); // Test the creating cookies using specific parameter instead of a cookie // string. - cookie.reset(CanonicalCookie::Create( - url, "A", "2", "www.example.com", "/test", creation_time, base::Time(), - false, false, false, false, COOKIE_PRIORITY_DEFAULT)); + cookie = CanonicalCookie::Create(url, "A", "2", "www.example.com", "/test", + creation_time, base::Time(), false, false, + false, false, COOKIE_PRIORITY_DEFAULT); EXPECT_EQ(url.GetOrigin(), cookie->Source()); EXPECT_EQ("A", cookie->Name()); EXPECT_EQ("2", cookie->Value()); @@ -105,9 +104,9 @@ EXPECT_FALSE(cookie->IsHttpOnly()); EXPECT_FALSE(cookie->IsFirstPartyOnly()); - cookie.reset(CanonicalCookie::Create( - url, "A", "2", ".www.example.com", "/test", creation_time, base::Time(), - false, false, false, false, COOKIE_PRIORITY_DEFAULT)); + cookie = CanonicalCookie::Create(url, "A", "2", ".www.example.com", "/test", + creation_time, base::Time(), false, false, + false, false, COOKIE_PRIORITY_DEFAULT); EXPECT_EQ(url.GetOrigin(), cookie->Source()); EXPECT_EQ("A", cookie->Name()); EXPECT_EQ("2", cookie->Value()); @@ -134,8 +133,7 @@ // With a stale server time options.set_server_time(creation_time - base::TimeDelta::FromHours(1)); - cookie.reset( - CanonicalCookie::Create(url, cookie_line, creation_time, options)); + cookie = CanonicalCookie::Create(url, cookie_line, creation_time, options); EXPECT_TRUE(cookie.get()); EXPECT_FALSE(cookie->IsPersistent()); EXPECT_FALSE(cookie->IsExpired(creation_time)); @@ -143,8 +141,7 @@ // With a future server time options.set_server_time(creation_time + base::TimeDelta::FromHours(1)); - cookie.reset( - CanonicalCookie::Create(url, cookie_line, creation_time, options)); + cookie = CanonicalCookie::Create(url, cookie_line, creation_time, options); EXPECT_TRUE(cookie.get()); EXPECT_FALSE(cookie->IsPersistent()); EXPECT_FALSE(cookie->IsExpired(creation_time)); @@ -353,8 +350,8 @@ EXPECT_FALSE(cookie->IsDomainMatch("www0.example.com")); EXPECT_FALSE(cookie->IsDomainMatch("example.com")); - cookie.reset(CanonicalCookie::Create(url, "A=2; Domain=www.example.com", - creation_time, options)); + cookie = CanonicalCookie::Create(url, "A=2; Domain=www.example.com", + creation_time, options); EXPECT_TRUE(cookie->IsDomainCookie()); EXPECT_TRUE(cookie->IsDomainMatch("www.example.com")); EXPECT_TRUE(cookie->IsDomainMatch("www.example.com")); @@ -362,8 +359,8 @@ EXPECT_FALSE(cookie->IsDomainMatch("www0.example.com")); EXPECT_FALSE(cookie->IsDomainMatch("example.com")); - cookie.reset(CanonicalCookie::Create(url, "A=2; Domain=.www.example.com", - creation_time, options)); + cookie = CanonicalCookie::Create(url, "A=2; Domain=.www.example.com", + creation_time, options); EXPECT_TRUE(cookie->IsDomainMatch("www.example.com")); EXPECT_TRUE(cookie->IsDomainMatch("www.example.com")); EXPECT_TRUE(cookie->IsDomainMatch("foo.www.example.com")); @@ -384,9 +381,8 @@ // Test the empty string edge case. EXPECT_FALSE(cookie->IsOnPath(std::string())); - cookie.reset( - CanonicalCookie::Create(GURL("http://www.example.com/test/foo.html"), - "A=2", creation_time, options)); + cookie = CanonicalCookie::Create(GURL("http://www.example.com/test/foo.html"), + "A=2", creation_time, options); EXPECT_FALSE(cookie->IsOnPath("/")); EXPECT_TRUE(cookie->IsOnPath("/test")); EXPECT_TRUE(cookie->IsOnPath("/test/bar.html")); @@ -412,16 +408,16 @@ // Test that cookie with a cookie path that does not match the url path are // not included. - cookie.reset(CanonicalCookie::Create(url, "A=2; Path=/foo/bar", creation_time, - options)); + cookie = CanonicalCookie::Create(url, "A=2; Path=/foo/bar", creation_time, + options); EXPECT_FALSE(cookie->IncludeForRequestURL(url, options)); EXPECT_TRUE(cookie->IncludeForRequestURL( GURL("http://www.example.com/foo/bar/index.html"), options)); // Test that a secure cookie is not included for a non secure URL. GURL secure_url("https://www.example.com"); - cookie.reset(CanonicalCookie::Create(secure_url, "A=2; Secure", creation_time, - options)); + cookie = CanonicalCookie::Create(secure_url, "A=2; Secure", creation_time, + options); EXPECT_TRUE(cookie->IsSecure()); EXPECT_TRUE(cookie->IncludeForRequestURL(secure_url, options)); EXPECT_FALSE(cookie->IncludeForRequestURL(url, options)); @@ -429,8 +425,8 @@ // Test that http only cookies are only included if the include httponly flag // is set on the cookie options. options.set_include_httponly(); - cookie.reset( - CanonicalCookie::Create(url, "A=2; HttpOnly", creation_time, options)); + cookie = + CanonicalCookie::Create(url, "A=2; HttpOnly", creation_time, options); EXPECT_TRUE(cookie->IsHttpOnly()); EXPECT_TRUE(cookie->IncludeForRequestURL(url, options)); options.set_exclude_httponly(); @@ -448,33 +444,33 @@ // First-party-only cookies are not included for non-first-party requests, // even if other properties match: - cookie.reset(CanonicalCookie::Create(secure_url, "A=2; First-Party-Only", - creation_time, options)); + cookie = CanonicalCookie::Create(secure_url, "A=2; First-Party-Only", + creation_time, options); EXPECT_TRUE(cookie->IsFirstPartyOnly()); EXPECT_FALSE(cookie->IncludeForRequestURL(secure_url, options)); - cookie.reset(CanonicalCookie::Create( - secure_url, "A=2; Secure; First-Party-Only", creation_time, options)); + cookie = CanonicalCookie::Create(secure_url, "A=2; Secure; First-Party-Only", + creation_time, options); EXPECT_TRUE(cookie->IsFirstPartyOnly()); EXPECT_FALSE(cookie->IncludeForRequestURL(secure_url, options)); - cookie.reset(CanonicalCookie::Create(secure_url_with_path, - "A=2; First-Party-Only; path=/foo/bar", - creation_time, options)); + cookie = CanonicalCookie::Create(secure_url_with_path, + "A=2; First-Party-Only; path=/foo/bar", + creation_time, options); EXPECT_TRUE(cookie->IsFirstPartyOnly()); EXPECT_FALSE(cookie->IncludeForRequestURL(secure_url, options)); // First-party-only cookies are included for first-party requests: options.set_include_first_party_only_cookies(); - cookie.reset(CanonicalCookie::Create(secure_url, "A=2; First-Party-Only", - creation_time, options)); + cookie = CanonicalCookie::Create(secure_url, "A=2; First-Party-Only", + creation_time, options); EXPECT_TRUE(cookie->IsFirstPartyOnly()); EXPECT_TRUE(cookie->IncludeForRequestURL(secure_url, options)); - cookie.reset(CanonicalCookie::Create( - secure_url, "A=2; Secure; First-Party-Only", creation_time, options)); + cookie = CanonicalCookie::Create(secure_url, "A=2; Secure; First-Party-Only", + creation_time, options); EXPECT_TRUE(cookie->IsFirstPartyOnly()); EXPECT_TRUE(cookie->IncludeForRequestURL(secure_url, options)); - cookie.reset(CanonicalCookie::Create(secure_url_with_path, - "A=2; First-Party-Only; path=/foo/bar", - creation_time, options)); + cookie = CanonicalCookie::Create(secure_url_with_path, + "A=2; First-Party-Only; path=/foo/bar", + creation_time, options); EXPECT_TRUE(cookie->IsFirstPartyOnly()); EXPECT_TRUE(cookie->IncludeForRequestURL(secure_url_with_path, options)); } @@ -549,28 +545,24 @@ CookieOptions options; // A __Secure- cookie must be Secure. - EXPECT_EQ(nullptr, make_scoped_ptr(CanonicalCookie::Create( - https_url, "__Secure-A=B", creation_time, options))); - EXPECT_EQ(nullptr, - make_scoped_ptr(CanonicalCookie::Create( - https_url, "__Secure-A=B; httponly", creation_time, options))); + EXPECT_FALSE(CanonicalCookie::Create(https_url, "__Secure-A=B", creation_time, + options)); + EXPECT_FALSE(CanonicalCookie::Create(https_url, "__Secure-A=B; httponly", + creation_time, options)); // A typoed prefix does not have to be Secure. - EXPECT_NE(nullptr, - make_scoped_ptr(CanonicalCookie::Create( - https_url, "__secure-A=B; Secure", creation_time, options))); - EXPECT_NE(nullptr, make_scoped_ptr(CanonicalCookie::Create( - https_url, "__secure-A=C;", creation_time, options))); - EXPECT_NE(nullptr, - make_scoped_ptr(CanonicalCookie::Create( - https_url, "__SecureA=B; Secure", creation_time, options))); - EXPECT_NE(nullptr, make_scoped_ptr(CanonicalCookie::Create( - https_url, "__SecureA=C;", creation_time, options))); + EXPECT_TRUE(CanonicalCookie::Create(https_url, "__secure-A=B; Secure", + creation_time, options)); + EXPECT_TRUE(CanonicalCookie::Create(https_url, "__secure-A=C;", creation_time, + options)); + EXPECT_TRUE(CanonicalCookie::Create(https_url, "__SecureA=B; Secure", + creation_time, options)); + EXPECT_TRUE(CanonicalCookie::Create(https_url, "__SecureA=C;", creation_time, + options)); // A __Secure- cookie can't be set on a non-secure origin. - EXPECT_EQ(nullptr, - make_scoped_ptr(CanonicalCookie::Create( - http_url, "__Secure-A=B; Secure", creation_time, options))); + EXPECT_FALSE(CanonicalCookie::Create(http_url, "__Secure-A=B; Secure", + creation_time, options)); } TEST(CanonicalCookieTest, HostCookiePrefix) { @@ -581,54 +573,44 @@ std::string domain = https_url.host(); // A __Host- cookie must be Secure. - EXPECT_EQ(nullptr, make_scoped_ptr(CanonicalCookie::Create( - https_url, "__Host-A=B;", creation_time, options))); - EXPECT_EQ(nullptr, - make_scoped_ptr(CanonicalCookie::Create( - https_url, "__Host-A=B; Domain=" + domain + "; Path=/;", - creation_time, options))); - EXPECT_NE(nullptr, make_scoped_ptr(CanonicalCookie::Create( - https_url, "__Host-A=B; Path=/; Secure;", - creation_time, options))); + EXPECT_FALSE(CanonicalCookie::Create(https_url, "__Host-A=B;", creation_time, + options)); + EXPECT_FALSE(CanonicalCookie::Create( + https_url, "__Host-A=B; Domain=" + domain + "; Path=/;", creation_time, + options)); + EXPECT_TRUE(CanonicalCookie::Create(https_url, "__Host-A=B; Path=/; Secure;", + creation_time, options)); // A __Host- cookie must be set from a secure scheme. - EXPECT_EQ(nullptr, - make_scoped_ptr(CanonicalCookie::Create( - http_url, "__Host-A=B; Domain=" + domain + "; Path=/; Secure;", - creation_time, options))); - EXPECT_NE(nullptr, make_scoped_ptr(CanonicalCookie::Create( - https_url, "__Host-A=B; Path=/; Secure;", - creation_time, options))); + EXPECT_FALSE(CanonicalCookie::Create( + http_url, "__Host-A=B; Domain=" + domain + "; Path=/; Secure;", + creation_time, options)); + EXPECT_TRUE(CanonicalCookie::Create(https_url, "__Host-A=B; Path=/; Secure;", + creation_time, options)); // A __Host- cookie can't have a Domain. - EXPECT_EQ(nullptr, - make_scoped_ptr(CanonicalCookie::Create( - https_url, "__Host-A=B; Domain=" + domain + "; Path=/; Secure;", - creation_time, options))); - EXPECT_EQ(nullptr, - make_scoped_ptr(CanonicalCookie::Create( - https_url, "__Host-A=B; Domain=" + domain + "; Secure;", - creation_time, options))); + EXPECT_FALSE(CanonicalCookie::Create( + https_url, "__Host-A=B; Domain=" + domain + "; Path=/; Secure;", + creation_time, options)); + EXPECT_FALSE(CanonicalCookie::Create( + https_url, "__Host-A=B; Domain=" + domain + "; Secure;", creation_time, + options)); // A __Host- cookie must have a Path of "/". - EXPECT_EQ(nullptr, make_scoped_ptr(CanonicalCookie::Create( - https_url, "__Host-A=B; Path=/foo; Secure;", - creation_time, options))); - EXPECT_EQ(nullptr, - make_scoped_ptr(CanonicalCookie::Create( - https_url, "__Host-A=B; Secure;", creation_time, options))); - EXPECT_NE(nullptr, make_scoped_ptr(CanonicalCookie::Create( - https_url, "__Host-A=B; Secure; Path=/;", - creation_time, options))); + EXPECT_FALSE(CanonicalCookie::Create( + https_url, "__Host-A=B; Path=/foo; Secure;", creation_time, options)); + EXPECT_FALSE(CanonicalCookie::Create(https_url, "__Host-A=B; Secure;", + creation_time, options)); + EXPECT_TRUE(CanonicalCookie::Create(https_url, "__Host-A=B; Secure; Path=/;", + creation_time, options)); // Rules don't apply for a typoed prefix. - EXPECT_NE(nullptr, - make_scoped_ptr(CanonicalCookie::Create( - http_url, "__host-A=B; Domain=" + domain + "; Path=/; Secure;", - creation_time, options))); - EXPECT_NE(nullptr, make_scoped_ptr(CanonicalCookie::Create( - https_url, "__HostA=B; Domain=" + domain + "; Secure;", - creation_time, options))); + EXPECT_TRUE(CanonicalCookie::Create( + http_url, "__host-A=B; Domain=" + domain + "; Path=/; Secure;", + creation_time, options)); + EXPECT_TRUE(CanonicalCookie::Create( + https_url, "__HostA=B; Domain=" + domain + "; Secure;", creation_time, + options)); } TEST(CanonicalCookieTest, EnforceSecureCookiesRequireSecureScheme) { @@ -683,48 +665,42 @@ base::Time creation_time = base::Time::Now(); CookieOptions options; - scoped_ptr<CanonicalCookie> cookie1 = make_scoped_ptr(CanonicalCookie::Create( - https_url, "__Host-A=B;", creation_time, options)); - EXPECT_EQ(nullptr, cookie1); + EXPECT_FALSE(CanonicalCookie::Create(https_url, "__Host-A=B;", creation_time, + options)); histograms.ExpectBucketCount(kCookiePrefixHistogram, CanonicalCookie::COOKIE_PREFIX_HOST, 1); histograms.ExpectBucketCount(kCookiePrefixBlockedHistogram, CanonicalCookie::COOKIE_PREFIX_HOST, 1); - EXPECT_NE(nullptr, make_scoped_ptr(CanonicalCookie::Create( - https_url, "__Host-A=B; Path=/; Secure", creation_time, - options))); + EXPECT_TRUE(CanonicalCookie::Create(https_url, "__Host-A=B; Path=/; Secure", + creation_time, options)); histograms.ExpectBucketCount(kCookiePrefixHistogram, CanonicalCookie::COOKIE_PREFIX_HOST, 2); histograms.ExpectBucketCount(kCookiePrefixBlockedHistogram, CanonicalCookie::COOKIE_PREFIX_HOST, 1); - EXPECT_NE(nullptr, make_scoped_ptr(CanonicalCookie::Create( - https_url, "__HostA=B; Path=/; Secure", creation_time, - options))); + EXPECT_TRUE(CanonicalCookie::Create(https_url, "__HostA=B; Path=/; Secure", + creation_time, options)); histograms.ExpectBucketCount(kCookiePrefixHistogram, CanonicalCookie::COOKIE_PREFIX_HOST, 2); histograms.ExpectBucketCount(kCookiePrefixBlockedHistogram, CanonicalCookie::COOKIE_PREFIX_HOST, 1); - scoped_ptr<CanonicalCookie> cookie2 = make_scoped_ptr(CanonicalCookie::Create( - https_url, "__Secure-A=B;", creation_time, options)); - EXPECT_EQ(nullptr, cookie2); + EXPECT_FALSE(CanonicalCookie::Create(https_url, "__Secure-A=B;", + creation_time, options)); histograms.ExpectBucketCount(kCookiePrefixHistogram, CanonicalCookie::COOKIE_PREFIX_SECURE, 1); histograms.ExpectBucketCount(kCookiePrefixBlockedHistogram, CanonicalCookie::COOKIE_PREFIX_SECURE, 1); - EXPECT_NE(nullptr, make_scoped_ptr(CanonicalCookie::Create( - https_url, "__Secure-A=B; Path=/; Secure", - creation_time, options))); + EXPECT_TRUE(CanonicalCookie::Create(https_url, "__Secure-A=B; Path=/; Secure", + creation_time, options)); histograms.ExpectBucketCount(kCookiePrefixHistogram, CanonicalCookie::COOKIE_PREFIX_SECURE, 2); histograms.ExpectBucketCount(kCookiePrefixBlockedHistogram, CanonicalCookie::COOKIE_PREFIX_SECURE, 1); - EXPECT_NE(nullptr, make_scoped_ptr(CanonicalCookie::Create( - https_url, "__SecureA=B; Path=/; Secure", - creation_time, options))); + EXPECT_TRUE(CanonicalCookie::Create(https_url, "__SecureA=B; Path=/; Secure", + creation_time, options)); histograms.ExpectBucketCount(kCookiePrefixHistogram, CanonicalCookie::COOKIE_PREFIX_SECURE, 2); histograms.ExpectBucketCount(kCookiePrefixBlockedHistogram,
diff --git a/net/cookies/cookie_monster.cc b/net/cookies/cookie_monster.cc index 15e4f7e..76f9d9350 100644 --- a/net/cookies/cookie_monster.cc +++ b/net/cookies/cookie_monster.cc
@@ -1153,8 +1153,7 @@ Time creation_time = CurrentTime(); last_time_seen_ = creation_time; - scoped_ptr<CanonicalCookie> cc; - cc.reset(CanonicalCookie::Create( + scoped_ptr<CanonicalCookie> cc(CanonicalCookie::Create( url, name, value, domain, path, creation_time, expiration_time, secure, http_only, first_party_only, enforce_strict_secure, priority));
diff --git a/net/cookies/cookie_monster_unittest.cc b/net/cookies/cookie_monster_unittest.cc index efeadd96..4097dfe 100644 --- a/net/cookies/cookie_monster_unittest.cc +++ b/net/cookies/cookie_monster_unittest.cc
@@ -2820,11 +2820,11 @@ // MultiThreadedCookieMonsterTest in order to test and use // GetAllCookiesForURLAsync, but it does not use any additional threads. TEST_F(MultiThreadedCookieMonsterTest, GetAllCookiesForURLEffectiveDomain) { - std::vector<CanonicalCookie*> cookies; - // This cookie will be freed by the CookieMonster. - cookies.push_back(CanonicalCookie::Create( + scoped_ptr<CanonicalCookie> cookie(CanonicalCookie::Create( http_www_google_.url(), kValidCookieLine, Time::Now(), CookieOptions())); - CanonicalCookie cookie = *cookies[0]; + + // This cookie will be freed by the CookieMonster. + std::vector<CanonicalCookie*> cookies = {new CanonicalCookie(*cookie)}; scoped_refptr<NewMockPersistentCookieStore> store( new NewMockPersistentCookieStore); scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL)); @@ -2856,7 +2856,7 @@ ASSERT_TRUE(callback.did_run()); // See that the callback was called with the cookies. ASSERT_EQ(1u, callback.cookies().size()); - EXPECT_TRUE(cookie.IsEquivalent(callback.cookies()[0])); + EXPECT_TRUE(cookie->IsEquivalent(callback.cookies()[0])); // All urls in |urls| should share the same cookie domain. const GURL kUrls[] = { @@ -2870,7 +2870,7 @@ GetAllCookiesForURLTask(cm.get(), url, &callback); ASSERT_TRUE(callback.did_run()); ASSERT_EQ(1u, callback.cookies().size()); - EXPECT_TRUE(cookie.IsEquivalent(callback.cookies()[0])); + EXPECT_TRUE(cookie->IsEquivalent(callback.cookies()[0])); } }
diff --git a/net/dns/host_resolver_mojo_unittest.cc b/net/dns/host_resolver_mojo_unittest.cc index c5f3ba9..c0d05a7 100644 --- a/net/dns/host_resolver_mojo_unittest.cc +++ b/net/dns/host_resolver_mojo_unittest.cc
@@ -192,7 +192,7 @@ interfaces::HostResolverRequestInfo& request = *mock_resolver_->requests()[0]; EXPECT_EQ("example.com", request.host.To<std::string>()); EXPECT_EQ(12345, request.port); - EXPECT_EQ(interfaces::ADDRESS_FAMILY_UNSPECIFIED, request.address_family); + EXPECT_EQ(interfaces::AddressFamily::UNSPECIFIED, request.address_family); EXPECT_FALSE(request.is_my_ip_address); } @@ -272,13 +272,13 @@ *mock_resolver_->requests()[0]; EXPECT_EQ("example.com", request1.host.To<std::string>()); EXPECT_EQ(12345, request1.port); - EXPECT_EQ(interfaces::ADDRESS_FAMILY_IPV4, request1.address_family); + EXPECT_EQ(interfaces::AddressFamily::IPV4, request1.address_family); EXPECT_TRUE(request1.is_my_ip_address); interfaces::HostResolverRequestInfo& request2 = *mock_resolver_->requests()[1]; EXPECT_EQ("example.org", request2.host.To<std::string>()); EXPECT_EQ(80, request2.port); - EXPECT_EQ(interfaces::ADDRESS_FAMILY_IPV6, request2.address_family); + EXPECT_EQ(interfaces::AddressFamily::IPV6, request2.address_family); EXPECT_FALSE(request2.is_my_ip_address); } @@ -296,7 +296,7 @@ interfaces::HostResolverRequestInfo& request = *mock_resolver_->requests()[0]; EXPECT_EQ("example.com", request.host.To<std::string>()); EXPECT_EQ(8080, request.port); - EXPECT_EQ(interfaces::ADDRESS_FAMILY_IPV4, request.address_family); + EXPECT_EQ(interfaces::AddressFamily::IPV4, request.address_family); EXPECT_FALSE(request.is_my_ip_address); } @@ -328,7 +328,7 @@ interfaces::HostResolverRequestInfo& request = *mock_resolver_->requests()[0]; EXPECT_EQ("example.com", request.host.To<std::string>()); EXPECT_EQ(80, request.port); - EXPECT_EQ(interfaces::ADDRESS_FAMILY_IPV6, request.address_family); + EXPECT_EQ(interfaces::AddressFamily::IPV6, request.address_family); EXPECT_FALSE(request.is_my_ip_address); } @@ -344,7 +344,7 @@ interfaces::HostResolverRequestInfo& request = *mock_resolver_->requests()[0]; EXPECT_EQ("example.com", request.host.To<std::string>()); EXPECT_EQ(1, request.port); - EXPECT_EQ(interfaces::ADDRESS_FAMILY_UNSPECIFIED, request.address_family); + EXPECT_EQ(interfaces::AddressFamily::UNSPECIFIED, request.address_family); EXPECT_FALSE(request.is_my_ip_address); }
diff --git a/net/dns/mojo_host_resolver_impl_unittest.cc b/net/dns/mojo_host_resolver_impl_unittest.cc index 3bf32758..543a172 100644 --- a/net/dns/mojo_host_resolver_impl_unittest.cc +++ b/net/dns/mojo_host_resolver_impl_unittest.cc
@@ -143,7 +143,7 @@ interfaces::HostResolverRequestInfo::New(); request->host = host; request->port = port; - request->address_family = interfaces::ADDRESS_FAMILY_IPV4; + request->address_family = interfaces::AddressFamily::IPV4; request->is_my_ip_address = is_my_ip_address; return request; }
diff --git a/net/dns/mojo_host_type_converters.cc b/net/dns/mojo_host_type_converters.cc index 07dfe4df..9c45e53 100644 --- a/net/dns/mojo_host_type_converters.cc +++ b/net/dns/mojo_host_type_converters.cc
@@ -15,11 +15,11 @@ AddressFamily AddressFamilyFromMojo(interfaces::AddressFamily address_family) { switch (address_family) { - case interfaces::ADDRESS_FAMILY_UNSPECIFIED: + case interfaces::AddressFamily::UNSPECIFIED: return ADDRESS_FAMILY_UNSPECIFIED; - case interfaces::ADDRESS_FAMILY_IPV4: + case interfaces::AddressFamily::IPV4: return ADDRESS_FAMILY_IPV4; - case interfaces::ADDRESS_FAMILY_IPV6: + case interfaces::AddressFamily::IPV6: return ADDRESS_FAMILY_IPV6; } NOTREACHED(); @@ -29,14 +29,14 @@ interfaces::AddressFamily AddressFamilyToMojo(AddressFamily address_family) { switch (address_family) { case ADDRESS_FAMILY_UNSPECIFIED: - return interfaces::ADDRESS_FAMILY_UNSPECIFIED; + return interfaces::AddressFamily::UNSPECIFIED; case ADDRESS_FAMILY_IPV4: - return interfaces::ADDRESS_FAMILY_IPV4; + return interfaces::AddressFamily::IPV4; case ADDRESS_FAMILY_IPV6: - return interfaces::ADDRESS_FAMILY_IPV6; + return interfaces::AddressFamily::IPV6; } NOTREACHED(); - return interfaces::ADDRESS_FAMILY_UNSPECIFIED; + return interfaces::AddressFamily::UNSPECIFIED; } } // namespace
diff --git a/net/proxy/mojo_proxy_type_converters.cc b/net/proxy/mojo_proxy_type_converters.cc index c927534..2da740f 100644 --- a/net/proxy/mojo_proxy_type_converters.cc +++ b/net/proxy/mojo_proxy_type_converters.cc
@@ -15,39 +15,39 @@ interfaces::ProxyScheme ProxySchemeToMojo(ProxyServer::Scheme scheme) { switch (scheme) { case ProxyServer::SCHEME_INVALID: - return interfaces::PROXY_SCHEME_INVALID; + return interfaces::ProxyScheme::INVALID; case ProxyServer::SCHEME_DIRECT: - return interfaces::PROXY_SCHEME_DIRECT; + return interfaces::ProxyScheme::DIRECT; case ProxyServer::SCHEME_HTTP: - return interfaces::PROXY_SCHEME_HTTP; + return interfaces::ProxyScheme::HTTP; case ProxyServer::SCHEME_SOCKS4: - return interfaces::PROXY_SCHEME_SOCKS4; + return interfaces::ProxyScheme::SOCKS4; case ProxyServer::SCHEME_SOCKS5: - return interfaces::PROXY_SCHEME_SOCKS5; + return interfaces::ProxyScheme::SOCKS5; case ProxyServer::SCHEME_HTTPS: - return interfaces::PROXY_SCHEME_HTTPS; + return interfaces::ProxyScheme::HTTPS; case ProxyServer::SCHEME_QUIC: - return interfaces::PROXY_SCHEME_QUIC; + return interfaces::ProxyScheme::QUIC; } NOTREACHED(); - return interfaces::PROXY_SCHEME_INVALID; + return interfaces::ProxyScheme::INVALID; } ProxyServer::Scheme ProxySchemeFromMojo(interfaces::ProxyScheme scheme) { switch (scheme) { - case interfaces::PROXY_SCHEME_INVALID: + case interfaces::ProxyScheme::INVALID: return ProxyServer::SCHEME_INVALID; - case interfaces::PROXY_SCHEME_DIRECT: + case interfaces::ProxyScheme::DIRECT: return ProxyServer::SCHEME_DIRECT; - case interfaces::PROXY_SCHEME_HTTP: + case interfaces::ProxyScheme::HTTP: return ProxyServer::SCHEME_HTTP; - case interfaces::PROXY_SCHEME_SOCKS4: + case interfaces::ProxyScheme::SOCKS4: return ProxyServer::SCHEME_SOCKS4; - case interfaces::PROXY_SCHEME_SOCKS5: + case interfaces::ProxyScheme::SOCKS5: return ProxyServer::SCHEME_SOCKS5; - case interfaces::PROXY_SCHEME_HTTPS: + case interfaces::ProxyScheme::HTTPS: return ProxyServer::SCHEME_HTTPS; - case interfaces::PROXY_SCHEME_QUIC: + case interfaces::ProxyScheme::QUIC: return ProxyServer::SCHEME_QUIC; } NOTREACHED(); @@ -65,8 +65,8 @@ const net::ProxyServer& obj) { net::interfaces::ProxyServerPtr server(net::interfaces::ProxyServer::New()); server->scheme = net::ProxySchemeToMojo(obj.scheme()); - if (server->scheme != net::interfaces::PROXY_SCHEME_DIRECT && - server->scheme != net::interfaces::PROXY_SCHEME_INVALID) { + if (server->scheme != net::interfaces::ProxyScheme::DIRECT && + server->scheme != net::interfaces::ProxyScheme::INVALID) { server->host = obj.host_port_pair().host(); server->port = obj.host_port_pair().port(); }
diff --git a/skia/config/SkUserConfig.h b/skia/config/SkUserConfig.h index e5284ff..fbd837dd 100644 --- a/skia/config/SkUserConfig.h +++ b/skia/config/SkUserConfig.h
@@ -242,10 +242,6 @@ # define SK_SUPPORT_LEGACY_BITMAP_FILTER #endif -#ifndef SK_SUPPORT_LEGACY_TRANSLATEROUNDHACK -# define SK_SUPPORT_LEGACY_TRANSLATEROUNDHACK -#endif - #ifndef SK_SUPPORT_LEGACY_ARCTO # define SK_SUPPORT_LEGACY_ARCTO #endif
diff --git a/skia/public/interfaces/bitmap.mojom b/skia/public/interfaces/bitmap.mojom index fd341201..dcb8ebf 100644 --- a/skia/public/interfaces/bitmap.mojom +++ b/skia/public/interfaces/bitmap.mojom
@@ -20,7 +20,7 @@ // Mirror of SkAlphaType. enum AlphaType { UNKNOWN, - OPAQUE, + ALPHA_TYPE_OPAQUE, PREMUL, UNPREMUL, };
diff --git a/skia/public/type_converters.cc b/skia/public/type_converters.cc index ef5a08b..fe13241 100644 --- a/skia/public/type_converters.cc +++ b/skia/public/type_converters.cc
@@ -17,21 +17,21 @@ SkColorType MojoColorTypeToSk(skia::ColorType type) { switch (type) { - case skia::COLOR_TYPE_UNKNOWN: + case skia::ColorType::UNKNOWN: return kUnknown_SkColorType; - case skia::COLOR_TYPE_ALPHA_8: + case skia::ColorType::ALPHA_8: return kAlpha_8_SkColorType; - case skia::COLOR_TYPE_RGB_565: + case skia::ColorType::RGB_565: return kRGB_565_SkColorType; - case skia::COLOR_TYPE_ARGB_4444: + case skia::ColorType::ARGB_4444: return kARGB_4444_SkColorType; - case skia::COLOR_TYPE_RGBA_8888: + case skia::ColorType::RGBA_8888: return kRGBA_8888_SkColorType; - case skia::COLOR_TYPE_BGRA_8888: + case skia::ColorType::BGRA_8888: return kBGRA_8888_SkColorType; - case skia::COLOR_TYPE_INDEX_8: + case skia::ColorType::INDEX_8: return kIndex_8_SkColorType; - case skia::COLOR_TYPE_GRAY_8: + case skia::ColorType::GRAY_8: return kGray_8_SkColorType; default: NOTREACHED(); @@ -41,13 +41,13 @@ SkAlphaType MojoAlphaTypeToSk(skia::AlphaType type) { switch (type) { - case skia::ALPHA_TYPE_UNKNOWN: + case skia::AlphaType::UNKNOWN: return kUnknown_SkAlphaType; - case skia::ALPHA_TYPE_OPAQUE: + case skia::AlphaType::ALPHA_TYPE_OPAQUE: return kOpaque_SkAlphaType; - case skia::ALPHA_TYPE_PREMUL: + case skia::AlphaType::PREMUL: return kPremul_SkAlphaType; - case skia::ALPHA_TYPE_UNPREMUL: + case skia::AlphaType::UNPREMUL: return kUnpremul_SkAlphaType; default: NOTREACHED(); @@ -58,41 +58,41 @@ skia::ColorType SkColorTypeToMojo(SkColorType type) { switch (type) { case kUnknown_SkColorType: - return skia::COLOR_TYPE_UNKNOWN; + return skia::ColorType::UNKNOWN; case kAlpha_8_SkColorType: - return skia::COLOR_TYPE_ALPHA_8; + return skia::ColorType::ALPHA_8; case kRGB_565_SkColorType: - return skia::COLOR_TYPE_RGB_565; + return skia::ColorType::RGB_565; case kARGB_4444_SkColorType: - return skia::COLOR_TYPE_ARGB_4444; + return skia::ColorType::ARGB_4444; case kRGBA_8888_SkColorType: - return skia::COLOR_TYPE_RGBA_8888; + return skia::ColorType::RGBA_8888; case kBGRA_8888_SkColorType: - return skia::COLOR_TYPE_BGRA_8888; + return skia::ColorType::BGRA_8888; case kIndex_8_SkColorType: - return skia::COLOR_TYPE_INDEX_8; + return skia::ColorType::INDEX_8; case kGray_8_SkColorType: - return skia::COLOR_TYPE_GRAY_8; + return skia::ColorType::GRAY_8; default: NOTREACHED(); } - return skia::COLOR_TYPE_UNKNOWN; + return skia::ColorType::UNKNOWN; } skia::AlphaType SkAlphaTypeToMojo(SkAlphaType type) { switch (type) { case kUnknown_SkAlphaType: - return skia::ALPHA_TYPE_UNKNOWN; + return skia::AlphaType::UNKNOWN; case kOpaque_SkAlphaType: - return skia::ALPHA_TYPE_OPAQUE; + return skia::AlphaType::ALPHA_TYPE_OPAQUE; case kPremul_SkAlphaType: - return skia::ALPHA_TYPE_PREMUL; + return skia::AlphaType::PREMUL; case kUnpremul_SkAlphaType: - return skia::ALPHA_TYPE_UNPREMUL; + return skia::AlphaType::UNPREMUL; default: NOTREACHED(); } - return skia::ALPHA_TYPE_UNKNOWN; + return skia::AlphaType::UNKNOWN; } } // namespace
diff --git a/sql/mojo/mojo_vfs.cc b/sql/mojo/mojo_vfs.cc index 5c427fb8..bd962d0 100644 --- a/sql/mojo/mojo_vfs.cc +++ b/sql/mojo/mojo_vfs.cc
@@ -67,7 +67,7 @@ DVLOG(1) << "MojoVFSClose(*)"; TRACE_EVENT0("sql", "MojoVFSClose"); using filesystem::FilePtr; - filesystem::FileError error = filesystem::FILE_ERROR_FAILED; + filesystem::FileError error = filesystem::FileError::FAILED; // Must call File::Close explicitly instead of just deleting the file, since // otherwise we wouldn't have an object to wait on. GetFSFile(file)->Close(mojo::Capture(&error)); @@ -82,13 +82,13 @@ sqlite3_int64 offset) { DVLOG(1) << "MojoVFSRead (" << size << " @ " << offset << ")"; TRACE_EVENT0("sql", "MojoVFSRead"); - filesystem::FileError error = filesystem::FILE_ERROR_FAILED; + filesystem::FileError error = filesystem::FileError::FAILED; mojo::Array<uint8_t> mojo_data; - GetFSFile(sql_file)->Read(size, offset, filesystem::WHENCE_FROM_BEGIN, + GetFSFile(sql_file)->Read(size, offset, filesystem::Whence::FROM_BEGIN, Capture(&error, &mojo_data)); GetFSFile(sql_file).WaitForIncomingResponse(); - if (error != filesystem::FILE_ERROR_OK) { + if (error != filesystem::FileError::OK) { // TODO(erg): Better implementation here. NOTIMPLEMENTED(); return SQLITE_IOERR_READ; @@ -115,13 +115,13 @@ mojo::Array<uint8_t> mojo_data(size); memcpy(&mojo_data.front(), buffer, size); - filesystem::FileError error = filesystem::FILE_ERROR_FAILED; + filesystem::FileError error = filesystem::FileError::FAILED; uint32_t num_bytes_written = 0; GetFSFile(sql_file)->Write(std::move(mojo_data), offset, - filesystem::WHENCE_FROM_BEGIN, + filesystem::Whence::FROM_BEGIN, Capture(&error, &num_bytes_written)); GetFSFile(sql_file).WaitForIncomingResponse(); - if (error != filesystem::FILE_ERROR_OK) { + if (error != filesystem::FileError::OK) { // TODO(erg): Better implementation here. NOTIMPLEMENTED(); return SQLITE_IOERR_WRITE; @@ -137,10 +137,10 @@ int MojoVFSTruncate(sqlite3_file* sql_file, sqlite_int64 size) { DVLOG(1) << "MojoVFSTruncate(*, " << size << ")"; TRACE_EVENT0("sql", "MojoVFSTruncate"); - filesystem::FileError error = filesystem::FILE_ERROR_FAILED; + filesystem::FileError error = filesystem::FileError::FAILED; GetFSFile(sql_file)->Truncate(size, Capture(&error)); GetFSFile(sql_file).WaitForIncomingResponse(); - if (error != filesystem::FILE_ERROR_OK) { + if (error != filesystem::FileError::OK) { // TODO(erg): Better implementation here. NOTIMPLEMENTED(); return SQLITE_IOERR_TRUNCATE; @@ -152,10 +152,10 @@ int MojoVFSSync(sqlite3_file* sql_file, int flags) { DVLOG(1) << "MojoVFSSync(*, " << flags << ")"; TRACE_EVENT0("sql", "MojoVFSSync"); - filesystem::FileError error = filesystem::FILE_ERROR_FAILED; + filesystem::FileError error = filesystem::FileError::FAILED; GetFSFile(sql_file)->Flush(Capture(&error)); GetFSFile(sql_file).WaitForIncomingResponse(); - if (error != filesystem::FILE_ERROR_OK) { + if (error != filesystem::FileError::OK) { // TODO(erg): Better implementation here. NOTIMPLEMENTED(); return SQLITE_IOERR_FSYNC; @@ -168,12 +168,12 @@ DVLOG(1) << "MojoVFSFileSize(*)"; TRACE_EVENT0("sql", "MojoVFSFileSize"); - filesystem::FileError err = filesystem::FILE_ERROR_FAILED; + filesystem::FileError err = filesystem::FileError::FAILED; filesystem::FileInformationPtr file_info; GetFSFile(sql_file)->Stat(Capture(&err, &file_info)); GetFSFile(sql_file).WaitForIncomingResponse(); - if (err != filesystem::FILE_ERROR_OK) { + if (err != filesystem::FileError::OK) { // TODO(erg): Better implementation here. NOTIMPLEMENTED(); return SQLITE_IOERR_FSTAT; @@ -283,11 +283,11 @@ // Grab the incoming file filesystem::FilePtr file_ptr; - filesystem::FileError error = filesystem::FILE_ERROR_FAILED; + filesystem::FileError error = filesystem::FileError::FAILED; GetRootDirectory(mojo_vfs)->OpenFile(mojo_name, GetProxy(&file_ptr), open_flags, Capture(&error)); GetRootDirectory(mojo_vfs).WaitForIncomingResponse(); - if (error != filesystem::FILE_ERROR_OK) { + if (error != filesystem::FileError::OK) { // TODO(erg): Translate more of the mojo error codes into sqlite error // codes. return SQLITE_CANTOPEN; @@ -313,16 +313,16 @@ // TODO(erg): The default windows sqlite VFS has retry code to work around // antivirus software keeping files open. We'll probably have to do something // like that in the far future if we ever support Windows. - filesystem::FileError error = filesystem::FILE_ERROR_FAILED; + filesystem::FileError error = filesystem::FileError::FAILED; GetRootDirectory(mojo_vfs)->Delete(filename, 0, Capture(&error)); GetRootDirectory(mojo_vfs).WaitForIncomingResponse(); - if (error == filesystem::FILE_ERROR_OK && sync_dir) { + if (error == filesystem::FileError::OK && sync_dir) { GetRootDirectory(mojo_vfs)->Flush(Capture(&error)); GetRootDirectory(mojo_vfs).WaitForIncomingResponse(); } - return error == filesystem::FILE_ERROR_OK ? SQLITE_OK : SQLITE_IOERR_DELETE; + return error == filesystem::FileError::OK ? SQLITE_OK : SQLITE_IOERR_DELETE; } int MojoVFSAccess(sqlite3_vfs* mojo_vfs, @@ -333,7 +333,7 @@ TRACE_EVENT2("sql", "MojoVFSAccess", "name", filename, "flags", flags); - filesystem::FileError error = filesystem::FILE_ERROR_FAILED; + filesystem::FileError error = filesystem::FileError::FAILED; if (flags == SQLITE_ACCESS_READWRITE || flags == SQLITE_ACCESS_READ) { bool is_writable = false;
diff --git a/sql/mojo/sql_test_base.cc b/sql/mojo/sql_test_base.cc index 72aaa64..a5e061d7 100644 --- a/sql/mojo/sql_test_base.cc +++ b/sql/mojo/sql_test_base.cc
@@ -38,11 +38,11 @@ } bool SQLTestBase::GetPathExists(const base::FilePath& path) { - filesystem::FileError error = filesystem::FILE_ERROR_FAILED; + filesystem::FileError error = filesystem::FileError::FAILED; bool exists = false; vfs_->GetDirectory()->Exists(path.AsUTF8Unsafe(), Capture(&error, &exists)); vfs_->GetDirectory().WaitForIncomingResponse(); - if (error != filesystem::FILE_ERROR_OK) + if (error != filesystem::FileError::OK) return false; return exists; } @@ -53,7 +53,7 @@ mojo::Array<uint8_t> header; - filesystem::FileError error = filesystem::FILE_ERROR_FAILED; + filesystem::FileError error = filesystem::FileError::FAILED; filesystem::FilePtr file_ptr; vfs_->GetDirectory()->OpenFile( mojo::String(db_path().AsUTF8Unsafe()), GetProxy(&file_ptr), @@ -61,29 +61,29 @@ filesystem::kFlagOpenAlways, Capture(&error)); vfs_->GetDirectory().WaitForIncomingResponse(); - if (error != filesystem::FILE_ERROR_OK) + if (error != filesystem::FileError::OK) return false; - file_ptr->Read(kHeaderSize, 0, filesystem::WHENCE_FROM_BEGIN, + file_ptr->Read(kHeaderSize, 0, filesystem::Whence::FROM_BEGIN, Capture(&error, &header)); file_ptr.WaitForIncomingResponse(); - if (error != filesystem::FILE_ERROR_OK) + if (error != filesystem::FileError::OK) return false; filesystem::FileInformationPtr info; file_ptr->Stat(Capture(&error, &info)); file_ptr.WaitForIncomingResponse(); - if (error != filesystem::FILE_ERROR_OK) + if (error != filesystem::FileError::OK) return false; int64_t db_size = info->size; test::CorruptSizeInHeaderMemory(&header.front(), db_size); uint32_t num_bytes_written = 0; - file_ptr->Write(std::move(header), 0, filesystem::WHENCE_FROM_BEGIN, + file_ptr->Write(std::move(header), 0, filesystem::Whence::FROM_BEGIN, Capture(&error, &num_bytes_written)); file_ptr.WaitForIncomingResponse(); - if (error != filesystem::FILE_ERROR_OK) + if (error != filesystem::FileError::OK) return false; if (num_bytes_written != kHeaderSize) return false; @@ -98,14 +98,14 @@ else flags = filesystem::kFlagWrite | filesystem::kFlagOpen; - filesystem::FileError error = filesystem::FILE_ERROR_FAILED; + filesystem::FileError error = filesystem::FileError::FAILED; filesystem::FilePtr file_ptr; vfs_->GetDirectory()->OpenFile( mojo::String(db_path().AsUTF8Unsafe()), GetProxy(&file_ptr), flags, Capture(&error)); vfs_->GetDirectory().WaitForIncomingResponse(); - if (error != filesystem::FILE_ERROR_OK) + if (error != filesystem::FileError::OK) return; const char* kJunk = "Now is the winter of our discontent."; @@ -113,25 +113,25 @@ memcpy(&data.front(), kJunk, strlen(kJunk)); uint32_t num_bytes_written = 0; - file_ptr->Write(std::move(data), 0, filesystem::WHENCE_FROM_BEGIN, + file_ptr->Write(std::move(data), 0, filesystem::Whence::FROM_BEGIN, Capture(&error, &num_bytes_written)); file_ptr.WaitForIncomingResponse(); } void SQLTestBase::TruncateDatabase() { - filesystem::FileError error = filesystem::FILE_ERROR_FAILED; + filesystem::FileError error = filesystem::FileError::FAILED; filesystem::FilePtr file_ptr; vfs_->GetDirectory()->OpenFile( mojo::String(db_path().AsUTF8Unsafe()), GetProxy(&file_ptr), filesystem::kFlagWrite | filesystem::kFlagOpen, Capture(&error)); vfs_->GetDirectory().WaitForIncomingResponse(); - if (error != filesystem::FILE_ERROR_OK) + if (error != filesystem::FileError::OK) return; file_ptr->Truncate(0, Capture(&error)); file_ptr.WaitForIncomingResponse(); - ASSERT_EQ(filesystem::FILE_ERROR_OK, error); + ASSERT_EQ(filesystem::FileError::OK, error); } void SQLTestBase::SetUp() { @@ -142,12 +142,12 @@ filesystem::FileSystemClientPtr client; binding_.Bind(GetProxy(&client)); - filesystem::FileError error = filesystem::FILE_ERROR_FAILED; + filesystem::FileError error = filesystem::FileError::FAILED; filesystem::DirectoryPtr directory; files()->OpenFileSystem("temp", GetProxy(&directory), std::move(client), Capture(&error)); ASSERT_TRUE(files().WaitForIncomingResponse()); - ASSERT_EQ(filesystem::FILE_ERROR_OK, error); + ASSERT_EQ(filesystem::FileError::OK, error); vfs_.reset(new ScopedMojoFilesystemVFS(std::move(directory))); ASSERT_TRUE(db_.Open(db_path()));
diff --git a/sql/mojo/vfs_unittest.cc b/sql/mojo/vfs_unittest.cc index e51f1bd..e53ea11cf 100644 --- a/sql/mojo/vfs_unittest.cc +++ b/sql/mojo/vfs_unittest.cc
@@ -58,12 +58,12 @@ filesystem::FileSystemClientPtr client; binding_.Bind(GetProxy(&client)); - filesystem::FileError error = filesystem::FILE_ERROR_FAILED; + filesystem::FileError error = filesystem::FileError::FAILED; filesystem::DirectoryPtr directory; files_->OpenFileSystem("temp", GetProxy(&directory), std::move(client), mojo::Capture(&error)); ASSERT_TRUE(files_.WaitForIncomingResponse()); - ASSERT_EQ(filesystem::FILE_ERROR_OK, error); + ASSERT_EQ(filesystem::FileError::OK, error); vfs_.reset(new ScopedMojoFilesystemVFS(std::move(directory))); }
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations index a0d8fd8..ee763f9 100644 --- a/third_party/WebKit/LayoutTests/TestExpectations +++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -261,6 +261,7 @@ crbug.com/576589 [ Mac10.10 ] tables/mozilla/bugs/bug46368-1.html [ NeedsRebaseline ] crbug.com/576589 [ Mac10.10 ] tables/mozilla/bugs/bug46368-2.html [ NeedsRebaseline ] crbug.com/576589 [ Mac10.10 ] tables/mozilla/dom/tableDom.html [ NeedsRebaseline ] +crbug.com/579381 fast/forms/text/input-placeholder-paint-order.html [ NeedsRebaseline ] crbug.com/498539 http/tests/inspector/elements/styles/selector-line.html [ Pass Timeout ] crbug.com/498539 http/tests/inspector/network/network-datareceived.html [ Pass Timeout ] @@ -836,6 +837,15 @@ crbug.com/425345 [ Mac ] fast/text/line-break-after-question-mark.html [ Failure ] +crbug.com/579816 fast/borders/border-image-outset-in-shorthand.html [ NeedsRebaseline ] +crbug.com/579816 fast/borders/border-image-outset-split-inline.html [ NeedsRebaseline ] +crbug.com/579816 fast/borders/border-image-outset.html [ NeedsRebaseline ] +crbug.com/579816 fast/borders/border-image-slice-constrained.html [ NeedsRebaseline ] +crbug.com/579816 fast/gradients/border-image-gradient-sides-and-corners.html [ NeedsRebaseline ] +crbug.com/579816 fast/writing-mode/border-image-vertical-lr.html [ NeedsRebaseline ] +crbug.com/579816 fast/writing-mode/border-image-vertical-rl.html [ NeedsRebaseline ] +crbug.com/579816 svg/W3C-SVG-1.1/coords-units-01-b.svg [ NeedsRebaseline ] + # When drawing subpixel smoothed glyphs, CoreGraphics will fake bold the glyphs. # In this configuration, the pixel smoothed glyphs will be created from subpixel smoothed glyphs. # This means that CoreGraphics may draw outside the reported glyph bounds, and in this case does. @@ -916,6 +926,8 @@ crbug.com/548630 [ XP ] fast/text/justify-vertical.html [ Failure ] +crbug.com/579854 [ Linux Win Debug ] http/tests/preload/dynamic_adding_preload.html [ Pass Failure ] + crbug.com/471824 imported/web-platform-tests/pointerevents/ [ Skip ] crbug.com/471824 virtual/pointerevent/imported/web-platform-tests/pointerevents/pointerevent_touch-action-illegal.html [ Skip ] crbug.com/471824 virtual/pointerevent/imported/web-platform-tests/pointerevents/pointerevent_touch-action-verification.html [ Skip ] @@ -1505,6 +1517,4 @@ crbug.com/579365 [ Mac ] fast/replaced/border-radius-clip.html [ NeedsRebaseline ] -crbug.com/579385 [ Win Linux Debug ] fast/forms/select-popup/popup-menu-resize-after-open.html [ Failure ] - crbug.com/573206 http/tests/workers/shared-worker-secure-context.https.html [ Skip ]
diff --git a/third_party/WebKit/LayoutTests/bluetooth/characteristicvaluechanged.html b/third_party/WebKit/LayoutTests/bluetooth/characteristicvaluechanged.html index d21107a..a8fe5fd 100644 --- a/third_party/WebKit/LayoutTests/bluetooth/characteristicvaluechanged.html +++ b/third_party/WebKit/LayoutTests/bluetooth/characteristicvaluechanged.html
@@ -18,10 +18,10 @@ 'readValue', 'characteristicvaluechanged'); }).then(results => { - let read_value = new Uint8Array(results[0]); - let event_value = new Uint8Array(results[1]); - // TODO(ortuno): The ArrayBuffer used to resolve the promise - // should be the same ArrayBuffer as the one saved in the + let read_value = results[0].buffer; + let event_value = results[1].buffer; + // TODO(ortuno): The DataView used to resolve the promise + // should be the same DataView as the one saved in the // characteristic. // http://crbug.com/543347 // assert_equals(event.target.value, value); @@ -41,11 +41,11 @@ 'characteristicvaluechanged', 3 /* attach 3 listeners */); }).then(results => { - let read_value = new Uint8Array(results[0]); - let event_values = results.slice(1).map(v => new Uint8Array(v)); + let read_value = results[0].buffer; + let event_values = results.slice(1).map(v => v.buffer); for (let event_value of event_values) { - // TODO(ortuno): The ArrayBuffer used to resolve the promise - // should be the same ArrayBuffer as the one saved in the + // TODO(ortuno): The DataView used to resolve the promise + // should be the same DataView as the one saved in the // characteristic. // http://crbug.com/543347 // assert_equals(event.target.value, value);
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLLinkElement/resolve-url-on-insertion.html b/third_party/WebKit/LayoutTests/fast/dom/HTMLLinkElement/resolve-url-on-insertion.html index d244e7b..4b6062b5 100644 --- a/third_party/WebKit/LayoutTests/fast/dom/HTMLLinkElement/resolve-url-on-insertion.html +++ b/third_party/WebKit/LayoutTests/fast/dom/HTMLLinkElement/resolve-url-on-insertion.html
@@ -5,20 +5,29 @@ base.href = 'resources/'; var link1 = document.createElement('link'); +var promises = []; link1.setAttribute('rel', 'stylesheet'); link1.setAttribute('href', 'stylesheet.css'); +promises.push(new Promise(function(resolve) { + link1.addEventListener('load', function() { resolve(); }, false); + })); var foreignDocument = document.implementation.createHTMLDocument(''); var link2 = foreignDocument.createElement('link'); link2.setAttribute('rel', 'stylesheet'); link2.setAttribute('href', 'stylesheet2.css'); +promises.push(new Promise(function(resolve) { + link2.addEventListener('load', function() { resolve(); }, false); + })); document.body.appendChild(base); document.body.appendChild(link1); document.body.appendChild(link2); -if (window.testRunner) +if (window.testRunner) { testRunner.dumpAsText(); + testRunner.waitUntilDone(); +} </script> <p>This tests that links resouce URLs are resolved dynamically when inserted into the document, and honor the base URL of the document at the time of insertion.</p> @@ -27,12 +36,14 @@ <h1 id=test2>I should be red</h1> <script> -var test = document.getElementById('test'); -var testColor = window.getComputedStyle(document.getElementById('test'), null).color; -var test2 = document.getElementById('test2'); -var test2Color = window.getComputedStyle(document.getElementById('test2'), null).color; -test.innerHTML += testColor === 'rgb(0, 0, 255)' ? '...and I am!!!' : '...but I am not =-('; -test2.innerHTML += test2Color === 'rgb(255, 0, 0)' ? '...and I am!!!' : '...but I am not =-('; +Promise.all(promises).then(function() { + var test = document.getElementById('test'); + var testColor = window.getComputedStyle(document.getElementById('test'), null).color; + var test2 = document.getElementById('test2'); + var test2Color = window.getComputedStyle(document.getElementById('test2'), null).color; + test.innerHTML += testColor === 'rgb(0, 0, 255)' ? '...and I am!!!' : '...but I am not =-('; + test2.innerHTML += test2Color === 'rgb(255, 0, 0)' ? '...and I am!!!' : '...but I am not =-('; + testRunner.notifyDone(); + }); </script> </body></html> -
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/event-deep-path.html b/third_party/WebKit/LayoutTests/fast/dom/shadow/event-deep-path.html new file mode 100644 index 0000000..79056f3 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/event-deep-path.html
@@ -0,0 +1,14 @@ +<!DOCTYPE html> +<script src="../../../resources/testharness.js"></script> +<script src="../../../resources/testharnessreport.js"></script> +<script src="resources/shadow-dom.js"></script> +<img id="img" src="../../images/resources/test-load.jpg"> +<script> + +img.onload = function(e) { + test(function() { + assert_array_equals(e.deepPath, e.path); + }, "Event.deepPath should be the same as Event.path."); +}; + +</script>
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/event-path-with-slot.html b/third_party/WebKit/LayoutTests/fast/dom/shadow/event-path-with-slot.html new file mode 100644 index 0000000..f3e28f1 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/event-path-with-slot.html
@@ -0,0 +1,84 @@ +<!DOCTYPE html> +<script src='../../../resources/testharness.js'></script> +<script src='../../../resources/testharnessreport.js'></script> +<script src='resources/shadow-dom.js'></script> +<div id='host1'> + <input id='input1' slot='slot1'> + <template data-mode='open'> + <slot name='slot1'></slot> + </template> +</div> + +<div id='host2'> + <input id='input2' slot='slot2'> + <template data-mode='open'> + <div id='host3'> + <div id='slot2-parent'> + <slot name='slot2'></slot> + </div> + <template data-mode='v0'> + <content select='#slot2-parent'></content> + </template> + </div> + </template> +</div> + +<div id='host4'> + <template data-mode='open'> + <slot name='slot3'></slot> + </template> + <div id='input-parent' slot='slot3'> + <input id='input3'> + </div> +</div> +<script> + +test(function() { + var host1 = document.getElementById('host1'); + convertTemplatesToShadowRootsWithin(host1); + removeWhiteSpaceOnlyTextNodes(host1); + document.body.offsetLeft; + var input1 = document.getElementById('input1'); + var slot1 = host1.shadowRoot.querySelector('slot'); + var shadowRoot = host1.shadowRoot; + input1.onfocus = function(e) { + var expected_array1 = [input1, slot1, shadowRoot, host1, document.body, document.documentElement, document, window]; + assert_array_equals(e.path, expected_array1); + }; + input1.focus(); +}, 'Triggered in a slotted element, eventPath should go through shadow tree.'); + +test(function() { + var input2 = document.getElementById('input2'); + var host2 = document.getElementById('host2'); + convertTemplatesToShadowRootsWithin(host2); + var shadowRootV1 = host2.shadowRoot; + var host3 = shadowRootV1.querySelector('#host3'); + convertTemplatesToShadowRootsWithin(host3); + var slotParent = host3.querySelector('div'); + var slot2 = host3.querySelector('slot'); + var shadowRootV0 = host3.shadowRoot; + var content = shadowRootV0.querySelector('content'); + + input2.onfocus = function(e) { + var expected_array2 = [input2, slot2, slotParent, content, shadowRootV0, host3, shadowRootV1, host2, document.body, document.documentElement, document, window]; + assert_array_equals(e.path, expected_array2); + }; + input2.focus(); +}, 'EventPath works fine with v0 insertion points & v1 slots.'); + +test(function() { + var host4 = document.getElementById('host4'); + convertTemplatesToShadowRootsWithin(host4); + var shadowRoot2 = host4.shadowRoot; + var slot3 = shadowRoot2.querySelector('slot'); + var input3 = document.getElementById('input3') + var inputParent = document.getElementById('input-parent'); + input3.onfocus = function(e) { + var expected_array3 = [input3, inputParent, slot3, shadowRoot2, host4, document.body, document.documentElement, document, window]; + assert_array_equals(e.path, expected_array3); + }; + input3.focus(); +}, 'EventPath works fine when event happens to a descendant of a slotted element.'); + +</script>
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element-dynamic-attribute-change-expected.html b/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element-dynamic-attribute-change-expected.html new file mode 100644 index 0000000..30a8a4b --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element-dynamic-attribute-change-expected.html
@@ -0,0 +1,4 @@ +<!DOCTYPE html> +<div id="host"> + <div style="background: green;">I should be green.</div> +</div>
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element-dynamic-attribute-change.html b/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element-dynamic-attribute-change.html new file mode 100644 index 0000000..b56c42c --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element-dynamic-attribute-change.html
@@ -0,0 +1,19 @@ +<!DOCTYPE html> +<div id="host"> + <div id="child">I should be green.</div> +</div> +<script> +if (window.testRunner) + testRunner.waitUntilDone(); + +var shadowRoot = document.getElementById('host').attachShadow({mode: 'open'}); +shadowRoot.innerHTML = '<style>slot::slotted(.selected) { ' + + 'background: green; }</style>' + + '<slot></slot>'; + +setTimeout(function() { + document.getElementById('child').classList.add('selected'); + if (window.testRunner) + testRunner.notifyDone(); +}, 0); +</script>
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element-expected.html b/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element-expected.html new file mode 100644 index 0000000..dabfb30 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element-expected.html
@@ -0,0 +1,9 @@ +<!DOCTYPE html> +<div> + <div> + <div style="color: green">green</div> + <div style="color: blue">blue</div> + <div style="color: red">red</div> + <div style="color: purple">purple</div> + </div> +</div>
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element-shared-style-expected.html b/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element-shared-style-expected.html new file mode 100644 index 0000000..cc92d288 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element-shared-style-expected.html
@@ -0,0 +1,7 @@ +<!DOCTYPE html> +<div> + <div> + <div>normal</div> + <div style="color: red">red</div> + </div> +</div>
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element-shared-style.html b/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element-shared-style.html new file mode 100644 index 0000000..f2f8192c --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element-shared-style.html
@@ -0,0 +1,20 @@ +<!DOCTYPE html> +<script src="resources/shadow-dom.js"></script> +<div id="sandbox"></div> +<script> +var shadowStyle = document.createElement('style'); +shadowStyle.innerHTML = 'slot::slotted([data-color=red]) { color: red; }'; + +var sandbox = document.getElementById('sandbox'); +sandbox.appendChild( + createDOM('div', {}, + attachShadow( + {'mode': 'open'}, + shadowStyle, + createDOM('slot')), + createDOM('div', {}, + document.createTextNode('normal')), + // If the style is falsely shared with the <div> above, this won't turn red. + createDOM('div', {'data-color': 'red'}, + document.createTextNode('red')))); +</script>
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element.html b/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element.html new file mode 100644 index 0000000..26e27087 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/slotted-pseudo-element.html
@@ -0,0 +1,26 @@ +<!DOCTYPE html> +<script src="resources/shadow-dom.js"></script> +<div id="sandbox"></div> +<script> +var shadowStyle = document.createElement('style'); +shadowStyle.innerHTML = '::slotted(div) { color: green; }' + + '::slotted(div.blue) { color: blue; }' + + 'slot::slotted(div#red) { color: red; }' + + 'slot::slotted(div[data-color=purple]) { color: purple; }'; + +var sandbox = document.getElementById('sandbox'); +sandbox.appendChild( + createDOM('div', {}, + attachShadow( + {'mode': 'open'}, + shadowStyle, + createDOM('slot')), + createDOM('div', {}, + document.createTextNode('green')), + createDOM('div', {class: 'blue'}, + document.createTextNode('blue')), + createDOM('div', {id: 'red'}, + document.createTextNode('red')), + createDOM('div', {'data-color': 'purple'}, + document.createTextNode('purple')))); +</script>
diff --git a/third_party/WebKit/LayoutTests/fast/forms/placeholder-position.html b/third_party/WebKit/LayoutTests/fast/forms/placeholder-position.html index f94ca3d9..a3f6220 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/placeholder-position.html +++ b/third_party/WebKit/LayoutTests/fast/forms/placeholder-position.html
@@ -4,8 +4,12 @@ } </style> <!-- This tests that the placeholder is positioned correctly in different kinds of elements --> -<input type="search" placeholder="placeholder"><br> -<input type="text" placeholder="placeholder"><br> +<input type="search" placeholder="placeholder"> +<br> +<input type="text" placeholder="placeholder" size=10> +<input placeholder="placeholder" style="line-height:1;" size=10> +<input placeholder="日本語placeholder"> +<br> <input type="search" placeholder="placeholder" style="direction: rtl"><br> <input type="search" placeholder="placeholder" results=5><br> <textarea placeholder="placeholder"></textarea><br> @@ -14,10 +18,14 @@ <input type="text" placeholder="placeholder" style="font-size: 15px; border: solid 5px black; margin: 5px;"><br> <input value="Value" style="line-height: 25px;"> -<input placeholder="placeholder" style="line-height: 25px;"> <br> +<input placeholder="placeholder" style="line-height: 25px;"> +<input placeholder="placeholder" style="height: 25px;"> +<input placeholder="placeholder" style="height: 25px; line-height: 25px;"> +<br> <input value="Value" style="text-align: center;"> <input placeholder="placeholder" style="text-align: center;"> -<input placeholder="placeholder" class="center"> <br> +<input placeholder="placeholder" class="center"> +<br> <input type="text" placeholder="placeholder" style="padding-top: 15px; transform: translateY(30px) rotateZ(30deg)"><br>
diff --git a/third_party/WebKit/LayoutTests/fast/forms/select-popup/popup-menu-resize-after-open.html b/third_party/WebKit/LayoutTests/fast/forms/select-popup/popup-menu-resize-after-open.html index e2a360b..bdc5fdac 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/select-popup/popup-menu-resize-after-open.html +++ b/third_party/WebKit/LayoutTests/fast/forms/select-popup/popup-menu-resize-after-open.html
@@ -23,8 +23,8 @@ var menu = document.getElementById('menu'); openPicker(menu, function() { shouldBe('popupWindow.innerWidth', '100'); + popupWindow.addEventListener("resize", checkPopupWidth, false); menu.style.width = "150px"; menu.offsetTop; - setTimeout(checkPopupWidth, 10); }, openPickerErrorCallback); </script>
diff --git a/third_party/WebKit/LayoutTests/fast/selectors/querySelector-pseudo-slotted.html b/third_party/WebKit/LayoutTests/fast/selectors/querySelector-pseudo-slotted.html new file mode 100644 index 0000000..331d91f8 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/selectors/querySelector-pseudo-slotted.html
@@ -0,0 +1,25 @@ +<!DOCTYPE html> +<script src="../../resources/testharness.js"></script> +<script src="../../resources/testharnessreport.js"></script> +<script src="../dom/shadow/resources/shadow-dom.js"></script> +<div id="host1"> + <template data-mode="open"> + <slot name="slot1"></slot> + </template> + <span slot="slot1" id="span1"></span> + <span slot="slot1" id="span2"></span> +</div> +<script> +convertTemplatesToShadowRootsWithin(host1); +document.body.offsetLeft; + +test(() => { + assert_equals(document.querySelector('::slotted(span)'), null); + assert_equals(host1.shadowRoot.querySelector('::slotted(span)'), null); +}, "querySelector for ::slotted pseudo element"); + +test(() => { + assert_equals(document.querySelectorAll('::slotted(span)').length, 0); + assert_equals(host1.shadowRoot.querySelectorAll('::slotted(span)').length, 0); +}, "querySelectorAll for ::slotted pseudo element"); +</script>
diff --git a/third_party/WebKit/LayoutTests/fast/xmlhttprequest/xmlhttprequest-get-expected.txt b/third_party/WebKit/LayoutTests/fast/xmlhttprequest/xmlhttprequest-get-expected.txt index 9af9a7ab..5940b6a 100644 --- a/third_party/WebKit/LayoutTests/fast/xmlhttprequest/xmlhttprequest-get-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/xmlhttprequest/xmlhttprequest-get-expected.txt
@@ -47,6 +47,7 @@ cancelBubble : 'false' cancelable : 'false' currentTarget : '[object XMLHttpRequest]' +deepPath : '' defaultPrevented : 'false' eventPhase : '2' initEvent : 'function initEvent() { [native code] }'
diff --git a/third_party/WebKit/LayoutTests/http/tests/css/css-non-blocking-expected.txt b/third_party/WebKit/LayoutTests/http/tests/css/css-non-blocking-expected.txt new file mode 100644 index 0000000..02d4dd5 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/css/css-non-blocking-expected.txt
@@ -0,0 +1,3 @@ +Dynamically inserted StyleSheet shouldn't block loading. + +rgb(0, 0, 255)
diff --git a/third_party/WebKit/LayoutTests/http/tests/css/css-non-blocking.html b/third_party/WebKit/LayoutTests/http/tests/css/css-non-blocking.html new file mode 100644 index 0000000..0551dfe --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/css/css-non-blocking.html
@@ -0,0 +1,21 @@ +<!DOCTYPE html> +<style type="text/css"> +h1 { background-color: blue } +</style> +</head> +<script> +var link = document.createElement('link'); +link.setAttribute('rel', 'stylesheet'); +link.setAttribute('type', 'text/css'); +link.setAttribute('href', 'resources/slow-loading-sheet.php?color=red'); +document.head.appendChild(link); +</script> +<h1 id='title'>Dynamically inserted StyleSheet shouldn't block loading.</h1> +<script> +var style = window.getComputedStyle(document.getElementById('title'), ''); +document.write(style['background-color']); + +if (window.testRunner) { + testRunner.dumpAsText(); +} +</script>
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/network/resource-priority-expected.txt b/third_party/WebKit/LayoutTests/http/tests/inspector/network/resource-priority-expected.txt index 9f7a66d7..b5a5c57 100644 --- a/third_party/WebKit/LayoutTests/http/tests/inspector/network/resource-priority-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/inspector/network/resource-priority-expected.txt
@@ -7,6 +7,6 @@ Request: empty.html?xhr-sync priority: VeryHigh Request: empty.html?xhr-async priority: Medium Request: abe.png priority: VeryLow -Request: style.css priority: High +Request: style.css priority: VeryLow Request: empty.html?iframe priority: VeryHigh
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt b/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt index 73f3390..9993fb7 100644 --- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
@@ -145,6 +145,7 @@ getter cancelBubble getter cancelable getter currentTarget + getter deepPath getter defaultPrevented getter eventPhase getter path
diff --git a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js-blackboxing.html b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js-blackboxing.html index 73b9dce..a130bbe 100644 --- a/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js-blackboxing.html +++ b/third_party/WebKit/LayoutTests/inspector/tracing/timeline-js-blackboxing.html
@@ -277,7 +277,7 @@ var timelineData = dataProvider.timelineData(); for (var i = 0; i < timelineData.entryStartTimes.length; ++i) { var name = dataProvider.entryTitle(i); - var padding = " ".repeat(timelineData.entryLevels[i]); + var padding = " ".repeat(timelineData.entryLevels[i] - 1); InspectorTest.addResult(padding + name + ": " + timelineData.entryTotalTimes[i] + " @ " + timelineData.entryStartTimes[i]); } } @@ -285,7 +285,7 @@ Runtime.experiments.enableForTest("blackboxJSFramesOnTimeline"); var tracingTimelineModel = InspectorTest.tracingTimelineModel(); tracingTimelineModel.setEventsForTest(rawTraceEvents); - var dataProvider = new WebInspector.TimelineFlameChartDataProvider(tracingTimelineModel); + var dataProvider = new WebInspector.TimelineFlameChartDataProvider(tracingTimelineModel, new WebInspector.TracingTimelineFrameModel()); InspectorTest.addResult("\nBlackboxed url: lib_script.js"); WebInspector.BlackboxSupport.blackboxURL("lib_script.js");
diff --git a/third_party/WebKit/LayoutTests/platform/mac/fast/forms/placeholder-position-expected.png b/third_party/WebKit/LayoutTests/platform/mac/fast/forms/placeholder-position-expected.png index 92e7967..31931594 100644 --- a/third_party/WebKit/LayoutTests/platform/mac/fast/forms/placeholder-position-expected.png +++ b/third_party/WebKit/LayoutTests/platform/mac/fast/forms/placeholder-position-expected.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac/fast/forms/placeholder-position-expected.txt b/third_party/WebKit/LayoutTests/platform/mac/fast/forms/placeholder-position-expected.txt index 78441ef..3a8a8333 100644 --- a/third_party/WebKit/LayoutTests/platform/mac/fast/forms/placeholder-position-expected.txt +++ b/third_party/WebKit/LayoutTests/platform/mac/fast/forms/placeholder-position-expected.txt
@@ -7,9 +7,19 @@ LayoutFlexibleBox {DIV} at (4,3) size 125x13 LayoutBlockFlow {DIV} at (0,6.50) size 5x0 LayoutBlockFlow {DIV} at (5,0) size 108x13 - LayoutBR {BR} at (133,14) size 0x0 - LayoutTextControl {INPUT} at (0,19) size 131x19 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)] - LayoutBR {BR} at (131,33) size 0x0 + LayoutText {#text} at (133,0) size 4x18 + text run at (133,0) width 4: " " + LayoutBR {BR} at (137,14) size 0x0 + LayoutTextControl {INPUT} at (0,19) size 71x19 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)] + LayoutText {#text} at (71,19) size 4x18 + text run at (71,19) width 4: " " + LayoutTextControl {INPUT} at (75,19) size 71x19 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)] + LayoutText {#text} at (146,19) size 4x18 + text run at (146,19) width 4: " " + LayoutTextControl {INPUT} at (150,19) size 131x19 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)] + LayoutText {#text} at (281,19) size 4x18 + text run at (281,19) width 4: " " + LayoutBR {BR} at (285,33) size 0x0 LayoutTextControl {INPUT} at (0,38) size 133x19 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)] LayoutFlexibleBox {DIV} at (4,3) size 125x13 LayoutBlockFlow {DIV} at (0,6.50) size 5x0 @@ -32,7 +42,13 @@ LayoutTextControl {INPUT} at (135,225) size 131x31 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)] LayoutText {#text} at (266,231) size 4x18 text run at (266,231) width 4: " " - LayoutBR {BR} at (270,245) size 0x0 + LayoutTextControl {INPUT} at (270,228) size 131x25 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)] + LayoutText {#text} at (401,231) size 4x18 + text run at (401,231) width 4: " " + LayoutTextControl {INPUT} at (405,228) size 131x25 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)] + LayoutText {#text} at (536,231) size 4x18 + text run at (536,231) width 4: " " + LayoutBR {BR} at (0,0) size 0x0 LayoutTextControl {INPUT} at (0,256) size 131x19 [bgcolor=#FFFFFF] [border: (2px inset #EEEEEE)] LayoutText {#text} at (131,256) size 4x18 text run at (131,256) width 4: " " @@ -50,11 +66,23 @@ text run at (0,0) width 59: "placeholder" layer at (17,11) size 108x13 LayoutBlockFlow {DIV} at (0,0) size 108x13 -layer at (11,30) size 125x13 - LayoutBlockFlow {DIV} at (3,3) size 125x13 [color=#A9A9A9] +layer at (11,30) size 65x13 + LayoutBlockFlow {DIV} at (3,3) size 65x13 [color=#A9A9A9] LayoutText {#text} at (0,0) size 59x13 text run at (0,0) width 59: "placeholder" -layer at (11,30) size 125x13 +layer at (11,30) size 65x13 + LayoutBlockFlow {DIV} at (3,3) size 65x13 +layer at (86,31) size 65x11 scrollHeight 12 + LayoutBlockFlow {DIV} at (3,4) size 65x11 [color=#A9A9A9] + LayoutText {#text} at (0,-1) size 59x13 + text run at (0,-1) width 59: "placeholder" +layer at (86,30) size 65x13 + LayoutBlockFlow {DIV} at (3,3) size 65x13 +layer at (161,30) size 125x13 + LayoutBlockFlow {DIV} at (3,3) size 125x13 [color=#A9A9A9] + LayoutText {#text} at (0,0) size 92x13 + text run at (0,0) width 92: "\x{65E5}\x{672C}\x{8A9E}placeholder" +layer at (161,30) size 125x13 LayoutBlockFlow {DIV} at (3,3) size 125x13 layer at (17,49) size 108x13 LayoutBlockFlow {DIV} at (9,3) size 108x13 [color=#A9A9A9] @@ -102,6 +130,18 @@ text run at (0,6) width 59: "placeholder" layer at (146,236) size 125x25 LayoutBlockFlow {DIV} at (3,3) size 125x25 +layer at (281,242) size 125x13 + LayoutBlockFlow {DIV} at (3,6) size 125x13 [color=#A9A9A9] + LayoutText {#text} at (0,0) size 59x13 + text run at (0,0) width 59: "placeholder" +layer at (281,242) size 125x13 + LayoutBlockFlow {DIV} at (3,6) size 125x13 +layer at (416,236) size 125x25 + LayoutBlockFlow {DIV} at (3,0) size 125x25 [color=#A9A9A9] + LayoutText {#text} at (0,6) size 59x13 + text run at (0,6) width 59: "placeholder" +layer at (416,242) size 125x13 + LayoutBlockFlow {DIV} at (3,6) size 125x13 layer at (11,267) size 125x13 LayoutBlockFlow {DIV} at (3,3) size 125x13 LayoutText {#text} at (49,0) size 27x13
diff --git a/third_party/WebKit/LayoutTests/typedcssom/calclength.html b/third_party/WebKit/LayoutTests/typedcssom/calcLength.html similarity index 100% rename from third_party/WebKit/LayoutTests/typedcssom/calclength.html rename to third_party/WebKit/LayoutTests/typedcssom/calcLength.html
diff --git a/third_party/WebKit/LayoutTests/typedcssom/lengthvalue.html b/third_party/WebKit/LayoutTests/typedcssom/lengthValue.html similarity index 100% rename from third_party/WebKit/LayoutTests/typedcssom/lengthvalue.html rename to third_party/WebKit/LayoutTests/typedcssom/lengthValue.html
diff --git a/third_party/WebKit/LayoutTests/typedcssom/matrixtransformcomponent.html b/third_party/WebKit/LayoutTests/typedcssom/matrixTransformComponent.html similarity index 100% rename from third_party/WebKit/LayoutTests/typedcssom/matrixtransformcomponent.html rename to third_party/WebKit/LayoutTests/typedcssom/matrixTransformComponent.html
diff --git a/third_party/WebKit/LayoutTests/typedcssom/numbervalue.html b/third_party/WebKit/LayoutTests/typedcssom/numberValue.html similarity index 100% rename from third_party/WebKit/LayoutTests/typedcssom/numbervalue.html rename to third_party/WebKit/LayoutTests/typedcssom/numberValue.html
diff --git a/third_party/WebKit/LayoutTests/typedcssom/scaletransformcomponent.html b/third_party/WebKit/LayoutTests/typedcssom/scaleTransformComponent.html similarity index 100% rename from third_party/WebKit/LayoutTests/typedcssom/scaletransformcomponent.html rename to third_party/WebKit/LayoutTests/typedcssom/scaleTransformComponent.html
diff --git a/third_party/WebKit/LayoutTests/typedcssom/simplelength.html b/third_party/WebKit/LayoutTests/typedcssom/simpleLength.html similarity index 100% rename from third_party/WebKit/LayoutTests/typedcssom/simplelength.html rename to third_party/WebKit/LayoutTests/typedcssom/simpleLength.html
diff --git a/third_party/WebKit/LayoutTests/typedcssom/TransformValue.html b/third_party/WebKit/LayoutTests/typedcssom/transformValue.html similarity index 100% rename from third_party/WebKit/LayoutTests/typedcssom/TransformValue.html rename to third_party/WebKit/LayoutTests/typedcssom/transformValue.html
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt index 7b1da3c..df1a334 100644 --- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt
@@ -146,6 +146,7 @@ [Worker] getter cancelBubble [Worker] getter cancelable [Worker] getter currentTarget +[Worker] getter deepPath [Worker] getter defaultPrevented [Worker] getter eventPhase [Worker] getter path
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt index 53a29bc6..bddceb6 100644 --- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
@@ -1393,6 +1393,7 @@ getter cancelBubble getter cancelable getter currentTarget + getter deepPath getter defaultPrevented getter eventPhase getter path @@ -5248,6 +5249,19 @@ interface Stream getter type method constructor +interface StylePropertyMap + method append + method constructor + method delete + method entries + method forEach + method get + method getAll + method getProperties + method has + method keys + method set + method values interface StyleSheet getter disabled getter href
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt index 400c75c..be9300b 100644 --- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt
@@ -136,6 +136,7 @@ [Worker] getter cancelBubble [Worker] getter cancelable [Worker] getter currentTarget +[Worker] getter deepPath [Worker] getter defaultPrevented [Worker] getter eventPhase [Worker] getter path
diff --git a/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.cpp b/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.cpp index 1da53648..36590bec 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.cpp
@@ -10,57 +10,61 @@ namespace blink { -ScriptValue ReadableStreamOperations::getReader(ScriptState* scriptState, v8::Local<v8::Value> stream, ExceptionState& es) +ScriptValue ReadableStreamOperations::getReader(ScriptState* scriptState, ScriptValue stream, ExceptionState& es) { ASSERT(isReadableStream(scriptState, stream)); v8::TryCatch block(scriptState->isolate()); - v8::Local<v8::Value> args[] = { stream }; + v8::Local<v8::Value> args[] = { stream.v8Value() }; ScriptValue result(scriptState, v8CallExtra(scriptState, "AcquireReadableStreamReader", args)); if (block.HasCaught()) es.rethrowV8Exception(block.Exception()); return result; } -bool ReadableStreamOperations::isReadableStream(ScriptState* scriptState, v8::Local<v8::Value> value) +bool ReadableStreamOperations::isReadableStream(ScriptState* scriptState, ScriptValue value) { - if (!value->IsObject()) + ASSERT(!value.isEmpty()); + + if (!value.isObject()) return false; - v8::Local<v8::Value> args[] = { value }; + v8::Local<v8::Value> args[] = { value.v8Value() }; return v8CallExtraOrCrash(scriptState, "IsReadableStream", args)->ToBoolean()->Value(); } -bool ReadableStreamOperations::isDisturbed(ScriptState* scriptState, v8::Local<v8::Value> stream) +bool ReadableStreamOperations::isDisturbed(ScriptState* scriptState, ScriptValue stream) { ASSERT(isReadableStream(scriptState, stream)); - v8::Local<v8::Value> args[] = { stream }; + v8::Local<v8::Value> args[] = { stream.v8Value() }; return v8CallExtraOrCrash(scriptState, "IsReadableStreamDisturbed", args)->ToBoolean()->Value(); } -bool ReadableStreamOperations::isLocked(ScriptState* scriptState, v8::Local<v8::Value> stream) +bool ReadableStreamOperations::isLocked(ScriptState* scriptState, ScriptValue stream) { ASSERT(isReadableStream(scriptState, stream)); - v8::Local<v8::Value> args[] = { stream }; + v8::Local<v8::Value> args[] = { stream.v8Value() }; return v8CallExtraOrCrash(scriptState, "IsReadableStreamLocked", args)->ToBoolean()->Value(); } -bool ReadableStreamOperations::isReadableStreamReader(ScriptState* scriptState, v8::Local<v8::Value> value) +bool ReadableStreamOperations::isReadableStreamReader(ScriptState* scriptState, ScriptValue value) { - if (!value->IsObject()) + ASSERT(!value.isEmpty()); + + if (!value.isObject()) return false; - v8::Local<v8::Value> args[] = { value }; + v8::Local<v8::Value> args[] = { value.v8Value() }; return v8CallExtraOrCrash(scriptState, "IsReadableStreamReader", args)->ToBoolean()->Value(); } -ScriptPromise ReadableStreamOperations::read(ScriptState* scriptState, v8::Local<v8::Value> reader) +ScriptPromise ReadableStreamOperations::read(ScriptState* scriptState, ScriptValue reader) { ASSERT(isReadableStreamReader(scriptState, reader)); - v8::Local<v8::Value> args[] = { reader }; + v8::Local<v8::Value> args[] = { reader.v8Value() }; return ScriptPromise::cast(scriptState, v8CallExtraOrCrash(scriptState, "ReadFromReadableStreamReader", args)); }
diff --git a/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.h b/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.h index b456fb9..5ff0f429 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.h +++ b/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.h
@@ -16,7 +16,7 @@ // This class has various methods for ReadableStream[Reader] implemented with // V8 Extras. -// All methods should be called in an appropriate V8 context. All v8 handle +// All methods should be called in an appropriate V8 context. All ScriptValue // arguments must not be empty. class CORE_EXPORT ReadableStreamOperations { STATIC_ONLY(ReadableStreamOperations); @@ -25,25 +25,25 @@ // This function assumes |isReadableStream(stream)|. // Returns an empty value and throws an error via the ExceptionState when // errored. - static ScriptValue getReader(ScriptState*, v8::Local<v8::Value> stream, ExceptionState&); + static ScriptValue getReader(ScriptState*, ScriptValue stream, ExceptionState&); // IsReadableStream - static bool isReadableStream(ScriptState*, v8::Local<v8::Value>); + static bool isReadableStream(ScriptState*, ScriptValue); // IsReadableStreamDisturbed // This function assumes |isReadableStream(stream)|. - static bool isDisturbed(ScriptState*, v8::Local<v8::Value> stream); + static bool isDisturbed(ScriptState*, ScriptValue stream); // IsReadableStreamLocked // This function assumes |isReadableStream(stream)|. - static bool isLocked(ScriptState*, v8::Local<v8::Value> stream); + static bool isLocked(ScriptState*, ScriptValue stream); // IsReadableStreamReader - static bool isReadableStreamReader(ScriptState*, v8::Local<v8::Value>); + static bool isReadableStreamReader(ScriptState*, ScriptValue); // ReadFromReadableStreamReader // This function assumes |isReadableStreamReader(reader)|. - static ScriptPromise read(ScriptState*, v8::Local<v8::Value> reader); + static ScriptPromise read(ScriptState*, ScriptValue reader); }; } // namespace blink
diff --git a/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperationsTest.cpp b/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperationsTest.cpp index 2693c75..9715147 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperationsTest.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperationsTest.cpp
@@ -7,6 +7,7 @@ #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/ScriptFunction.h" #include "bindings/core/v8/ScriptState.h" +#include "bindings/core/v8/ScriptValue.h" #include "bindings/core/v8/V8Binding.h" #include "bindings/core/v8/V8BindingForTesting.h" #include "bindings/core/v8/V8BindingMacros.h" @@ -128,24 +129,24 @@ ScriptState* scriptState() const { return m_scope.scriptState(); } v8::Isolate* isolate() const { return scriptState()->isolate(); } - v8::MaybeLocal<v8::Value> eval(const char* s) + ScriptValue eval(const char* s) { v8::Local<v8::String> source; v8::Local<v8::Script> script; if (!v8Call(v8::String::NewFromUtf8(isolate(), s, v8::NewStringType::kNormal), source)) { ADD_FAILURE(); - return v8::MaybeLocal<v8::Value>(); + return ScriptValue(); } if (!v8Call(v8::Script::Compile(scriptState()->context(), source), script)) { ADD_FAILURE() << "Compilation fails"; - return v8::MaybeLocal<v8::Value>(); + return ScriptValue(); } - return script->Run(scriptState()->context()); + return ScriptValue(scriptState(), script->Run(scriptState()->context())); } - v8::MaybeLocal<v8::Value> evalWithPrintingError(const char* s) + ScriptValue evalWithPrintingError(const char* s) { v8::TryCatch block(isolate()); - v8::MaybeLocal<v8::Value> r = eval(s); + ScriptValue r = eval(s); if (block.HasCaught()) { ADD_FAILURE() << toCoreString(block.Exception()->ToString(isolate())).utf8().data(); block.ReThrow(); @@ -160,29 +161,29 @@ TEST_F(ReadableStreamOperationsTest, IsReadableStream) { - EXPECT_FALSE(ReadableStreamOperations::isReadableStream(scriptState(), v8::Undefined(isolate()))); - EXPECT_FALSE(ReadableStreamOperations::isReadableStream(scriptState(), v8::Null(isolate()))); - EXPECT_FALSE(ReadableStreamOperations::isReadableStream(scriptState(), v8::Object::New(isolate()))); - v8::Local<v8::Value> stream; - ASSERT_TRUE(v8Call(evalWithPrintingError("new ReadableStream()"), stream)); + EXPECT_FALSE(ReadableStreamOperations::isReadableStream(scriptState(), ScriptValue(scriptState(), v8::Undefined(isolate())))); + EXPECT_FALSE(ReadableStreamOperations::isReadableStream(scriptState(), ScriptValue::createNull(scriptState()))); + EXPECT_FALSE(ReadableStreamOperations::isReadableStream(scriptState(), ScriptValue(scriptState(), v8::Object::New(isolate())))); + ScriptValue stream = evalWithPrintingError("new ReadableStream()"); + EXPECT_FALSE(stream.isEmpty()); EXPECT_TRUE(ReadableStreamOperations::isReadableStream(scriptState(), stream)); } TEST_F(ReadableStreamOperationsTest, IsReadableStreamReaderInvalid) { - EXPECT_FALSE(ReadableStreamOperations::isReadableStreamReader(scriptState(), v8::Undefined(isolate()))); - EXPECT_FALSE(ReadableStreamOperations::isReadableStreamReader(scriptState(), v8::Null(isolate()))); - EXPECT_FALSE(ReadableStreamOperations::isReadableStreamReader(scriptState(), v8::Object::New(isolate()))); - v8::Local<v8::Value> stream; - ASSERT_TRUE(v8Call(evalWithPrintingError("new ReadableStream()"), stream)); + EXPECT_FALSE(ReadableStreamOperations::isReadableStreamReader(scriptState(), ScriptValue(scriptState(), v8::Undefined(isolate())))); + EXPECT_FALSE(ReadableStreamOperations::isReadableStreamReader(scriptState(), ScriptValue::createNull(scriptState()))); + EXPECT_FALSE(ReadableStreamOperations::isReadableStreamReader(scriptState(), ScriptValue(scriptState(), v8::Object::New(isolate())))); + ScriptValue stream = evalWithPrintingError("new ReadableStream()"); + EXPECT_FALSE(stream.isEmpty()); EXPECT_FALSE(ReadableStreamOperations::isReadableStreamReader(scriptState(), stream)); } TEST_F(ReadableStreamOperationsTest, GetReader) { - v8::Local<v8::Value> stream; - ASSERT_TRUE(v8Call(evalWithPrintingError("new ReadableStream()"), stream)); + ScriptValue stream = evalWithPrintingError("new ReadableStream()"); + EXPECT_FALSE(stream.isEmpty()); EXPECT_FALSE(ReadableStreamOperations::isLocked(scriptState(), stream)); ScriptValue reader; @@ -194,8 +195,8 @@ EXPECT_TRUE(ReadableStreamOperations::isLocked(scriptState(), stream)); ASSERT_FALSE(reader.isEmpty()); - EXPECT_FALSE(ReadableStreamOperations::isReadableStream(scriptState(), reader.v8Value())); - EXPECT_TRUE(ReadableStreamOperations::isReadableStreamReader(scriptState(), reader.v8Value())); + EXPECT_FALSE(ReadableStreamOperations::isReadableStream(scriptState(), reader)); + EXPECT_TRUE(ReadableStreamOperations::isReadableStreamReader(scriptState(), reader)); // Already locked! { @@ -208,23 +209,23 @@ TEST_F(ReadableStreamOperationsTest, IsDisturbed) { - v8::Local<v8::Value> stream; - ASSERT_TRUE(v8Call(evalWithPrintingError("stream = new ReadableStream()"), stream)); + ScriptValue stream = evalWithPrintingError("stream = new ReadableStream()"); + EXPECT_FALSE(stream.isEmpty()); EXPECT_FALSE(ReadableStreamOperations::isDisturbed(scriptState(), stream)); - ASSERT_FALSE(evalWithPrintingError("stream.cancel()").IsEmpty()); + ASSERT_FALSE(evalWithPrintingError("stream.cancel()").isEmpty()); EXPECT_TRUE(ReadableStreamOperations::isDisturbed(scriptState(), stream)); } TEST_F(ReadableStreamOperationsTest, Read) { - v8::Local<v8::Value> reader; - ASSERT_TRUE(v8Call(evalWithPrintingError( + ScriptValue reader = evalWithPrintingError( "var controller;" "function start(c) { controller = c; }" - "new ReadableStream({start}).getReader()"), reader)); + "new ReadableStream({start}).getReader()"); + EXPECT_FALSE(reader.isEmpty()); ASSERT_TRUE(ReadableStreamOperations::isReadableStreamReader(scriptState(), reader)); Iteration* it1 = new Iteration(); @@ -240,7 +241,7 @@ EXPECT_FALSE(it1->isSet()); EXPECT_FALSE(it2->isSet()); - ASSERT_FALSE(evalWithPrintingError("controller.enqueue('hello')").IsEmpty()); + ASSERT_FALSE(evalWithPrintingError("controller.enqueue('hello')").isEmpty()); isolate()->RunMicrotasks(); EXPECT_TRUE(it1->isSet()); EXPECT_TRUE(it1->isValid()); @@ -248,7 +249,7 @@ EXPECT_EQ("hello", it1->value()); EXPECT_FALSE(it2->isSet()); - ASSERT_FALSE(evalWithPrintingError("controller.close()").IsEmpty()); + ASSERT_FALSE(evalWithPrintingError("controller.close()").isEmpty()); isolate()->RunMicrotasks(); EXPECT_TRUE(it1->isSet()); EXPECT_TRUE(it1->isValid());
diff --git a/third_party/WebKit/Source/core/animation/SampledEffect.h b/third_party/WebKit/Source/core/animation/SampledEffect.h index 040bfe88..b1ec858 100644 --- a/third_party/WebKit/Source/core/animation/SampledEffect.h +++ b/third_party/WebKit/Source/core/animation/SampledEffect.h
@@ -16,8 +16,6 @@ class SVGElement; -// TODO(haraken): Drop Finalized once we ship Oilpan and the OwnPtrWillBeMember -// is gone. class SampledEffect : public GarbageCollectedFinalized<SampledEffect> { WTF_MAKE_NONCOPYABLE(SampledEffect); public:
diff --git a/third_party/WebKit/Source/core/core.gypi b/third_party/WebKit/Source/core/core.gypi index bccc91c..1cb9f07 100644 --- a/third_party/WebKit/Source/core/core.gypi +++ b/third_party/WebKit/Source/core/core.gypi
@@ -46,6 +46,7 @@ 'css/cssom/NumberValue.idl', 'css/cssom/ScaleTransformComponent.idl', 'css/cssom/SimpleLength.idl', + 'css/cssom/StylePropertyMap.idl', 'css/cssom/StyleValue.idl', 'css/cssom/TransformComponent.idl', 'css/cssom/TransformValue.idl', @@ -1254,6 +1255,7 @@ 'css/StyleSheetContents.h', 'css/StyleSheetList.cpp', 'css/StyleSheetList.h', + 'css/cssom/ImmutableStylePropertyMap.h', 'css/cssom/StyleCalcLength.cpp', 'css/cssom/StyleCalcLength.h', 'css/cssom/KeywordValue.cpp', @@ -1262,11 +1264,14 @@ 'css/cssom/LengthValue.h', 'css/cssom/MatrixTransformComponent.cpp', 'css/cssom/MatrixTransformComponent.h', + 'css/cssom/MutableStylePropertyMap.h', 'css/cssom/NumberValue.h', 'css/cssom/ScaleTransformComponent.cpp', 'css/cssom/ScaleTransformComponent.h', 'css/cssom/SimpleLength.cpp', 'css/cssom/SimpleLength.h', + 'css/cssom/StylePropertyMap.cpp', + 'css/cssom/StylePropertyMap.h', 'css/cssom/StyleValue.cpp', 'css/cssom/StyleValue.h', 'css/cssom/TransformComponent.h', @@ -1695,6 +1700,7 @@ 'inspector/AsyncCallChain.h', 'inspector/AsyncCallTracker.cpp', 'inspector/AsyncCallTracker.h', + 'inspector/AsyncOperationMap.h', 'inspector/ConsoleAPITypes.h', 'inspector/ConsoleMessage.cpp', 'inspector/ConsoleMessage.h', @@ -1813,7 +1819,6 @@ 'inspector/ScriptCallFrame.h', 'inspector/ScriptCallStack.cpp', 'inspector/ScriptCallStack.h', - 'inspector/v8/AsyncOperationMap.h', 'inspector/v8/InspectorWrapper.cpp', 'inspector/v8/InspectorWrapper.h', 'inspector/v8/IgnoreExceptionsScope.h',
diff --git a/third_party/WebKit/Source/core/css/CSSSelector.h b/third_party/WebKit/Source/core/css/CSSSelector.h index 207ef44..70e0560b 100644 --- a/third_party/WebKit/Source/core/css/CSSSelector.h +++ b/third_party/WebKit/Source/core/css/CSSSelector.h
@@ -256,7 +256,7 @@ bool isSiblingSelector() const; bool isAttributeSelector() const { return m_match >= FirstAttributeSelectorMatch; } bool isHostPseudoClass() const { return m_pseudoType == PseudoHost || m_pseudoType == PseudoHostContext; } - bool isInsertionPointCrossing() const { return m_pseudoType == PseudoHostContext || m_pseudoType == PseudoContent; } + bool isInsertionPointCrossing() const { return m_pseudoType == PseudoHostContext || m_pseudoType == PseudoContent || m_pseudoType == PseudoSlotted; } Relation relation() const { return static_cast<Relation>(m_relation); } void setRelation(Relation relation)
diff --git a/third_party/WebKit/Source/core/css/CSSSelectorList.cpp b/third_party/WebKit/Source/core/css/CSSSelectorList.cpp index 7cba4aa1..83626a2 100644 --- a/third_party/WebKit/Source/core/css/CSSSelectorList.cpp +++ b/third_party/WebKit/Source/core/css/CSSSelectorList.cpp
@@ -185,7 +185,7 @@ bool CSSSelectorList::selectorNeedsUpdatedDistribution(size_t index) const { return forEachTagSelector([](const CSSSelector& selector) -> bool { - return selector.relationIsAffectedByPseudoContent() || selector.pseudoType() == CSSSelector::PseudoHostContext; + return selector.relationIsAffectedByPseudoContent() || selector.pseudoType() == CSSSelector::PseudoSlotted || selector.pseudoType() == CSSSelector::PseudoHostContext; }, selectorAt(index)); }
diff --git a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp index e9eaeee..e3003ff 100644 --- a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp +++ b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
@@ -56,6 +56,7 @@ #include "core/style/PathStyleMotionPath.h" #include "core/style/QuotesData.h" #include "core/style/ShadowList.h" +#include "core/style/StyleVariableData.h" #include "core/svg/SVGPathUtilities.h" #include "platform/LengthFunctions.h"
diff --git a/third_party/WebKit/Source/core/css/RuleFeature.cpp b/third_party/WebKit/Source/core/css/RuleFeature.cpp index c605524..59e3abd 100644 --- a/third_party/WebKit/Source/core/css/RuleFeature.cpp +++ b/third_party/WebKit/Source/core/css/RuleFeature.cpp
@@ -152,6 +152,7 @@ case CSSSelector::PseudoShadow: case CSSSelector::PseudoSpatialNavigationFocus: case CSSSelector::PseudoListBox: + case CSSSelector::PseudoSlotted: return true; case CSSSelector::PseudoUnknown: case CSSSelector::PseudoLeftPage: @@ -173,7 +174,8 @@ || pseudo == CSSSelector::PseudoCue || pseudo == CSSSelector::PseudoHost || pseudo == CSSSelector::PseudoHostContext - || pseudo == CSSSelector::PseudoNot; + || pseudo == CSSSelector::PseudoNot + || pseudo == CSSSelector::PseudoSlotted; } #endif // ENABLE(ASSERT) @@ -515,7 +517,7 @@ if (current->relation() == CSSSelector::SubSelector) continue; - if (current->relationIsAffectedByPseudoContent()) { + if (current->relationIsAffectedByPseudoContent() || current->relation() == CSSSelector::ShadowSlot) { descendantFeatures.insertionPointCrossing = true; descendantFeatures.contentPseudoCrossing = true; }
diff --git a/third_party/WebKit/Source/core/css/RuleSet.cpp b/third_party/WebKit/Source/core/css/RuleSet.cpp index bc735aa..42962a1 100644 --- a/third_party/WebKit/Source/core/css/RuleSet.cpp +++ b/third_party/WebKit/Source/core/css/RuleSet.cpp
@@ -261,9 +261,9 @@ if (selectorList.selectorUsesDeepCombinatorOrShadowPseudo(selectorIndex)) { m_deepCombinatorOrShadowPseudoRules.append(MinimalRuleData(styleRule, selectorIndex, addRuleFlags)); } else if (selectorList.selectorHasContentPseudo(selectorIndex)) { - m_shadowDistributedRules.append(MinimalRuleData(styleRule, selectorIndex, addRuleFlags)); + m_contentPseudoElementRules.append(MinimalRuleData(styleRule, selectorIndex, addRuleFlags)); } else if (selectorList.selectorHasSlottedPseudo(selectorIndex)) { - m_shadowSlottedRules.append(MinimalRuleData(styleRule, selectorIndex, addRuleFlags)); + m_slottedPseudoElementRules.append(MinimalRuleData(styleRule, selectorIndex, addRuleFlags)); } else { addRule(styleRule, selectorIndex, addRuleFlags); } @@ -343,8 +343,8 @@ m_fontFaceRules.shrinkToFit(); m_keyframesRules.shrinkToFit(); m_deepCombinatorOrShadowPseudoRules.shrinkToFit(); - m_shadowDistributedRules.shrinkToFit(); - m_shadowSlottedRules.shrinkToFit(); + m_contentPseudoElementRules.shrinkToFit(); + m_slottedPseudoElementRules.shrinkToFit(); } DEFINE_TRACE(MinimalRuleData) @@ -385,8 +385,8 @@ visitor->trace(m_fontFaceRules); visitor->trace(m_keyframesRules); visitor->trace(m_deepCombinatorOrShadowPseudoRules); - visitor->trace(m_shadowDistributedRules); - visitor->trace(m_shadowSlottedRules); + visitor->trace(m_contentPseudoElementRules); + visitor->trace(m_slottedPseudoElementRules); visitor->trace(m_viewportDependentMediaQueryResults); visitor->trace(m_deviceDependentMediaQueryResults); visitor->trace(m_pendingRules);
diff --git a/third_party/WebKit/Source/core/css/RuleSet.h b/third_party/WebKit/Source/core/css/RuleSet.h index 26fbc26..12dd72a 100644 --- a/third_party/WebKit/Source/core/css/RuleSet.h +++ b/third_party/WebKit/Source/core/css/RuleSet.h
@@ -145,8 +145,8 @@ const WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace>>& fontFaceRules() const { return m_fontFaceRules; } const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes>>& keyframesRules() const { return m_keyframesRules; } const WillBeHeapVector<MinimalRuleData>& deepCombinatorOrShadowPseudoRules() const { return m_deepCombinatorOrShadowPseudoRules; } - const WillBeHeapVector<MinimalRuleData>& shadowDistributedRules() const { return m_shadowDistributedRules; } - const WillBeHeapVector<MinimalRuleData>& shadowSlottedRules() const { return m_shadowSlottedRules; } + const WillBeHeapVector<MinimalRuleData>& contentPseudoElementRules() const { return m_contentPseudoElementRules; } + const WillBeHeapVector<MinimalRuleData>& slottedPseudoElementRules() const { return m_slottedPseudoElementRules; } const MediaQueryResultList& viewportDependentMediaQueryResults() const { return m_viewportDependentMediaQueryResults; } const MediaQueryResultList& deviceDependentMediaQueryResults() const { return m_deviceDependentMediaQueryResults; } @@ -223,8 +223,8 @@ WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace>> m_fontFaceRules; WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes>> m_keyframesRules; WillBeHeapVector<MinimalRuleData> m_deepCombinatorOrShadowPseudoRules; - WillBeHeapVector<MinimalRuleData> m_shadowDistributedRules; - WillBeHeapVector<MinimalRuleData> m_shadowSlottedRules; + WillBeHeapVector<MinimalRuleData> m_contentPseudoElementRules; + WillBeHeapVector<MinimalRuleData> m_slottedPseudoElementRules; MediaQueryResultList m_viewportDependentMediaQueryResults; MediaQueryResultList m_deviceDependentMediaQueryResults;
diff --git a/third_party/WebKit/Source/core/css/SelectorChecker.cpp b/third_party/WebKit/Source/core/css/SelectorChecker.cpp index 497e172..d634960 100644 --- a/third_party/WebKit/Source/core/css/SelectorChecker.cpp +++ b/third_party/WebKit/Source/core/css/SelectorChecker.cpp
@@ -47,6 +47,7 @@ #include "core/html/HTMLInputElement.h" #include "core/html/HTMLOptionElement.h" #include "core/html/HTMLSelectElement.h" +#include "core/html/HTMLSlotElement.h" #include "core/html/parser/HTMLParserIdioms.h" #include "core/html/track/vtt/VTTElement.h" #include "core/inspector/InspectorInstrumentation.h" @@ -113,6 +114,20 @@ return context.element->parentElement(); } +static const HTMLSlotElement* findSlotElementInScope(const SelectorChecker::SelectorCheckingContext& context) +{ + if (!context.scope) + return nullptr; + + const HTMLSlotElement* slot = context.element->assignedSlot(); + while (slot) { + if (slot->treeScope() == context.scope->treeScope()) + return slot; + slot = slot->assignedSlot(); + } + return nullptr; +} + static bool scopeContainsLastMatchedElement(const SelectorChecker::SelectorCheckingContext& context) { // If this context isn't scoped, skip checking. @@ -334,7 +349,7 @@ case CSSSelector::Descendant: if (context.selector->relationIsAffectedByPseudoContent()) { for (Element* element = context.element; element; element = element->parentElement()) { - if (matchForShadowDistributed(nextContext, *element, result) == SelectorMatches) + if (matchForPseudoContent(nextContext, *element, result) == SelectorMatches) return SelectorMatches; } return SelectorFailsCompletely; @@ -356,7 +371,7 @@ case CSSSelector::Child: { if (context.selector->relationIsAffectedByPseudoContent()) - return matchForShadowDistributed(nextContext, *context.element, result); + return matchForPseudoContent(nextContext, *context.element, result); nextContext.isSubSelector = false; nextContext.inRightmostCompound = false; @@ -433,7 +448,7 @@ if (context.selector->relationIsAffectedByPseudoContent()) { // TODO(kochi): closed mode tree should be handled as well for ::content. for (Element* element = context.element; element; element = element->parentOrShadowHostElement()) { - if (matchForShadowDistributed(nextContext, *element, result) == SelectorMatches) + if (matchForPseudoContent(nextContext, *element, result) == SelectorMatches) return SelectorMatches; } return SelectorFailsCompletely; @@ -451,9 +466,16 @@ } return SelectorFailsCompletely; } + case CSSSelector::ShadowSlot: - // TODO(kochi): Add this in later CL. - return SelectorFailsCompletely; + { + const HTMLSlotElement* slot = findSlotElementInScope(context); + if (!slot) + return SelectorFailsCompletely; + + nextContext.element = const_cast<HTMLSlotElement*>(slot); + return matchSelector(nextContext, result); + } case CSSSelector::SubSelector: ASSERT_NOT_REACHED(); @@ -463,7 +485,7 @@ return SelectorFailsCompletely; } -SelectorChecker::Match SelectorChecker::matchForShadowDistributed(const SelectorCheckingContext& context, const Element& element, MatchResult& result) const +SelectorChecker::Match SelectorChecker::matchForPseudoContent(const SelectorCheckingContext& context, const Element& element, MatchResult& result) const { WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> insertionPoints; collectDestinationInsertionPoints(element, insertionPoints); @@ -1034,6 +1056,19 @@ return root->type() == ShadowRootType::UserAgent && element.shadowPseudoId() == selector.value(); return false; } + case CSSSelector::PseudoSlotted: + { + SelectorCheckingContext subContext(context); + subContext.isSubSelector = true; + subContext.scope = nullptr; + subContext.treatShadowHostAsNormalScope = false; + + // ::slotted() only allows one compound selector. + ASSERT(selector.selectorList()->first()); + ASSERT(!CSSSelectorList::next(*selector.selectorList()->first())); + subContext.selector = selector.selectorList()->first(); + return match(subContext); + } case CSSSelector::PseudoContent: return element.isInShadowTree() && element.isInsertionPoint(); case CSSSelector::PseudoShadow:
diff --git a/third_party/WebKit/Source/core/css/SelectorChecker.h b/third_party/WebKit/Source/core/css/SelectorChecker.h index a827183..826418b 100644 --- a/third_party/WebKit/Source/core/css/SelectorChecker.h +++ b/third_party/WebKit/Source/core/css/SelectorChecker.h
@@ -112,7 +112,7 @@ Match matchSelector(const SelectorCheckingContext&, MatchResult&) const; Match matchForSubSelector(const SelectorCheckingContext&, MatchResult&) const; Match matchForRelation(const SelectorCheckingContext&, MatchResult&) const; - Match matchForShadowDistributed(const SelectorCheckingContext&, const Element&, MatchResult&) const; + Match matchForPseudoContent(const SelectorCheckingContext&, const Element&, MatchResult&) const; Match matchForPseudoShadow(const SelectorCheckingContext&, const ContainerNode*, MatchResult&) const; bool checkPseudoClass(const SelectorCheckingContext&, MatchResult&) const; bool checkPseudoElement(const SelectorCheckingContext&, MatchResult&) const;
diff --git a/third_party/WebKit/Source/core/css/SelectorFilter.cpp b/third_party/WebKit/Source/core/css/SelectorFilter.cpp index 8286300..edba01dc 100644 --- a/third_party/WebKit/Source/core/css/SelectorFilter.cpp +++ b/third_party/WebKit/Source/core/css/SelectorFilter.cpp
@@ -134,7 +134,11 @@ unsigned* hash = identifierHashes; unsigned* end = identifierHashes + maximumIdentifierCount; CSSSelector::Relation relation = selector.relation(); - bool relationIsAffectedByPseudoContent = selector.relationIsAffectedByPseudoContent(); + if (selector.relationIsAffectedByPseudoContent()) { + // Disable fastRejectSelector. + *identifierHashes = 0; + return; + } // Skip the topmost selector. It is handled quickly by the rule hashes. bool skipOverSubselectors = true; @@ -149,27 +153,27 @@ case CSSSelector::IndirectAdjacent: skipOverSubselectors = true; break; + case CSSSelector::ShadowSlot: + // Disable fastRejectSelector. + *identifierHashes = 0; + return; case CSSSelector::Descendant: case CSSSelector::Child: - if (relationIsAffectedByPseudoContent) { - // Disable fastRejectSelector. - *identifierHashes = 0; - return; - } // Fall through. case CSSSelector::ShadowPseudo: case CSSSelector::ShadowDeep: skipOverSubselectors = false; collectDescendantSelectorIdentifierHashes(*current, hash); break; - case CSSSelector::ShadowSlot: - // TODO(kochi): Add this in later CL. - break; } if (hash == end) return; relation = current->relation(); - relationIsAffectedByPseudoContent = current->relationIsAffectedByPseudoContent(); + if (current->relationIsAffectedByPseudoContent()) { + // Disable fastRejectSelector. + *identifierHashes = 0; + return; + } } *hash = 0; }
diff --git a/third_party/WebKit/Source/core/css/cssom/ImmutableStylePropertyMap.h b/third_party/WebKit/Source/core/css/cssom/ImmutableStylePropertyMap.h new file mode 100644 index 0000000..65bed42 --- /dev/null +++ b/third_party/WebKit/Source/core/css/cssom/ImmutableStylePropertyMap.h
@@ -0,0 +1,33 @@ +// 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 ImmutableStylePropertyMap_h +#define ImmutableStylePropertyMap_h + +#include "core/css/cssom/StylePropertyMap.h" + +namespace blink { + +class CORE_EXPORT ImmutableStylePropertyMap : public StylePropertyMap { + WTF_MAKE_NONCOPYABLE(ImmutableStylePropertyMap); +public: + void set(CSSPropertyID, StyleValueOrStyleValueSequenceOrString&, ExceptionState& exceptionState) override + { + exceptionState.throwTypeError("This StylePropertyMap is immutable."); + } + + void append(CSSPropertyID, StyleValueOrStyleValueSequenceOrString&, ExceptionState& exceptionState) override + { + exceptionState.throwTypeError("This StylePropertyMap is immutable."); + } + + void remove(CSSPropertyID, ExceptionState& exceptionState) override + { + exceptionState.throwTypeError("This StylePropertyMap is immutable."); + } +}; + +} // namespace blink + +#endif
diff --git a/third_party/WebKit/Source/core/css/cssom/MutableStylePropertyMap.h b/third_party/WebKit/Source/core/css/cssom/MutableStylePropertyMap.h new file mode 100644 index 0000000..be9f2d4 --- /dev/null +++ b/third_party/WebKit/Source/core/css/cssom/MutableStylePropertyMap.h
@@ -0,0 +1,18 @@ +// 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 MutableStylePropertyMap_h +#define MutableStylePropertyMap_h + +#include "core/css/cssom/StylePropertyMap.h" + +namespace blink { + +class CORE_EXPORT MutableStylePropertyMap : public StylePropertyMap { + WTF_MAKE_NONCOPYABLE(MutableStylePropertyMap); +}; + +} // namespace blink + +#endif
diff --git a/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp b/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp new file mode 100644 index 0000000..68bfe80 --- /dev/null +++ b/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp
@@ -0,0 +1,43 @@ +// 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/css/cssom/StylePropertyMap.h" + +#include "bindings/core/v8/ExceptionState.h" +#include "core/css/cssom/SimpleLength.h" +#include "core/css/cssom/StyleValue.h" + +namespace blink { + +StyleValue* StylePropertyMap::get(const String& propertyName) +{ + return get(cssPropertyID(propertyName)); +} + +HeapVector<Member<StyleValue>> StylePropertyMap::getAll(const String& propertyName) +{ + return getAll(cssPropertyID(propertyName)); +} + +bool StylePropertyMap::has(const String& propertyName) +{ + return has(cssPropertyID(propertyName)); +} + +void StylePropertyMap::set(const String& propertyName, StyleValueOrStyleValueSequenceOrString& item, ExceptionState& exceptionState) +{ + set(cssPropertyID(propertyName), item, exceptionState); +} + +void StylePropertyMap::append(const String& propertyName, StyleValueOrStyleValueSequenceOrString& item, ExceptionState& exceptionState) +{ + append(cssPropertyID(propertyName), item, exceptionState); +} + +void StylePropertyMap::remove(const String& propertyName, ExceptionState& exceptionState) +{ + remove(cssPropertyID(propertyName), exceptionState); +} + +} // namespace blink
diff --git a/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.h b/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.h new file mode 100644 index 0000000..79b873e --- /dev/null +++ b/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.h
@@ -0,0 +1,53 @@ +// 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 StylePropertyMap_h +#define StylePropertyMap_h + +#include "bindings/core/v8/Iterable.h" +#include "bindings/core/v8/ScriptWrappable.h" +#include "bindings/core/v8/UnionTypesCore.h" +#include "core/CSSPropertyNames.h" +#include "core/CoreExport.h" +#include "core/css/cssom/StyleValue.h" + +namespace blink { + +class ExceptionState; + +class CORE_EXPORT StylePropertyMap : public GarbageCollectedFinalized<StylePropertyMap>, public ScriptWrappable, public PairIterable<String, StyleValueOrStyleValueSequence> { + WTF_MAKE_NONCOPYABLE(StylePropertyMap); + DEFINE_WRAPPERTYPEINFO(); +public: + virtual ~StylePropertyMap() { } + + // Accessors. + StyleValue* get(const String& propertyName); + HeapVector<Member<StyleValue>> getAll(const String& propertyName); + bool has(const String& propertyName); + + virtual StyleValue* get(CSSPropertyID) = 0; + virtual HeapVector<Member<StyleValue>> getAll(CSSPropertyID) = 0; + virtual bool has(CSSPropertyID) = 0; + + virtual Vector<String> getProperties() = 0; + + // Modifiers. + void set(const String& propertyName, StyleValueOrStyleValueSequenceOrString& item, ExceptionState&); + void append(const String& propertyName, StyleValueOrStyleValueSequenceOrString& item, ExceptionState&); + void remove(const String& propertyName, ExceptionState&); + + virtual void set(CSSPropertyID, StyleValueOrStyleValueSequenceOrString& item, ExceptionState&) = 0; + virtual void append(CSSPropertyID, StyleValueOrStyleValueSequenceOrString& item, ExceptionState&) = 0; + virtual void remove(CSSPropertyID, ExceptionState&) = 0; + + DEFINE_INLINE_VIRTUAL_TRACE() { } + +protected: + StylePropertyMap() { } +}; + +} // namespace blink + +#endif
diff --git a/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.idl b/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.idl new file mode 100644 index 0000000..17d3945 --- /dev/null +++ b/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.idl
@@ -0,0 +1,17 @@ +// 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. + +[ + RuntimeEnabled=CSSTypedOM, + GarbageCollected +] interface StylePropertyMap { + [RaisesException] void append(DOMString property, (StyleValue or sequence<StyleValue> or DOMString) value); + [RaisesException, ImplementedAs=remove] void delete(DOMString property); + StyleValue? get(DOMString property); + sequence<StyleValue> getAll(DOMString property); + boolean has(DOMString property); + [RaisesException] void set(DOMString property, (StyleValue or sequence<StyleValue> or DOMString) value); + iterable<DOMString, (StyleValue or sequence<StyleValue>)>; + sequence<DOMString> getProperties(); +};
diff --git a/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp b/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp index 8cebdbf..67ae3a2 100644 --- a/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp +++ b/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp
@@ -207,7 +207,8 @@ void ScopedStyleResolver::addTreeBoundaryCrossingRules(const RuleSet& authorRules, CSSStyleSheet* parentStyleSheet, unsigned sheetIndex) { bool isDocumentScope = treeScope().rootNode().isDocumentNode(); - if (authorRules.deepCombinatorOrShadowPseudoRules().isEmpty() && (isDocumentScope || authorRules.shadowDistributedRules().isEmpty())) + if (authorRules.deepCombinatorOrShadowPseudoRules().isEmpty() + && (isDocumentScope || (authorRules.contentPseudoElementRules().isEmpty() && authorRules.slottedPseudoElementRules().isEmpty()))) return; if (!authorRules.deepCombinatorOrShadowPseudoRules().isEmpty()) @@ -216,8 +217,10 @@ OwnPtrWillBeRawPtr<RuleSet> ruleSetForScope = RuleSet::create(); addRules(ruleSetForScope.get(), authorRules.deepCombinatorOrShadowPseudoRules()); - if (!isDocumentScope) - addRules(ruleSetForScope.get(), authorRules.shadowDistributedRules()); + if (!isDocumentScope) { + addRules(ruleSetForScope.get(), authorRules.contentPseudoElementRules()); + addRules(ruleSetForScope.get(), authorRules.slottedPseudoElementRules()); + } if (!m_treeBoundaryCrossingRuleSet) { m_treeBoundaryCrossingRuleSet = adoptPtrWillBeNoop(new CSSStyleSheetRuleSubSet());
diff --git a/third_party/WebKit/Source/core/css/resolver/SharedStyleFinder.cpp b/third_party/WebKit/Source/core/css/resolver/SharedStyleFinder.cpp index 0f993d8..ddec353 100644 --- a/third_party/WebKit/Source/core/css/resolver/SharedStyleFinder.cpp +++ b/third_party/WebKit/Source/core/css/resolver/SharedStyleFinder.cpp
@@ -278,6 +278,11 @@ return false; } + // TODO(kochi): Write equivalent of sharingCandidateDistributedToSameInsertionPoint() + // for slotted elements. + if (element().assignedSlotForBinding()) + return false; + return true; }
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp b/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp index 8bec77e..4fae040 100644 --- a/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp +++ b/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp
@@ -73,6 +73,7 @@ #include "core/style/QuotesData.h" #include "core/style/SVGComputedStyle.h" #include "core/style/StyleGeneratedImage.h" +#include "core/style/StyleVariableData.h" #include "platform/fonts/FontDescription.h" #include "wtf/MathExtras.h" #include "wtf/StdLibExtras.h"
diff --git a/third_party/WebKit/Source/core/dom/ContainerNode.cpp b/third_party/WebKit/Source/core/dom/ContainerNode.cpp index 588fdcb..2fdfb8e 100644 --- a/third_party/WebKit/Source/core/dom/ContainerNode.cpp +++ b/third_party/WebKit/Source/core/dom/ContainerNode.cpp
@@ -1436,9 +1436,6 @@ PassRefPtrWillBeRawPtr<TagCollection> ContainerNode::getElementsByTagName(const AtomicString& localName) { - if (localName.isNull()) - return nullptr; - if (document().isHTMLDocument()) return ensureCachedCollection<HTMLTagCollection>(HTMLTagCollectionType, localName); return ensureCachedCollection<TagCollection>(TagCollectionType, localName); @@ -1446,9 +1443,6 @@ PassRefPtrWillBeRawPtr<TagCollection> ContainerNode::getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName) { - if (localName.isNull()) - return nullptr; - if (namespaceURI == starAtom) return getElementsByTagName(localName);
diff --git a/third_party/WebKit/Source/core/dom/DOMDataView.h b/third_party/WebKit/Source/core/dom/DOMDataView.h index 7e5d4b1..2b54c45 100644 --- a/third_party/WebKit/Source/core/dom/DOMDataView.h +++ b/third_party/WebKit/Source/core/dom/DOMDataView.h
@@ -5,11 +5,12 @@ #ifndef DOMDataView_h #define DOMDataView_h +#include "core/CoreExport.h" #include "core/dom/DOMArrayBufferView.h" namespace blink { -class DOMDataView final : public DOMArrayBufferView { +class CORE_EXPORT DOMDataView final : public DOMArrayBufferView { DEFINE_WRAPPERTYPEINFO(); public: typedef char ValueType;
diff --git a/third_party/WebKit/Source/core/editing/VisiblePositionTest.cpp b/third_party/WebKit/Source/core/editing/VisiblePositionTest.cpp index d6e2878..5990ff3 100644 --- a/third_party/WebKit/Source/core/editing/VisiblePositionTest.cpp +++ b/third_party/WebKit/Source/core/editing/VisiblePositionTest.cpp
@@ -12,7 +12,7 @@ class VisiblePositionTest : public EditingTestBase { }; -TEST_F(VisiblePositionTest, ShadowDistributedNodes) +TEST_F(VisiblePositionTest, ShadowV0DistributedNodes) { const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</b>33</p>"; const char* shadowContent = "<a><span id='s4'>44</span><content select=#two></content><span id='s5'>55</span><content select=#one></content><span id='s6'>66</span></a>";
diff --git a/third_party/WebKit/Source/core/editing/VisibleSelectionTest.cpp b/third_party/WebKit/Source/core/editing/VisibleSelectionTest.cpp index f2389234..c747e617 100644 --- a/third_party/WebKit/Source/core/editing/VisibleSelectionTest.cpp +++ b/third_party/WebKit/Source/core/editing/VisibleSelectionTest.cpp
@@ -187,7 +187,7 @@ EXPECT_EQ(PositionInComposedTree(six->firstChild(), 2), selectionInComposedTree.end()); } -TEST_F(VisibleSelectionTest, ShadowDistributedNodes) +TEST_F(VisibleSelectionTest, ShadowV0DistributedNodes) { const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</b>33</p>"; const char* shadowContent = "<a><span id='s4'>44</span><content select=#two></content><span id='s5'>55</span><content select=#one></content><span id='s6'>66</span></a>";
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp index 36f4570..9706da3 100644 --- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp +++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
@@ -239,7 +239,7 @@ // iteration, instead of using m_needsAnotherNewline. Node* lastChild = Strategy::lastChild(*m_node); Node* baseNode = lastChild ? lastChild : m_node.get(); - emitCharacter('\n', Strategy::parent(*baseNode), baseNode, 1, 1); + spliceBuffer('\n', Strategy::parent(*baseNode), baseNode, 1, 1); m_needsAnotherNewline = false; return; } @@ -460,11 +460,11 @@ if (m_lastTextNodeEndedWithCollapsedSpace && hasVisibleTextNode(layoutObject)) { if (m_behavior & TextIteratorCollapseTrailingSpace) { if (runStart > 0 && str[runStart - 1] == ' ') { - emitCharacter(spaceCharacter, textNode, 0, runStart, runStart); + spliceBuffer(spaceCharacter, textNode, 0, runStart, runStart); return false; } } else { - emitCharacter(spaceCharacter, textNode, 0, runStart, runStart); + spliceBuffer(spaceCharacter, textNode, 0, runStart, runStart); return false; } } @@ -549,7 +549,7 @@ --spaceRunStart; emitText(m_node, layoutObject, spaceRunStart, spaceRunStart + 1); } else { - emitCharacter(spaceCharacter, m_node, 0, runStart, runStart); + spliceBuffer(spaceCharacter, m_node, 0, runStart, runStart); } return; } @@ -581,7 +581,7 @@ // or a run of characters that does not include a newline. // This effectively translates newlines to spaces without copying the text. if (str[runStart] == '\n') { - emitCharacter(spaceCharacter, m_node, 0, runStart, runStart + 1); + spliceBuffer(spaceCharacter, m_node, 0, runStart, runStart + 1); m_offset = runStart + 1; } else { size_t subrunEnd = str.find('\n', runStart); @@ -674,7 +674,7 @@ return false; if (emitsObjectReplacementCharacter()) { - emitCharacter(objectReplacementCharacter, Strategy::parent(*m_node), m_node, 0, 1); + spliceBuffer(objectReplacementCharacter, Strategy::parent(*m_node), m_node, 0, 1); return true; } @@ -682,12 +682,12 @@ if (m_lastTextNode) { String str = m_lastTextNode->layoutObject()->text(); if (m_lastTextNodeEndedWithCollapsedSpace && m_offset > 0 && str[m_offset - 1] == ' ') { - emitCharacter(spaceCharacter, Strategy::parent(*m_lastTextNode), m_lastTextNode, 1, 1); + spliceBuffer(spaceCharacter, Strategy::parent(*m_lastTextNode), m_lastTextNode, 1, 1); return false; } } } else if (m_lastTextNodeEndedWithCollapsedSpace) { - emitCharacter(spaceCharacter, Strategy::parent(*m_lastTextNode), m_lastTextNode, 1, 1); + spliceBuffer(spaceCharacter, Strategy::parent(*m_lastTextNode), m_lastTextNode, 1, 1); return false; } @@ -700,7 +700,7 @@ // We want replaced elements to behave like punctuation for boundary // finding, and to simply take up space for the selection preservation // code in moveParagraphs, so we use a comma. - emitCharacter(',', Strategy::parent(*m_node), m_node, 0, 1); + spliceBuffer(',', Strategy::parent(*m_node), m_node, 0, 1); return true; } @@ -918,13 +918,13 @@ // before encountering shouldRepresentNodeOffsetZero()s worse case behavior. if (shouldEmitTabBeforeNode(m_node)) { if (shouldRepresentNodeOffsetZero()) - emitCharacter('\t', Strategy::parent(*m_node), m_node, 0, 0); + spliceBuffer('\t', Strategy::parent(*m_node), m_node, 0, 0); } else if (shouldEmitNewlineBeforeNode(*m_node)) { if (shouldRepresentNodeOffsetZero()) - emitCharacter('\n', Strategy::parent(*m_node), m_node, 0, 0); + spliceBuffer('\n', Strategy::parent(*m_node), m_node, 0, 0); } else if (shouldEmitSpaceBeforeAndAfterNode(m_node)) { if (shouldRepresentNodeOffsetZero()) - emitCharacter(spaceCharacter, Strategy::parent(*m_node), m_node, 0, 0); + spliceBuffer(spaceCharacter, Strategy::parent(*m_node), m_node, 0, 0); } } @@ -933,9 +933,9 @@ bool TextIteratorAlgorithm<Strategy>::handleNonTextNode() { if (shouldEmitNewlineForNode(m_node, emitsOriginalText())) - emitCharacter('\n', Strategy::parent(*m_node), m_node, 0, 1); + spliceBuffer('\n', Strategy::parent(*m_node), m_node, 0, 1); else if (emitsCharactersBetweenAllVisiblePositions() && m_node->layoutObject() && m_node->layoutObject()->isHR()) - emitCharacter(spaceCharacter, Strategy::parent(*m_node), m_node, 0, 1); + spliceBuffer(spaceCharacter, Strategy::parent(*m_node), m_node, 0, 1); else representNodeOffsetZero(); @@ -969,28 +969,28 @@ // contain a VisiblePosition when doing selection preservation. if (m_textState.lastCharacter() != '\n') { // insert a newline with a position following this block's contents. - emitCharacter(newlineCharacter, Strategy::parent(*baseNode), baseNode, 1, 1); + spliceBuffer(newlineCharacter, Strategy::parent(*baseNode), baseNode, 1, 1); // remember whether to later add a newline for the current node ASSERT(!m_needsAnotherNewline); m_needsAnotherNewline = addNewline; } else if (addNewline) { // insert a newline with a position following this block's contents. - emitCharacter(newlineCharacter, Strategy::parent(*baseNode), baseNode, 1, 1); + spliceBuffer(newlineCharacter, Strategy::parent(*baseNode), baseNode, 1, 1); } } // If nothing was emitted, see if we need to emit a space. if (!m_textState.positionNode() && shouldEmitSpaceBeforeAndAfterNode(m_node)) - emitCharacter(spaceCharacter, Strategy::parent(*baseNode), baseNode, 1, 1); + spliceBuffer(spaceCharacter, Strategy::parent(*baseNode), baseNode, 1, 1); } template<typename Strategy> -void TextIteratorAlgorithm<Strategy>::emitCharacter(UChar c, Node* textNode, Node* offsetBaseNode, int textStartOffset, int textEndOffset) +void TextIteratorAlgorithm<Strategy>::spliceBuffer(UChar c, Node* textNode, Node* offsetBaseNode, int textStartOffset, int textEndOffset) { // Since m_lastTextNodeEndedWithCollapsedSpace seems better placed in - // TextIterator, but is always reset when we call emitCharacter, we - // wrap TextIteratorTextState::emitCharacter() with this function. - m_textState.emitCharacter(c, textNode, offsetBaseNode, textStartOffset, textEndOffset); + // TextIterator, but is always reset when we call spliceBuffer, we + // wrap TextIteratorTextState::spliceBuffer() with this function. + m_textState.spliceBuffer(c, textNode, offsetBaseNode, textStartOffset, textEndOffset); m_lastTextNodeEndedWithCollapsedSpace = false; } @@ -998,8 +998,8 @@ void TextIteratorAlgorithm<Strategy>::emitText(Node* textNode, LayoutText* layoutObject, int textStartOffset, int textEndOffset) { // Since m_lastTextNodeEndedWithCollapsedSpace seems better placed in - // TextIterator, but is always reset when we call emitCharacter, we - // wrap TextIteratorTextState::emitCharacter() with this function. + // TextIterator, but is always reset when we call spliceBuffer, we + // wrap TextIteratorTextState::spliceBuffer() with this function. m_textState.emitText(textNode, layoutObject, textStartOffset, textEndOffset); m_lastTextNodeEndedWithCollapsedSpace = false; }
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIterator.h b/third_party/WebKit/Source/core/editing/iterators/TextIterator.h index a6de4a6..7e3ca29 100644 --- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.h +++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.h
@@ -121,7 +121,7 @@ bool handleNonTextNode(); void handleTextBox(); void handleTextNodeFirstLetter(LayoutTextFragment*); - void emitCharacter(UChar, Node* textNode, Node* offsetBaseNode, int textStartOffset, int textEndOffset); + void spliceBuffer(UChar, Node* textNode, Node* offsetBaseNode, int textStartOffset, int textEndOffset); void emitText(Node* textNode, LayoutText* layoutObject, int textStartOffset, int textEndOffset); // Used by selection preservation code. There should be one character emitted between every VisiblePosition
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.cpp index 712ac63..42cfafb 100644 --- a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.cpp +++ b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.cpp
@@ -111,7 +111,7 @@ m_positionOffsetBaseNode = nullptr; } -void TextIteratorTextState::emitCharacter(UChar c, Node* textNode, Node* offsetBaseNode, int textStartOffset, int textEndOffset) +void TextIteratorTextState::spliceBuffer(UChar c, Node* textNode, Node* offsetBaseNode, int textStartOffset, int textEndOffset) { ASSERT(textNode); m_hasEmitted = true;
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.h b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.h index c09db6e..3c9a502 100644 --- a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.h +++ b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.h
@@ -46,7 +46,7 @@ String substring(unsigned position, unsigned length) const; void appendTextToStringBuilder(StringBuilder&, unsigned position = 0, unsigned maxLength = UINT_MAX) const; - void emitCharacter(UChar, Node* textNode, Node* offsetBaseNode, int textStartOffset, int textEndOffset); + void spliceBuffer(UChar, Node* textNode, Node* offsetBaseNode, int textStartOffset, int textEndOffset); void emitText(Node* textNode, LayoutText* layoutObject, int textStartOffset, int textEndOffset); void emitAltText(Node*); void updateForReplacedElement(Node* baseNode);
diff --git a/third_party/WebKit/Source/core/events/Event.idl b/third_party/WebKit/Source/core/events/Event.idl index 1db19f6..0616b41 100644 --- a/third_party/WebKit/Source/core/events/Event.idl +++ b/third_party/WebKit/Source/core/events/Event.idl
@@ -64,7 +64,7 @@ // Shadow DOM // https://w3c.github.io/webcomponents/spec/shadow/#extensions-to-event-interface [MeasureAs=EventPath, CallWith=ScriptState] readonly attribute EventTarget[] path; - + [RuntimeEnabled=ShadowDOMV1, ImplementedAs=path, MeasureAs=EventDeepPath, CallWith=ScriptState] readonly attribute EventTarget[] deepPath; // Non-standard APIs const unsigned short MOUSEDOWN = 1; const unsigned short MOUSEUP = 2;
diff --git a/third_party/WebKit/Source/core/events/EventPath.cpp b/third_party/WebKit/Source/core/events/EventPath.cpp index b958b890..54175ab 100644 --- a/third_party/WebKit/Source/core/events/EventPath.cpp +++ b/third_party/WebKit/Source/core/events/EventPath.cpp
@@ -34,6 +34,7 @@ #include "core/dom/shadow/ShadowRoot.h" #include "core/events/TouchEvent.h" #include "core/events/TouchEventContext.h" +#include "core/html/HTMLSlotElement.h" namespace blink { @@ -127,6 +128,13 @@ current = insertionPoints.last(); continue; } + if (current->isChildOfV1ShadowHost()) { + if (HTMLSlotElement* slot = current->assignedSlot()) { + current = slot; + nodesInPath.append(current); + continue; + } + } if (current->isShadowRoot()) { if (m_event && shouldStopAtShadowRoot(*m_event, *toShadowRoot(current), *m_node)) break;
diff --git a/third_party/WebKit/Source/core/frame/UseCounter.h b/third_party/WebKit/Source/core/frame/UseCounter.h index f8116b4..cefcafd 100644 --- a/third_party/WebKit/Source/core/frame/UseCounter.h +++ b/third_party/WebKit/Source/core/frame/UseCounter.h
@@ -975,6 +975,7 @@ NonSecureSharedWorkerAccessedFromSecureContext = 1120, SecureSharedWorkerAccessedFromNonSecureContext = 1121, NonCSSStyleSheetType = 1122, + EventDeepPath = 1123, // Add new features immediately above this line. Don't change assigned // numbers of any item, and don't reuse removed slots.
diff --git a/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp b/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp index 01508aac6..7969585 100644 --- a/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
@@ -465,6 +465,7 @@ visitor->trace(m_linkLoader); visitor->trace(m_relList); HTMLElement::trace(visitor); + LinkLoaderClient::trace(visitor); DOMSettableTokenListObserver::trace(visitor); } @@ -746,7 +747,7 @@ // Don't hold up layout tree construction and script execution on stylesheets // that are not needed for the layout at the moment. - bool blocking = mediaQueryMatches && !m_owner->isAlternate(); + bool blocking = mediaQueryMatches && !m_owner->isAlternate() && m_owner->isCreatedByParser(); addPendingSheet(blocking ? Blocking : NonBlocking); // Load stylesheets that are not needed for the layout immediately with low priority.
diff --git a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp index 0b439d85..715dd85 100644 --- a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
@@ -1984,9 +1984,9 @@ m_popupIsVisible = true; LayoutMenuList* menuList = toLayoutMenuList(layoutObject()); + FloatQuad quad(menuList->localToAbsoluteQuad(FloatQuad(menuList->borderBoundingBox()))); IntSize size = pixelSnappedIntRect(menuList->frameRect()).size(); - // TODO(tkent): Remove show() arguments. They are unused. - m_popup->show(FloatQuad(), size, optionToListIndex(selectedIndex())); + m_popup->show(quad, size, optionToListIndex(selectedIndex())); if (AXObjectCache* cache = document().existingAXObjectCache()) cache->didShowMenuListPopup(menuList); }
diff --git a/third_party/WebKit/Source/core/inspector/AsyncCallTracker.cpp b/third_party/WebKit/Source/core/inspector/AsyncCallTracker.cpp index 384a664..eab47937 100644 --- a/third_party/WebKit/Source/core/inspector/AsyncCallTracker.cpp +++ b/third_party/WebKit/Source/core/inspector/AsyncCallTracker.cpp
@@ -35,7 +35,7 @@ #include "core/dom/ExecutionContextTask.h" #include "core/events/Event.h" #include "core/events/EventTarget.h" -#include "core/inspector/v8/AsyncOperationMap.h" +#include "core/inspector/AsyncOperationMap.h" #include "core/xmlhttprequest/XMLHttpRequest.h" #include "core/xmlhttprequest/XMLHttpRequestUpload.h" #include "platform/ScriptForbiddenScope.h"
diff --git a/third_party/WebKit/Source/core/inspector/v8/AsyncOperationMap.h b/third_party/WebKit/Source/core/inspector/AsyncOperationMap.h similarity index 100% rename from third_party/WebKit/Source/core/inspector/v8/AsyncOperationMap.h rename to third_party/WebKit/Source/core/inspector/AsyncOperationMap.h
diff --git a/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp index e49567e..3ef64c48 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp
@@ -76,6 +76,7 @@ #include "core/page/Page.h" #include "core/style/StyleGeneratedImage.h" #include "core/style/StyleImage.h" +#include "core/style/StyleVariableData.h" #include "core/svg/SVGElement.h" #include "platform/fonts/Font.h" #include "platform/fonts/FontCache.h"
diff --git a/third_party/WebKit/Source/core/inspector/v8/V8AsyncCallTracker.cpp b/third_party/WebKit/Source/core/inspector/v8/V8AsyncCallTracker.cpp index 91b2791..d2092195 100644 --- a/third_party/WebKit/Source/core/inspector/v8/V8AsyncCallTracker.cpp +++ b/third_party/WebKit/Source/core/inspector/v8/V8AsyncCallTracker.cpp
@@ -5,7 +5,6 @@ #include "core/inspector/v8/V8AsyncCallTracker.h" #include "bindings/core/v8/V8PerContextData.h" -#include "core/inspector/v8/AsyncOperationMap.h" #include "platform/heap/Handle.h" #include "wtf/HashMap.h" #include "wtf/text/StringBuilder.h" @@ -22,35 +21,6 @@ } -class V8AsyncCallTracker::V8ContextAsyncOperations final : public NoBaseWillBeGarbageCollectedFinalized<V8AsyncCallTracker::V8ContextAsyncOperations> { - WTF_MAKE_NONCOPYABLE(V8ContextAsyncOperations); -public: - explicit V8ContextAsyncOperations(V8DebuggerAgentImpl* debuggerAgent) - : m_v8AsyncOperations(debuggerAgent) - { - } - - ~V8ContextAsyncOperations() - { - ASSERT(m_v8AsyncOperations.hasBeenDisposed()); - } - - void dispose() - { - // FIXME: get rid of the dispose method and this class altogether once AsyncOperationMap is always allocated on C++ heap. - m_v8AsyncOperations.dispose(); - } - - DEFINE_INLINE_TRACE() - { -#if ENABLE(OILPAN) - visitor->trace(m_v8AsyncOperations); -#endif - } - - AsyncOperationMap<String> m_v8AsyncOperations; -}; - static String makeV8AsyncTaskUniqueId(const String& eventName, int id) { StringBuilder builder; @@ -69,13 +39,6 @@ ASSERT(m_contextAsyncOperationMap.isEmpty()); } -DEFINE_TRACE(V8AsyncCallTracker) -{ -#if ENABLE(OILPAN) - visitor->trace(m_contextAsyncOperationMap); -#endif -} - void V8AsyncCallTracker::asyncCallTrackingStateChanged(bool) { } @@ -84,13 +47,14 @@ { for (auto& it : m_contextAsyncOperationMap) { it.key->removeObserver(this); - it.value->dispose(); + completeOperations(it.value.get()); } m_contextAsyncOperationMap.clear(); } void V8AsyncCallTracker::willDisposeScriptState(ScriptState* state) { + completeOperations(m_contextAsyncOperationMap.get(state)); m_contextAsyncOperationMap.remove(state); } @@ -116,8 +80,8 @@ return; V8ContextAsyncOperations* contextCallChains = m_contextAsyncOperationMap.get(state); if (!contextCallChains) - contextCallChains = m_contextAsyncOperationMap.set(state, adoptPtrWillBeNoop(new V8ContextAsyncOperations(m_debuggerAgent))).storedValue->value.get(); - contextCallChains->m_v8AsyncOperations.set(makeV8AsyncTaskUniqueId(eventName, id), operationId); + contextCallChains = m_contextAsyncOperationMap.set(state, adoptPtr(new V8ContextAsyncOperations())).storedValue->value.get(); + contextCallChains->set(makeV8AsyncTaskUniqueId(eventName, id), operationId); } void V8AsyncCallTracker::willHandleV8AsyncTask(ScriptState* state, const String& eventName, int id) @@ -126,11 +90,21 @@ ASSERT(m_debuggerAgent->trackingAsyncCalls()); if (V8ContextAsyncOperations* contextCallChains = m_contextAsyncOperationMap.get(state)) { String taskId = makeV8AsyncTaskUniqueId(eventName, id); - m_debuggerAgent->traceAsyncCallbackStarting(contextCallChains->m_v8AsyncOperations.get(taskId)); - contextCallChains->m_v8AsyncOperations.remove(taskId); + int operationId = contextCallChains->get(taskId); + m_debuggerAgent->traceAsyncCallbackStarting(operationId); + m_debuggerAgent->traceAsyncOperationCompleted(operationId); + contextCallChains->remove(taskId); } else { m_debuggerAgent->traceAsyncCallbackStarting(V8DebuggerAgentImpl::unknownAsyncOperationId); } } +void V8AsyncCallTracker::completeOperations(V8ContextAsyncOperations* contextCallChains) +{ + if (!contextCallChains) + return; + for (auto& it : *contextCallChains) + m_debuggerAgent->traceAsyncOperationCompleted(it.value); +} + } // namespace blink
diff --git a/third_party/WebKit/Source/core/inspector/v8/V8AsyncCallTracker.h b/third_party/WebKit/Source/core/inspector/v8/V8AsyncCallTracker.h index 35940e21..3effdfc1 100644 --- a/third_party/WebKit/Source/core/inspector/v8/V8AsyncCallTracker.h +++ b/third_party/WebKit/Source/core/inspector/v8/V8AsyncCallTracker.h
@@ -16,17 +16,16 @@ class ScriptState; -class V8AsyncCallTracker final : public NoBaseWillBeGarbageCollectedFinalized<V8AsyncCallTracker>, public ScriptState::Observer { +class V8AsyncCallTracker final : public ScriptState::Observer { WTF_MAKE_NONCOPYABLE(V8AsyncCallTracker); - USING_FAST_MALLOC_WILL_BE_REMOVED(V8AsyncCallTracker); + USING_FAST_MALLOC(V8AsyncCallTracker); public: - static PassOwnPtrWillBeRawPtr<V8AsyncCallTracker> create(V8DebuggerAgentImpl* debuggerAgent) + static PassOwnPtr<V8AsyncCallTracker> create(V8DebuggerAgentImpl* debuggerAgent) { - return adoptPtrWillBeNoop(new V8AsyncCallTracker(debuggerAgent)); + return adoptPtr(new V8AsyncCallTracker(debuggerAgent)); } ~V8AsyncCallTracker(); - DECLARE_TRACE(); void asyncCallTrackingStateChanged(bool tracking); void resetAsyncOperations(); @@ -38,12 +37,13 @@ private: explicit V8AsyncCallTracker(V8DebuggerAgentImpl*); + using V8ContextAsyncOperations = HashMap<String, int>; void didEnqueueV8AsyncTask(ScriptState*, const String& eventName, int id); void willHandleV8AsyncTask(ScriptState*, const String& eventName, int id); + void completeOperations(V8ContextAsyncOperations* contextCallChains); - class V8ContextAsyncOperations; - WillBeHeapHashMap<RefPtr<ScriptState>, OwnPtrWillBeMember<V8ContextAsyncOperations>> m_contextAsyncOperationMap; + HashMap<RefPtr<ScriptState>, OwnPtr<V8ContextAsyncOperations>> m_contextAsyncOperationMap; V8DebuggerAgentImpl* m_debuggerAgent; };
diff --git a/third_party/WebKit/Source/core/inspector/v8/V8DebuggerAgentImpl.h b/third_party/WebKit/Source/core/inspector/v8/V8DebuggerAgentImpl.h index c9a3fef9..f87158c 100644 --- a/third_party/WebKit/Source/core/inspector/v8/V8DebuggerAgentImpl.h +++ b/third_party/WebKit/Source/core/inspector/v8/V8DebuggerAgentImpl.h
@@ -231,7 +231,7 @@ OwnPtr<ScriptRegexp> m_cachedSkipStackRegExp; unsigned m_cachedSkipStackGeneration; // This field must be destroyed before the listeners set above. - OwnPtrWillBePersistent<V8AsyncCallTracker> m_v8AsyncCallTracker; + OwnPtr<V8AsyncCallTracker> m_v8AsyncCallTracker; OwnPtr<PromiseTracker> m_promiseTracker; using AsyncOperationIdToAsyncCallChain = HashMap<int, RefPtr<AsyncCallChain>>;
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.h b/third_party/WebKit/Source/core/layout/LayoutObject.h index 76127a2..dbc9fcf 100644 --- a/third_party/WebKit/Source/core/layout/LayoutObject.h +++ b/third_party/WebKit/Source/core/layout/LayoutObject.h
@@ -741,7 +741,11 @@ // :first-letter pseudo elements for which their parent node is returned. Node* generatingNode() const { return isPseudoElement() ? node()->parentOrShadowHostNode() : node(); } - Document& document() const { return m_node->document(); } + Document& document() const + { + ASSERT(m_node || parent()); // crbug.com/402056 + return m_node ? m_node->document() : parent()->document(); + } LocalFrame* frame() const { return document().frame(); } virtual LayoutMultiColumnSpannerPlaceholder* spannerPlaceholder() const { return nullptr; }
diff --git a/third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp b/third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp index a86df4b..b8619f2 100644 --- a/third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp
@@ -165,7 +165,6 @@ if (innerEditorLayoutObject) innerEditorSize = innerEditorLayoutObject->size(); placeholderBox->mutableStyleRef().setWidth(Length(innerEditorSize.width() - placeholderBox->borderAndPaddingWidth(), Fixed)); - placeholderBox->mutableStyleRef().setHeight(Length(innerEditorSize.height() - placeholderBox->borderAndPaddingHeight(), Fixed)); bool neededLayout = placeholderBox->needsLayout(); placeholderBox->layoutIfNeeded(); LayoutPoint textOffset; @@ -175,6 +174,16 @@ textOffset += toLayoutSize(editingViewPortElement()->layoutBox()->location()); if (containerLayoutObject) textOffset += toLayoutSize(containerLayoutObject->location()); + if (innerEditorLayoutObject) { + // We use inlineBlockBaseline() for innerEditor because it has no + // inline boxes when we show the placeholder. + int innerEditorBaseline = innerEditorLayoutObject->inlineBlockBaseline(HorizontalLine); + // We use firstLineBoxBaseline() for placeholder. + // TODO(tkent): It's inconsistent with innerEditorBaseline. However + // placeholderBox->inlineBlockBase() is unexpectedly larger. + int placeholderBaseline = placeholderBox->firstLineBoxBaseline(); + textOffset += LayoutSize(0, innerEditorBaseline - placeholderBaseline); + } placeholderBox->setLocation(textOffset); // The placeholder gets layout last, after the parent text control and its other children,
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp index 5243c2c1..5c1719a 100644 --- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp +++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp
@@ -58,14 +58,6 @@ return newString.release(); } -static float squaredDistanceToClosestPoint(const FloatRect& rect, const FloatPoint& point) -{ - FloatPoint closestPoint; - closestPoint.setX(std::max(std::min(point.x(), rect.maxX()), rect.x())); - closestPoint.setY(std::max(std::min(point.y(), rect.maxY()), rect.y())); - return (point - closestPoint).diagonalLengthSquared(); -} - LayoutSVGInlineText::LayoutSVGInlineText(Node* n, PassRefPtr<StringImpl> string) : LayoutText(n, applySVGWhitespaceRules(string, false)) , m_scalingFactor(1) @@ -187,7 +179,7 @@ float distance = 0; if (!fragmentRect.contains(absolutePoint)) - distance = squaredDistanceToClosestPoint(fragmentRect, absolutePoint); + distance = fragmentRect.squaredDistanceTo(absolutePoint); if (distance <= closestDistance) { closestDistance = distance;
diff --git a/third_party/WebKit/Source/core/loader/LinkLoader.cpp b/third_party/WebKit/Source/core/loader/LinkLoader.cpp index 0c7f28e..680a5ab 100644 --- a/third_party/WebKit/Source/core/loader/LinkLoader.cpp +++ b/third_party/WebKit/Source/core/loader/LinkLoader.cpp
@@ -325,6 +325,7 @@ DEFINE_TRACE(LinkLoader) { + visitor->trace(m_client); visitor->trace(m_prerender); visitor->trace(m_linkPreloadResourceClient); ResourceOwner<Resource, ResourceClient>::trace(visitor);
diff --git a/third_party/WebKit/Source/core/loader/LinkLoader.h b/third_party/WebKit/Source/core/loader/LinkLoader.h index 56012a74..5d08d52 100644 --- a/third_party/WebKit/Source/core/loader/LinkLoader.h +++ b/third_party/WebKit/Source/core/loader/LinkLoader.h
@@ -87,7 +87,7 @@ void linkLoadingErrorTimerFired(Timer<LinkLoader>*); void createLinkPreloadResourceClient(ResourcePtr<Resource>); - LinkLoaderClient* m_client; + RawPtrWillBeMember<LinkLoaderClient> m_client; Timer<LinkLoader> m_linkLoadTimer; Timer<LinkLoader> m_linkLoadingErrorTimer;
diff --git a/third_party/WebKit/Source/core/loader/LinkLoaderClient.h b/third_party/WebKit/Source/core/loader/LinkLoaderClient.h index 0cac2b7..988a9b5e 100644 --- a/third_party/WebKit/Source/core/loader/LinkLoaderClient.h +++ b/third_party/WebKit/Source/core/loader/LinkLoaderClient.h
@@ -35,9 +35,10 @@ namespace blink { -class CORE_EXPORT LinkLoaderClient { +class CORE_EXPORT LinkLoaderClient : public WillBeGarbageCollectedMixin { public: virtual ~LinkLoaderClient() { } + DEFINE_INLINE_VIRTUAL_TRACE() { } virtual bool shouldLoadLink() = 0;
diff --git a/third_party/WebKit/Source/core/loader/LinkLoaderTest.cpp b/third_party/WebKit/Source/core/loader/LinkLoaderTest.cpp index 4bfe9a8..bbda6d0 100644 --- a/third_party/WebKit/Source/core/loader/LinkLoaderTest.cpp +++ b/third_party/WebKit/Source/core/loader/LinkLoaderTest.cpp
@@ -17,13 +17,16 @@ namespace blink { -class MockLinkLoaderClient : public LinkLoaderClient { +class MockLinkLoaderClient final : public NoBaseWillBeGarbageCollectedFinalized<MockLinkLoaderClient>, public LinkLoaderClient { + WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MockLinkLoaderClient); public: - MockLinkLoaderClient(bool shouldLoad) - : m_shouldLoad(shouldLoad) + static PassOwnPtrWillBeRawPtr<MockLinkLoaderClient> create(bool shouldLoad) { + return adoptPtrWillBeNoop(new MockLinkLoaderClient(shouldLoad)); } + DEFINE_INLINE_VIRTUAL_TRACE() { LinkLoaderClient::trace(visitor); } + bool shouldLoadLink() override { return m_shouldLoad; @@ -37,6 +40,11 @@ void didSendDOMContentLoadedForLinkPrerender() override {} private: + explicit MockLinkLoaderClient(bool shouldLoad) + : m_shouldLoad(shouldLoad) + { + } + bool m_shouldLoad; }; @@ -101,8 +109,8 @@ for (const auto& testCase : cases) { OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); dummyPageHolder->frame().settings()->setScriptEnabled(true); - MockLinkLoaderClient loaderClient(testCase.shouldLoad); - OwnPtrWillBeRawPtr<LinkLoader> loader = LinkLoader::create(&loaderClient); + OwnPtrWillBePersistent<MockLinkLoaderClient> loaderClient = MockLinkLoaderClient::create(testCase.shouldLoad); + OwnPtrWillBeRawPtr<LinkLoader> loader = LinkLoader::create(loaderClient.get()); KURL hrefURL = KURL(KURL(), testCase.href); loader->loadLink(LinkRelAttribute("preload"), CrossOriginAttributeNotSet, @@ -148,8 +156,8 @@ for (const auto& testCase : cases) { OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); dummyPageHolder->document().settings()->setDNSPrefetchingEnabled(true); - MockLinkLoaderClient loaderClient(testCase.shouldLoad); - OwnPtrWillBeRawPtr<LinkLoader> loader = LinkLoader::create(&loaderClient); + OwnPtrWillBePersistent<MockLinkLoaderClient> loaderClient = MockLinkLoaderClient::create(testCase.shouldLoad); + OwnPtrWillBeRawPtr<LinkLoader> loader = LinkLoader::create(loaderClient.get()); KURL hrefURL = KURL(KURL(ParsedURLStringTag(), String("http://example.com")), testCase.href); NetworkHintsMock networkHints; loader->loadLink(LinkRelAttribute("dns-prefetch"), @@ -182,8 +190,8 @@ // Test the cases with a single header for (const auto& testCase : cases) { OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); - MockLinkLoaderClient loaderClient(testCase.shouldLoad); - OwnPtrWillBeRawPtr<LinkLoader> loader = LinkLoader::create(&loaderClient); + OwnPtrWillBePersistent<MockLinkLoaderClient> loaderClient = MockLinkLoaderClient::create(testCase.shouldLoad); + OwnPtrWillBeRawPtr<LinkLoader> loader = LinkLoader::create(loaderClient.get()); KURL hrefURL = KURL(KURL(ParsedURLStringTag(), String("http://example.com")), testCase.href); NetworkHintsMock networkHints; loader->loadLink(LinkRelAttribute("preconnect"),
diff --git a/third_party/WebKit/Source/core/style/ComputedStyle.cpp b/third_party/WebKit/Source/core/style/ComputedStyle.cpp index 874e929..4cc2028 100644 --- a/third_party/WebKit/Source/core/style/ComputedStyle.cpp +++ b/third_party/WebKit/Source/core/style/ComputedStyle.cpp
@@ -35,6 +35,7 @@ #include "core/style/ShadowList.h" #include "core/style/StyleImage.h" #include "core/style/StyleInheritedData.h" +#include "core/style/StyleVariableData.h" #include "platform/LengthFunctions.h" #include "platform/RuntimeEnabledFeatures.h" #include "platform/fonts/Font.h"
diff --git a/third_party/WebKit/Source/core/style/ComputedStyle.h b/third_party/WebKit/Source/core/style/ComputedStyle.h index e44f182d..0d3b7b5a 100644 --- a/third_party/WebKit/Source/core/style/ComputedStyle.h +++ b/third_party/WebKit/Source/core/style/ComputedStyle.h
@@ -107,6 +107,7 @@ class AppliedTextDecoration; class BorderData; struct BorderEdge; +class CSSVariableData; class CounterContent; class Font; class FontMetrics;
diff --git a/third_party/WebKit/Source/core/style/StyleRareInheritedData.cpp b/third_party/WebKit/Source/core/style/StyleRareInheritedData.cpp index 06f477d..1c11543 100644 --- a/third_party/WebKit/Source/core/style/StyleRareInheritedData.cpp +++ b/third_party/WebKit/Source/core/style/StyleRareInheritedData.cpp
@@ -29,6 +29,7 @@ #include "core/style/QuotesData.h" #include "core/style/ShadowList.h" #include "core/style/StyleImage.h" +#include "core/style/StyleVariableData.h" namespace blink {
diff --git a/third_party/WebKit/Source/core/style/StyleRareInheritedData.h b/third_party/WebKit/Source/core/style/StyleRareInheritedData.h index 4b63722..e6ceeac 100644 --- a/third_party/WebKit/Source/core/style/StyleRareInheritedData.h +++ b/third_party/WebKit/Source/core/style/StyleRareInheritedData.h
@@ -28,7 +28,6 @@ #include "core/CoreExport.h" #include "core/css/StyleColor.h" #include "core/style/DataRef.h" -#include "core/style/StyleVariableData.h" #include "platform/Length.h" #include "platform/graphics/Color.h" #include "platform/heap/Handle.h" @@ -45,6 +44,7 @@ class QuotesData; class ShadowList; class StyleImage; +class StyleVariableData; typedef RefVector<AppliedTextDecoration> AppliedTextDecorationList; #if ENABLE(OILPAN)
diff --git a/third_party/WebKit/Source/devtools/front_end/externs.js b/third_party/WebKit/Source/devtools/front_end/externs.js index 773a9fd..93211c51 100644 --- a/third_party/WebKit/Source/devtools/front_end/externs.js +++ b/third_party/WebKit/Source/devtools/front_end/externs.js
@@ -171,6 +171,15 @@ */ Array.prototype.mergeOrdered = function(array, comparator) {} +/** + * @param {T} value + * @param {number} start + * @param {number=} end + * @this {!Array.<T>} + * @template T + */ +Array.prototype.fill = function(value, start, end) {} + // File System API /** * @constructor
diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineFlameChart.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineFlameChart.js index 552503a..dd9132cc 100644 --- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineFlameChart.js +++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineFlameChart.js
@@ -257,10 +257,19 @@ } /** + * @enum {symbol} + */ +WebInspector.TimelineFlameChartEntryType = { + Header: Symbol("Header"), + Frame: Symbol("Frame"), + Event: Symbol("Event"), +}; + +/** * @constructor * @extends {WebInspector.TimelineFlameChartDataProviderBase} * @param {!WebInspector.TimelineModel} model - * @param {?WebInspector.TimelineFrameModelBase} frameModel + * @param {!WebInspector.TimelineFrameModelBase} frameModel */ WebInspector.TimelineFlameChartDataProvider = function(model, frameModel) { @@ -282,8 +291,9 @@ */ entryTitle: function(entryIndex) { - var event = this._entryEvents[entryIndex]; - if (event) { + var entryType = this._entryType(entryIndex); + if (entryType === WebInspector.TimelineFlameChartEntryType.Event) { + var event = /** @type {!WebInspector.TracingModel.Event} */ (this._entryData[entryIndex]); if (event.phase === WebInspector.TracingModel.Phase.AsyncStepInto || event.phase === WebInspector.TracingModel.Phase.AsyncStepPast) return event.name + ":" + event.args["step"]; if (event._blackboxRoot) @@ -310,7 +320,7 @@ */ textColor: function(index) { - var event = this._entryEvents[index]; + var event = this._entryData[index]; if (event && event._blackboxRoot) return "#888"; else @@ -323,12 +333,14 @@ reset: function() { WebInspector.TimelineFlameChartDataProviderBase.prototype.reset.call(this); - /** @type {!Array.<!WebInspector.TracingModel.Event>} */ - this._entryEvents = []; - this._entryIndexToTitle = {}; + /** @type {!Array<!WebInspector.TracingModel.Event|!WebInspector.TimelineFrame>} */ + this._entryData = []; + /** @type {!Array<!WebInspector.TimelineFlameChartEntryType>} */ + this._entryTypeByLevel = []; + /** @type {!Array<string>} */ + this._entryIndexToTitle = []; /** @type {!Array.<!WebInspector.TimelineFlameChartMarker>} */ this._markers = []; - this._entryIndexToFrame = {}; this._asyncColorByCategory = {}; /** @type {!Map<string, boolean>} */ this._blackboxingURLCache = new Map(); @@ -349,11 +361,11 @@ this._minimumBoundary = this._model.minimumRecordTime(); this._timeSpan = this._model.isEmpty() ? 1000 : this._model.maximumRecordTime() - this._minimumBoundary; this._currentLevel = 0; - if (this._frameModel) - this._appendFrameBars(this._frameModel.frames()); + this._appendFrameBars(this._frameModel.frames()); this._appendThreadTimelineData(WebInspector.UIString("Main Thread"), this._model.mainThreadEvents(), this._model.mainThreadAsyncEvents()); if (Runtime.experiments.isEnabled("gpuTimeline")) this._appendGPUEvents(); + var threads = this._model.virtualThreads(); for (var i = 0; i < threads.length; i++) this._appendThreadTimelineData(threads[i].name, threads[i].events, threads[i].asyncEventsByGroup); @@ -420,7 +432,7 @@ e._blackboxRoot = true; } if (headerName) { - this._appendHeaderRecord(headerName, this._currentLevel++); + this._appendHeaderRecord(headerName); headerName = null; } @@ -432,6 +444,8 @@ if (e.endTime) openEvents.push(e); } + this._entryTypeByLevel.length = this._currentLevel + maxStackDepth; + this._entryTypeByLevel.fill(WebInspector.TimelineFlameChartEntryType.Event, this._currentLevel); this._currentLevel += maxStackDepth; }, @@ -468,38 +482,43 @@ var groups = Object.values(WebInspector.TimelineUIUtils.asyncEventGroups()); for (var groupIndex = 0; groupIndex < groups.length; ++groupIndex) { - var lastUsedTimeByLevel = []; var group = groups[groupIndex]; var events = asyncEvents.get(group); - if (!events) - continue; - var groupHeaderAppended = false; - for (var i = 0; i < events.length; ++i) { - var asyncEvent = events[i]; - if (!this._isVisible(asyncEvent)) - continue; - if (!groupHeaderAppended) { - this._appendHeaderRecord(group.title, this._currentLevel++); - groupHeaderAppended = true; - } - - var startTime = asyncEvent.startTime; - var level; - for (level = 0; level < lastUsedTimeByLevel.length && lastUsedTimeByLevel[level] > startTime; ++level) {} - this._appendAsyncEvent(asyncEvent, this._currentLevel + level); - lastUsedTimeByLevel[level] = asyncEvent.endTime; - } - this._currentLevel += lastUsedTimeByLevel.length; + if (events) + this._appendAsyncEventsGroup(group.title, events); } }, + /** + * @param {string} header + * @param {!Array<!WebInspector.TracingModel.AsyncEvent>} events + */ + _appendAsyncEventsGroup: function(header, events) + { + var lastUsedTimeByLevel = []; + var groupHeaderAppended = false; + for (var i = 0; i < events.length; ++i) { + var asyncEvent = events[i]; + if (!this._isVisible(asyncEvent)) + continue; + if (!groupHeaderAppended) { + this._appendHeaderRecord(header); + groupHeaderAppended = true; + } + var startTime = asyncEvent.startTime; + var level; + for (level = 0; level < lastUsedTimeByLevel.length && lastUsedTimeByLevel[level] > startTime; ++level) {} + this._appendAsyncEvent(asyncEvent, this._currentLevel + level); + lastUsedTimeByLevel[level] = asyncEvent.endTime; + } + this._entryTypeByLevel.length = this._currentLevel + lastUsedTimeByLevel.length; + this._entryTypeByLevel.fill(WebInspector.TimelineFlameChartEntryType.Event, this._currentLevel); + this._currentLevel += lastUsedTimeByLevel.length; + }, + _appendGPUEvents: function() { - function recordToEvent(record) - { - return record.traceEvent(); - } - if (this._appendSyncEvents(WebInspector.UIString("GPU"), this._model.gpuTasks().map(recordToEvent))) + if (this._appendSyncEvents(WebInspector.UIString("GPU"), this._model.gpuTasks().map(record => record.traceEvent()))) ++this._currentLevel; }, @@ -509,11 +528,21 @@ _appendFrameBars: function(frames) { var style = WebInspector.TimelineUIUtils.markerStyleForFrame(); - this._frameBarsLevel = this._currentLevel++; + this._entryTypeByLevel[this._currentLevel] = WebInspector.TimelineFlameChartEntryType.Frame; for (var i = 0; i < frames.length; ++i) { this._markers.push(new WebInspector.TimelineFlameChartMarker(frames[i].startTime, frames[i].startTime - this._model.minimumRecordTime(), style)); this._appendFrame(frames[i]); } + ++this._currentLevel; + }, + + /** + * @param {number} entryIndex + * @return {!WebInspector.TimelineFlameChartEntryType} + */ + _entryType: function(entryIndex) + { + return this._entryTypeByLevel[this._timelineData.entryLevels[entryIndex]]; }, /** @@ -523,11 +552,12 @@ */ prepareHighlightedEntryInfo: function(entryIndex) { - var event = this._entryEvents[entryIndex]; var time; var title; var warning; - if (event) { + var type = this._entryType(entryIndex); + if (type === WebInspector.TimelineFlameChartEntryType.Event) { + var event = /** @type {!WebInspector.TracingModel.Event} */ (this._entryData[entryIndex]); var totalTime = event.duration; var selfTime = event.selfTime; var /** @const */ eps = 1e-6; @@ -536,16 +566,16 @@ Number.millisToString(totalTime, true); title = this.entryTitle(entryIndex); warning = WebInspector.TimelineUIUtils.eventWarning(event); - } else { - var frame = this._entryIndexToFrame[entryIndex]; - if (!frame) - return null; + } else if (type === WebInspector.TimelineFlameChartEntryType.Frame) { + var frame = /** @type {!WebInspector.TimelineFrame} */ (this._entryData[entryIndex]); time = WebInspector.UIString("%s ~ %.0f\u2009fps", Number.preciseMillisToString(frame.duration, 1), (1000 / frame.duration)); title = frame.idle ? WebInspector.UIString("Idle Frame") : WebInspector.UIString("Frame"); if (frame.hasWarnings()) { warning = createElement("span"); warning.textContent = WebInspector.UIString("Long frame"); } + } else { + return null; } var value = createElement("div"); var root = WebInspector.createShadowRootWithCoreStyles(value, "timeline/timelineFlamechartPopover.css"); @@ -566,10 +596,11 @@ */ entryColor: function(entryIndex) { - var event = this._entryEvents[entryIndex]; - if (!event) - return this._entryIndexToFrame[entryIndex] ? "white" : "#aaa"; - if (WebInspector.TracingModel.isAsyncPhase(event.phase)) { + var type = this._entryType(entryIndex); + if (type === WebInspector.TimelineFlameChartEntryType.Event) { + var event = /** @type {!WebInspector.TracingModel.Event} */ (this._entryData[entryIndex]); + if (!WebInspector.TracingModel.isAsyncPhase(event.phase)) + return WebInspector.TimelineUIUtils.eventColor(event); if (event.hasCategory(WebInspector.TimelineModel.Category.Console) || event.hasCategory(WebInspector.TimelineModel.Category.UserTiming)) return this._consoleColorGenerator.colorForID(event.name); var category = WebInspector.TimelineUIUtils.eventStyle(event).category; @@ -581,7 +612,11 @@ this._asyncColorByCategory[category.name] = color; return color; } - return WebInspector.TimelineUIUtils.eventColor(event); + if (type === WebInspector.TimelineFlameChartEntryType.Frame) + return "white"; + if (type === WebInspector.TimelineFlameChartEntryType.Header) + return "#aaa"; + return ""; }, /** @@ -597,10 +632,12 @@ */ decorateEntry: function(entryIndex, context, text, barX, barY, barWidth, barHeight) { - var frame = this._entryIndexToFrame[entryIndex]; - if (frame) { + var data = this._entryData[entryIndex]; + var type = this._entryType(entryIndex); + if (type === WebInspector.TimelineFlameChartEntryType.Frame) { var /** @const */ vPadding = 1; var /** @const */ hPadding = 1; + var frame = /** {!WebInspector.TimelineFrame} */ (data); barX += hPadding; barWidth -= 2 * hPadding; barY += vPadding; @@ -628,9 +665,11 @@ context.restore(); } - var event = this._entryEvents[entryIndex]; - if (event && event.warning) - paintWarningDecoration(barX, barWidth - 1.5); + if (type === WebInspector.TimelineFlameChartEntryType.Event) { + var event = /** {!WebInspector.TracingModel.Event} */ (data); + if (event.warning) + paintWarningDecoration(barX, barWidth - 1.5); + } /** * @param {number} x @@ -662,22 +701,21 @@ */ forceDecoration: function(entryIndex) { - var event = this._entryEvents[entryIndex]; - if (!event) - return !!this._entryIndexToFrame[entryIndex]; - return !!event.warning; + var type = this._entryType(entryIndex); + return type === WebInspector.TimelineFlameChartEntryType.Frame || + type === WebInspector.TimelineFlameChartEntryType.Event && !!/** @type {!WebInspector.TracingModel.Event} */ (this._entryData[entryIndex]).warning; }, /** * @param {string} title - * @param {number} level */ - _appendHeaderRecord: function(title, level) + _appendHeaderRecord: function(title) { - var index = this._entryEvents.length; + var index = this._entryData.length; this._entryIndexToTitle[index] = title; - this._entryEvents.push(null); - this._timelineData.entryLevels[index] = level; + this._entryData.push(null); + this._entryTypeByLevel[this._currentLevel] = WebInspector.TimelineFlameChartEntryType.Header; + this._timelineData.entryLevels[index] = this._currentLevel++; this._timelineData.entryTotalTimes[index] = this._timeSpan; this._timelineData.entryStartTimes[index] = this._minimumBoundary; }, @@ -688,8 +726,8 @@ */ _appendEvent: function(event, level) { - var index = this._entryEvents.length; - this._entryEvents.push(event); + var index = this._entryData.length; + this._entryData.push(event); this._timelineData.entryLevels[index] = level; this._timelineData.entryTotalTimes[index] = event.duration || WebInspector.TimelineFlameChartDataProvider.InstantEventVisibleDurationMs; this._timelineData.entryStartTimes[index] = event.startTime; @@ -754,8 +792,8 @@ // If we have past steps, put the end event for each range rather than start one. var eventOffset = steps.length > 1 && steps[1].phase === WebInspector.TracingModel.Phase.AsyncStepPast ? 1 : 0; for (var i = 0; i < steps.length - 1; ++i) { - var index = this._entryEvents.length; - this._entryEvents.push(steps[i + eventOffset]); + var index = this._entryData.length; + this._entryData.push(steps[i + eventOffset]); var startTime = steps[i].startTime; this._timelineData.entryLevels[index] = level; this._timelineData.entryTotalTimes[index] = steps[i + 1].startTime - startTime; @@ -768,11 +806,10 @@ */ _appendFrame: function(frame) { - var index = this._entryEvents.length; - this._entryEvents.push(null); - this._entryIndexToFrame[index] = frame; + var index = this._entryData.length; + this._entryData.push(frame); this._entryIndexToTitle[index] = Number.millisToString(frame.duration, true); - this._timelineData.entryLevels[index] = this._frameBarsLevel; + this._timelineData.entryLevels[index] = this._currentLevel; this._timelineData.entryTotalTimes[index] = frame.duration; this._timelineData.entryStartTimes[index] = frame.startTime; }, @@ -784,17 +821,15 @@ */ createSelection: function(entryIndex) { - var event = this._entryEvents[entryIndex]; - if (event) { - this._lastSelection = new WebInspector.TimelineFlameChartView.Selection(WebInspector.TimelineSelection.fromTraceEvent(event), entryIndex); - return this._lastSelection.timelineSelection; - } - var frame = this._entryIndexToFrame[entryIndex]; - if (frame) { - this._lastSelection = new WebInspector.TimelineFlameChartView.Selection(WebInspector.TimelineSelection.fromFrame(frame), entryIndex); - return this._lastSelection.timelineSelection; - } - return null; + var type = this._entryType(entryIndex); + var timelineSelection = null; + if (type === WebInspector.TimelineFlameChartEntryType.Event) + timelineSelection = WebInspector.TimelineSelection.fromTraceEvent(/** @type {!WebInspector.TracingModel.Event} */ (this._entryData[entryIndex])) + else if (type === WebInspector.TimelineFlameChartEntryType.Frame) + timelineSelection = WebInspector.TimelineSelection.fromFrame(/** @type {!WebInspector.TimelineFrame} */ (this._entryData[entryIndex])); + if (timelineSelection) + this._lastSelection = new WebInspector.TimelineFlameChartView.Selection(timelineSelection, entryIndex); + return timelineSelection; }, /** @@ -808,24 +843,10 @@ if (this._lastSelection && this._lastSelection.timelineSelection.object() === selection.object()) return this._lastSelection.entryIndex; - switch (selection.type()) { - case WebInspector.TimelineSelection.Type.TraceEvent: - var event = /** @type{!WebInspector.TracingModel.Event} */ (selection.object()); - var entryIndex = this._entryEvents.indexOf(event); - if (entryIndex !== -1) - this._lastSelection = new WebInspector.TimelineFlameChartView.Selection(WebInspector.TimelineSelection.fromTraceEvent(event), entryIndex); - return entryIndex; - case WebInspector.TimelineSelection.Type.Frame: - var frame = /** @type {!WebInspector.TimelineFrame} */ (selection.object()); - for (var frameIndex in this._entryIndexToFrame) { - if (this._entryIndexToFrame[frameIndex] === frame) { - this._lastSelection = new WebInspector.TimelineFlameChartView.Selection(WebInspector.TimelineSelection.fromFrame(frame), Number(frameIndex)); - return Number(frameIndex); - } - } - break; - } - return -1; + var index = this._entryData.indexOf(selection.object()); + if (index !== -1) + this._lastSelection = new WebInspector.TimelineFlameChartView.Selection(selection, index); + return index; }, __proto__: WebInspector.TimelineFlameChartDataProviderBase.prototype @@ -1335,7 +1356,7 @@ return; } var traceEvent = record.traceEvent(); - var entryIndex = this._dataProvider._entryEvents.indexOf(traceEvent); + var entryIndex = this._dataProvider._entryData.indexOf(traceEvent); var timelineSelection = this._dataProvider.createSelection(entryIndex); if (timelineSelection) this._delegate.select(timelineSelection);
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.cpp index f75d0b1..837734b6 100644 --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.cpp +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.cpp
@@ -7,6 +7,7 @@ #include "bindings/core/v8/CallbackPromiseAdapter.h" #include "bindings/core/v8/ScriptPromise.h" #include "bindings/core/v8/ScriptPromiseResolver.h" +#include "core/dom/DOMDataView.h" #include "core/dom/DOMException.h" #include "core/dom/ExceptionCode.h" #include "core/events/Event.h" @@ -19,12 +20,13 @@ namespace { -PassRefPtr<DOMArrayBuffer> ConvertWebVectorToArrayBuffer( +PassRefPtr<DOMDataView> ConvertWebVectorToDataView( const WebVector<uint8_t>& webVector) { static_assert(sizeof(*webVector.data()) == 1, "uint8_t should be a single byte"); RefPtr<DOMArrayBuffer> domBuffer = DOMArrayBuffer::create(webVector.data(), webVector.size()); - return domBuffer; + RefPtr<DOMDataView> domDataView = DOMDataView::create(domBuffer, 0, webVector.size()); + return domDataView; } } // anonymous namespace @@ -51,16 +53,16 @@ } void BluetoothGATTCharacteristic::setValue( - const PassRefPtr<DOMArrayBuffer>& domBuffer) + const PassRefPtr<DOMDataView>& domDataView) { - m_value = domBuffer; + m_value = domDataView; } void BluetoothGATTCharacteristic::dispatchCharacteristicValueChanged( const WebVector<uint8_t>& value) { - RefPtr<DOMArrayBuffer> domBuffer = ConvertWebVectorToArrayBuffer(value); - this->setValue(domBuffer); + RefPtr<DOMDataView> domDataView = ConvertWebVectorToDataView(value); + this->setValue(domDataView); dispatchEvent(Event::create(EventTypeNames::characteristicvaluechanged)); } @@ -113,11 +115,11 @@ if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) return; - RefPtr<DOMArrayBuffer> domBuffer = ConvertWebVectorToArrayBuffer(value); + RefPtr<DOMDataView> domDataView = ConvertWebVectorToDataView(value); if (m_webCharacteristic) { - m_webCharacteristic->setValue(domBuffer); + m_webCharacteristic->setValue(domDataView); } - m_resolver->resolve(domBuffer); + m_resolver->resolve(domDataView); } void onError(const WebBluetoothError& e) override
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.h b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.h index 8e89ce0..0ff5428 100644 --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.h +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.h
@@ -8,6 +8,7 @@ #include "bindings/core/v8/ScriptWrappable.h" #include "core/dom/ActiveDOMObject.h" #include "core/dom/DOMArrayPiece.h" +#include "core/dom/DOMDataView.h" #include "modules/EventTargetModules.h" #include "platform/heap/Handle.h" #include "public/platform/modules/bluetooth/WebBluetoothGATTCharacteristic.h" @@ -48,7 +49,7 @@ static BluetoothGATTCharacteristic* take(ScriptPromiseResolver*, PassOwnPtr<WebBluetoothGATTCharacteristicInit>); // Save value. - void setValue(const PassRefPtr<DOMArrayBuffer>&); + void setValue(const PassRefPtr<DOMDataView>&); // WebBluetoothGATTCharacteristic interface: void dispatchCharacteristicValueChanged(const WebVector<uint8_t>&) override; @@ -75,7 +76,7 @@ String uuid() { return m_webCharacteristic->uuid; } BluetoothCharacteristicProperties* properties() { return m_properties; } - PassRefPtr<DOMArrayBuffer> value() const { return m_value; } + PassRefPtr<DOMDataView> value() const { return m_value; } ScriptPromise readValue(ScriptState*); ScriptPromise writeValue(ScriptState*, const DOMArrayPiece&); ScriptPromise startNotifications(ScriptState*); @@ -91,7 +92,7 @@ OwnPtr<WebBluetoothGATTCharacteristicInit> m_webCharacteristic; bool m_stopped; Member<BluetoothCharacteristicProperties> m_properties; - RefPtr<DOMArrayBuffer> m_value; + RefPtr<DOMDataView> m_value; }; } // namespace blink
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.idl b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.idl index b9edeec..b9a5379 100644 --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.idl +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.idl
@@ -14,12 +14,12 @@ // TODO(ortuno): Add test to make sure service matches the service // used to call getCharacteristic. // readonly attribute BluetoothGATTService service; - readonly attribute UUID uuid; + readonly attribute UUID uuid; readonly attribute BluetoothCharacteristicProperties properties; - readonly attribute ArrayBuffer? value; + readonly attribute DataView? value; // Promise<BluetoothGATTDescriptor> getDescriptor(BluetoothDescriptorUUID descriptor); // Promise<sequence<BluetoothGATTDescriptor>> getDescriptors(optional BluetoothDescriptorUUID descriptor); - [CallWith=ScriptState] Promise<ArrayBuffer> readValue(); + [CallWith=ScriptState] Promise<DataView> readValue(); [CallWith=ScriptState] Promise<void> writeValue(BufferSource value); [CallWith=ScriptState] Promise<void> startNotifications(); [CallWith=ScriptState] Promise<void> stopNotifications();
diff --git a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp index 0246818..449b0e6 100644 --- a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp +++ b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp
@@ -119,7 +119,7 @@ RefPtr<ReadingContext> m_readingContext; }; - static PassRefPtr<ReadingContext> create(ScriptState* scriptState, v8::Local<v8::Value> stream) + static PassRefPtr<ReadingContext> create(ScriptState* scriptState, ScriptValue stream) { return adoptRef(new ReadingContext(scriptState, stream)); } @@ -156,7 +156,7 @@ m_isReading = true; ScriptState::Scope scope(m_reader.scriptState()); V8RecursionScope recursionScope(m_reader.isolate()); - ReadableStreamOperations::read(m_reader.scriptState(), m_reader.v8Value()).then( + ReadableStreamOperations::read(m_reader.scriptState(), m_reader).then( OnFulfilled::createFunction(m_reader.scriptState(), m_weakPtrFactory.createWeakPtr()), OnRejected::createFunction(m_reader.scriptState(), m_weakPtrFactory.createWeakPtr())); // Note: Microtasks may run here. @@ -226,7 +226,7 @@ } private: - ReadingContext(ScriptState* scriptState, v8::Local<v8::Value> stream) + ReadingContext(ScriptState* scriptState, ScriptValue stream) : m_client(nullptr) , m_weakPtrFactory(this) , m_pendingOffset(0) @@ -260,7 +260,7 @@ bool m_isInRecursion; }; -ReadableStreamDataConsumerHandle::ReadableStreamDataConsumerHandle(ScriptState* scriptState, v8::Local<v8::Value> stream) +ReadableStreamDataConsumerHandle::ReadableStreamDataConsumerHandle(ScriptState* scriptState, ScriptValue stream) : m_readingContext(ReadingContext::create(scriptState, stream)) { }
diff --git a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.h b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.h index 9c634f73..1d80665e 100644 --- a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.h +++ b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.h
@@ -5,12 +5,12 @@ #ifndef ReadableStreamDataConsumerHandle_h #define ReadableStreamDataConsumerHandle_h +#include "bindings/core/v8/ScriptValue.h" #include "modules/ModulesExport.h" #include "modules/fetch/FetchDataConsumerHandle.h" #include "wtf/Forward.h" #include "wtf/PassOwnPtr.h" #include "wtf/RefPtr.h" -#include <v8.h> namespace blink { @@ -28,7 +28,7 @@ class MODULES_EXPORT ReadableStreamDataConsumerHandle final : public FetchDataConsumerHandle { WTF_MAKE_NONCOPYABLE(ReadableStreamDataConsumerHandle); public: - static PassOwnPtr<ReadableStreamDataConsumerHandle> create(ScriptState* scriptState, v8::Local<v8::Value> stream) + static PassOwnPtr<ReadableStreamDataConsumerHandle> create(ScriptState* scriptState, ScriptValue stream) { return adoptPtr(new ReadableStreamDataConsumerHandle(scriptState, stream)); } @@ -36,7 +36,7 @@ private: class ReadingContext; - ReadableStreamDataConsumerHandle(ScriptState*, v8::Local<v8::Value> stream); + ReadableStreamDataConsumerHandle(ScriptState*, ScriptValue stream); Reader* obtainReaderInternal(Client*) override; const char* debugName() const override { return "ReadableStreamDataConsumerHandle"; }
diff --git a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.cpp b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.cpp index 1356bcdd..3475196 100644 --- a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.cpp +++ b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.cpp
@@ -87,7 +87,7 @@ ScriptState::Scope scope(scriptState()); ScriptValue stream(scriptState(), evalWithPrintingError("new ReadableStream")); ASSERT_FALSE(stream.isEmpty()); - OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream.v8Value()); + OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream); ASSERT_TRUE(handle); MockClient* client = MockClient::create(); Checkpoint checkpoint; @@ -110,7 +110,7 @@ ScriptValue stream(scriptState(), evalWithPrintingError( "new ReadableStream({start: c => c.close()})")); ASSERT_FALSE(stream.isEmpty()); - OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream.v8Value()); + OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream); ASSERT_TRUE(handle); MockClient* client = MockClient::create(); Checkpoint checkpoint; @@ -141,7 +141,7 @@ ScriptValue stream(scriptState(), evalWithPrintingError( "new ReadableStream({start: c => c.error()})")); ASSERT_FALSE(stream.isEmpty()); - OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream.v8Value()); + OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream); ASSERT_TRUE(handle); MockClient* client = MockClient::create(); Checkpoint checkpoint; @@ -177,7 +177,7 @@ "controller.close();" "stream")); ASSERT_FALSE(stream.isEmpty()); - OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream.v8Value()); + OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream); ASSERT_TRUE(handle); MockClient* client = MockClient::create(); Checkpoint checkpoint; @@ -239,7 +239,7 @@ "controller.close();" "stream")); ASSERT_FALSE(stream.isEmpty()); - OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream.v8Value()); + OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream); ASSERT_TRUE(handle); MockClient* client = MockClient::create(); Checkpoint checkpoint; @@ -309,7 +309,7 @@ "stream.getReader();" "stream")); ASSERT_FALSE(stream.isEmpty()); - OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream.v8Value()); + OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream); ASSERT_TRUE(handle); MockClient* client = MockClient::create(); Checkpoint checkpoint; @@ -339,7 +339,7 @@ "controller.close();" "stream")); ASSERT_FALSE(stream.isEmpty()); - OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream.v8Value()); + OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream); ASSERT_TRUE(handle); MockClient* client = MockClient::create(); Checkpoint checkpoint; @@ -374,7 +374,7 @@ "controller.close();" "stream")); ASSERT_FALSE(stream.isEmpty()); - OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream.v8Value()); + OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream); ASSERT_TRUE(handle); MockClient* client = MockClient::create(); Checkpoint checkpoint; @@ -409,7 +409,7 @@ "controller.close();" "stream")); ASSERT_FALSE(stream.isEmpty()); - OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream.v8Value()); + OwnPtr<ReadableStreamDataConsumerHandle> handle = ReadableStreamDataConsumerHandle::create(scriptState(), stream); ASSERT_TRUE(handle); MockClient* client = MockClient::create(); Checkpoint checkpoint;
diff --git a/third_party/WebKit/Source/modules/fetch/Response.cpp b/third_party/WebKit/Source/modules/fetch/Response.cpp index 99c972a..e9138c88 100644 --- a/third_party/WebKit/Source/modules/fetch/Response.cpp +++ b/third_party/WebKit/Source/modules/fetch/Response.cpp
@@ -133,8 +133,8 @@ // FormDataEncoder::generateUniqueBoundaryString. contentType = AtomicString("multipart/form-data; boundary=", AtomicString::ConstructFromLiteral) + formData->boundary().data(); bodyHandle = FetchFormDataConsumerHandle::create(executionContext, formData.release()); - } else if (RuntimeEnabledFeatures::responseConstructedWithReadableStreamEnabled() && ReadableStreamOperations::isReadableStream(scriptState, body)) { - bodyHandle = ReadableStreamDataConsumerHandle::create(scriptState, body); + } else if (RuntimeEnabledFeatures::responseConstructedWithReadableStreamEnabled() && ReadableStreamOperations::isReadableStream(scriptState, bodyValue)) { + bodyHandle = ReadableStreamDataConsumerHandle::create(scriptState, bodyValue); } else { String string = toUSVString(isolate, body, exceptionState); if (exceptionState.hadException())
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FEBlend.cpp b/third_party/WebKit/Source/platform/graphics/filters/FEBlend.cpp index 0d5c326..daf34d0 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FEBlend.cpp +++ b/third_party/WebKit/Source/platform/graphics/filters/FEBlend.cpp
@@ -60,7 +60,7 @@ RefPtr<SkImageFilter> foreground(builder.build(inputEffect(0), operatingColorSpace())); RefPtr<SkImageFilter> background(builder.build(inputEffect(1), operatingColorSpace())); RefPtr<SkXfermode> mode(adoptRef(SkXfermode::Create(WebCoreCompositeToSkiaComposite(CompositeSourceOver, m_mode)))); - SkImageFilter::CropRect cropRect = getCropRect(builder.cropOffset()); + SkImageFilter::CropRect cropRect = getCropRect(); return adoptRef(SkXfermodeImageFilter::Create(mode.get(), background.get(), foreground.get(), &cropRect)); }
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FEColorMatrix.cpp b/third_party/WebKit/Source/platform/graphics/filters/FEColorMatrix.cpp index ae68a85d..8c09a88 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FEColorMatrix.cpp +++ b/third_party/WebKit/Source/platform/graphics/filters/FEColorMatrix.cpp
@@ -164,7 +164,7 @@ { RefPtr<SkImageFilter> input(builder.build(inputEffect(0), operatingColorSpace())); SkAutoTUnref<SkColorFilter> filter(createColorFilter(m_type, m_values)); - SkImageFilter::CropRect rect = getCropRect(builder.cropOffset()); + SkImageFilter::CropRect rect = getCropRect(); return adoptRef(SkColorFilterImageFilter::Create(filter, input.get(), &rect)); }
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FEComponentTransfer.cpp b/third_party/WebKit/Source/platform/graphics/filters/FEComponentTransfer.cpp index a921035f..a32da13 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FEComponentTransfer.cpp +++ b/third_party/WebKit/Source/platform/graphics/filters/FEComponentTransfer.cpp
@@ -137,7 +137,7 @@ SkAutoTUnref<SkColorFilter> colorFilter(SkTableColorFilter::CreateARGB(aValues, rValues, gValues, bValues)); - SkImageFilter::CropRect cropRect = getCropRect(builder.cropOffset()); + SkImageFilter::CropRect cropRect = getCropRect(); return adoptRef(SkColorFilterImageFilter::Create(colorFilter, input.get(), &cropRect)); }
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FEComposite.cpp b/third_party/WebKit/Source/platform/graphics/filters/FEComposite.cpp index eec1dcf..ec70f56 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FEComposite.cpp +++ b/third_party/WebKit/Source/platform/graphics/filters/FEComposite.cpp
@@ -204,7 +204,7 @@ { RefPtr<SkImageFilter> foreground(builder.build(inputEffect(0), operatingColorSpace(), !mayProduceInvalidPreMultipliedPixels())); RefPtr<SkImageFilter> background(builder.build(inputEffect(1), operatingColorSpace(), !mayProduceInvalidPreMultipliedPixels())); - SkImageFilter::CropRect cropRect = getCropRect(builder.cropOffset()); + SkImageFilter::CropRect cropRect = getCropRect(); RefPtr<SkXfermode> mode; if (m_type == FECOMPOSITE_OPERATOR_ARITHMETIC) mode = adoptRef(SkArithmeticMode::Create(SkFloatToScalar(m_k1), SkFloatToScalar(m_k2), SkFloatToScalar(m_k3), SkFloatToScalar(m_k4), requiresPMColorValidation));
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FEConvolveMatrix.cpp b/third_party/WebKit/Source/platform/graphics/filters/FEConvolveMatrix.cpp index 585cce04..cbaebda3 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FEConvolveMatrix.cpp +++ b/third_party/WebKit/Source/platform/graphics/filters/FEConvolveMatrix.cpp
@@ -152,7 +152,7 @@ OwnPtr<SkScalar[]> kernel = adoptArrayPtr(new SkScalar[numElements]); for (int i = 0; i < numElements; ++i) kernel[i] = SkFloatToScalar(m_kernelMatrix[numElements - 1 - i]); - SkImageFilter::CropRect cropRect = getCropRect(builder.cropOffset()); + SkImageFilter::CropRect cropRect = getCropRect(); return adoptRef(SkMatrixConvolutionImageFilter::Create(kernelSize, kernel.get(), gain, bias, target, tileMode, convolveAlpha, input.get(), &cropRect)); }
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FEDisplacementMap.cpp b/third_party/WebKit/Source/platform/graphics/filters/FEDisplacementMap.cpp index 789b353..616fe64 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FEDisplacementMap.cpp +++ b/third_party/WebKit/Source/platform/graphics/filters/FEDisplacementMap.cpp
@@ -115,7 +115,7 @@ RefPtr<SkImageFilter> displ = builder.build(inputEffect(1), operatingColorSpace()); SkDisplacementMapEffect::ChannelSelectorType typeX = toSkiaMode(m_xChannelSelector); SkDisplacementMapEffect::ChannelSelectorType typeY = toSkiaMode(m_yChannelSelector); - SkImageFilter::CropRect cropRect = getCropRect(builder.cropOffset()); + SkImageFilter::CropRect cropRect = getCropRect(); // FIXME : Only applyHorizontalScale is used and applyVerticalScale is ignored // This can be fixed by adding a 2nd scale parameter to SkDisplacementMapEffect return adoptRef(SkDisplacementMapEffect::Create(typeX, typeY, SkFloatToScalar(filter()->applyHorizontalScale(m_scale)), displ.get(), color.get(), &cropRect));
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.cpp b/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.cpp index 47097abf..75ddeb7 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.cpp +++ b/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.cpp
@@ -73,7 +73,7 @@ float stdX = filter()->applyHorizontalScale(m_stdX); float stdY = filter()->applyVerticalScale(m_stdY); Color color = adaptColorToOperatingColorSpace(m_shadowColor.combineWithAlpha(m_shadowOpacity)); - SkImageFilter::CropRect cropRect = getCropRect(builder.cropOffset()); + SkImageFilter::CropRect cropRect = getCropRect(); return adoptRef(SkDropShadowImageFilter::Create(SkFloatToScalar(dx), SkFloatToScalar(dy), SkFloatToScalar(stdX), SkFloatToScalar(stdY), color.rgb(), SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, input.get(), &cropRect)); }
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FEFlood.cpp b/third_party/WebKit/Source/platform/graphics/filters/FEFlood.cpp index 3a2d198..7dd0d89d 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FEFlood.cpp +++ b/third_party/WebKit/Source/platform/graphics/filters/FEFlood.cpp
@@ -73,7 +73,7 @@ { Color color = floodColor().combineWithAlpha(floodOpacity()); - SkImageFilter::CropRect rect = getCropRect(builder.cropOffset()); + SkImageFilter::CropRect rect = getCropRect(); SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(color.rgb(), SkXfermode::kSrc_Mode)); return adoptRef(SkColorFilterImageFilter::Create(cf, 0, &rect)); }
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FEGaussianBlur.cpp b/third_party/WebKit/Source/platform/graphics/filters/FEGaussianBlur.cpp index e454510eb..9a6ad05 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FEGaussianBlur.cpp +++ b/third_party/WebKit/Source/platform/graphics/filters/FEGaussianBlur.cpp
@@ -113,7 +113,7 @@ RefPtr<SkImageFilter> input(builder.build(inputEffect(0), operatingColorSpace())); float stdX = filter()->applyHorizontalScale(m_stdX); float stdY = filter()->applyVerticalScale(m_stdY); - SkImageFilter::CropRect rect = getCropRect(builder.cropOffset()); + SkImageFilter::CropRect rect = getCropRect(); return adoptRef(SkBlurImageFilter::Create(SkFloatToScalar(stdX), SkFloatToScalar(stdY), input.get(), &rect)); }
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FELighting.cpp b/third_party/WebKit/Source/platform/graphics/filters/FELighting.cpp index 680b43e..cefff61 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FELighting.cpp +++ b/third_party/WebKit/Source/platform/graphics/filters/FELighting.cpp
@@ -63,7 +63,7 @@ if (!m_lightSource) return createTransparentBlack(builder); - SkImageFilter::CropRect rect = getCropRect(builder.cropOffset()); + SkImageFilter::CropRect rect = getCropRect(); Color lightColor = adaptColorToOperatingColorSpace(m_lightingColor); RefPtr<SkImageFilter> input(builder.build(inputEffect(0), operatingColorSpace())); switch (m_lightSource->type()) {
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FEMerge.cpp b/third_party/WebKit/Source/platform/graphics/filters/FEMerge.cpp index 20ac88d..881a82c 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FEMerge.cpp +++ b/third_party/WebKit/Source/platform/graphics/filters/FEMerge.cpp
@@ -49,7 +49,7 @@ inputRefs[i] = builder.build(inputEffect(i), operatingColorSpace()); inputs[i] = inputRefs[i].get(); } - SkImageFilter::CropRect rect = getCropRect(builder.cropOffset()); + SkImageFilter::CropRect rect = getCropRect(); return adoptRef(SkMergeImageFilter::Create(inputs.get(), size, 0, &rect)); }
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FEMorphology.cpp b/third_party/WebKit/Source/platform/graphics/filters/FEMorphology.cpp index cbb0e7e..bd0dec6 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FEMorphology.cpp +++ b/third_party/WebKit/Source/platform/graphics/filters/FEMorphology.cpp
@@ -98,7 +98,7 @@ RefPtr<SkImageFilter> input(builder.build(inputEffect(0), operatingColorSpace())); SkScalar radiusX = SkFloatToScalar(filter()->applyHorizontalScale(m_radiusX)); SkScalar radiusY = SkFloatToScalar(filter()->applyVerticalScale(m_radiusY)); - SkImageFilter::CropRect rect = getCropRect(builder.cropOffset()); + SkImageFilter::CropRect rect = getCropRect(); if (m_type == FEMORPHOLOGY_OPERATOR_DILATE) return adoptRef(SkDilateImageFilter::Create(radiusX, radiusY, input.get(), &rect)); return adoptRef(SkErodeImageFilter::Create(radiusX, radiusY, input.get(), &rect));
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FEOffset.cpp b/third_party/WebKit/Source/platform/graphics/filters/FEOffset.cpp index 3425716..fa8cc091 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FEOffset.cpp +++ b/third_party/WebKit/Source/platform/graphics/filters/FEOffset.cpp
@@ -77,7 +77,7 @@ { RefPtr<SkImageFilter> input(builder.build(inputEffect(0), operatingColorSpace())); Filter* filter = this->filter(); - SkImageFilter::CropRect cropRect = getCropRect(builder.cropOffset()); + SkImageFilter::CropRect cropRect = getCropRect(); return adoptRef(SkOffsetImageFilter::Create(SkFloatToScalar(filter->applyHorizontalScale(m_dx)), SkFloatToScalar(filter->applyVerticalScale(m_dy)), input.get(), &cropRect)); }
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FETurbulence.cpp b/third_party/WebKit/Source/platform/graphics/filters/FETurbulence.cpp index 145dc763..091c340d 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FETurbulence.cpp +++ b/third_party/WebKit/Source/platform/graphics/filters/FETurbulence.cpp
@@ -154,7 +154,7 @@ SkAutoTUnref<SkShader> shader(createShader()); SkPaint paint; paint.setShader(shader); - SkImageFilter::CropRect rect = getCropRect(builder.cropOffset()); + SkImageFilter::CropRect rect = getCropRect(); return adoptRef(SkPaintImageFilter::Create(paint, &rect)); }
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp b/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp index c4c1d8f..e3f5b93 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp +++ b/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp
@@ -201,7 +201,7 @@ PassRefPtr<SkImageFilter> FilterEffect::createTransparentBlack(SkiaImageFilterBuilder& builder) const { SkAutoTUnref<SkColorFilter> filter(SkColorFilter::CreateModeFilter(0, SkXfermode::kClear_Mode)); - SkImageFilter::CropRect rect = getCropRect(builder.cropOffset()); + SkImageFilter::CropRect rect = getCropRect(); return adoptRef(SkColorFilterImageFilter::Create(filter, nullptr, &rect)); } @@ -215,7 +215,7 @@ return false; } -SkImageFilter::CropRect FilterEffect::getCropRect(const FloatSize& cropOffset) const +SkImageFilter::CropRect FilterEffect::getCropRect() const { FloatRect rect; uint32_t flags = 0; @@ -226,7 +226,6 @@ rect = applyEffectBoundaries(rect); - rect.move(cropOffset); rect.scale(filter()->scale()); flags |= hasX() ? SkImageFilter::CropRect::kHasLeft_CropEdge : 0;
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.h b/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.h index 3a90390..eeb0e7d1 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.h +++ b/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.h
@@ -156,7 +156,7 @@ Color adaptColorToOperatingColorSpace(const Color& deviceColor); - SkImageFilter::CropRect getCropRect(const FloatSize& cropOffset) const; + SkImageFilter::CropRect getCropRect() const; void addAbsolutePaintRect(const FloatRect& absolutePaintRect);
diff --git a/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.h b/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.h index e07970a7c..79885ef 100644 --- a/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.h +++ b/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.h
@@ -50,10 +50,6 @@ PassRefPtr<SkImageFilter> transformColorSpace( SkImageFilter* input, ColorSpace srcColorSpace, ColorSpace dstColorSpace); - FloatSize cropOffset() { return m_cropOffset; } - -private: - FloatSize m_cropOffset; }; } // namespace blink
diff --git a/third_party/WebKit/Source/platform/testing/RunAllTests.cpp b/third_party/WebKit/Source/platform/testing/RunAllTests.cpp index b08dcaf8..a852c3c 100644 --- a/third_party/WebKit/Source/platform/testing/RunAllTests.cpp +++ b/third_party/WebKit/Source/platform/testing/RunAllTests.cpp
@@ -57,8 +57,9 @@ int main(int argc, char** argv) { + WTF::Partitions::initialize(nullptr); WTF::setAlwaysZeroRandomSourceForTesting(); - WTF::initialize(CurrentTime, CurrentTime, nullptr, nullptr); + WTF::initialize(CurrentTime, CurrentTime, nullptr); WTF::initializeMainThread(0); blink::TestingPlatformSupport::Config platformConfig; @@ -80,5 +81,6 @@ blink::Heap::shutdown(); WTF::shutdown(); + WTF::Partitions::shutdown(); return result; }
diff --git a/third_party/WebKit/Source/web/ExternalPopupMenu.cpp b/third_party/WebKit/Source/web/ExternalPopupMenu.cpp index e1eafc7..939127f 100644 --- a/third_party/WebKit/Source/web/ExternalPopupMenu.cpp +++ b/third_party/WebKit/Source/web/ExternalPopupMenu.cpp
@@ -30,14 +30,12 @@ #include "web/ExternalPopupMenu.h" -#include "core/dom/ExecutionContextTask.h" #include "core/dom/NodeComputedStyle.h" #include "core/frame/FrameHost.h" #include "core/frame/FrameView.h" #include "core/frame/LocalFrame.h" #include "core/html/HTMLOptionElement.h" #include "core/html/HTMLSelectElement.h" -#include "core/layout/LayoutBox.h" #include "core/page/Page.h" #include "core/style/ComputedStyle.h" #include "platform/geometry/FloatQuad.h" @@ -73,10 +71,11 @@ PopupMenu::trace(visitor); } -bool ExternalPopupMenu::showInternal() +void ExternalPopupMenu::show(const FloatQuad& controlPosition, const IntSize&, int index) { - // Blink core reuses the PopupMenu of an element. For simplicity, we do - // recreate the actual external popup everytime. + IntRect rect(controlPosition.enclosingBoundingBox()); + // WebCore reuses the PopupMenu of an element. + // For simplicity, we do recreate the actual external popup everytime. if (m_webExternalPopupMenu) { m_webExternalPopupMenu->close(); m_webExternalPopupMenu = 0; @@ -85,46 +84,31 @@ WebPopupMenuInfo info; getPopupMenuInfo(info, *m_ownerElement); if (info.items.isEmpty()) - return false; + return; WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(m_localFrame.get()); m_webExternalPopupMenu = webframe->client()->createExternalPopupMenu(info, this); if (m_webExternalPopupMenu) { - LayoutObject* layoutObject = m_ownerElement->layoutObject(); - if (!layoutObject || !layoutObject->isBox()) - return false; - FloatQuad quad(toLayoutBox(layoutObject)->localToAbsoluteQuad(FloatQuad(toLayoutBox(layoutObject)->borderBoundingBox()))); - IntRect rect(quad.enclosingBoundingBox()); IntRect rectInViewport = m_localFrame->view()->soonToBeRemovedContentsToUnscaledViewport(rect); - // TODO(tkent): If the anchor rectangle is not visible, we should not - // show a popup. m_webExternalPopupMenu->show(rectInViewport); - return true; +#if OS(MACOSX) + const WebInputEvent* currentEvent = WebViewImpl::currentInputEvent(); + if (currentEvent && currentEvent->type == WebInputEvent::MouseDown) { + m_syntheticEvent = adoptPtr(new WebMouseEvent); + *m_syntheticEvent = *static_cast<const WebMouseEvent*>(currentEvent); + m_syntheticEvent->type = WebInputEvent::MouseUp; + m_dispatchEventTimer.startOneShot(0, BLINK_FROM_HERE); + // FIXME: show() is asynchronous. If preparing a popup is slow and + // a user released the mouse button before showing the popup, + // mouseup and click events are correctly dispatched. Dispatching + // the synthetic mouseup event is redundant in this case. + } +#endif } else { // The client might refuse to create a popup (when there is already one pending to be shown for example). didCancel(); - return false; } } -void ExternalPopupMenu::show(const FloatQuad&, const IntSize&, int) -{ - if (!showInternal()) - return; -#if OS(MACOSX) - const WebInputEvent* currentEvent = WebViewImpl::currentInputEvent(); - if (currentEvent && currentEvent->type == WebInputEvent::MouseDown) { - m_syntheticEvent = adoptPtr(new WebMouseEvent); - *m_syntheticEvent = *static_cast<const WebMouseEvent*>(currentEvent); - m_syntheticEvent->type = WebInputEvent::MouseUp; - m_dispatchEventTimer.startOneShot(0, BLINK_FROM_HERE); - // FIXME: show() is asynchronous. If preparing a popup is slow and a - // user released the mouse button before showing the popup, mouseup and - // click events are correctly dispatched. Dispatching the synthetic - // mouseup event is redundant in this case. - } -#endif -} - void ExternalPopupMenu::dispatchEvent(Timer<ExternalPopupMenu>*) { m_webView.handleInputEvent(*m_syntheticEvent); @@ -143,26 +127,6 @@ void ExternalPopupMenu::updateFromElement() { - if (m_needsUpdate) - return; - m_needsUpdate = true; - m_ownerElement->document().postTask(BLINK_FROM_HERE, createSameThreadTask(&ExternalPopupMenu::update, PassRefPtrWillBeRawPtr<ExternalPopupMenu>(this))); -} - -void ExternalPopupMenu::update() -{ - if (!m_webExternalPopupMenu || !m_ownerElement) - return; - m_ownerElement->document().updateLayoutTreeIfNeeded(); - // disconnectClient() might have been called. - if (!m_ownerElement) - return; - m_needsUpdate = false; - - if (showInternal()) - return; - // We failed to show a popup. Notify it to the owner. - hide(); } void ExternalPopupMenu::disconnectClient()
diff --git a/third_party/WebKit/Source/web/ExternalPopupMenu.h b/third_party/WebKit/Source/web/ExternalPopupMenu.h index e892ee2..902d7f3 100644 --- a/third_party/WebKit/Source/web/ExternalPopupMenu.h +++ b/third_party/WebKit/Source/web/ExternalPopupMenu.h
@@ -78,9 +78,7 @@ void didAcceptIndices(const WebVector<int>& indices) override; void didCancel() override; - bool showInternal(); void dispatchEvent(Timer<ExternalPopupMenu>*); - void update(); RawPtrWillBeMember<HTMLSelectElement> m_ownerElement; RefPtrWillBeMember<LocalFrame> m_localFrame; @@ -89,7 +87,6 @@ Timer<ExternalPopupMenu> m_dispatchEventTimer; // The actual implementor of the show menu. WebExternalPopupMenu* m_webExternalPopupMenu; - bool m_needsUpdate = false; }; } // namespace blink
diff --git a/third_party/WebKit/Source/web/WebKit.cpp b/third_party/WebKit/Source/web/WebKit.cpp index a880884..7e593938 100644 --- a/third_party/WebKit/Source/web/WebKit.cpp +++ b/third_party/WebKit/Source/web/WebKit.cpp
@@ -163,10 +163,11 @@ ASSERT(!s_webKitInitialized); s_webKitInitialized = true; + WTF::Partitions::initialize(histogramEnumerationFunction); ASSERT(platform); Platform::initialize(platform); - WTF::initialize(currentTimeFunction, monotonicallyIncreasingTimeFunction, histogramEnumerationFunction, adjustAmountOfExternalAllocatedMemory); + WTF::initialize(currentTimeFunction, monotonicallyIncreasingTimeFunction, adjustAmountOfExternalAllocatedMemory); WTF::initializeMainThread(callOnMainThreadFunction); Heap::init(); @@ -247,6 +248,7 @@ WTF::shutdown(); Platform::shutdown(); WebPrerenderingSupport::shutdown(); + WTF::Partitions::shutdown(); } // TODO(tkent): The following functions to wrap LayoutTestSupport should be
diff --git a/third_party/WebKit/Source/wtf/WTF.cpp b/third_party/WebKit/Source/wtf/WTF.cpp index 72767e97..010005c 100644 --- a/third_party/WebKit/Source/wtf/WTF.cpp +++ b/third_party/WebKit/Source/wtf/WTF.cpp
@@ -41,7 +41,7 @@ bool s_initialized; bool s_shutdown; -void initialize(TimeFunction currentTimeFunction, TimeFunction monotonicallyIncreasingTimeFunction, HistogramEnumerationFunction histogramEnumerationFunction, AdjustAmountOfExternalAllocatedMemoryFunction adjustAmountOfExternalAllocatedMemoryFunction) +void initialize(TimeFunction currentTimeFunction, TimeFunction monotonicallyIncreasingTimeFunction, AdjustAmountOfExternalAllocatedMemoryFunction adjustAmountOfExternalAllocatedMemoryFunction) { // WTF, and Blink in general, cannot handle being re-initialized, even if shutdown first. // Make that explicit here. @@ -50,7 +50,6 @@ s_initialized = true; setCurrentTimeFunction(currentTimeFunction); setMonotonicallyIncreasingTimeFunction(monotonicallyIncreasingTimeFunction); - Partitions::initialize(histogramEnumerationFunction); ArrayBufferContents::setAdjustAmoutOfExternalAllocatedMemoryFunction(adjustAmountOfExternalAllocatedMemoryFunction); initializeThreading(); } @@ -60,7 +59,6 @@ RELEASE_ASSERT(s_initialized); RELEASE_ASSERT(!s_shutdown); s_shutdown = true; - Partitions::shutdown(); } bool isShutdown()
diff --git a/third_party/WebKit/Source/wtf/WTF.h b/third_party/WebKit/Source/wtf/WTF.h index ac935287..806d52b 100644 --- a/third_party/WebKit/Source/wtf/WTF.h +++ b/third_party/WebKit/Source/wtf/WTF.h
@@ -41,7 +41,7 @@ typedef void(*AdjustAmountOfExternalAllocatedMemoryFunction)(int size); // This function must be called exactly once from the main thread before using anything else in WTF. -WTF_EXPORT void initialize(TimeFunction currentTimeFunction, TimeFunction monotonicallyIncreasingTimeFunction, HistogramEnumerationFunction, AdjustAmountOfExternalAllocatedMemoryFunction); +WTF_EXPORT void initialize(TimeFunction currentTimeFunction, TimeFunction monotonicallyIncreasingTimeFunction, AdjustAmountOfExternalAllocatedMemoryFunction); WTF_EXPORT void shutdown(); WTF_EXPORT bool isShutdown();
diff --git a/third_party/WebKit/Source/wtf/testing/RunAllTests.cpp b/third_party/WebKit/Source/wtf/testing/RunAllTests.cpp index 8e2bac7..0a90a91 100644 --- a/third_party/WebKit/Source/wtf/testing/RunAllTests.cpp +++ b/third_party/WebKit/Source/wtf/testing/RunAllTests.cpp
@@ -30,6 +30,7 @@ #include "wtf/CryptographicallyRandomNumber.h" #include "wtf/MainThread.h" +#include "wtf/Partitions.h" #include "wtf/WTF.h" #include <base/test/test_suite.h> #include <string.h> @@ -41,8 +42,9 @@ int main(int argc, char** argv) { + WTF::Partitions::initialize(nullptr); WTF::setAlwaysZeroRandomSourceForTesting(); - WTF::initialize(CurrentTime, nullptr, nullptr, nullptr); + WTF::initialize(CurrentTime, nullptr, nullptr); WTF::initializeMainThread(0); return base::RunUnitTestsUsingBaseTestSuite(argc, argv); }
diff --git a/third_party/boringssl/BUILD.gn b/third_party/boringssl/BUILD.gn index a6415da66..3f7887e 100644 --- a/third_party/boringssl/BUILD.gn +++ b/third_party/boringssl/BUILD.gn
@@ -7,10 +7,9 @@ # Config for us and everybody else depending on BoringSSL. config("openssl_config") { - defines = [ "OPENSSL_SMALL" ] include_dirs = [ "src/include" ] if (is_component_build) { - defines += [ "BORINGSSL_SHARED_LIBRARY" ] + defines = [ "BORINGSSL_SHARED_LIBRARY" ] } }
diff --git a/third_party/boringssl/boringssl.gyp b/third_party/boringssl/boringssl.gyp index 798b825..6539a90 100644 --- a/third_party/boringssl/boringssl.gyp +++ b/third_party/boringssl/boringssl.gyp
@@ -17,6 +17,7 @@ 'defines': [ 'BORINGSSL_IMPLEMENTATION', 'BORINGSSL_NO_STATIC_INITIALIZER', + 'OPENSSL_SMALL', ], 'dependencies': [ 'boringssl_asm' ], # TODO(davidben): Fix size_t truncations in BoringSSL. @@ -33,9 +34,6 @@ 'src/include', ], 'direct_dependent_settings': { - 'defines': [ - 'OPENSSL_SMALL', - ], 'include_dirs': [ 'src/include', ],
diff --git a/third_party/boringssl/boringssl.gypi b/third_party/boringssl/boringssl.gypi index 7b7f305..b9f8413 100644 --- a/third_party/boringssl/boringssl.gypi +++ b/third_party/boringssl/boringssl.gypi
@@ -29,6 +29,7 @@ 'src/ssl/ssl_buffer.c', 'src/ssl/ssl_cert.c', 'src/ssl/ssl_cipher.c', + 'src/ssl/ssl_ecdh.c', 'src/ssl/ssl_file.c', 'src/ssl/ssl_lib.c', 'src/ssl/ssl_rsa.c', @@ -134,6 +135,7 @@ 'src/crypto/cpu-intel.c', 'src/crypto/crypto.c', 'src/crypto/curve25519/curve25519.c', + 'src/crypto/curve25519/x25519-x86_64.c', 'src/crypto/des/des.c', 'src/crypto/dh/check.c', 'src/crypto/dh/dh.c', @@ -324,7 +326,7 @@ 'linux-arm/crypto/sha/sha512-armv4.S', 'src/crypto/chacha/chacha_vec_arm.S', 'src/crypto/cpu-arm-asm.S', - 'src/crypto/curve25519/asm/x25519-arm.S', + 'src/crypto/curve25519/asm/x25519-asm-arm.S', 'src/crypto/poly1305/poly1305_arm_asm.S', ], 'boringssl_linux_x86_sources': [ @@ -359,6 +361,7 @@ 'linux-x86_64/crypto/sha/sha1-x86_64.S', 'linux-x86_64/crypto/sha/sha256-x86_64.S', 'linux-x86_64/crypto/sha/sha512-x86_64.S', + 'src/crypto/curve25519/asm/x25519-asm-x86_64.S', ], 'boringssl_mac_x86_sources': [ 'mac-x86/crypto/aes/aes-586.S',
diff --git a/third_party/boringssl/boringssl_tests.gypi b/third_party/boringssl/boringssl_tests.gypi index ebf81c03..ec469ef 100644 --- a/third_party/boringssl/boringssl_tests.gypi +++ b/third_party/boringssl/boringssl_tests.gypi
@@ -455,6 +455,20 @@ 'msvs_disabled_warnings': [ 4267, ], }, { + 'target_name': 'boringssl_x509_test', + 'type': 'executable', + 'dependencies': [ + 'boringssl.gyp:boringssl', + ], + 'sources': [ + 'src/crypto/x509/x509_test.cc', + '<@(boringssl_test_support_sources)', + ], + # TODO(davidben): Fix size_t truncations in BoringSSL. + # https://crbug.com/429039 + 'msvs_disabled_warnings': [ 4267, ], + }, + { 'target_name': 'boringssl_tab_test', 'type': 'executable', 'dependencies': [ @@ -554,6 +568,7 @@ 'boringssl_thread_test', 'boringssl_v3name_test', 'boringssl_x25519_test', + 'boringssl_x509_test', ], } }
diff --git a/third_party/boringssl/boringssl_unittest.cc b/third_party/boringssl/boringssl_unittest.cc index a299dec..65839e1 100644 --- a/third_party/boringssl/boringssl_unittest.cc +++ b/third_party/boringssl/boringssl_unittest.cc
@@ -323,3 +323,7 @@ TEST(BoringSSL, X25519) { TestSimple("x25519_test"); } + +TEST(BoringSSL, X509) { + TestSimple("x509_test"); +}
diff --git a/third_party/boringssl/err_data.c b/third_party/boringssl/err_data.c index 1a1d950..fe7979b 100644 --- a/third_party/boringssl/err_data.c +++ b/third_party/boringssl/err_data.c
@@ -54,178 +54,178 @@ OPENSSL_COMPILE_ASSERT(ERR_NUM_LIBS == 33, library_values_changed_num); const uint32_t kOpenSSLReasonValues[] = { - 0xc3207ba, - 0xc3287d4, - 0xc3307e3, - 0xc3387f3, - 0xc340802, - 0xc34881b, - 0xc350827, - 0xc358844, - 0xc360856, - 0xc368864, - 0xc370874, - 0xc378881, - 0xc380891, - 0xc38889c, - 0xc3908b2, - 0xc3988c1, - 0xc3a08d5, - 0xc3a87c7, + 0xc3207ab, + 0xc3287c5, + 0xc3307d4, + 0xc3387e4, + 0xc3407f3, + 0xc34880c, + 0xc350818, + 0xc358835, + 0xc360847, + 0xc368855, + 0xc370865, + 0xc378872, + 0xc380882, + 0xc38888d, + 0xc3908a3, + 0xc3988b2, + 0xc3a08c6, + 0xc3a87b8, 0xc3b00b0, - 0x10321478, - 0x10329484, - 0x1033149d, - 0x103394b0, - 0x10340de1, - 0x103494cf, - 0x103514e4, - 0x10359516, - 0x1036152f, - 0x10369544, - 0x10371562, - 0x10379571, - 0x1038158d, - 0x103895a8, - 0x103915b7, - 0x103995d3, - 0x103a15ee, - 0x103a9605, - 0x103b1616, - 0x103b962a, - 0x103c1649, - 0x103c9658, - 0x103d166f, - 0x103d9682, - 0x103e0b6c, - 0x103e96b3, - 0x103f16c6, - 0x103f96e0, - 0x104016f0, - 0x10409704, - 0x1041171a, - 0x10419732, - 0x10421747, - 0x1042975b, - 0x1043176d, - 0x104385d0, - 0x104408c1, - 0x10449782, - 0x10451799, - 0x104597ae, - 0x104617bc, - 0x10469695, - 0x104714f7, - 0x104787c7, + 0x10321469, + 0x10329475, + 0x1033148e, + 0x103394a1, + 0x10340dd2, + 0x103494c0, + 0x103514d5, + 0x10359507, + 0x10361520, + 0x10369535, + 0x10371553, + 0x10379562, + 0x1038157e, + 0x10389599, + 0x103915a8, + 0x103995c4, + 0x103a15df, + 0x103a95f6, + 0x103b1607, + 0x103b961b, + 0x103c163a, + 0x103c9649, + 0x103d1660, + 0x103d9673, + 0x103e0b5d, + 0x103e96a4, + 0x103f16b7, + 0x103f96d1, + 0x104016e1, + 0x104096f5, + 0x1041170b, + 0x10419723, + 0x10421738, + 0x1042974c, + 0x1043175e, + 0x104385c1, + 0x104408b2, + 0x10449773, + 0x1045178a, + 0x1045979f, + 0x104617ad, + 0x10469686, + 0x104714e8, + 0x104787b8, 0x104800b0, - 0x104894c3, - 0x14320b4f, - 0x14328b5d, - 0x14330b6c, - 0x14338b7e, + 0x104894b4, + 0x14320b40, + 0x14328b4e, + 0x14330b5d, + 0x14338b6f, 0x18320083, - 0x18328e47, - 0x18340e75, - 0x18348e89, - 0x18358ec0, - 0x18368eed, - 0x18370f00, - 0x18378f14, - 0x18380f38, - 0x18388f46, - 0x18390f5c, - 0x18398f70, - 0x183a0f80, - 0x183b0f90, - 0x183b8fa5, - 0x183c8fd0, - 0x183d0fe4, - 0x183d8ff4, - 0x183e0b9b, - 0x183e9001, - 0x183f1013, - 0x183f901e, - 0x1840102e, - 0x1840903f, - 0x18411050, - 0x18419062, - 0x1842108b, - 0x184290bd, - 0x184310cc, - 0x18451135, - 0x1845914b, - 0x18461166, - 0x18468ed8, - 0x184709d9, + 0x18328e38, + 0x18340e66, + 0x18348e7a, + 0x18358eb1, + 0x18368ede, + 0x18370ef1, + 0x18378f05, + 0x18380f29, + 0x18388f37, + 0x18390f4d, + 0x18398f61, + 0x183a0f71, + 0x183b0f81, + 0x183b8f96, + 0x183c8fc1, + 0x183d0fd5, + 0x183d8fe5, + 0x183e0b8c, + 0x183e8ff2, + 0x183f1004, + 0x183f900f, + 0x1840101f, + 0x18409030, + 0x18411041, + 0x18419053, + 0x1842107c, + 0x184290ae, + 0x184310bd, + 0x18451126, + 0x1845913c, + 0x18461157, + 0x18468ec9, + 0x184709ca, 0x18478094, - 0x18480fbc, - 0x18489101, - 0x18490e5d, - 0x18498e9e, - 0x184a119c, - 0x184a9119, - 0x184b10e0, - 0x184b8e37, - 0x184c10a4, - 0x184c866b, - 0x184d1181, - 0x203211c3, - 0x243211cf, - 0x24328907, - 0x243311e1, - 0x243391ee, - 0x243411fb, - 0x2434920d, - 0x2435121c, - 0x24359239, - 0x24361246, - 0x24369254, - 0x24371262, - 0x24379270, - 0x24381279, - 0x24389286, - 0x24391299, - 0x28320b8f, - 0x28328b9b, - 0x28330b6c, - 0x28338bae, - 0x2c32281d, - 0x2c32a82b, - 0x2c33283d, - 0x2c33a84f, - 0x2c342863, - 0x2c34a875, - 0x2c352890, - 0x2c35a8a2, - 0x2c3628b5, + 0x18480fad, + 0x184890f2, + 0x18490e4e, + 0x18498e8f, + 0x184a118d, + 0x184a910a, + 0x184b10d1, + 0x184b8e28, + 0x184c1095, + 0x184c865c, + 0x184d1172, + 0x203211b4, + 0x243211c0, + 0x243288f8, + 0x243311d2, + 0x243391df, + 0x243411ec, + 0x243491fe, + 0x2435120d, + 0x2435922a, + 0x24361237, + 0x24369245, + 0x24371253, + 0x24379261, + 0x2438126a, + 0x24389277, + 0x2439128a, + 0x28320b80, + 0x28328b8c, + 0x28330b5d, + 0x28338b9f, + 0x2c32280e, + 0x2c32a81c, + 0x2c33282e, + 0x2c33a840, + 0x2c342854, + 0x2c34a866, + 0x2c352881, + 0x2c35a893, + 0x2c3628a6, 0x2c3682f3, - 0x2c3728c2, - 0x2c37a8d4, - 0x2c3828e7, - 0x2c38a8f5, - 0x2c392905, - 0x2c39a917, - 0x2c3a292b, - 0x2c3aa93c, - 0x2c3b1359, - 0x2c3ba94d, - 0x2c3c2961, - 0x2c3ca977, - 0x2c3d2990, - 0x2c3da9be, - 0x2c3e29cc, - 0x2c3ea9e4, - 0x2c3f29fc, - 0x2c3faa09, - 0x2c402a2c, - 0x2c40aa4b, - 0x2c4111c3, - 0x2c41aa5c, - 0x2c422a6f, - 0x2c429135, - 0x2c432a80, - 0x2c4386a2, - 0x2c4429ad, + 0x2c3728b3, + 0x2c37a8c5, + 0x2c3828d8, + 0x2c38a8e6, + 0x2c3928f6, + 0x2c39a908, + 0x2c3a291c, + 0x2c3aa92d, + 0x2c3b134a, + 0x2c3ba93e, + 0x2c3c2952, + 0x2c3ca968, + 0x2c3d2981, + 0x2c3da9af, + 0x2c3e29bd, + 0x2c3ea9d5, + 0x2c3f29ed, + 0x2c3fa9fa, + 0x2c402a1d, + 0x2c40aa3c, + 0x2c4111b4, + 0x2c41aa4d, + 0x2c422a60, + 0x2c429126, + 0x2c432a71, + 0x2c438693, + 0x2c44299e, 0x30320000, 0x30328015, 0x3033001f, @@ -277,399 +277,398 @@ 0x304a03b4, 0x304a83c7, 0x304b03d2, - 0x304b83e1, - 0x304c03f2, - 0x304c83fe, - 0x304d0414, - 0x304d8422, - 0x304e0438, - 0x304e844a, - 0x304f045c, - 0x304f846f, - 0x30500482, - 0x30508493, - 0x305104a3, - 0x305184bb, - 0x305204d0, - 0x305284e8, - 0x305304fc, - 0x30538514, - 0x3054052d, - 0x30548546, - 0x30550563, - 0x3055856e, - 0x30560586, - 0x30568596, - 0x305705a7, - 0x305785ba, - 0x305805d0, - 0x305885d9, - 0x305905ee, + 0x304b83e3, + 0x304c03ef, + 0x304c8405, + 0x304d0413, + 0x304d8429, + 0x304e043b, + 0x304e844d, + 0x304f0460, + 0x304f8473, + 0x30500484, + 0x30508494, + 0x305104ac, + 0x305184c1, + 0x305204d9, + 0x305284ed, + 0x30530505, + 0x3053851e, + 0x30540537, + 0x30548554, + 0x3055055f, + 0x30558577, + 0x30560587, + 0x30568598, + 0x305705ab, + 0x305785c1, + 0x305805ca, + 0x305885df, + 0x305905f2, 0x30598601, - 0x305a0610, + 0x305a0621, 0x305a8630, - 0x305b063f, - 0x305b864b, - 0x305c066b, - 0x305c8687, - 0x305d0698, - 0x305d86a2, - 0x34320ac9, - 0x34328add, - 0x34330afa, - 0x34338b0d, - 0x34340b1c, - 0x34348b39, + 0x305b063c, + 0x305b865c, + 0x305c0678, + 0x305c8689, + 0x305d0693, + 0x34320aba, + 0x34328ace, + 0x34330aeb, + 0x34338afe, + 0x34340b0d, + 0x34348b2a, 0x3c320083, - 0x3c328bd8, - 0x3c330bf1, - 0x3c338c0c, - 0x3c340c29, - 0x3c348c44, - 0x3c350c5f, - 0x3c358c74, - 0x3c360c8d, - 0x3c368ca5, - 0x3c370cb6, - 0x3c378cc4, - 0x3c380cd1, - 0x3c388ce5, - 0x3c390b9b, - 0x3c398cf9, - 0x3c3a0d0d, - 0x3c3a8881, - 0x3c3b0d1d, - 0x3c3b8d38, - 0x3c3c0d4a, - 0x3c3c8d60, - 0x3c3d0d6a, - 0x3c3d8d7e, - 0x3c3e0d8c, - 0x3c3e8db1, - 0x3c3f0bc4, - 0x3c3f8d9a, - 0x403217d3, - 0x403297e9, - 0x40331817, - 0x40339821, - 0x40341838, - 0x40349856, - 0x40351866, - 0x40359878, - 0x40361885, - 0x40369891, - 0x403718a6, - 0x403798b8, - 0x403818c3, - 0x403898d5, - 0x40390de1, - 0x403998e5, - 0x403a18f8, - 0x403a9919, - 0x403b192a, - 0x403b993a, + 0x3c328bc9, + 0x3c330be2, + 0x3c338bfd, + 0x3c340c1a, + 0x3c348c35, + 0x3c350c50, + 0x3c358c65, + 0x3c360c7e, + 0x3c368c96, + 0x3c370ca7, + 0x3c378cb5, + 0x3c380cc2, + 0x3c388cd6, + 0x3c390b8c, + 0x3c398cea, + 0x3c3a0cfe, + 0x3c3a8872, + 0x3c3b0d0e, + 0x3c3b8d29, + 0x3c3c0d3b, + 0x3c3c8d51, + 0x3c3d0d5b, + 0x3c3d8d6f, + 0x3c3e0d7d, + 0x3c3e8da2, + 0x3c3f0bb5, + 0x3c3f8d8b, + 0x403217c4, + 0x403297da, + 0x40331808, + 0x40339812, + 0x40341829, + 0x40349847, + 0x40351857, + 0x40359869, + 0x40361876, + 0x40369882, + 0x40371897, + 0x403798a9, + 0x403818b4, + 0x403898c6, + 0x40390dd2, + 0x403998d6, + 0x403a18e9, + 0x403a990a, + 0x403b191b, + 0x403b992b, 0x403c0064, 0x403c8083, - 0x403d1946, - 0x403d995c, - 0x403e196b, - 0x403e997e, - 0x403f1998, - 0x403f99a6, - 0x404019bb, - 0x404099cf, - 0x404119ec, - 0x40419a07, - 0x40421a20, - 0x40429a33, - 0x40431a47, - 0x40439a5f, - 0x40441a76, + 0x403d1937, + 0x403d994d, + 0x403e195c, + 0x403e996f, + 0x403f1989, + 0x403f9997, + 0x404019ac, + 0x404099c0, + 0x404119dd, + 0x404199f8, + 0x40421a11, + 0x40429a24, + 0x40431a38, + 0x40439a50, + 0x40441a67, 0x40448094, - 0x40451a8b, - 0x40459a9d, - 0x40461ac1, - 0x40469ae1, - 0x40471aef, - 0x40479b03, - 0x40481b18, - 0x40489b31, - 0x40491b48, - 0x40499b62, - 0x404a1b79, - 0x404a9b97, - 0x404b1baf, - 0x404b9bc6, - 0x404c1bdc, - 0x404c9bee, - 0x404d1c0f, - 0x404d9c31, - 0x404e1c45, - 0x404e9c52, - 0x404f1c69, - 0x404f9c79, - 0x40501c89, - 0x40509c9d, - 0x40511cb8, - 0x40519cc8, - 0x40521cdf, - 0x40529cf1, - 0x40531d09, - 0x40539d1c, - 0x40541d31, - 0x40549d54, - 0x40551d62, - 0x40559d7f, - 0x40561d8c, - 0x40569da5, - 0x40571dbd, - 0x40579dd0, - 0x40581de5, - 0x40589df7, - 0x40591e07, - 0x40599e20, - 0x405a1e34, - 0x405a9e44, - 0x405b1e5c, - 0x405b9e6d, - 0x405c1e80, - 0x405c9e91, - 0x405d1e9e, - 0x405d9eb5, - 0x405e1ed5, - 0x405e8a17, - 0x405f1ef6, - 0x405f9f03, - 0x40601f11, - 0x40609f33, - 0x40611f5b, - 0x40619f70, - 0x40621f87, - 0x40629f98, - 0x40631fa9, - 0x40639fbe, - 0x40641fd5, - 0x40649fe6, - 0x40652001, - 0x4065a018, - 0x40662030, - 0x4066a05a, - 0x40672085, - 0x4067a0a6, - 0x406820b9, - 0x4068a0da, - 0x406920f5, - 0x4069a123, - 0x406a2144, - 0x406aa164, - 0x406b22ec, - 0x406ba30f, - 0x406c2325, - 0x406ca551, - 0x406d2580, - 0x406da5a8, - 0x406e25c1, - 0x406ea5d9, - 0x406f25f8, - 0x406fa60d, - 0x40702620, - 0x4070a63d, - 0x40710782, - 0x4071a64f, - 0x40722662, - 0x4072a67b, - 0x40732693, - 0x407390bd, - 0x407426a7, - 0x4074a6c1, - 0x407526d2, - 0x4075a6e6, - 0x407626f4, - 0x40769286, - 0x40772719, - 0x4077a73b, - 0x40782756, - 0x4078a76b, - 0x40792782, - 0x4079a798, - 0x407a27a4, - 0x407aa7b7, - 0x407b27cc, - 0x407ba7de, - 0x407c27f3, - 0x407ca7fc, - 0x41f42217, - 0x41f922a9, - 0x41fe219c, - 0x41fea378, - 0x41ff2469, - 0x42032230, - 0x42082252, - 0x4208a28e, - 0x42092180, - 0x4209a2c8, - 0x420a21d7, - 0x420aa1b7, - 0x420b21f7, - 0x420ba270, - 0x420c2485, - 0x420ca345, - 0x420d235f, - 0x420da396, - 0x421223b0, - 0x4217244c, - 0x4217a3f2, - 0x421c2414, - 0x421f23cf, - 0x4221249c, - 0x4226242f, - 0x422b2535, - 0x422ba4fe, - 0x422c251d, - 0x422ca4d8, - 0x422d24b7, - 0x443206ad, - 0x443286bc, - 0x443306c8, - 0x443386d6, - 0x443406e9, - 0x443486fa, - 0x44350701, - 0x4435870b, - 0x4436071e, - 0x44368734, - 0x44370746, - 0x44378753, - 0x44380762, - 0x4438876a, - 0x44390782, - 0x44398790, - 0x443a07a3, - 0x4c3212b0, - 0x4c3292c0, - 0x4c3312d3, - 0x4c3392f3, + 0x40451a7c, + 0x40459a8e, + 0x40461ab2, + 0x40469ad2, + 0x40471ae0, + 0x40479af4, + 0x40481b09, + 0x40489b22, + 0x40491b39, + 0x40499b53, + 0x404a1b6a, + 0x404a9b88, + 0x404b1ba0, + 0x404b9bb7, + 0x404c1bcd, + 0x404c9bdf, + 0x404d1c00, + 0x404d9c22, + 0x404e1c36, + 0x404e9c43, + 0x404f1c5a, + 0x404f9c6a, + 0x40501c7a, + 0x40509c8e, + 0x40511ca9, + 0x40519cb9, + 0x40521cd0, + 0x40529ce2, + 0x40531cfa, + 0x40539d0d, + 0x40541d22, + 0x40549d45, + 0x40551d53, + 0x40559d70, + 0x40561d7d, + 0x40569d96, + 0x40571dae, + 0x40579dc1, + 0x40581dd6, + 0x40589de8, + 0x40591df8, + 0x40599e11, + 0x405a1e25, + 0x405a9e35, + 0x405b1e4d, + 0x405b9e5e, + 0x405c1e71, + 0x405c9e82, + 0x405d1e8f, + 0x405d9ea6, + 0x405e1ec6, + 0x405e8a08, + 0x405f1ee7, + 0x405f9ef4, + 0x40601f02, + 0x40609f24, + 0x40611f4c, + 0x40619f61, + 0x40621f78, + 0x40629f89, + 0x40631f9a, + 0x40639faf, + 0x40641fc6, + 0x40649fd7, + 0x40651ff2, + 0x4065a009, + 0x40662021, + 0x4066a04b, + 0x40672076, + 0x4067a097, + 0x406820aa, + 0x4068a0cb, + 0x406920e6, + 0x4069a114, + 0x406a2135, + 0x406aa155, + 0x406b22dd, + 0x406ba300, + 0x406c2316, + 0x406ca542, + 0x406d2571, + 0x406da599, + 0x406e25b2, + 0x406ea5ca, + 0x406f25e9, + 0x406fa5fe, + 0x40702611, + 0x4070a62e, + 0x40710773, + 0x4071a640, + 0x40722653, + 0x4072a66c, + 0x40732684, + 0x407390ae, + 0x40742698, + 0x4074a6b2, + 0x407526c3, + 0x4075a6d7, + 0x407626e5, + 0x40769277, + 0x4077270a, + 0x4077a72c, + 0x40782747, + 0x4078a75c, + 0x40792773, + 0x4079a789, + 0x407a2795, + 0x407aa7a8, + 0x407b27bd, + 0x407ba7cf, + 0x407c27e4, + 0x407ca7ed, + 0x41f42208, + 0x41f9229a, + 0x41fe218d, + 0x41fea369, + 0x41ff245a, + 0x42032221, + 0x42082243, + 0x4208a27f, + 0x42092171, + 0x4209a2b9, + 0x420a21c8, + 0x420aa1a8, + 0x420b21e8, + 0x420ba261, + 0x420c2476, + 0x420ca336, + 0x420d2350, + 0x420da387, + 0x421223a1, + 0x4217243d, + 0x4217a3e3, + 0x421c2405, + 0x421f23c0, + 0x4221248d, + 0x42262420, + 0x422b2526, + 0x422ba4ef, + 0x422c250e, + 0x422ca4c9, + 0x422d24a8, + 0x4432069e, + 0x443286ad, + 0x443306b9, + 0x443386c7, + 0x443406da, + 0x443486eb, + 0x443506f2, + 0x443586fc, + 0x4436070f, + 0x44368725, + 0x44370737, + 0x44378744, + 0x44380753, + 0x4438875b, + 0x44390773, + 0x44398781, + 0x443a0794, + 0x4c3212a1, + 0x4c3292b1, + 0x4c3312c4, + 0x4c3392e4, 0x4c340094, 0x4c3480b0, - 0x4c3512ff, - 0x4c35930d, - 0x4c361329, - 0x4c36933c, - 0x4c37134b, - 0x4c379359, - 0x4c38136e, - 0x4c38937a, - 0x4c39139a, - 0x4c3993c4, - 0x4c3a13dd, - 0x4c3a93f6, - 0x4c3b05d0, - 0x4c3b940f, - 0x4c3c1421, - 0x4c3c9430, - 0x4c3d10bd, - 0x4c3d9449, - 0x4c3e1456, - 0x50322a92, - 0x5032aaa1, - 0x50332aac, - 0x5033aabc, - 0x50342ad5, - 0x5034aaef, - 0x50352afd, - 0x5035ab13, - 0x50362b25, - 0x5036ab3b, - 0x50372b54, - 0x5037ab67, - 0x50382b7f, - 0x5038ab90, - 0x50392ba5, - 0x5039abb9, - 0x503a2bd9, - 0x503aabef, - 0x503b2c07, - 0x503bac19, - 0x503c2c35, - 0x503cac4c, - 0x503d2c65, - 0x503dac7b, - 0x503e2c88, - 0x503eac9e, - 0x503f2cb0, + 0x4c3512f0, + 0x4c3592fe, + 0x4c36131a, + 0x4c36932d, + 0x4c37133c, + 0x4c37934a, + 0x4c38135f, + 0x4c38936b, + 0x4c39138b, + 0x4c3993b5, + 0x4c3a13ce, + 0x4c3a93e7, + 0x4c3b05c1, + 0x4c3b9400, + 0x4c3c1412, + 0x4c3c9421, + 0x4c3d10ae, + 0x4c3d943a, + 0x4c3e1447, + 0x50322a83, + 0x5032aa92, + 0x50332a9d, + 0x5033aaad, + 0x50342ac6, + 0x5034aae0, + 0x50352aee, + 0x5035ab04, + 0x50362b16, + 0x5036ab2c, + 0x50372b45, + 0x5037ab58, + 0x50382b70, + 0x5038ab81, + 0x50392b96, + 0x5039abaa, + 0x503a2bca, + 0x503aabe0, + 0x503b2bf8, + 0x503bac0a, + 0x503c2c26, + 0x503cac3d, + 0x503d2c56, + 0x503dac6c, + 0x503e2c79, + 0x503eac8f, + 0x503f2ca1, 0x503f8348, - 0x50402cc3, - 0x5040acd3, - 0x50412ced, - 0x5041acfc, - 0x50422d16, - 0x5042ad33, - 0x50432d43, - 0x5043ad53, - 0x50442d62, - 0x50448414, - 0x50452d76, - 0x5045ad94, - 0x50462da7, - 0x5046adbd, - 0x50472dcf, - 0x5047ade4, - 0x50482e0a, - 0x5048ae18, - 0x50492e2b, - 0x5049ae40, - 0x504a2e56, - 0x504aae66, - 0x504b2e86, - 0x504bae99, - 0x504c2ebc, - 0x504caeea, - 0x504d2efc, - 0x504daf19, - 0x504e2f34, - 0x504eaf50, - 0x504f2f62, - 0x504faf79, - 0x50502f88, - 0x50508687, - 0x50512f9b, - 0x58320e1f, - 0x68320de1, - 0x68328b9b, - 0x68330bae, - 0x68338def, - 0x68340dff, + 0x50402cb4, + 0x5040acc4, + 0x50412cde, + 0x5041aced, + 0x50422d07, + 0x5042ad24, + 0x50432d34, + 0x5043ad44, + 0x50442d53, + 0x50448405, + 0x50452d67, + 0x5045ad85, + 0x50462d98, + 0x5046adae, + 0x50472dc0, + 0x5047add5, + 0x50482dfb, + 0x5048ae09, + 0x50492e1c, + 0x5049ae31, + 0x504a2e47, + 0x504aae57, + 0x504b2e77, + 0x504bae8a, + 0x504c2ead, + 0x504caedb, + 0x504d2eed, + 0x504daf0a, + 0x504e2f25, + 0x504eaf41, + 0x504f2f53, + 0x504faf6a, + 0x50502f79, + 0x50508678, + 0x50512f8c, + 0x58320e10, + 0x68320dd2, + 0x68328b8c, + 0x68330b9f, + 0x68338de0, + 0x68340df0, 0x683480b0, - 0x6c320dbd, - 0x6c328b7e, - 0x6c330dc8, - 0x7432098d, - 0x783208f2, - 0x78328907, - 0x78330913, + 0x6c320dae, + 0x6c328b6f, + 0x6c330db9, + 0x7432097e, + 0x783208e3, + 0x783288f8, + 0x78330904, 0x78338083, - 0x78340922, - 0x78348937, - 0x78350956, - 0x78358978, - 0x7836098d, - 0x783689a3, - 0x783709b3, - 0x783789c6, - 0x783809d9, - 0x783889eb, - 0x783909f8, - 0x78398a17, - 0x783a0a2c, - 0x783a8a3a, - 0x783b0a44, - 0x783b8a58, - 0x783c0a6f, - 0x783c8a84, - 0x783d0a9b, - 0x783d8ab0, - 0x783e0a06, - 0x7c3211b2, + 0x78340913, + 0x78348928, + 0x78350947, + 0x78358969, + 0x7836097e, + 0x78368994, + 0x783709a4, + 0x783789b7, + 0x783809ca, + 0x783889dc, + 0x783909e9, + 0x78398a08, + 0x783a0a1d, + 0x783a8a2b, + 0x783b0a35, + 0x783b8a49, + 0x783c0a60, + 0x783c8a75, + 0x783d0a8c, + 0x783d8aa1, + 0x783e09f7, + 0x7c3211a3, }; const size_t kOpenSSLReasonValuesLen = sizeof(kOpenSSLReasonValues) / sizeof(kOpenSSLReasonValues[0]); @@ -725,7 +724,6 @@ "INVALID_UNIVERSALSTRING_LENGTH\0" "INVALID_UTF8STRING\0" "LIST_ERROR\0" - "MALLOC_FAILURE\0" "MISSING_ASN1_EOS\0" "MISSING_EOC\0" "MISSING_SECOND_NUMBER\0"
diff --git a/third_party/boringssl/linux-aarch64/crypto/aes/aesv8-armx64.S b/third_party/boringssl/linux-aarch64/crypto/aes/aesv8-armx64.S index fa2abbc..51cdd9c 100644 --- a/third_party/boringssl/linux-aarch64/crypto/aes/aesv8-armx64.S +++ b/third_party/boringssl/linux-aarch64/crypto/aes/aesv8-armx64.S
@@ -748,4 +748,4 @@ ret .size aes_v8_ctr32_encrypt_blocks,.-aes_v8_ctr32_encrypt_blocks #endif -#endif \ No newline at end of file +#endif
diff --git a/third_party/boringssl/linux-aarch64/crypto/bn/armv8-mont.S b/third_party/boringssl/linux-aarch64/crypto/bn/armv8-mont.S index 9355ce7..7bc81cc 100644 --- a/third_party/boringssl/linux-aarch64/crypto/bn/armv8-mont.S +++ b/third_party/boringssl/linux-aarch64/crypto/bn/armv8-mont.S
@@ -1403,4 +1403,4 @@ .byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 2 .align 4 -#endif \ No newline at end of file +#endif
diff --git a/third_party/boringssl/linux-aarch64/crypto/modes/ghashv8-armx64.S b/third_party/boringssl/linux-aarch64/crypto/modes/ghashv8-armx64.S index 8d44667..8158063 100644 --- a/third_party/boringssl/linux-aarch64/crypto/modes/ghashv8-armx64.S +++ b/third_party/boringssl/linux-aarch64/crypto/modes/ghashv8-armx64.S
@@ -229,4 +229,4 @@ .byte 71,72,65,83,72,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 2 .align 2 -#endif \ No newline at end of file +#endif
diff --git a/third_party/boringssl/linux-aarch64/crypto/sha/sha1-armv8.S b/third_party/boringssl/linux-aarch64/crypto/sha/sha1-armv8.S index 6cf9877e..53cc8e7 100644 --- a/third_party/boringssl/linux-aarch64/crypto/sha/sha1-armv8.S +++ b/third_party/boringssl/linux-aarch64/crypto/sha/sha1-armv8.S
@@ -1212,4 +1212,4 @@ .align 2 .align 2 .comm OPENSSL_armcap_P,4,4 -#endif \ No newline at end of file +#endif
diff --git a/third_party/boringssl/linux-aarch64/crypto/sha/sha256-armv8.S b/third_party/boringssl/linux-aarch64/crypto/sha/sha256-armv8.S index 0fad009..5309b47 100644 --- a/third_party/boringssl/linux-aarch64/crypto/sha/sha256-armv8.S +++ b/third_party/boringssl/linux-aarch64/crypto/sha/sha256-armv8.S
@@ -1142,4 +1142,4 @@ ret .size sha256_block_armv8,.-sha256_block_armv8 .comm OPENSSL_armcap_P,4,4 -#endif \ No newline at end of file +#endif
diff --git a/third_party/boringssl/linux-aarch64/crypto/sha/sha512-armv8.S b/third_party/boringssl/linux-aarch64/crypto/sha/sha512-armv8.S index 517c033f..52549950 100644 --- a/third_party/boringssl/linux-aarch64/crypto/sha/sha512-armv8.S +++ b/third_party/boringssl/linux-aarch64/crypto/sha/sha512-armv8.S
@@ -1022,4 +1022,4 @@ .align 2 .align 2 .comm OPENSSL_armcap_P,4,4 -#endif \ No newline at end of file +#endif
diff --git a/third_party/boringssl/linux-arm/crypto/aes/aes-armv4.S b/third_party/boringssl/linux-arm/crypto/aes/aes-armv4.S index c4d7065..bc11e3f 100644 --- a/third_party/boringssl/linux-arm/crypto/aes/aes-armv4.S +++ b/third_party/boringssl/linux-arm/crypto/aes/aes-armv4.S
@@ -1197,4 +1197,4 @@ .align 2 #endif -#endif \ No newline at end of file +#endif
diff --git a/third_party/boringssl/linux-arm/crypto/aes/aesv8-armx32.S b/third_party/boringssl/linux-arm/crypto/aes/aesv8-armx32.S index 6012b0c..46ba32c 100644 --- a/third_party/boringssl/linux-arm/crypto/aes/aesv8-armx32.S +++ b/third_party/boringssl/linux-arm/crypto/aes/aesv8-armx32.S
@@ -753,4 +753,4 @@ ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,pc} .size aes_v8_ctr32_encrypt_blocks,.-aes_v8_ctr32_encrypt_blocks #endif -#endif \ No newline at end of file +#endif
diff --git a/third_party/boringssl/linux-arm/crypto/aes/bsaes-armv7.S b/third_party/boringssl/linux-arm/crypto/aes/bsaes-armv7.S index a3ebec8..abb414d 100644 --- a/third_party/boringssl/linux-arm/crypto/aes/bsaes-armv7.S +++ b/third_party/boringssl/linux-arm/crypto/aes/bsaes-armv7.S
@@ -2574,4 +2574,4 @@ .size bsaes_xts_decrypt,.-bsaes_xts_decrypt #endif -#endif \ No newline at end of file +#endif
diff --git a/third_party/boringssl/linux-arm/crypto/bn/armv4-mont.S b/third_party/boringssl/linux-arm/crypto/bn/armv4-mont.S index fc671e8d..28fbcf9 100644 --- a/third_party/boringssl/linux-arm/crypto/bn/armv4-mont.S +++ b/third_party/boringssl/linux-arm/crypto/bn/armv4-mont.S
@@ -586,4 +586,4 @@ .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P #endif -#endif \ No newline at end of file +#endif
diff --git a/third_party/boringssl/linux-arm/crypto/modes/ghash-armv4.S b/third_party/boringssl/linux-arm/crypto/modes/ghash-armv4.S index d955d82..791b2890 100644 --- a/third_party/boringssl/linux-arm/crypto/modes/ghash-armv4.S +++ b/third_party/boringssl/linux-arm/crypto/modes/ghash-armv4.S
@@ -535,4 +535,4 @@ .byte 71,72,65,83,72,32,102,111,114,32,65,82,77,118,52,47,78,69,79,78,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 2 .align 2 -#endif \ No newline at end of file +#endif
diff --git a/third_party/boringssl/linux-arm/crypto/modes/ghashv8-armx32.S b/third_party/boringssl/linux-arm/crypto/modes/ghashv8-armx32.S index 9a38ded4..129bb6e4 100644 --- a/third_party/boringssl/linux-arm/crypto/modes/ghashv8-armx32.S +++ b/third_party/boringssl/linux-arm/crypto/modes/ghashv8-armx32.S
@@ -230,4 +230,4 @@ .byte 71,72,65,83,72,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 2 .align 2 -#endif \ No newline at end of file +#endif
diff --git a/third_party/boringssl/linux-arm/crypto/sha/sha1-armv4-large.S b/third_party/boringssl/linux-arm/crypto/sha/sha1-armv4-large.S index 66d0ef3..3c122da 100644 --- a/third_party/boringssl/linux-arm/crypto/sha/sha1-armv4-large.S +++ b/third_party/boringssl/linux-arm/crypto/sha/sha1-armv4-large.S
@@ -1459,4 +1459,4 @@ .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P #endif -#endif \ No newline at end of file +#endif
diff --git a/third_party/boringssl/linux-arm/crypto/sha/sha256-armv4.S b/third_party/boringssl/linux-arm/crypto/sha/sha256-armv4.S index 9fc3e0b..e71eaa0f 100644 --- a/third_party/boringssl/linux-arm/crypto/sha/sha256-armv4.S +++ b/third_party/boringssl/linux-arm/crypto/sha/sha256-armv4.S
@@ -2815,4 +2815,4 @@ .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P #endif -#endif \ No newline at end of file +#endif
diff --git a/third_party/boringssl/linux-arm/crypto/sha/sha512-armv4.S b/third_party/boringssl/linux-arm/crypto/sha/sha512-armv4.S index 834ede9c..f351dd25 100644 --- a/third_party/boringssl/linux-arm/crypto/sha/sha512-armv4.S +++ b/third_party/boringssl/linux-arm/crypto/sha/sha512-armv4.S
@@ -1866,4 +1866,4 @@ .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P #endif -#endif \ No newline at end of file +#endif
diff --git a/third_party/closure_compiler/externs/bluetooth.js b/third_party/closure_compiler/externs/bluetooth.js index 43162bf..ca5038be 100644 --- a/third_party/closure_compiler/externs/bluetooth.js +++ b/third_party/closure_compiler/externs/bluetooth.js
@@ -82,7 +82,7 @@ /** * Get information about the Bluetooth adapter. * @param {function(!chrome.bluetooth.AdapterState):void} callback Called with - * an AdapterState object describing the adapter state. + * an AdapterState object describing the adapter state. * @see https://developer.chrome.com/extensions/bluetooth#method-getAdapterState */ chrome.bluetooth.getAdapterState = function(callback) {};
diff --git a/third_party/closure_compiler/externs/bluetooth_private.js b/third_party/closure_compiler/externs/bluetooth_private.js index ed9905f..8e04526b 100644 --- a/third_party/closure_compiler/externs/bluetooth_private.js +++ b/third_party/closure_compiler/externs/bluetooth_private.js
@@ -47,8 +47,8 @@ AUTH_TIMEOUT: 'authTimeout', CONNECTION_CONGESTED: 'connectionCongested', FAILED: 'failed', - INSUFFICIENT_ENCRYPTION: 'insufficientEncryption', IN_PROGRESS: 'inProgress', + INSUFFICIENT_ENCRYPTION: 'insufficientEncryption', OFFSET_INVALID: 'offsetInvalid', READ_NOT_PERMITTED: 'readNotPermitted', REQUEST_NOT_SUPPORTED: 'requestNotSupported',
diff --git a/third_party/closure_compiler/externs/settings_private.js b/third_party/closure_compiler/externs/settings_private.js index 5988b39..228516f 100644 --- a/third_party/closure_compiler/externs/settings_private.js +++ b/third_party/closure_compiler/externs/settings_private.js
@@ -26,6 +26,7 @@ STRING: 'STRING', URL: 'URL', LIST: 'LIST', + DICTIONARY: 'DICTIONARY', }; /**
diff --git a/tools/battor_agent/battor_connection_impl.cc b/tools/battor_agent/battor_connection_impl.cc index dc6af07..37accf8 100644 --- a/tools/battor_agent/battor_connection_impl.cc +++ b/tools/battor_agent/battor_connection_impl.cc
@@ -19,10 +19,10 @@ // Serial configuration parameters for the BattOr. const uint32_t kBattOrBitrate = 2000000; const device::serial::DataBits kBattOrDataBits = - device::serial::DATA_BITS_EIGHT; + device::serial::DataBits::EIGHT; const device::serial::ParityBit kBattOrParityBit = - device::serial::PARITY_BIT_NONE; -const device::serial::StopBits kBattOrStopBit = device::serial::STOP_BITS_ONE; + device::serial::ParityBit::NONE; +const device::serial::StopBits kBattOrStopBit = device::serial::StopBits::ONE; const bool kBattOrCtsFlowControl = true; const bool kBattOrHasCtsFlowControl = true; // The maximum BattOr message is 50kB long. @@ -161,7 +161,7 @@ void BattOrConnectionImpl::OnBytesRead(int bytes_read, device::serial::ReceiveError error) { - if (bytes_read == 0 || error != device::serial::RECEIVE_ERROR_NONE) { + if (bytes_read == 0 || error != device::serial::ReceiveError::NONE) { // If we didn't have a message before, and we weren't able to read any // additional bytes, then there's no valid message available. EndReadBytes(false, BATTOR_MESSAGE_TYPE_CONTROL, nullptr); @@ -255,7 +255,7 @@ void BattOrConnectionImpl::OnBytesSent(int bytes_sent, device::serial::SendError error) { - bool success = (error == device::serial::SEND_ERROR_NONE) && + bool success = (error == device::serial::SendError::NONE) && (pending_write_length_ == static_cast<size_t>(bytes_sent)); listener_->OnBytesSent(success); }
diff --git a/tools/json_schema_compiler/js_interface_generator.py b/tools/json_schema_compiler/js_interface_generator.py index e971ff50..e6c892a8 100644 --- a/tools/json_schema_compiler/js_interface_generator.py +++ b/tools/json_schema_compiler/js_interface_generator.py
@@ -46,13 +46,15 @@ for function in self._namespace.functions.values(): self._AppendFunction(c, function) + c.TrimTrailingNewlines() + c.Eblock('};') + c.Append() + for event in self._namespace.events.values(): self._AppendEvent(c, event) c.TrimTrailingNewlines() - c.Eblock('};') - return c def _GetHeader(self, tool, namespace): @@ -93,5 +95,7 @@ c.Append(self._js_util.GetSeeLink(self._namespace.name, 'event', event.name)) c.Eblock(' */') - c.Append('%s: new ChromeEvent(),' % (event.name)) + + c.Append('%s.prototype.%s;' % (self._interface, event.name)) + c.Append()
diff --git a/tools/json_schema_compiler/js_interface_generator_test.py b/tools/json_schema_compiler/js_interface_generator_test.py index 6821ac4..90837d7 100755 --- a/tools/json_schema_compiler/js_interface_generator_test.py +++ b/tools/json_schema_compiler/js_interface_generator_test.py
@@ -104,14 +104,14 @@ * @see https://developer.chrome.com/extensions/fakeApi#method-bazGreek */ bazGreek: assertNotReached, +}; - /** - * Fired when we realize it's a trap! - * @type {!ChromeEvent} - * @see https://developer.chrome.com/extensions/fakeApi#event-onTrapDetected - */ - onTrapDetected: new ChromeEvent(), -};""" % (datetime.now().year, sys.argv[0])) +/** + * Fired when we realize it's a trap! + * @type {!ChromeEvent} + * @see https://developer.chrome.com/extensions/fakeApi#event-onTrapDetected + */ +FakeApi.prototype.onTrapDetected;""" % (datetime.now().year, sys.argv[0])) class JsExternGeneratorTest(unittest.TestCase): def _GetNamespace(self, fake_content, filename):
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index a59c7c7..3c3257b 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml
@@ -1654,7 +1654,7 @@ </summary> </histogram> -<histogram name="AsyncDNS.ServerIsGood" units="BooleanSuccess"> +<histogram name="AsyncDNS.ServerIsGood" enum="BooleanSuccess"> <owner>ttuttle@chromium.org</owner> <summary> The current server is "good" and does not have to be skipped. @@ -3829,8 +3829,7 @@ </summary> </histogram> -<histogram name="Cast.Sender.CastTimeRemainingPercentage" - units="percent remaining"> +<histogram name="Cast.Sender.CastTimeRemainingPercentage" units="%"> <owner>mfoltz@chromium.org</owner> <summary> Records the percentage of the video left at the time the remote playback is @@ -11087,7 +11086,7 @@ </summary> </histogram> -<histogram name="Event.Touch.TimedOutOnDesktopSite" units="BooleanTimedOut"> +<histogram name="Event.Touch.TimedOutOnDesktopSite" enum="BooleanTimedOut"> <owner>rbyers@chromium.org</owner> <summary> On non-mobile-optimized (desktop) sites, whether the ack response from the @@ -11096,7 +11095,7 @@ </summary> </histogram> -<histogram name="Event.Touch.TimedOutOnMobileSite" units="BooleanTimedOut"> +<histogram name="Event.Touch.TimedOutOnMobileSite" enum="BooleanTimedOut"> <owner>rbyers@chromium.org</owner> <summary> On mobile-optimized sites, whether the ack response from the renderer for @@ -14307,7 +14306,7 @@ </summary> </histogram> -<histogram name="FileBrowser.PhotoImport.ImportPercentage"> +<histogram name="FileBrowser.PhotoImport.ImportPercentage" units="%"> <owner>joshwoodward@google.com</owner> <summary> Chrome OS Photo Import flow: the percent of photos imported among all the @@ -19486,7 +19485,7 @@ </summary> </histogram> -<histogram name="Media.VideoCapture.AspectRatio"> +<histogram name="Media.VideoCapture.AspectRatio" units="%"> <owner>mcasas@chromium.org</owner> <summary> Video Capture Device captured aspect ratio, as a rounded integer multiplied @@ -19597,7 +19596,7 @@ <summary>Video codec profile used in HTML5 media.</summary> </histogram> -<histogram name="Media.VideoCodedAspectRatio"> +<histogram name="Media.VideoCodedAspectRatio" units="%"> <owner>scherkus@chromium.org</owner> <summary>Coded aspect ratio of HTML5 video.</summary> </histogram> @@ -19697,7 +19696,7 @@ </summary> </histogram> -<histogram name="Media.VideoVisibleAspectRatio"> +<histogram name="Media.VideoVisibleAspectRatio" units="%"> <owner>scherkus@chromium.org</owner> <summary>Visible aspect ratio of HTML5 video.</summary> </histogram> @@ -20448,7 +20447,7 @@ </summary> </histogram> -<histogram name="Memory.Swap.HaveSwapped" units="BooleanSuccess"> +<histogram name="Memory.Swap.HaveSwapped" enum="BooleanSuccess"> <owner>hajimehoshi@chromium.org</owner> <owner>kenjibaheux@google.com</owner> <owner>kouhei@chromium.org</owner> @@ -23988,7 +23987,7 @@ </summary> </histogram> -<histogram name="Net.ErrorResponseHasContentMainFrame" units="BooleanSuccess"> +<histogram name="Net.ErrorResponseHasContentMainFrame" enum="BooleanSuccess"> <owner>mmenke@chromium.org</owner> <summary> The number of main frame 4xx/5xx responses that have content, to determine @@ -23997,8 +23996,7 @@ </summary> </histogram> -<histogram name="Net.ErrorResponseHasContentNonMainFrame" - units="BooleanSuccess"> +<histogram name="Net.ErrorResponseHasContentNonMainFrame" enum="BooleanSuccess"> <owner>mmenke@chromium.org</owner> <summary> The number of non-main frame 4xx/5xx responses that have content, to @@ -27038,7 +27036,7 @@ </summary> </histogram> -<histogram name="Net.SpdySynStreamCompressionPercentage"> +<histogram name="Net.SpdySynStreamCompressionPercentage" units="%"> <owner>rch@chromium.org</owner> <summary> The percent compression achieved when compression SYN_STREAM frames. @@ -35762,7 +35760,7 @@ </summary> </histogram> -<histogram name="Plugin.Flash.ClickSize.AspectRatio"> +<histogram name="Plugin.Flash.ClickSize.AspectRatio" units="%"> <owner>tommycli@chromium.org</owner> <summary> Aspect ratio of Flash plugins users click at least once. The aspect ratio is @@ -39271,7 +39269,7 @@ </summary> </histogram> -<histogram name="Renderer4.GpuRasterizationEnabled" units="BooleanEnabled"> +<histogram name="Renderer4.GpuRasterizationEnabled" enum="BooleanEnabled"> <owner>alokp@chromium.org</owner> <summary> Whether gpu rasterization is enabled (checked once after the page is painted @@ -39280,7 +39278,7 @@ </histogram> <histogram name="Renderer4.GpuRasterizationSuitableContent" - units="BooleanEnabled"> + enum="BooleanEnabled"> <owner>alokp@chromium.org</owner> <summary> If gpu rasterization is enabled, whether the page contents are suitable for @@ -39289,7 +39287,7 @@ </summary> </histogram> -<histogram name="Renderer4.GpuRasterizationTriggered" units="BooleanEnabled"> +<histogram name="Renderer4.GpuRasterizationTriggered" enum="BooleanEnabled"> <owner>alokp@chromium.org</owner> <summary> If gpu rasterization is enabled, whether it was triggered (checked once @@ -39297,7 +39295,7 @@ </summary> </histogram> -<histogram name="Renderer4.GpuRasterizationUsed" units="BooleanEnabled"> +<histogram name="Renderer4.GpuRasterizationUsed" enum="BooleanEnabled"> <owner>alokp@chromium.org</owner> <summary> If gpu rasterization is enabled, whether it was actually used for the page @@ -40288,7 +40286,8 @@ </histogram> <histogram - name="ResourcePrefetchPredictor.UrlTableMainFrameUrlsDeletedNotInHistoryPercent"> + name="ResourcePrefetchPredictor.UrlTableMainFrameUrlsDeletedNotInHistoryPercent" + units="%"> <owner>zhenw@chromium.org</owner> <summary> Same as ResourcePrefetchPredictor.UrlTableMainFrameUrlsDeletedNotInHistory @@ -41380,7 +41379,7 @@ </summary> </histogram> -<histogram name="SB2.PrefixSetUnsortedPercent"> +<histogram name="SB2.PrefixSetUnsortedPercent" units="%"> <obsolete> Deprecated 9/2012. No longer generated. </obsolete> @@ -44045,7 +44044,7 @@ </summary> </histogram> -<histogram name="ServiceWorker.ScriptLoadSuccess" units="BooleanSuccess"> +<histogram name="ServiceWorker.ScriptLoadSuccess" enum="BooleanSuccess"> <owner>falken@chromium.org</owner> <summary> Whether loading the service worker script succeeded. Only recorded for @@ -48035,7 +48034,7 @@ </summary> </histogram> -<histogram name="Storage.Blob.ReusedItem" units="BooleanReused"> +<histogram name="Storage.Blob.ReusedItem" enum="BooleanReused"> <owner>dmurph@chromium.org</owner> <summary> True if we reuse an item for a blob created from using Blob.slice, recorded @@ -48097,7 +48096,7 @@ </summary> </histogram> -<histogram name="Storage.BlobItemSize.File.Unknown" units="BooleanUnknown"> +<histogram name="Storage.BlobItemSize.File.Unknown" enum="BooleanUnknown"> <owner>dmurph@chromium.org</owner> <summary> True if the file size on blob append is unknown (which means the full file), @@ -48106,8 +48105,7 @@ </summary> </histogram> -<histogram name="Storage.BlobItemSize.FileSystem.Unknown" - units="BooleanUnknown"> +<histogram name="Storage.BlobItemSize.FileSystem.Unknown" enum="BooleanUnknown"> <owner>dmurph@chromium.org</owner> <summary> True if the file size of a filesystem object on blob append is unknown @@ -50306,7 +50304,7 @@ </histogram> <histogram name="TabManager.Discarding.DiscardedTabHasBeforeUnloadHandler" - units="Boolean"> + enum="Boolean"> <owner>georgesak@chromium.org</owner> <summary> Recorded for each discarding, allowing us to know whether the discarded tab @@ -61110,6 +61108,7 @@ <int value="23" label="P-256"/> <int value="24" label="P-384"/> <int value="25" label="P-521"/> + <int value="29" label="X25519"/> </enum> <enum name="EGLDisplayType" type="int"> @@ -63789,6 +63788,8 @@ <int value="1103" label="INPUT_IME_CREATEWINDOW"/> <int value="1104" label="INPUTMETHODPRIVATE_SETXKBLAYOUT"/> <int value="1105" label="ACCESSIBILITY_PRIVATE_SETKEYBOARDLISTENER"/> + <int value="1106" label="INPUT_IME_ACTIVATE"/> + <int value="1107" label="INPUT_IME_DEACTIVATE"/> </enum> <enum name="ExtensionInstallCause" type="int">
diff --git a/tools/perf/metrics/power.py b/tools/perf/metrics/power.py index 8cb0d2d..85174e5 100644 --- a/tools/perf/metrics/power.py +++ b/tools/perf/metrics/power.py
@@ -104,6 +104,7 @@ logging.info('Closing power monitors') if self._platform.IsMonitoringPower(): self._platform.StopMonitoringPower() + self._running = False def AddResults(self, _, results): """Add the collected power data into the results object.
diff --git a/tools/telemetry/catapult_base/__init__.py b/tools/telemetry/catapult_base/__init__.py deleted file mode 100644 index 653dd32..0000000 --- a/tools/telemetry/catapult_base/__init__.py +++ /dev/null
@@ -1,23 +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. - -# All files in this directory should be moved to catapult/base/ after moving -# to the new repo. - -import os -import sys - -from catapult_base import util - -def _AddDirToPythonPath(*path_parts): - path = os.path.abspath(os.path.join(*path_parts)) - if os.path.isdir(path) and path not in sys.path: - # Some callsite that use telemetry assumes that sys.path[0] is the directory - # containing the script, so we add these extra paths to right after it. - sys.path.insert(1, path) - -_AddDirToPythonPath(os.path.join(util.GetCatapultDir(), 'third_party', 'mock')) -_AddDirToPythonPath(os.path.join(util.GetCatapultDir(), 'third_party', 'mox3')) -_AddDirToPythonPath( - os.path.join(util.GetCatapultDir(), 'third_party', 'pyfakefs'))
diff --git a/tools/telemetry/catapult_base/bin/run_tests b/tools/telemetry/catapult_base/bin/run_tests deleted file mode 100755 index 56fcbfa..0000000 --- a/tools/telemetry/catapult_base/bin/run_tests +++ /dev/null
@@ -1,38 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 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. - -import os -import sys - -_CATAPULT_BASE_PATH = os.path.abspath( - os.path.join(os.path.dirname(__file__), '..')) -_TELEMETRY_BASE_PATH = os.path.abspath(os.path.join(_CATAPULT_BASE_PATH, '..')) -_CATAPULT_PATH = os.path.abspath(os.path.join( - _CATAPULT_BASE_PATH, '..', '..', '..', 'third_party', 'catapult')) - - -def _RunTestsOrDie(top_level_dir): - exit_code = run_with_typ.Run(top_level_dir, path=[_TELEMETRY_BASE_PATH]) - if exit_code: - sys.exit(exit_code) - - -def _AddToPathIfNeeded(path): - if path not in sys.path: - sys.path.insert(0, path) - - -if __name__ == '__main__': - _AddToPathIfNeeded(_CATAPULT_PATH) - - from hooks import install - if '--no-install-hooks' in sys.argv: - sys.argv.remove('--no-install-hooks') - else: - install.InstallHooks() - - from catapult_build import run_with_typ - _RunTestsOrDie(_CATAPULT_BASE_PATH) - sys.exit(0)
diff --git a/tools/telemetry/catapult_base/cloud_storage.py b/tools/telemetry/catapult_base/cloud_storage.py deleted file mode 100644 index fe8a2cb..0000000 --- a/tools/telemetry/catapult_base/cloud_storage.py +++ /dev/null
@@ -1,348 +0,0 @@ -# Copyright 2014 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. - -"""Wrappers for gsutil, for basic interaction with Google Cloud Storage.""" - -import collections -import contextlib -import hashlib -import logging -import os -import shutil -import stat -import subprocess -import sys -import tempfile -import time - -try: - import fcntl -except ImportError: - fcntl = None - -from catapult_base import util - - -PUBLIC_BUCKET = 'chromium-telemetry' -PARTNER_BUCKET = 'chrome-partner-telemetry' -INTERNAL_BUCKET = 'chrome-telemetry' -TELEMETRY_OUTPUT = 'chrome-telemetry-output' - -# Uses ordered dict to make sure that bucket's key-value items are ordered from -# the most open to the most restrictive. -BUCKET_ALIASES = collections.OrderedDict(( - ('public', PUBLIC_BUCKET), - ('partner', PARTNER_BUCKET), - ('internal', INTERNAL_BUCKET), - ('output', TELEMETRY_OUTPUT), -)) - -BUCKET_ALIAS_NAMES = BUCKET_ALIASES.keys() - - -_GSUTIL_PATH = os.path.join(util.GetCatapultDir(), 'third_party', 'gsutil', - 'gsutil') - -# TODO(tbarzic): A workaround for http://crbug.com/386416 and -# http://crbug.com/359293. See |_RunCommand|. -_CROS_GSUTIL_HOME_WAR = '/home/chromeos-test/' - - - -class CloudStorageError(Exception): - @staticmethod - def _GetConfigInstructions(): - command = _GSUTIL_PATH - if util.IsRunningOnCrosDevice(): - command = 'HOME=%s %s' % (_CROS_GSUTIL_HOME_WAR, _GSUTIL_PATH) - return ('To configure your credentials:\n' - ' 1. Run "%s config" and follow its instructions.\n' - ' 2. If you have a @google.com account, use that account.\n' - ' 3. For the project-id, just enter 0.' % command) - - -class PermissionError(CloudStorageError): - def __init__(self): - super(PermissionError, self).__init__( - 'Attempted to access a file from Cloud Storage but you don\'t ' - 'have permission. ' + self._GetConfigInstructions()) - - -class CredentialsError(CloudStorageError): - def __init__(self): - super(CredentialsError, self).__init__( - 'Attempted to access a file from Cloud Storage but you have no ' - 'configured credentials. ' + self._GetConfigInstructions()) - - -class NotFoundError(CloudStorageError): - pass - - -class ServerError(CloudStorageError): - pass - - -# TODO(tonyg/dtu): Can this be replaced with distutils.spawn.find_executable()? -def _FindExecutableInPath(relative_executable_path, *extra_search_paths): - search_paths = list(extra_search_paths) + os.environ['PATH'].split(os.pathsep) - for search_path in search_paths: - executable_path = os.path.join(search_path, relative_executable_path) - if util.IsExecutable(executable_path): - return executable_path - return None - -def _EnsureExecutable(gsutil): - """chmod +x if gsutil is not executable.""" - st = os.stat(gsutil) - if not st.st_mode & stat.S_IEXEC: - os.chmod(gsutil, st.st_mode | stat.S_IEXEC) - -def _RunCommand(args): - # On cros device, as telemetry is running as root, home will be set to /root/, - # which is not writable. gsutil will attempt to create a download tracker dir - # in home dir and fail. To avoid this, override HOME dir to something writable - # when running on cros device. - # - # TODO(tbarzic): Figure out a better way to handle gsutil on cros. - # http://crbug.com/386416, http://crbug.com/359293. - gsutil_env = None - if util.IsRunningOnCrosDevice(): - gsutil_env = os.environ.copy() - gsutil_env['HOME'] = _CROS_GSUTIL_HOME_WAR - - if os.name == 'nt': - # If Windows, prepend python. Python scripts aren't directly executable. - args = [sys.executable, _GSUTIL_PATH] + args - else: - # Don't do it on POSIX, in case someone is using a shell script to redirect. - args = [_GSUTIL_PATH] + args - _EnsureExecutable(_GSUTIL_PATH) - - gsutil = subprocess.Popen(args, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, env=gsutil_env) - stdout, stderr = gsutil.communicate() - - if gsutil.returncode: - if stderr.startswith(( - 'You are attempting to access protected data with no configured', - 'Failure: No handler was ready to authenticate.')): - raise CredentialsError() - if ('status=403' in stderr or 'status 403' in stderr or - '403 Forbidden' in stderr): - raise PermissionError() - if (stderr.startswith('InvalidUriError') or 'No such object' in stderr or - 'No URLs matched' in stderr or 'One or more URLs matched no' in stderr): - raise NotFoundError(stderr) - if '500 Internal Server Error' in stderr: - raise ServerError(stderr) - raise CloudStorageError(stderr) - - return stdout - - -def List(bucket): - query = 'gs://%s/' % bucket - stdout = _RunCommand(['ls', query]) - return [url[len(query):] for url in stdout.splitlines()] - - -def Exists(bucket, remote_path): - try: - _RunCommand(['ls', 'gs://%s/%s' % (bucket, remote_path)]) - return True - except NotFoundError: - return False - - -def Move(bucket1, bucket2, remote_path): - url1 = 'gs://%s/%s' % (bucket1, remote_path) - url2 = 'gs://%s/%s' % (bucket2, remote_path) - logging.info('Moving %s to %s' % (url1, url2)) - _RunCommand(['mv', url1, url2]) - - -def Copy(bucket_from, bucket_to, remote_path_from, remote_path_to): - """Copy a file from one location in CloudStorage to another. - - Args: - bucket_from: The cloud storage bucket where the file is currently located. - bucket_to: The cloud storage bucket it is being copied to. - remote_path_from: The file path where the file is located in bucket_from. - remote_path_to: The file path it is being copied to in bucket_to. - - It should: cause no changes locally or to the starting file, and will - overwrite any existing files in the destination location. - """ - url1 = 'gs://%s/%s' % (bucket_from, remote_path_from) - url2 = 'gs://%s/%s' % (bucket_to, remote_path_to) - logging.info('Copying %s to %s' % (url1, url2)) - _RunCommand(['cp', url1, url2]) - - -def Delete(bucket, remote_path): - url = 'gs://%s/%s' % (bucket, remote_path) - logging.info('Deleting %s' % url) - _RunCommand(['rm', url]) - - -def Get(bucket, remote_path, local_path): - with _PseudoFileLock(local_path): - _GetLocked(bucket, remote_path, local_path) - - -@contextlib.contextmanager -def _PseudoFileLock(base_path): - pseudo_lock_path = '%s.pseudo_lock' % base_path - _CreateDirectoryIfNecessary(os.path.dirname(pseudo_lock_path)) - # This is somewhat of a racy hack because we don't have a good - # cross-platform file lock. If we get one, this should be refactored - # to use it. - while os.path.exists(pseudo_lock_path): - time.sleep(0.1) - fd = os.open(pseudo_lock_path, os.O_RDONLY | os.O_CREAT) - if fcntl: - fcntl.flock(fd, fcntl.LOCK_EX) - try: - yield - finally: - if fcntl: - fcntl.flock(fd, fcntl.LOCK_UN) - try: - os.close(fd) - os.remove(pseudo_lock_path) - except OSError: - # We don't care if the pseudo-lock gets removed elsewhere before we have - # a chance to do so. - pass - - -def _CreateDirectoryIfNecessary(directory): - if not os.path.exists(directory): - os.makedirs(directory) - - -def _GetLocked(bucket, remote_path, local_path): - url = 'gs://%s/%s' % (bucket, remote_path) - logging.info('Downloading %s to %s' % (url, local_path)) - _CreateDirectoryIfNecessary(os.path.dirname(local_path)) - with tempfile.NamedTemporaryFile( - dir=os.path.dirname(local_path), - delete=False) as partial_download_path: - try: - # Windows won't download to an open file. - partial_download_path.close() - try: - _RunCommand(['cp', url, partial_download_path.name]) - except ServerError: - logging.info('Cloud Storage server error, retrying download') - _RunCommand(['cp', url, partial_download_path.name]) - shutil.move(partial_download_path.name, local_path) - finally: - if os.path.exists(partial_download_path.name): - os.remove(partial_download_path.name) - - -def Insert(bucket, remote_path, local_path, publicly_readable=False): - """ Upload file in |local_path| to cloud storage. - Args: - bucket: the google cloud storage bucket name. - remote_path: the remote file path in |bucket|. - local_path: path of the local file to be uploaded. - publicly_readable: whether the uploaded file has publicly readable - permission. - - Returns: - The url where the file is uploaded to. - """ - url = 'gs://%s/%s' % (bucket, remote_path) - command_and_args = ['cp'] - extra_info = '' - if publicly_readable: - command_and_args += ['-a', 'public-read'] - extra_info = ' (publicly readable)' - command_and_args += [local_path, url] - logging.info('Uploading %s to %s%s' % (local_path, url, extra_info)) - _RunCommand(command_and_args) - return 'https://console.developers.google.com/m/cloudstorage/b/%s/o/%s' % ( - bucket, remote_path) - - -def GetIfHashChanged(cs_path, download_path, bucket, file_hash): - """Downloads |download_path| to |file_path| if |file_path| doesn't exist or - it's hash doesn't match |file_hash|. - - Returns: - True if the binary was changed. - Raises: - CredentialsError if the user has no configured credentials. - PermissionError if the user does not have permission to access the bucket. - NotFoundError if the file is not in the given bucket in cloud_storage. - """ - with _PseudoFileLock(download_path): - if (os.path.exists(download_path) and - CalculateHash(download_path) == file_hash): - return False - _GetLocked(bucket, cs_path, download_path) - return True - - -def GetIfChanged(file_path, bucket): - """Gets the file at file_path if it has a hash file that doesn't match or - if there is no local copy of file_path, but there is a hash file for it. - - Returns: - True if the binary was changed. - Raises: - CredentialsError if the user has no configured credentials. - PermissionError if the user does not have permission to access the bucket. - NotFoundError if the file is not in the given bucket in cloud_storage. - """ - with _PseudoFileLock(file_path): - hash_path = file_path + '.sha1' - if not os.path.exists(hash_path): - logging.warning('Hash file not found: %s' % hash_path) - return False - - expected_hash = ReadHash(hash_path) - if os.path.exists(file_path) and CalculateHash(file_path) == expected_hash: - return False - _GetLocked(bucket, expected_hash, file_path) - return True - - -def GetFilesInDirectoryIfChanged(directory, bucket): - """ Scan the directory for .sha1 files, and download them from the given - bucket in cloud storage if the local and remote hash don't match or - there is no local copy. - """ - if not os.path.isdir(directory): - raise ValueError('Must provide a valid directory.') - # Don't allow the root directory to be a serving_dir. - if directory == os.path.abspath(os.sep): - raise ValueError('Trying to serve root directory from HTTP server.') - for dirpath, _, filenames in os.walk(directory): - for filename in filenames: - path_name, extension = os.path.splitext( - os.path.join(dirpath, filename)) - if extension != '.sha1': - continue - GetIfChanged(path_name, bucket) - -def CalculateHash(file_path): - """Calculates and returns the hash of the file at file_path.""" - sha1 = hashlib.sha1() - with open(file_path, 'rb') as f: - while True: - # Read in 1mb chunks, so it doesn't all have to be loaded into memory. - chunk = f.read(1024*1024) - if not chunk: - break - sha1.update(chunk) - return sha1.hexdigest() - - -def ReadHash(hash_path): - with open(hash_path, 'rb') as f: - return f.read(1024).rstrip()
diff --git a/tools/telemetry/catapult_base/dependency_manager/OWNERS b/tools/telemetry/catapult_base/dependency_manager/OWNERS deleted file mode 100644 index ca5ce3b9ee..0000000 --- a/tools/telemetry/catapult_base/dependency_manager/OWNERS +++ /dev/null
@@ -1 +0,0 @@ -aiolos@chromium.org
diff --git a/tools/telemetry/catapult_base/dependency_manager/__init__.py b/tools/telemetry/catapult_base/dependency_manager/__init__.py deleted file mode 100644 index aa73af98..0000000 --- a/tools/telemetry/catapult_base/dependency_manager/__init__.py +++ /dev/null
@@ -1,14 +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. - -from catapult_base.dependency_manager.archive_info import ArchiveInfo -from catapult_base.dependency_manager.base_config import BaseConfig -from catapult_base.dependency_manager.cloud_storage_info import CloudStorageInfo -from catapult_base.dependency_manager.dependency_info import DependencyInfo -from catapult_base.dependency_manager.dependency_manager import DependencyManager -from catapult_base.dependency_manager.exceptions import ( - EmptyConfigError, FileNotFoundError, NoPathFoundError, ReadWriteError, - UnsupportedConfigFormatError) -from catapult_base.dependency_manager.local_path_info import LocalPathInfo -
diff --git a/tools/telemetry/catapult_base/dependency_manager/archive_info.py b/tools/telemetry/catapult_base/dependency_manager/archive_info.py deleted file mode 100644 index 6d3361679..0000000 --- a/tools/telemetry/catapult_base/dependency_manager/archive_info.py +++ /dev/null
@@ -1,69 +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. - -import os - -from catapult_base.dependency_manager import exceptions -from catapult_base.dependency_manager import dependency_manager_util - - -class ArchiveInfo(object): - - def __init__(self, archive_file, unzip_path, path_within_archive): - """ Container for the information needed to unzip a downloaded archive. - - Args: - archive_path: Path to the archive file. - unzip_path: Path to unzip the archive into. Assumes that this path - is unique for the archive. - path_within_archive: Specify if and how to handle zip archives - downloaded from cloud_storage. Expected values: - None: Do not unzip the file downloaded from cloud_storage. - '.': Unzip the file downloaded from cloud_storage. The - unzipped file/folder is the expected dependency. - file_path: Unzip the file downloaded from cloud_storage. - |file_path| is the path to the expected dependency, - relative to the unzipped archive path. - """ - self._archive_file = archive_file - self._unzip_path = unzip_path - self._path_within_archive = path_within_archive - self._dependency_path = os.path.join( - self._unzip_path, self._path_within_archive) - if not self._has_minimum_data: - raise ValueError( - 'Not enough information specified to initialize an archive info.' - ' %s' % self) - - def GetUnzippedPath(self): - if self.ShouldUnzipArchive(): - # TODO(aiolos): Replace UnzipFile with zipfile.extractall once python - # version 2.7.4 or later can safely be assumed. - dependency_manager_util.UnzipArchive( - self._archive_file, self._unzip_path) - if self.ShouldUnzipArchive(): - raise exceptions.ArchiveError( - "Expected path '%s' was not extracted from archive '%s'." % - (self._dependency_path, self._archive_file)) - return self._dependency_path - - def ShouldUnzipArchive(self): - if not self._has_minimum_data: - raise exceptions.ArchiveError( - 'Missing needed info to unzip archive. Known data: %s', - self.data_string) - return not os.path.exists(self._dependency_path) - - @property - def _has_minimum_data(self): - return all([self._archive_file, self._unzip_path, - self._dependency_path]) - - def __repr__(self): - return ( - 'ArchiveInfo(archive_file=%s, unzip_path=%s, path_within_archive=%s, ' - 'dependency_path =%s)' % ( - self._archive_file, self._unzip_path, self._path_within_archive, - self._dependency_path)) -
diff --git a/tools/telemetry/catapult_base/dependency_manager/base_config.py b/tools/telemetry/catapult_base/dependency_manager/base_config.py deleted file mode 100644 index f3e98082..0000000 --- a/tools/telemetry/catapult_base/dependency_manager/base_config.py +++ /dev/null
@@ -1,380 +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. - -import json -import logging -import os - -from catapult_base import cloud_storage -from catapult_base.dependency_manager import archive_info -from catapult_base.dependency_manager import cloud_storage_info -from catapult_base.dependency_manager import dependency_info -from catapult_base.dependency_manager import exceptions -from catapult_base.dependency_manager import local_path_info -from catapult_base.dependency_manager import uploader - - -class BaseConfig(object): - """A basic config class for use with the DependencyManager. - - Initiated with a json file in the following format: - - { "config_type": "BaseConfig", - "dependencies": { - "dep_name1": { - "cloud_storage_base_folder": "base_folder1", - "cloud_storage_bucket": "bucket1", - "file_info": { - "platform1": { - "cloud_storage_hash": "hash_for_platform1", - "download_path": "download_path111", - "version_in_cs": "1.11.1.11." - "local_paths": ["local_path1110", "local_path1111"] - }, - "platform2": { - "cloud_storage_hash": "hash_for_platform2", - "download_path": "download_path2", - "local_paths": ["local_path20", "local_path21"] - }, - ... - } - }, - "dependency_name_2": { - ... - }, - ... - } - } - - Required fields: "dependencies" and "config_type". - Note that config_type must be "BaseConfig" - - Assumptions: - "cloud_storage_base_folder" is a top level folder in the given - "cloud_storage_bucket" where all of the dependency files are stored - at "dependency_name"_"cloud_storage_hash". - - "download_path" and all paths in "local_paths" are relative to the - config file's location. - - All or none of the following cloud storage related fields must be - included in each platform dictionary: - "cloud_storage_hash", "download_path", "cs_remote_path" - - "version_in_cs" is an optional cloud storage field, but is dependent - on the above cloud storage related fields. - - - Also note that platform names are often of the form os_architechture. - Ex: "win_AMD64" - - More information on the fields can be found in dependencies_info.py - """ - def __init__(self, file_path, writable=False): - """ Initialize a BaseConfig for the DependencyManager. - - Args: - writable: False: This config will be used to lookup information. - True: This config will be used to update information. - - file_path: Path to a file containing a json dictionary in the expected - json format for this config class. Base format expected: - - { "config_type": config_type, - "dependencies": dependencies_dict } - - config_type: must match the return value of GetConfigType. - dependencies: A dictionary with the information needed to - create dependency_info instances for the given - dependencies. - - See dependency_info.py for more information. - """ - self._config_path = file_path - self._writable = writable - self._is_dirty = False - self._pending_uploads = [] - if not self._config_path: - raise ValueError('Must supply config file path.') - if not os.path.exists(self._config_path): - if not writable: - raise exceptions.EmptyConfigError(file_path) - self._config_data = {} - self._WriteConfigToFile(self._config_path, dependencies=self._config_data) - else: - with open(file_path, 'r') as f: - config_data = json.load(f) - if not config_data: - raise exceptions.EmptyConfigError(file_path) - config_type = config_data.pop('config_type', None) - if config_type != self.GetConfigType(): - raise ValueError( - 'Supplied config_type (%s) is not the expected type (%s) in file ' - '%s' % (config_type, self.GetConfigType(), file_path)) - self._config_data = config_data.get('dependencies', {}) - - def IterDependencyInfo(self): - """ Yields a DependencyInfo for each dependency/platform pair. - - Raises: - ReadWriteError: If called when the config is writable. - ValueError: If any of the dependencies contain partial information for - downloading from cloud_storage. (See dependency_info.py) - """ - if self._writable: - raise exceptions.ReadWriteError( - 'Trying to read dependency info from a writable config. File for ' - 'config: %s' % self._config_path) - base_path = os.path.dirname(self._config_path) - for dependency in self._config_data: - dependency_dict = self._config_data.get(dependency) - platforms_dict = dependency_dict.get('file_info', {}) - for platform in platforms_dict: - platform_info = platforms_dict.get(platform) - - local_info = None - local_paths = platform_info.get('local_paths', []) - if local_paths: - paths = [] - for path in local_paths: - path = self._FormatPath(path) - paths.append(os.path.abspath(os.path.join(base_path, path))) - local_info = local_path_info.LocalPathInfo(paths) - - cs_info = None - cs_bucket = dependency_dict.get('cloud_storage_bucket') - cs_base_folder = dependency_dict.get('cloud_storage_base_folder', '') - download_path = platform_info.get('download_path') - if download_path: - download_path = self._FormatPath(download_path) - download_path = os.path.abspath( - os.path.join(base_path, download_path)) - - cs_hash = platform_info.get('cloud_storage_hash') - if not cs_hash: - raise exceptions.ConfigError( - 'Dependency %s has cloud storage info on platform %s, but is ' - 'missing a cloud storage hash.', dependency, platform) - cs_remote_path = self._CloudStorageRemotePath( - dependency, cs_hash, cs_base_folder) - version_in_cs = platform_info.get('version_in_cs') - - zip_info = None - path_within_archive = platform_info.get('path_within_archive') - if path_within_archive: - unzip_path = os.path.abspath( - os.path.join(os.path.dirname(download_path), - '%s_%s_%s' % (dependency, platform, cs_hash))) - zip_info = archive_info.ArchiveInfo( - download_path, unzip_path, path_within_archive) - - cs_info = cloud_storage_info.CloudStorageInfo( - cs_bucket, cs_hash, download_path, cs_remote_path, - version_in_cs=version_in_cs, archive_info=zip_info) - - dep_info = dependency_info.DependencyInfo( - dependency, platform, self._config_path, local_path_info=local_info, - cloud_storage_info=cs_info) - yield dep_info - - @classmethod - def GetConfigType(cls): - return 'BaseConfig' - - @property - def config_path(self): - return self._config_path - - def AddCloudStorageDependencyUpdateJob( - self, dependency, platform, dependency_path, version=None, - execute_job=True): - """Update the file downloaded from cloud storage for a dependency/platform. - - Upload a new file to cloud storage for the given dependency and platform - pair and update the cloud storage hash and the version for the given pair. - - Example usage: - The following should update the default platform for 'dep_name': - UpdateCloudStorageDependency('dep_name', 'default', 'path/to/file') - - The following should update both the mac and win platforms for 'dep_name', - or neither if either update fails: - UpdateCloudStorageDependency( - 'dep_name', 'mac_x86_64', 'path/to/mac/file', execute_job=False) - UpdateCloudStorageDependency( - 'dep_name', 'win_AMD64', 'path/to/win/file', execute_job=False) - ExecuteUpdateJobs() - - Args: - dependency: The dependency to update. - platform: The platform to update the dependency info for. - dependency_path: Path to the new dependency to be used. - version: Version of the updated dependency, for checking future updates - against. - execute_job: True if the config should be written to disk and the file - should be uploaded to cloud storage after the update. False if - multiple updates should be performed atomically. Must call - ExecuteUpdateJobs after all non-executed jobs are added to complete - the update. - - Raises: - ReadWriteError: If the config was not initialized as writable, or if - |execute_job| is True but the config has update jobs still pending - execution. - ValueError: If no information exists in the config for |dependency| on - |platform|. - """ - self._ValidateIsConfigUpdatable( - execute_job=execute_job, dependency=dependency, platform=platform) - self._is_dirty = True - cs_hash = cloud_storage.CalculateHash(dependency_path) - if version: - self._SetPlatformData(dependency, platform, 'version_in_cs', version) - self._SetPlatformData(dependency, platform, 'cloud_storage_hash', cs_hash) - - cs_base_folder = self._GetPlatformData( - dependency, platform, 'cloud_storage_base_folder') - cs_bucket = self._GetPlatformData( - dependency, platform, 'cloud_storage_bucket') - cs_remote_path = self._CloudStorageRemotePath( - dependency, cs_hash, cs_base_folder) - self._pending_uploads.append(uploader.CloudStorageUploader( - cs_bucket, cs_remote_path, dependency_path)) - if execute_job: - self.ExecuteUpdateJobs() - - def ExecuteUpdateJobs(self, force=False): - """Write all config changes to the config_path specified in __init__. - - Upload all files pending upload and then write the updated config to - file. Attempt to remove all uploaded files on failure. - - Args: - force: True if files should be uploaded to cloud storage even if a - file already exists in the upload location. - - Returns: - True: if the config was dirty and the upload succeeded. - False: if the config was not dirty. - - Raises: - CloudStorageUploadConflictError: If |force| is False and the potential - upload location of a file already exists. - CloudStorageError: If copying an existing file to the backup location - or uploading a new file fails. - """ - self._ValidateIsConfigUpdatable() - if not self._is_dirty: - logging.info('ExecuteUpdateJobs called on clean config') - return False - if not self._pending_uploads: - logging.debug('No files needing upload.') - else: - try: - for item_pending_upload in self._pending_uploads: - item_pending_upload.Upload(force) - self._WriteConfigToFile(self._config_path, self._config_data) - self._pending_uploads = [] - self._is_dirty = False - except: - # Attempt to rollback the update in any instance of failure, even user - # interrupt via Ctrl+C; but don't consume the exception. - logging.error('Update failed, attempting to roll it back.') - for upload_item in reversed(self._pending_uploads): - upload_item.Rollback() - raise - return True - - def GetVersion(self, dependency, platform): - """Return the Version information for the given dependency.""" - return self._GetPlatformData( - dependency, platform, data_type='version_in_cs') - - def _SetPlatformData(self, dependency, platform, data_type, data): - self._ValidateIsConfigWritable() - dependency_dict = self._config_data.get(dependency, {}) - platform_dict = dependency_dict.get('file_info', {}).get(platform) - if not platform_dict: - raise ValueError('No platform data for platform %s on dependency %s' % - (platform, dependency)) - if (data_type == 'cloud_storage_bucket' or - data_type == 'cloud_storage_base_folder'): - self._config_data[dependency][data_type] = data - else: - self._config_data[dependency]['file_info'][platform][data_type] = data - - def _GetPlatformData(self, dependency, platform, data_type=None): - dependency_dict = self._config_data.get(dependency, {}) - if not dependency_dict: - raise ValueError('Dependency %s is not in config.' % dependency) - platform_dict = dependency_dict.get('file_info', {}).get(platform) - if not platform_dict: - raise ValueError('No platform data for platform %s on dependency %s' % - (platform, dependency)) - if data_type: - if (data_type == 'cloud_storage_bucket' or - data_type == 'cloud_storage_base_folder'): - return dependency_dict.get(data_type) - return platform_dict.get(data_type) - return platform_dict - - def _ValidateIsConfigUpdatable( - self, execute_job=False, dependency=None, platform=None): - self._ValidateIsConfigWritable() - if self._is_dirty and execute_job: - raise exceptions.ReadWriteError( - 'A change has already been made to this config. Either call without' - 'using the execute_job option or first call ExecuteUpdateJobs().') - if dependency and not self._config_data.get(dependency): - raise ValueError('Cannot update information because dependency %s does ' - 'not exist.' % dependency) - if platform and not self._GetPlatformData(dependency, platform): - raise ValueError('No dependency info is available for the given ' - 'dependency: %s' % dependency) - - def _ValidateIsConfigWritable(self): - if not self._writable: - raise exceptions.ReadWriteError( - 'Trying to update the information from a read-only config. ' - 'File for config: %s' % self._config_path) - - @staticmethod - def _CloudStorageRemotePath(dependency, cs_hash, cs_base_folder): - cs_remote_file = '%s_%s' % (dependency, cs_hash) - cs_remote_path = cs_remote_file if not cs_base_folder else ( - '%s/%s' % (cs_base_folder, cs_remote_file)) - return cs_remote_path - - @classmethod - def _FormatPath(cls, file_path): - """ Format |file_path| for the current file system. - - We may be downloading files for another platform, so paths must be - downloadable on the current system. - """ - if not file_path: - return file_path - if os.path.sep != '\\': - return file_path.replace('\\', os.path.sep) - elif os.path.sep != '/': - return file_path.replace('/', os.path.sep) - return file_path - - @classmethod - def _WriteConfigToFile(cls, file_path, dependencies=None): - json_dict = cls._GetJsonDict(dependencies) - file_dir = os.path.dirname(file_path) - if not os.path.exists(file_dir): - os.makedirs(file_dir) - with open(file_path, 'w') as outfile: - json.dump( - json_dict, outfile, indent=2, sort_keys=True, separators=(',', ': ')) - return json_dict - - @classmethod - def _GetJsonDict(cls, dependencies=None): - dependencies = dependencies or {} - json_dict = {'config_type': cls.GetConfigType(), - 'dependencies': dependencies} - return json_dict
diff --git a/tools/telemetry/catapult_base/dependency_manager/cloud_storage_info.py b/tools/telemetry/catapult_base/dependency_manager/cloud_storage_info.py deleted file mode 100644 index 460a761..0000000 --- a/tools/telemetry/catapult_base/dependency_manager/cloud_storage_info.py +++ /dev/null
@@ -1,110 +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. - -import errno -import os -import stat - -from catapult_base import cloud_storage - -from catapult_base.dependency_manager import exceptions - -class CloudStorageInfo(object): - def __init__(self, cs_bucket, cs_hash, download_path, cs_remote_path, - version_in_cs=None, archive_info=None): - """ Container for the information needed to download a dependency from - cloud storage. - - Args: - cs_bucket: The cloud storage bucket the dependency is located in. - cs_hash: The hash of the file stored in cloud storage. - download_path: Where the file should be downloaded to. - cs_remote_path: Where the file is stored in the cloud storage bucket. - version_in_cs: The version of the file stored in cloud storage. - archive_info: An instance of ArchiveInfo if this dependency is an - archive. Else None. - """ - self._download_path = download_path - self._cs_remote_path = cs_remote_path - self._cs_bucket = cs_bucket - self._cs_hash = cs_hash - self._version_in_cs = version_in_cs - self._archive_info = archive_info - if not self._has_minimum_data: - raise ValueError( - 'Not enough information specified to initialize a cloud storage info.' - ' %s' % self) - - def DependencyExistsInCloudStorage(self): - return cloud_storage.Exists(self._cs_bucket, self._cs_remote_path) - - def GetRemotePath(self): - """Gets the path to a downloaded version of the dependency. - - May not download the file if it has already been downloaded. - Will unzip the downloaded file if a non-empty archive_info was passed in at - init. - - Returns: A path to an executable that was stored in cloud_storage, or None - if not found. - - Raises: - CredentialsError: If cloud_storage credentials aren't configured. - PermissionError: If cloud_storage credentials are configured, but not - with an account that has permission to download the needed file. - NotFoundError: If the needed file does not exist where expected in - cloud_storage or the downloaded zip file. - ServerError: If an internal server error is hit while downloading the - needed file. - CloudStorageError: If another error occured while downloading the remote - path. - FileNotFoundError: If the download was otherwise unsuccessful. - """ - if not self._has_minimum_data: - return None - - download_dir = os.path.dirname(self._download_path) - if not os.path.exists(download_dir): - try: - os.makedirs(download_dir) - except OSError as e: - # The logic above is racy, and os.makedirs will raise an OSError if - # the directory exists. - if e.errno != errno.EEXIST: - raise - - dependency_path = self._download_path - cloud_storage.GetIfHashChanged( - self._cs_remote_path, self._download_path, self._cs_bucket, - self._cs_hash) - if not os.path.exists(dependency_path): - raise exceptions.FileNotFoundError(dependency_path) - - if self.has_archive_info: - dependency_path = self._archive_info.GetUnzippedPath() - else: - mode = os.stat(dependency_path).st_mode - os.chmod(dependency_path, mode | stat.S_IXUSR) - return os.path.abspath(dependency_path) - - @property - def version_in_cs(self): - return self._version_in_cs - - @property - def _has_minimum_data(self): - return all([self._cs_bucket, self._cs_remote_path, self._download_path, - self._cs_hash]) - - - @property - def has_archive_info(self): - return bool(self._archive_info) - - def __repr__(self): - return ( - 'CloudStorageInfo(download_path=%s, cs_remote_path=%s, cs_bucket=%s, ' - 'cs_hash=%s, version_in_cs=%s, archive_info=%s)' % ( - self._download_path, self._cs_remote_path, self._cs_bucket, - self._cs_hash, self._version_in_cs, self._archive_info))
diff --git a/tools/telemetry/catapult_base/dependency_manager/dependency_info.py b/tools/telemetry/catapult_base/dependency_manager/dependency_info.py deleted file mode 100644 index 2821ede..0000000 --- a/tools/telemetry/catapult_base/dependency_manager/dependency_info.py +++ /dev/null
@@ -1,123 +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. - -class DependencyInfo(object): - def __init__(self, dependency, platform, config_path, local_path_info=None, - cloud_storage_info=None): - """ Container for the information needed for each dependency/platform pair - in the dependency_manager. - - Args: - Required: - dependency: Name of the dependency. - platform: Name of the platform to be run on. - config_path: Path to the config_path this information came from. Used - for error messages to improve debugging. - - Optional: - local_paths: A list of paths to search in order for a local file. - cloud_storage_info: An instance of CloudStorageInfo. - """ - # TODO(aiolos): update the above doc string for A) the usage of zip files - # and B) supporting lists of local_paths to be checked for most recently - # changed files. - if not dependency or not platform: - raise ValueError( - 'Must supply both a dependency and platform to DependencyInfo') - - self._dependency = dependency - self._platform = platform - self._config_paths = [config_path] - self._local_path_info = local_path_info - self._cloud_storage_info = cloud_storage_info - - def Update(self, new_dep_info): - """Add the information from |new_dep_info| to this instance. - """ - self._config_paths.extend(new_dep_info.config_paths) - if (self.dependency != new_dep_info.dependency or - self.platform != new_dep_info.platform): - raise ValueError( - 'Cannot update DependencyInfo with different dependency or platform.' - 'Existing dep: %s, existing platform: %s. New dep: %s, new platform:' - '%s. Config_paths conflicting: %s' % ( - self.dependency, self.platform, new_dep_info.dependency, - new_dep_info.platform, self.config_paths)) - if new_dep_info.has_cloud_storage_info: - if self.has_cloud_storage_info: - raise ValueError( - 'Overriding cloud storage data is not allowed when updating a ' - 'DependencyInfo. Conflict in dependency %s on platform %s in ' - 'config_paths: %s.' % (self.dependency, self.platform, - self.config_paths)) - else: - self._cloud_storage_info = new_dep_info._cloud_storage_info - if not self._local_path_info: - self._local_path_info = new_dep_info._local_path_info - else: - self._local_path_info.Update(new_dep_info._local_path_info) - - def GetRemotePath(self): - """Gets the path to a downloaded version of the dependency. - - May not download the file if it has already been downloaded. - Will unzip the downloaded file if specified in the config - via unzipped_hash. - - Returns: A path to an executable that was stored in cloud_storage, or None - if not found. - - Raises: - CredentialsError: If cloud_storage credentials aren't configured. - PermissionError: If cloud_storage credentials are configured, but not - with an account that has permission to download the needed file. - NotFoundError: If the needed file does not exist where expected in - cloud_storage or the downloaded zip file. - ServerError: If an internal server error is hit while downloading the - needed file. - CloudStorageError: If another error occured while downloading the remote - path. - FileNotFoundError: If the download was otherwise unsuccessful. - """ - if self.has_cloud_storage_info: - return self._cloud_storage_info.GetRemotePath() - return None - - def GetLocalPath(self): - """Gets the path to a local version of the dependency. - - Returns: A path to a local dependency, or None if not found. - - """ - if self.has_local_path_info: - return self._local_path_info.GetLocalPath() - return None - - @property - def dependency(self): - return self._dependency - - @property - def platform(self): - return self._platform - - @property - def config_paths(self): - return self._config_paths - - @property - def local_path_info(self): - return self._local_path_info - - @property - def has_cloud_storage_info(self): - return bool(self._cloud_storage_info) - - @property - def has_local_path_info(self): - return bool(self._local_path_info) - - @property - def cloud_storage_info(self): - return self._cloud_storage_info
diff --git a/tools/telemetry/catapult_base/dependency_manager/dependency_manager.py b/tools/telemetry/catapult_base/dependency_manager/dependency_manager.py deleted file mode 100644 index 147c5c4..0000000 --- a/tools/telemetry/catapult_base/dependency_manager/dependency_manager.py +++ /dev/null
@@ -1,172 +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. - -import os -import sys - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname( - os.path.abspath(__file__))))) -from catapult_base.dependency_manager import base_config -from catapult_base.dependency_manager import exceptions - - -DEFAULT_TYPE = 'default' - - -class DependencyManager(object): - def __init__(self, configs, supported_config_types=None): - """Manages file dependencies found locally or in cloud_storage. - - Args: - configs: A list of instances of BaseConfig or it's subclasses, passed - in decreasing order of precedence. - supported_config_types: A list of whitelisted config_types. - No restrictions if None is specified. - - Raises: - ValueError: If |configs| is not a list of instances of BaseConfig or - its subclasses. - UnsupportedConfigFormatError: If supported_config_types is specified and - configs contains a config not in the supported config_types. - - Example: DependencyManager([config1, config2, config3]) - No requirements on the type of Config, and any dependencies that have - local files for the same platform will first look in those from - config1, then those from config2, and finally those from config3. - """ - if configs is None or type(configs) != list: - raise ValueError( - 'Must supply a list of config files to DependencyManager') - # self._lookup_dict is a dictionary with the following format: - # { dependency1: {platform1: dependency_info1, - # platform2: dependency_info2} - # dependency2: {platform1: dependency_info3, - # ...} - # ...} - # - # Where the dependencies and platforms are strings, and the - # dependency_info's are DependencyInfo instances. - self._lookup_dict = {} - self.supported_configs = supported_config_types or [] - for config in configs: - self._UpdateDependencies(config) - - def FetchPath(self, dependency, platform): - """Get a path to an executable for |dependency|, downloading as needed. - - A path to a default executable may be returned if a platform specific - version is not specified in the config(s). - - Args: - dependency: Name of the desired dependency, as given in the config(s) - used in this DependencyManager. - platform: Name of the platform the dependency will run on. Often of the - form 'os_architecture'. Must match those specified in the config(s) - used in this DependencyManager. - Returns: - A path to an executable of |dependency| that will run on |platform|, - downloading from cloud storage if needed. - - Raises: - NoPathFoundError: If a local copy of the executable cannot be found and - a remote path could not be downloaded from cloud_storage. - CredentialsError: If cloud_storage credentials aren't configured. - PermissionError: If cloud_storage credentials are configured, but not - with an account that has permission to download the remote file. - NotFoundError: If the remote file does not exist where expected in - cloud_storage. - ServerError: If an internal server error is hit while downloading the - remote file. - CloudStorageError: If another error occured while downloading the remote - path. - FileNotFoundError: If an attempted download was otherwise unsuccessful. - - """ - dependency_info = self._GetDependencyInfo(dependency, platform) - if not dependency_info: - raise exceptions.NoPathFoundError(dependency, platform) - path = dependency_info.GetLocalPath() - if not path or not os.path.exists(path): - path = dependency_info.GetRemotePath() - if not path or not os.path.exists(path): - raise exceptions.NoPathFoundError(dependency, platform) - return path - - def LocalPath(self, dependency, platform): - """Get a path to a locally stored executable for |dependency|. - - A path to a default executable may be returned if a platform specific - version is not specified in the config(s). - Will not download the executable. - - Args: - dependency: Name of the desired dependency, as given in the config(s) - used in this DependencyManager. - platform: Name of the platform the dependency will run on. Often of the - form 'os_architecture'. Must match those specified in the config(s) - used in this DependencyManager. - Returns: - A path to an executable for |dependency| that will run on |platform|. - - Raises: - NoPathFoundError: If a local copy of the executable cannot be found. - """ - dependency_info = self._GetDependencyInfo(dependency, platform) - if not dependency_info: - raise exceptions.NoPathFoundError(dependency, platform) - local_path = dependency_info.GetLocalPath() - if not local_path or not os.path.exists(local_path): - raise exceptions.NoPathFoundError(dependency, platform) - return local_path - - def _UpdateDependencies(self, config): - """Add the dependency information stored in |config| to this instance. - - Args: - config: An instances of BaseConfig or a subclasses. - - Raises: - UnsupportedConfigFormatError: If supported_config_types was specified - and config is not in the supported config_types. - """ - if not isinstance(config, base_config.BaseConfig): - raise ValueError('Must use a BaseConfig or subclass instance with the ' - 'DependencyManager.') - if (self.supported_configs and - config.GetConfigType() not in self.supported_configs): - raise exceptions.UnsupportedConfigFormatError(config.GetConfigType(), - config.config_path) - for dep_info in config.IterDependencyInfo(): - dependency = dep_info.dependency - platform = dep_info.platform - if dependency not in self._lookup_dict: - self._lookup_dict[dependency] = {} - if platform not in self._lookup_dict[dependency]: - self._lookup_dict[dependency][platform] = dep_info - else: - self._lookup_dict[dependency][platform].Update(dep_info) - - - def _GetDependencyInfo(self, dependency, platform): - """Get information for |dependency| on |platform|, or a default if needed. - - Args: - dependency: Name of the desired dependency, as given in the config(s) - used in this DependencyManager. - platform: Name of the platform the dependency will run on. Often of the - form 'os_architecture'. Must match those specified in the config(s) - used in this DependencyManager. - - Returns: The dependency_info for |dependency| on |platform| if it exists. - Or the default version of |dependency| if it exists, or None if neither - exist. - """ - if not self._lookup_dict or dependency not in self._lookup_dict: - return None - dependency_dict = self._lookup_dict[dependency] - device_type = platform - if not device_type in dependency_dict: - device_type = DEFAULT_TYPE - return dependency_dict.get(device_type) -
diff --git a/tools/telemetry/catapult_base/dependency_manager/dependency_manager_util.py b/tools/telemetry/catapult_base/dependency_manager/dependency_manager_util.py deleted file mode 100644 index a0f6b6b..0000000 --- a/tools/telemetry/catapult_base/dependency_manager/dependency_manager_util.py +++ /dev/null
@@ -1,95 +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. - -import os -import shutil -import stat -import sys -import zipfile - -from . import exceptions - - -def _WinReadOnlyHandler(func, path, execinfo): - if not os.access(path, os.W_OK): - os.chmod(path, stat.S_IWRITE) - func(path) - else: - raise execinfo[0], execinfo[1], execinfo[2] - - -def RemoveDir(dir_path): - if os.path.isdir(dir_path): - shutil.rmtree(dir_path, onerror=_WinReadOnlyHandler) - - -def VerifySafeArchive(archive): - def ResolvePath(path_name): - return os.path.realpath(os.path.abspath(path_name)) - # Must add pathsep to avoid false positives. - # Ex: /tmp/abc/bad_file.py starts with /tmp/a but not /tmp/a/ - base_path = ResolvePath(os.getcwd()) + os.path.sep - for member in archive.namelist(): - if not ResolvePath(os.path.join(base_path, member)).startswith(base_path): - raise exceptions.ArchiveError( - 'Archive %s contains a bad member: %s.' % (archive.filename, member)) - - -def GetModeFromPath(file_path): - return stat.S_IMODE(os.stat(file_path).st_mode) - - -def GetModeFromZipInfo(zip_info): - return zip_info.external_attr >> 16 - - -def SetUnzippedDirPermissions(archive, unzipped_dir): - """Set the file permissions in an unzipped archive. - - Designed to be called right after extractall() was called on |archive|. - Noop on Win. Otherwise sets the executable bit on files where needed. - - Args: - archive: A zipfile.ZipFile object opened for reading. - unzipped_dir: A path to a directory containing the unzipped contents - of |archive|. - """ - if sys.platform.startswith('win'): - # Windows doesn't have an executable bit, so don't mess with the ACLs. - return - for zip_info in archive.infolist(): - archive_acls = GetModeFromZipInfo(zip_info) - if archive_acls & stat.S_IXUSR: - # Only preserve owner execurable permissions. - unzipped_path = os.path.abspath( - os.path.join(unzipped_dir, zip_info.filename)) - mode = GetModeFromPath(unzipped_path) - os.chmod(unzipped_path, mode | stat.S_IXUSR) - - -def UnzipArchive(archive_path, unzip_path): - """Unzips a file if it is a zip file. - - Args: - archive_path: The downloaded file to unzip. - unzip_path: The destination directory to unzip to. - - Raises: - ValueError: If |archive_path| is not a zipfile. - """ - # TODO(aiolos): Add tests once the refactor is completed. crbug.com/551158 - if not (archive_path and zipfile.is_zipfile(archive_path)): - raise ValueError( - 'Attempting to unzip a non-archive file at %s' % archive_path) - if not os.path.exists(unzip_path): - os.makedirs(unzip_path) - try: - with zipfile.ZipFile(archive_path, 'r') as archive: - VerifySafeArchive(archive) - archive.extractall(path=unzip_path) - SetUnzippedDirPermissions(archive, unzip_path) - except: - if unzip_path and os.path.isdir(unzip_path): - RemoveDir(unzip_path) - raise
diff --git a/tools/telemetry/catapult_base/dependency_manager/exceptions.py b/tools/telemetry/catapult_base/dependency_manager/exceptions.py deleted file mode 100644 index 015074f39..0000000 --- a/tools/telemetry/catapult_base/dependency_manager/exceptions.py +++ /dev/null
@@ -1,48 +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. - -from catapult_base import cloud_storage - -class UnsupportedConfigFormatError(ValueError): - def __init__(self, config_type, config_file): - if not config_type: - message = ('The json file at %s is unsupported by the dependency_manager ' - 'due to no specified config type' % config_file) - else: - message = ('The json file at %s has config type %s, which is unsupported ' - 'by the dependency manager.' % (config_file, config_type)) - super(UnsupportedConfigFormatError, self).__init__(message) - - -class EmptyConfigError(ValueError): - def __init__(self, file_path): - super(EmptyConfigError, self).__init__('Empty config at %s.' % file_path) - - -class FileNotFoundError(Exception): - def __init__(self, file_path): - super(FileNotFoundError, self).__init__('No file found at %s' % file_path) - - -class NoPathFoundError(Exception): - def __init__(self, dependency, platform): - super(NoPathFoundError, self).__init__( - 'No file could be found locally, and no file to download from cloud ' - 'storage for %s on platform %s' % (dependency, platform)) - - -class ReadWriteError(Exception): - pass - - -class CloudStorageUploadConflictError(cloud_storage.CloudStorageError): - def __init__(self, bucket, path): - super(CloudStorageUploadConflictError, self).__init__( - 'File location %s already exists in bucket %s' % (path, bucket)) - - -class ArchiveError(Exception): - def __init__(self, msg): - super(ArchiveError, self).__init__(msg) -
diff --git a/tools/telemetry/catapult_base/dependency_manager/local_path_info.py b/tools/telemetry/catapult_base/dependency_manager/local_path_info.py deleted file mode 100644 index 0103e8f..0000000 --- a/tools/telemetry/catapult_base/dependency_manager/local_path_info.py +++ /dev/null
@@ -1,40 +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. - -import os - - -class LocalPathInfo(object): - - def __init__(self, path_priority_groups): - self._path_priority_groups = self._ParseLocalPaths(path_priority_groups) - - def GetLocalPath(self): - for priority_group in self._path_priority_groups: - priority_group = filter(os.path.exists, priority_group) - if not priority_group: - continue - return max(priority_group, key=lambda path: os.stat(path).st_mtime) - return None - - def IsPathInLocalPaths(self, path): - return any( - path in priority_group for priority_group in self._path_priority_groups) - - def Update(self, local_path_info): - if not local_path_info: - return - for priority_group in local_path_info._path_priority_groups: - group_list = [] - for path in priority_group: - if not self.IsPathInLocalPaths(path): - group_list.append(path) - if group_list: - self._path_priority_groups.append(group_list) - - @staticmethod - def _ParseLocalPaths(local_paths): - if not local_paths: - return [] - return [[e] if isinstance(e, basestring) else e for e in local_paths]
diff --git a/tools/telemetry/catapult_base/dependency_manager/uploader.py b/tools/telemetry/catapult_base/dependency_manager/uploader.py deleted file mode 100644 index 08e9c8f..0000000 --- a/tools/telemetry/catapult_base/dependency_manager/uploader.py +++ /dev/null
@@ -1,106 +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. - -import logging -import os - -from catapult_base import cloud_storage - -from catapult_base.dependency_manager import exceptions - - -BACKUP_PATH_EXTENSION = 'old' - - -class CloudStorageUploader(object): - def __init__(self, bucket, remote_path, local_path, cs_backup_path=None): - if not bucket or not remote_path or not local_path: - raise ValueError( - 'Attempted to partially initialize upload data with bucket %s, ' - 'remote_path %s, and local_path %s', bucket, remote_path, local_path) - if not os.path.exists(local_path): - raise ValueError('Attempting to initilize UploadInfo with missing ' - 'local path %s', local_path) - - self._cs_bucket = bucket - self._cs_remote_path = remote_path - self._local_path = local_path - self._cs_backup_path = (cs_backup_path or - '%s.%s' % (self._cs_remote_path, - BACKUP_PATH_EXTENSION)) - self._updated = False - self._backed_up = False - - def Upload(self, force=False): - """Upload all pending files and then write the updated config to disk. - - Will attempt to copy files existing in the upload location to a backup - location in the same bucket in cloud storage if |force| is True. - - Args: - force: True if files should be uploaded to cloud storage even if a - file already exists in the upload location. - - Raises: - CloudStorageUploadConflictError: If |force| is False and the potential - upload location of a file already exists. - CloudStorageError: If copying an existing file to the backup location - or uploading the new file fails. - """ - if cloud_storage.Exists(self._cs_bucket, self._cs_remote_path): - if not force: - raise exceptions.CloudStorageUploadConflictError(self._cs_bucket, - self._cs_remote_path) - logging.debug('A file already exists at upload path %s in self.cs_bucket' - ' %s', self._cs_remote_path, self._cs_bucket) - try: - cloud_storage.Copy(self._cs_bucket, self._cs_bucket, - self._cs_remote_path, self._cs_backup_path) - self._backed_up = True - except cloud_storage.CloudStorageError: - logging.error('Failed to copy existing file %s in cloud storage bucket ' - '%s to backup location %s', self._cs_remote_path, self._cs_bucket, - self._cs_backup_path) - raise - - try: - cloud_storage.Insert( - self._cs_bucket, self._cs_remote_path, self._local_path) - except cloud_storage.CloudStorageError: - logging.error('Failed to upload %s to %s in cloud_storage bucket %s', - self._local_path, self._cs_remote_path, self._cs_bucket) - raise - self._updated = True - - def Rollback(self): - """Attempt to undo the previous call to Upload. - - Does nothing if no previous call to Upload was made, or if nothing was - successfully changed. - - Returns: - True iff changes were successfully rolled back. - Raises: - CloudStorageError: If copying the backed up file to its original - location or removing the uploaded file fails. - """ - cloud_storage_changed = False - if self._backed_up: - cloud_storage.Copy(self._cs_bucket, self._cs_bucket, self._cs_backup_path, - self._cs_remote_path) - cloud_storage_changed = True - self._cs_backup_path = None - elif self._updated: - cloud_storage.Delete(self._cs_bucket, self._cs_remote_path) - cloud_storage_changed = True - self._updated = False - return cloud_storage_changed - - def __eq__(self, other, msg=None): - if type(self) != type(other): - return False - return (self._local_path == other._local_path and - self._cs_remote_path == other._cs_remote_path and - self._cs_bucket == other._cs_bucket) -
diff --git a/tools/telemetry/catapult_base/refactor/__init__.py b/tools/telemetry/catapult_base/refactor/__init__.py deleted file mode 100644 index 406dc6f..0000000 --- a/tools/telemetry/catapult_base/refactor/__init__.py +++ /dev/null
@@ -1,28 +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. - -"""Style-preserving Python code transforms. - -This module provides components for modifying and querying Python code. They can -be used to build custom refactorings and linters. -""" - -import functools -import multiprocessing - -# pylint: disable=wildcard-import -from catapult_base.refactor.annotated_symbol import * -from catapult_base.refactor.module import Module - - -def _TransformFile(transform, file_path): - module = Module(file_path) - result = transform(module) - module.Write() - return result - - -def Transform(transform, file_paths): - transform = functools.partial(_TransformFile, transform) - return multiprocessing.Pool().map(transform, file_paths)
diff --git a/tools/telemetry/catapult_base/refactor/annotated_symbol/__init__.py b/tools/telemetry/catapult_base/refactor/annotated_symbol/__init__.py deleted file mode 100644 index 32858b5..0000000 --- a/tools/telemetry/catapult_base/refactor/annotated_symbol/__init__.py +++ /dev/null
@@ -1,71 +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. - -# pylint: disable=wildcard-import -from catapult_base.refactor.annotated_symbol.class_definition import * -from catapult_base.refactor.annotated_symbol.function_definition import * -from catapult_base.refactor.annotated_symbol.import_statement import * -from catapult_base.refactor.annotated_symbol.reference import * -from catapult_base.refactor import snippet - - -__all__ = [ - 'Annotate', - - 'Class', - 'Function', - 'Import', - 'Reference', -] - - -# Specific symbol types with extra methods for manipulating them. -# Python's full grammar is here: -# https://docs.python.org/2/reference/grammar.html - -# Annotated Symbols have an Annotate classmethod that takes a symbol type and -# list of children, and returns an instance of that annotated Symbol. - -ANNOTATED_SYMBOLS = ( - AsName, - Class, - DottedName, - ImportFrom, - ImportName, - Function, -) - - -# Unfortunately, some logical groupings are not represented by a node in the -# parse tree. To work around this, some annotated Symbols have an Annotate -# classmethod that takes and returns a list of Snippets instead. - -ANNOTATED_GROUPINGS = ( - Reference, -) - - -def Annotate(f): - """Return the syntax tree of the given file.""" - return _AnnotateNode(snippet.Snippetize(f)) - - -def _AnnotateNode(node): - if not isinstance(node, snippet.Symbol): - return node - - children = map(_AnnotateNode, node.children) - - for symbol_type in ANNOTATED_GROUPINGS: - annotated_grouping = symbol_type.Annotate(children) - if annotated_grouping: - children = annotated_grouping - break - - for symbol_type in ANNOTATED_SYMBOLS: - annotated_symbol = symbol_type.Annotate(node.type, children) - if annotated_symbol: - return annotated_symbol - - return snippet.Symbol(node.type, children)
diff --git a/tools/telemetry/catapult_base/refactor/annotated_symbol/base_symbol.py b/tools/telemetry/catapult_base/refactor/annotated_symbol/base_symbol.py deleted file mode 100644 index 80fbc0b0..0000000 --- a/tools/telemetry/catapult_base/refactor/annotated_symbol/base_symbol.py +++ /dev/null
@@ -1,36 +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. - -from catapult_base.refactor import snippet - - -class AnnotatedSymbol(snippet.Symbol): - def __init__(self, symbol_type, children): - super(AnnotatedSymbol, self).__init__(symbol_type, children) - self._modified = False - - @property - def modified(self): - if self._modified: - return True - return super(AnnotatedSymbol, self).modified - - def __setattr__(self, name, value): - if (hasattr(self.__class__, name) and - isinstance(getattr(self.__class__, name), property)): - self._modified = True - return super(AnnotatedSymbol, self).__setattr__(name, value) - - def Cut(self, child): - for i in xrange(len(self._children)): - if self._children[i] == child: - self._modified = True - del self._children[i] - break - else: - raise ValueError('%s is not in %s.' % (child, self)) - - def Paste(self, child): - self._modified = True - self._children.append(child)
diff --git a/tools/telemetry/catapult_base/refactor/annotated_symbol/class_definition.py b/tools/telemetry/catapult_base/refactor/annotated_symbol/class_definition.py deleted file mode 100644 index 8254aad..0000000 --- a/tools/telemetry/catapult_base/refactor/annotated_symbol/class_definition.py +++ /dev/null
@@ -1,48 +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. - -import symbol - -from catapult_base.refactor.annotated_symbol import base_symbol - - -__all__ = [ - 'Class', -] - - -class Class(base_symbol.AnnotatedSymbol): - @classmethod - def Annotate(cls, symbol_type, children): - if symbol_type != symbol.stmt: - return None - - compound_statement = children[0] - if compound_statement.type != symbol.compound_stmt: - return None - - statement = compound_statement.children[0] - if statement.type == symbol.classdef: - return cls(statement.type, statement.children) - elif (statement.type == symbol.decorated and - statement.children[-1].type == symbol.classdef): - return cls(statement.type, statement.children) - else: - return None - - @property - def suite(self): - raise NotImplementedError() - - def FindChild(self, snippet_type, **kwargs): - return self.suite.FindChild(snippet_type, **kwargs) - - def FindChildren(self, snippet_type): - return self.suite.FindChildren(snippet_type) - - def Cut(self, child): - self.suite.Cut(child) - - def Paste(self, child): - self.suite.Paste(child)
diff --git a/tools/telemetry/catapult_base/refactor/annotated_symbol/function_definition.py b/tools/telemetry/catapult_base/refactor/annotated_symbol/function_definition.py deleted file mode 100644 index d6accab..0000000 --- a/tools/telemetry/catapult_base/refactor/annotated_symbol/function_definition.py +++ /dev/null
@@ -1,48 +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. - -import symbol - -from catapult_base.refactor.annotated_symbol import base_symbol - - -__all__ = [ - 'Function', -] - - -class Function(base_symbol.AnnotatedSymbol): - @classmethod - def Annotate(cls, symbol_type, children): - if symbol_type != symbol.stmt: - return None - - compound_statement = children[0] - if compound_statement.type != symbol.compound_stmt: - return None - - statement = compound_statement.children[0] - if statement.type == symbol.funcdef: - return cls(statement.type, statement.children) - elif (statement.type == symbol.decorated and - statement.children[-1].type == symbol.funcdef): - return cls(statement.type, statement.children) - else: - return None - - @property - def suite(self): - raise NotImplementedError() - - def FindChild(self, snippet_type, **kwargs): - return self.suite.FindChild(snippet_type, **kwargs) - - def FindChildren(self, snippet_type): - return self.suite.FindChildren(snippet_type) - - def Cut(self, child): - self.suite.Cut(child) - - def Paste(self, child): - self.suite.Paste(child)
diff --git a/tools/telemetry/catapult_base/refactor/annotated_symbol/import_statement.py b/tools/telemetry/catapult_base/refactor/annotated_symbol/import_statement.py deleted file mode 100644 index e598f5aa..0000000 --- a/tools/telemetry/catapult_base/refactor/annotated_symbol/import_statement.py +++ /dev/null
@@ -1,322 +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. - -import itertools -import keyword -import symbol -import token - -from catapult_base.refactor.annotated_symbol import base_symbol -from catapult_base.refactor import snippet - - -__all__ = [ - 'AsName', - 'DottedName', - 'Import', - 'ImportFrom', - 'ImportName', -] - - -class DottedName(base_symbol.AnnotatedSymbol): - @classmethod - def Annotate(cls, symbol_type, children): - if symbol_type != symbol.dotted_name: - return None - return cls(symbol_type, children) - - @property - def value(self): - return ''.join(token_snippet.value for token_snippet in self._children) - - @value.setter - def value(self, value): - value_parts = value.split('.') - for value_part in value_parts: - if keyword.iskeyword(value_part): - raise ValueError('%s is a reserved keyword.' % value_part) - - # If we have too many children, cut the list down to size. - self._children = self._children[:len(value_parts)*2-1] - - # Update child nodes. - for child, value_part in itertools.izip_longest( - self._children[::2], value_parts): - if child: - # Modify existing children. This helps preserve comments and spaces. - child.value = value_part - else: - # Add children as needed. - self._children.append(snippet.TokenSnippet.Create(token.DOT, '.')) - self._children.append( - snippet.TokenSnippet.Create(token.NAME, value_part)) - - -class AsName(base_symbol.AnnotatedSymbol): - @classmethod - def Annotate(cls, symbol_type, children): - if (symbol_type != symbol.dotted_as_name and - symbol_type != symbol.import_as_name): - return None - return cls(symbol_type, children) - - @property - def name(self): - return self.children[0].value - - @name.setter - def name(self, value): - self.children[0].value = value - - @property - def alias(self): - if len(self.children) < 3: - return None - return self.children[2].value - - @alias.setter - def alias(self, value): - if keyword.iskeyword(value): - raise ValueError('%s is a reserved keyword.' % value) - - if value: - if len(self.children) < 3: - # If we currently have no alias, add one. - self.children.append( - snippet.TokenSnippet.Create(token.NAME, 'as', (0, 1))) - self.children.append( - snippet.TokenSnippet.Create(token.NAME, value, (0, 1))) - else: - # We already have an alias. Just update the value. - self.children[2].value = value - else: - # Removing the alias. Strip the "as foo". - self.children = [self.children[0]] - - -class Import(base_symbol.AnnotatedSymbol): - """An import statement. - - Example: - import a.b.c as d - from a.b import c as d - - In these examples, - path == 'a.b.c' - alias == 'd' - root == 'a.b' (only for "from" imports) - module == 'c' (only for "from" imports) - name (read-only) == the name used by references to the module, which is the - alias if there is one, the full module path in "full" imports, and the - module name in "from" imports. - """ - @property - def has_from(self): - """Returns True iff the import statment is of the form "from x import y".""" - raise NotImplementedError() - - @property - def values(self): - raise NotImplementedError() - - @property - def paths(self): - raise NotImplementedError() - - @property - def aliases(self): - raise NotImplementedError() - - @property - def path(self): - """The full dotted path of the module.""" - raise NotImplementedError() - - @path.setter - def path(self, value): - raise NotImplementedError() - - @property - def alias(self): - """The alias, if the module is renamed with "as". None otherwise.""" - raise NotImplementedError() - - @alias.setter - def alias(self, value): - raise NotImplementedError() - - @property - def name(self): - """The name used to reference this import's module.""" - raise NotImplementedError() - - -class ImportName(Import): - @classmethod - def Annotate(cls, symbol_type, children): - if symbol_type != symbol.import_stmt: - return None - if children[0].type != symbol.import_name: - return None - assert len(children) == 1 - return cls(symbol_type, children[0].children) - - @property - def has_from(self): - return False - - @property - def values(self): - dotted_as_names = self.children[1] - return tuple((dotted_as_name.name, dotted_as_name.alias) - for dotted_as_name in dotted_as_names.children[::2]) - - @property - def paths(self): - return tuple(path for path, _ in self.values) - - @property - def aliases(self): - return tuple(alias for _, alias in self.values) - - @property - def _dotted_as_name(self): - dotted_as_names = self.children[1] - if len(dotted_as_names.children) != 1: - raise NotImplementedError( - 'This method only works if the statement has one import.') - return dotted_as_names.children[0] - - @property - def path(self): - return self._dotted_as_name.name - - @path.setter - def path(self, value): # pylint: disable=arguments-differ - self._dotted_as_name.name = value - - @property - def alias(self): - return self._dotted_as_name.alias - - @alias.setter - def alias(self, value): # pylint: disable=arguments-differ - self._dotted_as_name.alias = value - - @property - def name(self): - if self.alias: - return self.alias - else: - return self.path - - -class ImportFrom(Import): - @classmethod - def Annotate(cls, symbol_type, children): - if symbol_type != symbol.import_stmt: - return None - if children[0].type != symbol.import_from: - return None - assert len(children) == 1 - return cls(symbol_type, children[0].children) - - @property - def has_from(self): - return True - - @property - def values(self): - try: - import_as_names = self.FindChild(symbol.import_as_names) - except ValueError: - return (('*', None),) - - return tuple((import_as_name.name, import_as_name.alias) - for import_as_name in import_as_names.children[::2]) - - @property - def paths(self): - module = self.module - return tuple('.'.join((module, name)) for name, _ in self.values) - - @property - def aliases(self): - return tuple(alias for _, alias in self.values) - - @property - def root(self): - return self.FindChild(symbol.dotted_name).value - - @root.setter - def root(self, value): - self.FindChild(symbol.dotted_name).value = value - - @property - def _import_as_name(self): - try: - import_as_names = self.FindChild(symbol.import_as_names) - except ValueError: - return None - - if len(import_as_names.children) != 1: - raise NotImplementedError( - 'This method only works if the statement has one import.') - - return import_as_names.children[0] - - @property - def module(self): - import_as_name = self._import_as_name - if import_as_name: - return import_as_name.name - else: - return '*' - - @module.setter - def module(self, value): - if keyword.iskeyword(value): - raise ValueError('%s is a reserved keyword.' % value) - - import_as_name = self._import_as_name - if value == '*': - # TODO: Implement this. - raise NotImplementedError() - else: - if import_as_name: - import_as_name.name = value - else: - # TODO: Implement this. - raise NotImplementedError() - - @property - def path(self): - return '.'.join((self.root, self.module)) - - @path.setter - def path(self, value): # pylint: disable=arguments-differ - self.root, _, self.module = value.rpartition('.') - - @property - def alias(self): - import_as_name = self._import_as_name - if import_as_name: - return import_as_name.alias - else: - return None - - @alias.setter - def alias(self, value): # pylint: disable=arguments-differ - import_as_name = self._import_as_name - if not import_as_name: - raise NotImplementedError('Cannot change alias for "import *".') - import_as_name.alias = value - - @property - def name(self): - if self.alias: - return self.alias - else: - return self.module
diff --git a/tools/telemetry/catapult_base/refactor/annotated_symbol/reference.py b/tools/telemetry/catapult_base/refactor/annotated_symbol/reference.py deleted file mode 100644 index b57c4f5..0000000 --- a/tools/telemetry/catapult_base/refactor/annotated_symbol/reference.py +++ /dev/null
@@ -1,75 +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. - -import itertools -import symbol -import token - -from catapult_base.refactor.annotated_symbol import base_symbol -from catapult_base.refactor import snippet - - -__all__ = [ - 'Reference', -] - - -class Reference(base_symbol.AnnotatedSymbol): - @classmethod - def Annotate(cls, nodes): - if not nodes: - return None - if nodes[0].type != symbol.atom: - return None - if not nodes[0].children or nodes[0].children[0].type != token.NAME: - return None - - for i in xrange(1, len(nodes)): - if not nodes: - break - if nodes[i].type != symbol.trailer: - break - if len(nodes[i].children) != 2: - break - if (nodes[i].children[0].type != token.DOT or - nodes[i].children[1].type != token.NAME): - break - else: - i = len(nodes) - - return [cls(nodes[:i])] + nodes[i:] - - def __init__(self, children): - super(Reference, self).__init__(-1, children) - - @property - def type_name(self): - return 'attribute_reference' - - @property - def value(self): - return ''.join(token_snippet.value - for child in self.children - for token_snippet in child.children) - - @value.setter - def value(self, value): - value_parts = value.split('.') - - # If we have too many children, cut the list down to size. - self._children = self._children[:len(value_parts)] - - # Update child nodes. - for child, value_part in itertools.izip_longest( - self._children, value_parts): - if child: - # Modify existing children. This helps preserve comments and spaces. - child.children[-1].value = value_part - else: - # Add children as needed. - token_snippets = [ - snippet.TokenSnippet.Create(token.DOT, '.'), - snippet.TokenSnippet.Create(token.NAME, value_part), - ] - self._children.append(snippet.Symbol(symbol.trailer, token_snippets))
diff --git a/tools/telemetry/catapult_base/refactor/module.py b/tools/telemetry/catapult_base/refactor/module.py deleted file mode 100644 index d8b6fb86..0000000 --- a/tools/telemetry/catapult_base/refactor/module.py +++ /dev/null
@@ -1,38 +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. - -from catapult_base.refactor import annotated_symbol - - -class Module(object): - def __init__(self, file_path): - self._file_path = file_path - - with open(self._file_path, 'r') as f: - self._snippet = annotated_symbol.Annotate(f) - - @property - def file_path(self): - return self._file_path - - @property - def modified(self): - return self._snippet.modified - - def FindAll(self, snippet_type): - return self._snippet.FindAll(snippet_type) - - def FindChildren(self, snippet_type): - return self._snippet.FindChildren(snippet_type) - - def Write(self): - """Write modifications to the file.""" - if not self.modified: - return - - # Stringify before opening the file for writing. - # If we fail, we won't truncate the file. - string = str(self._snippet) - with open(self._file_path, 'w') as f: - f.write(string)
diff --git a/tools/telemetry/catapult_base/refactor/offset_token.py b/tools/telemetry/catapult_base/refactor/offset_token.py deleted file mode 100644 index 2578f85..0000000 --- a/tools/telemetry/catapult_base/refactor/offset_token.py +++ /dev/null
@@ -1,113 +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. - -import collections -import itertools -import token -import tokenize - - -def _Pairwise(iterable): - """s -> (None, s0), (s0, s1), (s1, s2), (s2, s3), ...""" - a, b = itertools.tee(iterable) - a = itertools.chain((None,), a) - return itertools.izip(a, b) - - -class OffsetToken(object): - """A Python token with a relative position. - - A token is represented by a type defined in Python's token module, a string - representing the content, and an offset. Using relative positions makes it - easy to insert and remove tokens. - """ - def __init__(self, token_type, string, offset): - self._type = token_type - self._string = string - self._offset = offset - - @property - def type(self): - return self._type - - @property - def type_name(self): - return token.tok_name[self._type] - - @property - def string(self): - return self._string - - @string.setter - def string(self, value): - self._string = value - - @property - def offset(self): - return self._offset - - def __str__(self): - return str((self.type_name, self.string, self.offset)) - - -def Tokenize(f): - """Read tokens from a file-like object. - - Args: - f: Any object that has a readline method. - - Returns: - A collections.deque containing OffsetTokens. Deques are cheaper and easier - to manipulate sequentially than lists. - """ - f.seek(0) - tokenize_tokens = tokenize.generate_tokens(f.readline) - - offset_tokens = collections.deque() - for prev_token, next_token in _Pairwise(tokenize_tokens): - token_type, string, (srow, scol), _, _ = next_token - if not prev_token: - offset_tokens.append(OffsetToken(token_type, string, (0, 0))) - else: - erow, ecol = prev_token[3] - if erow == srow: - offset_tokens.append(OffsetToken(token_type, string, (0, scol-ecol))) - else: - offset_tokens.append(OffsetToken(token_type, string, (srow-erow, scol))) - - return offset_tokens - - -def Untokenize(offset_tokens): - """Return the string representation of an iterable of OffsetTokens.""" - # Make a copy. Don't modify the original. - offset_tokens = collections.deque(offset_tokens) - - # Strip leading NL tokens. - while offset_tokens[0].type == tokenize.NL: - offset_tokens.popleft() - - # Strip leading vertical whitespace. - first_token = offset_tokens.popleft() - # Take care not to modify the existing token. Create a new one in its place. - first_token = OffsetToken(first_token.type, first_token.string, - (0, first_token.offset[1])) - offset_tokens.appendleft(first_token) - - # Convert OffsetTokens to tokenize tokens. - tokenize_tokens = [] - row = 1 - col = 0 - for t in offset_tokens: - offset_row, offset_col = t.offset - if offset_row == 0: - col += offset_col - else: - row += offset_row - col = offset_col - tokenize_tokens.append((t.type, t.string, (row, col), (row, col), None)) - - # tokenize can't handle whitespace before line continuations. - # So add a space. - return tokenize.untokenize(tokenize_tokens).replace('\\\n', ' \\\n')
diff --git a/tools/telemetry/catapult_base/refactor/snippet.py b/tools/telemetry/catapult_base/refactor/snippet.py deleted file mode 100644 index ecb688af..0000000 --- a/tools/telemetry/catapult_base/refactor/snippet.py +++ /dev/null
@@ -1,242 +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. - -import parser -import symbol -import sys -import token -import tokenize - -from catapult_base.refactor import offset_token - - -class Snippet(object): - """A node in the Python parse tree. - - The Python grammar is defined at: - https://docs.python.org/2/reference/grammar.html - - There are two types of Snippets: - TokenSnippets are leaf nodes containing actual text. - Symbols are internal nodes representing higher-level groupings, and are - defined by the left-hand sides of the BNFs in the above link. - """ - @property - def type(self): - raise NotImplementedError() - - @property - def type_name(self): - raise NotImplementedError() - - @property - def children(self): - """Return a list of this node's children.""" - raise NotImplementedError() - - @property - def tokens(self): - """Return a tuple of the tokens this Snippet contains.""" - raise NotImplementedError() - - def PrintTree(self, indent=0, stream=sys.stdout): - """Spew a pretty-printed parse tree. Mostly useful for debugging.""" - raise NotImplementedError() - - def __str__(self): - return offset_token.Untokenize(self.tokens) - - def FindAll(self, snippet_type): - if isinstance(snippet_type, int): - if self.type == snippet_type: - yield self - else: - if isinstance(self, snippet_type): - yield self - - for child in self.children: - for snippet in child.FindAll(snippet_type): - yield snippet - - def FindChild(self, snippet_type, **kwargs): - for child in self.children: - if isinstance(snippet_type, int): - if child.type != snippet_type: - continue - else: - if not isinstance(child, snippet_type): - continue - - for attribute, value in kwargs: - if getattr(child, attribute) != value: - break - else: - return child - raise ValueError('%s is not in %s. Children are: %s' % - (snippet_type, self, self.children)) - - def FindChildren(self, snippet_type): - if isinstance(snippet_type, int): - for child in self.children: - if child.type == snippet_type: - yield child - else: - for child in self.children: - if isinstance(child, snippet_type): - yield child - - -class TokenSnippet(Snippet): - """A Snippet containing a list of tokens. - - A list of tokens may start with any number of comments and non-terminating - newlines, but must end with a syntactically meaningful token. - """ - def __init__(self, token_type, tokens): - # For operators and delimiters, the TokenSnippet's type may be more specific - # than the type of the constituent token. E.g. the TokenSnippet type is - # token.DOT, but the token type is token.OP. This is because the parser - # has more context than the tokenizer. - self._type = token_type - self._tokens = tokens - self._modified = False - - @classmethod - def Create(cls, token_type, string, offset=(0, 0)): - return cls(token_type, - [offset_token.OffsetToken(token_type, string, offset)]) - - @property - def type(self): - return self._type - - @property - def type_name(self): - return token.tok_name[self.type] - - @property - def value(self): - return self._tokens[-1].string - - @value.setter - def value(self, value): - self._tokens[-1].string = value - self._modified = True - - @property - def children(self): - return [] - - @property - def tokens(self): - return tuple(self._tokens) - - @property - def modified(self): - return self._modified - - def PrintTree(self, indent=0, stream=sys.stdout): - stream.write(' ' * indent) - if not self.tokens: - print >> stream, self.type_name - return - - print >> stream, '%-4s' % self.type_name, repr(self.tokens[0].string) - for tok in self.tokens[1:]: - stream.write(' ' * indent) - print >> stream, ' ' * max(len(self.type_name), 4), repr(tok.string) - - -class Symbol(Snippet): - """A Snippet containing sub-Snippets. - - The possible types and type_names are defined in Python's symbol module.""" - def __init__(self, symbol_type, children): - self._type = symbol_type - self._children = children - - @property - def type(self): - return self._type - - @property - def type_name(self): - return symbol.sym_name[self.type] - - @property - def children(self): - return self._children - - @children.setter - def children(self, value): # pylint: disable=arguments-differ - self._children = value - - @property - def tokens(self): - tokens = [] - for child in self.children: - tokens += child.tokens - return tuple(tokens) - - @property - def modified(self): - return any(child.modified for child in self.children) - - def PrintTree(self, indent=0, stream=sys.stdout): - stream.write(' ' * indent) - - # If there's only one child, collapse it onto the same line. - node = self - while len(node.children) == 1 and len(node.children[0].children) == 1: - print >> stream, node.type_name, - node = node.children[0] - - print >> stream, node.type_name - for child in node.children: - child.PrintTree(indent+2, stream) - - -def Snippetize(f): - """Return the syntax tree of the given file.""" - f.seek(0) - syntax_tree = parser.st2list(parser.suite(f.read())) - tokens = offset_token.Tokenize(f) - - snippet = _SnippetizeNode(syntax_tree, tokens) - assert not tokens - return snippet - - -def _SnippetizeNode(node, tokens): - # The parser module gives a syntax tree that discards comments, - # non-terminating newlines, and whitespace information. Use the tokens given - # by the tokenize module to annotate the syntax tree with the information - # needed to exactly reproduce the original source code. - node_type = node[0] - - if node_type >= token.NT_OFFSET: - # Symbol. - children = tuple(_SnippetizeNode(child, tokens) for child in node[1:]) - return Symbol(node_type, children) - else: - # Token. - grabbed_tokens = [] - while tokens and ( - tokens[0].type == tokenize.COMMENT or tokens[0].type == tokenize.NL): - grabbed_tokens.append(tokens.popleft()) - - # parser has 2 NEWLINEs right before the end. - # tokenize has 0 or 1 depending on if the file has one. - # Create extra nodes without consuming tokens to account for this. - if node_type == token.NEWLINE: - for tok in tokens: - if tok.type == token.ENDMARKER: - return TokenSnippet(node_type, grabbed_tokens) - if tok.type != token.DEDENT: - break - - assert tokens[0].type == token.OP or node_type == tokens[0].type - - grabbed_tokens.append(tokens.popleft()) - return TokenSnippet(node_type, grabbed_tokens)
diff --git a/tools/telemetry/catapult_base/refactor_util/__init__.py b/tools/telemetry/catapult_base/refactor_util/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/tools/telemetry/catapult_base/refactor_util/__init__.py +++ /dev/null
diff --git a/tools/telemetry/catapult_base/refactor_util/move.py b/tools/telemetry/catapult_base/refactor_util/move.py deleted file mode 100644 index 108413b..0000000 --- a/tools/telemetry/catapult_base/refactor_util/move.py +++ /dev/null
@@ -1,115 +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. - -import functools -import os -import sys - -from catapult_base import refactor - - -def Run(sources, target, files_to_update): - """Move modules and update imports. - - Args: - sources: List of source module or package paths. - target: Destination module or package path. - files_to_update: Modules whose imports we should check for changes. - """ - # TODO(dtu): Support moving classes and functions. - moves = tuple(_Move(source, target) for source in sources) - - # Update imports and references. - refactor.Transform(functools.partial(_Update, moves), files_to_update) - - # Move files. - for move in moves: - os.rename(move.source_path, move.target_path) - - -def _Update(moves, module): - for import_statement in module.FindAll(refactor.Import): - for move in moves: - try: - if move.UpdateImportAndReferences(module, import_statement): - break - except NotImplementedError as e: - print >> sys.stderr, 'Error updating %s: %s' % (module.file_path, e) - - -class _Move(object): - def __init__(self, source, target): - self._source_path = os.path.realpath(source) - self._target_path = os.path.realpath(target) - - if os.path.isdir(self._target_path): - self._target_path = os.path.join( - self._target_path, os.path.basename(self._source_path)) - - @property - def source_path(self): - return self._source_path - - @property - def target_path(self): - return self._target_path - - @property - def source_module_path(self): - return _ModulePath(self._source_path) - - @property - def target_module_path(self): - return _ModulePath(self._target_path) - - def UpdateImportAndReferences(self, module, import_statement): - """Update an import statement in a module and all its references.. - - Args: - module: The refactor.Module to update. - import_statement: The refactor.Import to update. - - Returns: - True if the import statement was updated, or False if the import statement - needed no updating. - """ - statement_path_parts = import_statement.path.split('.') - source_path_parts = self.source_module_path.split('.') - if source_path_parts != statement_path_parts[:len(source_path_parts)]: - return False - - # Update import statement. - old_name_parts = import_statement.name.split('.') - new_name_parts = ([self.target_module_path] + - statement_path_parts[len(source_path_parts):]) - import_statement.path = '.'.join(new_name_parts) - new_name = import_statement.name - - # Update references. - for reference in module.FindAll(refactor.Reference): - reference_parts = reference.value.split('.') - if old_name_parts != reference_parts[:len(old_name_parts)]: - continue - - new_reference_parts = [new_name] + reference_parts[len(old_name_parts):] - reference.value = '.'.join(new_reference_parts) - - return True - - -def _BaseDir(module_path): - if not os.path.isdir(module_path): - module_path = os.path.dirname(module_path) - - while '__init__.py' in os.listdir(module_path): - module_path = os.path.dirname(module_path) - - return module_path - - -def _ModulePath(module_path): - if os.path.split(module_path)[1] == '__init__.py': - module_path = os.path.dirname(module_path) - rel_path = os.path.relpath(module_path, _BaseDir(module_path)) - return os.path.splitext(rel_path)[0].replace(os.sep, '.')
diff --git a/tools/telemetry/catapult_base/test_data/foo.txt b/tools/telemetry/catapult_base/test_data/foo.txt deleted file mode 100644 index a9cac3ec..0000000 --- a/tools/telemetry/catapult_base/test_data/foo.txt +++ /dev/null
@@ -1 +0,0 @@ -This file is not executable.
diff --git a/tools/telemetry/catapult_base/util.py b/tools/telemetry/catapult_base/util.py deleted file mode 100644 index 25fed01..0000000 --- a/tools/telemetry/catapult_base/util.py +++ /dev/null
@@ -1,25 +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. -import os -import sys - - -def GetCatapultDir(): - return os.path.normpath(os.path.join( - os.path.dirname(__file__), '..', '..', '..', 'third_party', 'catapult')) - - -def IsRunningOnCrosDevice(): - """Returns True if we're on a ChromeOS device.""" - lsb_release = '/etc/lsb-release' - if sys.platform.startswith('linux') and os.path.exists(lsb_release): - with open(lsb_release, 'r') as f: - res = f.read() - if res.count('CHROMEOS_RELEASE_NAME'): - return True - return False - - -def IsExecutable(path): - return os.path.isfile(path) and os.access(path, os.X_OK)
diff --git a/ui/arc/notification/arc_notification_item.cc b/ui/arc/notification/arc_notification_item.cc index 05e67ab..694f41bd 100644 --- a/ui/arc/notification/arc_notification_item.cc +++ b/ui/arc/notification/arc_notification_item.cc
@@ -104,15 +104,15 @@ message_center::NotificationType type; switch (data.type) { - case ARC_NOTIFICATION_TYPE_BASIC: + case ArcNotificationType::BASIC: type = message_center::NOTIFICATION_TYPE_SIMPLE; break; - case ARC_NOTIFICATION_TYPE_IMAGE: + case ArcNotificationType::IMAGE: // TODO(yoshiki): Implement this types. type = message_center::NOTIFICATION_TYPE_SIMPLE; LOG(ERROR) << "Unsupported notification type: image"; break; - case ARC_NOTIFICATION_TYPE_PROGRESS: + case ArcNotificationType::PROGRESS: type = message_center::NOTIFICATION_TYPE_PROGRESS; rich_data.timestamp = base::Time::UnixEpoch() + base::TimeDelta::FromMilliseconds(data.time); @@ -122,7 +122,7 @@ data.progress_max * 100)))); break; } - DCHECK(0 <= data.type && data.type <= ARC_NOTIFICATION_TYPE_MAX) + DCHECK(ArcNotificationType_IsValidValue(data.type)) << "Unsupported notification type: " << data.type; // The identifier of the notifier, which is used to distinguish the notifiers
diff --git a/ui/arc/notification/arc_notification_manager.cc b/ui/arc/notification/arc_notification_manager.cc index 91b8c26..9c87735 100644 --- a/ui/arc/notification/arc_notification_manager.cc +++ b/ui/arc/notification/arc_notification_manager.cc
@@ -76,7 +76,7 @@ scoped_ptr<ArcNotificationItem> item(items_.take_and_erase(it)); arc_bridge_->notifications_instance()->SendNotificationEventToAndroid( - key, ARC_NOTIFICATION_EVENT_CLOSED); + key, ArcNotificationEvent::CLOSED); } void ArcNotificationManager::SendNotificationClickedOnChrome( @@ -88,7 +88,7 @@ } arc_bridge_->notifications_instance()->SendNotificationEventToAndroid( - key, ARC_NOTIFICATION_EVENT_BODY_CLICKED); + key, ArcNotificationEvent::BODY_CLICKED); } } // namespace arc
diff --git a/ui/base/ime/ime_engine_handler_interface.h b/ui/base/ime/ime_engine_handler_interface.h index a394f37..3987085 100644 --- a/ui/base/ime/ime_engine_handler_interface.h +++ b/ui/base/ime/ime_engine_handler_interface.h
@@ -138,6 +138,10 @@ // Hides the input view window (from API call). virtual void HideInputView() = 0; +#elif defined(OS_LINUX) || defined(OS_WIN) + + // Get the id of the IME extension. + virtual std::string GetExtensionId() const = 0; #endif // defined(OS_CHROMEOS) protected: IMEEngineHandlerInterface() {}
diff --git a/ui/gl/gl_surface.cc b/ui/gl/gl_surface.cc index 419af52..2fccf87 100644 --- a/ui/gl/gl_surface.cc +++ b/ui/gl/gl_surface.cc
@@ -213,10 +213,11 @@ float opacity, unsigned background_color, unsigned edge_aa_mask, - const RectF& bounds_rect, + const RectF& rect, bool is_clipped, const RectF& clip_rect, - const Transform& transform) { + const Transform& transform, + int sorting_content_id) { NOTIMPLEMENTED(); return false; }
diff --git a/ui/gl/gl_surface.h b/ui/gl/gl_surface.h index ff828985..3b08ebc 100644 --- a/ui/gl/gl_surface.h +++ b/ui/gl/gl_surface.h
@@ -182,10 +182,11 @@ float opacity, unsigned background_color, unsigned edge_aa_mask, - const RectF& bounds_rect, + const RectF& rect, bool is_clipped, const RectF& clip_rect, - const Transform& transform); + const Transform& transform, + int sorting_content_id); virtual bool IsSurfaceless() const;
diff --git a/ui/views/mus/native_widget_mus.cc b/ui/views/mus/native_widget_mus.cc index 11b77a2..4efb593 100644 --- a/ui/views/mus/native_widget_mus.cc +++ b/ui/views/mus/native_widget_mus.cc
@@ -155,16 +155,15 @@ DISALLOW_COPY_AND_ASSIGN(ClientSideNonClientFrameView); }; -mus::mojom::ResizeBehavior ResizeBehaviorFromDelegate( - WidgetDelegate* delegate) { - int32_t behavior = mus::mojom::RESIZE_BEHAVIOR_NONE; +int ResizeBehaviorFromDelegate(WidgetDelegate* delegate) { + int32_t behavior = mus::mojom::kResizeBehaviorNone; if (delegate->CanResize()) - behavior |= mus::mojom::RESIZE_BEHAVIOR_CAN_RESIZE; + behavior |= mus::mojom::kResizeBehaviorCanResize; if (delegate->CanMaximize()) - behavior |= mus::mojom::RESIZE_BEHAVIOR_CAN_MAXIMIZE; + behavior |= mus::mojom::kResizeBehaviorCanMaximize; if (delegate->CanMinimize()) - behavior |= mus::mojom::RESIZE_BEHAVIOR_CAN_MINIMIZE; - return static_cast<mus::mojom::ResizeBehavior>(behavior); + behavior |= mus::mojom::kResizeBehaviorCanMinimize; + return behavior; } } // namespace @@ -255,7 +254,8 @@ (*properties)[mus::mojom::WindowManager::kWindowType_Property] = mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert( - mojo::ConvertTo<mus::mojom::WindowType>(init_params.type)); + static_cast<int32_t>( + mojo::ConvertTo<mus::mojom::WindowType>(init_params.type))); (*properties)[mus::mojom::WindowManager::kResizeBehavior_Property] = mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert( ResizeBehaviorFromDelegate(init_params.delegate));
diff --git a/ui/views/mus/platform_window_mus.cc b/ui/views/mus/platform_window_mus.cc index 2f29180c..407d8201 100644 --- a/ui/views/mus/platform_window_mus.cc +++ b/ui/views/mus/platform_window_mus.cc
@@ -23,8 +23,8 @@ mus::Window* mus_window) : delegate_(delegate), mus_window_(mus_window), - show_state_(mus::mojom::SHOW_STATE_RESTORED), - last_cursor_(mus::mojom::CURSOR_NULL), + show_state_(mus::mojom::ShowState::RESTORED), + last_cursor_(mus::mojom::Cursor::CURSOR_NULL), has_capture_(false), mus_window_destroyed_(false) { DCHECK(delegate_); @@ -111,15 +111,15 @@ } void PlatformWindowMus::Maximize() { - SetShowState(mus::mojom::SHOW_STATE_MAXIMIZED); + SetShowState(mus::mojom::ShowState::MAXIMIZED); } void PlatformWindowMus::Minimize() { - SetShowState(mus::mojom::SHOW_STATE_MINIMIZED); + SetShowState(mus::mojom::ShowState::MINIMIZED); } void PlatformWindowMus::Restore() { - SetShowState(mus::mojom::SHOW_STATE_RESTORED); + SetShowState(mus::mojom::ShowState::RESTORED); } void PlatformWindowMus::SetCursor(ui::PlatformCursor cursor) { @@ -140,7 +140,8 @@ void PlatformWindowMus::SetShowState(mus::mojom::ShowState show_state) { mus_window_->SetSharedProperty<int32_t>( - mus::mojom::WindowManager::kShowState_Property, show_state); + mus::mojom::WindowManager::kShowState_Property, + static_cast<int32_t>(show_state)); } void PlatformWindowMus::OnWindowDestroyed(mus::Window* window) { @@ -193,17 +194,17 @@ show_state_ = show_state; ui::PlatformWindowState state = ui::PLATFORM_WINDOW_STATE_UNKNOWN; switch (show_state_) { - case mus::mojom::SHOW_STATE_MINIMIZED: + case mus::mojom::ShowState::MINIMIZED: state = ui::PLATFORM_WINDOW_STATE_MINIMIZED; break; - case mus::mojom::SHOW_STATE_MAXIMIZED: + case mus::mojom::ShowState::MAXIMIZED: state = ui::PLATFORM_WINDOW_STATE_MAXIMIZED; break; - case mus::mojom::SHOW_STATE_RESTORED: + case mus::mojom::ShowState::RESTORED: state = ui::PLATFORM_WINDOW_STATE_NORMAL; break; - case mus::mojom::SHOW_STATE_IMMERSIVE: - case mus::mojom::SHOW_STATE_PRESENTATION: + case mus::mojom::ShowState::IMMERSIVE: + case mus::mojom::ShowState::PRESENTATION: // This may not be sufficient. state = ui::PLATFORM_WINDOW_STATE_FULLSCREEN; break;
diff --git a/ui/views/mus/window_manager_connection.cc b/ui/views/mus/window_manager_connection.cc index 2865347..b13c09e 100644 --- a/ui/views/mus/window_manager_connection.cc +++ b/ui/views/mus/window_manager_connection.cc
@@ -28,13 +28,13 @@ gfx::Display::Rotation GFXRotationFromMojomRotation( mus::mojom::Rotation input) { switch (input) { - case mus::mojom::ROTATION_VALUE_0: + case mus::mojom::Rotation::VALUE_0: return gfx::Display::ROTATE_0; - case mus::mojom::ROTATION_VALUE_90: + case mus::mojom::Rotation::VALUE_90: return gfx::Display::ROTATE_90; - case mus::mojom::ROTATION_VALUE_180: + case mus::mojom::Rotation::VALUE_180: return gfx::Display::ROTATE_180; - case mus::mojom::ROTATION_VALUE_270: + case mus::mojom::Rotation::VALUE_270: return gfx::Display::ROTATE_270; } return gfx::Display::ROTATE_0; @@ -157,7 +157,7 @@ std::map<std::string, std::vector<uint8_t>> properties; NativeWidgetMus::ConfigurePropertiesForNewWindow(init_params, &properties); return new NativeWidgetMus(delegate, app_->shell(), NewWindow(properties), - mus::mojom::SURFACE_TYPE_DEFAULT); + mus::mojom::SurfaceType::DEFAULT); } } // namespace views
diff --git a/ui/views/mus/window_manager_constants_converters.cc b/ui/views/mus/window_manager_constants_converters.cc index 80e6d1f..8897376 100644 --- a/ui/views/mus/window_manager_constants_converters.cc +++ b/ui/views/mus/window_manager_constants_converters.cc
@@ -12,25 +12,25 @@ views::Widget::InitParams::Type type) { switch (type) { case views::Widget::InitParams::TYPE_WINDOW: - return mus::mojom::WINDOW_TYPE_WINDOW; + return mus::mojom::WindowType::WINDOW; case views::Widget::InitParams::TYPE_PANEL: - return mus::mojom::WINDOW_TYPE_PANEL; + return mus::mojom::WindowType::PANEL; case views::Widget::InitParams::TYPE_WINDOW_FRAMELESS: - return mus::mojom::WINDOW_TYPE_WINDOW_FRAMELESS; + return mus::mojom::WindowType::WINDOW_FRAMELESS; case views::Widget::InitParams::TYPE_CONTROL: - return mus::mojom::WINDOW_TYPE_CONTROL; + return mus::mojom::WindowType::CONTROL; case views::Widget::InitParams::TYPE_POPUP: - return mus::mojom::WINDOW_TYPE_POPUP; + return mus::mojom::WindowType::POPUP; case views::Widget::InitParams::TYPE_MENU: - return mus::mojom::WINDOW_TYPE_MENU; + return mus::mojom::WindowType::MENU; case views::Widget::InitParams::TYPE_TOOLTIP: - return mus::mojom::WINDOW_TYPE_TOOLTIP; + return mus::mojom::WindowType::TOOLTIP; case views::Widget::InitParams::TYPE_BUBBLE: - return mus::mojom::WINDOW_TYPE_BUBBLE; + return mus::mojom::WindowType::BUBBLE; case views::Widget::InitParams::TYPE_DRAG: - return mus::mojom::WINDOW_TYPE_DRAG; + return mus::mojom::WindowType::DRAG; } - return mus::mojom::WINDOW_TYPE_POPUP; + return mus::mojom::WindowType::POPUP; } } // namespace mojo