Chromium Code Reviews| 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..e28ff4b7cb02baa296e0df718262825c819331cf |
| --- /dev/null |
| +++ b/chrome/browser/predictors/resource_prefetch_common.cc |
| @@ -0,0 +1,47 @@ |
| +// 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()) { |
|
dominich
2012/05/24 16:07:53
not initializing creation_time here?
Shishir
2012/05/30 01:07:51
There is no creation time in web_contents. It come
|
| +} |
| + |
| +bool NavigationID::operator<(const NavigationID& rhs) const { |
| + 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 { |
| + return IsSameRenderer(rhs) && main_frame_url_ == rhs.main_frame_url_; |
| +} |
| + |
| +bool NavigationID::IsSameRenderer(const NavigationID& other) const { |
| + return render_process_id_ == other.render_process_id_ && |
| + render_view_id_ == other.render_view_id_; |
| +} |
| + |
| +} // namespace predictors |