summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/chromium_http
diff options
context:
space:
mode:
Diffstat (limited to 'media/libstagefright/chromium_http')
-rw-r--r--media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp6
-rw-r--r--media/libstagefright/chromium_http/support.cpp40
-rw-r--r--media/libstagefright/chromium_http/support.h5
3 files changed, 51 insertions, 0 deletions
diff --git a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
index 887fe7c..180460b 100644
--- a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
+++ b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
@@ -61,6 +61,12 @@ status_t ChromiumHTTPDataSource::connect(
off64_t offset) {
Mutex::Autolock autoLock(mLock);
+ uid_t uid;
+ if (getUID(&uid)) {
+ mDelegate->setUID(uid);
+ }
+ LOG_PRI(ANDROID_LOG_VERBOSE, LOG_TAG, "connect on behalf of uid %d", uid);
+
return connect_l(uri, headers, offset);
}
diff --git a/media/libstagefright/chromium_http/support.cpp b/media/libstagefright/chromium_http/support.cpp
index 26c3eda..de936c4 100644
--- a/media/libstagefright/chromium_http/support.cpp
+++ b/media/libstagefright/chromium_http/support.cpp
@@ -23,6 +23,7 @@
#include "support.h"
#include "android/net/android_network_library_impl.h"
+#include "base/logging.h"
#include "base/threading/thread.h"
#include "net/base/cert_verifier.h"
#include "net/base/cookie_monster.h"
@@ -34,8 +35,10 @@
#include "include/ChromiumHTTPDataSource.h"
+#include <cutils/log.h>
#include <cutils/properties.h>
#include <media/stagefright/MediaErrors.h>
+#include <string>
namespace android {
@@ -44,6 +47,34 @@ static base::Thread *gNetworkThread = NULL;
static scoped_refptr<net::URLRequestContext> gReqContext;
static scoped_ptr<net::NetworkChangeNotifier> gNetworkChangeNotifier;
+bool logMessageHandler(
+ int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& str) {
+ int androidSeverity = ANDROID_LOG_VERBOSE;
+ switch(severity) {
+ case logging::LOG_FATAL:
+ androidSeverity = ANDROID_LOG_FATAL;
+ break;
+ case logging::LOG_ERROR_REPORT:
+ case logging::LOG_ERROR:
+ androidSeverity = ANDROID_LOG_ERROR;
+ break;
+ case logging::LOG_WARNING:
+ androidSeverity = ANDROID_LOG_WARN;
+ break;
+ default:
+ androidSeverity = ANDROID_LOG_VERBOSE;
+ break;
+ }
+ android_printLog(androidSeverity, "chromium-libstagefright",
+ "%s:%d: %s", file, line, str.c_str());
+ return false;
+}
+
+
static void InitializeNetworkThreadIfNecessary() {
Mutex::Autolock autoLock(gNetworkThreadLock);
if (gNetworkThread == NULL) {
@@ -58,6 +89,7 @@ static void InitializeNetworkThreadIfNecessary() {
net::AndroidNetworkLibrary::RegisterSharedInstance(
new SfNetworkLibrary);
+ logging::SetLogMessageHandler(logMessageHandler);
}
}
@@ -181,6 +213,14 @@ void SfDelegate::setOwner(ChromiumHTTPDataSource *owner) {
mOwner = owner;
}
+void SfDelegate::setUID(uid_t uid) {
+ gReqContext->setUID(uid);
+}
+
+bool SfDelegate::getUID(uid_t *uid) const {
+ return gReqContext->getUID(uid);
+}
+
void SfDelegate::OnReceivedRedirect(
net::URLRequest *request, const GURL &new_url, bool *defer_redirect) {
MY_LOGV("OnReceivedRedirect");
diff --git a/media/libstagefright/chromium_http/support.h b/media/libstagefright/chromium_http/support.h
index 8fe8db1..d2c5bc0 100644
--- a/media/libstagefright/chromium_http/support.h
+++ b/media/libstagefright/chromium_http/support.h
@@ -91,6 +91,11 @@ struct SfDelegate : public net::URLRequest::Delegate {
void setOwner(ChromiumHTTPDataSource *mOwner);
+ // Gets the UID of the calling process
+ bool getUID(uid_t *uid) const;
+
+ void setUID(uid_t uid);
+
virtual void OnReceivedRedirect(
net::URLRequest *request, const GURL &new_url, bool *defer_redirect);