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

Unified Diff: chrome/browser/sync/glue/session_model_associator.h

Issue 10125002: [Sync] Add per-navigation timestamps/unique ids to tab sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sessions/session_types.h ('k') | chrome/browser/sync/glue/session_model_associator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/glue/session_model_associator.h
diff --git a/chrome/browser/sync/glue/session_model_associator.h b/chrome/browser/sync/glue/session_model_associator.h
index 45663d22cd6829deaf2fd471df6615d8158c887f..99c2966fdd75b719be53a3f05c4f6fe7273dbcd0 100644
--- a/chrome/browser/sync/glue/session_model_associator.h
+++ b/chrome/browser/sync/glue/session_model_associator.h
@@ -36,6 +36,10 @@ class Prefservice;
class Profile;
class ProfileSyncService;
+namespace content {
+class NavigationEntry;
+} // namespace content
+
namespace sync_api {
class BaseTransaction;
class ReadNode;
@@ -224,7 +228,13 @@ class SessionModelAssociator
// Callback for when the session name has been computed.
void OnSessionNameInitialized(const std::string& name);
+ // If a valid favicon for the page at |url| is found, fills |png_favicon| with
+ // the png-encoded image and returns true. Else, returns false.
+ bool GetSyncedFaviconForPageURL(const std::string& url,
+ std::string* png_favicon) const;
+
private:
+ friend class SyncSessionModelAssociatorTest;
FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceSessionTest, WriteSessionToNode);
FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceSessionTest,
WriteFilledSessionToNode);
@@ -286,6 +296,7 @@ class SessionModelAssociator
// A pool for managing free/used tab sync nodes. Performs lazy creation
// of sync nodes when necessary.
+ // TODO(zea): pull this into it's own file.
Andrew T Wilson (Slow) 2012/04/23 23:43:11 nit: it's->its
Nicolas Zea 2012/04/24 22:09:49 Done.
class TabNodePool {
public:
explicit TabNodePool(ProfileSyncService* sync_service);
@@ -400,6 +411,22 @@ class SessionModelAssociator
bool WriteTabContentsToSyncModel(TabLink* tab_link,
SyncError* error);
+ // Decrements the favicon usage counters for the favicon used by |page_url|.
+ // Deletes the favicon and associated pages from the favicon usage maps
+ // if no page is found to be referring to the favicon anymore.
+ void DecrementAndCleanFaviconForURL(std::string page_url);
+
+ // Helper method to build sync's tab specifics from a newly modified
+ // tab, window, and the locally stored previous tab data. After completing,
+ // |prev_tab| will be updated to reflect the current data, |sync_tab| will
+ // be filled with the tab data (preserving old timestamps as necessary), and
+ // |new_url| will be the tab's current url.
+ void AssociateTabContents(const SyncedWindowDelegate& window,
+ const SyncedTabDelegate& new_tab,
+ SyncedSessionTab* prev_tab,
+ sync_pb::SessionTab* sync_tab,
+ GURL* new_url);
+
// Load the favicon for the tab specified by |tab_link|. Will cancel any
// outstanding request for this tab. OnFaviconDataAvailable(..) will be called
// when the load completes.
@@ -429,20 +456,21 @@ class SessionModelAssociator
// Used to populate a session tab from the session specifics tab provided.
static void PopulateSessionTabFromSpecifics(const sync_pb::SessionTab& tab,
const base::Time& mtime,
- SessionTab* session_tab);
+ SyncedSessionTab* session_tab);
- // Helper method to take the favicon data in a foreign tab and store it
- // into the history db.
+ // Helper method to load the favicon data from the tab specifics. If the
+ // favicon is valid, stores it in |synced_favicons_|, increments
+ // |synced_favicon_usage_| and updates |synced_favicon_pages_| appropriately.
void LoadForeignTabFavicon(const sync_pb::SessionTab& tab);
- // Used to populate a session tab from the session specifics tab provided.
+ // Append a new navigation from sync specifics onto |tab| navigation vectors.
static void AppendSessionTabNavigation(
const sync_pb::TabNavigation& navigation,
- std::vector<TabNavigation>* navigations);
+ SyncedSessionTab* tab);
// Populates the navigation portion of the session specifics.
static void PopulateSessionSpecificsNavigation(
- const TabNavigation* navigation,
+ const content::NavigationEntry& navigation,
sync_pb::TabNavigation* tab_navigation);
// Returns true if this tab belongs to this profile and belongs to a window,
@@ -456,6 +484,9 @@ class SessionModelAssociator
bool TabHasValidEntry(const SyncedTabDelegate& tab) const;
// For testing only.
+ size_t NumFaviconsForTesting() const;
+
+ // For testing only.
void QuitLoopForSubtleTesting();
// Unique client tag.
@@ -503,6 +534,20 @@ class SessionModelAssociator
// SessionID for the tab whose favicon is being set.
CancelableRequestConsumerTSimple<SessionID::id_type> load_consumer_;
+ // Synced favicon storage and tracking.
+ // Map of favicon URL -> favicon data for favicons synced from other clients.
+ // Favicons are stored as png-encoded strings.
+ // TODO(zea): if this becomes expensive memory-wise, reconsider using the
+ // favicon service instead. For now, this is simpler due to the history
+ // backend not properly supporting expiration of synced favicons.
+ // See crbug.com/122890.
+ std::map<std::string, linked_ptr<std::string> > synced_favicons_;
+ // Map of favicon URL -> usage count. When the count reaches zero, we can
+ // safely delete the favicon as no tabs are referring to it anymore.
+ std::map<std::string, size_t> synced_favicon_usage_;
+ // Map of page URL -> favicon url.
+ std::map<std::string, std::string> synced_favicon_pages_;
+
DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator);
};
« no previous file with comments | « chrome/browser/sessions/session_types.h ('k') | chrome/browser/sync/glue/session_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698