Chromium Code Reviews| Index: chrome/browser/chromeos/system/debugd_log_fetcher.cc |
| diff --git a/chrome/browser/chromeos/system/sysinfo_provider.cc b/chrome/browser/chromeos/system/debugd_log_fetcher.cc |
| similarity index 64% |
| rename from chrome/browser/chromeos/system/sysinfo_provider.cc |
| rename to chrome/browser/chromeos/system/debugd_log_fetcher.cc |
| index 4869a104161b0cedbee86c8539e154295d58cfa3..e057e1f65b856483907c577ff95e5f6399c3739b 100644 |
| --- a/chrome/browser/chromeos/system/sysinfo_provider.cc |
| +++ b/chrome/browser/chromeos/system/debugd_log_fetcher.cc |
| @@ -2,8 +2,9 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/chromeos/system/sysinfo_provider.h" |
| +#include "chrome/browser/chromeos/system/debugd_log_fetcher.h" |
| +#include "vector" |
| #include "base/bind.h" |
| #include "base/bind_helpers.h" |
| #include "base/command_line.h" |
| @@ -15,12 +16,15 @@ |
| #include "base/string_util.h" |
| #include "base/synchronization/waitable_event.h" |
| #include "base/threading/thread.h" |
| +#include "chrome/browser/chromeos/system/syslogs_fetcher.h" |
| #include "chrome/browser/memory_details.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chromeos/dbus/dbus_thread_manager.h" |
| #include "chromeos/dbus/debug_daemon_client.h" |
| #include "content/public/browser/browser_thread.h" |
| + |
| + |
| using content::BrowserThread; |
| namespace chromeos { |
| @@ -32,45 +36,21 @@ namespace system { |
| // fetcher->Fetch(); |
| // Note that you do not need to delete the fetcher; it will delete itself after |
| // Fetch() has forwarded the result to the request handler. |
| -class DebugDaemonLogFetcher { |
| - public: |
| - typedef |
| - scoped_refptr<CancelableRequest<SysInfoProvider::FetchCompleteCallback> > |
| - Request; |
| - |
| - explicit DebugDaemonLogFetcher(Request request); |
| - ~DebugDaemonLogFetcher(); |
| - |
| - // Fetches logs from the daemon over dbus. After the fetch is complete, the |
| - // results will be forwarded to the request supplied to the constructor and |
| - // this instance will free itself. |
| - void Fetch(); |
| - private: |
| - // Callbacks |
| - void GotRoutes(bool succeeded, const std::vector<std::string>& routes); |
| - void GotNetworkStatus(bool succeeded, const std::string& status); |
| - void GotModemStatus(bool succeeded, const std::string& status); |
| - void GotLogs(bool succeeded, const std::map<std::string, std::string>& logs); |
| - void RequestCompleted(); |
| - |
| - SysInfoResponse* response_; |
| - Request request_; |
| - int pending_requests_; |
| - base::WeakPtrFactory<DebugDaemonLogFetcher> weak_ptr_factory_; |
| -}; |
| - |
| -DebugDaemonLogFetcher::DebugDaemonLogFetcher(Request request) |
| - : response_(new SysInfoResponse()), request_(request), |
| - weak_ptr_factory_(this) { } |
| + |
| + |
| +DebugDaemonLogFetcher::DebugDaemonLogFetcher() |
| + : response_(new SysInfoResponse()), weak_ptr_factory_(this) { } |
|
rkc1
2012/08/04 01:15:05
{}
(check other places also in the CL)
tudalex(Chromium)
2012/08/05 01:15:12
Done.
|
| DebugDaemonLogFetcher::~DebugDaemonLogFetcher() { } |
| -void DebugDaemonLogFetcher::Fetch() { |
| +void DebugDaemonLogFetcher::Fetch(SysLogsFetcherCallback request) { |
| + request_ = request; |
| DebugDaemonClient* client = DBusThreadManager::Get()->GetDebugDaemonClient(); |
| pending_requests_ = 4; |
| // Note that this use of base::Unretained(this) is safe, since |this| is |
| // deleted in RequestCompleted if and only if all outstanding callbacks are |
| // done. |
| + base::Unretained(this); |
|
rkc1
2012/08/04 01:15:05
Get rid of this; not sure if it's needed.
tudalex(Chromium)
2012/08/05 01:15:12
Done.
|
| client->GetRoutes(true, false, |
| base::Bind(&DebugDaemonLogFetcher::GotRoutes, |
| weak_ptr_factory_.GetWeakPtr())); |
| @@ -129,33 +109,9 @@ void DebugDaemonLogFetcher::GotLogs(bool /* succeeded */, |
| void DebugDaemonLogFetcher::RequestCompleted() { |
| if (--pending_requests_) |
| return; |
| - request_->ForwardResult(response_); |
| + request_.Run(response_); |
| BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); |
| } |
| -class SysInfoProviderImpl : public SysInfoProvider { |
| - public: |
| - virtual Handle Fetch(CancelableRequestConsumerBase* consumer, |
| - const FetchCompleteCallback& callback); |
| -}; |
| - |
| -CancelableRequestProvider::Handle SysInfoProviderImpl::Fetch( |
| - CancelableRequestConsumerBase* consumer, |
| - const FetchCompleteCallback& callback) { |
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - scoped_refptr<CancelableRequest<FetchCompleteCallback> > |
| - request(new CancelableRequest<FetchCompleteCallback>(callback)); |
| - AddRequest(request, consumer); |
| - // Deleted by DebugDaemonLogFetcher::RequestCompleted() |
| - DebugDaemonLogFetcher* fetcher = new DebugDaemonLogFetcher(request); |
| - fetcher->Fetch(); |
| - |
| - return request->handle(); |
| -} |
| - |
| -SysInfoProvider* SysInfoProvider::Create() { |
| - return new SysInfoProviderImpl(); |
| -} |
| - |
| } // namespace system |
| } // namespace chromeos |