| Index: content/browser/loader/async_revalidation_driver.h
|
| diff --git a/content/browser/loader/async_revalidation_driver.h b/content/browser/loader/async_revalidation_driver.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..61877707542e21150ad1697049ab8f66279e9e37
|
| --- /dev/null
|
| +++ b/content/browser/loader/async_revalidation_driver.h
|
| @@ -0,0 +1,92 @@
|
| +// 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 CONTENT_BROWSER_LOADER_ASYNC_REVALIDATION_DRIVER_H_
|
| +#define CONTENT_BROWSER_LOADER_ASYNC_REVALIDATION_DRIVER_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/callback.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "base/timer/timer.h"
|
| +#include "content/common/content_export.h"
|
| +#include "content/public/browser/resource_controller.h"
|
| +#include "content/public/browser/resource_throttle.h"
|
| +#include "net/base/io_buffer.h"
|
| +#include "net/url_request/url_request.h"
|
| +
|
| +namespace net {
|
| +class HttpCache;
|
| +}
|
| +
|
| +namespace content {
|
| +
|
| +// This class is responsible for driving the URLRequest for an async
|
| +// revalidation. It is passed an instance of ResourceThrottle created by
|
| +// content::ResourceScheduler to perform throttling on the request.
|
| +class CONTENT_EXPORT AsyncRevalidationDriver : public net::URLRequest::Delegate,
|
| + public ResourceController {
|
| + public:
|
| + // |completion_callback| is guaranteed to be called on completion,
|
| + // regardless of success or failure.
|
| + AsyncRevalidationDriver(scoped_ptr<net::URLRequest> request,
|
| + scoped_ptr<ResourceThrottle> throttle,
|
| + const base::Closure& completion_callback);
|
| + ~AsyncRevalidationDriver() override;
|
| +
|
| + void StartRequest();
|
| + void CancelRequest();
|
| +
|
| + private:
|
| + // net::URLRequest::Delegate implementation:
|
| + void OnReceivedRedirect(net::URLRequest* request,
|
| + const net::RedirectInfo& redirect_info,
|
| + bool* defer) override;
|
| + void OnAuthRequired(net::URLRequest* request,
|
| + net::AuthChallengeInfo* info) override;
|
| + void OnBeforeNetworkStart(net::URLRequest* request, bool* defer) override;
|
| + void OnResponseStarted(net::URLRequest* request) override;
|
| + void OnReadCompleted(net::URLRequest* request, int bytes_read) override;
|
| +
|
| + // ResourceController implementation:
|
| + void Resume() override;
|
| +
|
| + // For simplicity, this class assumes that ResourceScheduler never cancels
|
| + // requests, and so these three methods are never called.
|
| + void Cancel() override;
|
| + void CancelAndIgnore() override;
|
| + void CancelWithError(int error_code) override;
|
| +
|
| + // Internal methods.
|
| + void StartRequestInternal();
|
| + void CancelRequestInternal(int error);
|
| + void CompleteResponseStarted();
|
| + void StartReading(bool is_continuation);
|
| + void ResumeReading();
|
| + void ReadMore(int* bytes_read);
|
| + // Calls |completion_callback_| and clears it.
|
| + void ResponseCompleted();
|
| + void OnReadTimeout();
|
| + void RecordDefer();
|
| +
|
| + bool is_deferred_ = false;
|
| +
|
| + scoped_refptr<net::IOBuffer> read_buffer_;
|
| + base::Timer read_timer_;
|
| +
|
| + const scoped_ptr<net::URLRequest> request_;
|
| + scoped_ptr<ResourceThrottle> throttle_;
|
| +
|
| + base::Closure completion_callback_;
|
| +
|
| + base::WeakPtrFactory<AsyncRevalidationDriver> weak_ptr_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(AsyncRevalidationDriver);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_LOADER_ASYNC_REVALIDATION_DRIVER_H_
|
|
|