summaryrefslogtreecommitdiff
path: root/chromium/content/browser/loader/detachable_resource_handler.h
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2014-03-18 13:16:26 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-03-20 15:55:39 +0100
commit3f0f86b0caed75241fa71c95a5d73bc0164348c5 (patch)
tree92b9fb00f2e9e90b0be2262093876d4f43b6cd13 /chromium/content/browser/loader/detachable_resource_handler.h
parente90d7c4b152c56919d963987e2503f9909a666d2 (diff)
downloadqtwebengine-chromium-3f0f86b0caed75241fa71c95a5d73bc0164348c5.tar.gz
Update to new stable branch 1750
This also includes an updated ninja and chromium dependencies needed on Windows. Change-Id: Icd597d80ed3fa4425933c9f1334c3c2e31291c42 Reviewed-by: Zoltan Arvai <zarvai@inf.u-szeged.hu> Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'chromium/content/browser/loader/detachable_resource_handler.h')
-rw-r--r--chromium/content/browser/loader/detachable_resource_handler.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/chromium/content/browser/loader/detachable_resource_handler.h b/chromium/content/browser/loader/detachable_resource_handler.h
new file mode 100644
index 00000000000..990084d93b8
--- /dev/null
+++ b/chromium/content/browser/loader/detachable_resource_handler.h
@@ -0,0 +1,94 @@
+// Copyright 2013 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 CONTENT_BROWSER_LOADER_DETACHABLE_RESOURCE_HANDLER_H_
+#define CONTENT_BROWSER_LOADER_DETACHABLE_RESOURCE_HANDLER_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "base/timer/timer.h"
+#include "content/browser/loader/resource_handler.h"
+#include "content/public/browser/resource_controller.h"
+
+namespace net {
+class IOBuffer;
+class URLRequest;
+} // namespace net
+
+namespace content {
+
+// A ResourceHandler which delegates all calls to the next handler, unless
+// detached. Once detached, it drives the request to completion itself. This is
+// used for requests which outlive the owning renderer, such as <link
+// rel=prefetch> and <a ping>. Requests do not start out detached so, e.g.,
+// prefetches appear in DevTools and get placed in the renderer's local
+// cache. If the request does not complete after a timeout on detach, it is
+// cancelled.
+//
+// Note that, once detached, the request continues without the original next
+// handler, so any policy decisions in that handler are skipped.
+class DetachableResourceHandler : public ResourceHandler,
+ public ResourceController {
+ public:
+ DetachableResourceHandler(net::URLRequest* request,
+ base::TimeDelta cancel_delay,
+ scoped_ptr<ResourceHandler> next_handler);
+ virtual ~DetachableResourceHandler();
+
+ bool is_detached() const { return next_handler_ == NULL; }
+ void Detach();
+
+ void set_cancel_delay(base::TimeDelta cancel_delay) {
+ cancel_delay_ = cancel_delay;
+ }
+
+ // ResourceHandler implementation:
+ virtual void SetController(ResourceController* controller) OVERRIDE;
+ virtual bool OnUploadProgress(int request_id, uint64 position,
+ uint64 size) OVERRIDE;
+ virtual bool OnRequestRedirected(int request_id, const GURL& url,
+ ResourceResponse* response,
+ bool* defer) OVERRIDE;
+ virtual bool OnResponseStarted(int request_id,
+ ResourceResponse* response,
+ bool* defer) OVERRIDE;
+ virtual bool OnWillStart(int request_id, const GURL& url,
+ bool* defer) OVERRIDE;
+ virtual bool OnWillRead(int request_id,
+ scoped_refptr<net::IOBuffer>* buf,
+ int* buf_size,
+ int min_size) OVERRIDE;
+ virtual bool OnReadCompleted(int request_id, int bytes_read,
+ bool* defer) OVERRIDE;
+ virtual void OnResponseCompleted(int request_id,
+ const net::URLRequestStatus& status,
+ const std::string& security_info,
+ bool* defer) OVERRIDE;
+ virtual void OnDataDownloaded(int request_id, int bytes_downloaded) OVERRIDE;
+
+ // ResourceController implementation:
+ virtual void Resume() OVERRIDE;
+ virtual void Cancel() OVERRIDE;
+ virtual void CancelAndIgnore() OVERRIDE;
+ virtual void CancelWithError(int error_code) OVERRIDE;
+
+ private:
+ scoped_ptr<ResourceHandler> next_handler_;
+ scoped_refptr<net::IOBuffer> read_buffer_;
+
+ scoped_ptr<base::OneShotTimer<DetachableResourceHandler> > detached_timer_;
+ base::TimeDelta cancel_delay_;
+
+ bool is_deferred_;
+ bool is_finished_;
+
+ DISALLOW_COPY_AND_ASSIGN(DetachableResourceHandler);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_LOADER_DETACHABLE_RESOURCE_HANDLER_H_