Hello noel,
I'd like you to do a code review. Please execute
g4 diff -c 8965078
or point your web browser to
http://mondrian/8965078
to review the following code:
Change 8965078 by [EMAIL PROTECTED] on 2008/11/12 13:46:35 *pending*
Simplify the FF DropTarget's "get the file from URL" code.
PRESUBMIT=passed
R=noel
[EMAIL PROTECTED]
DELTA=22 (1 added, 18 deleted, 3 changed)
OCL=8965078
Affected files ...
... //depot/googleclient/gears/opensource/gears/desktop/drop_target_ff.cc#10
edit
22 delta lines: 1 added, 18 deleted, 3 changed
Also consider running:
g4 lint -c 8965078
which verifies that the changelist doesn't introduce new style violations.
If you can't do the review, please let me know as soon as possible. During
your review, please ensure that all new code has corresponding unit tests and
that existing unit tests are updated appropriately. Visit
http://www/eng/code_review.html for more information.
This is a semiautomated message from "g4 mail". Complaints or suggestions?
Mail [EMAIL PROTECTED]
Change 8965078 by [EMAIL PROTECTED] on 2008/11/12 13:46:35 *pending*
Simplify the FF DropTarget's "get the file from URL" code.
Affected files ...
... //depot/googleclient/gears/opensource/gears/desktop/drop_target_ff.cc#10
edit
==== //depot/googleclient/gears/opensource/gears/desktop/drop_target_ff.cc#10 -
/home/nigeltao/srcgears3/googleclient/gears/opensource/gears/desktop/drop_target_ff.cc
====
# action=edit type=text
--- googleclient/gears/opensource/gears/desktop/drop_target_ff.cc
2008-11-10 14:20:03.000000000 +1100
+++ googleclient/gears/opensource/gears/desktop/drop_target_ff.cc
2008-11-12 13:45:51.000000000 +1100
@@ -33,11 +33,11 @@
#include <gecko_sdk/include/nsIDOMHTMLElement.h>
#include <gecko_sdk/include/nsIDOMEvent.h>
#include <gecko_sdk/include/nsIDOMEventTarget.h>
-#include <gecko_sdk/include/nsIIOService.h>
#include <gecko_sdk/include/nsILocalFile.h>
#include <gecko_sdk/include/nsISupportsPrimitives.h>
#include <gecko_sdk/include/nsIURI.h>
#include "gears/base/common/leak_counter.h"
+#include "gears/base/firefox/ns_file_utils.h"
#include "gears/desktop/file_dialog.h"
@@ -284,14 +284,6 @@
JsArray *files_out,
std::string16 *error_out) {
#if defined(LINUX) && !defined(OS_MACOSX)
- // Note to future maintainers: the nsIIOService docs say that it may only be
- // used from the main thread. On the other hand, all we're using it for is
- // converting a string like "file:///blah" into a nsIFileURL, rather than
- // doing any actual I/O, so it's probably safe, regardless.
- nsCOMPtr<nsIIOService> io_service =
- do_GetService("@mozilla.org/network/io-service;1");
- if (!io_service) { return false; }
-
// Although Firefox's underlying XPCOM widget library aims to present a
// consistent cross-platform interface, there are still significant
// differences in drag-and-drop. In particular, different OSes support
@@ -333,19 +325,10 @@
#if defined(LINUX) && !defined(OS_MACOSX)
nsCOMPtr<nsISupportsString> data_as_xpcom_string(do_QueryInterface(data));
nsString data_as_string;
- data_as_xpcom_string->GetData(data_as_string);
-
- nsCString data_as_cstring;
- nr = NS_UTF16ToCString(
- data_as_string, NS_CSTRING_ENCODING_UTF8, data_as_cstring);
- nsCOMPtr<nsIURI> uri;
- nr = io_service->NewURI(data_as_cstring, NULL, NULL, getter_AddRefs(uri));
- if (NS_FAILED(nr)) { return false; }
-
- nsCOMPtr<nsIFileURL> file_url(do_QueryInterface(uri));
- if (!file_url) { return false; }
+ nr = data_as_xpcom_string->GetData(data_as_string);
+ if (NS_FAILED(nr)) { return false; }
nsCOMPtr<nsIFile> file;
- nr = file_url->GetFile(getter_AddRefs(file));
+ nr = NSFileUtils::GetFileFromURLSpec(data_as_string, getter_AddRefs(file));
if (NS_FAILED(nr)) { return false; }
nsString filename;
nr = file->GetPath(filename);