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

Unified Diff: chrome/browser/renderer_host/thread_hop_resource_throttle.h

Issue 1372263002: Add a field trial to delay all resource requests by thread hops. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke comments Created 5 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: chrome/browser/renderer_host/thread_hop_resource_throttle.h
diff --git a/chrome/browser/renderer_host/thread_hop_resource_throttle.h b/chrome/browser/renderer_host/thread_hop_resource_throttle.h
new file mode 100644
index 0000000000000000000000000000000000000000..1de718c305672a9e8304164ba70f0b64c7182287
--- /dev/null
+++ b/chrome/browser/renderer_host/thread_hop_resource_throttle.h
@@ -0,0 +1,43 @@
+// Copyright 2015 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.
+
+#ifndef CHROME_BROWSER_RENDERER_HOST_THREAD_HOP_RESOURCE_THROTTLE_H_
+#define CHROME_BROWSER_RENDERER_HOST_THREAD_HOP_RESOURCE_THROTTLE_H_
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "content/public/browser/resource_throttle.h"
+
+namespace base {
+class TimeTicks;
+}
+
+// A ResourceThrottle which defers request start, redirect, and response
+// completion on an IO to UI to IO round-trip. This throttle will be added on a
+// field trial to determine the cost of making some resource-related decisions
+// on the UI thread. See https://crbug.com/524228.
+class ThreadHopResourceThrottle : public content::ResourceThrottle {
+ public:
+ ThreadHopResourceThrottle();
+ ~ThreadHopResourceThrottle() override;
+
+ static bool IsEnabled();
+
+ // content::ResourceThrottle implementation:
Alexei Svitkine (slow) 2015/10/02 16:42:54 Nit: I think the new suggested content for this ty
davidben 2015/10/02 17:39:39 Done.
+ void WillStartRequest(bool* defer) override;
+ void WillRedirectRequest(const net::RedirectInfo& redirect_info,
+ bool* defer) override;
+ void WillProcessResponse(bool* defer) override;
+ const char* GetNameForLogging() const override;
+
+ private:
+ void ResumeAfterThreadHop();
+ void Resume(const base::TimeTicks& time);
+
+ base::WeakPtrFactory<ThreadHopResourceThrottle> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ThreadHopResourceThrottle);
+};
+
+#endif // CHROME_BROWSER_RENDERER_HOST_THREAD_HOP_RESOURCE_THROTTLE_H_

Powered by Google App Engine
This is Rietveld 408576698