Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: content/browser/transition_request_manager.cc

Issue 378743002: Navigation transitions: Place transition page in same process as destination page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "content/browser/transition_request_manager.h" 5 #include "content/browser/transition_request_manager.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "base/strings/stringprintf.h"
8 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/common/child_process_host.h"
11 #include "content/public/common/url_constants.h"
12 #include "url/gurl.h"
9 13
10 namespace content { 14 namespace content {
11 15
12 bool TransitionRequestManager::HasPendingTransitionRequest( 16 bool TransitionRequestManager::HasPendingTransitionRequest(
13 int process_id, 17 int process_id,
14 int render_frame_id) { 18 int render_frame_id) {
15 DCHECK_CURRENTLY_ON(BrowserThread::IO); 19 DCHECK_CURRENTLY_ON(BrowserThread::IO);
16 20
17 std::pair<int, int> key(process_id, render_frame_id); 21 std::pair<int, int> key(process_id, render_frame_id);
18 return (pending_transition_frames_.find(key) != 22 return (pending_transition_frames_.find(key) !=
19 pending_transition_frames_.end()); 23 pending_transition_frames_.end());
20 } 24 }
21 25
22 void TransitionRequestManager::SetHasPendingTransitionRequest( 26 void TransitionRequestManager::SetHasPendingTransitionRequest(
23 int process_id, 27 int process_id,
24 int render_frame_id, 28 int render_frame_id,
25 bool has_pending) { 29 bool has_pending) {
26 DCHECK_CURRENTLY_ON(BrowserThread::IO); 30 DCHECK_CURRENTLY_ON(BrowserThread::IO);
27 31
28 std::pair<int, int> key(process_id, render_frame_id); 32 std::pair<int, int> key(process_id, render_frame_id);
29 if (has_pending) { 33 if (has_pending) {
30 pending_transition_frames_.insert(key); 34 pending_transition_frames_.insert(key);
31 } else { 35 } else {
32 pending_transition_frames_.erase(key); 36 pending_transition_frames_.erase(key);
33 } 37 }
34 } 38 }
35 39
36 TransitionRequestManager::TransitionRequestManager() { 40 void TransitionRequestManager::AddPendingTransitionProcessID(const GURL& token,
41 int process_id) {
42 DCHECK_CURRENTLY_ON(BrowserThread::UI);
43 transition_process_ids_[token.spec()] = process_id;
44 }
45
46 void TransitionRequestManager::ClearPendingTransitionProcessID(
47 const GURL& token) {
48 DCHECK_CURRENTLY_ON(BrowserThread::UI);
49 transition_process_ids_.erase(token.spec());
50 }
51
52 int TransitionRequestManager::GetPendingTransitionProcessIDByToken(
53 const GURL& token) {
54 DCHECK_CURRENTLY_ON(BrowserThread::UI);
55 ProcessIDMap::iterator it = transition_process_ids_.find(token.spec());
56 if (it == transition_process_ids_.end())
57 return content::ChildProcessHost::kInvalidUniqueID;
58 return it->second;
59 }
60
61 GURL TransitionRequestManager::CreateTransitionURL() {
62 DCHECK_CURRENTLY_ON(BrowserThread::UI);
63 transition_unique_ids_++;
64 return GURL(base::StringPrintf(
65 "%s:%x", kNavigationTransitionScheme, transition_unique_ids_));
66 }
67
68 TransitionRequestManager::TransitionRequestManager()
69 : transition_unique_ids_(0) {
37 } 70 }
38 71
39 TransitionRequestManager::~TransitionRequestManager() { 72 TransitionRequestManager::~TransitionRequestManager() {
40 } 73 }
41 74
42 // static 75 // static
43 TransitionRequestManager* TransitionRequestManager::GetInstance() { 76 TransitionRequestManager* TransitionRequestManager::GetInstance() {
44 return Singleton<TransitionRequestManager>::get(); 77 return Singleton<TransitionRequestManager>::get();
45 } 78 }
46 79
47 } // namespace content 80 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698