summaryrefslogtreecommitdiffstats
path: root/content/browser/loader/navigation_url_loader.h
blob: 7713e736610268b7230a4baaebabb90eb4533f35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// 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_H_
#define CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_H_

#include "base/basictypes.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "content/common/content_export.h"

namespace content {

class BrowserContext;
class NavigationURLLoaderDelegate;
class NavigationURLLoaderFactory;
class ResourceRequestBody;
struct CommonNavigationParams;
struct NavigationRequestInfo;

// PlzNavigate: The navigation logic's UI thread entry point into the resource
// loading stack. It exposes an interface to control the request prior to
// receiving the response. If the NavigationURLLoader is destroyed before
// OnResponseStarted is called, the request is aborted.
class CONTENT_EXPORT NavigationURLLoader {
 public:
  // Creates a NavigationURLLoader. The caller is responsible for ensuring that
  // |delegate| outlives the loader. |request_body| must not be accessed on the
  // UI thread after this point.
  //
  // TODO(davidben): When navigation is disentangled from the loader, the
  // request parameters should not come in as a navigation-specific
  // structure. Information like has_user_gesture and
  // should_replace_current_entry shouldn't be needed at this layer.
  static scoped_ptr<NavigationURLLoader> Create(
      BrowserContext* browser_context,
      int64 frame_tree_node_id,
      const CommonNavigationParams& common_params,
      scoped_ptr<NavigationRequestInfo> request_info,
      ResourceRequestBody* request_body,
      NavigationURLLoaderDelegate* delegate);

  // For testing purposes; sets the factory for use in testing.
  static void SetFactoryForTesting(NavigationURLLoaderFactory* factory);

  virtual ~NavigationURLLoader() {}

  // Called in response to OnRequestRedirected to continue processing the
  // request.
  virtual void FollowRedirect() = 0;

 protected:
  NavigationURLLoader() {}

 private:
  DISALLOW_COPY_AND_ASSIGN(NavigationURLLoader);
};

}  // namespace content

#endif  // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_H_