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

Side by Side Diff: chrome/browser/sync/glue/session_model_associator.h

Issue 10662035: [Sync] Put everything in sync/api into csync namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comments 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 | Annotate | Revision Log
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_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_
6 #define CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // Resync local window information. Updates the local sessions header node 112 // Resync local window information. Updates the local sessions header node
113 // with the status of open windows and the order of tabs they contain. Should 113 // with the status of open windows and the order of tabs they contain. Should
114 // only be called for changes that affect a window, not a change within a 114 // only be called for changes that affect a window, not a change within a
115 // single tab. 115 // single tab.
116 // 116 //
117 // If |reload_tabs| is true, will also resync all tabs (same as calling 117 // If |reload_tabs| is true, will also resync all tabs (same as calling
118 // AssociateTabs with a vector of all tabs). 118 // AssociateTabs with a vector of all tabs).
119 // |error| gets set if any association error occurred. 119 // |error| gets set if any association error occurred.
120 // Returns: false if the local session's sync nodes were deleted and 120 // Returns: false if the local session's sync nodes were deleted and
121 // reassociation is necessary, true otherwise. 121 // reassociation is necessary, true otherwise.
122 bool AssociateWindows(bool reload_tabs, SyncError* error); 122 bool AssociateWindows(bool reload_tabs, csync::SyncError* error);
123 123
124 // Loads and reassociates the local tabs referenced in |tabs|. 124 // Loads and reassociates the local tabs referenced in |tabs|.
125 // |error| gets set if any association error occurred. 125 // |error| gets set if any association error occurred.
126 // Returns: false if the local session's sync nodes were deleted and 126 // Returns: false if the local session's sync nodes were deleted and
127 // reassociation is necessary, true otherwise. 127 // reassociation is necessary, true otherwise.
128 bool AssociateTabs(const std::vector<SyncedTabDelegate*>& tabs, 128 bool AssociateTabs(const std::vector<SyncedTabDelegate*>& tabs,
129 SyncError* error); 129 csync::SyncError* error);
130 130
131 // Reassociates a single tab with the sync model. Will check if the tab 131 // Reassociates a single tab with the sync model. Will check if the tab
132 // already is associated with a sync node and allocate one if necessary. 132 // already is associated with a sync node and allocate one if necessary.
133 // |error| gets set if any association error occurred. 133 // |error| gets set if any association error occurred.
134 // Returns: false if the local session's sync nodes were deleted and 134 // Returns: false if the local session's sync nodes were deleted and
135 // reassociation is necessary, true otherwise. 135 // reassociation is necessary, true otherwise.
136 bool AssociateTab(const SyncedTabDelegate& tab, 136 bool AssociateTab(const SyncedTabDelegate& tab,
137 SyncError* error); 137 csync::SyncError* error);
138 138
139 // Load any foreign session info stored in sync db and update the sync db 139 // Load any foreign session info stored in sync db and update the sync db
140 // with local client data. Processes/reuses any sync nodes owned by this 140 // with local client data. Processes/reuses any sync nodes owned by this
141 // client and creates any further sync nodes needed to store local header and 141 // client and creates any further sync nodes needed to store local header and
142 // tab info. 142 // tab info.
143 virtual SyncError AssociateModels() OVERRIDE; 143 virtual csync::SyncError AssociateModels() OVERRIDE;
144 144
145 // Initializes the given sync node from the given chrome node id. 145 // Initializes the given sync node from the given chrome node id.
146 // Returns false if no sync node was found for the given chrome node id or 146 // Returns false if no sync node was found for the given chrome node id or
147 // if the initialization of sync node fails. 147 // if the initialization of sync node fails.
148 virtual bool InitSyncNodeFromChromeId(const std::string& id, 148 virtual bool InitSyncNodeFromChromeId(const std::string& id,
149 csync::BaseNode* sync_node); 149 csync::BaseNode* sync_node);
150 150
151 // Clear local sync data buffers. Does not delete sync nodes to avoid 151 // Clear local sync data buffers. Does not delete sync nodes to avoid
152 // tombstones. TODO(zea): way to eventually delete orphaned nodes. 152 // tombstones. TODO(zea): way to eventually delete orphaned nodes.
153 virtual SyncError DisassociateModels() OVERRIDE; 153 virtual csync::SyncError DisassociateModels() OVERRIDE;
154 154
155 // Returns the tag used to uniquely identify this machine's session in the 155 // Returns the tag used to uniquely identify this machine's session in the
156 // sync model. 156 // sync model.
157 const std::string& GetCurrentMachineTag() const { 157 const std::string& GetCurrentMachineTag() const {
158 DCHECK(!current_machine_tag_.empty()); 158 DCHECK(!current_machine_tag_.empty());
159 return current_machine_tag_; 159 return current_machine_tag_;
160 } 160 }
161 161
162 // Load and associate window and tab data for a foreign session. 162 // Load and associate window and tab data for a foreign session.
163 void AssociateForeignSpecifics(const sync_pb::SessionSpecifics& specifics, 163 void AssociateForeignSpecifics(const sync_pb::SessionSpecifics& specifics,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 388
389 // Initializes the tag corresponding to this machine. 389 // Initializes the tag corresponding to this machine.
390 void InitializeCurrentMachineTag(csync::WriteTransaction* trans); 390 void InitializeCurrentMachineTag(csync::WriteTransaction* trans);
391 391
392 // Initializes the user visible name for this session 392 // Initializes the user visible name for this session
393 void InitializeCurrentSessionName(); 393 void InitializeCurrentSessionName();
394 394
395 // Updates the server data based upon the current client session. If no node 395 // Updates the server data based upon the current client session. If no node
396 // corresponding to this machine exists in the sync model, one is created. 396 // corresponding to this machine exists in the sync model, one is created.
397 // Returns true on success, false if association failed. 397 // Returns true on success, false if association failed.
398 bool UpdateSyncModelDataFromClient(SyncError* error); 398 bool UpdateSyncModelDataFromClient(csync::SyncError* error);
399 399
400 // Pulls the current sync model from the sync database and returns true upon 400 // Pulls the current sync model from the sync database and returns true upon
401 // update of the client model. Will associate any foreign sessions as well as 401 // update of the client model. Will associate any foreign sessions as well as
402 // keep track of any local tab nodes, adding them to our free tab node pool. 402 // keep track of any local tab nodes, adding them to our free tab node pool.
403 bool UpdateAssociationsFromSyncModel(const csync::ReadNode& root, 403 bool UpdateAssociationsFromSyncModel(const csync::ReadNode& root,
404 csync::WriteTransaction* trans, 404 csync::WriteTransaction* trans,
405 SyncError* error); 405 csync::SyncError* error);
406 406
407 // Fills a tab sync node with data from a WebContents object. Updates 407 // Fills a tab sync node with data from a WebContents object. Updates
408 // |tab_link| with the current url if it's valid and triggers a favicon 408 // |tab_link| with the current url if it's valid and triggers a favicon
409 // load if the url has changed. 409 // load if the url has changed.
410 // Returns true on success, false if we need to reassociate due to corruption. 410 // Returns true on success, false if we need to reassociate due to corruption.
411 bool WriteTabContentsToSyncModel(TabLink* tab_link, 411 bool WriteTabContentsToSyncModel(TabLink* tab_link,
412 SyncError* error); 412 csync::SyncError* error);
413 413
414 // Decrements the favicon usage counters for the favicon used by |page_url|. 414 // Decrements the favicon usage counters for the favicon used by |page_url|.
415 // Deletes the favicon and associated pages from the favicon usage maps 415 // Deletes the favicon and associated pages from the favicon usage maps
416 // if no page is found to be referring to the favicon anymore. 416 // if no page is found to be referring to the favicon anymore.
417 void DecrementAndCleanFaviconForURL(const std::string& page_url); 417 void DecrementAndCleanFaviconForURL(const std::string& page_url);
418 418
419 // Helper method to build sync's tab specifics from a newly modified 419 // Helper method to build sync's tab specifics from a newly modified
420 // tab, window, and the locally stored previous tab data. After completing, 420 // tab, window, and the locally stored previous tab data. After completing,
421 // |prev_tab| will be updated to reflect the current data, |sync_tab| will 421 // |prev_tab| will be updated to reflect the current data, |sync_tab| will
422 // be filled with the tab data (preserving old timestamps as necessary), and 422 // be filled with the tab data (preserving old timestamps as necessary), and
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 std::map<std::string, linked_ptr<SyncedFaviconInfo> > synced_favicons_; 559 std::map<std::string, linked_ptr<SyncedFaviconInfo> > synced_favicons_;
560 // Map of page URL -> favicon url. 560 // Map of page URL -> favicon url.
561 std::map<std::string, std::string> synced_favicon_pages_; 561 std::map<std::string, std::string> synced_favicon_pages_;
562 562
563 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); 563 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator);
564 }; 564 };
565 565
566 } // namespace browser_sync 566 } // namespace browser_sync
567 567
568 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ 568 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/session_change_processor.cc ('k') | chrome/browser/sync/glue/session_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698