Chromium Code Reviews| Index: content/browser/loader/navigation_url_loader_core.h |
| diff --git a/content/browser/loader/navigation_url_loader_core.h b/content/browser/loader/navigation_url_loader_core.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c06f00086a0726726674d8475ada56d080e76fc9 |
| --- /dev/null |
| +++ b/content/browser/loader/navigation_url_loader_core.h |
| @@ -0,0 +1,104 @@ |
| +// Copyright 2014 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_NAVIGATION_URL_LOADER_CORE_H_ |
| +#define CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_CORE_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "content/browser/loader/navigation_url_loader.h" |
| + |
| +namespace net { |
| +class URLRequest; |
| +struct RedirectInfo; |
| +} |
| + |
| +namespace content { |
| + |
| +class BrowserContext; |
| +class FrameTreeNode; |
| +class NavigationResourceHandler; |
| +class ResourceContext; |
| +class ResourceHandler; |
| +class ResourceRequestBody; |
| +class StreamHandle; |
| +struct ResourceResponse; |
| + |
| +// Part of the implementation of NavigationURLLoaderImpl. It is jointly owned by |
| +// NavigationURLLoaderImpl on the UI thread and NavigationResourceHandler and IO |
| +// thread. It passes signals across threads between the two objects. |
|
mmenke
2014/10/20 18:52:13
This currently doesn't pass messages to the Naviga
davidben
2014/10/22 01:32:37
Done.
|
| +class NavigationURLLoaderCore |
| + : public base::RefCountedThreadSafe<NavigationURLLoaderCore> { |
|
mmenke
2014/10/20 18:52:13
Do we really need a refcounted class for this? Se
mmenke
2014/10/20 18:55:18
Actually, I need to figure out ownership semantics
davidben
2014/10/22 01:32:37
Reworked so that Core is owned by Impl, but cross-
|
| + public: |
| + NavigationURLLoaderCore(); |
| + |
| + // Called on the UI thread to start the request. |
| + void StartRequest(BrowserContext* browser_context, |
| + int64 frame_tree_node_id, |
| + const CommonNavigationParams& common_params, |
| + scoped_ptr<NavigationRequestInfo> request_info, |
| + ResourceRequestBody* request_body); |
| + |
| + // Called on the UI thread to set the delegate. |
| + void set_delegate(NavigationURLLoader::Delegate* delegate) { |
| + delegate_ = delegate; |
| + } |
| + |
| + // Called on the UI thread to resume a deferred redirect. |
| + void FollowRedirect(); |
| + |
| + // Called on the UI thread to cancel a request, if it has not completed. |
| + // |
| + // Note: once the response headers are received, the request is considered |
|
nasko
2014/10/20 13:52:18
nit: No need for an empty line above.
davidben
2014/10/22 01:32:37
This class got reworked.
|
| + // completed from the perspective of NavigationURLLoader and ownership is |
| + // transferred to the StreamHandle containing the body. |
| + void Cancel(); |
| + |
| + // Called on the IO thread to set the resource handler. |
| + void set_resource_handler(NavigationResourceHandler* resource_handler) { |
| + resource_handler_ = resource_handler; |
| + } |
| + |
| + // Called on the IO thread when the request is redirected. The request will |
| + // resume processing on the next call to FollowRedirect on the UI thread. |
| + void RequestRedirectedOnIOThread(const net::RedirectInfo& redirect_info, |
| + ResourceResponse* response); |
| + |
| + // Called on the IO thread when the response started. |
| + void ResponseStartedOnIOThread(ResourceResponse* response, |
| + scoped_ptr<StreamHandle> body); |
| + |
| + // Called on the IO thread if the request failed before giving a response. |
| + void RequestFailedOnIOThread(int net_error); |
| + |
| + private: |
| + friend class base::RefCountedThreadSafe<NavigationURLLoaderCore>; |
| + |
| + ~NavigationURLLoaderCore(); |
| + |
| + void StartRequestOnIOThread(ResourceContext* resource_context, |
| + int64 frame_tree_node_id, |
| + const CommonNavigationParams& common_params, |
| + scoped_ptr<NavigationRequestInfo> request_info, |
| + ResourceRequestBody* request_body); |
| + void FollowRedirectOnIOThread(); |
| + void CancelOnIOThread(); |
| + |
| + void CallOnRequestRedirected(const net::RedirectInfo& redirect_info, |
| + ResourceResponse* response); |
| + void CallOnResponseStarted(ResourceResponse* response, |
| + scoped_ptr<StreamHandle> body); |
| + void CallOnRequestFailed(int net_error); |
| + |
| + NavigationURLLoader::Delegate* delegate_; |
| + NavigationResourceHandler* resource_handler_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(NavigationURLLoaderCore); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_H_ |