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

Side by Side Diff: webkit/renderer/compositor_bindings/web_layer_impl.cc

Issue 135493002: Plumb debug name via debug info (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/renderer/compositor_bindings/web_layer_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" 5 #include "webkit/renderer/compositor_bindings/web_layer_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event_impl.h" 8 #include "base/debug/trace_event_impl.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 layer_->set_did_scroll_callback(base::Closure()); 398 layer_->set_did_scroll_callback(base::Closure());
399 } 399 }
400 } 400 }
401 401
402 bool WebLayerImpl::isOrphan() const { return !layer_->layer_tree_host(); } 402 bool WebLayerImpl::isOrphan() const { return !layer_->layer_tree_host(); }
403 403
404 void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) { 404 void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) {
405 web_layer_client_ = client; 405 web_layer_client_ = client;
406 } 406 }
407 407
408 // TODO(chrishtr): move DebugName into this class.
409 class TracedDebugInfo : public base::debug::ConvertableToTraceFormat { 408 class TracedDebugInfo : public base::debug::ConvertableToTraceFormat {
410 public: 409 public:
411 // This object takes ownership of the debug_info object. 410 // This object takes ownership of the debug_info object.
412 explicit TracedDebugInfo(blink::WebGraphicsLayerDebugInfo* debug_info) : 411 explicit TracedDebugInfo(blink::WebGraphicsLayerDebugInfo* debug_info) :
413 debug_info_(debug_info) {} 412 debug_info_(debug_info) {}
414 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE { 413 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE {
415 DCHECK(thread_checker_.CalledOnValidThread()); 414 DCHECK(thread_checker_.CalledOnValidThread());
416 blink::WebString web_string; 415 blink::WebString web_string;
417 debug_info_->appendAsTraceFormat(&web_string); 416 debug_info_->appendAsTraceFormat(&web_string);
418 out->append(web_string.utf8()); 417 out->append(web_string.utf8());
419 } 418 }
420 private: 419 private:
421 virtual ~TracedDebugInfo() {} 420 virtual ~TracedDebugInfo() {}
422 scoped_ptr<blink::WebGraphicsLayerDebugInfo> debug_info_; 421 scoped_ptr<blink::WebGraphicsLayerDebugInfo> debug_info_;
423 base::ThreadChecker thread_checker_; 422 base::ThreadChecker thread_checker_;
424 }; 423 };
425 424
426 scoped_refptr<base::debug::ConvertableToTraceFormat> 425 scoped_refptr<base::debug::ConvertableToTraceFormat>
427 WebLayerImpl::TakeDebugInfo() { 426 WebLayerImpl::TakeDebugInfo() {
428 if (!web_layer_client_) 427 if (!web_layer_client_)
429 return NULL; 428 return NULL;
430 blink::WebGraphicsLayerDebugInfo* debug_info = 429 blink::WebGraphicsLayerDebugInfo* debug_info =
431 web_layer_client_->takeDebugInfo(); 430 web_layer_client_->takeDebugInfoFor(this);
432 431
433 if (debug_info) 432 if (debug_info)
434 return new TracedDebugInfo(debug_info); 433 return new TracedDebugInfo(debug_info);
435 else 434 else
436 return NULL; 435 return NULL;
437 } 436 }
438 437
439 std::string WebLayerImpl::DebugName() {
440 if (!web_layer_client_)
441 return std::string();
442
443 std::string name = web_layer_client_->debugName(this).utf8();
444 DCHECK(IsStringASCII(name));
445 return name;
446 }
447
448 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) { 438 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) {
449 cc::Layer* scroll_parent = NULL; 439 cc::Layer* scroll_parent = NULL;
450 if (parent) 440 if (parent)
451 scroll_parent = static_cast<WebLayerImpl*>(parent)->layer(); 441 scroll_parent = static_cast<WebLayerImpl*>(parent)->layer();
452 layer_->SetScrollParent(scroll_parent); 442 layer_->SetScrollParent(scroll_parent);
453 } 443 }
454 444
455 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { 445 void WebLayerImpl::setClipParent(blink::WebLayer* parent) {
456 cc::Layer* clip_parent = NULL; 446 cc::Layer* clip_parent = NULL;
457 if (parent) 447 if (parent)
458 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); 448 clip_parent = static_cast<WebLayerImpl*>(parent)->layer();
459 layer_->SetClipParent(clip_parent); 449 layer_->SetClipParent(clip_parent);
460 } 450 }
461 451
462 Layer* WebLayerImpl::layer() const { return layer_.get(); } 452 Layer* WebLayerImpl::layer() const { return layer_.get(); }
463 453
464 } // namespace webkit 454 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/renderer/compositor_bindings/web_layer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698