Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 #include "chrome/browser/extensions/api/systeminfo_storage/systeminfo_storage_ap i.h" | |
| 5 | |
| 6 #include "base/logging.h" | |
| 7 #include "base/json/json_writer.h" | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/string_number_conversions.h" | |
| 10 #include "base/string_piece.h" | |
| 11 #include "base/values.h" | |
| 12 #include "content/public/browser/browser_thread.h" | |
| 13 #include "chrome/browser/extensions/extension_service.h" | |
| 14 #include "chrome/browser/extensions/api/systeminfo_storage/storage_info_provider .h" | |
| 15 | |
| 16 namespace extensions { | |
| 17 using content::BrowserThread; | |
| 18 | |
| 19 SysteminfoStorageGetFunction::SysteminfoStorageGetFunction() { | |
| 20 } | |
| 21 | |
| 22 SysteminfoStorageGetFunction::~SysteminfoStorageGetFunction() { | |
| 23 } | |
| 24 | |
| 25 bool SysteminfoStorageGetFunction::RunImpl() { | |
| 26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 27 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | |
| 28 base::Bind(&SysteminfoStorageGetFunction::WorkOnFileThread, this)); | |
|
James Hawkins
2012/08/09 15:47:34
nit: Start of parameter rows must align on the sam
Hongbo Min
2012/08/12 03:31:58
Done.
| |
| 29 return true; | |
| 30 } | |
| 31 | |
| 32 void SysteminfoStorageGetFunction::WorkOnFileThread() { | |
| 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
| 34 bool success = false; | |
| 35 scoped_ptr<StorageInfoProvider> provider(StorageInfoProvider::Create()); | |
| 36 StorageInfo info; | |
| 37 if (provider.get() && provider->GetStorageInfo(&info)) { | |
|
James Hawkins
2012/08/09 15:47:34
Why would provider.get() ever be non-NULL?
Hongbo Min
2012/08/10 02:43:29
In case of out of memory, the allocation for provi
James Hawkins
2012/08/11 16:37:54
Chrome code does not check for OOM situations, so
| |
| 38 SetResult(info.ToValue().release()); | |
| 39 success = true; | |
| 40 } else { | |
| 41 SetError("Error in querying storage information"); | |
| 42 success = false; | |
|
James Hawkins
2012/08/09 15:47:34
nit: This line is redundant with line 34.
Hongbo Min
2012/08/12 03:31:58
Done.
| |
| 43 } | |
| 44 | |
| 45 // Response on UI thread | |
|
James Hawkins
2012/08/09 15:47:34
nit: Comments must end with a period.
Hongbo Min
2012/08/12 03:31:58
Done.
| |
| 46 BrowserThread::PostTask( | |
| 47 BrowserThread::UI, FROM_HERE, | |
| 48 base::Bind(&SysteminfoStorageGetFunction::RespondOnUIThread, | |
|
James Hawkins
2012/08/09 15:47:34
nit: Alignment is off.
Hongbo Min
2012/08/12 03:31:58
Done.
| |
| 49 this, success)); | |
| 50 } | |
| 51 | |
| 52 void SysteminfoStorageGetFunction::RespondOnUIThread(bool success) { | |
| 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 54 SendResponse(success); | |
| 55 } | |
| 56 | |
| 57 } // namespace extensions | |
| OLD | NEW |