diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-01 22:50:25 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-01 22:50:25 +0000 |
commit | 8ff0e48bd3ee623b6521efbd18f49a0534dfbb09 (patch) | |
tree | 0f523ef967258d1f1e191be47e748600b1f670cd /chrome/browser/sessions | |
parent | 9db95ef4fdf0375b8a6905e3cf8dbd2f5310b33f (diff) | |
download | chromium_src-8ff0e48bd3ee623b6521efbd18f49a0534dfbb09.zip chromium_src-8ff0e48bd3ee623b6521efbd18f49a0534dfbb09.tar.gz chromium_src-8ff0e48bd3ee623b6521efbd18f49a0534dfbb09.tar.bz2 |
FBTF: Move the TabRestoreService::Observer into its own file.
This means browser.h no longer includes a large chunk of the tab restore
system.
BUG=none
TEST=compiles
Review URL: http://codereview.chromium.org/3296003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58256 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sessions')
-rw-r--r-- | chrome/browser/sessions/session_backend.cc | 4 | ||||
-rw-r--r-- | chrome/browser/sessions/session_backend.h | 7 | ||||
-rw-r--r-- | chrome/browser/sessions/session_types.cc | 56 | ||||
-rw-r--r-- | chrome/browser/sessions/session_types.h | 25 | ||||
-rw-r--r-- | chrome/browser/sessions/tab_restore_service.cc | 11 | ||||
-rw-r--r-- | chrome/browser/sessions/tab_restore_service.h | 22 | ||||
-rw-r--r-- | chrome/browser/sessions/tab_restore_service_observer.h | 25 |
7 files changed, 108 insertions, 42 deletions
diff --git a/chrome/browser/sessions/session_backend.cc b/chrome/browser/sessions/session_backend.cc index c06f811..342c1f0 100644 --- a/chrome/browser/sessions/session_backend.cc +++ b/chrome/browser/sessions/session_backend.cc @@ -9,6 +9,7 @@ #include "base/file_util.h" #include "base/histogram.h" #include "base/scoped_vector.h" +#include "net/base/file_stream.h" using base::TimeTicks; @@ -335,6 +336,9 @@ bool SessionBackend::AppendCommandsToFile(net::FileStream* file, return true; } +SessionBackend::~SessionBackend() { +} + void SessionBackend::ResetFile() { DCHECK(inited_); if (current_session_file_.get()) { diff --git a/chrome/browser/sessions/session_backend.h b/chrome/browser/sessions/session_backend.h index 523ef58..883a58f 100644 --- a/chrome/browser/sessions/session_backend.h +++ b/chrome/browser/sessions/session_backend.h @@ -12,7 +12,10 @@ #include "base/scoped_ptr.h" #include "chrome/browser/sessions/base_session_service.h" #include "chrome/browser/sessions/session_command.h" -#include "net/base/file_stream.h" + +namespace net { +class FileStream; +} // SessionBackend ------------------------------------------------------------- @@ -93,7 +96,7 @@ class SessionBackend : public base::RefCountedThreadSafe<SessionBackend> { private: friend class base::RefCountedThreadSafe<SessionBackend>; - ~SessionBackend() {} + ~SessionBackend(); // If current_session_file_ is open, it is truncated so that it is essentially // empty (only contains the header). If current_session_file_ isn't open, it diff --git a/chrome/browser/sessions/session_types.cc b/chrome/browser/sessions/session_types.cc index cdf77f6..995a9a2 100644 --- a/chrome/browser/sessions/session_types.cc +++ b/chrome/browser/sessions/session_types.cc @@ -11,6 +11,51 @@ // TabNavigation -------------------------------------------------------------- +TabNavigation::TabNavigation() + : transition_(PageTransition::TYPED), + type_mask_(0), + index_(-1) { +} + +TabNavigation::TabNavigation(int index, + const GURL& virtual_url, + const GURL& referrer, + const string16& title, + const std::string& state, + PageTransition::Type transition) + : virtual_url_(virtual_url), + referrer_(referrer), + title_(title), + state_(state), + transition_(transition), + type_mask_(0), + index_(index) { +} + +TabNavigation::TabNavigation(const TabNavigation& tab) + : virtual_url_(tab.virtual_url_), + referrer_(tab.referrer_), + title_(tab.title_), + state_(tab.state_), + transition_(tab.transition_), + type_mask_(tab.type_mask_), + index_(tab.index_) { +} + +TabNavigation::~TabNavigation() { +} + +TabNavigation& TabNavigation::operator=(const TabNavigation& tab) { + virtual_url_ = tab.virtual_url_; + referrer_ = tab.referrer_; + title_ = tab.title_; + state_ = tab.state_; + transition_ = tab.transition_; + type_mask_ = tab.type_mask_; + index_ = tab.index_; + return *this; +} + // static NavigationEntry* TabNavigation::ToNavigationEntry(int page_id, Profile *profile) const { @@ -39,6 +84,17 @@ void TabNavigation::SetFromNavigationEntry(const NavigationEntry& entry) { type_mask_ = entry.has_post_data() ? TabNavigation::HAS_POST_DATA : 0; } +// SessionTab ----------------------------------------------------------------- + +SessionTab::SessionTab() + : tab_visual_index(-1), + current_navigation_index(-1), + pinned(false) { +} + +SessionTab::~SessionTab() { +} + // SessionWindow --------------------------------------------------------------- SessionWindow::SessionWindow() diff --git a/chrome/browser/sessions/session_types.h b/chrome/browser/sessions/session_types.h index 07dbae4..119392a 100644 --- a/chrome/browser/sessions/session_types.h +++ b/chrome/browser/sessions/session_types.h @@ -31,25 +31,16 @@ class TabNavigation { HAS_POST_DATA = 1 }; - TabNavigation() - : transition_(PageTransition::TYPED), - type_mask_(0), - index_(-1) { - } - + TabNavigation(); TabNavigation(int index, const GURL& virtual_url, const GURL& referrer, const string16& title, const std::string& state, - PageTransition::Type transition) - : virtual_url_(virtual_url), - referrer_(referrer), - title_(title), - state_(state), - transition_(transition), - type_mask_(0), - index_(index) {} + PageTransition::Type transition); + TabNavigation(const TabNavigation& tab); + ~TabNavigation(); + TabNavigation& operator=(const TabNavigation& tab); // Converts this TabNavigation into a NavigationEntry with a page id of // |page_id|. The caller owns the returned NavigationEntry. @@ -107,10 +98,8 @@ class TabNavigation { // SessionTab corresponds to a NavigationController. struct SessionTab { - SessionTab() - : tab_visual_index(-1), - current_navigation_index(-1), - pinned(false) { } + SessionTab(); + ~SessionTab(); // Unique id of the window. SessionID window_id; diff --git a/chrome/browser/sessions/tab_restore_service.cc b/chrome/browser/sessions/tab_restore_service.cc index 116f819..c62312a 100644 --- a/chrome/browser/sessions/tab_restore_service.cc +++ b/chrome/browser/sessions/tab_restore_service.cc @@ -17,6 +17,7 @@ #include "chrome/browser/sessions/session_service.h" #include "chrome/browser/sessions/session_command.h" #include "chrome/browser/sessions/session_types.h" +#include "chrome/browser/sessions/tab_restore_service_observer.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents.h" @@ -182,17 +183,18 @@ TabRestoreService::~TabRestoreService() { if (backend()) Save(); - FOR_EACH_OBSERVER(Observer, observer_list_, TabRestoreServiceDestroyed(this)); + FOR_EACH_OBSERVER(TabRestoreServiceObserver, observer_list_, + TabRestoreServiceDestroyed(this)); STLDeleteElements(&entries_); STLDeleteElements(&staging_entries_); time_factory_ = NULL; } -void TabRestoreService::AddObserver(Observer* observer) { +void TabRestoreService::AddObserver(TabRestoreServiceObserver* observer) { observer_list_.AddObserver(observer); } -void TabRestoreService::RemoveObserver(Observer* observer) { +void TabRestoreService::RemoveObserver(TabRestoreServiceObserver* observer) { observer_list_.RemoveObserver(observer); } @@ -484,7 +486,8 @@ void TabRestoreService::PopulateTab(Tab* tab, } void TabRestoreService::NotifyTabsChanged() { - FOR_EACH_OBSERVER(Observer, observer_list_, TabRestoreServiceChanged(this)); + FOR_EACH_OBSERVER(TabRestoreServiceObserver, observer_list_, + TabRestoreServiceChanged(this)); } void TabRestoreService::AddEntry(Entry* entry, bool notify, bool to_front) { diff --git a/chrome/browser/sessions/tab_restore_service.h b/chrome/browser/sessions/tab_restore_service.h index e12b9d1..2f9a237 100644 --- a/chrome/browser/sessions/tab_restore_service.h +++ b/chrome/browser/sessions/tab_restore_service.h @@ -20,6 +20,7 @@ class Browser; class NavigationController; class Profile; struct SessionWindow; +class TabRestoreServiceObserver; // TabRestoreService is responsible for maintaining the most recently closed // tabs and windows. When a tab is closed @@ -34,21 +35,6 @@ struct SessionWindow; // add an observer. class TabRestoreService : public BaseSessionService { public: - // Observer is notified when the set of entries managed by TabRestoreService - // changes in some way. - class Observer { - public: - // Sent when the set of entries changes in some way. - virtual void TabRestoreServiceChanged(TabRestoreService* service) = 0; - - // Sent to all remaining Observers when TabRestoreService's - // destructor is run. - virtual void TabRestoreServiceDestroyed(TabRestoreService* service) = 0; - - protected: - virtual ~Observer() {} - }; - // Interface used to allow the test to provide a custom time. class TimeFactory { public: @@ -132,8 +118,8 @@ class TabRestoreService : public BaseSessionService { // Adds/removes an observer. TabRestoreService does not take ownership of // the observer. - void AddObserver(Observer* observer); - void RemoveObserver(Observer* observer); + void AddObserver(TabRestoreServiceObserver* observer); + void RemoveObserver(TabRestoreServiceObserver* observer); // Creates a Tab to represent |tab| and notifies observers the list of // entries has changed. @@ -328,7 +314,7 @@ class TabRestoreService : public BaseSessionService { // Number of entries we've written. int entries_written_; - ObserverList<Observer> observer_list_; + ObserverList<TabRestoreServiceObserver> observer_list_; // Set of tabs that we've received a BrowserClosing method for but no // corresponding BrowserClosed. We cache the set of browsers closing to diff --git a/chrome/browser/sessions/tab_restore_service_observer.h b/chrome/browser/sessions/tab_restore_service_observer.h new file mode 100644 index 0000000..e4d21184 --- /dev/null +++ b/chrome/browser/sessions/tab_restore_service_observer.h @@ -0,0 +1,25 @@ +// Copyright (c) 2010 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. + +#ifndef CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_OBSERVER_H_ +#define CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_OBSERVER_H_ + +class TabRestoreService; + +// Observer is notified when the set of entries managed by TabRestoreService +// changes in some way. +class TabRestoreServiceObserver { + public: + // Sent when the set of entries changes in some way. + virtual void TabRestoreServiceChanged(TabRestoreService* service) = 0; + + // Sent to all remaining Observers when TabRestoreService's + // destructor is run. + virtual void TabRestoreServiceDestroyed(TabRestoreService* service) = 0; + + protected: + virtual ~TabRestoreServiceObserver() {} +}; + +#endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_OBSERVER_H_ |