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

Unified Diff: gpu/ipc/service/gpu_command_buffer_stub.cc

Issue 2378583003: Ping watchdog thread during GpuChannel destruction (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: gpu/ipc/service/gpu_command_buffer_stub.cc
diff --git a/gpu/ipc/service/gpu_command_buffer_stub.cc b/gpu/ipc/service/gpu_command_buffer_stub.cc
index 412d9a97182600dd249a90304302123b615ba887..3e206101b2eceb4f4a93ec5eb13c2dc21543f088 100644
--- a/gpu/ipc/service/gpu_command_buffer_stub.cc
+++ b/gpu/ipc/service/gpu_command_buffer_stub.cc
@@ -26,6 +26,7 @@
#include "gpu/command_buffer/service/logger.h"
#include "gpu/command_buffer/service/mailbox_manager.h"
#include "gpu/command_buffer/service/memory_tracking.h"
+#include "gpu/command_buffer/service/progress_reporter.h"
#include "gpu/command_buffer/service/query_manager.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
#include "gpu/command_buffer/service/transfer_buffer_manager.h"
@@ -105,6 +106,35 @@ class GpuCommandBufferMemoryTracker : public gles2::MemoryTracker {
DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferMemoryTracker);
};
+// GpuCommandBufferProgressReporter is used as a bridge between the
+// ContextGroup and the GpuChannel's GpuWatchdogThread.
+class GpuCommandBufferProgressReporter : public gles2::ProgressReporter {
+ public:
+ GpuCommandBufferProgressReporter(GpuChannel* channel) : channel_(channel) {}
+
+ void ReportProgress() override {
+ if (auto* watchdog = channel_->watchdog()) {
+ // CheckArmed posts a task. Throttle this so we don't post more than
vmiura 2016/09/30 18:24:35 Rather than adding throttling here, it seems we co
ericrk 2016/10/01 06:19:27 Good point - I don't want to overload this CL, so
+ // one task per second.
+ base::TimeTicks now = base::TimeTicks::Now();
+ if (now < next_check_time_)
+ return;
+
+ next_check_time_ = now + base::TimeDelta::FromSeconds(kMaxCheckRateS);
+ watchdog->CheckArmed();
+ }
+ }
+
+ private:
+ // The max rate at which we will signal the watchdog thread.
+ static const int kMaxCheckRateS = 1;
+
+ // The GpuChannel always outlives the GpuCommandBufferStub and the
+ // ContextGroups it creates, so it's safe to hold by raw pointer here.
+ GpuChannel* channel_;
+ base::TimeTicks next_check_time_;
+};
+
// FastSetActiveURL will shortcut the expensive call to SetActiveURL when the
// url_hash matches.
void FastSetActiveURL(const GURL& url, size_t url_hash, GpuChannel* channel) {
@@ -469,7 +499,8 @@ bool GpuCommandBufferStub::Initialize(
manager->shader_translator_cache(),
manager->framebuffer_completeness_cache(), feature_info,
init_params.attribs.bind_generates_resource,
- gmb_factory ? gmb_factory->AsImageFactory() : nullptr);
+ gmb_factory ? gmb_factory->AsImageFactory() : nullptr,
+ base::MakeUnique<GpuCommandBufferProgressReporter>(channel_));
}
#if defined(OS_MACOSX)
« gpu/command_buffer/service/context_group.cc ('K') | « gpu/gles2_conform_support/egl/context.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698