OLD | NEW |
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 #include "chrome/browser/sync/glue/bookmark_change_processor.h" | 5 #include "chrome/browser/sync/glue/bookmark_change_processor.h" |
6 | 6 |
7 #include <stack> | 7 #include <stack> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/bookmarks/bookmark_model.h" | 14 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
15 #include "chrome/browser/bookmarks/bookmark_utils.h" | 16 #include "chrome/browser/bookmarks/bookmark_utils.h" |
16 #include "chrome/browser/favicon/favicon_service.h" | 17 #include "chrome/browser/favicon/favicon_service.h" |
17 #include "chrome/browser/history/history_service_factory.h" | 18 #include "chrome/browser/history/history_service_factory.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/sync/profile_sync_service.h" | 20 #include "chrome/browser/sync/profile_sync_service.h" |
20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
21 #include "sync/internal_api/public/change_record.h" | 22 #include "sync/internal_api/public/change_record.h" |
22 #include "sync/internal_api/public/read_node.h" | 23 #include "sync/internal_api/public/read_node.h" |
23 #include "sync/internal_api/public/write_node.h" | 24 #include "sync/internal_api/public/write_node.h" |
24 #include "sync/internal_api/public/write_transaction.h" | 25 #include "sync/internal_api/public/write_transaction.h" |
(...skipping 13 matching lines...) Expand all Loading... |
38 bookmark_model_(NULL), | 39 bookmark_model_(NULL), |
39 model_associator_(model_associator) { | 40 model_associator_(model_associator) { |
40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
41 DCHECK(model_associator); | 42 DCHECK(model_associator); |
42 DCHECK(error_handler); | 43 DCHECK(error_handler); |
43 } | 44 } |
44 | 45 |
45 void BookmarkChangeProcessor::StartImpl(Profile* profile) { | 46 void BookmarkChangeProcessor::StartImpl(Profile* profile) { |
46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
47 DCHECK(!bookmark_model_); | 48 DCHECK(!bookmark_model_); |
48 bookmark_model_ = profile->GetBookmarkModel(); | 49 bookmark_model_ = BookmarkModelFactory::GetForProfile(profile); |
49 DCHECK(bookmark_model_->IsLoaded()); | 50 DCHECK(bookmark_model_->IsLoaded()); |
50 bookmark_model_->AddObserver(this); | 51 bookmark_model_->AddObserver(this); |
51 } | 52 } |
52 | 53 |
53 void BookmarkChangeProcessor::StopImpl() { | 54 void BookmarkChangeProcessor::StopImpl() { |
54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
55 DCHECK(bookmark_model_); | 56 DCHECK(bookmark_model_); |
56 bookmark_model_->RemoveObserver(this); | 57 bookmark_model_->RemoveObserver(this); |
57 bookmark_model_ = NULL; | 58 bookmark_model_ = NULL; |
58 model_associator_ = NULL; | 59 model_associator_ = NULL; |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 const BookmarkNode* bookmark_node, | 652 const BookmarkNode* bookmark_node, |
652 BookmarkModel* model, | 653 BookmarkModel* model, |
653 syncer::WriteNode* sync_node) { | 654 syncer::WriteNode* sync_node) { |
654 std::vector<unsigned char> favicon_bytes; | 655 std::vector<unsigned char> favicon_bytes; |
655 EncodeFavicon(bookmark_node, model, &favicon_bytes); | 656 EncodeFavicon(bookmark_node, model, &favicon_bytes); |
656 if (!favicon_bytes.empty()) | 657 if (!favicon_bytes.empty()) |
657 sync_node->SetFaviconBytes(favicon_bytes); | 658 sync_node->SetFaviconBytes(favicon_bytes); |
658 } | 659 } |
659 | 660 |
660 } // namespace browser_sync | 661 } // namespace browser_sync |
OLD | NEW |