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 <map> | |
| 8 #include <set> | 9 #include <set> |
| 10 #include <string> | |
| 9 #include <utility> | 11 #include <utility> |
| 10 | 12 |
| 11 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 12 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 13 | 15 |
| 14 template <typename T> | 16 template <typename T> |
| 15 struct DefaultSingletonTraits; | 17 struct DefaultSingletonTraits; |
| 16 | 18 |
| 19 class GURL; | |
| 20 | |
| 17 namespace content { | 21 namespace content { |
| 18 | 22 |
| 19 // TransitionRequestManager is used to handle bookkeeping for transition | 23 // TransitionRequestManager is used to handle bookkeeping for transition |
| 20 // requests and responses. | 24 // requests and responses. |
| 21 // | 25 // |
| 22 // TransitionRequestManager is a singleton and should only be accessed on the IO | 26 // TransitionRequestManager is a singleton and should only be accessed on the IO |
| 23 // thread. | 27 // thread. |
|
jam
2014/07/14 23:14:21
this comment would have to be updated per below
shatch
2014/07/21 17:47:11
Done.
| |
| 24 // | 28 // |
| 25 class TransitionRequestManager { | 29 class TransitionRequestManager { |
| 26 public: | 30 public: |
| 27 // Returns the singleton instance. | 31 // Returns the singleton instance. |
| 28 CONTENT_EXPORT static TransitionRequestManager* GetInstance(); | 32 CONTENT_EXPORT static TransitionRequestManager* GetInstance(); |
| 29 | 33 |
| 34 // Accessed from IO thread only ---------------------------------------------- | |
| 35 | |
| 30 // Returns whether the RenderFrameHost specified by the given IDs currently | 36 // Returns whether the RenderFrameHost specified by the given IDs currently |
| 31 // has a pending transition request. If so, we will have to delay the | 37 // has a pending transition request. If so, we will have to delay the |
| 32 // response until the embedder resumes the request. | 38 // response until the embedder resumes the request. |
| 33 bool HasPendingTransitionRequest(int process_id, int render_frame_id); | 39 bool HasPendingTransitionRequest(int process_id, int render_frame_id); |
| 34 | 40 |
| 35 // Sets whether the RenderFrameHost specified by the given IDs currently has a | 41 // Sets whether the RenderFrameHost specified by the given IDs currently has a |
| 36 // pending transition request. | 42 // pending transition request. |
| 37 CONTENT_EXPORT void SetHasPendingTransitionRequest(int process_id, | 43 CONTENT_EXPORT void SetHasPendingTransitionRequest(int process_id, |
| 38 int render_frame_id, | 44 int render_frame_id, |
| 39 bool has_pending); | 45 bool has_pending); |
| 40 | 46 |
| 47 // Accessed from UI thread only ---------------------------------------------- | |
| 48 | |
| 49 // These functions are used to store the process ID for an outgoing | |
| 50 // navigation, so that the same renderer can be reused by the transition. | |
| 51 void AddPendingTransitionProcessID(const GURL& token, int process_id); | |
| 52 void ClearPendingTransitionProcessID(const GURL& token); | |
| 53 int GetPendingTransitionProcessIDByToken(const GURL& token); | |
| 54 | |
| 55 // Creates a unique transition url that is used to identify which process | |
| 56 // to use during a transition. | |
| 57 GURL CreateTransitionURL(); | |
| 58 | |
| 41 private: | 59 private: |
| 42 friend struct DefaultSingletonTraits<TransitionRequestManager>; | 60 friend struct DefaultSingletonTraits<TransitionRequestManager>; |
| 43 typedef std::set<std::pair<int, int> > RenderFrameSet; | 61 typedef std::set<std::pair<int, int> > RenderFrameSet; |
| 62 typedef std::map<std::string, int> ProcessIDMap; | |
| 44 | 63 |
| 45 TransitionRequestManager(); | 64 TransitionRequestManager(); |
| 46 ~TransitionRequestManager(); | 65 ~TransitionRequestManager(); |
| 47 | 66 |
| 48 // Set of (render_process_host_id, render_frame_id) pairs of all | 67 // Set of (render_process_host_id, render_frame_id) pairs of all |
| 49 // RenderFrameHosts that have pending transition requests. Used to pass | 68 // RenderFrameHosts that have pending transition requests. Used to pass |
| 50 // information to the CrossSiteResourceHandler without doing a round-trip | 69 // information to the CrossSiteResourceHandler without doing a round-trip |
| 51 // between IO->UI->IO threads. | 70 // between IO->UI->IO threads. |
| 52 RenderFrameSet pending_transition_frames_; | 71 RenderFrameSet pending_transition_frames_; |
| 53 | 72 |
| 73 // Map of transition urls to process ids for process sharing. | |
| 74 ProcessIDMap transition_process_ids_; | |
| 75 | |
| 76 int transition_unique_ids_; | |
| 77 | |
| 54 DISALLOW_COPY_AND_ASSIGN(TransitionRequestManager); | 78 DISALLOW_COPY_AND_ASSIGN(TransitionRequestManager); |
| 55 }; | 79 }; |
| 56 | 80 |
| 57 } // namespace content | 81 } // namespace content |
| 58 | 82 |
| 59 #endif // CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ | 83 #endif // CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ |
| OLD | NEW |