Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: components/mus/public/cpp/lib/window_surface.cc

Issue 1484533002: mus: Introduce AttachSurface to allow creating Surface prior to OnEmbed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Sadrul's comments Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/mus/public/cpp/lib/window.cc ('k') | components/mus/public/cpp/lib/window_tree_client_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/public/cpp/lib/window_surface.cc
diff --git a/components/mus/public/cpp/lib/window_surface.cc b/components/mus/public/cpp/lib/window_surface.cc
index 83c4be011dda8a7549267aeaae1e63c8f4ed2e43..076243cadfdcb7a98f6777d795f9541ec4087dbe 100644
--- a/components/mus/public/cpp/lib/window_surface.cc
+++ b/components/mus/public/cpp/lib/window_surface.cc
@@ -9,11 +9,25 @@
namespace mus {
+// static
+scoped_ptr<WindowSurface> WindowSurface::Create(
+ scoped_ptr<WindowSurfaceBinding>* surface_binding) {
+ mojom::SurfacePtr surface;
+ mojom::SurfaceClientPtr surface_client;
+ mojo::InterfaceRequest<mojom::SurfaceClient> surface_client_request =
+ GetProxy(&surface_client);
+
+ surface_binding->reset(
+ new WindowSurfaceBinding(GetProxy(&surface), surface_client.Pass()));
+ return make_scoped_ptr(new WindowSurface(surface.PassInterface(),
+ surface_client_request.Pass()));
+}
+
WindowSurface::~WindowSurface() {}
void WindowSurface::BindToThread() {
- DCHECK(!bound_to_thread_);
- bound_to_thread_ = true;
+ DCHECK(!thread_checker_);
+ thread_checker_.reset(new base::ThreadChecker());
surface_.Bind(surface_info_.Pass());
client_binding_.reset(
new mojo::Binding<mojom::SurfaceClient>(this, client_request_.Pass()));
@@ -21,7 +35,8 @@ void WindowSurface::BindToThread() {
void WindowSurface::SubmitCompositorFrame(mojom::CompositorFramePtr frame,
const mojo::Closure& callback) {
- DCHECK(bound_to_thread_);
+ DCHECK(thread_checker_);
+ DCHECK(thread_checker_->CalledOnValidThread());
if (!surface_)
return;
surface_->SubmitCompositorFrame(frame.Pass(), callback);
@@ -32,14 +47,23 @@ WindowSurface::WindowSurface(
mojo::InterfaceRequest<mojom::SurfaceClient> client_request)
: client_(nullptr),
surface_info_(surface_info.Pass()),
- client_request_(client_request.Pass()),
- bound_to_thread_(false) {}
+ client_request_(client_request.Pass()) {}
void WindowSurface::ReturnResources(
mojo::Array<mojom::ReturnedResourcePtr> resources) {
+ DCHECK(thread_checker_);
+ DCHECK(thread_checker_->CalledOnValidThread());
if (!client_)
return;
client_->OnResourcesReturned(this, resources.Pass());
}
+WindowSurfaceBinding::~WindowSurfaceBinding() {}
+
+WindowSurfaceBinding::WindowSurfaceBinding(
+ mojo::InterfaceRequest<mojom::Surface> surface_request,
+ mojom::SurfaceClientPtr surface_client)
+ : surface_request_(surface_request.Pass()),
+ surface_client_(surface_client.Pass()) {}
+
} // namespace mus
« no previous file with comments | « components/mus/public/cpp/lib/window.cc ('k') | components/mus/public/cpp/lib/window_tree_client_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698