Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ | 6 #define CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <map> |
| 9 #include <string> | |
| 9 #include <utility> | 10 #include <utility> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 | 17 |
| 17 template <typename T> | 18 template <typename T> |
| 18 struct DefaultSingletonTraits; | 19 struct DefaultSingletonTraits; |
| 19 | 20 |
| 20 namespace net { | 21 namespace net { |
| 21 class HttpResponseHeaders; | 22 class HttpResponseHeaders; |
| 22 } | 23 } |
| 24 class GURL; | |
| 23 | 25 |
| 24 namespace content { | 26 namespace content { |
| 25 | 27 |
| 28 struct TransitionLayerData { | |
|
nasko
2014/08/04 13:36:48
Adding a comment that this structure is passed bet
oystein (OOO til 10th of July)
2014/08/05 19:02:49
Done.
| |
| 29 TransitionLayerData(); | |
| 30 ~TransitionLayerData(); | |
| 31 | |
| 32 std::string markup; | |
| 33 std::string css_selector; | |
| 34 scoped_refptr<net::HttpResponseHeaders> response_headers; | |
| 35 GURL request_url; | |
| 36 }; | |
| 37 | |
| 26 // TransitionRequestManager is used to handle bookkeeping for transition | 38 // TransitionRequestManager is used to handle bookkeeping for transition |
| 27 // requests and responses. | 39 // requests and responses. |
| 28 // | 40 // |
| 29 // TransitionRequestManager is a singleton and should only be accessed on the IO | 41 // TransitionRequestManager is a singleton and should only be accessed on the IO |
| 30 // thread. | 42 // thread. |
| 31 // | 43 // |
| 32 class TransitionRequestManager { | 44 class TransitionRequestManager { |
| 33 public: | 45 public: |
| 34 // Returns the singleton instance. | 46 // Returns the singleton instance. |
| 35 CONTENT_EXPORT static TransitionRequestManager* GetInstance(); | 47 CONTENT_EXPORT static TransitionRequestManager* GetInstance(); |
| 36 | 48 |
| 37 // Parses out any transition-entering-stylesheet link headers from the | 49 // Parses out any transition-entering-stylesheet link headers from the |
| 38 // response headers. | 50 // response headers. |
| 39 CONTENT_EXPORT static void ParseTransitionStylesheetsFromHeaders( | 51 CONTENT_EXPORT static void ParseTransitionStylesheetsFromHeaders( |
| 40 const scoped_refptr<net::HttpResponseHeaders>& headers, | 52 const scoped_refptr<net::HttpResponseHeaders>& headers, |
| 41 std::vector<GURL>& entering_stylesheets, | 53 std::vector<GURL>& entering_stylesheets, |
| 42 const GURL& resolve_address); | 54 const GURL& resolve_address); |
| 43 | 55 |
| 44 // Returns whether the RenderFrameHost specified by the given IDs currently | 56 // Returns whether the RenderFrameHost specified by the given IDs currently |
| 45 // has a pending transition request. If so, we will have to delay the | 57 // has any pending transition request data. If so, we will have to delay the |
| 46 // response until the embedder resumes the request. | 58 // response until the embedder resumes the request. |
| 47 bool HasPendingTransitionRequest(int process_id, int render_frame_id); | 59 bool HasPendingTransitionRequest(int renderer_id, |
|
nasko
2014/08/04 13:36:48
nit: why drop the "process" part of the variable n
oystein (OOO til 10th of July)
2014/08/05 19:02:49
Done; unintentional change actually due to some me
| |
| 60 int render_frame_id, | |
| 61 const GURL& request_url, | |
| 62 TransitionLayerData* transition_data); | |
| 48 | 63 |
| 49 // Sets whether the RenderFrameHost specified by the given IDs currently has a | 64 // Adds pending request data for a transition navigation for the |
| 50 // pending transition request. | 65 // RenderFrameHost specified by the given IDs. |
| 51 CONTENT_EXPORT void SetHasPendingTransitionRequest(int process_id, | 66 CONTENT_EXPORT void AddPendingTransitionRequestData( |
| 52 int render_frame_id, | 67 int renderer_id, |
| 53 bool has_pending); | 68 int render_view_id, |
|
nasko
2014/08/04 13:36:48
Isn't this render_frame_id?
oystein (OOO til 10th of July)
2014/08/05 19:02:49
Done; same as above.
| |
| 69 const std::string& origin, | |
| 70 const std::string& css_selector, | |
| 71 const std::string& markup); | |
| 72 | |
| 73 void ClearPendingTransitionRequestData(int renderer_id, int render_frame_id); | |
| 54 | 74 |
| 55 private: | 75 private: |
| 76 class TransitionRequestData { | |
| 77 public: | |
| 78 TransitionRequestData(); | |
| 79 ~TransitionRequestData(); | |
| 80 void AddEntry(const std::string& origin, | |
| 81 const std::string& selector, | |
| 82 const std::string& markup); | |
| 83 bool FindEntry(const GURL& request_url, | |
| 84 TransitionLayerData* transition_data); | |
| 85 | |
| 86 private: | |
| 87 struct AllowedEntry { | |
| 88 std::string origin; | |
| 89 std::string css_selector; | |
| 90 std::string markup; | |
| 91 | |
| 92 AllowedEntry(const std::string& origin, | |
| 93 const std::string& css_selector, | |
| 94 const std::string& markup) : | |
| 95 origin(origin), | |
| 96 css_selector(css_selector), | |
| 97 markup(markup) {} | |
| 98 }; | |
| 99 std::vector<AllowedEntry> allowed_entries_; | |
| 100 }; | |
| 101 | |
| 56 friend struct DefaultSingletonTraits<TransitionRequestManager>; | 102 friend struct DefaultSingletonTraits<TransitionRequestManager>; |
| 57 typedef std::set<std::pair<int, int> > RenderFrameSet; | 103 typedef std::map<std::pair<int, int>, TransitionRequestData> |
| 104 RenderFrameRequestDataMap; | |
| 58 | 105 |
| 59 TransitionRequestManager(); | 106 TransitionRequestManager(); |
| 60 ~TransitionRequestManager(); | 107 ~TransitionRequestManager(); |
| 61 | 108 |
| 62 // Set of (render_process_host_id, render_frame_id) pairs of all | 109 // Map of (render_process_host_id, render_frame_id) pairs of all |
| 63 // RenderFrameHosts that have pending transition requests. Used to pass | 110 // RenderFrameHosts that have pending cross-site requests and their data. |
| 64 // information to the CrossSiteResourceHandler without doing a round-trip | 111 // Used to pass information to the CrossSiteResourceHandler without doing a |
| 65 // between IO->UI->IO threads. | 112 // round-trip between IO->UI->IO threads. |
| 66 RenderFrameSet pending_transition_frames_; | 113 RenderFrameRequestDataMap pending_transition_frames_; |
| 67 | 114 |
| 68 DISALLOW_COPY_AND_ASSIGN(TransitionRequestManager); | 115 DISALLOW_COPY_AND_ASSIGN(TransitionRequestManager); |
| 69 }; | 116 }; |
| 70 | 117 |
| 71 } // namespace content | 118 } // namespace content |
| 72 | 119 |
| 73 #endif // CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ | 120 #endif // CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ |
| OLD | NEW |