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

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

Issue 200045: Use Scoped[Bstr,ComPtr,Variant] instead of their ATL equivalents to reduce de... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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/browser_accessibility.cc ('k') | chrome/browser/importer/ie_importer.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) 2008-2009 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/registry.h" 12 #include "base/registry.h"
13 #include "base/scoped_bstr_win.h"
13 #include "base/scoped_comptr_win.h" 14 #include "base/scoped_comptr_win.h"
15 #include "base/scoped_variant_win.h"
16 #include "base/string_util.h"
14 #include "base/time.h" 17 #include "base/time.h"
15 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
16 19
17 namespace { 20 namespace {
18 21
19 // Instantiates a IChromeHistoryIndexer COM object. Takes a COM class id 22 // Instantiates a IChromeHistoryIndexer COM object. Takes a COM class id
20 // in |name| and returns the object in |indexer|. Returns false if the 23 // in |name| and returns the object in |indexer|. Returns false if the
21 // operation fails. 24 // operation fails.
22 bool CoCreateIndexerFromName(const wchar_t* name, 25 bool CoCreateIndexerFromName(const wchar_t* name,
23 IChromeHistoryIndexer** indexer) { 26 IChromeHistoryIndexer** indexer) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 kRegKeyRegisteredIndexersInfo, &indexers_); 103 kRegKeyRegisteredIndexersInfo, &indexers_);
101 return indexers_.size() > 0; 104 return indexers_.size() > 0;
102 } 105 }
103 106
104 void HistoryPublisher::PublishDataToIndexers(const PageData& page_data) 107 void HistoryPublisher::PublishDataToIndexers(const PageData& page_data)
105 const { 108 const {
106 double var_time = TimeToUTCVariantTime(page_data.time); 109 double var_time = TimeToUTCVariantTime(page_data.time);
107 110
108 CComSafeArray<unsigned char> thumbnail_arr; 111 CComSafeArray<unsigned char> thumbnail_arr;
109 if (page_data.thumbnail) { 112 if (page_data.thumbnail) {
110 for(size_t i = 0; i < page_data.thumbnail->size(); ++i) 113 for (size_t i = 0; i < page_data.thumbnail->size(); ++i)
111 thumbnail_arr.Add((*page_data.thumbnail)[i]); 114 thumbnail_arr.Add((*page_data.thumbnail)[i]);
112 } 115 }
113 116
114 // Send data to registered indexers. 117 // Send data to registered indexers.
115 for(size_t i = 0; i < indexers_.size(); ++i) { 118 ScopedVariant time(var_time, VT_DATE);
tommi (sloooow) - chröme 2009/09/10 20:22:42 one more absolute nit... you might want to surroun
116 indexers_[i]->SendPageData( 119 ScopedBstr url(ASCIIToWide(page_data.url.spec()).c_str());
117 CComVariant(var_time, VT_DATE), 120 ScopedBstr html(page_data.html);
118 CComBSTR(page_data.url.spec().c_str()), 121 ScopedBstr title(page_data.title);
119 CComBSTR(page_data.html), 122 ScopedBstr format(ASCIIToWide(page_data.thumbnail_format).c_str());
120 CComBSTR(page_data.title), 123 ScopedVariant psa(thumbnail_arr.m_psa);
121 CComBSTR(page_data.thumbnail_format), 124 for (size_t i = 0; i < indexers_.size(); ++i) {
122 CComVariant(thumbnail_arr.m_psa)); 125 indexers_[i]->SendPageData(time, url, html, title, format, psa);
123 } 126 }
124 } 127 }
125 128
126 void HistoryPublisher::DeleteUserHistoryBetween(const base::Time& begin_time, 129 void HistoryPublisher::DeleteUserHistoryBetween(const base::Time& begin_time,
127 const base::Time& end_time) 130 const base::Time& end_time)
128 const { 131 const {
129 double var_begin_time = TimeToUTCVariantTime(begin_time); 132 ScopedVariant var_begin_time(TimeToUTCVariantTime(begin_time), VT_DATE);
130 double var_end_time = TimeToUTCVariantTime(end_time); 133 ScopedVariant var_end_time(TimeToUTCVariantTime(end_time), VT_DATE);
131 for(size_t i = 0; i < indexers_.size(); ++i) { 134 for (size_t i = 0; i < indexers_.size(); ++i) {
132 indexers_[i]->DeleteUserHistoryBetween(CComVariant(var_begin_time, VT_DATE), 135 indexers_[i]->DeleteUserHistoryBetween(var_begin_time, var_end_time);
133 CComVariant(var_end_time, VT_DATE));
134 } 136 }
135 } 137 }
136 138
137 } // namespace history 139 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/browser_accessibility.cc ('k') | chrome/browser/importer/ie_importer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698