#define DA_READELF_PATH "/home/developer/sdk_tools/da/readelf"
#define SCREENSHOT_DIR "/tmp/da"
-#define WSI_HOST "127.0.0.1"
-
#define MAX_APP_LAUNCH_TIME 60
#define MAX_CONNECT_TIMEOUT_TIME 5*60
break;
}
- if (wsi_init(WSI_HOST, 0)) {
- LOGE("Cannot init web application profiling\n");
- res = -1;
- } else {
- if (wsi_start_profiling()) {
- LOGE("Cannot start web application profiling\n");
- res = -1;
- }
- }
+ wsi_start();
+
break;
default:
LOGE("Unknown app type %d\n", app_info->app_type);
PROTOCOL_PROFILING
};
+const char WSI_HOST[] = "127.0.0.1";
struct libwebsocket_context *context;
struct libwebsocket *wsi;
int pstate = PSTATE_DEFAULT;
int request_id = 1;
+static void wsi_destroy(void);
+
static int set_profile_info(const char *path, const char *info)
{
FILE *fp;
return NULL;
}
-int wsi_init(const char *address, int port)
+static int wsi_init(const char *address, int port)
{
if (!port) {
char buf[sizeof(struct msg_t) + sizeof(uint32_t)];
return 0;
}
-void wsi_destroy(void)
+static void wsi_destroy(void)
{
if (CHKSTAT(pstate, PSTATE_CONNECTED)) {
if (CHKSTAT(pstate, PSTATE_WAIT_ACK))
}
}
-int wsi_start_profiling(void)
+static int wsi_start_profiling(void)
{
pthread_t tid;
return 0;
}
-void wsi_stop_profiling(void)
+static void wsi_stop_profiling(void)
{
if (CHKSTAT(pstate, PSTATE_CONNECTED)) {
send_request("Profiler.stop");
send_request("Profiler.disable");
}
}
+
+static void *do_start(void *arg)
+{
+ if (wsi_init(WSI_HOST, 0)) {
+ LOGE("Cannot init web application profiling\n");
+ goto out;
+ }
+
+ if (wsi_start_profiling())
+ LOGE("Cannot start web application profiling\n");
+
+out:
+ return NULL;
+}
+
+int wsi_start(void)
+{
+ int ret;
+ pthread_t t;
+
+ /* FIXME: call pthread_joun() */
+ ret = pthread_create(&t, NULL, &do_start, NULL);
+ if (ret) {
+ LOGE("Can't create do_start thread\n");
+ destroy_wsi_conn(context);
+ }
+
+ return ret;
+}
+
+void wsi_stop(void)
+{
+ wsi_stop_profiling();
+ wsi_destroy();
+}
int wsi_set_profile(const struct app_info_t *app_info);
int wsi_set_smack_rules(const struct app_info_t *app_info);
int wsi_enable_profiling(enum web_prof_state_t mode);
-int wsi_init(const char *address, int port);
-int wsi_start_profiling(void);
-void wsi_destroy(void);
-void wsi_stop_profiling(void);
+
+int wsi_start(void);
+void wsi_stop(void);
#endif /* WSI_H_ */