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_URL_LOADER_DELEGATE_H_
6 #define CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_DELEGATE_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "content/common/content_export.h"
20 struct ResourceResponse
;
22 // PlzNavigate: The delegate interface to NavigationURLLoader.
23 class CONTENT_EXPORT NavigationURLLoaderDelegate
{
25 // Called when the request is redirected. Call FollowRedirect to continue
26 // processing the request.
27 virtual void OnRequestRedirected(
28 const net::RedirectInfo
& redirect_info
,
29 const scoped_refptr
<ResourceResponse
>& response
) = 0;
31 // Called when the request receives its response. No further calls will be
32 // made to the delegate. The response body is returned as a stream in
34 virtual void OnResponseStarted(
35 const scoped_refptr
<ResourceResponse
>& response
,
36 scoped_ptr
<StreamHandle
> body_stream
) = 0;
38 // Called if the request fails before receving a response. |net_error| is a
39 // network error code for the failure.
40 virtual void OnRequestFailed(int net_error
) = 0;
42 // Called after the network request has begun on the IO thread at time
43 // |timestamp|. This is just a thread hop but is used to compare timing
44 // against the pre-PlzNavigate codepath which didn't start the network request
45 // until after the renderer was initialized.
46 virtual void OnRequestStarted(base::TimeTicks timestamp
) = 0;
49 NavigationURLLoaderDelegate() {}
50 virtual ~NavigationURLLoaderDelegate() {}
53 DISALLOW_COPY_AND_ASSIGN(NavigationURLLoaderDelegate
);
56 } // namespace content
58 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_DELEGATE_H_