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_IMPL_H_
6 #define CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_IMPL_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/time/time.h"
13 #include "content/browser/loader/navigation_url_loader.h"
21 class NavigationURLLoaderImplCore
;
23 struct ResourceResponse
;
25 class NavigationURLLoaderImpl
: public NavigationURLLoader
{
27 // The caller is responsible for ensuring that |delegate| outlives the loader.
28 NavigationURLLoaderImpl(BrowserContext
* browser_context
,
29 int64 frame_tree_node_id
,
30 scoped_ptr
<NavigationRequestInfo
> request_info
,
31 NavigationURLLoaderDelegate
* delegate
);
32 ~NavigationURLLoaderImpl() override
;
34 // Called in response to OnRequestRedirected to continue processing the
36 void FollowRedirect() override
;
39 friend class NavigationURLLoaderImplCore
;
41 // Notifies the delegate of a redirect.
42 void NotifyRequestRedirected(const net::RedirectInfo
& redirect_info
,
43 const scoped_refptr
<ResourceResponse
>& response
);
45 // Notifies the delegate that the response has started.
46 void NotifyResponseStarted(const scoped_refptr
<ResourceResponse
>& response
,
47 scoped_ptr
<StreamHandle
> body
);
49 // Notifies the delegate the request failed to return a response.
50 void NotifyRequestFailed(int net_error
);
52 // Notifies the delegate the begin navigation request was handled and a
53 // potential first network request is about to be made.
54 void NotifyRequestStarted(base::TimeTicks timestamp
);
56 NavigationURLLoaderDelegate
* delegate_
;
58 // |core_| is deleted on the IO thread in a subsequent task when the
59 // NavigationURLLoaderImpl goes out of scope.
60 NavigationURLLoaderImplCore
* core_
;
62 base::WeakPtrFactory
<NavigationURLLoaderImpl
> weak_factory_
;
64 DISALLOW_COPY_AND_ASSIGN(NavigationURLLoaderImpl
);
67 } // namespace content
69 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_IMPL_H_