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

Side by Side Diff: chrome/browser/media_galleries/media_file_system_registry_unittest.cc

Issue 2448183002: Remove stl_util's deletion function use from media galleries. (Closed)
Patch Set: fix Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/media_galleries/media_file_system_registry.cc ('k') | no next file » | 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) 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 // MediaFileSystemRegistry unit tests. 5 // MediaFileSystemRegistry unit tests.
6 6
7 #include "chrome/browser/media_galleries/media_file_system_registry.h" 7 #include "chrome/browser/media_galleries/media_file_system_registry.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
11 #include <algorithm> 11 #include <algorithm>
12 #include <memory> 12 #include <memory>
13 #include <set> 13 #include <set>
14 14
15 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/files/file_util.h" 17 #include "base/files/file_util.h"
18 #include "base/files/scoped_temp_dir.h" 18 #include "base/files/scoped_temp_dir.h"
19 #include "base/macros.h" 19 #include "base/macros.h"
20 #include "base/memory/ptr_util.h"
20 #include "base/memory/ref_counted.h" 21 #include "base/memory/ref_counted.h"
21 #include "base/memory/scoped_vector.h" 22 #include "base/memory/scoped_vector.h"
22 #include "base/path_service.h" 23 #include "base/path_service.h"
23 #include "base/run_loop.h" 24 #include "base/run_loop.h"
24 #include "base/stl_util.h"
25 #include "base/strings/stringprintf.h" 25 #include "base/strings/stringprintf.h"
26 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
27 #include "base/threading/sequenced_worker_pool.h" 27 #include "base/threading/sequenced_worker_pool.h"
28 #include "base/values.h" 28 #include "base/values.h"
29 #include "build/build_config.h" 29 #include "build/build_config.h"
30 #include "chrome/browser/extensions/extension_service.h" 30 #include "chrome/browser/extensions/extension_service.h"
31 #include "chrome/browser/extensions/test_extension_system.h" 31 #include "chrome/browser/extensions/test_extension_system.h"
32 #include "chrome/browser/media_galleries/media_file_system_context.h" 32 #include "chrome/browser/media_galleries/media_file_system_context.h"
33 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h" 33 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h"
34 #include "chrome/browser/media_galleries/media_galleries_test_util.h" 34 #include "chrome/browser/media_galleries/media_galleries_test_util.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // RPH created with this factory are owned by it. If the RPH is destroyed 199 // RPH created with this factory are owned by it. If the RPH is destroyed
200 // for testing purposes, it must be removed from the factory first. 200 // for testing purposes, it must be removed from the factory first.
201 content::MockRenderProcessHost* ReleaseRPH( 201 content::MockRenderProcessHost* ReleaseRPH(
202 content::BrowserContext* browser_context); 202 content::BrowserContext* browser_context);
203 203
204 content::RenderProcessHost* CreateRenderProcessHost( 204 content::RenderProcessHost* CreateRenderProcessHost(
205 content::BrowserContext* browser_context, 205 content::BrowserContext* browser_context,
206 content::SiteInstance* site_instance) const override; 206 content::SiteInstance* site_instance) const override;
207 207
208 private: 208 private:
209 typedef std::map<content::BrowserContext*, content::MockRenderProcessHost*> 209 mutable std::map<content::BrowserContext*,
210 ProfileRPHMap; 210 std::unique_ptr<content::MockRenderProcessHost>>
211 mutable ProfileRPHMap rph_map_; 211 rph_map_;
212 212
213 DISALLOW_COPY_AND_ASSIGN(MockProfileSharedRenderProcessHostFactory); 213 DISALLOW_COPY_AND_ASSIGN(MockProfileSharedRenderProcessHostFactory);
214 }; 214 };
215 215
216 class ProfileState { 216 class ProfileState {
217 public: 217 public:
218 explicit ProfileState( 218 explicit ProfileState(
219 MockProfileSharedRenderProcessHostFactory* rph_factory); 219 MockProfileSharedRenderProcessHostFactory* rph_factory);
220 ~ProfileState(); 220 ~ProfileState();
221 221
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 CHECK_NE(a.name, b.name); // Name must be unique. 390 CHECK_NE(a.name, b.name); // Name must be unique.
391 return a.name < b.name; 391 return a.name < b.name;
392 } 392 }
393 393
394 /////////////////////////////////////////////// 394 ///////////////////////////////////////////////
395 // MockProfileSharedRenderProcessHostFactory // 395 // MockProfileSharedRenderProcessHostFactory //
396 /////////////////////////////////////////////// 396 ///////////////////////////////////////////////
397 397
398 MockProfileSharedRenderProcessHostFactory:: 398 MockProfileSharedRenderProcessHostFactory::
399 ~MockProfileSharedRenderProcessHostFactory() { 399 ~MockProfileSharedRenderProcessHostFactory() {
400 base::STLDeleteValues(&rph_map_);
401 } 400 }
402 401
403 content::MockRenderProcessHost* 402 content::MockRenderProcessHost*
404 MockProfileSharedRenderProcessHostFactory::ReleaseRPH( 403 MockProfileSharedRenderProcessHostFactory::ReleaseRPH(
405 content::BrowserContext* browser_context) { 404 content::BrowserContext* browser_context) {
406 ProfileRPHMap::iterator existing = rph_map_.find(browser_context); 405 auto existing = rph_map_.find(browser_context);
407 if (existing == rph_map_.end()) 406 if (existing == rph_map_.end())
408 return NULL; 407 return NULL;
409 content::MockRenderProcessHost* result = existing->second; 408 std::unique_ptr<content::MockRenderProcessHost> result =
409 std::move(existing->second);
410 rph_map_.erase(existing); 410 rph_map_.erase(existing);
411 return result; 411 return result.release();
412 } 412 }
413 413
414 content::RenderProcessHost* 414 content::RenderProcessHost*
415 MockProfileSharedRenderProcessHostFactory::CreateRenderProcessHost( 415 MockProfileSharedRenderProcessHostFactory::CreateRenderProcessHost(
416 content::BrowserContext* browser_context, 416 content::BrowserContext* browser_context,
417 content::SiteInstance* site_instance) const { 417 content::SiteInstance* site_instance) const {
418 ProfileRPHMap::const_iterator existing = rph_map_.find(browser_context); 418 auto existing = rph_map_.find(browser_context);
419 if (existing != rph_map_.end()) 419 if (existing != rph_map_.end())
420 return existing->second; 420 return existing->second.get();
421 rph_map_[browser_context] = 421 rph_map_[browser_context] =
422 new content::MockRenderProcessHost(browser_context); 422 base::MakeUnique<content::MockRenderProcessHost>(browser_context);
423 return rph_map_[browser_context]; 423 return rph_map_[browser_context].get();
424 } 424 }
425 425
426 ////////////////// 426 //////////////////
427 // ProfileState // 427 // ProfileState //
428 ////////////////// 428 //////////////////
429 429
430 ProfileState::ProfileState( 430 ProfileState::ProfileState(
431 MockProfileSharedRenderProcessHostFactory* rph_factory) 431 MockProfileSharedRenderProcessHostFactory* rph_factory)
432 : num_comparisons_(0), 432 : num_comparisons_(0),
433 profile_(new TestingProfile()) { 433 profile_(new TestingProfile()) {
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 fs_info.begin()->second.fsid).empty()); 1071 fs_info.begin()->second.fsid).empty());
1072 1072
1073 // Revoke permission and ensure that the file system is revoked. 1073 // Revoke permission and ensure that the file system is revoked.
1074 SetGalleryPermission(profile_state, 1074 SetGalleryPermission(profile_state,
1075 profile_state->regular_permission_extension(), 1075 profile_state->regular_permission_extension(),
1076 device_id, 1076 device_id,
1077 false /*has access*/); 1077 false /*has access*/);
1078 EXPECT_TRUE(test_file_system_context()->GetRegisteredPath( 1078 EXPECT_TRUE(test_file_system_context()->GetRegisteredPath(
1079 fs_info.begin()->second.fsid).empty()); 1079 fs_info.begin()->second.fsid).empty());
1080 } 1080 }
OLDNEW
« no previous file with comments | « chrome/browser/media_galleries/media_file_system_registry.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698