OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/job_event_router.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/job_event_router.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 url.append("filesystem:chrome-extension://"); | 39 url.append("filesystem:chrome-extension://"); |
40 url.append(extension_id); | 40 url.append(extension_id); |
41 url.append(file_path.value()); | 41 url.append(file_path.value()); |
42 return GURL(url); | 42 return GURL(url); |
43 } | 43 } |
44 | 44 |
45 void DispatchEventToExtension( | 45 void DispatchEventToExtension( |
46 const std::string& extension_id, | 46 const std::string& extension_id, |
47 extensions::events::HistogramValue histogram_value, | 47 extensions::events::HistogramValue histogram_value, |
48 const std::string& event_name, | 48 const std::string& event_name, |
49 scoped_ptr<base::ListValue> event_args) override { | 49 std::unique_ptr<base::ListValue> event_args) override { |
50 const base::DictionaryValue* event; | 50 const base::DictionaryValue* event; |
51 event_args->GetDictionary(0, &event); | 51 event_args->GetDictionary(0, &event); |
52 events.push_back(make_linked_ptr(event->DeepCopy())); | 52 events.push_back(make_linked_ptr(event->DeepCopy())); |
53 } | 53 } |
54 | 54 |
55 private: | 55 private: |
56 std::set<std::string> listener_extension_ids_; | 56 std::set<std::string> listener_extension_ids_; |
57 | 57 |
58 DISALLOW_COPY_AND_ASSIGN(JobEventRouterImpl); | 58 DISALLOW_COPY_AND_ASSIGN(JobEventRouterImpl); |
59 }; | 59 }; |
(...skipping 19 matching lines...) Expand all Loading... |
79 job_event_router->events[index]->GetString(name, &value); | 79 job_event_router->events[index]->GetString(name, &value); |
80 return value; | 80 return value; |
81 } | 81 } |
82 | 82 |
83 double GetEventDouble(size_t index, const std::string& name) { | 83 double GetEventDouble(size_t index, const std::string& name) { |
84 double value = NAN; | 84 double value = NAN; |
85 job_event_router->events[index]->GetDouble(name, &value); | 85 job_event_router->events[index]->GetDouble(name, &value); |
86 return value; | 86 return value; |
87 } | 87 } |
88 | 88 |
89 scoped_ptr<JobEventRouterImpl> job_event_router; | 89 std::unique_ptr<JobEventRouterImpl> job_event_router; |
90 | 90 |
91 private: | 91 private: |
92 base::MessageLoop message_loop_; | 92 base::MessageLoop message_loop_; |
93 }; | 93 }; |
94 | 94 |
95 TEST_F(JobEventRouterTest, Basic) { | 95 TEST_F(JobEventRouterTest, Basic) { |
96 // Add a job. | 96 // Add a job. |
97 job_event_router->OnJobAdded( | 97 job_event_router->OnJobAdded( |
98 CreateJobInfo(0, 0, 100, base::FilePath("/test/a"))); | 98 CreateJobInfo(0, 0, 100, base::FilePath("/test/a"))); |
99 // Event should be throttled. | 99 // Event should be throttled. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // Check event for extension_b. | 240 // Check event for extension_b. |
241 EXPECT_EQ("in_progress", GetEventString(1, "transferState")); | 241 EXPECT_EQ("in_progress", GetEventString(1, "transferState")); |
242 EXPECT_EQ(0.0f, GetEventDouble(1, "processed")); | 242 EXPECT_EQ(0.0f, GetEventDouble(1, "processed")); |
243 EXPECT_EQ(100.0f, GetEventDouble(1, "total")); | 243 EXPECT_EQ(100.0f, GetEventDouble(1, "total")); |
244 EXPECT_EQ("filesystem:chrome-extension://extension_b/test/a", | 244 EXPECT_EQ("filesystem:chrome-extension://extension_b/test/a", |
245 GetEventString(1, "fileUrl")); | 245 GetEventString(1, "fileUrl")); |
246 } | 246 } |
247 | 247 |
248 } // namespace | 248 } // namespace |
249 } // namespace file_manager | 249 } // namespace file_manager |
OLD | NEW |