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

Unified Diff: content/child/high_priority_resource_filter.cc

Issue 281073002: NOT FOR REVIEW: Adding prioritized incoming task queue to renderers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Prioritize input events Created 6 years, 7 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
« no previous file with comments | « content/child/high_priority_resource_filter.h ('k') | content/child/resource_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/high_priority_resource_filter.cc
diff --git a/content/child/high_priority_resource_filter.cc b/content/child/high_priority_resource_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7b68c33eed4fc80c646bb2301ce63d424a21de6d
--- /dev/null
+++ b/content/child/high_priority_resource_filter.cc
@@ -0,0 +1,83 @@
+// 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.
+
+#include "content/child/high_priority_resource_filter.h"
+
+#include "base/bind.h"
+#include "base/debug/trace_event.h"
+#include "base/message_loop/high_priority_task_runner.h"
+#include "base/pickle.h"
+#include "base/thread_task_runner_handle.h"
+#include "content/child/resource_dispatcher.h"
+#include "content/common/resource_messages.h"
+
+namespace content {
+
+namespace {
+
+// Runs on the main thread.
+void DispatchMessage(ResourceDispatcher* resource_dispatcher,
+ base::TimeTicks io_timestamp,
+ const IPC::Message& message) {
+ TRACE_EVENT0("loader", "HighPriorityResourceFilter::DispatchMessage");
+ resource_dispatcher->set_io_timestamp(io_timestamp);
+ resource_dispatcher->OnMessageReceived(message);
+}
+
+} // namespace
+
+HighPriorityResourceFilter::HighPriorityResourceFilter(
+ ResourceDispatcher* resource_dispatcher,
+ scoped_refptr<base::HighPriorityTaskRunner> runner)
+ : resource_dispatcher_(resource_dispatcher),
+ runner_(runner) {
+}
+
+HighPriorityResourceFilter::~HighPriorityResourceFilter() {
+}
+
+bool HighPriorityResourceFilter::OnMessageReceived(
+ const IPC::Message& message) {
+ if (IsHighPriorityResourceResonse(message)) {
+ runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&DispatchMessage,
+ base::Unretained(resource_dispatcher_),
+ base::TimeTicks::Now(),
+ message));
+ return true;
+ }
+ return false;
+}
+
+// Runs on the IO thread
+bool HighPriorityResourceFilter::IsHighPriorityResourceResonse(
+ const IPC::Message& message) {
+ if (ResourceDispatcher::IsResourceDispatcherMessage(message)) {
+ int request_id;
+ PickleIterator iter(message);
+ if (!message.ReadInt(&iter, &request_id))
+ return false;
+
+ base::AutoLock auto_lock(request_ids_lock_);
+ return request_ids_.find(request_id) != request_ids_.end();
+ }
+ return false;
+}
+
+// Runs on the main thread
+void HighPriorityResourceFilter::AddPendingRequest(
+ int request_id, ResourceType::Type resource_type) {
+ if (resource_type == ResourceType::FONT_RESOURCE) {
+ base::AutoLock auto_lock(request_ids_lock_);
+ request_ids_.insert(request_id);
+ }
+}
+
+void HighPriorityResourceFilter::RemovePendingRequest(int request_id) {
+ base::AutoLock auto_lock(request_ids_lock_);
+ request_ids_.erase(request_id);
+}
+
+} // namespace content
« no previous file with comments | « content/child/high_priority_resource_filter.h ('k') | content/child/resource_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698