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

Side by Side Diff: chrome/browser/history/history_publisher_win.cc

Issue 6825055: Include base/win/scoped_comptr.h instead of base/scoped_comptr_win.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert bad indentation, rebase Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/history/history_publisher.h ('k') | chrome/browser/jumplist_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/history/history_publisher.h" 5 #include "chrome/browser/history/history_publisher.h"
6 6
7 #include <atlsafe.h> 7 #include <atlsafe.h>
8 #include <objbase.h> 8 #include <objbase.h>
9 #include <oleauto.h> 9 #include <oleauto.h>
10 #include <wtypes.h> 10 #include <wtypes.h>
11 11
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "base/win/registry.h" 15 #include "base/win/registry.h"
16 #include "base/win/scoped_bstr.h" 16 #include "base/win/scoped_bstr.h"
17 #include "base/win/scoped_comptr.h" 17 #include "base/win/scoped_comptr.h"
18 #include "base/win/scoped_variant.h" 18 #include "base/win/scoped_variant.h"
19 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
20 20
21 using base::win::ScopedVariant;
22 using base::win::ScopedBstr;
23
24 namespace { 21 namespace {
25 22
26 // Instantiates a IChromeHistoryIndexer COM object. Takes a COM class id 23 // Instantiates a IChromeHistoryIndexer COM object. Takes a COM class id
27 // in |name| and returns the object in |indexer|. Returns false if the 24 // in |name| and returns the object in |indexer|. Returns false if the
28 // operation fails. 25 // operation fails.
29 bool CoCreateIndexerFromName(const wchar_t* name, 26 bool CoCreateIndexerFromName(const wchar_t* name,
30 IChromeHistoryIndexer** indexer) { 27 IChromeHistoryIndexer** indexer) {
31 CLSID clsid; 28 CLSID clsid;
32 HRESULT hr = CLSIDFromString(const_cast<wchar_t*>(name), &clsid); 29 HRESULT hr = CLSIDFromString(const_cast<wchar_t*>(name), &clsid);
33 if (FAILED(hr)) 30 if (FAILED(hr))
34 return false; 31 return false;
35 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC, 32 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC,
36 __uuidof(IChromeHistoryIndexer), 33 __uuidof(IChromeHistoryIndexer),
37 reinterpret_cast<void**>(indexer)); 34 reinterpret_cast<void**>(indexer));
38 if (FAILED(hr)) 35 if (FAILED(hr))
39 return false; 36 return false;
40 return true; 37 return true;
41 } 38 }
42 39
43 // Instantiates the registered indexers from the registry |root| + |path| key 40 // Instantiates the registered indexers from the registry |root| + |path| key
44 // and adds them to the |indexers| list. 41 // and adds them to the |indexers| list.
45 void AddRegisteredIndexers(HKEY root, const wchar_t* path, 42 void AddRegisteredIndexers(HKEY root, const wchar_t* path,
46 std::vector< ScopedComPtr<IChromeHistoryIndexer> >* indexers) { 43 std::vector< base::win::ScopedComPtr<IChromeHistoryIndexer> >* indexers) {
47 IChromeHistoryIndexer* indexer; 44 IChromeHistoryIndexer* indexer;
48 base::win::RegistryKeyIterator r_iter(root, path); 45 base::win::RegistryKeyIterator r_iter(root, path);
49 while (r_iter.Valid()) { 46 while (r_iter.Valid()) {
50 if (CoCreateIndexerFromName(r_iter.Name(), &indexer)) { 47 if (CoCreateIndexerFromName(r_iter.Name(), &indexer)) {
51 indexers->push_back(ScopedComPtr<IChromeHistoryIndexer>(indexer)); 48 indexers->push_back(
49 base::win::ScopedComPtr<IChromeHistoryIndexer>(indexer));
52 indexer->Release(); 50 indexer->Release();
53 } 51 }
54 ++r_iter; 52 ++r_iter;
55 } 53 }
56 } 54 }
57 55
58 } // namespace 56 } // namespace
59 57
60 namespace history { 58 namespace history {
61 59
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 double var_time = TimeToUTCVariantTime(page_data.time); 111 double var_time = TimeToUTCVariantTime(page_data.time);
114 112
115 CComSafeArray<unsigned char> thumbnail_arr; 113 CComSafeArray<unsigned char> thumbnail_arr;
116 if (page_data.thumbnail) { 114 if (page_data.thumbnail) {
117 for (size_t i = 0; i < page_data.thumbnail->size(); ++i) 115 for (size_t i = 0; i < page_data.thumbnail->size(); ++i)
118 thumbnail_arr.Add((*page_data.thumbnail)[i]); 116 thumbnail_arr.Add((*page_data.thumbnail)[i]);
119 } 117 }
120 118
121 // Send data to registered indexers. 119 // Send data to registered indexers.
122 base::win::ScopedVariant time(var_time, VT_DATE); 120 base::win::ScopedVariant time(var_time, VT_DATE);
123 ScopedBstr url(ASCIIToWide(page_data.url.spec()).c_str()); 121 base::win::ScopedBstr url(ASCIIToWide(page_data.url.spec()).c_str());
124 ScopedBstr html(page_data.html); 122 base::win::ScopedBstr html(page_data.html);
125 ScopedBstr title(page_data.title); 123 base::win::ScopedBstr title(page_data.title);
126 // Don't send a NULL string through ASCIIToWide. 124 // Don't send a NULL string through ASCIIToWide.
127 ScopedBstr format(page_data.thumbnail_format ? 125 base::win::ScopedBstr format(page_data.thumbnail_format ?
128 ASCIIToWide(page_data.thumbnail_format).c_str() : 126 ASCIIToWide(page_data.thumbnail_format).c_str() :
129 NULL); 127 NULL);
130 base::win::ScopedVariant psa(thumbnail_arr.m_psa); 128 base::win::ScopedVariant psa(thumbnail_arr.m_psa);
131 for (size_t i = 0; i < indexers_.size(); ++i) { 129 for (size_t i = 0; i < indexers_.size(); ++i) {
132 indexers_[i]->SendPageData(time, url, html, title, format, psa); 130 indexers_[i]->SendPageData(time, url, html, title, format, psa);
133 } 131 }
134 } 132 }
135 133
136 void HistoryPublisher::DeleteUserHistoryBetween(const base::Time& begin_time, 134 void HistoryPublisher::DeleteUserHistoryBetween(const base::Time& begin_time,
137 const base::Time& end_time) 135 const base::Time& end_time)
138 const { 136 const {
139 base::win::ScopedVariant var_begin_time(TimeToUTCVariantTime(begin_time), 137 base::win::ScopedVariant var_begin_time(TimeToUTCVariantTime(begin_time),
140 VT_DATE); 138 VT_DATE);
141 base::win::ScopedVariant var_end_time(TimeToUTCVariantTime(end_time), 139 base::win::ScopedVariant var_end_time(TimeToUTCVariantTime(end_time),
142 VT_DATE); 140 VT_DATE);
143 for (size_t i = 0; i < indexers_.size(); ++i) { 141 for (size_t i = 0; i < indexers_.size(); ++i) {
144 indexers_[i]->DeleteUserHistoryBetween(var_begin_time, var_end_time); 142 indexers_[i]->DeleteUserHistoryBetween(var_begin_time, var_end_time);
145 } 143 }
146 } 144 }
147 145
148 } // namespace history 146 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_publisher.h ('k') | chrome/browser/jumplist_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698