OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/lazy_instance.h" | 5 #include "base/lazy_instance.h" |
6 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_
operation.h" | 8 #include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_
operation.h" |
9 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" | 9 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" |
10 #include "chrome/browser/extensions/api/image_writer_private/operation.h" | 10 #include "chrome/browser/extensions/api/image_writer_private/operation.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 operations_[extension_id] = operation; | 132 operations_[extension_id] = operation; |
133 BrowserThread::PostTask(BrowserThread::FILE, | 133 BrowserThread::PostTask(BrowserThread::FILE, |
134 FROM_HERE, | 134 FROM_HERE, |
135 base::Bind(&Operation::Start, operation)); | 135 base::Bind(&Operation::Start, operation)); |
136 callback.Run(true, ""); | 136 callback.Run(true, ""); |
137 } | 137 } |
138 | 138 |
139 void OperationManager::OnProgress(const ExtensionId& extension_id, | 139 void OperationManager::OnProgress(const ExtensionId& extension_id, |
140 image_writer_api::Stage stage, | 140 image_writer_api::Stage stage, |
141 int progress) { | 141 int progress) { |
142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 142 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
143 | 143 |
144 image_writer_api::ProgressInfo info; | 144 image_writer_api::ProgressInfo info; |
145 info.stage = stage; | 145 info.stage = stage; |
146 info.percent_complete = progress; | 146 info.percent_complete = progress; |
147 | 147 |
148 scoped_ptr<base::ListValue> args( | 148 scoped_ptr<base::ListValue> args( |
149 image_writer_api::OnWriteProgress::Create(info)); | 149 image_writer_api::OnWriteProgress::Create(info)); |
150 scoped_ptr<Event> event(new Event( | 150 scoped_ptr<Event> event(new Event( |
151 image_writer_api::OnWriteProgress::kEventName, args.Pass())); | 151 image_writer_api::OnWriteProgress::kEventName, args.Pass())); |
152 | 152 |
153 ExtensionSystem::Get(profile_)->event_router()-> | 153 ExtensionSystem::Get(profile_)->event_router()-> |
154 DispatchEventToExtension(extension_id, event.Pass()); | 154 DispatchEventToExtension(extension_id, event.Pass()); |
155 } | 155 } |
156 | 156 |
157 void OperationManager::OnComplete(const ExtensionId& extension_id) { | 157 void OperationManager::OnComplete(const ExtensionId& extension_id) { |
158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 158 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
159 | 159 |
160 scoped_ptr<base::ListValue> args(image_writer_api::OnWriteComplete::Create()); | 160 scoped_ptr<base::ListValue> args(image_writer_api::OnWriteComplete::Create()); |
161 scoped_ptr<Event> event(new Event( | 161 scoped_ptr<Event> event(new Event( |
162 image_writer_api::OnWriteComplete::kEventName, args.Pass())); | 162 image_writer_api::OnWriteComplete::kEventName, args.Pass())); |
163 | 163 |
164 ExtensionSystem::Get(profile_)->event_router()-> | 164 ExtensionSystem::Get(profile_)->event_router()-> |
165 DispatchEventToExtension(extension_id, event.Pass()); | 165 DispatchEventToExtension(extension_id, event.Pass()); |
166 | 166 |
167 DeleteOperation(extension_id); | 167 DeleteOperation(extension_id); |
168 } | 168 } |
169 | 169 |
170 void OperationManager::OnError(const ExtensionId& extension_id, | 170 void OperationManager::OnError(const ExtensionId& extension_id, |
171 image_writer_api::Stage stage, | 171 image_writer_api::Stage stage, |
172 int progress, | 172 int progress, |
173 const std::string& error_message) { | 173 const std::string& error_message) { |
174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 174 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
175 image_writer_api::ProgressInfo info; | 175 image_writer_api::ProgressInfo info; |
176 | 176 |
177 DLOG(ERROR) << "ImageWriter error: " << error_message; | 177 DLOG(ERROR) << "ImageWriter error: " << error_message; |
178 | 178 |
179 info.stage = stage; | 179 info.stage = stage; |
180 info.percent_complete = progress; | 180 info.percent_complete = progress; |
181 | 181 |
182 scoped_ptr<base::ListValue> args( | 182 scoped_ptr<base::ListValue> args( |
183 image_writer_api::OnWriteError::Create(info, error_message)); | 183 image_writer_api::OnWriteError::Create(info, error_message)); |
184 scoped_ptr<Event> event(new Event( | 184 scoped_ptr<Event> event(new Event( |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 g_factory = LAZY_INSTANCE_INITIALIZER; | 246 g_factory = LAZY_INSTANCE_INITIALIZER; |
247 | 247 |
248 BrowserContextKeyedAPIFactory<OperationManager>* | 248 BrowserContextKeyedAPIFactory<OperationManager>* |
249 OperationManager::GetFactoryInstance() { | 249 OperationManager::GetFactoryInstance() { |
250 return g_factory.Pointer(); | 250 return g_factory.Pointer(); |
251 } | 251 } |
252 | 252 |
253 | 253 |
254 } // namespace image_writer | 254 } // namespace image_writer |
255 } // namespace extensions | 255 } // namespace extensions |
OLD | NEW |