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

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api.cc

Issue 10694085: Refactor extension event distribution to use Values instead of JSON strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing memory leak in a test. Created 8 years, 4 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 | Annotate | Revision Log
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/downloads/downloads_api.h" 5 #include "chrome/browser/extensions/api/downloads/downloads_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cctype> 8 #include <cctype>
9 #include <iterator> 9 #include <iterator>
10 #include <set> 10 #include <set>
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 void ExtensionDownloadsEventRouter::ManagerGoingDown( 911 void ExtensionDownloadsEventRouter::ManagerGoingDown(
912 DownloadManager* manager) { 912 DownloadManager* manager) {
913 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 913 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
914 manager_->RemoveObserver(this); 914 manager_->RemoveObserver(this);
915 manager_ = NULL; 915 manager_ = NULL;
916 } 916 }
917 917
918 void ExtensionDownloadsEventRouter::DispatchEvent( 918 void ExtensionDownloadsEventRouter::DispatchEvent(
919 const char* event_name, base::Value* arg) { 919 const char* event_name, base::Value* arg) {
920 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 920 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
921 base::ListValue args; 921 scoped_ptr<ListValue> args(new ListValue());
922 args.Append(arg); 922 args->Append(arg);
923 std::string json_args; 923 std::string json_args;
924 base::JSONWriter::Write(&args, &json_args); 924 base::JSONWriter::Write(args.get(), &json_args);
925
925 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( 926 profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
926 event_name, 927 event_name,
927 json_args, 928 args.Pass(),
928 profile_, 929 profile_,
929 GURL(), 930 GURL(),
930 extensions::EventFilteringInfo()); 931 extensions::EventFilteringInfo());
931 932
932 DownloadsNotificationSource notification_source; 933 DownloadsNotificationSource notification_source;
933 notification_source.event_name = event_name; 934 notification_source.event_name = event_name;
934 notification_source.profile = profile_; 935 notification_source.profile = profile_;
935 content::NotificationService::current()->Notify( 936 content::NotificationService::current()->Notify(
936 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, 937 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT,
937 content::Source<DownloadsNotificationSource>(&notification_source), 938 content::Source<DownloadsNotificationSource>(&notification_source),
938 content::Details<std::string>(&json_args)); 939 content::Details<std::string>(&json_args));
939 } 940 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/debugger/debugger_api.cc ('k') | chrome/browser/extensions/api/idle/idle_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698