OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/sync/util/extensions_activity_monitor.h" | 5 #include "chrome/browser/sync/util/extensions_activity_monitor.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/extensions/extension_bookmarks_module.h" | 11 #include "chrome/browser/extensions/extension_bookmarks_module.h" |
| 12 #include "chrome/common/chrome_notification_types.h" |
12 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
13 #include "chrome/common/extensions/extension_constants.h" | 14 #include "chrome/common/extensions/extension_constants.h" |
14 #include "content/browser/browser_thread.h" | 15 #include "content/browser/browser_thread.h" |
15 #include "content/common/notification_service.h" | 16 #include "content/common/notification_service.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 | 18 |
18 using browser_sync::ExtensionsActivityMonitor; | 19 using browser_sync::ExtensionsActivityMonitor; |
19 namespace keys = extension_manifest_keys; | 20 namespace keys = extension_manifest_keys; |
20 | 21 |
21 namespace { | 22 namespace { |
(...skipping 17 matching lines...) Expand all Loading... |
39 | 40 |
40 template <class FunctionType> | 41 template <class FunctionType> |
41 class BookmarkAPIEventTask : public Task { | 42 class BookmarkAPIEventTask : public Task { |
42 public: | 43 public: |
43 BookmarkAPIEventTask(FunctionType* t, Extension* e, size_t repeats, | 44 BookmarkAPIEventTask(FunctionType* t, Extension* e, size_t repeats, |
44 base::WaitableEvent* done) : | 45 base::WaitableEvent* done) : |
45 extension_(e), function_(t), repeats_(repeats), done_(done) {} | 46 extension_(e), function_(t), repeats_(repeats), done_(done) {} |
46 virtual void Run() { | 47 virtual void Run() { |
47 for (size_t i = 0; i < repeats_; i++) { | 48 for (size_t i = 0; i < repeats_; i++) { |
48 NotificationService::current()->Notify( | 49 NotificationService::current()->Notify( |
49 NotificationType::EXTENSION_BOOKMARKS_API_INVOKED, | 50 chrome::NOTIFICATION_EXTENSION_BOOKMARKS_API_INVOKED, |
50 Source<Extension>(extension_.get()), | 51 Source<Extension>(extension_.get()), |
51 Details<const BookmarksFunction>(function_.get())); | 52 Details<const BookmarksFunction>(function_.get())); |
52 } | 53 } |
53 done_->Signal(); | 54 done_->Signal(); |
54 } | 55 } |
55 private: | 56 private: |
56 scoped_refptr<Extension> extension_; | 57 scoped_refptr<Extension> extension_; |
57 scoped_refptr<FunctionType> function_; | 58 scoped_refptr<FunctionType> function_; |
58 size_t repeats_; | 59 size_t repeats_; |
59 base::WaitableEvent* done_; | 60 base::WaitableEvent* done_; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 240 |
240 generator.NewEvent<CreateBookmarkFunction>(kTestExtensionPath1, | 241 generator.NewEvent<CreateBookmarkFunction>(kTestExtensionPath1, |
241 new CreateBookmarkFunction(), 3); | 242 new CreateBookmarkFunction(), 3); |
242 monitor->GetAndClearRecords(&results); | 243 monitor->GetAndClearRecords(&results); |
243 | 244 |
244 EXPECT_EQ(1U, results.size()); | 245 EXPECT_EQ(1U, results.size()); |
245 EXPECT_EQ(3U, results[id1].bookmark_write_count); | 246 EXPECT_EQ(3U, results[id1].bookmark_write_count); |
246 | 247 |
247 ui_loop()->DeleteSoon(FROM_HERE, monitor); | 248 ui_loop()->DeleteSoon(FROM_HERE, monitor); |
248 } | 249 } |
OLD | NEW |