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

Side by Side Diff: chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 (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 #include "chrome/browser/extensions/api/sync_file_system/extension_sync_event_ob server.h" 5 #include "chrome/browser/extensions/api/sync_file_system/extension_sync_event_ob server.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api_he lpers.h" 10 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api_he lpers.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 71
72 void ExtensionSyncEventObserver::OnSyncStateUpdated( 72 void ExtensionSyncEventObserver::OnSyncStateUpdated(
73 const GURL& app_origin, 73 const GURL& app_origin,
74 sync_file_system::SyncServiceState state, 74 sync_file_system::SyncServiceState state,
75 const std::string& description) { 75 const std::string& description) {
76 // Convert state and description into SyncState Object. 76 // Convert state and description into SyncState Object.
77 api::sync_file_system::ServiceInfo service_info; 77 api::sync_file_system::ServiceInfo service_info;
78 service_info.state = SyncServiceStateToExtensionEnum(state); 78 service_info.state = SyncServiceStateToExtensionEnum(state);
79 service_info.description = description; 79 service_info.description = description;
80 scoped_ptr<base::ListValue> params( 80 std::unique_ptr<base::ListValue> params(
81 api::sync_file_system::OnServiceStatusChanged::Create(service_info)); 81 api::sync_file_system::OnServiceStatusChanged::Create(service_info));
82 82
83 BroadcastOrDispatchEvent( 83 BroadcastOrDispatchEvent(
84 app_origin, events::SYNC_FILE_SYSTEM_ON_SERVICE_STATUS_CHANGED, 84 app_origin, events::SYNC_FILE_SYSTEM_ON_SERVICE_STATUS_CHANGED,
85 api::sync_file_system::OnServiceStatusChanged::kEventName, 85 api::sync_file_system::OnServiceStatusChanged::kEventName,
86 std::move(params)); 86 std::move(params));
87 } 87 }
88 88
89 void ExtensionSyncEventObserver::OnFileSynced( 89 void ExtensionSyncEventObserver::OnFileSynced(
90 const storage::FileSystemURL& url, 90 const storage::FileSystemURL& url,
91 sync_file_system::SyncFileType file_type, 91 sync_file_system::SyncFileType file_type,
92 sync_file_system::SyncFileStatus status, 92 sync_file_system::SyncFileStatus status,
93 sync_file_system::SyncAction action, 93 sync_file_system::SyncAction action,
94 sync_file_system::SyncDirection direction) { 94 sync_file_system::SyncDirection direction) {
95 scoped_ptr<base::ListValue> params(new base::ListValue()); 95 std::unique_ptr<base::ListValue> params(new base::ListValue());
96 96
97 scoped_ptr<base::DictionaryValue> entry( 97 std::unique_ptr<base::DictionaryValue> entry(
98 CreateDictionaryValueForFileSystemEntry(url, file_type)); 98 CreateDictionaryValueForFileSystemEntry(url, file_type));
99 if (!entry) 99 if (!entry)
100 return; 100 return;
101 params->Append(entry.release()); 101 params->Append(entry.release());
102 102
103 // Status, SyncAction and any optional notes to go here. 103 // Status, SyncAction and any optional notes to go here.
104 api::sync_file_system::FileStatus status_enum = 104 api::sync_file_system::FileStatus status_enum =
105 SyncFileStatusToExtensionEnum(status); 105 SyncFileStatusToExtensionEnum(status);
106 api::sync_file_system::SyncAction action_enum = 106 api::sync_file_system::SyncAction action_enum =
107 SyncActionToExtensionEnum(action); 107 SyncActionToExtensionEnum(action);
108 api::sync_file_system::SyncDirection direction_enum = 108 api::sync_file_system::SyncDirection direction_enum =
109 SyncDirectionToExtensionEnum(direction); 109 SyncDirectionToExtensionEnum(direction);
110 params->AppendString(api::sync_file_system::ToString(status_enum)); 110 params->AppendString(api::sync_file_system::ToString(status_enum));
111 params->AppendString(api::sync_file_system::ToString(action_enum)); 111 params->AppendString(api::sync_file_system::ToString(action_enum));
112 params->AppendString(api::sync_file_system::ToString(direction_enum)); 112 params->AppendString(api::sync_file_system::ToString(direction_enum));
113 113
114 BroadcastOrDispatchEvent( 114 BroadcastOrDispatchEvent(
115 url.origin(), events::SYNC_FILE_SYSTEM_ON_FILE_STATUS_CHANGED, 115 url.origin(), events::SYNC_FILE_SYSTEM_ON_FILE_STATUS_CHANGED,
116 api::sync_file_system::OnFileStatusChanged::kEventName, 116 api::sync_file_system::OnFileStatusChanged::kEventName,
117 std::move(params)); 117 std::move(params));
118 } 118 }
119 119
120 void ExtensionSyncEventObserver::BroadcastOrDispatchEvent( 120 void ExtensionSyncEventObserver::BroadcastOrDispatchEvent(
121 const GURL& app_origin, 121 const GURL& app_origin,
122 events::HistogramValue histogram_value, 122 events::HistogramValue histogram_value,
123 const std::string& event_name, 123 const std::string& event_name,
124 scoped_ptr<base::ListValue> values) { 124 std::unique_ptr<base::ListValue> values) {
125 // Check to see whether the event should be broadcasted to all listening 125 // Check to see whether the event should be broadcasted to all listening
126 // extensions or sent to a specific extension ID. 126 // extensions or sent to a specific extension ID.
127 bool broadcast_mode = app_origin.is_empty(); 127 bool broadcast_mode = app_origin.is_empty();
128 EventRouter* event_router = EventRouter::Get(browser_context_); 128 EventRouter* event_router = EventRouter::Get(browser_context_);
129 DCHECK(event_router); 129 DCHECK(event_router);
130 130
131 scoped_ptr<Event> event( 131 std::unique_ptr<Event> event(
132 new Event(histogram_value, event_name, std::move(values))); 132 new Event(histogram_value, event_name, std::move(values)));
133 event->restrict_to_browser_context = browser_context_; 133 event->restrict_to_browser_context = browser_context_;
134 134
135 // No app_origin, broadcast to all listening extensions for this event name. 135 // No app_origin, broadcast to all listening extensions for this event name.
136 if (broadcast_mode) { 136 if (broadcast_mode) {
137 event_router->BroadcastEvent(std::move(event)); 137 event_router->BroadcastEvent(std::move(event));
138 return; 138 return;
139 } 139 }
140 140
141 // Dispatch to single extension ID. 141 // Dispatch to single extension ID.
142 const std::string extension_id = GetExtensionId(app_origin); 142 const std::string extension_id = GetExtensionId(app_origin);
143 if (extension_id.empty()) 143 if (extension_id.empty())
144 return; 144 return;
145 event_router->DispatchEventToExtension(extension_id, std::move(event)); 145 event_router->DispatchEventToExtension(extension_id, std::move(event));
146 } 146 }
147 147
148 template <> 148 template <>
149 void BrowserContextKeyedAPIFactory< 149 void BrowserContextKeyedAPIFactory<
150 ExtensionSyncEventObserver>::DeclareFactoryDependencies() { 150 ExtensionSyncEventObserver>::DeclareFactoryDependencies() {
151 DependsOn(sync_file_system::SyncFileSystemServiceFactory::GetInstance()); 151 DependsOn(sync_file_system::SyncFileSystemServiceFactory::GetInstance());
152 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 152 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
153 } 153 }
154 154
155 } // namespace extensions 155 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698