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

Side by Side Diff: content/common/gpu/gpu_channel.cc

Issue 649533003: C++11 declares a type safe null pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Presubmit errors Created 6 years, 2 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
« no previous file with comments | « content/common/gpu/gpu_channel.h ('k') | content/common/gpu/gpu_channel_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #if defined(OS_WIN) 5 #if defined(OS_WIN)
6 #include <windows.h> 6 #include <windows.h>
7 #endif 7 #endif
8 8
9 #include "content/common/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // into the channel's queue. 69 // into the channel's queue.
70 // - it generates mailbox names for clients of the GPU process on the IO thread. 70 // - it generates mailbox names for clients of the GPU process on the IO thread.
71 class GpuChannelMessageFilter : public IPC::MessageFilter { 71 class GpuChannelMessageFilter : public IPC::MessageFilter {
72 public: 72 public:
73 GpuChannelMessageFilter(base::WeakPtr<GpuChannel> gpu_channel, 73 GpuChannelMessageFilter(base::WeakPtr<GpuChannel> gpu_channel,
74 scoped_refptr<SyncPointManager> sync_point_manager, 74 scoped_refptr<SyncPointManager> sync_point_manager,
75 scoped_refptr<base::MessageLoopProxy> message_loop, 75 scoped_refptr<base::MessageLoopProxy> message_loop,
76 bool future_sync_points) 76 bool future_sync_points)
77 : preemption_state_(IDLE), 77 : preemption_state_(IDLE),
78 gpu_channel_(gpu_channel), 78 gpu_channel_(gpu_channel),
79 sender_(NULL), 79 sender_(nullptr),
80 sync_point_manager_(sync_point_manager), 80 sync_point_manager_(sync_point_manager),
81 message_loop_(message_loop), 81 message_loop_(message_loop),
82 messages_forwarded_to_channel_(0), 82 messages_forwarded_to_channel_(0),
83 a_stub_is_descheduled_(false), 83 a_stub_is_descheduled_(false),
84 future_sync_points_(future_sync_points) {} 84 future_sync_points_(future_sync_points) {}
85 85
86 virtual void OnFilterAdded(IPC::Sender* sender) override { 86 virtual void OnFilterAdded(IPC::Sender* sender) override {
87 DCHECK(!sender_); 87 DCHECK(!sender_);
88 sender_ = sender; 88 sender_ = sender;
89 } 89 }
90 90
91 virtual void OnFilterRemoved() override { 91 virtual void OnFilterRemoved() override {
92 DCHECK(sender_); 92 DCHECK(sender_);
93 sender_ = NULL; 93 sender_ = nullptr;
94 } 94 }
95 95
96 virtual bool OnMessageReceived(const IPC::Message& message) override { 96 virtual bool OnMessageReceived(const IPC::Message& message) override {
97 DCHECK(sender_); 97 DCHECK(sender_);
98 98
99 bool handled = false; 99 bool handled = false;
100 if ((message.type() == GpuCommandBufferMsg_RetireSyncPoint::ID) && 100 if ((message.type() == GpuCommandBufferMsg_RetireSyncPoint::ID) &&
101 !future_sync_points_) { 101 !future_sync_points_) {
102 DLOG(ERROR) << "Untrusted client should not send " 102 DLOG(ERROR) << "Untrusted client should not send "
103 "GpuCommandBufferMsg_RetireSyncPoint message"; 103 "GpuCommandBufferMsg_RetireSyncPoint message";
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 bool software, 402 bool software,
403 bool allow_future_sync_points) 403 bool allow_future_sync_points)
404 : gpu_channel_manager_(gpu_channel_manager), 404 : gpu_channel_manager_(gpu_channel_manager),
405 messages_processed_(0), 405 messages_processed_(0),
406 client_id_(client_id), 406 client_id_(client_id),
407 share_group_(share_group ? share_group : new gfx::GLShareGroup), 407 share_group_(share_group ? share_group : new gfx::GLShareGroup),
408 mailbox_manager_(mailbox ? mailbox : new gpu::gles2::MailboxManager), 408 mailbox_manager_(mailbox ? mailbox : new gpu::gles2::MailboxManager),
409 watchdog_(watchdog), 409 watchdog_(watchdog),
410 software_(software), 410 software_(software),
411 handle_messages_scheduled_(false), 411 handle_messages_scheduled_(false),
412 currently_processing_message_(NULL), 412 currently_processing_message_(nullptr),
413 num_stubs_descheduled_(0), 413 num_stubs_descheduled_(0),
414 allow_future_sync_points_(allow_future_sync_points), 414 allow_future_sync_points_(allow_future_sync_points),
415 weak_factory_(this) { 415 weak_factory_(this) {
416 DCHECK(gpu_channel_manager); 416 DCHECK(gpu_channel_manager);
417 DCHECK(client_id); 417 DCHECK(client_id);
418 418
419 channel_id_ = IPC::Channel::GenerateVerifiedChannelID("gpu"); 419 channel_id_ = IPC::Channel::GenerateVerifiedChannelID("gpu");
420 const base::CommandLine* command_line = 420 const base::CommandLine* command_line =
421 base::CommandLine::ForCurrentProcess(); 421 base::CommandLine::ForCurrentProcess();
422 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); 422 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 } 504 }
505 505
506 return channel_->Send(message); 506 return channel_->Send(message);
507 } 507 }
508 508
509 void GpuChannel::RequeueMessage() { 509 void GpuChannel::RequeueMessage() {
510 DCHECK(currently_processing_message_); 510 DCHECK(currently_processing_message_);
511 deferred_messages_.push_front( 511 deferred_messages_.push_front(
512 new IPC::Message(*currently_processing_message_)); 512 new IPC::Message(*currently_processing_message_));
513 messages_processed_--; 513 messages_processed_--;
514 currently_processing_message_ = NULL; 514 currently_processing_message_ = nullptr;
515 } 515 }
516 516
517 void GpuChannel::OnScheduled() { 517 void GpuChannel::OnScheduled() {
518 if (handle_messages_scheduled_) 518 if (handle_messages_scheduled_)
519 return; 519 return;
520 // Post a task to handle any deferred messages. The deferred message queue is 520 // Post a task to handle any deferred messages. The deferred message queue is
521 // not emptied here, which ensures that OnMessageReceived will continue to 521 // not emptied here, which ensures that OnMessageReceived will continue to
522 // defer newly received messages until the ones in the queue have all been 522 // defer newly received messages until the ones in the queue have all been
523 // handled by HandleMessage. HandleMessage is invoked as a 523 // handled by HandleMessage. HandleMessage is invoked as a
524 // task to prevent reentrancy. 524 // task to prevent reentrancy.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 IPC_END_MESSAGE_MAP() 660 IPC_END_MESSAGE_MAP()
661 DCHECK(handled) << msg.type(); 661 DCHECK(handled) << msg.type();
662 return handled; 662 return handled;
663 } 663 }
664 664
665 void GpuChannel::HandleMessage() { 665 void GpuChannel::HandleMessage() {
666 handle_messages_scheduled_ = false; 666 handle_messages_scheduled_ = false;
667 if (deferred_messages_.empty()) 667 if (deferred_messages_.empty())
668 return; 668 return;
669 669
670 IPC::Message* m = NULL; 670 IPC::Message* m = nullptr;
671 GpuCommandBufferStub* stub = NULL; 671 GpuCommandBufferStub* stub = nullptr;
672 672
673 m = deferred_messages_.front(); 673 m = deferred_messages_.front();
674 stub = stubs_.Lookup(m->routing_id()); 674 stub = stubs_.Lookup(m->routing_id());
675 if (stub) { 675 if (stub) {
676 if (!stub->IsScheduled()) 676 if (!stub->IsScheduled())
677 return; 677 return;
678 if (stub->IsPreempted()) { 678 if (stub->IsPreempted()) {
679 OnScheduled(); 679 OnScheduled();
680 return; 680 return;
681 } 681 }
682 } 682 }
683 683
684 scoped_ptr<IPC::Message> message(m); 684 scoped_ptr<IPC::Message> message(m);
685 deferred_messages_.pop_front(); 685 deferred_messages_.pop_front();
686 bool message_processed = true; 686 bool message_processed = true;
687 687
688 currently_processing_message_ = message.get(); 688 currently_processing_message_ = message.get();
689 bool result; 689 bool result;
690 if (message->routing_id() == MSG_ROUTING_CONTROL) 690 if (message->routing_id() == MSG_ROUTING_CONTROL)
691 result = OnControlMessageReceived(*message); 691 result = OnControlMessageReceived(*message);
692 else 692 else
693 result = router_.RouteMessage(*message); 693 result = router_.RouteMessage(*message);
694 currently_processing_message_ = NULL; 694 currently_processing_message_ = nullptr;
695 695
696 if (!result) { 696 if (!result) {
697 // Respond to sync messages even if router failed to route. 697 // Respond to sync messages even if router failed to route.
698 if (message->is_sync()) { 698 if (message->is_sync()) {
699 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&*message); 699 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&*message);
700 reply->set_reply_error(); 700 reply->set_reply_error();
701 Send(reply); 701 Send(reply);
702 } 702 }
703 } else { 703 } else {
704 // If the command buffer becomes unscheduled as a result of handling the 704 // If the command buffer becomes unscheduled as a result of handling the
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 uint64 GpuChannel::GetMemoryUsage() { 812 uint64 GpuChannel::GetMemoryUsage() {
813 uint64 size = 0; 813 uint64 size = 0;
814 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); 814 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_);
815 !it.IsAtEnd(); it.Advance()) { 815 !it.IsAtEnd(); it.Advance()) {
816 size += it.GetCurrentValue()->GetMemoryUsage(); 816 size += it.GetCurrentValue()->GetMemoryUsage();
817 } 817 }
818 return size; 818 return size;
819 } 819 }
820 820
821 } // namespace content 821 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel.h ('k') | content/common/gpu/gpu_channel_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698