1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_HANDLER_H_
6 #define CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_HANDLER_H_
8 #include "base/macros.h"
9 #include "content/browser/loader/resource_handler.h"
10 #include "content/browser/loader/stream_writer.h"
14 class NavigationURLLoaderImplCore
;
16 // PlzNavigate: The leaf ResourceHandler used with NavigationURLLoaderImplCore.
17 class NavigationResourceHandler
: public ResourceHandler
{
19 NavigationResourceHandler(net::URLRequest
* request
,
20 NavigationURLLoaderImplCore
* core
);
21 ~NavigationResourceHandler() override
;
23 // Called by the loader the cancel the request.
26 // Called to the loader to resume a paused redirect.
27 void FollowRedirect();
29 // ResourceHandler implementation.
30 void SetController(ResourceController
* controller
) override
;
31 bool OnRequestRedirected(const net::RedirectInfo
& redirect_info
,
32 ResourceResponse
* response
,
33 bool* defer
) override
;
34 bool OnResponseStarted(ResourceResponse
* response
, bool* defer
) override
;
35 bool OnWillStart(const GURL
& url
, bool* defer
) override
;
36 bool OnBeforeNetworkStart(const GURL
& url
, bool* defer
) override
;
37 bool OnWillRead(scoped_refptr
<net::IOBuffer
>* buf
,
39 int min_size
) override
;
40 bool OnReadCompleted(int bytes_read
, bool* defer
) override
;
41 void OnResponseCompleted(const net::URLRequestStatus
& status
,
42 const std::string
& security_info
,
43 bool* defer
) override
;
44 void OnDataDownloaded(int bytes_downloaded
) override
;
47 // Clears |core_| and its reference to the resource handler. After calling
48 // this, the lifetime of the request is no longer tied to |core_|.
49 void DetachFromCore();
51 NavigationURLLoaderImplCore
* core_
;
54 DISALLOW_COPY_AND_ASSIGN(NavigationResourceHandler
);
57 } // namespace content
59 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_HANDLER_H_