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

Unified Diff: chrome/browser/predictors/resource_prefetch_common.cc

Issue 10416002: Seculative resource prefetching for URLs CL. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Resolving conflicts. Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/predictors/resource_prefetch_common.cc
diff --git a/chrome/browser/predictors/resource_prefetch_common.cc b/chrome/browser/predictors/resource_prefetch_common.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5e87d43f1754f530a6ab4555b3b7ea3da005878d
--- /dev/null
+++ b/chrome/browser/predictors/resource_prefetch_common.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/predictors/resource_prefetch_common.h"
+
+#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
+
+namespace predictors {
+
+NavigationID::NavigationID() : render_process_id(-1), render_view_id(-1) {
+}
+
+NavigationID::NavigationID(const NavigationID& other)
+ : render_process_id(other.render_process_id),
+ render_view_id(other.render_view_id),
+ main_frame_url(other.main_frame_url),
+ creation_time(other.creation_time) {
+}
+
+NavigationID::NavigationID(const content::WebContents& web_contents)
+ : render_process_id(web_contents.GetRenderProcessHost()->GetID()),
+ render_view_id(web_contents.GetRenderViewHost()->GetRoutingID()),
+ main_frame_url(web_contents.GetURL()) {
+}
+
+bool NavigationID::is_valid() const {
+ return render_process_id != -1 && render_view_id != -1 &&
+ !main_frame_url.is_empty();
+}
+
+bool NavigationID::operator<(const NavigationID& rhs) const {
+ DCHECK(is_valid() && rhs.is_valid());
+ if (render_process_id != rhs.render_process_id)
+ return render_process_id < rhs.render_process_id;
+ else if (render_view_id != rhs.render_view_id)
+ return render_view_id < rhs.render_view_id;
+ else
+ return main_frame_url < rhs.main_frame_url;
+}
+
+bool NavigationID::operator==(const NavigationID& rhs) const {
+ DCHECK(is_valid() && rhs.is_valid());
+ return IsSameRenderer(rhs) && main_frame_url == rhs.main_frame_url;
+}
+
+bool NavigationID::IsSameRenderer(const NavigationID& other) const {
+ DCHECK(is_valid() && other.is_valid());
+ return render_process_id == other.render_process_id &&
+ render_view_id == other.render_view_id;
+}
+
+} // namespace predictors
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_common.h ('k') | chrome/browser/predictors/resource_prefetch_predictor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698