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

Side by Side Diff: components/storage_monitor/portable_device_watcher_win.cc

Issue 1223983002: Move WriteInto to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // Any tasks that communicates with the portable device may take >100ms to 5 // Any tasks that communicates with the portable device may take >100ms to
6 // complete. Those tasks should be run on an blocking thread instead of the 6 // complete. Those tasks should be run on an blocking thread instead of the
7 // UI thread. 7 // UI thread.
8 8
9 #include "components/storage_monitor/portable_device_watcher_win.h" 9 #include "components/storage_monitor/portable_device_watcher_win.h"
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 base::string16* name) { 70 base::string16* name) {
71 DCHECK(device_manager); 71 DCHECK(device_manager);
72 DCHECK(name); 72 DCHECK(name);
73 DWORD name_len = 0; 73 DWORD name_len = 0;
74 HRESULT hr = device_manager->GetDeviceFriendlyName(pnp_device_id.c_str(), 74 HRESULT hr = device_manager->GetDeviceFriendlyName(pnp_device_id.c_str(),
75 NULL, &name_len); 75 NULL, &name_len);
76 if (FAILED(hr)) 76 if (FAILED(hr))
77 return false; 77 return false;
78 78
79 hr = device_manager->GetDeviceFriendlyName( 79 hr = device_manager->GetDeviceFriendlyName(
80 pnp_device_id.c_str(), WriteInto(name, name_len), &name_len); 80 pnp_device_id.c_str(), base::WriteInto(name, name_len), &name_len);
81 return (SUCCEEDED(hr) && !name->empty()); 81 return (SUCCEEDED(hr) && !name->empty());
82 } 82 }
83 83
84 // Gets the manufacturer name of the device specified by the |pnp_device_id|. 84 // Gets the manufacturer name of the device specified by the |pnp_device_id|.
85 // On success, returns true and fills in |name|. 85 // On success, returns true and fills in |name|.
86 bool GetManufacturerName(const base::string16& pnp_device_id, 86 bool GetManufacturerName(const base::string16& pnp_device_id,
87 IPortableDeviceManager* device_manager, 87 IPortableDeviceManager* device_manager,
88 base::string16* name) { 88 base::string16* name) {
89 DCHECK(device_manager); 89 DCHECK(device_manager);
90 DCHECK(name); 90 DCHECK(name);
91 DWORD name_len = 0; 91 DWORD name_len = 0;
92 HRESULT hr = device_manager->GetDeviceManufacturer(pnp_device_id.c_str(), 92 HRESULT hr = device_manager->GetDeviceManufacturer(pnp_device_id.c_str(),
93 NULL, &name_len); 93 NULL, &name_len);
94 if (FAILED(hr)) 94 if (FAILED(hr))
95 return false; 95 return false;
96 96
97 hr = device_manager->GetDeviceManufacturer(pnp_device_id.c_str(), 97 hr = device_manager->GetDeviceManufacturer(pnp_device_id.c_str(),
98 WriteInto(name, name_len), 98 base::WriteInto(name, name_len),
99 &name_len); 99 &name_len);
100 return (SUCCEEDED(hr) && !name->empty()); 100 return (SUCCEEDED(hr) && !name->empty());
101 } 101 }
102 102
103 // Gets the description of the device specified by the |pnp_device_id|. On 103 // Gets the description of the device specified by the |pnp_device_id|. On
104 // success, returns true and fills in |description|. 104 // success, returns true and fills in |description|.
105 bool GetDeviceDescription(const base::string16& pnp_device_id, 105 bool GetDeviceDescription(const base::string16& pnp_device_id,
106 IPortableDeviceManager* device_manager, 106 IPortableDeviceManager* device_manager,
107 base::string16* description) { 107 base::string16* description) {
108 DCHECK(device_manager); 108 DCHECK(device_manager);
109 DCHECK(description); 109 DCHECK(description);
110 DWORD desc_len = 0; 110 DWORD desc_len = 0;
111 HRESULT hr = device_manager->GetDeviceDescription(pnp_device_id.c_str(), NULL, 111 HRESULT hr = device_manager->GetDeviceDescription(pnp_device_id.c_str(), NULL,
112 &desc_len); 112 &desc_len);
113 if (FAILED(hr)) 113 if (FAILED(hr))
114 return false; 114 return false;
115 115
116 hr = device_manager->GetDeviceDescription(pnp_device_id.c_str(), 116 hr = device_manager->GetDeviceDescription(
117 WriteInto(description, desc_len), 117 pnp_device_id.c_str(), base::WriteInto(description, desc_len), &desc_len);
118 &desc_len);
119 return (SUCCEEDED(hr) && !description->empty()); 118 return (SUCCEEDED(hr) && !description->empty());
120 } 119 }
121 120
122 // On success, returns true and updates |client_info| with a reference to an 121 // On success, returns true and updates |client_info| with a reference to an
123 // IPortableDeviceValues interface that holds information about the 122 // IPortableDeviceValues interface that holds information about the
124 // application that communicates with the device. 123 // application that communicates with the device.
125 bool GetClientInformation( 124 bool GetClientInformation(
126 base::win::ScopedComPtr<IPortableDeviceValues>* client_info) { 125 base::win::ScopedComPtr<IPortableDeviceValues>* client_info) {
127 HRESULT hr = client_info->CreateInstance(__uuidof(PortableDeviceValues), 126 HRESULT hr = client_info->CreateInstance(__uuidof(PortableDeviceValues),
128 NULL, CLSCTX_INPROC_SERVER); 127 NULL, CLSCTX_INPROC_SERVER);
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 if (storage_notifications_) { 667 if (storage_notifications_) {
669 storage_notifications_->ProcessDetach( 668 storage_notifications_->ProcessDetach(
670 storage_map_iter->second.device_id()); 669 storage_map_iter->second.device_id());
671 } 670 }
672 storage_map_.erase(storage_map_iter); 671 storage_map_.erase(storage_map_iter);
673 } 672 }
674 device_map_.erase(device_iter); 673 device_map_.erase(device_iter);
675 } 674 }
676 675
677 } // namespace storage_monitor 676 } // namespace storage_monitor
OLDNEW
« no previous file with comments | « components/omnibox/search_provider.cc ('k') | components/storage_monitor/volume_mount_watcher_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698