summaryrefslogtreecommitdiffstats
path: root/content/browser/transition_request_manager.h
blob: 48be189ca50e0dfb7016dd909116bba22187f122 (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
63
64
65
66
67
68
69
70
71
72
73
// 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_TRANSITION_REQUEST_MANAGER_H_
#define CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_

#include <set>
#include <utility>
#include <vector>

#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
#include "url/gurl.h"

template <typename T>
struct DefaultSingletonTraits;

namespace net {
class HttpResponseHeaders;
}

namespace content {

// TransitionRequestManager is used to handle bookkeeping for transition
// requests and responses.
//
// TransitionRequestManager is a singleton and should only be accessed on the IO
// thread.
//
class TransitionRequestManager {
 public:
  // Returns the singleton instance.
  CONTENT_EXPORT static TransitionRequestManager* GetInstance();

  // Parses out any transition-entering-stylesheet link headers from the
  // response headers.
  CONTENT_EXPORT static void ParseTransitionStylesheetsFromHeaders(
      const scoped_refptr<net::HttpResponseHeaders>& headers,
      std::vector<GURL>& entering_stylesheets,
      const GURL& resolve_address);

  // Returns whether the RenderFrameHost specified by the given IDs currently
  // has a pending transition request. If so, we will have to delay the
  // response until the embedder resumes the request.
  bool HasPendingTransitionRequest(int process_id, int render_frame_id);

  // Sets whether the RenderFrameHost specified by the given IDs currently has a
  // pending transition request.
  CONTENT_EXPORT void SetHasPendingTransitionRequest(int process_id,
                                                     int render_frame_id,
                                                     bool has_pending);

 private:
  friend struct DefaultSingletonTraits<TransitionRequestManager>;
  typedef std::set<std::pair<int, int> > RenderFrameSet;

  TransitionRequestManager();
  ~TransitionRequestManager();

  // Set of (render_process_host_id, render_frame_id) pairs of all
  // RenderFrameHosts that have pending transition requests. Used to pass
  // information to the CrossSiteResourceHandler without doing a round-trip
  // between IO->UI->IO threads.
  RenderFrameSet pending_transition_frames_;

  DISALLOW_COPY_AND_ASSIGN(TransitionRequestManager);
};

}  // namespace content

#endif  // CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_