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

Unified Diff: content/browser/frame_mapper.cc

Issue 8760024: Cross-process postMessage (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_mapper.cc
diff --git a/content/browser/frame_mapper.cc b/content/browser/frame_mapper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..34697f372aabfd311e1f8087b83ee9b135566d3d
--- /dev/null
+++ b/content/browser/frame_mapper.cc
@@ -0,0 +1,89 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+// Author: supersat@google.com (Karl Koscher)
+
+#include "frame_mapper.h"
+#include "browsing_instance_frame_id.h"
+#include "base/logging.h"
+
+namespace content {
+
+FrameMapper::FrameMapper() {
+}
+
+FrameMapper::~FrameMapper() {
+}
+
+int64 FrameMapper::AllocateFrameId() {
+ return next_frame_id_.GetNext() + 1;
+}
+
+BrowsingInstanceFrame* FrameMapper::InitializeFrameId(int64 frame_id,
+ bool is_top_level) {
+ BrowsingInstanceFrame* frameId = new BrowsingInstanceFrame(frame_id,
+ is_top_level);
+ frame_id_map_.insert(
+ std::pair<int64, BrowsingInstanceFrame*>(frameId->id(), frameId));
+ return frameId;
+}
+
+BrowsingInstanceFrame* FrameMapper::AllocateNewTopLevelFrameId() {
+ return InitializeFrameId(AllocateFrameId(), true);
+}
+
+BrowsingInstanceFrame* FrameMapper::FindById(int64 id) {
+ return frame_id_map_[id];
+}
+
+BrowsingInstanceFrame *FrameMapper::FindByWebKitId(int render_process_host_id,
+ int64 frame_id) {
+ BrowsingInstanceFrame::WebKitFrameIdTuple webkitFrameId(
+ render_process_host_id, frame_id);
+
+ BrowsingInstanceFrame* retVal = webkit_frame_id_map_[webkitFrameId];
+ DCHECK(retVal);
+ return retVal;
+}
+
+BrowsingInstanceFrame* FrameMapper::FindTopLevelFrameByProcessAndRoute(int process_id,
+ int route_id) {
+ // TODO(supersat): Make this significantly less hacky
+ FrameIdMap::iterator iter;
+ for (iter = frame_id_map_.begin(); iter != frame_id_map_.end(); iter++) {
+ BrowsingInstanceFrame* iterFrame = (*iter).second;
+ if (iterFrame->current_process_host_id() == process_id &&
+ iterFrame->current_route_id() == route_id &&
+ iterFrame->is_top_level()) {
+ return iterFrame;
+ }
+ }
+
+ return 0;
+}
+
+void FrameMapper::UpdateFrame(BrowsingInstanceFrame* frame,
+ int render_process_host_id,
+ int route_id,
+ int64 frame_id) {
+ DLOG(WARNING) << "Calling UpdateFrame: " <<
+ render_process_host_id << ", " << route_id << ", " <<
+ frame_id;
+
+ DCHECK(frame);
+ BrowsingInstanceFrame::WebKitFrameIdTuple webkitFrameId(
+ render_process_host_id, frame_id);
+ frame->current_webkit_frame_ = webkitFrameId;
+ frame->current_route_id_ = route_id;
+ webkit_frame_id_map_.insert(
+ std::pair<BrowsingInstanceFrame::WebKitFrameIdTuple,
+ BrowsingInstanceFrame*>(webkitFrameId, frame));
+}
+
+void FrameMapper::RemoveFrame(BrowsingInstanceFrame* frame)
+{
+ DLOG(WARNING) << "Calling RemoveFrame";
+ // TODO(supersat): Remove child frames when they're supported
+ frame_id_map_.erase(frame->id());
+ webkit_frame_id_map_.erase(frame->current_webkit_frame());
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698