| 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 "chrome/browser/extensions/api/log_private/log_private_api.h" | 5 #include "chrome/browser/extensions/api/log_private/log_private_api.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 BrowserThread::PostTask( | 237 BrowserThread::PostTask( |
| 238 BrowserThread::UI, FROM_HERE, | 238 BrowserThread::UI, FROM_HERE, |
| 239 base::Bind(&LogPrivateAPI:: AddEntriesOnUI, | 239 base::Bind(&LogPrivateAPI:: AddEntriesOnUI, |
| 240 base::Unretained(this), | 240 base::Unretained(this), |
| 241 base::Passed(&pending_entries_))); | 241 base::Passed(&pending_entries_))); |
| 242 } | 242 } |
| 243 | 243 |
| 244 void LogPrivateAPI::AddEntriesOnUI(std::unique_ptr<base::ListValue> value) { | 244 void LogPrivateAPI::AddEntriesOnUI(std::unique_ptr<base::ListValue> value) { |
| 245 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 245 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 246 | 246 |
| 247 for (std::set<std::string>::iterator ix = net_internal_watches_.begin(); | 247 for (const std::string& extension_id : net_internal_watches_) { |
| 248 ix != net_internal_watches_.end(); ++ix) { | |
| 249 // Create the event's arguments value. | 248 // Create the event's arguments value. |
| 250 std::unique_ptr<base::ListValue> event_args(new base::ListValue()); | 249 std::unique_ptr<base::ListValue> event_args(new base::ListValue()); |
| 251 event_args->Append(value->DeepCopy()); | 250 event_args->Append(value->CreateDeepCopy()); |
| 252 std::unique_ptr<Event> event( | 251 std::unique_ptr<Event> event( |
| 253 new Event(::extensions::events::LOG_PRIVATE_ON_CAPTURED_EVENTS, | 252 new Event(::extensions::events::LOG_PRIVATE_ON_CAPTURED_EVENTS, |
| 254 ::events::kOnCapturedEvents, std::move(event_args))); | 253 ::events::kOnCapturedEvents, std::move(event_args))); |
| 255 EventRouter::Get(browser_context_) | 254 EventRouter::Get(browser_context_) |
| 256 ->DispatchEventToExtension(*ix, std::move(event)); | 255 ->DispatchEventToExtension(extension_id, std::move(event)); |
| 257 } | 256 } |
| 258 } | 257 } |
| 259 | 258 |
| 260 void LogPrivateAPI::CreateTempNetLogFile(const std::string& owner_extension_id, | 259 void LogPrivateAPI::CreateTempNetLogFile(const std::string& owner_extension_id, |
| 261 base::ScopedFILE* file) { | 260 base::ScopedFILE* file) { |
| 262 AssertCurrentlyOnFileResourceSequence(); | 261 AssertCurrentlyOnFileResourceSequence(); |
| 263 | 262 |
| 264 // Create app-specific subdirectory in session logs folder. | 263 // Create app-specific subdirectory in session logs folder. |
| 265 base::FilePath app_log_dir = GetAppLogDirectory().Append(owner_extension_id); | 264 base::FilePath app_log_dir = GetAppLogDirectory().Append(owner_extension_id); |
| 266 if (!base::DirectoryExists(app_log_dir)) { | 265 if (!base::DirectoryExists(app_log_dir)) { |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 entry->SetBoolean("isDirectory", false); | 544 entry->SetBoolean("isDirectory", false); |
| 546 base::ListValue* entry_list = new base::ListValue(); | 545 base::ListValue* entry_list = new base::ListValue(); |
| 547 entry_list->Append(std::move(entry)); | 546 entry_list->Append(std::move(entry)); |
| 548 response->Set("entries", entry_list); | 547 response->Set("entries", entry_list); |
| 549 response->SetBoolean("multiple", false); | 548 response->SetBoolean("multiple", false); |
| 550 SetResult(std::move(response)); | 549 SetResult(std::move(response)); |
| 551 SendResponse(succeeded); | 550 SendResponse(succeeded); |
| 552 } | 551 } |
| 553 | 552 |
| 554 } // namespace extensions | 553 } // namespace extensions |
| OLD | NEW |