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

Side by Side 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, 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
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/predictors/resource_prefetch_common.h"
6
7 #include "content/public/browser/render_process_host.h"
8 #include "content/public/browser/render_view_host.h"
9 #include "content/public/browser/web_contents.h"
10
11 namespace predictors {
12
13 NavigationID::NavigationID() : render_process_id(-1), render_view_id(-1) {
14 }
15
16 NavigationID::NavigationID(const NavigationID& other)
17 : render_process_id(other.render_process_id),
18 render_view_id(other.render_view_id),
19 main_frame_url(other.main_frame_url),
20 creation_time(other.creation_time) {
21 }
22
23 NavigationID::NavigationID(const content::WebContents& web_contents)
24 : render_process_id(web_contents.GetRenderProcessHost()->GetID()),
25 render_view_id(web_contents.GetRenderViewHost()->GetRoutingID()),
26 main_frame_url(web_contents.GetURL()) {
27 }
28
29 bool NavigationID::is_valid() const {
30 return render_process_id != -1 && render_view_id != -1 &&
31 !main_frame_url.is_empty();
32 }
33
34 bool NavigationID::operator<(const NavigationID& rhs) const {
35 DCHECK(is_valid() && rhs.is_valid());
36 if (render_process_id != rhs.render_process_id)
37 return render_process_id < rhs.render_process_id;
38 else if (render_view_id != rhs.render_view_id)
39 return render_view_id < rhs.render_view_id;
40 else
41 return main_frame_url < rhs.main_frame_url;
42 }
43
44 bool NavigationID::operator==(const NavigationID& rhs) const {
45 DCHECK(is_valid() && rhs.is_valid());
46 return IsSameRenderer(rhs) && main_frame_url == rhs.main_frame_url;
47 }
48
49 bool NavigationID::IsSameRenderer(const NavigationID& other) const {
50 DCHECK(is_valid() && other.is_valid());
51 return render_process_id == other.render_process_id &&
52 render_view_id == other.render_view_id;
53 }
54
55 } // namespace predictors
OLDNEW
« 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