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

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

Issue 8760024: Cross-process postMessage (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: New patch, still not quite done Created 9 years 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
(Empty)
1 // Copyright 2011 Google Inc. All Rights Reserved.
2 // Author: supersat@google.com (Karl Koscher)
3
4 #include "frame_map.h"
5 #include "browsing_instance_frame_id.h"
6 #include "base/logging.h"
7
8 namespace content {
9
10 FrameMap::FrameMap() {
11 }
12
13 FrameMap::~FrameMap() {
14 }
15
16 int64 FrameMap::AllocateFrameId() {
17 return next_frame_id_.GetNext() + 1;
18 }
19
20 BrowsingInstanceFrame* FrameMap::InitializeFrameId(int64 frame_id,
21 bool is_top_level) {
Charlie Reis 2011/12/12 22:20:36 Indent wrong here and below.
supersat 2011/12/15 19:30:49 Done.
22 BrowsingInstanceFrame* frameId = new BrowsingInstanceFrame(frame_id,
23 is_top_level);
24 frame_id_map_.insert(
25 std::pair<int64, BrowsingInstanceFrame*>(frameId->id(), frameId));
26 return frameId;
27 }
28
29 BrowsingInstanceFrame* FrameMap::AllocateNewTopLevelFrameId() {
30 return InitializeFrameId(AllocateFrameId(), true);
31 }
32
33 BrowsingInstanceFrame* FrameMap::FindById(int64 id) {
34 return frame_id_map_[id];
35 }
36
37 BrowsingInstanceFrame *FrameMap::FindByWebKitId(int render_process_host_id,
38 int64 frame_id) {
39 BrowsingInstanceFrame::WebKitFrameIdTuple webkitFrameId(
40 render_process_host_id, frame_id);
41
42 BrowsingInstanceFrame* retVal = webkit_frame_id_map_[webkitFrameId];
43 DCHECK(retVal);
44 return retVal;
45 }
46
47 BrowsingInstanceFrame* FrameMap::FindTopLevelFrameByProcessAndRoute(int process_ id,
48 int route _id) {
49 // TODO(supersat): Make this significantly less hacky
50 FrameIdMap::iterator iter;
51 for (iter = frame_id_map_.begin(); iter != frame_id_map_.end(); iter++) {
52 BrowsingInstanceFrame* iterFrame = (*iter).second;
53 if (iterFrame->current_process_host_id() == process_id &&
54 iterFrame->current_route_id() == route_id &&
55 iterFrame->is_top_level()) {
56 return iterFrame;
57 }
58 }
59
60 return 0;
61 }
62
63 void FrameMap::UpdateFrame(BrowsingInstanceFrame* frame,
64 int render_process_host_id,
65 int route_id,
66 int64 frame_id) {
67 DLOG(WARNING) << "Calling UpdateFrame: " <<
68 render_process_host_id << ", " << route_id << ", " <<
69 frame_id;
70
71 DCHECK(frame);
72 BrowsingInstanceFrame::WebKitFrameIdTuple webkitFrameId(
73 render_process_host_id, frame_id);
74 frame->current_webkit_frame_ = webkitFrameId;
75 frame->current_route_id_ = route_id;
76 webkit_frame_id_map_.insert(
77 std::pair<BrowsingInstanceFrame::WebKitFrameIdTuple,
78 BrowsingInstanceFrame*>(webkitFrameId, frame));
79 }
80
81 void FrameMap::RemoveFrame(BrowsingInstanceFrame* frame)
82 {
Charlie Reis 2011/12/12 22:20:36 Brace on previous line.
83 DLOG(WARNING) << "Calling RemoveFrame";
84 // TODO(supersat): Remove child frames when they're supported
85 frame_id_map_.erase(frame->id());
86 webkit_frame_id_map_.erase(frame->current_webkit_frame());
87 }
88
89 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698