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

Side by Side Diff: chrome/browser/prerender/prerender_manager.h

Issue 1077433002: Remove PrerenderLocalPredictor, part 1. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke comments Created 5 years, 8 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/threading/non_thread_safe.h" 16 #include "base/threading/non_thread_safe.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "base/timer/timer.h" 18 #include "base/timer/timer.h"
19 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 19 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
20 #include "chrome/browser/predictors/logged_in_predictor_table.h"
21 #include "chrome/browser/prerender/prerender_config.h" 20 #include "chrome/browser/prerender/prerender_config.h"
22 #include "chrome/browser/prerender/prerender_contents.h" 21 #include "chrome/browser/prerender/prerender_contents.h"
23 #include "chrome/browser/prerender/prerender_final_status.h" 22 #include "chrome/browser/prerender/prerender_final_status.h"
24 #include "chrome/browser/prerender/prerender_histograms.h" 23 #include "chrome/browser/prerender/prerender_histograms.h"
25 #include "chrome/browser/prerender/prerender_origin.h" 24 #include "chrome/browser/prerender/prerender_origin.h"
26 #include "components/keyed_service/core/keyed_service.h" 25 #include "components/keyed_service/core/keyed_service.h"
27 #include "content/public/browser/notification_observer.h" 26 #include "content/public/browser/notification_observer.h"
28 #include "content/public/browser/notification_registrar.h" 27 #include "content/public/browser/notification_registrar.h"
29 #include "content/public/browser/render_process_host_observer.h" 28 #include "content/public/browser/render_process_host_observer.h"
30 #include "net/cookies/cookie_monster.h" 29 #include "net/cookies/cookie_monster.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 }; 80 };
82 81
83 // One or more of these flags must be passed to ClearData() to specify just 82 // One or more of these flags must be passed to ClearData() to specify just
84 // what data to clear. See function declaration for more information. 83 // what data to clear. See function declaration for more information.
85 enum ClearFlags { 84 enum ClearFlags {
86 CLEAR_PRERENDER_CONTENTS = 0x1 << 0, 85 CLEAR_PRERENDER_CONTENTS = 0x1 << 0,
87 CLEAR_PRERENDER_HISTORY = 0x1 << 1, 86 CLEAR_PRERENDER_HISTORY = 0x1 << 1,
88 CLEAR_MAX = 0x1 << 2 87 CLEAR_MAX = 0x1 << 2
89 }; 88 };
90 89
91 typedef predictors::LoggedInPredictorTable::LoggedInStateMap LoggedInStateMap;
92
93 // ID indicating that no experiment is active. 90 // ID indicating that no experiment is active.
94 static const uint8 kNoExperiment = 0; 91 static const uint8 kNoExperiment = 0;
95 92
96 // Owned by a Profile object for the lifetime of the profile. 93 // Owned by a Profile object for the lifetime of the profile.
97 explicit PrerenderManager(Profile* profile); 94 explicit PrerenderManager(Profile* profile);
98 95
99 ~PrerenderManager() override; 96 ~PrerenderManager() override;
100 97
101 // From KeyedService: 98 // From KeyedService:
102 void Shutdown() override; 99 void Shutdown() override;
(...skipping 18 matching lines...) Expand all
121 // from a source without a RenderFrameHost (i.e., the omnibox) we don't have a 118 // from a source without a RenderFrameHost (i.e., the omnibox) we don't have a
122 // child or route id, or a referrer. This method uses sensible values for 119 // child or route id, or a referrer. This method uses sensible values for
123 // those. The |session_storage_namespace| matches the namespace of the active 120 // those. The |session_storage_namespace| matches the namespace of the active
124 // tab at the time the prerender is generated from the omnibox. Returns a 121 // tab at the time the prerender is generated from the omnibox. Returns a
125 // caller-owned PrerenderHandle*, or NULL. 122 // caller-owned PrerenderHandle*, or NULL.
126 PrerenderHandle* AddPrerenderFromOmnibox( 123 PrerenderHandle* AddPrerenderFromOmnibox(
127 const GURL& url, 124 const GURL& url,
128 content::SessionStorageNamespace* session_storage_namespace, 125 content::SessionStorageNamespace* session_storage_namespace,
129 const gfx::Size& size); 126 const gfx::Size& size);
130 127
131 PrerenderHandle* AddPrerenderFromLocalPredictor(
132 const GURL& url,
133 content::SessionStorageNamespace* session_storage_namespace,
134 const gfx::Size& size);
135
136 PrerenderHandle* AddPrerenderFromExternalRequest( 128 PrerenderHandle* AddPrerenderFromExternalRequest(
137 const GURL& url, 129 const GURL& url,
138 const content::Referrer& referrer, 130 const content::Referrer& referrer,
139 content::SessionStorageNamespace* session_storage_namespace, 131 content::SessionStorageNamespace* session_storage_namespace,
140 const gfx::Size& size); 132 const gfx::Size& size);
141 133
142 // Adds a prerender for Instant Search |url| if valid. The 134 // Adds a prerender for Instant Search |url| if valid. The
143 // |session_storage_namespace| matches the namespace of the active tab at the 135 // |session_storage_namespace| matches the namespace of the active tab at the
144 // time the prerender is generated. Returns a caller-owned PrerenderHandle* or 136 // time the prerender is generated. Returns a caller-owned PrerenderHandle* or
145 // NULL. 137 // NULL.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 void OnCreatingAudioStream(int render_process_id, 256 void OnCreatingAudioStream(int render_process_id,
265 int render_frame_id) override; 257 int render_frame_id) override;
266 258
267 const Config& config() const { return config_; } 259 const Config& config() const { return config_; }
268 Config& mutable_config() { return config_; } 260 Config& mutable_config() { return config_; }
269 261
270 // Records that some visible tab navigated (or was redirected) to the 262 // Records that some visible tab navigated (or was redirected) to the
271 // provided URL. 263 // provided URL.
272 void RecordNavigation(const GURL& url); 264 void RecordNavigation(const GURL& url);
273 265
274 // Updates the LoggedInPredictor state to reflect that a login has likely
275 // on the URL provided.
276 void RecordLikelyLoginOnURL(const GURL& url);
277
278 // Checks if the LoggedInPredictor shows that the user is likely logged on
279 // to the site for the URL provided.
280 void CheckIfLikelyLoggedInOnURL(const GURL& url,
281 bool* lookup_result,
282 bool* database_was_present,
283 const base::Closure& result_cb);
284
285 Profile* profile() const { return profile_; } 266 Profile* profile() const { return profile_; }
286 267
287 // Classes which will be tested in prerender unit browser tests should use 268 // Classes which will be tested in prerender unit browser tests should use
288 // these methods to get times for comparison, so that the test framework can 269 // these methods to get times for comparison, so that the test framework can
289 // mock advancing/retarding time. 270 // mock advancing/retarding time.
290 virtual base::Time GetCurrentTime() const; 271 virtual base::Time GetCurrentTime() const;
291 virtual base::TimeTicks GetCurrentTimeTicks() const; 272 virtual base::TimeTicks GetCurrentTimeTicks() const;
292 273
293 scoped_refptr<predictors::LoggedInPredictorTable>
294 logged_in_predictor_table() {
295 return logged_in_predictor_table_;
296 }
297
298 PrerenderLocalPredictor* local_predictor() {
299 return local_predictor_.get();
300 }
301
302 // Notification that a prerender has completed and its bytes should be 274 // Notification that a prerender has completed and its bytes should be
303 // recorded. 275 // recorded.
304 void RecordNetworkBytes(Origin origin, bool used, int64 prerender_bytes); 276 void RecordNetworkBytes(Origin origin, bool used, int64 prerender_bytes);
305 277
306 // Returns whether prerendering is currently enabled for this manager. 278 // Returns whether prerendering is currently enabled for this manager.
307 bool IsEnabled() const; 279 bool IsEnabled() const;
308 280
309 // Add to the running tally of bytes transferred over the network for this 281 // Add to the running tally of bytes transferred over the network for this
310 // profile if prerendering is currently enabled. 282 // profile if prerendering is currently enabled.
311 void AddProfileNetworkBytesIfEnabled(int64 bytes); 283 void AddProfileNetworkBytesIfEnabled(int64 bytes);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 473
502 // Records the final status a prerender in the case that a PrerenderContents 474 // Records the final status a prerender in the case that a PrerenderContents
503 // was never created, and also adds a PrerenderHistory entry. 475 // was never created, and also adds a PrerenderHistory entry.
504 // This is a helper function which will ultimately call 476 // This is a helper function which will ultimately call
505 // RecordFinalStatusWthMatchCompleteStatus, using MATCH_COMPLETE_DEFAULT. 477 // RecordFinalStatusWthMatchCompleteStatus, using MATCH_COMPLETE_DEFAULT.
506 void RecordFinalStatusWithoutCreatingPrerenderContents( 478 void RecordFinalStatusWithoutCreatingPrerenderContents(
507 const GURL& url, Origin origin, uint8 experiment_id, 479 const GURL& url, Origin origin, uint8 experiment_id,
508 FinalStatus final_status) const; 480 FinalStatus final_status) const;
509 481
510 482
511 void CookieChanged(ChromeCookieDetails* details);
512 void CookieChangedAnyCookiesLeftLookupResult(const std::string& domain_key,
513 bool cookies_exist);
514 void LoggedInPredictorDataReceived(scoped_ptr<LoggedInStateMap> new_map);
515
516 // Swaps a prerender |prerender_data| for |url| into the tab, replacing 483 // Swaps a prerender |prerender_data| for |url| into the tab, replacing
517 // |web_contents|. Returns the new WebContents that was swapped in, or NULL 484 // |web_contents|. Returns the new WebContents that was swapped in, or NULL
518 // if a swap-in was not possible. If |should_replace_current_entry| is true, 485 // if a swap-in was not possible. If |should_replace_current_entry| is true,
519 // the current history entry in |web_contents| is replaced. 486 // the current history entry in |web_contents| is replaced.
520 content::WebContents* SwapInternal(const GURL& url, 487 content::WebContents* SwapInternal(const GURL& url,
521 content::WebContents* web_contents, 488 content::WebContents* web_contents,
522 PrerenderData* prerender_data, 489 PrerenderData* prerender_data,
523 bool should_replace_current_entry); 490 bool should_replace_current_entry);
524 491
525 // The configuration. 492 // The configuration.
(...skipping 28 matching lines...) Expand all
554 base::TimeTicks last_prerender_start_time_; 521 base::TimeTicks last_prerender_start_time_;
555 522
556 std::list<content::WebContents*> old_web_contents_list_; 523 std::list<content::WebContents*> old_web_contents_list_;
557 524
558 ScopedVector<OnCloseWebContentsDeleter> on_close_web_contents_deleters_; 525 ScopedVector<OnCloseWebContentsDeleter> on_close_web_contents_deleters_;
559 526
560 scoped_ptr<PrerenderHistory> prerender_history_; 527 scoped_ptr<PrerenderHistory> prerender_history_;
561 528
562 scoped_ptr<PrerenderHistograms> histograms_; 529 scoped_ptr<PrerenderHistograms> histograms_;
563 530
564 scoped_ptr<PrerenderLocalPredictor> local_predictor_;
565
566 scoped_refptr<predictors::LoggedInPredictorTable> logged_in_predictor_table_;
567
568 // Here, we keep the logged in predictor state, but potentially a superset
569 // of its actual (database-backed) state, since we do not incorporate
570 // browser data deletion. We do not use this for actual lookups, but only
571 // to query cookie data for domains we know there was a login before.
572 // This is required to avoid a large number of cookie lookups on bulk
573 // deletion of cookies.
574 scoped_ptr<LoggedInStateMap> logged_in_state_;
575
576 content::NotificationRegistrar notification_registrar_; 531 content::NotificationRegistrar notification_registrar_;
577 532
578 // The number of bytes transferred over the network for the profile this 533 // The number of bytes transferred over the network for the profile this
579 // PrerenderManager is attached to. 534 // PrerenderManager is attached to.
580 int64 profile_network_bytes_; 535 int64 profile_network_bytes_;
581 536
582 // The value of profile_network_bytes_ that was last recorded. 537 // The value of profile_network_bytes_ that was last recorded.
583 int64 last_recorded_profile_network_bytes_; 538 int64 last_recorded_profile_network_bytes_;
584 539
585 // Set of process hosts being prerendered. 540 // Set of process hosts being prerendered.
586 typedef std::set<content::RenderProcessHost*> PrerenderProcessSet; 541 typedef std::set<content::RenderProcessHost*> PrerenderProcessSet;
587 PrerenderProcessSet prerender_process_hosts_; 542 PrerenderProcessSet prerender_process_hosts_;
588 543
589 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); 544 DISALLOW_COPY_AND_ASSIGN(PrerenderManager);
590 }; 545 };
591 546
592 } // namespace prerender 547 } // namespace prerender
593 548
594 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ 549 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698