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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/event_router.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: iwyu fixes Created 4 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
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 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8
8 #include <utility> 9 #include <utility>
9 10
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/command_line.h" 12 #include "base/command_line.h"
12 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ptr_util.h"
14 #include "base/stl_util.h" 16 #include "base/stl_util.h"
15 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
16 #include "base/threading/sequenced_worker_pool.h" 18 #include "base/threading/sequenced_worker_pool.h"
17 #include "base/values.h" 19 #include "base/values.h"
18 #include "chrome/browser/app_mode/app_mode_utils.h" 20 #include "chrome/browser/app_mode/app_mode_utils.h"
19 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 21 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
20 #include "chrome/browser/chromeos/drive/file_system_util.h" 22 #include "chrome/browser/chromeos/drive/file_system_util.h"
21 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" 23 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
22 #include "chrome/browser/chromeos/file_manager/app_id.h" 24 #include "chrome/browser/chromeos/file_manager/app_id.h"
23 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" 25 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return true; 96 return true;
95 } 97 }
96 98
97 return false; 99 return false;
98 } 100 }
99 101
100 // Sends an event named |event_name| with arguments |event_args| to extensions. 102 // Sends an event named |event_name| with arguments |event_args| to extensions.
101 void BroadcastEvent(Profile* profile, 103 void BroadcastEvent(Profile* profile,
102 extensions::events::HistogramValue histogram_value, 104 extensions::events::HistogramValue histogram_value,
103 const std::string& event_name, 105 const std::string& event_name,
104 scoped_ptr<base::ListValue> event_args) { 106 std::unique_ptr<base::ListValue> event_args) {
105 extensions::EventRouter::Get(profile) 107 extensions::EventRouter::Get(profile)->BroadcastEvent(
106 ->BroadcastEvent(make_scoped_ptr(new extensions::Event( 108 base::WrapUnique(new extensions::Event(histogram_value, event_name,
107 histogram_value, event_name, std::move(event_args)))); 109 std::move(event_args))));
108 } 110 }
109 111
110 // Sends an event named |event_name| with arguments |event_args| to an extension 112 // Sends an event named |event_name| with arguments |event_args| to an extension
111 // of |extention_id|. 113 // of |extention_id|.
112 void DispatchEventToExtension( 114 void DispatchEventToExtension(
113 Profile* profile, 115 Profile* profile,
114 const std::string& extension_id, 116 const std::string& extension_id,
115 extensions::events::HistogramValue histogram_value, 117 extensions::events::HistogramValue histogram_value,
116 const std::string& event_name, 118 const std::string& event_name,
117 scoped_ptr<base::ListValue> event_args) { 119 std::unique_ptr<base::ListValue> event_args) {
118 extensions::EventRouter::Get(profile)->DispatchEventToExtension( 120 extensions::EventRouter::Get(profile)->DispatchEventToExtension(
119 extension_id, make_scoped_ptr(new extensions::Event( 121 extension_id, base::WrapUnique(new extensions::Event(
120 histogram_value, event_name, std::move(event_args)))); 122 histogram_value, event_name, std::move(event_args))));
121 } 123 }
122 124
123 file_manager_private::MountCompletedStatus 125 file_manager_private::MountCompletedStatus
124 MountErrorToMountCompletedStatus(chromeos::MountError error) { 126 MountErrorToMountCompletedStatus(chromeos::MountError error) {
125 switch (error) { 127 switch (error) {
126 case chromeos::MOUNT_ERROR_NONE: 128 case chromeos::MOUNT_ERROR_NONE:
127 return file_manager_private::MOUNT_COMPLETED_STATUS_SUCCESS; 129 return file_manager_private::MOUNT_COMPLETED_STATUS_SUCCESS;
128 case chromeos::MOUNT_ERROR_UNKNOWN: 130 case chromeos::MOUNT_ERROR_UNKNOWN:
129 return file_manager_private::MOUNT_COMPLETED_STATUS_ERROR_UNKNOWN; 131 return file_manager_private::MOUNT_COMPLETED_STATUS_ERROR_UNKNOWN;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 const base::FilePath& file_path, 353 const base::FilePath& file_path,
352 const std::string& extension_id) override { 354 const std::string& extension_id) override {
353 return file_manager::util::ConvertDrivePathToFileSystemUrl( 355 return file_manager::util::ConvertDrivePathToFileSystemUrl(
354 profile_, file_path, extension_id); 356 profile_, file_path, extension_id);
355 } 357 }
356 358
357 void DispatchEventToExtension( 359 void DispatchEventToExtension(
358 const std::string& extension_id, 360 const std::string& extension_id,
359 extensions::events::HistogramValue histogram_value, 361 extensions::events::HistogramValue histogram_value,
360 const std::string& event_name, 362 const std::string& event_name,
361 scoped_ptr<base::ListValue> event_args) override { 363 std::unique_ptr<base::ListValue> event_args) override {
362 ::file_manager::DispatchEventToExtension(profile_, extension_id, 364 ::file_manager::DispatchEventToExtension(profile_, extension_id,
363 histogram_value, event_name, 365 histogram_value, event_name,
364 std::move(event_args)); 366 std::move(event_args));
365 } 367 }
366 368
367 private: 369 private:
368 Profile* const profile_; 370 Profile* const profile_;
369 371
370 DISALLOW_COPY_AND_ASSIGN(JobEventRouterImpl); 372 DISALLOW_COPY_AND_ASSIGN(JobEventRouterImpl);
371 }; 373 };
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 base::FilePath watch_path = local_path; 495 base::FilePath watch_path = local_path;
494 bool is_on_drive = drive::util::IsUnderDriveMountPoint(watch_path); 496 bool is_on_drive = drive::util::IsUnderDriveMountPoint(watch_path);
495 // Tweak watch path for remote sources - we need to drop leading /special 497 // Tweak watch path for remote sources - we need to drop leading /special
496 // directory from there in order to be able to pair these events with 498 // directory from there in order to be able to pair these events with
497 // their change notifications. 499 // their change notifications.
498 if (is_on_drive) 500 if (is_on_drive)
499 watch_path = drive::util::ExtractDrivePath(watch_path); 501 watch_path = drive::util::ExtractDrivePath(watch_path);
500 502
501 WatcherMap::iterator iter = file_watchers_.find(watch_path); 503 WatcherMap::iterator iter = file_watchers_.find(watch_path);
502 if (iter == file_watchers_.end()) { 504 if (iter == file_watchers_.end()) {
503 scoped_ptr<FileWatcher> watcher(new FileWatcher(virtual_path)); 505 std::unique_ptr<FileWatcher> watcher(new FileWatcher(virtual_path));
504 watcher->AddExtension(extension_id); 506 watcher->AddExtension(extension_id);
505 507
506 if (is_on_drive) { 508 if (is_on_drive) {
507 // For Drive, file watching is done via OnDirectoryChanged(). 509 // For Drive, file watching is done via OnDirectoryChanged().
508 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 510 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
509 base::Bind(callback, true)); 511 base::Bind(callback, true));
510 } else { 512 } else {
511 // For local files, start watching using FileWatcher. 513 // For local files, start watching using FileWatcher.
512 watcher->WatchLocalFile( 514 watcher->WatchLocalFile(
513 watch_path, 515 watch_path,
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting( 977 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting(
976 const DispatchDirectoryChangeEventImplCallback& callback) { 978 const DispatchDirectoryChangeEventImplCallback& callback) {
977 dispatch_directory_change_event_impl_ = callback; 979 dispatch_directory_change_event_impl_ = callback;
978 } 980 }
979 981
980 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() { 982 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() {
981 return weak_factory_.GetWeakPtr(); 983 return weak_factory_.GetWeakPtr();
982 } 984 }
983 985
984 } // namespace file_manager 986 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698